From 22fd782d2e490b74674abf1301dbd68549fb4db5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Adri=C3=A1n=20Mart=C3=ADnez?=
Date: Fri, 13 Oct 2017 14:04:26 +0200
Subject: [PATCH 001/904] Ability to use whitelist for testing code style,
based on const defined in phpunit xml config file
---
dev/tests/static/phpunit-all.xml.dist | 2 ++
dev/tests/static/phpunit.xml.dist | 1 +
2 files changed, 3 insertions(+)
diff --git a/dev/tests/static/phpunit-all.xml.dist b/dev/tests/static/phpunit-all.xml.dist
index 626e753c3c242..a0d1f2fe75dc9 100644
--- a/dev/tests/static/phpunit-all.xml.dist
+++ b/dev/tests/static/phpunit-all.xml.dist
@@ -20,5 +20,7 @@
+
+
diff --git a/dev/tests/static/phpunit.xml.dist b/dev/tests/static/phpunit.xml.dist
index 0afaddb34caef..d9f9dbdfe54cd 100644
--- a/dev/tests/static/phpunit.xml.dist
+++ b/dev/tests/static/phpunit.xml.dist
@@ -30,6 +30,7 @@
+
From 2008b357dc607084e6cae20a3d0d3dee07979578 Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Mon, 12 Dec 2016 08:50:26 -0600
Subject: [PATCH 002/904] MAGETWO-61910: Create module and configuration
---
app/code/Magento/Signifyd/LICENSE.txt | 48 +++++++++++++++++++
app/code/Magento/Signifyd/LICENSE_AFL.txt | 48 +++++++++++++++++++
app/code/Magento/Signifyd/README.md | 1 +
app/code/Magento/Signifyd/composer.json | 22 +++++++++
app/code/Magento/Signifyd/etc/acl.xml | 22 +++++++++
.../Magento/Signifyd/etc/adminhtml/system.xml | 42 ++++++++++++++++
app/code/Magento/Signifyd/etc/config.xml | 15 ++++++
.../Magento/Signifyd/etc/frontend/routes.xml | 14 ++++++
app/code/Magento/Signifyd/etc/module.xml | 14 ++++++
app/code/Magento/Signifyd/registration.php | 11 +++++
composer.json | 1 +
11 files changed, 238 insertions(+)
create mode 100644 app/code/Magento/Signifyd/LICENSE.txt
create mode 100644 app/code/Magento/Signifyd/LICENSE_AFL.txt
create mode 100644 app/code/Magento/Signifyd/README.md
create mode 100644 app/code/Magento/Signifyd/composer.json
create mode 100644 app/code/Magento/Signifyd/etc/acl.xml
create mode 100644 app/code/Magento/Signifyd/etc/adminhtml/system.xml
create mode 100644 app/code/Magento/Signifyd/etc/config.xml
create mode 100644 app/code/Magento/Signifyd/etc/frontend/routes.xml
create mode 100644 app/code/Magento/Signifyd/etc/module.xml
create mode 100644 app/code/Magento/Signifyd/registration.php
diff --git a/app/code/Magento/Signifyd/LICENSE.txt b/app/code/Magento/Signifyd/LICENSE.txt
new file mode 100644
index 0000000000000..49525fd99da9c
--- /dev/null
+++ b/app/code/Magento/Signifyd/LICENSE.txt
@@ -0,0 +1,48 @@
+
+Open Software License ("OSL") v. 3.0
+
+This Open Software License (the "License") applies to any original work of authorship (the "Original Work") whose owner (the "Licensor") has placed the following licensing notice adjacent to the copyright notice for the Original Work:
+
+Licensed under the Open Software License version 3.0
+
+ 1. Grant of Copyright License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, for the duration of the copyright, to do the following:
+
+ 1. to reproduce the Original Work in copies, either alone or as part of a collective work;
+
+ 2. to translate, adapt, alter, transform, modify, or arrange the Original Work, thereby creating derivative works ("Derivative Works") based upon the Original Work;
+
+ 3. to distribute or communicate copies of the Original Work and Derivative Works to the public, with the proviso that copies of Original Work or Derivative Works that You distribute or communicate shall be licensed under this Open Software License;
+
+ 4. to perform the Original Work publicly; and
+
+ 5. to display the Original Work publicly.
+
+ 2. Grant of Patent License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, under patent claims owned or controlled by the Licensor that are embodied in the Original Work as furnished by the Licensor, for the duration of the patents, to make, use, sell, offer for sale, have made, and import the Original Work and Derivative Works.
+
+ 3. Grant of Source Code License. The term "Source Code" means the preferred form of the Original Work for making modifications to it and all available documentation describing how to modify the Original Work. Licensor agrees to provide a machine-readable copy of the Source Code of the Original Work along with each copy of the Original Work that Licensor distributes. Licensor reserves the right to satisfy this obligation by placing a machine-readable copy of the Source Code in an information repository reasonably calculated to permit inexpensive and convenient access by You for as long as Licensor continues to distribute the Original Work.
+
+ 4. Exclusions From License Grant. Neither the names of Licensor, nor the names of any contributors to the Original Work, nor any of their trademarks or service marks, may be used to endorse or promote products derived from this Original Work without express prior permission of the Licensor. Except as expressly stated herein, nothing in this License grants any license to Licensor's trademarks, copyrights, patents, trade secrets or any other intellectual property. No patent license is granted to make, use, sell, offer for sale, have made, or import embodiments of any patent claims other than the licensed claims defined in Section 2. No license is granted to the trademarks of Licensor even if such marks are included in the Original Work. Nothing in this License shall be interpreted to prohibit Licensor from licensing under terms different from this License any Original Work that Licensor otherwise would have a right to license.
+
+ 5. External Deployment. The term "External Deployment" means the use, distribution, or communication of the Original Work or Derivative Works in any way such that the Original Work or Derivative Works may be used by anyone other than You, whether those works are distributed or communicated to those persons or made available as an application intended for use over a network. As an express condition for the grants of license hereunder, You must treat any External Deployment by You of the Original Work or a Derivative Work as a distribution under section 1(c).
+
+ 6. Attribution Rights. You must retain, in the Source Code of any Derivative Works that You create, all copyright, patent, or trademark notices from the Source Code of the Original Work, as well as any notices of licensing and any descriptive text identified therein as an "Attribution Notice." You must cause the Source Code for any Derivative Works that You create to carry a prominent Attribution Notice reasonably calculated to inform recipients that You have modified the Original Work.
+
+ 7. Warranty of Provenance and Disclaimer of Warranty. Licensor warrants that the copyright in and to the Original Work and the patent rights granted herein by Licensor are owned by the Licensor or are sublicensed to You under the terms of this License with the permission of the contributor(s) of those copyrights and patent rights. Except as expressly stated in the immediately preceding sentence, the Original Work is provided under this License on an "AS IS" BASIS and WITHOUT WARRANTY, either express or implied, including, without limitation, the warranties of non-infringement, merchantability or fitness for a particular purpose. THE ENTIRE RISK AS TO THE QUALITY OF THE ORIGINAL WORK IS WITH YOU. This DISCLAIMER OF WARRANTY constitutes an essential part of this License. No license to the Original Work is granted by this License except under this disclaimer.
+
+ 8. Limitation of Liability. Under no circumstances and under no legal theory, whether in tort (including negligence), contract, or otherwise, shall the Licensor be liable to anyone for any indirect, special, incidental, or consequential damages of any character arising as a result of this License or the use of the Original Work including, without limitation, damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses. This limitation of liability shall not apply to the extent applicable law prohibits such limitation.
+
+ 9. Acceptance and Termination. If, at any time, You expressly assented to this License, that assent indicates your clear and irrevocable acceptance of this License and all of its terms and conditions. If You distribute or communicate copies of the Original Work or a Derivative Work, You must make a reasonable effort under the circumstances to obtain the express assent of recipients to the terms of this License. This License conditions your rights to undertake the activities listed in Section 1, including your right to create Derivative Works based upon the Original Work, and doing so without honoring these terms and conditions is prohibited by copyright law and international treaty. Nothing in this License is intended to affect copyright exceptions and limitations (including 'fair use' or 'fair dealing'). This License shall terminate immediately and You may no longer exercise any of the rights granted to You by this License upon your failure to honor the conditions in Section 1(c).
+
+ 10. Termination for Patent Action. This License shall terminate automatically and You may no longer exercise any of the rights granted to You by this License as of the date You commence an action, including a cross-claim or counterclaim, against Licensor or any licensee alleging that the Original Work infringes a patent. This termination provision shall not apply for an action alleging patent infringement by combinations of the Original Work with other software or hardware.
+
+ 11. Jurisdiction, Venue and Governing Law. Any action or suit relating to this License may be brought only in the courts of a jurisdiction wherein the Licensor resides or in which Licensor conducts its primary business, and under the laws of that jurisdiction excluding its conflict-of-law provisions. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any use of the Original Work outside the scope of this License or after its termination shall be subject to the requirements and penalties of copyright or patent law in the appropriate jurisdiction. This section shall survive the termination of this License.
+
+ 12. Attorneys' Fees. In any action to enforce the terms of this License or seeking damages relating thereto, the prevailing party shall be entitled to recover its costs and expenses, including, without limitation, reasonable attorneys' fees and costs incurred in connection with such action, including any appeal of such action. This section shall survive the termination of this License.
+
+ 13. Miscellaneous. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable.
+
+ 14. Definition of "You" in This License. "You" throughout this License, whether in upper or lower case, means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License. For legal entities, "You" includes any entity that controls, is controlled by, or is under common control with you. For purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
+
+ 15. Right to Use. You may use the Original Work in all ways not otherwise restricted or conditioned by this License or by law, and Licensor promises not to interfere with or be responsible for such uses by You.
+
+ 16. Modification of This License. This License is Copyright (C) 2005 Lawrence Rosen. Permission is granted to copy, distribute, or communicate this License without modification. Nothing in this License permits You to modify this License as applied to the Original Work or to Derivative Works. However, You may modify the text of this License and copy, distribute or communicate your modified version (the "Modified License") and apply it to other original works of authorship subject to the following conditions: (i) You may not indicate in any way that your Modified License is the "Open Software License" or "OSL" and you may not use those names in the name of your Modified License; (ii) You must replace the notice specified in the first paragraph above with the notice "Licensed under " or with a notice of your own that is not confusingly similar to the notice in this License; and (iii) You may not claim that your original works are open source software unless your Modified License has been approved by Open Source Initiative (OSI) and You comply with its license review and certification process.
\ No newline at end of file
diff --git a/app/code/Magento/Signifyd/LICENSE_AFL.txt b/app/code/Magento/Signifyd/LICENSE_AFL.txt
new file mode 100644
index 0000000000000..f39d641b18a19
--- /dev/null
+++ b/app/code/Magento/Signifyd/LICENSE_AFL.txt
@@ -0,0 +1,48 @@
+
+Academic Free License ("AFL") v. 3.0
+
+This Academic Free License (the "License") applies to any original work of authorship (the "Original Work") whose owner (the "Licensor") has placed the following licensing notice adjacent to the copyright notice for the Original Work:
+
+Licensed under the Academic Free License version 3.0
+
+ 1. Grant of Copyright License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, for the duration of the copyright, to do the following:
+
+ 1. to reproduce the Original Work in copies, either alone or as part of a collective work;
+
+ 2. to translate, adapt, alter, transform, modify, or arrange the Original Work, thereby creating derivative works ("Derivative Works") based upon the Original Work;
+
+ 3. to distribute or communicate copies of the Original Work and Derivative Works to the public, under any license of your choice that does not contradict the terms and conditions, including Licensor's reserved rights and remedies, in this Academic Free License;
+
+ 4. to perform the Original Work publicly; and
+
+ 5. to display the Original Work publicly.
+
+ 2. Grant of Patent License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, under patent claims owned or controlled by the Licensor that are embodied in the Original Work as furnished by the Licensor, for the duration of the patents, to make, use, sell, offer for sale, have made, and import the Original Work and Derivative Works.
+
+ 3. Grant of Source Code License. The term "Source Code" means the preferred form of the Original Work for making modifications to it and all available documentation describing how to modify the Original Work. Licensor agrees to provide a machine-readable copy of the Source Code of the Original Work along with each copy of the Original Work that Licensor distributes. Licensor reserves the right to satisfy this obligation by placing a machine-readable copy of the Source Code in an information repository reasonably calculated to permit inexpensive and convenient access by You for as long as Licensor continues to distribute the Original Work.
+
+ 4. Exclusions From License Grant. Neither the names of Licensor, nor the names of any contributors to the Original Work, nor any of their trademarks or service marks, may be used to endorse or promote products derived from this Original Work without express prior permission of the Licensor. Except as expressly stated herein, nothing in this License grants any license to Licensor's trademarks, copyrights, patents, trade secrets or any other intellectual property. No patent license is granted to make, use, sell, offer for sale, have made, or import embodiments of any patent claims other than the licensed claims defined in Section 2. No license is granted to the trademarks of Licensor even if such marks are included in the Original Work. Nothing in this License shall be interpreted to prohibit Licensor from licensing under terms different from this License any Original Work that Licensor otherwise would have a right to license.
+
+ 5. External Deployment. The term "External Deployment" means the use, distribution, or communication of the Original Work or Derivative Works in any way such that the Original Work or Derivative Works may be used by anyone other than You, whether those works are distributed or communicated to those persons or made available as an application intended for use over a network. As an express condition for the grants of license hereunder, You must treat any External Deployment by You of the Original Work or a Derivative Work as a distribution under section 1(c).
+
+ 6. Attribution Rights. You must retain, in the Source Code of any Derivative Works that You create, all copyright, patent, or trademark notices from the Source Code of the Original Work, as well as any notices of licensing and any descriptive text identified therein as an "Attribution Notice." You must cause the Source Code for any Derivative Works that You create to carry a prominent Attribution Notice reasonably calculated to inform recipients that You have modified the Original Work.
+
+ 7. Warranty of Provenance and Disclaimer of Warranty. Licensor warrants that the copyright in and to the Original Work and the patent rights granted herein by Licensor are owned by the Licensor or are sublicensed to You under the terms of this License with the permission of the contributor(s) of those copyrights and patent rights. Except as expressly stated in the immediately preceding sentence, the Original Work is provided under this License on an "AS IS" BASIS and WITHOUT WARRANTY, either express or implied, including, without limitation, the warranties of non-infringement, merchantability or fitness for a particular purpose. THE ENTIRE RISK AS TO THE QUALITY OF THE ORIGINAL WORK IS WITH YOU. This DISCLAIMER OF WARRANTY constitutes an essential part of this License. No license to the Original Work is granted by this License except under this disclaimer.
+
+ 8. Limitation of Liability. Under no circumstances and under no legal theory, whether in tort (including negligence), contract, or otherwise, shall the Licensor be liable to anyone for any indirect, special, incidental, or consequential damages of any character arising as a result of this License or the use of the Original Work including, without limitation, damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses. This limitation of liability shall not apply to the extent applicable law prohibits such limitation.
+
+ 9. Acceptance and Termination. If, at any time, You expressly assented to this License, that assent indicates your clear and irrevocable acceptance of this License and all of its terms and conditions. If You distribute or communicate copies of the Original Work or a Derivative Work, You must make a reasonable effort under the circumstances to obtain the express assent of recipients to the terms of this License. This License conditions your rights to undertake the activities listed in Section 1, including your right to create Derivative Works based upon the Original Work, and doing so without honoring these terms and conditions is prohibited by copyright law and international treaty. Nothing in this License is intended to affect copyright exceptions and limitations (including "fair use" or "fair dealing"). This License shall terminate immediately and You may no longer exercise any of the rights granted to You by this License upon your failure to honor the conditions in Section 1(c).
+
+ 10. Termination for Patent Action. This License shall terminate automatically and You may no longer exercise any of the rights granted to You by this License as of the date You commence an action, including a cross-claim or counterclaim, against Licensor or any licensee alleging that the Original Work infringes a patent. This termination provision shall not apply for an action alleging patent infringement by combinations of the Original Work with other software or hardware.
+
+ 11. Jurisdiction, Venue and Governing Law. Any action or suit relating to this License may be brought only in the courts of a jurisdiction wherein the Licensor resides or in which Licensor conducts its primary business, and under the laws of that jurisdiction excluding its conflict-of-law provisions. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any use of the Original Work outside the scope of this License or after its termination shall be subject to the requirements and penalties of copyright or patent law in the appropriate jurisdiction. This section shall survive the termination of this License.
+
+ 12. Attorneys' Fees. In any action to enforce the terms of this License or seeking damages relating thereto, the prevailing party shall be entitled to recover its costs and expenses, including, without limitation, reasonable attorneys' fees and costs incurred in connection with such action, including any appeal of such action. This section shall survive the termination of this License.
+
+ 13. Miscellaneous. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable.
+
+ 14. Definition of "You" in This License. "You" throughout this License, whether in upper or lower case, means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License. For legal entities, "You" includes any entity that controls, is controlled by, or is under common control with you. For purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
+
+ 15. Right to Use. You may use the Original Work in all ways not otherwise restricted or conditioned by this License or by law, and Licensor promises not to interfere with or be responsible for such uses by You.
+
+ 16. Modification of This License. This License is Copyright © 2005 Lawrence Rosen. Permission is granted to copy, distribute, or communicate this License without modification. Nothing in this License permits You to modify this License as applied to the Original Work or to Derivative Works. However, You may modify the text of this License and copy, distribute or communicate your modified version (the "Modified License") and apply it to other original works of authorship subject to the following conditions: (i) You may not indicate in any way that your Modified License is the "Academic Free License" or "AFL" and you may not use those names in the name of your Modified License; (ii) You must replace the notice specified in the first paragraph above with the notice "Licensed under " or with a notice of your own that is not confusingly similar to the notice in this License; and (iii) You may not claim that your original works are open source software unless your Modified License has been approved by Open Source Initiative (OSI) and You comply with its license review and certification process.
diff --git a/app/code/Magento/Signifyd/README.md b/app/code/Magento/Signifyd/README.md
new file mode 100644
index 0000000000000..3cd2b4a30a858
--- /dev/null
+++ b/app/code/Magento/Signifyd/README.md
@@ -0,0 +1 @@
+The Magento_Signifyd module implements the integration with the Signifyd fraud prevention service.
diff --git a/app/code/Magento/Signifyd/composer.json b/app/code/Magento/Signifyd/composer.json
new file mode 100644
index 0000000000000..9f0c56a845f37
--- /dev/null
+++ b/app/code/Magento/Signifyd/composer.json
@@ -0,0 +1,22 @@
+{
+ "name": "magento/module-signifyd",
+ "description": "Submitting Case Entry to Signifyd on Order Creation",
+ "require": {
+ "php": "~5.6.5|7.0.2|7.0.4|~7.0.6",
+ "magento/framework": "100.2.*",
+ "magento/module-sales": "100.2.*"
+ },
+ "type": "magento2-module",
+ "version": "100.2.0-dev",
+ "license": [
+ "proprietary"
+ ],
+ "autoload": {
+ "files": [
+ "registration.php"
+ ],
+ "psr-4": {
+ "Magento\\Signifyd\\": ""
+ }
+ }
+}
diff --git a/app/code/Magento/Signifyd/etc/acl.xml b/app/code/Magento/Signifyd/etc/acl.xml
new file mode 100644
index 0000000000000..ab6db0dce88c2
--- /dev/null
+++ b/app/code/Magento/Signifyd/etc/acl.xml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Signifyd/etc/adminhtml/system.xml b/app/code/Magento/Signifyd/etc/adminhtml/system.xml
new file mode 100644
index 0000000000000..14ae7d73e0e48
--- /dev/null
+++ b/app/code/Magento/Signifyd/etc/adminhtml/system.xml
@@ -0,0 +1,42 @@
+
+
+
+
+
+ Fraud Protection
+ sales
+ Magento_Sales::fraud_protection
+
+ Signifyd
+
+ Enable this Solution
+ Magento\Config\Model\Config\Source\Yesno
+ fraud_protection/signifyd/active
+
+
+ API Key
+ http://signifyd.com/settings/teams after you create a Signifyd account]]>
+ fraud_protection/signifyd/api_key
+ Magento\Config\Model\Config\Backend\Encrypted
+
+
+ API URL
+ fraud_protection/signifyd/api_url
+
+ Don’t change unless asked to do so.
+
+
+
+ Debug
+ Magento\Config\Model\Config\Source\Yesno
+ fraud_protection/signifyd/debug
+
+
+
+
+
diff --git a/app/code/Magento/Signifyd/etc/config.xml b/app/code/Magento/Signifyd/etc/config.xml
new file mode 100644
index 0000000000000..b16f0903c2d1f
--- /dev/null
+++ b/app/code/Magento/Signifyd/etc/config.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
+ 0
+ https://api.signifiyd.com/v2/
+
+
+
diff --git a/app/code/Magento/Signifyd/etc/frontend/routes.xml b/app/code/Magento/Signifyd/etc/frontend/routes.xml
new file mode 100644
index 0000000000000..8a6c5b4e22c1d
--- /dev/null
+++ b/app/code/Magento/Signifyd/etc/frontend/routes.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Signifyd/etc/module.xml b/app/code/Magento/Signifyd/etc/module.xml
new file mode 100644
index 0000000000000..1ee26044bbef4
--- /dev/null
+++ b/app/code/Magento/Signifyd/etc/module.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Signifyd/registration.php b/app/code/Magento/Signifyd/registration.php
new file mode 100644
index 0000000000000..d7c40b5aa176a
--- /dev/null
+++ b/app/code/Magento/Signifyd/registration.php
@@ -0,0 +1,11 @@
+
Date: Fri, 9 Dec 2016 02:31:15 -0600
Subject: [PATCH 003/904] MAGETWO-61913: Create request builders
- Create builder interface
---
.../Model/Request/CreateCaseBuilder.php | 34 ++++++
.../Request/CreateCaseBuilderInterface.php | 20 ++++
.../Model/Request/PurchaseBuilder.php | 102 ++++++++++++++++++
3 files changed, 156 insertions(+)
create mode 100644 app/code/Magento/Signifyd/Model/Request/CreateCaseBuilder.php
create mode 100644 app/code/Magento/Signifyd/Model/Request/CreateCaseBuilderInterface.php
create mode 100644 app/code/Magento/Signifyd/Model/Request/PurchaseBuilder.php
diff --git a/app/code/Magento/Signifyd/Model/Request/CreateCaseBuilder.php b/app/code/Magento/Signifyd/Model/Request/CreateCaseBuilder.php
new file mode 100644
index 0000000000000..055f78aa401b9
--- /dev/null
+++ b/app/code/Magento/Signifyd/Model/Request/CreateCaseBuilder.php
@@ -0,0 +1,34 @@
+purchaseBuilder = $purchaseBuilder;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function build($orderId)
+ {
+ return $this->purchaseBuilder;
+ }
+}
diff --git a/app/code/Magento/Signifyd/Model/Request/CreateCaseBuilderInterface.php b/app/code/Magento/Signifyd/Model/Request/CreateCaseBuilderInterface.php
new file mode 100644
index 0000000000000..63a302509cf76
--- /dev/null
+++ b/app/code/Magento/Signifyd/Model/Request/CreateCaseBuilderInterface.php
@@ -0,0 +1,20 @@
+orderRepository = $orderRepository;
+ $this->dateTimeFactory = $dateTimeFactory;
+ $this->scope = $scope;
+ }
+
+ /**
+ * Returns purchase data params
+ *
+ * @param int $orderId
+ * @return array
+ */
+ public function build($orderId)
+ {
+ /** @var \Magento\Sales\Model\Order $order */
+ $order = $this->orderRepository->get($orderId);
+ $orderPayment = $order->getPayment();
+ $createdAt = $this->dateTimeFactory->create(
+ $order->getCreatedAt(),
+ new \DateTimeZone('UTC')
+ );
+
+
+ return [
+ 'purchase' => [
+ 'browserIpAddress' => $order->getRemoteIp(),
+ 'shipments' => [
+ 'shippingPrice' => $order->getShippingAmount()
+
+ ],
+ 'orderId' => $order->getEntityId(),
+ 'createdAt' => $createdAt->format(\DateTime::ISO8601),
+ 'paymentGateway' => $this->getPaymentGateway($orderPayment->getMethod()),
+ 'transactionId' => $orderPayment->getLastTransId(),
+ 'currency' => $order->getOrderCurrencyCode(),
+ 'orderChannel' => $this->getOrderChannel(),
+ 'totalPrice' => $order->getGrandTotal(),
+ ],
+ ];
+ }
+
+ /**
+ * Returns the gateway that processed the transaction. For PayPal orders use paypal_account.
+ *
+ * @param string $gatewayCode
+ * @return string
+ */
+ private function getPaymentGateway($gatewayCode)
+ {
+ return (bool)substr_count($gatewayCode, 'paypal') ? 'paypal_account' : $gatewayCode;
+ }
+
+ /**
+ * Returns WEB for web-orders, PHONE for orders created by Admin
+ *
+ * @return string
+ */
+ private function getOrderChannel()
+ {
+ return $this->scope->getCurrentScope() === 'adminhtml' ? 'PHONE' : 'WEB';
+ }
+}
From 9a9fded72409649eda318d24fa03ff6d191dea6d Mon Sep 17 00:00:00 2001
From: Dmytro Yushkin
Date: Fri, 9 Dec 2016 09:06:57 -0600
Subject: [PATCH 004/904] MAGETWO-61967: Generate orderSessionId on backend
---
.../Magento/Signifyd/Model/OrderSessionId.php | 56 ++++++++++++++++
.../Signifyd/Model/Ui/ConfigProvider.php | 46 +++++++++++++
.../Test/Unit/Model/OrderSessionIdTest.php | 62 ++++++++++++++++++
.../Test/Unit/Model/Ui/ConfigProviderTest.php | 64 +++++++++++++++++++
app/code/Magento/Signifyd/etc/frontend/di.xml | 16 +++++
5 files changed, 244 insertions(+)
create mode 100644 app/code/Magento/Signifyd/Model/OrderSessionId.php
create mode 100644 app/code/Magento/Signifyd/Model/Ui/ConfigProvider.php
create mode 100644 app/code/Magento/Signifyd/Test/Unit/Model/OrderSessionIdTest.php
create mode 100644 app/code/Magento/Signifyd/Test/Unit/Model/Ui/ConfigProviderTest.php
create mode 100644 app/code/Magento/Signifyd/etc/frontend/di.xml
diff --git a/app/code/Magento/Signifyd/Model/OrderSessionId.php b/app/code/Magento/Signifyd/Model/OrderSessionId.php
new file mode 100644
index 0000000000000..22be3c6911493
--- /dev/null
+++ b/app/code/Magento/Signifyd/Model/OrderSessionId.php
@@ -0,0 +1,56 @@
+checkoutSession = $checkoutSession;
+ }
+
+ /**
+ * Generate the unique ID for the user's browsing session
+ *
+ * @return string
+ */
+ public function generate()
+ {
+ return sha1($this->getQuote()->getId() . $this->getQuote()->getCreatedAt());
+ }
+
+ /**
+ * Get current quote
+ *
+ * @return \Magento\Quote\Model\Quote
+ */
+ private function getQuote()
+ {
+ if ($this->quote === null) {
+ $this->quote = $this->checkoutSession->getQuote();
+ }
+
+ return $this->quote;
+ }
+}
diff --git a/app/code/Magento/Signifyd/Model/Ui/ConfigProvider.php b/app/code/Magento/Signifyd/Model/Ui/ConfigProvider.php
new file mode 100644
index 0000000000000..4b690a0234e1d
--- /dev/null
+++ b/app/code/Magento/Signifyd/Model/Ui/ConfigProvider.php
@@ -0,0 +1,46 @@
+orderSessionId = $orderSessionId;
+ }
+
+ /**
+ * Retrieve assoc array of checkout configuration
+ *
+ * @return array
+ */
+ public function getConfig()
+ {
+ return [
+ 'fraud' => [
+ self::SIGNIFYD_CODE => [
+ 'orderSessionId' => $this->orderSessionId->generate()
+ ]
+ ]
+ ];
+ }
+}
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/OrderSessionIdTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/OrderSessionIdTest.php
new file mode 100644
index 0000000000000..7057956a8edaf
--- /dev/null
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/OrderSessionIdTest.php
@@ -0,0 +1,62 @@
+checkoutSession = $this->getMockBuilder(Session::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->quote = $this->getMockBuilder(Quote::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->orderSessionId = new OrderSessionId($this->checkoutSession);
+ }
+
+ public function testGenerate()
+ {
+ $this->checkoutSession->expects(static::once())
+ ->method('getQuote')
+ ->willReturn($this->quote);
+
+ $this->quote->expects(static::once())
+ ->method('getId')
+ ->willReturn(self::QUOTE_ID);
+ $this->quote->expects(static::once())
+ ->method('getCreatedAt')
+ ->willReturn(self::QUOTE_CREATED_AT);
+
+ static::assertSame(self::HASH, $this->orderSessionId->generate());
+ }
+}
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/Ui/ConfigProviderTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/Ui/ConfigProviderTest.php
new file mode 100644
index 0000000000000..66e7f8be34b19
--- /dev/null
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/Ui/ConfigProviderTest.php
@@ -0,0 +1,64 @@
+orderSessionId = $this->getMockBuilder(OrderSessionId::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->configProvider = new ConfigProvider($this->orderSessionId);
+ }
+
+ /**
+ * @dataProvider getConfigDataProvider
+ */
+ public function testGetConfig($expected)
+ {
+ $this->orderSessionId->expects(static::once())
+ ->method('generate')
+ ->willReturn(self::HASH);
+
+ static::assertSame($expected, $this->configProvider->getConfig());
+ }
+
+ /**
+ * @return array
+ */
+ public function getConfigDataProvider()
+ {
+ return [
+ [
+ [
+ 'fraud' => [
+ ConfigProvider::SIGNIFYD_CODE => [
+ 'orderSessionId' => self::HASH
+ ]
+ ]
+ ]
+ ]
+ ];
+ }
+}
diff --git a/app/code/Magento/Signifyd/etc/frontend/di.xml b/app/code/Magento/Signifyd/etc/frontend/di.xml
new file mode 100644
index 0000000000000..a81fde778a02a
--- /dev/null
+++ b/app/code/Magento/Signifyd/etc/frontend/di.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+ - Magento\Signifyd\Model\Ui\ConfigProvider
+
+
+
+
From adda6aa136f22f61c99ce4d2921f5045304fb381 Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Mon, 12 Dec 2016 03:16:56 -0600
Subject: [PATCH 005/904] MAGETWO-61913: Create request builders
- Creates card, recipient and purchase builders
---
.../Signifyd/Model/Request/AddressBuilder.php | 44 ++++++
.../Signifyd/Model/Request/CardBuilder.php | 54 ++++++++
.../Model/Request/CreateCaseBuilder.php | 39 +++++-
.../Model/Request/PurchaseBuilder.php | 127 +++++++++++++++---
.../Model/Request/RecipientBuilder.php | 53 ++++++++
5 files changed, 292 insertions(+), 25 deletions(-)
create mode 100644 app/code/Magento/Signifyd/Model/Request/AddressBuilder.php
create mode 100644 app/code/Magento/Signifyd/Model/Request/CardBuilder.php
create mode 100644 app/code/Magento/Signifyd/Model/Request/RecipientBuilder.php
diff --git a/app/code/Magento/Signifyd/Model/Request/AddressBuilder.php b/app/code/Magento/Signifyd/Model/Request/AddressBuilder.php
new file mode 100644
index 0000000000000..621058e7f2c67
--- /dev/null
+++ b/app/code/Magento/Signifyd/Model/Request/AddressBuilder.php
@@ -0,0 +1,44 @@
+ $this->getStreetLine(1, $address->getStreet()),
+ 'unit' => $this->getStreetLine(2, $address->getStreet()),
+ 'city' => $address->getCity(),
+ 'provinceCode' => $address->getRegionCode(),
+ 'postalCode' => $address->getPostcode(),
+ 'countryCode' => $address->getCountryId()
+ ];
+ }
+
+ /**
+ * Get street line by number
+ *
+ * @param int $number
+ * @param string[]|null $street
+ * @return string
+ */
+ public function getStreetLine($number, $street)
+ {
+ $lines = is_array($street) ? $street : [];
+
+ return isset($lines[$number - 1]) ? $lines[$number - 1] : '';
+ }
+}
diff --git a/app/code/Magento/Signifyd/Model/Request/CardBuilder.php b/app/code/Magento/Signifyd/Model/Request/CardBuilder.php
new file mode 100644
index 0000000000000..ec3e08f428b50
--- /dev/null
+++ b/app/code/Magento/Signifyd/Model/Request/CardBuilder.php
@@ -0,0 +1,54 @@
+addressBuilder = $addressBuilder;
+ }
+
+ /**
+ * Returns card data params
+ *
+ * @param Order $order
+ * @return array
+ */
+ public function build(Order $order)
+ {
+ $result = [];
+ $address = $order->getBillingAddress();
+ if ($address === null) {
+ return $result;
+ }
+
+ $payment = $order->getPayment();
+ $result = [
+ 'cardHolderName' => $address->getFirstname() . ' ' . $address->getLastname(),
+ 'last4' => $payment->getCcLast4(),
+ 'expiryMonth' => $payment->getCcExpMonth(),
+ 'expiryYear' => $payment->getCcExpYear(),
+ 'billingAddress' => $this->addressBuilder->build($address),
+ ];
+
+ return $result;
+ }
+}
diff --git a/app/code/Magento/Signifyd/Model/Request/CreateCaseBuilder.php b/app/code/Magento/Signifyd/Model/Request/CreateCaseBuilder.php
index 055f78aa401b9..346aa7a91465e 100644
--- a/app/code/Magento/Signifyd/Model/Request/CreateCaseBuilder.php
+++ b/app/code/Magento/Signifyd/Model/Request/CreateCaseBuilder.php
@@ -5,23 +5,49 @@
*/
namespace Magento\Signifyd\Model\Request;
+use Magento\Sales\Model\OrderFactory;
+
/**
- * Class CreateCaseBuilder
+ * Handles the conversion from Magento Order to Signifyd Case.
*/
class CreateCaseBuilder implements CreateCaseBuilderInterface
{
+ /**
+ * @var OrderFactory
+ */
+ private $orderFactory;
+
/**
* @var PurchaseBuilder
*/
private $purchaseBuilder;
/**
+ * @var CardBuilder
+ */
+ private $cardBuilder;
+
+ /**
+ * @var RecipientBuilder
+ */
+ private $recipientBuilder;
+
+ /**
+ * @param OrderFactory $orderFactory
* @param PurchaseBuilder $purchaseBuilder
+ * @param CardBuilder $cardBuilder
+ * @param RecipientBuilder $recipientBuilder
*/
public function __construct(
- PurchaseBuilder $purchaseBuilder
+ OrderFactory $orderFactory,
+ PurchaseBuilder $purchaseBuilder,
+ CardBuilder $cardBuilder,
+ RecipientBuilder $recipientBuilder
) {
+ $this->orderFactory = $orderFactory;
$this->purchaseBuilder = $purchaseBuilder;
+ $this->cardBuilder = $cardBuilder;
+ $this->recipientBuilder = $recipientBuilder;
}
/**
@@ -29,6 +55,13 @@ public function __construct(
*/
public function build($orderId)
{
- return $this->purchaseBuilder;
+ /* @var $order \Magento\Sales\Model\Order */
+ $order = $this->orderFactory->create()->load($orderId);
+
+ return array_merge(
+ $this->purchaseBuilder->build($order),
+ $this->cardBuilder->build($order),
+ $this->recipientBuilder->build($order)
+ );
}
}
diff --git a/app/code/Magento/Signifyd/Model/Request/PurchaseBuilder.php b/app/code/Magento/Signifyd/Model/Request/PurchaseBuilder.php
index ca1560d65c44a..46e691b8032f9 100644
--- a/app/code/Magento/Signifyd/Model/Request/PurchaseBuilder.php
+++ b/app/code/Magento/Signifyd/Model/Request/PurchaseBuilder.php
@@ -5,20 +5,15 @@
*/
namespace Magento\Signifyd\Model\Request;
-use Magento\Sales\Api\OrderRepositoryInterface;
use Magento\Framework\Intl\DateTimeFactory;
use Magento\Framework\Config\ScopeInterface;
+use Magento\Sales\Model\Order;
/**
* Prepare data related to purchase event represented in Case Creation request.
*/
class PurchaseBuilder
{
- /**
- * @var OrderRepositoryInterface
- */
- private $orderRepository;
-
/**
* @var DateTimeFactory
*/
@@ -30,16 +25,13 @@ class PurchaseBuilder
private $scope;
/**
- * @param OrderRepositoryInterface $orderRepository
* @param DateTimeFactory $dateTimeFactory
* @param ScopeInterface $scope
*/
public function __construct(
- OrderRepositoryInterface $orderRepository,
DateTimeFactory $dateTimeFactory,
ScopeInterface $scope
) {
- $this->orderRepository = $orderRepository;
$this->dateTimeFactory = $dateTimeFactory;
$this->scope = $scope;
}
@@ -47,27 +39,20 @@ public function __construct(
/**
* Returns purchase data params
*
- * @param int $orderId
+ * @param Order $order
* @return array
*/
- public function build($orderId)
+ public function build(Order $order)
{
- /** @var \Magento\Sales\Model\Order $order */
- $order = $this->orderRepository->get($orderId);
$orderPayment = $order->getPayment();
$createdAt = $this->dateTimeFactory->create(
$order->getCreatedAt(),
new \DateTimeZone('UTC')
);
-
- return [
+ $result = [
'purchase' => [
'browserIpAddress' => $order->getRemoteIp(),
- 'shipments' => [
- 'shippingPrice' => $order->getShippingAmount()
-
- ],
'orderId' => $order->getEntityId(),
'createdAt' => $createdAt->format(\DateTime::ISO8601),
'paymentGateway' => $this->getPaymentGateway($orderPayment->getMethod()),
@@ -77,21 +62,119 @@ public function build($orderId)
'totalPrice' => $order->getGrandTotal(),
],
];
+
+ $shipments = $this->getShipments($order);
+ if (!empty($shipments)) {
+ $result['purchase']['shipments'] = $shipments;
+ }
+
+ $products = $this->getProducts($order);
+ if (!empty($products)) {
+ $result['purchase']['products'] = $products;
+ }
+
+ return $result;
+ }
+
+ /**
+ * Gets the products purchased in the transaction.
+ *
+ * @param Order $order
+ * @return array
+ */
+ private function getProducts(Order $order)
+ {
+ $result = [];
+ foreach ($order->getAllItems() as $orderItem) {
+ $result[] = [
+ 'itemId' => $orderItem->getSku(),
+ 'itemName' => $orderItem->getName(),
+ 'itemPrice' => $orderItem->getPrice(),
+ 'itemQuantity' => $orderItem->getQtyOrdered(),
+ 'itemUrl' => $orderItem->getProduct()->getProductUrl(),
+ 'itemWeight' => $orderItem->getProduct()->getWeight()
+ ];
+ }
+
+ return $result;
+ }
+
+ /**
+ * Gets the shipments associated with this purchase.
+ *
+ * @param Order $order
+ * @return array
+ */
+ private function getShipments(Order $order)
+ {
+ $result = [];
+ $shipper = $this->getShipper($order->getShippingDescription());
+ $shippingMethod = $this->getShippingMethod($order->getShippingDescription());
+
+ $shipmentList = $order->getShipmentsCollection();
+ /** @var \Magento\Sales\Api\Data\ShipmentInterface $shipment */
+ foreach ($shipmentList as $shipment) {
+ $totalPrice = 0;
+ foreach ($shipment->getItems() as $shipmentItem) {
+ $totalPrice += $shipmentItem->getPrice();
+ }
+
+ $item = [
+ 'shipper' => $shipper,
+ 'shippingMethod' => $shippingMethod,
+ 'shippingPrice' => $totalPrice
+ ];
+
+ $tracks = $shipment->getTracks();
+ if (!empty($tracks)) {
+ $item['trackingNumber'] = end($tracks)->getTrackNumber();
+ }
+
+ $result[] = $item;
+ }
+
+ return $result;
+ }
+
+ /**
+ * Gets the name of the shipper
+ *
+ * @param $shippingDescription
+ * @return string
+ */
+ private function getShipper($shippingDescription)
+ {
+ $result = explode(' - ', $shippingDescription, 2);
+
+ return count($result) == 2 ? $result[0] : '';
+ }
+
+ /**
+ * Gets the type of the shipment method used
+ *
+ * @param $shippingDescription
+ * @return string
+ */
+ private function getShippingMethod($shippingDescription)
+ {
+ $result = explode(' - ', $shippingDescription, 2);
+
+ return count($result) == 2 ? $result[1] : '';
}
/**
- * Returns the gateway that processed the transaction. For PayPal orders use paypal_account.
+ * Gets the gateway that processed the transaction. For PayPal orders use paypal_account.
*
* @param string $gatewayCode
* @return string
*/
private function getPaymentGateway($gatewayCode)
{
- return (bool)substr_count($gatewayCode, 'paypal') ? 'paypal_account' : $gatewayCode;
+ return strstr($gatewayCode, 'paypal') === false ? $gatewayCode : 'paypal_account';
}
/**
- * Returns WEB for web-orders, PHONE for orders created by Admin
+ * Gets WEB for web-orders, PHONE for orders created by Admin
*
* @return string
*/
diff --git a/app/code/Magento/Signifyd/Model/Request/RecipientBuilder.php b/app/code/Magento/Signifyd/Model/Request/RecipientBuilder.php
new file mode 100644
index 0000000000000..38cb79d32de2b
--- /dev/null
+++ b/app/code/Magento/Signifyd/Model/Request/RecipientBuilder.php
@@ -0,0 +1,53 @@
+addressBuilder = $addressBuilder;
+ }
+
+ /**
+ * Returns recipient data params
+ *
+ * @param Order $order
+ * @return array
+ */
+ public function build(Order $order)
+ {
+ $result = [];
+ $address = $order->getShippingAddress();
+ if ($address === null) {
+ return $result;
+ }
+
+ $result = [
+ 'fullName' => $address->getName(),
+ 'confirmationEmail' => $address->getEmail(),
+ 'confirmationPhone' => $address->getTelephone(),
+ 'organization' => $address->getCompany(),
+ 'deliveryAddress' => $this->addressBuilder->build($address)
+ ];
+
+ return $result;
+ }
+}
From a64ec0b80ef160c4d59dfd7826a036b3a19679b3 Mon Sep 17 00:00:00 2001
From: Dmytro Yushkin
Date: Mon, 12 Dec 2016 04:16:39 -0600
Subject: [PATCH 006/904] MAGETWO-61967: Generate orderSessionId on backend
- Added Checkout module dependency
---
app/code/Magento/Signifyd/composer.json | 3 ++-
app/code/Magento/Signifyd/etc/module.xml | 1 +
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/app/code/Magento/Signifyd/composer.json b/app/code/Magento/Signifyd/composer.json
index 9f0c56a845f37..cc8bd9d228508 100644
--- a/app/code/Magento/Signifyd/composer.json
+++ b/app/code/Magento/Signifyd/composer.json
@@ -4,7 +4,8 @@
"require": {
"php": "~5.6.5|7.0.2|7.0.4|~7.0.6",
"magento/framework": "100.2.*",
- "magento/module-sales": "100.2.*"
+ "magento/module-sales": "100.2.*",
+ "magento/module-checkout": "100.2.*"
},
"type": "magento2-module",
"version": "100.2.0-dev",
diff --git a/app/code/Magento/Signifyd/etc/module.xml b/app/code/Magento/Signifyd/etc/module.xml
index 1ee26044bbef4..82eb61e9ff0a8 100644
--- a/app/code/Magento/Signifyd/etc/module.xml
+++ b/app/code/Magento/Signifyd/etc/module.xml
@@ -9,6 +9,7 @@
+
From 546fc8af8ab8b04e27f1c7c3991f1eea13e41840 Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Mon, 12 Dec 2016 05:00:00 -0600
Subject: [PATCH 007/904] MAGETWO-61925: Create case entity infrastructure
- Added API interfaces for Sygnifyd integration
- Added implementation of API interfaces
- Covered Sygnifyd management by integration tests
---
.../Signifyd/Api/CaseManagementInterface.php | 31 +++
.../Signifyd/Api/CaseRepositoryInterface.php | 32 +++
.../Signifyd/Api/Data/CaseInterface.php | 227 ++++++++++++++++++
.../Magento/Signifyd/Model/CaseEntity.php | 205 ++++++++++++++++
.../Magento/Signifyd/Model/CaseManagement.php | 57 +++++
.../Magento/Signifyd/Model/CaseRepository.php | 56 +++++
.../Magento/Signifyd/Setup/InstallSchema.php | 64 +++++
app/code/Magento/Signifyd/etc/constraints.xml | 14 ++
app/code/Magento/Signifyd/etc/di.xml | 39 +++
app/code/Magento/Signifyd/i18n/en_US.csv | 13 +
.../Signifyd/Model/CaseManagementTest.php | 93 +++++++
.../Magento/Signifyd/_files/case.php | 31 +++
12 files changed, 862 insertions(+)
create mode 100644 app/code/Magento/Signifyd/Api/CaseManagementInterface.php
create mode 100644 app/code/Magento/Signifyd/Api/CaseRepositoryInterface.php
create mode 100644 app/code/Magento/Signifyd/Api/Data/CaseInterface.php
create mode 100644 app/code/Magento/Signifyd/Model/CaseEntity.php
create mode 100644 app/code/Magento/Signifyd/Model/CaseManagement.php
create mode 100644 app/code/Magento/Signifyd/Model/CaseRepository.php
create mode 100644 app/code/Magento/Signifyd/Setup/InstallSchema.php
create mode 100644 app/code/Magento/Signifyd/etc/constraints.xml
create mode 100644 app/code/Magento/Signifyd/etc/di.xml
create mode 100644 app/code/Magento/Signifyd/i18n/en_US.csv
create mode 100644 dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseManagementTest.php
create mode 100644 dev/tests/integration/testsuite/Magento/Signifyd/_files/case.php
diff --git a/app/code/Magento/Signifyd/Api/CaseManagementInterface.php b/app/code/Magento/Signifyd/Api/CaseManagementInterface.php
new file mode 100644
index 0000000000000..c4d6005011b93
--- /dev/null
+++ b/app/code/Magento/Signifyd/Api/CaseManagementInterface.php
@@ -0,0 +1,31 @@
+getData('entity_id');
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function setEntityId($id)
+ {
+ $this->setData('entity_id', (int) $id);
+ return $this;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function getCaseId()
+ {
+ return (int) $this->getData('case_id');
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function setCaseId($id)
+ {
+ $this->setData('case_id', (int) $id);
+ return $this;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function getGuaranteeEligible()
+ {
+ return $this->getData('guarantee_eligible');
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function setGuaranteeEligible($guaranteeEligible)
+ {
+ $this->setData('guarantee_eligible', $guaranteeEligible);
+ return $this;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function getGuaranteeDisposition()
+ {
+ return (string) $this->getData('guarantee_disposition');
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function setGuaranteeDisposition($disposition)
+ {
+ $this->setData('guarantee_disposition', (string) $disposition);
+ return $this;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function getStatus()
+ {
+ return (string) $this->getData('status');
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function setStatus($status)
+ {
+ $this->setData('status', (string) $status);
+ return $this;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function getScore()
+ {
+ return (int) $this->getData('score');
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function setScore($score)
+ {
+ $this->setData('score', (int) $score);
+ return $this;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function getOrderId()
+ {
+ return (int) $this->getData('order_id');
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function setOrderId($orderId)
+ {
+ $this->setData('order_id', (int) $orderId);
+ return $this;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function getAssociatedTeam()
+ {
+ return (int) $this->getData('associated_team');
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function setAssociatedTeam($teamId)
+ {
+ $this->setData('associated_team', (int) $teamId);
+ return $this;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function getReviewDisposition()
+ {
+ return (string) $this->getData('review_disposition');
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function setReviewDisposition($disposition)
+ {
+ $this->setData('review_disposition', (string) $disposition);
+ return $this;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function getCreatedAt()
+ {
+ return $this->getData('created_at');
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function setCreatedAt($datetime)
+ {
+ $this->setData('created_at', $datetime);
+ return $this;
+ }
+
+ /**
+ * Gets updating datetime for a case
+ * @return string
+ */
+ public function getUpdatedAt()
+ {
+ return $this->getData('updated_at');
+ }
+
+ /**
+ * Sets updating datetime for a case
+ * @param $datetime
+ * @return $this
+ */
+ public function setUpdatedAt($datetime)
+ {
+ $this->setData('updated_at', $datetime);
+ return $this;
+ }
+}
diff --git a/app/code/Magento/Signifyd/Model/CaseManagement.php b/app/code/Magento/Signifyd/Model/CaseManagement.php
new file mode 100644
index 0000000000000..9269d8622dfab
--- /dev/null
+++ b/app/code/Magento/Signifyd/Model/CaseManagement.php
@@ -0,0 +1,57 @@
+caseRepository = $caseRepository;
+ $this->caseFactory = $caseFactory;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function create($orderId)
+ {
+ $case = $this->caseFactory->create(
+ ['data' => ['order_id' => $orderId, 'status' => CaseInterface::STATUS_PROCESSING]]
+ );
+ return $this->caseRepository->save($case);
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function getByOrderId($orderId)
+ {
+ return $this->caseRepository->getById($orderId);
+ }
+}
diff --git a/app/code/Magento/Signifyd/Model/CaseRepository.php b/app/code/Magento/Signifyd/Model/CaseRepository.php
new file mode 100644
index 0000000000000..916cbe6136817
--- /dev/null
+++ b/app/code/Magento/Signifyd/Model/CaseRepository.php
@@ -0,0 +1,56 @@
+entityManager = $entityManager;
+ $this->caseFactory = $caseFactory;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function save(CaseInterface $case)
+ {
+ return $this->entityManager->save($case);
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function getById($orderId)
+ {
+ $case = $this->caseFactory->create();
+ return $this->entityManager->load($case, $orderId);
+ }
+}
diff --git a/app/code/Magento/Signifyd/Setup/InstallSchema.php b/app/code/Magento/Signifyd/Setup/InstallSchema.php
new file mode 100644
index 0000000000000..c12399e669394
--- /dev/null
+++ b/app/code/Magento/Signifyd/Setup/InstallSchema.php
@@ -0,0 +1,64 @@
+startSetup()->getConnection();
+
+ $table = $connection->newTable($setup->getTable(static::$table));
+ $table->addColumn(
+ 'entity_id',
+ Table::TYPE_INTEGER,
+ null,
+ ['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true]
+ );
+ $table->addColumn('order_id', Table::TYPE_INTEGER, null, ['unsigned' => true]);
+ $table->addColumn('case_id', Table::TYPE_INTEGER, null, ['unsigned' => true]);
+ $table->addColumn('guarantee_eligible', Table::TYPE_BOOLEAN, null);
+ $table->addColumn('guarantee_disposition', Table::TYPE_TEXT, 32);
+ $table->addColumn('status', Table::TYPE_TEXT, 32, ['default' => CaseInterface::STATUS_PROCESSING]);
+ $table->addColumn('score', Table::TYPE_INTEGER, null, ['unsigned' => true]);
+ $table->addColumn('associated_team', Table::TYPE_INTEGER, null, ['unsigned' => true]);
+ $table->addColumn('review_disposition', Table::TYPE_TEXT, 32);
+ $table->addColumn('created_at', Table::TYPE_TIMESTAMP);
+ $table->addColumn('updated_at', Table::TYPE_TIMESTAMP);
+ $table->addForeignKey(
+ $setup->getFkName(
+ $setup->getTable(static::$table),
+ 'order_id',
+ $setup->getTable('sales_order'),
+ 'entity_id'
+ ),
+ 'order_id',
+ $setup->getTable('sales_order'),
+ 'entity_id',
+ Table::ACTION_SET_NULL
+ );
+ $connection->createTable($table);
+ }
+}
diff --git a/app/code/Magento/Signifyd/etc/constraints.xml b/app/code/Magento/Signifyd/etc/constraints.xml
new file mode 100644
index 0000000000000..4947f84a5adc9
--- /dev/null
+++ b/app/code/Magento/Signifyd/etc/constraints.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/code/Magento/Signifyd/etc/di.xml b/app/code/Magento/Signifyd/etc/di.xml
new file mode 100644
index 0000000000000..3abcaad08a639
--- /dev/null
+++ b/app/code/Magento/Signifyd/etc/di.xml
@@ -0,0 +1,39 @@
+
+
+
+
+
+
+
+
+
+
+
+ -
+
- Magento\Framework\EntityManager\Operation\Read
+ - Magento\Framework\EntityManager\Operation\Create
+ - Magento\Framework\EntityManager\Operation\Update
+
+
+
+
+
+
+
+
+
+
+ -
+
- signifyd_case
+ - order_id
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/code/Magento/Signifyd/i18n/en_US.csv b/app/code/Magento/Signifyd/i18n/en_US.csv
new file mode 100644
index 0000000000000..2785e217040ca
--- /dev/null
+++ b/app/code/Magento/Signifyd/i18n/en_US.csv
@@ -0,0 +1,13 @@
+"OPEN","Open"
+"PROCESSING","Processing"
+"FLAGGED","Flagged"
+"DISMISSED","Dismissed"
+"HELD","Held"
+"GOOD","Good"
+"FRAUDULENT","Fraudulent"
+"UNSET","Unset"
+"APPROVED","Approved"
+"DECLINED","Declined"
+"PENDING","Pending"
+"CANCELED","Canceled"
+"IN_REVIEW","In review"
\ No newline at end of file
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseManagementTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseManagementTest.php
new file mode 100644
index 0000000000000..c81a18a8afc99
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseManagementTest.php
@@ -0,0 +1,93 @@
+objectManager = Bootstrap::getObjectManager();
+ $this->caseManagement = $this->objectManager->get(CaseManagement::class);
+ }
+
+ /**
+ * @covers \Magento\Signifyd\Model\CaseManagement::create
+ * @magentoDataFixture Magento/Signifyd/_files/order.php
+ */
+ public function testCreate()
+ {
+ $order = $this->getOrder();
+ $case = $this->caseManagement->create($order->getEntityId());
+
+ static::assertNotEmpty($case->getEntityId());
+ static::assertEquals(CaseInterface::STATUS_PROCESSING, $case->getStatus());
+ }
+
+ /**
+ * @covers \Magento\Signifyd\Model\CaseManagement::getByOrderId
+ * @magentoDataFixture Magento/Signifyd/_files/case.php
+ */
+ public function testGetByOrderId()
+ {
+ $order = $this->getOrder();
+ $case = $this->caseManagement->getByOrderId($order->getEntityId());
+
+ static::assertEquals(CaseInterface::GUARANTEE_PENDING, $case->getGuaranteeDisposition());
+ static::assertEquals(CaseInterface::STATUS_PROCESSING, $case->getStatus());
+ static::assertEquals(CaseInterface::DISPOSITION_GOOD, $case->getReviewDisposition());
+ static::assertEquals('2016-12-12 15:17:17', $case->getCreatedAt());
+ static::assertEquals('2016-12-12 19:23:16', $case->getUpdatedAt());
+ }
+
+ /**
+ * Get stored order
+ * @return OrderInterface
+ */
+ private function getOrder()
+ {
+ /** @var FilterBuilder $filterBuilder */
+ $filterBuilder = $this->objectManager->get(FilterBuilder::class);
+ $filters = [
+ $filterBuilder->setField(OrderInterface::INCREMENT_ID)
+ ->setValue('100000001')
+ ->create()
+ ];
+
+ /** @var SearchCriteriaBuilder $searchCriteriaBuilder */
+ $searchCriteriaBuilder = $this->objectManager->get(SearchCriteriaBuilder::class);
+ $searchCriteria = $searchCriteriaBuilder->addFilters($filters)
+ ->create();
+
+ $orderRepository = $this->objectManager->get(OrderRepositoryInterface::class);
+ $orders = $orderRepository->getList($searchCriteria)
+ ->getItems();
+
+ /** @var OrderInterface $order */
+ return array_pop($orders);
+ }
+}
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/_files/case.php b/dev/tests/integration/testsuite/Magento/Signifyd/_files/case.php
new file mode 100644
index 0000000000000..2ec61edef8f39
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/_files/case.php
@@ -0,0 +1,31 @@
+get(CaseInterfaceFactory::class);
+
+/** @var CaseInterface $case */
+$case = $caseFactory->create();
+$case->setCaseId(123)
+ ->setGuaranteeEligible(true)
+ ->setGuaranteeDisposition(CaseInterface::GUARANTEE_PENDING)
+ ->setStatus(CaseInterface::STATUS_PROCESSING)
+ ->setScore(553)
+ ->setOrderId($order->getEntityId())
+ ->setAssociatedTeam(124)
+ ->setReviewDisposition(CaseInterface::DISPOSITION_GOOD)
+ ->setCreatedAt('2016-12-12T15:17:17+0000')
+ ->setUpdatedAt('2016-12-12T19:23:16+0000');
+
+/** @var CaseRepositoryInterface $caseRepository */
+$caseRepository = $objectManager->get(CaseRepositoryInterface::class);
+$caseRepository->save($case);
+
From b1ce254d6d1643a771e9d90876c6e504ed3f6bf3 Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Mon, 12 Dec 2016 05:15:19 -0600
Subject: [PATCH 008/904] MAGETWO-61925: Create case entity infrastructure
- Fixed failed static tests
---
app/code/Magento/Signifyd/Api/Data/CaseInterface.php | 4 +++-
app/code/Magento/Signifyd/Model/CaseEntity.php | 2 +-
.../integration/testsuite/Magento/Signifyd/_files/case.php | 1 -
3 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/app/code/Magento/Signifyd/Api/Data/CaseInterface.php b/app/code/Magento/Signifyd/Api/Data/CaseInterface.php
index 1a1358836003f..f1c4980d7fe2a 100644
--- a/app/code/Magento/Signifyd/Api/Data/CaseInterface.php
+++ b/app/code/Magento/Signifyd/Api/Data/CaseInterface.php
@@ -16,6 +16,7 @@ interface CaseInterface
/**#@+
* Constants for case available statuses
*/
+
/**
* Open status
*/
@@ -67,6 +68,7 @@ interface CaseInterface
/**#@+
* Constants for case available review dispositions
*/
+
/**
* Review disposition is good
*/
@@ -112,7 +114,7 @@ public function setCaseId($id);
* Gets value, which indicates if a guarantee can be requested for a case
* @return boolean
*/
- public function getGuaranteeEligible();
+ public function isGuaranteeEligible();
/**
* Sets value-indicator about guarantee availability for a case
diff --git a/app/code/Magento/Signifyd/Model/CaseEntity.php b/app/code/Magento/Signifyd/Model/CaseEntity.php
index 05f77fa752547..4dd028e5b74ab 100644
--- a/app/code/Magento/Signifyd/Model/CaseEntity.php
+++ b/app/code/Magento/Signifyd/Model/CaseEntity.php
@@ -50,7 +50,7 @@ public function setCaseId($id)
/**
* @inheritdoc
*/
- public function getGuaranteeEligible()
+ public function isGuaranteeEligible()
{
return $this->getData('guarantee_eligible');
}
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/_files/case.php b/dev/tests/integration/testsuite/Magento/Signifyd/_files/case.php
index 2ec61edef8f39..148c831a9f2d7 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/_files/case.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/_files/case.php
@@ -28,4 +28,3 @@
/** @var CaseRepositoryInterface $caseRepository */
$caseRepository = $objectManager->get(CaseRepositoryInterface::class);
$caseRepository->save($case);
-
From 7da30556276cab8474dc5f7786233f5bed322540 Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Mon, 12 Dec 2016 05:26:08 -0600
Subject: [PATCH 009/904] MAGETWO-61925: Create case entity infrastructure
- Fixed failed static test
---
app/code/Magento/Signifyd/Api/Data/CaseInterface.php | 1 +
1 file changed, 1 insertion(+)
diff --git a/app/code/Magento/Signifyd/Api/Data/CaseInterface.php b/app/code/Magento/Signifyd/Api/Data/CaseInterface.php
index f1c4980d7fe2a..9a85652f3d57c 100644
--- a/app/code/Magento/Signifyd/Api/Data/CaseInterface.php
+++ b/app/code/Magento/Signifyd/Api/Data/CaseInterface.php
@@ -40,6 +40,7 @@ interface CaseInterface
/**#@+
* Constants for guarantee available statuses
*/
+
/**
* Approved status
*/
From 65604fdd4181d2b12d82080664b88818d3474164 Mon Sep 17 00:00:00 2001
From: Dmytro Yushkin
Date: Mon, 12 Dec 2016 05:48:33 -0600
Subject: [PATCH 010/904] MAGETWO-61967: Generate orderSessionId on backend
- Removed hard dependency on checkout session
- Used identity generator instead of sha1 hash
---
.../Magento/Signifyd/Model/OrderSessionId.php | 30 ++++++++++++-----
.../Signifyd/Model/Ui/ConfigProvider.php | 2 +-
.../Test/Unit/Model/OrderSessionIdTest.php | 33 +++++++++++++------
.../Test/Unit/Model/Ui/ConfigProviderTest.php | 4 +--
.../Magento/Signifyd/etc/adminhtml/di.xml | 14 ++++++++
app/code/Magento/Signifyd/etc/frontend/di.xml | 5 +++
6 files changed, 66 insertions(+), 22 deletions(-)
create mode 100644 app/code/Magento/Signifyd/etc/adminhtml/di.xml
diff --git a/app/code/Magento/Signifyd/Model/OrderSessionId.php b/app/code/Magento/Signifyd/Model/OrderSessionId.php
index 22be3c6911493..96356f81dd287 100644
--- a/app/code/Magento/Signifyd/Model/OrderSessionId.php
+++ b/app/code/Magento/Signifyd/Model/OrderSessionId.php
@@ -5,7 +5,8 @@
*/
namespace Magento\Signifyd\Model;
-use Magento\Checkout\Model\Session;
+use Magento\Framework\DataObject\IdentityGeneratorInterface;
+use Magento\Framework\Session\SessionManagerInterface;
/**
* Class OrderSessionId
@@ -13,9 +14,9 @@
class OrderSessionId
{
/**
- * @var Session
+ * @var SessionManagerInterface
*/
- private $checkoutSession;
+ private $session;
/**
* @var \Magento\Quote\Model\Quote
@@ -23,11 +24,20 @@ class OrderSessionId
private $quote;
/**
- * @param Session $checkoutSession
+ * @var IdentityGeneratorInterface
*/
- public function __construct(Session $checkoutSession)
- {
- $this->checkoutSession = $checkoutSession;
+ private $identityGenerator;
+
+ /**
+ * @param SessionManagerInterface $session
+ * @param IdentityGeneratorInterface $identityGenerator
+ */
+ public function __construct(
+ SessionManagerInterface $session,
+ IdentityGeneratorInterface $identityGenerator
+ ) {
+ $this->session = $session;
+ $this->identityGenerator = $identityGenerator;
}
/**
@@ -37,7 +47,9 @@ public function __construct(Session $checkoutSession)
*/
public function generate()
{
- return sha1($this->getQuote()->getId() . $this->getQuote()->getCreatedAt());
+ return $this->identityGenerator->generateIdForData(
+ $this->getQuote()->getId() . $this->getQuote()->getCreatedAt()
+ );
}
/**
@@ -48,7 +60,7 @@ public function generate()
private function getQuote()
{
if ($this->quote === null) {
- $this->quote = $this->checkoutSession->getQuote();
+ $this->quote = $this->session->getQuote();
}
return $this->quote;
diff --git a/app/code/Magento/Signifyd/Model/Ui/ConfigProvider.php b/app/code/Magento/Signifyd/Model/Ui/ConfigProvider.php
index 4b690a0234e1d..af6555a4329db 100644
--- a/app/code/Magento/Signifyd/Model/Ui/ConfigProvider.php
+++ b/app/code/Magento/Signifyd/Model/Ui/ConfigProvider.php
@@ -36,7 +36,7 @@ public function __construct(OrderSessionId $orderSessionId)
public function getConfig()
{
return [
- 'fraud' => [
+ 'fraud_protection' => [
self::SIGNIFYD_CODE => [
'orderSessionId' => $this->orderSessionId->generate()
]
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/OrderSessionIdTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/OrderSessionIdTest.php
index 7057956a8edaf..32a8e3b6a7426 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/OrderSessionIdTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/OrderSessionIdTest.php
@@ -5,7 +5,8 @@
*/
namespace Magento\Signifyd\Test\Unit\Model;
-use Magento\Checkout\Model\Session;
+use Magento\Framework\DataObject\IdentityGeneratorInterface;
+use Magento\Framework\Session\SessionManagerInterface;
use Magento\Quote\Model\Quote;
use Magento\Signifyd\Model\OrderSessionId;
use PHPUnit_Framework_MockObject_MockObject as MockObject;
@@ -14,7 +15,7 @@ class OrderSessionIdTest extends \PHPUnit_Framework_TestCase
{
const QUOTE_ID = 1;
const QUOTE_CREATED_AT = '1970-01-01 00:00:00';
- const HASH = 'ede3c2f59fabe6dee8d1fefb5580200884ff1f16';
+ const HASH = 'hash';
/**
* @var OrderSessionId
@@ -22,31 +23,39 @@ class OrderSessionIdTest extends \PHPUnit_Framework_TestCase
private $orderSessionId;
/**
- * @var Session|MockObject
+ * @var SessionManagerInterface|MockObject
*/
- private $checkoutSession;
+ private $session;
/**
* @var Quote|MockObject
*/
private $quote;
- public function setUp()
+ /**
+ * @var IdentityGeneratorInterface|MockObject
+ */
+ private $identityGenerator;
+
+ protected function setUp()
{
- $this->checkoutSession = $this->getMockBuilder(Session::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->session = $this->getMockBuilder(SessionManagerInterface::class)
+ ->setMethods(['getQuote'])
+ ->getMockForAbstractClass();
$this->quote = $this->getMockBuilder(Quote::class)
->disableOriginalConstructor()
->getMock();
- $this->orderSessionId = new OrderSessionId($this->checkoutSession);
+ $this->identityGenerator = $this->getMockBuilder(IdentityGeneratorInterface::class)
+ ->getMockForAbstractClass();
+
+ $this->orderSessionId = new OrderSessionId($this->session, $this->identityGenerator);
}
public function testGenerate()
{
- $this->checkoutSession->expects(static::once())
+ $this->session->expects(static::once())
->method('getQuote')
->willReturn($this->quote);
@@ -57,6 +66,10 @@ public function testGenerate()
->method('getCreatedAt')
->willReturn(self::QUOTE_CREATED_AT);
+ $this->identityGenerator->expects(static::once())
+ ->method('generateIdForData')
+ ->willReturn('hash');
+
static::assertSame(self::HASH, $this->orderSessionId->generate());
}
}
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/Ui/ConfigProviderTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/Ui/ConfigProviderTest.php
index 66e7f8be34b19..bfae3b8773cba 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/Ui/ConfigProviderTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/Ui/ConfigProviderTest.php
@@ -11,7 +11,7 @@
class ConfigProviderTest extends \PHPUnit_Framework_TestCase
{
- const HASH = 'ede3c2f59fabe6dee8d1fefb5580200884ff1f16';
+ const HASH = 'hash';
/**
* @var ConfigProvider
@@ -52,7 +52,7 @@ public function getConfigDataProvider()
return [
[
[
- 'fraud' => [
+ 'fraud_protection' => [
ConfigProvider::SIGNIFYD_CODE => [
'orderSessionId' => self::HASH
]
diff --git a/app/code/Magento/Signifyd/etc/adminhtml/di.xml b/app/code/Magento/Signifyd/etc/adminhtml/di.xml
new file mode 100644
index 0000000000000..2509a0be47376
--- /dev/null
+++ b/app/code/Magento/Signifyd/etc/adminhtml/di.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+ Magento\Backend\Model\Session\Quote
+
+
+
diff --git a/app/code/Magento/Signifyd/etc/frontend/di.xml b/app/code/Magento/Signifyd/etc/frontend/di.xml
index a81fde778a02a..b5a97f00ac3a4 100644
--- a/app/code/Magento/Signifyd/etc/frontend/di.xml
+++ b/app/code/Magento/Signifyd/etc/frontend/di.xml
@@ -13,4 +13,9 @@
+
+
+ Magento\Checkout\Model\Session
+
+
From c56be06630ee6bb310b27a2404753e391dc79aba Mon Sep 17 00:00:00 2001
From: Dmytro Yushkin
Date: Mon, 12 Dec 2016 05:55:44 -0600
Subject: [PATCH 011/904] MAGETWO-61967: Generate orderSessionId on backend
- Removed module.xml dependency
---
.../Magento/Signifyd/Test/Unit/Model/Ui/ConfigProviderTest.php | 2 +-
app/code/Magento/Signifyd/etc/module.xml | 1 -
2 files changed, 1 insertion(+), 2 deletions(-)
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/Ui/ConfigProviderTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/Ui/ConfigProviderTest.php
index bfae3b8773cba..99f4c23e70cbd 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/Ui/ConfigProviderTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/Ui/ConfigProviderTest.php
@@ -23,7 +23,7 @@ class ConfigProviderTest extends \PHPUnit_Framework_TestCase
*/
private $orderSessionId;
- public function setUp()
+ protected function setUp()
{
$this->orderSessionId = $this->getMockBuilder(OrderSessionId::class)
->disableOriginalConstructor()
diff --git a/app/code/Magento/Signifyd/etc/module.xml b/app/code/Magento/Signifyd/etc/module.xml
index 82eb61e9ff0a8..1ee26044bbef4 100644
--- a/app/code/Magento/Signifyd/etc/module.xml
+++ b/app/code/Magento/Signifyd/etc/module.xml
@@ -9,7 +9,6 @@
-
From 3f89bd07bdd46470b38ac4caf364f4447b81722c Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Mon, 12 Dec 2016 11:35:10 -0600
Subject: [PATCH 012/904] MAGETWO-61913: Create request builders
- Add seller, clientVersion and userAccount builders
---
.../Signifyd/Model/Request/AddressBuilder.php | 2 +-
.../Model/Request/ClientVersionBuilder.php | 43 +++++
.../Model/Request/CreateCaseBuilder.php | 34 +++-
.../Signifyd/Model/Request/CustomerOrders.php | 66 +++++++
.../Model/Request/PurchaseBuilder.php | 4 +-
.../Signifyd/Model/Request/SellerBuilder.php | 85 +++++++++
.../Model/Request/UserAccountBuilder.php | 168 ++++++++++++++++++
7 files changed, 396 insertions(+), 6 deletions(-)
create mode 100644 app/code/Magento/Signifyd/Model/Request/ClientVersionBuilder.php
create mode 100644 app/code/Magento/Signifyd/Model/Request/CustomerOrders.php
create mode 100644 app/code/Magento/Signifyd/Model/Request/SellerBuilder.php
create mode 100644 app/code/Magento/Signifyd/Model/Request/UserAccountBuilder.php
diff --git a/app/code/Magento/Signifyd/Model/Request/AddressBuilder.php b/app/code/Magento/Signifyd/Model/Request/AddressBuilder.php
index 621058e7f2c67..2d2b4ac28f6f2 100644
--- a/app/code/Magento/Signifyd/Model/Request/AddressBuilder.php
+++ b/app/code/Magento/Signifyd/Model/Request/AddressBuilder.php
@@ -35,7 +35,7 @@ public function build(OrderAddressInterface $address)
* @param string[]|null $street
* @return string
*/
- public function getStreetLine($number, $street)
+ private function getStreetLine($number, $street)
{
$lines = is_array($street) ? $street : [];
diff --git a/app/code/Magento/Signifyd/Model/Request/ClientVersionBuilder.php b/app/code/Magento/Signifyd/Model/Request/ClientVersionBuilder.php
new file mode 100644
index 0000000000000..4c8f4e843163a
--- /dev/null
+++ b/app/code/Magento/Signifyd/Model/Request/ClientVersionBuilder.php
@@ -0,0 +1,43 @@
+productMetadata = $productMetadata;
+ }
+
+ /**
+ * Returns version info
+ *
+ * @return array
+ */
+ public function build()
+ {
+ return [
+ 'clientVersion' => [
+ 'platform' => $this->productMetadata->getName() . ' ' . $this->productMetadata->getEdition(),
+ 'platformVersion' => $this->productMetadata->getVersion()
+ ]
+ ];
+ }
+}
diff --git a/app/code/Magento/Signifyd/Model/Request/CreateCaseBuilder.php b/app/code/Magento/Signifyd/Model/Request/CreateCaseBuilder.php
index 346aa7a91465e..926c5354af57a 100644
--- a/app/code/Magento/Signifyd/Model/Request/CreateCaseBuilder.php
+++ b/app/code/Magento/Signifyd/Model/Request/CreateCaseBuilder.php
@@ -8,7 +8,8 @@
use Magento\Sales\Model\OrderFactory;
/**
- * Handles the conversion from Magento Order to Signifyd Case.
+ * Handles the conversion from Magento Order to Signifyd Case
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class CreateCaseBuilder implements CreateCaseBuilderInterface
{
@@ -32,22 +33,46 @@ class CreateCaseBuilder implements CreateCaseBuilderInterface
*/
private $recipientBuilder;
+ /**
+ * @var SellerBuilder
+ */
+ private $sellerBuilder;
+
+ /**
+ * @var ClientVersionBuilder
+ */
+ private $clientVersionBuilder;
+
+ /**
+ * @var UserAccountBuilder
+ */
+ private $userAccountBuilder;
+
/**
* @param OrderFactory $orderFactory
* @param PurchaseBuilder $purchaseBuilder
* @param CardBuilder $cardBuilder
* @param RecipientBuilder $recipientBuilder
+ * @param SellerBuilder $sellerBuilder
+ * @param ClientVersionBuilder $clientVersionBuilder
+ * @param UserAccountBuilder $userAccountBuilder
*/
public function __construct(
OrderFactory $orderFactory,
PurchaseBuilder $purchaseBuilder,
CardBuilder $cardBuilder,
- RecipientBuilder $recipientBuilder
+ RecipientBuilder $recipientBuilder,
+ SellerBuilder $sellerBuilder,
+ ClientVersionBuilder $clientVersionBuilder,
+ UserAccountBuilder $userAccountBuilder
) {
$this->orderFactory = $orderFactory;
$this->purchaseBuilder = $purchaseBuilder;
$this->cardBuilder = $cardBuilder;
$this->recipientBuilder = $recipientBuilder;
+ $this->sellerBuilder = $sellerBuilder;
+ $this->clientVersionBuilder = $clientVersionBuilder;
+ $this->userAccountBuilder = $userAccountBuilder;
}
/**
@@ -61,7 +86,10 @@ public function build($orderId)
return array_merge(
$this->purchaseBuilder->build($order),
$this->cardBuilder->build($order),
- $this->recipientBuilder->build($order)
+ $this->recipientBuilder->build($order),
+ $this->userAccountBuilder->build($order),
+ $this->sellerBuilder->build($order),
+ $this->clientVersionBuilder->build()
);
}
}
diff --git a/app/code/Magento/Signifyd/Model/Request/CustomerOrders.php b/app/code/Magento/Signifyd/Model/Request/CustomerOrders.php
new file mode 100644
index 0000000000000..26322a745b8ee
--- /dev/null
+++ b/app/code/Magento/Signifyd/Model/Request/CustomerOrders.php
@@ -0,0 +1,66 @@
+searchCriteriaBuilder = $searchCriteriaBuilder;
+ $this->filterBuilder = $filterBuilder;
+ $this->orderRepository = $orderRepository;
+ }
+
+ /**
+ * Gets customer orders
+ *
+ * @param int $customerId
+ * @return \Magento\Sales\Api\Data\OrderInterface[]
+ */
+ public function get($customerId)
+ {
+ $filters = [
+ $this->filterBuilder->setField(OrderInterface::CUSTOMER_ID)->setValue($customerId)->create()
+ ];
+ $this->searchCriteriaBuilder->addFilters($filters);
+ $searchCriteria = $this->searchCriteriaBuilder->create();
+ $searchResults = $this->orderRepository->getList($searchCriteria);
+
+ return $searchResults->getItems();
+ }
+}
diff --git a/app/code/Magento/Signifyd/Model/Request/PurchaseBuilder.php b/app/code/Magento/Signifyd/Model/Request/PurchaseBuilder.php
index 46e691b8032f9..215c5f39a172d 100644
--- a/app/code/Magento/Signifyd/Model/Request/PurchaseBuilder.php
+++ b/app/code/Magento/Signifyd/Model/Request/PurchaseBuilder.php
@@ -139,7 +139,7 @@ private function getShipments(Order $order)
/**
* Gets the name of the shipper
*
- * @param $shippingDescription
+ * @param string $shippingDescription
* @return string
*/
private function getShipper($shippingDescription)
@@ -152,7 +152,7 @@ private function getShipper($shippingDescription)
/**
* Gets the type of the shipment method used
*
- * @param $shippingDescription
+ * @param string $shippingDescription
* @return string
*/
private function getShippingMethod($shippingDescription)
diff --git a/app/code/Magento/Signifyd/Model/Request/SellerBuilder.php b/app/code/Magento/Signifyd/Model/Request/SellerBuilder.php
new file mode 100644
index 0000000000000..62977c6d81e51
--- /dev/null
+++ b/app/code/Magento/Signifyd/Model/Request/SellerBuilder.php
@@ -0,0 +1,85 @@
+scopeConfig = $scopeConfig;
+ }
+
+ /**
+ * Returns seller data params
+ *
+ * @param Order $order
+ * @return array
+ */
+ public function build(Order $order)
+ {
+ $store = $order->getStore();
+
+ return [
+ 'seller' => [
+ 'name' => $this->getConfigValue(Information::XML_PATH_STORE_INFO_NAME, $store),
+ 'domain' => parse_url($store->getBaseUrl(), PHP_URL_HOST),
+ 'shipFromAddress' => [
+ 'streetAddress' => $this->getConfigValue(Shipment::XML_PATH_STORE_ADDRESS1, $store),
+ 'unit' => $this->getConfigValue(Shipment::XML_PATH_STORE_ADDRESS2, $store),
+ 'city' => $this->getConfigValue(Shipment::XML_PATH_STORE_CITY, $store),
+ 'provinceCode' => $this->getConfigValue(Shipment::XML_PATH_STORE_REGION_ID, $store),
+ 'postalCode' => $this->getConfigValue(Shipment::XML_PATH_STORE_ZIP, $store),
+ 'countryCode' => $this->getConfigValue(Shipment::XML_PATH_STORE_COUNTRY_ID, $store),
+ ],
+ 'corporateAddress' => [
+ 'streetAddress' => $this->getConfigValue(Information::XML_PATH_STORE_INFO_STREET_LINE1, $store),
+ 'unit' => $this->getConfigValue(Information::XML_PATH_STORE_INFO_STREET_LINE2, $store),
+ 'city' => $this->getConfigValue(Information::XML_PATH_STORE_INFO_CITY, $store),
+ 'provinceCode' => $this->getConfigValue(Information::XML_PATH_STORE_INFO_REGION_CODE, $store),
+ 'postalCode' => $this->getConfigValue(Information::XML_PATH_STORE_INFO_POSTCODE, $store),
+ 'countryCode' => $this->getConfigValue(Information::XML_PATH_STORE_INFO_COUNTRY_CODE, $store),
+ ]
+ ]
+ ];
+ }
+
+ /**
+ * Gets value from config
+ *
+ * @param string $value
+ * @param StoreInterface $store
+ * @return mixed
+ */
+ private function getConfigValue($value, StoreInterface $store)
+ {
+ return $this->scopeConfig->getValue(
+ $value,
+ ScopeInterface::SCOPE_STORE,
+ $store
+ );
+ }
+}
diff --git a/app/code/Magento/Signifyd/Model/Request/UserAccountBuilder.php b/app/code/Magento/Signifyd/Model/Request/UserAccountBuilder.php
new file mode 100644
index 0000000000000..198b57d3e238e
--- /dev/null
+++ b/app/code/Magento/Signifyd/Model/Request/UserAccountBuilder.php
@@ -0,0 +1,168 @@
+customerRepository = $customerRepository;
+ $this->dateTimeFactory = $dateTimeFactory;
+ $this->logger = $logger;
+ $this->currencyFactory = $currencyFactory;
+ $this->customerOrders = $customerOrders;
+ }
+
+ /**
+ * Returns user account data params.
+ * Only for registered customers.
+ *
+ * @param Order $order
+ * @return array
+ */
+ public function build(Order $order)
+ {
+ $result = [];
+
+ $customerId = $order->getCustomerId();
+ if (null === $customerId) {
+ return $result;
+ }
+
+ $customer = $this->customerRepository->getById($customerId);
+ $result = [
+ 'email' => $customer->getEmail(),
+ 'username' => $customer->getEmail(),
+ 'phone' => $order->getBillingAddress()->getTelephone(),
+ 'accountNumber' => $customerId,
+ 'createdDate' => $this->formatDate($customer->getCreatedAt()),
+ 'lastUpdateDate' => $this->formatDate($customer->getUpdatedAt())
+ ];
+
+ $customerOrders = $this->customerOrders->get($customerId);
+ if (!empty($customerOrders)) {
+ try {
+ $orderTotalDollars = 0.0;
+ foreach ($customerOrders as $order) {
+ $orderTotalDollars += $this->getUsdOrderTotal(
+ $order->getBaseGrandTotal(),
+ $order->getBaseCurrencyCode()
+ );
+ }
+ $result['aggregateOrderCount'] = count($customerOrders);
+ $result['aggregateOrderDollars'] = $orderTotalDollars;
+ } catch (\Exception $e) {
+ $this->logger->error($e->getMessage());
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Returns amount in USD
+ *
+ * @param float $amount
+ * @param string $currency
+ * @return float
+ */
+ private function getUsdOrderTotal($amount, $currency)
+ {
+ if ($currency === self::$usdCurrencyCode) {
+ return $amount;
+ }
+
+ $operationCurrency = $this->getCurrencyByCode($currency);
+
+ return $operationCurrency->convert($amount, self::$usdCurrencyCode);
+ }
+
+ /**
+ * Get currency by currency code
+ *
+ * @param string|null $currencyCode
+ * @return \Magento\Directory\Model\Currency
+ */
+ private function getCurrencyByCode($currencyCode)
+ {
+ if (isset($this->currencies[$currencyCode])) {
+ return $this->currencies[$currencyCode];
+ }
+
+ /** @var \Magento\Directory\Model\Currency $currency */
+ $currency = $this->currencyFactory->create();
+ $this->currencies[$currencyCode] = $currency->load($currencyCode);
+
+ return $this->currencies[$currencyCode];
+ }
+
+ /**
+ * Format date in ISO8601
+ *
+ * @param string $date
+ * @return string
+ */
+ private function formatDate($date)
+ {
+ $result = $this->dateTimeFactory->create(
+ $date,
+ new \DateTimeZone('UTC')
+ );
+
+ return $result->format(\DateTime::ISO8601);
+ }
+}
From 58493f3afff0b8d2dbc2fcb3e26badfac13993a6 Mon Sep 17 00:00:00 2001
From: Dmytro Yushkin
Date: Mon, 12 Dec 2016 04:16:39 -0600
Subject: [PATCH 013/904] MAGETWO-61967: Generate orderSessionId on backend
- Added Checkout module dependency
---
app/code/Magento/Signifyd/etc/module.xml | 1 +
1 file changed, 1 insertion(+)
diff --git a/app/code/Magento/Signifyd/etc/module.xml b/app/code/Magento/Signifyd/etc/module.xml
index 1ee26044bbef4..82eb61e9ff0a8 100644
--- a/app/code/Magento/Signifyd/etc/module.xml
+++ b/app/code/Magento/Signifyd/etc/module.xml
@@ -9,6 +9,7 @@
+
From 84bc7af4730d8cff3770ba320b6d86699eec609d Mon Sep 17 00:00:00 2001
From: Dmytro Yushkin
Date: Mon, 12 Dec 2016 05:55:44 -0600
Subject: [PATCH 014/904] MAGETWO-61967: Generate orderSessionId on backend
- Removed module.xml dependency
---
app/code/Magento/Signifyd/etc/module.xml | 1 -
1 file changed, 1 deletion(-)
diff --git a/app/code/Magento/Signifyd/etc/module.xml b/app/code/Magento/Signifyd/etc/module.xml
index 82eb61e9ff0a8..1ee26044bbef4 100644
--- a/app/code/Magento/Signifyd/etc/module.xml
+++ b/app/code/Magento/Signifyd/etc/module.xml
@@ -9,7 +9,6 @@
-
From e416c6bdf508b7359d44ea60819721a768e43527 Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Tue, 13 Dec 2016 06:22:45 -0600
Subject: [PATCH 015/904] MAGETWO-61925: Create case entity infrastructure
- Replaced entity manager by resource model
---
.../Signifyd/Api/CaseRepositoryInterface.php | 20 ++++-
.../Signifyd/Api/Data/CaseInterface.php | 5 ++
.../Api/Data/CaseSearchResultsInterface.php | 31 +++++++
.../Magento/Signifyd/Model/CaseEntity.php | 17 +++-
.../Magento/Signifyd/Model/CaseManagement.php | 39 +++++++--
.../Magento/Signifyd/Model/CaseRepository.php | 83 ++++++++++++++++---
.../Model/ResourceModel/CaseEntity.php | 22 +++++
.../ResourceModel/CaseEntity/Collection.php | 24 ++++++
.../Magento/Signifyd/Setup/InstallSchema.php | 2 +-
app/code/Magento/Signifyd/etc/di.xml | 28 +------
.../Signifyd/Model/CaseManagementTest.php | 2 +-
11 files changed, 223 insertions(+), 50 deletions(-)
create mode 100644 app/code/Magento/Signifyd/Api/Data/CaseSearchResultsInterface.php
create mode 100644 app/code/Magento/Signifyd/Model/ResourceModel/CaseEntity.php
create mode 100644 app/code/Magento/Signifyd/Model/ResourceModel/CaseEntity/Collection.php
diff --git a/app/code/Magento/Signifyd/Api/CaseRepositoryInterface.php b/app/code/Magento/Signifyd/Api/CaseRepositoryInterface.php
index 5c869fc05392d..99ca62e99643e 100644
--- a/app/code/Magento/Signifyd/Api/CaseRepositoryInterface.php
+++ b/app/code/Magento/Signifyd/Api/CaseRepositoryInterface.php
@@ -7,7 +7,7 @@
use Magento\Framework\Api\SearchCriteria;
use Magento\Signifyd\Api\Data\CaseInterface;
-use Magento\Signifyd\Api\Data\CaseSearchResultInterface;
+use Magento\Signifyd\Api\Data\CaseSearchResultsInterface;
/**
* Signifyd Case repository interface
@@ -25,8 +25,22 @@ public function save(CaseInterface $case);
/**
* Gets case entity by order id
- * @param int $orderId
+ * @param int $id
* @return CaseInterface
*/
- public function getById($orderId);
+ public function getById($id);
+
+ /**
+ * Deletes case entity
+ * @param CaseInterface $case
+ * @return bool
+ */
+ public function delete(CaseInterface $case);
+
+ /**
+ * Gets list of case entities
+ * @param SearchCriteria $searchCriteria
+ * @return CaseSearchResultsInterface
+ */
+ public function getList(SearchCriteria $searchCriteria);
}
diff --git a/app/code/Magento/Signifyd/Api/Data/CaseInterface.php b/app/code/Magento/Signifyd/Api/Data/CaseInterface.php
index 9a85652f3d57c..ffcfd3f118eb9 100644
--- a/app/code/Magento/Signifyd/Api/Data/CaseInterface.php
+++ b/app/code/Magento/Signifyd/Api/Data/CaseInterface.php
@@ -22,6 +22,11 @@ interface CaseInterface
*/
const STATUS_OPEN = 'OPEN';
+ /**
+ * Pending status
+ */
+ const STATUS_PENDING = 'PENDING';
+
/**
* Processing status
*/
diff --git a/app/code/Magento/Signifyd/Api/Data/CaseSearchResultsInterface.php b/app/code/Magento/Signifyd/Api/Data/CaseSearchResultsInterface.php
new file mode 100644
index 0000000000000..6113411a73e01
--- /dev/null
+++ b/app/code/Magento/Signifyd/Api/Data/CaseSearchResultsInterface.php
@@ -0,0 +1,31 @@
+_init(ResourceModel\CaseEntity::class);
+ }
+
/**
* @inheritdoc
*/
diff --git a/app/code/Magento/Signifyd/Model/CaseManagement.php b/app/code/Magento/Signifyd/Model/CaseManagement.php
index 9269d8622dfab..3e31e0af1d883 100644
--- a/app/code/Magento/Signifyd/Model/CaseManagement.php
+++ b/app/code/Magento/Signifyd/Model/CaseManagement.php
@@ -5,6 +5,8 @@
*/
namespace Magento\Signifyd\Model;
+use Magento\Framework\Api\FilterBuilder;
+use Magento\Framework\Api\SearchCriteriaBuilder;
use Magento\Signifyd\Api\CaseManagementInterface;
use Magento\Signifyd\Api\CaseRepositoryInterface;
use Magento\Signifyd\Api\Data\CaseInterface;
@@ -25,15 +27,33 @@ class CaseManagement implements CaseManagementInterface
*/
private $caseFactory;
+ /**
+ * @var FilterBuilder
+ */
+ private $filterBuilder;
+
+ /**
+ * @var SearchCriteriaBuilder
+ */
+ private $searchCriteriaBuilder;
+
/**
* CaseManagement constructor.
* @param CaseRepositoryInterface $caseRepository
* @param CaseInterfaceFactory $caseFactory
+ * @param FilterBuilder $filterBuilder
+ * @param SearchCriteriaBuilder $searchCriteriaBuilder
*/
- public function __construct(CaseRepositoryInterface $caseRepository, CaseInterfaceFactory $caseFactory)
- {
+ public function __construct(
+ CaseRepositoryInterface $caseRepository,
+ CaseInterfaceFactory $caseFactory,
+ FilterBuilder $filterBuilder,
+ SearchCriteriaBuilder $searchCriteriaBuilder
+ ) {
$this->caseRepository = $caseRepository;
$this->caseFactory = $caseFactory;
+ $this->searchCriteriaBuilder = $searchCriteriaBuilder;
+ $this->filterBuilder = $filterBuilder;
}
/**
@@ -41,9 +61,9 @@ public function __construct(CaseRepositoryInterface $caseRepository, CaseInterfa
*/
public function create($orderId)
{
- $case = $this->caseFactory->create(
- ['data' => ['order_id' => $orderId, 'status' => CaseInterface::STATUS_PROCESSING]]
- );
+ $case = $this->caseFactory->create();
+ $case->setOrderId($orderId)
+ ->setStatus(CaseInterface::STATUS_PENDING);
return $this->caseRepository->save($case);
}
@@ -52,6 +72,13 @@ public function create($orderId)
*/
public function getByOrderId($orderId)
{
- return $this->caseRepository->getById($orderId);
+ $filters = [
+ $this->filterBuilder->setField('order_id')
+ ->setValue($orderId)
+ ->create()
+ ];
+ $searchCriteria = $this->searchCriteriaBuilder->addFilters($filters)->create();
+ $items = $this->caseRepository->getList($searchCriteria)->getItems();
+ return !empty($items) ? array_pop($items) : null;
}
}
diff --git a/app/code/Magento/Signifyd/Model/CaseRepository.php b/app/code/Magento/Signifyd/Model/CaseRepository.php
index 916cbe6136817..e9e326a459dd5 100644
--- a/app/code/Magento/Signifyd/Model/CaseRepository.php
+++ b/app/code/Magento/Signifyd/Model/CaseRepository.php
@@ -6,10 +6,15 @@
namespace Magento\Signifyd\Model;
use Magento\Framework\Api\SearchCriteria;
-use Magento\Framework\EntityManager\EntityManager;
+use Magento\Framework\Api\SearchCriteria\CollectionProcessorInterface;
use Magento\Signifyd\Api\CaseRepositoryInterface;
use Magento\Signifyd\Api\Data\CaseInterface;
use Magento\Signifyd\Api\Data\CaseInterfaceFactory;
+use Magento\Signifyd\Api\Data\CaseSearchResultsInterface;
+use Magento\Signifyd\Api\Data\CaseSearchResultsInterfaceFactory;
+use Magento\Signifyd\Model\ResourceModel\CaseEntity as CaseResourceModel;
+use Magento\Signifyd\Model\ResourceModel\CaseEntity\Collection;
+use Magento\Signifyd\Model\ResourceModel\CaseEntity\CollectionFactory;
/**
* Repository for Case interface
@@ -17,24 +22,50 @@
class CaseRepository implements CaseRepositoryInterface
{
/**
- * @var EntityManager
+ * @var CollectionProcessorInterface
*/
- private $entityManager;
+ private $collectionProcessor;
+
+ /**
+ * @var CollectionFactory
+ */
+ private $collectionFactory;
+
+ /**
+ * @var CaseSearchResultsInterfaceFactory
+ */
+ private $searchResultsFactory;
/**
* @var CaseInterfaceFactory
*/
private $caseFactory;
+ /**
+ * @var CaseResourceModel
+ */
+ private $resourceModel;
+
/**
* CaseRepository constructor.
- * @param EntityManager $entityManager
+ * @param CollectionProcessorInterface $collectionProcessor
+ * @param CollectionFactory $collectionFactory
+ * @param CaseSearchResultsInterfaceFactory $searchResultsFactory
* @param CaseInterfaceFactory $caseFactory
+ * @param CaseResourceModel $resourceModel
*/
- public function __construct(EntityManager $entityManager, CaseInterfaceFactory $caseFactory)
- {
- $this->entityManager = $entityManager;
+ public function __construct(
+ CollectionProcessorInterface $collectionProcessor,
+ CollectionFactory $collectionFactory,
+ CaseSearchResultsInterfaceFactory $searchResultsFactory,
+ CaseInterfaceFactory $caseFactory,
+ CaseResourceModel $resourceModel
+ ) {
+ $this->collectionProcessor = $collectionProcessor;
+ $this->collectionFactory = $collectionFactory;
+ $this->searchResultsFactory = $searchResultsFactory;
$this->caseFactory = $caseFactory;
+ $this->resourceModel = $resourceModel;
}
/**
@@ -42,15 +73,47 @@ public function __construct(EntityManager $entityManager, CaseInterfaceFactory $
*/
public function save(CaseInterface $case)
{
- return $this->entityManager->save($case);
+ /** @var CaseEntity $case */
+ $this->resourceModel->save($case);
+ return $case;
}
/**
* @inheritdoc
*/
- public function getById($orderId)
+ public function getById($id)
{
+ /** @var CaseEntity $case */
$case = $this->caseFactory->create();
- return $this->entityManager->load($case, $orderId);
+ $this->resourceModel->load($case, $id);
+ return $case;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function delete(CaseInterface $case)
+ {
+ $this->resourceModel->delete($case);
+ return true;
+ }
+
+ /**
+ * Gets list of case entities
+ * @param SearchCriteria $searchCriteria
+ * @return CaseSearchResultsInterface
+ */
+ public function getList(SearchCriteria $searchCriteria)
+ {
+ /** @var Collection $collection */
+ $collection = $this->collectionFactory->create();
+ $this->collectionProcessor->process($searchCriteria, $collection);
+
+ /** @var CaseSearchResultsInterface $searchResults */
+ $searchResults = $this->searchResultsFactory->create();
+ $searchResults->setSearchCriteria($searchCriteria);
+ $searchResults->setItems($collection->getItems());
+
+ return $searchResults;
}
}
diff --git a/app/code/Magento/Signifyd/Model/ResourceModel/CaseEntity.php b/app/code/Magento/Signifyd/Model/ResourceModel/CaseEntity.php
new file mode 100644
index 0000000000000..c86f97812900d
--- /dev/null
+++ b/app/code/Magento/Signifyd/Model/ResourceModel/CaseEntity.php
@@ -0,0 +1,22 @@
+_init('signifyd_case', 'entity_id');
+ }
+}
diff --git a/app/code/Magento/Signifyd/Model/ResourceModel/CaseEntity/Collection.php b/app/code/Magento/Signifyd/Model/ResourceModel/CaseEntity/Collection.php
new file mode 100644
index 0000000000000..d8e999516a294
--- /dev/null
+++ b/app/code/Magento/Signifyd/Model/ResourceModel/CaseEntity/Collection.php
@@ -0,0 +1,24 @@
+_init(CaseEntity::class, CaseResourceModel::class);
+ }
+}
diff --git a/app/code/Magento/Signifyd/Setup/InstallSchema.php b/app/code/Magento/Signifyd/Setup/InstallSchema.php
index c12399e669394..dfd9a7cfcab19 100644
--- a/app/code/Magento/Signifyd/Setup/InstallSchema.php
+++ b/app/code/Magento/Signifyd/Setup/InstallSchema.php
@@ -41,7 +41,7 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
$table->addColumn('case_id', Table::TYPE_INTEGER, null, ['unsigned' => true]);
$table->addColumn('guarantee_eligible', Table::TYPE_BOOLEAN, null);
$table->addColumn('guarantee_disposition', Table::TYPE_TEXT, 32);
- $table->addColumn('status', Table::TYPE_TEXT, 32, ['default' => CaseInterface::STATUS_PROCESSING]);
+ $table->addColumn('status', Table::TYPE_TEXT, 32, ['default' => CaseInterface::STATUS_PENDING]);
$table->addColumn('score', Table::TYPE_INTEGER, null, ['unsigned' => true]);
$table->addColumn('associated_team', Table::TYPE_INTEGER, null, ['unsigned' => true]);
$table->addColumn('review_disposition', Table::TYPE_TEXT, 32);
diff --git a/app/code/Magento/Signifyd/etc/di.xml b/app/code/Magento/Signifyd/etc/di.xml
index 3abcaad08a639..6b49c74337868 100644
--- a/app/code/Magento/Signifyd/etc/di.xml
+++ b/app/code/Magento/Signifyd/etc/di.xml
@@ -9,31 +9,5 @@
-
-
-
-
-
- -
-
- Magento\Framework\EntityManager\Operation\Read
- - Magento\Framework\EntityManager\Operation\Create
- - Magento\Framework\EntityManager\Operation\Update
-
-
-
-
-
-
-
-
-
-
- -
-
- signifyd_case
- - order_id
-
-
-
-
-
+
\ No newline at end of file
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseManagementTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseManagementTest.php
index c81a18a8afc99..fe85408204dfd 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseManagementTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseManagementTest.php
@@ -45,7 +45,7 @@ public function testCreate()
$case = $this->caseManagement->create($order->getEntityId());
static::assertNotEmpty($case->getEntityId());
- static::assertEquals(CaseInterface::STATUS_PROCESSING, $case->getStatus());
+ static::assertEquals(CaseInterface::STATUS_PENDING, $case->getStatus());
}
/**
From b632d5fdf3139a0e17e051723ffff38e90ca897e Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Tue, 13 Dec 2016 06:28:08 -0600
Subject: [PATCH 016/904] MAGETWO-61913: Create request builders
- Update builders
---
.../Signifyd/Model/Request/CardBuilder.php | 12 +++--
.../Model/Request/ClientVersionBuilder.php | 8 +--
.../Model/Request/CreateCaseBuilder.php | 40 ++++++++++++---
.../Model/Request/PurchaseBuilder.php | 49 ++++---------------
.../Model/Request/RecipientBuilder.php | 12 +++--
.../Signifyd/Model/Request/SellerBuilder.php | 39 +++++++++++++--
.../Model/Request/UserAccountBuilder.php | 19 ++++---
7 files changed, 107 insertions(+), 72 deletions(-)
diff --git a/app/code/Magento/Signifyd/Model/Request/CardBuilder.php b/app/code/Magento/Signifyd/Model/Request/CardBuilder.php
index ec3e08f428b50..2c931924d9c2a 100644
--- a/app/code/Magento/Signifyd/Model/Request/CardBuilder.php
+++ b/app/code/Magento/Signifyd/Model/Request/CardBuilder.php
@@ -42,11 +42,13 @@ public function build(Order $order)
$payment = $order->getPayment();
$result = [
- 'cardHolderName' => $address->getFirstname() . ' ' . $address->getLastname(),
- 'last4' => $payment->getCcLast4(),
- 'expiryMonth' => $payment->getCcExpMonth(),
- 'expiryYear' => $payment->getCcExpYear(),
- 'billingAddress' => $this->addressBuilder->build($address),
+ 'card' => [
+ 'cardHolderName' => $address->getFirstname() . ' ' . $address->getLastname(),
+ 'last4' => $payment->getCcLast4(),
+ 'expiryMonth' => $payment->getCcExpMonth(),
+ 'expiryYear' => $payment->getCcExpYear(),
+ 'billingAddress' => $this->addressBuilder->build($address)
+ ]
];
return $result;
diff --git a/app/code/Magento/Signifyd/Model/Request/ClientVersionBuilder.php b/app/code/Magento/Signifyd/Model/Request/ClientVersionBuilder.php
index 4c8f4e843163a..25ee03da20dc1 100644
--- a/app/code/Magento/Signifyd/Model/Request/ClientVersionBuilder.php
+++ b/app/code/Magento/Signifyd/Model/Request/ClientVersionBuilder.php
@@ -5,7 +5,7 @@
*/
namespace Magento\Signifyd\Model\Request;
-use Magento\Framework\App\ProductMetadata;
+use Magento\Framework\App\ProductMetadataInterface;
/**
* Class ClientVersionBuilder
@@ -13,15 +13,15 @@
class ClientVersionBuilder
{
/**
- * @var ProductMetadata
+ * @var ProductMetadataInterface
*/
private $productMetadata;
/**
- * @param ProductMetadata $productMetadata
+ * @param ProductMetadataInterface $productMetadata
*/
public function __construct(
- ProductMetadata $productMetadata
+ ProductMetadataInterface $productMetadata
) {
$this->productMetadata = $productMetadata;
}
diff --git a/app/code/Magento/Signifyd/Model/Request/CreateCaseBuilder.php b/app/code/Magento/Signifyd/Model/Request/CreateCaseBuilder.php
index 926c5354af57a..5abaeffc01b01 100644
--- a/app/code/Magento/Signifyd/Model/Request/CreateCaseBuilder.php
+++ b/app/code/Magento/Signifyd/Model/Request/CreateCaseBuilder.php
@@ -83,13 +83,39 @@ public function build($orderId)
/* @var $order \Magento\Sales\Model\Order */
$order = $this->orderFactory->create()->load($orderId);
- return array_merge(
- $this->purchaseBuilder->build($order),
- $this->cardBuilder->build($order),
- $this->recipientBuilder->build($order),
- $this->userAccountBuilder->build($order),
- $this->sellerBuilder->build($order),
- $this->clientVersionBuilder->build()
+ return $this->removeEmptyValues(
+ array_merge(
+ $this->purchaseBuilder->build($order),
+ $this->cardBuilder->build($order),
+ $this->recipientBuilder->build($order),
+ $this->userAccountBuilder->build($order),
+ $this->sellerBuilder->build($order),
+ $this->clientVersionBuilder->build()
+ )
);
}
+
+ /**
+ * Remove empty and null values
+ *
+ * @param array $data
+ * @return array
+ */
+ private function removeEmptyValues($data)
+ {
+ foreach ($data as $key => $value) {
+ if (is_array($value)) {
+ $data[$key] = $this->removeEmptyValues($data[$key]);
+ }
+
+ if ($data[$key] === null ||
+ $data[$key] === '' ||
+ (is_array($data[$key]) && empty($data[$key]))
+ ) {
+ unset($data[$key]);
+ }
+ }
+
+ return $data;
+ }
}
diff --git a/app/code/Magento/Signifyd/Model/Request/PurchaseBuilder.php b/app/code/Magento/Signifyd/Model/Request/PurchaseBuilder.php
index 215c5f39a172d..f64bf75c30e14 100644
--- a/app/code/Magento/Signifyd/Model/Request/PurchaseBuilder.php
+++ b/app/code/Magento/Signifyd/Model/Request/PurchaseBuilder.php
@@ -63,9 +63,15 @@ public function build(Order $order)
],
];
- $shipments = $this->getShipments($order);
- if (!empty($shipments)) {
- $result['purchase']['shipments'] = $shipments;
+ $shippingDescription = $order->getShippingDescription();
+ if ($shippingDescription !== null) {
+ $result['purchase']['shipments'] = [
+ [
+ 'shipper' => $this->getShipper($order->getShippingDescription()),
+ 'shippingMethod' => $this->getShippingMethod($order->getShippingDescription()),
+ 'shippingPrice' => $order->getShippingAmount()
+ ]
+ ];
}
$products = $this->getProducts($order);
@@ -99,43 +105,6 @@ private function getProducts(Order $order)
return $result;
}
- /**
- * Gets the shipments associated with this purchase.
- *
- * @param Order $order
- * @return array
- */
- private function getShipments(Order $order)
- {
- $result = [];
- $shipper = $this->getShipper($order->getShippingDescription());
- $shippingMethod = $this->getShippingMethod($order->getShippingDescription());
-
- $shipmentList = $order->getShipmentsCollection();
- /** @var \Magento\Sales\Api\Data\ShipmentInterface $shipment */
- foreach ($shipmentList as $shipment) {
- $totalPrice = 0;
- foreach ($shipment->getItems() as $shipmentItem) {
- $totalPrice += $shipmentItem->getPrice();
- }
-
- $item = [
- 'shipper' => $shipper,
- 'shippingMethod' => $shippingMethod,
- 'shippingPrice' => $totalPrice
- ];
-
- $tracks = $shipment->getTracks();
- if (!empty($tracks)) {
- $item['trackingNumber'] = end($tracks)->getTrackNumber();
- }
-
- $result[] = $item;
- }
-
- return $result;
- }
-
/**
* Gets the name of the shipper
*
diff --git a/app/code/Magento/Signifyd/Model/Request/RecipientBuilder.php b/app/code/Magento/Signifyd/Model/Request/RecipientBuilder.php
index 38cb79d32de2b..510276d1cc75c 100644
--- a/app/code/Magento/Signifyd/Model/Request/RecipientBuilder.php
+++ b/app/code/Magento/Signifyd/Model/Request/RecipientBuilder.php
@@ -41,11 +41,13 @@ public function build(Order $order)
}
$result = [
- 'fullName' => $address->getName(),
- 'confirmationEmail' => $address->getEmail(),
- 'confirmationPhone' => $address->getTelephone(),
- 'organization' => $address->getCompany(),
- 'deliveryAddress' => $this->addressBuilder->build($address)
+ 'recipient' => [
+ 'fullName' => $address->getName(),
+ 'confirmationEmail' => $address->getEmail(),
+ 'confirmationPhone' => $address->getTelephone(),
+ 'organization' => $address->getCompany(),
+ 'deliveryAddress' => $this->addressBuilder->build($address)
+ ]
];
return $result;
diff --git a/app/code/Magento/Signifyd/Model/Request/SellerBuilder.php b/app/code/Magento/Signifyd/Model/Request/SellerBuilder.php
index 62977c6d81e51..21b319421d57c 100644
--- a/app/code/Magento/Signifyd/Model/Request/SellerBuilder.php
+++ b/app/code/Magento/Signifyd/Model/Request/SellerBuilder.php
@@ -5,6 +5,7 @@
*/
namespace Magento\Signifyd\Model\Request;
+use Magento\Directory\Model\RegionFactory;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Sales\Model\Order;
use Magento\Sales\Model\Order\Shipment;
@@ -24,13 +25,26 @@ class SellerBuilder
*/
private $scopeConfig;
+ /**
+ * @var RegionFactory
+ */
+ private $regionFactory;
+
+ /**
+ * @var array
+ */
+ private $regionCodes = [];
+
/**
* @param ScopeConfigInterface $scopeConfig
+ * @param RegionFactory $regionFactory
*/
public function __construct(
- ScopeConfigInterface $scopeConfig
+ ScopeConfigInterface $scopeConfig,
+ RegionFactory $regionFactory
) {
$this->scopeConfig = $scopeConfig;
+ $this->regionFactory = $regionFactory;
}
/**
@@ -51,7 +65,9 @@ public function build(Order $order)
'streetAddress' => $this->getConfigValue(Shipment::XML_PATH_STORE_ADDRESS1, $store),
'unit' => $this->getConfigValue(Shipment::XML_PATH_STORE_ADDRESS2, $store),
'city' => $this->getConfigValue(Shipment::XML_PATH_STORE_CITY, $store),
- 'provinceCode' => $this->getConfigValue(Shipment::XML_PATH_STORE_REGION_ID, $store),
+ 'provinceCode' => $this->getRegionCodeById(
+ $this->getConfigValue(Shipment::XML_PATH_STORE_REGION_ID, $store)
+ ),
'postalCode' => $this->getConfigValue(Shipment::XML_PATH_STORE_ZIP, $store),
'countryCode' => $this->getConfigValue(Shipment::XML_PATH_STORE_COUNTRY_ID, $store),
],
@@ -59,7 +75,9 @@ public function build(Order $order)
'streetAddress' => $this->getConfigValue(Information::XML_PATH_STORE_INFO_STREET_LINE1, $store),
'unit' => $this->getConfigValue(Information::XML_PATH_STORE_INFO_STREET_LINE2, $store),
'city' => $this->getConfigValue(Information::XML_PATH_STORE_INFO_CITY, $store),
- 'provinceCode' => $this->getConfigValue(Information::XML_PATH_STORE_INFO_REGION_CODE, $store),
+ 'provinceCode' => $this->getRegionCodeById(
+ $this->getConfigValue(Information::XML_PATH_STORE_INFO_REGION_CODE, $store)
+ ),
'postalCode' => $this->getConfigValue(Information::XML_PATH_STORE_INFO_POSTCODE, $store),
'countryCode' => $this->getConfigValue(Information::XML_PATH_STORE_INFO_COUNTRY_CODE, $store),
]
@@ -67,6 +85,21 @@ public function build(Order $order)
];
}
+ /**
+ * Get region code by id
+ *
+ * @param int $regionId
+ * @return string
+ */
+ private function getRegionCodeById($regionId)
+ {
+ if (!isset($this->regionCodes[$regionId])) {
+ $this->regionCodes[$regionId] = $this->regionFactory->create()->load($regionId)->getCode();
+ }
+
+ return $this->regionCodes[$regionId];
+ }
+
/**
* Gets value from config
*
diff --git a/app/code/Magento/Signifyd/Model/Request/UserAccountBuilder.php b/app/code/Magento/Signifyd/Model/Request/UserAccountBuilder.php
index 198b57d3e238e..c3296984be6b5 100644
--- a/app/code/Magento/Signifyd/Model/Request/UserAccountBuilder.php
+++ b/app/code/Magento/Signifyd/Model/Request/UserAccountBuilder.php
@@ -36,6 +36,7 @@ class UserAccountBuilder
* @var array
*/
private $currencies = [];
+
/**
* @var CustomerOrders
*/
@@ -85,12 +86,14 @@ public function build(Order $order)
$customer = $this->customerRepository->getById($customerId);
$result = [
- 'email' => $customer->getEmail(),
- 'username' => $customer->getEmail(),
- 'phone' => $order->getBillingAddress()->getTelephone(),
- 'accountNumber' => $customerId,
- 'createdDate' => $this->formatDate($customer->getCreatedAt()),
- 'lastUpdateDate' => $this->formatDate($customer->getUpdatedAt())
+ 'userAccount' => [
+ 'email' => $customer->getEmail(),
+ 'username' => $customer->getEmail(),
+ 'phone' => $order->getBillingAddress()->getTelephone(),
+ 'accountNumber' => $customerId,
+ 'createdDate' => $this->formatDate($customer->getCreatedAt()),
+ 'lastUpdateDate' => $this->formatDate($customer->getUpdatedAt())
+ ]
];
$customerOrders = $this->customerOrders->get($customerId);
@@ -103,8 +106,8 @@ public function build(Order $order)
$order->getBaseCurrencyCode()
);
}
- $result['aggregateOrderCount'] = count($customerOrders);
- $result['aggregateOrderDollars'] = $orderTotalDollars;
+ $result['userAccount']['aggregateOrderCount'] = count($customerOrders);
+ $result['userAccount']['aggregateOrderDollars'] = $orderTotalDollars;
} catch (\Exception $e) {
$this->logger->error($e->getMessage());
}
From 8746dcbb75d4469a6234364ea6e5a717a15ac822 Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Tue, 13 Dec 2016 06:34:30 -0600
Subject: [PATCH 017/904] MAGETWO-61925: Create case entity infrastructure
- Fixed failed static test
---
app/code/Magento/Signifyd/Model/CaseEntity.php | 7 ++-----
app/code/Magento/Signifyd/Model/CaseRepository.php | 2 ++
2 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/app/code/Magento/Signifyd/Model/CaseEntity.php b/app/code/Magento/Signifyd/Model/CaseEntity.php
index b3a7b05ac217a..85783da3308da 100644
--- a/app/code/Magento/Signifyd/Model/CaseEntity.php
+++ b/app/code/Magento/Signifyd/Model/CaseEntity.php
@@ -197,8 +197,7 @@ public function setCreatedAt($datetime)
}
/**
- * Gets updating datetime for a case
- * @return string
+ * @inheritdoc
*/
public function getUpdatedAt()
{
@@ -206,9 +205,7 @@ public function getUpdatedAt()
}
/**
- * Sets updating datetime for a case
- * @param $datetime
- * @return $this
+ * @inheritdoc
*/
public function setUpdatedAt($datetime)
{
diff --git a/app/code/Magento/Signifyd/Model/CaseRepository.php b/app/code/Magento/Signifyd/Model/CaseRepository.php
index e9e326a459dd5..723dea8421167 100644
--- a/app/code/Magento/Signifyd/Model/CaseRepository.php
+++ b/app/code/Magento/Signifyd/Model/CaseRepository.php
@@ -18,6 +18,8 @@
/**
* Repository for Case interface
+ *
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class CaseRepository implements CaseRepositoryInterface
{
From 5bb77275376c21eab05ba136936409acc98a3964 Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Tue, 13 Dec 2016 07:51:03 -0600
Subject: [PATCH 018/904] MAGETWO-61913: Create request builders
- Replace ISO8601 with ATOM
---
app/code/Magento/Signifyd/Model/Request/PurchaseBuilder.php | 2 +-
app/code/Magento/Signifyd/Model/Request/UserAccountBuilder.php | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/app/code/Magento/Signifyd/Model/Request/PurchaseBuilder.php b/app/code/Magento/Signifyd/Model/Request/PurchaseBuilder.php
index f64bf75c30e14..16de64b869cd1 100644
--- a/app/code/Magento/Signifyd/Model/Request/PurchaseBuilder.php
+++ b/app/code/Magento/Signifyd/Model/Request/PurchaseBuilder.php
@@ -54,7 +54,7 @@ public function build(Order $order)
'purchase' => [
'browserIpAddress' => $order->getRemoteIp(),
'orderId' => $order->getEntityId(),
- 'createdAt' => $createdAt->format(\DateTime::ISO8601),
+ 'createdAt' => $createdAt->format(\DateTime::ATOM),
'paymentGateway' => $this->getPaymentGateway($orderPayment->getMethod()),
'transactionId' => $orderPayment->getLastTransId(),
'currency' => $order->getOrderCurrencyCode(),
diff --git a/app/code/Magento/Signifyd/Model/Request/UserAccountBuilder.php b/app/code/Magento/Signifyd/Model/Request/UserAccountBuilder.php
index c3296984be6b5..6cb33697488f6 100644
--- a/app/code/Magento/Signifyd/Model/Request/UserAccountBuilder.php
+++ b/app/code/Magento/Signifyd/Model/Request/UserAccountBuilder.php
@@ -166,6 +166,6 @@ private function formatDate($date)
new \DateTimeZone('UTC')
);
- return $result->format(\DateTime::ISO8601);
+ return $result->format(\DateTime::ATOM);
}
}
From bec36977b6a254b343827b2d5f838323c3466373 Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Tue, 13 Dec 2016 07:59:27 -0600
Subject: [PATCH 019/904] MAGETWO-61913: Create request builders
- integration tests
---
.../Model/Request/CreateCaseBuilderTest.php | 108 ++++++++++++++++++
.../Magento/Signifyd/_files/order.php | 77 +++++++++++++
2 files changed, 185 insertions(+)
create mode 100644 dev/tests/integration/testsuite/Magento/Signifyd/Model/Request/CreateCaseBuilderTest.php
create mode 100644 dev/tests/integration/testsuite/Magento/Signifyd/_files/order.php
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Model/Request/CreateCaseBuilderTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Model/Request/CreateCaseBuilderTest.php
new file mode 100644
index 0000000000000..bda6802572507
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/Request/CreateCaseBuilderTest.php
@@ -0,0 +1,108 @@
+loadArea(Area::AREA_FRONTEND);
+ $this->objectManager = Bootstrap::getObjectManager();
+
+ $this->order = $this->objectManager->create(Order::class);
+ $this->order->loadByIncrementId(self::ORDER_INCREMENT_ID);
+
+ $this->caseBuilder = $this->objectManager->create(CreateCaseBuilder::class);
+ $this->builderData = $this->caseBuilder->build($this->order->getEntityId());
+ }
+
+ /**
+ * Check the stability purchaseBuilder
+ *
+ * @magentoDataFixture Magento/Signifyd/_files/order.php
+ */
+ public function testPurchaseBuilder()
+ {
+ $orderMethod = 'paypal_account';
+ $orderChannel = 'WEB';
+ $shippingProvider = 'Flat Rate';
+ $shippingMethod = 'Fixed';
+
+ $purchaseData = $this->builderData['purchase'];
+
+ $dateTimeFactory = $this->objectManager->get(DateTimeFactory::class);
+ $createdAt = $dateTimeFactory->create(
+ $this->order->getCreatedAt(),
+ new \DateTimeZone('UTC')
+ );
+
+ $orderPayment = $this->order->getPayment();
+
+ $orderItems = $this->order->getAllItems();
+ $product = $orderItems[0]->getProduct();
+ $purchaseProducts = $purchaseData['products'][0];
+
+ static::assertEquals($this->order->getRemoteIp(), $purchaseData['browserIpAddress']);
+ static::assertEquals($shippingProvider, $purchaseData['shipments'][0]['shipper']);
+ static::assertEquals($shippingMethod, $purchaseData['shipments'][0]['shippingMethod']);
+ //static::assertEquals($this->order->getShippingAmount(), $purchaseData['shipments'][0]['shippingPrice']);
+ static::assertEquals($this->order->getEntityId(), $purchaseData['orderId']);
+ static::assertEquals($createdAt->format(\DateTime::ISO8601), $purchaseData['createdAt']);
+
+ static::assertEquals($orderMethod, $purchaseData['paymentGateway']);
+ static::assertEquals($orderPayment->getLastTransId(), $purchaseData['transactionId']);
+ static::assertEquals($this->order->getOrderCurrencyCode(), $purchaseData['currency']);
+ static::assertEquals($orderChannel, $purchaseData['orderChannel']);
+ static::assertEquals($this->order->getGrandTotal(), $purchaseData['totalPrice']);
+
+ //static::assertEquals($product->getSku(), $purchaseProducts['itemId']);
+ //static::assertEquals($product->getName(), $purchaseProducts['itemName']);
+ static::assertEquals($orderItems[0]->getPrice(), $purchaseProducts['itemPrice']);
+ static::assertEquals($orderItems[0]->getQtyOrdered(), $purchaseProducts['itemQuantity']);
+ static::assertEquals($product->getProductUrl(), $purchaseProducts['itemUrl']);
+ static::assertEquals($product->getWeight(), $purchaseProducts['itemWeight']);
+ }
+}
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/_files/order.php b/dev/tests/integration/testsuite/Magento/Signifyd/_files/order.php
new file mode 100644
index 0000000000000..762c952b36743
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/_files/order.php
@@ -0,0 +1,77 @@
+create(Address::class, ['data' => $addressData]);
+$billingAddress->setAddressType('billing');
+
+$shippingAddress = clone $billingAddress;
+$shippingAddress->setid(null)
+ ->setAddressType('shipping')
+ ->setShippingMethod('flatrate_flatrate');
+
+$payment = $objectManager->create(Payment::class);
+$payment->setMethod(PaypalConfig::METHOD_WPP_EXPRESS);
+
+/** @var Item $orderItem */
+$orderItem = $objectManager->create(Item::class);
+$orderItem->setProductId($product->getId())
+ ->setQtyOrdered(1)
+ ->setBasePrice($product->getPrice())
+ ->setPrice($product->getPrice())
+ ->setRowTotal($product->getPrice())
+ ->setProductType($product->getTypeId());
+
+$orderAmount = 100;
+$customerEmail = $billingAddress->getEmail();
+
+/** @var Order $order */
+$order = $objectManager->create(Order::class);
+$order->setIncrementId('100000001')
+ ->setState(Order::STATE_PROCESSING)
+ ->setStatus(Order::STATE_PROCESSING)
+ ->setCreatedAt('2016-12-12T12:00:55+0000')
+ ->setBaseGrandTotal($orderAmount)
+ ->setSubtotal($orderAmount)
+ ->setGrandTotal($orderAmount)
+ ->setBaseSubtotal($orderAmount)
+ ->setBaseGrandTotal($orderAmount)
+ ->setCustomerIsGuest(true)
+ ->setCustomerEmail($customerEmail)
+ ->setBillingAddress($billingAddress)
+ ->setShippingAddress($shippingAddress)
+ ->setShippingDescription('Flat Rate - Fixed')
+ ->setShippingAmount(10)
+ ->setStoreId($objectManager->get(StoreManagerInterface::class)->getStore()->getId())
+ ->addItem($orderItem)
+ ->setPayment($payment);
+
+/** @var OrderRepositoryInterface $orderRepository */
+$orderRepository = $objectManager->get(OrderRepositoryInterface::class);
+$orderRepository->save($order);
+
+$shipmentItem = $objectManager->create(\Magento\Sales\Model\Order\Shipment\Item::class);
+$shipmentItem->setOrderItem($orderItem);
+
+/** @var \Magento\Sales\Model\Order\Shipment $shipment */
+$shipment = $objectManager->create(\Magento\Sales\Model\Order\Shipment::class);
+$shipment->setOrder($order)
+ ->addItem($shipmentItem)
+ ->setShipmentStatus(\Magento\Sales\Model\Order\Shipment::STATUS_NEW)
+ ->save();
From adfe3918834fd4b566697c3c6b0188b6813eb6fd Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Tue, 13 Dec 2016 08:17:07 -0600
Subject: [PATCH 020/904] MAGETWO-61913: Create request builders
- Declare Store dependency
---
app/code/Magento/Signifyd/composer.json | 2 +-
app/code/Magento/Signifyd/etc/module.xml | 1 +
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/app/code/Magento/Signifyd/composer.json b/app/code/Magento/Signifyd/composer.json
index cc8bd9d228508..69a42f2aa3336 100644
--- a/app/code/Magento/Signifyd/composer.json
+++ b/app/code/Magento/Signifyd/composer.json
@@ -5,7 +5,7 @@
"php": "~5.6.5|7.0.2|7.0.4|~7.0.6",
"magento/framework": "100.2.*",
"magento/module-sales": "100.2.*",
- "magento/module-checkout": "100.2.*"
+ "magento/module-store": "100.2.*"
},
"type": "magento2-module",
"version": "100.2.0-dev",
diff --git a/app/code/Magento/Signifyd/etc/module.xml b/app/code/Magento/Signifyd/etc/module.xml
index 1ee26044bbef4..aa2d26414b484 100644
--- a/app/code/Magento/Signifyd/etc/module.xml
+++ b/app/code/Magento/Signifyd/etc/module.xml
@@ -9,6 +9,7 @@
+
From e68affec3721065c6df0876312752c238c2c2082 Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Tue, 13 Dec 2016 09:44:34 -0600
Subject: [PATCH 021/904] MAGETWO-61925: Create case entity infrastructure
- Updated interface annotation
- Added integration test for case repository
---
.../Signifyd/Api/CaseManagementInterface.php | 2 +-
.../Signifyd/Model/CaseRepositoryTest.php | 148 ++++++++++++++++++
.../Signifyd/_files/multiple_cases.php | 27 ++++
3 files changed, 176 insertions(+), 1 deletion(-)
create mode 100644 dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseRepositoryTest.php
create mode 100644 dev/tests/integration/testsuite/Magento/Signifyd/_files/multiple_cases.php
diff --git a/app/code/Magento/Signifyd/Api/CaseManagementInterface.php b/app/code/Magento/Signifyd/Api/CaseManagementInterface.php
index c4d6005011b93..cced6d2e4afe3 100644
--- a/app/code/Magento/Signifyd/Api/CaseManagementInterface.php
+++ b/app/code/Magento/Signifyd/Api/CaseManagementInterface.php
@@ -18,7 +18,7 @@ interface CaseManagementInterface
/**
* Creates new Case entity
* @param string $orderId
- * @return void
+ * @return CaseInterface
*/
public function create($orderId);
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseRepositoryTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseRepositoryTest.php
new file mode 100644
index 0000000000000..05a2eb443b248
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseRepositoryTest.php
@@ -0,0 +1,148 @@
+objectManager = Bootstrap::getObjectManager();
+ $this->filterBuilder = $this->objectManager->get(FilterBuilder::class);
+ $this->searchCriteriaBuilder = $this->objectManager->get(SearchCriteriaBuilder::class);
+ $this->repository = $this->objectManager->get(CaseRepository::class);
+ }
+
+ /**
+ * @covers \Magento\Signifyd\Model\CaseRepository::delete
+ * @magentoDataFixture Magento/Signifyd/_files/case.php
+ */
+ public function testDelete()
+ {
+ $filters = [
+ $this->filterBuilder->setField('case_id')
+ ->setValue(123)
+ ->create()
+ ];
+ $searchCriteria = $this->searchCriteriaBuilder->addFilters($filters)->create();
+ $cases = $this->repository->getList($searchCriteria)
+ ->getItems();
+
+ $case = array_pop($cases);
+ $this->repository->delete($case);
+
+ static::assertEmpty($this->repository->getList($searchCriteria)->getItems());
+ }
+
+ /**
+ * @covers \Magento\Signifyd\Model\CaseRepository::getById
+ * @magentoDataFixture Magento/Signifyd/_files/case.php
+ */
+ public function testGetById()
+ {
+ $filters = [
+ $this->filterBuilder->setField('case_id')
+ ->setValue(123)
+ ->create()
+ ];
+ $searchCriteria = $this->searchCriteriaBuilder->addFilters($filters)->create();
+ $cases = $this->repository->getList($searchCriteria)
+ ->getItems();
+
+ $case = array_pop($cases);
+
+ $found = $this->repository->getById($case->getEntityId());
+
+ static::assertNotEmpty($found->getEntityId());
+ static::assertEquals($case->getEntityId(), $found->getEntityId());
+ static::assertEquals($case->getOrderId(), $found->getOrderId());
+ }
+
+ /**
+ * @covers \Magento\Signifyd\Model\CaseRepository::getList
+ * @magentoDataFixture Magento/Signifyd/_files/multiple_cases.php
+ */
+ public function testGetListDateInterval()
+ {
+ $startDateInterval = [
+ $this->filterBuilder->setField('created_at')
+ ->setConditionType('gteq')
+ ->setValue('2016-12-01 00:00:01')
+ ->create()
+ ];
+ $endDateInterval = [
+ $this->filterBuilder->setField('created_at')
+ ->setConditionType('lteq')
+ ->setValue('2016-12-03 23:59:59')
+ ->create()
+ ];
+
+ $this->searchCriteriaBuilder->addFilters($startDateInterval);
+ $searchCriteria = $this->searchCriteriaBuilder->addFilters($endDateInterval)->create();
+ $items = $this->repository->getList($searchCriteria)
+ ->getItems();
+
+ static::assertCount(3, $items);
+
+ for ($i = 1; $i < 4; $i ++) {
+ $current = array_shift($items);
+ static::assertEquals($i, $current->getCaseId());
+ }
+ }
+
+ /**
+ * @covers \Magento\Signifyd\Model\CaseRepository::getList
+ * @magentoDataFixture Magento/Signifyd/_files/multiple_cases.php
+ */
+ public function testGetListStatusProcessing()
+ {
+ $filters = [
+ $this->filterBuilder->setField('status')
+ ->setValue(CaseInterface::STATUS_PROCESSING)
+ ->create()
+ ];
+
+ $searchCriteria = $this->searchCriteriaBuilder->addFilters($filters)->create();
+ $items = $this->repository->getList($searchCriteria)
+ ->getItems();
+
+ static::assertCount(1, $items);
+
+ $case = array_pop($items);
+ static::assertEquals(123, $case->getCaseId());
+ }
+}
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/_files/multiple_cases.php b/dev/tests/integration/testsuite/Magento/Signifyd/_files/multiple_cases.php
new file mode 100644
index 0000000000000..e0c0f61310077
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/_files/multiple_cases.php
@@ -0,0 +1,27 @@
+setEntityId(null)
+ ->setIncrementId($order->getIncrementId() + $i);
+
+ $orderRepository->save($newOrder);
+
+ $newCase = clone $case;
+ $newCase->setEntityId(null)
+ ->setCaseId($i)
+ ->setOrderId($newOrder->getEntityId())
+ ->setStatus(CaseInterface::STATUS_OPEN)
+ ->setCreatedAt('2016-12-0' . $i . 'T15:' . $i . ':17+0000')
+ ->setUpdatedAt('2016-12-12T0' . $i . ':23:16+0000')
+ ->setId(null);
+
+ $caseRepository->save($newCase);
+}
From e4be7f2b00447a03ce11079eb80708ce2e709bce Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Tue, 13 Dec 2016 12:06:39 -0600
Subject: [PATCH 022/904] MAGETWO-61913: Create request builders
- integration test
---
.../Model/Request/CreateCaseBuilderTest.php | 108 ++++++++++++------
.../Magento/Signifyd/_files/customer.php | 38 ++++++
.../Magento/Signifyd/_files/order.php | 29 +++--
3 files changed, 130 insertions(+), 45 deletions(-)
create mode 100644 dev/tests/integration/testsuite/Magento/Signifyd/_files/customer.php
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Model/Request/CreateCaseBuilderTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Model/Request/CreateCaseBuilderTest.php
index bda6802572507..9186b6c6f0932 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Model/Request/CreateCaseBuilderTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/Request/CreateCaseBuilderTest.php
@@ -10,6 +10,7 @@
use Magento\Framework\Intl\DateTimeFactory;
use Magento\Framework\ObjectManagerInterface;
use Magento\Sales\Model\Order;
+use Magento\Customer\Api\CustomerRepositoryInterface;
/**
* Class PurchaseBuilderTest
@@ -66,43 +67,78 @@ protected function setUp()
*/
public function testPurchaseBuilder()
{
- $orderMethod = 'paypal_account';
- $orderChannel = 'WEB';
- $shippingProvider = 'Flat Rate';
- $shippingMethod = 'Fixed';
-
- $purchaseData = $this->builderData['purchase'];
-
- $dateTimeFactory = $this->objectManager->get(DateTimeFactory::class);
- $createdAt = $dateTimeFactory->create(
- $this->order->getCreatedAt(),
- new \DateTimeZone('UTC')
- );
-
- $orderPayment = $this->order->getPayment();
-
$orderItems = $this->order->getAllItems();
$product = $orderItems[0]->getProduct();
- $purchaseProducts = $purchaseData['products'][0];
-
- static::assertEquals($this->order->getRemoteIp(), $purchaseData['browserIpAddress']);
- static::assertEquals($shippingProvider, $purchaseData['shipments'][0]['shipper']);
- static::assertEquals($shippingMethod, $purchaseData['shipments'][0]['shippingMethod']);
- //static::assertEquals($this->order->getShippingAmount(), $purchaseData['shipments'][0]['shippingPrice']);
- static::assertEquals($this->order->getEntityId(), $purchaseData['orderId']);
- static::assertEquals($createdAt->format(\DateTime::ISO8601), $purchaseData['createdAt']);
-
- static::assertEquals($orderMethod, $purchaseData['paymentGateway']);
- static::assertEquals($orderPayment->getLastTransId(), $purchaseData['transactionId']);
- static::assertEquals($this->order->getOrderCurrencyCode(), $purchaseData['currency']);
- static::assertEquals($orderChannel, $purchaseData['orderChannel']);
- static::assertEquals($this->order->getGrandTotal(), $purchaseData['totalPrice']);
-
- //static::assertEquals($product->getSku(), $purchaseProducts['itemId']);
- //static::assertEquals($product->getName(), $purchaseProducts['itemName']);
- static::assertEquals($orderItems[0]->getPrice(), $purchaseProducts['itemPrice']);
- static::assertEquals($orderItems[0]->getQtyOrdered(), $purchaseProducts['itemQuantity']);
- static::assertEquals($product->getProductUrl(), $purchaseProducts['itemUrl']);
- static::assertEquals($product->getWeight(), $purchaseProducts['itemWeight']);
+ $payment = $this->order->getPayment();
+ $billingAddress = $this->order->getBillingAddress();
+ $shippingAddress = $this->order->getShippingAddress();
+
+ $customerRepository = $this->objectManager->create(CustomerRepositoryInterface::class);
+ $customer = $customerRepository->getById(1);
+
+ $expected = [
+ 'purchase' => [
+ 'browserIpAddress' => $this->order->getRemoteIp(),
+ 'orderId' => $this->order->getEntityId(),
+ 'createdAt' => '2016-12-12T12:00:55+00:00',
+ 'paymentGateway' => 'paypal_account',
+ 'transactionId' => $payment->getLastTransId(),
+ 'currency' => $this->order->getOrderCurrencyCode(),
+ 'orderChannel' => 'WEB',
+ 'totalPrice' => $this->order->getGrandTotal(),
+ 'shipments' => [
+ 0 => [
+ 'shipper' => 'Flat Rate',
+ 'shippingMethod' => 'Fixed',
+ 'shippingPrice' => $this->order->getShippingAmount()
+ ]
+ ],
+ 'products' => [
+ 0 => [
+ 'itemId' => $orderItems[0]->getSku(),
+ 'itemName' => $orderItems[0]->getName(),
+ 'itemPrice' => $orderItems[0]->getPrice(),
+ 'itemQuantity' => $orderItems[0]->getQtyOrdered(),
+ 'itemUrl' => $product->getProductUrl(),
+ 'itemWeight' => $product->getWeight()
+ ]
+ ]
+ ],
+ 'card' => [
+ 'cardHolderName' => 'firstname lastname',
+ 'last4' => $payment->getCcLast4(),
+ 'expiryMonth' => $payment->getCcExpMonth(),
+ 'expiryYear' => $payment->getCcExpYear(),
+ 'billingAddress' => [
+ 'streetAddress' => 'street',
+ 'city' => $billingAddress->getCity(),
+ 'provinceCode' => $billingAddress->getRegionCode(),
+ 'postalCode' => $billingAddress->getPostcode(),
+ 'countryCode' => $billingAddress->getCountryId()
+ ]
+ ],
+ 'recipient' => [
+ 'fullName' => $shippingAddress->getName(),
+ 'confirmationEmail' => $shippingAddress->getEmail(),
+ 'confirmationPhone' => $shippingAddress->getTelephone(),
+ 'deliveryAddress' => [
+ 'streetAddress' => 'street',
+ 'city' => $shippingAddress->getCity(),
+ 'provinceCode' => $shippingAddress->getRegionCode(),
+ 'postalCode' => $shippingAddress->getPostcode(),
+ 'countryCode' => $shippingAddress->getCountryId()
+ ]
+ ],
+ 'userAccount' => [
+ 'email' => $customer->getEmail(),
+ 'username' => $customer->getEmail(),
+ 'phone' => $this->order->getBillingAddress()->getTelephone(),
+ 'accountNumber' => $customer->getId(),
+ 'createdDate' => '2016-12-12 11:00:00+00:00',
+ 'lastUpdateDate' => '2016-12-12 11:05:00+00:00'
+ ]
+ ];
+
+ static::assertEquals($expected['userAccount'], $this->builderData['userAccount']);
}
}
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/_files/customer.php b/dev/tests/integration/testsuite/Magento/Signifyd/_files/customer.php
new file mode 100644
index 0000000000000..df9a814b2ec5b
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/_files/customer.php
@@ -0,0 +1,38 @@
+get(CustomerRegistry::class);
+$customer = $objectManager->create(Customer::class);
+
+/** @var CustomerInterface $customer */
+$customer->setWebsiteId(1)
+ ->setId(1)
+ ->setEmail('customer@example.com')
+ ->setGroupId(1)
+ ->setStoreId(1)
+ ->setPrefix('Mr.')
+ ->setFirstname('John')
+ ->setMiddlename('A')
+ ->setLastname('Smith')
+ ->setSuffix('Esq.')
+ ->setDefaultBilling(1)
+ ->setDefaultShipping(1)
+ ->setTaxvat('12')
+ ->setGender(0)
+ ->setCreatedAt('2016-12-12T11:00:00+0000')
+ ->setUpdatedAt('2016-12-12T11:05:00+0000');
+
+$customer->isObjectNew(true);
+$customer->save();
+
+$customerRegistry->remove($customer->getId());
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/_files/order.php b/dev/tests/integration/testsuite/Magento/Signifyd/_files/order.php
index 762c952b36743..285f2a28394bd 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/_files/order.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/_files/order.php
@@ -11,10 +11,13 @@
use Magento\Store\Model\StoreManagerInterface;
use Magento\TestFramework\Helper\Bootstrap;
use Magento\Paypal\Model\Config as PaypalConfig;
+use Magento\Sales\Model\Order\Shipment\Item as ShipmentItem;
+use Magento\Sales\Model\Order\Shipment;
require __DIR__ . '/../../../Magento/Catalog/_files/product_simple.php';
+require __DIR__ . '/customer.php';
-$addressData = include __DIR__ . '/../../../Magento/Sales/_files/address_data.php';
+$addressData = require __DIR__ . '/../../../Magento/Sales/_files/address_data.php';
$objectManager = Bootstrap::getObjectManager();
@@ -22,16 +25,22 @@
$billingAddress->setAddressType('billing');
$shippingAddress = clone $billingAddress;
-$shippingAddress->setid(null)
+$shippingAddress->setId(null)
->setAddressType('shipping')
->setShippingMethod('flatrate_flatrate');
$payment = $objectManager->create(Payment::class);
-$payment->setMethod(PaypalConfig::METHOD_WPP_EXPRESS);
+$payment->setMethod(PaypalConfig::METHOD_WPP_EXPRESS)
+ ->setLastTransId('00001')
+ ->setCcLast4('1234')
+ ->setCcExpMonth('01')
+ ->setCcExpYear('21');
/** @var Item $orderItem */
$orderItem = $objectManager->create(Item::class);
$orderItem->setProductId($product->getId())
+ ->setSku($product->getSku())
+ ->setName($product->getName())
->setQtyOrdered(1)
->setBasePrice($product->getPrice())
->setPrice($product->getPrice())
@@ -46,13 +55,13 @@
$order->setIncrementId('100000001')
->setState(Order::STATE_PROCESSING)
->setStatus(Order::STATE_PROCESSING)
+ ->setRemoteIp('127.0.0.1')
->setCreatedAt('2016-12-12T12:00:55+0000')
- ->setBaseGrandTotal($orderAmount)
+ ->setOrderCurrencyCode('USD')
->setSubtotal($orderAmount)
->setGrandTotal($orderAmount)
->setBaseSubtotal($orderAmount)
->setBaseGrandTotal($orderAmount)
- ->setCustomerIsGuest(true)
->setCustomerEmail($customerEmail)
->setBillingAddress($billingAddress)
->setShippingAddress($shippingAddress)
@@ -60,18 +69,20 @@
->setShippingAmount(10)
->setStoreId($objectManager->get(StoreManagerInterface::class)->getStore()->getId())
->addItem($orderItem)
- ->setPayment($payment);
+ ->setPayment($payment)
+ ->setCustomerId(1)
+ ->setCustomerIsGuest(false);
/** @var OrderRepositoryInterface $orderRepository */
$orderRepository = $objectManager->get(OrderRepositoryInterface::class);
$orderRepository->save($order);
-$shipmentItem = $objectManager->create(\Magento\Sales\Model\Order\Shipment\Item::class);
+$shipmentItem = $objectManager->create(ShipmentItem::class);
$shipmentItem->setOrderItem($orderItem);
/** @var \Magento\Sales\Model\Order\Shipment $shipment */
-$shipment = $objectManager->create(\Magento\Sales\Model\Order\Shipment::class);
+$shipment = $objectManager->create(Shipment::class);
$shipment->setOrder($order)
->addItem($shipmentItem)
- ->setShipmentStatus(\Magento\Sales\Model\Order\Shipment::STATUS_NEW)
+ ->setShipmentStatus(Shipment::STATUS_NEW)
->save();
From 530c5f04abff932f313cddea96a3feca0315c6b3 Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Wed, 14 Dec 2016 04:55:01 -0600
Subject: [PATCH 023/904] MAGETWO-61913: Create request builders
- Make filtering empty values more obvious
---
.../Signifyd/Model/Request/CreateCaseBuilder.php | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/app/code/Magento/Signifyd/Model/Request/CreateCaseBuilder.php b/app/code/Magento/Signifyd/Model/Request/CreateCaseBuilder.php
index 5abaeffc01b01..b108bfa8cade6 100644
--- a/app/code/Magento/Signifyd/Model/Request/CreateCaseBuilder.php
+++ b/app/code/Magento/Signifyd/Model/Request/CreateCaseBuilder.php
@@ -108,14 +108,22 @@ private function removeEmptyValues($data)
$data[$key] = $this->removeEmptyValues($data[$key]);
}
- if ($data[$key] === null ||
- $data[$key] === '' ||
- (is_array($data[$key]) && empty($data[$key]))
- ) {
+ if ($this->isEmpty($data[$key])) {
unset($data[$key]);
}
}
return $data;
}
+
+ /**
+ * Empty values are null, empty string and empty array
+ *
+ * @param mixed $value
+ * @return bool
+ */
+ private function isEmpty($value)
+ {
+ return $value === null || $value === '' || (is_array($value) && empty($value));
+ }
}
From a8b0a39b70ad982223c7beafc3ac56d1102ab050 Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Wed, 14 Dec 2016 05:05:04 -0600
Subject: [PATCH 024/904] MAGETWO-61913: Create request builders
- integration test
---
.../Model/Request/CreateCaseBuilderTest.php | 69 +++++++++++++++++--
.../Magento/Signifyd/_files/order.php | 38 +++++++---
.../Magento/Signifyd/_files/store.php | 31 +++++++++
3 files changed, 120 insertions(+), 18 deletions(-)
create mode 100644 dev/tests/integration/testsuite/Magento/Signifyd/_files/store.php
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Model/Request/CreateCaseBuilderTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Model/Request/CreateCaseBuilderTest.php
index 9186b6c6f0932..2ca933376d66c 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Model/Request/CreateCaseBuilderTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/Request/CreateCaseBuilderTest.php
@@ -11,7 +11,7 @@
use Magento\Framework\ObjectManagerInterface;
use Magento\Sales\Model\Order;
use Magento\Customer\Api\CustomerRepositoryInterface;
-
+use Magento\Framework\App\ProductMetadataInterface;
/**
* Class PurchaseBuilderTest
* @magentoAppIsolation enabled
@@ -44,6 +44,11 @@ class CreateCaseBuilderTest extends \PHPUnit_Framework_TestCase
*/
private $builderData;
+ /**
+ * @var DateTimeFactory
+ */
+ private $dateTimeFactory;
+
/**
* Initial setup
*/
@@ -53,6 +58,8 @@ protected function setUp()
$bootstrap->loadArea(Area::AREA_FRONTEND);
$this->objectManager = Bootstrap::getObjectManager();
+ $this->dateTimeFactory = $this->objectManager->create(DateTimeFactory::class);
+
$this->order = $this->objectManager->create(Order::class);
$this->order->loadByIncrementId(self::ORDER_INCREMENT_ID);
@@ -72,9 +79,9 @@ public function testPurchaseBuilder()
$payment = $this->order->getPayment();
$billingAddress = $this->order->getBillingAddress();
$shippingAddress = $this->order->getShippingAddress();
-
$customerRepository = $this->objectManager->create(CustomerRepositoryInterface::class);
- $customer = $customerRepository->getById(1);
+ $customer = $customerRepository->getById($this->order->getCustomerId());
+ $productMetadata = $this->objectManager->create(ProductMetadataInterface::class);
$expected = [
'purchase' => [
@@ -101,6 +108,14 @@ public function testPurchaseBuilder()
'itemQuantity' => $orderItems[0]->getQtyOrdered(),
'itemUrl' => $product->getProductUrl(),
'itemWeight' => $product->getWeight()
+ ],
+ 1 => [
+ 'itemId' => 'simple2',
+ 'itemName' => 'Simple product',
+ 'itemPrice' => $orderItems[1]->getPrice(),
+ 'itemQuantity' => $orderItems[1]->getQtyOrdered(),
+ 'itemUrl' => $product->getProductUrl(),
+ 'itemWeight' => $product->getWeight()
]
]
],
@@ -122,7 +137,7 @@ public function testPurchaseBuilder()
'confirmationEmail' => $shippingAddress->getEmail(),
'confirmationPhone' => $shippingAddress->getTelephone(),
'deliveryAddress' => [
- 'streetAddress' => 'street',
+ 'streetAddress' => '6161 West Centinela Avenue',
'city' => $shippingAddress->getCity(),
'provinceCode' => $shippingAddress->getRegionCode(),
'postalCode' => $shippingAddress->getPostcode(),
@@ -134,11 +149,51 @@ public function testPurchaseBuilder()
'username' => $customer->getEmail(),
'phone' => $this->order->getBillingAddress()->getTelephone(),
'accountNumber' => $customer->getId(),
- 'createdDate' => '2016-12-12 11:00:00+00:00',
- 'lastUpdateDate' => '2016-12-12 11:05:00+00:00'
+ 'createdDate' => $this->formatDate($customer->getCreatedAt()),
+ 'lastUpdateDate' => $this->formatDate($customer->getUpdatedAt())
+ ],
+ 'seller' => [
+ 'name' => 'Sample Store',
+ 'domain' => 'm2.com',
+ 'shipFromAddress' => [
+ 'streetAddress' => '6161 West Centinela Avenue',
+ 'unit' => 'app. 111',
+ 'city' => 'Culver City',
+ 'provinceCode' => 'AE',
+ 'postalCode' => '90230',
+ 'countryCode' => 1,
+ ],
+ 'corporateAddress' => [
+ 'streetAddress' => '5th Avenue',
+ 'unit' => '75',
+ 'city' => 'New York',
+ 'provinceCode' => 'MH',
+ 'postalCode' => '19032',
+ 'countryCode' => 1,
+ ],
+ ],
+ 'clientVersion' => [
+ 'platform' => $productMetadata->getName() . ' ' . $productMetadata->getEdition(),
+ 'platformVersion' => $productMetadata->getVersion()
]
];
- static::assertEquals($expected['userAccount'], $this->builderData['userAccount']);
+ static::assertEquals($expected, $this->builderData);
+ }
+
+ /**
+ * Format date in ISO8601
+ *
+ * @param string $date
+ * @return string
+ */
+ private function formatDate($date)
+ {
+ $result = $this->dateTimeFactory->create(
+ $date,
+ new \DateTimeZone('UTC')
+ );
+
+ return $result->format(\DateTime::ATOM);
}
}
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/_files/order.php b/dev/tests/integration/testsuite/Magento/Signifyd/_files/order.php
index 285f2a28394bd..092b31553f3a7 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/_files/order.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/_files/order.php
@@ -8,14 +8,14 @@
use Magento\Sales\Model\Order\Address;
use Magento\Sales\Model\Order\Item;
use Magento\Sales\Api\OrderRepositoryInterface;
-use Magento\Store\Model\StoreManagerInterface;
use Magento\TestFramework\Helper\Bootstrap;
use Magento\Paypal\Model\Config as PaypalConfig;
use Magento\Sales\Model\Order\Shipment\Item as ShipmentItem;
use Magento\Sales\Model\Order\Shipment;
require __DIR__ . '/../../../Magento/Catalog/_files/product_simple.php';
-require __DIR__ . '/customer.php';
+require __DIR__ . '/../../../Magento/Customer/_files/customer.php';
+require __DIR__ . '/store.php';
$addressData = require __DIR__ . '/../../../Magento/Sales/_files/address_data.php';
@@ -27,6 +27,9 @@
$shippingAddress = clone $billingAddress;
$shippingAddress->setId(null)
->setAddressType('shipping')
+ ->setStreet('6161 West Centinela Avenue')
+ ->setFirstname('John')
+ ->setLastname('Doe')
->setShippingMethod('flatrate_flatrate');
$payment = $objectManager->create(Payment::class);
@@ -37,8 +40,8 @@
->setCcExpYear('21');
/** @var Item $orderItem */
-$orderItem = $objectManager->create(Item::class);
-$orderItem->setProductId($product->getId())
+$orderItem1 = $objectManager->create(Item::class);
+$orderItem1->setProductId($product->getId())
->setSku($product->getSku())
->setName($product->getName())
->setQtyOrdered(1)
@@ -47,6 +50,18 @@
->setRowTotal($product->getPrice())
->setProductType($product->getTypeId());
+/** @var Item $orderItem */
+$orderItem2 = $objectManager->create(Item::class);
+$orderItem2->setProductId($product->getId())
+ ->setSku('simple2')
+ ->setName('Simple product')
+ ->setPrice(100)
+ ->setQtyOrdered(2)
+ ->setBasePrice($product->getPrice())
+ ->setPrice($product->getPrice())
+ ->setRowTotal($product->getPrice())
+ ->setProductType($product->getTypeId());
+
$orderAmount = 100;
$customerEmail = $billingAddress->getEmail();
@@ -55,6 +70,8 @@
$order->setIncrementId('100000001')
->setState(Order::STATE_PROCESSING)
->setStatus(Order::STATE_PROCESSING)
+ ->setCustomerId($customer->getId())
+ ->setCustomerIsGuest(false)
->setRemoteIp('127.0.0.1')
->setCreatedAt('2016-12-12T12:00:55+0000')
->setOrderCurrencyCode('USD')
@@ -67,20 +84,19 @@
->setShippingAddress($shippingAddress)
->setShippingDescription('Flat Rate - Fixed')
->setShippingAmount(10)
- ->setStoreId($objectManager->get(StoreManagerInterface::class)->getStore()->getId())
- ->addItem($orderItem)
- ->setPayment($payment)
- ->setCustomerId(1)
- ->setCustomerIsGuest(false);
+ ->setStoreId($store->getId())
+ ->addItem($orderItem1)
+ ->addItem($orderItem2)
+ ->setPayment($payment);
/** @var OrderRepositoryInterface $orderRepository */
$orderRepository = $objectManager->get(OrderRepositoryInterface::class);
$orderRepository->save($order);
$shipmentItem = $objectManager->create(ShipmentItem::class);
-$shipmentItem->setOrderItem($orderItem);
+$shipmentItem->setOrderItem($orderItem1);
-/** @var \Magento\Sales\Model\Order\Shipment $shipment */
+/** @var Shipment $shipment */
$shipment = $objectManager->create(Shipment::class);
$shipment->setOrder($order)
->addItem($shipmentItem)
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/_files/store.php b/dev/tests/integration/testsuite/Magento/Signifyd/_files/store.php
new file mode 100644
index 0000000000000..9a20bb1982069
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/_files/store.php
@@ -0,0 +1,31 @@
+get(StoreManagerInterface::class)->getStore();
+/** @var MutableScopeConfigInterface $mutableConfig */
+$mutableConfig = $objectManager->get(MutableScopeConfigInterface::class);
+$mutableConfig->setValue(Information::XML_PATH_STORE_INFO_NAME, 'Sample Store', ScopeInterface::SCOPE_STORE);
+$mutableConfig->setValue(Store::XML_PATH_UNSECURE_BASE_LINK_URL, 'http://m2.com/', ScopeInterface::SCOPE_STORE);
+$mutableConfig->setValue(Shipment::XML_PATH_STORE_ADDRESS1, '6161 West Centinela Avenue', ScopeInterface::SCOPE_STORE);
+$mutableConfig->setValue(Shipment::XML_PATH_STORE_ADDRESS2, 'app. 111', ScopeInterface::SCOPE_STORE);
+$mutableConfig->setValue(Shipment::XML_PATH_STORE_CITY, 'Culver City', ScopeInterface::SCOPE_STORE);
+$mutableConfig->setValue(Shipment::XML_PATH_STORE_REGION_ID, 10, ScopeInterface::SCOPE_STORE);
+$mutableConfig->setValue(Shipment::XML_PATH_STORE_ZIP, '90230', ScopeInterface::SCOPE_STORE);
+$mutableConfig->setValue(Shipment::XML_PATH_STORE_COUNTRY_ID, 1, ScopeInterface::SCOPE_STORE);
+
+$mutableConfig->setValue(Information::XML_PATH_STORE_INFO_STREET_LINE1, '5th Avenue', ScopeInterface::SCOPE_STORE);
+$mutableConfig->setValue(Information::XML_PATH_STORE_INFO_STREET_LINE2, '75', ScopeInterface::SCOPE_STORE);
+$mutableConfig->setValue(Information::XML_PATH_STORE_INFO_CITY, 'New York', ScopeInterface::SCOPE_STORE);
+$mutableConfig->setValue(Information::XML_PATH_STORE_INFO_REGION_CODE, 30, ScopeInterface::SCOPE_STORE);
+$mutableConfig->setValue(Information::XML_PATH_STORE_INFO_POSTCODE, '19032', ScopeInterface::SCOPE_STORE);
+$mutableConfig->setValue(Information::XML_PATH_STORE_INFO_COUNTRY_CODE, 1, ScopeInterface::SCOPE_STORE);
From c03f1a9ae74b5842976b839002d4b87b00dc75a9 Mon Sep 17 00:00:00 2001
From: Volodymyr Kublytskyi
Date: Wed, 14 Dec 2016 08:27:07 -0600
Subject: [PATCH 025/904] MAGETWO-61914: Create case request to Signifyd
- created Signifyd API gateway
- some builders modified to not trigger validation errors on Signifyd side
- request builders moved to gateway namespace
---
.../Api/CaseCreationServiceInterface.php | 26 ++
.../Signifyd/Model/CaseCreationService.php | 68 ++++++
app/code/Magento/Signifyd/Model/Config.php | 91 +++++++
.../Request/AddressBuilder.php | 2 +-
.../Request/CardBuilder.php | 2 +-
.../Request/ClientVersionBuilder.php | 2 +-
.../Request/CreateCaseBuilder.php | 2 +-
.../Request/CreateCaseBuilderInterface.php | 2 +-
.../Request/CustomerOrders.php | 2 +-
.../Request/PurchaseBuilder.php | 4 +-
.../Request/RecipientBuilder.php | 2 +-
.../Request/SellerBuilder.php | 21 +-
.../Request/UserAccountBuilder.php | 2 +-
.../SignifydApiCallException.php | 14 ++
.../SignifydGateway/SignifydApiClient.php | 222 ++++++++++++++++++
.../SignifydApiResponseException.php | 14 ++
.../Model/SignifydGateway/SignifydGateway.php | 63 +++++
.../SignifydGatewayException.php | 14 ++
.../Magento/Signifyd/Observer/PlaceOrder.php | 83 +++++++
app/code/Magento/Signifyd/etc/config.xml | 10 +-
app/code/Magento/Signifyd/etc/di.xml | 2 +
app/code/Magento/Signifyd/etc/events.xml | 12 +
app/code/Magento/Signifyd/etc/module.xml | 1 +
.../Request/CreateCaseBuilderTest.php | 4 +-
24 files changed, 647 insertions(+), 18 deletions(-)
create mode 100644 app/code/Magento/Signifyd/Api/CaseCreationServiceInterface.php
create mode 100644 app/code/Magento/Signifyd/Model/CaseCreationService.php
create mode 100644 app/code/Magento/Signifyd/Model/Config.php
rename app/code/Magento/Signifyd/Model/{ => SignifydGateway}/Request/AddressBuilder.php (94%)
rename app/code/Magento/Signifyd/Model/{ => SignifydGateway}/Request/CardBuilder.php (95%)
rename app/code/Magento/Signifyd/Model/{ => SignifydGateway}/Request/ClientVersionBuilder.php (93%)
rename app/code/Magento/Signifyd/Model/{ => SignifydGateway}/Request/CreateCaseBuilder.php (98%)
rename app/code/Magento/Signifyd/Model/{ => SignifydGateway}/Request/CreateCaseBuilderInterface.php (85%)
rename app/code/Magento/Signifyd/Model/{ => SignifydGateway}/Request/CustomerOrders.php (96%)
rename app/code/Magento/Signifyd/Model/{ => SignifydGateway}/Request/PurchaseBuilder.php (97%)
rename app/code/Magento/Signifyd/Model/{ => SignifydGateway}/Request/RecipientBuilder.php (95%)
rename app/code/Magento/Signifyd/Model/{ => SignifydGateway}/Request/SellerBuilder.php (88%)
rename app/code/Magento/Signifyd/Model/{ => SignifydGateway}/Request/UserAccountBuilder.php (98%)
create mode 100644 app/code/Magento/Signifyd/Model/SignifydGateway/SignifydApiCallException.php
create mode 100644 app/code/Magento/Signifyd/Model/SignifydGateway/SignifydApiClient.php
create mode 100644 app/code/Magento/Signifyd/Model/SignifydGateway/SignifydApiResponseException.php
create mode 100644 app/code/Magento/Signifyd/Model/SignifydGateway/SignifydGateway.php
create mode 100644 app/code/Magento/Signifyd/Model/SignifydGateway/SignifydGatewayException.php
create mode 100644 app/code/Magento/Signifyd/Observer/PlaceOrder.php
create mode 100644 app/code/Magento/Signifyd/etc/events.xml
rename dev/tests/integration/testsuite/Magento/Signifyd/Model/{ => SignifydGateway}/Request/CreateCaseBuilderTest.php (98%)
diff --git a/app/code/Magento/Signifyd/Api/CaseCreationServiceInterface.php b/app/code/Magento/Signifyd/Api/CaseCreationServiceInterface.php
new file mode 100644
index 0000000000000..d1bddc29d76f8
--- /dev/null
+++ b/app/code/Magento/Signifyd/Api/CaseCreationServiceInterface.php
@@ -0,0 +1,26 @@
+caseManagement = $caseManagement;
+ $this->signifydGateway = $signifydGateway;
+ $this->logger = $logger;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function createForOrder($orderId)
+ {
+ $this->caseManagement->create($orderId);
+ try {
+ $this->signifydGateway->createCase($orderId);
+ } catch (SignifydGatewayException $e) {
+ $this->logger->error($e->getMessage());
+ }
+
+ return true;
+ }
+
+}
\ No newline at end of file
diff --git a/app/code/Magento/Signifyd/Model/Config.php b/app/code/Magento/Signifyd/Model/Config.php
new file mode 100644
index 0000000000000..b6af0aaef3a59
--- /dev/null
+++ b/app/code/Magento/Signifyd/Model/Config.php
@@ -0,0 +1,91 @@
+scopeConfig = $scopeConfig;
+ $this->encryptor = $encryptor;
+ }
+
+ /**
+ * If this config option set to false no Signifyd integration should be available
+ * (only possibility to configure Signifyd setting in admin)
+ *
+ * @return bool
+ */
+ public function isEnabled()
+ {
+ $enabled = $this->scopeConfig->isSetFlag('fraud_protection/signifyd/active');
+ return $enabled;
+ }
+
+ /**
+ * Signifyd API Key used for authentication.
+ *
+ * @see https://www.signifyd.com/docs/api/#/introduction/authentication
+ * @see https://app.signifyd.com/settings
+ *
+ * @return string
+ */
+ public function getApiKey()
+ {
+ $encryptedApiKey = $this->scopeConfig->getValue('fraud_protection/signifyd/api_key');
+ $apiKey = $this->encryptor->decrypt($encryptedApiKey);
+ return $apiKey;
+ }
+
+ /**
+ * Base URL to Signifyd REST API.
+ * Usually equals to https://api.signifyd.com/v2 and should not be changed
+ *
+ * @return string
+ */
+ public function getApiUrl()
+ {
+ $apiUrl = $this->scopeConfig->getValue('fraud_protection/signifyd/api_url');
+ return $apiUrl;
+ }
+
+ /**
+ * If is "true" extra information about interaction with Signifyd API are written to debug.log file
+ *
+ * @return bool
+ */
+ public function isDebugModeEnabled()
+ {
+ $debugModeEnabled = $this->scopeConfig->isSetFlag('fraud_protection/signifyd/debug');
+ return $debugModeEnabled;
+ }
+
+}
\ No newline at end of file
diff --git a/app/code/Magento/Signifyd/Model/Request/AddressBuilder.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/AddressBuilder.php
similarity index 94%
rename from app/code/Magento/Signifyd/Model/Request/AddressBuilder.php
rename to app/code/Magento/Signifyd/Model/SignifydGateway/Request/AddressBuilder.php
index 2d2b4ac28f6f2..76ac256a1efa6 100644
--- a/app/code/Magento/Signifyd/Model/Request/AddressBuilder.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/AddressBuilder.php
@@ -3,7 +3,7 @@
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-namespace Magento\Signifyd\Model\Request;
+namespace Magento\Signifyd\Model\SignifydGateway\Request;
use Magento\Sales\Api\Data\OrderAddressInterface;
diff --git a/app/code/Magento/Signifyd/Model/Request/CardBuilder.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/CardBuilder.php
similarity index 95%
rename from app/code/Magento/Signifyd/Model/Request/CardBuilder.php
rename to app/code/Magento/Signifyd/Model/SignifydGateway/Request/CardBuilder.php
index 2c931924d9c2a..5e50c637a2bff 100644
--- a/app/code/Magento/Signifyd/Model/Request/CardBuilder.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/CardBuilder.php
@@ -3,7 +3,7 @@
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-namespace Magento\Signifyd\Model\Request;
+namespace Magento\Signifyd\Model\SignifydGateway\Request;
use Magento\Sales\Model\Order;
diff --git a/app/code/Magento/Signifyd/Model/Request/ClientVersionBuilder.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/ClientVersionBuilder.php
similarity index 93%
rename from app/code/Magento/Signifyd/Model/Request/ClientVersionBuilder.php
rename to app/code/Magento/Signifyd/Model/SignifydGateway/Request/ClientVersionBuilder.php
index 25ee03da20dc1..b9c514a41f3d8 100644
--- a/app/code/Magento/Signifyd/Model/Request/ClientVersionBuilder.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/ClientVersionBuilder.php
@@ -3,7 +3,7 @@
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-namespace Magento\Signifyd\Model\Request;
+namespace Magento\Signifyd\Model\SignifydGateway\Request;
use Magento\Framework\App\ProductMetadataInterface;
diff --git a/app/code/Magento/Signifyd/Model/Request/CreateCaseBuilder.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilder.php
similarity index 98%
rename from app/code/Magento/Signifyd/Model/Request/CreateCaseBuilder.php
rename to app/code/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilder.php
index b108bfa8cade6..2248e8089c5a2 100644
--- a/app/code/Magento/Signifyd/Model/Request/CreateCaseBuilder.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilder.php
@@ -3,7 +3,7 @@
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-namespace Magento\Signifyd\Model\Request;
+namespace Magento\Signifyd\Model\SignifydGateway\Request;
use Magento\Sales\Model\OrderFactory;
diff --git a/app/code/Magento/Signifyd/Model/Request/CreateCaseBuilderInterface.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderInterface.php
similarity index 85%
rename from app/code/Magento/Signifyd/Model/Request/CreateCaseBuilderInterface.php
rename to app/code/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderInterface.php
index 63a302509cf76..c18f7b0216a3d 100644
--- a/app/code/Magento/Signifyd/Model/Request/CreateCaseBuilderInterface.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderInterface.php
@@ -3,7 +3,7 @@
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-namespace Magento\Signifyd\Model\Request;
+namespace Magento\Signifyd\Model\SignifydGateway\Request;
/**
* Interface CreateCaseBuilderInterface
diff --git a/app/code/Magento/Signifyd/Model/Request/CustomerOrders.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/CustomerOrders.php
similarity index 96%
rename from app/code/Magento/Signifyd/Model/Request/CustomerOrders.php
rename to app/code/Magento/Signifyd/Model/SignifydGateway/Request/CustomerOrders.php
index 26322a745b8ee..fb80837c2c1ed 100644
--- a/app/code/Magento/Signifyd/Model/Request/CustomerOrders.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/CustomerOrders.php
@@ -3,7 +3,7 @@
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-namespace Magento\Signifyd\Model\Request;
+namespace Magento\Signifyd\Model\SignifydGateway\Request;
use Magento\Framework\Api\FilterBuilder;
use Magento\Framework\Api\SearchCriteriaBuilder;
diff --git a/app/code/Magento/Signifyd/Model/Request/PurchaseBuilder.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php
similarity index 97%
rename from app/code/Magento/Signifyd/Model/Request/PurchaseBuilder.php
rename to app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php
index 16de64b869cd1..3d5cb1e3cc92d 100644
--- a/app/code/Magento/Signifyd/Model/Request/PurchaseBuilder.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php
@@ -3,7 +3,7 @@
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-namespace Magento\Signifyd\Model\Request;
+namespace Magento\Signifyd\Model\SignifydGateway\Request;
use Magento\Framework\Intl\DateTimeFactory;
use Magento\Framework\Config\ScopeInterface;
@@ -96,7 +96,7 @@ private function getProducts(Order $order)
'itemId' => $orderItem->getSku(),
'itemName' => $orderItem->getName(),
'itemPrice' => $orderItem->getPrice(),
- 'itemQuantity' => $orderItem->getQtyOrdered(),
+ 'itemQuantity' => (int)$orderItem->getQtyOrdered(),
'itemUrl' => $orderItem->getProduct()->getProductUrl(),
'itemWeight' => $orderItem->getProduct()->getWeight()
];
diff --git a/app/code/Magento/Signifyd/Model/Request/RecipientBuilder.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/RecipientBuilder.php
similarity index 95%
rename from app/code/Magento/Signifyd/Model/Request/RecipientBuilder.php
rename to app/code/Magento/Signifyd/Model/SignifydGateway/Request/RecipientBuilder.php
index 510276d1cc75c..81212c7b1c02a 100644
--- a/app/code/Magento/Signifyd/Model/Request/RecipientBuilder.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/RecipientBuilder.php
@@ -3,7 +3,7 @@
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-namespace Magento\Signifyd\Model\Request;
+namespace Magento\Signifyd\Model\SignifydGateway\Request;
use Magento\Sales\Model\Order;
diff --git a/app/code/Magento/Signifyd/Model/Request/SellerBuilder.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/SellerBuilder.php
similarity index 88%
rename from app/code/Magento/Signifyd/Model/Request/SellerBuilder.php
rename to app/code/Magento/Signifyd/Model/SignifydGateway/Request/SellerBuilder.php
index 21b319421d57c..f3129e441a5a9 100644
--- a/app/code/Magento/Signifyd/Model/Request/SellerBuilder.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/SellerBuilder.php
@@ -3,7 +3,7 @@
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-namespace Magento\Signifyd\Model\Request;
+namespace Magento\Signifyd\Model\SignifydGateway\Request;
use Magento\Directory\Model\RegionFactory;
use Magento\Framework\App\Config\ScopeConfigInterface;
@@ -60,7 +60,7 @@ public function build(Order $order)
return [
'seller' => [
'name' => $this->getConfigValue(Information::XML_PATH_STORE_INFO_NAME, $store),
- 'domain' => parse_url($store->getBaseUrl(), PHP_URL_HOST),
+ 'domain' => $this->getPublicDomain($store),
'shipFromAddress' => [
'streetAddress' => $this->getConfigValue(Shipment::XML_PATH_STORE_ADDRESS1, $store),
'unit' => $this->getConfigValue(Shipment::XML_PATH_STORE_ADDRESS2, $store),
@@ -115,4 +115,21 @@ private function getConfigValue($value, StoreInterface $store)
$store
);
}
+
+ /**
+ * @param StoreInterface $store
+ *
+ * @return string|null
+ */
+ private function getPublicDomain(StoreInterface $store)
+ {
+ $baseUrl = $store->getBaseUrl();
+ $domain = parse_url($baseUrl, PHP_URL_HOST);
+ if (\function_exists('checkdnsrr') && false === \checkdnsrr($domain)) {
+ return null;
+ }
+
+ return $domain;
+ }
+
}
diff --git a/app/code/Magento/Signifyd/Model/Request/UserAccountBuilder.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/UserAccountBuilder.php
similarity index 98%
rename from app/code/Magento/Signifyd/Model/Request/UserAccountBuilder.php
rename to app/code/Magento/Signifyd/Model/SignifydGateway/Request/UserAccountBuilder.php
index 6cb33697488f6..a3f7cead80605 100644
--- a/app/code/Magento/Signifyd/Model/Request/UserAccountBuilder.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/UserAccountBuilder.php
@@ -3,7 +3,7 @@
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-namespace Magento\Signifyd\Model\Request;
+namespace Magento\Signifyd\Model\SignifydGateway\Request;
use Magento\Sales\Model\Order;
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/SignifydApiCallException.php b/app/code/Magento/Signifyd/Model/SignifydGateway/SignifydApiCallException.php
new file mode 100644
index 0000000000000..e62ece8946926
--- /dev/null
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/SignifydApiCallException.php
@@ -0,0 +1,14 @@
+config = $config;
+ $this->clientFactory = $clientFactory;
+ $this->dataEncoder = $dataEncoder;
+ $this->dataDecoder = $dataDecoder;
+ }
+
+ /**
+ * Perform call to Signifyd API.
+ *
+ * Method returns associative array that corresponds to successful result.
+ * Current implementation do not expose details in case of failure.
+ *
+ * @param $url
+ * @param $method
+ * @param array $params
+ * @return array
+ * @throws SignifydApiCallException
+ * @throws SignifydApiResponseException
+ */
+ public function makeApiCall($url, $method, array $params = [])
+ {
+ try {
+ $response = $this->sendRequest($url, $method, $params);
+ } catch (\Exception $e) {
+ throw new SignifydApiCallException(
+ 'Unable to call Signifyd API: ' . $e->getMessage(),
+ $e->getCode(),
+ $e
+ );
+ }
+ $result = $this->handleResponse($response);
+ return $result;
+ }
+
+ /**
+ * Send HTTP request to Signifyd API.
+ *
+ * @param $url
+ * @param $method
+ * @param array $params
+ * @return \Zend_Http_Response
+ * @throws SignifydApiCallException
+ */
+ private function sendRequest($url, $method, array $params = [])
+ {
+ $apiKey = $this->getApiKey();
+ $apiUrl = $this->buildFullApiUrl($url);
+
+ $client = $this->createNewClient();
+ $client->setHeaders(
+ 'Authorization',
+ sprintf('Basic %s', $apiKey)
+ );
+// $client->setHeaders(
+// 'Accept-encoding',
+// 'identity'
+// );
+ if (!empty($params)) {
+ $encodedData = $this->dataEncoder->encode($params);
+ $client->setRawData($encodedData, 'application/json');
+ }
+ $client->setMethod($method);
+ $client->setUri($apiUrl);
+
+ $response = $client->request();
+ return $response;
+ }
+
+ /**
+ * Read result of successful operation and throw exception in case of any failure.
+ *
+ * @param \Zend_Http_Response $response
+ *
+ * @return mixed
+ * @throws SignifydApiCallException
+ * @throws SignifydApiResponseException
+ */
+ private function handleResponse(\Zend_Http_Response $response)
+ {
+ $responseBody = $response->getBody();
+
+ switch ($response->getStatus()) {
+ case 200:
+ case 201:
+ case 204:
+ try {
+ $decodedResponseBody = $this->dataDecoder->decode($responseBody);
+ } catch (\Exception $e) {
+ throw new SignifydApiResponseException('Signifyd API response is not valid JSON.');
+ }
+ return $decodedResponseBody;
+ case 400:
+ throw new SignifydApiCallException(
+ 'Bad Request - The request could not be parsed. Response: ' . $responseBody
+ );
+ case 404:
+ throw new SignifydApiCallException(
+ 'Not Found - resource does not exist. Response: ' . $responseBody
+ );
+ case 409:
+ throw new SignifydApiCallException(
+ 'Conflict - with state of the resource on server. Can occur with (too rapid) PUT requests.' .
+ 'Response: ' . $responseBody
+ );
+ case 401:
+ throw new SignifydApiCallException(
+ 'Unauthorized - user is not logged in, could not be authenticated. Response: ' . $responseBody
+ );
+ case 403:
+ throw new SignifydApiCallException(
+ 'Forbidden - Cannot access resource. Response: ' . $responseBody
+ );
+ case 500:
+ throw new SignifydApiCallException('Server error.');
+ default:
+ throw new SignifydApiResponseException(
+ sprintf('Unexpected Signifyd API response code "%s"', $response->getStatus())
+ );
+ }
+ }
+
+ /**
+ * @return ZendClient
+ */
+ private function createNewClient()
+ {
+ return $this->clientFactory->create();
+ }
+
+ /**
+ * Returns Signifyd API key for merchant account
+ * @see https://www.signifyd.com/docs/api/#/introduction/authentication
+ *
+ * @return string
+ */
+ private function getApiKey()
+ {
+ return $this->config->getApiKey();
+ }
+
+ /**
+ * Builds full URL for Singifyd API based on relative URL
+ *
+ * @param $url
+ * @return string
+ */
+ private function buildFullApiUrl($url)
+ {
+ $baseApiUrl = $this->getBaseApiUrl();
+ $fullUrl = $baseApiUrl . '/' . ltrim($url, '/');
+ return $fullUrl;
+ }
+
+ /**
+ * Returns Base Sigifyd API URL without trailing slash
+ *
+ * @return string
+ */
+ private function getBaseApiUrl()
+ {
+ $baseApiUrl = $this->config->getApiUrl();
+ return rtrim($baseApiUrl, '/');
+ }
+
+}
\ No newline at end of file
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/SignifydApiResponseException.php b/app/code/Magento/Signifyd/Model/SignifydGateway/SignifydApiResponseException.php
new file mode 100644
index 0000000000000..cd6d9113e2119
--- /dev/null
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/SignifydApiResponseException.php
@@ -0,0 +1,14 @@
+createCaseBuilder = $createCaseBuilder;
+ $this->apiClient = $apiClient;
+ }
+
+ /**
+ * @param $orderId
+ * @return int Signifyd case (investigation) identifier
+ * @throws SignifydGatewayException
+ */
+ public function createCase($orderId)
+ {
+ $caseParams = $this->createCaseBuilder->build($orderId);
+
+ $caseCreationResult = $this->apiClient->makeApiCall(
+ '/cases',
+ 'POST',
+ $caseParams
+ );
+
+ if (!isset($caseCreationResult['investigationId'])) {
+ throw new SignifydGatewayException('Expected field "investigationId" missed.');
+ }
+
+ return (int)$caseCreationResult['investigationId'];
+ }
+}
\ No newline at end of file
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/SignifydGatewayException.php b/app/code/Magento/Signifyd/Model/SignifydGateway/SignifydGatewayException.php
new file mode 100644
index 0000000000000..d1d46a7d79445
--- /dev/null
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/SignifydGatewayException.php
@@ -0,0 +1,14 @@
+signifydIntegrationConfig = $signifydIntegrationConfig;
+ $this->caseCreationService = $caseCreationService;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function execute(Observer $observer)
+ {
+ $event = $observer->getEvent();
+ $order = $this->extractOrder($event);
+
+ if (null === $order) {
+ return;
+ }
+
+ $orderId = $order->getEntityId();
+ if (null === $order) {
+ return;
+ }
+
+ if (!$this->signifydIntegrationConfig->isEnabled()) {
+ return;
+ }
+
+ $this->caseCreationService->createForOrder($orderId);
+ }
+
+ /**
+ * Fetch Order entity from Event data container
+ *
+ * @param Event $event
+ * @return OrderInterface|null
+ */
+ private function extractOrder(Event $event)
+ {
+ return $event->getData('order');
+ }
+
+}
\ No newline at end of file
diff --git a/app/code/Magento/Signifyd/etc/config.xml b/app/code/Magento/Signifyd/etc/config.xml
index b16f0903c2d1f..7ff088dcb0321 100644
--- a/app/code/Magento/Signifyd/etc/config.xml
+++ b/app/code/Magento/Signifyd/etc/config.xml
@@ -7,9 +7,11 @@
-->
-
- 0
- https://api.signifiyd.com/v2/
-
+
+
+ 0
+ https://api.signifyd.com/v2/
+
+
diff --git a/app/code/Magento/Signifyd/etc/di.xml b/app/code/Magento/Signifyd/etc/di.xml
index 6b49c74337868..81d157887f7e1 100644
--- a/app/code/Magento/Signifyd/etc/di.xml
+++ b/app/code/Magento/Signifyd/etc/di.xml
@@ -10,4 +10,6 @@
+
+
\ No newline at end of file
diff --git a/app/code/Magento/Signifyd/etc/events.xml b/app/code/Magento/Signifyd/etc/events.xml
new file mode 100644
index 0000000000000..dd4fff95b8c4a
--- /dev/null
+++ b/app/code/Magento/Signifyd/etc/events.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/code/Magento/Signifyd/etc/module.xml b/app/code/Magento/Signifyd/etc/module.xml
index aa2d26414b484..40335d45f28a5 100644
--- a/app/code/Magento/Signifyd/etc/module.xml
+++ b/app/code/Magento/Signifyd/etc/module.xml
@@ -9,6 +9,7 @@
+
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Model/Request/CreateCaseBuilderTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
similarity index 98%
rename from dev/tests/integration/testsuite/Magento/Signifyd/Model/Request/CreateCaseBuilderTest.php
rename to dev/tests/integration/testsuite/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
index 2ca933376d66c..516ecd329bf7e 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Model/Request/CreateCaseBuilderTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
@@ -3,7 +3,7 @@
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-namespace Magento\Signifyd\Model\Request;
+namespace Magento\Signifyd\Model\SignifydGateway\Request;
use Magento\TestFramework\Helper\Bootstrap;
use Magento\Framework\App\Area;
@@ -15,7 +15,7 @@
/**
* Class PurchaseBuilderTest
* @magentoAppIsolation enabled
- * @package Magento\Signifyd\Model\Request\CreateCaseBuilder
+ * @package Magento\Signifyd\Model\SignifydGateway\Request\CreateCaseBuilder
*/
class CreateCaseBuilderTest extends \PHPUnit_Framework_TestCase
{
From 1293ed46280eceab7b15ce98ce4a143637ea0519 Mon Sep 17 00:00:00 2001
From: Volodymyr Kublytskyi
Date: Wed, 14 Dec 2016 09:09:23 -0600
Subject: [PATCH 026/904] MAGETWO-61914: Create case request to Signifyd
- Removed debugging code
---
.../Signifyd/Model/SignifydGateway/SignifydApiClient.php | 4 ----
1 file changed, 4 deletions(-)
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/SignifydApiClient.php b/app/code/Magento/Signifyd/Model/SignifydGateway/SignifydApiClient.php
index b485f54dc16d7..ba2e778b4ef93 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/SignifydApiClient.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/SignifydApiClient.php
@@ -108,10 +108,6 @@ private function sendRequest($url, $method, array $params = [])
'Authorization',
sprintf('Basic %s', $apiKey)
);
-// $client->setHeaders(
-// 'Accept-encoding',
-// 'identity'
-// );
if (!empty($params)) {
$encodedData = $this->dataEncoder->encode($params);
$client->setRawData($encodedData, 'application/json');
From 66f4b1cf401583be7ebb3d1f85d7ccf892bd8398 Mon Sep 17 00:00:00 2001
From: Volodymyr Kublytskyi
Date: Wed, 14 Dec 2016 09:23:52 -0600
Subject: [PATCH 027/904] MAGETWO-61914: Create case request to Signifyd
- fixed issue with not encrypted API key
---
.../Signifyd/Model/SignifydGateway/SignifydApiClient.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/SignifydApiClient.php b/app/code/Magento/Signifyd/Model/SignifydGateway/SignifydApiClient.php
index ba2e778b4ef93..b2a7be8b752f7 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/SignifydApiClient.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/SignifydApiClient.php
@@ -106,7 +106,7 @@ private function sendRequest($url, $method, array $params = [])
$client = $this->createNewClient();
$client->setHeaders(
'Authorization',
- sprintf('Basic %s', $apiKey)
+ sprintf('Basic %s', base64_encode($apiKey))
);
if (!empty($params)) {
$encodedData = $this->dataEncoder->encode($params);
From 88254012115c326993745aadf31ab9910f97db99 Mon Sep 17 00:00:00 2001
From: Volodymyr Kublytskyi
Date: Wed, 14 Dec 2016 09:46:43 -0600
Subject: [PATCH 028/904] MAGETWO-61914: Create case request to Signifyd
- fixed configuration reading
---
app/code/Magento/Signifyd/Model/Config.php | 34 ++++++++++++----------
app/code/Magento/Signifyd/etc/config.xml | 2 ++
2 files changed, 20 insertions(+), 16 deletions(-)
diff --git a/app/code/Magento/Signifyd/Model/Config.php b/app/code/Magento/Signifyd/Model/Config.php
index b6af0aaef3a59..af3f26b80b5ca 100644
--- a/app/code/Magento/Signifyd/Model/Config.php
+++ b/app/code/Magento/Signifyd/Model/Config.php
@@ -6,7 +6,7 @@
namespace Magento\Signifyd\Model;
use Magento\Framework\App\Config\ScopeConfigInterface;
-use Magento\Framework\Encryption\EncryptorInterface;
+use Magento\Store\Model\ScopeInterface;
/**
* Signifyd integration configuration.
@@ -20,22 +20,13 @@ class Config
*/
private $scopeConfig;
- /**
- * @var EncryptorInterface
- */
- private $encryptor;
-
/**
* Config constructor.
*
* @param ScopeConfigInterface $scopeConfig
*/
- public function __construct(
- ScopeConfigInterface $scopeConfig,
- EncryptorInterface $encryptor
- ) {
+ public function __construct(ScopeConfigInterface $scopeConfig) {
$this->scopeConfig = $scopeConfig;
- $this->encryptor = $encryptor;
}
/**
@@ -46,7 +37,10 @@ public function __construct(
*/
public function isEnabled()
{
- $enabled = $this->scopeConfig->isSetFlag('fraud_protection/signifyd/active');
+ $enabled = $this->scopeConfig->isSetFlag(
+ 'fraud_protection/signifyd/active',
+ ScopeInterface::SCOPE_STORE
+ );
return $enabled;
}
@@ -60,8 +54,10 @@ public function isEnabled()
*/
public function getApiKey()
{
- $encryptedApiKey = $this->scopeConfig->getValue('fraud_protection/signifyd/api_key');
- $apiKey = $this->encryptor->decrypt($encryptedApiKey);
+ $apiKey = $this->scopeConfig->getValue(
+ 'fraud_protection/signifyd/api_key',
+ ScopeInterface::SCOPE_STORE
+ );
return $apiKey;
}
@@ -73,7 +69,10 @@ public function getApiKey()
*/
public function getApiUrl()
{
- $apiUrl = $this->scopeConfig->getValue('fraud_protection/signifyd/api_url');
+ $apiUrl = $this->scopeConfig->getValue(
+ 'fraud_protection/signifyd/api_url',
+ ScopeInterface::SCOPE_STORE
+ );
return $apiUrl;
}
@@ -84,7 +83,10 @@ public function getApiUrl()
*/
public function isDebugModeEnabled()
{
- $debugModeEnabled = $this->scopeConfig->isSetFlag('fraud_protection/signifyd/debug');
+ $debugModeEnabled = $this->scopeConfig->isSetFlag(
+ 'fraud_protection/signifyd/debug',
+ ScopeInterface::SCOPE_STORE
+ );
return $debugModeEnabled;
}
diff --git a/app/code/Magento/Signifyd/etc/config.xml b/app/code/Magento/Signifyd/etc/config.xml
index 7ff088dcb0321..da606e2361c40 100644
--- a/app/code/Magento/Signifyd/etc/config.xml
+++ b/app/code/Magento/Signifyd/etc/config.xml
@@ -11,6 +11,8 @@
0
https://api.signifyd.com/v2/
+
+ 0
From 0cff549863237c9d968c5a94494da5cb1403784a Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Wed, 14 Dec 2016 10:05:49 -0600
Subject: [PATCH 029/904] MAGETWO-61913: Create request builders
- Update CreateCaseBuilderTest
---
.../Request/PurchaseBuilder.php | 3 +-
.../Request/CreateCaseBuilderTest.php | 189 ++++++++++++------
.../Magento/Signifyd/_files/case.php | 2 +-
...with_customer_and_two_simple_products.php} | 42 ++--
.../order_with_guest_and_virtual_product.php | 62 ++++++
.../Magento/Signifyd/_files/store.php | 6 +-
6 files changed, 228 insertions(+), 76 deletions(-)
rename dev/tests/integration/testsuite/Magento/Signifyd/_files/{order.php => order_with_customer_and_two_simple_products.php} (73%)
create mode 100644 dev/tests/integration/testsuite/Magento/Signifyd/_files/order_with_guest_and_virtual_product.php
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php
index 3d5cb1e3cc92d..fdb683e61631f 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php
@@ -5,6 +5,7 @@
*/
namespace Magento\Signifyd\Model\SignifydGateway\Request;
+use Magento\Framework\App\Area;
use Magento\Framework\Intl\DateTimeFactory;
use Magento\Framework\Config\ScopeInterface;
use Magento\Sales\Model\Order;
@@ -149,6 +150,6 @@ private function getPaymentGateway($gatewayCode)
*/
private function getOrderChannel()
{
- return $this->scope->getCurrentScope() === 'adminhtml' ? 'PHONE' : 'WEB';
+ return $this->scope->getCurrentScope() === Area::AREA_ADMINHTML ? 'PHONE' : 'WEB';
}
}
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
index 516ecd329bf7e..8d7a88c6c884c 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
@@ -5,6 +5,7 @@
*/
namespace Magento\Signifyd\Model\SignifydGateway\Request;
+use Magento\Framework\Config\ScopeInterface;
use Magento\TestFramework\Helper\Bootstrap;
use Magento\Framework\App\Area;
use Magento\Framework\Intl\DateTimeFactory;
@@ -12,38 +13,24 @@
use Magento\Sales\Model\Order;
use Magento\Customer\Api\CustomerRepositoryInterface;
use Magento\Framework\App\ProductMetadataInterface;
+
/**
- * Class PurchaseBuilderTest
+ * Class CreateCaseBuilderTest
* @magentoAppIsolation enabled
- * @package Magento\Signifyd\Model\SignifydGateway\Request\CreateCaseBuilder
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class CreateCaseBuilderTest extends \PHPUnit_Framework_TestCase
{
- /**
- * Order increment ID
- */
- const ORDER_INCREMENT_ID = '100000001';
-
/**
* @var ObjectManagerInterface
*/
private $objectManager;
- /**
- * @var Order
- */
- private $order;
-
/**
* @var CreateCaseBuilder
*/
private $caseBuilder;
- /**
- * @var array
- */
- private $builderData;
-
/**
* @var DateTimeFactory
*/
@@ -57,47 +44,51 @@ protected function setUp()
$bootstrap = Bootstrap::getInstance();
$bootstrap->loadArea(Area::AREA_FRONTEND);
$this->objectManager = Bootstrap::getObjectManager();
-
$this->dateTimeFactory = $this->objectManager->create(DateTimeFactory::class);
-
- $this->order = $this->objectManager->create(Order::class);
- $this->order->loadByIncrementId(self::ORDER_INCREMENT_ID);
-
$this->caseBuilder = $this->objectManager->create(CreateCaseBuilder::class);
- $this->builderData = $this->caseBuilder->build($this->order->getEntityId());
}
/**
- * Check the stability purchaseBuilder
+ * Test builder on order with customer, simple product, frontend area,
+ * PayPal gateway, shipping and billing addresses, with two orders
*
- * @magentoDataFixture Magento/Signifyd/_files/order.php
+ * @covers \Magento\Signifyd\Model\SignifydGateway\Request\CreateCaseBuilder::build()
+ * @magentoDataFixture Magento/Signifyd/_files/order_with_customer_and_two_simple_products.php
+ * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
- public function testPurchaseBuilder()
+ public function testCreateCaseBuilderWithFullSetOfData()
{
- $orderItems = $this->order->getAllItems();
+ /** @var Order $order */
+ $order = $this->objectManager->create(Order::class);
+ $order->loadByIncrementId('100000001');
+
+ $orderItems = $order->getAllItems();
$product = $orderItems[0]->getProduct();
- $payment = $this->order->getPayment();
- $billingAddress = $this->order->getBillingAddress();
- $shippingAddress = $this->order->getShippingAddress();
+ $payment = $order->getPayment();
+ $billingAddress = $order->getBillingAddress();
+ $shippingAddress = $order->getShippingAddress();
+
+ /** @var CustomerRepositoryInterface $customerRepository */
$customerRepository = $this->objectManager->create(CustomerRepositoryInterface::class);
- $customer = $customerRepository->getById($this->order->getCustomerId());
+ $customer = $customerRepository->getById($order->getCustomerId());
+
$productMetadata = $this->objectManager->create(ProductMetadataInterface::class);
$expected = [
'purchase' => [
- 'browserIpAddress' => $this->order->getRemoteIp(),
- 'orderId' => $this->order->getEntityId(),
+ 'browserIpAddress' => $order->getRemoteIp(),
+ 'orderId' => $order->getEntityId(),
'createdAt' => '2016-12-12T12:00:55+00:00',
'paymentGateway' => 'paypal_account',
'transactionId' => $payment->getLastTransId(),
- 'currency' => $this->order->getOrderCurrencyCode(),
+ 'currency' => $order->getOrderCurrencyCode(),
'orderChannel' => 'WEB',
- 'totalPrice' => $this->order->getGrandTotal(),
+ 'totalPrice' => $order->getGrandTotal(),
'shipments' => [
0 => [
'shipper' => 'Flat Rate',
'shippingMethod' => 'Fixed',
- 'shippingPrice' => $this->order->getShippingAmount()
+ 'shippingPrice' => $order->getShippingAmount()
]
],
'products' => [
@@ -138,6 +129,7 @@ public function testPurchaseBuilder()
'confirmationPhone' => $shippingAddress->getTelephone(),
'deliveryAddress' => [
'streetAddress' => '6161 West Centinela Avenue',
+ 'unit' => 'app. 33',
'city' => $shippingAddress->getCity(),
'provinceCode' => $shippingAddress->getRegionCode(),
'postalCode' => $shippingAddress->getPostcode(),
@@ -147,38 +139,119 @@ public function testPurchaseBuilder()
'userAccount' => [
'email' => $customer->getEmail(),
'username' => $customer->getEmail(),
- 'phone' => $this->order->getBillingAddress()->getTelephone(),
+ 'phone' => $order->getBillingAddress()->getTelephone(),
'accountNumber' => $customer->getId(),
'createdDate' => $this->formatDate($customer->getCreatedAt()),
- 'lastUpdateDate' => $this->formatDate($customer->getUpdatedAt())
+ 'lastUpdateDate' => $this->formatDate($customer->getUpdatedAt()),
+ 'aggregateOrderCount' => 2,
+ 'aggregateOrderDollars' => 150.0
],
- 'seller' => [
- 'name' => 'Sample Store',
- 'domain' => 'm2.com',
- 'shipFromAddress' => [
- 'streetAddress' => '6161 West Centinela Avenue',
- 'unit' => 'app. 111',
- 'city' => 'Culver City',
- 'provinceCode' => 'AE',
- 'postalCode' => '90230',
- 'countryCode' => 1,
- ],
- 'corporateAddress' => [
- 'streetAddress' => '5th Avenue',
- 'unit' => '75',
- 'city' => 'New York',
- 'provinceCode' => 'MH',
- 'postalCode' => '19032',
- 'countryCode' => 1,
- ],
+ 'seller' => $this->getSellerData(),
+ 'clientVersion' => [
+ 'platform' => $productMetadata->getName() . ' ' . $productMetadata->getEdition(),
+ 'platformVersion' => $productMetadata->getVersion()
+ ]
+ ];
+
+
+ static::assertEquals(
+ $expected,
+ $this->caseBuilder->build($order->getEntityId())
+ );
+ }
+
+ /**
+ * Test builder on order with guest, virtual product, admin area,
+ * none PayPal gateway, no shipping address, without credit card data
+ *
+ * @covers \Magento\Signifyd\Model\SignifydGateway\Request\CreateCaseBuilder::build()
+ * @magentoDataFixture Magento/Signifyd/_files/order_with_guest_and_virtual_product.php
+ */
+ public function testCreateCaseBuilderWithVirtualProductAndGuest()
+ {
+ /** @var Order $order */
+ $order = $this->objectManager->create(Order::class);
+ $order->loadByIncrementId('100000002');
+
+ $scope = $this->objectManager->get(ScopeInterface::class);
+ $scope->setCurrentScope(Area::AREA_ADMINHTML);
+
+ $orderItems = $order->getAllItems();
+ $product = $orderItems[0]->getProduct();
+ $payment = $order->getPayment();
+ $billingAddress = $order->getBillingAddress();
+ $productMetadata = $this->objectManager->create(ProductMetadataInterface::class);
+
+ $expected = [
+ 'purchase' => [
+ 'browserIpAddress' => $order->getRemoteIp(),
+ 'orderId' => $order->getEntityId(),
+ 'createdAt' => '2016-12-12T12:00:55+00:00',
+ 'paymentGateway' => $payment->getMethod(),
+ 'transactionId' => $payment->getLastTransId(),
+ 'currency' => $order->getOrderCurrencyCode(),
+ 'orderChannel' => 'PHONE',
+ 'totalPrice' => $order->getGrandTotal(),
+ 'products' => [
+ 0 => [
+ 'itemId' => $orderItems[0]->getSku(),
+ 'itemName' => $orderItems[0]->getName(),
+ 'itemPrice' => $orderItems[0]->getPrice(),
+ 'itemQuantity' => $orderItems[0]->getQtyOrdered(),
+ 'itemUrl' => $product->getProductUrl()
+ ],
+ ]
+ ],
+ 'card' => [
+ 'cardHolderName' => 'firstname lastname',
+ 'billingAddress' => [
+ 'streetAddress' => 'street',
+ 'city' => $billingAddress->getCity(),
+ 'provinceCode' => $billingAddress->getRegionCode(),
+ 'postalCode' => $billingAddress->getPostcode(),
+ 'countryCode' => $billingAddress->getCountryId()
+ ]
],
+ 'seller' => $this->getSellerData(),
'clientVersion' => [
'platform' => $productMetadata->getName() . ' ' . $productMetadata->getEdition(),
'platformVersion' => $productMetadata->getVersion()
]
];
- static::assertEquals($expected, $this->builderData);
+ static::assertEquals(
+ $expected,
+ $this->caseBuilder->build($order->getEntityId())
+ );
+ }
+
+ /**
+ * Return seller data according to fixture
+ *
+ * @return array
+ */
+ private function getSellerData()
+ {
+ return [
+ 'name' => 'Sample Store',
+ 'domain' => 'm2.com',
+ 'shipFromAddress' => [
+ 'streetAddress' => '6161 West Centinela Avenue',
+ 'unit' => 'app. 111',
+ 'city' => 'Culver City',
+ 'provinceCode' => 'AE',
+ 'postalCode' => '90230',
+ 'countryCode' => 'US',
+ ],
+ 'corporateAddress' => [
+ 'streetAddress' => '5th Avenue',
+ 'unit' => '75',
+ 'city' => 'New York',
+ 'provinceCode' => 'MH',
+ 'postalCode' => '19032',
+ 'countryCode' => 'US',
+ ],
+ ];
}
/**
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/_files/case.php b/dev/tests/integration/testsuite/Magento/Signifyd/_files/case.php
index 148c831a9f2d7..de635ba750399 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/_files/case.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/_files/case.php
@@ -7,7 +7,7 @@
use Magento\Signifyd\Api\Data\CaseInterface;
use Magento\Signifyd\Api\Data\CaseInterfaceFactory;
-require __DIR__ . '/order.php';
+require __DIR__ . '/order_with_customer_and_two_simple_products.php';
/** @var CaseInterfaceFactory $caseFactory */
$caseFactory = $objectManager->get(CaseInterfaceFactory::class);
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/_files/order.php b/dev/tests/integration/testsuite/Magento/Signifyd/_files/order_with_customer_and_two_simple_products.php
similarity index 73%
rename from dev/tests/integration/testsuite/Magento/Signifyd/_files/order.php
rename to dev/tests/integration/testsuite/Magento/Signifyd/_files/order_with_customer_and_two_simple_products.php
index 092b31553f3a7..53ab5fd724e45 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/_files/order.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/_files/order_with_customer_and_two_simple_products.php
@@ -9,15 +9,13 @@
use Magento\Sales\Model\Order\Item;
use Magento\Sales\Api\OrderRepositoryInterface;
use Magento\TestFramework\Helper\Bootstrap;
-use Magento\Paypal\Model\Config as PaypalConfig;
-use Magento\Sales\Model\Order\Shipment\Item as ShipmentItem;
-use Magento\Sales\Model\Order\Shipment;
require __DIR__ . '/../../../Magento/Catalog/_files/product_simple.php';
require __DIR__ . '/../../../Magento/Customer/_files/customer.php';
require __DIR__ . '/store.php';
-$addressData = require __DIR__ . '/../../../Magento/Sales/_files/address_data.php';
+$addressData = include __DIR__ . '/../../../Magento/Sales/_files/address_data.php';
+
$objectManager = Bootstrap::getObjectManager();
@@ -27,13 +25,13 @@
$shippingAddress = clone $billingAddress;
$shippingAddress->setId(null)
->setAddressType('shipping')
- ->setStreet('6161 West Centinela Avenue')
+ ->setStreet(['6161 West Centinela Avenue', 'app. 33'])
->setFirstname('John')
->setLastname('Doe')
->setShippingMethod('flatrate_flatrate');
$payment = $objectManager->create(Payment::class);
-$payment->setMethod(PaypalConfig::METHOD_WPP_EXPRESS)
+$payment->setMethod('paypal_express')
->setLastTransId('00001')
->setCcLast4('1234')
->setCcExpMonth('01')
@@ -75,6 +73,7 @@
->setRemoteIp('127.0.0.1')
->setCreatedAt('2016-12-12T12:00:55+0000')
->setOrderCurrencyCode('USD')
+ ->setBaseCurrencyCode('USD')
->setSubtotal($orderAmount)
->setGrandTotal($orderAmount)
->setBaseSubtotal($orderAmount)
@@ -93,12 +92,27 @@
$orderRepository = $objectManager->get(OrderRepositoryInterface::class);
$orderRepository->save($order);
-$shipmentItem = $objectManager->create(ShipmentItem::class);
-$shipmentItem->setOrderItem($orderItem1);
+$orderAmount2 = 50;
+$payment2 = $objectManager->create(Payment::class);
+$payment2->setMethod('checkmo');
+/** @var Order $order2 */
+$order2 = $objectManager->create(Order::class);
+$order2->setIncrementId('100000005')
+ ->setCustomerId($customer->getId())
+ ->setCustomerIsGuest(false)
+ ->setRemoteIp('127.0.0.1')
+ ->setCreatedAt('2016-12-12T12:00:55+0000')
+ ->setOrderCurrencyCode('USD')
+ ->setBaseCurrencyCode('USD')
+ ->setGrandTotal($orderAmount2)
+ ->setBaseGrandTotal($orderAmount2)
+ ->setCustomerEmail($customerEmail)
+ ->setBillingAddress($billingAddress)
+ ->setShippingAddress($shippingAddress)
+ ->setShippingDescription('Flat Rate - Fixed')
+ ->setShippingAmount(10)
+ ->setStoreId($store->getId())
+ ->addItem($orderItem1)
+ ->setPayment($payment2);
-/** @var Shipment $shipment */
-$shipment = $objectManager->create(Shipment::class);
-$shipment->setOrder($order)
- ->addItem($shipmentItem)
- ->setShipmentStatus(Shipment::STATUS_NEW)
- ->save();
+$orderRepository->save($order2);
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/_files/order_with_guest_and_virtual_product.php b/dev/tests/integration/testsuite/Magento/Signifyd/_files/order_with_guest_and_virtual_product.php
new file mode 100644
index 0000000000000..fa0d00be90497
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/_files/order_with_guest_and_virtual_product.php
@@ -0,0 +1,62 @@
+create(Address::class, ['data' => $addressData]);
+$billingAddress->setAddressType('billing');
+
+$payment = $objectManager->create(Payment::class);
+$payment->setMethod('braintree')
+ ->setLastTransId('00001');
+
+/** @var Item $orderItem */
+$orderItem1 = $objectManager->create(Item::class);
+$orderItem1->setProductId($product->getId())
+ ->setSku($product->getSku())
+ ->setName($product->getName())
+ ->setQtyOrdered(1)
+ ->setBasePrice($product->getPrice())
+ ->setPrice($product->getPrice())
+ ->setRowTotal($product->getPrice())
+ ->setProductType($product->getTypeId());
+
+$orderAmount = 100;
+$customerEmail = $billingAddress->getEmail();
+
+/** @var Order $order */
+$order = $objectManager->create(Order::class);
+$order->setIncrementId('100000002')
+ ->setState(Order::STATE_PROCESSING)
+ ->setStatus(Order::STATE_PROCESSING)
+ ->setCustomerIsGuest(true)
+ ->setRemoteIp('127.0.0.1')
+ ->setCreatedAt('2016-12-12T12:00:55+0000')
+ ->setOrderCurrencyCode('USD')
+ ->setBaseCurrencyCode('USD')
+ ->setSubtotal($orderAmount)
+ ->setGrandTotal($orderAmount)
+ ->setBaseSubtotal($orderAmount)
+ ->setBaseGrandTotal($orderAmount)
+ ->setCustomerEmail($customerEmail)
+ ->setBillingAddress($billingAddress)
+ ->setStoreId($store->getId())
+ ->addItem($orderItem1)
+ ->setPayment($payment);
+
+/** @var OrderRepositoryInterface $orderRepository */
+$orderRepository = $objectManager->get(OrderRepositoryInterface::class);
+$orderRepository->save($order);
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/_files/store.php b/dev/tests/integration/testsuite/Magento/Signifyd/_files/store.php
index 9a20bb1982069..e27f9a4e7370c 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/_files/store.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/_files/store.php
@@ -10,7 +10,9 @@
use Magento\Store\Model\StoreManagerInterface;
use Magento\Sales\Model\Order\Shipment;
use Magento\Framework\App\Config\MutableScopeConfigInterface;
+use Magento\TestFramework\Helper\Bootstrap;
+$objectManager = Bootstrap::getObjectManager();
$store = $objectManager->get(StoreManagerInterface::class)->getStore();
/** @var MutableScopeConfigInterface $mutableConfig */
$mutableConfig = $objectManager->get(MutableScopeConfigInterface::class);
@@ -21,11 +23,11 @@
$mutableConfig->setValue(Shipment::XML_PATH_STORE_CITY, 'Culver City', ScopeInterface::SCOPE_STORE);
$mutableConfig->setValue(Shipment::XML_PATH_STORE_REGION_ID, 10, ScopeInterface::SCOPE_STORE);
$mutableConfig->setValue(Shipment::XML_PATH_STORE_ZIP, '90230', ScopeInterface::SCOPE_STORE);
-$mutableConfig->setValue(Shipment::XML_PATH_STORE_COUNTRY_ID, 1, ScopeInterface::SCOPE_STORE);
+$mutableConfig->setValue(Shipment::XML_PATH_STORE_COUNTRY_ID, 'US', ScopeInterface::SCOPE_STORE);
$mutableConfig->setValue(Information::XML_PATH_STORE_INFO_STREET_LINE1, '5th Avenue', ScopeInterface::SCOPE_STORE);
$mutableConfig->setValue(Information::XML_PATH_STORE_INFO_STREET_LINE2, '75', ScopeInterface::SCOPE_STORE);
$mutableConfig->setValue(Information::XML_PATH_STORE_INFO_CITY, 'New York', ScopeInterface::SCOPE_STORE);
$mutableConfig->setValue(Information::XML_PATH_STORE_INFO_REGION_CODE, 30, ScopeInterface::SCOPE_STORE);
$mutableConfig->setValue(Information::XML_PATH_STORE_INFO_POSTCODE, '19032', ScopeInterface::SCOPE_STORE);
-$mutableConfig->setValue(Information::XML_PATH_STORE_INFO_COUNTRY_CODE, 1, ScopeInterface::SCOPE_STORE);
+$mutableConfig->setValue(Information::XML_PATH_STORE_INFO_COUNTRY_CODE, 'US', ScopeInterface::SCOPE_STORE);
From ce95f1de80d53d1c8f23e82098c8b572d775a8c7 Mon Sep 17 00:00:00 2001
From: Volodymyr Kublytskyi
Date: Wed, 14 Dec 2016 11:00:54 -0600
Subject: [PATCH 030/904] MAGETWO-61914: Create case request to Signifyd
- Refactoring: apply code standards
---
.../Api/CaseCreationServiceInterface.php | 5 +-
.../Signifyd/Model/CaseCreationService.php | 3 +-
app/code/Magento/Signifyd/Model/Config.php | 6 +-
.../SignifydGateway/Request/SellerBuilder.php | 1 -
.../SignifydApiCallException.php | 2 +-
.../SignifydGateway/SignifydApiClient.php | 85 +++++++++++--------
.../SignifydApiResponseException.php | 2 +-
.../Model/SignifydGateway/SignifydGateway.php | 4 +-
.../SignifydGatewayException.php | 2 +-
.../Magento/Signifyd/Observer/PlaceOrder.php | 3 +-
10 files changed, 60 insertions(+), 53 deletions(-)
diff --git a/app/code/Magento/Signifyd/Api/CaseCreationServiceInterface.php b/app/code/Magento/Signifyd/Api/CaseCreationServiceInterface.php
index d1bddc29d76f8..939f64409a577 100644
--- a/app/code/Magento/Signifyd/Api/CaseCreationServiceInterface.php
+++ b/app/code/Magento/Signifyd/Api/CaseCreationServiceInterface.php
@@ -18,9 +18,8 @@ interface CaseCreationServiceInterface
/**
* Create new case for order with specified id.
*
- * @param $orderId
+ * @param int $orderId
* @return bool
*/
public function createForOrder($orderId);
-
-}
+}
\ No newline at end of file
diff --git a/app/code/Magento/Signifyd/Model/CaseCreationService.php b/app/code/Magento/Signifyd/Model/CaseCreationService.php
index d876fe6585cc0..8c761a1c8fee0 100644
--- a/app/code/Magento/Signifyd/Model/CaseCreationService.php
+++ b/app/code/Magento/Signifyd/Model/CaseCreationService.php
@@ -64,5 +64,4 @@ public function createForOrder($orderId)
return true;
}
-
-}
\ No newline at end of file
+}
diff --git a/app/code/Magento/Signifyd/Model/Config.php b/app/code/Magento/Signifyd/Model/Config.php
index af3f26b80b5ca..f99480386293a 100644
--- a/app/code/Magento/Signifyd/Model/Config.php
+++ b/app/code/Magento/Signifyd/Model/Config.php
@@ -25,7 +25,8 @@ class Config
*
* @param ScopeConfigInterface $scopeConfig
*/
- public function __construct(ScopeConfigInterface $scopeConfig) {
+ public function __construct(ScopeConfigInterface $scopeConfig)
+ {
$this->scopeConfig = $scopeConfig;
}
@@ -89,5 +90,4 @@ public function isDebugModeEnabled()
);
return $debugModeEnabled;
}
-
-}
\ No newline at end of file
+}
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/SellerBuilder.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/SellerBuilder.php
index f3129e441a5a9..9b8af9535407c 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/SellerBuilder.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/SellerBuilder.php
@@ -131,5 +131,4 @@ private function getPublicDomain(StoreInterface $store)
return $domain;
}
-
}
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/SignifydApiCallException.php b/app/code/Magento/Signifyd/Model/SignifydGateway/SignifydApiCallException.php
index e62ece8946926..ea1a1f73dfa1b 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/SignifydApiCallException.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/SignifydApiCallException.php
@@ -11,4 +11,4 @@
class SignifydApiCallException extends SignifydGatewayException
{
-}
\ No newline at end of file
+}
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/SignifydApiClient.php b/app/code/Magento/Signifyd/Model/SignifydGateway/SignifydApiClient.php
index b2a7be8b752f7..7c70bf8770ab3 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/SignifydApiClient.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/SignifydApiClient.php
@@ -44,7 +44,7 @@ class SignifydApiClient
* Class uses client factory to instantiate new client for interacting with API.
* All requests and responses are processed by JSON encoder and decoder.
*
- * @aparm Config $config
+ * @param Config $config
* @param ZendClientFactory $clientFactory
* @param EncoderInterface $dataEncoder
* @param DecoderInterface $dataDecoder
@@ -67,8 +67,8 @@ public function __construct(
* Method returns associative array that corresponds to successful result.
* Current implementation do not expose details in case of failure.
*
- * @param $url
- * @param $method
+ * @param string $url
+ * @param string $method
* @param array $params
* @return array
* @throws SignifydApiCallException
@@ -92,8 +92,8 @@ public function makeApiCall($url, $method, array $params = [])
/**
* Send HTTP request to Signifyd API.
*
- * @param $url
- * @param $method
+ * @param string $url
+ * @param string $method
* @param array $params
* @return \Zend_Http_Response
* @throws SignifydApiCallException
@@ -124,50 +124,62 @@ private function sendRequest($url, $method, array $params = [])
*
* @param \Zend_Http_Response $response
*
- * @return mixed
+ * @return array
* @throws SignifydApiCallException
* @throws SignifydApiResponseException
*/
private function handleResponse(\Zend_Http_Response $response)
{
+ $responseCode = $response->getStatus();
+ $successResponseCodes = [200, 201, 204];
+
+ if (!in_array($responseCode, $successResponseCodes)) {
+ $errorMessage = $this->buildApiCallFailureMesage($response);
+ throw new SignifydApiResponseException($errorMessage);
+ }
+
$responseBody = $response->getBody();
+ try {
+ $decodedResponseBody = $this->dataDecoder->decode($responseBody);
+ } catch (\Exception $e) {
+ throw new SignifydApiResponseException(
+ 'Signifyd API response is not valid JSON: ' . $e->getMessage(),
+ $e->getCode(),
+ $e
+ );
+ }
+ return $decodedResponseBody;
+ }
+
+ /**
+ * Make error message for request rejected by Signify
+ *
+ * @param \Zend_Http_Response $response
+ * @return string
+ */
+ private function buildApiCallFailureMesage(\Zend_Http_Response $response)
+ {
+ $responseBody = $response->getBody();
switch ($response->getStatus()) {
- case 200:
- case 201:
- case 204:
- try {
- $decodedResponseBody = $this->dataDecoder->decode($responseBody);
- } catch (\Exception $e) {
- throw new SignifydApiResponseException('Signifyd API response is not valid JSON.');
- }
- return $decodedResponseBody;
case 400:
- throw new SignifydApiCallException(
- 'Bad Request - The request could not be parsed. Response: ' . $responseBody
- );
+ return 'Bad Request - The request could not be parsed. Response: ' . $responseBody;
case 404:
- throw new SignifydApiCallException(
- 'Not Found - resource does not exist. Response: ' . $responseBody
- );
+ return 'Not Found - resource does not exist. Response: ' . $responseBody;
case 409:
- throw new SignifydApiCallException(
- 'Conflict - with state of the resource on server. Can occur with (too rapid) PUT requests.' .
- 'Response: ' . $responseBody
- );
+ return 'Conflict - with state of the resource on server. Can occur with (too rapid) PUT requests.' .
+ 'Response: ' . $responseBody;
case 401:
- throw new SignifydApiCallException(
- 'Unauthorized - user is not logged in, could not be authenticated. Response: ' . $responseBody
- );
+ 'Unauthorized - user is not logged in, could not be authenticated. Response: ' . $responseBody;
case 403:
- throw new SignifydApiCallException(
- 'Forbidden - Cannot access resource. Response: ' . $responseBody
- );
+ 'Forbidden - Cannot access resource. Response: ' . $responseBody;
case 500:
- throw new SignifydApiCallException('Server error.');
+ return 'Server error.';
default:
- throw new SignifydApiResponseException(
- sprintf('Unexpected Signifyd API response code "%s"', $response->getStatus())
+ return sprintf(
+ 'Unexpected Signifyd API response code "%s" with content "%s".',
+ $response->getStatus(),
+ $responseBody
);
}
}
@@ -194,7 +206,7 @@ private function getApiKey()
/**
* Builds full URL for Singifyd API based on relative URL
*
- * @param $url
+ * @param string $url
* @return string
*/
private function buildFullApiUrl($url)
@@ -214,5 +226,4 @@ private function getBaseApiUrl()
$baseApiUrl = $this->config->getApiUrl();
return rtrim($baseApiUrl, '/');
}
-
-}
\ No newline at end of file
+}
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/SignifydApiResponseException.php b/app/code/Magento/Signifyd/Model/SignifydGateway/SignifydApiResponseException.php
index cd6d9113e2119..a353537074fea 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/SignifydApiResponseException.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/SignifydApiResponseException.php
@@ -11,4 +11,4 @@
class SignifydApiResponseException extends SignifydGatewayException
{
-}
\ No newline at end of file
+}
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/SignifydGateway.php b/app/code/Magento/Signifyd/Model/SignifydGateway/SignifydGateway.php
index 0626f727168b0..0975b9359aab6 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/SignifydGateway.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/SignifydGateway.php
@@ -40,7 +40,7 @@ public function __construct(
}
/**
- * @param $orderId
+ * @param int $orderId
* @return int Signifyd case (investigation) identifier
* @throws SignifydGatewayException
*/
@@ -60,4 +60,4 @@ public function createCase($orderId)
return (int)$caseCreationResult['investigationId'];
}
-}
\ No newline at end of file
+}
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/SignifydGatewayException.php b/app/code/Magento/Signifyd/Model/SignifydGateway/SignifydGatewayException.php
index d1d46a7d79445..7deb44fba132d 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/SignifydGatewayException.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/SignifydGatewayException.php
@@ -11,4 +11,4 @@
class SignifydGatewayException extends \Exception
{
-}
\ No newline at end of file
+}
diff --git a/app/code/Magento/Signifyd/Observer/PlaceOrder.php b/app/code/Magento/Signifyd/Observer/PlaceOrder.php
index 80309e7bbd497..aa9d0d39e5988 100644
--- a/app/code/Magento/Signifyd/Observer/PlaceOrder.php
+++ b/app/code/Magento/Signifyd/Observer/PlaceOrder.php
@@ -79,5 +79,4 @@ private function extractOrder(Event $event)
{
return $event->getData('order');
}
-
-}
\ No newline at end of file
+}
From 23848c66c70fed745aadb7ecdcb3da444a1dfdd0 Mon Sep 17 00:00:00 2001
From: Volodymyr Kublytskyi
Date: Wed, 14 Dec 2016 11:17:19 -0600
Subject: [PATCH 031/904] MAGETWO-61914: Create case request to Signifyd
- Refactoring: renamed gateway classes
---
.../Signifyd/Model/CaseCreationService.php | 12 ++++++------
...ewayException.php => ApiCallException.php} | 2 +-
.../{SignifydApiClient.php => ApiClient.php} | 19 +++++++++----------
...Exception.php => ApiResponseException.php} | 2 +-
.../{SignifydGateway.php => Gateway.php} | 16 ++++++++--------
...onseException.php => GatewayException.php} | 2 +-
6 files changed, 26 insertions(+), 27 deletions(-)
rename app/code/Magento/Signifyd/Model/SignifydGateway/{SignifydGatewayException.php => ApiCallException.php} (81%)
rename app/code/Magento/Signifyd/Model/SignifydGateway/{SignifydApiClient.php => ApiClient.php} (93%)
rename app/code/Magento/Signifyd/Model/SignifydGateway/{SignifydApiCallException.php => ApiResponseException.php} (77%)
rename app/code/Magento/Signifyd/Model/SignifydGateway/{SignifydGateway.php => Gateway.php} (77%)
rename app/code/Magento/Signifyd/Model/SignifydGateway/{SignifydApiResponseException.php => GatewayException.php} (76%)
diff --git a/app/code/Magento/Signifyd/Model/CaseCreationService.php b/app/code/Magento/Signifyd/Model/CaseCreationService.php
index 8c761a1c8fee0..2dc76f4e74d4f 100644
--- a/app/code/Magento/Signifyd/Model/CaseCreationService.php
+++ b/app/code/Magento/Signifyd/Model/CaseCreationService.php
@@ -7,8 +7,8 @@
use Magento\Signifyd\Api\CaseCreationServiceInterface;
use Magento\Signifyd\Api\CaseManagementInterface;
-use Magento\Signifyd\Model\SignifydGateway\SignifydGateway;
-use Magento\Signifyd\Model\SignifydGateway\SignifydGatewayException;
+use Magento\Signifyd\Model\SignifydGateway\Gateway;
+use Magento\Signifyd\Model\SignifydGateway\GatewayException;
use Psr\Log\LoggerInterface;
/**
@@ -24,7 +24,7 @@ class CaseCreationService implements CaseCreationServiceInterface
private $caseManagement;
/**
- * @var SignifydGateway;
+ * @var Gateway;
*/
private $signifydGateway;
@@ -37,12 +37,12 @@ class CaseCreationService implements CaseCreationServiceInterface
* CaseCreationService constructor.
*
* @param CaseManagementInterface $caseManagement
- * @param SignifydGateway $signifydGateway
+ * @param Gateway $signifydGateway
* @param LoggerInterface $logger
*/
public function __construct(
CaseManagementInterface $caseManagement,
- SignifydGateway $signifydGateway,
+ Gateway $signifydGateway,
LoggerInterface $logger
) {
$this->caseManagement = $caseManagement;
@@ -58,7 +58,7 @@ public function createForOrder($orderId)
$this->caseManagement->create($orderId);
try {
$this->signifydGateway->createCase($orderId);
- } catch (SignifydGatewayException $e) {
+ } catch (GatewayException $e) {
$this->logger->error($e->getMessage());
}
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/SignifydGatewayException.php b/app/code/Magento/Signifyd/Model/SignifydGateway/ApiCallException.php
similarity index 81%
rename from app/code/Magento/Signifyd/Model/SignifydGateway/SignifydGatewayException.php
rename to app/code/Magento/Signifyd/Model/SignifydGateway/ApiCallException.php
index 7deb44fba132d..5aaa44e2f0bb7 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/SignifydGatewayException.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/ApiCallException.php
@@ -8,7 +8,7 @@
/**
* Exception of interacation with Signifyd API
*/
-class SignifydGatewayException extends \Exception
+class ApiCallException extends GatewayException
{
}
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/SignifydApiClient.php b/app/code/Magento/Signifyd/Model/SignifydGateway/ApiClient.php
similarity index 93%
rename from app/code/Magento/Signifyd/Model/SignifydGateway/SignifydApiClient.php
rename to app/code/Magento/Signifyd/Model/SignifydGateway/ApiClient.php
index 7c70bf8770ab3..a489c99f500a3 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/SignifydApiClient.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/ApiClient.php
@@ -16,7 +16,7 @@
*
* Encapsulates Signifyd API protocol.
*/
-class SignifydApiClient
+class ApiClient
{
/**
* @var Config
@@ -39,7 +39,7 @@ class SignifydApiClient
private $dataDecoder;
/**
- * SignifydApiClient constructor.
+ * ApiClient constructor.
*
* Class uses client factory to instantiate new client for interacting with API.
* All requests and responses are processed by JSON encoder and decoder.
@@ -71,15 +71,15 @@ public function __construct(
* @param string $method
* @param array $params
* @return array
- * @throws SignifydApiCallException
- * @throws SignifydApiResponseException
+ * @throws ApiCallException
+ * @throws ApiResponseException
*/
public function makeApiCall($url, $method, array $params = [])
{
try {
$response = $this->sendRequest($url, $method, $params);
} catch (\Exception $e) {
- throw new SignifydApiCallException(
+ throw new ApiCallException(
'Unable to call Signifyd API: ' . $e->getMessage(),
$e->getCode(),
$e
@@ -96,7 +96,6 @@ public function makeApiCall($url, $method, array $params = [])
* @param string $method
* @param array $params
* @return \Zend_Http_Response
- * @throws SignifydApiCallException
*/
private function sendRequest($url, $method, array $params = [])
{
@@ -125,8 +124,8 @@ private function sendRequest($url, $method, array $params = [])
* @param \Zend_Http_Response $response
*
* @return array
- * @throws SignifydApiCallException
- * @throws SignifydApiResponseException
+ * @throws ApiCallException
+ * @throws ApiResponseException
*/
private function handleResponse(\Zend_Http_Response $response)
{
@@ -135,14 +134,14 @@ private function handleResponse(\Zend_Http_Response $response)
if (!in_array($responseCode, $successResponseCodes)) {
$errorMessage = $this->buildApiCallFailureMesage($response);
- throw new SignifydApiResponseException($errorMessage);
+ throw new ApiCallException($errorMessage);
}
$responseBody = $response->getBody();
try {
$decodedResponseBody = $this->dataDecoder->decode($responseBody);
} catch (\Exception $e) {
- throw new SignifydApiResponseException(
+ throw new ApiResponseException(
'Signifyd API response is not valid JSON: ' . $e->getMessage(),
$e->getCode(),
$e
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/SignifydApiCallException.php b/app/code/Magento/Signifyd/Model/SignifydGateway/ApiResponseException.php
similarity index 77%
rename from app/code/Magento/Signifyd/Model/SignifydGateway/SignifydApiCallException.php
rename to app/code/Magento/Signifyd/Model/SignifydGateway/ApiResponseException.php
index ea1a1f73dfa1b..80bbe02b17b34 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/SignifydApiCallException.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/ApiResponseException.php
@@ -8,7 +8,7 @@
/**
* Exception of interacation with Signifyd API
*/
-class SignifydApiCallException extends SignifydGatewayException
+class ApiResponseException extends GatewayException
{
}
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/SignifydGateway.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Gateway.php
similarity index 77%
rename from app/code/Magento/Signifyd/Model/SignifydGateway/SignifydGateway.php
rename to app/code/Magento/Signifyd/Model/SignifydGateway/Gateway.php
index 0975b9359aab6..2ffefb65937ee 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/SignifydGateway.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Gateway.php
@@ -6,14 +6,14 @@
namespace Magento\Signifyd\Model\SignifydGateway;
use Magento\Signifyd\Model\SignifydGateway\Request\CreateCaseBuilderInterface;
-use Magento\Signifyd\Model\SignifydGateway\SignifydApiClient;
+use Magento\Signifyd\Model\SignifydGateway\ApiClient;
/**
* Signifyd Gateway.
*
* Encapsulates interaction with Signifyd API.
*/
-class SignifydGateway
+class Gateway
{
/**
* @var CreateCaseBuilderInterface
@@ -21,19 +21,19 @@ class SignifydGateway
private $createCaseBuilder;
/**
- * @var SignifydApiClient
+ * @var ApiClient
*/
private $apiClient;
/**
- * SignifydGateway constructor.
+ * Gateway constructor.
*
* @param CreateCaseBuilderInterface $createCaseBuilder
- * @param SignifydApiClient $apiClient
+ * @param ApiClient $apiClient
*/
public function __construct(
CreateCaseBuilderInterface $createCaseBuilder,
- SignifydApiClient $apiClient
+ ApiClient $apiClient
) {
$this->createCaseBuilder = $createCaseBuilder;
$this->apiClient = $apiClient;
@@ -42,7 +42,7 @@ public function __construct(
/**
* @param int $orderId
* @return int Signifyd case (investigation) identifier
- * @throws SignifydGatewayException
+ * @throws GatewayException
*/
public function createCase($orderId)
{
@@ -55,7 +55,7 @@ public function createCase($orderId)
);
if (!isset($caseCreationResult['investigationId'])) {
- throw new SignifydGatewayException('Expected field "investigationId" missed.');
+ throw new GatewayException('Expected field "investigationId" missed.');
}
return (int)$caseCreationResult['investigationId'];
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/SignifydApiResponseException.php b/app/code/Magento/Signifyd/Model/SignifydGateway/GatewayException.php
similarity index 76%
rename from app/code/Magento/Signifyd/Model/SignifydGateway/SignifydApiResponseException.php
rename to app/code/Magento/Signifyd/Model/SignifydGateway/GatewayException.php
index a353537074fea..21066f8872d32 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/SignifydApiResponseException.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/GatewayException.php
@@ -8,7 +8,7 @@
/**
* Exception of interacation with Signifyd API
*/
-class SignifydApiResponseException extends SignifydGatewayException
+class GatewayException extends \Exception
{
}
From a2d512ef53e767184a4e44e4f79e23fef1536204 Mon Sep 17 00:00:00 2001
From: Volodymyr Kublytskyi
Date: Wed, 14 Dec 2016 11:30:27 -0600
Subject: [PATCH 032/904] MAGETWO-61914: Create case request to Signifyd
- fixed refactoring issues
---
.../Magento/Signifyd/Api/CaseCreationServiceInterface.php | 2 +-
app/code/Magento/Signifyd/Model/SignifydGateway/ApiClient.php | 4 ++--
.../Model/SignifydGateway/Request/CreateCaseBuilderTest.php | 1 -
3 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/app/code/Magento/Signifyd/Api/CaseCreationServiceInterface.php b/app/code/Magento/Signifyd/Api/CaseCreationServiceInterface.php
index 939f64409a577..2118652f31a7d 100644
--- a/app/code/Magento/Signifyd/Api/CaseCreationServiceInterface.php
+++ b/app/code/Magento/Signifyd/Api/CaseCreationServiceInterface.php
@@ -22,4 +22,4 @@ interface CaseCreationServiceInterface
* @return bool
*/
public function createForOrder($orderId);
-}
\ No newline at end of file
+}
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/ApiClient.php b/app/code/Magento/Signifyd/Model/SignifydGateway/ApiClient.php
index a489c99f500a3..5de361eec7975 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/ApiClient.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/ApiClient.php
@@ -169,9 +169,9 @@ private function buildApiCallFailureMesage(\Zend_Http_Response $response)
return 'Conflict - with state of the resource on server. Can occur with (too rapid) PUT requests.' .
'Response: ' . $responseBody;
case 401:
- 'Unauthorized - user is not logged in, could not be authenticated. Response: ' . $responseBody;
+ return 'Unauthorized - user is not logged in, could not be authenticated. Response: ' . $responseBody;
case 403:
- 'Forbidden - Cannot access resource. Response: ' . $responseBody;
+ return 'Forbidden - Cannot access resource. Response: ' . $responseBody;
case 500:
return 'Server error.';
default:
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
index 8d7a88c6c884c..2665e9756e0f3 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
@@ -153,7 +153,6 @@ public function testCreateCaseBuilderWithFullSetOfData()
]
];
-
static::assertEquals(
$expected,
$this->caseBuilder->build($order->getEntityId())
From 2393f41d654a04e483be3f633e93271100638bf4 Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Wed, 14 Dec 2016 11:34:44 -0600
Subject: [PATCH 033/904] MAGETWO-61929: Create integration tests
- Added test to cover case for orders with different currencies
---
.../Request/UserAccountBuilderTest.php | 247 ++++++++++++++++++
1 file changed, 247 insertions(+)
create mode 100644 app/code/Magento/Signifyd/Test/Unit/SignifydGateway/Request/UserAccountBuilderTest.php
diff --git a/app/code/Magento/Signifyd/Test/Unit/SignifydGateway/Request/UserAccountBuilderTest.php b/app/code/Magento/Signifyd/Test/Unit/SignifydGateway/Request/UserAccountBuilderTest.php
new file mode 100644
index 0000000000000..a5d6ea624c1a6
--- /dev/null
+++ b/app/code/Magento/Signifyd/Test/Unit/SignifydGateway/Request/UserAccountBuilderTest.php
@@ -0,0 +1,247 @@
+objectManager = new ObjectManager($this);
+
+ $this->customerOrdersService = $this->getMockBuilder(CustomerOrders::class)
+ ->disableOriginalConstructor()
+ ->setMethods(['get'])
+ ->getMock();
+
+ $this->customerRepository = $this->getMockBuilder(CustomerRepositoryInterface::class)
+ ->setMethods(['getById'])
+ ->getMockForAbstractClass();
+
+ $dateTimeFactory = new DateTimeFactory();
+
+ $this->builder = $this->objectManager->getObject(UserAccountBuilder::class, [
+ 'customerRepository' => $this->customerRepository,
+ 'dateTimeFactory' => $dateTimeFactory,
+ 'customerOrders' => $this->customerOrdersService
+ ]);
+
+ $this->initCurrencies();
+
+ $this->objectManager->setBackwardCompatibleProperty(
+ $this->builder,
+ 'currencies',
+ ['EUR' => $this->eurCurrency, 'UAH' => $this->uahCurrency]
+ );
+ }
+
+ /**
+ * @covers \Magento\Signifyd\Model\SignifydGateway\Request\UserAccountBuilder::build
+ */
+ public function testBuild()
+ {
+ $order = $this->getOrder();
+
+ $customer = $this->getMockBuilder(CustomerInterface::class)
+ ->setMethods(['getEmail', 'getCreatedAt', 'getUpdatedAt'])
+ ->getMockForAbstractClass();
+ $customer->expects(static::exactly(2))
+ ->method('getEmail')
+ ->willReturn('jonh.doe@testmage.com');
+ $customer->expects(static::once())
+ ->method('getCreatedAt')
+ ->willReturn('2016-10-12 12:23:12');
+ $customer->expects(static::once())
+ ->method('getUpdatedAt')
+ ->willReturn('2016-12-14 18:19:00');
+
+ $this->customerRepository->expects(static::once())
+ ->method('getById')
+ ->with(self::$customerId)
+ ->willReturn($customer);
+
+ $orders = $this->getOrders();
+ $this->customerOrdersService->expects(static::once())
+ ->method('get')
+ ->with(self::$customerId)
+ ->willReturn($orders);
+
+ $this->eurCurrency->expects(static::once())
+ ->method('convert')
+ ->with(self::$eurAmount, 'USD')
+ ->willReturn(109);
+
+ $this->uahCurrency->expects(static::once())
+ ->method('convert')
+ ->with(self::$uahAmount, 'USD')
+ ->willReturn(10.35);
+
+ $actual = $this->builder->build($order);
+
+ static::assertEquals(3, $actual['userAccount']['aggregateOrderCount']);
+ static::assertEquals(169.35, $actual['userAccount']['aggregateOrderDollars']);
+ }
+
+ /**
+ * Creates mocks for currencies
+ * @return void
+ */
+ private function initCurrencies()
+ {
+ $this->eurCurrency = $this->getMockBuilder(Currency::class)
+ ->disableOriginalConstructor()
+ ->setMethods(['convert'])
+ ->getMock();
+
+ $this->uahCurrency = $this->getMockBuilder(Currency::class)
+ ->disableOriginalConstructor()
+ ->setMethods(['convert'])
+ ->getMock();
+ }
+
+ /**
+ * Creates order mock
+ * @return Order|MockObject
+ */
+ private function getOrder()
+ {
+ $order = $this->getMockBuilder(Order::class)
+ ->disableOriginalConstructor()
+ ->setMethods(['getBillingAddress', 'getCustomerId'])
+ ->getMock();
+
+ $order->expects(static::once())
+ ->method('getCustomerId')
+ ->willReturn(self::$customerId);
+
+ $billingAddress = $this->getMockBuilder(OrderAddressInterface::class)
+ ->setMethods(['getTelephone'])
+ ->getMockForAbstractClass();
+ $billingAddress->expects(static::once())
+ ->method('getTelephone')
+ ->willReturn('444-444-44');
+
+ $order->expects(static::once())
+ ->method('getBillingAddress')
+ ->willReturn($billingAddress);
+
+ return $order;
+ }
+
+ /**
+ * Get list of mocked orders with different currencies
+ * @return array
+ */
+ private function getOrders()
+ {
+ $eurOrder = $this->getMockBuilder(Order::class)
+ ->disableOriginalConstructor()
+ ->setMethods(['getBaseGrandTotal', 'getBaseCurrencyCode'])
+ ->getMock();
+
+ $eurOrder->expects(static::once())
+ ->method('getBaseGrandTotal')
+ ->willReturn(self::$eurAmount);
+ $eurOrder->expects(static::once())
+ ->method('getBaseCurrencyCode')
+ ->willReturn('EUR');
+
+ $uahOrder = $this->getMockBuilder(Order::class)
+ ->disableOriginalConstructor()
+ ->setMethods(['getBaseGrandTotal', 'getBaseCurrencyCode'])
+ ->getMock();
+
+ $uahOrder->expects(static::once())
+ ->method('getBaseGrandTotal')
+ ->willReturn(self::$uahAmount);
+ $uahOrder->expects(static::once())
+ ->method('getBaseCurrencyCode')
+ ->willReturn('UAH');
+
+ $usdOrder = $this->getMockBuilder(Order::class)
+ ->disableOriginalConstructor()
+ ->setMethods(['getBaseGrandTotal', 'getBaseCurrencyCode'])
+ ->getMock();
+
+ $usdOrder->expects(static::once())
+ ->method('getBaseGrandTotal')
+ ->willReturn(self::$usdAmount);
+ $usdOrder->expects(static::once())
+ ->method('getBaseCurrencyCode')
+ ->willReturn('USD');
+
+ return [$eurOrder, $uahOrder, $usdOrder];
+ }
+}
From 8ad50801ef6a1195f9527612c2400b63d2699c23 Mon Sep 17 00:00:00 2001
From: Volodymyr Kublytskyi
Date: Thu, 15 Dec 2016 04:13:21 -0600
Subject: [PATCH 034/904] MAGETWO-61914: Create case request to Signifyd
- improved observer implementation in case of disabled Signifyd integration
---
app/code/Magento/Signifyd/Observer/PlaceOrder.php | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/app/code/Magento/Signifyd/Observer/PlaceOrder.php b/app/code/Magento/Signifyd/Observer/PlaceOrder.php
index aa9d0d39e5988..2eba75225ffcd 100644
--- a/app/code/Magento/Signifyd/Observer/PlaceOrder.php
+++ b/app/code/Magento/Signifyd/Observer/PlaceOrder.php
@@ -50,6 +50,10 @@ public function __construct(
*/
public function execute(Observer $observer)
{
+ if (!$this->signifydIntegrationConfig->isEnabled()) {
+ return;
+ }
+
$event = $observer->getEvent();
$order = $this->extractOrder($event);
@@ -62,10 +66,6 @@ public function execute(Observer $observer)
return;
}
- if (!$this->signifydIntegrationConfig->isEnabled()) {
- return;
- }
-
$this->caseCreationService->createForOrder($orderId);
}
From 66c5ba85f54538cb4ed31787bf9103985b58b5d8 Mon Sep 17 00:00:00 2001
From: Volodymyr Kublytskyi
Date: Thu, 15 Dec 2016 04:14:37 -0600
Subject: [PATCH 035/904] MAGETWO-61914: Create case request to Signifyd
- fixed typo in guard condition
---
app/code/Magento/Signifyd/Observer/PlaceOrder.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/code/Magento/Signifyd/Observer/PlaceOrder.php b/app/code/Magento/Signifyd/Observer/PlaceOrder.php
index 2eba75225ffcd..f59dc7769e310 100644
--- a/app/code/Magento/Signifyd/Observer/PlaceOrder.php
+++ b/app/code/Magento/Signifyd/Observer/PlaceOrder.php
@@ -62,7 +62,7 @@ public function execute(Observer $observer)
}
$orderId = $order->getEntityId();
- if (null === $order) {
+ if (null === $orderId) {
return;
}
From bc5f1d89317a6caf7d0cd65a78dcb5ec89975df7 Mon Sep 17 00:00:00 2001
From: Volodymyr Kublytskyi
Date: Thu, 15 Dec 2016 04:18:55 -0600
Subject: [PATCH 036/904] MAGETWO-61914: Create case request to Signifyd
- declared used dependecies
---
app/code/Magento/Signifyd/composer.json | 5 ++++-
app/code/Magento/Signifyd/etc/module.xml | 2 ++
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/app/code/Magento/Signifyd/composer.json b/app/code/Magento/Signifyd/composer.json
index 69a42f2aa3336..5f18eff9001c2 100644
--- a/app/code/Magento/Signifyd/composer.json
+++ b/app/code/Magento/Signifyd/composer.json
@@ -5,7 +5,10 @@
"php": "~5.6.5|7.0.2|7.0.4|~7.0.6",
"magento/framework": "100.2.*",
"magento/module-sales": "100.2.*",
- "magento/module-store": "100.2.*"
+ "magento/module-store": "100.2.*",
+ "magento/module-checkout": "100.2.*",
+ "magento/module-customer": "100.2.*",
+ "magento/module-directory": "100.2.*"
},
"type": "magento2-module",
"version": "100.2.0-dev",
diff --git a/app/code/Magento/Signifyd/etc/module.xml b/app/code/Magento/Signifyd/etc/module.xml
index 40335d45f28a5..0a84948b522f7 100644
--- a/app/code/Magento/Signifyd/etc/module.xml
+++ b/app/code/Magento/Signifyd/etc/module.xml
@@ -11,6 +11,8 @@
+
+
From ef31feadf1ff3510124d2952c3059ec97136ec58 Mon Sep 17 00:00:00 2001
From: Volodymyr Kublytskyi
Date: Thu, 15 Dec 2016 04:32:23 -0600
Subject: [PATCH 037/904] MAGETWO-61914: Create case request to Signifyd
- removed edundant dependencies
---
app/code/Magento/Signifyd/composer.json | 1 -
app/code/Magento/Signifyd/etc/module.xml | 1 -
2 files changed, 2 deletions(-)
diff --git a/app/code/Magento/Signifyd/composer.json b/app/code/Magento/Signifyd/composer.json
index 5f18eff9001c2..920086ebd0106 100644
--- a/app/code/Magento/Signifyd/composer.json
+++ b/app/code/Magento/Signifyd/composer.json
@@ -6,7 +6,6 @@
"magento/framework": "100.2.*",
"magento/module-sales": "100.2.*",
"magento/module-store": "100.2.*",
- "magento/module-checkout": "100.2.*",
"magento/module-customer": "100.2.*",
"magento/module-directory": "100.2.*"
},
diff --git a/app/code/Magento/Signifyd/etc/module.xml b/app/code/Magento/Signifyd/etc/module.xml
index 0a84948b522f7..565ee18b92142 100644
--- a/app/code/Magento/Signifyd/etc/module.xml
+++ b/app/code/Magento/Signifyd/etc/module.xml
@@ -9,7 +9,6 @@
-
From fe2bf20ba62fe4380804bd7f691ffce45bd3778b Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Fri, 16 Dec 2016 04:28:06 -0600
Subject: [PATCH 038/904] MAGETWO-61968: Create component for frontend
(cherry picked from commit 7b65337)
---
.../Magento/Signifyd/Block/Fingerprint.php | 71 +++++++++++++++++++
.../frontend/layout/checkout_index_index.xml | 14 ++++
.../view/frontend/templates/fingerprint.phtml | 17 +++++
.../Signifyd/Block/FingerprintTest.php | 61 ++++++++++++++++
.../Signifyd/frontend/js/Fingerprint.test.js | 38 ++++++++++
5 files changed, 201 insertions(+)
create mode 100644 app/code/Magento/Signifyd/Block/Fingerprint.php
create mode 100644 app/code/Magento/Signifyd/view/frontend/layout/checkout_index_index.xml
create mode 100644 app/code/Magento/Signifyd/view/frontend/templates/fingerprint.phtml
create mode 100644 dev/tests/integration/testsuite/Magento/Signifyd/Block/FingerprintTest.php
create mode 100644 dev/tests/js/jasmine/tests/app/code/Magento/Signifyd/frontend/js/Fingerprint.test.js
diff --git a/app/code/Magento/Signifyd/Block/Fingerprint.php b/app/code/Magento/Signifyd/Block/Fingerprint.php
new file mode 100644
index 0000000000000..07b6df02cf103
--- /dev/null
+++ b/app/code/Magento/Signifyd/Block/Fingerprint.php
@@ -0,0 +1,71 @@
+orderSessionId = $orderSessionId;
+ $this->config = $config;
+ }
+
+ /**
+ * Retrieves per-order session id.
+ *
+ * @return string
+ */
+ public function getOrderSessionId()
+ {
+ return $this->orderSessionId->generate();
+ }
+
+ /**
+ * Checks if module is enabled.
+ *
+ * @return boolean
+ */
+ public function isModuleEnabled()
+ {
+ return $this->config->isEnabled();
+ }
+}
diff --git a/app/code/Magento/Signifyd/view/frontend/layout/checkout_index_index.xml b/app/code/Magento/Signifyd/view/frontend/layout/checkout_index_index.xml
new file mode 100644
index 0000000000000..07b04cc41d1bf
--- /dev/null
+++ b/app/code/Magento/Signifyd/view/frontend/layout/checkout_index_index.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Signifyd/view/frontend/templates/fingerprint.phtml b/app/code/Magento/Signifyd/view/frontend/templates/fingerprint.phtml
new file mode 100644
index 0000000000000..e15632ca9d4af
--- /dev/null
+++ b/app/code/Magento/Signifyd/view/frontend/templates/fingerprint.phtml
@@ -0,0 +1,17 @@
+
+isModuleEnabled()): ?>
+
+
\ No newline at end of file
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Block/FingerprintTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Block/FingerprintTest.php
new file mode 100644
index 0000000000000..1f7c71ba7b2c4
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Block/FingerprintTest.php
@@ -0,0 +1,61 @@
+loadArea(Area::AREA_FRONTEND);
+
+ $this->objectManager = Bootstrap::getObjectManager();
+ }
+
+ /**
+ * Checks if session id attribute is present when the module is enabled.
+ *
+ * @magentoConfigFixture current_store fraud_protection/signifyd/active 1
+ */
+ public function testSessionIdPresent() {
+ static::assertRegExp('/data-order-session-id=\"[^\"]+\"/', $this->getBlockContents());
+ }
+
+ /**
+ * Checks if block is an empty when the module is disabled.
+ *
+ * @magentoConfigFixture current_store fraud_protection/signifyd/active 0
+ */
+ public function testBlockEmpty() {
+ static::assertEmpty($this->getBlockContents());
+ }
+
+ /**
+ * Renders block contents.
+ *
+ * @return string
+ */
+ private function getBlockContents() {
+ $block = $this->objectManager->get(LayoutInterface::class)
+ ->createBlock(Fingerprint::class);
+
+ return $block->fetchView($block->getTemplateFile());
+ }
+}
diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Signifyd/frontend/js/Fingerprint.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Signifyd/frontend/js/Fingerprint.test.js
new file mode 100644
index 0000000000000..e9a9122eadb85
--- /dev/null
+++ b/dev/tests/js/jasmine/tests/app/code/Magento/Signifyd/frontend/js/Fingerprint.test.js
@@ -0,0 +1,38 @@
+/**
+ * Copyright © 2016 Magento. All rights reserved.
+ * See COPYING.txt for license details.
+ */
+
+define([
+ 'jquery'
+], function ($) {
+ 'use strict';
+
+ /*eslint max-nested-callbacks: ["error", 5]*/
+ describe('Signifyd device fingerprint client script', function () {
+
+ it('SIGNIFYD_GLOBAL object initialization check', function (done) {
+ var script = document.createElement('script');
+
+ script.setAttribute('src', 'https://cdn-scripts.signifyd.com/api/script-tag.js');
+ script.setAttribute('id', 'sig-api');
+ script.setAttribute('type', 'text/javascript');
+ script.setAttribute('async', '');
+ script.setAttribute('data-order-session-id', 'mage-jasmin-test');
+
+ $(document.body).append(script);
+
+ setTimeout(function () {
+ var signifyd = window.SIGNIFYD_GLOBAL;
+
+ expect(signifyd).toBeDefined();
+ expect(typeof signifyd).toBe('object');
+ expect(signifyd.scriptTagHasLoaded).toBeDefined();
+ expect(typeof signifyd.scriptTagHasLoaded).toBe('function');
+ expect(signifyd.scriptTagHasLoaded()).toBe(true);
+ done();
+ }, 10000);
+
+ }, 12000);
+ });
+});
From 73652d5bb8bec5b3adf7ec459c062a045f8ae87e Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Fri, 16 Dec 2016 05:00:04 -0600
Subject: [PATCH 039/904] MAGETWO-61968: Create component for frontend
- static tests fix
---
.../view/frontend/templates/fingerprint.phtml | 1 -
.../Magento/Signifyd/Block/FingerprintTest.php | 11 +++++++----
2 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/app/code/Magento/Signifyd/view/frontend/templates/fingerprint.phtml b/app/code/Magento/Signifyd/view/frontend/templates/fingerprint.phtml
index e15632ca9d4af..7d0e645afba01 100644
--- a/app/code/Magento/Signifyd/view/frontend/templates/fingerprint.phtml
+++ b/app/code/Magento/Signifyd/view/frontend/templates/fingerprint.phtml
@@ -9,7 +9,6 @@
isModuleEnabled()): ?>
\ No newline at end of file
From 2ff10581e9240beb38981307db4b1f63f11ba772 Mon Sep 17 00:00:00 2001
From: Dmytro Yushkin
Date: Mon, 19 Dec 2016 04:06:43 -0600
Subject: [PATCH 049/904] MAGETWO-61969: Add fingerprint to case builder
- Refactoring of quote session id generation
---
.../Magento/Signifyd/Model/QuoteSessionId.php | 5 +++--
.../Request/PurchaseBuilder.php | 14 +++++++-------
.../Test/Unit/Model/QuoteSessionIdTest.php | 19 +++++++++++++++++--
.../Request/CreateCaseBuilderTest.php | 14 +++++++-------
4 files changed, 34 insertions(+), 18 deletions(-)
diff --git a/app/code/Magento/Signifyd/Model/QuoteSessionId.php b/app/code/Magento/Signifyd/Model/QuoteSessionId.php
index 044836f6a54a6..e36e7f27b8efa 100644
--- a/app/code/Magento/Signifyd/Model/QuoteSessionId.php
+++ b/app/code/Magento/Signifyd/Model/QuoteSessionId.php
@@ -42,12 +42,13 @@ public function __construct(
/**
* Generates unique identifier by quote id.
*
+ * @param int|null $quoteId
* @return string
*/
- public function generate()
+ public function generate($quoteId = null)
{
return $this->identityGenerator->generateIdForData(
- $this->quoteSession->getQuote()->getId()
+ $quoteId ? : $this->quoteSession->getQuote()->getId()
);
}
}
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php
index 5224a28830f96..de10249970cde 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php
@@ -6,10 +6,10 @@
namespace Magento\Signifyd\Model\SignifydGateway\Request;
use Magento\Framework\App\Area;
-use Magento\Framework\DataObject\IdentityGeneratorInterface;
use Magento\Framework\Intl\DateTimeFactory;
use Magento\Framework\Config\ScopeInterface;
use Magento\Sales\Model\Order;
+use Magento\Signifyd\Model\QuoteSessionId;
/**
* Prepare data related to purchase event represented in case creation request.
@@ -27,23 +27,23 @@ class PurchaseBuilder
private $scope;
/**
- * @var IdentityGeneratorInterface
+ * @var QuoteSessionId
*/
- private $identityGenerator;
+ private $quoteSessionId;
/**
* @param DateTimeFactory $dateTimeFactory
* @param ScopeInterface $scope
- * @param IdentityGeneratorInterface $identityGenerator
+ * @param QuoteSessionId $quoteSessionId
*/
public function __construct(
DateTimeFactory $dateTimeFactory,
ScopeInterface $scope,
- IdentityGeneratorInterface $identityGenerator
+ QuoteSessionId $quoteSessionId
) {
$this->dateTimeFactory = $dateTimeFactory;
$this->scope = $scope;
- $this->identityGenerator = $identityGenerator;
+ $this->quoteSessionId = $quoteSessionId;
}
/**
@@ -62,7 +62,7 @@ public function build(Order $order)
$result = [
'purchase' => [
- 'orderSessionId' => $this->identityGenerator->generateIdForData($order->getQuoteId()),
+ 'orderSessionId' => $this->quoteSessionId->generate($order->getQuoteId()),
'browserIpAddress' => $order->getRemoteIp(),
'orderId' => $order->getEntityId(),
'createdAt' => $createdAt->format(\DateTime::ATOM),
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/QuoteSessionIdTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/QuoteSessionIdTest.php
index cd6e1f82c9b98..4601939fe2057 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/QuoteSessionIdTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/QuoteSessionIdTest.php
@@ -18,6 +18,8 @@
*/
class QuoteSessionIdTest extends \PHPUnit_Framework_TestCase
{
+ const QUOTE_ID = 1;
+
/**
* @var QuoteSessionId
*/
@@ -48,11 +50,24 @@ protected function setUp()
}
/**
- * Sets up general expectations for method.
+ * Tests method by passing quoteId parameter
+ *
+ * @covers \Magento\Signifyd\Model\QuoteSessionId::generate
+ */
+ public function testGenerateByQuoteId()
+ {
+ $this->identityGenerator->expects(static::once())
+ ->method('generateIdForData');
+
+ $this->quoteSessionId->generate(self::QUOTE_ID);
+ }
+
+ /**
+ * Tests method by getting quoteId from session
*
* @covers \Magento\Signifyd\Model\QuoteSessionId::generate
*/
- public function testGenerateQuoteSessionId()
+ public function testGenerateByQuoteSession()
{
$quote = $this->getMockBuilder(CartInterface::class)
->getMockForAbstractClass();
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
index 9367a483fc2dc..9f1119954b311 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
@@ -6,7 +6,7 @@
namespace Magento\Signifyd\Model\SignifydGateway\Request;
use Magento\Framework\Config\ScopeInterface;
-use Magento\Framework\DataObject\IdentityGeneratorInterface;
+use Magento\Signifyd\Model\QuoteSessionId;
use Magento\TestFramework\Helper\Bootstrap;
use Magento\Framework\App\Area;
use Magento\Framework\Intl\DateTimeFactory;
@@ -75,12 +75,12 @@ public function testCreateCaseBuilderWithFullSetOfData()
$productMetadata = $this->objectManager->create(ProductMetadataInterface::class);
- /** @var IdentityGeneratorInterface $identityGenerator */
- $identityGenerator = $this->objectManager->create(IdentityGeneratorInterface::class);
+ /** @var QuoteSessionId $quoteSessionId */
+ $quoteSessionId = $this->objectManager->create(QuoteSessionId::class);
$expected = [
'purchase' => [
- 'orderSessionId' => $identityGenerator->generateIdForData($order->getQuoteId()),
+ 'orderSessionId' => $quoteSessionId->generate($order->getQuoteId()),
'browserIpAddress' => $order->getRemoteIp(),
'orderId' => $order->getEntityId(),
'createdAt' => '2016-12-12T12:00:55+00:00',
@@ -186,12 +186,12 @@ public function testCreateCaseBuilderWithVirtualProductAndGuest()
$billingAddress = $order->getBillingAddress();
$productMetadata = $this->objectManager->create(ProductMetadataInterface::class);
- /** @var IdentityGeneratorInterface $identityGenerator */
- $identityGenerator = $this->objectManager->create(IdentityGeneratorInterface::class);
+ /** @var QuoteSessionId $quoteSessionId */
+ $quoteSessionId = $this->objectManager->create(QuoteSessionId::class);
$expected = [
'purchase' => [
- 'orderSessionId' => $identityGenerator->generateIdForData($order->getQuoteId()),
+ 'orderSessionId' => $quoteSessionId->generate($order->getQuoteId()),
'browserIpAddress' => $order->getRemoteIp(),
'orderId' => $order->getEntityId(),
'createdAt' => '2016-12-12T12:00:55+00:00',
From 02345a47ac6b1671e25a85186635708136357432 Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Fri, 23 Dec 2016 07:22:37 -0600
Subject: [PATCH 050/904] MAGETWO-54389: Submitting Case Entry to Signifyd on
Order Creation
- static and acceptance tests fix
---
app/code/Magento/Signifyd/etc/di.xml | 1 +
app/code/Magento/Signifyd/etc/module.xml | 2 ++
2 files changed, 3 insertions(+)
diff --git a/app/code/Magento/Signifyd/etc/di.xml b/app/code/Magento/Signifyd/etc/di.xml
index 81d157887f7e1..df5214ba14c52 100644
--- a/app/code/Magento/Signifyd/etc/di.xml
+++ b/app/code/Magento/Signifyd/etc/di.xml
@@ -12,4 +12,5 @@
+
\ No newline at end of file
diff --git a/app/code/Magento/Signifyd/etc/module.xml b/app/code/Magento/Signifyd/etc/module.xml
index 565ee18b92142..2db123b053108 100644
--- a/app/code/Magento/Signifyd/etc/module.xml
+++ b/app/code/Magento/Signifyd/etc/module.xml
@@ -12,6 +12,8 @@
+
+
From 56a6573801e0bffb94a0df5f4d2804b2fc439809 Mon Sep 17 00:00:00 2001
From: Dmytro Yushkin
Date: Mon, 19 Dec 2016 05:56:50 -0600
Subject: [PATCH 051/904] MAGETWO-61969: Add fingerprint to case builder
- Refactor name of quote session id getter method
---
app/code/Magento/Signifyd/Block/Fingerprint.php | 2 +-
.../Model/QuoteSession/QuoteSessionInterface.php | 4 +---
.../Magento/Signifyd/Model/QuoteSessionId.php | 6 +++---
.../SignifydGateway/Request/PurchaseBuilder.php | 2 +-
.../Test/Unit/Model/QuoteSessionIdTest.php | 12 ++++++------
app/code/Magento/Signifyd/composer.json | 4 +++-
.../view/frontend/templates/fingerprint.phtml | 16 +++++++++-------
.../Request/CreateCaseBuilderTest.php | 4 ++--
8 files changed, 26 insertions(+), 24 deletions(-)
diff --git a/app/code/Magento/Signifyd/Block/Fingerprint.php b/app/code/Magento/Signifyd/Block/Fingerprint.php
index 0e541f9036eba..ed14d75e7a16f 100644
--- a/app/code/Magento/Signifyd/Block/Fingerprint.php
+++ b/app/code/Magento/Signifyd/Block/Fingerprint.php
@@ -56,7 +56,7 @@ public function __construct(
*/
public function getQuoteSessionId()
{
- return $this->quoteSessionId->generate();
+ return $this->quoteSessionId->get();
}
/**
diff --git a/app/code/Magento/Signifyd/Model/QuoteSession/QuoteSessionInterface.php b/app/code/Magento/Signifyd/Model/QuoteSession/QuoteSessionInterface.php
index 9a68341596b65..dafaf680ee39d 100644
--- a/app/code/Magento/Signifyd/Model/QuoteSession/QuoteSessionInterface.php
+++ b/app/code/Magento/Signifyd/Model/QuoteSession/QuoteSessionInterface.php
@@ -5,8 +5,6 @@
*/
namespace Magento\Signifyd\Model\QuoteSession;
-use Magento\Quote\Api\Data\CartInterface;
-
/**
* Interface QuoteSessionInterface
*/
@@ -15,7 +13,7 @@ interface QuoteSessionInterface
/**
* Returns quote from session.
*
- * @return CartInterface
+ * @return \Magento\Quote\Api\Data\CartInterface
*/
public function getQuote();
}
diff --git a/app/code/Magento/Signifyd/Model/QuoteSessionId.php b/app/code/Magento/Signifyd/Model/QuoteSessionId.php
index e36e7f27b8efa..004fff462b16d 100644
--- a/app/code/Magento/Signifyd/Model/QuoteSessionId.php
+++ b/app/code/Magento/Signifyd/Model/QuoteSessionId.php
@@ -9,7 +9,7 @@
use Magento\Signifyd\Model\QuoteSession\QuoteSessionInterface;
/**
- * Class SessionId generate uuid by quote id.
+ * Class SessionId encapsulate generation of uuid by quote id.
*/
class QuoteSessionId
{
@@ -40,12 +40,12 @@ public function __construct(
}
/**
- * Generates unique identifier by quote id.
+ * Gets unique identifier through generation uuid by quote id.
*
* @param int|null $quoteId
* @return string
*/
- public function generate($quoteId = null)
+ public function get($quoteId = null)
{
return $this->identityGenerator->generateIdForData(
$quoteId ? : $this->quoteSession->getQuote()->getId()
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php
index de10249970cde..8a83cc64ad1de 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php
@@ -62,7 +62,7 @@ public function build(Order $order)
$result = [
'purchase' => [
- 'orderSessionId' => $this->quoteSessionId->generate($order->getQuoteId()),
+ 'orderSessionId' => $this->quoteSessionId->get($order->getQuoteId()),
'browserIpAddress' => $order->getRemoteIp(),
'orderId' => $order->getEntityId(),
'createdAt' => $createdAt->format(\DateTime::ATOM),
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/QuoteSessionIdTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/QuoteSessionIdTest.php
index 4601939fe2057..e4cdad26ec204 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/QuoteSessionIdTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/QuoteSessionIdTest.php
@@ -52,22 +52,22 @@ protected function setUp()
/**
* Tests method by passing quoteId parameter
*
- * @covers \Magento\Signifyd\Model\QuoteSessionId::generate
+ * @covers \Magento\Signifyd\Model\QuoteSessionId::get
*/
- public function testGenerateByQuoteId()
+ public function testGetByQuoteId()
{
$this->identityGenerator->expects(static::once())
->method('generateIdForData');
- $this->quoteSessionId->generate(self::QUOTE_ID);
+ $this->quoteSessionId->get(self::QUOTE_ID);
}
/**
* Tests method by getting quoteId from session
*
- * @covers \Magento\Signifyd\Model\QuoteSessionId::generate
+ * @covers \Magento\Signifyd\Model\QuoteSessionId::get
*/
- public function testGenerateByQuoteSession()
+ public function testGetByQuoteSession()
{
$quote = $this->getMockBuilder(CartInterface::class)
->getMockForAbstractClass();
@@ -81,6 +81,6 @@ public function testGenerateByQuoteSession()
$quote->expects(static::once())
->method('getId');
- $this->quoteSessionId->generate();
+ $this->quoteSessionId->get();
}
}
diff --git a/app/code/Magento/Signifyd/composer.json b/app/code/Magento/Signifyd/composer.json
index 920086ebd0106..cf9b2311bbba5 100644
--- a/app/code/Magento/Signifyd/composer.json
+++ b/app/code/Magento/Signifyd/composer.json
@@ -7,7 +7,9 @@
"magento/module-sales": "100.2.*",
"magento/module-store": "100.2.*",
"magento/module-customer": "100.2.*",
- "magento/module-directory": "100.2.*"
+ "magento/module-directory": "100.2.*",
+ "magento/module-checkout": "100.2.*",
+ "magento/module-backend": "100.2.*"
},
"type": "magento2-module",
"version": "100.2.0-dev",
diff --git a/app/code/Magento/Signifyd/view/frontend/templates/fingerprint.phtml b/app/code/Magento/Signifyd/view/frontend/templates/fingerprint.phtml
index e3388531c4670..a9f5a9dd476da 100644
--- a/app/code/Magento/Signifyd/view/frontend/templates/fingerprint.phtml
+++ b/app/code/Magento/Signifyd/view/frontend/templates/fingerprint.phtml
@@ -4,13 +4,15 @@
* See COPYING.txt for license details.
*/
+// @codingStandardsIgnoreFile
+
/** @var $block Magento\Signifyd\Block\Fingerprint */
?>
isModuleEnabled()): ?>
-
-
\ No newline at end of file
+
+
\ No newline at end of file
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
index 9f1119954b311..2201a4ed6a3aa 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
@@ -80,7 +80,7 @@ public function testCreateCaseBuilderWithFullSetOfData()
$expected = [
'purchase' => [
- 'orderSessionId' => $quoteSessionId->generate($order->getQuoteId()),
+ 'orderSessionId' => $quoteSessionId->get($order->getQuoteId()),
'browserIpAddress' => $order->getRemoteIp(),
'orderId' => $order->getEntityId(),
'createdAt' => '2016-12-12T12:00:55+00:00',
@@ -191,7 +191,7 @@ public function testCreateCaseBuilderWithVirtualProductAndGuest()
$expected = [
'purchase' => [
- 'orderSessionId' => $quoteSessionId->generate($order->getQuoteId()),
+ 'orderSessionId' => $quoteSessionId->get($order->getQuoteId()),
'browserIpAddress' => $order->getRemoteIp(),
'orderId' => $order->getEntityId(),
'createdAt' => '2016-12-12T12:00:55+00:00',
From 0bd394012087714743ce3637d1e70fa651d78d1c Mon Sep 17 00:00:00 2001
From: Volodymyr Kublytskyi
Date: Mon, 19 Dec 2016 04:35:59 -0600
Subject: [PATCH 052/904] MAGETWO-61928: Handle response
- fixed debugger issue after refactoring: exception thrown during respone handling should not be recorded to debug info as failure of API call, we should write API response instead
---
.../Model/SignifydGateway/ApiClient.php | 74 ++++++++++++-------
1 file changed, 47 insertions(+), 27 deletions(-)
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/ApiClient.php b/app/code/Magento/Signifyd/Model/SignifydGateway/ApiClient.php
index 0887c384e901d..86e424b45bc62 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/ApiClient.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/ApiClient.php
@@ -85,31 +85,9 @@ public function __construct(
*/
public function makeApiCall($url, $method, array $params = [])
{
- try {
- $client = $this->getRequestClient($url, $method, $params);
- $response = $client->request();
- $result = $this->handleResponse($response);
-
- $this->debuggerFactory->create()->success(
- $client->getUri(true),
- $client->getLastRequest(),
- $response->getStatus() . ' ' . $response->getMessage(),
- $response->getBody()
- );
- } catch (\Exception $e) {
- $this->debuggerFactory->create()->failure(
- $client->getUri(true),
- $client->getLastRequest(),
- $e
- );
-
- throw new ApiCallException(
- 'Unable to process Signifyd API: ' . $e->getMessage(),
- $e->getCode(),
- $e,
- $client->getLastRequest()
- );
- }
+ $client = $this->buildRequestClient($url, $method, $params);
+ $response = $this->sendRequest($client);
+ $result = $this->handleResponse($response);
return $result;
}
@@ -119,9 +97,9 @@ public function makeApiCall($url, $method, array $params = [])
* @param string $url
* @param string $method
* @param array $params
- * @return \Zend_Http_Client
+ * @return ZendClient
*/
- private function getRequestClient($url, $method, array $params = [])
+ private function buildRequestClient($url, $method, array $params = [])
{
$apiKey = $this->getApiKey();
$apiUrl = $this->buildFullApiUrl($url);
@@ -141,6 +119,48 @@ private function getRequestClient($url, $method, array $params = [])
return $client;
}
+ /**
+ * Send HTTP request to Signifyd API with configured client
+ *
+ * Each request/response pair is handled by debugger.
+ * If debug mode for Signifyd integration enabled in configuration
+ * debug information is recorded to debug.log.
+ *
+ * @param ZendClient $client
+ *
+ * @return \Zend_Http_Response
+ * @throws ApiCallException
+ */
+ private function sendRequest(ZendClient $client)
+ {
+
+ try {
+ $response = $client->request();
+
+ $this->debuggerFactory->create()->success(
+ $client->getUri(true),
+ $client->getLastRequest(),
+ $response->getStatus() . ' ' . $response->getMessage(),
+ $response->getBody()
+ );
+
+ return $response;
+ } catch (\Exception $e) {
+ $this->debuggerFactory->create()->failure(
+ $client->getUri(true),
+ $client->getLastRequest(),
+ $e
+ );
+
+ throw new ApiCallException(
+ 'Unable to process Signifyd API: ' . $e->getMessage(),
+ $e->getCode(),
+ $e,
+ $client->getLastRequest()
+ );
+ }
+ }
+
/**
* Read result of successful operation and throw exception in case of any failure.
*
From 811706517af7353e0354b8bb7dd95f68132999fc Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Tue, 20 Dec 2016 03:36:58 -0600
Subject: [PATCH 053/904] MAGETWO-54389: Submitting Case Entry to Signifyd on
Order Creation
- Updates error messages in CaseCreationServiceTest
---
.../Magento/Signifyd/Model/CaseCreationServiceTest.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseCreationServiceTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseCreationServiceTest.php
index a200d93c6618b..effee790eaa2a 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseCreationServiceTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseCreationServiceTest.php
@@ -117,7 +117,7 @@ public function testCreateForOrderWithEmptyResponse()
$this->logger->expects(static::once())
->method('error')
- ->with('Unable to process Signifyd API: Response is not valid JSON: Decoding failed: Syntax error');
+ ->with('Response is not valid JSON: Decoding failed: Syntax error');
$result = $this->service->createForOrder($order->getEntityId());
static::assertTrue($result);
@@ -152,7 +152,7 @@ public function testCreateForOrderWithBadResponse()
$this->logger->expects(static::once())
->method('error')
->with(
- 'Unable to process Signifyd API: Bad Request - The request could not be parsed. Response: ' .
+ 'Bad Request - The request could not be parsed. Response: ' .
json_encode($responseData)
);
From 70b6d80eebc7fcf534239c1d955796a987d437f3 Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Tue, 20 Dec 2016 10:55:10 -0600
Subject: [PATCH 054/904] MAGETWO-54389: Submitting Case Entry to Signifyd on
Order Creation
- Fix bug with multishipping place order
- Rename QuoteSessionId to SignifydOrderSessionId
- Update annotations
---
.../Magento/Signifyd/Block/Fingerprint.php | 42 ++++++---
.../Magento/Signifyd/Model/CaseManagement.php | 3 +-
.../Magento/Signifyd/Model/CaseRepository.php | 7 +-
app/code/Magento/Signifyd/Model/Config.php | 2 +-
.../Magento/Signifyd/Model/QuoteSessionId.php | 54 ------------
.../Model/SignifydGateway/ApiClient.php | 28 +++---
.../Request/CreateCaseBuilderInterface.php | 6 +-
.../Request/PurchaseBuilder.php | 14 +--
.../Signifyd/Model/SignifydOrderSessionId.php | 39 +++++++++
.../Magento/Signifyd/Observer/PlaceOrder.php | 34 +++++---
app/code/Magento/Signifyd/README.md | 2 +-
.../Test/Unit/Model/QuoteSessionIdTest.php | 86 -------------------
.../Unit/Model/SignifydOrderSessionIdTest.php | 60 +++++++++++++
.../Magento/Signifyd/etc/adminhtml/system.xml | 6 +-
.../Magento/Signifyd/etc/frontend/routes.xml | 14 ---
.../view/frontend/templates/fingerprint.phtml | 4 +-
.../Request/CreateCaseBuilderTest.php | 12 +--
17 files changed, 187 insertions(+), 226 deletions(-)
delete mode 100644 app/code/Magento/Signifyd/Model/QuoteSessionId.php
create mode 100644 app/code/Magento/Signifyd/Model/SignifydOrderSessionId.php
delete mode 100644 app/code/Magento/Signifyd/Test/Unit/Model/QuoteSessionIdTest.php
create mode 100644 app/code/Magento/Signifyd/Test/Unit/Model/SignifydOrderSessionIdTest.php
delete mode 100644 app/code/Magento/Signifyd/etc/frontend/routes.xml
diff --git a/app/code/Magento/Signifyd/Block/Fingerprint.php b/app/code/Magento/Signifyd/Block/Fingerprint.php
index ed14d75e7a16f..babceee2e1423 100644
--- a/app/code/Magento/Signifyd/Block/Fingerprint.php
+++ b/app/code/Magento/Signifyd/Block/Fingerprint.php
@@ -8,55 +8,69 @@
use Magento\Framework\View\Element\Template;
use Magento\Framework\View\Element\Template\Context;
use Magento\Signifyd\Model\Config;
-use Magento\Signifyd\Model\QuoteSessionId;
+use Magento\Signifyd\Model\QuoteSession\QuoteSessionInterface;
+use Magento\Signifyd\Model\SignifydOrderSessionId;
/**
- * Class Fingerprint
+ * Provides data for Signifyd device fingerprinting script.
+ *
+ * Signifyd’s device fingerprinting solution uniquely tracks and identifies devices
+ * used to transact on your site, increasing your protection from fraud.
+ *
+ * @see https://www.signifyd.com/docs/api/#/reference/device-fingerprint/create-a-case
*/
class Fingerprint extends Template
{
/**
- * @var QuoteSessionId
+ * @var SignifydOrderSessionId
*/
- private $quoteSessionId;
+ private $signifydOrderSessionId;
/**
* @var Config
*/
private $config;
+ /**
+ * @var QuoteSessionInterface
+ */
+ private $quoteSession;
+
/**
* @var string
*/
protected $_template = 'fingerprint.phtml';
/**
- * Constructor
- *
* @param Context $context
* @param Config $config
- * @param QuoteSessionId $orderSessionId
+ * @param SignifydOrderSessionId $signifydOrderSessionId
+ * @param QuoteSessionInterface $quoteSession
* @param array $data
*/
public function __construct(
Context $context,
Config $config,
- QuoteSessionId $orderSessionId,
+ SignifydOrderSessionId $signifydOrderSessionId,
+ QuoteSessionInterface $quoteSession,
array $data = []
) {
parent::__construct($context, $data);
- $this->quoteSessionId = $orderSessionId;
+ $this->signifydOrderSessionId = $signifydOrderSessionId;
$this->config = $config;
+ $this->quoteSession = $quoteSession;
}
/**
- * Retrieves per-order session id.
+ * Returns a unique Signifyd order session id.
*
* @return string
*/
- public function getQuoteSessionId()
+ public function getSignifydOrderSessionId()
{
- return $this->quoteSessionId->get();
+ $quoteId = $this->quoteSession->getQuote()->getId();
+
+ return $this->signifydOrderSessionId->get($quoteId);
}
/**
@@ -64,8 +78,8 @@ public function getQuoteSessionId()
*
* @return boolean
*/
- public function isModuleEnabled()
+ public function isModuleActive()
{
- return $this->config->isEnabled();
+ return $this->config->isActive();
}
}
diff --git a/app/code/Magento/Signifyd/Model/CaseManagement.php b/app/code/Magento/Signifyd/Model/CaseManagement.php
index 3e31e0af1d883..504b52b85a74a 100644
--- a/app/code/Magento/Signifyd/Model/CaseManagement.php
+++ b/app/code/Magento/Signifyd/Model/CaseManagement.php
@@ -13,7 +13,8 @@
use Magento\Signifyd\Api\Data\CaseInterfaceFactory;
/**
- * Implementation of case management interface
+ *
+ * Default case management implementation
*/
class CaseManagement implements CaseManagementInterface
{
diff --git a/app/code/Magento/Signifyd/Model/CaseRepository.php b/app/code/Magento/Signifyd/Model/CaseRepository.php
index 723dea8421167..f18ffc47356d9 100644
--- a/app/code/Magento/Signifyd/Model/CaseRepository.php
+++ b/app/code/Magento/Signifyd/Model/CaseRepository.php
@@ -77,6 +77,7 @@ public function save(CaseInterface $case)
{
/** @var CaseEntity $case */
$this->resourceModel->save($case);
+
return $case;
}
@@ -88,6 +89,7 @@ public function getById($id)
/** @var CaseEntity $case */
$case = $this->caseFactory->create();
$this->resourceModel->load($case, $id);
+
return $case;
}
@@ -97,13 +99,12 @@ public function getById($id)
public function delete(CaseInterface $case)
{
$this->resourceModel->delete($case);
+
return true;
}
/**
- * Gets list of case entities
- * @param SearchCriteria $searchCriteria
- * @return CaseSearchResultsInterface
+ * @inheritdoc
*/
public function getList(SearchCriteria $searchCriteria)
{
diff --git a/app/code/Magento/Signifyd/Model/Config.php b/app/code/Magento/Signifyd/Model/Config.php
index f99480386293a..b7c2afe4cb109 100644
--- a/app/code/Magento/Signifyd/Model/Config.php
+++ b/app/code/Magento/Signifyd/Model/Config.php
@@ -36,7 +36,7 @@ public function __construct(ScopeConfigInterface $scopeConfig)
*
* @return bool
*/
- public function isEnabled()
+ public function isActive()
{
$enabled = $this->scopeConfig->isSetFlag(
'fraud_protection/signifyd/active',
diff --git a/app/code/Magento/Signifyd/Model/QuoteSessionId.php b/app/code/Magento/Signifyd/Model/QuoteSessionId.php
deleted file mode 100644
index 004fff462b16d..0000000000000
--- a/app/code/Magento/Signifyd/Model/QuoteSessionId.php
+++ /dev/null
@@ -1,54 +0,0 @@
-quoteSession = $quoteSession;
- $this->identityGenerator = $identityGenerator;
- }
-
- /**
- * Gets unique identifier through generation uuid by quote id.
- *
- * @param int|null $quoteId
- * @return string
- */
- public function get($quoteId = null)
- {
- return $this->identityGenerator->generateIdForData(
- $quoteId ? : $this->quoteSession->getQuote()->getId()
- );
- }
-}
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/ApiClient.php b/app/code/Magento/Signifyd/Model/SignifydGateway/ApiClient.php
index 86e424b45bc62..3b14773b3fd25 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/ApiClient.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/ApiClient.php
@@ -14,8 +14,6 @@
use Exception;
/**
- * Signifyd API Client.
- *
* Encapsulates Signifyd API protocol.
*/
class ApiClient
@@ -46,8 +44,6 @@ class ApiClient
private $debuggerFactory;
/**
- * ApiClient constructor.
- *
* Class uses client factory to instantiate new client for interacting with API.
* All requests and responses are processed by JSON encoder and decoder.
*
@@ -92,7 +88,7 @@ public function makeApiCall($url, $method, array $params = [])
}
/**
- * Init HTTP client for processing requests to Signifyd API.
+ * Returns HTTP client configured with request for API call.
*
* @param string $url
* @param string $method
@@ -120,14 +116,13 @@ private function buildRequestClient($url, $method, array $params = [])
}
/**
- * Send HTTP request to Signifyd API with configured client
+ * Send HTTP request to Signifyd API with configured client.
*
* Each request/response pair is handled by debugger.
* If debug mode for Signifyd integration enabled in configuration
* debug information is recorded to debug.log.
*
* @param ZendClient $client
- *
* @return \Zend_Http_Response
* @throws ApiCallException
*/
@@ -165,7 +160,6 @@ private function sendRequest(ZendClient $client)
* Read result of successful operation and throw exception in case of any failure.
*
* @param \Zend_Http_Response $response
- *
* @return array
* @throws ApiCallException
*/
@@ -194,7 +188,7 @@ private function handleResponse(\Zend_Http_Response $response)
}
/**
- * Make error message for request rejected by Signify
+ * Make error message for request rejected by Signify.
*
* @param \Zend_Http_Response $response
* @return string
@@ -205,15 +199,15 @@ private function buildApiCallFailureMessage(\Zend_Http_Response $response)
switch ($response->getStatus()) {
case 400:
return 'Bad Request - The request could not be parsed. Response: ' . $responseBody;
+ case 401:
+ return 'Unauthorized - user is not logged in, could not be authenticated. Response: ' . $responseBody;
+ case 403:
+ return 'Forbidden - Cannot access resource. Response: ' . $responseBody;
case 404:
return 'Not Found - resource does not exist. Response: ' . $responseBody;
case 409:
return 'Conflict - with state of the resource on server. Can occur with (too rapid) PUT requests.' .
'Response: ' . $responseBody;
- case 401:
- return 'Unauthorized - user is not logged in, could not be authenticated. Response: ' . $responseBody;
- case 403:
- return 'Forbidden - Cannot access resource. Response: ' . $responseBody;
case 500:
return 'Server error.';
default:
@@ -234,9 +228,9 @@ private function createNewClient()
}
/**
- * Returns Signifyd API key for merchant account
- * @see https://www.signifyd.com/docs/api/#/introduction/authentication
+ * Returns Signifyd API key for merchant account.
*
+ * @see https://www.signifyd.com/docs/api/#/introduction/authentication
* @return string
*/
private function getApiKey()
@@ -245,7 +239,7 @@ private function getApiKey()
}
/**
- * Builds full URL for Singifyd API based on relative URL
+ * Builds full URL for Singifyd API based on relative URL.
*
* @param string $url
* @return string
@@ -258,7 +252,7 @@ private function buildFullApiUrl($url)
}
/**
- * Returns Base Sigifyd API URL without trailing slash
+ * Returns Base Sigifyd API URL without trailing slash.
*
* @return string
*/
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderInterface.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderInterface.php
index e75a8aa9dbcfc..aa5e4ce48485b 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderInterface.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderInterface.php
@@ -5,10 +5,12 @@
*/
namespace Magento\Signifyd\Model\SignifydGateway\Request;
+
+
/**
- * Signifyd case creation request builder interface
+ * Collects information about order and build array with parameters required by Signifyd API.
*
- * Retrieves params for case creation request API call based on order ID
+ * @see https://www.signifyd.com/docs/api/#/reference/cases/create-a-case
*/
interface CreateCaseBuilderInterface
{
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php
index 8a83cc64ad1de..6f39369bc6752 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php
@@ -9,7 +9,7 @@
use Magento\Framework\Intl\DateTimeFactory;
use Magento\Framework\Config\ScopeInterface;
use Magento\Sales\Model\Order;
-use Magento\Signifyd\Model\QuoteSessionId;
+use Magento\Signifyd\Model\SignifydOrderSessionId;
/**
* Prepare data related to purchase event represented in case creation request.
@@ -27,23 +27,23 @@ class PurchaseBuilder
private $scope;
/**
- * @var QuoteSessionId
+ * @var SignifydOrderSessionId
*/
- private $quoteSessionId;
+ private $signifydOrderSessionId;
/**
* @param DateTimeFactory $dateTimeFactory
* @param ScopeInterface $scope
- * @param QuoteSessionId $quoteSessionId
+ * @param SignifydOrderSessionId $signifydOrderSessionId
*/
public function __construct(
DateTimeFactory $dateTimeFactory,
ScopeInterface $scope,
- QuoteSessionId $quoteSessionId
+ SignifydOrderSessionId $signifydOrderSessionId
) {
$this->dateTimeFactory = $dateTimeFactory;
$this->scope = $scope;
- $this->quoteSessionId = $quoteSessionId;
+ $this->signifydOrderSessionId = $signifydOrderSessionId;
}
/**
@@ -62,7 +62,7 @@ public function build(Order $order)
$result = [
'purchase' => [
- 'orderSessionId' => $this->quoteSessionId->get($order->getQuoteId()),
+ 'orderSessionId' => $this->signifydOrderSessionId->get($order->getQuoteId()),
'browserIpAddress' => $order->getRemoteIp(),
'orderId' => $order->getEntityId(),
'createdAt' => $createdAt->format(\DateTime::ATOM),
diff --git a/app/code/Magento/Signifyd/Model/SignifydOrderSessionId.php b/app/code/Magento/Signifyd/Model/SignifydOrderSessionId.php
new file mode 100644
index 0000000000000..b5f0fcee06ccd
--- /dev/null
+++ b/app/code/Magento/Signifyd/Model/SignifydOrderSessionId.php
@@ -0,0 +1,39 @@
+identityGenerator = $identityGenerator;
+ }
+
+ /**
+ * Returns unique identifier through generation uuid by quote id.
+ *
+ * @param int $quoteId
+ * @return string
+ */
+ public function get($quoteId)
+ {
+ return $this->identityGenerator->generateIdForData($quoteId);
+ }
+}
diff --git a/app/code/Magento/Signifyd/Observer/PlaceOrder.php b/app/code/Magento/Signifyd/Observer/PlaceOrder.php
index f59dc7769e310..1d0a51167dc34 100644
--- a/app/code/Magento/Signifyd/Observer/PlaceOrder.php
+++ b/app/code/Magento/Signifyd/Observer/PlaceOrder.php
@@ -14,7 +14,7 @@
use Magento\Signifyd\Api\CaseCreationServiceInterface;
/**
- * Place Order
+ * Place Order observer.
*
* Observer should be triggered when new order is created and placed.
* If Signifyd integration enabled in configuration then new case will be created.
@@ -50,33 +50,39 @@ public function __construct(
*/
public function execute(Observer $observer)
{
- if (!$this->signifydIntegrationConfig->isEnabled()) {
+ if (!$this->signifydIntegrationConfig->isActive()) {
return;
}
- $event = $observer->getEvent();
- $order = $this->extractOrder($event);
+ $orders = $this->extractOrders(
+ $observer->getEvent()
+ );
- if (null === $order) {
+ if (null === $orders) {
return;
}
- $orderId = $order->getEntityId();
- if (null === $orderId) {
- return;
+ foreach ($orders as $order) {
+ $orderId = $order->getEntityId();
+ if (null !== $orderId) {
+ $this->caseCreationService->createForOrder($orderId);
+ }
}
-
- $this->caseCreationService->createForOrder($orderId);
}
/**
- * Fetch Order entity from Event data container
+ * Returns Orders entity list from Event data container
*
* @param Event $event
- * @return OrderInterface|null
+ * @return OrderInterface[]|null
*/
- private function extractOrder(Event $event)
+ private function extractOrders(Event $event)
{
- return $event->getData('order');
+ $order = $event->getData('order');
+ if (null !== $order) {
+ return [$order];
+ }
+
+ return $event->getData('orders');
}
}
diff --git a/app/code/Magento/Signifyd/README.md b/app/code/Magento/Signifyd/README.md
index 3cd2b4a30a858..5159d4c6951c4 100644
--- a/app/code/Magento/Signifyd/README.md
+++ b/app/code/Magento/Signifyd/README.md
@@ -1 +1 @@
-The Magento_Signifyd module implements the integration with the Signifyd fraud prevention service.
+The Magento_Signifyd module implements the integration with the [Signifyd](https://www.signifyd.com/docs/api/) fraud prevention service.
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/QuoteSessionIdTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/QuoteSessionIdTest.php
deleted file mode 100644
index e4cdad26ec204..0000000000000
--- a/app/code/Magento/Signifyd/Test/Unit/Model/QuoteSessionIdTest.php
+++ /dev/null
@@ -1,86 +0,0 @@
-quoteSession = $this->getMockBuilder(QuoteSessionInterface::class)
- ->getMockForAbstractClass();
-
- $this->identityGenerator = $this->getMockBuilder(IdentityGeneratorInterface::class)
- ->getMockForAbstractClass();
-
- $this->quoteSessionId = new QuoteSessionId($this->quoteSession, $this->identityGenerator);
- }
-
- /**
- * Tests method by passing quoteId parameter
- *
- * @covers \Magento\Signifyd\Model\QuoteSessionId::get
- */
- public function testGetByQuoteId()
- {
- $this->identityGenerator->expects(static::once())
- ->method('generateIdForData');
-
- $this->quoteSessionId->get(self::QUOTE_ID);
- }
-
- /**
- * Tests method by getting quoteId from session
- *
- * @covers \Magento\Signifyd\Model\QuoteSessionId::get
- */
- public function testGetByQuoteSession()
- {
- $quote = $this->getMockBuilder(CartInterface::class)
- ->getMockForAbstractClass();
-
- $this->identityGenerator->expects(static::once())
- ->method('generateIdForData');
-
- $this->quoteSession->expects(static::once())
- ->method('getQuote')
- ->willReturn($quote);
- $quote->expects(static::once())
- ->method('getId');
-
- $this->quoteSessionId->get();
- }
-}
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/SignifydOrderSessionIdTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/SignifydOrderSessionIdTest.php
new file mode 100644
index 0000000000000..f8a36ef172dc5
--- /dev/null
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/SignifydOrderSessionIdTest.php
@@ -0,0 +1,60 @@
+identityGenerator = $this->getMockBuilder(IdentityGeneratorInterface::class)
+ ->getMockForAbstractClass();
+
+ $this->signifydOrderSessionId = new SignifydOrderSessionId($this->identityGenerator);
+ }
+
+ /**
+ * Tests method by passing quoteId parameter
+ *
+ * @covers \Magento\Signifyd\Model\SignifydOrderSessionId::get
+ */
+ public function testGetByQuoteId()
+ {
+ $quoteId = 1;
+ $signifydOrderSessionId = 'asdfzxcv';
+
+ $this->identityGenerator->expects(static::once())
+ ->method('generateIdForData')
+ ->with($quoteId)
+ ->willReturn($signifydOrderSessionId);
+
+ $this->assertEquals(
+ $signifydOrderSessionId,
+ $this->signifydOrderSessionId->get($quoteId)
+ );
+ }
+}
diff --git a/app/code/Magento/Signifyd/etc/adminhtml/system.xml b/app/code/Magento/Signifyd/etc/adminhtml/system.xml
index 14ae7d73e0e48..a1ecbfcdff95c 100644
--- a/app/code/Magento/Signifyd/etc/adminhtml/system.xml
+++ b/app/code/Magento/Signifyd/etc/adminhtml/system.xml
@@ -13,7 +13,7 @@
Magento_Sales::fraud_protection
Signifyd
-
+
Enable this Solution
Magento\Config\Model\Config\Source\Yesno
fraud_protection/signifyd/active
@@ -27,9 +27,7 @@
API URL
fraud_protection/signifyd/api_url
-
- Don’t change unless asked to do so.
-
+ Don’t change unless asked to do so.
Debug
diff --git a/app/code/Magento/Signifyd/etc/frontend/routes.xml b/app/code/Magento/Signifyd/etc/frontend/routes.xml
deleted file mode 100644
index 8a6c5b4e22c1d..0000000000000
--- a/app/code/Magento/Signifyd/etc/frontend/routes.xml
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
-
-
-
-
-
-
diff --git a/app/code/Magento/Signifyd/view/frontend/templates/fingerprint.phtml b/app/code/Magento/Signifyd/view/frontend/templates/fingerprint.phtml
index a9f5a9dd476da..609391c2d695d 100644
--- a/app/code/Magento/Signifyd/view/frontend/templates/fingerprint.phtml
+++ b/app/code/Magento/Signifyd/view/frontend/templates/fingerprint.phtml
@@ -8,11 +8,11 @@
/** @var $block Magento\Signifyd\Block\Fingerprint */
?>
-isModuleEnabled()): ?>
+isModuleActive()): ?>
\ No newline at end of file
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
index 2201a4ed6a3aa..61dc67b7f7808 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
@@ -6,7 +6,7 @@
namespace Magento\Signifyd\Model\SignifydGateway\Request;
use Magento\Framework\Config\ScopeInterface;
-use Magento\Signifyd\Model\QuoteSessionId;
+use Magento\Signifyd\Model\SignifydOrderSessionId;
use Magento\TestFramework\Helper\Bootstrap;
use Magento\Framework\App\Area;
use Magento\Framework\Intl\DateTimeFactory;
@@ -75,12 +75,12 @@ public function testCreateCaseBuilderWithFullSetOfData()
$productMetadata = $this->objectManager->create(ProductMetadataInterface::class);
- /** @var QuoteSessionId $quoteSessionId */
- $quoteSessionId = $this->objectManager->create(QuoteSessionId::class);
+ /** @var SignifydOrderSessionId $signifydOrderSessionId */
+ $signifydOrderSessionId = $this->objectManager->create(SignifydOrderSessionId::class);
$expected = [
'purchase' => [
- 'orderSessionId' => $quoteSessionId->get($order->getQuoteId()),
+ 'orderSessionId' => $signifydOrderSessionId->get($order->getQuoteId()),
'browserIpAddress' => $order->getRemoteIp(),
'orderId' => $order->getEntityId(),
'createdAt' => '2016-12-12T12:00:55+00:00',
@@ -186,8 +186,8 @@ public function testCreateCaseBuilderWithVirtualProductAndGuest()
$billingAddress = $order->getBillingAddress();
$productMetadata = $this->objectManager->create(ProductMetadataInterface::class);
- /** @var QuoteSessionId $quoteSessionId */
- $quoteSessionId = $this->objectManager->create(QuoteSessionId::class);
+ /** @var SignifydOrderSessionId $quoteSessionId */
+ $quoteSessionId = $this->objectManager->create(SignifydOrderSessionId::class);
$expected = [
'purchase' => [
From b504a588ad0306c40c886a38f991cac4dd6af3c7 Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Fri, 23 Dec 2016 07:23:59 -0600
Subject: [PATCH 055/904] MAGETWO-54389: Submitting Case Entry to Signifyd on
Order Creation
- Move CreateCaseBuilderInterface preference from global to frontend area
---
app/code/Magento/Signifyd/etc/di.xml | 1 -
1 file changed, 1 deletion(-)
diff --git a/app/code/Magento/Signifyd/etc/di.xml b/app/code/Magento/Signifyd/etc/di.xml
index df5214ba14c52..81d157887f7e1 100644
--- a/app/code/Magento/Signifyd/etc/di.xml
+++ b/app/code/Magento/Signifyd/etc/di.xml
@@ -12,5 +12,4 @@
-
\ No newline at end of file
From 176d11efa3c198c1b57fe05a8ecbf67ac4657f46 Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Tue, 20 Dec 2016 11:36:44 -0600
Subject: [PATCH 056/904] MAGETWO-54389: Submitting Case Entry to Signifyd on
Order Creation
- code review comments
---
.../Api/CaseCreationServiceInterface.php | 1 +
.../Signifyd/Api/CaseManagementInterface.php | 10 +-
.../Signifyd/Api/CaseRepositoryInterface.php | 12 +-
.../Signifyd/Api/Data/CaseInterface.php | 129 +++++++-----------
.../Api/Data/CaseSearchResultsInterface.php | 6 +-
.../Signifyd/Model/CaseCreationService.php | 11 +-
.../Magento/Signifyd/Setup/InstallSchema.php | 11 ++
7 files changed, 90 insertions(+), 90 deletions(-)
diff --git a/app/code/Magento/Signifyd/Api/CaseCreationServiceInterface.php b/app/code/Magento/Signifyd/Api/CaseCreationServiceInterface.php
index 2118652f31a7d..7141d76371c06 100644
--- a/app/code/Magento/Signifyd/Api/CaseCreationServiceInterface.php
+++ b/app/code/Magento/Signifyd/Api/CaseCreationServiceInterface.php
@@ -20,6 +20,7 @@ interface CaseCreationServiceInterface
*
* @param int $orderId
* @return bool
+ * @throws \Magento\Framework\Exception\AlreadyExistsException If case for $orderId already exists
*/
public function createForOrder($orderId);
}
diff --git a/app/code/Magento/Signifyd/Api/CaseManagementInterface.php b/app/code/Magento/Signifyd/Api/CaseManagementInterface.php
index cced6d2e4afe3..40f1dcc11b54f 100644
--- a/app/code/Magento/Signifyd/Api/CaseManagementInterface.php
+++ b/app/code/Magento/Signifyd/Api/CaseManagementInterface.php
@@ -9,23 +9,25 @@
/**
* Signifyd management interface
- * Allows to performs operations with Signifyd cases
+ * Allows to performs operations with Signifyd cases.
*
* @api
*/
interface CaseManagementInterface
{
/**
- * Creates new Case entity
+ * Creates new Case entity linked to order id.
+ *
* @param string $orderId
* @return CaseInterface
*/
public function create($orderId);
/**
- * Gets Case entity
+ * Gets Case entity associated with order id.
+ *
* @param string $orderId
- * @return CaseInterface
+ * @return CaseInterface|null
*/
public function getByOrderId($orderId);
}
diff --git a/app/code/Magento/Signifyd/Api/CaseRepositoryInterface.php b/app/code/Magento/Signifyd/Api/CaseRepositoryInterface.php
index 99ca62e99643e..0e63e9283ad28 100644
--- a/app/code/Magento/Signifyd/Api/CaseRepositoryInterface.php
+++ b/app/code/Magento/Signifyd/Api/CaseRepositoryInterface.php
@@ -17,28 +17,32 @@
interface CaseRepositoryInterface
{
/**
- * Saves case entity
+ * Saves case entity.
+ *
* @param CaseInterface $case
* @return CaseInterface
*/
public function save(CaseInterface $case);
/**
- * Gets case entity by order id
+ * Gets case entity by order id.
+ *
* @param int $id
* @return CaseInterface
*/
public function getById($id);
/**
- * Deletes case entity
+ * Deletes case entity.
+ *
* @param CaseInterface $case
* @return bool
*/
public function delete(CaseInterface $case);
/**
- * Gets list of case entities
+ * Gets list of case entities.
+ *
* @param SearchCriteria $searchCriteria
* @return CaseSearchResultsInterface
*/
diff --git a/app/code/Magento/Signifyd/Api/Data/CaseInterface.php b/app/code/Magento/Signifyd/Api/Data/CaseInterface.php
index ffcfd3f118eb9..6a58effa19e4f 100644
--- a/app/code/Magento/Signifyd/Api/Data/CaseInterface.php
+++ b/app/code/Magento/Signifyd/Api/Data/CaseInterface.php
@@ -6,7 +6,7 @@
namespace Magento\Signifyd\Api\Data;
/**
- * Interface Signifyd Case entity
+ * Signifyd Case entity interface
*
* @api
* @see https://www.signifyd.com/docs/api/#/reference/cases/retrieve-a-case/get-a-case
@@ -16,218 +16,191 @@ interface CaseInterface
/**#@+
* Constants for case available statuses
*/
-
- /**
- * Open status
- */
const STATUS_OPEN = 'OPEN';
-
- /**
- * Pending status
- */
const STATUS_PENDING = 'PENDING';
-
- /**
- * Processing status
- */
const STATUS_PROCESSING = 'PROCESSING';
-
- /**
- * Flagged status
- */
const STATUS_FLAGGED = 'FLAGGED';
-
- /**
- * Dismissed status
- */
const STATUS_DISMISSED = 'DISMISSED';
+ /**#@-*/
/**#@+
* Constants for guarantee available statuses
*/
-
- /**
- * Approved status
- */
const GUARANTEE_APPROVED = 'APPROVED';
-
- /**
- * Declined status
- */
const GUARANTEE_DECLINED = 'DECLINED';
-
- /**
- * Pending status
- */
const GUARANTEE_PENDING = 'PENDING';
-
- /**
- * Canceled status
- */
const GUARANTEE_CANCELED = 'CANCELED';
-
- /**
- * In review status
- */
const GUARANTEE_IN_REVIEW = 'IN_REVIEW';
+ /**#@-*/
/**#@+
* Constants for case available review dispositions
*/
-
- /**
- * Review disposition is good
- */
const DISPOSITION_GOOD = 'GOOD';
-
- /**
- * Review disposition is fraud
- */
const DISPOSITION_FRAUDULENT = 'FRAUDULENT';
-
- /**
- * Review disposition is not set
- */
const DISPOSITION_UNSET = 'UNSET';
+ /**#@-*/
/**
- * Gets case entity id
+ * Returns local case entity identifier.
+ *
* @return int
*/
public function getEntityId();
/**
- * Sets case entity id
+ * Sets local case entity id.
+ *
* @param int $id
* @return $this
*/
public function setEntityId($id);
/**
- * Gets Signifyd case id
+ * Returns Signifyd case identifier.
+ *
* @return int
*/
public function getCaseId();
/**
- * Sets Signifyd case id
+ * Sets Signifyd case id.
+ *
* @param int $id
* @return $this
*/
public function setCaseId($id);
/**
- * Gets value, which indicates if a guarantee can be requested for a case
+ * Returns value, which indicates if a guarantee can be requested for a case.
+ *
* @return boolean
*/
public function isGuaranteeEligible();
/**
- * Sets value-indicator about guarantee availability for a case
+ * Sets value-indicator about guarantee availability for a case.
+ *
* @param bool $guaranteeEligible
* @return $this
*/
public function setGuaranteeEligible($guaranteeEligible);
/**
- * Gets decision state of the guarantee
+ * Returns decision state of the guarantee.
+ *
* @return string
*/
public function getGuaranteeDisposition();
/**
- * Sets decision state of the guarantee
+ * Sets decision state of the guarantee.
+ *
* @param string $disposition
* @return $this
*/
public function setGuaranteeDisposition($disposition);
/**
- * Gets case status
+ * Returns case status.
+ *
* @return string
*/
public function getStatus();
/**
- * Sets case status
+ * Sets case status.
+ *
* @param string $status
* @return $this
*/
public function setStatus($status);
/**
- * Gets value, which indicates the likelihood that the order is fraud
+ * Returns value, which indicates the likelihood that the order is fraud.
+ *
* @return int
*/
public function getScore();
/**
- * Sets risk level value
+ * Sets risk level value.
+ *
* @param int $score
* @return $this
*/
public function setScore($score);
/**
- * Get order id for a case
+ * Get order id for a case.
+ *
* @return int
*/
public function getOrderId();
/**
- * Sets order id for a case
+ * Sets order id for a case.
+ *
* @param int $orderId
* @return $this
*/
public function setOrderId($orderId);
/**
- * Gets id of team associated with a case
- * @return int
+ * Returns data about a team associated with a case.
+ *
+ * @return array
*/
public function getAssociatedTeam();
/**
- * Sets case associated team id
- * @param int $teamId
+ * Sets team data associated with a case.
+ *
+ * @param array $team
* @return $this
*/
- public function setAssociatedTeam($teamId);
+ public function setAssociatedTeam(array $team);
/**
- * Gets disposition of an agent's opinion after reviewing the case
+ * Returns disposition of an agent's opinion after reviewing the case.
+ *
* @return string
*/
public function getReviewDisposition();
/**
- * Sets case disposition
+ * Sets case disposition.
+ *
* @param string $disposition
* @return $this
*/
public function setReviewDisposition($disposition);
/**
- * Gets creation datetime for a case
+ * Returns creation datetime for a case.
+ *
* @return string
*/
public function getCreatedAt();
/**
- * Sets creation datetime for a case
+ * Sets creation datetime for a case.
+ *
* @param string $datetime in DATE_ATOM format
* @return $this
*/
public function setCreatedAt($datetime);
/**
- * Gets updating datetime for a case
+ * Returns updating datetime for a case.
+ *
* @return string
*/
public function getUpdatedAt();
/**
- * Sets updating datetime for a case
+ * Sets updating datetime for a case.
+ *
* @param string $datetime in DATE_ATOM format
* @return $this
*/
diff --git a/app/code/Magento/Signifyd/Api/Data/CaseSearchResultsInterface.php b/app/code/Magento/Signifyd/Api/Data/CaseSearchResultsInterface.php
index 6113411a73e01..451206f1b3d15 100644
--- a/app/code/Magento/Signifyd/Api/Data/CaseSearchResultsInterface.php
+++ b/app/code/Magento/Signifyd/Api/Data/CaseSearchResultsInterface.php
@@ -8,21 +8,21 @@
use Magento\Framework\Api\SearchResultsInterface;
/**
- * Interface for case search results
+ * Retrieve and set list of case entities.
*
* @api
*/
interface CaseSearchResultsInterface extends SearchResultsInterface
{
/**
- * Gets collection items.
+ * Gets collection of case entities.
*
* @return \Magento\Signifyd\Api\Data\CaseInterface[]
*/
public function getItems();
/**
- * Sets collection items.
+ * Sets collection of case entities.
*
* @param \Magento\Signifyd\Api\Data\CaseInterface[] $items
* @return $this
diff --git a/app/code/Magento/Signifyd/Model/CaseCreationService.php b/app/code/Magento/Signifyd/Model/CaseCreationService.php
index 27fb33a80345c..dcbbbf11554be 100644
--- a/app/code/Magento/Signifyd/Model/CaseCreationService.php
+++ b/app/code/Magento/Signifyd/Model/CaseCreationService.php
@@ -5,6 +5,9 @@
*/
namespace Magento\Signifyd\Model;
+use Magento\Framework\Exception\AlreadyExistsException;
+use Magento\Framework\DB\Adapter\DuplicateException;
+use Magento\Framework\Phrase;
use Magento\Signifyd\Api\CaseCreationServiceInterface;
use Magento\Signifyd\Api\CaseManagementInterface;
use Magento\Signifyd\Model\SignifydGateway\ApiCallException;
@@ -56,7 +59,12 @@ public function __construct(
*/
public function createForOrder($orderId)
{
- $this->caseManagement->create($orderId);
+ try {
+ $this->caseManagement->create($orderId);
+ } catch (DuplicateException $e) {
+ throw new AlreadyExistsException(new Phrase('This order already has associated case entity'), $e);
+ }
+
try {
$this->signifydGateway->createCase($orderId);
} catch (ApiCallException $e) {
@@ -64,6 +72,7 @@ public function createForOrder($orderId)
} catch (GatewayException $e) {
$this->logger->error($e->getMessage());
}
+
return true;
}
}
diff --git a/app/code/Magento/Signifyd/Setup/InstallSchema.php b/app/code/Magento/Signifyd/Setup/InstallSchema.php
index dfd9a7cfcab19..5b5f807e1f520 100644
--- a/app/code/Magento/Signifyd/Setup/InstallSchema.php
+++ b/app/code/Magento/Signifyd/Setup/InstallSchema.php
@@ -47,6 +47,17 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
$table->addColumn('review_disposition', Table::TYPE_TEXT, 32);
$table->addColumn('created_at', Table::TYPE_TIMESTAMP);
$table->addColumn('updated_at', Table::TYPE_TIMESTAMP);
+
+ $table->addIndex(
+ $setup->getIdxName(
+ $setup->getTable(static::$table),
+ 'order_id',
+ \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE
+ ),
+ 'order_id',
+ ['type' => \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE]
+ );
+
$table->addForeignKey(
$setup->getFkName(
$setup->getTable(static::$table),
From 9d0a5a18ab3e6ffeca40d22e7a3abd47d1146ac6 Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Wed, 21 Dec 2016 03:53:15 -0600
Subject: [PATCH 057/904] MAGETWO-54389: Submitting Case Entry to Signifyd on
Order Creation
- refactor associated team to array
---
app/code/Magento/Signifyd/Model/CaseEntity.php | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/app/code/Magento/Signifyd/Model/CaseEntity.php b/app/code/Magento/Signifyd/Model/CaseEntity.php
index 85783da3308da..8502ac5a51b95 100644
--- a/app/code/Magento/Signifyd/Model/CaseEntity.php
+++ b/app/code/Magento/Signifyd/Model/CaseEntity.php
@@ -5,8 +5,10 @@
*/
namespace Magento\Signifyd\Model;
+use Magento\Framework\App\ObjectManager;
use Magento\Framework\Model\AbstractModel;
use Magento\Signifyd\Api\Data\CaseInterface;
+use Magento\Framework\Serialize\SerializerInterface;
/**
* Implementation of Signifyd Case interface
@@ -18,11 +20,17 @@ class CaseEntity extends AbstractModel implements CaseInterface
*/
protected $_eventPrefix = 'signifyd_case';
+ /**
+ * @var SerializerInterface
+ */
+ protected $serializer;
+
/**
* @inheritdoc
*/
protected function _construct()
{
+ $this->serializer = ObjectManager::getInstance()->get(SerializerInterface::class);
$this->_init(ResourceModel\CaseEntity::class);
}
@@ -150,15 +158,16 @@ public function setOrderId($orderId)
*/
public function getAssociatedTeam()
{
- return (int) $this->getData('associated_team');
+ $teamData = $this->getData('associated_team');
+ return empty($teamData) ? array() : $this->serializer->unserialize($teamData);
}
/**
* @inheritdoc
*/
- public function setAssociatedTeam($teamId)
+ public function setAssociatedTeam(array $team)
{
- $this->setData('associated_team', (int) $teamId);
+ $this->setData('associated_team', $this->serializer->serialize($team));
return $this;
}
From 805fce3366a0ff72d1f36263ceafa3a754b2523c Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Wed, 21 Dec 2016 07:35:32 -0600
Subject: [PATCH 058/904] MAGETWO-54389: Submitting Case Entry to Signifyd on
Order Creation
- refactor according to review
---
.../Signifyd/Api/CaseManagementInterface.php | 1 +
.../Signifyd/Model/CaseCreationService.php | 9 +----
.../Magento/Signifyd/Model/CaseManagement.php | 8 ++++-
.../Magento/Signifyd/Observer/PlaceOrder.php | 35 ++++++++++++++++---
.../Magento/Signifyd/Setup/InstallSchema.php | 2 +-
.../Signifyd/Block/FingerprintTest.php | 2 +-
.../Request/CreateCaseBuilderTest.php | 4 +--
7 files changed, 43 insertions(+), 18 deletions(-)
diff --git a/app/code/Magento/Signifyd/Api/CaseManagementInterface.php b/app/code/Magento/Signifyd/Api/CaseManagementInterface.php
index 40f1dcc11b54f..09c2e8c0e164c 100644
--- a/app/code/Magento/Signifyd/Api/CaseManagementInterface.php
+++ b/app/code/Magento/Signifyd/Api/CaseManagementInterface.php
@@ -20,6 +20,7 @@ interface CaseManagementInterface
*
* @param string $orderId
* @return CaseInterface
+ * @throws \Magento\Framework\Exception\AlreadyExistsException If case for $orderId already exists
*/
public function create($orderId);
diff --git a/app/code/Magento/Signifyd/Model/CaseCreationService.php b/app/code/Magento/Signifyd/Model/CaseCreationService.php
index dcbbbf11554be..c544ab30d6b35 100644
--- a/app/code/Magento/Signifyd/Model/CaseCreationService.php
+++ b/app/code/Magento/Signifyd/Model/CaseCreationService.php
@@ -5,9 +5,6 @@
*/
namespace Magento\Signifyd\Model;
-use Magento\Framework\Exception\AlreadyExistsException;
-use Magento\Framework\DB\Adapter\DuplicateException;
-use Magento\Framework\Phrase;
use Magento\Signifyd\Api\CaseCreationServiceInterface;
use Magento\Signifyd\Api\CaseManagementInterface;
use Magento\Signifyd\Model\SignifydGateway\ApiCallException;
@@ -59,11 +56,7 @@ public function __construct(
*/
public function createForOrder($orderId)
{
- try {
- $this->caseManagement->create($orderId);
- } catch (DuplicateException $e) {
- throw new AlreadyExistsException(new Phrase('This order already has associated case entity'), $e);
- }
+ $this->caseManagement->create($orderId);
try {
$this->signifydGateway->createCase($orderId);
diff --git a/app/code/Magento/Signifyd/Model/CaseManagement.php b/app/code/Magento/Signifyd/Model/CaseManagement.php
index 504b52b85a74a..8705f9a812ae3 100644
--- a/app/code/Magento/Signifyd/Model/CaseManagement.php
+++ b/app/code/Magento/Signifyd/Model/CaseManagement.php
@@ -11,6 +11,8 @@
use Magento\Signifyd\Api\CaseRepositoryInterface;
use Magento\Signifyd\Api\Data\CaseInterface;
use Magento\Signifyd\Api\Data\CaseInterfaceFactory;
+use Magento\Framework\Exception\AlreadyExistsException;
+use Magento\Framework\DB\Adapter\DuplicateException;
/**
*
@@ -65,7 +67,11 @@ public function create($orderId)
$case = $this->caseFactory->create();
$case->setOrderId($orderId)
->setStatus(CaseInterface::STATUS_PENDING);
- return $this->caseRepository->save($case);
+ try {
+ return $this->caseRepository->save($case);
+ } catch (DuplicateException $e) {
+ throw new AlreadyExistsException(__('This order already has associated case entity'), $e);
+ }
}
/**
diff --git a/app/code/Magento/Signifyd/Observer/PlaceOrder.php b/app/code/Magento/Signifyd/Observer/PlaceOrder.php
index 1d0a51167dc34..ef037ca7cd8e4 100644
--- a/app/code/Magento/Signifyd/Observer/PlaceOrder.php
+++ b/app/code/Magento/Signifyd/Observer/PlaceOrder.php
@@ -12,6 +12,8 @@
use Magento\Signifyd\Model\Config;
use Magento\Signifyd\Api\CaseCreationServiceInterface;
+use Psr\Log\LoggerInterface;
+use Magento\Framework\Exception\AlreadyExistsException;
/**
* Place Order observer.
@@ -31,18 +33,26 @@ class PlaceOrder implements ObserverInterface
*/
private $caseCreationService;
+ /**
+ * @var LoggerInterface
+ */
+ private $logger;
+
/**
* PlaceOrder constructor.
*
* @param Config $signifydIntegrationConfig
* @param CaseCreationServiceInterface $caseCreationService
+ * @param LoggerInterface $logger
*/
public function __construct(
Config $signifydIntegrationConfig,
- CaseCreationServiceInterface $caseCreationService
+ CaseCreationServiceInterface $caseCreationService,
+ LoggerInterface $logger
) {
$this->signifydIntegrationConfig = $signifydIntegrationConfig;
$this->caseCreationService = $caseCreationService;
+ $this->logger = $logger;
}
/**
@@ -63,10 +73,25 @@ public function execute(Observer $observer)
}
foreach ($orders as $order) {
- $orderId = $order->getEntityId();
- if (null !== $orderId) {
- $this->caseCreationService->createForOrder($orderId);
- }
+ $this->createCaseForOrder($order);
+ }
+ }
+
+ /**
+ * Creates signifyd case for single order
+ *
+ * @param OrderInterface $order
+ */
+ private function createCaseForOrder($order) {
+ $orderId = $order->getEntityId();
+ if (null !== $orderId) {
+ return;
+ }
+
+ try {
+ $this->caseCreationService->createForOrder($orderId);
+ } catch (AlreadyExistsException $e) {
+ $this->logger->error($e->getMessage());
}
}
diff --git a/app/code/Magento/Signifyd/Setup/InstallSchema.php b/app/code/Magento/Signifyd/Setup/InstallSchema.php
index 5b5f807e1f520..deb313c66a828 100644
--- a/app/code/Magento/Signifyd/Setup/InstallSchema.php
+++ b/app/code/Magento/Signifyd/Setup/InstallSchema.php
@@ -43,7 +43,7 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
$table->addColumn('guarantee_disposition', Table::TYPE_TEXT, 32);
$table->addColumn('status', Table::TYPE_TEXT, 32, ['default' => CaseInterface::STATUS_PENDING]);
$table->addColumn('score', Table::TYPE_INTEGER, null, ['unsigned' => true]);
- $table->addColumn('associated_team', Table::TYPE_INTEGER, null, ['unsigned' => true]);
+ $table->addColumn('associated_team', Table::TYPE_TEXT, '64k');
$table->addColumn('review_disposition', Table::TYPE_TEXT, 32);
$table->addColumn('created_at', Table::TYPE_TIMESTAMP);
$table->addColumn('updated_at', Table::TYPE_TIMESTAMP);
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Block/FingerprintTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Block/FingerprintTest.php
index 2cdd3c1d67a3c..6708af55dddf9 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Block/FingerprintTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Block/FingerprintTest.php
@@ -36,7 +36,7 @@ protected function setUp()
*/
public function testSessionIdPresent()
{
- static::assertRegExp('/data-order-session-id=\"[^\"]+\"/', $this->getBlockContents());
+ static::assertContains('data-order-session-id', $this->getBlockContents());
}
/**
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
index 61dc67b7f7808..de0ddc7c1f03f 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
@@ -106,8 +106,8 @@ public function testCreateCaseBuilderWithFullSetOfData()
'itemWeight' => $product->getWeight()
],
1 => [
- 'itemId' => 'simple2',
- 'itemName' => 'Simple product',
+ 'itemId' => $orderItems[1]->getSku(),
+ 'itemName' => $orderItems[1]->getName(),
'itemPrice' => $orderItems[1]->getPrice(),
'itemQuantity' => $orderItems[1]->getQtyOrdered(),
'itemUrl' => $product->getProductUrl(),
From bfc5f475dc8fec24f9dcc331fd3249861009fbe9 Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Wed, 21 Dec 2016 08:49:26 -0600
Subject: [PATCH 059/904] MAGETWO-54389: Submitting Case Entry to Signifyd on
Order Creation
- replace orderId with orderIncrementId
- fixes for integration tests
- db schema update
---
.../Signifyd/Api/Data/CaseInterface.php | 15 +++++++++++++++
.../Magento/Signifyd/Model/CaseEntity.php | 19 ++++++++++++++++++-
.../Request/PurchaseBuilder.php | 2 +-
.../Magento/Signifyd/Setup/InstallSchema.php | 1 +
.../Request/CreateCaseBuilderTest.php | 4 ++--
.../Magento/Signifyd/_files/case.php | 9 ++++++++-
6 files changed, 45 insertions(+), 5 deletions(-)
diff --git a/app/code/Magento/Signifyd/Api/Data/CaseInterface.php b/app/code/Magento/Signifyd/Api/Data/CaseInterface.php
index 6a58effa19e4f..cd1122e276c87 100644
--- a/app/code/Magento/Signifyd/Api/Data/CaseInterface.php
+++ b/app/code/Magento/Signifyd/Api/Data/CaseInterface.php
@@ -146,6 +146,21 @@ public function getOrderId();
*/
public function setOrderId($orderId);
+ /**
+ * Returns order increment id for a case.
+ *
+ * @return string
+ */
+ public function getOrderIncrementId();
+
+ /**
+ * Sets order increment id for a case.
+ *
+ * @param string $orderIncrementId
+ * @return $this
+ */
+ public function setOrderIncrementId($orderIncrementId);
+
/**
* Returns data about a team associated with a case.
*
diff --git a/app/code/Magento/Signifyd/Model/CaseEntity.php b/app/code/Magento/Signifyd/Model/CaseEntity.php
index 8502ac5a51b95..efccab18da65b 100644
--- a/app/code/Magento/Signifyd/Model/CaseEntity.php
+++ b/app/code/Magento/Signifyd/Model/CaseEntity.php
@@ -153,13 +153,30 @@ public function setOrderId($orderId)
return $this;
}
+ /**
+ * @inheritdoc
+ */
+ public function getOrderIncrementId()
+ {
+ return (string) $this->getData('order_increment_id');
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function setOrderIncrementId($orderIncrementId)
+ {
+ $this->setData('order_increment_id', (string) $orderIncrementId);
+ return $this;
+ }
+
/**
* @inheritdoc
*/
public function getAssociatedTeam()
{
$teamData = $this->getData('associated_team');
- return empty($teamData) ? array() : $this->serializer->unserialize($teamData);
+ return empty($teamData) ? [] : $this->serializer->unserialize($teamData);
}
/**
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php
index 6f39369bc6752..81d601898373d 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php
@@ -64,7 +64,7 @@ public function build(Order $order)
'purchase' => [
'orderSessionId' => $this->signifydOrderSessionId->get($order->getQuoteId()),
'browserIpAddress' => $order->getRemoteIp(),
- 'orderId' => $order->getEntityId(),
+ 'orderId' => $order->getIncrementId(),
'createdAt' => $createdAt->format(\DateTime::ATOM),
'paymentGateway' => $this->getPaymentGateway($orderPayment->getMethod()),
'transactionId' => $orderPayment->getLastTransId(),
diff --git a/app/code/Magento/Signifyd/Setup/InstallSchema.php b/app/code/Magento/Signifyd/Setup/InstallSchema.php
index deb313c66a828..61e26eb3bb46a 100644
--- a/app/code/Magento/Signifyd/Setup/InstallSchema.php
+++ b/app/code/Magento/Signifyd/Setup/InstallSchema.php
@@ -38,6 +38,7 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true]
);
$table->addColumn('order_id', Table::TYPE_INTEGER, null, ['unsigned' => true]);
+ $table->addColumn('order_increment_id', Table::TYPE_TEXT, 32);
$table->addColumn('case_id', Table::TYPE_INTEGER, null, ['unsigned' => true]);
$table->addColumn('guarantee_eligible', Table::TYPE_BOOLEAN, null);
$table->addColumn('guarantee_disposition', Table::TYPE_TEXT, 32);
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
index de0ddc7c1f03f..d37d6fd6f8a7f 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
@@ -82,7 +82,7 @@ public function testCreateCaseBuilderWithFullSetOfData()
'purchase' => [
'orderSessionId' => $signifydOrderSessionId->get($order->getQuoteId()),
'browserIpAddress' => $order->getRemoteIp(),
- 'orderId' => $order->getEntityId(),
+ 'orderId' => $order->getIncrementId(),
'createdAt' => '2016-12-12T12:00:55+00:00',
'paymentGateway' => 'paypal_account',
'transactionId' => $payment->getLastTransId(),
@@ -193,7 +193,7 @@ public function testCreateCaseBuilderWithVirtualProductAndGuest()
'purchase' => [
'orderSessionId' => $quoteSessionId->get($order->getQuoteId()),
'browserIpAddress' => $order->getRemoteIp(),
- 'orderId' => $order->getEntityId(),
+ 'orderId' => $order->getIncrementId(),
'createdAt' => '2016-12-12T12:00:55+00:00',
'paymentGateway' => $payment->getMethod(),
'transactionId' => $payment->getLastTransId(),
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/_files/case.php b/dev/tests/integration/testsuite/Magento/Signifyd/_files/case.php
index de635ba750399..09f81b14725d1 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/_files/case.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/_files/case.php
@@ -12,6 +12,13 @@
/** @var CaseInterfaceFactory $caseFactory */
$caseFactory = $objectManager->get(CaseInterfaceFactory::class);
+$associatedTeam = array(
+ 'teamName' => 'Some Team',
+ 'teamId' => 123,
+ 'getAutoDismiss' => true,
+ 'getTeamDismissalDays' => 3
+);
+
/** @var CaseInterface $case */
$case = $caseFactory->create();
$case->setCaseId(123)
@@ -20,7 +27,7 @@
->setStatus(CaseInterface::STATUS_PROCESSING)
->setScore(553)
->setOrderId($order->getEntityId())
- ->setAssociatedTeam(124)
+ ->setAssociatedTeam($associatedTeam)
->setReviewDisposition(CaseInterface::DISPOSITION_GOOD)
->setCreatedAt('2016-12-12T15:17:17+0000')
->setUpdatedAt('2016-12-12T19:23:16+0000');
From d7398bb7d160d8cbb31d1aa2d610723258998550 Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Wed, 21 Dec 2016 09:46:08 -0600
Subject: [PATCH 060/904] MAGETWO-54389: Submitting Case Entry to Signifyd on
Order Creation
- fixes for static tests
---
app/code/Magento/Signifyd/Observer/PlaceOrder.php | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/app/code/Magento/Signifyd/Observer/PlaceOrder.php b/app/code/Magento/Signifyd/Observer/PlaceOrder.php
index ef037ca7cd8e4..f5468d1aef667 100644
--- a/app/code/Magento/Signifyd/Observer/PlaceOrder.php
+++ b/app/code/Magento/Signifyd/Observer/PlaceOrder.php
@@ -81,8 +81,10 @@ public function execute(Observer $observer)
* Creates signifyd case for single order
*
* @param OrderInterface $order
+ * @return void
*/
- private function createCaseForOrder($order) {
+ private function createCaseForOrder($order)
+ {
$orderId = $order->getEntityId();
if (null !== $orderId) {
return;
From 54e6652ec01c007adf5424b8d011a5a8f6487e5e Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Wed, 21 Dec 2016 09:19:27 -0600
Subject: [PATCH 061/904] MAGETWO-54389: Submitting Case Entry to Signifyd on
Order Creation
- Move customer orders total processing logic from UserAccountBuilder to CustomerOrders model
---
.../Request/CustomerOrders.php | 109 ++++++-
.../Request/UserAccountBuilder.php | 87 +-----
.../Request/CustomerOrdersTest.php | 269 ++++++++++++++++++
.../Request/UserAccountBuilderTest.php | 247 ----------------
4 files changed, 386 insertions(+), 326 deletions(-)
create mode 100644 app/code/Magento/Signifyd/Test/Unit/SignifydGateway/Request/CustomerOrdersTest.php
delete mode 100644 app/code/Magento/Signifyd/Test/Unit/SignifydGateway/Request/UserAccountBuilderTest.php
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/CustomerOrders.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/CustomerOrders.php
index 5fed6ebc99ab7..64d538e4c7cdb 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/CustomerOrders.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/CustomerOrders.php
@@ -5,13 +5,14 @@
*/
namespace Magento\Signifyd\Model\SignifydGateway\Request;
+use Magento\Directory\Model\CurrencyFactory;
use Magento\Framework\Api\FilterBuilder;
use Magento\Framework\Api\SearchCriteriaBuilder;
use Magento\Sales\Api\Data\OrderInterface;
use Magento\Sales\Api\OrderRepositoryInterface;
/**
- * Collects customer orders
+ * Provides information about customer orders.
*/
class CustomerOrders
{
@@ -30,6 +31,26 @@ class CustomerOrders
*/
private $orderRepository;
+ /**
+ * @var \Psr\Log\LoggerInterface
+ */
+ private $logger;
+
+ /**
+ * @var CurrencyFactory
+ */
+ private $currencyFactory;
+
+ /**
+ * @var array
+ */
+ private $currencies = [];
+
+ /**
+ * @var string
+ */
+ private static $usdCurrencyCode = 'USD';
+
/**
* @param SearchCriteriaBuilder $searchCriteriaBuilder
* @param FilterBuilder $filterBuilder
@@ -38,21 +59,64 @@ class CustomerOrders
public function __construct(
SearchCriteriaBuilder $searchCriteriaBuilder,
FilterBuilder $filterBuilder,
- OrderRepositoryInterface $orderRepository
+ OrderRepositoryInterface $orderRepository,
+ CurrencyFactory $currencyFactory,
+ \Psr\Log\LoggerInterface $logger
) {
$this->searchCriteriaBuilder = $searchCriteriaBuilder;
$this->filterBuilder = $filterBuilder;
$this->orderRepository = $orderRepository;
+ $this->logger = $logger;
+ $this->currencyFactory = $currencyFactory;
}
/**
- * Returns customer orders
+ * Returns aggregated customer orders count and total amount in USD.
+ *
+ * Returned array contains next keys:
+ ** aggregateOrderCount - total count of orders placed by this account since it was created, including the current
+ ** aggregateOrderDollars - total amount spent by this account since it was created, including the current order
*
* @param int $customerId
+ * @return array
+ */
+ public function getCountAndTotalAmount($customerId)
+ {
+ $result = [
+ 'aggregateOrderCount' => null,
+ 'aggregateOrderDollars' => null
+ ];
+
+ $customerOrders = $this->getCustomerOrders($customerId);
+ if (!empty($customerOrders)) {
+ try {
+ $orderTotalDollars = 0.0;
+ foreach ($customerOrders as $order) {
+ $orderTotalDollars += $this->getUsdOrderTotal(
+ $order->getBaseGrandTotal(),
+ $order->getBaseCurrencyCode()
+ );
+ }
+ $result = [
+ 'aggregateOrderCount' => count($customerOrders),
+ 'aggregateOrderDollars' => $orderTotalDollars
+ ];
+ } catch (\Exception $e) {
+ $this->logger->error($e->getMessage());
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Returns customer orders.
+ *
+ * @param $customerId
* @return \Magento\Sales\Api\Data\OrderInterface[]
*/
- public function get($customerId)
+ private function getCustomerOrders($customerId)
{
$filters = [
$this->filterBuilder->setField(OrderInterface::CUSTOMER_ID)->setValue($customerId)->create()
@@ -63,4 +127,41 @@ public function get($customerId)
return $searchResults->getItems();
}
+
+ /**
+ * Returns amount in USD.
+ *
+ * @param float $amount
+ * @param string $currency
+ * @return float
+ */
+ private function getUsdOrderTotal($amount, $currency)
+ {
+ if ($currency === self::$usdCurrencyCode) {
+ return $amount;
+ }
+
+ $operationCurrency = $this->getCurrencyByCode($currency);
+
+ return $operationCurrency->convert($amount, self::$usdCurrencyCode);
+ }
+
+ /**
+ * Returns currency by currency code.
+ *
+ * @param string|null $currencyCode
+ * @return \Magento\Directory\Model\Currency
+ */
+ private function getCurrencyByCode($currencyCode)
+ {
+ if (isset($this->currencies[$currencyCode])) {
+ return $this->currencies[$currencyCode];
+ }
+
+ /** @var \Magento\Directory\Model\Currency $currency */
+ $currency = $this->currencyFactory->create();
+ $this->currencies[$currencyCode] = $currency->load($currencyCode);
+
+ return $this->currencies[$currencyCode];
+ }
}
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/UserAccountBuilder.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/UserAccountBuilder.php
index 7133942741360..ac9bff2a14171 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/UserAccountBuilder.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/UserAccountBuilder.php
@@ -8,7 +8,7 @@
use Magento\Sales\Model\Order;
/**
- * Prepare details based on registered user account info
+ * Prepares details based on registered user account info
*/
class UserAccountBuilder
{
@@ -22,49 +22,23 @@ class UserAccountBuilder
*/
private $dateTimeFactory;
- /**
- * @var \Psr\Log\LoggerInterface
- */
- private $logger;
-
- /**
- * @var \Magento\Directory\Model\CurrencyFactory
- */
- private $currencyFactory;
-
- /**
- * @var array
- */
- private $currencies = [];
-
/**
* @var CustomerOrders
*/
private $customerOrders;
- /**
- * @var string
- */
- private static $usdCurrencyCode = 'USD';
-
/**
* @param \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository
* @param CustomerOrders $customerOrders
- * @param \Psr\Log\LoggerInterface $logger
- * @param \Magento\Directory\Model\CurrencyFactory $currencyFactory
* @param \Magento\Framework\Intl\DateTimeFactory $dateTimeFactory
*/
public function __construct(
\Magento\Customer\Api\CustomerRepositoryInterface $customerRepository,
CustomerOrders $customerOrders,
- \Magento\Framework\Intl\DateTimeFactory $dateTimeFactory,
- \Psr\Log\LoggerInterface $logger,
- \Magento\Directory\Model\CurrencyFactory $currencyFactory
+ \Magento\Framework\Intl\DateTimeFactory $dateTimeFactory
) {
$this->customerRepository = $customerRepository;
$this->dateTimeFactory = $dateTimeFactory;
- $this->logger = $logger;
- $this->currencyFactory = $currencyFactory;
$this->customerOrders = $customerOrders;
}
@@ -96,65 +70,28 @@ public function build(Order $order)
]
];
- $customerOrders = $this->customerOrders->get($customerId);
- if (!empty($customerOrders)) {
- try {
- $orderTotalDollars = 0.0;
- foreach ($customerOrders as $order) {
- $orderTotalDollars += $this->getUsdOrderTotal(
- $order->getBaseGrandTotal(),
- $order->getBaseCurrencyCode()
- );
- }
- $result['userAccount']['aggregateOrderCount'] = count($customerOrders);
- $result['userAccount']['aggregateOrderDollars'] = $orderTotalDollars;
- } catch (\Exception $e) {
- $this->logger->error($e->getMessage());
- }
+ $ordersInfo = $this->customerOrders->getCountAndTotalAmount($customerId);
+ if ($this->isNotEmptyCustomerOrdersInfo($ordersInfo)) {
+ $result['userAccount']['aggregateOrderCount'] = $ordersInfo['aggregateOrderCount'];
+ $result['userAccount']['aggregateOrderDollars'] = $ordersInfo['aggregateOrderDollars'];
}
return $result;
}
/**
- * Returns amount in USD
+ * Checks if customer aggregated orders count and total amount are available.
*
- * @param float $amount
- * @param string $currency
- * @return float
+ * @param array $ordersInfo
+ * @return bool
*/
- private function getUsdOrderTotal($amount, $currency)
+ private function isNotEmptyCustomerOrdersInfo(array $ordersInfo)
{
- if ($currency === self::$usdCurrencyCode) {
- return $amount;
- }
-
- $operationCurrency = $this->getCurrencyByCode($currency);
-
- return $operationCurrency->convert($amount, self::$usdCurrencyCode);
- }
-
- /**
- * Returns currency by currency code
- *
- * @param string|null $currencyCode
- * @return \Magento\Directory\Model\Currency
- */
- private function getCurrencyByCode($currencyCode)
- {
- if (isset($this->currencies[$currencyCode])) {
- return $this->currencies[$currencyCode];
- }
-
- /** @var \Magento\Directory\Model\Currency $currency */
- $currency = $this->currencyFactory->create();
- $this->currencies[$currencyCode] = $currency->load($currencyCode);
-
- return $this->currencies[$currencyCode];
+ return null !== $ordersInfo['aggregateOrderCount'] && null !== $ordersInfo['aggregateOrderDollars'];
}
/**
- * Returns date formatted according to ISO8601
+ * Returns date formatted according to ISO8601.
*
* @param string $date
* @return string
diff --git a/app/code/Magento/Signifyd/Test/Unit/SignifydGateway/Request/CustomerOrdersTest.php b/app/code/Magento/Signifyd/Test/Unit/SignifydGateway/Request/CustomerOrdersTest.php
new file mode 100644
index 0000000000000..1e6d792d962f7
--- /dev/null
+++ b/app/code/Magento/Signifyd/Test/Unit/SignifydGateway/Request/CustomerOrdersTest.php
@@ -0,0 +1,269 @@
+objectManager = new ObjectManager($this);
+
+ $this->orderRepository = $this->getMockBuilder(OrderRepositoryInterface::class)
+ ->getMockForAbstractClass();
+
+ $this->logger = $this->getMockBuilder(LoggerInterface::class)
+ ->getMockForAbstractClass();
+
+ $this->filterBuilder = $this->getMockBuilder(FilterBuilder::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->searchCriteriaBuilder = $this->getMockBuilder(SearchCriteriaBuilder::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->model = $this->objectManager->getObject(CustomerOrders::class, [
+ 'filterBuilder' => $this->filterBuilder,
+ 'orderRepository' => $this->orderRepository,
+ 'searchCriteriaBuilder' => $this->searchCriteriaBuilder,
+ 'logger' => $this->logger
+ ]);
+
+
+
+ $this->initCurrencies();
+ $this->initOrderRepository();
+
+ $this->objectManager->setBackwardCompatibleProperty(
+ $this->model,
+ 'currencies',
+ ['EUR' => $this->eurCurrency, 'UAH' => $this->uahCurrency]
+ );
+ }
+
+ /**
+ * @covers \Magento\Signifyd\Model\SignifydGateway\Request\CustomerOrders::getCountAndTotalAmount()
+ */
+ public function testGetCountAndTotalAmount()
+ {
+ $this->eurCurrency->expects($this->once())
+ ->method('convert')
+ ->with(self::$eurAmount, 'USD')
+ ->willReturn(109);
+
+ $this->uahCurrency->expects($this->once())
+ ->method('convert')
+ ->with(self::$uahAmount, 'USD')
+ ->willReturn(10.35);
+
+ $actual = $this->model->getCountAndTotalAmount(1);
+
+ static::assertEquals(3, $actual['aggregateOrderCount']);
+ static::assertEquals(169.35, $actual['aggregateOrderDollars']);
+ }
+
+ /**
+ * Test case when required currency rate is absent and exception is thrown
+ * @covers \Magento\Signifyd\Model\SignifydGateway\Request\CustomerOrders::getCountAndTotalAmount()
+ */
+ public function testGetCountAndTotalAmountNegative()
+ {
+ $this->eurCurrency->expects($this->once())
+ ->method('convert')
+ ->with(self::$eurAmount, 'USD')
+ ->willReturn(109);
+
+ $this->uahCurrency->expects($this->once())
+ ->method('convert')
+ ->with(self::$uahAmount, 'USD')
+ ->willThrowException(new \Exception());
+
+ $this->logger->expects($this->once())
+ ->method('error');
+
+ $actual = $this->model->getCountAndTotalAmount(1);
+
+ $this->assertNull($actual['aggregateOrderCount']);
+ $this->assertNull($actual['aggregateOrderDollars']);
+ }
+
+ /**
+ * Populate order repository with mocked orders
+ */
+ private function initOrderRepository()
+ {
+ $this->filterBuilder->expects($this->once())
+ ->method('setField')
+ ->willReturnSelf();
+ $this->filterBuilder->expects($this->once())
+ ->method('setValue')
+ ->willReturnSelf();
+ $filter = $this->getMockBuilder(\Magento\Framework\Api\Filter::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->filterBuilder->expects($this->once())
+ ->method('create')
+ ->willReturn($filter);
+
+ $searchCriteria = $this->getMockBuilder(\Magento\Framework\Api\SearchCriteria::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->searchCriteriaBuilder->expects($this->once())
+ ->method('create')
+ ->willReturn($searchCriteria);
+
+ $orderSearchResult = $this->getMockBuilder(OrderSearchResultInterface::class)
+ ->getMockForAbstractClass();
+ $orderSearchResult->expects($this->once())
+ ->method('getItems')
+ ->willReturn($this->getOrders());
+ $this->orderRepository->expects($this->once())
+ ->method('getList')
+ ->willReturn($orderSearchResult);
+ }
+
+ /**
+ * Creates mocks for currencies
+ * @return void
+ */
+ private function initCurrencies()
+ {
+ $this->eurCurrency = $this->getMockBuilder(Currency::class)
+ ->disableOriginalConstructor()
+ ->setMethods(['convert'])
+ ->getMock();
+
+ $this->uahCurrency = $this->getMockBuilder(Currency::class)
+ ->disableOriginalConstructor()
+ ->setMethods(['convert'])
+ ->getMock();
+ }
+
+ /**
+ * Get list of mocked orders with different currencies
+ * @return array
+ */
+ private function getOrders()
+ {
+ $eurOrder = $this->getMockBuilder(Order::class)
+ ->disableOriginalConstructor()
+ ->setMethods(['getBaseGrandTotal', 'getBaseCurrencyCode'])
+ ->getMock();
+
+ $eurOrder->expects($this->once())
+ ->method('getBaseGrandTotal')
+ ->willReturn(self::$eurAmount);
+ $eurOrder->expects($this->once())
+ ->method('getBaseCurrencyCode')
+ ->willReturn('EUR');
+
+ $uahOrder = $this->getMockBuilder(Order::class)
+ ->disableOriginalConstructor()
+ ->setMethods(['getBaseGrandTotal', 'getBaseCurrencyCode'])
+ ->getMock();
+
+ $uahOrder->expects($this->once())
+ ->method('getBaseGrandTotal')
+ ->willReturn(self::$uahAmount);
+ $uahOrder->expects($this->once())
+ ->method('getBaseCurrencyCode')
+ ->willReturn('UAH');
+
+ $usdOrder = $this->getMockBuilder(Order::class)
+ ->disableOriginalConstructor()
+ ->setMethods(['getBaseGrandTotal', 'getBaseCurrencyCode'])
+ ->getMock();
+
+ $usdOrder->expects($this->once())
+ ->method('getBaseGrandTotal')
+ ->willReturn(self::$usdAmount);
+ $usdOrder->expects($this->once())
+ ->method('getBaseCurrencyCode')
+ ->willReturn('USD');
+
+ return [$usdOrder, $eurOrder, $uahOrder];
+ }
+}
diff --git a/app/code/Magento/Signifyd/Test/Unit/SignifydGateway/Request/UserAccountBuilderTest.php b/app/code/Magento/Signifyd/Test/Unit/SignifydGateway/Request/UserAccountBuilderTest.php
deleted file mode 100644
index a5d6ea624c1a6..0000000000000
--- a/app/code/Magento/Signifyd/Test/Unit/SignifydGateway/Request/UserAccountBuilderTest.php
+++ /dev/null
@@ -1,247 +0,0 @@
-objectManager = new ObjectManager($this);
-
- $this->customerOrdersService = $this->getMockBuilder(CustomerOrders::class)
- ->disableOriginalConstructor()
- ->setMethods(['get'])
- ->getMock();
-
- $this->customerRepository = $this->getMockBuilder(CustomerRepositoryInterface::class)
- ->setMethods(['getById'])
- ->getMockForAbstractClass();
-
- $dateTimeFactory = new DateTimeFactory();
-
- $this->builder = $this->objectManager->getObject(UserAccountBuilder::class, [
- 'customerRepository' => $this->customerRepository,
- 'dateTimeFactory' => $dateTimeFactory,
- 'customerOrders' => $this->customerOrdersService
- ]);
-
- $this->initCurrencies();
-
- $this->objectManager->setBackwardCompatibleProperty(
- $this->builder,
- 'currencies',
- ['EUR' => $this->eurCurrency, 'UAH' => $this->uahCurrency]
- );
- }
-
- /**
- * @covers \Magento\Signifyd\Model\SignifydGateway\Request\UserAccountBuilder::build
- */
- public function testBuild()
- {
- $order = $this->getOrder();
-
- $customer = $this->getMockBuilder(CustomerInterface::class)
- ->setMethods(['getEmail', 'getCreatedAt', 'getUpdatedAt'])
- ->getMockForAbstractClass();
- $customer->expects(static::exactly(2))
- ->method('getEmail')
- ->willReturn('jonh.doe@testmage.com');
- $customer->expects(static::once())
- ->method('getCreatedAt')
- ->willReturn('2016-10-12 12:23:12');
- $customer->expects(static::once())
- ->method('getUpdatedAt')
- ->willReturn('2016-12-14 18:19:00');
-
- $this->customerRepository->expects(static::once())
- ->method('getById')
- ->with(self::$customerId)
- ->willReturn($customer);
-
- $orders = $this->getOrders();
- $this->customerOrdersService->expects(static::once())
- ->method('get')
- ->with(self::$customerId)
- ->willReturn($orders);
-
- $this->eurCurrency->expects(static::once())
- ->method('convert')
- ->with(self::$eurAmount, 'USD')
- ->willReturn(109);
-
- $this->uahCurrency->expects(static::once())
- ->method('convert')
- ->with(self::$uahAmount, 'USD')
- ->willReturn(10.35);
-
- $actual = $this->builder->build($order);
-
- static::assertEquals(3, $actual['userAccount']['aggregateOrderCount']);
- static::assertEquals(169.35, $actual['userAccount']['aggregateOrderDollars']);
- }
-
- /**
- * Creates mocks for currencies
- * @return void
- */
- private function initCurrencies()
- {
- $this->eurCurrency = $this->getMockBuilder(Currency::class)
- ->disableOriginalConstructor()
- ->setMethods(['convert'])
- ->getMock();
-
- $this->uahCurrency = $this->getMockBuilder(Currency::class)
- ->disableOriginalConstructor()
- ->setMethods(['convert'])
- ->getMock();
- }
-
- /**
- * Creates order mock
- * @return Order|MockObject
- */
- private function getOrder()
- {
- $order = $this->getMockBuilder(Order::class)
- ->disableOriginalConstructor()
- ->setMethods(['getBillingAddress', 'getCustomerId'])
- ->getMock();
-
- $order->expects(static::once())
- ->method('getCustomerId')
- ->willReturn(self::$customerId);
-
- $billingAddress = $this->getMockBuilder(OrderAddressInterface::class)
- ->setMethods(['getTelephone'])
- ->getMockForAbstractClass();
- $billingAddress->expects(static::once())
- ->method('getTelephone')
- ->willReturn('444-444-44');
-
- $order->expects(static::once())
- ->method('getBillingAddress')
- ->willReturn($billingAddress);
-
- return $order;
- }
-
- /**
- * Get list of mocked orders with different currencies
- * @return array
- */
- private function getOrders()
- {
- $eurOrder = $this->getMockBuilder(Order::class)
- ->disableOriginalConstructor()
- ->setMethods(['getBaseGrandTotal', 'getBaseCurrencyCode'])
- ->getMock();
-
- $eurOrder->expects(static::once())
- ->method('getBaseGrandTotal')
- ->willReturn(self::$eurAmount);
- $eurOrder->expects(static::once())
- ->method('getBaseCurrencyCode')
- ->willReturn('EUR');
-
- $uahOrder = $this->getMockBuilder(Order::class)
- ->disableOriginalConstructor()
- ->setMethods(['getBaseGrandTotal', 'getBaseCurrencyCode'])
- ->getMock();
-
- $uahOrder->expects(static::once())
- ->method('getBaseGrandTotal')
- ->willReturn(self::$uahAmount);
- $uahOrder->expects(static::once())
- ->method('getBaseCurrencyCode')
- ->willReturn('UAH');
-
- $usdOrder = $this->getMockBuilder(Order::class)
- ->disableOriginalConstructor()
- ->setMethods(['getBaseGrandTotal', 'getBaseCurrencyCode'])
- ->getMock();
-
- $usdOrder->expects(static::once())
- ->method('getBaseGrandTotal')
- ->willReturn(self::$usdAmount);
- $usdOrder->expects(static::once())
- ->method('getBaseCurrencyCode')
- ->willReturn('USD');
-
- return [$eurOrder, $uahOrder, $usdOrder];
- }
-}
From b5977eba43fdb419610bf1605ac768915a4d95bf Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Wed, 21 Dec 2016 09:22:56 -0600
Subject: [PATCH 062/904] MAGETWO-54389: Submitting Case Entry to Signifyd on
Order Creation
- Remove empty lines
---
.../Test/Unit/SignifydGateway/Request/CustomerOrdersTest.php | 2 --
1 file changed, 2 deletions(-)
diff --git a/app/code/Magento/Signifyd/Test/Unit/SignifydGateway/Request/CustomerOrdersTest.php b/app/code/Magento/Signifyd/Test/Unit/SignifydGateway/Request/CustomerOrdersTest.php
index 1e6d792d962f7..db89c9748bcc4 100644
--- a/app/code/Magento/Signifyd/Test/Unit/SignifydGateway/Request/CustomerOrdersTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/SignifydGateway/Request/CustomerOrdersTest.php
@@ -112,8 +112,6 @@ protected function setUp()
'logger' => $this->logger
]);
-
-
$this->initCurrencies();
$this->initOrderRepository();
From ffa18a7745b3f4e1d19fb524259c7559fe2f1f70 Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Wed, 21 Dec 2016 10:05:10 -0600
Subject: [PATCH 063/904] MAGETWO-54389: Submitting Case Entry to Signifyd on
Order Creation
- fixes for static tests
---
.../Signifyd/Model/SignifydGateway/Request/CustomerOrders.php | 2 ++
.../integration/testsuite/Magento/Signifyd/_files/case.php | 4 ++--
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/CustomerOrders.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/CustomerOrders.php
index 64d538e4c7cdb..e757e16d4ae3f 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/CustomerOrders.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/CustomerOrders.php
@@ -55,6 +55,8 @@ class CustomerOrders
* @param SearchCriteriaBuilder $searchCriteriaBuilder
* @param FilterBuilder $filterBuilder
* @param OrderRepositoryInterface $orderRepository
+ * @param CurrencyFactory $currencyFactory
+ * @param \Psr\Log\LoggerInterface $logger
*/
public function __construct(
SearchCriteriaBuilder $searchCriteriaBuilder,
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/_files/case.php b/dev/tests/integration/testsuite/Magento/Signifyd/_files/case.php
index 09f81b14725d1..0bd47cb790d9e 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/_files/case.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/_files/case.php
@@ -12,12 +12,12 @@
/** @var CaseInterfaceFactory $caseFactory */
$caseFactory = $objectManager->get(CaseInterfaceFactory::class);
-$associatedTeam = array(
+$associatedTeam = [
'teamName' => 'Some Team',
'teamId' => 123,
'getAutoDismiss' => true,
'getTeamDismissalDays' => 3
-);
+];
/** @var CaseInterface $case */
$case = $caseFactory->create();
From 9eb9ef937be60d3324ae0c0cc1f6320fdadcc50c Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Wed, 21 Dec 2016 10:02:23 -0600
Subject: [PATCH 064/904] MAGETWO-54389: Submitting Case Entry to Signifyd on
Order Creation
- Change CustomOrders namespace
---
.../Request => }/CustomerOrders.php | 16 +++++++++-------
.../Request/UserAccountBuilder.php | 3 ++-
.../Request => Model}/CustomerOrdersTest.php | 12 ++++++------
3 files changed, 17 insertions(+), 14 deletions(-)
rename app/code/Magento/Signifyd/Model/{SignifydGateway/Request => }/CustomerOrders.php (94%)
rename app/code/Magento/Signifyd/Test/Unit/{SignifydGateway/Request => Model}/CustomerOrdersTest.php (94%)
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/CustomerOrders.php b/app/code/Magento/Signifyd/Model/CustomerOrders.php
similarity index 94%
rename from app/code/Magento/Signifyd/Model/SignifydGateway/Request/CustomerOrders.php
rename to app/code/Magento/Signifyd/Model/CustomerOrders.php
index e757e16d4ae3f..bcfea4403c930 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/CustomerOrders.php
+++ b/app/code/Magento/Signifyd/Model/CustomerOrders.php
@@ -3,16 +3,19 @@
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-namespace Magento\Signifyd\Model\SignifydGateway\Request;
+namespace Magento\Signifyd\Model;
use Magento\Directory\Model\CurrencyFactory;
use Magento\Framework\Api\FilterBuilder;
use Magento\Framework\Api\SearchCriteriaBuilder;
use Magento\Sales\Api\Data\OrderInterface;
use Magento\Sales\Api\OrderRepositoryInterface;
+use Psr\Log\LoggerInterface;
/**
* Provides information about customer orders.
+ *
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class CustomerOrders
{
@@ -32,7 +35,7 @@ class CustomerOrders
private $orderRepository;
/**
- * @var \Psr\Log\LoggerInterface
+ * @var LoggerInterface
*/
private $logger;
@@ -56,21 +59,20 @@ class CustomerOrders
* @param FilterBuilder $filterBuilder
* @param OrderRepositoryInterface $orderRepository
* @param CurrencyFactory $currencyFactory
- * @param \Psr\Log\LoggerInterface $logger
+ * @param LoggerInterface $logger
*/
public function __construct(
SearchCriteriaBuilder $searchCriteriaBuilder,
FilterBuilder $filterBuilder,
OrderRepositoryInterface $orderRepository,
CurrencyFactory $currencyFactory,
- \Psr\Log\LoggerInterface $logger
+ LoggerInterface $logger
) {
-
$this->searchCriteriaBuilder = $searchCriteriaBuilder;
$this->filterBuilder = $filterBuilder;
$this->orderRepository = $orderRepository;
- $this->logger = $logger;
$this->currencyFactory = $currencyFactory;
+ $this->logger = $logger;
}
/**
@@ -83,7 +85,7 @@ public function __construct(
* @param int $customerId
* @return array
*/
- public function getCountAndTotalAmount($customerId)
+ public function getAggregatedOrdersInfo($customerId)
{
$result = [
'aggregateOrderCount' => null,
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/UserAccountBuilder.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/UserAccountBuilder.php
index ac9bff2a14171..5e02f108714c7 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/UserAccountBuilder.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/UserAccountBuilder.php
@@ -6,6 +6,7 @@
namespace Magento\Signifyd\Model\SignifydGateway\Request;
use Magento\Sales\Model\Order;
+use Magento\Signifyd\Model\CustomerOrders;
/**
* Prepares details based on registered user account info
@@ -70,7 +71,7 @@ public function build(Order $order)
]
];
- $ordersInfo = $this->customerOrders->getCountAndTotalAmount($customerId);
+ $ordersInfo = $this->customerOrders->getAggregatedOrdersInfo($customerId);
if ($this->isNotEmptyCustomerOrdersInfo($ordersInfo)) {
$result['userAccount']['aggregateOrderCount'] = $ordersInfo['aggregateOrderCount'];
$result['userAccount']['aggregateOrderDollars'] = $ordersInfo['aggregateOrderDollars'];
diff --git a/app/code/Magento/Signifyd/Test/Unit/SignifydGateway/Request/CustomerOrdersTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/CustomerOrdersTest.php
similarity index 94%
rename from app/code/Magento/Signifyd/Test/Unit/SignifydGateway/Request/CustomerOrdersTest.php
rename to app/code/Magento/Signifyd/Test/Unit/Model/CustomerOrdersTest.php
index db89c9748bcc4..8798431f46873 100644
--- a/app/code/Magento/Signifyd/Test/Unit/SignifydGateway/Request/CustomerOrdersTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/CustomerOrdersTest.php
@@ -3,7 +3,7 @@
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-namespace Magento\Signifyd\Test\Unit\SignifydGateway\Request;
+namespace Magento\Signifyd\Test\Unit\Model;
use Magento\Directory\Model\Currency;
use Magento\Framework\Api\FilterBuilder;
@@ -11,7 +11,7 @@
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
use Magento\Sales\Api\Data\OrderSearchResultInterface;
use Magento\Sales\Model\Order;
-use Magento\Signifyd\Model\SignifydGateway\Request\CustomerOrders;
+use Magento\Signifyd\Model\CustomerOrders;
use PHPUnit_Framework_MockObject_MockObject as MockObject;
use Magento\Sales\Api\OrderRepositoryInterface;
use Psr\Log\LoggerInterface;
@@ -123,7 +123,7 @@ protected function setUp()
}
/**
- * @covers \Magento\Signifyd\Model\SignifydGateway\Request\CustomerOrders::getCountAndTotalAmount()
+ * @covers \Magento\Signifyd\Model\CustomerOrders::getCountAndTotalAmount()
*/
public function testGetCountAndTotalAmount()
{
@@ -137,7 +137,7 @@ public function testGetCountAndTotalAmount()
->with(self::$uahAmount, 'USD')
->willReturn(10.35);
- $actual = $this->model->getCountAndTotalAmount(1);
+ $actual = $this->model->getAggregatedOrdersInfo(self::$customerId);
static::assertEquals(3, $actual['aggregateOrderCount']);
static::assertEquals(169.35, $actual['aggregateOrderDollars']);
@@ -145,7 +145,7 @@ public function testGetCountAndTotalAmount()
/**
* Test case when required currency rate is absent and exception is thrown
- * @covers \Magento\Signifyd\Model\SignifydGateway\Request\CustomerOrders::getCountAndTotalAmount()
+ * @covers \Magento\Signifyd\Model\CustomerOrders::getCountAndTotalAmount()
*/
public function testGetCountAndTotalAmountNegative()
{
@@ -162,7 +162,7 @@ public function testGetCountAndTotalAmountNegative()
$this->logger->expects($this->once())
->method('error');
- $actual = $this->model->getCountAndTotalAmount(1);
+ $actual = $this->model->getAggregatedOrdersInfo(self::$customerId);
$this->assertNull($actual['aggregateOrderCount']);
$this->assertNull($actual['aggregateOrderDollars']);
From 267473ab32cb27087a9bf220696ca29932607e5e Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Wed, 21 Dec 2016 10:19:58 -0600
Subject: [PATCH 065/904] MAGETWO-54389: Submitting Case Entry to Signifyd on
Order Creation
- Import all class names in CustomerOrders
---
app/code/Magento/Signifyd/Model/CustomerOrders.php | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/app/code/Magento/Signifyd/Model/CustomerOrders.php b/app/code/Magento/Signifyd/Model/CustomerOrders.php
index bcfea4403c930..2865e60ae3801 100644
--- a/app/code/Magento/Signifyd/Model/CustomerOrders.php
+++ b/app/code/Magento/Signifyd/Model/CustomerOrders.php
@@ -5,6 +5,8 @@
*/
namespace Magento\Signifyd\Model;
+use Exception;
+use Magento\Directory\Model\Currency;
use Magento\Directory\Model\CurrencyFactory;
use Magento\Framework\Api\FilterBuilder;
use Magento\Framework\Api\SearchCriteriaBuilder;
@@ -106,7 +108,7 @@ public function getAggregatedOrdersInfo($customerId)
'aggregateOrderCount' => count($customerOrders),
'aggregateOrderDollars' => $orderTotalDollars
];
- } catch (\Exception $e) {
+ } catch (Exception $e) {
$this->logger->error($e->getMessage());
}
}
@@ -118,7 +120,7 @@ public function getAggregatedOrdersInfo($customerId)
* Returns customer orders.
*
* @param $customerId
- * @return \Magento\Sales\Api\Data\OrderInterface[]
+ * @return OrderInterface[]
*/
private function getCustomerOrders($customerId)
{
@@ -154,7 +156,7 @@ private function getUsdOrderTotal($amount, $currency)
* Returns currency by currency code.
*
* @param string|null $currencyCode
- * @return \Magento\Directory\Model\Currency
+ * @return Currency
*/
private function getCurrencyByCode($currencyCode)
{
@@ -162,7 +164,7 @@ private function getCurrencyByCode($currencyCode)
return $this->currencies[$currencyCode];
}
- /** @var \Magento\Directory\Model\Currency $currency */
+ /** @var Currency $currency */
$currency = $this->currencyFactory->create();
$this->currencies[$currencyCode] = $currency->load($currencyCode);
From c20914e5ddd7e2aaa060b7f2dd5bc686c43975ad Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Wed, 21 Dec 2016 10:37:24 -0600
Subject: [PATCH 066/904] MAGETWO-54389: Submitting Case Entry to Signifyd on
Order Creation
- flow fix
---
app/code/Magento/Signifyd/Observer/PlaceOrder.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/code/Magento/Signifyd/Observer/PlaceOrder.php b/app/code/Magento/Signifyd/Observer/PlaceOrder.php
index f5468d1aef667..5f3d858e5cfec 100644
--- a/app/code/Magento/Signifyd/Observer/PlaceOrder.php
+++ b/app/code/Magento/Signifyd/Observer/PlaceOrder.php
@@ -86,7 +86,7 @@ public function execute(Observer $observer)
private function createCaseForOrder($order)
{
$orderId = $order->getEntityId();
- if (null !== $orderId) {
+ if (null === $orderId) {
return;
}
From 97ff576257f753bd3615bb61aeb12f22f3f92e39 Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Wed, 21 Dec 2016 10:56:45 -0600
Subject: [PATCH 067/904] MAGETWO-54389: Submitting Case Entry to Signifyd on
Order Creation
- Refactor UserAccountBuilder
---
.../Request/UserAccountBuilder.php | 15 +++------------
1 file changed, 3 insertions(+), 12 deletions(-)
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/UserAccountBuilder.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/UserAccountBuilder.php
index 5e02f108714c7..60806e0ee05da 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/UserAccountBuilder.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/UserAccountBuilder.php
@@ -72,25 +72,16 @@ public function build(Order $order)
];
$ordersInfo = $this->customerOrders->getAggregatedOrdersInfo($customerId);
- if ($this->isNotEmptyCustomerOrdersInfo($ordersInfo)) {
+ if (isset($ordersInfo['aggregateOrderCount'])) {
$result['userAccount']['aggregateOrderCount'] = $ordersInfo['aggregateOrderCount'];
+ }
+ if (isset($ordersInfo['aggregateOrderDollars'])) {
$result['userAccount']['aggregateOrderDollars'] = $ordersInfo['aggregateOrderDollars'];
}
return $result;
}
- /**
- * Checks if customer aggregated orders count and total amount are available.
- *
- * @param array $ordersInfo
- * @return bool
- */
- private function isNotEmptyCustomerOrdersInfo(array $ordersInfo)
- {
- return null !== $ordersInfo['aggregateOrderCount'] && null !== $ordersInfo['aggregateOrderDollars'];
- }
-
/**
* Returns date formatted according to ISO8601.
*
From 4e5650b3d42526bed907c35134b67936b7c1ae89 Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Wed, 21 Dec 2016 10:51:27 -0600
Subject: [PATCH 068/904] MAGETWO-54389: Submitting Case Entry to Signifyd on
Order Creation
- fixes according to review comments
---
.../Model/SignifydGateway/Request/CreateCaseBuilder.php | 8 ++++----
.../Request/CreateCaseBuilderInterface.php | 4 +---
2 files changed, 5 insertions(+), 7 deletions(-)
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilder.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilder.php
index 1e2f35f7838bc..06f3a601889c9 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilder.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilder.php
@@ -8,9 +8,9 @@
use Magento\Sales\Model\OrderFactory;
/**
- * Signifyd case creation request builder
+ * Signifyd case creation request builder.
*
- * Handles the conversion from Magento Order to Signifyd Case
+ * Handles the conversion from Magento Order to Signifyd Case.
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class CreateCaseBuilder implements CreateCaseBuilderInterface
@@ -98,7 +98,7 @@ public function build($orderId)
}
/**
- * Remove empty and null values
+ * Remove empty and null values.
*
* @param array $data
* @return array
@@ -119,7 +119,7 @@ private function removeEmptyValues($data)
}
/**
- * Empty values are null, empty string and empty array
+ * Empty values are null, empty string and empty array.
*
* @param mixed $value
* @return bool
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderInterface.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderInterface.php
index aa5e4ce48485b..13d119d7fe441 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderInterface.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderInterface.php
@@ -5,10 +5,8 @@
*/
namespace Magento\Signifyd\Model\SignifydGateway\Request;
-
-
/**
- * Collects information about order and build array with parameters required by Signifyd API.
+ * Collects information about order and build array with parameters required by Signifyd API
*
* @see https://www.signifyd.com/docs/api/#/reference/cases/create-a-case
*/
From fcd12408abd490f435becbce2ac97f2b02f84281 Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Wed, 21 Dec 2016 11:31:15 -0600
Subject: [PATCH 069/904] MAGETWO-62506: Stabilization
- Fix static tests
---
.../Magento/Signifyd/Test/Unit/Model/CustomerOrdersTest.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/CustomerOrdersTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/CustomerOrdersTest.php
index 8798431f46873..5e03d8806f5af 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/CustomerOrdersTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/CustomerOrdersTest.php
@@ -123,7 +123,7 @@ protected function setUp()
}
/**
- * @covers \Magento\Signifyd\Model\CustomerOrders::getCountAndTotalAmount()
+ * @covers \Magento\Signifyd\Model\CustomerOrders::getAggregatedOrdersInfo()
*/
public function testGetCountAndTotalAmount()
{
@@ -145,7 +145,7 @@ public function testGetCountAndTotalAmount()
/**
* Test case when required currency rate is absent and exception is thrown
- * @covers \Magento\Signifyd\Model\CustomerOrders::getCountAndTotalAmount()
+ * @covers \Magento\Signifyd\Model\CustomerOrders::getAggregatedOrdersInfo()
*/
public function testGetCountAndTotalAmountNegative()
{
From 38a479aac0dd831f40805a64113062de12286da7 Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Thu, 22 Dec 2016 02:22:52 -0600
Subject: [PATCH 070/904] MAGETWO-62506: Stabilization
- Fix static tests
---
app/code/Magento/Signifyd/Model/CustomerOrders.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/code/Magento/Signifyd/Model/CustomerOrders.php b/app/code/Magento/Signifyd/Model/CustomerOrders.php
index 2865e60ae3801..58f563c56df7c 100644
--- a/app/code/Magento/Signifyd/Model/CustomerOrders.php
+++ b/app/code/Magento/Signifyd/Model/CustomerOrders.php
@@ -119,7 +119,7 @@ public function getAggregatedOrdersInfo($customerId)
/**
* Returns customer orders.
*
- * @param $customerId
+ * @param int $customerId
* @return OrderInterface[]
*/
private function getCustomerOrders($customerId)
From e22aba50ffacd395bdfdf793c0ae22244048ba5e Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Wed, 21 Dec 2016 11:34:43 -0600
Subject: [PATCH 071/904] MAGETWO-54389: Submitting Case Entry to Signifyd on
Order Creation
- remove orderIncrementId
---
.../Magento/Signifyd/Api/Data/CaseInterface.php | 15 ---------------
app/code/Magento/Signifyd/Model/CaseEntity.php | 17 -----------------
.../Magento/Signifyd/Setup/InstallSchema.php | 1 -
3 files changed, 33 deletions(-)
diff --git a/app/code/Magento/Signifyd/Api/Data/CaseInterface.php b/app/code/Magento/Signifyd/Api/Data/CaseInterface.php
index cd1122e276c87..6a58effa19e4f 100644
--- a/app/code/Magento/Signifyd/Api/Data/CaseInterface.php
+++ b/app/code/Magento/Signifyd/Api/Data/CaseInterface.php
@@ -146,21 +146,6 @@ public function getOrderId();
*/
public function setOrderId($orderId);
- /**
- * Returns order increment id for a case.
- *
- * @return string
- */
- public function getOrderIncrementId();
-
- /**
- * Sets order increment id for a case.
- *
- * @param string $orderIncrementId
- * @return $this
- */
- public function setOrderIncrementId($orderIncrementId);
-
/**
* Returns data about a team associated with a case.
*
diff --git a/app/code/Magento/Signifyd/Model/CaseEntity.php b/app/code/Magento/Signifyd/Model/CaseEntity.php
index efccab18da65b..a59763e091383 100644
--- a/app/code/Magento/Signifyd/Model/CaseEntity.php
+++ b/app/code/Magento/Signifyd/Model/CaseEntity.php
@@ -153,23 +153,6 @@ public function setOrderId($orderId)
return $this;
}
- /**
- * @inheritdoc
- */
- public function getOrderIncrementId()
- {
- return (string) $this->getData('order_increment_id');
- }
-
- /**
- * @inheritdoc
- */
- public function setOrderIncrementId($orderIncrementId)
- {
- $this->setData('order_increment_id', (string) $orderIncrementId);
- return $this;
- }
-
/**
* @inheritdoc
*/
diff --git a/app/code/Magento/Signifyd/Setup/InstallSchema.php b/app/code/Magento/Signifyd/Setup/InstallSchema.php
index 61e26eb3bb46a..deb313c66a828 100644
--- a/app/code/Magento/Signifyd/Setup/InstallSchema.php
+++ b/app/code/Magento/Signifyd/Setup/InstallSchema.php
@@ -38,7 +38,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true]
);
$table->addColumn('order_id', Table::TYPE_INTEGER, null, ['unsigned' => true]);
- $table->addColumn('order_increment_id', Table::TYPE_TEXT, 32);
$table->addColumn('case_id', Table::TYPE_INTEGER, null, ['unsigned' => true]);
$table->addColumn('guarantee_eligible', Table::TYPE_BOOLEAN, null);
$table->addColumn('guarantee_disposition', Table::TYPE_TEXT, 32);
From 9ff05cd78584212fd9a5e31f62d5eab1791be578 Mon Sep 17 00:00:00 2001
From: Dmytro Yushkin
Date: Thu, 22 Dec 2016 05:22:03 -0600
Subject: [PATCH 072/904] MAGETWO-62506: Stabilization
- Add device fingerprint script to cart page
---
.../view/frontend/layout/checkout_cart_index.xml | 14 ++++++++++++++
1 file changed, 14 insertions(+)
create mode 100644 app/code/Magento/Signifyd/view/frontend/layout/checkout_cart_index.xml
diff --git a/app/code/Magento/Signifyd/view/frontend/layout/checkout_cart_index.xml b/app/code/Magento/Signifyd/view/frontend/layout/checkout_cart_index.xml
new file mode 100644
index 0000000000000..07b04cc41d1bf
--- /dev/null
+++ b/app/code/Magento/Signifyd/view/frontend/layout/checkout_cart_index.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
From b1e4f5a344064ee7f0defabc47e0af695fa4fb00 Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Fri, 23 Dec 2016 07:31:11 -0600
Subject: [PATCH 073/904] MAGETWO-54389: Submitting Case Entry to Signifyd on
Order Creation
- di refactoring
---
app/code/Magento/Signifyd/etc/adminhtml/di.xml | 6 +-----
app/code/Magento/Signifyd/etc/frontend/di.xml | 6 +-----
2 files changed, 2 insertions(+), 10 deletions(-)
diff --git a/app/code/Magento/Signifyd/etc/adminhtml/di.xml b/app/code/Magento/Signifyd/etc/adminhtml/di.xml
index c41b360bb5f78..4c7abb1d830bb 100644
--- a/app/code/Magento/Signifyd/etc/adminhtml/di.xml
+++ b/app/code/Magento/Signifyd/etc/adminhtml/di.xml
@@ -6,9 +6,5 @@
*/
-->
-
-
- Magento\Signifyd\Model\QuoteSession\Adminhtml\BackendSession
-
-
+
diff --git a/app/code/Magento/Signifyd/etc/frontend/di.xml b/app/code/Magento/Signifyd/etc/frontend/di.xml
index 8da5b4e010161..d0702e9c4c5ce 100644
--- a/app/code/Magento/Signifyd/etc/frontend/di.xml
+++ b/app/code/Magento/Signifyd/etc/frontend/di.xml
@@ -13,9 +13,5 @@
-
-
- Magento\Signifyd\Model\QuoteSession\FrontendSession
-
-
+
From 8f1f4f4f2818b11c0c3f747934a80ffc6d31ea4d Mon Sep 17 00:00:00 2001
From: Volodymyr Kublytskyi
Date: Thu, 29 Dec 2016 06:31:11 -0600
Subject: [PATCH 074/904] MAGETWO-62738:
Magento\Signifyd\Model\CaseCreationServiceTest failed on mainline develop
- fixed issue with BiC in json_decode in PHP7.0
---
.../Signifyd/Model/SignifydGateway/ApiClient.php | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/ApiClient.php b/app/code/Magento/Signifyd/Model/SignifydGateway/ApiClient.php
index 3b14773b3fd25..19b2b78a932b2 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/ApiClient.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/ApiClient.php
@@ -173,7 +173,16 @@ private function handleResponse(\Zend_Http_Response $response)
throw new ApiCallException($errorMessage);
}
- $responseBody = $response->getBody();
+ $responseBody = (string)$response->getBody();
+
+ if (PHP_VERSION_ID < 70000 && empty($responseBody)) {
+ /*
+ * Only since PHP 7.0 empty string treated as JSON syntax error
+ * http://php.net/manual/en/function.json-decode.php
+ */
+ throw new ApiCallException('Response is not valid JSON: Decoding failed: Syntax error');
+ }
+
try {
$decodedResponseBody = $this->dataDecoder->decode($responseBody);
} catch (\Exception $e) {
From f3e6cb2acf7edb1c3fc5bb73a1bc57a65e54f1f8 Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Thu, 29 Dec 2016 07:17:44 -0600
Subject: [PATCH 075/904] MAGETWO-62738:
Magento\Signifyd\Model\CaseCreationServiceTest failed on mainline develop
- Fixed failed static test
---
.../Magento/Signifyd/Model/SignifydGateway/ApiClient.php | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/ApiClient.php b/app/code/Magento/Signifyd/Model/SignifydGateway/ApiClient.php
index 19b2b78a932b2..8fc17cf1ac293 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/ApiClient.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/ApiClient.php
@@ -5,13 +5,12 @@
*/
namespace Magento\Signifyd\Model\SignifydGateway;
-use Magento\Signifyd\Model\Config;
-use Magento\Framework\HTTP\ZendClientFactory;
use Magento\Framework\HTTP\ZendClient;
-use Magento\Framework\Json\EncoderInterface;
+use Magento\Framework\HTTP\ZendClientFactory;
use Magento\Framework\Json\DecoderInterface;
+use Magento\Framework\Json\EncoderInterface;
+use Magento\Signifyd\Model\Config;
use Magento\Signifyd\Model\SignifydGateway\Debugger\DebuggerFactory;
-use Exception;
/**
* Encapsulates Signifyd API protocol.
From d2aa505df50a8f4cc13b0dd468c0e0ccee7971ac Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Thu, 29 Dec 2016 07:22:56 -0600
Subject: [PATCH 076/904] MAGETWO-62738:
Magento\Signifyd\Model\CaseCreationServiceTest failed on mainline develop
- Added suppress
---
app/code/Magento/Signifyd/Model/SignifydGateway/ApiClient.php | 2 ++
1 file changed, 2 insertions(+)
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/ApiClient.php b/app/code/Magento/Signifyd/Model/SignifydGateway/ApiClient.php
index 8fc17cf1ac293..566f08b498105 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/ApiClient.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/ApiClient.php
@@ -14,6 +14,8 @@
/**
* Encapsulates Signifyd API protocol.
+ *
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class ApiClient
{
From 2c55b17c24c90f0a0c7a30fe9b143fc4732346bd Mon Sep 17 00:00:00 2001
From: isavchuk
Date: Tue, 3 Jan 2017 08:49:55 -0600
Subject: [PATCH 077/904] MAGETWO-62883: Update copyright year to 2017
- Changed copyright year
---
app/code/Magento/Signifyd/Model/SignifydGateway/ApiClient.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/ApiClient.php b/app/code/Magento/Signifyd/Model/SignifydGateway/ApiClient.php
index 566f08b498105..48d48ae4f81d4 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/ApiClient.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/ApiClient.php
@@ -1,6 +1,6 @@
Date: Wed, 4 Jan 2017 06:19:21 -0600
Subject: [PATCH 078/904] MAGETWO-62803: Signifyd webhook controller
- Added webhook controller
- Added webhook message validator
---
.../Signifyd/Controller/Webhooks/Index.php | 91 ++++++++++++++
.../Response/RawRequestBody.php | 22 ++++
.../Response/ResponseValidator.php | 112 ++++++++++++++++++
.../SignifydGateway/Response/Webhook.php | 74 ++++++++++++
.../Response/WebhookException.php | 14 +++
.../Response/WebhookFactory.php | 80 +++++++++++++
.../Magento/Signifyd/etc/frontend/routes.xml | 14 +++
7 files changed, 407 insertions(+)
create mode 100644 app/code/Magento/Signifyd/Controller/Webhooks/Index.php
create mode 100644 app/code/Magento/Signifyd/Model/SignifydGateway/Response/RawRequestBody.php
create mode 100644 app/code/Magento/Signifyd/Model/SignifydGateway/Response/ResponseValidator.php
create mode 100644 app/code/Magento/Signifyd/Model/SignifydGateway/Response/Webhook.php
create mode 100644 app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookException.php
create mode 100644 app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookFactory.php
create mode 100644 app/code/Magento/Signifyd/etc/frontend/routes.xml
diff --git a/app/code/Magento/Signifyd/Controller/Webhooks/Index.php b/app/code/Magento/Signifyd/Controller/Webhooks/Index.php
new file mode 100644
index 0000000000000..2385e221038c8
--- /dev/null
+++ b/app/code/Magento/Signifyd/Controller/Webhooks/Index.php
@@ -0,0 +1,91 @@
+rawRequestBody = $rawRequestBody;
+ $this->config = $config;
+ $this->logger = $logger;
+ $this->webhookFactory = $webhookFactory;
+ }
+
+ /**
+ * Processes webhook message data and updates case entity
+ *
+ * @return void
+ */
+ public function execute()
+ {
+ if ($this->config->isActive() === false) {
+ return;
+ }
+
+ /** @var \Magento\Framework\App\Request\Http $request */
+ $request = $this->getRequest();
+ $hash = $request->getHeader('X-SIGNIFYD-SEC-HMAC-SHA256');
+ $topic = $request->getHeader('X-SIGNIFYD-TOPIC');
+ $rawResponseBody = $this->rawRequestBody->get();
+
+ try {
+ $webhook = $this->webhookFactory->create($rawResponseBody, $hash, $topic);
+ if ($webhook->isTest()) {
+ return;
+ }
+ } catch (WebhookException $e) {
+ $this->getResponse()->setHttpResponseCode(400);
+ $this->logger->error($e->getMessage());
+ }
+ }
+}
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Response/RawRequestBody.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Response/RawRequestBody.php
new file mode 100644
index 0000000000000..ec77193ba3e5f
--- /dev/null
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Response/RawRequestBody.php
@@ -0,0 +1,22 @@
+config = $config;
+ }
+
+ /**
+ * Validates webhook response.
+ *
+ * @param string $rawResponseBody
+ * @param string $hash Base64 encoded output of the HMAC SHA256 encoding of the JSON body of the message.
+ * @param string $topic event topic identifier.
+ * @return bool
+ */
+ public function validate($rawResponseBody, $hash, $topic)
+ {
+ if ($this->isValidTopic($topic) === false) {
+ $this->errorMessages[] = 'Value of X-SIGNIFYD-TOPIC header is not allowed';
+ }
+
+ if (empty($rawResponseBody)) {
+ $this->errorMessages[] = 'Webhook message is empty';
+ }
+
+ if ($this->isValidHmacSha256($rawResponseBody, $hash, $topic) === false) {
+ $this->errorMessages[] = 'X-SIGNIFYD-SEC-HMAC-SHA256 header verification fails';
+ }
+
+ return empty($this->errorMessages);
+
+ }
+
+ /**
+ * Returns error message if validation fails
+ *
+ * @return string
+ */
+ public function getErrorMessage()
+ {
+ return !empty($this->errorMessages) ? implode('; ', $this->errorMessages) : '';
+ }
+
+ /**
+ * Checks if value of topic identifier is in allowed list
+ *
+ * @param string $topic topic identifier.
+ * @return bool
+ */
+ private function isValidTopic($topic)
+ {
+ return in_array($topic, $this->allowedTopicValues);
+ }
+
+ /**
+ * Verifies a webhook message has in fact come from SIGNIFYD.
+ *
+ * @param string $rawResponseBody
+ * @param string $hash X-SIGNIFYD-SEC-HMAC-SHA256 header is included in each webhook POST message.
+ * @param string $topic topic identifier.
+ * @return bool
+ */
+ private function isValidHmacSha256($rawResponseBody, $hash, $topic)
+ {
+ // In the case that this is a webhook test, the encoding ABCDE is allowed
+ $apiKey = $topic == 'cases/test' ? 'ABCDE' : $this->config->getApiKey();
+ $check = base64_encode(hash_hmac('sha256', $rawResponseBody, $apiKey, true));
+
+ return $check === $hash;
+ }
+}
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Response/Webhook.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Response/Webhook.php
new file mode 100644
index 0000000000000..128daad8e08e4
--- /dev/null
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Response/Webhook.php
@@ -0,0 +1,74 @@
+body = $body;
+ $this->topic = $topic;
+ }
+
+ /**
+ * Returns webhook body
+ *
+ * @return array
+ */
+ public function getBody()
+ {
+ return $this->body;
+ }
+
+ /**
+ * Returns event topic identifier
+ *
+ * @return string
+ */
+ public function getTopic()
+ {
+ return $this->topic;
+ }
+
+ /**
+ * Checks if webhook is a test
+ *
+ * @return bool
+ */
+ public function isTest()
+ {
+ return $this->topic === 'cases/test';
+ }
+}
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookException.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookException.php
new file mode 100644
index 0000000000000..8820e1be006dd
--- /dev/null
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookException.php
@@ -0,0 +1,14 @@
+objectManager = $objectManager;
+ $this->responseValidator = $responseValidator;
+ $this->dataDecoder = $decoder;
+ }
+
+
+ /**
+ * Create webhook data object.
+ *
+ * @param string $rawResponseBody
+ * @param string $hash Base64 encoded output of the HMAC SHA256 encoding of the JSON body of the message.
+ * @param string $topic event topic identifier.
+ * @return Webhook
+ * @throws WebhookException if data validation fails
+ */
+ public function create($rawResponseBody, $hash, $topic)
+ {
+
+ if (!$this->responseValidator->validate($rawResponseBody, $hash, $topic)) {
+ throw new WebhookException(
+ $this->responseValidator->getErrorMessage()
+ );
+ }
+
+ try {
+ $decodedResponseBody = $this->dataDecoder->decode($rawResponseBody);
+ } catch (\Exception $e) {
+ throw new WebhookException(
+ 'Webhook message body is not valid JSON: ' . $e->getMessage(),
+ $e->getCode(),
+ $e
+ );
+ }
+
+ return $this->objectManager->create(
+ Webhook::class,
+ ['topic' => $topic, 'body' => $decodedResponseBody]
+ );
+ }
+}
diff --git a/app/code/Magento/Signifyd/etc/frontend/routes.xml b/app/code/Magento/Signifyd/etc/frontend/routes.xml
new file mode 100644
index 0000000000000..c7101ae29f069
--- /dev/null
+++ b/app/code/Magento/Signifyd/etc/frontend/routes.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
From 26d89451b4b812174868e4859819efb860c55ee2 Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Wed, 4 Jan 2017 06:46:38 -0600
Subject: [PATCH 079/904] MAGETWO-62803: Signifyd webhook controller
- Fix static
---
.../Magento/Signifyd/Model/SignifydGateway/Response/Webhook.php | 2 +-
.../Model/SignifydGateway/Response/WebhookException.php | 2 +-
.../Signifyd/Model/SignifydGateway/Response/WebhookFactory.php | 1 -
3 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Response/Webhook.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Response/Webhook.php
index 128daad8e08e4..db251c83c407c 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/Response/Webhook.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Response/Webhook.php
@@ -1,6 +1,6 @@
dataDecoder = $decoder;
}
-
/**
* Create webhook data object.
*
From 589f63e1f99a6c14ef0b936b209ebea4a9619145 Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Wed, 4 Jan 2017 10:44:01 -0600
Subject: [PATCH 080/904] MAGETWO-62806: Update case entity
- Added messages generators for comments history
- Added service for case updating
- Covered case updating by integration test
---
.../Signifyd/Api/CaseManagementInterface.php | 8 ++
.../Magento/Signifyd/Model/CaseEntity.php | 2 +-
.../Magento/Signifyd/Model/CaseManagement.php | 16 +++
.../Signifyd/Model/CaseUpdatingService.php | 120 ++++++++++++++++++
.../Model/CaseUpdatingServiceFactory.php | 93 ++++++++++++++
.../Model/MessageGeneratorException.php | 16 +++
.../Model/MessageGeneratorInterface.php | 23 ++++
.../Model/MessageGenerators/CaseCreation.php | 44 +++++++
.../Model/MessageGenerators/CaseRescore.php | 62 +++++++++
.../Model/MessageGenerators/CaseReview.php | 31 +++++
.../MessageGenerators/GuaranteeCompletion.php | 28 ++++
.../Model/Validators/CaseDataValidator.php | 29 +++++
app/code/Magento/Signifyd/i18n/en_US.csv | 9 +-
.../Model/CaseUpdatingServiceTest.php | 100 +++++++++++++++
14 files changed, 579 insertions(+), 2 deletions(-)
create mode 100644 app/code/Magento/Signifyd/Model/CaseUpdatingService.php
create mode 100644 app/code/Magento/Signifyd/Model/CaseUpdatingServiceFactory.php
create mode 100644 app/code/Magento/Signifyd/Model/MessageGeneratorException.php
create mode 100644 app/code/Magento/Signifyd/Model/MessageGeneratorInterface.php
create mode 100644 app/code/Magento/Signifyd/Model/MessageGenerators/CaseCreation.php
create mode 100644 app/code/Magento/Signifyd/Model/MessageGenerators/CaseRescore.php
create mode 100644 app/code/Magento/Signifyd/Model/MessageGenerators/CaseReview.php
create mode 100644 app/code/Magento/Signifyd/Model/MessageGenerators/GuaranteeCompletion.php
create mode 100644 app/code/Magento/Signifyd/Model/Validators/CaseDataValidator.php
create mode 100644 dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseUpdatingServiceTest.php
diff --git a/app/code/Magento/Signifyd/Api/CaseManagementInterface.php b/app/code/Magento/Signifyd/Api/CaseManagementInterface.php
index 09c2e8c0e164c..2cf5db226cbff 100644
--- a/app/code/Magento/Signifyd/Api/CaseManagementInterface.php
+++ b/app/code/Magento/Signifyd/Api/CaseManagementInterface.php
@@ -31,4 +31,12 @@ public function create($orderId);
* @return CaseInterface|null
*/
public function getByOrderId($orderId);
+
+ /**
+ * Gets Case entity by received case (investigation) id.
+ *
+ * @param $caseId
+ * @return CaseInterface|null
+ */
+ public function getByCaseId($caseId);
}
diff --git a/app/code/Magento/Signifyd/Model/CaseEntity.php b/app/code/Magento/Signifyd/Model/CaseEntity.php
index a59763e091383..00951b6bb55f5 100644
--- a/app/code/Magento/Signifyd/Model/CaseEntity.php
+++ b/app/code/Magento/Signifyd/Model/CaseEntity.php
@@ -23,7 +23,7 @@ class CaseEntity extends AbstractModel implements CaseInterface
/**
* @var SerializerInterface
*/
- protected $serializer;
+ private $serializer;
/**
* @inheritdoc
diff --git a/app/code/Magento/Signifyd/Model/CaseManagement.php b/app/code/Magento/Signifyd/Model/CaseManagement.php
index 8705f9a812ae3..0af87b9b89d3f 100644
--- a/app/code/Magento/Signifyd/Model/CaseManagement.php
+++ b/app/code/Magento/Signifyd/Model/CaseManagement.php
@@ -88,4 +88,20 @@ public function getByOrderId($orderId)
$items = $this->caseRepository->getList($searchCriteria)->getItems();
return !empty($items) ? array_pop($items) : null;
}
+
+ /**
+ * @inheritdoc
+ */
+ public function getByCaseId($caseId)
+ {
+ $filters = [
+ $this->filterBuilder->setField('case_id')
+ ->setValue($caseId)
+ ->create()
+ ];
+
+ $searchCriteria = $this->searchCriteriaBuilder->addFilters($filters)->create();
+ $items = $this->caseRepository->getList($searchCriteria)->getItems();
+ return !empty($items) ? array_pop($items) : null;
+ }
}
diff --git a/app/code/Magento/Signifyd/Model/CaseUpdatingService.php b/app/code/Magento/Signifyd/Model/CaseUpdatingService.php
new file mode 100644
index 0000000000000..474ade3ce8797
--- /dev/null
+++ b/app/code/Magento/Signifyd/Model/CaseUpdatingService.php
@@ -0,0 +1,120 @@
+messageGenerator = $messageGenerator;
+ $this->caseManagement = $caseManagement;
+ $this->caseRepository = $caseRepository;
+ $this->historyFactory = $historyFactory;
+ $this->logger = $logger;
+ $this->caseDataValidator = $caseDataValidator;
+ }
+
+ /**
+ * Updates Signifyd Case entity by received data.
+ *
+ * @param DataObject $data
+ * @throws LocalizedException
+ * @throws NotFoundException
+ */
+ public function update(DataObject $data)
+ {
+ if (!$this->caseDataValidator->validate($data)) {
+ throw new LocalizedException(__('The "%1" should not be empty.', 'caseId'));
+ }
+
+ $case = $this->caseManagement->getByCaseId($data->getData('caseId'));
+ if ($case === null) {
+ throw new NotFoundException(__('Case entity not found.'));
+ }
+
+ try {
+ $case->setGuaranteeEligible($data->getData('guaranteeEligible'))
+ ->setStatus($data->getData('status'))
+ ->setReviewDisposition($data->getData('reviewDisposition'))
+ ->setAssociatedTeam($data->getData('associatedTeam'))
+ ->setCreatedAt($data->getData('createdAt'))
+ ->setUpdatedAt($data->getData('updatedAt'))
+ ->setScore($data->getData('score'))
+ ->setGuaranteeDisposition($data->getData('guaranteeDisposition'));
+ $this->caseRepository->save($case);
+
+ // add comment to order history
+ $message = $this->messageGenerator->generate($data);
+ /** @var \Magento\Sales\Api\Data\OrderStatusHistoryInterface $history */
+ $history = $this->historyFactory->create();
+ $history->setParentId($case->getOrderId())
+ ->setComment($message)
+ ->save();
+
+ } catch (\Exception $e) {
+ $this->logger->error($e->getMessage());
+ throw new LocalizedException(__('Cannot update Case entity.'), $e);
+ }
+ }
+}
diff --git a/app/code/Magento/Signifyd/Model/CaseUpdatingServiceFactory.php b/app/code/Magento/Signifyd/Model/CaseUpdatingServiceFactory.php
new file mode 100644
index 0000000000000..c2bb54a4dc95d
--- /dev/null
+++ b/app/code/Magento/Signifyd/Model/CaseUpdatingServiceFactory.php
@@ -0,0 +1,93 @@
+objectManager = $objectManager;
+ }
+
+ /**
+ * Creates instance of service updating case.
+ * As param retrieves type of message generator.
+ *
+ * @param string $type
+ * @return CaseUpdatingService
+ */
+ public function create($type)
+ {
+ switch ($type) {
+ case self::$caseCreation:
+ $className = CaseCreation::class;
+ break;
+ case self::$caseRescore:
+ $className = CaseRescore::class;
+ break;
+ case self::$caseReview:
+ $className = CaseReview::class;
+ break;
+ case self::$guaranteeCompletion:
+ $className = GuaranteeCompletion::class;
+ break;
+ default:
+ throw new \InvalidArgumentException('Specified message type does not supported.');
+ }
+
+ $messageGenerator = $this->objectManager->get($className);
+ $service = $this->objectManager->create(CaseUpdatingService::class, [
+ 'messageGenerator' => $messageGenerator
+ ]);
+
+ return $service;
+ }
+}
diff --git a/app/code/Magento/Signifyd/Model/MessageGeneratorException.php b/app/code/Magento/Signifyd/Model/MessageGeneratorException.php
new file mode 100644
index 0000000000000..3958595bc1f45
--- /dev/null
+++ b/app/code/Magento/Signifyd/Model/MessageGeneratorException.php
@@ -0,0 +1,16 @@
+caseDataValidator = $caseDataValidator;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function generate(DataObject $data)
+ {
+ if (!$this->caseDataValidator->validate($data)) {
+ throw new MessageGeneratorException(__('The "%1" should not be empty.', 'caseId'));
+ }
+
+ return __('Signifyd Case %1 has been created for order.', $data->getData('caseId'));
+ }
+}
diff --git a/app/code/Magento/Signifyd/Model/MessageGenerators/CaseRescore.php b/app/code/Magento/Signifyd/Model/MessageGenerators/CaseRescore.php
new file mode 100644
index 0000000000000..81765a66e278b
--- /dev/null
+++ b/app/code/Magento/Signifyd/Model/MessageGenerators/CaseRescore.php
@@ -0,0 +1,62 @@
+caseManagement = $caseManagement;
+ $this->caseDataValidator = $caseDataValidator;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function generate(DataObject $data)
+ {
+ if (!$this->caseDataValidator->validate($data)) {
+ throw new MessageGeneratorException(__('The "%1" should not be empty.', 'caseId'));
+ }
+
+ $caseEntity = $this->caseManagement->getByCaseId($data->getData('caseId'));
+
+ if ($caseEntity === null) {
+ throw new MessageGeneratorException(__('Case entity not found.'));
+ }
+
+ return __(
+ 'Case Update: New score for the order is %1. Previous score was %2.',
+ $data->getData('score'),
+ $caseEntity->getScore()
+ );
+ }
+}
diff --git a/app/code/Magento/Signifyd/Model/MessageGenerators/CaseReview.php b/app/code/Magento/Signifyd/Model/MessageGenerators/CaseReview.php
new file mode 100644
index 0000000000000..06cedd4ad42fb
--- /dev/null
+++ b/app/code/Magento/Signifyd/Model/MessageGenerators/CaseReview.php
@@ -0,0 +1,31 @@
+getData('reviewDisposition'))) {
+ throw new MessageGeneratorException(__('The "%1" should not be empty.', 'reviewDisposition'));
+ }
+
+ return __(
+ 'Case Update: Case Review was completed. Review Deposition is %1.',
+ __($data->getData('reviewDisposition'))
+ );
+ }
+}
diff --git a/app/code/Magento/Signifyd/Model/MessageGenerators/GuaranteeCompletion.php b/app/code/Magento/Signifyd/Model/MessageGenerators/GuaranteeCompletion.php
new file mode 100644
index 0000000000000..051a48f68c7bb
--- /dev/null
+++ b/app/code/Magento/Signifyd/Model/MessageGenerators/GuaranteeCompletion.php
@@ -0,0 +1,28 @@
+getData('guaranteeDisposition'))) {
+ throw new MessageGeneratorException(__('The "%1" should not be empty.', 'guaranteeDisposition'));
+ }
+
+ return __('Case Update: Guarantee Disposition is %1.', __($data->getData('guaranteeDisposition')));
+ }
+}
diff --git a/app/code/Magento/Signifyd/Model/Validators/CaseDataValidator.php b/app/code/Magento/Signifyd/Model/Validators/CaseDataValidator.php
new file mode 100644
index 0000000000000..1b44d26ec5f23
--- /dev/null
+++ b/app/code/Magento/Signifyd/Model/Validators/CaseDataValidator.php
@@ -0,0 +1,29 @@
+getData('caseId'))) {
+ return false;
+ }
+
+ return true;
+ }
+}
diff --git a/app/code/Magento/Signifyd/i18n/en_US.csv b/app/code/Magento/Signifyd/i18n/en_US.csv
index 2785e217040ca..a10f12073987f 100644
--- a/app/code/Magento/Signifyd/i18n/en_US.csv
+++ b/app/code/Magento/Signifyd/i18n/en_US.csv
@@ -6,8 +6,15 @@
"GOOD","Good"
"FRAUDULENT","Fraudulent"
"UNSET","Unset"
+"NULL","Unset"
"APPROVED","Approved"
"DECLINED","Declined"
"PENDING","Pending"
"CANCELED","Canceled"
-"IN_REVIEW","In review"
\ No newline at end of file
+"IN_REVIEW","In review"
+"Case Update: Case Review was completed. Review Deposition is %1.","Case Update: Case Review was completed. Review Deposition is %1."
+"Case Update: New score for the order is %1. Previous score was %2.","Case Update: New score for the order is %1. Previous score was %2."
+"Signifyd Case %1 has been created for order.","Signifyd Case %1 has been created for order."
+"The "%1" should not be empty.","The "%1" should not be empty."
+"Case entity not found.","Case entity not found."
+"Cannot update Case entity.","Cannot update Case entity."
\ No newline at end of file
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseUpdatingServiceTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseUpdatingServiceTest.php
new file mode 100644
index 0000000000000..750178e718e76
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseUpdatingServiceTest.php
@@ -0,0 +1,100 @@
+objectManager = Bootstrap::getObjectManager();
+
+ $messageGenerator = $this->objectManager->create(CaseCreation::class);
+
+ $logger = $this->getMockBuilder(LoggerInterface::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->service = $this->objectManager->create(CaseUpdatingService::class, [
+ 'messageGenerator' => $messageGenerator,
+ 'logger' => $logger
+ ]);
+ }
+
+ /**
+ * @covers \Magento\Signifyd\Model\CaseUpdatingService::update
+ * @magentoDataFixture Magento/Signifyd/_files/case.php
+ */
+ public function testUpdate()
+ {
+ $caseId = 123;
+ $data = new DataObject(
+ [
+ 'caseId' => $caseId,
+ 'guaranteeEligible' => true,
+ 'status' => CaseInterface::STATUS_DISMISSED,
+ 'score' => 750,
+ 'reviewDisposition' => CaseInterface::DISPOSITION_FRAUDULENT,
+ 'associatedTeam' => [
+ 'teamName' => 'AnyTeam',
+ 'teamId' => 26,
+ 'getAutoDismiss' => true,
+ 'getTeamDismissalDays' => 2
+ ],
+ 'createdAt' => '2017-01-05T14:23:26-0800',
+ 'updatedAt' => '2017-01-05T14:44:26-0800',
+ 'guaranteeDisposition' => CaseInterface::GUARANTEE_APPROVED
+ ]
+ );
+
+ $this->service->update($data);
+
+ /** @var CaseManagementInterface $caseManagement */
+ $caseManagement = $this->objectManager->get(CaseManagementInterface::class);
+ $caseEntity = $caseManagement->getByCaseId($caseId);
+
+ static::assertNotEmpty($caseEntity);
+ static::assertEquals('2017-01-05 22:23:26', $caseEntity->getCreatedAt());
+ static::assertEquals(CaseInterface::GUARANTEE_APPROVED, $caseEntity->getGuaranteeDisposition());
+ static::assertEquals('AnyTeam', $caseEntity->getAssociatedTeam()['teamName']);
+
+ /** @var OrderRepositoryInterface $orderRepository */
+ $orderRepository = $this->objectManager->get(OrderRepositoryInterface::class);
+ $order = $orderRepository->get($caseEntity->getOrderId());
+ $histories = $order->getStatusHistories();
+ static::assertNotEmpty($histories);
+
+ /** @var OrderStatusHistoryInterface $caseCreationComment */
+ $caseCreationComment = array_pop($histories);
+ static::assertInstanceOf(OrderStatusHistoryInterface::class, $caseCreationComment);
+ static::assertEquals("Signifyd Case $caseId has been created for order.", $caseCreationComment->getComment());
+ }
+}
From d718021567fc45d21157e13d6532c7eeab951acb Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Wed, 4 Jan 2017 10:52:08 -0600
Subject: [PATCH 081/904] MAGETWO-62806: Update case entity
- Updated method annotations
---
app/code/Magento/Signifyd/Api/CaseManagementInterface.php | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/app/code/Magento/Signifyd/Api/CaseManagementInterface.php b/app/code/Magento/Signifyd/Api/CaseManagementInterface.php
index 2cf5db226cbff..1e72b30e30110 100644
--- a/app/code/Magento/Signifyd/Api/CaseManagementInterface.php
+++ b/app/code/Magento/Signifyd/Api/CaseManagementInterface.php
@@ -18,7 +18,7 @@ interface CaseManagementInterface
/**
* Creates new Case entity linked to order id.
*
- * @param string $orderId
+ * @param int $orderId
* @return CaseInterface
* @throws \Magento\Framework\Exception\AlreadyExistsException If case for $orderId already exists
*/
@@ -27,7 +27,7 @@ public function create($orderId);
/**
* Gets Case entity associated with order id.
*
- * @param string $orderId
+ * @param int $orderId
* @return CaseInterface|null
*/
public function getByOrderId($orderId);
@@ -35,7 +35,7 @@ public function getByOrderId($orderId);
/**
* Gets Case entity by received case (investigation) id.
*
- * @param $caseId
+ * @param int $caseId
* @return CaseInterface|null
*/
public function getByCaseId($caseId);
From 6d2a03216f699351093bde0bae519120f62bb290 Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Wed, 4 Jan 2017 13:57:50 -0600
Subject: [PATCH 082/904] MAGETWO-62803: Signifyd webhook controller
- Refactoring webhook data structure
---
.../Signifyd/Controller/Webhooks/Handler.php | 101 +++++++++++++++
.../Signifyd/Controller/Webhooks/Index.php | 91 --------------
.../Response/RawRequestBody.php | 22 ----
.../SignifydGateway/Response/Webhook.php | 74 -----------
.../Response/WebhookFactory.php | 79 ------------
.../Response/WebhookMessage.php | 117 ++++++++++++++++++
...idator.php => WebhookMessageValidator.php} | 29 ++---
.../Response/WebhookRequest.php | 49 ++++++++
.../Response/WebhookRequestReader.php | 85 +++++++++++++
9 files changed, 364 insertions(+), 283 deletions(-)
create mode 100644 app/code/Magento/Signifyd/Controller/Webhooks/Handler.php
delete mode 100644 app/code/Magento/Signifyd/Controller/Webhooks/Index.php
delete mode 100644 app/code/Magento/Signifyd/Model/SignifydGateway/Response/RawRequestBody.php
delete mode 100644 app/code/Magento/Signifyd/Model/SignifydGateway/Response/Webhook.php
delete mode 100644 app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookFactory.php
create mode 100644 app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookMessage.php
rename app/code/Magento/Signifyd/Model/SignifydGateway/Response/{ResponseValidator.php => WebhookMessageValidator.php} (65%)
create mode 100644 app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookRequest.php
create mode 100644 app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookRequestReader.php
diff --git a/app/code/Magento/Signifyd/Controller/Webhooks/Handler.php b/app/code/Magento/Signifyd/Controller/Webhooks/Handler.php
new file mode 100644
index 0000000000000..c02fc3127d5c0
--- /dev/null
+++ b/app/code/Magento/Signifyd/Controller/Webhooks/Handler.php
@@ -0,0 +1,101 @@
+webhookRequest = $webhookRequest;
+ $this->config = $config;
+ $this->logger = $logger;
+ $this->webhookRequestReader = $webhookRequestReader;
+ $this->caseUpdatingServiceFactory = $caseUpdatingServiceFactory;
+ }
+
+ /**
+ * Processes webhook message data and updates case entity
+ *
+ * @return void
+ */
+ public function execute()
+ {
+ if ($this->config->isActive() === false) {
+ return;
+ }
+
+ try {
+ $webhookMessage = $this->webhookRequestReader->read($this->webhookRequest);
+ $caseUpdatingService = $this->caseUpdatingServiceFactory->create($webhookMessage->getEventTopic());
+ $caseUpdatingService->update($webhookMessage->getData());
+ } catch (WebhookException $e) {
+ $this->getResponse()->setHttpResponseCode(400);
+ $this->logger->error($e->getMessage());
+ } catch (\InvalidArgumentException $e) {
+ $this->getResponse()->setHttpResponseCode(400);
+ $this->logger->error($e->getMessage());
+ } catch (LocalizedException $e) {
+ $this->getResponse()->setHttpResponseCode(400);
+ $this->logger->error($e->getMessage());
+ }
+ }
+}
diff --git a/app/code/Magento/Signifyd/Controller/Webhooks/Index.php b/app/code/Magento/Signifyd/Controller/Webhooks/Index.php
deleted file mode 100644
index 2385e221038c8..0000000000000
--- a/app/code/Magento/Signifyd/Controller/Webhooks/Index.php
+++ /dev/null
@@ -1,91 +0,0 @@
-rawRequestBody = $rawRequestBody;
- $this->config = $config;
- $this->logger = $logger;
- $this->webhookFactory = $webhookFactory;
- }
-
- /**
- * Processes webhook message data and updates case entity
- *
- * @return void
- */
- public function execute()
- {
- if ($this->config->isActive() === false) {
- return;
- }
-
- /** @var \Magento\Framework\App\Request\Http $request */
- $request = $this->getRequest();
- $hash = $request->getHeader('X-SIGNIFYD-SEC-HMAC-SHA256');
- $topic = $request->getHeader('X-SIGNIFYD-TOPIC');
- $rawResponseBody = $this->rawRequestBody->get();
-
- try {
- $webhook = $this->webhookFactory->create($rawResponseBody, $hash, $topic);
- if ($webhook->isTest()) {
- return;
- }
- } catch (WebhookException $e) {
- $this->getResponse()->setHttpResponseCode(400);
- $this->logger->error($e->getMessage());
- }
- }
-}
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Response/RawRequestBody.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Response/RawRequestBody.php
deleted file mode 100644
index ec77193ba3e5f..0000000000000
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/Response/RawRequestBody.php
+++ /dev/null
@@ -1,22 +0,0 @@
-body = $body;
- $this->topic = $topic;
- }
-
- /**
- * Returns webhook body
- *
- * @return array
- */
- public function getBody()
- {
- return $this->body;
- }
-
- /**
- * Returns event topic identifier
- *
- * @return string
- */
- public function getTopic()
- {
- return $this->topic;
- }
-
- /**
- * Checks if webhook is a test
- *
- * @return bool
- */
- public function isTest()
- {
- return $this->topic === 'cases/test';
- }
-}
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookFactory.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookFactory.php
deleted file mode 100644
index daa88a0af0b06..0000000000000
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookFactory.php
+++ /dev/null
@@ -1,79 +0,0 @@
-objectManager = $objectManager;
- $this->responseValidator = $responseValidator;
- $this->dataDecoder = $decoder;
- }
-
- /**
- * Create webhook data object.
- *
- * @param string $rawResponseBody
- * @param string $hash Base64 encoded output of the HMAC SHA256 encoding of the JSON body of the message.
- * @param string $topic event topic identifier.
- * @return Webhook
- * @throws WebhookException if data validation fails
- */
- public function create($rawResponseBody, $hash, $topic)
- {
-
- if (!$this->responseValidator->validate($rawResponseBody, $hash, $topic)) {
- throw new WebhookException(
- $this->responseValidator->getErrorMessage()
- );
- }
-
- try {
- $decodedResponseBody = $this->dataDecoder->decode($rawResponseBody);
- } catch (\Exception $e) {
- throw new WebhookException(
- 'Webhook message body is not valid JSON: ' . $e->getMessage(),
- $e->getCode(),
- $e
- );
- }
-
- return $this->objectManager->create(
- Webhook::class,
- ['topic' => $topic, 'body' => $decodedResponseBody]
- );
- }
-}
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookMessage.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookMessage.php
new file mode 100644
index 0000000000000..6ac5d9a0501bd
--- /dev/null
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookMessage.php
@@ -0,0 +1,117 @@
+rawData = $rawData;
+ $this->data = $data;
+ $this->eventTopic = $eventTopic;
+ $this->expectedHash = $expectedHash;
+ }
+
+ /**
+ * Returns decoded webhook request body.
+ *
+ * @return DataObject
+ */
+ public function getData()
+ {
+ return new DataObject($this->data);
+ }
+
+ /**
+ * Returns event topic identifier.
+ *
+ * @return string
+ */
+ public function getEventTopic()
+ {
+ return $this->eventTopic;
+ }
+
+ /**
+ * Returns expected hash.
+ *
+ * @return string
+ */
+ public function getExpectedHash()
+ {
+ return $this->expectedHash;
+ }
+
+ /**
+ * Returns actual hash based on raw request body and api key
+ *
+ * @param string $apiKey
+ * @return string
+ */
+ public function getActualHash($apiKey)
+ {
+ return base64_encode(hash_hmac('sha256', $this->rawData, $apiKey, true));
+ }
+
+ /**
+ * Checks if webhook is a test.
+ *
+ * @return bool
+ */
+ public function isTest()
+ {
+ return $this->eventTopic === 'cases/test';
+ }
+}
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Response/ResponseValidator.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookMessageValidator.php
similarity index 65%
rename from app/code/Magento/Signifyd/Model/SignifydGateway/Response/ResponseValidator.php
rename to app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookMessageValidator.php
index 0ca443132c0e9..ff383d90b182c 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/Response/ResponseValidator.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookMessageValidator.php
@@ -8,10 +8,10 @@
use Magento\Signifyd\Model\Config;
/**
- * Validates webhook response.
+ * Validates webhook message.
*
*/
-class ResponseValidator
+class WebhookMessageValidator
{
/**
@@ -47,24 +47,22 @@ public function __construct(
}
/**
- * Validates webhook response.
+ * Validates webhook message.
*
- * @param string $rawResponseBody
- * @param string $hash Base64 encoded output of the HMAC SHA256 encoding of the JSON body of the message.
- * @param string $topic event topic identifier.
+ * @param WebhookMessage $webhookMessage
* @return bool
*/
- public function validate($rawResponseBody, $hash, $topic)
+ public function validate(WebhookMessage $webhookMessage)
{
- if ($this->isValidTopic($topic) === false) {
+ if ($this->isValidTopic($webhookMessage->getEventTopic()) === false) {
$this->errorMessages[] = 'Value of X-SIGNIFYD-TOPIC header is not allowed';
}
- if (empty($rawResponseBody)) {
+ if (empty($webhookMessage->getData())) {
$this->errorMessages[] = 'Webhook message is empty';
}
- if ($this->isValidHmacSha256($rawResponseBody, $hash, $topic) === false) {
+ if ($this->isValidHash($webhookMessage) === false) {
$this->errorMessages[] = 'X-SIGNIFYD-SEC-HMAC-SHA256 header verification fails';
}
@@ -96,17 +94,14 @@ private function isValidTopic($topic)
/**
* Verifies a webhook message has in fact come from SIGNIFYD.
*
- * @param string $rawResponseBody
- * @param string $hash X-SIGNIFYD-SEC-HMAC-SHA256 header is included in each webhook POST message.
- * @param string $topic topic identifier.
+ * @param WebhookMessage $webhookMessage
* @return bool
*/
- private function isValidHmacSha256($rawResponseBody, $hash, $topic)
+ private function isValidHash(WebhookMessage $webhookMessage)
{
// In the case that this is a webhook test, the encoding ABCDE is allowed
- $apiKey = $topic == 'cases/test' ? 'ABCDE' : $this->config->getApiKey();
- $check = base64_encode(hash_hmac('sha256', $rawResponseBody, $apiKey, true));
+ $apiKey = $webhookMessage->isTest() ? 'ABCDE' : $this->config->getApiKey();
- return $check === $hash;
+ return $webhookMessage->getActualHash($apiKey) === $webhookMessage->getExpectedHash();
}
}
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookRequest.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookRequest.php
new file mode 100644
index 0000000000000..04367f6caf4b3
--- /dev/null
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookRequest.php
@@ -0,0 +1,49 @@
+request = $request;
+ }
+
+ /**
+ * Retrieve header value.
+ *
+ * @param string $name header name to retrieve.
+ * @return string
+ */
+ public function getHeader($name)
+ {
+ return $this->request->getHeader($name) ?: '';
+ }
+
+ /**
+ * Returns raw data from the request body.
+ *
+ * @return string
+ */
+ public function getBody()
+ {
+ return file_get_contents("php://input") ?: '';
+ }
+}
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookRequestReader.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookRequestReader.php
new file mode 100644
index 0000000000000..97bfaf2dc6213
--- /dev/null
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookRequestReader.php
@@ -0,0 +1,85 @@
+webhookMessageValidator = $webhookMessageValidator;
+ $this->dataDecoder = $decoder;
+ $this->webhookMessageFactory = $webhookMessageFactory;
+ }
+
+ /**
+ * Returns webhook message data object.
+ *
+ * @param WebhookRequest $request
+ * @return WebhookMessage
+ * @throws WebhookException if data validation fails
+ */
+ public function read(WebhookRequest $request)
+ {
+ $hash = $request->getHeader('X-SIGNIFYD-SEC-HMAC-SHA256');
+ $eventTopic = $request->getHeader('X-SIGNIFYD-TOPIC');
+ $rawData = $request->getBody();
+
+ try {
+ $decodedData = $this->dataDecoder->decode($rawData);
+ } catch (\Exception $e) {
+ throw new WebhookException(
+ 'Webhook request body is not valid JSON: ' . $e->getMessage(),
+ $e->getCode(),
+ $e
+ );
+ }
+
+ $webhookMessage = $this->webhookMessageFactory->create(
+ [
+ 'rawData' => $rawData,
+ 'data' => $decodedData,
+ 'eventTopic' => $eventTopic,
+ 'expectedHash' => $hash
+ ]
+ );
+
+ if (!$this->webhookMessageValidator->validate($webhookMessage)) {
+ throw new WebhookException(
+ $this->webhookMessageValidator->getErrorMessage()
+ );
+ }
+
+ return $webhookMessage;
+ }
+}
From 5cc6fae42ac4be541b2fc4415386de259d84fdaf Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Thu, 5 Jan 2017 05:25:26 -0600
Subject: [PATCH 083/904] MAGETWO-62806: Update case entity
- Moved message generator initialization to own factory
- Added internal service to update order comments history
- Refactored service and factory for case updating
---
.../Signifyd/Api/CaseManagementInterface.php | 8 --
.../Signifyd/Api/CaseRepositoryInterface.php | 8 ++
.../Magento/Signifyd/Model/CaseManagement.php | 16 ----
.../Magento/Signifyd/Model/CaseRepository.php | 14 +++-
.../Signifyd/Model/CaseUpdatingService.php | 75 ++++++++----------
.../Model/CaseUpdatingServiceFactory.php | 64 +++++----------
.../Model/CaseUpdatingServiceInterface.php | 22 ++++++
.../Signifyd/Model/CommentsHistoryUpdater.php | 49 ++++++++++++
.../Model/MessageGenerators/CaseRescore.php | 14 ++--
.../MessageGenerators/GeneratorFactory.php | 79 +++++++++++++++++++
.../Model/StubCaseUpdatingService.php | 24 ++++++
.../Model/Validators/CaseDataValidator.php | 3 +-
.../Model/CaseUpdatingServiceTest.php | 22 ++----
13 files changed, 262 insertions(+), 136 deletions(-)
create mode 100644 app/code/Magento/Signifyd/Model/CaseUpdatingServiceInterface.php
create mode 100644 app/code/Magento/Signifyd/Model/CommentsHistoryUpdater.php
create mode 100644 app/code/Magento/Signifyd/Model/MessageGenerators/GeneratorFactory.php
create mode 100644 app/code/Magento/Signifyd/Model/StubCaseUpdatingService.php
diff --git a/app/code/Magento/Signifyd/Api/CaseManagementInterface.php b/app/code/Magento/Signifyd/Api/CaseManagementInterface.php
index 1e72b30e30110..bb13cc552c74e 100644
--- a/app/code/Magento/Signifyd/Api/CaseManagementInterface.php
+++ b/app/code/Magento/Signifyd/Api/CaseManagementInterface.php
@@ -31,12 +31,4 @@ public function create($orderId);
* @return CaseInterface|null
*/
public function getByOrderId($orderId);
-
- /**
- * Gets Case entity by received case (investigation) id.
- *
- * @param int $caseId
- * @return CaseInterface|null
- */
- public function getByCaseId($caseId);
}
diff --git a/app/code/Magento/Signifyd/Api/CaseRepositoryInterface.php b/app/code/Magento/Signifyd/Api/CaseRepositoryInterface.php
index 0e63e9283ad28..d84bd4a3bf7d8 100644
--- a/app/code/Magento/Signifyd/Api/CaseRepositoryInterface.php
+++ b/app/code/Magento/Signifyd/Api/CaseRepositoryInterface.php
@@ -32,6 +32,14 @@ public function save(CaseInterface $case);
*/
public function getById($id);
+ /**
+ * Gets entity by Signifyd case id.
+ *
+ * @param int $caseId
+ * @return CaseInterface|null
+ */
+ public function getByCaseId($caseId);
+
/**
* Deletes case entity.
*
diff --git a/app/code/Magento/Signifyd/Model/CaseManagement.php b/app/code/Magento/Signifyd/Model/CaseManagement.php
index 0af87b9b89d3f..8705f9a812ae3 100644
--- a/app/code/Magento/Signifyd/Model/CaseManagement.php
+++ b/app/code/Magento/Signifyd/Model/CaseManagement.php
@@ -88,20 +88,4 @@ public function getByOrderId($orderId)
$items = $this->caseRepository->getList($searchCriteria)->getItems();
return !empty($items) ? array_pop($items) : null;
}
-
- /**
- * @inheritdoc
- */
- public function getByCaseId($caseId)
- {
- $filters = [
- $this->filterBuilder->setField('case_id')
- ->setValue($caseId)
- ->create()
- ];
-
- $searchCriteria = $this->searchCriteriaBuilder->addFilters($filters)->create();
- $items = $this->caseRepository->getList($searchCriteria)->getItems();
- return !empty($items) ? array_pop($items) : null;
- }
}
diff --git a/app/code/Magento/Signifyd/Model/CaseRepository.php b/app/code/Magento/Signifyd/Model/CaseRepository.php
index f18ffc47356d9..9c68302074400 100644
--- a/app/code/Magento/Signifyd/Model/CaseRepository.php
+++ b/app/code/Magento/Signifyd/Model/CaseRepository.php
@@ -1,6 +1,6 @@
caseFactory->create();
+ $this->resourceModel->load($case, $caseId, 'case_id');
+
+ return $case->getEntityId() ? $case : null;
+ }
+
/**
* @inheritdoc
*/
diff --git a/app/code/Magento/Signifyd/Model/CaseUpdatingService.php b/app/code/Magento/Signifyd/Model/CaseUpdatingService.php
index 474ade3ce8797..cbdb2c77714e9 100644
--- a/app/code/Magento/Signifyd/Model/CaseUpdatingService.php
+++ b/app/code/Magento/Signifyd/Model/CaseUpdatingService.php
@@ -8,77 +8,60 @@
use Magento\Framework\DataObject;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Exception\NotFoundException;
-use Magento\Sales\Model\Order\Status\HistoryFactory;
-use Magento\Signifyd\Api\CaseManagementInterface;
use Magento\Signifyd\Api\CaseRepositoryInterface;
+use Magento\Signifyd\Api\Data\CaseInterface;
use Magento\Signifyd\Model\Validators\CaseDataValidator;
-use Psr\Log\LoggerInterface;
/**
* Performs Signifyd case entity updating operations.
*/
-class CaseUpdatingService
+class CaseUpdatingService implements CaseUpdatingServiceInterface
{
/**
* @var MessageGeneratorInterface
*/
private $messageGenerator;
- /**
- * @var CaseManagementInterface
- */
- private $caseManagement;
-
/**
* @var CaseRepositoryInterface
*/
private $caseRepository;
/**
- * @var HistoryFactory
- */
- private $historyFactory;
-
- /**
- * @var LoggerInterface
+ * @var CaseDataValidator
*/
- private $logger;
+ private $caseDataValidator;
/**
- * @var CaseDataValidator
+ * @var CommentsHistoryUpdater
*/
- private $caseDataValidator;
+ private $commentsHistoryUpdater;
/**
* CaseUpdatingService constructor.
*
* @param MessageGeneratorInterface $messageGenerator
- * @param CaseManagementInterface $caseManagement
* @param CaseRepositoryInterface $caseRepository
- * @param LoggerInterface $logger
* @param CaseDataValidator $caseDataValidator
- * @param HistoryFactory $historyFactory
+ * @param CommentsHistoryUpdater $commentsHistoryUpdater
*/
public function __construct(
MessageGeneratorInterface $messageGenerator,
- CaseManagementInterface $caseManagement,
CaseRepositoryInterface $caseRepository,
- LoggerInterface $logger,
CaseDataValidator $caseDataValidator,
- HistoryFactory $historyFactory
+ CommentsHistoryUpdater $commentsHistoryUpdater
) {
$this->messageGenerator = $messageGenerator;
- $this->caseManagement = $caseManagement;
$this->caseRepository = $caseRepository;
- $this->historyFactory = $historyFactory;
- $this->logger = $logger;
$this->caseDataValidator = $caseDataValidator;
+ $this->commentsHistoryUpdater = $commentsHistoryUpdater;
}
/**
* Updates Signifyd Case entity by received data.
*
* @param DataObject $data
+ * @return void
* @throws LocalizedException
* @throws NotFoundException
*/
@@ -88,33 +71,39 @@ public function update(DataObject $data)
throw new LocalizedException(__('The "%1" should not be empty.', 'caseId'));
}
- $case = $this->caseManagement->getByCaseId($data->getData('caseId'));
+ $case = $this->caseRepository->getByCaseId($data->getData('caseId'));
if ($case === null) {
throw new NotFoundException(__('Case entity not found.'));
}
try {
- $case->setGuaranteeEligible($data->getData('guaranteeEligible'))
- ->setStatus($data->getData('status'))
- ->setReviewDisposition($data->getData('reviewDisposition'))
- ->setAssociatedTeam($data->getData('associatedTeam'))
- ->setCreatedAt($data->getData('createdAt'))
- ->setUpdatedAt($data->getData('updatedAt'))
- ->setScore($data->getData('score'))
- ->setGuaranteeDisposition($data->getData('guaranteeDisposition'));
+ $this->prepareCaseData($case, $data);
$this->caseRepository->save($case);
// add comment to order history
$message = $this->messageGenerator->generate($data);
- /** @var \Magento\Sales\Api\Data\OrderStatusHistoryInterface $history */
- $history = $this->historyFactory->create();
- $history->setParentId($case->getOrderId())
- ->setComment($message)
- ->save();
-
+ $this->commentsHistoryUpdater->addComment($case, $message);
} catch (\Exception $e) {
- $this->logger->error($e->getMessage());
throw new LocalizedException(__('Cannot update Case entity.'), $e);
}
}
+
+ /**
+ * Sets data to case entity.
+ *
+ * @param CaseInterface $case
+ * @param DataObject $data
+ * @return void
+ */
+ private function prepareCaseData(CaseInterface $case, DataObject $data)
+ {
+ $case->setGuaranteeEligible($data->getData('guaranteeEligible') ?: $case->isGuaranteeEligible())
+ ->setStatus($data->getData('status') ?: $case->getStatus())
+ ->setReviewDisposition($data->getData('reviewDisposition') ?: $case->getReviewDisposition())
+ ->setAssociatedTeam($data->getData('associatedTeam') ?: $case->getAssociatedTeam())
+ ->setCreatedAt($data->getData('createdAt') ?: $case->getCreatedAt())
+ ->setUpdatedAt($data->getData('updatedAt') ?: $case->getUpdatedAt())
+ ->setScore($data->getData('score') ?: $case->getScore())
+ ->setGuaranteeDisposition($data->getData('guaranteeDisposition') ?: $case->getGuaranteeDisposition());
+ }
}
diff --git a/app/code/Magento/Signifyd/Model/CaseUpdatingServiceFactory.php b/app/code/Magento/Signifyd/Model/CaseUpdatingServiceFactory.php
index c2bb54a4dc95d..e626e8347d239 100644
--- a/app/code/Magento/Signifyd/Model/CaseUpdatingServiceFactory.php
+++ b/app/code/Magento/Signifyd/Model/CaseUpdatingServiceFactory.php
@@ -6,10 +6,7 @@
namespace Magento\Signifyd\Model;
use Magento\Framework\ObjectManagerInterface;
-use Magento\Signifyd\Model\MessageGenerators\CaseCreation;
-use Magento\Signifyd\Model\MessageGenerators\CaseRescore;
-use Magento\Signifyd\Model\MessageGenerators\CaseReview;
-use Magento\Signifyd\Model\MessageGenerators\GuaranteeCompletion;
+use Magento\Signifyd\Model\MessageGenerators\GeneratorFactory;
/**
* Creates instance of case updating service configured with specific message generator.
@@ -19,42 +16,31 @@
class CaseUpdatingServiceFactory
{
/**
- * Type of message for Signifyd case creation.
+ * Type of testing Signifyd case
* @var string
*/
- private static $caseCreation = 'CASE_CREATION';
+ private static $caseTest = 'cases/test';
/**
- * Type of message for Signifyd case re-scoring.
- * @var string
- */
- private static $caseRescore = 'CASE_RESCORE';
-
- /**
- * Type of message for Signifyd case reviewing
- * @var string
- */
- private static $caseReview = 'CASE_REVIEW';
-
- /**
- * Type of message of Signifyd guarantee completion
- * @var string
+ * @var ObjectManagerInterface
*/
- private static $guaranteeCompletion = 'GUARANTEE_COMPLETION';
+ private $objectManager;
/**
- * @var ObjectManagerInterface
+ * @var GeneratorFactory
*/
- private $objectManager;
+ private $generatorFactory;
/**
* CaseUpdatingServiceFactory constructor.
*
* @param ObjectManagerInterface $objectManager
+ * @param GeneratorFactory $generatorFactory
*/
- public function __construct(ObjectManagerInterface $objectManager)
+ public function __construct(ObjectManagerInterface $objectManager, GeneratorFactory $generatorFactory)
{
$this->objectManager = $objectManager;
+ $this->generatorFactory = $generatorFactory;
}
/**
@@ -62,32 +48,20 @@ public function __construct(ObjectManagerInterface $objectManager)
* As param retrieves type of message generator.
*
* @param string $type
- * @return CaseUpdatingService
+ * @return CaseUpdatingServiceInterface
+ * @throws \InvalidArgumentException
*/
public function create($type)
{
- switch ($type) {
- case self::$caseCreation:
- $className = CaseCreation::class;
- break;
- case self::$caseRescore:
- $className = CaseRescore::class;
- break;
- case self::$caseReview:
- $className = CaseReview::class;
- break;
- case self::$guaranteeCompletion:
- $className = GuaranteeCompletion::class;
- break;
- default:
- throw new \InvalidArgumentException('Specified message type does not supported.');
+ if ($type === self::$caseTest) {
+ $service = $this->objectManager->create(StubCaseUpdatingService::class);
+ } else {
+ $messageGenerator = $this->generatorFactory->create($type);
+ $service = $this->objectManager->create(CaseUpdatingService::class, [
+ 'messageGenerator' => $messageGenerator
+ ]);
}
- $messageGenerator = $this->objectManager->get($className);
- $service = $this->objectManager->create(CaseUpdatingService::class, [
- 'messageGenerator' => $messageGenerator
- ]);
-
return $service;
}
}
diff --git a/app/code/Magento/Signifyd/Model/CaseUpdatingServiceInterface.php b/app/code/Magento/Signifyd/Model/CaseUpdatingServiceInterface.php
new file mode 100644
index 0000000000000..1fa97ce3b2ad4
--- /dev/null
+++ b/app/code/Magento/Signifyd/Model/CaseUpdatingServiceInterface.php
@@ -0,0 +1,22 @@
+historyFactory = $historyFactory;
+ }
+
+ /**
+ * Adds comment to case related order.
+ *
+ * @param CaseInterface $case
+ * @param Phrase $message
+ * @return void
+ */
+ public function addComment(CaseInterface $case, Phrase $message)
+ {
+ /** @var \Magento\Sales\Api\Data\OrderStatusHistoryInterface $history */
+ $history = $this->historyFactory->create();
+ $history->setParentId($case->getOrderId())
+ ->setComment($message)
+ ->setEntityName('order')
+ ->save();
+ }
+}
diff --git a/app/code/Magento/Signifyd/Model/MessageGenerators/CaseRescore.php b/app/code/Magento/Signifyd/Model/MessageGenerators/CaseRescore.php
index 81765a66e278b..5df98975d51e2 100644
--- a/app/code/Magento/Signifyd/Model/MessageGenerators/CaseRescore.php
+++ b/app/code/Magento/Signifyd/Model/MessageGenerators/CaseRescore.php
@@ -6,7 +6,7 @@
namespace Magento\Signifyd\Model\MessageGenerators;
use Magento\Framework\DataObject;
-use Magento\Signifyd\Api\CaseManagementInterface;
+use Magento\Signifyd\Api\CaseRepositoryInterface;
use Magento\Signifyd\Model\MessageGeneratorException;
use Magento\Signifyd\Model\MessageGeneratorInterface;
use Magento\Signifyd\Model\Validators\CaseDataValidator;
@@ -17,9 +17,9 @@
class CaseRescore implements MessageGeneratorInterface
{
/**
- * @var CaseManagementInterface
+ * @var CaseRepositoryInterface
*/
- private $caseManagement;
+ private $caseRepository;
/**
* @var CaseDataValidator
@@ -29,12 +29,12 @@ class CaseRescore implements MessageGeneratorInterface
/**
* CaseRescore constructor.
*
- * @param CaseManagementInterface $caseManagement
+ * @param CaseRepositoryInterface $caseRepository
* @param CaseDataValidator $caseDataValidator
*/
- public function __construct(CaseManagementInterface $caseManagement, CaseDataValidator $caseDataValidator)
+ public function __construct(CaseRepositoryInterface $caseRepository, CaseDataValidator $caseDataValidator)
{
- $this->caseManagement = $caseManagement;
+ $this->caseRepository = $caseRepository;
$this->caseDataValidator = $caseDataValidator;
}
@@ -47,7 +47,7 @@ public function generate(DataObject $data)
throw new MessageGeneratorException(__('The "%1" should not be empty.', 'caseId'));
}
- $caseEntity = $this->caseManagement->getByCaseId($data->getData('caseId'));
+ $caseEntity = $this->caseRepository->getByCaseId($data->getData('caseId'));
if ($caseEntity === null) {
throw new MessageGeneratorException(__('Case entity not found.'));
diff --git a/app/code/Magento/Signifyd/Model/MessageGenerators/GeneratorFactory.php b/app/code/Magento/Signifyd/Model/MessageGenerators/GeneratorFactory.php
new file mode 100644
index 0000000000000..2b1b4a01b0ed3
--- /dev/null
+++ b/app/code/Magento/Signifyd/Model/MessageGenerators/GeneratorFactory.php
@@ -0,0 +1,79 @@
+objectManager = $objectManager;
+ }
+
+ /**
+ * Creates instance of message generator.
+ * Throws exception if type of message generator does not have implementations.
+ *
+ * @param string $type
+ * @return MessageGeneratorInterface
+ * @throws \InvalidArgumentException
+ */
+ public function create($type)
+ {
+ switch ($type) {
+ case self::$caseCreation:
+ $className = CaseCreation::class;
+ break;
+ case self::$caseRescore:
+ $className = CaseRescore::class;
+ break;
+ case self::$caseReview:
+ $className = CaseReview::class;
+ break;
+ case self::$guaranteeCompletion:
+ $className = GuaranteeCompletion::class;
+ break;
+ default:
+ throw new \InvalidArgumentException('Specified message type does not supported.');
+ }
+
+ return $this->objectManager->create($className);
+ }
+}
diff --git a/app/code/Magento/Signifyd/Model/StubCaseUpdatingService.php b/app/code/Magento/Signifyd/Model/StubCaseUpdatingService.php
new file mode 100644
index 0000000000000..3d8ff6478f06c
--- /dev/null
+++ b/app/code/Magento/Signifyd/Model/StubCaseUpdatingService.php
@@ -0,0 +1,24 @@
+objectManager->create(CaseCreation::class);
- $logger = $this->getMockBuilder(LoggerInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
-
$this->service = $this->objectManager->create(CaseUpdatingService::class, [
- 'messageGenerator' => $messageGenerator,
- 'logger' => $logger
+ 'messageGenerator' => $messageGenerator
]);
}
@@ -59,8 +53,6 @@ public function testUpdate()
$data = new DataObject(
[
'caseId' => $caseId,
- 'guaranteeEligible' => true,
- 'status' => CaseInterface::STATUS_DISMISSED,
'score' => 750,
'reviewDisposition' => CaseInterface::DISPOSITION_FRAUDULENT,
'associatedTeam' => [
@@ -77,14 +69,16 @@ public function testUpdate()
$this->service->update($data);
- /** @var CaseManagementInterface $caseManagement */
- $caseManagement = $this->objectManager->get(CaseManagementInterface::class);
- $caseEntity = $caseManagement->getByCaseId($caseId);
+ /** @var CaseRepositoryInterface $caseManagement */
+ $caseRepository = $this->objectManager->get(CaseRepositoryInterface::class);
+ $caseEntity = $caseRepository->getByCaseId($caseId);
static::assertNotEmpty($caseEntity);
static::assertEquals('2017-01-05 22:23:26', $caseEntity->getCreatedAt());
static::assertEquals(CaseInterface::GUARANTEE_APPROVED, $caseEntity->getGuaranteeDisposition());
static::assertEquals('AnyTeam', $caseEntity->getAssociatedTeam()['teamName']);
+ static::assertEquals(true, $caseEntity->isGuaranteeEligible());
+ static::assertEquals(CaseInterface::STATUS_PROCESSING, $caseEntity->getStatus());
/** @var OrderRepositoryInterface $orderRepository */
$orderRepository = $this->objectManager->get(OrderRepositoryInterface::class);
From 1d6e6e27dd4470a1b44150acb7ea18243bd9edd5 Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Thu, 5 Jan 2017 05:40:55 -0600
Subject: [PATCH 084/904] MAGETWO-62806: Update case entity
- Refactored code according to failed static tests
---
.../Signifyd/Api/CaseManagementInterface.php | 2 +-
.../Signifyd/Model/CaseUpdatingService.php | 32 ++++++++++++++-----
2 files changed, 25 insertions(+), 9 deletions(-)
diff --git a/app/code/Magento/Signifyd/Api/CaseManagementInterface.php b/app/code/Magento/Signifyd/Api/CaseManagementInterface.php
index bb13cc552c74e..7c0445a4211c7 100644
--- a/app/code/Magento/Signifyd/Api/CaseManagementInterface.php
+++ b/app/code/Magento/Signifyd/Api/CaseManagementInterface.php
@@ -1,6 +1,6 @@
setGuaranteeEligible($data->getData('guaranteeEligible') ?: $case->isGuaranteeEligible())
- ->setStatus($data->getData('status') ?: $case->getStatus())
- ->setReviewDisposition($data->getData('reviewDisposition') ?: $case->getReviewDisposition())
- ->setAssociatedTeam($data->getData('associatedTeam') ?: $case->getAssociatedTeam())
- ->setCreatedAt($data->getData('createdAt') ?: $case->getCreatedAt())
- ->setUpdatedAt($data->getData('updatedAt') ?: $case->getUpdatedAt())
- ->setScore($data->getData('score') ?: $case->getScore())
- ->setGuaranteeDisposition($data->getData('guaranteeDisposition') ?: $case->getGuaranteeDisposition());
+ if ($data->getData('guaranteeEligible') !== null) {
+ $case->setGuaranteeEligible($data->getData('guaranteeEligible'));
+ }
+ if ($data->getData('status') !== null) {
+ $case->setStatus($data->getData('status'));
+ }
+ if ($data->getData('reviewDisposition') !== null) {
+ $case->setReviewDisposition($data->getData('reviewDisposition'));
+ }
+ if ($data->getData('associatedTeam') !== null) {
+ $case->setAssociatedTeam($data->getData('associatedTeam'));
+ }
+ if ($data->getData('createdAt') !== null) {
+ $case->setCreatedAt($data->getData('createdAt'));
+ }
+ if ($data->getData('updatedAt') !== null) {
+ $case->setUpdatedAt($data->getData('updatedAt'));
+ }
+ if ($data->getData('score') !== null) {
+ $case->setScore($data->getData('score'));
+ }
+ if ($data->getData('guaranteeDisposition') !== null) {
+ $case->setGuaranteeDisposition($data->getData('guaranteeDisposition'));
+ }
}
}
From 1509b3400d8a98c711b8c3067edd2f9d140a0aa3 Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Thu, 5 Jan 2017 06:24:37 -0600
Subject: [PATCH 085/904] MAGETWO-62803: Signifyd webhook controller
- Move webhook request validation to controller
---
.../Signifyd/Controller/Webhooks/Handler.php | 50 ++++----
.../Response/WebhookException.php | 14 ---
.../Response/WebhookMessage.php | 53 +-------
...estReader.php => WebhookMessageReader.php} | 35 +-----
.../Response/WebhookMessageValidator.php | 107 -----------------
.../Response/WebhookRequest.php | 21 +++-
.../Response/WebhookRequestValidator.php | 113 ++++++++++++++++++
7 files changed, 157 insertions(+), 236 deletions(-)
delete mode 100644 app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookException.php
rename app/code/Magento/Signifyd/Model/SignifydGateway/Response/{WebhookRequestReader.php => WebhookMessageReader.php} (51%)
delete mode 100644 app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookMessageValidator.php
create mode 100644 app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookRequestValidator.php
diff --git a/app/code/Magento/Signifyd/Controller/Webhooks/Handler.php b/app/code/Magento/Signifyd/Controller/Webhooks/Handler.php
index c02fc3127d5c0..d773149a373d5 100644
--- a/app/code/Magento/Signifyd/Controller/Webhooks/Handler.php
+++ b/app/code/Magento/Signifyd/Controller/Webhooks/Handler.php
@@ -8,12 +8,10 @@
use Magento\Framework\App\Action\Action;
use Magento\Framework\App\Action\Context;
use Magento\Framework\Exception\LocalizedException;
-use Magento\Signifyd\Model\CaseUpdatingService;
use Magento\Signifyd\Model\CaseUpdatingServiceFactory;
-use Magento\Signifyd\Model\Config;
+use Magento\Signifyd\Model\SignifydGateway\Response\WebhookRequestValidator;
use Magento\Signifyd\Model\SignifydGateway\Response\WebhookRequest;
-use Magento\Signifyd\Model\SignifydGateway\Response\WebhookRequestReader;
-use Magento\Signifyd\Model\SignifydGateway\Response\WebhookException;
+use Magento\Signifyd\Model\SignifydGateway\Response\WebhookMessageReader;
use Psr\Log\LoggerInterface;
/**
@@ -28,71 +26,67 @@ class Handler extends Action
*/
private $webhookRequest;
- /**
- * @var Config
- */
- private $config;
-
/**
* @var LoggerInterface
*/
private $logger;
/**
- * @var WebhookRequestReader
+ * @var WebhookMessageReader
*/
- private $webhookRequestReader;
+ private $webhookMessageReader;
/**
* @var CaseUpdatingServiceFactory
*/
private $caseUpdatingServiceFactory;
+ /**
+ * @var WebhookRequestValidator
+ */
+ private $webhookRequestValidator;
+
/**
* @param Context $context
* @param WebhookRequest $webhookRequest
- * @param Config $config
* @param LoggerInterface $logger
- * @param WebhookRequestReader $webhookRequestReader
+ * @param WebhookMessageReader $webhookMessageReader
* @param CaseUpdatingServiceFactory $caseUpdatingServiceFactory
+ * @param WebhookRequestValidator $webhookRequestValidator
*/
public function __construct(
Context $context,
WebhookRequest $webhookRequest,
- Config $config,
LoggerInterface $logger,
- WebhookRequestReader $webhookRequestReader,
- CaseUpdatingServiceFactory $caseUpdatingServiceFactory
+ WebhookMessageReader $webhookMessageReader,
+ CaseUpdatingServiceFactory $caseUpdatingServiceFactory,
+ WebhookRequestValidator $webhookRequestValidator
) {
parent::__construct($context);
$this->webhookRequest = $webhookRequest;
- $this->config = $config;
$this->logger = $logger;
- $this->webhookRequestReader = $webhookRequestReader;
+ $this->webhookMessageReader = $webhookMessageReader;
$this->caseUpdatingServiceFactory = $caseUpdatingServiceFactory;
+ $this->webhookRequestValidator = $webhookRequestValidator;
}
/**
- * Processes webhook message data and updates case entity
+ * Processes webhook request data and updates case entity
*
* @return void
*/
public function execute()
{
- if ($this->config->isActive() === false) {
+ if (!$this->webhookRequestValidator->validate($this->webhookRequest)) {
+ $this->getResponse()->setHttpResponseCode(400);
return;
}
+ $webhookMessage = $this->webhookMessageReader->read($this->webhookRequest);
+ $caseUpdatingService = $this->caseUpdatingServiceFactory->create($webhookMessage->getEventTopic());
+
try {
- $webhookMessage = $this->webhookRequestReader->read($this->webhookRequest);
- $caseUpdatingService = $this->caseUpdatingServiceFactory->create($webhookMessage->getEventTopic());
$caseUpdatingService->update($webhookMessage->getData());
- } catch (WebhookException $e) {
- $this->getResponse()->setHttpResponseCode(400);
- $this->logger->error($e->getMessage());
- } catch (\InvalidArgumentException $e) {
- $this->getResponse()->setHttpResponseCode(400);
- $this->logger->error($e->getMessage());
} catch (LocalizedException $e) {
$this->getResponse()->setHttpResponseCode(400);
$this->logger->error($e->getMessage());
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookException.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookException.php
deleted file mode 100644
index 5b5f34320456d..0000000000000
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookException.php
+++ /dev/null
@@ -1,14 +0,0 @@
-rawData = $rawData;
$this->data = $data;
$this->eventTopic = $eventTopic;
- $this->expectedHash = $expectedHash;
}
/**
@@ -83,35 +63,4 @@ public function getEventTopic()
{
return $this->eventTopic;
}
-
- /**
- * Returns expected hash.
- *
- * @return string
- */
- public function getExpectedHash()
- {
- return $this->expectedHash;
- }
-
- /**
- * Returns actual hash based on raw request body and api key
- *
- * @param string $apiKey
- * @return string
- */
- public function getActualHash($apiKey)
- {
- return base64_encode(hash_hmac('sha256', $this->rawData, $apiKey, true));
- }
-
- /**
- * Checks if webhook is a test.
- *
- * @return bool
- */
- public function isTest()
- {
- return $this->eventTopic === 'cases/test';
- }
}
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookRequestReader.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookMessageReader.php
similarity index 51%
rename from app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookRequestReader.php
rename to app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookMessageReader.php
index 97bfaf2dc6213..3511101680f05 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookRequestReader.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookMessageReader.php
@@ -8,15 +8,10 @@
use Magento\Framework\Json\DecoderInterface;
/**
- * Reads request and produces webhook data object based on request params.
+ * Reads request and produces webhook message data object based on request params.
*/
-class WebhookRequestReader
+class WebhookMessageReader
{
- /**
- * @var WebhookMessageValidator
- */
- private $webhookMessageValidator;
-
/**
* @var DecoderInterface
*/
@@ -28,16 +23,13 @@ class WebhookRequestReader
private $webhookMessageFactory;
/**
- * @param WebhookMessageValidator $webhookMessageValidator
* @param DecoderInterface $decoder
* @param WebhookMessageFactory $webhookMessageFactory
*/
public function __construct(
- WebhookMessageValidator $webhookMessageValidator,
DecoderInterface $decoder,
WebhookMessageFactory $webhookMessageFactory
) {
- $this->webhookMessageValidator = $webhookMessageValidator;
$this->dataDecoder = $decoder;
$this->webhookMessageFactory = $webhookMessageFactory;
}
@@ -47,39 +39,24 @@ public function __construct(
*
* @param WebhookRequest $request
* @return WebhookMessage
- * @throws WebhookException if data validation fails
*/
public function read(WebhookRequest $request)
{
- $hash = $request->getHeader('X-SIGNIFYD-SEC-HMAC-SHA256');
- $eventTopic = $request->getHeader('X-SIGNIFYD-TOPIC');
- $rawData = $request->getBody();
-
try {
- $decodedData = $this->dataDecoder->decode($rawData);
+ $decodedData = $this->dataDecoder->decode($request->getBody());
} catch (\Exception $e) {
- throw new WebhookException(
+ throw new \InvalidArgumentException(
'Webhook request body is not valid JSON: ' . $e->getMessage(),
$e->getCode(),
$e
);
}
- $webhookMessage = $this->webhookMessageFactory->create(
+ return $this->webhookMessageFactory->create(
[
- 'rawData' => $rawData,
'data' => $decodedData,
- 'eventTopic' => $eventTopic,
- 'expectedHash' => $hash
+ 'eventTopic' => $request->getEventTopic()
]
);
-
- if (!$this->webhookMessageValidator->validate($webhookMessage)) {
- throw new WebhookException(
- $this->webhookMessageValidator->getErrorMessage()
- );
- }
-
- return $webhookMessage;
}
}
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookMessageValidator.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookMessageValidator.php
deleted file mode 100644
index ff383d90b182c..0000000000000
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookMessageValidator.php
+++ /dev/null
@@ -1,107 +0,0 @@
-config = $config;
- }
-
- /**
- * Validates webhook message.
- *
- * @param WebhookMessage $webhookMessage
- * @return bool
- */
- public function validate(WebhookMessage $webhookMessage)
- {
- if ($this->isValidTopic($webhookMessage->getEventTopic()) === false) {
- $this->errorMessages[] = 'Value of X-SIGNIFYD-TOPIC header is not allowed';
- }
-
- if (empty($webhookMessage->getData())) {
- $this->errorMessages[] = 'Webhook message is empty';
- }
-
- if ($this->isValidHash($webhookMessage) === false) {
- $this->errorMessages[] = 'X-SIGNIFYD-SEC-HMAC-SHA256 header verification fails';
- }
-
- return empty($this->errorMessages);
-
- }
-
- /**
- * Returns error message if validation fails
- *
- * @return string
- */
- public function getErrorMessage()
- {
- return !empty($this->errorMessages) ? implode('; ', $this->errorMessages) : '';
- }
-
- /**
- * Checks if value of topic identifier is in allowed list
- *
- * @param string $topic topic identifier.
- * @return bool
- */
- private function isValidTopic($topic)
- {
- return in_array($topic, $this->allowedTopicValues);
- }
-
- /**
- * Verifies a webhook message has in fact come from SIGNIFYD.
- *
- * @param WebhookMessage $webhookMessage
- * @return bool
- */
- private function isValidHash(WebhookMessage $webhookMessage)
- {
- // In the case that this is a webhook test, the encoding ABCDE is allowed
- $apiKey = $webhookMessage->isTest() ? 'ABCDE' : $this->config->getApiKey();
-
- return $webhookMessage->getActualHash($apiKey) === $webhookMessage->getExpectedHash();
- }
-}
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookRequest.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookRequest.php
index 04367f6caf4b3..fb5e7781a15d9 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookRequest.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookRequest.php
@@ -8,7 +8,7 @@
use Magento\Framework\App\Request\Http;
/**
- * Reads raw data from the request body.
+ * Reads Signifyd webhook request data.
*/
class WebhookRequest
{
@@ -27,14 +27,23 @@ public function __construct(
}
/**
- * Retrieve header value.
+ * Returns Base64 encoded output of the HMAC SHA256 encoding of the JSON body of the message.
*
- * @param string $name header name to retrieve.
* @return string
*/
- public function getHeader($name)
+ public function getHash()
{
- return $this->request->getHeader($name) ?: '';
+ return (string)$this->request->getHeader('X-SIGNIFYD-SEC-HMAC-SHA256');
+ }
+
+ /**
+ * Returns event topic identifier.
+ *
+ * @return string
+ */
+ public function getEventTopic()
+ {
+ return (string)$this->request->getHeader('X-SIGNIFYD-TOPIC');
}
/**
@@ -44,6 +53,6 @@ public function getHeader($name)
*/
public function getBody()
{
- return file_get_contents("php://input") ?: '';
+ return (string)file_get_contents("php://input");
}
}
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookRequestValidator.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookRequestValidator.php
new file mode 100644
index 0000000000000..f9bf59a0fdb8c
--- /dev/null
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookRequestValidator.php
@@ -0,0 +1,113 @@
+config = $config;
+ $this->decoder = $decoder;
+ }
+
+ /**
+ * Validates webhook request.
+ *
+ * @param WebhookRequest $webhookRequest
+ * @return bool
+ */
+ public function validate(WebhookRequest $webhookRequest)
+ {
+ $body = $webhookRequest->getBody();
+ $eventTopic = $webhookRequest->getEventTopic();
+ $hash = $webhookRequest->getHash();
+
+ return $this->isValidTopic($eventTopic)
+ && $this->isValidBody($body)
+ && $this->isValidHash($eventTopic, $body, $hash);
+ }
+
+ /**
+ * Checks if value of topic identifier is in allowed list
+ *
+ * @param string $topic topic identifier.
+ * @return bool
+ */
+ private function isValidTopic($topic)
+ {
+ return in_array($topic, $this->allowedTopicValues);
+ }
+
+ /**
+ * Verifies a webhook request body is valid JSON and not empty.
+ *
+ * @param string $body
+ * @return bool
+ */
+ private function isValidBody($body)
+ {
+ try {
+ $decodedBody = $this->decoder->decode($body);
+ } catch (\Exception $e) {
+ return false;
+ }
+
+ return !empty($decodedBody);
+ }
+
+ /**
+ * Verifies a webhook request has in fact come from SIGNIFYD.
+ *
+ * @param string $eventTopic
+ * @param string $body
+ * @param string $hash
+ * @return bool
+ */
+ private function isValidHash($eventTopic, $body, $hash)
+ {
+ // In the case that this is a webhook test, the encoding ABCDE is allowed
+ $apiKey = $eventTopic == 'cases/test' ? 'ABCDE' : $this->config->getApiKey();
+ $actualHash = base64_encode(hash_hmac('sha256', $body, $apiKey, true));
+
+ return $hash === $actualHash;
+ }
+}
From df3b3e1e67733716849552eda62b36f512dc635b Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Thu, 5 Jan 2017 07:20:15 -0600
Subject: [PATCH 086/904] MAGETWO-62803: Signifyd webhook controller
- Add redirect to 404 page if webhook request validation fails
---
app/code/Magento/Signifyd/Controller/Webhooks/Handler.php | 2 +-
.../Model/SignifydGateway/Response/WebhookMessageReader.php | 5 ++++-
.../Model/SignifydGateway/Response/WebhookRequest.php | 2 +-
3 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/app/code/Magento/Signifyd/Controller/Webhooks/Handler.php b/app/code/Magento/Signifyd/Controller/Webhooks/Handler.php
index d773149a373d5..346e41c8fb12f 100644
--- a/app/code/Magento/Signifyd/Controller/Webhooks/Handler.php
+++ b/app/code/Magento/Signifyd/Controller/Webhooks/Handler.php
@@ -78,7 +78,7 @@ public function __construct(
public function execute()
{
if (!$this->webhookRequestValidator->validate($this->webhookRequest)) {
- $this->getResponse()->setHttpResponseCode(400);
+ $this->_redirect('noroute');
return;
}
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookMessageReader.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookMessageReader.php
index 3511101680f05..26764eaef0cd3 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookMessageReader.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookMessageReader.php
@@ -39,6 +39,7 @@ public function __construct(
*
* @param WebhookRequest $request
* @return WebhookMessage
+ * @throws \InvalidArgumentException
*/
public function read(WebhookRequest $request)
{
@@ -52,11 +53,13 @@ public function read(WebhookRequest $request)
);
}
- return $this->webhookMessageFactory->create(
+ $webhookMessage = $this->webhookMessageFactory->create(
[
'data' => $decodedData,
'eventTopic' => $request->getEventTopic()
]
);
+
+ return $webhookMessage;
}
}
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookRequest.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookRequest.php
index fb5e7781a15d9..0a892dd02733d 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookRequest.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookRequest.php
@@ -53,6 +53,6 @@ public function getEventTopic()
*/
public function getBody()
{
- return (string)file_get_contents("php://input");
+ return (string)@file_get_contents("php://input");
}
}
From 18f661ce45975175e71f8c96d59937046934b8d9 Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Thu, 5 Jan 2017 07:37:23 -0600
Subject: [PATCH 087/904] MAGETWO-62806: Update case entity
- Refactored code according to code review comments
---
.../Signifyd/Api/CaseRepositoryInterface.php | 2 +-
.../Magento/Signifyd/Model/CaseEntity.php | 24 ++++++++---
.../Signifyd/Model/CaseUpdatingService.php | 43 ++++++-------------
.../Model/CaseUpdatingServiceFactory.php | 29 +++++++++----
.../Model/CaseUpdatingServiceInterface.php | 6 +--
.../Model/MessageGeneratorInterface.php | 6 +--
.../Model/MessageGenerators/CaseCreation.php | 5 +--
.../Model/MessageGenerators/CaseRescore.php | 7 ++-
.../Model/MessageGenerators/CaseReview.php | 7 ++-
.../MessageGenerators/GuaranteeCompletion.php | 7 ++-
.../Response/WebhookMessage.php | 6 +--
.../Model/StubCaseUpdatingService.php | 4 +-
.../Model/Validators/CaseDataValidator.php | 8 ++--
.../Model/CaseUpdatingServiceTest.php | 37 ++++++++--------
14 files changed, 95 insertions(+), 96 deletions(-)
diff --git a/app/code/Magento/Signifyd/Api/CaseRepositoryInterface.php b/app/code/Magento/Signifyd/Api/CaseRepositoryInterface.php
index d84bd4a3bf7d8..e985effe84b59 100644
--- a/app/code/Magento/Signifyd/Api/CaseRepositoryInterface.php
+++ b/app/code/Magento/Signifyd/Api/CaseRepositoryInterface.php
@@ -1,6 +1,6 @@
serializer = $serializer;
+ parent::__construct($context, $registry, $resource, $resourceCollection, $data);
+ }
+
/**
* @inheritdoc
*/
protected function _construct()
{
- $this->serializer = ObjectManager::getInstance()->get(SerializerInterface::class);
$this->_init(ResourceModel\CaseEntity::class);
}
diff --git a/app/code/Magento/Signifyd/Model/CaseUpdatingService.php b/app/code/Magento/Signifyd/Model/CaseUpdatingService.php
index 897b36b2635b9..90364ea541582 100644
--- a/app/code/Magento/Signifyd/Model/CaseUpdatingService.php
+++ b/app/code/Magento/Signifyd/Model/CaseUpdatingService.php
@@ -5,7 +5,6 @@
*/
namespace Magento\Signifyd\Model;
-use Magento\Framework\DataObject;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Exception\NotFoundException;
use Magento\Signifyd\Api\CaseRepositoryInterface;
@@ -60,18 +59,18 @@ public function __construct(
/**
* Updates Signifyd Case entity by received data.
*
- * @param DataObject $data
+ * @param array $data
* @return void
* @throws LocalizedException
* @throws NotFoundException
*/
- public function update(DataObject $data)
+ public function update(array $data)
{
if (!$this->caseDataValidator->validate($data)) {
throw new LocalizedException(__('The "%1" should not be empty.', 'caseId'));
}
- $case = $this->caseRepository->getByCaseId($data->getData('caseId'));
+ $case = $this->caseRepository->getByCaseId($data['caseId']);
if ($case === null) {
throw new NotFoundException(__('Case entity not found.'));
}
@@ -92,34 +91,20 @@ public function update(DataObject $data)
* Sets data to case entity.
*
* @param CaseInterface $case
- * @param DataObject $data
+ * @param array $data
* @return void
*/
- private function prepareCaseData(CaseInterface $case, DataObject $data)
+ private function prepareCaseData(CaseInterface $case, array $data)
{
- if ($data->getData('guaranteeEligible') !== null) {
- $case->setGuaranteeEligible($data->getData('guaranteeEligible'));
- }
- if ($data->getData('status') !== null) {
- $case->setStatus($data->getData('status'));
- }
- if ($data->getData('reviewDisposition') !== null) {
- $case->setReviewDisposition($data->getData('reviewDisposition'));
- }
- if ($data->getData('associatedTeam') !== null) {
- $case->setAssociatedTeam($data->getData('associatedTeam'));
- }
- if ($data->getData('createdAt') !== null) {
- $case->setCreatedAt($data->getData('createdAt'));
- }
- if ($data->getData('updatedAt') !== null) {
- $case->setUpdatedAt($data->getData('updatedAt'));
- }
- if ($data->getData('score') !== null) {
- $case->setScore($data->getData('score'));
- }
- if ($data->getData('guaranteeDisposition') !== null) {
- $case->setGuaranteeDisposition($data->getData('guaranteeDisposition'));
+ // list of keys which should not be replaced, like order id
+ $notResolvedKeys = [
+ 'orderId'
+ ];
+ foreach ($data as $key => $value) {
+ $methodName = 'set' . ucfirst($key);
+ if (!in_array($key, $notResolvedKeys) && method_exists($case, $methodName)) {
+ call_user_func([$case, $methodName], $value);
+ }
}
}
}
diff --git a/app/code/Magento/Signifyd/Model/CaseUpdatingServiceFactory.php b/app/code/Magento/Signifyd/Model/CaseUpdatingServiceFactory.php
index e626e8347d239..e4cb86d724137 100644
--- a/app/code/Magento/Signifyd/Model/CaseUpdatingServiceFactory.php
+++ b/app/code/Magento/Signifyd/Model/CaseUpdatingServiceFactory.php
@@ -7,6 +7,7 @@
use Magento\Framework\ObjectManagerInterface;
use Magento\Signifyd\Model\MessageGenerators\GeneratorFactory;
+use Magento\Signifyd\Model\Config;
/**
* Creates instance of case updating service configured with specific message generator.
@@ -31,16 +32,26 @@ class CaseUpdatingServiceFactory
*/
private $generatorFactory;
+ /**
+ * @var Config
+ */
+ private $config;
+
/**
* CaseUpdatingServiceFactory constructor.
*
* @param ObjectManagerInterface $objectManager
* @param GeneratorFactory $generatorFactory
+ * @param Config $config
*/
- public function __construct(ObjectManagerInterface $objectManager, GeneratorFactory $generatorFactory)
- {
+ public function __construct(
+ ObjectManagerInterface $objectManager,
+ GeneratorFactory $generatorFactory,
+ Config $config
+ ) {
$this->objectManager = $objectManager;
$this->generatorFactory = $generatorFactory;
+ $this->config = $config;
}
/**
@@ -53,15 +64,15 @@ public function __construct(ObjectManagerInterface $objectManager, GeneratorFact
*/
public function create($type)
{
- if ($type === self::$caseTest) {
- $service = $this->objectManager->create(StubCaseUpdatingService::class);
- } else {
- $messageGenerator = $this->generatorFactory->create($type);
- $service = $this->objectManager->create(CaseUpdatingService::class, [
- 'messageGenerator' => $messageGenerator
- ]);
+ if (!$this->config->isActive() || $type === self::$caseTest) {
+ return $this->objectManager->create(StubCaseUpdatingService::class);
}
+ $messageGenerator = $this->generatorFactory->create($type);
+ $service = $this->objectManager->create(CaseUpdatingService::class, [
+ 'messageGenerator' => $messageGenerator
+ ]);
+
return $service;
}
}
diff --git a/app/code/Magento/Signifyd/Model/CaseUpdatingServiceInterface.php b/app/code/Magento/Signifyd/Model/CaseUpdatingServiceInterface.php
index 1fa97ce3b2ad4..3e221f24682e1 100644
--- a/app/code/Magento/Signifyd/Model/CaseUpdatingServiceInterface.php
+++ b/app/code/Magento/Signifyd/Model/CaseUpdatingServiceInterface.php
@@ -5,8 +5,6 @@
*/
namespace Magento\Signifyd\Model;
-use Magento\Framework\DataObject;
-
/**
* Common abstraction to perform updating operations with Signifyd case entity.
*/
@@ -15,8 +13,8 @@ interface CaseUpdatingServiceInterface
/**
* Updates Signifyd Case entity by received data.
*
- * @param DataObject $data
+ * @param array $data
* @return void
*/
- public function update(DataObject $data);
+ public function update(array $data);
}
diff --git a/app/code/Magento/Signifyd/Model/MessageGeneratorInterface.php b/app/code/Magento/Signifyd/Model/MessageGeneratorInterface.php
index 949c957748274..1126973e1abf2 100644
--- a/app/code/Magento/Signifyd/Model/MessageGeneratorInterface.php
+++ b/app/code/Magento/Signifyd/Model/MessageGeneratorInterface.php
@@ -5,8 +5,6 @@
*/
namespace Magento\Signifyd\Model;
-use Magento\Framework\DataObject;
-
/**
* Represents common abstraction for Signifyd Case/Guarantee messages.
* Each interface implementation might use Case/Guarantee data to generate specific message.
@@ -15,9 +13,9 @@ interface MessageGeneratorInterface
{
/**
* Creates new localized message based on Signifyd Case/Guarantee data.
- * @param DataObject $data
+ * @param $data
* @return \Magento\Framework\Phrase
* @throws MessageGeneratorException
*/
- public function generate(DataObject $data);
+ public function generate(array $data);
}
diff --git a/app/code/Magento/Signifyd/Model/MessageGenerators/CaseCreation.php b/app/code/Magento/Signifyd/Model/MessageGenerators/CaseCreation.php
index 7c65f923ff13f..72165538956b4 100644
--- a/app/code/Magento/Signifyd/Model/MessageGenerators/CaseCreation.php
+++ b/app/code/Magento/Signifyd/Model/MessageGenerators/CaseCreation.php
@@ -5,7 +5,6 @@
*/
namespace Magento\Signifyd\Model\MessageGenerators;
-use Magento\Framework\DataObject;
use Magento\Signifyd\Model\MessageGeneratorException;
use Magento\Signifyd\Model\MessageGeneratorInterface;
use Magento\Signifyd\Model\Validators\CaseDataValidator;
@@ -33,12 +32,12 @@ public function __construct(CaseDataValidator $caseDataValidator)
/**
* @inheritdoc
*/
- public function generate(DataObject $data)
+ public function generate(array $data)
{
if (!$this->caseDataValidator->validate($data)) {
throw new MessageGeneratorException(__('The "%1" should not be empty.', 'caseId'));
}
- return __('Signifyd Case %1 has been created for order.', $data->getData('caseId'));
+ return __('Signifyd Case %1 has been created for order.', $data['caseId']);
}
}
diff --git a/app/code/Magento/Signifyd/Model/MessageGenerators/CaseRescore.php b/app/code/Magento/Signifyd/Model/MessageGenerators/CaseRescore.php
index 5df98975d51e2..adbd604ed9376 100644
--- a/app/code/Magento/Signifyd/Model/MessageGenerators/CaseRescore.php
+++ b/app/code/Magento/Signifyd/Model/MessageGenerators/CaseRescore.php
@@ -5,7 +5,6 @@
*/
namespace Magento\Signifyd\Model\MessageGenerators;
-use Magento\Framework\DataObject;
use Magento\Signifyd\Api\CaseRepositoryInterface;
use Magento\Signifyd\Model\MessageGeneratorException;
use Magento\Signifyd\Model\MessageGeneratorInterface;
@@ -41,13 +40,13 @@ public function __construct(CaseRepositoryInterface $caseRepository, CaseDataVal
/**
* @inheritdoc
*/
- public function generate(DataObject $data)
+ public function generate(array $data)
{
if (!$this->caseDataValidator->validate($data)) {
throw new MessageGeneratorException(__('The "%1" should not be empty.', 'caseId'));
}
- $caseEntity = $this->caseRepository->getByCaseId($data->getData('caseId'));
+ $caseEntity = $this->caseRepository->getByCaseId($data['caseId']));
if ($caseEntity === null) {
throw new MessageGeneratorException(__('Case entity not found.'));
@@ -55,7 +54,7 @@ public function generate(DataObject $data)
return __(
'Case Update: New score for the order is %1. Previous score was %2.',
- $data->getData('score'),
+ !empty($data['score']) ? $data['score'] : 0,
$caseEntity->getScore()
);
}
diff --git a/app/code/Magento/Signifyd/Model/MessageGenerators/CaseReview.php b/app/code/Magento/Signifyd/Model/MessageGenerators/CaseReview.php
index 06cedd4ad42fb..c34c6592b751d 100644
--- a/app/code/Magento/Signifyd/Model/MessageGenerators/CaseReview.php
+++ b/app/code/Magento/Signifyd/Model/MessageGenerators/CaseReview.php
@@ -5,7 +5,6 @@
*/
namespace Magento\Signifyd\Model\MessageGenerators;
-use Magento\Framework\DataObject;
use Magento\Signifyd\Model\MessageGeneratorException;
use Magento\Signifyd\Model\MessageGeneratorInterface;
@@ -17,15 +16,15 @@ class CaseReview implements MessageGeneratorInterface
/**
* @inheritdoc
*/
- public function generate(DataObject $data)
+ public function generate(array $data)
{
- if (empty($data->getData('reviewDisposition'))) {
+ if (empty($data['reviewDisposition'])) {
throw new MessageGeneratorException(__('The "%1" should not be empty.', 'reviewDisposition'));
}
return __(
'Case Update: Case Review was completed. Review Deposition is %1.',
- __($data->getData('reviewDisposition'))
+ __($data['reviewDisposition'])
);
}
}
diff --git a/app/code/Magento/Signifyd/Model/MessageGenerators/GuaranteeCompletion.php b/app/code/Magento/Signifyd/Model/MessageGenerators/GuaranteeCompletion.php
index 051a48f68c7bb..cfc73922c5d9a 100644
--- a/app/code/Magento/Signifyd/Model/MessageGenerators/GuaranteeCompletion.php
+++ b/app/code/Magento/Signifyd/Model/MessageGenerators/GuaranteeCompletion.php
@@ -5,7 +5,6 @@
*/
namespace Magento\Signifyd\Model\MessageGenerators;
-use Magento\Framework\DataObject;
use Magento\Signifyd\Model\MessageGeneratorException;
use Magento\Signifyd\Model\MessageGeneratorInterface;
@@ -17,12 +16,12 @@ class GuaranteeCompletion implements MessageGeneratorInterface
/**
* @inheritdoc
*/
- public function generate(DataObject $data)
+ public function generate(array $data)
{
- if (empty($data->getData('guaranteeDisposition'))) {
+ if (empty($data['guaranteeDisposition'])) {
throw new MessageGeneratorException(__('The "%1" should not be empty.', 'guaranteeDisposition'));
}
- return __('Case Update: Guarantee Disposition is %1.', __($data->getData('guaranteeDisposition')));
+ return __('Case Update: Guarantee Disposition is %1.', __($data['guaranteeDisposition']));
}
}
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookMessage.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookMessage.php
index 8ce2d78657725..f48c5c3a39a6f 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookMessage.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookMessage.php
@@ -5,8 +5,6 @@
*/
namespace Magento\Signifyd\Model\SignifydGateway\Response;
-use Magento\Framework\DataObject;
-
/**
* Webhooks are messages sent by SIGNIFYD via HTTP POST to a url you configure on your
* Notifications page in the SIGNIFYD settings.
@@ -47,11 +45,11 @@ public function __construct(
/**
* Returns decoded webhook request body.
*
- * @return DataObject
+ * @return array
*/
public function getData()
{
- return new DataObject($this->data);
+ return $this->data;
}
/**
diff --git a/app/code/Magento/Signifyd/Model/StubCaseUpdatingService.php b/app/code/Magento/Signifyd/Model/StubCaseUpdatingService.php
index 3d8ff6478f06c..9d7cffdd7ca1a 100644
--- a/app/code/Magento/Signifyd/Model/StubCaseUpdatingService.php
+++ b/app/code/Magento/Signifyd/Model/StubCaseUpdatingService.php
@@ -5,8 +5,6 @@
*/
namespace Magento\Signifyd\Model;
-use Magento\Framework\DataObject;
-
/**
* Stub implementation for case updating service interface and might be used
* for test Signifyd webhooks
@@ -17,7 +15,7 @@ class StubCaseUpdatingService implements CaseUpdatingServiceInterface
/**
* @inheritdoc
*/
- public function update(DataObject $data)
+ public function update(array $data)
{
// just stub method and doesn't contain any logic
}
diff --git a/app/code/Magento/Signifyd/Model/Validators/CaseDataValidator.php b/app/code/Magento/Signifyd/Model/Validators/CaseDataValidator.php
index 07b109b82745f..9827984956f54 100644
--- a/app/code/Magento/Signifyd/Model/Validators/CaseDataValidator.php
+++ b/app/code/Magento/Signifyd/Model/Validators/CaseDataValidator.php
@@ -5,8 +5,6 @@
*/
namespace Magento\Signifyd\Model\Validators;
-use Magento\Framework\DataObject;
-
/**
* Validates Signifyd Case id field.
*/
@@ -14,12 +12,12 @@ class CaseDataValidator
{
/**
* Checks if data object contains Signifyd Case id.
- * @param DataObject $data
+ * @param array $data
* @return bool
*/
- public function validate(DataObject $data)
+ public function validate(array $data)
{
- if (empty($data->getData('caseId'))) {
+ if (empty($data['caseId'])) {
return false;
}
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseUpdatingServiceTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseUpdatingServiceTest.php
index ecc16820e934b..2fb3d0481a2e3 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseUpdatingServiceTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseUpdatingServiceTest.php
@@ -6,7 +6,6 @@
namespace Magento\Signifyd\Model;
use Magento\Framework\App\ObjectManager;
-use Magento\Framework\DataObject;
use Magento\Sales\Api\Data\OrderStatusHistoryInterface;
use Magento\Sales\Api\OrderRepositoryInterface;
use Magento\Signifyd\Api\CaseRepositoryInterface;
@@ -44,34 +43,37 @@ protected function setUp()
}
/**
+ * Checks case updating flow and messages in order comments history.
+ *
* @covers \Magento\Signifyd\Model\CaseUpdatingService::update
* @magentoDataFixture Magento/Signifyd/_files/case.php
*/
public function testUpdate()
{
$caseId = 123;
- $data = new DataObject(
- [
- 'caseId' => $caseId,
- 'score' => 750,
- 'reviewDisposition' => CaseInterface::DISPOSITION_FRAUDULENT,
- 'associatedTeam' => [
- 'teamName' => 'AnyTeam',
- 'teamId' => 26,
- 'getAutoDismiss' => true,
- 'getTeamDismissalDays' => 2
- ],
- 'createdAt' => '2017-01-05T14:23:26-0800',
- 'updatedAt' => '2017-01-05T14:44:26-0800',
- 'guaranteeDisposition' => CaseInterface::GUARANTEE_APPROVED
- ]
- );
+ $data = [
+ 'caseId' => $caseId,
+ 'score' => 750,
+ 'orderId' => '100000001',
+ 'reviewDisposition' => CaseInterface::DISPOSITION_FRAUDULENT,
+ 'associatedTeam' => [
+ 'teamName' => 'AnyTeam',
+ 'teamId' => 26,
+ 'getAutoDismiss' => true,
+ 'getTeamDismissalDays' => 2
+ ],
+ 'createdAt' => '2017-01-05T14:23:26-0800',
+ 'updatedAt' => '2017-01-05T14:44:26-0800',
+ 'guaranteeDisposition' => CaseInterface::GUARANTEE_APPROVED
+ ];
$this->service->update($data);
/** @var CaseRepositoryInterface $caseManagement */
$caseRepository = $this->objectManager->get(CaseRepositoryInterface::class);
+ /** @var CaseInterface $caseEntity */
$caseEntity = $caseRepository->getByCaseId($caseId);
+ $orderEntityId = $caseEntity->getOrderId();
static::assertNotEmpty($caseEntity);
static::assertEquals('2017-01-05 22:23:26', $caseEntity->getCreatedAt());
@@ -79,6 +81,7 @@ public function testUpdate()
static::assertEquals('AnyTeam', $caseEntity->getAssociatedTeam()['teamName']);
static::assertEquals(true, $caseEntity->isGuaranteeEligible());
static::assertEquals(CaseInterface::STATUS_PROCESSING, $caseEntity->getStatus());
+ static::assertEquals($orderEntityId, $caseEntity->getOrderId());
/** @var OrderRepositoryInterface $orderRepository */
$orderRepository = $this->objectManager->get(OrderRepositoryInterface::class);
From 2f4c7bb4698b45df8430b714d066bc522392a883 Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Thu, 5 Jan 2017 11:31:36 -0600
Subject: [PATCH 088/904] MAGETWO-62803: Signifyd webhook controller
- Add WebhookRequestValidatorTest
- Add HandlerTest
---
.../Unit/Controller/Webhooks/HandlerTest.php | 228 +++++++++++++++++
.../Response/WebhookRequestValidatorTest.php | 231 ++++++++++++++++++
2 files changed, 459 insertions(+)
create mode 100644 app/code/Magento/Signifyd/Test/Unit/Controller/Webhooks/HandlerTest.php
create mode 100644 app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/Response/WebhookRequestValidatorTest.php
diff --git a/app/code/Magento/Signifyd/Test/Unit/Controller/Webhooks/HandlerTest.php b/app/code/Magento/Signifyd/Test/Unit/Controller/Webhooks/HandlerTest.php
new file mode 100644
index 0000000000000..8fcec8433f87a
--- /dev/null
+++ b/app/code/Magento/Signifyd/Test/Unit/Controller/Webhooks/HandlerTest.php
@@ -0,0 +1,228 @@
+context = $this->getMockBuilder(Context::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->webhookRequest = $this->getMockBuilder(WebhookRequest::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->webhookMessageReader = $this->getMockBuilder(WebhookMessageReader::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->webhookRequestValidator = $this->getMockBuilder(WebhookRequestValidator::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->caseUpdatingServiceFactory = $this->getMockBuilder(CaseUpdatingServiceFactory::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->logger = $this->getMockBuilder(LoggerInterface::class)
+ ->getMockForAbstractClass();
+
+ $this->response = $this->getMockBuilder(ResponseHttp::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->context->expects($this->once())
+ ->method('getResponse')
+ ->willReturn($this->response);
+ $this->redirect = $this->getMockBuilder(RedirectInterface::class)
+ ->getMockForAbstractClass();
+ $this->context->expects($this->once())
+ ->method('getRedirect')
+ ->willReturn($this->redirect);
+
+ $this->controller = new Handler(
+ $this->context,
+ $this->webhookRequest,
+ $this->logger,
+ $this->webhookMessageReader,
+ $this->caseUpdatingServiceFactory,
+ $this->webhookRequestValidator
+ );
+ }
+
+ /**
+ * Successfull case
+ */
+ public function testExecuteSuccessfully()
+ {
+ $eventTopic = 'cases\test';
+ $data = ['score' => 200, 'caseId' => 1];
+
+ $this->webhookRequestValidator->expects($this->once())
+ ->method('validate')
+ ->willReturn(true);
+
+ $webhookMessage = $this->getMockBuilder(WebhookMessage::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+ $webhookMessage->expects($this->once())
+ ->method('getEventTopic')
+ ->willReturn($eventTopic);
+ $webhookMessage->expects($this->once())
+ ->method('getData')
+ ->willReturn($data);
+ $this->webhookMessageReader->expects($this->once())
+ ->method('read')
+ ->with($this->webhookRequest)
+ ->willReturn($webhookMessage);
+
+ $caseUpdatingService = $this->getMockBuilder(CaseUpdatingService::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+ $caseUpdatingService->expects($this->once())
+ ->method('update')
+ ->with($data)
+ ->willReturn($caseUpdatingService);
+
+ $this->caseUpdatingServiceFactory->expects($this->once())
+ ->method('create')
+ ->with($eventTopic)
+ ->willReturn($caseUpdatingService);
+
+ $this->controller->execute();
+ }
+
+ /**
+ * Case when there is exception while updating case
+ */
+ public function testExecuteCaseUpdatingServiceException()
+ {
+ $eventTopic = 'cases\test';
+ $data = ['score' => 200, 'caseId' => 1];
+
+ $this->webhookRequestValidator->expects($this->once())
+ ->method('validate')
+ ->willReturn(true);
+
+ $webhookMessage = $this->getMockBuilder(WebhookMessage::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+ $webhookMessage->expects($this->once())
+ ->method('getEventTopic')
+ ->willReturn($eventTopic);
+ $webhookMessage->expects($this->once())
+ ->method('getData')
+ ->willReturn($data);
+ $this->webhookMessageReader->expects($this->once())
+ ->method('read')
+ ->with($this->webhookRequest)
+ ->willReturn($webhookMessage);
+
+ $caseUpdatingService = $this->getMockBuilder(CaseUpdatingService::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+ $caseUpdatingService->expects($this->once())
+ ->method('update')
+ ->with($data)
+ ->willThrowException(new LocalizedException(__('Error')));
+
+ $this->caseUpdatingServiceFactory->expects($this->once())
+ ->method('create')
+ ->with($eventTopic)
+ ->willReturn($caseUpdatingService);
+
+ $this->response->expects($this->once())
+ ->method('setHttpResponseCode')
+ ->with(400);
+ $this->logger->expects($this->once())
+ ->method('error')
+ ->with(__('Error'));
+
+ $this->controller->execute();
+ }
+
+ /**
+ * Case when webhook request validation fails
+ */
+ public function testExecuteRequestValidationFails()
+ {
+ $this->webhookRequestValidator->expects($this->once())
+ ->method('validate')
+ ->willReturn(false);
+ $this->redirect->expects($this->once())
+ ->method('redirect')
+ ->with($this->response, 'noroute', []);
+ $this->webhookMessageReader->expects($this->never())
+ ->method('read');
+ $this->caseUpdatingServiceFactory->expects($this->never())
+ ->method('create');
+
+ $this->controller->execute();
+ }
+}
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/Response/WebhookRequestValidatorTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/Response/WebhookRequestValidatorTest.php
new file mode 100644
index 0000000000000..0209a64d5c94b
--- /dev/null
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/Response/WebhookRequestValidatorTest.php
@@ -0,0 +1,231 @@
+config = $this->getMockBuilder(Config::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->decoder = $this->getMockBuilder(DecoderInterface::class)
+ ->getMockForAbstractClass();
+
+ $this->model = new WebhookRequestValidator(
+ $this->config,
+ $this->decoder
+ );
+ }
+
+ /**
+ * Tests successful cases.
+ *
+ * @param string $body
+ * @param string $topic
+ * @param string $hash
+ * @param int$callConfigCount
+ * @dataProvider validateSuccessDataProvider
+ */
+ public function testValidateSuccess($body, $topic, $hash, $callConfigCount)
+ {
+ $this->config->expects($this->exactly($callConfigCount))
+ ->method('getApiKey')
+ ->willReturn('GpFZZnxGgIxuI8BazSm3v6eGK');
+
+ $this->decoder->expects($this->once())
+ ->method('decode')
+ ->with($body)
+ ->willReturn(['status' => "DISMISSED", 'orderId' => '19418']);
+
+ $webhookRequest = $this->createWebhookRequest($body, $topic, $hash);
+
+ $this->assertTrue(
+ $this->model->validate($webhookRequest)
+ );
+ }
+
+ /**
+ * @case 1. All data are correct, event topic has real value
+ * @case 2. All data are correct, event topic has test value
+ * @return array
+ */
+ public function validateSuccessDataProvider()
+ {
+ return [
+ 1 => [
+ 'body' => '{ status: "DISMISSED", orderId: "19418" }',
+ 'topic' => 'cases/creation',
+ 'hash' => 'KWR8Bzu3tinEpDviw1opWSMJGFqfpA79nNGp0TEYM6Q=',
+ 'callConfigCount' => 1
+ ],
+ 2 => [
+ 'body' => '{ status: "DISMISSED", orderId: "19418" }',
+ 'topic' => 'cases/test',
+ 'hash' => '6npAahliNbzYo/Qi4+g+JeqPhLFgg19sIbuxDLmvobw=',
+ 'callConfigCount' => 0
+ ]
+ ];
+ }
+
+ /**
+ * Case with wrong event topic
+ *
+ * @param string $topic
+ * @dataProvider validationTopicFailsDataProvider
+ */
+ public function testValidationTopicFails($topic)
+ {
+ $body = '{ status: "DISMISSED", orderId: "19418" }';
+ $hash = 'KWR8Bzu3tinEpDviw1opWSMJGFqfpA79nNGp0TEYM6Q=';
+
+ $this->config->expects($this->never())
+ ->method('getApiKey');
+
+ $this->decoder->expects($this->never())
+ ->method('decode');
+
+ $webhookRequest = $this->createWebhookRequest($body, $topic, $hash);
+
+ $this->assertFalse(
+ $this->model->validate($webhookRequest),
+ 'Negative webhook event topic value validation fails'
+ );
+ }
+
+ /**
+ * @return array
+ */
+ public function validationTopicFailsDataProvider()
+ {
+ return [
+ ['wrong topic' => 'bla-bla-topic'],
+ ['empty topic' => '']
+ ];
+ }
+
+ /**
+ * Case with wrong webhook request body
+ *
+ * @param string $body
+ * @dataProvider validationBodyFailsDataProvider
+ */
+ public function testValidationBodyFails($body)
+ {
+ $topic = 'cases/creation';
+ $hash = 'KWR8Bzu3tinEpDviw1opWSMJGFqfpA79nNGp0TEYM6Q=';
+ $webhookRequest = $this->createWebhookRequest($body, $topic, $hash);
+
+ $this->config->expects($this->never())
+ ->method('getApiKey');
+
+ if (empty($body)) {
+ $this->decoder->expects($this->once())
+ ->method('decode')
+ ->with($body)
+ ->willReturn('');
+ } else {
+ $this->decoder->expects($this->once())
+ ->method('decode')
+ ->with($body)
+ ->willThrowException(new \Exception('Error'));
+ }
+
+ $this->assertFalse(
+ $this->model->validate($webhookRequest),
+ 'Negative webhook request body validation fails'
+ );
+ }
+
+ /**
+ * @return array
+ */
+ public function validationBodyFailsDataProvider()
+ {
+ return [
+ ['Empty request body' => ''],
+ ['Bad request body' => '{ bad data}']
+ ];
+ }
+
+ /**
+ * Case with wrong hash
+ */
+ public function testValidationHashFails()
+ {
+ $topic = 'cases/creation';
+ $body = '{ status: "DISMISSED", orderId: "19418" }';
+ $hash = 'wrong hash';
+ $webhookRequest = $this->createWebhookRequest($body, $topic, $hash);
+
+ $this->config->expects($this->once())
+ ->method('getApiKey')
+ ->willReturn('GpFZZnxGgIxuI8BazSm3v6eGK');
+
+ $this->decoder->expects($this->once())
+ ->method('decode')
+ ->with($body)
+ ->willReturn(['status' => "DISMISSED", 'orderId' => '19418']);
+
+ $this->assertFalse(
+ $this->model->validate($webhookRequest),
+ 'Negative webhook hash validation fails'
+ );
+ }
+
+ /**
+ * Returns mocked WebhookRequest
+ *
+ * @param string $body
+ * @param string $topic
+ * @param string $hash
+ * @return WebhookRequest|\PHPUnit_Framework_MockObject_MockObject
+ */
+ private function createWebhookRequest($body, $topic, $hash)
+ {
+ $webhookRequest = $this->getMockBuilder(WebhookRequest::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+ $webhookRequest->expects($this->once())
+ ->method('getBody')
+ ->willReturn($body);
+ $webhookRequest->expects($this->once())
+ ->method('getEventTopic')
+ ->willReturn($topic);
+ $webhookRequest->expects($this->once())
+ ->method('getHash')
+ ->willReturn($hash);
+
+ return $webhookRequest;
+ }
+}
From b785f2bae0f5a598c82924ed9b919609b9d5acb2 Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Fri, 6 Jan 2017 02:50:30 -0600
Subject: [PATCH 089/904] MAGETWO-62806: Update case entity
- Added unit tests
---
.../Magento/Signifyd/Model/CaseEntity.php | 16 +-
.../Model/CaseUpdatingServiceFactory.php | 1 -
.../Signifyd/Model/CommentsHistoryUpdater.php | 2 +
.../Model/MessageGeneratorInterface.php | 2 +-
.../Model/MessageGenerators/CaseRescore.php | 2 +-
.../Model/CaseUpdatingServiceFactoryTest.php | 167 +++++++++
.../Unit/Model/CaseUpdatingServiceTest.php | 336 ++++++++++++++++++
.../Unit/Model/CommentsHistoryUpdaterTest.php | 140 ++++++++
.../GeneratorFactoryTest.php | 99 ++++++
.../Unit/Model/SignifydOrderSessionIdTest.php | 4 +-
10 files changed, 761 insertions(+), 8 deletions(-)
create mode 100644 app/code/Magento/Signifyd/Test/Unit/Model/CaseUpdatingServiceFactoryTest.php
create mode 100644 app/code/Magento/Signifyd/Test/Unit/Model/CaseUpdatingServiceTest.php
create mode 100644 app/code/Magento/Signifyd/Test/Unit/Model/CommentsHistoryUpdaterTest.php
create mode 100644 app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/GeneratorFactoryTest.php
diff --git a/app/code/Magento/Signifyd/Model/CaseEntity.php b/app/code/Magento/Signifyd/Model/CaseEntity.php
index 647b8e2410301..d75285d228e4e 100644
--- a/app/code/Magento/Signifyd/Model/CaseEntity.php
+++ b/app/code/Magento/Signifyd/Model/CaseEntity.php
@@ -28,13 +28,23 @@ class CaseEntity extends AbstractModel implements CaseInterface
*/
private $serializer;
+ /**
+ * CaseEntity constructor.
+ *
+ * @param Context $context
+ * @param Registry $registry
+ * @param SerializerInterface $serializer
+ * @param array $data
+ * @param AbstractResource|null $resource
+ * @param AbstractDb|null $resourceCollection
+ */
public function __construct(
- SerializerInterface $serializer,
Context $context,
Registry $registry,
+ SerializerInterface $serializer,
+ array $data = [],
AbstractResource $resource = null,
- AbstractDb $resourceCollection = null,
- array $data = []
+ AbstractDb $resourceCollection = null
) {
$this->serializer = $serializer;
parent::__construct($context, $registry, $resource, $resourceCollection, $data);
diff --git a/app/code/Magento/Signifyd/Model/CaseUpdatingServiceFactory.php b/app/code/Magento/Signifyd/Model/CaseUpdatingServiceFactory.php
index e4cb86d724137..f9236a5fa9395 100644
--- a/app/code/Magento/Signifyd/Model/CaseUpdatingServiceFactory.php
+++ b/app/code/Magento/Signifyd/Model/CaseUpdatingServiceFactory.php
@@ -7,7 +7,6 @@
use Magento\Framework\ObjectManagerInterface;
use Magento\Signifyd\Model\MessageGenerators\GeneratorFactory;
-use Magento\Signifyd\Model\Config;
/**
* Creates instance of case updating service configured with specific message generator.
diff --git a/app/code/Magento/Signifyd/Model/CommentsHistoryUpdater.php b/app/code/Magento/Signifyd/Model/CommentsHistoryUpdater.php
index 914efd0cd7e6a..ff600b91d0a6b 100644
--- a/app/code/Magento/Signifyd/Model/CommentsHistoryUpdater.php
+++ b/app/code/Magento/Signifyd/Model/CommentsHistoryUpdater.php
@@ -32,10 +32,12 @@ public function __construct(HistoryFactory $historyFactory)
/**
* Adds comment to case related order.
+ * Throws an exception if cannot save history comment.
*
* @param CaseInterface $case
* @param Phrase $message
* @return void
+ * @throws \Exception
*/
public function addComment(CaseInterface $case, Phrase $message)
{
diff --git a/app/code/Magento/Signifyd/Model/MessageGeneratorInterface.php b/app/code/Magento/Signifyd/Model/MessageGeneratorInterface.php
index 1126973e1abf2..265b6ae1e5f5a 100644
--- a/app/code/Magento/Signifyd/Model/MessageGeneratorInterface.php
+++ b/app/code/Magento/Signifyd/Model/MessageGeneratorInterface.php
@@ -13,7 +13,7 @@ interface MessageGeneratorInterface
{
/**
* Creates new localized message based on Signifyd Case/Guarantee data.
- * @param $data
+ * @param array $data
* @return \Magento\Framework\Phrase
* @throws MessageGeneratorException
*/
diff --git a/app/code/Magento/Signifyd/Model/MessageGenerators/CaseRescore.php b/app/code/Magento/Signifyd/Model/MessageGenerators/CaseRescore.php
index adbd604ed9376..0f184590d4946 100644
--- a/app/code/Magento/Signifyd/Model/MessageGenerators/CaseRescore.php
+++ b/app/code/Magento/Signifyd/Model/MessageGenerators/CaseRescore.php
@@ -46,7 +46,7 @@ public function generate(array $data)
throw new MessageGeneratorException(__('The "%1" should not be empty.', 'caseId'));
}
- $caseEntity = $this->caseRepository->getByCaseId($data['caseId']));
+ $caseEntity = $this->caseRepository->getByCaseId($data['caseId']);
if ($caseEntity === null) {
throw new MessageGeneratorException(__('Case entity not found.'));
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/CaseUpdatingServiceFactoryTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/CaseUpdatingServiceFactoryTest.php
new file mode 100644
index 0000000000000..4c73756e39ac8
--- /dev/null
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/CaseUpdatingServiceFactoryTest.php
@@ -0,0 +1,167 @@
+config = $this->getMockBuilder(Config::class)
+ ->disableOriginalConstructor()
+ ->setMethods(['isActive'])
+ ->getMock();
+
+ $this->fakeObjectManager = $this->getMockBuilder(ObjectManagerInterface::class)
+ ->disableOriginalConstructor()
+ ->setMethods(['create'])
+ ->getMockForAbstractClass();
+
+ $this->generatorFactory = $this->getMockBuilder(GeneratorFactory::class)
+ ->disableOriginalConstructor()
+ ->setMethods(['create'])
+ ->getMock();
+
+ $objectManager = new ObjectManager($this);
+ $this->factory = $objectManager->getObject(CaseUpdatingServiceFactory::class, [
+ 'objectManager' => $this->fakeObjectManager,
+ 'generatorFactory' => $this->generatorFactory,
+ 'config' => $this->config
+ ]);
+ }
+
+ /**
+ * Checks type of instance for updating service if Signifyd is not enabled.
+ *
+ * @covers \Magento\Signifyd\Model\CaseUpdatingServiceFactory::create
+ */
+ public function testCreateWithInactiveConfig()
+ {
+ $type = 'cases/creation';
+ $this->config->expects(self::once())
+ ->method('isActive')
+ ->willReturn(false);
+
+ $this->fakeObjectManager->expects(self::once())
+ ->method('create')
+ ->with(StubCaseUpdatingService::class)
+ ->willReturn(new StubCaseUpdatingService());
+
+ $instance = $this->factory->create($type);
+ static::assertInstanceOf(StubCaseUpdatingService::class, $instance);
+ }
+
+ /**
+ * Checks type of instance for updating service if test type is received.
+ *
+ * @covers \Magento\Signifyd\Model\CaseUpdatingServiceFactory::create
+ */
+ public function testCreateWithTestType()
+ {
+ $type = 'cases/test';
+ $this->config->expects(self::once())
+ ->method('isActive')
+ ->willReturn(true);
+
+ $this->fakeObjectManager->expects(self::once())
+ ->method('create')
+ ->with(StubCaseUpdatingService::class)
+ ->willReturn(new StubCaseUpdatingService());
+
+ $instance = $this->factory->create($type);
+ static::assertInstanceOf(StubCaseUpdatingService::class, $instance);
+ }
+
+ /**
+ * Checks exception type and message for unknown case type.
+ *
+ * @covers \Magento\Signifyd\Model\CaseUpdatingServiceFactory::create
+ * @expectedException \InvalidArgumentException
+ * @expectedExceptionMessage Specified message type does not supported.
+ */
+ public function testCreateWithException()
+ {
+ $type = 'cases/unknown';
+ $this->config->expects(self::once())
+ ->method('isActive')
+ ->willReturn(true);
+
+ $this->generatorFactory->expects(self::once())
+ ->method('create')
+ ->with($type)
+ ->willThrowException(new \InvalidArgumentException('Specified message type does not supported.'));
+
+ $this->factory->create($type);
+ }
+
+ /**
+ * Checks if factory creates correct instance of case updating service.
+ *
+ * @covers \Magento\Signifyd\Model\CaseUpdatingServiceFactory::create
+ */
+ public function testCreate()
+ {
+ $type = 'case/creation';
+ $this->config->expects(self::once())
+ ->method('isActive')
+ ->willReturn(true);
+
+ $messageGenerator = $this->getMockBuilder(MessageGeneratorInterface::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->generatorFactory->expects(self::once())
+ ->method('create')
+ ->with($type)
+ ->willReturn($messageGenerator);
+
+ $service = $this->getMockBuilder(CaseUpdatingService::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->fakeObjectManager->expects(self::once())
+ ->method('create')
+ ->with(CaseUpdatingService::class, ['messageGenerator' => $messageGenerator])
+ ->willReturn($service);
+
+ $result = $this->factory->create($type);
+ static::assertInstanceOf(CaseUpdatingService::class, $result);
+ }
+}
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/CaseUpdatingServiceTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/CaseUpdatingServiceTest.php
new file mode 100644
index 0000000000000..6c72190b0f16c
--- /dev/null
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/CaseUpdatingServiceTest.php
@@ -0,0 +1,336 @@
+objectManager = new ObjectManager($this);
+
+ $this->messageGenerator = $this->getMockBuilder(MessageGeneratorInterface::class)
+ ->disableOriginalConstructor()
+ ->setMethods(['generate'])
+ ->getMock();
+
+ $this->caseRepository = $this->getMockBuilder(CaseRepositoryInterface::class)
+ ->disableOriginalConstructor()
+ ->setMethods(['getByCaseId'])
+ ->getMockForAbstractClass();
+
+ $this->caseDataValidator = $this->getMockBuilder(CaseDataValidator::class)
+ ->disableOriginalConstructor()
+ ->setMethods(['validate'])
+ ->getMock();
+
+ $this->commentsHistoryUpdater = $this->getMockBuilder(CommentsHistoryUpdater::class)
+ ->disableOriginalConstructor()
+ ->setMethods(['addComment'])
+ ->getMock();
+
+ $this->service = $this->objectManager->getObject(CaseUpdatingService::class, [
+ 'messageGenerator' => $this->messageGenerator,
+ 'caseRepository' => $this->caseRepository,
+ 'caseDataValidator' => $this->caseDataValidator,
+ 'commentsHistoryUpdater' => $this->commentsHistoryUpdater
+ ]);
+ }
+
+ /**
+ * Checks a test case when Signifyd case id is missed in input data.
+ *
+ * @covers \Magento\Signifyd\Model\CaseUpdatingService::update
+ * @expectedException \Magento\Framework\Exception\LocalizedException
+ * @expectedExceptionMessage The "caseId" should not be empty.
+ */
+ public function testUpdateWithFailedValidation()
+ {
+ $data = [];
+ $this->caseDataValidator->expects(self::once())
+ ->method('validate')
+ ->with($data)
+ ->willReturn(false);
+
+ $this->service->update($data);
+ }
+
+ /**
+ * Checks a test case when Signifyd case entity not found in repository.
+ *
+ * @covers \Magento\Signifyd\Model\CaseUpdatingService::update
+ * @expectedException \Magento\Framework\Exception\NotFoundException
+ * @expectedExceptionMessage Case entity not found.
+ */
+ public function testUpdateWithNotExistingCase()
+ {
+ $caseId = 123;
+ $data = [
+ 'caseId' => $caseId
+ ];
+
+ $this->caseDataValidator->expects(self::once())
+ ->method('validate')
+ ->with($data)
+ ->willReturn(true);
+
+ $this->caseRepository->expects(self::once())
+ ->method('getByCaseId')
+ ->with($caseId)
+ ->willReturn(null);
+
+ $this->service->update($data);
+ }
+
+ /**
+ * Checks as test case when service cannot save Signifyd case entity
+ *
+ * @covers \Magento\Signifyd\Model\CaseUpdatingService::update
+ * @expectedException \Magento\Framework\Exception\LocalizedException
+ * @expectedExceptionMessage Cannot update Case entity.
+ */
+ public function testUpdateWithFailedCaseSaving()
+ {
+ $caseId = 123;
+ $data = [
+ 'caseId' => $caseId,
+ 'status' => CaseInterface::STATUS_OPEN,
+ 'orderId' => '10000012',
+ 'score' => 500
+ ];
+
+ $this->caseDataValidator->expects(self::once())
+ ->method('validate')
+ ->with($data)
+ ->willReturn(true);
+
+ $caseEntity = $this->getMockBuilder(CaseInterface::class)
+ ->disableOriginalConstructor()
+ ->setMethods(['setCaseId', 'setStatus', 'setOrderId', 'setScore'])
+ ->getMockForAbstractClass();
+
+ $this->caseRepository->expects(self::once())
+ ->method('getByCaseId')
+ ->with($caseId)
+ ->willReturn($caseEntity);
+
+ $caseEntity->expects(self::never())
+ ->method('setOrderId');
+ $caseEntity->expects(self::once())
+ ->method('setCaseId')
+ ->with($caseId)
+ ->willReturnSelf();
+ $caseEntity->expects(self::once())
+ ->method('setStatus')
+ ->with(CaseInterface::STATUS_OPEN)
+ ->willReturnSelf();
+ $caseEntity->expects(self::once())
+ ->method('setScore')
+ ->with(500)
+ ->willReturnSelf();
+
+ $this->caseRepository->expects(self::once())
+ ->method('save')
+ ->willThrowException(new \Exception('Something wrong.'));
+
+ $this->service->update($data);
+ }
+
+ /**
+ * Checks as test case when message generator throws an exception
+ *
+ * @covers \Magento\Signifyd\Model\CaseUpdatingService::update
+ * @expectedException \Magento\Framework\Exception\LocalizedException
+ * @expectedExceptionMessage Cannot update Case entity.
+ */
+ public function testUpdateWithExceptionFromMessageGenerator()
+ {
+ $caseId = 123;
+ $data = [
+ 'caseId' => $caseId
+ ];
+
+ $this->caseDataValidator->expects(self::once())
+ ->method('validate')
+ ->with($data)
+ ->willReturn(true);
+
+ $caseEntity = $this->getMockBuilder(CaseInterface::class)
+ ->disableOriginalConstructor()
+ ->setMethods(['setCaseId'])
+ ->getMockForAbstractClass();
+
+ $this->caseRepository->expects(self::once())
+ ->method('getByCaseId')
+ ->with($caseId)
+ ->willReturn($caseEntity);
+
+ $caseEntity->expects(self::once())
+ ->method('setCaseId')
+ ->with($caseId)
+ ->willReturnSelf();
+
+ $this->caseRepository->expects(self::once())
+ ->method('save')
+ ->with($caseEntity)
+ ->willReturn($caseEntity);
+
+ $this->messageGenerator->expects(self::once())
+ ->method('generate')
+ ->with($data)
+ ->willThrowException(new MessageGeneratorException(__('Cannot generate message.')));
+
+ $this->service->update($data);
+ }
+
+ /**
+ * Checks a test case when comments history updater throws an exception.
+ *
+ * @covers \Magento\Signifyd\Model\CaseUpdatingService::update
+ * @expectedException \Magento\Framework\Exception\LocalizedException
+ * @expectedExceptionMessage Cannot update Case entity.
+ */
+ public function testUpdateWithFailedCommentSaving()
+ {
+ $caseId = 123;
+ $data = [
+ 'caseId' => $caseId
+ ];
+
+ $this->caseDataValidator->expects(self::once())
+ ->method('validate')
+ ->with($data)
+ ->willReturn(true);
+
+ $caseEntity = $this->getMockBuilder(CaseInterface::class)
+ ->disableOriginalConstructor()
+ ->setMethods(['setCaseId'])
+ ->getMockForAbstractClass();
+
+ $this->caseRepository->expects(self::once())
+ ->method('getByCaseId')
+ ->with($caseId)
+ ->willReturn($caseEntity);
+
+ $caseEntity->expects(self::once())
+ ->method('setCaseId')
+ ->with($caseId)
+ ->willReturnSelf();
+
+ $this->caseRepository->expects(self::once())
+ ->method('save')
+ ->with($caseEntity)
+ ->willReturn($caseEntity);
+
+ $message = __('Message is generated.');
+ $this->messageGenerator->expects(self::once())
+ ->method('generate')
+ ->with($data)
+ ->willReturn($message);
+
+ $this->commentsHistoryUpdater->expects(self::once())
+ ->method('addComment')
+ ->with($caseEntity, $message)
+ ->willThrowException(new \Exception('Something wrong'));
+
+ $this->service->update($data);
+ }
+
+ /**
+ * Checks a test case when Signifyd case entity is successfully updated and message stored in comments history.
+ *
+ * @covers \Magento\Signifyd\Model\CaseUpdatingService::update
+ */
+ public function testUpdate()
+ {
+ $caseId = 123;
+ $data = [
+ 'caseId' => $caseId
+ ];
+
+ $this->caseDataValidator->expects(self::once())
+ ->method('validate')
+ ->with($data)
+ ->willReturn(true);
+
+ $caseEntity = $this->getMockBuilder(CaseInterface::class)
+ ->disableOriginalConstructor()
+ ->setMethods(['setCaseId'])
+ ->getMockForAbstractClass();
+
+ $this->caseRepository->expects(self::once())
+ ->method('getByCaseId')
+ ->with($caseId)
+ ->willReturn($caseEntity);
+
+ $caseEntity->expects(self::once())
+ ->method('setCaseId')
+ ->with($caseId)
+ ->willReturnSelf();
+
+ $this->caseRepository->expects(self::once())
+ ->method('save')
+ ->with($caseEntity)
+ ->willReturn($caseEntity);
+
+ $message = __('Message is generated.');
+ $this->messageGenerator->expects(self::once())
+ ->method('generate')
+ ->with($data)
+ ->willReturn($message);
+
+ $this->commentsHistoryUpdater->expects(self::once())
+ ->method('addComment')
+ ->with($caseEntity, $message);
+
+ $this->service->update($data);
+ }
+}
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/CommentsHistoryUpdaterTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/CommentsHistoryUpdaterTest.php
new file mode 100644
index 0000000000000..e154fc32afa9a
--- /dev/null
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/CommentsHistoryUpdaterTest.php
@@ -0,0 +1,140 @@
+historyFactory = $this->getMockBuilder(HistoryFactory::class)
+ ->disableOriginalConstructor()
+ ->setMethods(['create'])
+ ->getMock();
+
+ $this->caseEntity = $this->getMockBuilder(CaseInterface::class)
+ ->disableOriginalConstructor()
+ ->setMethods(['getOrderId'])
+ ->getMockForAbstractClass();
+
+ $this->initCommentMock();
+
+ $this->updater = $objectManager->getObject(CommentsHistoryUpdater::class, [
+ 'historyFactory' => $this->historyFactory
+ ]);
+ }
+
+ /**
+ * Checks a test case when updater throws an exception while saving history comment.
+ *
+ * @covers \Magento\Signifyd\Model\CommentsHistoryUpdater::addComment
+ * @expectedException \Exception
+ */
+ public function testAddCommentWithException()
+ {
+ $this->caseEntity->expects(self::once())
+ ->method('getOrderId')
+ ->willReturn(self::$orderId);
+
+ $this->historyEntity->expects(self::once())
+ ->method('save')
+ ->willThrowException(new \Exception('Cannot save comment message.'));
+
+ $this->updater->addComment($this->caseEntity, __(self::$message));
+ }
+
+ /**
+ * Checks a test case when updater successfully saves history comment.
+ *
+ * @covers \Magento\Signifyd\Model\CommentsHistoryUpdater::addComment
+ */
+ public function testAddComment()
+ {
+ $this->caseEntity->expects(self::once())
+ ->method('getOrderId')
+ ->willReturn(self::$orderId);
+
+ $this->historyEntity->expects(self::once())
+ ->method('save')
+ ->willReturnSelf();
+
+ $this->updater->addComment($this->caseEntity, __(self::$message));
+ }
+
+ /**
+ * Creates mock object for history entity.
+ *
+ * @return void
+ */
+ private function initCommentMock()
+ {
+ $this->historyEntity = $this->getMockBuilder(OrderStatusHistoryInterface::class)
+ ->disableOriginalConstructor()
+ ->setMethods(['setParentId', 'setComment', 'setEntityName', 'save'])
+ ->getMockForAbstractClass();
+
+ $this->historyFactory->expects(self::once())
+ ->method('create')
+ ->willReturn($this->historyEntity);
+
+ $this->historyEntity->expects(self::once())
+ ->method('setParentId')
+ ->with(self::$orderId)
+ ->willReturnSelf();
+ $this->historyEntity->expects(self::once())
+ ->method('setComment')
+ ->with(self::$message)
+ ->willReturnSelf();
+ $this->historyEntity->expects(self::once())
+ ->method('setEntityName')
+ ->with('order')
+ ->willReturnSelf();
+ }
+}
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/GeneratorFactoryTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/GeneratorFactoryTest.php
new file mode 100644
index 0000000000000..c154b22fcab2a
--- /dev/null
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/GeneratorFactoryTest.php
@@ -0,0 +1,99 @@
+fakeObjectManager = $this->getMockBuilder(ObjectManagerInterface::class)
+ ->disableOriginalConstructor()
+ ->setMethods(['create'])
+ ->getMockForAbstractClass();
+
+ $this->factory = $objectManager->getObject(GeneratorFactory::class, [
+ 'objectManager' => $this->fakeObjectManager
+ ]);
+ }
+
+ /**
+ * Checks if factory returns correct instance of message generator.
+ *
+ * @covers \Magento\Signifyd\Model\MessageGenerators\GeneratorFactory::create
+ * @param string $type
+ * @param string $className
+ * @dataProvider typeDataProvider
+ */
+ public function testCreate($type, $className)
+ {
+ $generator = $this->getMockBuilder($className)
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->fakeObjectManager->expects(self::once())
+ ->method('create')
+ ->with($className)
+ ->willReturn($generator);
+
+ $instance = $this->factory->create($type);
+ static::assertInstanceOf($className, $instance);
+ }
+
+ /**
+ * Get list of available messages generators types and equal class names.
+ *
+ * @return array
+ */
+ public function typeDataProvider()
+ {
+ return [
+ ['cases/creation', CaseCreation::class],
+ ['cases/rescore', CaseRescore::class],
+ ['cases/review', CaseReview::class],
+ ['guarantees/completion', GuaranteeCompletion::class],
+ ];
+ }
+
+ /**
+ * Checks correct exception message for unknown type of message generator.
+ *
+ * @covers \Magento\Signifyd\Model\MessageGenerators\GeneratorFactory::create
+ * @expectedException \InvalidArgumentException
+ * @expectedExceptionMessage Specified message type does not supported.
+ */
+ public function testCreateWithException()
+ {
+ $type = 'cases/unknown';
+ $this->factory->create($type);
+ }
+}
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/SignifydOrderSessionIdTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/SignifydOrderSessionIdTest.php
index f8a36ef172dc5..2c1788ad288c2 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/SignifydOrderSessionIdTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/SignifydOrderSessionIdTest.php
@@ -1,6 +1,6 @@
identityGenerator->expects(static::once())
+ $this->identityGenerator->expects(self::once())
->method('generateIdForData')
->with($quoteId)
->willReturn($signifydOrderSessionId);
From 3c01a61fba4f8f27523fa6c3b077a4089f234b68 Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Fri, 6 Jan 2017 03:15:57 -0600
Subject: [PATCH 090/904] MAGETWO-62803: Signifyd webhook controller
- Add WebhookMessageReaderTest
---
.../Response/WebhookMessageReaderTest.php | 114 ++++++++++++++++++
1 file changed, 114 insertions(+)
create mode 100644 app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/Response/WebhookMessageReaderTest.php
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/Response/WebhookMessageReaderTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/Response/WebhookMessageReaderTest.php
new file mode 100644
index 0000000000000..03d13566e28c7
--- /dev/null
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/Response/WebhookMessageReaderTest.php
@@ -0,0 +1,114 @@
+decoder = $this->getMockBuilder(DecoderInterface::class)
+ ->getMockForAbstractClass();
+
+ $this->webhookMessageFactory = $this->getMockBuilder(WebhookMessageFactory::class)
+ ->setMethods(['create'])
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->webhookRequest = $this->getMockBuilder(WebhookRequest::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->model = new WebhookMessageReader(
+ $this->decoder,
+ $this->webhookMessageFactory
+ );
+ }
+
+ /**
+ * Tests successful reading webhook message from request.
+ *
+ */
+ public function testReadSuccess()
+ {
+ $rawBody = 'body';
+ $topic = 'topic';
+ $decodedData = ['status' => "DISMISSED", 'orderId' => '19418'];
+
+ $this->webhookRequest->expects($this->once())
+ ->method('getBody')
+ ->willReturn($rawBody);
+ $this->webhookRequest->expects($this->once())
+ ->method('getEventTopic')
+ ->willReturn('topic');
+ $this->decoder->expects($this->once())
+ ->method('decode')
+ ->with($rawBody)
+ ->willReturn($decodedData);
+ $webhookMessage = $this->getMockBuilder(WebhookMessage::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->webhookMessageFactory->expects($this->once())
+ ->method('create')
+ ->with(
+ [
+ 'data' => $decodedData,
+ 'eventTopic' => $topic
+ ]
+ )
+ ->willReturn($webhookMessage);
+
+ $this->assertEquals(
+ $webhookMessage,
+ $this->model->read($this->webhookRequest)
+ );
+ }
+
+ /**
+ * Tests reading failure webhook message from request.
+ *
+ * @expectedException \InvalidArgumentException
+ */
+ public function testReadFail()
+ {
+ $this->decoder->expects($this->once())
+ ->method('decode')
+ ->willThrowException(new \Exception('Error'));
+
+ $this->model->read($this->webhookRequest);
+ }
+}
From 1befdc3033973f6562d5bfb0ca48af75cb7a8e17 Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Fri, 6 Jan 2017 05:45:32 -0600
Subject: [PATCH 091/904] MAGETWO-62806: Update case entity
- Added possibility to store Signifyd case id on case entity creation
---
.../Signifyd/Model/CaseCreationService.php | 19 +++++++++++++++----
.../Model/CaseCreationServiceTest.php | 10 +++++++++-
2 files changed, 24 insertions(+), 5 deletions(-)
diff --git a/app/code/Magento/Signifyd/Model/CaseCreationService.php b/app/code/Magento/Signifyd/Model/CaseCreationService.php
index c544ab30d6b35..39414d8f84fc1 100644
--- a/app/code/Magento/Signifyd/Model/CaseCreationService.php
+++ b/app/code/Magento/Signifyd/Model/CaseCreationService.php
@@ -1,12 +1,13 @@
caseManagement = $caseManagement;
$this->signifydGateway = $signifydGateway;
$this->logger = $logger;
+ $this->caseRepository = $caseRepository;
}
/**
@@ -56,10 +65,12 @@ public function __construct(
*/
public function createForOrder($orderId)
{
- $this->caseManagement->create($orderId);
+ $case = $this->caseManagement->create($orderId);
try {
- $this->signifydGateway->createCase($orderId);
+ $caseId = $this->signifydGateway->createCase($orderId);
+ $case->setCaseId($caseId);
+ $this->caseRepository->save($case);
} catch (ApiCallException $e) {
$this->logger->error($e->getMessage());
} catch (GatewayException $e) {
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseCreationServiceTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseCreationServiceTest.php
index effee790eaa2a..fc4841c5388f8 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseCreationServiceTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseCreationServiceTest.php
@@ -1,6 +1,6 @@
service->createForOrder($order->getEntityId());
static::assertTrue($result);
+
+ /** @var CaseRepositoryInterface $caseRepository */
+ $caseRepository = $this->objectManager->get(CaseRepositoryInterface::class);
+ $caseEntity = $caseRepository->getByCaseId(123123);
+
+ static::assertNotEmpty($caseEntity);
+ static::assertEquals($order->getEntityId(), $caseEntity->getOrderId());
}
/**
From 04588c9fe1bd001f26539453121d8e6385511b31 Mon Sep 17 00:00:00 2001
From: isavchuk
Date: Fri, 6 Jan 2017 05:49:37 -0600
Subject: [PATCH 092/904] MAGETWO-62806: Update case entity
- Added tests for MessageGenerators
---
.../MessageGenerators/CaseCreationTest.php | 75 +++++++++
.../MessageGenerators/CaseRescoreTest.php | 151 ++++++++++++++++++
.../MessageGenerators/CaseReviewTest.php | 67 ++++++++
.../GuaranteeCompletionTest.php | 64 ++++++++
4 files changed, 357 insertions(+)
create mode 100644 app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseCreationTest.php
create mode 100644 app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseRescoreTest.php
create mode 100644 app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseReviewTest.php
create mode 100644 app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/GuaranteeCompletionTest.php
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseCreationTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseCreationTest.php
new file mode 100644
index 0000000000000..91b542fc5dff5
--- /dev/null
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseCreationTest.php
@@ -0,0 +1,75 @@
+ 100];
+
+ /**
+ * @var ObjectManager
+ */
+ private $objectManager;
+
+ /**
+ * @var CaseCreation
+ */
+ private $caseCreation;
+
+ /**
+ * @inheritdoc
+ */
+ protected function setUp()
+ {
+ $this->objectManager = new ObjectManager($this);
+
+ $this->caseCreation = $this->objectManager->getObject(CaseCreation::class, [
+ 'caseDataValidator' => new CaseDataValidator()
+ ]);
+ }
+
+ /**
+ * Parameter without required attribute caseId.
+ *
+ * @expectedException \Magento\Signifyd\Model\MessageGeneratorException
+ * @expectedExceptionMessage The "caseId" should not be empty
+ */
+ public function testGenerateException()
+ {
+ $this->caseCreation->generate([]);
+ }
+
+ /**
+ * Checks interface generated message.
+ */
+ public function testGenerateMessageInterface()
+ {
+ $message = $this->caseCreation->generate(self::$data);
+
+ $this->assertInstanceOf(\Magento\Framework\Phrase::class, $message);
+ }
+
+ /**
+ * Generates case creation message for created Signifyd properly.
+ */
+ public function testGenerate()
+ {
+ $message = $this->caseCreation->generate(self::$data);
+
+ $phrase = __('Signifyd Case %1 has been created for order.', self::$data['caseId']);
+
+ $this->assertEquals($phrase, $message);
+ }
+}
\ No newline at end of file
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseRescoreTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseRescoreTest.php
new file mode 100644
index 0000000000000..0d230544ee190
--- /dev/null
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseRescoreTest.php
@@ -0,0 +1,151 @@
+ 100,
+ 'score' => 200
+ ];
+
+ /**
+ * @var ObjectManager
+ */
+ private $objectManager;
+
+ /**
+ * @var CaseRepository|MockObject
+ */
+ private $caseRepository;
+
+ /**
+ * @var CaseRescore|MocObject
+ */
+ private $CaseRescore;
+
+ /**
+ * @var Case|MockObject
+ */
+ private $case;
+
+ /**
+ * @inheritdoc
+ */
+ protected function setUp()
+ {
+ $this->case = $this->getMockBuilder(CaseInterface::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->objectManager = new ObjectManager($this);
+ $this->caseRepository = $this->getMockBuilder(CaseRepositoryInterface::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->CaseRescore = $this->objectManager->getObject(CaseRescore::class, [
+ 'caseDataValidator' => new CaseDataValidator(),
+ 'caseRepository' => $this->caseRepository
+ ]);
+
+ }
+
+ /**
+ * Data array without required attribute caseId.
+ *
+ * @expectedException \Magento\Signifyd\Model\MessageGeneratorException
+ * @expectedExceptionMessage The "caseId" should not be empty
+ */
+ public function testGenerateEmptyCaseIdException()
+ {
+ $this->CaseRescore->generate([]);
+ }
+
+ /**
+ * Case entity was not found in DB.
+ *
+ * @expectedException \Magento\Signifyd\Model\MessageGeneratorException
+ * @expectedExceptionMessage Case entity not found.
+ */
+ public function testGenerateNotFoundException()
+ {
+ $this->caseRepository->expects($this->once())
+ ->method('getByCaseId')
+ ->with(self::$data['caseId'])
+ ->willReturn(null);
+
+ $this->CaseRescore = $this->objectManager->getObject(CaseRescore::class, [
+ 'caseDataValidator' => new CaseDataValidator(),
+ 'caseRepository' => $this->caseRepository
+ ]);
+
+ $this->CaseRescore->generate(self::$data);
+ }
+
+ /**
+ * Generate case message with not empty previous score.
+ */
+ public function testGenerateWithPreviousScore()
+ {
+ $this->case->expects($this->once())
+ ->method('getScore')
+ ->willReturn(self::$data['score']);
+
+ $this->caseRepository->expects($this->once())
+ ->method('getByCaseId')
+ ->with(self::$data['caseId'])
+ ->willReturn($this->case);
+
+ $this->CaseRescore = $this->objectManager->getObject(CaseRescore::class, [
+ 'caseDataValidator' => new CaseDataValidator(),
+ 'caseRepository' => $this->caseRepository
+ ]);
+
+ $phrase = __(
+ 'Case Update: New score for the order is %1. Previous score was %2.',
+ self::$data['score'],
+ self::$data['score']);
+
+ $message = $this->CaseRescore->generate(self::$data);
+
+ $this->assertEquals($phrase, $message);
+ }
+
+ /**
+ * Generate case message with empty previous score.
+ */
+ public function testGenerateWithoutPreviousScore()
+ {
+ $this->caseRepository->expects($this->once())
+ ->method('getByCaseId')
+ ->with(self::$data['caseId'])
+ ->willReturn($this->case);
+
+ $this->CaseRescore = $this->objectManager->getObject(CaseRescore::class, [
+ 'caseDataValidator' => new CaseDataValidator(),
+ 'caseRepository' => $this->caseRepository
+ ]);
+
+ $phrase = __(
+ 'Case Update: New score for the order is %1. Previous score was %2.',
+ self::$data['score'],
+ null);
+
+ $message = $this->CaseRescore->generate(self::$data);
+
+ $this->assertEquals($phrase, $message);
+ }
+}
\ No newline at end of file
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseReviewTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseReviewTest.php
new file mode 100644
index 0000000000000..f27676be8d534
--- /dev/null
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseReviewTest.php
@@ -0,0 +1,67 @@
+ 100];
+
+ /**
+ * @var CaseReview
+ */
+ private $caseReview;
+
+ /**
+ * @inheritdoc
+ */
+ protected function setUp()
+ {
+ $this->caseReview = new CaseReview();
+ }
+
+ /**
+ * Parameter without required attribute reviewDisposition.
+ *
+ * @expectedException \Magento\Signifyd\Model\MessageGeneratorException
+ * @expectedExceptionMessage The "reviewDisposition" should not be empty
+ */
+ public function testGenerateException()
+ {
+ $this->caseReview->generate([]);
+ }
+
+ /**
+ * Checks interface generated message.
+ */
+ public function testGenerateMessageInterface()
+ {
+ $message = $this->caseReview->generate(self::$data);
+
+ $this->assertInstanceOf(\Magento\Framework\Phrase::class, $message);
+ }
+
+ /**
+ * Generates Case Review message for created Signifyd properly.
+ */
+ public function testGenerate()
+ {
+ $message = $this->caseReview->generate(self::$data);
+
+ $phrase = __(
+ 'Case Update: Case Review was completed. Review Deposition is %1.',
+ __(self::$data['reviewDisposition'])
+ );
+
+ $this->assertEquals($phrase, $message);
+ }
+}
\ No newline at end of file
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/GuaranteeCompletionTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/GuaranteeCompletionTest.php
new file mode 100644
index 0000000000000..7e95d10bc3c6a
--- /dev/null
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/GuaranteeCompletionTest.php
@@ -0,0 +1,64 @@
+ 100];
+
+ /**
+ * @var GuaranteeCompletion
+ */
+ private $guaranteeCompletion;
+
+ /**
+ * @inheritdoc
+ */
+ protected function setUp()
+ {
+ $this->guaranteeCompletion = new GuaranteeCompletion();
+ }
+
+ /**
+ * Parameter without required attribute guaranteeDisposition.
+ *
+ * @expectedException \Magento\Signifyd\Model\MessageGeneratorException
+ * @expectedExceptionMessage The "guaranteeDisposition" should not be empty
+ */
+ public function testGenerateException()
+ {
+ $this->guaranteeCompletion->generate([]);
+ }
+
+ /**
+ * Checks interface generated Guarantee Completion message.
+ */
+ public function testGenerateMessageInterface()
+ {
+ $message = $this->guaranteeCompletion->generate(self::$data);
+
+ $this->assertInstanceOf(\Magento\Framework\Phrase::class, $message);
+ }
+
+ /**
+ * Generates Guarantee Completion message for created Signifyd properly.
+ */
+ public function testGenerate()
+ {
+ $message = $this->guaranteeCompletion->generate(self::$data);
+
+ $phrase = __('Case Update: Guarantee Disposition is %1.', __(self::$data['guaranteeDisposition']));
+
+ $this->assertEquals($phrase, $message);
+ }
+}
\ No newline at end of file
From 68a8ff2fff19a54ddd5512505ebe7f564aeb70ac Mon Sep 17 00:00:00 2001
From: isavchuk
Date: Fri, 6 Jan 2017 06:24:10 -0600
Subject: [PATCH 093/904] MAGETWO-62806: Update case entity
- Fixed code styling
---
.../MessageGenerators/CaseCreationTest.php | 2 +-
.../MessageGenerators/CaseRescoreTest.php | 26 ++++++++++---------
.../MessageGenerators/CaseReviewTest.php | 2 +-
.../GuaranteeCompletionTest.php | 2 +-
4 files changed, 17 insertions(+), 15 deletions(-)
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseCreationTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseCreationTest.php
index 91b542fc5dff5..639ffdf8c458c 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseCreationTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseCreationTest.php
@@ -72,4 +72,4 @@ public function testGenerate()
$this->assertEquals($phrase, $message);
}
-}
\ No newline at end of file
+}
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseRescoreTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseRescoreTest.php
index 0d230544ee190..1662d830289d3 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseRescoreTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseRescoreTest.php
@@ -36,7 +36,7 @@ class CaseRescoreTest extends \PHPUnit_Framework_TestCase
/**
* @var CaseRescore|MocObject
*/
- private $CaseRescore;
+ private $caseRescore;
/**
* @var Case|MockObject
@@ -56,7 +56,7 @@ protected function setUp()
->disableOriginalConstructor()
->getMock();
- $this->CaseRescore = $this->objectManager->getObject(CaseRescore::class, [
+ $this->caseRescore = $this->objectManager->getObject(CaseRescore::class, [
'caseDataValidator' => new CaseDataValidator(),
'caseRepository' => $this->caseRepository
]);
@@ -71,7 +71,7 @@ protected function setUp()
*/
public function testGenerateEmptyCaseIdException()
{
- $this->CaseRescore->generate([]);
+ $this->caseRescore->generate([]);
}
/**
@@ -87,12 +87,12 @@ public function testGenerateNotFoundException()
->with(self::$data['caseId'])
->willReturn(null);
- $this->CaseRescore = $this->objectManager->getObject(CaseRescore::class, [
+ $this->caseRescore = $this->objectManager->getObject(CaseRescore::class, [
'caseDataValidator' => new CaseDataValidator(),
'caseRepository' => $this->caseRepository
]);
- $this->CaseRescore->generate(self::$data);
+ $this->caseRescore->generate(self::$data);
}
/**
@@ -109,7 +109,7 @@ public function testGenerateWithPreviousScore()
->with(self::$data['caseId'])
->willReturn($this->case);
- $this->CaseRescore = $this->objectManager->getObject(CaseRescore::class, [
+ $this->caseRescore = $this->objectManager->getObject(CaseRescore::class, [
'caseDataValidator' => new CaseDataValidator(),
'caseRepository' => $this->caseRepository
]);
@@ -117,9 +117,10 @@ public function testGenerateWithPreviousScore()
$phrase = __(
'Case Update: New score for the order is %1. Previous score was %2.',
self::$data['score'],
- self::$data['score']);
+ self::$data['score']
+ );
- $message = $this->CaseRescore->generate(self::$data);
+ $message = $this->caseRescore->generate(self::$data);
$this->assertEquals($phrase, $message);
}
@@ -134,7 +135,7 @@ public function testGenerateWithoutPreviousScore()
->with(self::$data['caseId'])
->willReturn($this->case);
- $this->CaseRescore = $this->objectManager->getObject(CaseRescore::class, [
+ $this->caseRescore = $this->objectManager->getObject(CaseRescore::class, [
'caseDataValidator' => new CaseDataValidator(),
'caseRepository' => $this->caseRepository
]);
@@ -142,10 +143,11 @@ public function testGenerateWithoutPreviousScore()
$phrase = __(
'Case Update: New score for the order is %1. Previous score was %2.',
self::$data['score'],
- null);
+ null
+ );
- $message = $this->CaseRescore->generate(self::$data);
+ $message = $this->caseRescore->generate(self::$data);
$this->assertEquals($phrase, $message);
}
-}
\ No newline at end of file
+}
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseReviewTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseReviewTest.php
index f27676be8d534..700a5de134bac 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseReviewTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseReviewTest.php
@@ -64,4 +64,4 @@ public function testGenerate()
$this->assertEquals($phrase, $message);
}
-}
\ No newline at end of file
+}
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/GuaranteeCompletionTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/GuaranteeCompletionTest.php
index 7e95d10bc3c6a..250ce1a7553a4 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/GuaranteeCompletionTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/GuaranteeCompletionTest.php
@@ -61,4 +61,4 @@ public function testGenerate()
$this->assertEquals($phrase, $message);
}
-}
\ No newline at end of file
+}
From dce616bc4757d02cea4d8bdd92447df73cf63bca Mon Sep 17 00:00:00 2001
From: isavchuk
Date: Fri, 6 Jan 2017 07:40:24 -0600
Subject: [PATCH 094/904] MAGETWO-62806: Update case entity
- Code refactoring
- Fixed PHPDoc blocks
---
.../MessageGenerators/CaseCreationTest.php | 14 +++++--
.../MessageGenerators/CaseRescoreTest.php | 37 ++++++++++---------
.../MessageGenerators/CaseReviewTest.php | 14 +++++--
.../GuaranteeCompletionTest.php | 14 +++++--
4 files changed, 49 insertions(+), 30 deletions(-)
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseCreationTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseCreationTest.php
index 639ffdf8c458c..a268dacd57dd2 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseCreationTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseCreationTest.php
@@ -8,6 +8,7 @@
use Magento\Signifyd\Model\MessageGenerators\CaseCreation;
use Magento\Signifyd\Model\Validators\CaseDataValidator;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use Magento\Framework\Phrase;
/**
* Tests for Signifyd CaseCreation message generator.
@@ -53,21 +54,26 @@ public function testGenerateException()
/**
* Checks interface generated message.
+ *
+ * @return Phrase
*/
public function testGenerateMessageInterface()
{
$message = $this->caseCreation->generate(self::$data);
- $this->assertInstanceOf(\Magento\Framework\Phrase::class, $message);
+ $this->assertInstanceOf(Phrase::class, $message);
+
+ return $message;
}
/**
* Generates case creation message for created Signifyd properly.
+ *
+ * @depends testGenerateMessageInterface
+ * @param Phrase $message
*/
- public function testGenerate()
+ public function testGenerate(Phrase $message)
{
- $message = $this->caseCreation->generate(self::$data);
-
$phrase = __('Signifyd Case %1 has been created for order.', self::$data['caseId']);
$this->assertEquals($phrase, $message);
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseRescoreTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseRescoreTest.php
index 1662d830289d3..a18927b811f3c 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseRescoreTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseRescoreTest.php
@@ -10,6 +10,7 @@
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
use Magento\Signifyd\Api\CaseRepositoryInterface;
use Magento\Signifyd\Api\Data\CaseInterface;
+use PHPUnit_Framework_MockObject_MockObject as MockObject;
/**
* Tests for Signifyd CaseRescore message generator.
@@ -29,17 +30,17 @@ class CaseRescoreTest extends \PHPUnit_Framework_TestCase
private $objectManager;
/**
- * @var CaseRepository|MockObject
+ * @var CaseRepositoryInterface|MockObject
*/
private $caseRepository;
/**
- * @var CaseRescore|MocObject
+ * @var CaseRescore|MockObject
*/
private $caseRescore;
/**
- * @var Case|MockObject
+ * @var CaseInterface|MockObject
*/
private $case;
@@ -49,12 +50,12 @@ class CaseRescoreTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
$this->case = $this->getMockBuilder(CaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ ->disableOriginalConstructor()
+ ->getMock();
$this->objectManager = new ObjectManager($this);
$this->caseRepository = $this->getMockBuilder(CaseRepositoryInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ ->disableOriginalConstructor()
+ ->getMock();
$this->caseRescore = $this->objectManager->getObject(CaseRescore::class, [
'caseDataValidator' => new CaseDataValidator(),
@@ -83,9 +84,9 @@ public function testGenerateEmptyCaseIdException()
public function testGenerateNotFoundException()
{
$this->caseRepository->expects($this->once())
- ->method('getByCaseId')
- ->with(self::$data['caseId'])
- ->willReturn(null);
+ ->method('getByCaseId')
+ ->with(self::$data['caseId'])
+ ->willReturn(null);
$this->caseRescore = $this->objectManager->getObject(CaseRescore::class, [
'caseDataValidator' => new CaseDataValidator(),
@@ -101,13 +102,13 @@ public function testGenerateNotFoundException()
public function testGenerateWithPreviousScore()
{
$this->case->expects($this->once())
- ->method('getScore')
- ->willReturn(self::$data['score']);
+ ->method('getScore')
+ ->willReturn(self::$data['score']);
$this->caseRepository->expects($this->once())
- ->method('getByCaseId')
- ->with(self::$data['caseId'])
- ->willReturn($this->case);
+ ->method('getByCaseId')
+ ->with(self::$data['caseId'])
+ ->willReturn($this->case);
$this->caseRescore = $this->objectManager->getObject(CaseRescore::class, [
'caseDataValidator' => new CaseDataValidator(),
@@ -131,9 +132,9 @@ public function testGenerateWithPreviousScore()
public function testGenerateWithoutPreviousScore()
{
$this->caseRepository->expects($this->once())
- ->method('getByCaseId')
- ->with(self::$data['caseId'])
- ->willReturn($this->case);
+ ->method('getByCaseId')
+ ->with(self::$data['caseId'])
+ ->willReturn($this->case);
$this->caseRescore = $this->objectManager->getObject(CaseRescore::class, [
'caseDataValidator' => new CaseDataValidator(),
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseReviewTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseReviewTest.php
index 700a5de134bac..4bbf45aa77d5f 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseReviewTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseReviewTest.php
@@ -6,6 +6,7 @@
namespace Magento\Signifyd\Test\Unit\Model\MessageGenerators;
use Magento\Signifyd\Model\MessageGenerators\CaseReview;
+use \Magento\Framework\Phrase;
/**
* Tests for Signifyd CaseReview message generator.
@@ -42,21 +43,26 @@ public function testGenerateException()
/**
* Checks interface generated message.
+ *
+ * @return \Magento\Framework\Phrase
*/
public function testGenerateMessageInterface()
{
$message = $this->caseReview->generate(self::$data);
- $this->assertInstanceOf(\Magento\Framework\Phrase::class, $message);
+ $this->assertInstanceOf(Phrase::class, $message);
+
+ return $message;
}
/**
* Generates Case Review message for created Signifyd properly.
+ *
+ * @depends testGenerateMessageInterface
+ * @param Phrase $message
*/
- public function testGenerate()
+ public function testGenerate(Phrase $message)
{
- $message = $this->caseReview->generate(self::$data);
-
$phrase = __(
'Case Update: Case Review was completed. Review Deposition is %1.',
__(self::$data['reviewDisposition'])
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/GuaranteeCompletionTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/GuaranteeCompletionTest.php
index 250ce1a7553a4..801d455b4f076 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/GuaranteeCompletionTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/GuaranteeCompletionTest.php
@@ -6,6 +6,7 @@
namespace Magento\Signifyd\Test\Unit\Model\MessageGenerators;
use Magento\Signifyd\Model\MessageGenerators\GuaranteeCompletion;
+use \Magento\Framework\Phrase;
/**
* Tests for Signifyd GuaranteeCompletion message generator.
@@ -42,21 +43,26 @@ public function testGenerateException()
/**
* Checks interface generated Guarantee Completion message.
+ *
+ * @return Phrase
*/
public function testGenerateMessageInterface()
{
$message = $this->guaranteeCompletion->generate(self::$data);
- $this->assertInstanceOf(\Magento\Framework\Phrase::class, $message);
+ $this->assertInstanceOf(Phrase::class, $message);
+
+ return $message;
}
/**
* Generates Guarantee Completion message for created Signifyd properly.
+ *
+ * @depends testGenerateMessageInterface
+ * @param Phrase $message
*/
- public function testGenerate()
+ public function testGenerate(Phrase $message)
{
- $message = $this->guaranteeCompletion->generate(self::$data);
-
$phrase = __('Case Update: Guarantee Disposition is %1.', __(self::$data['guaranteeDisposition']));
$this->assertEquals($phrase, $message);
From 07de30ae4416703134ba2fcc4b5058115a0e56ec Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Fri, 6 Jan 2017 08:33:13 -0600
Subject: [PATCH 095/904] MAGETWO-62807: Case information block on order
details page in admin panel
---
.../Signifyd/Block/Adminhtml/CaseInfo.php | 157 ++++++++++++++++++
.../adminhtml/layout/sales_order_view.xml | 14 ++
.../view/adminhtml/templates/case_info.phtml | 54 ++++++
3 files changed, 225 insertions(+)
create mode 100644 app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php
create mode 100644 app/code/Magento/Signifyd/view/adminhtml/layout/sales_order_view.xml
create mode 100644 app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml
diff --git a/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php b/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php
new file mode 100644
index 0000000000000..f2d29cd70170f
--- /dev/null
+++ b/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php
@@ -0,0 +1,157 @@
+config = $config;
+ $this->caseManagement = $caseManagement;
+
+ parent::__construct($context, $registry, $adminHelper, $data);
+ }
+
+ /**
+ * Retrieve required options from parent
+ *
+ * @throws \Magento\Framework\Exception\LocalizedException
+ * @return void
+ */
+ protected function _beforeToHtml()
+ {
+ if (!$this->getParentBlock()) {
+ throw new \Magento\Framework\Exception\LocalizedException(
+ __('Please correct the parent block for this block.')
+ );
+ }
+ $this->setOrder($this->getParentBlock()->getOrder());
+
+ foreach ($this->getParentBlock()->getOrderInfoData() as $key => $value) {
+ $this->setDataUsingMethod($key, $value);
+ }
+
+ parent::_beforeToHtml();
+ }
+
+ /**
+ * Checks if module is enabled.
+ *
+ * @return boolean
+ */
+ public function isModuleActive()
+ {
+ return $this->config->isActive();
+ }
+
+ /**
+ * Gets Case entity associated with order id.
+ *
+ * @return CaseInterface|null
+ */
+ public function getCaseEntity()
+ {
+ return $this->caseManagement->getByOrderId(
+ $this->getOrder()->getEntityId()
+ );
+ }
+
+ /**
+ * Gets state of case guarantee eligible.
+ *
+ * @param CaseInterface $caseEntity
+ * @return \Magento\Framework\Phrase
+ */
+ public function getGuaranteeEligible(CaseInterface $caseEntity) {
+ return $caseEntity->isGuaranteeEligible() ? __('Yes') : __('No');
+ }
+
+ /**
+ * Gets state of case guarantee eligible.
+ *
+ * @param CaseInterface $caseEntity
+ * @return string
+ */
+ public function getAssociatedTeam(CaseInterface $caseEntity) {
+
+ $result = 'unknown';
+ $team = $caseEntity->getAssociatedTeam();
+ if (isset($team['teamName'])) {
+ $result = $team['teamName'];
+ }
+
+ return $result;
+ }
+
+ /**
+ * Returns cell class name according to case score value.
+ * It could be used by merchant to customize order view skin.
+ *
+ * @param CaseInterface $caseEntity
+ * @return string
+ */
+ public function getScoreClass(CaseInterface $caseEntity)
+ {
+ $score = $caseEntity->getScore();
+
+ if (self::$scoreAccept <= $score) {
+ $result = 'green';
+ } elseif ($score <= self::$scoreDecline) {
+ $result = 'red';
+ } else {
+ $result = 'yellow';
+ }
+
+ return $result;
+ }
+}
diff --git a/app/code/Magento/Signifyd/view/adminhtml/layout/sales_order_view.xml b/app/code/Magento/Signifyd/view/adminhtml/layout/sales_order_view.xml
new file mode 100644
index 0000000000000..2e1b692b009f4
--- /dev/null
+++ b/app/code/Magento/Signifyd/view/adminhtml/layout/sales_order_view.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml b/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml
new file mode 100644
index 0000000000000..90327fcfeb64f
--- /dev/null
+++ b/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml
@@ -0,0 +1,54 @@
+
+
+isModuleActive()) {
+ return '';
+ }
+
+ $case = $block->getCaseEntity();
+?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ escapeHtml($case->getStatus()); ?>
+ escapeHtml($case->getScore()); ?>
+ escapeHtml($block->getGuaranteeEligible($case)); ?>
+ escapeHtml($case->getGuaranteeDisposition()); ?>
+ escapeHtml($block->getAssociatedTeam($case)); ?>
+ escapeHtml($case->getReviewDisposition()); ?>
+ escapeHtml($case->getCreatedAt()); ?>
+ escapeHtml($case->getUpdatedAt()); ?>
+
+
+
+
+
+
+
+
+
From 53668bee934008b67835ca506588bd0e5c37e04d Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Fri, 6 Jan 2017 10:15:02 -0600
Subject: [PATCH 096/904] MAGETWO-62809: Controller integration tests
- Added integration test for webhook controller
- Generation message for order comment history moved before saving case entity
---
.../Signifyd/Controller/Webhooks/Handler.php | 2 +-
.../Signifyd/Model/CaseUpdatingService.php | 6 +-
.../Unit/Controller/Webhooks/HandlerTest.php | 3 +-
.../Unit/Model/CaseUpdatingServiceTest.php | 2 +-
.../Controller/Webhooks/HandlerTest.php | 95 +++++++++++++++++++
.../Magento/Signifyd/_files/webhook_body.json | 1 +
6 files changed, 101 insertions(+), 8 deletions(-)
create mode 100644 dev/tests/integration/testsuite/Magento/Signifyd/Controller/Webhooks/HandlerTest.php
create mode 100644 dev/tests/integration/testsuite/Magento/Signifyd/_files/webhook_body.json
diff --git a/app/code/Magento/Signifyd/Controller/Webhooks/Handler.php b/app/code/Magento/Signifyd/Controller/Webhooks/Handler.php
index 346e41c8fb12f..b513bb328db65 100644
--- a/app/code/Magento/Signifyd/Controller/Webhooks/Handler.php
+++ b/app/code/Magento/Signifyd/Controller/Webhooks/Handler.php
@@ -89,7 +89,7 @@ public function execute()
$caseUpdatingService->update($webhookMessage->getData());
} catch (LocalizedException $e) {
$this->getResponse()->setHttpResponseCode(400);
- $this->logger->error($e->getMessage());
+ $this->logger->critical($e);
}
}
}
diff --git a/app/code/Magento/Signifyd/Model/CaseUpdatingService.php b/app/code/Magento/Signifyd/Model/CaseUpdatingService.php
index 90364ea541582..996b8e144c122 100644
--- a/app/code/Magento/Signifyd/Model/CaseUpdatingService.php
+++ b/app/code/Magento/Signifyd/Model/CaseUpdatingService.php
@@ -77,11 +77,9 @@ public function update(array $data)
try {
$this->prepareCaseData($case, $data);
+ $orderHistoryComment = $this->messageGenerator->generate($data);
$this->caseRepository->save($case);
-
- // add comment to order history
- $message = $this->messageGenerator->generate($data);
- $this->commentsHistoryUpdater->addComment($case, $message);
+ $this->commentsHistoryUpdater->addComment($case, $orderHistoryComment);
} catch (\Exception $e) {
throw new LocalizedException(__('Cannot update Case entity.'), $e);
}
diff --git a/app/code/Magento/Signifyd/Test/Unit/Controller/Webhooks/HandlerTest.php b/app/code/Magento/Signifyd/Test/Unit/Controller/Webhooks/HandlerTest.php
index 8fcec8433f87a..b9b29ae0766fa 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Controller/Webhooks/HandlerTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Controller/Webhooks/HandlerTest.php
@@ -201,8 +201,7 @@ public function testExecuteCaseUpdatingServiceException()
->method('setHttpResponseCode')
->with(400);
$this->logger->expects($this->once())
- ->method('error')
- ->with(__('Error'));
+ ->method('critical');
$this->controller->execute();
}
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/CaseUpdatingServiceTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/CaseUpdatingServiceTest.php
index 6c72190b0f16c..49d5fb676a71b 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/CaseUpdatingServiceTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/CaseUpdatingServiceTest.php
@@ -218,7 +218,7 @@ public function testUpdateWithExceptionFromMessageGenerator()
->with($caseId)
->willReturnSelf();
- $this->caseRepository->expects(self::once())
+ $this->caseRepository->expects(self::never())
->method('save')
->with($caseEntity)
->willReturn($caseEntity);
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Controller/Webhooks/HandlerTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Controller/Webhooks/HandlerTest.php
new file mode 100644
index 0000000000000..49e9ee0296f79
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Controller/Webhooks/HandlerTest.php
@@ -0,0 +1,95 @@
+getWebhookRequest();
+ $this->_objectManager->addSharedInstance($webhookRequest, WebhookRequest::class);
+
+ $this->dispatch(self::$entryPoint);
+
+ /** @var CaseRepositoryInterface $caseManagement */
+ $caseRepository = $this->_objectManager->get(CaseRepositoryInterface::class);
+ /** @var CaseInterface $caseEntity */
+ $caseEntity = $caseRepository->getByCaseId($caseId);
+ $orderEntityId = $caseEntity->getOrderId();
+
+ static::assertNotEmpty($caseEntity);
+ static::assertEquals('2017-01-06 12:47:03', $caseEntity->getCreatedAt());
+ static::assertEquals('2017-01-06 12:47:03', $caseEntity->getUpdatedAt());
+ static::assertEquals(CaseInterface::GUARANTEE_PENDING, $caseEntity->getGuaranteeDisposition());
+ static::assertEquals('Magento', $caseEntity->getAssociatedTeam()['teamName']);
+ static::assertEquals(true, $caseEntity->isGuaranteeEligible());
+ static::assertEquals(CaseInterface::STATUS_OPEN, $caseEntity->getStatus());
+ static::assertEquals($orderEntityId, $caseEntity->getOrderId());
+
+ /** @var OrderRepositoryInterface $orderRepository */
+ $orderRepository = $this->_objectManager->get(OrderRepositoryInterface::class);
+ $order = $orderRepository->get($caseEntity->getOrderId());
+ $histories = $order->getStatusHistories();
+ static::assertNotEmpty($histories);
+
+ /** @var OrderStatusHistoryInterface $caseCreationComment */
+ $caseComment = array_pop($histories);
+ static::assertInstanceOf(OrderStatusHistoryInterface::class, $caseComment);
+
+ static::assertEquals(
+ "Case Update: New score for the order is 384. Previous score was 553.",
+ $caseComment->getComment()
+ );
+ }
+
+ /**
+ * Returns mocked WebhookRequest
+ *
+ * @return WebhookRequest|\PHPUnit_Framework_MockObject_MockObject
+ */
+ private function getWebhookRequest()
+ {
+ $webhookRequest = $this->getMockBuilder(WebhookRequest::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+ $webhookRequest->expects($this->any())
+ ->method('getBody')
+ ->willReturn(file_get_contents(__DIR__ . '/../../_files/webhook_body.json'));
+ $webhookRequest->expects($this->any())
+ ->method('getEventTopic')
+ ->willReturn('cases/rescore');
+ $webhookRequest->expects($this->any())
+ ->method('getHash')
+ ->willReturn('m/X29RcHWPSCDPgQuSXjnyTfKISJDopcdGbVsRLeqy8=');
+
+ return $webhookRequest;
+ }
+}
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/_files/webhook_body.json b/dev/tests/integration/testsuite/Magento/Signifyd/_files/webhook_body.json
new file mode 100644
index 0000000000000..4308c8bf833ef
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/_files/webhook_body.json
@@ -0,0 +1 @@
+{"investigationId":123,"analysisUrl":"https://signifyd.com/v2/cases/185088720/analysis","entriesUrl":"https://signifyd.com/v2/cases/185088720/entries","notesUrl":"https://signifyd.com/v2/cases/185088720/notes","orderUrl":"https://signifyd.com/v2/cases/185088720/order","currency":"USD","uuid":"368df42c-d25f-44ef-a1d9-92755f743901","createdAt":"2017-01-06T12:47:03+0000","updatedAt":"2017-01-06T12:47:03+0000","status":"OPEN","caseId":123,"score":384,"headline":"John Doe","orderId":"000000003","adjustedScore":385,"orderDate":"2017-01-06T12:46:58+0000","orderAmount":5.85,"orderOutcome":"SUCCESSFUL","associatedTeam":{"teamName":"Magento","teamId":7940},"testInvestigation":true,"reviewDisposition":null}
\ No newline at end of file
From fe5f9c440920490fd06683f5922c5ffa62f96785 Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Tue, 10 Jan 2017 04:45:21 -0600
Subject: [PATCH 097/904] MAGETWO-62807: Case information block on order
details page in admin panel
- static tests fix
---
app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php | 6 ++++--
.../Signifyd/view/adminhtml/templates/case_info.phtml | 2 +-
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php b/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php
index f2d29cd70170f..2a61f66144ed2 100644
--- a/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php
+++ b/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php
@@ -112,7 +112,8 @@ public function getCaseEntity()
* @param CaseInterface $caseEntity
* @return \Magento\Framework\Phrase
*/
- public function getGuaranteeEligible(CaseInterface $caseEntity) {
+ public function getGuaranteeEligible(CaseInterface $caseEntity)
+ {
return $caseEntity->isGuaranteeEligible() ? __('Yes') : __('No');
}
@@ -122,7 +123,8 @@ public function getGuaranteeEligible(CaseInterface $caseEntity) {
* @param CaseInterface $caseEntity
* @return string
*/
- public function getAssociatedTeam(CaseInterface $caseEntity) {
+ public function getAssociatedTeam(CaseInterface $caseEntity)
+ {
$result = 'unknown';
$team = $caseEntity->getAssociatedTeam();
diff --git a/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml b/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml
index 90327fcfeb64f..eff571558f2b6 100644
--- a/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml
+++ b/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml
@@ -36,7 +36,7 @@
escapeHtml($case->getStatus()); ?>
- escapeHtml($case->getScore()); ?>
+ escapeHtml($case->getScore()); ?>
escapeHtml($block->getGuaranteeEligible($case)); ?>
escapeHtml($case->getGuaranteeDisposition()); ?>
escapeHtml($block->getAssociatedTeam($case)); ?>
From 32a891b502dc2e8e05b668be10b3666872039216 Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Tue, 10 Jan 2017 05:03:01 -0600
Subject: [PATCH 098/904] MAGETWO-62809: Controller integration tests
- Remove webhook request object from object manager instances after test execution
---
.../Magento/Signifyd/Controller/Webhooks/HandlerTest.php | 2 ++
1 file changed, 2 insertions(+)
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Controller/Webhooks/HandlerTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Controller/Webhooks/HandlerTest.php
index 49e9ee0296f79..952f961298218 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Controller/Webhooks/HandlerTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Controller/Webhooks/HandlerTest.php
@@ -68,6 +68,8 @@ public function testExecuteSuccess()
"Case Update: New score for the order is 384. Previous score was 553.",
$caseComment->getComment()
);
+
+ $this->_objectManager->removeSharedInstance(WebhookRequest::class);
}
/**
From 881cf1426fc3fa0eaf188b467290325b37412be2 Mon Sep 17 00:00:00 2001
From: Volodymyr Kublytskyi
Date: Wed, 4 Jan 2017 09:25:47 -0600
Subject: [PATCH 099/904] MAGETWO-62822: Create Guarantee creation service
- existing gateway functionality covered with unit tests
---
.../Model/SignifydGateway/GatewayTest.php | 169 ++++++++++++++++++
1 file changed, 169 insertions(+)
create mode 100644 app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/GatewayTest.php
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/GatewayTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/GatewayTest.php
new file mode 100644
index 0000000000000..ea2d5986edd44
--- /dev/null
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/GatewayTest.php
@@ -0,0 +1,169 @@
+createCaseBuilder = $this->getMockBuilder(CreateCaseBuilderInterface::class)
+ ->getMockForAbstractClass();
+
+ $this->apiClient = $this->getMockBuilder(ApiClient::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $om = new ObjectManager($this);
+ $this->gateway = $om->getObject(Gateway::class, [
+ 'createCaseBuilder' => $this->createCaseBuilder,
+ 'apiClient' => $this->apiClient,
+ ]);
+ }
+
+ public function testCreateCaseForSpecifiedOrder()
+ {
+ $dummyOrderId = 1;
+ $dummySignifydInvestigationId = 42;
+ $this->apiClient
+ ->method('makeApiCall')
+ ->willReturn([
+ 'investigationId' => $dummySignifydInvestigationId
+ ]);
+
+ $this->createCaseBuilder
+ ->expects($this->atLeastOnce())
+ ->method('build')
+ ->with($this->equalTo($dummyOrderId))
+ ->willReturn([]);
+
+ $this->gateway->createCase($dummyOrderId);
+ }
+
+ public function testCreateCaseCallsValidApiMethod()
+ {
+ $dummyOrderId = 1;
+ $dummySignifydInvestigationId = 42;
+ $this->createCaseBuilder
+ ->method('build')
+ ->willReturn([]);
+
+ $this->apiClient
+ ->expects($this->atLeastOnce())
+ ->method('makeApiCall')
+ ->with(
+ $this->equalTo('/cases'),
+ $this->equalTo('POST'),
+ $this->isType('array')
+ )
+ ->willReturn([
+ 'investigationId' => $dummySignifydInvestigationId
+ ]);
+
+ $this->gateway->createCase($dummyOrderId);
+
+ }
+
+ public function testCreateCaseNormalFlow()
+ {
+ $dummyOrderId = 1;
+ $dummySignifydInvestigationId = 42;
+ $this->createCaseBuilder
+ ->method('build')
+ ->willReturn([]);
+ $this->apiClient
+ ->method('makeApiCall')
+ ->willReturn([
+ 'investigationId' => $dummySignifydInvestigationId
+ ]);
+
+ $returnedInvestigationId = $this->gateway->createCase($dummyOrderId);
+ $this->assertEquals(
+ $dummySignifydInvestigationId,
+ $returnedInvestigationId,
+ 'Method must return value specified in "investigationId" response parameter'
+ );
+ }
+
+ public function testCreateCaseWithFailedApiCall()
+ {
+ $dummyOrderId = 1;
+ $apiCallFailureMessage = 'Api call failed';
+ $this->createCaseBuilder
+ ->method('build')
+ ->willReturn([]);
+ $this->apiClient
+ ->method('makeApiCall')
+ ->willThrowException(new ApiCallException($apiCallFailureMessage));
+
+ $this->setExpectedException(
+ GatewayException::class,
+ $apiCallFailureMessage
+ );
+ $this->gateway->createCase($dummyOrderId);
+ }
+
+ public function testCreateCaseWithMissedResponseRequiredData()
+ {
+ $dummyOrderId = 1;
+ $this->createCaseBuilder
+ ->method('build')
+ ->willReturn([]);
+ $this->apiClient
+ ->method('makeApiCall')
+ ->willReturn([
+ 'someOtherParameter' => 'foo',
+ ]);
+
+ $this->setExpectedException(GatewayException::class);
+ $this->gateway->createCase($dummyOrderId);
+ }
+
+ public function testCreateCaseWithAdditionalResponseData()
+ {
+ $dummyOrderId = 1;
+ $dummySignifydInvestigationId = 42;
+ $this->createCaseBuilder
+ ->method('build')
+ ->willReturn([]);
+ $this->apiClient
+ ->method('makeApiCall')
+ ->willReturn([
+ 'investigationId' => $dummySignifydInvestigationId,
+ 'someOtherParameter' => 'foo',
+ ]);
+
+ $returnedInvestigationId = $this->gateway->createCase($dummyOrderId);
+ $this->assertEquals(
+ $dummySignifydInvestigationId,
+ $returnedInvestigationId,
+ 'Method must return value specified in "investigationId" response parameter and ignore any other parameters'
+ );
+ }
+}
From d87f9d96e1dc3d0d7e517041817f91156bb2d33f Mon Sep 17 00:00:00 2001
From: Volodymyr Kublytskyi
Date: Wed, 4 Jan 2017 09:41:02 -0600
Subject: [PATCH 100/904] MAGETWO-62822: Create Guarantee creation service
- added initial implementation of submitting case for guarantee to gateway
---
.../Model/SignifydGateway/Gateway.php | 18 ++++++++++++++++++
.../Model/SignifydGateway/GatewayTest.php | 19 +++++++++++++++++++
2 files changed, 37 insertions(+)
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Gateway.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Gateway.php
index 2ffefb65937ee..218e917f15fa3 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/Gateway.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Gateway.php
@@ -60,4 +60,22 @@ public function createCase($orderId)
return (int)$caseCreationResult['investigationId'];
}
+
+ /**
+ * @param int $signifydCaseId
+ * @return array
+ * @throws GatewayException
+ */
+ public function submitCaseForGuarantee($signifydCaseId)
+ {
+ $guaranteeCreationResult = $this->apiClient->makeApiCall(
+ '/guarantees',
+ 'POST',
+ [
+ 'caseId' => $signifydCaseId,
+ ]
+ );
+
+ return $guaranteeCreationResult;
+ }
}
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/GatewayTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/GatewayTest.php
index ea2d5986edd44..8d5fc9767ba7f 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/GatewayTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/GatewayTest.php
@@ -166,4 +166,23 @@ public function testCreateCaseWithAdditionalResponseData()
'Method must return value specified in "investigationId" response parameter and ignore any other parameters'
);
}
+
+ public function testCreateGuaranteeCallsValidApiMethod()
+ {
+ $dummySygnifydCaseId = 42;
+
+ $this->apiClient
+ ->expects($this->atLeastOnce())
+ ->method('makeApiCall')
+ ->with(
+ $this->equalTo('/guarantees'),
+ $this->equalTo('POST'),
+ $this->equalTo([
+ 'caseId' => $dummySygnifydCaseId
+ ])
+ );
+
+ $this->gateway->submitCaseForGuarantee($dummySygnifydCaseId);
+
+ }
}
From 371cde76c25e1f24e2421a65421d7a8b571a448d Mon Sep 17 00:00:00 2001
From: Volodymyr Kublytskyi
Date: Tue, 10 Jan 2017 04:31:40 -0600
Subject: [PATCH 101/904] MAGETWO-62822: Create Guarantee creation service
- implemented submitting case for the guarantee and covered with unit tests
- refactoring (constants described in Signifyd API added to Gateway)
---
.../Signifyd/Api/Data/CaseInterface.php | 27 +++--
.../Model/SignifydGateway/Gateway.php | 49 +++++++-
.../Model/SignifydGateway/GatewayTest.php | 111 +++++++++++++++++-
3 files changed, 172 insertions(+), 15 deletions(-)
diff --git a/app/code/Magento/Signifyd/Api/Data/CaseInterface.php b/app/code/Magento/Signifyd/Api/Data/CaseInterface.php
index 6a58effa19e4f..f534cd04da4c3 100644
--- a/app/code/Magento/Signifyd/Api/Data/CaseInterface.php
+++ b/app/code/Magento/Signifyd/Api/Data/CaseInterface.php
@@ -5,6 +5,8 @@
*/
namespace Magento\Signifyd\Api\Data;
+use Magento\Signifyd\Model\SignifydGateway\Gateway;
+
/**
* Signifyd Case entity interface
*
@@ -16,29 +18,30 @@ interface CaseInterface
/**#@+
* Constants for case available statuses
*/
- const STATUS_OPEN = 'OPEN';
+ const STATUS_OPEN = Gateway::STATUS_OPEN;
const STATUS_PENDING = 'PENDING';
- const STATUS_PROCESSING = 'PROCESSING';
- const STATUS_FLAGGED = 'FLAGGED';
- const STATUS_DISMISSED = 'DISMISSED';
+ const STATUS_PROCESSING = Gateway::STATUS_PROCESSING;
+ const STATUS_FLAGGED = Gateway::STATUS_FLAGGED;
+ const STATUS_DISMISSED = Gateway::STATUS_DISMISSED;
/**#@-*/
/**#@+
* Constants for guarantee available statuses
*/
- const GUARANTEE_APPROVED = 'APPROVED';
- const GUARANTEE_DECLINED = 'DECLINED';
- const GUARANTEE_PENDING = 'PENDING';
- const GUARANTEE_CANCELED = 'CANCELED';
- const GUARANTEE_IN_REVIEW = 'IN_REVIEW';
+ const GUARANTEE_APPROVED = Gateway::GUARANTEE_APPROVED;
+ const GUARANTEE_DECLINED = Gateway::GUARANTEE_DECLINED;
+ const GUARANTEE_PENDING = Gateway::GUARANTEE_PENDING;
+ const GUARANTEE_CANCELED = Gateway::GUARANTEE_CANCELED;
+ const GUARANTEE_IN_REVIEW = Gateway::GUARANTEE_IN_REVIEW;
+ const GUARANTEE_UNREQUESTED = Gateway::GUARANTEE_UNREQUESTED;
/**#@-*/
/**#@+
* Constants for case available review dispositions
*/
- const DISPOSITION_GOOD = 'GOOD';
- const DISPOSITION_FRAUDULENT = 'FRAUDULENT';
- const DISPOSITION_UNSET = 'UNSET';
+ const DISPOSITION_GOOD = Gateway::DISPOSITION_GOOD;
+ const DISPOSITION_FRAUDULENT = Gateway::DISPOSITION_FRAUDULENT;
+ const DISPOSITION_UNSET = Gateway::DISPOSITION_UNSET;
/**#@-*/
/**
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Gateway.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Gateway.php
index 218e917f15fa3..930d5ef472a00 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/Gateway.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Gateway.php
@@ -15,6 +15,34 @@
*/
class Gateway
{
+ /**#@+
+ * Constants for case available statuses
+ */
+ const STATUS_OPEN = 'OPEN';
+ const STATUS_PROCESSING = 'PROCESSING';
+ const STATUS_FLAGGED = 'FLAGGED';
+ const STATUS_DISMISSED = 'DISMISSED';
+ /**#@-*/
+
+ /**#@+
+ * Constants for guarantee available statuses
+ * @see https://www.signifyd.com/resources/manual/signifyd-guarantee/signifyd-guarantee/
+ */
+ const GUARANTEE_APPROVED = 'APPROVED';
+ const GUARANTEE_DECLINED = 'DECLINED';
+ const GUARANTEE_PENDING = 'PENDING';
+ const GUARANTEE_CANCELED = 'CANCELED';
+ const GUARANTEE_IN_REVIEW = 'IN_REVIEW';
+ const GUARANTEE_UNREQUESTED = 'UNREQUESTED';
+ /**#@-*/
+
+ /**#@+
+ * Constants for case available review dispositions
+ */
+ const DISPOSITION_GOOD = 'GOOD';
+ const DISPOSITION_FRAUDULENT = 'FRAUDULENT';
+ const DISPOSITION_UNSET = 'UNSET';
+
/**
* @var CreateCaseBuilderInterface
*/
@@ -76,6 +104,25 @@ public function submitCaseForGuarantee($signifydCaseId)
]
);
- return $guaranteeCreationResult;
+ if (!isset($guaranteeCreationResult['disposition'])) {
+ throw new GatewayException('Expected field "disposition" missed.');
+ }
+
+ $disposition = strtoupper($guaranteeCreationResult['disposition']);
+
+ if (!in_array($disposition, [
+ self::GUARANTEE_APPROVED,
+ self::GUARANTEE_DECLINED,
+ self::GUARANTEE_PENDING,
+ self::GUARANTEE_CANCELED,
+ self::GUARANTEE_IN_REVIEW,
+ self::GUARANTEE_UNREQUESTED
+ ])) {
+ throw new GatewayException(
+ sprintf('API returns unknown guaranty disposition "%s".', $disposition)
+ );
+ }
+
+ return $disposition;
}
}
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/GatewayTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/GatewayTest.php
index 8d5fc9767ba7f..94f4aef036981 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/GatewayTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/GatewayTest.php
@@ -167,9 +167,10 @@ public function testCreateCaseWithAdditionalResponseData()
);
}
- public function testCreateGuaranteeCallsValidApiMethod()
+ public function testSubmitCaseForGuaranteeCallsValidApiMethod()
{
$dummySygnifydCaseId = 42;
+ $dummyDisposition = 'APPROVED';
$this->apiClient
->expects($this->atLeastOnce())
@@ -180,9 +181,115 @@ public function testCreateGuaranteeCallsValidApiMethod()
$this->equalTo([
'caseId' => $dummySygnifydCaseId
])
- );
+ )->willReturn([
+ 'disposition' => $dummyDisposition
+ ]);
+
+ $this->gateway->submitCaseForGuarantee($dummySygnifydCaseId);
+
+ }
+
+ public function testSubmitCaseForGuaranteeWithFailedApiCall()
+ {
+ $dummySygnifydCaseId = 42;
+ $apiCallFailureMessage = 'Api call failed';
+ $this->apiClient
+ ->method('makeApiCall')
+ ->willThrowException(new ApiCallException($apiCallFailureMessage));
+
+ $this->setExpectedException(
+ GatewayException::class,
+ $apiCallFailureMessage
+ );
$this->gateway->submitCaseForGuarantee($dummySygnifydCaseId);
+ }
+ public function testSubmitCaseForGuaranteeReturnsDisposition()
+ {
+ $dummySygnifydCaseId = 42;
+ $dummyDisposition = 'APPROVED';
+ $dummyGuaranteeId = 123;
+ $dummyRereviewCount = 0;
+
+ $this->apiClient
+ ->method('makeApiCall')
+ ->willReturn([
+ 'guaranteeId' => $dummyGuaranteeId,
+ 'disposition' => $dummyDisposition,
+ 'rereviewCount' => $dummyRereviewCount,
+ ]);
+
+ $actualDisposition = $this->gateway->submitCaseForGuarantee($dummySygnifydCaseId);
+ $this->assertEquals(
+ $dummyDisposition,
+ $actualDisposition,
+ 'Method must return guarantee disposition retrieved in Signifyd API response as a result'
+ );
+ }
+
+ public function testSubmitCaseForGuaranteeWithMissedDisposition()
+ {
+ $dummySygnifydCaseId = 42;
+ $dummyGuaranteeId = 123;
+ $dummyRereviewCount = 0;
+
+ $this->apiClient
+ ->method('makeApiCall')
+ ->willReturn([
+ 'guaranteeId' => $dummyGuaranteeId,
+ 'rereviewCount' => $dummyRereviewCount,
+ ]);
+
+ $this->setExpectedException(GatewayException::class);
+ $this->gateway->submitCaseForGuarantee($dummySygnifydCaseId);
+ }
+
+ public function testSubmitCaseForGuaranteeWithUnexpectedDisposition()
+ {
+ $dummySygnifydCaseId = 42;
+ $dummyUnexpectedDisposition = 'UNEXPECTED';
+
+ $this->apiClient
+ ->method('makeApiCall')
+ ->willReturn([
+ 'disposition' => $dummyUnexpectedDisposition,
+ ]);
+
+ $this->setExpectedException(GatewayException::class);
+ $this->gateway->submitCaseForGuarantee($dummySygnifydCaseId);
+ }
+
+ /**
+ * @dataProvider supportedGuaranteeDispositionsProvider
+ */
+ public function testSubmitCaseForGuaranteeWithExpectedDisposition($dummyExpectedDisposition)
+ {
+ $dummySygnifydCaseId = 42;
+
+ $this->apiClient
+ ->method('makeApiCall')
+ ->willReturn([
+ 'disposition' => $dummyExpectedDisposition,
+ ]);
+
+ $actualDisposition = $this->gateway->submitCaseForGuarantee($dummySygnifydCaseId);
+ $this->assertEquals(
+ $dummyExpectedDisposition,
+ $actualDisposition,
+ 'Expected disposition should be return from method'
+ );
+ }
+
+ public function supportedGuaranteeDispositionsProvider()
+ {
+ return [
+ ['APPROVED'],
+ ['DECLINED'],
+ ['PENDING'],
+ ['CANCELED'],
+ ['IN_REVIEW'],
+ ['UNREQUESTED'],
+ ];
}
}
From 8a34b8230f8d297be1ddcd96fd9c7cabc93388b4 Mon Sep 17 00:00:00 2001
From: Volodymyr Kublytskyi
Date: Tue, 10 Jan 2017 04:35:38 -0600
Subject: [PATCH 102/904] MAGETWO-62822: Create Guarantee creation service
- changed to named data sets in gateway unit test
---
.../Test/Unit/Model/SignifydGateway/GatewayTest.php | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/GatewayTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/GatewayTest.php
index 94f4aef036981..3a58a5db1ec43 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/GatewayTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/GatewayTest.php
@@ -284,12 +284,12 @@ public function testSubmitCaseForGuaranteeWithExpectedDisposition($dummyExpected
public function supportedGuaranteeDispositionsProvider()
{
return [
- ['APPROVED'],
- ['DECLINED'],
- ['PENDING'],
- ['CANCELED'],
- ['IN_REVIEW'],
- ['UNREQUESTED'],
+ 'APPROVED' => ['APPROVED'],
+ 'DECLINED' => ['DECLINED'],
+ 'PENDING' => ['PENDING'],
+ 'CANCELED' => ['CANCELED'],
+ 'IN_REVIEW' => ['IN_REVIEW'],
+ 'UNREQUESTED' => ['UNREQUESTED'],
];
}
}
From 4d570889886262318ea4f77f9238030fbd1a41c4 Mon Sep 17 00:00:00 2001
From: Volodymyr Kublytskyi
Date: Tue, 10 Jan 2017 04:45:05 -0600
Subject: [PATCH 103/904] MAGETWO-62822: Create Guarantee creation service
- reimplementing gateway unit test without object manager
---
.../Test/Unit/Model/SignifydGateway/GatewayTest.php | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/GatewayTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/GatewayTest.php
index 3a58a5db1ec43..74be30f8544dd 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/GatewayTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/GatewayTest.php
@@ -7,7 +7,6 @@
use PHPUnit_Framework_TestCase as TestCase;
use PHPUnit_Framework_MockObject_MockObject as MockObject;
-use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
use Magento\Signifyd\Model\SignifydGateway\Gateway;
use Magento\Signifyd\Model\SignifydGateway\GatewayException;
use Magento\Signifyd\Model\SignifydGateway\Request\CreateCaseBuilderInterface;
@@ -40,11 +39,10 @@ public function setUp()
->disableOriginalConstructor()
->getMock();
- $om = new ObjectManager($this);
- $this->gateway = $om->getObject(Gateway::class, [
- 'createCaseBuilder' => $this->createCaseBuilder,
- 'apiClient' => $this->apiClient,
- ]);
+ $this->gateway = new Gateway(
+ $this->createCaseBuilder,
+ $this->apiClient
+ );
}
public function testCreateCaseForSpecifiedOrder()
From 88e8c8fd03a3354b96669e7d6ab32839d333ea42 Mon Sep 17 00:00:00 2001
From: Volodymyr Kublytskyi
Date: Tue, 10 Jan 2017 04:54:09 -0600
Subject: [PATCH 104/904] MAGETWO-62822: Create Guarantee creation service
- changed copyright year
---
app/code/Magento/Signifyd/Api/Data/CaseInterface.php | 2 +-
app/code/Magento/Signifyd/Model/SignifydGateway/Gateway.php | 2 +-
.../Signifyd/Test/Unit/Model/SignifydGateway/GatewayTest.php | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/app/code/Magento/Signifyd/Api/Data/CaseInterface.php b/app/code/Magento/Signifyd/Api/Data/CaseInterface.php
index f534cd04da4c3..13b6564ad3323 100644
--- a/app/code/Magento/Signifyd/Api/Data/CaseInterface.php
+++ b/app/code/Magento/Signifyd/Api/Data/CaseInterface.php
@@ -1,6 +1,6 @@
Date: Tue, 10 Jan 2017 05:39:14 -0600
Subject: [PATCH 105/904] MAGETWO-62822: Create Guarantee creation service
- added links to Signifyd API docs
---
app/code/Magento/Signifyd/Model/SignifydGateway/Gateway.php | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Gateway.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Gateway.php
index 2f732bef758c9..dfd21776e98ad 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/Gateway.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Gateway.php
@@ -68,6 +68,8 @@ public function __construct(
}
/**
+ * @see https://www.signifyd.com/docs/api/#/reference/cases/create-a-case
+ *
* @param int $orderId
* @return int Signifyd case (investigation) identifier
* @throws GatewayException
@@ -90,6 +92,8 @@ public function createCase($orderId)
}
/**
+ * @see https://www.signifyd.com/docs/api/#/reference/guarantees/submit-a-case-for-guarantee
+ *
* @param int $signifydCaseId
* @return array
* @throws GatewayException
From 3499bde06272d249497a8e1bb59aac83c2c0294e Mon Sep 17 00:00:00 2001
From: Volodymyr Kublytskyi
Date: Tue, 10 Jan 2017 07:15:05 -0600
Subject: [PATCH 106/904] MAGETWO-63047: Add possibility to fetch raw HTTP
request data from Magento app request
---
.../Signifyd/Model/SignifydGateway/Response/WebhookRequest.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookRequest.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookRequest.php
index 0a892dd02733d..4a77fa5245fe5 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookRequest.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Response/WebhookRequest.php
@@ -53,6 +53,6 @@ public function getEventTopic()
*/
public function getBody()
{
- return (string)@file_get_contents("php://input");
+ return (string)$this->request->getContent();
}
}
From cfcb2eab3a8d930a2f09e5addc4e13990b6437e1 Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Tue, 10 Jan 2017 08:16:43 -0600
Subject: [PATCH 107/904] MAGETWO-62823: Update case entity on Guarantee
creation
- Added service to update case entity after guarantee submitting
- Added index for a case id
- Covered guarantee creation service by integration test
---
.../Model/Guarantee/CreationService.php | 92 +++++++++
.../MessageGenerators/GeneratorFactory.php | 9 +
.../MessageGenerators/GuaranteeCreation.php | 22 +++
.../Magento/Signifyd/Setup/InstallSchema.php | 17 +-
.../GeneratorFactoryTest.php | 2 +
.../GuaranteeCreationTest.php | 46 +++++
.../Model/Guarantee/CreationServiceTest.php | 175 ++++++++++++++++++
7 files changed, 360 insertions(+), 3 deletions(-)
create mode 100644 app/code/Magento/Signifyd/Model/Guarantee/CreationService.php
create mode 100644 app/code/Magento/Signifyd/Model/MessageGenerators/GuaranteeCreation.php
create mode 100644 app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/GuaranteeCreationTest.php
create mode 100644 dev/tests/integration/testsuite/Magento/Signifyd/Model/Guarantee/CreationServiceTest.php
diff --git a/app/code/Magento/Signifyd/Model/Guarantee/CreationService.php b/app/code/Magento/Signifyd/Model/Guarantee/CreationService.php
new file mode 100644
index 0000000000000..574972289188c
--- /dev/null
+++ b/app/code/Magento/Signifyd/Model/Guarantee/CreationService.php
@@ -0,0 +1,92 @@
+caseUpdatingServiceFactory = $caseUpdatingServiceFactory;
+ $this->gateway = $gateway;
+ $this->logger = $logger;
+ $this->caseManagement = $caseManagement;
+ }
+
+ /**
+ * Sends request to Signifyd to create guarantee for a case and updates case entity by retrieved data.
+ *
+ * @param int $orderId
+ * @return bool
+ */
+ public function create($orderId)
+ {
+ $caseEntity = $this->caseManagement->getByOrderId($orderId);
+ if ($caseEntity === null) {
+ $this->logger->error("Cannot find case entity for order entity id: {$orderId}");
+ return false;
+ }
+ $updatingService = $this->caseUpdatingServiceFactory->create('guarantees/creation');
+
+ try {
+ $data = $this->gateway->submitCaseForGuarantee($caseEntity->getCaseId());
+ $updatingService->update($data);
+ } catch (ApiCallException $e) {
+ $this->logger->error($e->getMessage());
+ return false;
+ } catch (GatewayException $e) {
+ $this->logger->error($e->getMessage());
+ return false;
+ } catch (LocalizedException $e) {
+ $this->logger->error($e->getMessage());
+ return false;
+ }
+
+ return true;
+ }
+}
diff --git a/app/code/Magento/Signifyd/Model/MessageGenerators/GeneratorFactory.php b/app/code/Magento/Signifyd/Model/MessageGenerators/GeneratorFactory.php
index 2b1b4a01b0ed3..4d0d12b03ebe8 100644
--- a/app/code/Magento/Signifyd/Model/MessageGenerators/GeneratorFactory.php
+++ b/app/code/Magento/Signifyd/Model/MessageGenerators/GeneratorFactory.php
@@ -37,6 +37,12 @@ class GeneratorFactory
*/
private static $guaranteeCompletion = 'guarantees/completion';
+ /**
+ * Type of message of Signifyd guarantee creation
+ * @var string
+ */
+ private static $guaranteeCreation = 'guarantees/creation';
+
/**
* CaseUpdatingServiceFactory constructor.
*
@@ -70,6 +76,9 @@ public function create($type)
case self::$guaranteeCompletion:
$className = GuaranteeCompletion::class;
break;
+ case self::$guaranteeCreation:
+ $className = GuaranteeCreation::class;
+ break;
default:
throw new \InvalidArgumentException('Specified message type does not supported.');
}
diff --git a/app/code/Magento/Signifyd/Model/MessageGenerators/GuaranteeCreation.php b/app/code/Magento/Signifyd/Model/MessageGenerators/GuaranteeCreation.php
new file mode 100644
index 0000000000000..4c87b6cd5009b
--- /dev/null
+++ b/app/code/Magento/Signifyd/Model/MessageGenerators/GuaranteeCreation.php
@@ -0,0 +1,22 @@
+getIdxName(
$setup->getTable(static::$table),
'order_id',
- \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE
+ AdapterInterface::INDEX_TYPE_UNIQUE
),
'order_id',
- ['type' => \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE]
+ ['type' => AdapterInterface::INDEX_TYPE_UNIQUE]
+ );
+
+ $table->addIndex(
+ $setup->getIdxName(
+ $setup->getTable(static::$table),
+ 'case_id',
+ AdapterInterface::INDEX_TYPE_UNIQUE
+ ),
+ 'case_id',
+ ['type' => AdapterInterface::INDEX_TYPE_UNIQUE]
);
$table->addForeignKey(
@@ -70,6 +80,7 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'entity_id',
Table::ACTION_SET_NULL
);
+
$connection->createTable($table);
}
}
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/GeneratorFactoryTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/GeneratorFactoryTest.php
index c154b22fcab2a..ddc71b60b3816 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/GeneratorFactoryTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/GeneratorFactoryTest.php
@@ -12,6 +12,7 @@
use Magento\Signifyd\Model\MessageGenerators\CaseReview;
use Magento\Signifyd\Model\MessageGenerators\GeneratorFactory;
use Magento\Signifyd\Model\MessageGenerators\GuaranteeCompletion;
+use Magento\Signifyd\Model\MessageGenerators\GuaranteeCreation;
use PHPUnit_Framework_MockObject_MockObject as MockObject;
/**
@@ -81,6 +82,7 @@ public function typeDataProvider()
['cases/rescore', CaseRescore::class],
['cases/review', CaseReview::class],
['guarantees/completion', GuaranteeCompletion::class],
+ ['guarantees/creation', GuaranteeCreation::class],
];
}
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/GuaranteeCreationTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/GuaranteeCreationTest.php
new file mode 100644
index 0000000000000..dd90e4c57da1d
--- /dev/null
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/GuaranteeCreationTest.php
@@ -0,0 +1,46 @@
+generate($data);
+
+ static::assertEquals($message, $message);
+ static::assertInstanceOf(Phrase::class, $message);
+ }
+
+ /**
+ * Gets list of variations for input data.
+ *
+ * @return array
+ */
+ public function dataProvider()
+ {
+ $message = 'Case Update: Case is submitted for guarantee.';
+ return [
+ [[], $message],
+ [['caseId' => 123], $message],
+ ];
+ }
+}
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Model/Guarantee/CreationServiceTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Model/Guarantee/CreationServiceTest.php
new file mode 100644
index 0000000000000..3547c6a8c8f29
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/Guarantee/CreationServiceTest.php
@@ -0,0 +1,175 @@
+objectManager = Bootstrap::getObjectManager();
+
+ $this->gateway = $this->getMockBuilder(Gateway::class)
+ ->disableOriginalConstructor()
+ ->setMethods(['submitCaseForGuarantee'])
+ ->getMock();
+
+ $this->logger = $this->getMockBuilder(LoggerInterface::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->service = $this->objectManager->create(CreationService::class, [
+ 'gateway' => $this->gateway,
+ 'logger' => $this->logger
+ ]);
+ }
+
+ /**
+ * Checks a test case, when Signifyd case entity cannot be found
+ * for a specified order.
+ *
+ * @covers \Magento\Signifyd\Model\Guarantee\CreationService::create
+ */
+ public function testCreateWithoutCaseEntity()
+ {
+ $orderId = 123;
+ $this->logger->expects(self::once())
+ ->method('error')
+ ->with('Cannot find case entity for order entity id: 123');
+
+ $this->gateway->expects(self::never())
+ ->method('submitCaseForGuarantee');
+
+ $result = $this->service->create($orderId);
+ self::assertFalse($result);
+ }
+
+ /**
+ * Checks a test case, when request is failing.
+ *
+ * @covers \Magento\Signifyd\Model\Guarantee\CreationService::create
+ * @magentoDataFixture Magento/Signifyd/_files/case.php
+ */
+ public function testCreateWithFailedRequest()
+ {
+ $caseEntity = $this->getCaseEntity();
+
+ $this->gateway->expects(self::once())
+ ->method('submitCaseForGuarantee')
+ ->willThrowException(new ApiCallException('Something wrong'));
+
+ $this->logger->expects(self::once())
+ ->method('error')
+ ->with('Something wrong');
+
+ $result = $this->service->create($caseEntity->getOrderId());
+ self::assertFalse($result);
+ }
+
+ /**
+ * Checks a test case, when case entity updating is failed.
+ *
+ * @covers \Magento\Signifyd\Model\Guarantee\CreationService::create
+ * @magentoDataFixture Magento/Signifyd/_files/case.php
+ * @magentoConfigFixture current_store fraud_protection/signifyd/active 1
+ */
+ public function testCreateWithFailedCaseUpdating()
+ {
+ $caseEntity = $this->getCaseEntity();
+
+ $this->gateway->expects(self::once())
+ ->method('submitCaseForGuarantee')
+ ->with($caseEntity->getCaseId())
+ ->willReturn([]);
+
+ $this->logger->expects(self::once())
+ ->method('error')
+ ->with('The "caseId" should not be empty.');
+
+ $result = $this->service->create($caseEntity->getOrderId());
+ self::assertFalse($result);
+ }
+
+ /**
+ * Checks a test case, when case entity is updated successfully.
+ *
+ * @covers \Magento\Signifyd\Model\Guarantee\CreationService::create
+ * @magentoDataFixture Magento/Signifyd/_files/case.php
+ * @magentoConfigFixture current_store fraud_protection/signifyd/active 1
+ */
+ public function testCreate()
+ {
+ $caseEntity = $this->getCaseEntity();
+ $data = [
+ 'caseId' => $caseEntity->getCaseId(),
+ 'guaranteeEligible' => true,
+ 'guaranteeDisposition' => CaseInterface::GUARANTEE_IN_REVIEW
+ ];
+
+ $this->gateway->expects(self::once())
+ ->method('submitCaseForGuarantee')
+ ->with($caseEntity->getCaseId())
+ ->willReturn($data);
+
+ $this->logger->expects(self::never())
+ ->method('error');
+
+ $result = $this->service->create($caseEntity->getOrderId());
+ self::assertTrue($result);
+
+ $updatedCase = $this->getCaseEntity();
+ self::assertEquals(CaseInterface::GUARANTEE_IN_REVIEW, $updatedCase->getGuaranteeDisposition());
+ self::assertTrue((bool) $updatedCase->isGuaranteeEligible());
+ self::assertEquals(CaseInterface::STATUS_PROCESSING, $updatedCase->getStatus());
+ }
+
+ /**
+ * Gets case entity.
+ *
+ * @return \Magento\Signifyd\Api\Data\CaseInterface|null
+ */
+ private function getCaseEntity()
+ {
+ /** @var CaseRepositoryInterface $caseRepository */
+ $caseRepository = $this->objectManager->get(CaseRepositoryInterface::class);
+ return $caseRepository->getByCaseId(123);
+ }
+}
From bf8e06d495d34aa9874fea368da8022943777484 Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Tue, 10 Jan 2017 09:26:51 -0600
Subject: [PATCH 108/904] MAGETWO-62821: Controller to submit for Guarantee
- Add controller to submit order for Guarantee
---
.../Controller/Adminhtml/Guarantee/Create.php | 60 ++++++++
.../Magento/Signifyd/etc/adminhtml/routes.xml | 14 ++
app/code/Magento/Signifyd/i18n/en_US.csv | 5 +-
.../Adminhtml/Guarantee/CreateTest.php | 134 ++++++++++++++++++
.../Model/CaseUpdatingServiceTest.php | 2 +-
5 files changed, 213 insertions(+), 2 deletions(-)
create mode 100644 app/code/Magento/Signifyd/Controller/Adminhtml/Guarantee/Create.php
create mode 100644 app/code/Magento/Signifyd/etc/adminhtml/routes.xml
create mode 100644 dev/tests/integration/testsuite/Magento/Signifyd/Controller/Adminhtml/Guarantee/CreateTest.php
diff --git a/app/code/Magento/Signifyd/Controller/Adminhtml/Guarantee/Create.php b/app/code/Magento/Signifyd/Controller/Adminhtml/Guarantee/Create.php
new file mode 100644
index 0000000000000..7550a6d2c7ee3
--- /dev/null
+++ b/app/code/Magento/Signifyd/Controller/Adminhtml/Guarantee/Create.php
@@ -0,0 +1,60 @@
+creationService = $creationService;
+ }
+
+ public function execute()
+ {
+ $orderId = $this->getRequest()->getParam('orderId');
+ $resultRedirect = $this->resultRedirectFactory->create();
+
+ if (empty($orderId)) {
+ $this->messageManager->addErrorMessage(__('Order id is required.'));
+ $resultRedirect->setPath('sales/order/index');
+ return $resultRedirect;
+ }
+
+ $resultRedirect->setPath('sales/order/view', ['order_id' => $orderId]);
+ if ($this->creationService->create($orderId)) {
+ $this->messageManager->addSuccessMessage(
+ __('Order has been submitted for Guarantee.')
+ );
+ } else {
+ $this->messageManager->addErrorMessage(
+ __('Sorry, we can\'t submit order for Guarantee.')
+ );
+ }
+
+ return $resultRedirect;
+ }
+}
diff --git a/app/code/Magento/Signifyd/etc/adminhtml/routes.xml b/app/code/Magento/Signifyd/etc/adminhtml/routes.xml
new file mode 100644
index 0000000000000..1f94759c1b7b6
--- /dev/null
+++ b/app/code/Magento/Signifyd/etc/adminhtml/routes.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Signifyd/i18n/en_US.csv b/app/code/Magento/Signifyd/i18n/en_US.csv
index a10f12073987f..fe940d75ef691 100644
--- a/app/code/Magento/Signifyd/i18n/en_US.csv
+++ b/app/code/Magento/Signifyd/i18n/en_US.csv
@@ -17,4 +17,7 @@
"Signifyd Case %1 has been created for order.","Signifyd Case %1 has been created for order."
"The "%1" should not be empty.","The "%1" should not be empty."
"Case entity not found.","Case entity not found."
-"Cannot update Case entity.","Cannot update Case entity."
\ No newline at end of file
+"Cannot update Case entity.","Cannot update Case entity."
+"Order has been submitted for Guarantee.","Order has been submitted for Guarantee."
+"Sorry, we can't submit order for Guarantee.","Sorry, we can't submit order for Guarantee."
+"Order id is required.","Order id is required."
\ No newline at end of file
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Controller/Adminhtml/Guarantee/CreateTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Controller/Adminhtml/Guarantee/CreateTest.php
new file mode 100644
index 0000000000000..46c7464105ff6
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Controller/Adminhtml/Guarantee/CreateTest.php
@@ -0,0 +1,134 @@
+creationService = $this->getMockBuilder(CreationService::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->_objectManager->addSharedInstance($this->creationService, CreationService::class);
+ }
+
+ /**
+ * Tests successful Guarantee creation for an order.
+ *
+ * @covers \Magento\Signifyd\Controller\Adminhtml\Guarantee\Create::execute
+ * @magentoDataFixture Magento/Signifyd/_files/case.php
+ * @magentoAppArea adminhtml
+ */
+ public function testExecuteSuccess()
+ {
+ $orderId = $this->getOrderId();
+ $this->getRequest()->setPostValue('orderId', $orderId);
+
+ $this->creationService->expects($this->once())
+ ->method('create')
+ ->with($orderId)
+ ->willReturn(true);
+
+ $this->dispatch(self::$entryPoint);
+
+ $this->assertRedirect($this->stringContains('backend/sales/order/view'));
+ $this->assertSessionMessages(
+ $this->equalTo(['Order has been submitted for Guarantee.']),
+ MessageInterface::TYPE_SUCCESS
+ );
+ }
+
+ /**
+ * Tests failure Guarantee creation due to empty order id.
+ *
+ * @covers \Magento\Signifyd\Controller\Adminhtml\Guarantee\Create::execute
+ * @magentoDataFixture Magento/Signifyd/_files/case.php
+ * @magentoAppArea adminhtml
+ */
+ public function testExecuteWithEmptyOrderId()
+ {
+ $orderId = '';
+ $this->getRequest()->setPostValue('orderId', $orderId);
+
+ $this->creationService->expects($this->never())
+ ->method('create');
+
+ $this->dispatch(self::$entryPoint);
+
+ $this->assertRedirect($this->stringContains('backend/sales/order/index'));
+ $this->assertSessionMessages(
+ $this->equalTo(['Order id is required.']),
+ MessageInterface::TYPE_ERROR
+ );
+ }
+
+ /**
+ * Tests failure Guarantee creation due to unsuccessful CreationService call.
+ *
+ * @covers \Magento\Signifyd\Controller\Adminhtml\Guarantee\Create::execute
+ * @magentoDataFixture Magento/Signifyd/_files/case.php
+ * @magentoAppArea adminhtml
+ */
+ public function testExecuteWithCreationServiceFail()
+ {
+ $orderId = $this->getOrderId();
+ $this->getRequest()->setPostValue('orderId', $orderId);
+
+ $this->creationService->expects($this->once())
+ ->method('create')
+ ->with($orderId)
+ ->willReturn(false);
+
+ $this->dispatch(self::$entryPoint);
+
+ $this->assertRedirect($this->stringContains('backend/sales/order/view'));
+ $this->assertSessionMessages(
+ $this->equalTo(['Sorry, we can't submit order for Guarantee.']),
+ MessageInterface::TYPE_ERROR
+ );
+ }
+
+ /**
+ * Returns orderId from case in fixture
+ *
+ * @return int
+ */
+ private function getOrderId()
+ {
+ $caseId = 123;
+ /** @var CaseRepositoryInterface $caseRepository */
+ $caseRepository = $this->_objectManager->get(CaseRepositoryInterface::class);
+ /** @var CaseInterface $caseEntity */
+ $caseEntity = $caseRepository->getByCaseId($caseId);
+
+ return $caseEntity->getOrderId();
+ }
+}
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseUpdatingServiceTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseUpdatingServiceTest.php
index 2fb3d0481a2e3..25af28570737c 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseUpdatingServiceTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseUpdatingServiceTest.php
@@ -69,7 +69,7 @@ public function testUpdate()
$this->service->update($data);
- /** @var CaseRepositoryInterface $caseManagement */
+ /** @var CaseRepositoryInterface $caseRepository */
$caseRepository = $this->objectManager->get(CaseRepositoryInterface::class);
/** @var CaseInterface $caseEntity */
$caseEntity = $caseRepository->getByCaseId($caseId);
From cf33015f1a7bc579d6fa873c0ca5280ad7567793 Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Tue, 10 Jan 2017 09:31:42 -0600
Subject: [PATCH 109/904] MAGETWO-62821: Controller to submit for Guarantee
- Add correct annotation
---
.../Signifyd/Controller/Adminhtml/Guarantee/Create.php | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/app/code/Magento/Signifyd/Controller/Adminhtml/Guarantee/Create.php b/app/code/Magento/Signifyd/Controller/Adminhtml/Guarantee/Create.php
index 7550a6d2c7ee3..ea0ac3654e32b 100644
--- a/app/code/Magento/Signifyd/Controller/Adminhtml/Guarantee/Create.php
+++ b/app/code/Magento/Signifyd/Controller/Adminhtml/Guarantee/Create.php
@@ -10,7 +10,7 @@
use Magento\Signifyd\Model\Guarantee\CreationService;
/**
- * Responsible for submitting case for Guarantee.
+ * Responsible for submitting order for Guarantee.
*
* @see https://www.signifyd.com/docs/api/#/reference/guarantees/create-guarantee
*/
@@ -33,6 +33,11 @@ public function __construct(
$this->creationService = $creationService;
}
+ /**
+ * Submits order for Guarantee and redirects user to order page with result message
+ *
+ * @return \Magento\Framework\Controller\Result\Redirect
+ */
public function execute()
{
$orderId = $this->getRequest()->getParam('orderId');
From 3992cd8189a2772296972b9a91ea3a9a592f59eb Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Tue, 10 Jan 2017 11:06:06 -0600
Subject: [PATCH 110/904] MAGETWO-62823: Update case entity on Guarantee
creation
- Updated integration test
---
.../Model/Guarantee/CreationServiceTest.php | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Model/Guarantee/CreationServiceTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Model/Guarantee/CreationServiceTest.php
index 3547c6a8c8f29..c9ee755912e2f 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Model/Guarantee/CreationServiceTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/Guarantee/CreationServiceTest.php
@@ -6,6 +6,8 @@
namespace Magento\Signifyd\Model\Guarantee;
use Magento\Framework\App\ObjectManager;
+use Magento\Sales\Api\Data\OrderStatusHistoryInterface;
+use Magento\Sales\Api\OrderRepositoryInterface;
use Magento\Signifyd\Api\CaseRepositoryInterface;
use Magento\Signifyd\Api\Data\CaseInterface;
use Magento\Signifyd\Model\SignifydGateway\ApiCallException;
@@ -159,6 +161,18 @@ public function testCreate()
self::assertEquals(CaseInterface::GUARANTEE_IN_REVIEW, $updatedCase->getGuaranteeDisposition());
self::assertTrue((bool) $updatedCase->isGuaranteeEligible());
self::assertEquals(CaseInterface::STATUS_PROCESSING, $updatedCase->getStatus());
+
+ /** @var OrderRepositoryInterface $orderRepository */
+ $orderRepository = $this->objectManager->get(OrderRepositoryInterface::class);
+ $order = $orderRepository->get($updatedCase->getOrderId());
+ $histories = $order->getStatusHistories();
+ static::assertNotEmpty($histories);
+
+
+ /** @var OrderStatusHistoryInterface $caseCreationComment */
+ $caseCreationComment = array_pop($histories);
+ static::assertInstanceOf(OrderStatusHistoryInterface::class, $caseCreationComment);
+ static::assertEquals('Case Update: Case is submitted for guarantee.', $caseCreationComment->getComment());
}
/**
From 4223f6f33ef34810279abe5654e23a7a1b7c50cb Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Tue, 10 Jan 2017 11:41:35 -0600
Subject: [PATCH 111/904] MAGETWO-62806: Update case entity
- Renamed validator
---
.../Signifyd/Model/CaseUpdatingService.php | 14 ++++++------
.../Model/MessageGenerators/CaseCreation.php | 14 ++++++------
.../Model/MessageGenerators/CaseRescore.php | 14 ++++++------
...eDataValidator.php => CaseIdValidator.php} | 2 +-
.../Unit/Model/CaseUpdatingServiceTest.php | 22 +++++++++----------
.../MessageGenerators/CaseCreationTest.php | 4 ++--
.../MessageGenerators/CaseRescoreTest.php | 14 ++++++------
7 files changed, 42 insertions(+), 42 deletions(-)
rename app/code/Magento/Signifyd/Model/Validators/{CaseDataValidator.php => CaseIdValidator.php} (95%)
diff --git a/app/code/Magento/Signifyd/Model/CaseUpdatingService.php b/app/code/Magento/Signifyd/Model/CaseUpdatingService.php
index 996b8e144c122..a4ca6b8b716a7 100644
--- a/app/code/Magento/Signifyd/Model/CaseUpdatingService.php
+++ b/app/code/Magento/Signifyd/Model/CaseUpdatingService.php
@@ -9,7 +9,7 @@
use Magento\Framework\Exception\NotFoundException;
use Magento\Signifyd\Api\CaseRepositoryInterface;
use Magento\Signifyd\Api\Data\CaseInterface;
-use Magento\Signifyd\Model\Validators\CaseDataValidator;
+use Magento\Signifyd\Model\Validators\CaseIdValidator;
/**
* Performs Signifyd case entity updating operations.
@@ -27,9 +27,9 @@ class CaseUpdatingService implements CaseUpdatingServiceInterface
private $caseRepository;
/**
- * @var CaseDataValidator
+ * @var CaseIdValidator
*/
- private $caseDataValidator;
+ private $caseIdValidator;
/**
* @var CommentsHistoryUpdater
@@ -41,18 +41,18 @@ class CaseUpdatingService implements CaseUpdatingServiceInterface
*
* @param MessageGeneratorInterface $messageGenerator
* @param CaseRepositoryInterface $caseRepository
- * @param CaseDataValidator $caseDataValidator
+ * @param CaseIdValidator $caseIdValidator
* @param CommentsHistoryUpdater $commentsHistoryUpdater
*/
public function __construct(
MessageGeneratorInterface $messageGenerator,
CaseRepositoryInterface $caseRepository,
- CaseDataValidator $caseDataValidator,
+ CaseIdValidator $caseIdValidator,
CommentsHistoryUpdater $commentsHistoryUpdater
) {
$this->messageGenerator = $messageGenerator;
$this->caseRepository = $caseRepository;
- $this->caseDataValidator = $caseDataValidator;
+ $this->caseIdValidator = $caseIdValidator;
$this->commentsHistoryUpdater = $commentsHistoryUpdater;
}
@@ -66,7 +66,7 @@ public function __construct(
*/
public function update(array $data)
{
- if (!$this->caseDataValidator->validate($data)) {
+ if (!$this->caseIdValidator->validate($data)) {
throw new LocalizedException(__('The "%1" should not be empty.', 'caseId'));
}
diff --git a/app/code/Magento/Signifyd/Model/MessageGenerators/CaseCreation.php b/app/code/Magento/Signifyd/Model/MessageGenerators/CaseCreation.php
index 72165538956b4..a9affc97bbe4a 100644
--- a/app/code/Magento/Signifyd/Model/MessageGenerators/CaseCreation.php
+++ b/app/code/Magento/Signifyd/Model/MessageGenerators/CaseCreation.php
@@ -7,7 +7,7 @@
use Magento\Signifyd\Model\MessageGeneratorException;
use Magento\Signifyd\Model\MessageGeneratorInterface;
-use Magento\Signifyd\Model\Validators\CaseDataValidator;
+use Magento\Signifyd\Model\Validators\CaseIdValidator;
/**
* Generates message for created Signifyd case.
@@ -15,18 +15,18 @@
class CaseCreation implements MessageGeneratorInterface
{
/**
- * @var CaseDataValidator
+ * @var CaseIdValidator
*/
- private $caseDataValidator;
+ private $caseIdValidator;
/**
* CaseCreation constructor.
*
- * @param CaseDataValidator $caseDataValidator
+ * @param CaseIdValidator $caseIdValidator
*/
- public function __construct(CaseDataValidator $caseDataValidator)
+ public function __construct(CaseIdValidator $caseIdValidator)
{
- $this->caseDataValidator = $caseDataValidator;
+ $this->caseIdValidator = $caseIdValidator;
}
/**
@@ -34,7 +34,7 @@ public function __construct(CaseDataValidator $caseDataValidator)
*/
public function generate(array $data)
{
- if (!$this->caseDataValidator->validate($data)) {
+ if (!$this->caseIdValidator->validate($data)) {
throw new MessageGeneratorException(__('The "%1" should not be empty.', 'caseId'));
}
diff --git a/app/code/Magento/Signifyd/Model/MessageGenerators/CaseRescore.php b/app/code/Magento/Signifyd/Model/MessageGenerators/CaseRescore.php
index 0f184590d4946..b2ff54c5c1c3b 100644
--- a/app/code/Magento/Signifyd/Model/MessageGenerators/CaseRescore.php
+++ b/app/code/Magento/Signifyd/Model/MessageGenerators/CaseRescore.php
@@ -8,7 +8,7 @@
use Magento\Signifyd\Api\CaseRepositoryInterface;
use Magento\Signifyd\Model\MessageGeneratorException;
use Magento\Signifyd\Model\MessageGeneratorInterface;
-use Magento\Signifyd\Model\Validators\CaseDataValidator;
+use Magento\Signifyd\Model\Validators\CaseIdValidator;
/**
* Generates message based on previous and current Case scores.
@@ -21,20 +21,20 @@ class CaseRescore implements MessageGeneratorInterface
private $caseRepository;
/**
- * @var CaseDataValidator
+ * @var CaseIdValidator
*/
- private $caseDataValidator;
+ private $caseIdValidator;
/**
* CaseRescore constructor.
*
* @param CaseRepositoryInterface $caseRepository
- * @param CaseDataValidator $caseDataValidator
+ * @param CaseIdValidator $caseIdValidator
*/
- public function __construct(CaseRepositoryInterface $caseRepository, CaseDataValidator $caseDataValidator)
+ public function __construct(CaseRepositoryInterface $caseRepository, CaseIdValidator $caseIdValidator)
{
$this->caseRepository = $caseRepository;
- $this->caseDataValidator = $caseDataValidator;
+ $this->caseIdValidator = $caseIdValidator;
}
/**
@@ -42,7 +42,7 @@ public function __construct(CaseRepositoryInterface $caseRepository, CaseDataVal
*/
public function generate(array $data)
{
- if (!$this->caseDataValidator->validate($data)) {
+ if (!$this->caseIdValidator->validate($data)) {
throw new MessageGeneratorException(__('The "%1" should not be empty.', 'caseId'));
}
diff --git a/app/code/Magento/Signifyd/Model/Validators/CaseDataValidator.php b/app/code/Magento/Signifyd/Model/Validators/CaseIdValidator.php
similarity index 95%
rename from app/code/Magento/Signifyd/Model/Validators/CaseDataValidator.php
rename to app/code/Magento/Signifyd/Model/Validators/CaseIdValidator.php
index 9827984956f54..2dea2b30235c3 100644
--- a/app/code/Magento/Signifyd/Model/Validators/CaseDataValidator.php
+++ b/app/code/Magento/Signifyd/Model/Validators/CaseIdValidator.php
@@ -8,7 +8,7 @@
/**
* Validates Signifyd Case id field.
*/
-class CaseDataValidator
+class CaseIdValidator
{
/**
* Checks if data object contains Signifyd Case id.
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/CaseUpdatingServiceTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/CaseUpdatingServiceTest.php
index 49d5fb676a71b..2d09cbc8a540b 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/CaseUpdatingServiceTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/CaseUpdatingServiceTest.php
@@ -12,7 +12,7 @@
use Magento\Signifyd\Model\CommentsHistoryUpdater;
use Magento\Signifyd\Model\MessageGeneratorException;
use Magento\Signifyd\Model\MessageGeneratorInterface;
-use Magento\Signifyd\Model\Validators\CaseDataValidator;
+use Magento\Signifyd\Model\Validators\CaseIdValidator;
use PHPUnit_Framework_MockObject_MockObject as MockObject;
/**
@@ -41,9 +41,9 @@ class CaseUpdatingServiceTest extends \PHPUnit_Framework_TestCase
private $caseRepository;
/**
- * @var CaseDataValidator|MockObject
+ * @var CaseIdValidator|MockObject
*/
- private $caseDataValidator;
+ private $caseIdValidator;
/**
* @var CommentsHistoryUpdater|MockObject
@@ -67,7 +67,7 @@ protected function setUp()
->setMethods(['getByCaseId'])
->getMockForAbstractClass();
- $this->caseDataValidator = $this->getMockBuilder(CaseDataValidator::class)
+ $this->caseIdValidator = $this->getMockBuilder(CaseIdValidator::class)
->disableOriginalConstructor()
->setMethods(['validate'])
->getMock();
@@ -80,7 +80,7 @@ protected function setUp()
$this->service = $this->objectManager->getObject(CaseUpdatingService::class, [
'messageGenerator' => $this->messageGenerator,
'caseRepository' => $this->caseRepository,
- 'caseDataValidator' => $this->caseDataValidator,
+ 'caseIdValidator' => $this->caseIdValidator,
'commentsHistoryUpdater' => $this->commentsHistoryUpdater
]);
}
@@ -95,7 +95,7 @@ protected function setUp()
public function testUpdateWithFailedValidation()
{
$data = [];
- $this->caseDataValidator->expects(self::once())
+ $this->caseIdValidator->expects(self::once())
->method('validate')
->with($data)
->willReturn(false);
@@ -117,7 +117,7 @@ public function testUpdateWithNotExistingCase()
'caseId' => $caseId
];
- $this->caseDataValidator->expects(self::once())
+ $this->caseIdValidator->expects(self::once())
->method('validate')
->with($data)
->willReturn(true);
@@ -147,7 +147,7 @@ public function testUpdateWithFailedCaseSaving()
'score' => 500
];
- $this->caseDataValidator->expects(self::once())
+ $this->caseIdValidator->expects(self::once())
->method('validate')
->with($data)
->willReturn(true);
@@ -198,7 +198,7 @@ public function testUpdateWithExceptionFromMessageGenerator()
'caseId' => $caseId
];
- $this->caseDataValidator->expects(self::once())
+ $this->caseIdValidator->expects(self::once())
->method('validate')
->with($data)
->willReturn(true);
@@ -245,7 +245,7 @@ public function testUpdateWithFailedCommentSaving()
'caseId' => $caseId
];
- $this->caseDataValidator->expects(self::once())
+ $this->caseIdValidator->expects(self::once())
->method('validate')
->with($data)
->willReturn(true);
@@ -296,7 +296,7 @@ public function testUpdate()
'caseId' => $caseId
];
- $this->caseDataValidator->expects(self::once())
+ $this->caseIdValidator->expects(self::once())
->method('validate')
->with($data)
->willReturn(true);
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseCreationTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseCreationTest.php
index a268dacd57dd2..1daa58f6917d9 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseCreationTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseCreationTest.php
@@ -6,7 +6,7 @@
namespace Magento\Signifyd\Test\Unit\Model\MessageGenerators;
use Magento\Signifyd\Model\MessageGenerators\CaseCreation;
-use Magento\Signifyd\Model\Validators\CaseDataValidator;
+use Magento\Signifyd\Model\Validators\CaseIdValidator;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
use Magento\Framework\Phrase;
@@ -37,7 +37,7 @@ protected function setUp()
$this->objectManager = new ObjectManager($this);
$this->caseCreation = $this->objectManager->getObject(CaseCreation::class, [
- 'caseDataValidator' => new CaseDataValidator()
+ 'caseIdValidator' => new CaseIdValidator()
]);
}
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseRescoreTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseRescoreTest.php
index a18927b811f3c..21d08fa5afb1f 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseRescoreTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseRescoreTest.php
@@ -6,7 +6,7 @@
namespace Magento\Signifyd\Test\Unit\Model\MessageGenerators;
use Magento\Signifyd\Model\MessageGenerators\CaseRescore;
-use Magento\Signifyd\Model\Validators\CaseDataValidator;
+use Magento\Signifyd\Model\Validators\CaseIdValidator;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
use Magento\Signifyd\Api\CaseRepositoryInterface;
use Magento\Signifyd\Api\Data\CaseInterface;
@@ -58,7 +58,7 @@ protected function setUp()
->getMock();
$this->caseRescore = $this->objectManager->getObject(CaseRescore::class, [
- 'caseDataValidator' => new CaseDataValidator(),
+ 'caseIdValidator' => new CaseIdValidator(),
'caseRepository' => $this->caseRepository
]);
@@ -89,7 +89,7 @@ public function testGenerateNotFoundException()
->willReturn(null);
$this->caseRescore = $this->objectManager->getObject(CaseRescore::class, [
- 'caseDataValidator' => new CaseDataValidator(),
+ 'caseIdValidator' => new CaseIdValidator(),
'caseRepository' => $this->caseRepository
]);
@@ -111,8 +111,8 @@ public function testGenerateWithPreviousScore()
->willReturn($this->case);
$this->caseRescore = $this->objectManager->getObject(CaseRescore::class, [
- 'caseDataValidator' => new CaseDataValidator(),
- 'caseRepository' => $this->caseRepository
+ 'caseIdValidator' => new CaseIdValidator(),
+ 'caseRepository' => $this->caseRepository
]);
$phrase = __(
@@ -137,8 +137,8 @@ public function testGenerateWithoutPreviousScore()
->willReturn($this->case);
$this->caseRescore = $this->objectManager->getObject(CaseRescore::class, [
- 'caseDataValidator' => new CaseDataValidator(),
- 'caseRepository' => $this->caseRepository
+ 'caseIdValidator' => new CaseIdValidator(),
+ 'caseRepository' => $this->caseRepository
]);
$phrase = __(
From 3c578aa8c9d82360fa453683e5186939ac27a98a Mon Sep 17 00:00:00 2001
From: Volodymyr Kublytskyi
Date: Wed, 11 Jan 2017 03:52:18 -0600
Subject: [PATCH 112/904] MAGETWO-62822: Create Guarantee creation service
- fixed doc blocks
---
app/code/Magento/Signifyd/Model/SignifydGateway/Gateway.php | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Gateway.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Gateway.php
index dfd21776e98ad..9e437ecff1be6 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/Gateway.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Gateway.php
@@ -68,6 +68,7 @@ public function __construct(
}
/**
+ * Returns id of created case (investigation) on Signifyd service
* @see https://www.signifyd.com/docs/api/#/reference/cases/create-a-case
*
* @param int $orderId
@@ -92,10 +93,11 @@ public function createCase($orderId)
}
/**
+ * Returns guaranty decision result
* @see https://www.signifyd.com/docs/api/#/reference/guarantees/submit-a-case-for-guarantee
*
* @param int $signifydCaseId
- * @return array
+ * @return string
* @throws GatewayException
*/
public function submitCaseForGuarantee($signifydCaseId)
From a27c6fe5c4a7be533491ab0a882401a6fa728478 Mon Sep 17 00:00:00 2001
From: Dmytro Yushkin
Date: Wed, 11 Jan 2017 04:26:48 -0600
Subject: [PATCH 113/904] MAGETWO-62807: Case information block on order
details page in admin panel
- Covered with integration test
---
.../view/adminhtml/templates/case_info.phtml | 9 +-
.../Signifyd/Block/Adminhtml/CaseInfoTest.php | 112 ++++++++++++++++++
.../Signifyd/Block/FingerprintTest.php | 1 -
3 files changed, 113 insertions(+), 9 deletions(-)
create mode 100644 dev/tests/integration/testsuite/Magento/Signifyd/Block/Adminhtml/CaseInfoTest.php
diff --git a/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml b/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml
index eff571558f2b6..adcbb6f924609 100644
--- a/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml
+++ b/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml
@@ -8,11 +8,9 @@
?>
isModuleActive()) {
+ if (!$block->isModuleActive() || !($case = $block->getCaseEntity())) {
return '';
}
-
- $case = $block->getCaseEntity();
?>
-
escapeHtml($case->getStatus()); ?>
@@ -45,10 +42,6 @@
escapeHtml($case->getUpdatedAt()); ?>
-
-
-
-
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Block/Adminhtml/CaseInfoTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Block/Adminhtml/CaseInfoTest.php
new file mode 100644
index 0000000000000..52cb4865eff96
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Block/Adminhtml/CaseInfoTest.php
@@ -0,0 +1,112 @@
+loadArea(Area::AREA_ADMINHTML);
+
+ $objectManager = Bootstrap::getObjectManager();
+ $this->order = $objectManager->create(Order::class);
+ $this->registry = $objectManager->get(Registry::class);
+ $this->layout = $objectManager->get(LayoutInterface::class);
+ }
+
+ /**
+ * Checks that block does not give contents
+ * if Signifyd module is inactive.
+ *
+ * @covers \Magento\Signifyd\Block\Adminhtml\CaseInfo::isModuleActive
+ * @magentoConfigFixture current_store fraud_protection/signifyd/active 0
+ */
+ public function testModuleIsInactive()
+ {
+ static::assertEmpty($this->getBlockContents());
+ }
+
+ /**
+ * Checks that block does not give contents
+ * if there is no case entity created for order.
+ *
+ * @covers \Magento\Signifyd\Block\Adminhtml\CaseInfo::getCaseEntity
+ * @magentoConfigFixture current_store fraud_protection/signifyd/active 1
+ * @magentoDataFixture Magento/Signifyd/_files/order_with_customer_and_two_simple_products.php
+ */
+ public function testCaseEntityNotExists()
+ {
+ $this->registry->register('current_order', $this->order->loadByIncrementId('100000001'));
+
+ static::assertEmpty($this->getBlockContents());
+ }
+
+ /**
+ * Checks that:
+ * - block give contents
+ * - associated team displays correct
+ * - score class displays correct
+ *
+ * @covers \Magento\Signifyd\Block\Adminhtml\CaseInfo::getAssociatedTeam
+ * @covers \Magento\Signifyd\Block\Adminhtml\CaseInfo::getScoreClass
+ * @magentoConfigFixture current_store fraud_protection/signifyd/active 1
+ * @magentoDataFixture Magento/Signifyd/_files/case.php
+ */
+ public function testCaseEntityExists()
+ {
+ $this->registry->register('current_order', $this->order->loadByIncrementId('100000001'));
+
+ $html = $this->getBlockContents();
+ static::assertNotEmpty($html);
+ static::assertContains('Some Team', $html);
+ static::assertContains('col-case-score-green', $html);
+ }
+
+ /**
+ * Renders block contents.
+ *
+ * @return string
+ */
+ private function getBlockContents()
+ {
+ /** @var CaseInfo $block */
+ $block = $this->layout->createBlock(CaseInfo::class, 'order_case_info');
+ $block->setTemplate('Magento_Signifyd::case_info.phtml');
+
+ /** @var OrderTabInfo $parent */
+ $parent = $this->layout->createBlock(OrderTabInfo::class, 'order_tab_info');
+ $parent->setChild('order_case_info', $block);
+
+ return $block->toHtml();
+ }
+}
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Block/FingerprintTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Block/FingerprintTest.php
index 6708af55dddf9..a9780a560381f 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Block/FingerprintTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Block/FingerprintTest.php
@@ -8,7 +8,6 @@
use Magento\Framework\App\Area;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\View\LayoutInterface;
-use Magento\Signifyd\Block\Fingerprint;
use Magento\TestFramework\Helper\Bootstrap;
class FingerprintTest extends \PHPUnit_Framework_TestCase
From 34dcb55f526269138bc86888f3fee1cc20c8abd8 Mon Sep 17 00:00:00 2001
From: Volodymyr Kublytskyi
Date: Wed, 11 Jan 2017 04:42:33 -0600
Subject: [PATCH 114/904] MAGETWO-62822: Create Guarantee creation service
- refactored unit test for more explicit failure reason
---
.../Unit/Model/SignifydGateway/GatewayTest.php | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/GatewayTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/GatewayTest.php
index f84300af354bd..b8bc60ebf77e9 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/GatewayTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/GatewayTest.php
@@ -271,12 +271,15 @@ public function testSubmitCaseForGuaranteeWithExpectedDisposition($dummyExpected
'disposition' => $dummyExpectedDisposition,
]);
- $actualDisposition = $this->gateway->submitCaseForGuarantee($dummySygnifydCaseId);
- $this->assertEquals(
- $dummyExpectedDisposition,
- $actualDisposition,
- 'Expected disposition should be return from method'
- );
+ try {
+ $this->gateway->submitCaseForGuarantee($dummySygnifydCaseId);
+ } catch (GatewayException $e) {
+ $this->fail(sprintf(
+ 'Expected disposition "%s" was not accepted with message "%s"',
+ $dummyExpectedDisposition,
+ $e->getMessage()
+ ));
+ }
}
public function supportedGuaranteeDispositionsProvider()
From 1ba93c37ea8e4e728fb5e0a52837aaf07726790c Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Wed, 11 Jan 2017 05:12:32 -0600
Subject: [PATCH 115/904] MAGETWO-62823: Update case entity on Guarantee
creation
- Updated service according to gateway changes
---
.../Signifyd/Model/Guarantee/CreationService.php | 12 ++++++++++--
.../Model/Guarantee/CreationServiceTest.php | 13 +++----------
2 files changed, 13 insertions(+), 12 deletions(-)
diff --git a/app/code/Magento/Signifyd/Model/Guarantee/CreationService.php b/app/code/Magento/Signifyd/Model/Guarantee/CreationService.php
index 574972289188c..18e500446b105 100644
--- a/app/code/Magento/Signifyd/Model/Guarantee/CreationService.php
+++ b/app/code/Magento/Signifyd/Model/Guarantee/CreationService.php
@@ -6,12 +6,12 @@
namespace Magento\Signifyd\Model\Guarantee;
use Magento\Framework\Exception\LocalizedException;
+use Magento\Signifyd\Model\CaseManagement;
use Magento\Signifyd\Model\CaseUpdatingServiceFactory;
use Magento\Signifyd\Model\SignifydGateway\ApiCallException;
use Magento\Signifyd\Model\SignifydGateway\Gateway;
use Magento\Signifyd\Model\SignifydGateway\GatewayException;
use Psr\Log\LoggerInterface;
-use Magento\Signifyd\Model\CaseManagement;
/**
* Register guarantee at Signifyd and updates case entity
@@ -74,7 +74,15 @@ public function create($orderId)
$updatingService = $this->caseUpdatingServiceFactory->create('guarantees/creation');
try {
- $data = $this->gateway->submitCaseForGuarantee($caseEntity->getCaseId());
+ $disposition = $this->gateway->submitCaseForGuarantee($caseEntity->getCaseId());
+ if (!$disposition) {
+ $this->logger->error("Cannot retrieve guarantee disposition for case: {$caseEntity->getEntityId()}.");
+ return false;
+ }
+ $data = [
+ 'caseId' => $caseEntity->getCaseId(),
+ 'guaranteeDisposition' => $disposition
+ ];
$updatingService->update($data);
} catch (ApiCallException $e) {
$this->logger->error($e->getMessage());
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Model/Guarantee/CreationServiceTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Model/Guarantee/CreationServiceTest.php
index c9ee755912e2f..be529923f2fae 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Model/Guarantee/CreationServiceTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/Guarantee/CreationServiceTest.php
@@ -120,11 +120,11 @@ public function testCreateWithFailedCaseUpdating()
$this->gateway->expects(self::once())
->method('submitCaseForGuarantee')
->with($caseEntity->getCaseId())
- ->willReturn([]);
+ ->willReturn('');
$this->logger->expects(self::once())
->method('error')
- ->with('The "caseId" should not be empty.');
+ ->with('Cannot retrieve guarantee disposition for case: ' . $caseEntity->getEntityId() . '.');
$result = $this->service->create($caseEntity->getOrderId());
self::assertFalse($result);
@@ -140,16 +140,11 @@ public function testCreateWithFailedCaseUpdating()
public function testCreate()
{
$caseEntity = $this->getCaseEntity();
- $data = [
- 'caseId' => $caseEntity->getCaseId(),
- 'guaranteeEligible' => true,
- 'guaranteeDisposition' => CaseInterface::GUARANTEE_IN_REVIEW
- ];
$this->gateway->expects(self::once())
->method('submitCaseForGuarantee')
->with($caseEntity->getCaseId())
- ->willReturn($data);
+ ->willReturn(CaseInterface::GUARANTEE_IN_REVIEW);
$this->logger->expects(self::never())
->method('error');
@@ -159,7 +154,6 @@ public function testCreate()
$updatedCase = $this->getCaseEntity();
self::assertEquals(CaseInterface::GUARANTEE_IN_REVIEW, $updatedCase->getGuaranteeDisposition());
- self::assertTrue((bool) $updatedCase->isGuaranteeEligible());
self::assertEquals(CaseInterface::STATUS_PROCESSING, $updatedCase->getStatus());
/** @var OrderRepositoryInterface $orderRepository */
@@ -168,7 +162,6 @@ public function testCreate()
$histories = $order->getStatusHistories();
static::assertNotEmpty($histories);
-
/** @var OrderStatusHistoryInterface $caseCreationComment */
$caseCreationComment = array_pop($histories);
static::assertInstanceOf(OrderStatusHistoryInterface::class, $caseCreationComment);
From 1ffffac9a7a6264bec1eada0aab4db532afd1187 Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Wed, 11 Jan 2017 05:52:28 -0600
Subject: [PATCH 116/904] MAGETWO-62807: Case information block on order
details page in admin panel
- copyrights
---
app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php | 2 +-
.../Magento/Signifyd/view/adminhtml/layout/sales_order_view.xml | 2 +-
.../Magento/Signifyd/view/adminhtml/templates/case_info.phtml | 2 +-
.../testsuite/Magento/Signifyd/Block/Adminhtml/CaseInfoTest.php | 2 +-
.../testsuite/Magento/Signifyd/Block/FingerprintTest.php | 2 +-
5 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php b/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php
index 2a61f66144ed2..febea5219a2a4 100644
--- a/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php
+++ b/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php
@@ -1,6 +1,6 @@
diff --git a/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml b/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml
index adcbb6f924609..be4a8d993d0ff 100644
--- a/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml
+++ b/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml
@@ -1,6 +1,6 @@
Date: Wed, 11 Jan 2017 07:18:40 -0600
Subject: [PATCH 117/904] MAGETWO-62806: Update case entity
- Renamed method
---
app/code/Magento/Signifyd/Model/CaseUpdatingService.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/app/code/Magento/Signifyd/Model/CaseUpdatingService.php b/app/code/Magento/Signifyd/Model/CaseUpdatingService.php
index a4ca6b8b716a7..69263c9fef970 100644
--- a/app/code/Magento/Signifyd/Model/CaseUpdatingService.php
+++ b/app/code/Magento/Signifyd/Model/CaseUpdatingService.php
@@ -76,7 +76,7 @@ public function update(array $data)
}
try {
- $this->prepareCaseData($case, $data);
+ $this->setCaseData($case, $data);
$orderHistoryComment = $this->messageGenerator->generate($data);
$this->caseRepository->save($case);
$this->commentsHistoryUpdater->addComment($case, $orderHistoryComment);
@@ -92,7 +92,7 @@ public function update(array $data)
* @param array $data
* @return void
*/
- private function prepareCaseData(CaseInterface $case, array $data)
+ private function setCaseData(CaseInterface $case, array $data)
{
// list of keys which should not be replaced, like order id
$notResolvedKeys = [
From 8b47d09e57e0b5fa9467fa9e889b08018f89890f Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Wed, 11 Jan 2017 09:19:20 -0600
Subject: [PATCH 118/904] MAGETWO-62821: Controller to submit for Guarantee
- Fix static
---
.../Signifyd/Controller/Adminhtml/Guarantee/CreateTest.php | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Controller/Adminhtml/Guarantee/CreateTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Controller/Adminhtml/Guarantee/CreateTest.php
index 46c7464105ff6..7375ff8c6d983 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Controller/Adminhtml/Guarantee/CreateTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Controller/Adminhtml/Guarantee/CreateTest.php
@@ -1,7 +1,6 @@
Date: Wed, 11 Jan 2017 10:28:54 -0600
Subject: [PATCH 119/904] MAGETWO-62806: Update case entity
- Simplified messages generators
- Removed case id validator
---
.../Signifyd/Model/CaseUpdatingService.php | 11 +--
.../Model/MessageGenerators/BaseGenerator.php | 58 +++++++++++++
.../Model/MessageGenerators/CaseCreation.php | 43 ----------
.../Model/MessageGenerators/CaseRescore.php | 12 +--
.../Model/MessageGenerators/CaseReview.php | 30 -------
.../MessageGenerators/GeneratorFactory.php | 23 +++--
.../MessageGenerators/GuaranteeCompletion.php | 27 ------
.../MessageGenerators/GuaranteeCreation.php | 22 -----
.../Model/Validators/CaseIdValidator.php | 26 ------
.../Unit/Model/CaseUpdatingServiceTest.php | 41 ---------
.../MessageGenerators/BaseGeneratorTest.php | 83 +++++++++++++++++++
.../MessageGenerators/CaseCreationTest.php | 81 ------------------
.../MessageGenerators/CaseRescoreTest.php | 15 ++--
.../MessageGenerators/CaseReviewTest.php | 73 ----------------
.../GeneratorFactoryTest.php | 15 ++--
.../GuaranteeCompletionTest.php | 70 ----------------
.../GuaranteeCreationTest.php | 46 ----------
.../Model/CaseUpdatingServiceTest.php | 5 +-
18 files changed, 177 insertions(+), 504 deletions(-)
create mode 100644 app/code/Magento/Signifyd/Model/MessageGenerators/BaseGenerator.php
delete mode 100644 app/code/Magento/Signifyd/Model/MessageGenerators/CaseCreation.php
delete mode 100644 app/code/Magento/Signifyd/Model/MessageGenerators/CaseReview.php
delete mode 100644 app/code/Magento/Signifyd/Model/MessageGenerators/GuaranteeCompletion.php
delete mode 100644 app/code/Magento/Signifyd/Model/MessageGenerators/GuaranteeCreation.php
delete mode 100644 app/code/Magento/Signifyd/Model/Validators/CaseIdValidator.php
create mode 100644 app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/BaseGeneratorTest.php
delete mode 100644 app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseCreationTest.php
delete mode 100644 app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseReviewTest.php
delete mode 100644 app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/GuaranteeCompletionTest.php
delete mode 100644 app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/GuaranteeCreationTest.php
diff --git a/app/code/Magento/Signifyd/Model/CaseUpdatingService.php b/app/code/Magento/Signifyd/Model/CaseUpdatingService.php
index 69263c9fef970..bf39d2356a28d 100644
--- a/app/code/Magento/Signifyd/Model/CaseUpdatingService.php
+++ b/app/code/Magento/Signifyd/Model/CaseUpdatingService.php
@@ -9,7 +9,6 @@
use Magento\Framework\Exception\NotFoundException;
use Magento\Signifyd\Api\CaseRepositoryInterface;
use Magento\Signifyd\Api\Data\CaseInterface;
-use Magento\Signifyd\Model\Validators\CaseIdValidator;
/**
* Performs Signifyd case entity updating operations.
@@ -26,11 +25,6 @@ class CaseUpdatingService implements CaseUpdatingServiceInterface
*/
private $caseRepository;
- /**
- * @var CaseIdValidator
- */
- private $caseIdValidator;
-
/**
* @var CommentsHistoryUpdater
*/
@@ -41,18 +35,15 @@ class CaseUpdatingService implements CaseUpdatingServiceInterface
*
* @param MessageGeneratorInterface $messageGenerator
* @param CaseRepositoryInterface $caseRepository
- * @param CaseIdValidator $caseIdValidator
* @param CommentsHistoryUpdater $commentsHistoryUpdater
*/
public function __construct(
MessageGeneratorInterface $messageGenerator,
CaseRepositoryInterface $caseRepository,
- CaseIdValidator $caseIdValidator,
CommentsHistoryUpdater $commentsHistoryUpdater
) {
$this->messageGenerator = $messageGenerator;
$this->caseRepository = $caseRepository;
- $this->caseIdValidator = $caseIdValidator;
$this->commentsHistoryUpdater = $commentsHistoryUpdater;
}
@@ -66,7 +57,7 @@ public function __construct(
*/
public function update(array $data)
{
- if (!$this->caseIdValidator->validate($data)) {
+ if (empty($data['caseId'])) {
throw new LocalizedException(__('The "%1" should not be empty.', 'caseId'));
}
diff --git a/app/code/Magento/Signifyd/Model/MessageGenerators/BaseGenerator.php b/app/code/Magento/Signifyd/Model/MessageGenerators/BaseGenerator.php
new file mode 100644
index 0000000000000..b76a0885a3611
--- /dev/null
+++ b/app/code/Magento/Signifyd/Model/MessageGenerators/BaseGenerator.php
@@ -0,0 +1,58 @@
+template = $template;
+ $this->requiredParams = $requiredParams;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function generate(array $data)
+ {
+ $placeholders = [];
+ foreach ($this->requiredParams as $param) {
+ if (empty($data[$param])) {
+ throw new MessageGeneratorException(__('The "%1" should not be empty.', $param));
+ }
+ $placeholders[] = $data[$param];
+ }
+ return __($this->template, ...$placeholders);
+ }
+}
diff --git a/app/code/Magento/Signifyd/Model/MessageGenerators/CaseCreation.php b/app/code/Magento/Signifyd/Model/MessageGenerators/CaseCreation.php
deleted file mode 100644
index a9affc97bbe4a..0000000000000
--- a/app/code/Magento/Signifyd/Model/MessageGenerators/CaseCreation.php
+++ /dev/null
@@ -1,43 +0,0 @@
-caseIdValidator = $caseIdValidator;
- }
-
- /**
- * @inheritdoc
- */
- public function generate(array $data)
- {
- if (!$this->caseIdValidator->validate($data)) {
- throw new MessageGeneratorException(__('The "%1" should not be empty.', 'caseId'));
- }
-
- return __('Signifyd Case %1 has been created for order.', $data['caseId']);
- }
-}
diff --git a/app/code/Magento/Signifyd/Model/MessageGenerators/CaseRescore.php b/app/code/Magento/Signifyd/Model/MessageGenerators/CaseRescore.php
index b2ff54c5c1c3b..c62d4334755ed 100644
--- a/app/code/Magento/Signifyd/Model/MessageGenerators/CaseRescore.php
+++ b/app/code/Magento/Signifyd/Model/MessageGenerators/CaseRescore.php
@@ -8,7 +8,6 @@
use Magento\Signifyd\Api\CaseRepositoryInterface;
use Magento\Signifyd\Model\MessageGeneratorException;
use Magento\Signifyd\Model\MessageGeneratorInterface;
-use Magento\Signifyd\Model\Validators\CaseIdValidator;
/**
* Generates message based on previous and current Case scores.
@@ -20,21 +19,14 @@ class CaseRescore implements MessageGeneratorInterface
*/
private $caseRepository;
- /**
- * @var CaseIdValidator
- */
- private $caseIdValidator;
-
/**
* CaseRescore constructor.
*
* @param CaseRepositoryInterface $caseRepository
- * @param CaseIdValidator $caseIdValidator
*/
- public function __construct(CaseRepositoryInterface $caseRepository, CaseIdValidator $caseIdValidator)
+ public function __construct(CaseRepositoryInterface $caseRepository)
{
$this->caseRepository = $caseRepository;
- $this->caseIdValidator = $caseIdValidator;
}
/**
@@ -42,7 +34,7 @@ public function __construct(CaseRepositoryInterface $caseRepository, CaseIdValid
*/
public function generate(array $data)
{
- if (!$this->caseIdValidator->validate($data)) {
+ if (empty($data['caseId'])) {
throw new MessageGeneratorException(__('The "%1" should not be empty.', 'caseId'));
}
diff --git a/app/code/Magento/Signifyd/Model/MessageGenerators/CaseReview.php b/app/code/Magento/Signifyd/Model/MessageGenerators/CaseReview.php
deleted file mode 100644
index c34c6592b751d..0000000000000
--- a/app/code/Magento/Signifyd/Model/MessageGenerators/CaseReview.php
+++ /dev/null
@@ -1,30 +0,0 @@
- 'Signifyd Case %1 has been created for order.',
+ 'requiredParams' => ['caseId']
+ ];
break;
case self::$caseRescore:
+ $classConfig = [];
$className = CaseRescore::class;
break;
case self::$caseReview:
- $className = CaseReview::class;
+ $classConfig = [
+ 'template' => 'Case Update: Case Review was completed. Review Deposition is %1.',
+ 'requiredParams' => ['reviewDisposition']
+ ];
break;
case self::$guaranteeCompletion:
- $className = GuaranteeCompletion::class;
+ $classConfig = [
+ 'template' => 'Case Update: Guarantee Disposition is %1.',
+ 'requiredParams' => ['guaranteeDisposition']
+ ];
break;
case self::$guaranteeCreation:
- $className = GuaranteeCreation::class;
+ $classConfig = [
+ 'template' => 'Case Update: Case is submitted for guarantee.'
+ ];
break;
default:
throw new \InvalidArgumentException('Specified message type does not supported.');
}
- return $this->objectManager->create($className);
+ return $this->objectManager->create($className, $classConfig);
}
}
diff --git a/app/code/Magento/Signifyd/Model/MessageGenerators/GuaranteeCompletion.php b/app/code/Magento/Signifyd/Model/MessageGenerators/GuaranteeCompletion.php
deleted file mode 100644
index cfc73922c5d9a..0000000000000
--- a/app/code/Magento/Signifyd/Model/MessageGenerators/GuaranteeCompletion.php
+++ /dev/null
@@ -1,27 +0,0 @@
-setMethods(['getByCaseId'])
->getMockForAbstractClass();
- $this->caseIdValidator = $this->getMockBuilder(CaseIdValidator::class)
- ->disableOriginalConstructor()
- ->setMethods(['validate'])
- ->getMock();
-
$this->commentsHistoryUpdater = $this->getMockBuilder(CommentsHistoryUpdater::class)
->disableOriginalConstructor()
->setMethods(['addComment'])
@@ -80,7 +69,6 @@ protected function setUp()
$this->service = $this->objectManager->getObject(CaseUpdatingService::class, [
'messageGenerator' => $this->messageGenerator,
'caseRepository' => $this->caseRepository,
- 'caseIdValidator' => $this->caseIdValidator,
'commentsHistoryUpdater' => $this->commentsHistoryUpdater
]);
}
@@ -95,10 +83,6 @@ protected function setUp()
public function testUpdateWithFailedValidation()
{
$data = [];
- $this->caseIdValidator->expects(self::once())
- ->method('validate')
- ->with($data)
- ->willReturn(false);
$this->service->update($data);
}
@@ -117,11 +101,6 @@ public function testUpdateWithNotExistingCase()
'caseId' => $caseId
];
- $this->caseIdValidator->expects(self::once())
- ->method('validate')
- ->with($data)
- ->willReturn(true);
-
$this->caseRepository->expects(self::once())
->method('getByCaseId')
->with($caseId)
@@ -147,11 +126,6 @@ public function testUpdateWithFailedCaseSaving()
'score' => 500
];
- $this->caseIdValidator->expects(self::once())
- ->method('validate')
- ->with($data)
- ->willReturn(true);
-
$caseEntity = $this->getMockBuilder(CaseInterface::class)
->disableOriginalConstructor()
->setMethods(['setCaseId', 'setStatus', 'setOrderId', 'setScore'])
@@ -198,11 +172,6 @@ public function testUpdateWithExceptionFromMessageGenerator()
'caseId' => $caseId
];
- $this->caseIdValidator->expects(self::once())
- ->method('validate')
- ->with($data)
- ->willReturn(true);
-
$caseEntity = $this->getMockBuilder(CaseInterface::class)
->disableOriginalConstructor()
->setMethods(['setCaseId'])
@@ -245,11 +214,6 @@ public function testUpdateWithFailedCommentSaving()
'caseId' => $caseId
];
- $this->caseIdValidator->expects(self::once())
- ->method('validate')
- ->with($data)
- ->willReturn(true);
-
$caseEntity = $this->getMockBuilder(CaseInterface::class)
->disableOriginalConstructor()
->setMethods(['setCaseId'])
@@ -296,11 +260,6 @@ public function testUpdate()
'caseId' => $caseId
];
- $this->caseIdValidator->expects(self::once())
- ->method('validate')
- ->with($data)
- ->willReturn(true);
-
$caseEntity = $this->getMockBuilder(CaseInterface::class)
->disableOriginalConstructor()
->setMethods(['setCaseId'])
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/BaseGeneratorTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/BaseGeneratorTest.php
new file mode 100644
index 0000000000000..8005b316f24b8
--- /dev/null
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/BaseGeneratorTest.php
@@ -0,0 +1,83 @@
+generate($data);
+ }
+
+ /**
+ * Checks cases with different template placeholders and input data.
+ *
+ * @covers \Magento\Signifyd\Model\MessageGenerators\BaseGenerator::generate
+ * @param string $template
+ * @param array $requiredFields
+ * @param string $expected
+ * @dataProvider messageDataProvider
+ */
+ public function testGenerate($template, array $requiredFields, $expected)
+ {
+ $data = [
+ 'caseId' => 123,
+ 'reviewDisposition' => 'Good',
+ 'guaranteeDisposition' => 'Approved',
+ 'score' => 500,
+ 'case_score' => 300
+ ];
+
+ $generator = new BaseGenerator($template, $requiredFields);
+ $actual = $generator->generate($data);
+ self::assertEquals($expected, $actual);
+ }
+
+ /**
+ * Get list of variations with message templates, required fields and expected generated messages.
+ *
+ * @return array
+ */
+ public function messageDataProvider()
+ {
+ return [
+ [
+ 'Signifyd Case %1 has been created for order.',
+ ['caseId'],
+ 'Signifyd Case 123 has been created for order.'
+ ],
+ [
+ 'Case Update: Case Review was completed. Review Deposition is %1.',
+ ['reviewDisposition'],
+ 'Case Update: Case Review was completed. Review Deposition is Good.'
+ ],
+ [
+ 'Case Update: New score for the order is %1. Previous score was %2.',
+ ['score', 'case_score'],
+ 'Case Update: New score for the order is 500. Previous score was 300.'
+ ],
+ [
+ 'Case Update: Case is submitted for guarantee.',
+ [],
+ 'Case Update: Case is submitted for guarantee.'
+ ],
+ ];
+ }
+}
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseCreationTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseCreationTest.php
deleted file mode 100644
index 1daa58f6917d9..0000000000000
--- a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseCreationTest.php
+++ /dev/null
@@ -1,81 +0,0 @@
- 100];
-
- /**
- * @var ObjectManager
- */
- private $objectManager;
-
- /**
- * @var CaseCreation
- */
- private $caseCreation;
-
- /**
- * @inheritdoc
- */
- protected function setUp()
- {
- $this->objectManager = new ObjectManager($this);
-
- $this->caseCreation = $this->objectManager->getObject(CaseCreation::class, [
- 'caseIdValidator' => new CaseIdValidator()
- ]);
- }
-
- /**
- * Parameter without required attribute caseId.
- *
- * @expectedException \Magento\Signifyd\Model\MessageGeneratorException
- * @expectedExceptionMessage The "caseId" should not be empty
- */
- public function testGenerateException()
- {
- $this->caseCreation->generate([]);
- }
-
- /**
- * Checks interface generated message.
- *
- * @return Phrase
- */
- public function testGenerateMessageInterface()
- {
- $message = $this->caseCreation->generate(self::$data);
-
- $this->assertInstanceOf(Phrase::class, $message);
-
- return $message;
- }
-
- /**
- * Generates case creation message for created Signifyd properly.
- *
- * @depends testGenerateMessageInterface
- * @param Phrase $message
- */
- public function testGenerate(Phrase $message)
- {
- $phrase = __('Signifyd Case %1 has been created for order.', self::$data['caseId']);
-
- $this->assertEquals($phrase, $message);
- }
-}
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseRescoreTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseRescoreTest.php
index 21d08fa5afb1f..2dc7a4b14c492 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseRescoreTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseRescoreTest.php
@@ -5,11 +5,10 @@
*/
namespace Magento\Signifyd\Test\Unit\Model\MessageGenerators;
-use Magento\Signifyd\Model\MessageGenerators\CaseRescore;
-use Magento\Signifyd\Model\Validators\CaseIdValidator;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
use Magento\Signifyd\Api\CaseRepositoryInterface;
use Magento\Signifyd\Api\Data\CaseInterface;
+use Magento\Signifyd\Model\MessageGenerators\CaseRescore;
use PHPUnit_Framework_MockObject_MockObject as MockObject;
/**
@@ -58,8 +57,7 @@ protected function setUp()
->getMock();
$this->caseRescore = $this->objectManager->getObject(CaseRescore::class, [
- 'caseIdValidator' => new CaseIdValidator(),
- 'caseRepository' => $this->caseRepository
+ 'caseRepository' => $this->caseRepository
]);
}
@@ -67,7 +65,7 @@ protected function setUp()
/**
* Data array without required attribute caseId.
*
- * @expectedException \Magento\Signifyd\Model\MessageGeneratorException
+ * @expectedException \Magento\Signifyd\Model\MessageGeneratorException
* @expectedExceptionMessage The "caseId" should not be empty
*/
public function testGenerateEmptyCaseIdException()
@@ -78,7 +76,7 @@ public function testGenerateEmptyCaseIdException()
/**
* Case entity was not found in DB.
*
- * @expectedException \Magento\Signifyd\Model\MessageGeneratorException
+ * @expectedException \Magento\Signifyd\Model\MessageGeneratorException
* @expectedExceptionMessage Case entity not found.
*/
public function testGenerateNotFoundException()
@@ -89,8 +87,7 @@ public function testGenerateNotFoundException()
->willReturn(null);
$this->caseRescore = $this->objectManager->getObject(CaseRescore::class, [
- 'caseIdValidator' => new CaseIdValidator(),
- 'caseRepository' => $this->caseRepository
+ 'caseRepository' => $this->caseRepository
]);
$this->caseRescore->generate(self::$data);
@@ -111,7 +108,6 @@ public function testGenerateWithPreviousScore()
->willReturn($this->case);
$this->caseRescore = $this->objectManager->getObject(CaseRescore::class, [
- 'caseIdValidator' => new CaseIdValidator(),
'caseRepository' => $this->caseRepository
]);
@@ -137,7 +133,6 @@ public function testGenerateWithoutPreviousScore()
->willReturn($this->case);
$this->caseRescore = $this->objectManager->getObject(CaseRescore::class, [
- 'caseIdValidator' => new CaseIdValidator(),
'caseRepository' => $this->caseRepository
]);
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseReviewTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseReviewTest.php
deleted file mode 100644
index 4bbf45aa77d5f..0000000000000
--- a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseReviewTest.php
+++ /dev/null
@@ -1,73 +0,0 @@
- 100];
-
- /**
- * @var CaseReview
- */
- private $caseReview;
-
- /**
- * @inheritdoc
- */
- protected function setUp()
- {
- $this->caseReview = new CaseReview();
- }
-
- /**
- * Parameter without required attribute reviewDisposition.
- *
- * @expectedException \Magento\Signifyd\Model\MessageGeneratorException
- * @expectedExceptionMessage The "reviewDisposition" should not be empty
- */
- public function testGenerateException()
- {
- $this->caseReview->generate([]);
- }
-
- /**
- * Checks interface generated message.
- *
- * @return \Magento\Framework\Phrase
- */
- public function testGenerateMessageInterface()
- {
- $message = $this->caseReview->generate(self::$data);
-
- $this->assertInstanceOf(Phrase::class, $message);
-
- return $message;
- }
-
- /**
- * Generates Case Review message for created Signifyd properly.
- *
- * @depends testGenerateMessageInterface
- * @param Phrase $message
- */
- public function testGenerate(Phrase $message)
- {
- $phrase = __(
- 'Case Update: Case Review was completed. Review Deposition is %1.',
- __(self::$data['reviewDisposition'])
- );
-
- $this->assertEquals($phrase, $message);
- }
-}
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/GeneratorFactoryTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/GeneratorFactoryTest.php
index ddc71b60b3816..f50b60ca436e2 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/GeneratorFactoryTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/GeneratorFactoryTest.php
@@ -7,12 +7,9 @@
use Magento\Framework\ObjectManagerInterface;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
-use Magento\Signifyd\Model\MessageGenerators\CaseCreation;
+use Magento\Signifyd\Model\MessageGenerators\BaseGenerator;
use Magento\Signifyd\Model\MessageGenerators\CaseRescore;
-use Magento\Signifyd\Model\MessageGenerators\CaseReview;
use Magento\Signifyd\Model\MessageGenerators\GeneratorFactory;
-use Magento\Signifyd\Model\MessageGenerators\GuaranteeCompletion;
-use Magento\Signifyd\Model\MessageGenerators\GuaranteeCreation;
use PHPUnit_Framework_MockObject_MockObject as MockObject;
/**
@@ -67,7 +64,7 @@ public function testCreate($type, $className)
->willReturn($generator);
$instance = $this->factory->create($type);
- static::assertInstanceOf($className, $instance);
+ self::assertInstanceOf($className, $instance);
}
/**
@@ -78,11 +75,11 @@ public function testCreate($type, $className)
public function typeDataProvider()
{
return [
- ['cases/creation', CaseCreation::class],
+ ['cases/creation', BaseGenerator::class],
+ ['cases/review', BaseGenerator::class],
['cases/rescore', CaseRescore::class],
- ['cases/review', CaseReview::class],
- ['guarantees/completion', GuaranteeCompletion::class],
- ['guarantees/creation', GuaranteeCreation::class],
+ ['guarantees/completion', BaseGenerator::class],
+ ['guarantees/creation', BaseGenerator::class],
];
}
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/GuaranteeCompletionTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/GuaranteeCompletionTest.php
deleted file mode 100644
index 801d455b4f076..0000000000000
--- a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/GuaranteeCompletionTest.php
+++ /dev/null
@@ -1,70 +0,0 @@
- 100];
-
- /**
- * @var GuaranteeCompletion
- */
- private $guaranteeCompletion;
-
- /**
- * @inheritdoc
- */
- protected function setUp()
- {
- $this->guaranteeCompletion = new GuaranteeCompletion();
- }
-
- /**
- * Parameter without required attribute guaranteeDisposition.
- *
- * @expectedException \Magento\Signifyd\Model\MessageGeneratorException
- * @expectedExceptionMessage The "guaranteeDisposition" should not be empty
- */
- public function testGenerateException()
- {
- $this->guaranteeCompletion->generate([]);
- }
-
- /**
- * Checks interface generated Guarantee Completion message.
- *
- * @return Phrase
- */
- public function testGenerateMessageInterface()
- {
- $message = $this->guaranteeCompletion->generate(self::$data);
-
- $this->assertInstanceOf(Phrase::class, $message);
-
- return $message;
- }
-
- /**
- * Generates Guarantee Completion message for created Signifyd properly.
- *
- * @depends testGenerateMessageInterface
- * @param Phrase $message
- */
- public function testGenerate(Phrase $message)
- {
- $phrase = __('Case Update: Guarantee Disposition is %1.', __(self::$data['guaranteeDisposition']));
-
- $this->assertEquals($phrase, $message);
- }
-}
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/GuaranteeCreationTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/GuaranteeCreationTest.php
deleted file mode 100644
index dd90e4c57da1d..0000000000000
--- a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/GuaranteeCreationTest.php
+++ /dev/null
@@ -1,46 +0,0 @@
-generate($data);
-
- static::assertEquals($message, $message);
- static::assertInstanceOf(Phrase::class, $message);
- }
-
- /**
- * Gets list of variations for input data.
- *
- * @return array
- */
- public function dataProvider()
- {
- $message = 'Case Update: Case is submitted for guarantee.';
- return [
- [[], $message],
- [['caseId' => 123], $message],
- ];
- }
-}
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseUpdatingServiceTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseUpdatingServiceTest.php
index 25af28570737c..4862c160118d8 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseUpdatingServiceTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseUpdatingServiceTest.php
@@ -11,6 +11,7 @@
use Magento\Signifyd\Api\CaseRepositoryInterface;
use Magento\Signifyd\Api\Data\CaseInterface;
use Magento\Signifyd\Model\MessageGenerators\CaseCreation;
+use Magento\Signifyd\Model\MessageGenerators\GeneratorFactory;
use Magento\TestFramework\Helper\Bootstrap;
/**
@@ -35,7 +36,9 @@ protected function setUp()
{
$this->objectManager = Bootstrap::getObjectManager();
- $messageGenerator = $this->objectManager->create(CaseCreation::class);
+ /** @var GeneratorFactory $messageFactory */
+ $messageFactory = $this->objectManager->get(GeneratorFactory::class);
+ $messageGenerator = $messageFactory->create('cases/creation');
$this->service = $this->objectManager->create(CaseUpdatingService::class, [
'messageGenerator' => $messageGenerator
From c51ec744df6857758e1c24305ccf5c424e20e098 Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Wed, 11 Jan 2017 11:35:35 -0600
Subject: [PATCH 120/904] MAGETWO-62820: Create toolbar button to send
Guarantee request
---
.../Signifyd/Block/Adminhtml/CaseInfo.php | 59 +++++++++++++++++--
.../Model/Guarantee/SubmitEligible.php | 52 ++++++++++++++++
.../view/adminhtml/templates/case_info.phtml | 32 ++++++++++
.../view/adminhtml/web/js/request-send.js | 24 ++++++++
4 files changed, 161 insertions(+), 6 deletions(-)
create mode 100644 app/code/Magento/Signifyd/Model/Guarantee/SubmitEligible.php
create mode 100644 app/code/Magento/Signifyd/view/adminhtml/web/js/request-send.js
diff --git a/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php b/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php
index febea5219a2a4..4fc88a5d4b614 100644
--- a/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php
+++ b/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php
@@ -12,6 +12,7 @@
use Magento\Signifyd\Model\Config;
use Magento\Signifyd\Model\CaseManagement;
use Magento\Signifyd\Api\Data\CaseInterface;
+use Magento\Signifyd\Model\Guarantee\SubmitEligible;
/**
* Get Signifyd Case Info
@@ -28,6 +29,11 @@ class CaseInfo extends AbstractOrder
*/
private $caseManagement;
+ /**
+ * @var SubmitEligible
+ */
+ private $submitEligible;
+
/**
* @var int
*/
@@ -46,6 +52,7 @@ class CaseInfo extends AbstractOrder
* @param Admin $adminHelper
* @param Config $config
* @param CaseManagement $caseManagement
+ * @param SubmitEligible $submitEligible
* @param array $data
*/
public function __construct(
@@ -54,10 +61,12 @@ public function __construct(
Admin $adminHelper,
Config $config,
CaseManagement $caseManagement,
+ SubmitEligible $submitEligible,
array $data = []
) {
$this->config = $config;
$this->caseManagement = $caseManagement;
+ $this->submitEligible = $submitEligible;
parent::__construct($context, $registry, $adminHelper, $data);
}
@@ -95,15 +104,23 @@ public function isModuleActive()
}
/**
- * Gets Case entity associated with order id.
+ * Retrieves current order Id.
+ *
+ * @return integer
+ */
+ public function getOrderId()
+ {
+ return $this->getOrder()->getEntityId();
+ }
+
+ /**
+ * Gets case entity associated with order id.
*
* @return CaseInterface|null
*/
public function getCaseEntity()
{
- return $this->caseManagement->getByOrderId(
- $this->getOrder()->getEntityId()
- );
+ return $this->caseManagement->getByOrderId($this->getOrderId());
}
/**
@@ -118,7 +135,7 @@ public function getGuaranteeEligible(CaseInterface $caseEntity)
}
/**
- * Gets state of case guarantee eligible.
+ * Gets associated team name.
*
* @param CaseInterface $caseEntity
* @return string
@@ -137,7 +154,7 @@ public function getAssociatedTeam(CaseInterface $caseEntity)
/**
* Returns cell class name according to case score value.
- * It could be used by merchant to customize order view skin.
+ * It could be used by merchant to customize order view template.
*
* @param CaseInterface $caseEntity
* @return string
@@ -156,4 +173,34 @@ public function getScoreClass(CaseInterface $caseEntity)
return $result;
}
+
+ /**
+ * Gets configuration of allowed buttons.
+ *
+ * @return array
+ */
+ public function getButtons()
+ {
+ $buttons = [];
+
+ if ($this->submitEligible->check($this->getOrderId())) {
+ $buttons[] = $this->getSubmitButton();
+ }
+
+ return $buttons;
+ }
+
+ /**
+ * Returns configuration for submit Guarantee request button.
+ *
+ * @return array
+ */
+ private function getSubmitButton()
+ {
+ return [
+ 'title' => __('Submit Guarantee request'),
+ 'url' => $this->getUrl('signifyd/guarantee/create'),
+ 'componentName' => 'submit_guarantee_request'
+ ];
+ }
}
diff --git a/app/code/Magento/Signifyd/Model/Guarantee/SubmitEligible.php b/app/code/Magento/Signifyd/Model/Guarantee/SubmitEligible.php
new file mode 100644
index 0000000000000..2571812fff03e
--- /dev/null
+++ b/app/code/Magento/Signifyd/Model/Guarantee/SubmitEligible.php
@@ -0,0 +1,52 @@
+caseManagement = $caseManagement;
+ }
+
+ /**
+ * Checks if Guarantee submit is applicable for order.
+ *
+ * @param integer $orderId
+ * @return bool
+ */
+ public function check($orderId)
+ {
+ $case = $this->getCaseEntity($orderId);
+
+ return true;
+ }
+
+ /**
+ * Retrieves case entity by order id.
+ *
+ * @param integer $orderId
+ * @return CaseInterface|null
+ */
+ private function getCaseEntity($orderId)
+ {
+ return $this->caseManagement->getByOrderId($orderId);
+ }
+}
diff --git a/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml b/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml
index be4a8d993d0ff..8a5a9605dc55a 100644
--- a/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml
+++ b/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml
@@ -43,5 +43,37 @@
+
+ getButtons() as $button):?>
+
+
+
+
+
diff --git a/app/code/Magento/Signifyd/view/adminhtml/web/js/request-send.js b/app/code/Magento/Signifyd/view/adminhtml/web/js/request-send.js
new file mode 100644
index 0000000000000..e68ab939cd4b9
--- /dev/null
+++ b/app/code/Magento/Signifyd/view/adminhtml/web/js/request-send.js
@@ -0,0 +1,24 @@
+/**
+ * Copyright © 2013-2017 Magento, Inc. All rights reserved.
+ * See COPYING.txt for license details.
+ */
+
+define([
+ 'mageUtils',
+ 'Magento_Ui/js/form/components/button'
+], function (utils, Button) {
+ 'use strict';
+
+ return Button.extend({
+
+ /**
+ * Creates and submits form for Guarantee create/cancel
+ */
+ sendRequest: function() {
+ utils.submit({
+ url: this.requestURL,
+ data: this.data
+ });
+ }
+ });
+});
From edfd6ccaf97aac5a36b7bdd2809d3b680772082f Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Wed, 11 Jan 2017 11:57:39 -0600
Subject: [PATCH 121/904] MAGETWO-62806: Update case entity
- Renamed message generator
---
.../Model/MessageGenerators/GeneratorFactory.php | 2 +-
.../{BaseGenerator.php => PatternGenerator.php} | 7 ++++---
.../Model/MessageGenerators/GeneratorFactoryTest.php | 10 +++++-----
...aseGeneratorTest.php => PatternGeneratorTest.php} | 12 ++++++------
4 files changed, 16 insertions(+), 15 deletions(-)
rename app/code/Magento/Signifyd/Model/MessageGenerators/{BaseGenerator.php => PatternGenerator.php} (91%)
rename app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/{BaseGeneratorTest.php => PatternGeneratorTest.php} (83%)
diff --git a/app/code/Magento/Signifyd/Model/MessageGenerators/GeneratorFactory.php b/app/code/Magento/Signifyd/Model/MessageGenerators/GeneratorFactory.php
index 4271605ddd2cb..6f9f855350441 100644
--- a/app/code/Magento/Signifyd/Model/MessageGenerators/GeneratorFactory.php
+++ b/app/code/Magento/Signifyd/Model/MessageGenerators/GeneratorFactory.php
@@ -63,7 +63,7 @@ public function __construct(ObjectManagerInterface $objectManager)
*/
public function create($type)
{
- $className = BaseGenerator::class;
+ $className = PatternGenerator::class;
switch ($type) {
case self::$caseCreation:
$classConfig = [
diff --git a/app/code/Magento/Signifyd/Model/MessageGenerators/BaseGenerator.php b/app/code/Magento/Signifyd/Model/MessageGenerators/PatternGenerator.php
similarity index 91%
rename from app/code/Magento/Signifyd/Model/MessageGenerators/BaseGenerator.php
rename to app/code/Magento/Signifyd/Model/MessageGenerators/PatternGenerator.php
index b76a0885a3611..e69bb565360b7 100644
--- a/app/code/Magento/Signifyd/Model/MessageGenerators/BaseGenerator.php
+++ b/app/code/Magento/Signifyd/Model/MessageGenerators/PatternGenerator.php
@@ -18,7 +18,7 @@
* Message is 'Case Update: New score for the order is %1. Previous score was %2.', then the required params order
* should be ['new_score', 'prev_score'].
*/
-class BaseGenerator implements MessageGeneratorInterface
+class PatternGenerator implements MessageGeneratorInterface
{
/**
* @var string
@@ -31,8 +31,9 @@ class BaseGenerator implements MessageGeneratorInterface
private $requiredParams;
/**
- * BaseGenerator constructor.
- * @param $template
+ * PatternGenerator constructor.
+ *
+ * @param string $template
* @param array $requiredParams
*/
public function __construct($template, array $requiredParams = [])
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/GeneratorFactoryTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/GeneratorFactoryTest.php
index f50b60ca436e2..ff7a6d06f6074 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/GeneratorFactoryTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/GeneratorFactoryTest.php
@@ -7,7 +7,7 @@
use Magento\Framework\ObjectManagerInterface;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
-use Magento\Signifyd\Model\MessageGenerators\BaseGenerator;
+use Magento\Signifyd\Model\MessageGenerators\PatternGenerator;
use Magento\Signifyd\Model\MessageGenerators\CaseRescore;
use Magento\Signifyd\Model\MessageGenerators\GeneratorFactory;
use PHPUnit_Framework_MockObject_MockObject as MockObject;
@@ -75,11 +75,11 @@ public function testCreate($type, $className)
public function typeDataProvider()
{
return [
- ['cases/creation', BaseGenerator::class],
- ['cases/review', BaseGenerator::class],
+ ['cases/creation', PatternGenerator::class],
+ ['cases/review', PatternGenerator::class],
['cases/rescore', CaseRescore::class],
- ['guarantees/completion', BaseGenerator::class],
- ['guarantees/creation', BaseGenerator::class],
+ ['guarantees/completion', PatternGenerator::class],
+ ['guarantees/creation', PatternGenerator::class],
];
}
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/BaseGeneratorTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/PatternGeneratorTest.php
similarity index 83%
rename from app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/BaseGeneratorTest.php
rename to app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/PatternGeneratorTest.php
index 8005b316f24b8..32d3aeec52d36 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/BaseGeneratorTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/PatternGeneratorTest.php
@@ -5,31 +5,31 @@
*/
namespace Magento\Signifyd\Test\Unit\Model\MessageGenerators;
-use Magento\Signifyd\Model\MessageGenerators\BaseGenerator;
+use Magento\Signifyd\Model\MessageGenerators\PatternGenerator;
/**
* Contains tests for different variations like empty data, wrong required arguments, or bad placeholders.
*/
-class BaseGeneratorTest extends \PHPUnit_Framework_TestCase
+class PatternGeneratorTest extends \PHPUnit_Framework_TestCase
{
/**
* Checks an exception if generators does not receives required data.
*
- * @covers \Magento\Signifyd\Model\MessageGenerators\BaseGenerator::generate
+ * @covers \Magento\Signifyd\Model\MessageGenerators\PatternGenerator::generate
* @expectedException \Magento\Signifyd\Model\MessageGeneratorException
* @expectedExceptionMessage The "caseId" should not be empty.
*/
public function testGenerateThrowsException()
{
$data = [];
- $generator = new BaseGenerator('Signifyd Case %1 has been created for order.', ['caseId']);
+ $generator = new PatternGenerator('Signifyd Case %1 has been created for order.', ['caseId']);
$generator->generate($data);
}
/**
* Checks cases with different template placeholders and input data.
*
- * @covers \Magento\Signifyd\Model\MessageGenerators\BaseGenerator::generate
+ * @covers \Magento\Signifyd\Model\MessageGenerators\PatternGenerator::generate
* @param string $template
* @param array $requiredFields
* @param string $expected
@@ -45,7 +45,7 @@ public function testGenerate($template, array $requiredFields, $expected)
'case_score' => 300
];
- $generator = new BaseGenerator($template, $requiredFields);
+ $generator = new PatternGenerator($template, $requiredFields);
$actual = $generator->generate($data);
self::assertEquals($expected, $actual);
}
From fa30953c0b7b776de15174e8636a6ddc56a518da Mon Sep 17 00:00:00 2001
From: Volodymyr Kublytskyi
Date: Thu, 12 Jan 2017 05:04:29 -0600
Subject: [PATCH 122/904] MAGETWO-62822: Create Guarantee creation service
- added API interface for guarantee creation service
- guarantee creation service implementation covered with unit test
- refactoring
---
.../Api/CaseCreationServiceInterface.php | 1 +
.../Signifyd/Api/CaseManagementInterface.php | 7 +-
.../Signifyd/Api/CaseRepositoryInterface.php | 24 +-
.../Api/GuaranteeCreationServiceInterface.php | 27 ++
.../Controller/Adminhtml/Guarantee/Create.php | 2 +-
.../Signifyd/Model/CaseCreationService.php | 9 +-
.../Signifyd/Model/CaseUpdatingService.php | 2 +-
.../Model/Guarantee/CreationService.php | 70 ++---
.../Model/Guarantee/CreationServiceTest.php | 270 ++++++++++++++++++
app/code/Magento/Signifyd/etc/di.xml | 1 +
10 files changed, 353 insertions(+), 60 deletions(-)
create mode 100644 app/code/Magento/Signifyd/Api/GuaranteeCreationServiceInterface.php
create mode 100644 app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CreationServiceTest.php
diff --git a/app/code/Magento/Signifyd/Api/CaseCreationServiceInterface.php b/app/code/Magento/Signifyd/Api/CaseCreationServiceInterface.php
index 7141d76371c06..139e3690403e7 100644
--- a/app/code/Magento/Signifyd/Api/CaseCreationServiceInterface.php
+++ b/app/code/Magento/Signifyd/Api/CaseCreationServiceInterface.php
@@ -20,6 +20,7 @@ interface CaseCreationServiceInterface
*
* @param int $orderId
* @return bool
+ * @throws \Magento\Framework\Exception\NotFoundException If order does not exists
* @throws \Magento\Framework\Exception\AlreadyExistsException If case for $orderId already exists
*/
public function createForOrder($orderId);
diff --git a/app/code/Magento/Signifyd/Api/CaseManagementInterface.php b/app/code/Magento/Signifyd/Api/CaseManagementInterface.php
index 7c0445a4211c7..d02f5b5831413 100644
--- a/app/code/Magento/Signifyd/Api/CaseManagementInterface.php
+++ b/app/code/Magento/Signifyd/Api/CaseManagementInterface.php
@@ -5,8 +5,6 @@
*/
namespace Magento\Signifyd\Api;
-use Magento\Signifyd\Api\Data\CaseInterface;
-
/**
* Signifyd management interface
* Allows to performs operations with Signifyd cases.
@@ -19,7 +17,8 @@ interface CaseManagementInterface
* Creates new Case entity linked to order id.
*
* @param int $orderId
- * @return CaseInterface
+ * @return \Magento\Signifyd\Api\Data\CaseInterface
+ * @throws \Magento\Framework\Exception\NotFoundException If order does not exists
* @throws \Magento\Framework\Exception\AlreadyExistsException If case for $orderId already exists
*/
public function create($orderId);
@@ -28,7 +27,7 @@ public function create($orderId);
* Gets Case entity associated with order id.
*
* @param int $orderId
- * @return CaseInterface|null
+ * @return \Magento\Signifyd\Api\Data\CaseInterface|null
*/
public function getByOrderId($orderId);
}
diff --git a/app/code/Magento/Signifyd/Api/CaseRepositoryInterface.php b/app/code/Magento/Signifyd/Api/CaseRepositoryInterface.php
index e985effe84b59..e265088ff673b 100644
--- a/app/code/Magento/Signifyd/Api/CaseRepositoryInterface.php
+++ b/app/code/Magento/Signifyd/Api/CaseRepositoryInterface.php
@@ -5,10 +5,6 @@
*/
namespace Magento\Signifyd\Api;
-use Magento\Framework\Api\SearchCriteria;
-use Magento\Signifyd\Api\Data\CaseInterface;
-use Magento\Signifyd\Api\Data\CaseSearchResultsInterface;
-
/**
* Signifyd Case repository interface
*
@@ -19,16 +15,16 @@ interface CaseRepositoryInterface
/**
* Saves case entity.
*
- * @param CaseInterface $case
- * @return CaseInterface
+ * @param \Magento\Signifyd\Api\Data\CaseInterface $case
+ * @return \Magento\Signifyd\Api\Data\CaseInterface
*/
- public function save(CaseInterface $case);
+ public function save(\Magento\Signifyd\Api\Data\CaseInterface $case);
/**
* Gets case entity by order id.
*
* @param int $id
- * @return CaseInterface
+ * @return \Magento\Signifyd\Api\Data\CaseInterface
*/
public function getById($id);
@@ -36,23 +32,23 @@ public function getById($id);
* Gets entity by Signifyd case id.
*
* @param int $caseId
- * @return CaseInterface|null
+ * @return \Magento\Signifyd\Api\Data\CaseInterface|null
*/
public function getByCaseId($caseId);
/**
* Deletes case entity.
*
- * @param CaseInterface $case
+ * @param \Magento\Signifyd\Api\Data\CaseInterface $case
* @return bool
*/
- public function delete(CaseInterface $case);
+ public function delete(\Magento\Signifyd\Api\Data\CaseInterface $case);
/**
* Gets list of case entities.
*
- * @param SearchCriteria $searchCriteria
- * @return CaseSearchResultsInterface
+ * @param \Magento\Framework\Api\SearchCriteria $searchCriteria
+ * @return \Magento\Signifyd\Api\Data\CaseSearchResultsInterface
*/
- public function getList(SearchCriteria $searchCriteria);
+ public function getList(\Magento\Framework\Api\SearchCriteria $searchCriteria);
}
diff --git a/app/code/Magento/Signifyd/Api/GuaranteeCreationServiceInterface.php b/app/code/Magento/Signifyd/Api/GuaranteeCreationServiceInterface.php
new file mode 100644
index 0000000000000..ad6d5e8098190
--- /dev/null
+++ b/app/code/Magento/Signifyd/Api/GuaranteeCreationServiceInterface.php
@@ -0,0 +1,27 @@
+setPath('sales/order/view', ['order_id' => $orderId]);
- if ($this->creationService->create($orderId)) {
+ if ($this->creationService->createForOrder($orderId)) {
$this->messageManager->addSuccessMessage(
__('Order has been submitted for Guarantee.')
);
diff --git a/app/code/Magento/Signifyd/Model/CaseCreationService.php b/app/code/Magento/Signifyd/Model/CaseCreationService.php
index 39414d8f84fc1..b546c9c63fe4f 100644
--- a/app/code/Magento/Signifyd/Model/CaseCreationService.php
+++ b/app/code/Magento/Signifyd/Model/CaseCreationService.php
@@ -8,7 +8,6 @@
use Magento\Signifyd\Api\CaseCreationServiceInterface;
use Magento\Signifyd\Api\CaseManagementInterface;
use Magento\Signifyd\Api\CaseRepositoryInterface;
-use Magento\Signifyd\Model\SignifydGateway\ApiCallException;
use Magento\Signifyd\Model\SignifydGateway\Gateway;
use Magento\Signifyd\Model\SignifydGateway\GatewayException;
use Psr\Log\LoggerInterface;
@@ -69,14 +68,14 @@ public function createForOrder($orderId)
try {
$caseId = $this->signifydGateway->createCase($orderId);
- $case->setCaseId($caseId);
- $this->caseRepository->save($case);
- } catch (ApiCallException $e) {
- $this->logger->error($e->getMessage());
} catch (GatewayException $e) {
$this->logger->error($e->getMessage());
+ return true;
}
+ $case->setCaseId($caseId);
+ $this->caseRepository->save($case);
+
return true;
}
}
diff --git a/app/code/Magento/Signifyd/Model/CaseUpdatingService.php b/app/code/Magento/Signifyd/Model/CaseUpdatingService.php
index bf39d2356a28d..22a287357c771 100644
--- a/app/code/Magento/Signifyd/Model/CaseUpdatingService.php
+++ b/app/code/Magento/Signifyd/Model/CaseUpdatingService.php
@@ -52,8 +52,8 @@ public function __construct(
*
* @param array $data
* @return void
- * @throws LocalizedException
* @throws NotFoundException
+ * @throws LocalizedException
*/
public function update(array $data)
{
diff --git a/app/code/Magento/Signifyd/Model/Guarantee/CreationService.php b/app/code/Magento/Signifyd/Model/Guarantee/CreationService.php
index 18e500446b105..e3ca93842f29b 100644
--- a/app/code/Magento/Signifyd/Model/Guarantee/CreationService.php
+++ b/app/code/Magento/Signifyd/Model/Guarantee/CreationService.php
@@ -5,10 +5,11 @@
*/
namespace Magento\Signifyd\Model\Guarantee;
-use Magento\Framework\Exception\LocalizedException;
-use Magento\Signifyd\Model\CaseManagement;
+use Magento\Framework\Exception\AlreadyExistsException;
+use Magento\Framework\Exception\NotFoundException;
+use Magento\Signifyd\Api\GuaranteeCreationServiceInterface;
+use Magento\Signifyd\Api\CaseManagementInterface;
use Magento\Signifyd\Model\CaseUpdatingServiceFactory;
-use Magento\Signifyd\Model\SignifydGateway\ApiCallException;
use Magento\Signifyd\Model\SignifydGateway\Gateway;
use Magento\Signifyd\Model\SignifydGateway\GatewayException;
use Psr\Log\LoggerInterface;
@@ -16,8 +17,13 @@
/**
* Register guarantee at Signifyd and updates case entity
*/
-class CreationService
+class CreationService implements GuaranteeCreationServiceInterface
{
+ /**
+ * @var CaseManagementInterface
+ */
+ private $caseManagement;
+
/**
* @var CaseUpdatingServiceFactory
*/
@@ -33,68 +39,62 @@ class CreationService
*/
private $logger;
- /**
- * @var CaseManagement
- */
- private $caseManagement;
-
/**
* CreationService constructor.
*
+ * @param CaseManagementInterface $caseManagement
* @param CaseUpdatingServiceFactory $caseUpdatingServiceFactory
* @param Gateway $gateway
- * @param CaseManagement $caseManagement
* @param LoggerInterface $logger
*/
public function __construct(
+ CaseManagementInterface $caseManagement,
CaseUpdatingServiceFactory $caseUpdatingServiceFactory,
Gateway $gateway,
- CaseManagement $caseManagement,
LoggerInterface $logger
) {
+ $this->caseManagement = $caseManagement;
$this->caseUpdatingServiceFactory = $caseUpdatingServiceFactory;
$this->gateway = $gateway;
$this->logger = $logger;
- $this->caseManagement = $caseManagement;
}
/**
- * Sends request to Signifyd to create guarantee for a case and updates case entity by retrieved data.
- *
- * @param int $orderId
- * @return bool
+ * @inheritdoc
*/
- public function create($orderId)
+ public function createForOrder($orderId)
{
$caseEntity = $this->caseManagement->getByOrderId($orderId);
if ($caseEntity === null) {
- $this->logger->error("Cannot find case entity for order entity id: {$orderId}");
- return false;
+ throw new NotFoundException(
+ __('Case for order with specified id "%1" is not created', $orderId)
+ );
+ }
+ if ($caseEntity->getCaseId() === null) {
+ throw new NotFoundException(
+ __('Case for order with specified id "%1" is not registered in Signifyd', $orderId)
+ );
+ }
+ if ($caseEntity->getGuaranteeDisposition() !== null) {
+ throw new AlreadyExistsException(
+ __('Guarantee for order "%1" has been created already', $orderId)
+ );
}
- $updatingService = $this->caseUpdatingServiceFactory->create('guarantees/creation');
try {
$disposition = $this->gateway->submitCaseForGuarantee($caseEntity->getCaseId());
- if (!$disposition) {
- $this->logger->error("Cannot retrieve guarantee disposition for case: {$caseEntity->getEntityId()}.");
- return false;
- }
- $data = [
- 'caseId' => $caseEntity->getCaseId(),
- 'guaranteeDisposition' => $disposition
- ];
- $updatingService->update($data);
- } catch (ApiCallException $e) {
- $this->logger->error($e->getMessage());
- return false;
} catch (GatewayException $e) {
$this->logger->error($e->getMessage());
return false;
- } catch (LocalizedException $e) {
- $this->logger->error($e->getMessage());
- return false;
}
+ $updatingService = $this->caseUpdatingServiceFactory->create('guarantees/creation');
+ $data = [
+ 'caseId' => $caseEntity->getCaseId(),
+ 'guaranteeDisposition' => $disposition
+ ];
+ $updatingService->update($data);
+
return true;
}
}
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CreationServiceTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CreationServiceTest.php
new file mode 100644
index 0000000000000..b8ee861c1e5dd
--- /dev/null
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CreationServiceTest.php
@@ -0,0 +1,270 @@
+caseManagement = $this->getMockBuilder(CaseManagementInterface::class)
+ ->getMockForAbstractClass();
+
+ $caseUpdatingServiceFactory = $this->getMockBuilder(CaseUpdatingServiceFactory::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->caseUpdatingService = $this->getMockBuilder(CaseUpdatingServiceInterface::class)
+ ->getMockForAbstractClass();
+ $caseUpdatingServiceFactory
+ ->method('create')
+ ->willReturn($this->caseUpdatingService);
+
+ $this->gateway = $this->getMockBuilder(Gateway::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->logger = $this->getMockBuilder(LoggerInterface::class)
+ ->getMockForAbstractClass();
+
+ $this->service = new CreationService(
+ $this->caseManagement,
+ $caseUpdatingServiceFactory,
+ $this->gateway,
+ $this->logger
+ );
+ }
+
+ public function testCreateForOrderWithoutCase()
+ {
+ $dummyOrderId = 1;
+ $this->withCaseEntityNotExistsForOrderId($dummyOrderId);
+
+ $this->gateway
+ ->expects($this->never())
+ ->method('submitCaseForGuarantee');
+ $this->caseUpdatingService
+ ->expects($this->never())
+ ->method('update');
+ $this->setExpectedException(NotFoundException::class);
+
+ $this->service->createForOrder($dummyOrderId);
+ }
+
+ public function testCreateForOrderWitCase()
+ {
+ $dummyOrderId = 1;
+ $dummyCaseId = 42;
+ $this->withCaseEntityExistsForOrderId(
+ $dummyOrderId,
+ [
+ 'caseId' => $dummyCaseId,
+ ]
+ );
+
+ $this->gateway
+ ->expects($this->once())
+ ->method('submitCaseForGuarantee');
+
+ $this->service->createForOrder($dummyOrderId);
+ }
+
+ public function testCreateForOrderWithGatewayFailure()
+ {
+ $dummyOrderId = 1;
+ $dummyCaseId = 42;
+ $dummyGatewayFailureMessage = 'Everything fails sometimes';
+ $this->withCaseEntityExistsForOrderId(
+ $dummyOrderId,
+ [
+ 'caseId' => $dummyCaseId,
+ ]
+ );
+ $this->withGatewayFailure($dummyGatewayFailureMessage);
+
+ $this->logger
+ ->expects($this->once())
+ ->method('error')
+ ->with($this->equalTo($dummyGatewayFailureMessage));
+ $this->caseUpdatingService
+ ->expects($this->never())
+ ->method('update');
+
+ $result = $this->service->createForOrder($dummyOrderId);
+ $this->assertEquals(
+ false,
+ $result,
+ 'Service should return false in case of gateway failure'
+ );
+ }
+
+ public function testCreateForOrderWithGatewaySuccess()
+ {
+ $dummyOrderId = 1;
+ $dummyCaseId = 42;
+ $dummyGuaranteeDisposition = 'foo';
+ $this->withCaseEntityExistsForOrderId(
+ $dummyOrderId,
+ [
+ 'caseId' => $dummyCaseId,
+ ]
+ );
+ $this->withGatewaySuccess($dummyGuaranteeDisposition);
+
+ $this->caseUpdatingService
+ ->expects($this->once())
+ ->method('update')
+ ->with($this->equalTo([
+ 'caseId' => $dummyCaseId,
+ 'guaranteeDisposition' => $dummyGuaranteeDisposition,
+ ]));
+
+ $this->service->createForOrder($dummyOrderId);
+ }
+
+ public function testCreateForOrderWithCaseUpdate()
+ {
+ $dummyOrderId = 1;
+ $dummyCaseId = 42;
+ $dummyGuaranteeDisposition = 'foo';
+ $this->withCaseEntityExistsForOrderId(
+ $dummyOrderId,
+ [
+ 'caseId' => $dummyCaseId,
+ ]
+ );
+ $this->withGatewaySuccess($dummyGuaranteeDisposition);
+
+
+
+ $result = $this->service->createForOrder($dummyOrderId);
+ $this->assertEquals(
+ true,
+ $result,
+ 'Service should return true in case if case update service is called'
+ );
+ }
+
+ public function testCreateForOrderWithNotRegisteredCase()
+ {
+ $dummyOrderId = 1;
+ $dummyCaseId = null;
+ $this->withCaseEntityExistsForOrderId(
+ $dummyOrderId,
+ [
+ 'caseId' => $dummyCaseId,
+ ]
+ );
+
+ $this->gateway
+ ->expects($this->never())
+ ->method('submitCaseForGuarantee');
+ $this->caseUpdatingService
+ ->expects($this->never())
+ ->method('update');
+ $this->setExpectedException(NotFoundException::class);
+
+ $this->service->createForOrder($dummyOrderId);
+ }
+
+ public function testCreateForOrderWithExistedGuarantee()
+ {
+ $dummyOrderId = 1;
+ $dummyCaseId = 42;
+ $dummyGuarantyDisposition = 'APPROVED';
+ $this->withCaseEntityExistsForOrderId(
+ $dummyOrderId,
+ [
+ 'caseId' => $dummyCaseId,
+ 'guaranteeDisposition' => $dummyGuarantyDisposition
+ ]
+ );
+
+ $this->gateway
+ ->expects($this->never())
+ ->method('submitCaseForGuarantee');
+ $this->caseUpdatingService
+ ->expects($this->never())
+ ->method('update');
+ $this->setExpectedException(AlreadyExistsException::class);
+
+ $this->service->createForOrder($dummyOrderId);
+ }
+
+ private function withCaseEntityNotExistsForOrderId($orderId)
+ {
+ $this->caseManagement
+ ->method('getByOrderId')
+ ->with($this->equalTo($orderId))
+ ->willReturn(null);
+ }
+
+ private function withCaseEntityExistsForOrderId($orderId, array $caseData = [])
+ {
+ $dummyCaseEntity = $this->getMockBuilder(CaseInterface::class)
+ ->getMockForAbstractClass();
+ foreach ($caseData as $caseProperty => $casePropertyValue) {
+ $dummyCaseEntity
+ ->method('get' . ucfirst($caseProperty))
+ ->willReturn($casePropertyValue);
+ }
+
+ $this->caseManagement
+ ->method('getByOrderId')
+ ->with($this->equalTo($orderId))
+ ->willReturn($dummyCaseEntity);
+ }
+
+ private function withGatewayFailure($failureMessage)
+ {
+ $this->gateway
+ ->method('submitCaseForGuarantee')
+ ->willThrowException(new GatewayException($failureMessage));
+ }
+
+ private function withGatewaySuccess($gatewayResult)
+ {
+ $this->gateway
+ ->method('submitCaseForGuarantee')
+ ->willReturn($gatewayResult);
+ }
+}
diff --git a/app/code/Magento/Signifyd/etc/di.xml b/app/code/Magento/Signifyd/etc/di.xml
index 81d157887f7e1..9a2eb0527d63f 100644
--- a/app/code/Magento/Signifyd/etc/di.xml
+++ b/app/code/Magento/Signifyd/etc/di.xml
@@ -11,5 +11,6 @@
+
\ No newline at end of file
From d1b3370c438e63fc380e38969ab1365e726ac80e Mon Sep 17 00:00:00 2001
From: Volodymyr Kublytskyi
Date: Thu, 12 Jan 2017 05:05:17 -0600
Subject: [PATCH 123/904] MAGETWO-62822: Create Guarantee creation service
- refactoring
---
.../Model/Guarantee/CreationServiceTest.php | 19 +++++++------------
1 file changed, 7 insertions(+), 12 deletions(-)
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Model/Guarantee/CreationServiceTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Model/Guarantee/CreationServiceTest.php
index be529923f2fae..0900a9f1a2162 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Model/Guarantee/CreationServiceTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/Guarantee/CreationServiceTest.php
@@ -36,11 +36,6 @@ class CreationServiceTest extends \PHPUnit_Framework_TestCase
*/
private $logger;
- /**
- * @var ObjectManager
- */
- private $objectManager;
-
/**
* @inheritdoc
*/
@@ -68,7 +63,7 @@ protected function setUp()
* Checks a test case, when Signifyd case entity cannot be found
* for a specified order.
*
- * @covers \Magento\Signifyd\Model\Guarantee\CreationService::create
+ * @covers \Magento\Signifyd\Model\Guarantee\CreationService::createForOrder
*/
public function testCreateWithoutCaseEntity()
{
@@ -87,7 +82,7 @@ public function testCreateWithoutCaseEntity()
/**
* Checks a test case, when request is failing.
*
- * @covers \Magento\Signifyd\Model\Guarantee\CreationService::create
+ * @covers \Magento\Signifyd\Model\Guarantee\CreationService::createForOrder
* @magentoDataFixture Magento/Signifyd/_files/case.php
*/
public function testCreateWithFailedRequest()
@@ -102,14 +97,14 @@ public function testCreateWithFailedRequest()
->method('error')
->with('Something wrong');
- $result = $this->service->create($caseEntity->getOrderId());
+ $result = $this->service->createForOrder($caseEntity->getOrderId());
self::assertFalse($result);
}
/**
* Checks a test case, when case entity updating is failed.
*
- * @covers \Magento\Signifyd\Model\Guarantee\CreationService::create
+ * @covers \Magento\Signifyd\Model\Guarantee\CreationService::createForOrder
* @magentoDataFixture Magento/Signifyd/_files/case.php
* @magentoConfigFixture current_store fraud_protection/signifyd/active 1
*/
@@ -126,14 +121,14 @@ public function testCreateWithFailedCaseUpdating()
->method('error')
->with('Cannot retrieve guarantee disposition for case: ' . $caseEntity->getEntityId() . '.');
- $result = $this->service->create($caseEntity->getOrderId());
+ $result = $this->service->createForOrder($caseEntity->getOrderId());
self::assertFalse($result);
}
/**
* Checks a test case, when case entity is updated successfully.
*
- * @covers \Magento\Signifyd\Model\Guarantee\CreationService::create
+ * @covers \Magento\Signifyd\Model\Guarantee\CreationService::createForOrder
* @magentoDataFixture Magento/Signifyd/_files/case.php
* @magentoConfigFixture current_store fraud_protection/signifyd/active 1
*/
@@ -149,7 +144,7 @@ public function testCreate()
$this->logger->expects(self::never())
->method('error');
- $result = $this->service->create($caseEntity->getOrderId());
+ $result = $this->service->createForOrder($caseEntity->getOrderId());
self::assertTrue($result);
$updatedCase = $this->getCaseEntity();
From cd3f77b8460ecf6959e639233d1776f1941a1ba8 Mon Sep 17 00:00:00 2001
From: Dmytro Yushkin
Date: Thu, 12 Jan 2017 05:30:37 -0600
Subject: [PATCH 124/904] MAGETWO-62820: Create toolbar button to send
Guarantee request
- Covered with integration test
---
.../Signifyd/Block/Adminhtml/CaseInfo.php | 24 +++++-----
.../view/adminhtml/templates/case_info.phtml | 2 +-
.../Signifyd/Block/Adminhtml/CaseInfoTest.php | 47 +++++++++++++++----
3 files changed, 52 insertions(+), 21 deletions(-)
diff --git a/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php b/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php
index 4fc88a5d4b614..e46ea352740ca 100644
--- a/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php
+++ b/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php
@@ -103,16 +103,6 @@ public function isModuleActive()
return $this->config->isActive();
}
- /**
- * Retrieves current order Id.
- *
- * @return integer
- */
- public function getOrderId()
- {
- return $this->getOrder()->getEntityId();
- }
-
/**
* Gets case entity associated with order id.
*
@@ -142,7 +132,6 @@ public function getGuaranteeEligible(CaseInterface $caseEntity)
*/
public function getAssociatedTeam(CaseInterface $caseEntity)
{
-
$result = 'unknown';
$team = $caseEntity->getAssociatedTeam();
if (isset($team['teamName'])) {
@@ -200,7 +189,18 @@ private function getSubmitButton()
return [
'title' => __('Submit Guarantee request'),
'url' => $this->getUrl('signifyd/guarantee/create'),
- 'componentName' => 'submit_guarantee_request'
+ 'componentName' => 'submit_guarantee_request',
+ 'orderId' => $this->getOrderId()
];
}
+
+ /**
+ * Retrieves current order Id.
+ *
+ * @return integer
+ */
+ private function getOrderId()
+ {
+ return $this->getOrder()->getEntityId();
+ }
}
diff --git a/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml b/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml
index 8a5a9605dc55a..4ff6820b702dc 100644
--- a/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml
+++ b/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml
@@ -58,7 +58,7 @@
"title": "escapeHtml($button['title']); ?>",
"requestURL": "",
"data": {
- "orderId": "getOrderId(); ?>"
+ "orderId": ""
},
"actions": [
{
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Block/Adminhtml/CaseInfoTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Block/Adminhtml/CaseInfoTest.php
index 95f4fd1f70db2..f05c630c76b21 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Block/Adminhtml/CaseInfoTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Block/Adminhtml/CaseInfoTest.php
@@ -6,7 +6,6 @@
namespace Magento\Signifyd\Block\Adminhtml;
-use Magento\Framework\App\Area;
use Magento\Framework\Registry;
use Magento\Framework\View\LayoutInterface;
use Magento\Sales\Block\Adminhtml\Order\View\Tab\Info as OrderTabInfo;
@@ -35,9 +34,6 @@ class CaseInfoTest extends \PHPUnit_Framework_TestCase
*/
protected function setUp()
{
- $bootstrap = Bootstrap::getInstance();
- $bootstrap->loadArea(Area::AREA_ADMINHTML);
-
$objectManager = Bootstrap::getObjectManager();
$this->order = $objectManager->create(Order::class);
$this->registry = $objectManager->get(Registry::class);
@@ -48,8 +44,9 @@ protected function setUp()
* Checks that block does not give contents
* if Signifyd module is inactive.
*
- * @covers \Magento\Signifyd\Block\Adminhtml\CaseInfo::isModuleActive
+ * @covers CaseInfo::isModuleActive
* @magentoConfigFixture current_store fraud_protection/signifyd/active 0
+ * @magentoAppArea adminhtml
*/
public function testModuleIsInactive()
{
@@ -60,9 +57,10 @@ public function testModuleIsInactive()
* Checks that block does not give contents
* if there is no case entity created for order.
*
- * @covers \Magento\Signifyd\Block\Adminhtml\CaseInfo::getCaseEntity
+ * @covers CaseInfo::getCaseEntity
* @magentoConfigFixture current_store fraud_protection/signifyd/active 1
* @magentoDataFixture Magento/Signifyd/_files/order_with_customer_and_two_simple_products.php
+ * @magentoAppArea adminhtml
*/
public function testCaseEntityNotExists()
{
@@ -77,10 +75,11 @@ public function testCaseEntityNotExists()
* - associated team displays correct
* - score class displays correct
*
- * @covers \Magento\Signifyd\Block\Adminhtml\CaseInfo::getAssociatedTeam
- * @covers \Magento\Signifyd\Block\Adminhtml\CaseInfo::getScoreClass
+ * @covers CaseInfo::getAssociatedTeam
+ * @covers CaseInfo::getScoreClass
* @magentoConfigFixture current_store fraud_protection/signifyd/active 1
* @magentoDataFixture Magento/Signifyd/_files/case.php
+ * @magentoAppArea adminhtml
*/
public function testCaseEntityExists()
{
@@ -92,6 +91,38 @@ public function testCaseEntityExists()
static::assertContains('col-case-score-green', $html);
}
+ /**
+ * Checks that guarantee action buttons is available on order page.
+ *
+ * @covers CaseInfo::getButtons
+ * @magentoConfigFixture current_store fraud_protection/signifyd/active 1
+ * @magentoDataFixture Magento/Signifyd/_files/case.php
+ * @magentoAppArea adminhtml
+ */
+ public function testButtonsAvailable()
+ {
+ $this->registry->register('current_order', $this->order->loadByIncrementId('100000001'));
+
+ static::assertContains('Submit Guarantee request', $this->getBlockContents());
+ }
+
+ /**
+ * Checks that guarantee action buttons is unavailable on order page.
+ *
+ * @covers CaseInfo::getButtons
+ * @magentoConfigFixture current_store fraud_protection/signifyd/active 1
+ * @magentoDataFixture Magento/Signifyd/_files/case.php
+ * @magentoAppArea adminhtml
+ */
+ public function testButtonsUnavailable()
+ {
+ $this->registry->register('current_order', $this->order->loadByIncrementId('100000001'));
+
+ $this->order->setState(Order::STATE_CANCELED);
+
+ static::assertNotContains('Submit Guarantee request', $this->getBlockContents());
+ }
+
/**
* Renders block contents.
*
From 33f9d15ab29f14191d45af7337c9e8a7204e1059 Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Thu, 12 Jan 2017 05:42:21 -0600
Subject: [PATCH 125/904] MAGETWO-62820: Create toolbar button to send
Guarantee request
- unit test and refactoring
---
.../Signifyd/Block/Adminhtml/CaseInfo.php | 4 +-
.../Unit/Block/Adminhtml/CaseInfoTest.php | 78 +++++++++++++++++++
.../view/adminhtml/templates/case_info.phtml | 2 +-
3 files changed, 81 insertions(+), 3 deletions(-)
create mode 100644 app/code/Magento/Signifyd/Test/Unit/Block/Adminhtml/CaseInfoTest.php
diff --git a/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php b/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php
index e46ea352740ca..fe0960282218c 100644
--- a/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php
+++ b/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php
@@ -94,11 +94,11 @@ protected function _beforeToHtml()
}
/**
- * Checks if module is enabled.
+ * Checks if service is enabled.
*
* @return boolean
*/
- public function isModuleActive()
+ public function isServiceActive()
{
return $this->config->isActive();
}
diff --git a/app/code/Magento/Signifyd/Test/Unit/Block/Adminhtml/CaseInfoTest.php b/app/code/Magento/Signifyd/Test/Unit/Block/Adminhtml/CaseInfoTest.php
new file mode 100644
index 0000000000000..5384ce749a0bd
--- /dev/null
+++ b/app/code/Magento/Signifyd/Test/Unit/Block/Adminhtml/CaseInfoTest.php
@@ -0,0 +1,78 @@
+caseEntity = $this->getMockBuilder(CaseInterface::class)
+ ->disableOriginalConstructor()
+ ->setMethods(['getScore'])
+ ->getMockForAbstractClass();
+
+ $this->caseInfo = $objectManager->getObject(CaseInfo::class);
+ }
+
+ /**
+ * Checks css class according to case entity score value.
+ *
+ * @param integer $score
+ * @param string $expectedClassName
+ * @covers \Magento\Signifyd\Block\CaseInfo::getScoreClass
+ * @dataProvider getScoreClassDataProvider
+ */
+ public function testGetScoreClass($score, $expectedClassName)
+ {
+ $this->caseEntity->expects($this->once())
+ ->method('getScore')
+ ->willReturn($score);
+
+ self::assertEquals(
+ $expectedClassName,
+ $this->caseInfo->getScoreClass($this->caseEntity)
+ );
+ }
+
+ /**
+ * Case scores and corresponding class name data provider
+
+ * @return array
+ */
+ public function getScoreClassDataProvider()
+ {
+ return [
+ [300, 'red'],
+ [400, 'yellow'],
+ [500, 'green'],
+ ];
+ }
+}
diff --git a/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml b/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml
index 4ff6820b702dc..98b2b63224d4f 100644
--- a/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml
+++ b/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml
@@ -8,7 +8,7 @@
?>
isModuleActive() || !($case = $block->getCaseEntity())) {
+ if (!$block->isServiceActive() || !($case = $block->getCaseEntity())) {
return '';
}
?>
From 2e080f535fff447cf23e7ffb93762d77071f8afb Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Thu, 12 Jan 2017 06:28:25 -0600
Subject: [PATCH 126/904] MAGETWO-62825: Guarantee creation possibility
validator
-Add class for checking submit guarantee possibility
---
.../Signifyd/Block/Adminhtml/CaseInfo.php | 14 +--
.../Model/Guarantee/SubmitEligible.php | 88 ++++++++++++++++---
2 files changed, 84 insertions(+), 18 deletions(-)
diff --git a/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php b/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php
index fe0960282218c..9684a8bd10789 100644
--- a/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php
+++ b/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php
@@ -12,7 +12,7 @@
use Magento\Signifyd\Model\Config;
use Magento\Signifyd\Model\CaseManagement;
use Magento\Signifyd\Api\Data\CaseInterface;
-use Magento\Signifyd\Model\Guarantee\SubmitEligible;
+use Magento\Signifyd\Model\Guarantee\SubmitEligible as GuaranteeSubmitEligible;
/**
* Get Signifyd Case Info
@@ -30,9 +30,9 @@ class CaseInfo extends AbstractOrder
private $caseManagement;
/**
- * @var SubmitEligible
+ * @var GuaranteeSubmitEligible
*/
- private $submitEligible;
+ private $guaranteeSubmitEligible;
/**
* @var int
@@ -52,7 +52,7 @@ class CaseInfo extends AbstractOrder
* @param Admin $adminHelper
* @param Config $config
* @param CaseManagement $caseManagement
- * @param SubmitEligible $submitEligible
+ * @param GuaranteeSubmitEligible $guaranteeSubmitEligible
* @param array $data
*/
public function __construct(
@@ -61,12 +61,12 @@ public function __construct(
Admin $adminHelper,
Config $config,
CaseManagement $caseManagement,
- SubmitEligible $submitEligible,
+ GuaranteeSubmitEligible $guaranteeSubmitEligible,
array $data = []
) {
$this->config = $config;
$this->caseManagement = $caseManagement;
- $this->submitEligible = $submitEligible;
+ $this->guaranteeSubmitEligible = $guaranteeSubmitEligible;
parent::__construct($context, $registry, $adminHelper, $data);
}
@@ -172,7 +172,7 @@ public function getButtons()
{
$buttons = [];
- if ($this->submitEligible->check($this->getOrderId())) {
+ if ($this->guaranteeSubmitEligible->check($this->getOrderId())) {
$buttons[] = $this->getSubmitButton();
}
diff --git a/app/code/Magento/Signifyd/Model/Guarantee/SubmitEligible.php b/app/code/Magento/Signifyd/Model/Guarantee/SubmitEligible.php
index 2571812fff03e..5e216a49c281d 100644
--- a/app/code/Magento/Signifyd/Model/Guarantee/SubmitEligible.php
+++ b/app/code/Magento/Signifyd/Model/Guarantee/SubmitEligible.php
@@ -5,9 +5,17 @@
*/
namespace Magento\Signifyd\Model\Guarantee;
+use Magento\Framework\Exception\InputException;
+use Magento\Framework\Exception\NoSuchEntityException;
+use Magento\Framework\Intl\DateTimeFactory;
+use Magento\Sales\Api\Data\OrderInterface;
+use Magento\Sales\Api\OrderRepositoryInterface;
+use Magento\Sales\Model\Order;
use Magento\Signifyd\Model\CaseManagement;
-use Magento\Signifyd\Api\Data\CaseInterface;
+/**
+ * Checks if is possible to submit guarantee request for order.
+ */
class SubmitEligible
{
/**
@@ -16,37 +24,95 @@ class SubmitEligible
private $caseManagement;
/**
- * SubmitEligible constructor.
+ * @var OrderRepositoryInterface
+ */
+ private $orderRepository;
+
+ /**
+ * @var DateTimeFactory
+ */
+ private $dateTimeFactory;
+
+ /**
+ * Eligible count of days from the order date to submit a case for Guarantee.
*
+ * @var int
+ */
+ private static $guarantyEligibleDays = 7;
+
+ /**
* @param CaseManagement $caseManagement
+ * @param OrderRepositoryInterface $orderRepository
+ * @param DateTimeFactory $dateTimeFactory
*/
public function __construct(
- CaseManagement $caseManagement
+ CaseManagement $caseManagement,
+ OrderRepositoryInterface $orderRepository,
+ DateTimeFactory $dateTimeFactory
) {
$this->caseManagement = $caseManagement;
+ $this->orderRepository = $orderRepository;
+ $this->dateTimeFactory = $dateTimeFactory;
}
/**
- * Checks if Guarantee submit is applicable for order.
+ * Checks if Guarantee submit is applicable for order and case.
*
- * @param integer $orderId
+ * @param int $orderId
* @return bool
*/
public function check($orderId)
{
- $case = $this->getCaseEntity($orderId);
+ $case = $this->caseManagement->getByOrderId($orderId);
+ if (null === $case || $case->isGuaranteeEligible() === false) {
+ return false;
+ }
+
+ $order = $this->getOrder($orderId);
+ if (null === $order || $this->checkOrder($order) === false) {
+ return false;
+ }
return true;
}
/**
- * Retrieves case entity by order id.
+ * Checks if Guarantee submit is applicable for order.
+ *
+ * @param OrderInterface $order
+ * @return bool
+ */
+ private function checkOrder(OrderInterface $order)
+ {
+ if (in_array($order->getState(), [Order::STATE_CANCELED, Order::STATE_CLOSED])) {
+ return false;
+ }
+
+ $orderCreateDate = $this->dateTimeFactory->create($order->getCreatedAt(), new \DateTimeZone('UTC'));
+ $currentDate = $this->dateTimeFactory->create('now', new \DateTimeZone('UTC'));
+ if ($orderCreateDate->diff($currentDate)->days >= static::$guarantyEligibleDays) {
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Returns order by id
*
- * @param integer $orderId
- * @return CaseInterface|null
+ * @param int $orderId
+ * @return OrderInterface|null
*/
- private function getCaseEntity($orderId)
+ private function getOrder($orderId)
{
- return $this->caseManagement->getByOrderId($orderId);
+ try {
+ $order = $this->orderRepository->get($orderId);
+ } catch (InputException $e) {
+ return null;
+ } catch (NoSuchEntityException $e) {
+ return null;
+ }
+
+ return $order;
}
}
From 19d19f5c7b9ca0559c14e962407192f5a146507e Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Thu, 12 Jan 2017 10:57:17 -0600
Subject: [PATCH 127/904] MAGETWO-54393: Updating Order Status using Webhooks
- Refactored code according to code review comments
---
.../Signifyd/Controller/Webhooks/Handler.php | 8 ++--
.../CreationService.php} | 6 +--
.../StubUpdatingService.php} | 4 +-
.../UpdatingService.php} | 14 +++---
.../UpdatingServiceFactory.php} | 13 +++---
.../UpdatingServiceInterface.php} | 4 +-
.../Signifyd/Model/CommentsHistoryUpdater.php | 4 ++
.../Model/Guarantee/CreationService.php | 12 ++---
.../Model/MessageGenerators/CaseRescore.php | 8 ++--
.../GeneratorException.php} | 4 +-
.../MessageGenerators/GeneratorFactory.php | 4 +-
.../GeneratorInterface.php} | 6 +--
.../MessageGenerators/PatternGenerator.php | 7 +--
.../Unit/Controller/Webhooks/HandlerTest.php | 24 +++++-----
.../UpdatingServiceFactoryTest.php} | 44 +++++++++----------
.../UpdatingServiceTest.php} | 32 +++++++-------
.../Unit/Model/CommentsHistoryUpdaterTest.php | 24 ++++++++--
.../Model/Guarantee/CreationServiceTest.php | 10 ++---
.../MessageGenerators/CaseRescoreTest.php | 4 +-
.../PatternGeneratorTest.php | 2 +-
app/code/Magento/Signifyd/etc/di.xml | 2 +-
.../Controller/Webhooks/HandlerTest.php | 1 -
.../Signifyd/Model/CaseManagementTest.php | 2 -
.../CreationServiceTest.php} | 16 +++----
.../UpdatingServiceTest.php} | 11 +++--
.../Model/Guarantee/CreationServiceTest.php | 36 ++++-----------
.../Magento/Signifyd/_files/case.php | 1 -
27 files changed, 148 insertions(+), 155 deletions(-)
rename app/code/Magento/Signifyd/Model/{CaseCreationService.php => CaseServices/CreationService.php} (92%)
rename app/code/Magento/Signifyd/Model/{StubCaseUpdatingService.php => CaseServices/StubUpdatingService.php} (77%)
rename app/code/Magento/Signifyd/Model/{CaseUpdatingService.php => CaseServices/UpdatingService.php} (87%)
rename app/code/Magento/Signifyd/Model/{CaseUpdatingServiceFactory.php => CaseServices/UpdatingServiceFactory.php} (83%)
rename app/code/Magento/Signifyd/Model/{CaseUpdatingServiceInterface.php => CaseServices/UpdatingServiceInterface.php} (81%)
rename app/code/Magento/Signifyd/Model/{MessageGeneratorException.php => MessageGenerators/GeneratorException.php} (68%)
rename app/code/Magento/Signifyd/Model/{MessageGeneratorInterface.php => MessageGenerators/GeneratorInterface.php} (80%)
rename app/code/Magento/Signifyd/Test/Unit/Model/{CaseUpdatingServiceFactoryTest.php => CaseServices/UpdatingServiceFactoryTest.php} (72%)
rename app/code/Magento/Signifyd/Test/Unit/Model/{CaseUpdatingServiceTest.php => CaseServices/UpdatingServiceTest.php} (88%)
rename dev/tests/integration/testsuite/Magento/Signifyd/Model/{CaseCreationServiceTest.php => CaseServices/CreationServiceTest.php} (93%)
rename dev/tests/integration/testsuite/Magento/Signifyd/Model/{CaseUpdatingServiceTest.php => CaseServices/UpdatingServiceTest.php} (90%)
diff --git a/app/code/Magento/Signifyd/Controller/Webhooks/Handler.php b/app/code/Magento/Signifyd/Controller/Webhooks/Handler.php
index b513bb328db65..ce89bdf163dc3 100644
--- a/app/code/Magento/Signifyd/Controller/Webhooks/Handler.php
+++ b/app/code/Magento/Signifyd/Controller/Webhooks/Handler.php
@@ -8,7 +8,7 @@
use Magento\Framework\App\Action\Action;
use Magento\Framework\App\Action\Context;
use Magento\Framework\Exception\LocalizedException;
-use Magento\Signifyd\Model\CaseUpdatingServiceFactory;
+use Magento\Signifyd\Model\CaseServices\UpdatingServiceFactory;
use Magento\Signifyd\Model\SignifydGateway\Response\WebhookRequestValidator;
use Magento\Signifyd\Model\SignifydGateway\Response\WebhookRequest;
use Magento\Signifyd\Model\SignifydGateway\Response\WebhookMessageReader;
@@ -37,7 +37,7 @@ class Handler extends Action
private $webhookMessageReader;
/**
- * @var CaseUpdatingServiceFactory
+ * @var UpdatingServiceFactory
*/
private $caseUpdatingServiceFactory;
@@ -51,7 +51,7 @@ class Handler extends Action
* @param WebhookRequest $webhookRequest
* @param LoggerInterface $logger
* @param WebhookMessageReader $webhookMessageReader
- * @param CaseUpdatingServiceFactory $caseUpdatingServiceFactory
+ * @param UpdatingServiceFactory $caseUpdatingServiceFactory
* @param WebhookRequestValidator $webhookRequestValidator
*/
public function __construct(
@@ -59,7 +59,7 @@ public function __construct(
WebhookRequest $webhookRequest,
LoggerInterface $logger,
WebhookMessageReader $webhookMessageReader,
- CaseUpdatingServiceFactory $caseUpdatingServiceFactory,
+ UpdatingServiceFactory $caseUpdatingServiceFactory,
WebhookRequestValidator $webhookRequestValidator
) {
parent::__construct($context);
diff --git a/app/code/Magento/Signifyd/Model/CaseCreationService.php b/app/code/Magento/Signifyd/Model/CaseServices/CreationService.php
similarity index 92%
rename from app/code/Magento/Signifyd/Model/CaseCreationService.php
rename to app/code/Magento/Signifyd/Model/CaseServices/CreationService.php
index b546c9c63fe4f..d735aae67df41 100644
--- a/app/code/Magento/Signifyd/Model/CaseCreationService.php
+++ b/app/code/Magento/Signifyd/Model/CaseServices/CreationService.php
@@ -3,7 +3,7 @@
* Copyright © 2017 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-namespace Magento\Signifyd\Model;
+namespace Magento\Signifyd\Model\CaseServices;
use Magento\Signifyd\Api\CaseCreationServiceInterface;
use Magento\Signifyd\Api\CaseManagementInterface;
@@ -17,7 +17,7 @@
*
* Creates new Case entity and register it at Signifyd
*/
-class CaseCreationService implements CaseCreationServiceInterface
+class CreationService implements CaseCreationServiceInterface
{
/**
* @var CaseManagementInterface
@@ -40,7 +40,7 @@ class CaseCreationService implements CaseCreationServiceInterface
private $caseRepository;
/**
- * CaseCreationService constructor.
+ * CreationService constructor.
*
* @param CaseManagementInterface $caseManagement
* @param Gateway $signifydGateway
diff --git a/app/code/Magento/Signifyd/Model/StubCaseUpdatingService.php b/app/code/Magento/Signifyd/Model/CaseServices/StubUpdatingService.php
similarity index 77%
rename from app/code/Magento/Signifyd/Model/StubCaseUpdatingService.php
rename to app/code/Magento/Signifyd/Model/CaseServices/StubUpdatingService.php
index 9d7cffdd7ca1a..6c91235f22799 100644
--- a/app/code/Magento/Signifyd/Model/StubCaseUpdatingService.php
+++ b/app/code/Magento/Signifyd/Model/CaseServices/StubUpdatingService.php
@@ -3,13 +3,13 @@
* Copyright © 2017 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-namespace Magento\Signifyd\Model;
+namespace Magento\Signifyd\Model\CaseServices;
/**
* Stub implementation for case updating service interface and might be used
* for test Signifyd webhooks
*/
-class StubCaseUpdatingService implements CaseUpdatingServiceInterface
+class StubUpdatingService implements UpdatingServiceInterface
{
/**
diff --git a/app/code/Magento/Signifyd/Model/CaseUpdatingService.php b/app/code/Magento/Signifyd/Model/CaseServices/UpdatingService.php
similarity index 87%
rename from app/code/Magento/Signifyd/Model/CaseUpdatingService.php
rename to app/code/Magento/Signifyd/Model/CaseServices/UpdatingService.php
index 22a287357c771..8f002b82bac7b 100644
--- a/app/code/Magento/Signifyd/Model/CaseUpdatingService.php
+++ b/app/code/Magento/Signifyd/Model/CaseServices/UpdatingService.php
@@ -3,20 +3,22 @@
* Copyright © 2017 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-namespace Magento\Signifyd\Model;
+namespace Magento\Signifyd\Model\CaseServices;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Exception\NotFoundException;
use Magento\Signifyd\Api\CaseRepositoryInterface;
use Magento\Signifyd\Api\Data\CaseInterface;
+use Magento\Signifyd\Model\CommentsHistoryUpdater;
+use Magento\Signifyd\Model\MessageGenerators\GeneratorInterface;
/**
* Performs Signifyd case entity updating operations.
*/
-class CaseUpdatingService implements CaseUpdatingServiceInterface
+class UpdatingService implements UpdatingServiceInterface
{
/**
- * @var MessageGeneratorInterface
+ * @var GeneratorInterface
*/
private $messageGenerator;
@@ -31,14 +33,14 @@ class CaseUpdatingService implements CaseUpdatingServiceInterface
private $commentsHistoryUpdater;
/**
- * CaseUpdatingService constructor.
+ * UpdatingService constructor.
*
- * @param MessageGeneratorInterface $messageGenerator
+ * @param GeneratorInterface $messageGenerator
* @param CaseRepositoryInterface $caseRepository
* @param CommentsHistoryUpdater $commentsHistoryUpdater
*/
public function __construct(
- MessageGeneratorInterface $messageGenerator,
+ GeneratorInterface $messageGenerator,
CaseRepositoryInterface $caseRepository,
CommentsHistoryUpdater $commentsHistoryUpdater
) {
diff --git a/app/code/Magento/Signifyd/Model/CaseUpdatingServiceFactory.php b/app/code/Magento/Signifyd/Model/CaseServices/UpdatingServiceFactory.php
similarity index 83%
rename from app/code/Magento/Signifyd/Model/CaseUpdatingServiceFactory.php
rename to app/code/Magento/Signifyd/Model/CaseServices/UpdatingServiceFactory.php
index f9236a5fa9395..8c6023fae1445 100644
--- a/app/code/Magento/Signifyd/Model/CaseUpdatingServiceFactory.php
+++ b/app/code/Magento/Signifyd/Model/CaseServices/UpdatingServiceFactory.php
@@ -3,17 +3,18 @@
* Copyright © 2017 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-namespace Magento\Signifyd\Model;
+namespace Magento\Signifyd\Model\CaseServices;
use Magento\Framework\ObjectManagerInterface;
use Magento\Signifyd\Model\MessageGenerators\GeneratorFactory;
+use Magento\Signifyd\Model\Config;
/**
* Creates instance of case updating service configured with specific message generator.
* The message generator initialization depends on specified type (like, case creation, re-scoring, review and
* guarantee completion).
*/
-class CaseUpdatingServiceFactory
+class UpdatingServiceFactory
{
/**
* Type of testing Signifyd case
@@ -37,7 +38,7 @@ class CaseUpdatingServiceFactory
private $config;
/**
- * CaseUpdatingServiceFactory constructor.
+ * UpdatingServiceFactory constructor.
*
* @param ObjectManagerInterface $objectManager
* @param GeneratorFactory $generatorFactory
@@ -58,17 +59,17 @@ public function __construct(
* As param retrieves type of message generator.
*
* @param string $type
- * @return CaseUpdatingServiceInterface
+ * @return UpdatingServiceInterface
* @throws \InvalidArgumentException
*/
public function create($type)
{
if (!$this->config->isActive() || $type === self::$caseTest) {
- return $this->objectManager->create(StubCaseUpdatingService::class);
+ return $this->objectManager->create(StubUpdatingService::class);
}
$messageGenerator = $this->generatorFactory->create($type);
- $service = $this->objectManager->create(CaseUpdatingService::class, [
+ $service = $this->objectManager->create(UpdatingService::class, [
'messageGenerator' => $messageGenerator
]);
diff --git a/app/code/Magento/Signifyd/Model/CaseUpdatingServiceInterface.php b/app/code/Magento/Signifyd/Model/CaseServices/UpdatingServiceInterface.php
similarity index 81%
rename from app/code/Magento/Signifyd/Model/CaseUpdatingServiceInterface.php
rename to app/code/Magento/Signifyd/Model/CaseServices/UpdatingServiceInterface.php
index 3e221f24682e1..33d44e7c8cf3b 100644
--- a/app/code/Magento/Signifyd/Model/CaseUpdatingServiceInterface.php
+++ b/app/code/Magento/Signifyd/Model/CaseServices/UpdatingServiceInterface.php
@@ -3,12 +3,12 @@
* Copyright © 2017 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-namespace Magento\Signifyd\Model;
+namespace Magento\Signifyd\Model\CaseServices;
/**
* Common abstraction to perform updating operations with Signifyd case entity.
*/
-interface CaseUpdatingServiceInterface
+interface UpdatingServiceInterface
{
/**
* Updates Signifyd Case entity by received data.
diff --git a/app/code/Magento/Signifyd/Model/CommentsHistoryUpdater.php b/app/code/Magento/Signifyd/Model/CommentsHistoryUpdater.php
index ff600b91d0a6b..976e5aa0a9dc6 100644
--- a/app/code/Magento/Signifyd/Model/CommentsHistoryUpdater.php
+++ b/app/code/Magento/Signifyd/Model/CommentsHistoryUpdater.php
@@ -41,6 +41,10 @@ public function __construct(HistoryFactory $historyFactory)
*/
public function addComment(CaseInterface $case, Phrase $message)
{
+ if (!$message->getText()) {
+ return;
+ }
+
/** @var \Magento\Sales\Api\Data\OrderStatusHistoryInterface $history */
$history = $this->historyFactory->create();
$history->setParentId($case->getOrderId())
diff --git a/app/code/Magento/Signifyd/Model/Guarantee/CreationService.php b/app/code/Magento/Signifyd/Model/Guarantee/CreationService.php
index e3ca93842f29b..5801c4f490608 100644
--- a/app/code/Magento/Signifyd/Model/Guarantee/CreationService.php
+++ b/app/code/Magento/Signifyd/Model/Guarantee/CreationService.php
@@ -7,9 +7,9 @@
use Magento\Framework\Exception\AlreadyExistsException;
use Magento\Framework\Exception\NotFoundException;
-use Magento\Signifyd\Api\GuaranteeCreationServiceInterface;
use Magento\Signifyd\Api\CaseManagementInterface;
-use Magento\Signifyd\Model\CaseUpdatingServiceFactory;
+use Magento\Signifyd\Api\GuaranteeCreationServiceInterface;
+use Magento\Signifyd\Model\CaseServices\UpdatingServiceFactory;
use Magento\Signifyd\Model\SignifydGateway\Gateway;
use Magento\Signifyd\Model\SignifydGateway\GatewayException;
use Psr\Log\LoggerInterface;
@@ -25,7 +25,7 @@ class CreationService implements GuaranteeCreationServiceInterface
private $caseManagement;
/**
- * @var CaseUpdatingServiceFactory
+ * @var UpdatingServiceFactory
*/
private $caseUpdatingServiceFactory;
@@ -43,13 +43,13 @@ class CreationService implements GuaranteeCreationServiceInterface
* CreationService constructor.
*
* @param CaseManagementInterface $caseManagement
- * @param CaseUpdatingServiceFactory $caseUpdatingServiceFactory
+ * @param UpdatingServiceFactory $caseUpdatingServiceFactory
* @param Gateway $gateway
* @param LoggerInterface $logger
*/
public function __construct(
CaseManagementInterface $caseManagement,
- CaseUpdatingServiceFactory $caseUpdatingServiceFactory,
+ UpdatingServiceFactory $caseUpdatingServiceFactory,
Gateway $gateway,
LoggerInterface $logger
) {
@@ -75,7 +75,7 @@ public function createForOrder($orderId)
__('Case for order with specified id "%1" is not registered in Signifyd', $orderId)
);
}
- if ($caseEntity->getGuaranteeDisposition() !== null) {
+ if ($caseEntity->getGuaranteeDisposition()) {
throw new AlreadyExistsException(
__('Guarantee for order "%1" has been created already', $orderId)
);
diff --git a/app/code/Magento/Signifyd/Model/MessageGenerators/CaseRescore.php b/app/code/Magento/Signifyd/Model/MessageGenerators/CaseRescore.php
index c62d4334755ed..0c716b122501b 100644
--- a/app/code/Magento/Signifyd/Model/MessageGenerators/CaseRescore.php
+++ b/app/code/Magento/Signifyd/Model/MessageGenerators/CaseRescore.php
@@ -6,13 +6,11 @@
namespace Magento\Signifyd\Model\MessageGenerators;
use Magento\Signifyd\Api\CaseRepositoryInterface;
-use Magento\Signifyd\Model\MessageGeneratorException;
-use Magento\Signifyd\Model\MessageGeneratorInterface;
/**
* Generates message based on previous and current Case scores.
*/
-class CaseRescore implements MessageGeneratorInterface
+class CaseRescore implements GeneratorInterface
{
/**
* @var CaseRepositoryInterface
@@ -35,13 +33,13 @@ public function __construct(CaseRepositoryInterface $caseRepository)
public function generate(array $data)
{
if (empty($data['caseId'])) {
- throw new MessageGeneratorException(__('The "%1" should not be empty.', 'caseId'));
+ throw new GeneratorException(__('The "%1" should not be empty.', 'caseId'));
}
$caseEntity = $this->caseRepository->getByCaseId($data['caseId']);
if ($caseEntity === null) {
- throw new MessageGeneratorException(__('Case entity not found.'));
+ throw new GeneratorException(__('Case entity not found.'));
}
return __(
diff --git a/app/code/Magento/Signifyd/Model/MessageGeneratorException.php b/app/code/Magento/Signifyd/Model/MessageGenerators/GeneratorException.php
similarity index 68%
rename from app/code/Magento/Signifyd/Model/MessageGeneratorException.php
rename to app/code/Magento/Signifyd/Model/MessageGenerators/GeneratorException.php
index 3958595bc1f45..ed967da231165 100644
--- a/app/code/Magento/Signifyd/Model/MessageGeneratorException.php
+++ b/app/code/Magento/Signifyd/Model/MessageGenerators/GeneratorException.php
@@ -3,14 +3,14 @@
* Copyright © 2017 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-namespace Magento\Signifyd\Model;
+namespace Magento\Signifyd\Model\MessageGenerators;
use Magento\Framework\Exception\LocalizedException;
/**
* Common exception for Signifyd message generators.
*/
-class MessageGeneratorException extends LocalizedException
+class GeneratorException extends LocalizedException
{
}
diff --git a/app/code/Magento/Signifyd/Model/MessageGenerators/GeneratorFactory.php b/app/code/Magento/Signifyd/Model/MessageGenerators/GeneratorFactory.php
index 6f9f855350441..cd40b6b9ab7ac 100644
--- a/app/code/Magento/Signifyd/Model/MessageGenerators/GeneratorFactory.php
+++ b/app/code/Magento/Signifyd/Model/MessageGenerators/GeneratorFactory.php
@@ -44,7 +44,7 @@ class GeneratorFactory
private static $guaranteeCreation = 'guarantees/creation';
/**
- * CaseUpdatingServiceFactory constructor.
+ * UpdatingServiceFactory constructor.
*
* @param ObjectManagerInterface $objectManager
*/
@@ -58,7 +58,7 @@ public function __construct(ObjectManagerInterface $objectManager)
* Throws exception if type of message generator does not have implementations.
*
* @param string $type
- * @return MessageGeneratorInterface
+ * @return GeneratorInterface
* @throws \InvalidArgumentException
*/
public function create($type)
diff --git a/app/code/Magento/Signifyd/Model/MessageGeneratorInterface.php b/app/code/Magento/Signifyd/Model/MessageGenerators/GeneratorInterface.php
similarity index 80%
rename from app/code/Magento/Signifyd/Model/MessageGeneratorInterface.php
rename to app/code/Magento/Signifyd/Model/MessageGenerators/GeneratorInterface.php
index 265b6ae1e5f5a..11726bf74a924 100644
--- a/app/code/Magento/Signifyd/Model/MessageGeneratorInterface.php
+++ b/app/code/Magento/Signifyd/Model/MessageGenerators/GeneratorInterface.php
@@ -3,19 +3,19 @@
* Copyright © 2017 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-namespace Magento\Signifyd\Model;
+namespace Magento\Signifyd\Model\MessageGenerators;
/**
* Represents common abstraction for Signifyd Case/Guarantee messages.
* Each interface implementation might use Case/Guarantee data to generate specific message.
*/
-interface MessageGeneratorInterface
+interface GeneratorInterface
{
/**
* Creates new localized message based on Signifyd Case/Guarantee data.
* @param array $data
* @return \Magento\Framework\Phrase
- * @throws MessageGeneratorException
+ * @throws GeneratorException
*/
public function generate(array $data);
}
diff --git a/app/code/Magento/Signifyd/Model/MessageGenerators/PatternGenerator.php b/app/code/Magento/Signifyd/Model/MessageGenerators/PatternGenerator.php
index e69bb565360b7..a03b32b243dd5 100644
--- a/app/code/Magento/Signifyd/Model/MessageGenerators/PatternGenerator.php
+++ b/app/code/Magento/Signifyd/Model/MessageGenerators/PatternGenerator.php
@@ -5,9 +5,6 @@
*/
namespace Magento\Signifyd\Model\MessageGenerators;
-use Magento\Signifyd\Model\MessageGeneratorException;
-use Magento\Signifyd\Model\MessageGeneratorInterface;
-
/**
* Common implementation of message generator.
* Takes a message template (placeholders for localization also can be used) and list
@@ -18,7 +15,7 @@
* Message is 'Case Update: New score for the order is %1. Previous score was %2.', then the required params order
* should be ['new_score', 'prev_score'].
*/
-class PatternGenerator implements MessageGeneratorInterface
+class PatternGenerator implements GeneratorInterface
{
/**
* @var string
@@ -50,7 +47,7 @@ public function generate(array $data)
$placeholders = [];
foreach ($this->requiredParams as $param) {
if (empty($data[$param])) {
- throw new MessageGeneratorException(__('The "%1" should not be empty.', $param));
+ throw new GeneratorException(__('The "%1" should not be empty.', $param));
}
$placeholders[] = $data[$param];
}
diff --git a/app/code/Magento/Signifyd/Test/Unit/Controller/Webhooks/HandlerTest.php b/app/code/Magento/Signifyd/Test/Unit/Controller/Webhooks/HandlerTest.php
index b9b29ae0766fa..9ce3d0ad682fb 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Controller/Webhooks/HandlerTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Controller/Webhooks/HandlerTest.php
@@ -6,17 +6,17 @@
namespace Magento\Signifyd\Test\Unit\Controller\Webhooks;
use Magento\Framework\App\Action\Context;
+use Magento\Framework\App\Response\Http as ResponseHttp;
+use Magento\Framework\App\Response\RedirectInterface;
use Magento\Framework\Exception\LocalizedException;
-use Magento\Signifyd\Model\CaseUpdatingServiceFactory;
-use Magento\Signifyd\Model\CaseUpdatingService;
-use Magento\Signifyd\Model\SignifydGateway\Response\WebhookRequestValidator;
-use Magento\Signifyd\Model\SignifydGateway\Response\WebhookRequest;
-use Magento\Signifyd\Model\SignifydGateway\Response\WebhookMessageReader;
+use Magento\Signifyd\Controller\Webhooks\Handler;
+use Magento\Signifyd\Model\CaseServices\UpdatingService;
+use Magento\Signifyd\Model\CaseServices\UpdatingServiceFactory;
use Magento\Signifyd\Model\SignifydGateway\Response\WebhookMessage;
+use Magento\Signifyd\Model\SignifydGateway\Response\WebhookMessageReader;
+use Magento\Signifyd\Model\SignifydGateway\Response\WebhookRequest;
+use Magento\Signifyd\Model\SignifydGateway\Response\WebhookRequestValidator;
use Psr\Log\LoggerInterface;
-use Magento\Signifyd\Controller\Webhooks\Handler;
-use Magento\Framework\App\Response\RedirectInterface;
-use Magento\Framework\App\Response\Http as ResponseHttp;
/**
* Class IndexTest
@@ -66,7 +66,7 @@ class HandlerTest extends \PHPUnit_Framework_TestCase
private $webhookRequestValidator;
/**
- * @var CaseUpdatingServiceFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var UpdatingServiceFactory|\PHPUnit_Framework_MockObject_MockObject
*/
private $caseUpdatingServiceFactory;
@@ -88,7 +88,7 @@ protected function setUp()
$this->webhookRequestValidator = $this->getMockBuilder(WebhookRequestValidator::class)
->disableOriginalConstructor()
->getMock();
- $this->caseUpdatingServiceFactory = $this->getMockBuilder(CaseUpdatingServiceFactory::class)
+ $this->caseUpdatingServiceFactory = $this->getMockBuilder(UpdatingServiceFactory::class)
->disableOriginalConstructor()
->getMock();
$this->logger = $this->getMockBuilder(LoggerInterface::class)
@@ -142,7 +142,7 @@ public function testExecuteSuccessfully()
->with($this->webhookRequest)
->willReturn($webhookMessage);
- $caseUpdatingService = $this->getMockBuilder(CaseUpdatingService::class)
+ $caseUpdatingService = $this->getMockBuilder(UpdatingService::class)
->disableOriginalConstructor()
->getMock();
$caseUpdatingService->expects($this->once())
@@ -184,7 +184,7 @@ public function testExecuteCaseUpdatingServiceException()
->with($this->webhookRequest)
->willReturn($webhookMessage);
- $caseUpdatingService = $this->getMockBuilder(CaseUpdatingService::class)
+ $caseUpdatingService = $this->getMockBuilder(UpdatingService::class)
->disableOriginalConstructor()
->getMock();
$caseUpdatingService->expects($this->once())
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/CaseUpdatingServiceFactoryTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/CaseServices/UpdatingServiceFactoryTest.php
similarity index 72%
rename from app/code/Magento/Signifyd/Test/Unit/Model/CaseUpdatingServiceFactoryTest.php
rename to app/code/Magento/Signifyd/Test/Unit/Model/CaseServices/UpdatingServiceFactoryTest.php
index 4c73756e39ac8..0639c420c9b9b 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/CaseUpdatingServiceFactoryTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/CaseServices/UpdatingServiceFactoryTest.php
@@ -3,25 +3,25 @@
* Copyright © 2017 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-namespace Magento\Signifyd\Test\Unit\Model;
+namespace Magento\Signifyd\Test\Unit\Model\CaseServices;
use Magento\Framework\ObjectManagerInterface;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
-use Magento\Signifyd\Model\CaseUpdatingService;
-use Magento\Signifyd\Model\CaseUpdatingServiceFactory;
+use Magento\Signifyd\Model\CaseServices\StubUpdatingService;
+use Magento\Signifyd\Model\CaseServices\UpdatingService;
+use Magento\Signifyd\Model\CaseServices\UpdatingServiceFactory;
use Magento\Signifyd\Model\Config;
-use Magento\Signifyd\Model\MessageGeneratorInterface;
use Magento\Signifyd\Model\MessageGenerators\GeneratorFactory;
-use Magento\Signifyd\Model\StubCaseUpdatingService;
+use Magento\Signifyd\Model\MessageGenerators\GeneratorInterface;
use PHPUnit_Framework_MockObject_MockObject as MockObject;
/**
* Contains tests for case updating service factory.
*/
-class CaseUpdatingServiceFactoryTest extends \PHPUnit_Framework_TestCase
+class UpdatingServiceFactoryTest extends \PHPUnit_Framework_TestCase
{
/**
- * @var CaseUpdatingServiceFactory
+ * @var UpdatingServiceFactory
*/
private $factory;
@@ -61,7 +61,7 @@ protected function setUp()
->getMock();
$objectManager = new ObjectManager($this);
- $this->factory = $objectManager->getObject(CaseUpdatingServiceFactory::class, [
+ $this->factory = $objectManager->getObject(UpdatingServiceFactory::class, [
'objectManager' => $this->fakeObjectManager,
'generatorFactory' => $this->generatorFactory,
'config' => $this->config
@@ -71,7 +71,7 @@ protected function setUp()
/**
* Checks type of instance for updating service if Signifyd is not enabled.
*
- * @covers \Magento\Signifyd\Model\CaseUpdatingServiceFactory::create
+ * @covers \Magento\Signifyd\Model\CaseServices\UpdatingServiceFactory::create
*/
public function testCreateWithInactiveConfig()
{
@@ -82,17 +82,17 @@ public function testCreateWithInactiveConfig()
$this->fakeObjectManager->expects(self::once())
->method('create')
- ->with(StubCaseUpdatingService::class)
- ->willReturn(new StubCaseUpdatingService());
+ ->with(StubUpdatingService::class)
+ ->willReturn(new StubUpdatingService());
$instance = $this->factory->create($type);
- static::assertInstanceOf(StubCaseUpdatingService::class, $instance);
+ static::assertInstanceOf(StubUpdatingService::class, $instance);
}
/**
* Checks type of instance for updating service if test type is received.
*
- * @covers \Magento\Signifyd\Model\CaseUpdatingServiceFactory::create
+ * @covers \Magento\Signifyd\Model\CaseServices\UpdatingServiceFactory::create
*/
public function testCreateWithTestType()
{
@@ -103,17 +103,17 @@ public function testCreateWithTestType()
$this->fakeObjectManager->expects(self::once())
->method('create')
- ->with(StubCaseUpdatingService::class)
- ->willReturn(new StubCaseUpdatingService());
+ ->with(StubUpdatingService::class)
+ ->willReturn(new StubUpdatingService());
$instance = $this->factory->create($type);
- static::assertInstanceOf(StubCaseUpdatingService::class, $instance);
+ static::assertInstanceOf(StubUpdatingService::class, $instance);
}
/**
* Checks exception type and message for unknown case type.
*
- * @covers \Magento\Signifyd\Model\CaseUpdatingServiceFactory::create
+ * @covers \Magento\Signifyd\Model\CaseServices\UpdatingServiceFactory::create
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage Specified message type does not supported.
*/
@@ -135,7 +135,7 @@ public function testCreateWithException()
/**
* Checks if factory creates correct instance of case updating service.
*
- * @covers \Magento\Signifyd\Model\CaseUpdatingServiceFactory::create
+ * @covers \Magento\Signifyd\Model\CaseServices\UpdatingServiceFactory::create
*/
public function testCreate()
{
@@ -144,7 +144,7 @@ public function testCreate()
->method('isActive')
->willReturn(true);
- $messageGenerator = $this->getMockBuilder(MessageGeneratorInterface::class)
+ $messageGenerator = $this->getMockBuilder(GeneratorInterface::class)
->disableOriginalConstructor()
->getMock();
$this->generatorFactory->expects(self::once())
@@ -152,16 +152,16 @@ public function testCreate()
->with($type)
->willReturn($messageGenerator);
- $service = $this->getMockBuilder(CaseUpdatingService::class)
+ $service = $this->getMockBuilder(UpdatingService::class)
->disableOriginalConstructor()
->getMock();
$this->fakeObjectManager->expects(self::once())
->method('create')
- ->with(CaseUpdatingService::class, ['messageGenerator' => $messageGenerator])
+ ->with(UpdatingService::class, ['messageGenerator' => $messageGenerator])
->willReturn($service);
$result = $this->factory->create($type);
- static::assertInstanceOf(CaseUpdatingService::class, $result);
+ static::assertInstanceOf(UpdatingService::class, $result);
}
}
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/CaseUpdatingServiceTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/CaseServices/UpdatingServiceTest.php
similarity index 88%
rename from app/code/Magento/Signifyd/Test/Unit/Model/CaseUpdatingServiceTest.php
rename to app/code/Magento/Signifyd/Test/Unit/Model/CaseServices/UpdatingServiceTest.php
index 321953aef2120..581682c37b6a4 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/CaseUpdatingServiceTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/CaseServices/UpdatingServiceTest.php
@@ -3,24 +3,24 @@
* Copyright © 2017 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-namespace Magento\Signifyd\Test\Unit\Model;
+namespace Magento\Signifyd\Test\Unit\Model\CaseServices;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
use Magento\Signifyd\Api\CaseRepositoryInterface;
use Magento\Signifyd\Api\Data\CaseInterface;
-use Magento\Signifyd\Model\CaseUpdatingService;
+use Magento\Signifyd\Model\CaseServices\UpdatingService;
use Magento\Signifyd\Model\CommentsHistoryUpdater;
-use Magento\Signifyd\Model\MessageGeneratorException;
-use Magento\Signifyd\Model\MessageGeneratorInterface;
+use Magento\Signifyd\Model\MessageGenerators\GeneratorException;
+use Magento\Signifyd\Model\MessageGenerators\GeneratorInterface;
use PHPUnit_Framework_MockObject_MockObject as MockObject;
/**
* Contains tests with different negative and positive scenarios for case updating service.
*/
-class CaseUpdatingServiceTest extends \PHPUnit_Framework_TestCase
+class UpdatingServiceTest extends \PHPUnit_Framework_TestCase
{
/**
- * @var CaseUpdatingService
+ * @var UpdatingService
*/
private $service;
@@ -30,7 +30,7 @@ class CaseUpdatingServiceTest extends \PHPUnit_Framework_TestCase
private $objectManager;
/**
- * @var MessageGeneratorInterface|MockObject
+ * @var GeneratorInterface|MockObject
*/
private $messageGenerator;
@@ -51,7 +51,7 @@ protected function setUp()
{
$this->objectManager = new ObjectManager($this);
- $this->messageGenerator = $this->getMockBuilder(MessageGeneratorInterface::class)
+ $this->messageGenerator = $this->getMockBuilder(GeneratorInterface::class)
->disableOriginalConstructor()
->setMethods(['generate'])
->getMock();
@@ -66,7 +66,7 @@ protected function setUp()
->setMethods(['addComment'])
->getMock();
- $this->service = $this->objectManager->getObject(CaseUpdatingService::class, [
+ $this->service = $this->objectManager->getObject(UpdatingService::class, [
'messageGenerator' => $this->messageGenerator,
'caseRepository' => $this->caseRepository,
'commentsHistoryUpdater' => $this->commentsHistoryUpdater
@@ -76,7 +76,7 @@ protected function setUp()
/**
* Checks a test case when Signifyd case id is missed in input data.
*
- * @covers \Magento\Signifyd\Model\CaseUpdatingService::update
+ * @covers \Magento\Signifyd\Model\CaseServices\UpdatingService::update
* @expectedException \Magento\Framework\Exception\LocalizedException
* @expectedExceptionMessage The "caseId" should not be empty.
*/
@@ -90,7 +90,7 @@ public function testUpdateWithFailedValidation()
/**
* Checks a test case when Signifyd case entity not found in repository.
*
- * @covers \Magento\Signifyd\Model\CaseUpdatingService::update
+ * @covers \Magento\Signifyd\Model\CaseServices\UpdatingService::update
* @expectedException \Magento\Framework\Exception\NotFoundException
* @expectedExceptionMessage Case entity not found.
*/
@@ -112,7 +112,7 @@ public function testUpdateWithNotExistingCase()
/**
* Checks as test case when service cannot save Signifyd case entity
*
- * @covers \Magento\Signifyd\Model\CaseUpdatingService::update
+ * @covers \Magento\Signifyd\Model\CaseServices\UpdatingService::update
* @expectedException \Magento\Framework\Exception\LocalizedException
* @expectedExceptionMessage Cannot update Case entity.
*/
@@ -161,7 +161,7 @@ public function testUpdateWithFailedCaseSaving()
/**
* Checks as test case when message generator throws an exception
*
- * @covers \Magento\Signifyd\Model\CaseUpdatingService::update
+ * @covers \Magento\Signifyd\Model\CaseServices\UpdatingService::update
* @expectedException \Magento\Framework\Exception\LocalizedException
* @expectedExceptionMessage Cannot update Case entity.
*/
@@ -195,7 +195,7 @@ public function testUpdateWithExceptionFromMessageGenerator()
$this->messageGenerator->expects(self::once())
->method('generate')
->with($data)
- ->willThrowException(new MessageGeneratorException(__('Cannot generate message.')));
+ ->willThrowException(new GeneratorException(__('Cannot generate message.')));
$this->service->update($data);
}
@@ -203,7 +203,7 @@ public function testUpdateWithExceptionFromMessageGenerator()
/**
* Checks a test case when comments history updater throws an exception.
*
- * @covers \Magento\Signifyd\Model\CaseUpdatingService::update
+ * @covers \Magento\Signifyd\Model\CaseServices\UpdatingService::update
* @expectedException \Magento\Framework\Exception\LocalizedException
* @expectedExceptionMessage Cannot update Case entity.
*/
@@ -251,7 +251,7 @@ public function testUpdateWithFailedCommentSaving()
/**
* Checks a test case when Signifyd case entity is successfully updated and message stored in comments history.
*
- * @covers \Magento\Signifyd\Model\CaseUpdatingService::update
+ * @covers \Magento\Signifyd\Model\CaseServices\UpdatingService::update
*/
public function testUpdate()
{
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/CommentsHistoryUpdaterTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/CommentsHistoryUpdaterTest.php
index e154fc32afa9a..d85b0410ee27a 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/CommentsHistoryUpdaterTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/CommentsHistoryUpdaterTest.php
@@ -108,6 +108,22 @@ public function testAddComment()
$this->updater->addComment($this->caseEntity, __(self::$message));
}
+ /**
+ * Checks a test when message does not specified.
+ *
+ * @covers \Magento\Signifyd\Model\CommentsHistoryUpdater::addComment
+ */
+ public function testAddCommentWithoutMessage()
+ {
+ $this->caseEntity->expects(self::never())
+ ->method('getOrderId');
+
+ $this->historyFactory->expects(self::never())
+ ->method('save');
+
+ $this->updater->addComment($this->caseEntity, __(''));
+ }
+
/**
* Creates mock object for history entity.
*
@@ -120,19 +136,19 @@ private function initCommentMock()
->setMethods(['setParentId', 'setComment', 'setEntityName', 'save'])
->getMockForAbstractClass();
- $this->historyFactory->expects(self::once())
+ $this->historyFactory->expects(self::any())
->method('create')
->willReturn($this->historyEntity);
- $this->historyEntity->expects(self::once())
+ $this->historyEntity->expects(self::any())
->method('setParentId')
->with(self::$orderId)
->willReturnSelf();
- $this->historyEntity->expects(self::once())
+ $this->historyEntity->expects(self::any())
->method('setComment')
->with(self::$message)
->willReturnSelf();
- $this->historyEntity->expects(self::once())
+ $this->historyEntity->expects(self::any())
->method('setEntityName')
->with('order')
->willReturnSelf();
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CreationServiceTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CreationServiceTest.php
index b8ee861c1e5dd..119165407e301 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CreationServiceTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CreationServiceTest.php
@@ -12,8 +12,8 @@
use Magento\Framework\Exception\NotFoundException;
use Magento\Framework\Exception\AlreadyExistsException;
use Magento\Signifyd\Api\CaseManagementInterface;
-use Magento\Signifyd\Model\CaseUpdatingServiceFactory;
-use Magento\Signifyd\Model\CaseUpdatingServiceInterface;
+use Magento\Signifyd\Model\CaseServices\UpdatingServiceFactory;
+use Magento\Signifyd\Model\CaseServices\UpdatingServiceInterface;
use Magento\Signifyd\Model\SignifydGateway\Gateway;
use Psr\Log\LoggerInterface;
use Magento\Signifyd\Api\Data\CaseInterface;
@@ -31,7 +31,7 @@ class CreationServiceTest extends TestCase
private $caseManagement;
/**
- * @var CaseUpdatingServiceInterface|MockObject
+ * @var UpdatingServiceInterface|MockObject
*/
private $caseUpdatingService;
@@ -50,10 +50,10 @@ public function setUp()
$this->caseManagement = $this->getMockBuilder(CaseManagementInterface::class)
->getMockForAbstractClass();
- $caseUpdatingServiceFactory = $this->getMockBuilder(CaseUpdatingServiceFactory::class)
+ $caseUpdatingServiceFactory = $this->getMockBuilder(UpdatingServiceFactory::class)
->disableOriginalConstructor()
->getMock();
- $this->caseUpdatingService = $this->getMockBuilder(CaseUpdatingServiceInterface::class)
+ $this->caseUpdatingService = $this->getMockBuilder(UpdatingServiceInterface::class)
->getMockForAbstractClass();
$caseUpdatingServiceFactory
->method('create')
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseRescoreTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseRescoreTest.php
index 2dc7a4b14c492..dc47f1458926c 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseRescoreTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseRescoreTest.php
@@ -65,7 +65,7 @@ protected function setUp()
/**
* Data array without required attribute caseId.
*
- * @expectedException \Magento\Signifyd\Model\MessageGeneratorException
+ * @expectedException \Magento\Signifyd\Model\MessageGenerators\GeneratorException
* @expectedExceptionMessage The "caseId" should not be empty
*/
public function testGenerateEmptyCaseIdException()
@@ -76,7 +76,7 @@ public function testGenerateEmptyCaseIdException()
/**
* Case entity was not found in DB.
*
- * @expectedException \Magento\Signifyd\Model\MessageGeneratorException
+ * @expectedException \Magento\Signifyd\Model\MessageGenerators\GeneratorException
* @expectedExceptionMessage Case entity not found.
*/
public function testGenerateNotFoundException()
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/PatternGeneratorTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/PatternGeneratorTest.php
index 32d3aeec52d36..e819a958cf6bf 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/PatternGeneratorTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/PatternGeneratorTest.php
@@ -16,7 +16,7 @@ class PatternGeneratorTest extends \PHPUnit_Framework_TestCase
* Checks an exception if generators does not receives required data.
*
* @covers \Magento\Signifyd\Model\MessageGenerators\PatternGenerator::generate
- * @expectedException \Magento\Signifyd\Model\MessageGeneratorException
+ * @expectedException \Magento\Signifyd\Model\MessageGenerators\GeneratorException
* @expectedExceptionMessage The "caseId" should not be empty.
*/
public function testGenerateThrowsException()
diff --git a/app/code/Magento/Signifyd/etc/di.xml b/app/code/Magento/Signifyd/etc/di.xml
index 9a2eb0527d63f..4b517ee389af9 100644
--- a/app/code/Magento/Signifyd/etc/di.xml
+++ b/app/code/Magento/Signifyd/etc/di.xml
@@ -10,7 +10,7 @@
-
+
\ No newline at end of file
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Controller/Webhooks/HandlerTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Controller/Webhooks/HandlerTest.php
index 952f961298218..c6d523a8cd50d 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Controller/Webhooks/HandlerTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Controller/Webhooks/HandlerTest.php
@@ -48,7 +48,6 @@ public function testExecuteSuccess()
static::assertNotEmpty($caseEntity);
static::assertEquals('2017-01-06 12:47:03', $caseEntity->getCreatedAt());
static::assertEquals('2017-01-06 12:47:03', $caseEntity->getUpdatedAt());
- static::assertEquals(CaseInterface::GUARANTEE_PENDING, $caseEntity->getGuaranteeDisposition());
static::assertEquals('Magento', $caseEntity->getAssociatedTeam()['teamName']);
static::assertEquals(true, $caseEntity->isGuaranteeEligible());
static::assertEquals(CaseInterface::STATUS_OPEN, $caseEntity->getStatus());
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseManagementTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseManagementTest.php
index 7271cdffcca21..9725956c6ceb6 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseManagementTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseManagementTest.php
@@ -11,7 +11,6 @@
use Magento\Sales\Api\Data\OrderInterface;
use Magento\Sales\Api\OrderRepositoryInterface;
use Magento\Signifyd\Api\Data\CaseInterface;
-use Magento\Signifyd\Model\CaseManagement;
use Magento\TestFramework\Helper\Bootstrap;
/**
@@ -57,7 +56,6 @@ public function testGetByOrderId()
$order = $this->getOrder();
$case = $this->caseManagement->getByOrderId($order->getEntityId());
- static::assertEquals(CaseInterface::GUARANTEE_PENDING, $case->getGuaranteeDisposition());
static::assertEquals(CaseInterface::STATUS_PROCESSING, $case->getStatus());
static::assertEquals(CaseInterface::DISPOSITION_GOOD, $case->getReviewDisposition());
static::assertEquals('2016-12-12 15:17:17', $case->getCreatedAt());
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseCreationServiceTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseServices/CreationServiceTest.php
similarity index 93%
rename from dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseCreationServiceTest.php
rename to dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseServices/CreationServiceTest.php
index fc4841c5388f8..4838bf794a513 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseCreationServiceTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseServices/CreationServiceTest.php
@@ -3,7 +3,7 @@
* Copyright © 2017 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-namespace Magento\Signifyd\Model;
+namespace Magento\Signifyd\Model\CaseServices;
use Magento\Framework\Api\FilterBuilder;
use Magento\Framework\Api\SearchCriteriaBuilder;
@@ -24,7 +24,7 @@
*
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class CaseCreationServiceTest extends \PHPUnit_Framework_TestCase
+class CreationServiceTest extends \PHPUnit_Framework_TestCase
{
/**
* @var ObjectManager
@@ -47,7 +47,7 @@ class CaseCreationServiceTest extends \PHPUnit_Framework_TestCase
private $logger;
/**
- * @var CaseCreationService
+ * @var CreationService
*/
private $service;
@@ -87,7 +87,7 @@ protected function setUp()
->getMockForAbstractClass();
$this->service = $this->objectManager->create(
- CaseCreationService::class,
+ CreationService::class,
[
'signifydGateway' => $gateway,
'logger' => $this->logger
@@ -96,7 +96,7 @@ protected function setUp()
}
/**
- * @covers \Magento\Signifyd\Model\CaseCreationService::createForOrder
+ * @covers \Magento\Signifyd\Model\CaseServices\CreationService::createForOrder
* @magentoDataFixture Magento/Signifyd/_files/order_with_customer_and_two_simple_products.php
*/
public function testCreateForOrderWithEmptyResponse()
@@ -125,7 +125,7 @@ public function testCreateForOrderWithEmptyResponse()
}
/**
- * @covers \Magento\Signifyd\Model\CaseCreationService::createForOrder
+ * @covers \Magento\Signifyd\Model\CaseServices\CreationService::createForOrder
* @magentoDataFixture Magento/Signifyd/_files/order_with_customer_and_two_simple_products.php
*/
public function testCreateForOrderWithBadResponse()
@@ -162,7 +162,7 @@ public function testCreateForOrderWithBadResponse()
}
/**
- * @covers \Magento\Signifyd\Model\CaseCreationService::createForOrder
+ * @covers \Magento\Signifyd\Model\CaseServices\CreationService::createForOrder
* @magentoDataFixture Magento/Signifyd/_files/order_with_customer_and_two_simple_products.php
*/
public function testCreateOrderWithEmptyInvestigationId()
@@ -183,7 +183,7 @@ public function testCreateOrderWithEmptyInvestigationId()
}
/**
- * @covers \Magento\Signifyd\Model\CaseCreationService::createForOrder
+ * @covers \Magento\Signifyd\Model\CaseServices\CreationService::createForOrder
* @magentoDataFixture Magento/Signifyd/_files/order_with_customer_and_two_simple_products.php
*/
public function testCreateForOrder()
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseUpdatingServiceTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseServices/UpdatingServiceTest.php
similarity index 90%
rename from dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseUpdatingServiceTest.php
rename to dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseServices/UpdatingServiceTest.php
index 4862c160118d8..04813b3eb19f7 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseUpdatingServiceTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseServices/UpdatingServiceTest.php
@@ -3,21 +3,20 @@
* Copyright © 2017 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-namespace Magento\Signifyd\Model;
+namespace Magento\Signifyd\Model\CaseServices;
use Magento\Framework\App\ObjectManager;
use Magento\Sales\Api\Data\OrderStatusHistoryInterface;
use Magento\Sales\Api\OrderRepositoryInterface;
use Magento\Signifyd\Api\CaseRepositoryInterface;
use Magento\Signifyd\Api\Data\CaseInterface;
-use Magento\Signifyd\Model\MessageGenerators\CaseCreation;
use Magento\Signifyd\Model\MessageGenerators\GeneratorFactory;
use Magento\TestFramework\Helper\Bootstrap;
/**
* Contains tests for case entity updating service.
*/
-class CaseUpdatingServiceTest extends \PHPUnit_Framework_TestCase
+class UpdatingServiceTest extends \PHPUnit_Framework_TestCase
{
/**
* @var ObjectManager
@@ -25,7 +24,7 @@ class CaseUpdatingServiceTest extends \PHPUnit_Framework_TestCase
private $objectManager;
/**
- * @var CaseUpdatingService
+ * @var UpdatingService
*/
private $service;
@@ -40,7 +39,7 @@ protected function setUp()
$messageFactory = $this->objectManager->get(GeneratorFactory::class);
$messageGenerator = $messageFactory->create('cases/creation');
- $this->service = $this->objectManager->create(CaseUpdatingService::class, [
+ $this->service = $this->objectManager->create(UpdatingService::class, [
'messageGenerator' => $messageGenerator
]);
}
@@ -48,7 +47,7 @@ protected function setUp()
/**
* Checks case updating flow and messages in order comments history.
*
- * @covers \Magento\Signifyd\Model\CaseUpdatingService::update
+ * @covers \Magento\Signifyd\Model\CaseServices\UpdatingService::update
* @magentoDataFixture Magento/Signifyd/_files/case.php
*/
public function testUpdate()
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Model/Guarantee/CreationServiceTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Model/Guarantee/CreationServiceTest.php
index 0900a9f1a2162..aa26311acf87a 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Model/Guarantee/CreationServiceTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/Guarantee/CreationServiceTest.php
@@ -36,6 +36,11 @@ class CreationServiceTest extends \PHPUnit_Framework_TestCase
*/
private $logger;
+ /**
+ * @var ObjectManager
+ */
+ private $objectManager;
+
/**
* @inheritdoc
*/
@@ -64,18 +69,17 @@ protected function setUp()
* for a specified order.
*
* @covers \Magento\Signifyd\Model\Guarantee\CreationService::createForOrder
+ * @expectedException \Magento\Framework\Exception\NotFoundException
+ * @expectedExceptionMessage Case for order with specified id "123" is not created
*/
public function testCreateWithoutCaseEntity()
{
$orderId = 123;
- $this->logger->expects(self::once())
- ->method('error')
- ->with('Cannot find case entity for order entity id: 123');
$this->gateway->expects(self::never())
->method('submitCaseForGuarantee');
- $result = $this->service->create($orderId);
+ $result = $this->service->createForOrder($orderId);
self::assertFalse($result);
}
@@ -101,30 +105,6 @@ public function testCreateWithFailedRequest()
self::assertFalse($result);
}
- /**
- * Checks a test case, when case entity updating is failed.
- *
- * @covers \Magento\Signifyd\Model\Guarantee\CreationService::createForOrder
- * @magentoDataFixture Magento/Signifyd/_files/case.php
- * @magentoConfigFixture current_store fraud_protection/signifyd/active 1
- */
- public function testCreateWithFailedCaseUpdating()
- {
- $caseEntity = $this->getCaseEntity();
-
- $this->gateway->expects(self::once())
- ->method('submitCaseForGuarantee')
- ->with($caseEntity->getCaseId())
- ->willReturn('');
-
- $this->logger->expects(self::once())
- ->method('error')
- ->with('Cannot retrieve guarantee disposition for case: ' . $caseEntity->getEntityId() . '.');
-
- $result = $this->service->createForOrder($caseEntity->getOrderId());
- self::assertFalse($result);
- }
-
/**
* Checks a test case, when case entity is updated successfully.
*
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/_files/case.php b/dev/tests/integration/testsuite/Magento/Signifyd/_files/case.php
index 0bd47cb790d9e..2c12403f93b63 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/_files/case.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/_files/case.php
@@ -23,7 +23,6 @@
$case = $caseFactory->create();
$case->setCaseId(123)
->setGuaranteeEligible(true)
- ->setGuaranteeDisposition(CaseInterface::GUARANTEE_PENDING)
->setStatus(CaseInterface::STATUS_PROCESSING)
->setScore(553)
->setOrderId($order->getEntityId())
From 73f4b291de9c9f2e80f334e30218a900e85068ee Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Thu, 12 Jan 2017 11:09:40 -0600
Subject: [PATCH 128/904] MAGETWO-62825: Guarantee creation possibility
validator
- Cover with unit test
---
.../Signifyd/Block/Adminhtml/CaseInfo.php | 14 +-
...ligible.php => CreateGuaranteeAbility.php} | 39 ++-
.../Guarantee/CreateGuaranteeAbilityTest.php | 257 ++++++++++++++++++
.../Adminhtml/Guarantee/CreateTest.php | 4 +-
4 files changed, 290 insertions(+), 24 deletions(-)
rename app/code/Magento/Signifyd/Model/Guarantee/{SubmitEligible.php => CreateGuaranteeAbility.php} (75%)
create mode 100644 app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CreateGuaranteeAbilityTest.php
diff --git a/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php b/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php
index 9684a8bd10789..6fcdf24aafa3f 100644
--- a/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php
+++ b/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php
@@ -12,7 +12,7 @@
use Magento\Signifyd\Model\Config;
use Magento\Signifyd\Model\CaseManagement;
use Magento\Signifyd\Api\Data\CaseInterface;
-use Magento\Signifyd\Model\Guarantee\SubmitEligible as GuaranteeSubmitEligible;
+use Magento\Signifyd\Model\Guarantee\CreateGuaranteeAbility;
/**
* Get Signifyd Case Info
@@ -30,9 +30,9 @@ class CaseInfo extends AbstractOrder
private $caseManagement;
/**
- * @var GuaranteeSubmitEligible
+ * @var CreateGuaranteeAbility
*/
- private $guaranteeSubmitEligible;
+ private $createGuaranteeAbility;
/**
* @var int
@@ -52,7 +52,7 @@ class CaseInfo extends AbstractOrder
* @param Admin $adminHelper
* @param Config $config
* @param CaseManagement $caseManagement
- * @param GuaranteeSubmitEligible $guaranteeSubmitEligible
+ * @param CreateGuaranteeAbility $createGuaranteeAbility
* @param array $data
*/
public function __construct(
@@ -61,12 +61,12 @@ public function __construct(
Admin $adminHelper,
Config $config,
CaseManagement $caseManagement,
- GuaranteeSubmitEligible $guaranteeSubmitEligible,
+ CreateGuaranteeAbility $createGuaranteeAbility,
array $data = []
) {
$this->config = $config;
$this->caseManagement = $caseManagement;
- $this->guaranteeSubmitEligible = $guaranteeSubmitEligible;
+ $this->createGuaranteeAbility = $createGuaranteeAbility;
parent::__construct($context, $registry, $adminHelper, $data);
}
@@ -172,7 +172,7 @@ public function getButtons()
{
$buttons = [];
- if ($this->guaranteeSubmitEligible->check($this->getOrderId())) {
+ if ($this->createGuaranteeAbility->isAvailable($this->getOrderId())) {
$buttons[] = $this->getSubmitButton();
}
diff --git a/app/code/Magento/Signifyd/Model/Guarantee/SubmitEligible.php b/app/code/Magento/Signifyd/Model/Guarantee/CreateGuaranteeAbility.php
similarity index 75%
rename from app/code/Magento/Signifyd/Model/Guarantee/SubmitEligible.php
rename to app/code/Magento/Signifyd/Model/Guarantee/CreateGuaranteeAbility.php
index 5e216a49c281d..57bd9f0f90830 100644
--- a/app/code/Magento/Signifyd/Model/Guarantee/SubmitEligible.php
+++ b/app/code/Magento/Signifyd/Model/Guarantee/CreateGuaranteeAbility.php
@@ -14,9 +14,9 @@
use Magento\Signifyd\Model\CaseManagement;
/**
- * Checks if is possible to submit guarantee request for order.
+ * Checks if is possible to create Guarantee for order.
*/
-class SubmitEligible
+class CreateGuaranteeAbility
{
/**
* @var CaseManagement
@@ -34,7 +34,7 @@ class SubmitEligible
private $dateTimeFactory;
/**
- * Eligible count of days from the order date to submit a case for Guarantee.
+ * Eligible count of days from the order creation date to submit a case for Guarantee.
*
* @var int
*/
@@ -56,20 +56,32 @@ public function __construct(
}
/**
- * Checks if Guarantee submit is applicable for order and case.
+ * Checks if it is possible to create Guarantee for order and case.
*
* @param int $orderId
* @return bool
*/
- public function check($orderId)
+ public function isAvailable($orderId)
{
$case = $this->caseManagement->getByOrderId($orderId);
- if (null === $case || $case->isGuaranteeEligible() === false) {
+ if (null === $case) {
+ return false;
+ }
+
+ if ($case->isGuaranteeEligible() === false) {
return false;
}
$order = $this->getOrder($orderId);
- if (null === $order || $this->checkOrder($order) === false) {
+ if (null === $order) {
+ return false;
+ }
+
+ if (in_array($order->getState(), [Order::STATE_CANCELED, Order::STATE_CLOSED])) {
+ return false;
+ }
+
+ if ($this->isOrderOlderThen(static::$guarantyEligibleDays, $order)) {
return false;
}
@@ -80,21 +92,18 @@ public function check($orderId)
* Checks if Guarantee submit is applicable for order.
*
* @param OrderInterface $order
+ * @param int $days number of days from the order creation date to submit a case for Guarantee.
* @return bool
*/
- private function checkOrder(OrderInterface $order)
+ private function isOrderOlderThen($days, OrderInterface $order)
{
- if (in_array($order->getState(), [Order::STATE_CANCELED, Order::STATE_CLOSED])) {
- return false;
- }
-
$orderCreateDate = $this->dateTimeFactory->create($order->getCreatedAt(), new \DateTimeZone('UTC'));
$currentDate = $this->dateTimeFactory->create('now', new \DateTimeZone('UTC'));
- if ($orderCreateDate->diff($currentDate)->days >= static::$guarantyEligibleDays) {
- return false;
+ if ($orderCreateDate->diff($currentDate)->days >= $days) {
+ return true;
}
- return true;
+ return false;
}
/**
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CreateGuaranteeAbilityTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CreateGuaranteeAbilityTest.php
new file mode 100644
index 0000000000000..db279c724e263
--- /dev/null
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CreateGuaranteeAbilityTest.php
@@ -0,0 +1,257 @@
+dateTimeFactory = new DateTimeFactory();
+ $this->orderRepository = $this->getMockBuilder(OrderRepositoryInterface::class)
+ ->getMockForAbstractClass();
+ $this->caseManagement = $this->getMockBuilder(CaseManagement::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->createGuaranteeAbility = new CreateGuaranteeAbility(
+ $this->caseManagement,
+ $this->orderRepository,
+ $this->dateTimeFactory
+ );
+ }
+
+ public function testIsAvailableSuccess()
+ {
+ $orderId = 123;
+ $orderCreatedAt = $this->getDateAgo(6);
+
+ /** @var CaseInterface|\PHPUnit_Framework_MockObject_MockObject $case */
+ $case = $this->getMockBuilder(CaseInterface::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+ $case->expects($this->once())
+ ->method('isGuaranteeEligible')
+ ->willReturn(true);
+
+ $this->caseManagement->expects($this->once())
+ ->method('getByOrderId')
+ ->with($orderId)
+ ->willReturn($case);
+
+ /** @var OrderInterface|\PHPUnit_Framework_MockObject_MockObject $order */
+ $order = $this->getMockBuilder(OrderInterface::class)
+ ->getMockForAbstractClass();
+ $order->expects($this->once())
+ ->method('getState')
+ ->willReturn(Order::STATE_COMPLETE);
+ $order->expects($this->once())
+ ->method('getCreatedAt')
+ ->willReturn($orderCreatedAt);
+
+ $this->orderRepository->expects($this->once())
+ ->method('get')
+ ->with($orderId)
+ ->willReturn($order);
+
+ $this->assertTrue($this->createGuaranteeAbility->isAvailable($orderId));
+ }
+
+ /**
+ * Tests case when Case entity doesn't exist for order
+ */
+ public function testIsAvailableWithNullCase()
+ {
+ $orderId = 123;
+
+ $this->caseManagement->expects($this->once())
+ ->method('getByOrderId')
+ ->with($orderId)
+ ->willReturn(null);
+
+ $this->assertFalse($this->createGuaranteeAbility->isAvailable($orderId));
+ }
+
+ /**
+ * Tests case when GuaranteeEligible for Case is false
+ */
+ public function testIsAvailableWithGuarantyEligibleFalse()
+ {
+ $orderId = 123;
+
+ /** @var CaseInterface|\PHPUnit_Framework_MockObject_MockObject $case */
+ $case = $this->getMockBuilder(CaseInterface::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+ $case->expects($this->once())
+ ->method('isGuaranteeEligible')
+ ->willReturn(false);
+
+ $this->caseManagement->expects($this->once())
+ ->method('getByOrderId')
+ ->with($orderId)
+ ->willReturn($case);
+
+ $this->assertFalse($this->createGuaranteeAbility->isAvailable($orderId));
+ }
+
+ /**
+ * Tests case when GuaranteeEligible for Case is false
+ */
+ public function testIsAvailableWithNullOrder()
+ {
+ $orderId = 123;
+
+ /** @var CaseInterface|\PHPUnit_Framework_MockObject_MockObject $case */
+ $case = $this->getMockBuilder(CaseInterface::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+ $case->expects($this->once())
+ ->method('isGuaranteeEligible')
+ ->willReturn(true);
+
+ $this->caseManagement->expects($this->once())
+ ->method('getByOrderId')
+ ->with($orderId)
+ ->willReturn($case);
+
+ $this->orderRepository->expects($this->once())
+ ->method('get')
+ ->with($orderId)
+ ->willThrowException(new NoSuchEntityException());
+
+ $this->assertFalse($this->createGuaranteeAbility->isAvailable($orderId));
+ }
+
+ /**
+ * Tests case when order has Canceled Or Closed states.
+ *
+ * @param string $state
+ * @dataProvider isAvailableWithCanceledOrderDataProvider
+ */
+ public function testIsAvailableWithCanceledOrder($state)
+ {
+ $orderId = 123;
+
+ /** @var CaseInterface|\PHPUnit_Framework_MockObject_MockObject $case */
+ $case = $this->getMockBuilder(CaseInterface::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+ $case->expects($this->once())
+ ->method('isGuaranteeEligible')
+ ->willReturn(true);
+
+ $this->caseManagement->expects($this->once())
+ ->method('getByOrderId')
+ ->with($orderId)
+ ->willReturn($case);
+
+ /** @var OrderInterface|\PHPUnit_Framework_MockObject_MockObject $order */
+ $order = $this->getMockBuilder(OrderInterface::class)
+ ->getMockForAbstractClass();
+ $order->expects($this->once())
+ ->method('getState')
+ ->willReturn($state);
+
+ $this->orderRepository->expects($this->once())
+ ->method('get')
+ ->with($orderId)
+ ->willReturn($order);
+
+ $this->assertFalse($this->createGuaranteeAbility->isAvailable($orderId));
+ }
+
+ public function isAvailableWithCanceledOrderDataProvider()
+ {
+ return [
+ [Order::STATE_CANCELED], [Order::STATE_CLOSED]
+ ];
+ }
+
+ public function testIsAvailableWithOldOrder()
+ {
+ $orderId = 123;
+ $orderCreatedAt = $this->getDateAgo(8);
+
+ /** @var CaseInterface|\PHPUnit_Framework_MockObject_MockObject $case */
+ $case = $this->getMockBuilder(CaseInterface::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+ $case->expects($this->once())
+ ->method('isGuaranteeEligible')
+ ->willReturn(true);
+
+ $this->caseManagement->expects($this->once())
+ ->method('getByOrderId')
+ ->with($orderId)
+ ->willReturn($case);
+
+ /** @var OrderInterface|\PHPUnit_Framework_MockObject_MockObject $order */
+ $order = $this->getMockBuilder(OrderInterface::class)
+ ->getMockForAbstractClass();
+ $order->expects($this->once())
+ ->method('getState')
+ ->willReturn(Order::STATE_COMPLETE);
+ $order->expects($this->once())
+ ->method('getCreatedAt')
+ ->willReturn($orderCreatedAt);
+
+ $this->orderRepository->expects($this->once())
+ ->method('get')
+ ->with($orderId)
+ ->willReturn($order);
+
+ $this->assertFalse($this->createGuaranteeAbility->isAvailable($orderId));
+ }
+
+ /**
+ * Returns date N days ago
+ *
+ * @param int $days number of days that will be deducted from the current date
+ * @return string
+ */
+ private function getDateAgo($days)
+ {
+ $createdAtTime = $this->dateTimeFactory->create('now', new \DateTimeZone('UTC'));
+ $createdAtTime->sub(new \DateInterval('P' . $days . 'D'));
+
+ return $createdAtTime->format('Y-m-d h:i:s');
+ }
+}
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Controller/Adminhtml/Guarantee/CreateTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Controller/Adminhtml/Guarantee/CreateTest.php
index 7375ff8c6d983..7add34e1a4586 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Controller/Adminhtml/Guarantee/CreateTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Controller/Adminhtml/Guarantee/CreateTest.php
@@ -52,7 +52,7 @@ public function testExecuteSuccess()
$this->getRequest()->setPostValue('orderId', $orderId);
$this->creationService->expects($this->once())
- ->method('create')
+ ->method('createForOrder')
->with($orderId)
->willReturn(true);
@@ -78,7 +78,7 @@ public function testExecuteWithEmptyOrderId()
$this->getRequest()->setPostValue('orderId', $orderId);
$this->creationService->expects($this->never())
- ->method('create');
+ ->method('createForOrder');
$this->dispatch(self::$entryPoint);
From 1c8213145a83fb6ff0da5278ed75257629623a08 Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Thu, 12 Jan 2017 11:20:43 -0600
Subject: [PATCH 129/904] MAGETWO-62807: Case information block on order
details page in admin panel
- refactoring
---
.../Signifyd/Block/Adminhtml/CaseInfo.php | 162 +++++++++++++-----
.../view/adminhtml/templates/case_info.phtml | 19 +-
2 files changed, 130 insertions(+), 51 deletions(-)
diff --git a/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php b/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php
index 6fcdf24aafa3f..c2e424db42496 100644
--- a/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php
+++ b/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php
@@ -5,10 +5,8 @@
*/
namespace Magento\Signifyd\Block\Adminhtml;
-use Magento\Backend\Block\Template\Context;
-use Magento\Framework\Registry;
-use Magento\Sales\Block\Adminhtml\Order\AbstractOrder;
-use Magento\Sales\Helper\Admin;
+use Magento\Framework\View\Element\Template;
+use Magento\Framework\View\Element\Template\Context;
use Magento\Signifyd\Model\Config;
use Magento\Signifyd\Model\CaseManagement;
use Magento\Signifyd\Api\Data\CaseInterface;
@@ -17,13 +15,18 @@
/**
* Get Signifyd Case Info
*/
-class CaseInfo extends AbstractOrder
+class CaseInfo extends Template
{
/**
* @var Config
*/
private $config;
+ /**
+ * @var CaseInterface
+ */
+ private $caseEntity = null;
+
/**
* @var CaseManagement
*/
@@ -48,8 +51,6 @@ class CaseInfo extends AbstractOrder
* Constructor
*
* @param Context $context
- * @param Registry $registry
- * @param Admin $adminHelper
* @param Config $config
* @param CaseManagement $caseManagement
* @param CreateGuaranteeAbility $createGuaranteeAbility
@@ -57,8 +58,6 @@ class CaseInfo extends AbstractOrder
*/
public function __construct(
Context $context,
- Registry $registry,
- Admin $adminHelper,
Config $config,
CaseManagement $caseManagement,
CreateGuaranteeAbility $createGuaranteeAbility,
@@ -68,72 +67,148 @@ public function __construct(
$this->caseManagement = $caseManagement;
$this->createGuaranteeAbility = $createGuaranteeAbility;
- parent::__construct($context, $registry, $adminHelper, $data);
+ parent::__construct($context, $data);
+ }
+
+ /**
+ * Checks if service is enabled.
+ *
+ * @return boolean
+ */
+ public function isServiceActive()
+ {
+ return $this->config->isActive();
}
/**
- * Retrieve required options from parent
+ * Gets case entity associated with order id.
*
- * @throws \Magento\Framework\Exception\LocalizedException
- * @return void
+ * @return CaseInterface|null
*/
- protected function _beforeToHtml()
+ private function getCaseEntity()
{
- if (!$this->getParentBlock()) {
- throw new \Magento\Framework\Exception\LocalizedException(
- __('Please correct the parent block for this block.')
+ if (is_null($this->caseEntity)) {
+ $this->caseEntity = $this->caseManagement->getByOrderId(
+ $this->getOrderId()
);
}
- $this->setOrder($this->getParentBlock()->getOrder());
- foreach ($this->getParentBlock()->getOrderInfoData() as $key => $value) {
- $this->setDataUsingMethod($key, $value);
- }
+ return $this->caseEntity;
+ }
- parent::_beforeToHtml();
+ /**
+ * Checks if case is exists for order
+ *
+ * @return bool
+ */
+ public function isEmptyCase()
+ {
+ return is_null($this->getCaseEntity());
}
/**
- * Checks if service is enabled.
+ * Gets case status
*
- * @return boolean
+ * @return string
*/
- public function isServiceActive()
+ public function getCaseStatus()
{
- return $this->config->isActive();
+ return $this->isEmptyCase() ? '' : $this->getCaseEntity()->getStatus();
}
/**
- * Gets case entity associated with order id.
+ * Gets case score value
*
- * @return CaseInterface|null
+ * @return int
*/
- public function getCaseEntity()
+ public function getCaseScore()
{
- return $this->caseManagement->getByOrderId($this->getOrderId());
+ return $this->isEmptyCase() ? 0 : $this->getCaseEntity()->getScore();
}
/**
* Gets state of case guarantee eligible.
*
- * @param CaseInterface $caseEntity
- * @return \Magento\Framework\Phrase
+ * @return string|\Magento\Framework\Phrase
+ */
+ public function getCaseGuaranteeEligible()
+ {
+ if ($this->isEmptyCase()) {
+ return '';
+ }
+
+ return $this->getCaseEntity()->isGuaranteeEligible() ? __('Yes') : __('No');
+ }
+
+ /**
+ * Gets case guarantee disposition status.
+ *
+ * @return string
+ */
+ public function getCaseGuaranteeDisposition()
+ {
+ if ($this->isEmptyCase()) {
+ return '';
+ }
+
+ return $this->getCaseEntity()->getGuaranteeDisposition();
+ }
+
+ /**
+ * Gets case review disposition status.
+ *
+ * @return string
*/
- public function getGuaranteeEligible(CaseInterface $caseEntity)
+ public function getCaseReviewDisposition()
{
- return $caseEntity->isGuaranteeEligible() ? __('Yes') : __('No');
+ if ($this->isEmptyCase()) {
+ return '';
+ }
+
+ return $this->getCaseEntity()->getReviewDisposition();
}
/**
- * Gets associated team name.
+ * Gets case create date.
*
- * @param CaseInterface $caseEntity
* @return string
*/
- public function getAssociatedTeam(CaseInterface $caseEntity)
+ public function getCaseCreatedAt()
{
+ if ($this->isEmptyCase()) {
+ return '';
+ }
+
+ return $this->getCaseEntity()->getCreatedAt();
+ }
+
+ /**
+ * Gets case update date.
+ *
+ * @return string
+ */
+ public function getCaseUpdatedAt()
+ {
+ if ($this->isEmptyCase()) {
+ return '';
+ }
+
+ return $this->getCaseEntity()->getUpdatedAt();
+ }
+
+ /**
+ * Gets case associated team name.
+ *
+ * @return string
+ */
+ public function getCaseAssociatedTeam()
+ {
+ if ($this->isEmptyCase()) {
+ return '';
+ }
+
$result = 'unknown';
- $team = $caseEntity->getAssociatedTeam();
+ $team = $this->getCaseEntity()->getAssociatedTeam();
if (isset($team['teamName'])) {
$result = $team['teamName'];
}
@@ -145,12 +220,15 @@ public function getAssociatedTeam(CaseInterface $caseEntity)
* Returns cell class name according to case score value.
* It could be used by merchant to customize order view template.
*
- * @param CaseInterface $caseEntity
* @return string
*/
- public function getScoreClass(CaseInterface $caseEntity)
+ public function getScoreClass()
{
- $score = $caseEntity->getScore();
+ if ($this->isEmptyCase()) {
+ return '';
+ }
+
+ $score = $this->getCaseEntity()->getScore();
if (self::$scoreAccept <= $score) {
$result = 'green';
@@ -201,6 +279,6 @@ private function getSubmitButton()
*/
private function getOrderId()
{
- return $this->getOrder()->getEntityId();
+ return (int) $this->getRequest()->getParam('order_id');
}
}
diff --git a/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml b/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml
index 98b2b63224d4f..b0160e263ef98 100644
--- a/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml
+++ b/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml
@@ -8,7 +8,8 @@
?>
isServiceActive() || !($case = $block->getCaseEntity())) {
+
+ if (!$block->isServiceActive() || $block->isEmptyCase()) {
return '';
}
?>
@@ -32,14 +33,14 @@
- escapeHtml($case->getStatus()); ?>
- escapeHtml($case->getScore()); ?>
- escapeHtml($block->getGuaranteeEligible($case)); ?>
- escapeHtml($case->getGuaranteeDisposition()); ?>
- escapeHtml($block->getAssociatedTeam($case)); ?>
- escapeHtml($case->getReviewDisposition()); ?>
- escapeHtml($case->getCreatedAt()); ?>
- escapeHtml($case->getUpdatedAt()); ?>
+ escapeHtml($block->getCaseStatus()); ?>
+ escapeHtml($block->getCaseScore()); ?>
+ escapeHtml($block->getCaseGuaranteeEligible()); ?>
+ escapeHtml($block->getCaseGuaranteeDisposition()); ?>
+ escapeHtml($block->getCaseAssociatedTeam()); ?>
+ escapeHtml($block->getCaseReviewDisposition()); ?>
+ escapeHtml($block->getCaseCreatedAt()); ?>
+ escapeHtml($block->getCaseUpdatedAt()); ?>
From 342f7836b6e8decf502796d75dcaae4b4f7112c5 Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Fri, 13 Jan 2017 03:56:46 -0600
Subject: [PATCH 130/904] MAGETWO-54393: Updating Order Status using Webhooks
- Refactored code according to code review
---
.../Signifyd/Api/Data/CaseInterface.php | 3 +-
.../Api/GuaranteeCreationServiceInterface.php | 2 -
.../Signifyd/Model/CommentsHistoryUpdater.php | 1 -
.../Model/Guarantee/CreationService.php | 27 ++--
.../Model/Guarantee/CreationServiceTest.php | 118 +++++++-----------
.../Model/Guarantee/CreationServiceTest.php | 5 +-
.../Request/CreateCaseBuilderTest.php | 2 +-
..._with_customer_and_two_simple_products.php | 2 +-
8 files changed, 62 insertions(+), 98 deletions(-)
diff --git a/app/code/Magento/Signifyd/Api/Data/CaseInterface.php b/app/code/Magento/Signifyd/Api/Data/CaseInterface.php
index 13b6564ad3323..6e05d2334656e 100644
--- a/app/code/Magento/Signifyd/Api/Data/CaseInterface.php
+++ b/app/code/Magento/Signifyd/Api/Data/CaseInterface.php
@@ -76,8 +76,9 @@ public function setCaseId($id);
/**
* Returns value, which indicates if a guarantee can be requested for a case.
+ * Returns null if state of guarantee eligible does not set yet.
*
- * @return boolean
+ * @return boolean|null
*/
public function isGuaranteeEligible();
diff --git a/app/code/Magento/Signifyd/Api/GuaranteeCreationServiceInterface.php b/app/code/Magento/Signifyd/Api/GuaranteeCreationServiceInterface.php
index ad6d5e8098190..3f3b0e223c71c 100644
--- a/app/code/Magento/Signifyd/Api/GuaranteeCreationServiceInterface.php
+++ b/app/code/Magento/Signifyd/Api/GuaranteeCreationServiceInterface.php
@@ -20,8 +20,6 @@ interface GuaranteeCreationServiceInterface
*
* @param int $orderId
* @return bool
- * @throws \Magento\Framework\Exception\NotFoundException If case for specified order is not created yet.
- * @throws \Magento\Framework\Exception\AlreadyExistsException If guarantee already created.
*/
public function createForOrder($orderId);
}
diff --git a/app/code/Magento/Signifyd/Model/CommentsHistoryUpdater.php b/app/code/Magento/Signifyd/Model/CommentsHistoryUpdater.php
index 976e5aa0a9dc6..2f794aedca67a 100644
--- a/app/code/Magento/Signifyd/Model/CommentsHistoryUpdater.php
+++ b/app/code/Magento/Signifyd/Model/CommentsHistoryUpdater.php
@@ -26,7 +26,6 @@ class CommentsHistoryUpdater
*/
public function __construct(HistoryFactory $historyFactory)
{
-
$this->historyFactory = $historyFactory;
}
diff --git a/app/code/Magento/Signifyd/Model/Guarantee/CreationService.php b/app/code/Magento/Signifyd/Model/Guarantee/CreationService.php
index 5801c4f490608..0288476bd6fcd 100644
--- a/app/code/Magento/Signifyd/Model/Guarantee/CreationService.php
+++ b/app/code/Magento/Signifyd/Model/Guarantee/CreationService.php
@@ -34,6 +34,11 @@ class CreationService implements GuaranteeCreationServiceInterface
*/
private $gateway;
+ /**
+ * @var CreateGuaranteeAbility
+ */
+ private $createGuaranteeAbility;
+
/**
* @var LoggerInterface
*/
@@ -45,17 +50,20 @@ class CreationService implements GuaranteeCreationServiceInterface
* @param CaseManagementInterface $caseManagement
* @param UpdatingServiceFactory $caseUpdatingServiceFactory
* @param Gateway $gateway
+ * @param CreateGuaranteeAbility $createGuaranteeAbility
* @param LoggerInterface $logger
*/
public function __construct(
CaseManagementInterface $caseManagement,
UpdatingServiceFactory $caseUpdatingServiceFactory,
Gateway $gateway,
+ CreateGuaranteeAbility $createGuaranteeAbility,
LoggerInterface $logger
) {
$this->caseManagement = $caseManagement;
$this->caseUpdatingServiceFactory = $caseUpdatingServiceFactory;
$this->gateway = $gateway;
+ $this->createGuaranteeAbility = $createGuaranteeAbility;
$this->logger = $logger;
}
@@ -64,23 +72,12 @@ public function __construct(
*/
public function createForOrder($orderId)
{
- $caseEntity = $this->caseManagement->getByOrderId($orderId);
- if ($caseEntity === null) {
- throw new NotFoundException(
- __('Case for order with specified id "%1" is not created', $orderId)
- );
- }
- if ($caseEntity->getCaseId() === null) {
- throw new NotFoundException(
- __('Case for order with specified id "%1" is not registered in Signifyd', $orderId)
- );
- }
- if ($caseEntity->getGuaranteeDisposition()) {
- throw new AlreadyExistsException(
- __('Guarantee for order "%1" has been created already', $orderId)
- );
+ if (!$this->createGuaranteeAbility->isAvailable($orderId)) {
+ return false;
}
+ $caseEntity = $this->caseManagement->getByOrderId($orderId);
+
try {
$disposition = $this->gateway->submitCaseForGuarantee($caseEntity->getCaseId());
} catch (GatewayException $e) {
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CreationServiceTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CreationServiceTest.php
index 119165407e301..cd41ce4c34d3b 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CreationServiceTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CreationServiceTest.php
@@ -5,18 +5,17 @@
*/
namespace Magento\Signifyd\Test\Unit\Model\Guarantee;
-use Magento\Signifyd\Model\SignifydGateway\GatewayException;
-use PHPUnit_Framework_TestCase as TestCase;
-use PHPUnit_Framework_MockObject_MockObject as MockObject;
-use Magento\Signifyd\Model\Guarantee\CreationService;
-use Magento\Framework\Exception\NotFoundException;
-use Magento\Framework\Exception\AlreadyExistsException;
use Magento\Signifyd\Api\CaseManagementInterface;
+use Magento\Signifyd\Api\Data\CaseInterface;
use Magento\Signifyd\Model\CaseServices\UpdatingServiceFactory;
use Magento\Signifyd\Model\CaseServices\UpdatingServiceInterface;
+use Magento\Signifyd\Model\Guarantee\CreateGuaranteeAbility;
+use Magento\Signifyd\Model\Guarantee\CreationService;
use Magento\Signifyd\Model\SignifydGateway\Gateway;
+use Magento\Signifyd\Model\SignifydGateway\GatewayException;
+use PHPUnit_Framework_MockObject_MockObject as MockObject;
+use PHPUnit_Framework_TestCase as TestCase;
use Psr\Log\LoggerInterface;
-use Magento\Signifyd\Api\Data\CaseInterface;
class CreationServiceTest extends TestCase
{
@@ -45,7 +44,15 @@ class CreationServiceTest extends TestCase
*/
private $logger;
- public function setUp()
+ /**
+ * @var CreateGuaranteeAbility|MockObject
+ */
+ private $createGuaranteeAbility;
+
+ /**
+ * @inheritdoc
+ */
+ protected function setUp()
{
$this->caseManagement = $this->getMockBuilder(CaseManagementInterface::class)
->getMockForAbstractClass();
@@ -63,6 +70,11 @@ public function setUp()
->disableOriginalConstructor()
->getMock();
+ $this->createGuaranteeAbility = $this->getMockBuilder(CreateGuaranteeAbility::class)
+ ->disableOriginalConstructor()
+ ->setMethods(['isAvailable'])
+ ->getMock();
+
$this->logger = $this->getMockBuilder(LoggerInterface::class)
->getMockForAbstractClass();
@@ -70,24 +82,33 @@ public function setUp()
$this->caseManagement,
$caseUpdatingServiceFactory,
$this->gateway,
+ $this->createGuaranteeAbility,
$this->logger
);
}
- public function testCreateForOrderWithoutCase()
+ /**
+ * Checks a test case, when guarantee ability checker does not allow to submit case for a guarantee.
+ *
+ * @covers \Magento\Signifyd\Model\Guarantee\CreationService::createForOrder
+ */
+ public function testCreateForOrderWithNotEligibleCase()
{
- $dummyOrderId = 1;
- $this->withCaseEntityNotExistsForOrderId($dummyOrderId);
+ $orderId = 1;
- $this->gateway
- ->expects($this->never())
+ $this->createGuaranteeAbility->expects(self::once())
+ ->method('isAvailable')
+ ->with($orderId)
+ ->willReturn(false);
+
+ $this->caseManagement->expects(self::never())
+ ->method('getByOrderId');
+
+ $this->gateway->expects(self::never())
->method('submitCaseForGuarantee');
- $this->caseUpdatingService
- ->expects($this->never())
- ->method('update');
- $this->setExpectedException(NotFoundException::class);
- $this->service->createForOrder($dummyOrderId);
+ $result = $this->service->createForOrder($orderId);
+ self::assertFalse($result);
}
public function testCreateForOrderWitCase()
@@ -174,8 +195,6 @@ public function testCreateForOrderWithCaseUpdate()
);
$this->withGatewaySuccess($dummyGuaranteeDisposition);
-
-
$result = $this->service->createForOrder($dummyOrderId);
$this->assertEquals(
true,
@@ -184,62 +203,13 @@ public function testCreateForOrderWithCaseUpdate()
);
}
- public function testCreateForOrderWithNotRegisteredCase()
- {
- $dummyOrderId = 1;
- $dummyCaseId = null;
- $this->withCaseEntityExistsForOrderId(
- $dummyOrderId,
- [
- 'caseId' => $dummyCaseId,
- ]
- );
-
- $this->gateway
- ->expects($this->never())
- ->method('submitCaseForGuarantee');
- $this->caseUpdatingService
- ->expects($this->never())
- ->method('update');
- $this->setExpectedException(NotFoundException::class);
-
- $this->service->createForOrder($dummyOrderId);
- }
-
- public function testCreateForOrderWithExistedGuarantee()
- {
- $dummyOrderId = 1;
- $dummyCaseId = 42;
- $dummyGuarantyDisposition = 'APPROVED';
- $this->withCaseEntityExistsForOrderId(
- $dummyOrderId,
- [
- 'caseId' => $dummyCaseId,
- 'guaranteeDisposition' => $dummyGuarantyDisposition
- ]
- );
-
- $this->gateway
- ->expects($this->never())
- ->method('submitCaseForGuarantee');
- $this->caseUpdatingService
- ->expects($this->never())
- ->method('update');
- $this->setExpectedException(AlreadyExistsException::class);
-
- $this->service->createForOrder($dummyOrderId);
- }
-
- private function withCaseEntityNotExistsForOrderId($orderId)
- {
- $this->caseManagement
- ->method('getByOrderId')
- ->with($this->equalTo($orderId))
- ->willReturn(null);
- }
-
private function withCaseEntityExistsForOrderId($orderId, array $caseData = [])
{
+ $this->createGuaranteeAbility->expects(self::once())
+ ->method('isAvailable')
+ ->with(self::equalTo($orderId))
+ ->willReturn(true);
+
$dummyCaseEntity = $this->getMockBuilder(CaseInterface::class)
->getMockForAbstractClass();
foreach ($caseData as $caseProperty => $casePropertyValue) {
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Model/Guarantee/CreationServiceTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Model/Guarantee/CreationServiceTest.php
index aa26311acf87a..f42945a6bacd7 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Model/Guarantee/CreationServiceTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/Guarantee/CreationServiceTest.php
@@ -12,6 +12,7 @@
use Magento\Signifyd\Api\Data\CaseInterface;
use Magento\Signifyd\Model\SignifydGateway\ApiCallException;
use Magento\Signifyd\Model\SignifydGateway\Gateway;
+use Magento\Signifyd\Model\SignifydGateway\GatewayException;
use Magento\TestFramework\Helper\Bootstrap;
use PHPUnit_Framework_MockObject_MockObject as MockObject;
use Psr\Log\LoggerInterface;
@@ -69,8 +70,6 @@ protected function setUp()
* for a specified order.
*
* @covers \Magento\Signifyd\Model\Guarantee\CreationService::createForOrder
- * @expectedException \Magento\Framework\Exception\NotFoundException
- * @expectedExceptionMessage Case for order with specified id "123" is not created
*/
public function testCreateWithoutCaseEntity()
{
@@ -95,7 +94,7 @@ public function testCreateWithFailedRequest()
$this->gateway->expects(self::once())
->method('submitCaseForGuarantee')
- ->willThrowException(new ApiCallException('Something wrong'));
+ ->willThrowException(new GatewayException('Something wrong'));
$this->logger->expects(self::once())
->method('error')
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
index d37d6fd6f8a7f..d1a863290d13f 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
@@ -83,7 +83,7 @@ public function testCreateCaseBuilderWithFullSetOfData()
'orderSessionId' => $signifydOrderSessionId->get($order->getQuoteId()),
'browserIpAddress' => $order->getRemoteIp(),
'orderId' => $order->getIncrementId(),
- 'createdAt' => '2016-12-12T12:00:55+00:00',
+ 'createdAt' => date('c', strtotime(date('Y-m-d 00:00:55'))),
'paymentGateway' => 'paypal_account',
'transactionId' => $payment->getLastTransId(),
'currency' => $order->getOrderCurrencyCode(),
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/_files/order_with_customer_and_two_simple_products.php b/dev/tests/integration/testsuite/Magento/Signifyd/_files/order_with_customer_and_two_simple_products.php
index 8f69f7a281610..a38cd01873cfc 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/_files/order_with_customer_and_two_simple_products.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/_files/order_with_customer_and_two_simple_products.php
@@ -71,7 +71,7 @@
->setCustomerId($customer->getId())
->setCustomerIsGuest(false)
->setRemoteIp('127.0.0.1')
- ->setCreatedAt('2016-12-12T12:00:55+0000')
+ ->setCreatedAt(date('Y-m-d 00:00:55'))
->setOrderCurrencyCode('USD')
->setBaseCurrencyCode('USD')
->setSubtotal($orderAmount)
From 828acbe2b763b06f2a80a5a89e4491db60550936 Mon Sep 17 00:00:00 2001
From: Dmytro Yushkin
Date: Fri, 13 Jan 2017 05:08:23 -0600
Subject: [PATCH 131/904] MAGETWO-62807: Case information block on order
details page in admin panel
- Extension point created for sales order view
---
.../Magento/Signifyd/view/adminhtml/layout/sales_order_view.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/code/Magento/Signifyd/view/adminhtml/layout/sales_order_view.xml b/app/code/Magento/Signifyd/view/adminhtml/layout/sales_order_view.xml
index 998e5e82a686a..4764050633c85 100644
--- a/app/code/Magento/Signifyd/view/adminhtml/layout/sales_order_view.xml
+++ b/app/code/Magento/Signifyd/view/adminhtml/layout/sales_order_view.xml
@@ -7,7 +7,7 @@
-->
-
+
From 2c5077d285f75ded9db183634cc5da246280d503 Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Fri, 13 Jan 2017 05:15:32 -0600
Subject: [PATCH 132/904] MAGETWO-62825: Guarantee creation possibility
validator
- Add CreateGuarantyAbility check to controller
---
.../Controller/Adminhtml/Guarantee/Create.php | 14 +++++++++++---
.../Controller/Adminhtml/Guarantee/CreateTest.php | 2 +-
2 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/app/code/Magento/Signifyd/Controller/Adminhtml/Guarantee/Create.php b/app/code/Magento/Signifyd/Controller/Adminhtml/Guarantee/Create.php
index 837f22e976b9c..54d41fe8bfa7c 100644
--- a/app/code/Magento/Signifyd/Controller/Adminhtml/Guarantee/Create.php
+++ b/app/code/Magento/Signifyd/Controller/Adminhtml/Guarantee/Create.php
@@ -7,6 +7,7 @@
use Magento\Framework\App\Action\Action;
use Magento\Framework\App\Action\Context;
+use Magento\Signifyd\Model\Guarantee\CreateGuaranteeAbility;
use Magento\Signifyd\Model\Guarantee\CreationService;
/**
@@ -20,17 +21,24 @@ class Create extends Action
* @var CreationService
*/
private $creationService;
+ /**
+ * @var CreateGuaranteeAbility
+ */
+ private $createGuaranteeAbility;
/**
* @param Context $context
* @param CreationService $creationService
+ * @param CreateGuaranteeAbility $createGuaranteeAbility
*/
public function __construct(
Context $context,
- CreationService $creationService
+ CreationService $creationService,
+ CreateGuaranteeAbility $createGuaranteeAbility
) {
parent::__construct($context);
$this->creationService = $creationService;
+ $this->createGuaranteeAbility = $createGuaranteeAbility;
}
/**
@@ -40,7 +48,7 @@ public function __construct(
*/
public function execute()
{
- $orderId = $this->getRequest()->getParam('orderId');
+ $orderId = (int)$this->getRequest()->getParam('orderId');
$resultRedirect = $this->resultRedirectFactory->create();
if (empty($orderId)) {
@@ -50,7 +58,7 @@ public function execute()
}
$resultRedirect->setPath('sales/order/view', ['order_id' => $orderId]);
- if ($this->creationService->createForOrder($orderId)) {
+ if ($this->createGuaranteeAbility->isAvailable($orderId) && $this->creationService->createForOrder($orderId)) {
$this->messageManager->addSuccessMessage(
__('Order has been submitted for Guarantee.')
);
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Controller/Adminhtml/Guarantee/CreateTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Controller/Adminhtml/Guarantee/CreateTest.php
index 7add34e1a4586..71afeb8ad6dc9 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Controller/Adminhtml/Guarantee/CreateTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Controller/Adminhtml/Guarantee/CreateTest.php
@@ -102,7 +102,7 @@ public function testExecuteWithCreationServiceFail()
$this->getRequest()->setPostValue('orderId', $orderId);
$this->creationService->expects($this->once())
- ->method('create')
+ ->method('createForOrder')
->with($orderId)
->willReturn(false);
From b35187174567bff5ee7664e56fa4869089f32209 Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Fri, 13 Jan 2017 09:28:35 -0600
Subject: [PATCH 133/904] MAGETWO-62807: Case information block on order
details page in admin panel
- refactoring
---
.../Signifyd/Block/Adminhtml/CaseInfo.php | 112 +++++++++---------
.../Unit/Block/Adminhtml/CaseInfoTest.php | 108 ++++++++++++++++-
2 files changed, 162 insertions(+), 58 deletions(-)
diff --git a/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php b/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php
index c2e424db42496..7ddd7b02e0a0d 100644
--- a/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php
+++ b/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php
@@ -25,7 +25,7 @@ class CaseInfo extends Template
/**
* @var CaseInterface
*/
- private $caseEntity = null;
+ private $caseEntity = false;
/**
* @var CaseManagement
@@ -87,7 +87,7 @@ public function isServiceActive()
*/
private function getCaseEntity()
{
- if (is_null($this->caseEntity)) {
+ if ($this->caseEntity === false) {
$this->caseEntity = $this->caseManagement->getByOrderId(
$this->getOrderId()
);
@@ -96,6 +96,18 @@ private function getCaseEntity()
return $this->caseEntity;
}
+ /**
+ * Default getter for case properties
+ *
+ * @param mixed $defaultValue
+ * @param callable $callback
+ * @return mixed
+ */
+ private function getCaseProperty( $defaultValue, callable $callback)
+ {
+ return $this->isEmptyCase() ? $defaultValue : call_user_func($callback);
+ }
+
/**
* Checks if case is exists for order
*
@@ -113,7 +125,9 @@ public function isEmptyCase()
*/
public function getCaseStatus()
{
- return $this->isEmptyCase() ? '' : $this->getCaseEntity()->getStatus();
+ return $this->getCaseProperty('', function () {
+ return $this->getCaseEntity()->getStatus();
+ });
}
/**
@@ -123,7 +137,9 @@ public function getCaseStatus()
*/
public function getCaseScore()
{
- return $this->isEmptyCase() ? 0 : $this->getCaseEntity()->getScore();
+ return $this->getCaseProperty(0, function () {
+ return $this->getCaseEntity()->getScore();
+ });
}
/**
@@ -133,11 +149,9 @@ public function getCaseScore()
*/
public function getCaseGuaranteeEligible()
{
- if ($this->isEmptyCase()) {
- return '';
- }
-
- return $this->getCaseEntity()->isGuaranteeEligible() ? __('Yes') : __('No');
+ return $this->getCaseProperty('', function () {
+ return $this->getCaseEntity()->isGuaranteeEligible() ? __('Yes') : __('No');
+ });
}
/**
@@ -147,11 +161,9 @@ public function getCaseGuaranteeEligible()
*/
public function getCaseGuaranteeDisposition()
{
- if ($this->isEmptyCase()) {
- return '';
- }
-
- return $this->getCaseEntity()->getGuaranteeDisposition();
+ return $this->getCaseProperty('', function () {
+ return $this->getCaseEntity()->getGuaranteeDisposition();
+ });
}
/**
@@ -161,11 +173,9 @@ public function getCaseGuaranteeDisposition()
*/
public function getCaseReviewDisposition()
{
- if ($this->isEmptyCase()) {
- return '';
- }
-
- return $this->getCaseEntity()->getReviewDisposition();
+ return $this->getCaseProperty('', function () {
+ return $this->getCaseEntity()->getReviewDisposition();
+ });
}
/**
@@ -175,11 +185,9 @@ public function getCaseReviewDisposition()
*/
public function getCaseCreatedAt()
{
- if ($this->isEmptyCase()) {
- return '';
- }
-
- return $this->getCaseEntity()->getCreatedAt();
+ return $this->getCaseProperty('asd', function () {
+ return $this->getCaseEntity()->getCreatedAt();
+ });
}
/**
@@ -189,11 +197,9 @@ public function getCaseCreatedAt()
*/
public function getCaseUpdatedAt()
{
- if ($this->isEmptyCase()) {
- return '';
- }
-
- return $this->getCaseEntity()->getUpdatedAt();
+ return $this->getCaseProperty('', function () {
+ return $this->getCaseEntity()->getUpdatedAt();
+ });
}
/**
@@ -203,17 +209,15 @@ public function getCaseUpdatedAt()
*/
public function getCaseAssociatedTeam()
{
- if ($this->isEmptyCase()) {
- return '';
- }
-
- $result = 'unknown';
- $team = $this->getCaseEntity()->getAssociatedTeam();
- if (isset($team['teamName'])) {
- $result = $team['teamName'];
- }
-
- return $result;
+ return $this->getCaseProperty('', function () {
+ $teamName = 'unknown';
+ $team = $this->getCaseEntity()->getAssociatedTeam();
+ if (isset($team['teamName'])) {
+ $teamName = $team['teamName'];
+ }
+
+ return $teamName;
+ });
}
/**
@@ -224,21 +228,19 @@ public function getCaseAssociatedTeam()
*/
public function getScoreClass()
{
- if ($this->isEmptyCase()) {
- return '';
- }
-
- $score = $this->getCaseEntity()->getScore();
-
- if (self::$scoreAccept <= $score) {
- $result = 'green';
- } elseif ($score <= self::$scoreDecline) {
- $result = 'red';
- } else {
- $result = 'yellow';
- }
-
- return $result;
+ return $this->getCaseProperty('', function () {
+ $score = $this->getCaseEntity()->getScore();
+
+ if (self::$scoreAccept <= $score) {
+ $result = 'green';
+ } elseif ($score <= self::$scoreDecline) {
+ $result = 'red';
+ } else {
+ $result = 'yellow';
+ }
+
+ return $result;
+ });
}
/**
diff --git a/app/code/Magento/Signifyd/Test/Unit/Block/Adminhtml/CaseInfoTest.php b/app/code/Magento/Signifyd/Test/Unit/Block/Adminhtml/CaseInfoTest.php
index 5384ce749a0bd..060a3a1e49421 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Block/Adminhtml/CaseInfoTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Block/Adminhtml/CaseInfoTest.php
@@ -5,10 +5,15 @@
*/
namespace Magento\Signifyd\Test\Unit\Block\Adminhtml;
+use PHPUnit_Framework_MockObject_MockObject as MockObject;
+use Magento\Framework\App\RequestInterface;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use Magento\Framework\View\Element\Template\Context;
use Magento\Signifyd\Api\Data\CaseInterface;
+use Magento\Signifyd\Model\Config;
+use Magento\Signifyd\Model\CaseManagement;
+use Magento\Signifyd\Model\Guarantee\CreateGuaranteeAbility;
use Magento\Signifyd\Block\Adminhtml\CaseInfo;
-use PHPUnit_Framework_MockObject_MockObject as MockObject;
/**
* Tests for Signifyd block information.
@@ -27,6 +32,31 @@ class CaseInfoTest extends \PHPUnit_Framework_TestCase
*/
private $caseInfo;
+ /**
+ * @var Context
+ */
+ private $context;
+
+ /**
+ * @var Config
+ */
+ private $config;
+
+ /**
+ * @var CaseManagement
+ */
+ private $caseManagement;
+
+ /**
+ * @var CreateGuaranteeAbility
+ */
+ private $createGuaranteeAbility;
+
+ /**
+ * @var RequestInterface
+ */
+ private $request;
+
/**
* @inheritdoc
*/
@@ -34,12 +64,40 @@ protected function setUp()
{
$objectManager = new ObjectManager($this);
+ $this->context = $this->getMockBuilder(Context::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->request = $this->getMockBuilder(RequestInterface::class)
+ ->getMockForAbstractClass();
+
+ $this->context->expects(self::once())
+ ->method('getRequest')
+ ->willReturn($this->request);
+
+ $this->config = $this->getMockBuilder(Config::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->caseManagement = $this->getMockBuilder(CaseManagement::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->createGuaranteeAbility = $this->getMockBuilder(CreateGuaranteeAbility::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+
$this->caseEntity = $this->getMockBuilder(CaseInterface::class)
->disableOriginalConstructor()
->setMethods(['getScore'])
->getMockForAbstractClass();
- $this->caseInfo = $objectManager->getObject(CaseInfo::class);
+ $this->caseInfo = $objectManager->getObject(CaseInfo::class, [
+ 'context' => $this->context,
+ 'config' => $this->config,
+ 'caseManagement' => $this->caseManagement,
+ 'createGuaranteeAbility' => $this->createGuaranteeAbility
+ ]);
}
/**
@@ -56,9 +114,53 @@ public function testGetScoreClass($score, $expectedClassName)
->method('getScore')
->willReturn($score);
+ $this->caseManagement->expects(self::once())
+ ->method('getByOrderId')
+ ->willReturn($this->caseEntity);
+
self::assertEquals(
$expectedClassName,
- $this->caseInfo->getScoreClass($this->caseEntity)
+ $this->caseInfo->getScoreClass()
+ );
+ }
+
+ /**
+ * Checks case property getter with real case.
+ *
+ * @covers \Magento\Signifyd\Block\CaseInfo::getCaseProperty
+ */
+ public function testCasePropertyWithCaseExists()
+ {
+ $score = 575;
+
+ $this->caseEntity->expects($this->once())
+ ->method('getScore')
+ ->willReturn($score);
+
+ $this->caseManagement->expects(self::once())
+ ->method('getByOrderId')
+ ->willReturn($this->caseEntity);
+
+ self::assertEquals(
+ $score,
+ $this->caseInfo->getCaseScore()
+ );
+ }
+
+ /**
+ * Checks case property getter with empty case.
+ *
+ * @covers \Magento\Signifyd\Block\CaseInfo::getCaseProperty
+ */
+ public function testCasePropertyWithEmptyCase()
+ {
+ $this->caseManagement->expects(self::once())
+ ->method('getByOrderId')
+ ->willReturn(null);
+
+ self::assertEquals(
+ 0,
+ $this->caseInfo->getCaseScore()
);
}
From f910c71303c21018322066397b80fe5e29130f20 Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Fri, 13 Jan 2017 10:28:35 -0600
Subject: [PATCH 134/904] MAGETWO-62807: Case information block on order
details page in admin panel
- refactoring
---
app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php | 4 ++--
.../Signifyd/view/adminhtml/templates/case_info.phtml | 10 +++++-----
.../Signifyd/view/adminhtml/web/js/request-send.js | 2 +-
3 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php b/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php
index 7ddd7b02e0a0d..6d964c3c92e89 100644
--- a/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php
+++ b/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php
@@ -103,7 +103,7 @@ private function getCaseEntity()
* @param callable $callback
* @return mixed
*/
- private function getCaseProperty( $defaultValue, callable $callback)
+ private function getCaseProperty($defaultValue, callable $callback)
{
return $this->isEmptyCase() ? $defaultValue : call_user_func($callback);
}
@@ -115,7 +115,7 @@ private function getCaseProperty( $defaultValue, callable $callback)
*/
public function isEmptyCase()
{
- return is_null($this->getCaseEntity());
+ return $this->getCaseEntity() === null;
}
/**
diff --git a/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml b/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml
index b0160e263ef98..679a584fa2ad5 100644
--- a/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml
+++ b/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml
@@ -46,20 +46,20 @@
getButtons() as $button):?>
-
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Block/Adminhtml/CaseInfoTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Block/Adminhtml/CaseInfoTest.php
index 2b5569dbf8c50..c59c64a5f60e1 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Block/Adminhtml/CaseInfoTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Block/Adminhtml/CaseInfoTest.php
@@ -5,13 +5,11 @@
*/
namespace Magento\Signifyd\Block\Adminhtml;
-use Magento\Backend\Block\Template;
use Magento\Framework\App\RequestInterface;
use Magento\Framework\ObjectManagerInterface;
use Magento\Framework\View\Element\Template\Context;
use Magento\Framework\View\LayoutInterface;
use Magento\Sales\Model\Order;
-use Magento\Sales\Model\OrderRepository;
use Magento\TestFramework\Helper\Bootstrap;
class CaseInfoTest extends \PHPUnit_Framework_TestCase
@@ -31,16 +29,6 @@ class CaseInfoTest extends \PHPUnit_Framework_TestCase
*/
private $layout;
- /**
- * @var string
- */
- private static $submitButton = 'Submit Guarantee Request';
-
- /**
- * @var string
- */
- private static $cancelButton = 'Cancel Guarantee Request';
-
/**
* @inheritdoc
*/
@@ -100,69 +88,6 @@ public function testCaseEntityExists()
static::assertContains('col-case-score-green', $html);
}
- /**
- * Checks state of Guarantee action buttons on order page.
- *
- * @covers \Magento\Signifyd\Block\Adminhtml\CaseInfo::getButtons
- * @magentoConfigFixture current_store fraud_protection/signifyd/active 1
- * @magentoDataFixture Magento/Signifyd/_files/case.php
- * @magentoAppArea adminhtml
- */
- public function testSubmitButtonAvailable()
- {
- $this->order->loadByIncrementId('100000001');
-
- $blockContents = $this->getBlockContents();
-
- static::assertContains(self::$submitButton, $blockContents);
- static::assertNotContains(self::$cancelButton, $blockContents);
- }
-
- /**
- * Checks that guarantee action buttons is unavailable on order page.
- *
- * @covers \Magento\Signifyd\Block\Adminhtml\CaseInfo::getButtons
- * @magentoConfigFixture current_store fraud_protection/signifyd/active 1
- * @magentoDataFixture Magento/Signifyd/_files/case.php
- * @magentoAppArea adminhtml
- */
- public function testButtonsUnavailable()
- {
- $this->order->loadByIncrementId('100000001');
- $this->order->setState(Order::STATE_CANCELED);
-
- /** @var OrderRepository $orderRepository */
- $orderRepository = $this->objectManager->get(OrderRepository::class);
- $orderRepository->save($this->order);
-
- $blockContents = $this->getBlockContents();
-
- static::assertNotContains(self::$submitButton, $blockContents);
- static::assertNotContains(self::$cancelButton, $blockContents);
- }
-
- /**
- * Checks action buttons for case entity with Guarantee submitted.
- *
- * @covers \Magento\Signifyd\Block\Adminhtml\CaseInfo::getButtons
- * @magentoConfigFixture current_store fraud_protection/signifyd/active 1
- * @magentoDataFixture Magento/Signifyd/_files/approved_case.php
- * @magentoAppArea adminhtml
- */
- public function testButtonsForApprovedCase()
- {
- $this->order->loadByIncrementId('100000001');
-
- /** @var OrderRepository $orderRepository */
- $orderRepository = $this->objectManager->get(OrderRepository::class);
- $orderRepository->save($this->order);
-
- $blockContents = $this->getBlockContents();
-
- static::assertNotContains(self::$submitButton, $blockContents);
- static::assertContains(self::$cancelButton, $blockContents);
- }
-
/**
* Renders block contents.
*
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Controller/Adminhtml/Guarantee/CancelTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Controller/Adminhtml/Guarantee/CancelTest.php
deleted file mode 100644
index 05089bde9ac56..0000000000000
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Controller/Adminhtml/Guarantee/CancelTest.php
+++ /dev/null
@@ -1,157 +0,0 @@
-cancelingService = $this->getMockBuilder(GuaranteeCancelingServiceInterface::class)
- ->disableOriginalConstructor()
- ->setMethods(['cancelForOrder'])
- ->getMockForAbstractClass();
-
- $this->_objectManager->addSharedInstance($this->cancelingService, CancelingService::class);
- }
-
- /**
- * @inheritdoc
- */
- protected function tearDown()
- {
- $this->_objectManager->removeSharedInstance(CancelingService::class);
-
- parent::tearDown();
- }
-
- /**
- * Checks a test case, when order id is missed in request.
- *
- * @covers \Magento\Signifyd\Controller\Adminhtml\Guarantee\Cancel::execute
- * @magentoAppArea adminhtml
- */
- public function testExecuteWithEmptyOrderId()
- {
- $this->getRequest()->setPostValue('order_id', null);
-
- $this->cancelingService->expects(self::never())
- ->method('cancelForOrder');
-
- $this->dispatch(self::$entryPoint);
-
- self::assertRedirect(self::stringContains('backend/sales/order/index'));
- self::assertSessionMessages(
- self::equalTo(['Order id is required.']),
- MessageInterface::TYPE_ERROR
- );
- }
-
- /**
- * Checks a test case, when guarantee is not available for canceling.
- *
- * @covers \Magento\Signifyd\Controller\Adminhtml\Guarantee\Cancel::execute
- * @magentoAppArea adminhtml
- */
- public function testExecuteWithNotAvailableGuarantee()
- {
- $this->getRequest()->setPostValue('order_id', 123);
-
- $this->cancelingService->expects(self::never())
- ->method('cancelForOrder');
-
- $this->dispatch(self::$entryPoint);
-
- self::assertRedirect(self::stringContains('backend/sales/order/view'));
- self::assertSessionMessages(
- self::equalTo(['Sorry, we cannot cancel Guarantee for order.']),
- MessageInterface::TYPE_ERROR
- );
- }
-
- /**
- * Checks as test case, when canceling service cannot successfully cancel guarantee.
- *
- * @covers \Magento\Signifyd\Controller\Adminhtml\Guarantee\Cancel::execute
- * @magentoDataFixture Magento/Signifyd/_files/approved_case.php
- * @magentoAppArea adminhtml
- */
- public function testExecuteWithCancelingFailedRequest()
- {
- $caseId = 123;
-
- /** @var CaseRepositoryInterface $caseRepository */
- $caseRepository = $this->_objectManager->get(CaseRepositoryInterface::class);
- $caseEntity = $caseRepository->getByCaseId($caseId);
-
- $this->getRequest()->setPostValue('order_id', $caseEntity->getOrderId());
-
- $this->cancelingService->expects(self::once())
- ->method('cancelForOrder')
- ->with(self::equalTo($caseEntity->getOrderId()))
- ->willReturn(false);
-
- $this->dispatch(self::$entryPoint);
-
- self::assertRedirect(self::stringContains('backend/sales/order/view'));
- self::assertSessionMessages(
- self::equalTo(['Sorry, we cannot cancel Guarantee for order.']),
- MessageInterface::TYPE_ERROR
- );
- }
-
- /**
- * Checks a test case, when guarantee is successfully canceled for order.
- *
- * @covers \Magento\Signifyd\Controller\Adminhtml\Guarantee\Cancel::execute
- * @magentoDataFixture Magento/Signifyd/_files/approved_case.php
- * @magentoAppArea adminhtml
- */
- public function testExecute()
- {
- $caseId = 123;
-
- /** @var CaseRepositoryInterface $caseRepository */
- $caseRepository = $this->_objectManager->get(CaseRepositoryInterface::class);
- $caseEntity = $caseRepository->getByCaseId($caseId);
-
- $this->getRequest()->setPostValue('order_id', $caseEntity->getOrderId());
-
- $this->cancelingService->expects(self::once())
- ->method('cancelForOrder')
- ->with(self::equalTo($caseEntity->getOrderId()))
- ->willReturn(true);
-
- $this->dispatch(self::$entryPoint);
-
- self::assertRedirect(self::stringContains('backend/sales/order/view'));
- self::assertSessionMessages(
- self::equalTo(['Guarantee has been cancelled for order.']),
- MessageInterface::TYPE_SUCCESS
- );
- }
-}
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Controller/Adminhtml/Guarantee/CreateTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Controller/Adminhtml/Guarantee/CreateTest.php
deleted file mode 100644
index 4c1e4e61cba7c..0000000000000
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Controller/Adminhtml/Guarantee/CreateTest.php
+++ /dev/null
@@ -1,133 +0,0 @@
-creationService = $this->getMockBuilder(CreationService::class)
- ->disableOriginalConstructor()
- ->getMock();
- $this->_objectManager->addSharedInstance($this->creationService, CreationService::class);
- }
-
- /**
- * Tests successful Guarantee creation for an order.
- *
- * @covers \Magento\Signifyd\Controller\Adminhtml\Guarantee\Create::execute
- * @magentoDataFixture Magento/Signifyd/_files/case.php
- * @magentoAppArea adminhtml
- */
- public function testExecuteSuccess()
- {
- $orderId = $this->getOrderId();
- $this->getRequest()->setPostValue('order_id', $orderId);
-
- $this->creationService->expects($this->once())
- ->method('createForOrder')
- ->with($orderId)
- ->willReturn(true);
-
- $this->dispatch(self::$entryPoint);
-
- $this->assertRedirect($this->stringContains('backend/sales/order/view'));
- $this->assertSessionMessages(
- $this->equalTo(['Order has been submitted for Guarantee.']),
- MessageInterface::TYPE_SUCCESS
- );
- }
-
- /**
- * Tests failure Guarantee creation due to empty order id.
- *
- * @covers \Magento\Signifyd\Controller\Adminhtml\Guarantee\Create::execute
- * @magentoDataFixture Magento/Signifyd/_files/case.php
- * @magentoAppArea adminhtml
- */
- public function testExecuteWithEmptyOrderId()
- {
- $orderId = '';
- $this->getRequest()->setPostValue('order_id', $orderId);
-
- $this->creationService->expects($this->never())
- ->method('createForOrder');
-
- $this->dispatch(self::$entryPoint);
-
- $this->assertRedirect($this->stringContains('backend/sales/order/index'));
- $this->assertSessionMessages(
- $this->equalTo(['Order id is required.']),
- MessageInterface::TYPE_ERROR
- );
- }
-
- /**
- * Tests failure Guarantee creation due to unsuccessful CreationService call.
- *
- * @covers \Magento\Signifyd\Controller\Adminhtml\Guarantee\Create::execute
- * @magentoDataFixture Magento/Signifyd/_files/case.php
- * @magentoAppArea adminhtml
- */
- public function testExecuteWithCreationServiceFail()
- {
- $orderId = $this->getOrderId();
- $this->getRequest()->setPostValue('order_id', $orderId);
-
- $this->creationService->expects($this->once())
- ->method('createForOrder')
- ->with($orderId)
- ->willReturn(false);
-
- $this->dispatch(self::$entryPoint);
-
- $this->assertRedirect($this->stringContains('backend/sales/order/view'));
- $this->assertSessionMessages(
- $this->equalTo(['Sorry, we cannot submit order for Guarantee.']),
- MessageInterface::TYPE_ERROR
- );
- }
-
- /**
- * Returns orderId from case in fixture
- *
- * @return int
- */
- private function getOrderId()
- {
- $caseId = 123;
- /** @var CaseRepositoryInterface $caseRepository */
- $caseRepository = $this->_objectManager->get(CaseRepositoryInterface::class);
- /** @var CaseInterface $caseEntity */
- $caseEntity = $caseRepository->getByCaseId($caseId);
-
- return $caseEntity->getOrderId();
- }
-}
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Observer/CancelOrderTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Observer/CancelOrderTest.php
new file mode 100644
index 0000000000000..d00204191aa32
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Observer/CancelOrderTest.php
@@ -0,0 +1,119 @@
+objectManager = Bootstrap::getObjectManager();
+
+ $this->apiClient = $this->getMockBuilder(ApiClient::class)
+ ->disableOriginalConstructor()
+ ->setMethods(['makeApiCall'])
+ ->getMock();
+
+ $this->objectManager->addSharedInstance($this->apiClient, ApiClient::class);
+ }
+
+ /**
+ * @inheritdoc
+ */
+ protected function tearDown()
+ {
+ $this->objectManager->removeSharedInstance(ApiClient::class);
+ }
+
+ /**
+ * Checks a test case, when order has been cancelled and triggers event to cancel Signifyd case guarantee
+ *
+ * @covers \Magento\Signifyd\Observer\CancelOrder::execute
+ * @magentoDataFixture Magento/Signifyd/_files/approved_case.php
+ * @magentoConfigFixture current_store fraud_protection/signifyd/active 1
+ */
+ public function testExecute()
+ {
+ $order = $this->getOrder();
+
+ $this->apiClient->expects(self::once())
+ ->method('makeApiCall')
+ ->with(
+ self::equalTo('/cases/' . self::$caseId . '/guarantee'),
+ 'PUT',
+ [
+ 'guaranteeDisposition' => CaseInterface::GUARANTEE_CANCELED
+ ]
+ )
+ ->willReturn([
+ 'disposition' => CaseInterface::GUARANTEE_CANCELED
+ ]);
+
+ /** @var OrderManagementInterface $orderService */
+ $orderService = $this->objectManager->get(OrderManagementInterface::class);
+ $orderService->cancel($order->getEntityId());
+
+ /** @var CaseRepositoryInterface $caseRepository */
+ $caseRepository = $this->objectManager->get(CaseRepositoryInterface::class);
+ $case = $caseRepository->getByCaseId(self::$caseId);
+
+ self::assertEquals(CaseInterface::GUARANTEE_CANCELED, $case->getGuaranteeDisposition());
+ }
+
+ /**
+ * Get stored order
+ * @return OrderInterface
+ */
+ private function getOrder()
+ {
+ /** @var FilterBuilder $filterBuilder */
+ $filterBuilder = $this->objectManager->get(FilterBuilder::class);
+ $filters = [
+ $filterBuilder->setField(OrderInterface::INCREMENT_ID)
+ ->setValue('100000001')
+ ->create()
+ ];
+
+ /** @var SearchCriteriaBuilder $searchCriteriaBuilder */
+ $searchCriteriaBuilder = $this->objectManager->get(SearchCriteriaBuilder::class);
+ $searchCriteria = $searchCriteriaBuilder->addFilters($filters)
+ ->create();
+
+ $orderRepository = $this->objectManager->get(OrderRepositoryInterface::class);
+ $orders = $orderRepository->getList($searchCriteria)
+ ->getItems();
+
+ /** @var OrderInterface $order */
+ return array_pop($orders);
+ }
+}
From 067f39c00094f14c7d7560a8dd4cacb11da718af Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Fri, 3 Feb 2017 05:08:33 -0600
Subject: [PATCH 162/904] MAGETWO-63851: Re-implement cancel guarantee
mechanism
- Added missed namespace
---
.../testsuite/Magento/Signifyd/Observer/CancelOrderTest.php | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Observer/CancelOrderTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Observer/CancelOrderTest.php
index d00204191aa32..94f1779312f1f 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Observer/CancelOrderTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Observer/CancelOrderTest.php
@@ -3,6 +3,8 @@
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+namespace Magento\Signifyd\Observer;
+
use Magento\Framework\Api\FilterBuilder;
use Magento\Framework\Api\SearchCriteriaBuilder;
use Magento\Sales\Api\Data\OrderInterface;
@@ -15,7 +17,7 @@
use Magento\TestFramework\ObjectManager;
use PHPUnit_Framework_MockObject_MockObject as MockObject;
-class CancelOrderTest extends PHPUnit_Framework_TestCase
+class CancelOrderTest extends \PHPUnit_Framework_TestCase
{
/**
* @var int
From 5d527cd45f882cdba7fbd518d21c78fc1580e949 Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Fri, 3 Feb 2017 05:11:14 -0600
Subject: [PATCH 163/904] MAGETWO-63942: Add Signifyd Guarantee Status column
to order grid
- static test fix
---
app/code/Magento/Signifyd/Setup/InstallData.php | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/app/code/Magento/Signifyd/Setup/InstallData.php b/app/code/Magento/Signifyd/Setup/InstallData.php
index d82a16a5a0286..1436d52d4b823 100644
--- a/app/code/Magento/Signifyd/Setup/InstallData.php
+++ b/app/code/Magento/Signifyd/Setup/InstallData.php
@@ -33,7 +33,8 @@ public function __construct(
/**
* Installs data for sales module
*
- * Update of sales_order_grid* tables is provided here to be sure that these tables are already created. {@inheritdoc}
+ * Update of sales_order_grid* tables is provided here to be sure that these tables are already created.
+ * {@inheritdoc}
*/
public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
{
From 3fc99c3875fcafa739caa58704b5f4d5f9a8d6e8 Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Fri, 3 Feb 2017 06:00:10 -0600
Subject: [PATCH 164/904] MAGETWO-63942: Add Signifyd Guarantee Status column
to order grid
- SalesArchive dependency added
(cherry picked from commit 4c897f1)
---
app/code/Magento/Signifyd/composer.json | 1 +
app/code/Magento/Signifyd/etc/module.xml | 1 +
2 files changed, 2 insertions(+)
diff --git a/app/code/Magento/Signifyd/composer.json b/app/code/Magento/Signifyd/composer.json
index cf9b2311bbba5..87ce791eae618 100644
--- a/app/code/Magento/Signifyd/composer.json
+++ b/app/code/Magento/Signifyd/composer.json
@@ -5,6 +5,7 @@
"php": "~5.6.5|7.0.2|7.0.4|~7.0.6",
"magento/framework": "100.2.*",
"magento/module-sales": "100.2.*",
+ "magento/module-sales-archive": "100.2.*",
"magento/module-store": "100.2.*",
"magento/module-customer": "100.2.*",
"magento/module-directory": "100.2.*",
diff --git a/app/code/Magento/Signifyd/etc/module.xml b/app/code/Magento/Signifyd/etc/module.xml
index e2469080bdac2..5d973cc95851e 100644
--- a/app/code/Magento/Signifyd/etc/module.xml
+++ b/app/code/Magento/Signifyd/etc/module.xml
@@ -9,6 +9,7 @@
+
From 856ff86e05013fa85c176c9d34b4488d56f6a064 Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Mon, 6 Feb 2017 03:02:23 -0600
Subject: [PATCH 165/904] MAGETWO-63942: Add Signifyd Guarantee Status column
to order grid
- type attribute removed for VirtualType
(cherry picked from commit 44d6ceb)
---
app/code/Magento/Signifyd/etc/di.xml | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/app/code/Magento/Signifyd/etc/di.xml b/app/code/Magento/Signifyd/etc/di.xml
index fd2396f1b0aa2..2f0261ec8d131 100644
--- a/app/code/Magento/Signifyd/etc/di.xml
+++ b/app/code/Magento/Signifyd/etc/di.xml
@@ -14,8 +14,7 @@
-
-
+
-
@@ -29,8 +28,7 @@
-
-
+
-
From dd08983cc002b45ba9e8d10d9aaea0b2cfb144bd Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Mon, 6 Feb 2017 06:02:30 -0600
Subject: [PATCH 166/904] MAGETWO-63910: Create infrastructure for mapper in
Payment module
- Added api interfaces and default mapper implementation
- Added AVS, CVV codes mapper for Braintree payment method
(cherry picked from commit e928e23)
---
.../SignifydGateway/Request/PurchaseBuilder.php | 17 +++++++++++++++--
app/code/Magento/Signifyd/composer.json | 3 ++-
app/code/Magento/Signifyd/etc/module.xml | 1 +
3 files changed, 18 insertions(+), 3 deletions(-)
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php
index dd464f73c1df2..524b4a2e6ab8f 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php
@@ -6,8 +6,9 @@
namespace Magento\Signifyd\Model\SignifydGateway\Request;
use Magento\Framework\App\Area;
-use Magento\Framework\Intl\DateTimeFactory;
use Magento\Framework\Config\ScopeInterface;
+use Magento\Framework\Intl\DateTimeFactory;
+use Magento\Payment\Api\Data\CodeVerificationInterfaceFactory;
use Magento\Sales\Model\Order;
use Magento\Signifyd\Model\SignifydOrderSessionId;
@@ -31,19 +32,27 @@ class PurchaseBuilder
*/
private $signifydOrderSessionId;
+ /**
+ * @var CodeVerificationInterfaceFactory
+ */
+ private $codeVerificationFactory;
+
/**
* @param DateTimeFactory $dateTimeFactory
* @param ScopeInterface $scope
* @param SignifydOrderSessionId $signifydOrderSessionId
+ * @param CodeVerificationInterfaceFactory $codeVerificationFactory
*/
public function __construct(
DateTimeFactory $dateTimeFactory,
ScopeInterface $scope,
- SignifydOrderSessionId $signifydOrderSessionId
+ SignifydOrderSessionId $signifydOrderSessionId,
+ CodeVerificationInterfaceFactory $codeVerificationFactory
) {
$this->dateTimeFactory = $dateTimeFactory;
$this->scope = $scope;
$this->signifydOrderSessionId = $signifydOrderSessionId;
+ $this->codeVerificationFactory = $codeVerificationFactory;
}
/**
@@ -60,6 +69,8 @@ public function build(Order $order)
new \DateTimeZone('UTC')
);
+ $verificationService = $this->codeVerificationFactory->create($orderPayment);
+
$result = [
'purchase' => [
'orderSessionId' => $this->signifydOrderSessionId->get($order->getQuoteId()),
@@ -69,6 +80,8 @@ public function build(Order $order)
'paymentGateway' => $this->getPaymentGateway($orderPayment->getMethod()),
'transactionId' => $orderPayment->getLastTransId(),
'currency' => $order->getOrderCurrencyCode(),
+ 'avsResponseCode' => $verificationService->getAvsCode(),
+ 'cvvResponseCode' => $verificationService->getCvvCode(),
'orderChannel' => $this->getOrderChannel(),
'totalPrice' => $order->getGrandTotal(),
],
diff --git a/app/code/Magento/Signifyd/composer.json b/app/code/Magento/Signifyd/composer.json
index 87ce791eae618..3c5d5bd592253 100644
--- a/app/code/Magento/Signifyd/composer.json
+++ b/app/code/Magento/Signifyd/composer.json
@@ -10,7 +10,8 @@
"magento/module-customer": "100.2.*",
"magento/module-directory": "100.2.*",
"magento/module-checkout": "100.2.*",
- "magento/module-backend": "100.2.*"
+ "magento/module-backend": "100.2.*",
+ "magento/module-payment": "100.2.*"
},
"type": "magento2-module",
"version": "100.2.0-dev",
diff --git a/app/code/Magento/Signifyd/etc/module.xml b/app/code/Magento/Signifyd/etc/module.xml
index 5d973cc95851e..602860b1be220 100644
--- a/app/code/Magento/Signifyd/etc/module.xml
+++ b/app/code/Magento/Signifyd/etc/module.xml
@@ -15,6 +15,7 @@
+
From 99ce874fc21bb0cc7d4f8c0e66f447a2755073af Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Mon, 6 Feb 2017 10:28:15 -0600
Subject: [PATCH 167/904] MAGETWO-64154: Rearrange Signifyd information table
in order view template
(cherry picked from commit e28585a)
---
.../Signifyd/Block/Adminhtml/CaseInfo.php | 142 +++++-------------
.../Unit/Block/Adminhtml/CaseInfoTest.php | 127 ++++++++++++----
.../view/adminhtml/templates/case_info.phtml | 48 +++---
.../Signifyd/Block/Adminhtml/CaseInfoTest.php | 4 +-
4 files changed, 153 insertions(+), 168 deletions(-)
diff --git a/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php b/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php
index 873f5c6df1da7..af3d30785efaf 100644
--- a/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php
+++ b/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php
@@ -31,16 +31,6 @@ class CaseInfo extends Template
*/
private $caseManagement;
- /**
- * @var int
- */
- private static $scoreAccept = 500;
-
- /**
- * @var int
- */
- private static $scoreDecline = 300;
-
/**
* Constructor
*
@@ -117,37 +107,19 @@ public function isEmptyCase()
public function getCaseStatus()
{
return $this->getCaseProperty('', function () {
- return $this->getCaseEntity()->getStatus();
- });
- }
-
- /**
- * Gets case score value
- *
- * @return int
- */
- public function getCaseScore()
- {
- return $this->getCaseProperty(0, function () {
- return $this->getCaseEntity()->getScore();
- });
- }
-
- /**
- * Gets state of case guarantee eligible.
- *
- * @return string|\Magento\Framework\Phrase
- */
- public function getCaseGuaranteeEligible()
- {
- return $this->getCaseProperty('', function () {
- $value = $this->getCaseEntity()->isGuaranteeEligible();
-
- if ($value === null) {
- return '';
- }
-
- return $value ? __('Yes') : __('No');
+ $caseStatusMap = [
+ CaseInterface::STATUS_OPEN => __('Open'),
+ CaseInterface::STATUS_PENDING => __('Pending'),
+ CaseInterface::STATUS_PROCESSING => __('Processing'),
+ CaseInterface::STATUS_FLAGGED => __('Flagged'),
+ CaseInterface::STATUS_DISMISSED => __('Dismissed')
+ ];
+
+ $status = isset($caseStatusMap[$this->getCaseEntity()->getStatus()]) ?
+ $caseStatusMap[$this->getCaseEntity()->getStatus()] :
+ '';
+
+ return $status;
});
}
@@ -159,7 +131,20 @@ public function getCaseGuaranteeEligible()
public function getCaseGuaranteeDisposition()
{
return $this->getCaseProperty('', function () {
- return $this->getCaseEntity()->getGuaranteeDisposition();
+ $guaranteeStatusMap = [
+ CaseInterface::GUARANTEE_APPROVED => __('Approved'),
+ CaseInterface::GUARANTEE_DECLINED => __('Declined'),
+ CaseInterface::GUARANTEE_PENDING => __('Pending'),
+ CaseInterface::GUARANTEE_CANCELED => __('Canceled'),
+ CaseInterface::GUARANTEE_IN_REVIEW => __('In Review'),
+ CaseInterface::GUARANTEE_UNREQUESTED => __('Unrequested')
+ ];
+
+ $status = isset($guaranteeStatusMap[$this->getCaseEntity()->getGuaranteeDisposition()]) ?
+ $guaranteeStatusMap[$this->getCaseEntity()->getGuaranteeDisposition()] :
+ '';
+
+ return $status;
});
}
@@ -171,72 +156,17 @@ public function getCaseGuaranteeDisposition()
public function getCaseReviewDisposition()
{
return $this->getCaseProperty('', function () {
- return $this->getCaseEntity()->getReviewDisposition();
- });
- }
-
- /**
- * Gets case create date.
- *
- * @return string
- */
- public function getCaseCreatedAt()
- {
- return $this->getCaseProperty('asd', function () {
- return $this->getCaseEntity()->getCreatedAt();
- });
- }
-
- /**
- * Gets case update date.
- *
- * @return string
- */
- public function getCaseUpdatedAt()
- {
- return $this->getCaseProperty('', function () {
- return $this->getCaseEntity()->getUpdatedAt();
- });
- }
-
- /**
- * Gets case associated team name.
- *
- * @return string
- */
- public function getCaseAssociatedTeam()
- {
- return $this->getCaseProperty('', function () {
- $teamName = 'unknown';
- $team = $this->getCaseEntity()->getAssociatedTeam();
- if (isset($team['teamName'])) {
- $teamName = $team['teamName'];
- }
-
- return $teamName;
- });
- }
-
- /**
- * Returns cell class name according to case score value.
- * It could be used by merchant to customize order view template.
- *
- * @return string
- */
- public function getScoreClass()
- {
- return $this->getCaseProperty('', function () {
- $score = $this->getCaseEntity()->getScore();
+ $reviewStatusMap = [
+ CaseInterface::DISPOSITION_GOOD => __('Good'),
+ CaseInterface::DISPOSITION_FRAUDULENT => __('Fraudulent'),
+ CaseInterface::DISPOSITION_UNSET => __('Unset')
+ ];
- if (self::$scoreAccept <= $score) {
- $result = 'green';
- } elseif ($score <= self::$scoreDecline) {
- $result = 'red';
- } else {
- $result = 'yellow';
- }
+ $status = isset($reviewStatusMap[$this->getCaseEntity()->getReviewDisposition()]) ?
+ $reviewStatusMap[$this->getCaseEntity()->getReviewDisposition()] :
+ '';
- return $result;
+ return $status;
});
}
diff --git a/app/code/Magento/Signifyd/Test/Unit/Block/Adminhtml/CaseInfoTest.php b/app/code/Magento/Signifyd/Test/Unit/Block/Adminhtml/CaseInfoTest.php
index f44639bfce96b..0d046800d9523 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Block/Adminhtml/CaseInfoTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Block/Adminhtml/CaseInfoTest.php
@@ -90,80 +90,141 @@ protected function setUp()
}
/**
- * Checks css class according to case entity score value.
+ * Checks label according to Signifyd status.
*
- * @param integer $score
- * @param string $expectedClassName
- * @covers \Magento\Signifyd\Block\Adminhtml\CaseInfo::getScoreClass
- * @dataProvider getScoreClassDataProvider
+ * @param string $status
+ * @param string $expectedLabel
+ * @covers \Magento\Signifyd\Block\Adminhtml\CaseInfo::getCaseStatus()
+ * @dataProvider getStatusLabelDataProvider
*/
- public function testGetScoreClass($score, $expectedClassName)
+ public function testGetCaseStatus($status, $expectedLabel)
{
- $this->caseEntity->expects($this->once())
- ->method('getScore')
- ->willReturn($score);
-
$this->caseManagement->expects(self::once())
->method('getByOrderId')
->willReturn($this->caseEntity);
+ $this->caseEntity->expects(self::atLeastOnce())
+ ->method('getStatus')
+ ->willReturn($status);
+
self::assertEquals(
- $expectedClassName,
- $this->caseInfo->getScoreClass()
+ $expectedLabel,
+ $this->caseInfo->getCaseStatus()
);
}
/**
- * Checks case property getter with real case.
+ * Case status and corresponding label data provider.
*
- * @covers \Magento\Signifyd\Block\Adminhtml\CaseInfo::getCaseProperty
+ * @return array
*/
- public function testCasePropertyWithCaseExists()
+ public function getStatusLabelDataProvider()
{
- $score = 575;
-
- $this->caseEntity->expects($this->once())
- ->method('getScore')
- ->willReturn($score);
+ return [
+ [CaseInterface::STATUS_OPEN, __('Open')],
+ [CaseInterface::STATUS_PENDING, __('Pending')],
+ [CaseInterface::STATUS_PROCESSING, __('Processing')],
+ [CaseInterface::STATUS_FLAGGED, __('Flagged')],
+ [CaseInterface::STATUS_DISMISSED, __('Dismissed')],
+ ['Unregistered', '']
+ ];
+ }
+ /**
+ * Checks label according to Signifyd Guarantee Disposition.
+ *
+ * @param string $guaranteeDisposition
+ * @param string $expectedLabel
+ * @covers \Magento\Signifyd\Block\Adminhtml\CaseInfo::getCaseGuaranteeDisposition()
+ * @dataProvider getGuaranteeLabelDataProvider
+ */
+ public function testGetGuaranteeDisposition($guaranteeDisposition, $expectedLabel)
+ {
$this->caseManagement->expects(self::once())
->method('getByOrderId')
->willReturn($this->caseEntity);
+ $this->caseEntity->expects(self::atLeastOnce())
+ ->method('getGuaranteeDisposition')
+ ->willReturn($guaranteeDisposition);
+
self::assertEquals(
- $score,
- $this->caseInfo->getCaseScore()
+ $expectedLabel,
+ $this->caseInfo->getCaseGuaranteeDisposition()
);
}
/**
- * Checks case property getter with empty case.
+ * Case Guarantee Disposition and corresponding label data provider.
*
- * @covers \Magento\Signifyd\Block\Adminhtml\CaseInfo::getCaseProperty
+ * @return array
*/
- public function testCasePropertyWithEmptyCase()
+ public function getGuaranteeLabelDataProvider()
+ {
+ return [
+ [CaseInterface::GUARANTEE_APPROVED, __('Approved')],
+ [CaseInterface::GUARANTEE_DECLINED, __('Declined')],
+ [CaseInterface::GUARANTEE_PENDING, __('Pending')],
+ [CaseInterface::GUARANTEE_CANCELED, __('Canceled')],
+ [CaseInterface::GUARANTEE_IN_REVIEW, __('In Review')],
+ [CaseInterface::GUARANTEE_UNREQUESTED, __('Unrequested')],
+ ['Unregistered', '']
+ ];
+ }
+
+ /**
+ * Checks label according to Signifyd Review Disposition.
+ *
+ * @param string $reviewDisposition
+ * @param string $expectedLabel
+ * @covers \Magento\Signifyd\Block\Adminhtml\CaseInfo::getCaseReviewDisposition()
+ * @dataProvider getReviewLabelDataProvider
+ */
+ public function testGetReviewDisposition($reviewDisposition, $expectedLabel)
{
$this->caseManagement->expects(self::once())
->method('getByOrderId')
- ->willReturn(null);
+ ->willReturn($this->caseEntity);
+
+ $this->caseEntity->expects(self::atLeastOnce())
+ ->method('getReviewDisposition')
+ ->willReturn($reviewDisposition);
self::assertEquals(
- 0,
- $this->caseInfo->getCaseScore()
+ $expectedLabel,
+ $this->caseInfo->getCaseReviewDisposition()
);
}
/**
- * Case scores and corresponding class name data provider
+ * Case Review Disposition and corresponding label data provider.
*
* @return array
*/
- public function getScoreClassDataProvider()
+ public function getReviewLabelDataProvider()
{
return [
- [300, 'red'],
- [400, 'yellow'],
- [500, 'green'],
+ [CaseInterface::DISPOSITION_GOOD, __('Good')],
+ [CaseInterface::DISPOSITION_FRAUDULENT, __('Fraudulent')],
+ [CaseInterface::DISPOSITION_UNSET, __('Unset')],
+ ['Unregistered', '']
];
}
+
+ /**
+ * Checks case property getter with empty case.
+ *
+ * @covers \Magento\Signifyd\Block\Adminhtml\CaseInfo::getCaseProperty
+ */
+ public function testCasePropertyWithEmptyCase()
+ {
+ $this->caseManagement->expects(self::once())
+ ->method('getByOrderId')
+ ->willReturn(null);
+
+ self::assertEquals(
+ '',
+ $this->caseInfo->getCaseGuaranteeDisposition()
+ );
+ }
}
diff --git a/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml b/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml
index 08ebd64400ca0..6649ca8fcd2fe 100644
--- a/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml
+++ b/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml
@@ -17,32 +17,26 @@
escapeHtml(__('Fraud Protection Information')); ?>
-
-
-
-
- escapeHtml(__('Case Status')); ?>
- escapeHtml(__('Case Score')); ?>
- escapeHtml(__('Guarantee Eligible')); ?>
- escapeHtml(__('Guarantee Disposition')); ?>
- escapeHtml(__('Associated Team')); ?>
- escapeHtml(__('Review Disposition')); ?>
- escapeHtml(__('Case Created')); ?>
- escapeHtml(__('Case Updated')); ?>
-
-
-
-
- escapeHtml($block->getCaseStatus()); ?>
- escapeHtml($block->getCaseScore()); ?>
- escapeHtml($block->getCaseGuaranteeEligible()); ?>
- escapeHtml($block->getCaseGuaranteeDisposition()); ?>
- escapeHtml($block->getCaseAssociatedTeam()); ?>
- escapeHtml($block->getCaseReviewDisposition()); ?>
- escapeHtml($block->getCaseCreatedAt()); ?>
- escapeHtml($block->getCaseUpdatedAt()); ?>
-
-
-
+
+
+
+
+
+
+ escapeHtml(__('Case Status')); ?>
+ escapeHtml($block->getCaseStatus()); ?>
+
+
+ escapeHtml(__('Guarantee Disposition')); ?>
+ escapeHtml($block->getCaseGuaranteeDisposition()); ?>
+
+
+ escapeHtml(__('Review Disposition')); ?>
+ escapeHtml($block->getCaseReviewDisposition()); ?>
+
+
+
+
+
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Block/Adminhtml/CaseInfoTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Block/Adminhtml/CaseInfoTest.php
index c59c64a5f60e1..95a24791e6911 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Block/Adminhtml/CaseInfoTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Block/Adminhtml/CaseInfoTest.php
@@ -84,8 +84,8 @@ public function testCaseEntityExists()
$html = $this->getBlockContents();
static::assertNotEmpty($html);
- static::assertContains('Some Team', $html);
- static::assertContains('col-case-score-green', $html);
+ static::assertContains('Processing', $html);
+ static::assertContains('Good', $html);
}
/**
From 1fb4b41570e88ede878151c75f4d7180ec9e132f Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Mon, 6 Feb 2017 10:57:54 -0600
Subject: [PATCH 168/904] MAGETWO-63910: Create infrastructure for mapper in
Payment module
- Reimplemented API interfaces
- Updated purchase builder
(cherry picked from commit bc7c6b4)
---
.../Model/PaymentVerificationFactory.php | 66 +++++++++++++++++++
.../Request/PurchaseBuilder.php | 50 +++++++++++---
app/code/Magento/Signifyd/etc/di.xml | 8 ++-
3 files changed, 113 insertions(+), 11 deletions(-)
create mode 100644 app/code/Magento/Signifyd/Model/PaymentVerificationFactory.php
diff --git a/app/code/Magento/Signifyd/Model/PaymentVerificationFactory.php b/app/code/Magento/Signifyd/Model/PaymentVerificationFactory.php
new file mode 100644
index 0000000000000..f6f3024fdeee1
--- /dev/null
+++ b/app/code/Magento/Signifyd/Model/PaymentVerificationFactory.php
@@ -0,0 +1,66 @@
+config = $config;
+ $this->objectManager = $objectManager;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function createPaymentCvv($paymentCode)
+ {
+ return $this->create($paymentCode, 'cvv_ems_adapter');
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function createPaymentAvs($paymentCode)
+ {
+ return $this->create($paymentCode, 'avs_ems_adapter');
+ }
+
+ /**
+ * @inheritdoc
+ */
+ private function create($paymentCode, $configKey)
+ {
+ $this->config->setMethodCode($paymentCode);
+ $verificationClass = $this->config->getValue($configKey);
+ if ($verificationClass === null) {
+ return $this->objectManager->get(PaymentVerificationInterface::class);
+ }
+ return $this->objectManager->create($verificationClass);
+ }
+}
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php
index 524b4a2e6ab8f..48e2c3837fc71 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php
@@ -8,8 +8,10 @@
use Magento\Framework\App\Area;
use Magento\Framework\Config\ScopeInterface;
use Magento\Framework\Intl\DateTimeFactory;
-use Magento\Payment\Api\Data\CodeVerificationInterfaceFactory;
+use Magento\Payment\Api\PaymentVerificationInterface;
+use Magento\Sales\Api\Data\OrderPaymentInterface;
use Magento\Sales\Model\Order;
+use Magento\Signifyd\Model\PaymentVerificationFactory;
use Magento\Signifyd\Model\SignifydOrderSessionId;
/**
@@ -33,26 +35,26 @@ class PurchaseBuilder
private $signifydOrderSessionId;
/**
- * @var CodeVerificationInterfaceFactory
+ * @var PaymentVerificationFactory
*/
- private $codeVerificationFactory;
+ private $paymentVerificationFactory;
/**
* @param DateTimeFactory $dateTimeFactory
* @param ScopeInterface $scope
* @param SignifydOrderSessionId $signifydOrderSessionId
- * @param CodeVerificationInterfaceFactory $codeVerificationFactory
+ * @param PaymentVerificationFactory $paymentVerificationFactory
*/
public function __construct(
DateTimeFactory $dateTimeFactory,
ScopeInterface $scope,
SignifydOrderSessionId $signifydOrderSessionId,
- CodeVerificationInterfaceFactory $codeVerificationFactory
+ PaymentVerificationFactory $paymentVerificationFactory
) {
$this->dateTimeFactory = $dateTimeFactory;
$this->scope = $scope;
$this->signifydOrderSessionId = $signifydOrderSessionId;
- $this->codeVerificationFactory = $codeVerificationFactory;
+ $this->paymentVerificationFactory = $paymentVerificationFactory;
}
/**
@@ -69,8 +71,6 @@ public function build(Order $order)
new \DateTimeZone('UTC')
);
- $verificationService = $this->codeVerificationFactory->create($orderPayment);
-
$result = [
'purchase' => [
'orderSessionId' => $this->signifydOrderSessionId->get($order->getQuoteId()),
@@ -80,8 +80,8 @@ public function build(Order $order)
'paymentGateway' => $this->getPaymentGateway($orderPayment->getMethod()),
'transactionId' => $orderPayment->getLastTransId(),
'currency' => $order->getOrderCurrencyCode(),
- 'avsResponseCode' => $verificationService->getAvsCode(),
- 'cvvResponseCode' => $verificationService->getCvvCode(),
+ 'avsResponseCode' => $this->getAvsCode($orderPayment),
+ 'cvvResponseCode' => $this->getCvvCode($orderPayment),
'orderChannel' => $this->getOrderChannel(),
'totalPrice' => $order->getGrandTotal(),
],
@@ -175,4 +175,34 @@ private function getOrderChannel()
{
return $this->scope->getCurrentScope() === Area::AREA_ADMINHTML ? 'PHONE' : 'WEB';
}
+
+ /**
+ * Gets AVS code for order payment method.
+ *
+ * @param OrderPaymentInterface $orderPayment
+ * @return string
+ */
+ private function getAvsCode(OrderPaymentInterface $orderPayment)
+ {
+ /** @var PaymentVerificationInterface $avsAdapter */
+ $avsAdapter = $this->paymentVerificationFactory->createPaymentAvs($orderPayment->getMethod());
+ $code = $avsAdapter->getCode($orderPayment);
+
+ return $code !== null ? $code : 'U';
+ }
+
+ /**
+ * Gets CVV code for order payment method.
+ *
+ * @param OrderPaymentInterface $orderPayment
+ * @return string
+ */
+ private function getCvvCode(OrderPaymentInterface $orderPayment)
+ {
+ /** @var PaymentVerificationInterface $cvvAdapter */
+ $cvvAdapter = $this->paymentVerificationFactory->createPaymentCvv($orderPayment->getMethod());
+ $code = $cvvAdapter->getCode($orderPayment);
+
+ return $code !== null ? $code : '';
+ }
}
diff --git a/app/code/Magento/Signifyd/etc/di.xml b/app/code/Magento/Signifyd/etc/di.xml
index 2f0261ec8d131..b60bc6b1dfb3d 100644
--- a/app/code/Magento/Signifyd/etc/di.xml
+++ b/app/code/Magento/Signifyd/etc/di.xml
@@ -42,4 +42,10 @@
-
\ No newline at end of file
+
+
+
+ Magento\Payment\Gateway\Config\Config
+
+
+
From e06d7ab2a815d2d0ad62a7e14244b517a6e18bfe Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Mon, 6 Feb 2017 11:24:16 -0600
Subject: [PATCH 169/904] MAGETWO-63945: Add extension point to sales grid
indexer
(cherry picked from commit 3d6ed7a)
---
.../Magento/Signifyd/Model/CaseManagement.php | 4 +-
.../Model/CaseServices/UpdatingService.php | 13 +++-
.../Signifyd/Model/OrderGridUpdater.php | 53 +++++++++++++
.../Signifyd/Model/OrderIdListProvider.php | 53 +++++++++++++
.../Magento/Signifyd/Setup/InstallSchema.php | 7 +-
.../CaseServices/UpdatingServiceTest.php | 37 ++++++++-
.../Test/Unit/Model/OrderGridUpdaterTest.php | 75 +++++++++++++++++++
app/code/Magento/Signifyd/etc/di.xml | 13 ++++
.../Signifyd/Model/CaseManagementTest.php | 1 +
.../CaseServices/UpdatingServiceTest.php | 28 +++++++
10 files changed, 277 insertions(+), 7 deletions(-)
create mode 100644 app/code/Magento/Signifyd/Model/OrderGridUpdater.php
create mode 100644 app/code/Magento/Signifyd/Model/OrderIdListProvider.php
create mode 100644 app/code/Magento/Signifyd/Test/Unit/Model/OrderGridUpdaterTest.php
diff --git a/app/code/Magento/Signifyd/Model/CaseManagement.php b/app/code/Magento/Signifyd/Model/CaseManagement.php
index 79b90333209f1..4f62dbb563ce6 100644
--- a/app/code/Magento/Signifyd/Model/CaseManagement.php
+++ b/app/code/Magento/Signifyd/Model/CaseManagement.php
@@ -64,9 +64,11 @@ public function __construct(
*/
public function create($orderId)
{
+ /** @var \Magento\Signifyd\Api\Data\CaseInterface $case */
$case = $this->caseFactory->create();
$case->setOrderId($orderId)
- ->setStatus(CaseInterface::STATUS_PENDING);
+ ->setStatus(CaseInterface::STATUS_PENDING)
+ ->setGuaranteeDisposition(CaseInterface::GUARANTEE_PENDING);
try {
return $this->caseRepository->save($case);
} catch (DuplicateException $e) {
diff --git a/app/code/Magento/Signifyd/Model/CaseServices/UpdatingService.php b/app/code/Magento/Signifyd/Model/CaseServices/UpdatingService.php
index f0336938d2515..70a214fe19a31 100644
--- a/app/code/Magento/Signifyd/Model/CaseServices/UpdatingService.php
+++ b/app/code/Magento/Signifyd/Model/CaseServices/UpdatingService.php
@@ -11,6 +11,7 @@
use Magento\Signifyd\Api\Data\CaseInterface;
use Magento\Signifyd\Model\CommentsHistoryUpdater;
use Magento\Signifyd\Model\MessageGenerators\GeneratorInterface;
+use Magento\Signifyd\Model\OrderGridUpdater;
/**
* Performs Signifyd case entity updating operations.
@@ -32,21 +33,30 @@ class UpdatingService implements UpdatingServiceInterface
*/
private $commentsHistoryUpdater;
+ /**
+ * @var OrderGridUpdater
+ */
+ private $orderGridUpdater;
+
/**
* UpdatingService constructor.
*
* @param GeneratorInterface $messageGenerator
* @param CaseRepositoryInterface $caseRepository
* @param CommentsHistoryUpdater $commentsHistoryUpdater
+ * @param OrderGridUpdater $orderGridUpdater
*/
public function __construct(
GeneratorInterface $messageGenerator,
CaseRepositoryInterface $caseRepository,
- CommentsHistoryUpdater $commentsHistoryUpdater
+ CommentsHistoryUpdater $commentsHistoryUpdater,
+ OrderGridUpdater $orderGridUpdater
+
) {
$this->messageGenerator = $messageGenerator;
$this->caseRepository = $caseRepository;
$this->commentsHistoryUpdater = $commentsHistoryUpdater;
+ $this->orderGridUpdater = $orderGridUpdater;
}
/**
@@ -68,6 +78,7 @@ public function update(CaseInterface $case, array $data)
$this->setCaseData($case, $data);
$orderHistoryComment = $this->messageGenerator->generate($data);
$this->caseRepository->save($case);
+ $this->orderGridUpdater->update($case->getOrderId());
$this->commentsHistoryUpdater->addComment($case, $orderHistoryComment);
} catch (\Exception $e) {
throw new LocalizedException(__('Cannot update Case entity.'), $e);
diff --git a/app/code/Magento/Signifyd/Model/OrderGridUpdater.php b/app/code/Magento/Signifyd/Model/OrderGridUpdater.php
new file mode 100644
index 0000000000000..eeb67a90b6475
--- /dev/null
+++ b/app/code/Magento/Signifyd/Model/OrderGridUpdater.php
@@ -0,0 +1,53 @@
+globalConfig = $globalConfig;
+ $this->entityGrid = $entityGrid;
+ }
+
+ /**
+ * Handles synchronous updating order entity in grid after.
+ *
+ * Works only if asynchronous grid indexing is disabled
+ * in global settings.
+ *
+ * @param $orderId
+ * @return void
+ */
+ public function update($orderId)
+ {
+ if (!$this->globalConfig->getValue('dev/grid/async_indexing')) {
+ $this->entityGrid->refresh($orderId);
+ }
+ }
+}
diff --git a/app/code/Magento/Signifyd/Model/OrderIdListProvider.php b/app/code/Magento/Signifyd/Model/OrderIdListProvider.php
new file mode 100644
index 0000000000000..8093ce23f55d8
--- /dev/null
+++ b/app/code/Magento/Signifyd/Model/OrderIdListProvider.php
@@ -0,0 +1,53 @@
+caseEntity = $caseEntity;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function get($mainTableName, $gridTableName)
+ {
+ $connection = $this->caseEntity->getConnection();
+ $select = $connection->select()
+ ->from($this->caseEntity->getMainTable(), ['order_id'])
+ ->joinLeft(
+ [$gridTableName => $connection->getTableName($gridTableName)],
+ sprintf(
+ '%s.%s = %s.%s',
+ $this->caseEntity->getMainTable(),
+ 'order_id',
+ $gridTableName,
+ 'entity_id'
+ ),
+ []
+ )
+ ->where('guarantee_disposition != signifyd_guarantee_status');
+
+ return $connection->fetchAll($select, [], \Zend_Db::FETCH_COLUMN);
+ }
+}
diff --git a/app/code/Magento/Signifyd/Setup/InstallSchema.php b/app/code/Magento/Signifyd/Setup/InstallSchema.php
index e6436a3f1b7e3..8107d06285bff 100644
--- a/app/code/Magento/Signifyd/Setup/InstallSchema.php
+++ b/app/code/Magento/Signifyd/Setup/InstallSchema.php
@@ -40,7 +40,12 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
$table->addColumn('order_id', Table::TYPE_INTEGER, null, ['unsigned' => true]);
$table->addColumn('case_id', Table::TYPE_INTEGER, null, ['unsigned' => true]);
$table->addColumn('guarantee_eligible', Table::TYPE_BOOLEAN, null);
- $table->addColumn('guarantee_disposition', Table::TYPE_TEXT, 32);
+ $table->addColumn(
+ 'guarantee_disposition',
+ Table::TYPE_TEXT,
+ 32,
+ ['default' => CaseInterface::GUARANTEE_PENDING]
+ );
$table->addColumn('status', Table::TYPE_TEXT, 32, ['default' => CaseInterface::STATUS_PENDING]);
$table->addColumn('score', Table::TYPE_INTEGER, null, ['unsigned' => true]);
$table->addColumn('associated_team', Table::TYPE_TEXT, '64k');
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/CaseServices/UpdatingServiceTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/CaseServices/UpdatingServiceTest.php
index 76ed91c887538..1dff0981e5d5b 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/CaseServices/UpdatingServiceTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/CaseServices/UpdatingServiceTest.php
@@ -12,6 +12,7 @@
use Magento\Signifyd\Model\CommentsHistoryUpdater;
use Magento\Signifyd\Model\MessageGenerators\GeneratorException;
use Magento\Signifyd\Model\MessageGenerators\GeneratorInterface;
+use Magento\Signifyd\Model\OrderGridUpdater;
use PHPUnit_Framework_MockObject_MockObject as MockObject;
/**
@@ -44,6 +45,11 @@ class UpdatingServiceTest extends \PHPUnit_Framework_TestCase
*/
private $commentsHistoryUpdater;
+ /**
+ * @var OrderGridUpdater|MockObject
+ */
+ private $orderGridUpdater;
+
/**
* @inheritdoc
*/
@@ -66,10 +72,15 @@ protected function setUp()
->setMethods(['addComment'])
->getMock();
+ $this->orderGridUpdater = $this->getMockBuilder(OrderGridUpdater::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+
$this->service = $this->objectManager->getObject(UpdatingService::class, [
'messageGenerator' => $this->messageGenerator,
'caseRepository' => $this->caseRepository,
- 'commentsHistoryUpdater' => $this->commentsHistoryUpdater
+ 'commentsHistoryUpdater' => $this->commentsHistoryUpdater,
+ 'orderGridUpdater' => $this->orderGridUpdater
]);
}
@@ -171,7 +182,8 @@ public function testUpdateWithFailedCommentSaving()
{
$caseId = 123;
$data = [
- 'caseId' => $caseId
+ 'caseId' => $caseId,
+ 'orderId' => 1
];
$caseEntity = $this->withCaseEntity(1, $caseId, $data);
@@ -181,6 +193,10 @@ public function testUpdateWithFailedCommentSaving()
->with($caseEntity)
->willReturn($caseEntity);
+ $this->orderGridUpdater->expects(self::once())
+ ->method('update')
+ ->with($data['orderId']);
+
$message = __('Message is generated.');
$this->messageGenerator->expects(self::once())
->method('generate')
@@ -204,7 +220,8 @@ public function testUpdate()
{
$caseId = 123;
$data = [
- 'caseId' => $caseId
+ 'caseId' => $caseId,
+ 'orderId' => 1
];
$caseEntity = $this->withCaseEntity(21, $caseId, $data);
@@ -220,6 +237,10 @@ public function testUpdate()
->with($data)
->willReturn($message);
+ $this->orderGridUpdater->expects(self::once())
+ ->method('update')
+ ->with($data['orderId']);
+
$this->commentsHistoryUpdater->expects(self::once())
->method('addComment')
->with($caseEntity, $message);
@@ -240,7 +261,10 @@ private function withCaseEntity($caseEntityId, $caseId, array $data = [])
/** @var CaseInterface|MockObject $caseEntity */
$caseEntity = $this->getMockBuilder(CaseInterface::class)
->disableOriginalConstructor()
- ->setMethods(['getEntityId', 'getCaseId', 'setCaseId', 'setStatus', 'setOrderId', 'setScore'])
+ ->setMethods([
+ 'getEntityId', 'getCaseId', 'getOrderId',
+ 'setCaseId', 'setStatus', 'setOrderId', 'setScore'
+ ])
->getMockForAbstractClass();
$caseEntity->expects(self::any())
@@ -260,6 +284,11 @@ private function withCaseEntity($caseEntityId, $caseId, array $data = [])
->method($method)
->with(self::equalTo($value))
->willReturnSelf();
+
+ $method = 'get' . ucfirst($property);
+ $caseEntity->expects(self::any())
+ ->method($method)
+ ->willReturn($value);
}
return $caseEntity;
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/OrderGridUpdaterTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/OrderGridUpdaterTest.php
new file mode 100644
index 0000000000000..90f672cc956ce
--- /dev/null
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/OrderGridUpdaterTest.php
@@ -0,0 +1,75 @@
+orderGrid = $this->getMockBuilder(GridInterface::class)
+ ->getMockForAbstractClass();
+ $this->globalConfig = $this->getMockBuilder(ScopeConfigInterface::class)
+ ->getMockForAbstractClass();
+
+ $this->model = new OrderGridUpdater($this->orderGrid, $this->globalConfig);
+ }
+
+ public function testUpdateInSyncMode()
+ {
+ $orderId = 1;
+
+ $this->globalConfig->expects($this->once())
+ ->method('getValue')
+ ->with('dev/grid/async_indexing', 'default', null)
+ ->willReturn(false);
+ $this->orderGrid->expects($this->once())
+ ->method('refresh')
+ ->with($orderId);
+
+ $this->model->update($orderId);
+ }
+
+ public function testUpdateInAsyncMode()
+ {
+ $orderId = 1;
+
+ $this->globalConfig->expects($this->once())
+ ->method('getValue')
+ ->with('dev/grid/async_indexing', 'default', null)
+ ->willReturn(true);
+ $this->orderGrid->expects($this->never())
+ ->method('refresh')
+ ->with($orderId);
+
+ $this->model->update($orderId);
+ }
+}
diff --git a/app/code/Magento/Signifyd/etc/di.xml b/app/code/Magento/Signifyd/etc/di.xml
index b60bc6b1dfb3d..02bb8d34adce7 100644
--- a/app/code/Magento/Signifyd/etc/di.xml
+++ b/app/code/Magento/Signifyd/etc/di.xml
@@ -14,8 +14,21 @@
+
+
+ Magento\Sales\Model\ResourceModel\Order\Grid
+
+
+
+
+
+ - Magento\Signifyd\Model\OrderIdListProvider
+
+
+
+ SignifydIdListProvider
-
- signifyd_case
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseManagementTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseManagementTest.php
index fee9bb9f06b01..fd772594f48ef 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseManagementTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseManagementTest.php
@@ -45,6 +45,7 @@ public function testCreate()
static::assertNotEmpty($case->getEntityId());
static::assertEquals(CaseInterface::STATUS_PENDING, $case->getStatus());
+ static::assertEquals(CaseInterface::GUARANTEE_PENDING, $case->getGuaranteeDisposition());
}
/**
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseServices/UpdatingServiceTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseServices/UpdatingServiceTest.php
index 01ac31dd249d1..f04108d2b3c8a 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseServices/UpdatingServiceTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseServices/UpdatingServiceTest.php
@@ -6,6 +6,7 @@
namespace Magento\Signifyd\Model\CaseServices;
use Magento\Framework\App\ObjectManager;
+use Magento\Framework\App\ResourceConnection;
use Magento\Sales\Api\Data\OrderStatusHistoryInterface;
use Magento\Sales\Api\OrderRepositoryInterface;
use Magento\Signifyd\Api\CaseRepositoryInterface;
@@ -78,6 +79,8 @@ public function testUpdate()
$caseEntity = $caseRepository->getByCaseId($caseId);
$orderEntityId = $caseEntity->getOrderId();
+ $gridGuarantyStatus = $this->getOrderGridGuarantyStatus($orderEntityId);
+
static::assertNotEmpty($caseEntity);
static::assertEquals('2017-01-05 22:23:26', $caseEntity->getCreatedAt());
static::assertEquals(CaseInterface::GUARANTEE_APPROVED, $caseEntity->getGuaranteeDisposition());
@@ -85,6 +88,11 @@ public function testUpdate()
static::assertEquals(true, $caseEntity->isGuaranteeEligible());
static::assertEquals(CaseInterface::STATUS_PROCESSING, $caseEntity->getStatus());
static::assertEquals($orderEntityId, $caseEntity->getOrderId());
+ static::assertEquals(
+ $gridGuarantyStatus,
+ $caseEntity->getGuaranteeDisposition(),
+ 'Signifyd guaranty status in sales_order_grid table does not match case entity guaranty status'
+ );
/** @var OrderRepositoryInterface $orderRepository */
$orderRepository = $this->objectManager->get(OrderRepositoryInterface::class);
@@ -97,4 +105,24 @@ public function testUpdate()
static::assertInstanceOf(OrderStatusHistoryInterface::class, $caseCreationComment);
static::assertEquals("Signifyd Case $caseId has been created for order.", $caseCreationComment->getComment());
}
+
+ /**
+ * Returns value of signifyd_guarantee_status column from sales order grid
+ *
+ * @param int $orderEntityId
+ * @return string|null
+ */
+ private function getOrderGridGuarantyStatus($orderEntityId)
+ {
+ /** @var \Magento\Sales\Model\ResourceModel\Order\Grid\Collection $orderGridCollection */
+ $orderGridCollection = $this->objectManager->get(
+ \Magento\Sales\Model\ResourceModel\Order\Grid\Collection::class
+ );
+
+ $items = $orderGridCollection->addFilter($orderGridCollection->getIdFieldName(), $orderEntityId)
+ ->getItems();
+ $result = array_pop($items);
+
+ return isset($result['signifyd_guarantee_status']) ? $result['signifyd_guarantee_status'] : null;
+ }
}
From d5c92d1687c09b5dd24008a1e26d364f12141cfa Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Mon, 6 Feb 2017 11:28:44 -0600
Subject: [PATCH 170/904] MAGETWO-63942: Add Signifyd Guarantee Status column
to order grid
- update connection name
(cherry picked from commit aa9fb31)
---
app/code/Magento/Signifyd/Setup/InstallData.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/app/code/Magento/Signifyd/Setup/InstallData.php b/app/code/Magento/Signifyd/Setup/InstallData.php
index 1436d52d4b823..6e37ac63c493e 100644
--- a/app/code/Magento/Signifyd/Setup/InstallData.php
+++ b/app/code/Magento/Signifyd/Setup/InstallData.php
@@ -38,7 +38,7 @@ public function __construct(
*/
public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
{
- $this->resource->getConnection('sales_order')->addColumn(
+ $this->resource->getConnection('sales')->addColumn(
$setup->getTable('sales_order_grid'),
'signifyd_guarantee_status',
[
@@ -48,7 +48,7 @@ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface
]
);
- $this->resource->getConnection('sales_order')->addColumn(
+ $this->resource->getConnection('sales')->addColumn(
$setup->getTable('magento_sales_order_grid_archive'),
'signifyd_guarantee_status',
[
From d7a5b86f2ec961525066c3b0cd137d9b38961ae7 Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Tue, 7 Feb 2017 01:57:49 -0600
Subject: [PATCH 171/904] MAGETWO-63945: Add extension point to sales grid
indexer
- Rename IdListProviderComposite to IdListProvider
- Fix static
(cherry picked from commit 14b0ba9)
---
.../Magento/Signifyd/Model/CaseServices/UpdatingService.php | 1 -
app/code/Magento/Signifyd/Model/OrderGridUpdater.php | 2 +-
app/code/Magento/Signifyd/etc/di.xml | 2 +-
3 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/app/code/Magento/Signifyd/Model/CaseServices/UpdatingService.php b/app/code/Magento/Signifyd/Model/CaseServices/UpdatingService.php
index 70a214fe19a31..f93bb08eb0761 100644
--- a/app/code/Magento/Signifyd/Model/CaseServices/UpdatingService.php
+++ b/app/code/Magento/Signifyd/Model/CaseServices/UpdatingService.php
@@ -51,7 +51,6 @@ public function __construct(
CaseRepositoryInterface $caseRepository,
CommentsHistoryUpdater $commentsHistoryUpdater,
OrderGridUpdater $orderGridUpdater
-
) {
$this->messageGenerator = $messageGenerator;
$this->caseRepository = $caseRepository;
diff --git a/app/code/Magento/Signifyd/Model/OrderGridUpdater.php b/app/code/Magento/Signifyd/Model/OrderGridUpdater.php
index eeb67a90b6475..0e6cbefedb483 100644
--- a/app/code/Magento/Signifyd/Model/OrderGridUpdater.php
+++ b/app/code/Magento/Signifyd/Model/OrderGridUpdater.php
@@ -36,7 +36,7 @@ public function __construct(
}
/**
- * Handles synchronous updating order entity in grid after.
+ * Handles synchronous updating order entity in grid.
*
* Works only if asynchronous grid indexing is disabled
* in global settings.
diff --git a/app/code/Magento/Signifyd/etc/di.xml b/app/code/Magento/Signifyd/etc/di.xml
index 02bb8d34adce7..764d8f7eddb77 100644
--- a/app/code/Magento/Signifyd/etc/di.xml
+++ b/app/code/Magento/Signifyd/etc/di.xml
@@ -19,7 +19,7 @@
Magento\Sales\Model\ResourceModel\Order\Grid
-
+
- Magento\Signifyd\Model\OrderIdListProvider
From 17122c86a092ab38e1fb6e82f9b8f813942b70d9 Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Tue, 7 Feb 2017 03:04:38 -0600
Subject: [PATCH 172/904] MAGETWO-63945: Add extension point to sales grid
indexer
- Add constraints for sales_order_grid
(cherry picked from commit f9a639b)
---
app/code/Magento/Signifyd/Model/OrderGridUpdater.php | 2 +-
app/code/Magento/Signifyd/etc/constraints.xml | 3 +++
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/app/code/Magento/Signifyd/Model/OrderGridUpdater.php b/app/code/Magento/Signifyd/Model/OrderGridUpdater.php
index 0e6cbefedb483..5cefddaf21022 100644
--- a/app/code/Magento/Signifyd/Model/OrderGridUpdater.php
+++ b/app/code/Magento/Signifyd/Model/OrderGridUpdater.php
@@ -41,7 +41,7 @@ public function __construct(
* Works only if asynchronous grid indexing is disabled
* in global settings.
*
- * @param $orderId
+ * @param int $orderId
* @return void
*/
public function update($orderId)
diff --git a/app/code/Magento/Signifyd/etc/constraints.xml b/app/code/Magento/Signifyd/etc/constraints.xml
index 6c4224e28f7e8..65e3f45035dc2 100644
--- a/app/code/Magento/Signifyd/etc/constraints.xml
+++ b/app/code/Magento/Signifyd/etc/constraints.xml
@@ -10,5 +10,8 @@
+
+
+
\ No newline at end of file
From b8fe05a0b9c4c94a7d701b8d9d19b1d3b0282479 Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Tue, 7 Feb 2017 04:41:21 -0600
Subject: [PATCH 173/904] MAGETWO-63942: Add Signifyd Guarantee Status column
to order grid
- update Oms and set default connection name
(cherry picked from commit e8fc565)
---
app/code/Magento/Signifyd/etc/di.xml | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/app/code/Magento/Signifyd/etc/di.xml b/app/code/Magento/Signifyd/etc/di.xml
index 764d8f7eddb77..453e5d61179a2 100644
--- a/app/code/Magento/Signifyd/etc/di.xml
+++ b/app/code/Magento/Signifyd/etc/di.xml
@@ -61,4 +61,9 @@
Magento\Payment\Gateway\Config\Config
+
+
+ sales
+
+
From 90be2c0ce1479d73e9fb2e6757c3ec34acc43bb6 Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Tue, 7 Feb 2017 05:26:53 -0600
Subject: [PATCH 174/904] MAGETWO-63910: Create infrastructure for mapper in
Payment module
- Refactored code according to code review.
(cherry picked from commit 99af3fc)
---
.../Model/PaymentVerificationFactory.php | 31 ++++++++++++++++---
1 file changed, 26 insertions(+), 5 deletions(-)
diff --git a/app/code/Magento/Signifyd/Model/PaymentVerificationFactory.php b/app/code/Magento/Signifyd/Model/PaymentVerificationFactory.php
index f6f3024fdeee1..e228df47b040c 100644
--- a/app/code/Magento/Signifyd/Model/PaymentVerificationFactory.php
+++ b/app/code/Magento/Signifyd/Model/PaymentVerificationFactory.php
@@ -10,7 +10,7 @@
use Magento\Payment\Gateway\ConfigInterface;
/**
- * Creates verification service for provided payment method, or \Magento\Payment\Api\PaymentVerificationInterface::class
+ * Creates verification service for provided payment method, or PaymentVerificationInterface::class
* if payment method does not support AVS, CVV verifications.
*/
class PaymentVerificationFactory
@@ -36,7 +36,12 @@ public function __construct(ObjectManagerInterface $objectManager, ConfigInterfa
}
/**
- * @inheritdoc
+ * Creates instance of CVV code verification.
+ * Exception will be thrown if CVV mapper does not implement PaymentVerificationInterface.
+ *
+ * @param string $paymentCode
+ * @return PaymentVerificationInterface
+ * @throws \Exception
*/
public function createPaymentCvv($paymentCode)
{
@@ -44,7 +49,12 @@ public function createPaymentCvv($paymentCode)
}
/**
- * @inheritdoc
+ * Creates instance of AVS code verification.
+ * Exception will be thrown if AVS mapper does not implement PaymentVerificationInterface.
+ *
+ * @param string $paymentCode
+ * @return PaymentVerificationInterface
+ * @throws \Exception
*/
public function createPaymentAvs($paymentCode)
{
@@ -52,7 +62,14 @@ public function createPaymentAvs($paymentCode)
}
/**
- * @inheritdoc
+ * Creates instance of PaymentVerificationInterface.
+ * Default implementation will be returned if payment method does not implement PaymentVerificationInterface.
+ * Exception will be thrown if payment verification instance does not implement PaymentVerificationInterface.
+ *
+ * @param string $paymentCode
+ * @param string $configKey
+ * @return PaymentVerificationInterface
+ * @throws \Exception
*/
private function create($paymentCode, $configKey)
{
@@ -61,6 +78,10 @@ private function create($paymentCode, $configKey)
if ($verificationClass === null) {
return $this->objectManager->get(PaymentVerificationInterface::class);
}
- return $this->objectManager->create($verificationClass);
+ $mapper = $this->objectManager->create($verificationClass);
+ if (!$mapper instanceof PaymentVerificationInterface) {
+ throw new \Exception($verificationClass . ' must implement ' . PaymentVerificationInterface::class);
+ }
+ return $mapper;
}
}
From cfd313ea932d5897ea6954f3c2e4525d39bc4e85 Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Tue, 7 Feb 2017 05:33:41 -0600
Subject: [PATCH 175/904] MAGETWO-63851: Re-implement cancel guarantee
mechanism
- Updated doc blocks
(cherry picked from commit a19956d)
---
app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php | 2 --
app/code/Magento/Signifyd/Observer/PlaceOrder.php | 4 ----
2 files changed, 6 deletions(-)
diff --git a/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php b/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php
index af3d30785efaf..9aaf15ca4a688 100644
--- a/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php
+++ b/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php
@@ -32,8 +32,6 @@ class CaseInfo extends Template
private $caseManagement;
/**
- * Constructor
- *
* @param Context $context
* @param Config $config
* @param CaseManagement $caseManagement
diff --git a/app/code/Magento/Signifyd/Observer/PlaceOrder.php b/app/code/Magento/Signifyd/Observer/PlaceOrder.php
index 764caaf97adea..d260de96c5a9e 100644
--- a/app/code/Magento/Signifyd/Observer/PlaceOrder.php
+++ b/app/code/Magento/Signifyd/Observer/PlaceOrder.php
@@ -15,8 +15,6 @@
use Psr\Log\LoggerInterface;
/**
- * Place Order observer.
- *
* Observer should be triggered when new order is created and placed.
* If Signifyd integration enabled in configuration then new case will be created.
*/
@@ -38,8 +36,6 @@ class PlaceOrder implements ObserverInterface
private $logger;
/**
- * PlaceOrder constructor.
- *
* @param Config $signifydIntegrationConfig
* @param CaseCreationServiceInterface $caseCreationService
* @param LoggerInterface $logger
From 781e984ed0b5f86da4b9f9ec24ccdb4ad4bc57a1 Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Tue, 7 Feb 2017 07:00:08 -0600
Subject: [PATCH 176/904] MAGETWO-63945: Add extension point to sales grid
indexer
- Refactoring according CR
---
.../Signifyd/Model/CaseServices/UpdatingService.php | 6 +++---
.../NotSyncedOrderIdListProvider.php} | 9 +++++----
.../Model/{ => SalesOrderGrid}/OrderGridUpdater.php | 2 +-
.../Test/Unit/Model/CaseServices/UpdatingServiceTest.php | 4 ++--
.../Model/{ => SalesOrderGrid}/OrderGridUpdaterTest.php | 9 +++------
app/code/Magento/Signifyd/etc/di.xml | 6 +++---
6 files changed, 17 insertions(+), 19 deletions(-)
rename app/code/Magento/Signifyd/Model/{OrderIdListProvider.php => SalesOrderGrid/NotSyncedOrderIdListProvider.php} (80%)
rename app/code/Magento/Signifyd/Model/{ => SalesOrderGrid}/OrderGridUpdater.php (95%)
rename app/code/Magento/Signifyd/Test/Unit/Model/{ => SalesOrderGrid}/OrderGridUpdaterTest.php (87%)
diff --git a/app/code/Magento/Signifyd/Model/CaseServices/UpdatingService.php b/app/code/Magento/Signifyd/Model/CaseServices/UpdatingService.php
index f93bb08eb0761..40f28b32ec0eb 100644
--- a/app/code/Magento/Signifyd/Model/CaseServices/UpdatingService.php
+++ b/app/code/Magento/Signifyd/Model/CaseServices/UpdatingService.php
@@ -11,7 +11,7 @@
use Magento\Signifyd\Api\Data\CaseInterface;
use Magento\Signifyd\Model\CommentsHistoryUpdater;
use Magento\Signifyd\Model\MessageGenerators\GeneratorInterface;
-use Magento\Signifyd\Model\OrderGridUpdater;
+use Magento\Signifyd\Model\SalesOrderGrid\OrderGridUpdater;
/**
* Performs Signifyd case entity updating operations.
@@ -34,7 +34,7 @@ class UpdatingService implements UpdatingServiceInterface
private $commentsHistoryUpdater;
/**
- * @var OrderGridUpdater
+ * @var \Magento\Signifyd\Model\SalesOrderGrid\OrderGridUpdater
*/
private $orderGridUpdater;
@@ -44,7 +44,7 @@ class UpdatingService implements UpdatingServiceInterface
* @param GeneratorInterface $messageGenerator
* @param CaseRepositoryInterface $caseRepository
* @param CommentsHistoryUpdater $commentsHistoryUpdater
- * @param OrderGridUpdater $orderGridUpdater
+ * @param \Magento\Signifyd\Model\SalesOrderGrid\OrderGridUpdater $orderGridUpdater
*/
public function __construct(
GeneratorInterface $messageGenerator,
diff --git a/app/code/Magento/Signifyd/Model/OrderIdListProvider.php b/app/code/Magento/Signifyd/Model/SalesOrderGrid/NotSyncedOrderIdListProvider.php
similarity index 80%
rename from app/code/Magento/Signifyd/Model/OrderIdListProvider.php
rename to app/code/Magento/Signifyd/Model/SalesOrderGrid/NotSyncedOrderIdListProvider.php
index 8093ce23f55d8..cbcd376d35b2e 100644
--- a/app/code/Magento/Signifyd/Model/OrderIdListProvider.php
+++ b/app/code/Magento/Signifyd/Model/SalesOrderGrid/NotSyncedOrderIdListProvider.php
@@ -3,15 +3,16 @@
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-namespace Magento\Signifyd\Model;
+namespace Magento\Signifyd\Model\SalesOrderGrid;
-use Magento\Sales\Model\ResourceModel\Provider\IdListProviderInterface;
+use Magento\Sales\Model\ResourceModel\Provider\NotSyncedDataProviderInterface;
+use Magento\Signifyd\Model\ResourceModel;
use Magento\Signifyd\Model\ResourceModel\CaseEntity;
/**
* Provides order ids list which Signifyd Case guaranty status were changed
*/
-class OrderIdListProvider implements IdListProviderInterface
+class NotSyncedOrderIdListProvider implements NotSyncedDataProviderInterface
{
/**
* @var ResourceModel\CaseEntity
@@ -30,7 +31,7 @@ public function __construct(
/**
* @inheritdoc
*/
- public function get($mainTableName, $gridTableName)
+ public function getIds($mainTableName, $gridTableName)
{
$connection = $this->caseEntity->getConnection();
$select = $connection->select()
diff --git a/app/code/Magento/Signifyd/Model/OrderGridUpdater.php b/app/code/Magento/Signifyd/Model/SalesOrderGrid/OrderGridUpdater.php
similarity index 95%
rename from app/code/Magento/Signifyd/Model/OrderGridUpdater.php
rename to app/code/Magento/Signifyd/Model/SalesOrderGrid/OrderGridUpdater.php
index 5cefddaf21022..5cb87d3316645 100644
--- a/app/code/Magento/Signifyd/Model/OrderGridUpdater.php
+++ b/app/code/Magento/Signifyd/Model/SalesOrderGrid/OrderGridUpdater.php
@@ -3,7 +3,7 @@
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-namespace Magento\Signifyd\Model;
+namespace Magento\Signifyd\Model\SalesOrderGrid;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Sales\Model\ResourceModel\GridInterface;
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/CaseServices/UpdatingServiceTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/CaseServices/UpdatingServiceTest.php
index 1dff0981e5d5b..a2894939042dd 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/CaseServices/UpdatingServiceTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/CaseServices/UpdatingServiceTest.php
@@ -12,7 +12,7 @@
use Magento\Signifyd\Model\CommentsHistoryUpdater;
use Magento\Signifyd\Model\MessageGenerators\GeneratorException;
use Magento\Signifyd\Model\MessageGenerators\GeneratorInterface;
-use Magento\Signifyd\Model\OrderGridUpdater;
+use Magento\Signifyd\Model\SalesOrderGrid\OrderGridUpdater;
use PHPUnit_Framework_MockObject_MockObject as MockObject;
/**
@@ -46,7 +46,7 @@ class UpdatingServiceTest extends \PHPUnit_Framework_TestCase
private $commentsHistoryUpdater;
/**
- * @var OrderGridUpdater|MockObject
+ * @var \Magento\Signifyd\Model\SalesOrderGrid\OrderGridUpdater|MockObject
*/
private $orderGridUpdater;
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/OrderGridUpdaterTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/SalesOrderGrid/OrderGridUpdaterTest.php
similarity index 87%
rename from app/code/Magento/Signifyd/Test/Unit/Model/OrderGridUpdaterTest.php
rename to app/code/Magento/Signifyd/Test/Unit/Model/SalesOrderGrid/OrderGridUpdaterTest.php
index 90f672cc956ce..eda647c214db7 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/OrderGridUpdaterTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/SalesOrderGrid/OrderGridUpdaterTest.php
@@ -3,16 +3,13 @@
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-namespace Magento\Signifyd\Test\Unit\Model;
+namespace Magento\Signifyd\Test\Unit\Model\SalesOrderGrid;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Sales\Model\ResourceModel\GridInterface;
-use Magento\Signifyd\Model\OrderGridUpdater;
+use Magento\Signifyd\Model\SalesOrderGrid\OrderGridUpdater;
use PHPUnit_Framework_MockObject_MockObject as MockObject;
-/**
- * Class OrderGridUpdaterTest
- */
class OrderGridUpdaterTest extends \PHPUnit_Framework_TestCase
{
/**
@@ -40,7 +37,7 @@ protected function setUp()
$this->globalConfig = $this->getMockBuilder(ScopeConfigInterface::class)
->getMockForAbstractClass();
- $this->model = new OrderGridUpdater($this->orderGrid, $this->globalConfig);
+ $this->model = new \Magento\Signifyd\Model\SalesOrderGrid\OrderGridUpdater($this->orderGrid, $this->globalConfig);
}
public function testUpdateInSyncMode()
diff --git a/app/code/Magento/Signifyd/etc/di.xml b/app/code/Magento/Signifyd/etc/di.xml
index 453e5d61179a2..35d9c54e8149b 100644
--- a/app/code/Magento/Signifyd/etc/di.xml
+++ b/app/code/Magento/Signifyd/etc/di.xml
@@ -14,15 +14,15 @@
-
+
Magento\Sales\Model\ResourceModel\Order\Grid
-
+
- - Magento\Signifyd\Model\OrderIdListProvider
+ - Magento\Signifyd\Model\SalesOrderGrid\NotSyncedOrderIdListProvider
From e3037df2d7e89ba22f7525258db8dd87b9d1c826 Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Tue, 7 Feb 2017 07:58:48 -0600
Subject: [PATCH 177/904] MAGETWO-63910: Create infrastructure for mapper in
Payment module
- Updated payment verification interface
- Updated Braintree avs/cvv mappers behaviour
- Refactored payment verification default implementation
(cherry picked from commit 32323c2)
---
.../Model/DefaultPaymentVerification.php | 37 +++++++++++++++++++
.../Model/PaymentVerificationFactory.php | 33 +++++++++++++----
.../Request/PurchaseBuilder.php | 8 +---
app/code/Magento/Signifyd/etc/di.xml | 6 +++
4 files changed, 71 insertions(+), 13 deletions(-)
create mode 100644 app/code/Magento/Signifyd/Model/DefaultPaymentVerification.php
diff --git a/app/code/Magento/Signifyd/Model/DefaultPaymentVerification.php b/app/code/Magento/Signifyd/Model/DefaultPaymentVerification.php
new file mode 100644
index 0000000000000..fdea5b7cac138
--- /dev/null
+++ b/app/code/Magento/Signifyd/Model/DefaultPaymentVerification.php
@@ -0,0 +1,37 @@
+default = $default;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function getCode(OrderPaymentInterface $orderPayment)
+ {
+ return $this->default;
+ }
+}
diff --git a/app/code/Magento/Signifyd/Model/PaymentVerificationFactory.php b/app/code/Magento/Signifyd/Model/PaymentVerificationFactory.php
index e228df47b040c..ecd6867073d98 100644
--- a/app/code/Magento/Signifyd/Model/PaymentVerificationFactory.php
+++ b/app/code/Magento/Signifyd/Model/PaymentVerificationFactory.php
@@ -25,14 +25,32 @@ class PaymentVerificationFactory
*/
private $objectManager;
+ /**
+ * @var DefaultPaymentVerification
+ */
+ private $avsAdapter;
+
+ /**
+ * @var DefaultPaymentVerification
+ */
+ private $cvvAdapter;
+
/**
* @param ObjectManagerInterface $objectManager
- * @param Config $config
+ * @param ConfigInterface|Config $config
+ * @param DefaultPaymentVerification $avsAdapter
+ * @param DefaultPaymentVerification $cvvAdapter
*/
- public function __construct(ObjectManagerInterface $objectManager, ConfigInterface $config)
- {
+ public function __construct(
+ ObjectManagerInterface $objectManager,
+ ConfigInterface $config,
+ DefaultPaymentVerification $avsAdapter,
+ DefaultPaymentVerification $cvvAdapter
+ ) {
$this->config = $config;
$this->objectManager = $objectManager;
+ $this->avsAdapter = $avsAdapter;
+ $this->cvvAdapter = $cvvAdapter;
}
/**
@@ -45,7 +63,7 @@ public function __construct(ObjectManagerInterface $objectManager, ConfigInterfa
*/
public function createPaymentCvv($paymentCode)
{
- return $this->create($paymentCode, 'cvv_ems_adapter');
+ return $this->create($this->cvvAdapter, $paymentCode, 'cvv_ems_adapter');
}
/**
@@ -58,7 +76,7 @@ public function createPaymentCvv($paymentCode)
*/
public function createPaymentAvs($paymentCode)
{
- return $this->create($paymentCode, 'avs_ems_adapter');
+ return $this->create($this->avsAdapter, $paymentCode, 'avs_ems_adapter');
}
/**
@@ -66,17 +84,18 @@ public function createPaymentAvs($paymentCode)
* Default implementation will be returned if payment method does not implement PaymentVerificationInterface.
* Exception will be thrown if payment verification instance does not implement PaymentVerificationInterface.
*
+ * @param DefaultPaymentVerification $defaultAdapter
* @param string $paymentCode
* @param string $configKey
* @return PaymentVerificationInterface
* @throws \Exception
*/
- private function create($paymentCode, $configKey)
+ private function create(DefaultPaymentVerification $defaultAdapter, $paymentCode, $configKey)
{
$this->config->setMethodCode($paymentCode);
$verificationClass = $this->config->getValue($configKey);
if ($verificationClass === null) {
- return $this->objectManager->get(PaymentVerificationInterface::class);
+ return $defaultAdapter;
}
$mapper = $this->objectManager->create($verificationClass);
if (!$mapper instanceof PaymentVerificationInterface) {
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php
index 48e2c3837fc71..86f9520a13309 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php
@@ -186,9 +186,7 @@ private function getAvsCode(OrderPaymentInterface $orderPayment)
{
/** @var PaymentVerificationInterface $avsAdapter */
$avsAdapter = $this->paymentVerificationFactory->createPaymentAvs($orderPayment->getMethod());
- $code = $avsAdapter->getCode($orderPayment);
-
- return $code !== null ? $code : 'U';
+ return $avsAdapter->getCode($orderPayment);
}
/**
@@ -201,8 +199,6 @@ private function getCvvCode(OrderPaymentInterface $orderPayment)
{
/** @var PaymentVerificationInterface $cvvAdapter */
$cvvAdapter = $this->paymentVerificationFactory->createPaymentCvv($orderPayment->getMethod());
- $code = $cvvAdapter->getCode($orderPayment);
-
- return $code !== null ? $code : '';
+ return $cvvAdapter->getCode($orderPayment);
}
}
diff --git a/app/code/Magento/Signifyd/etc/di.xml b/app/code/Magento/Signifyd/etc/di.xml
index 35d9c54e8149b..b43d708fc852a 100644
--- a/app/code/Magento/Signifyd/etc/di.xml
+++ b/app/code/Magento/Signifyd/etc/di.xml
@@ -56,9 +56,15 @@
+
+
+ U
+
+
Magento\Payment\Gateway\Config\Config
+ SignifydAvsDefaultMapper
From 751c24e0db28b20b0ad05dccd87271d6287d719b Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Tue, 7 Feb 2017 08:21:56 -0600
Subject: [PATCH 178/904] MAGETWO-63945: Add extension point to sales grid
indexer
- Fix static
(cherry picked from commit 6f7df62)
---
.../Test/Unit/Model/SalesOrderGrid/OrderGridUpdaterTest.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/SalesOrderGrid/OrderGridUpdaterTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/SalesOrderGrid/OrderGridUpdaterTest.php
index eda647c214db7..1390a036955c2 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/SalesOrderGrid/OrderGridUpdaterTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/SalesOrderGrid/OrderGridUpdaterTest.php
@@ -37,7 +37,7 @@ protected function setUp()
$this->globalConfig = $this->getMockBuilder(ScopeConfigInterface::class)
->getMockForAbstractClass();
- $this->model = new \Magento\Signifyd\Model\SalesOrderGrid\OrderGridUpdater($this->orderGrid, $this->globalConfig);
+ $this->model = new OrderGridUpdater($this->orderGrid, $this->globalConfig);
}
public function testUpdateInSyncMode()
From 1d67a0e374e99d27ec48505abae3aa75d752cad1 Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Tue, 7 Feb 2017 10:51:44 -0600
Subject: [PATCH 179/904] MAGETWO-63942: Add Signifyd Guarantee Status column
to order grid
- refactoring
---
app/code/Magento/Signifyd/Setup/InstallData.php | 9 +++++++--
app/code/Magento/Signifyd/Setup/InstallSchema.php | 7 ++++++-
app/code/Magento/Signifyd/composer.json | 3 +++
app/code/Magento/Signifyd/etc/di.xml | 7 +++++++
4 files changed, 23 insertions(+), 3 deletions(-)
diff --git a/app/code/Magento/Signifyd/Setup/InstallData.php b/app/code/Magento/Signifyd/Setup/InstallData.php
index 6e37ac63c493e..a7490064a895a 100644
--- a/app/code/Magento/Signifyd/Setup/InstallData.php
+++ b/app/code/Magento/Signifyd/Setup/InstallData.php
@@ -21,6 +21,11 @@ class InstallData implements InstallDataInterface
*/
private $resource;
+ /**
+ * @var string
+ */
+ private static $connectionName = 'sales';
+
/**
* @param ResourceConnection $resource
*/
@@ -38,7 +43,7 @@ public function __construct(
*/
public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
{
- $this->resource->getConnection('sales')->addColumn(
+ $this->resource->getConnection(self::$connectionName)->addColumn(
$setup->getTable('sales_order_grid'),
'signifyd_guarantee_status',
[
@@ -48,7 +53,7 @@ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface
]
);
- $this->resource->getConnection('sales')->addColumn(
+ $this->resource->getConnection(self::$connectionName)->addColumn(
$setup->getTable('magento_sales_order_grid_archive'),
'signifyd_guarantee_status',
[
diff --git a/app/code/Magento/Signifyd/Setup/InstallSchema.php b/app/code/Magento/Signifyd/Setup/InstallSchema.php
index 8107d06285bff..b66bd5314b6bb 100644
--- a/app/code/Magento/Signifyd/Setup/InstallSchema.php
+++ b/app/code/Magento/Signifyd/Setup/InstallSchema.php
@@ -22,13 +22,18 @@ class InstallSchema implements InstallSchemaInterface
*/
private static $table = 'signifyd_case';
+ /**
+ * @var string
+ */
+ private static $connectionName = 'sales';
+
/**
* @inheritdoc
*/
public function install(SchemaSetupInterface $setup, ModuleContextInterface $context)
{
/** @var AdapterInterface $connection */
- $connection = $setup->startSetup()->getConnection();
+ $connection = $setup->startSetup()->getConnection(self::$connectionName);
$table = $connection->newTable($setup->getTable(static::$table));
$table->addColumn(
diff --git a/app/code/Magento/Signifyd/composer.json b/app/code/Magento/Signifyd/composer.json
index 3c5d5bd592253..315ed2db7495d 100644
--- a/app/code/Magento/Signifyd/composer.json
+++ b/app/code/Magento/Signifyd/composer.json
@@ -13,6 +13,9 @@
"magento/module-backend": "100.2.*",
"magento/module-payment": "100.2.*"
},
+ "suggest": {
+ "magento/module-scalable-oms": "100.2.*"
+ },
"type": "magento2-module",
"version": "100.2.0-dev",
"license": [
diff --git a/app/code/Magento/Signifyd/etc/di.xml b/app/code/Magento/Signifyd/etc/di.xml
index b43d708fc852a..b17b5f3e8a8f4 100644
--- a/app/code/Magento/Signifyd/etc/di.xml
+++ b/app/code/Magento/Signifyd/etc/di.xml
@@ -72,4 +72,11 @@
sales
+
+
+
+ - signifyd_case
+
+
+
From 829e3edf3a89c2282e3d74cce8149d154bc18ee5 Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Wed, 8 Feb 2017 03:51:07 -0600
Subject: [PATCH 180/904] MAGETWO-63910: Create infrastructure for mapper in
Payment module
- Added payment method code validation to Braintree mappers
- Updated default payment verification mapper and factory for creating mappers
(cherry picked from commit 8464db0)
---
.../Model/PaymentVerificationFactory.php | 28 +++++++++----------
...p => PredefinedVerificationCodeMapper.php} | 12 ++++----
.../Request/CreateCaseBuilder.php | 14 ++++++++++
.../Request/PurchaseBuilder.php | 3 --
app/code/Magento/Signifyd/etc/di.xml | 9 ++++--
.../Request/CreateCaseBuilderTest.php | 8 ++++--
.../order_with_guest_and_virtual_product.php | 7 ++++-
7 files changed, 52 insertions(+), 29 deletions(-)
rename app/code/Magento/Signifyd/Model/{DefaultPaymentVerification.php => PredefinedVerificationCodeMapper.php} (70%)
diff --git a/app/code/Magento/Signifyd/Model/PaymentVerificationFactory.php b/app/code/Magento/Signifyd/Model/PaymentVerificationFactory.php
index ecd6867073d98..b84fa43628c0f 100644
--- a/app/code/Magento/Signifyd/Model/PaymentVerificationFactory.php
+++ b/app/code/Magento/Signifyd/Model/PaymentVerificationFactory.php
@@ -26,31 +26,31 @@ class PaymentVerificationFactory
private $objectManager;
/**
- * @var DefaultPaymentVerification
+ * @var PaymentVerificationInterface
*/
- private $avsAdapter;
+ private $avsDefaultAdapter;
/**
- * @var DefaultPaymentVerification
+ * @var PaymentVerificationInterface
*/
- private $cvvAdapter;
+ private $cvvDefaultAdapter;
/**
* @param ObjectManagerInterface $objectManager
* @param ConfigInterface|Config $config
- * @param DefaultPaymentVerification $avsAdapter
- * @param DefaultPaymentVerification $cvvAdapter
+ * @param PaymentVerificationInterface $avsDefaultAdapter
+ * @param PaymentVerificationInterface $cvvDefaultAdapter
*/
public function __construct(
ObjectManagerInterface $objectManager,
ConfigInterface $config,
- DefaultPaymentVerification $avsAdapter,
- DefaultPaymentVerification $cvvAdapter
+ PaymentVerificationInterface $avsDefaultAdapter,
+ PaymentVerificationInterface $cvvDefaultAdapter
) {
$this->config = $config;
$this->objectManager = $objectManager;
- $this->avsAdapter = $avsAdapter;
- $this->cvvAdapter = $cvvAdapter;
+ $this->avsDefaultAdapter = $avsDefaultAdapter;
+ $this->cvvDefaultAdapter = $cvvDefaultAdapter;
}
/**
@@ -63,7 +63,7 @@ public function __construct(
*/
public function createPaymentCvv($paymentCode)
{
- return $this->create($this->cvvAdapter, $paymentCode, 'cvv_ems_adapter');
+ return $this->create($this->cvvDefaultAdapter, $paymentCode, 'cvv_ems_adapter');
}
/**
@@ -76,7 +76,7 @@ public function createPaymentCvv($paymentCode)
*/
public function createPaymentAvs($paymentCode)
{
- return $this->create($this->avsAdapter, $paymentCode, 'avs_ems_adapter');
+ return $this->create($this->avsDefaultAdapter, $paymentCode, 'avs_ems_adapter');
}
/**
@@ -84,13 +84,13 @@ public function createPaymentAvs($paymentCode)
* Default implementation will be returned if payment method does not implement PaymentVerificationInterface.
* Exception will be thrown if payment verification instance does not implement PaymentVerificationInterface.
*
- * @param DefaultPaymentVerification $defaultAdapter
+ * @param PaymentVerificationInterface $defaultAdapter
* @param string $paymentCode
* @param string $configKey
* @return PaymentVerificationInterface
* @throws \Exception
*/
- private function create(DefaultPaymentVerification $defaultAdapter, $paymentCode, $configKey)
+ private function create(PaymentVerificationInterface $defaultAdapter, $paymentCode, $configKey)
{
$this->config->setMethodCode($paymentCode);
$verificationClass = $this->config->getValue($configKey);
diff --git a/app/code/Magento/Signifyd/Model/DefaultPaymentVerification.php b/app/code/Magento/Signifyd/Model/PredefinedVerificationCodeMapper.php
similarity index 70%
rename from app/code/Magento/Signifyd/Model/DefaultPaymentVerification.php
rename to app/code/Magento/Signifyd/Model/PredefinedVerificationCodeMapper.php
index fdea5b7cac138..149743192ba9c 100644
--- a/app/code/Magento/Signifyd/Model/DefaultPaymentVerification.php
+++ b/app/code/Magento/Signifyd/Model/PredefinedVerificationCodeMapper.php
@@ -12,19 +12,19 @@
* Default implementation of payment verification interface.
* The default code value can be configured via DI.
*/
-class DefaultPaymentVerification implements PaymentVerificationInterface
+class PredefinedVerificationCodeMapper implements PaymentVerificationInterface
{
/**
* @var string
*/
- private $default;
+ private $code;
/**
- * @param string $default
+ * @param string $code
*/
- public function __construct($default = '')
+ public function __construct($code = '')
{
- $this->default = $default;
+ $this->code = $code;
}
/**
@@ -32,6 +32,6 @@ public function __construct($default = '')
*/
public function getCode(OrderPaymentInterface $orderPayment)
{
- return $this->default;
+ return $this->code;
}
}
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilder.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilder.php
index ec0d4dcb55889..16823447d32ee 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilder.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilder.php
@@ -15,6 +15,15 @@
*/
class CreateCaseBuilder implements CreateCaseBuilderInterface
{
+ /**
+ * List of params, which can be empty, but required by Signifyd API.
+ *
+ * @var array
+ */
+ private static $allowed = [
+ 'cvvResponseCode'
+ ];
+
/**
* @var OrderFactory
*/
@@ -106,6 +115,11 @@ public function build($orderId)
private function removeEmptyValues($data)
{
foreach ($data as $key => $value) {
+ // skip allowed empty values
+ if (in_array($key, self::$allowed, true)) {
+ continue;
+ }
+
if (is_array($value)) {
$data[$key] = $this->removeEmptyValues($data[$key]);
}
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php
index 86f9520a13309..287ecdb84ca77 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php
@@ -8,7 +8,6 @@
use Magento\Framework\App\Area;
use Magento\Framework\Config\ScopeInterface;
use Magento\Framework\Intl\DateTimeFactory;
-use Magento\Payment\Api\PaymentVerificationInterface;
use Magento\Sales\Api\Data\OrderPaymentInterface;
use Magento\Sales\Model\Order;
use Magento\Signifyd\Model\PaymentVerificationFactory;
@@ -184,7 +183,6 @@ private function getOrderChannel()
*/
private function getAvsCode(OrderPaymentInterface $orderPayment)
{
- /** @var PaymentVerificationInterface $avsAdapter */
$avsAdapter = $this->paymentVerificationFactory->createPaymentAvs($orderPayment->getMethod());
return $avsAdapter->getCode($orderPayment);
}
@@ -197,7 +195,6 @@ private function getAvsCode(OrderPaymentInterface $orderPayment)
*/
private function getCvvCode(OrderPaymentInterface $orderPayment)
{
- /** @var PaymentVerificationInterface $cvvAdapter */
$cvvAdapter = $this->paymentVerificationFactory->createPaymentCvv($orderPayment->getMethod());
return $cvvAdapter->getCode($orderPayment);
}
diff --git a/app/code/Magento/Signifyd/etc/di.xml b/app/code/Magento/Signifyd/etc/di.xml
index b17b5f3e8a8f4..08c2a343262a7 100644
--- a/app/code/Magento/Signifyd/etc/di.xml
+++ b/app/code/Magento/Signifyd/etc/di.xml
@@ -56,15 +56,18 @@
-
+
- U
+ U
+
+
Magento\Payment\Gateway\Config\Config
- SignifydAvsDefaultMapper
+ SignifydAvsDefaultMapper
+ SignifydCvvDefaultMapper
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
index b6844a4da447d..1f93dc9b87d8a 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
@@ -87,6 +87,8 @@ public function testCreateCaseBuilderWithFullSetOfData()
'paymentGateway' => 'paypal_account',
'transactionId' => $payment->getLastTransId(),
'currency' => $order->getOrderCurrencyCode(),
+ 'avsResponseCode' => 'U',
+ 'cvvResponseCode' => '',
'orderChannel' => 'WEB',
'totalPrice' => $order->getGrandTotal(),
'shipments' => [
@@ -160,7 +162,7 @@ public function testCreateCaseBuilderWithFullSetOfData()
]
];
- static::assertEquals(
+ self::assertEquals(
$expected,
$this->caseBuilder->build($order->getEntityId())
);
@@ -200,6 +202,8 @@ public function testCreateCaseBuilderWithVirtualProductAndGuest()
'paymentGateway' => $payment->getMethod(),
'transactionId' => $payment->getLastTransId(),
'currency' => $order->getOrderCurrencyCode(),
+ 'avsResponseCode' => 'Y',
+ 'cvvResponseCode' => 'M',
'orderChannel' => 'PHONE',
'totalPrice' => $order->getGrandTotal(),
'products' => [
@@ -231,7 +235,7 @@ public function testCreateCaseBuilderWithVirtualProductAndGuest()
]
];
- static::assertEquals(
+ self::assertEquals(
$expected,
$this->caseBuilder->build($order->getEntityId())
);
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/_files/order_with_guest_and_virtual_product.php b/dev/tests/integration/testsuite/Magento/Signifyd/_files/order_with_guest_and_virtual_product.php
index a5a55b431df37..3d60f1c6f7e8c 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/_files/order_with_guest_and_virtual_product.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/_files/order_with_guest_and_virtual_product.php
@@ -9,6 +9,7 @@
use Magento\Sales\Model\Order\Item;
use Magento\Sales\Api\OrderRepositoryInterface;
use Magento\TestFramework\Helper\Bootstrap;
+use Magento\Sales\Api\Data\OrderPaymentInterface;
require __DIR__ . '/../../../Magento/Catalog/_files/product_virtual.php';
require __DIR__ . '/store.php';
@@ -19,9 +20,13 @@
$billingAddress = $objectManager->create(Address::class, ['data' => $addressData]);
$billingAddress->setAddressType('billing');
+/** @var OrderPaymentInterface $payment */
$payment = $objectManager->create(Payment::class);
$payment->setMethod('braintree')
- ->setLastTransId('00001');
+ ->setLastTransId('00001')
+ ->setAdditionalInformation('avsPostalCodeResponseCode', 'M')
+ ->setAdditionalInformation('avsStreetAddressResponseCode', 'M')
+ ->setAdditionalInformation('cvvResponseCode', 'M');
/** @var Item $orderItem */
$orderItem1 = $objectManager->create(Item::class);
From f253ba513694adf6db666f42ac1a13ffca9a83b0 Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Wed, 8 Feb 2017 07:50:12 -0600
Subject: [PATCH 181/904] MAGETWO-63945: Add extension point to sales grid
indexer
- Add docblock to OrderGridUpdater
(cherry picked from commit f077436)
---
.../Signifyd/Model/SalesOrderGrid/OrderGridUpdater.php | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/app/code/Magento/Signifyd/Model/SalesOrderGrid/OrderGridUpdater.php b/app/code/Magento/Signifyd/Model/SalesOrderGrid/OrderGridUpdater.php
index 5cb87d3316645..1d5e67b0c1065 100644
--- a/app/code/Magento/Signifyd/Model/SalesOrderGrid/OrderGridUpdater.php
+++ b/app/code/Magento/Signifyd/Model/SalesOrderGrid/OrderGridUpdater.php
@@ -9,7 +9,9 @@
use Magento\Sales\Model\ResourceModel\GridInterface;
/**
- * Perfoms sales order grid updating operations
+ * Perfoms sales order grid updating operations.
+ *
+ * Serves order grid updates in both synchronous and asynchronous modes.
*/
class OrderGridUpdater
{
From ad11d9aa0462265b56d7090cec46633f845d284d Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Wed, 8 Feb 2017 07:59:05 -0600
Subject: [PATCH 182/904] MAGETWO-63910: Create infrastructure for mapper in
Payment module
- Refactored code
- Added unit tests
(cherry picked from commit 9d9f254)
---
...per.php => PredefinedVerificationCode.php} | 2 +-
.../Request/CreateCaseBuilder.php | 2 +-
.../Model/PaymentVerificationFactoryTest.php | 222 ++++++++++++++++++
app/code/Magento/Signifyd/etc/di.xml | 4 +-
4 files changed, 226 insertions(+), 4 deletions(-)
rename app/code/Magento/Signifyd/Model/{PredefinedVerificationCodeMapper.php => PredefinedVerificationCode.php} (89%)
create mode 100644 app/code/Magento/Signifyd/Test/Unit/Model/PaymentVerificationFactoryTest.php
diff --git a/app/code/Magento/Signifyd/Model/PredefinedVerificationCodeMapper.php b/app/code/Magento/Signifyd/Model/PredefinedVerificationCode.php
similarity index 89%
rename from app/code/Magento/Signifyd/Model/PredefinedVerificationCodeMapper.php
rename to app/code/Magento/Signifyd/Model/PredefinedVerificationCode.php
index 149743192ba9c..c6f12d01364a0 100644
--- a/app/code/Magento/Signifyd/Model/PredefinedVerificationCodeMapper.php
+++ b/app/code/Magento/Signifyd/Model/PredefinedVerificationCode.php
@@ -12,7 +12,7 @@
* Default implementation of payment verification interface.
* The default code value can be configured via DI.
*/
-class PredefinedVerificationCodeMapper implements PaymentVerificationInterface
+class PredefinedVerificationCode implements PaymentVerificationInterface
{
/**
* @var string
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilder.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilder.php
index 16823447d32ee..4f46cf69b70aa 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilder.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilder.php
@@ -116,7 +116,7 @@ private function removeEmptyValues($data)
{
foreach ($data as $key => $value) {
// skip allowed empty values
- if (in_array($key, self::$allowed, true)) {
+ if (in_array($key, self::$allowed, true) && $value === '') {
continue;
}
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/PaymentVerificationFactoryTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/PaymentVerificationFactoryTest.php
new file mode 100644
index 0000000000000..4e335d5a35c95
--- /dev/null
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/PaymentVerificationFactoryTest.php
@@ -0,0 +1,222 @@
+objectManager = new ObjectManager($this);
+
+ $this->fakeObjectManager = $this->getMockBuilder(ObjectManagerInterface::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->config = $this->getMockBuilder(ConfigInterface::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->avsDefaultAdapter = $this->getMockBuilder(PaymentVerificationInterface::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->cvvDefaultAdapter = $this->getMockBuilder(PaymentVerificationInterface::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->factory = $this->objectManager->getObject(PaymentVerificationFactory::class, [
+ 'objectManager' => $this->fakeObjectManager,
+ 'config' => $this->config,
+ 'avsDefaultAdapter' => $this->avsDefaultAdapter,
+ 'cvvDefaultAdapter' => $this->cvvDefaultAdapter
+ ]);
+ }
+
+ /**
+ * Checks a test case when factory creates CVV mapper for provided payment method.
+ *
+ * @covers \Magento\Signifyd\Model\PaymentVerificationFactory::createPaymentCvv
+ */
+ public function testCreatePaymentCvv()
+ {
+ $paymentMethodCode = 'exists_payment';
+
+ $this->config->expects(self::once())
+ ->method('setMethodCode')
+ ->with(self::equalTo($paymentMethodCode))
+ ->willReturnSelf();
+
+ $this->config->expects(self::once())
+ ->method('getValue')
+ ->with('cvv_ems_adapter')
+ ->willReturn(PaymentVerificationInterface::class);
+
+ /** @var PaymentVerificationInterface|MockObject $cvvAdapter */
+ $cvvAdapter = $this->getMockBuilder(PaymentVerificationInterface::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->fakeObjectManager->expects(self::once())
+ ->method('create')
+ ->with(self::equalTo(PaymentVerificationInterface::class))
+ ->willReturn($cvvAdapter);
+
+ $mapper = $this->factory->createPaymentCvv($paymentMethodCode);
+ self::assertInstanceOf(PaymentVerificationInterface::class, $mapper);
+ }
+
+ /**
+ * Checks a test case, when provided payment method does not have cvv mapper.
+ *
+ * @covers \Magento\Signifyd\Model\PaymentVerificationFactory::createPaymentCvv
+ */
+ public function testCreateDefaultCvvMapper()
+ {
+ $paymentMethodCode = 'non_exists_payment';
+
+ $this->config->expects(self::once())
+ ->method('setMethodCode')
+ ->with(self::equalTo($paymentMethodCode))
+ ->willReturnSelf();
+
+ $this->config->expects(self::once())
+ ->method('getValue')
+ ->with('cvv_ems_adapter')
+ ->willReturn(null);
+
+ $this->fakeObjectManager->expects(self::never())
+ ->method('create');
+
+ $mapper = $this->factory->createPaymentCvv($paymentMethodCode);
+ self::assertSame($this->cvvDefaultAdapter, $mapper);
+ }
+
+ /**
+ * Checks a test case, when mapper implementation does not corresponding to PaymentVerificationInterface.
+ *
+ * @covers \Magento\Signifyd\Model\PaymentVerificationFactory::createPaymentCvv
+ * @expectedException \Exception
+ * @expectedExceptionMessage stdClass must implement Magento\Payment\Api\PaymentVerificationInterface
+ */
+ public function testCreateWithUnsupportedImplementation()
+ {
+ $paymentMethodCode = 'exists_payment';
+
+ $this->config->expects(self::once())
+ ->method('setMethodCode')
+ ->with(self::equalTo($paymentMethodCode))
+ ->willReturnSelf();
+
+ $this->config->expects(self::once())
+ ->method('getValue')
+ ->with('cvv_ems_adapter')
+ ->willReturn(\stdClass::class);
+
+ $cvvAdapter = new \stdClass();
+ $this->fakeObjectManager->expects(self::once())
+ ->method('create')
+ ->with(self::equalTo(\stdClass::class))
+ ->willReturn($cvvAdapter);
+
+ $this->factory->createPaymentCvv($paymentMethodCode);
+ }
+
+ /**
+ * Checks a test case when factory creates AVS mapper for provided payment method.
+ *
+ * @covers \Magento\Signifyd\Model\PaymentVerificationFactory::createPaymentAvs
+ */
+ public function testCreatePaymentAvs()
+ {
+ $paymentMethodCode = 'exists_payment';
+
+ $this->config->expects(self::once())
+ ->method('setMethodCode')
+ ->with(self::equalTo($paymentMethodCode))
+ ->willReturnSelf();
+
+ $this->config->expects(self::once())
+ ->method('getValue')
+ ->with('avs_ems_adapter')
+ ->willReturn(PaymentVerificationInterface::class);
+
+ $avsAdapter = $this->getMockBuilder(PaymentVerificationInterface::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->fakeObjectManager->expects(self::once())
+ ->method('create')
+ ->with(self::equalTo(PaymentVerificationInterface::class))
+ ->willReturn($avsAdapter);
+
+ $mapper = $this->factory->createPaymentAvs($paymentMethodCode);
+ self::assertInstanceOf(PaymentVerificationInterface::class, $mapper);
+ }
+
+ /**
+ * Checks a test case when provided payment method does not support
+ */
+ public function testCreateDefaultAvsMapper()
+ {
+ $paymentMethodCode = 'non_exists_payment';
+
+ $this->config->expects(self::once())
+ ->method('setMethodCode')
+ ->with(self::equalTo($paymentMethodCode))
+ ->willReturnSelf();
+
+ $this->config->expects(self::once())
+ ->method('getValue')
+ ->with('avs_ems_adapter')
+ ->willReturn(null);
+
+ $this->fakeObjectManager->expects(self::never())
+ ->method('create');
+
+ $mapper = $this->factory->createPaymentAvs($paymentMethodCode);
+ self::assertSame($this->avsDefaultAdapter, $mapper);
+ }
+}
diff --git a/app/code/Magento/Signifyd/etc/di.xml b/app/code/Magento/Signifyd/etc/di.xml
index 08c2a343262a7..6bf80d12402fc 100644
--- a/app/code/Magento/Signifyd/etc/di.xml
+++ b/app/code/Magento/Signifyd/etc/di.xml
@@ -56,12 +56,12 @@
-
+
U
-
+
From fbc36e1db6c0a8a44377c23c108dda0393547355 Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Wed, 8 Feb 2017 10:24:16 -0600
Subject: [PATCH 183/904] MAGETWO-63910: Create infrastructure for mapper in
Payment module
- Updated data fields filtration
(cherry picked from commit c06d779)
---
.../Request/CreateCaseBuilder.php | 16 +---------------
.../Request/CreateCaseBuilderTest.php | 6 ++++--
2 files changed, 5 insertions(+), 17 deletions(-)
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilder.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilder.php
index 4f46cf69b70aa..317337d70b58a 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilder.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilder.php
@@ -15,15 +15,6 @@
*/
class CreateCaseBuilder implements CreateCaseBuilderInterface
{
- /**
- * List of params, which can be empty, but required by Signifyd API.
- *
- * @var array
- */
- private static $allowed = [
- 'cvvResponseCode'
- ];
-
/**
* @var OrderFactory
*/
@@ -115,11 +106,6 @@ public function build($orderId)
private function removeEmptyValues($data)
{
foreach ($data as $key => $value) {
- // skip allowed empty values
- if (in_array($key, self::$allowed, true) && $value === '') {
- continue;
- }
-
if (is_array($value)) {
$data[$key] = $this->removeEmptyValues($data[$key]);
}
@@ -140,6 +126,6 @@ private function removeEmptyValues($data)
*/
private function isEmpty($value)
{
- return $value === null || $value === '' || (is_array($value) && empty($value));
+ return $value === null || (is_array($value) && empty($value));
}
}
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
index 1f93dc9b87d8a..066e493dc0f01 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
@@ -127,7 +127,8 @@ public function testCreateCaseBuilderWithFullSetOfData()
'city' => $billingAddress->getCity(),
'provinceCode' => $billingAddress->getRegionCode(),
'postalCode' => $billingAddress->getPostcode(),
- 'countryCode' => $billingAddress->getCountryId()
+ 'countryCode' => $billingAddress->getCountryId(),
+ 'unit' => ''
]
],
'recipient' => [
@@ -223,7 +224,8 @@ public function testCreateCaseBuilderWithVirtualProductAndGuest()
'city' => $billingAddress->getCity(),
'provinceCode' => $billingAddress->getRegionCode(),
'postalCode' => $billingAddress->getPostcode(),
- 'countryCode' => $billingAddress->getCountryId()
+ 'countryCode' => $billingAddress->getCountryId(),
+ 'unit' => ''
]
],
'seller' => $this->getSellerData(),
From c205be8ae94ee2bd1a0c9a421756700bcad9d9bd Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Thu, 9 Feb 2017 03:10:30 -0600
Subject: [PATCH 184/904] MAGETWO-64345: Fix test request processing in webhook
controller
---
.../Signifyd/Controller/Webhooks/Handler.php | 18 ++++++--
.../Unit/Controller/Webhooks/HandlerTest.php | 43 ++++++++++++++++---
.../Controller/Webhooks/HandlerTest.php | 39 +++++++++++++++++
3 files changed, 91 insertions(+), 9 deletions(-)
diff --git a/app/code/Magento/Signifyd/Controller/Webhooks/Handler.php b/app/code/Magento/Signifyd/Controller/Webhooks/Handler.php
index 9a522b073900a..ac13ff028afcf 100644
--- a/app/code/Magento/Signifyd/Controller/Webhooks/Handler.php
+++ b/app/code/Magento/Signifyd/Controller/Webhooks/Handler.php
@@ -23,6 +23,13 @@
*/
class Handler extends Action
{
+ /**
+ * Event topic of test webhook request.
+ *
+ * @var string
+ */
+ private static $eventTopicTest = 'cases/test';
+
/**
* @var WebhookRequest
*/
@@ -95,18 +102,21 @@ public function __construct(
*/
public function execute()
{
+ if ($this->config->isDebugModeEnabled()) {
+ $this->logger->debug($this->webhookRequest->getEventTopic() . '|' . $this->webhookRequest->getBody());
+ }
+
if (!$this->webhookRequestValidator->validate($this->webhookRequest)) {
$this->_redirect('noroute');
return;
}
$webhookMessage = $this->webhookMessageReader->read($this->webhookRequest);
-
- $data = $webhookMessage->getData();
- if ($this->config->isDebugModeEnabled()) {
- $this->logger->debug(json_encode($data));
+ if ($webhookMessage->getEventTopic() === self::$eventTopicTest) {
+ return;
}
+ $data = $webhookMessage->getData();
if (empty($data['caseId'])) {
$this->_redirect('noroute');
return;
diff --git a/app/code/Magento/Signifyd/Test/Unit/Controller/Webhooks/HandlerTest.php b/app/code/Magento/Signifyd/Test/Unit/Controller/Webhooks/HandlerTest.php
index 598fb9f20a41a..9230419ace200 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Controller/Webhooks/HandlerTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Controller/Webhooks/HandlerTest.php
@@ -144,7 +144,7 @@ protected function setUp()
*/
public function testExecuteSuccessfully()
{
- $eventTopic = 'cases\test';
+ $eventTopic = 'cases/creation';
$caseId = 1;
$data = ['score' => 200, 'caseId' => $caseId];
@@ -155,7 +155,7 @@ public function testExecuteSuccessfully()
$webhookMessage = $this->getMockBuilder(WebhookMessage::class)
->disableOriginalConstructor()
->getMock();
- $webhookMessage->expects($this->once())
+ $webhookMessage->expects($this->exactly(2))
->method('getEventTopic')
->willReturn($eventTopic);
$webhookMessage->expects($this->once())
@@ -194,7 +194,7 @@ public function testExecuteSuccessfully()
*/
public function testExecuteCaseUpdatingServiceException()
{
- $eventTopic = 'cases\test';
+ $eventTopic = 'cases/creation';
$caseId = 1;
$data = ['score' => 200, 'caseId' => $caseId];
@@ -205,7 +205,7 @@ public function testExecuteCaseUpdatingServiceException()
$webhookMessage = $this->getMockBuilder(WebhookMessage::class)
->disableOriginalConstructor()
->getMock();
- $webhookMessage->expects($this->once())
+ $webhookMessage->expects($this->exactly(2))
->method('getEventTopic')
->willReturn($eventTopic);
$webhookMessage->expects($this->once())
@@ -265,6 +265,37 @@ public function testExecuteRequestValidationFails()
$this->controller->execute();
}
+ /**
+ * Case when webhook request has test event topic.
+ */
+ public function testExecuteWithTestEventTopic()
+ {
+ $this->webhookRequestValidator->expects($this->once())
+ ->method('validate')
+ ->willReturn(true);
+ $this->redirect->expects($this->never())
+ ->method('redirect');
+
+ $webhookMessage = $this->getMockBuilder(WebhookMessage::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+ $webhookMessage->expects($this->once())
+ ->method('getEventTopic')
+ ->willReturn('cases/test');
+ $webhookMessage->expects($this->never())
+ ->method('getData');
+
+ $this->webhookMessageReader->expects($this->once())
+ ->method('read')
+ ->with($this->webhookRequest)
+ ->willReturn($webhookMessage);
+
+ $this->caseUpdatingServiceFactory->expects($this->never())
+ ->method('create');
+
+ $this->controller->execute();
+ }
+
/**
* Checks a test case when received input data does not contain Signifyd case id.
*
@@ -278,8 +309,10 @@ public function testExecuteWithMissedCaseId()
$webhookMessage = $this->getMockBuilder(WebhookMessage::class)
->disableOriginalConstructor()
- ->setMethods(['getData'])
->getMock();
+ $webhookMessage->expects($this->once())
+ ->method('getEventTopic')
+ ->willReturn('cases/creation');
$webhookMessage->expects(self::once())
->method('getData')
->willReturn([
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Controller/Webhooks/HandlerTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Controller/Webhooks/HandlerTest.php
index 26818a0a0c41a..e483328a680d7 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Controller/Webhooks/HandlerTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Controller/Webhooks/HandlerTest.php
@@ -71,6 +71,22 @@ public function testExecuteSuccess()
$this->_objectManager->removeSharedInstance(WebhookRequest::class);
}
+ /**
+ * Tests handling webhook message of cases/test type.
+ * Controller should response with code 200.
+ *
+ * @covers \Magento\Signifyd\Controller\Webhooks\Handler::execute
+ * @magentoConfigFixture current_store fraud_protection/signifyd/active 1
+ */
+ public function testExecuteTestSuccess()
+ {
+ $webhookRequest = $this->getTestWebhookRequest();
+ $this->_objectManager->addSharedInstance($webhookRequest, WebhookRequest::class);
+ $this->dispatch(self::$entryPoint);
+ $this->assertEquals(200, $this->getResponse()->getHttpResponseCode());
+ $this->_objectManager->removeSharedInstance(WebhookRequest::class);
+ }
+
/**
* Returns mocked WebhookRequest
*
@@ -93,4 +109,27 @@ private function getWebhookRequest()
return $webhookRequest;
}
+
+ /**
+ * Returns mocked test WebhookRequest
+ *
+ * @return WebhookRequest|\PHPUnit_Framework_MockObject_MockObject
+ */
+ private function getTestWebhookRequest()
+ {
+ $webhookRequest = $this->getMockBuilder(WebhookRequest::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+ $webhookRequest->expects($this->any())
+ ->method('getBody')
+ ->willReturn(file_get_contents(__DIR__ . '/../../_files/webhook_body.json'));
+ $webhookRequest->expects($this->any())
+ ->method('getEventTopic')
+ ->willReturn('cases/test');
+ $webhookRequest->expects($this->any())
+ ->method('getHash')
+ ->willReturn('wyG0r9mOmv1IqVlN6ZqJ5sgA635yKW6lbSsqlYF2b8U=');
+
+ return $webhookRequest;
+ }
}
From edea198792590f5255eeade43200e7054a6dc35b Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Fri, 10 Feb 2017 05:54:15 -0600
Subject: [PATCH 185/904] MAGETWO-64154: Rearrange Signifyd information table
in order view template
- always display fraud block when case entity for order is exists
(cherry picked from commit e785e77)
---
.../Signifyd/Block/Adminhtml/CaseInfo.php | 19 -------------------
.../view/adminhtml/templates/case_info.phtml | 2 +-
.../Signifyd/Block/Adminhtml/CaseInfoTest.php | 9 ++++++---
3 files changed, 7 insertions(+), 23 deletions(-)
diff --git a/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php b/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php
index 9aaf15ca4a688..43c138bb5150f 100644
--- a/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php
+++ b/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php
@@ -9,18 +9,12 @@
use Magento\Framework\View\Element\Template\Context;
use Magento\Signifyd\Api\Data\CaseInterface;
use Magento\Signifyd\Model\CaseManagement;
-use Magento\Signifyd\Model\Config;
/**
* Get Signifyd Case Info
*/
class CaseInfo extends Template
{
- /**
- * @var Config
- */
- private $config;
-
/**
* @var CaseInterface
*/
@@ -33,32 +27,19 @@ class CaseInfo extends Template
/**
* @param Context $context
- * @param Config $config
* @param CaseManagement $caseManagement
* @param array $data
*/
public function __construct(
Context $context,
- Config $config,
CaseManagement $caseManagement,
array $data = []
) {
- $this->config = $config;
$this->caseManagement = $caseManagement;
parent::__construct($context, $data);
}
- /**
- * Checks if service is enabled.
- *
- * @return boolean
- */
- public function isServiceActive()
- {
- return $this->config->isActive();
- }
-
/**
* Gets case entity associated with order id.
*
diff --git a/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml b/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml
index 6649ca8fcd2fe..fef28b05ebb8c 100644
--- a/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml
+++ b/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml
@@ -9,7 +9,7 @@
isServiceActive() || $block->isEmptyCase()) {
+ if ($block->isEmptyCase()) {
return '';
}
?>
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Block/Adminhtml/CaseInfoTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Block/Adminhtml/CaseInfoTest.php
index 95a24791e6911..1f55beea98a37 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Block/Adminhtml/CaseInfoTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Block/Adminhtml/CaseInfoTest.php
@@ -40,15 +40,18 @@ protected function setUp()
}
/**
- * Checks that block does not give contents
- * if Signifyd module is inactive.
+ * Checks that block has contents when case entity for order is exists
+ * even if Signifyd module is inactive.
*
* @magentoConfigFixture current_store fraud_protection/signifyd/active 0
+ * @magentoDataFixture Magento/Signifyd/_files/case.php
* @magentoAppArea adminhtml
*/
public function testModuleIsInactive()
{
- static::assertEmpty($this->getBlockContents());
+ $this->order->loadByIncrementId('100000001');
+
+ static::assertNotEmpty($this->getBlockContents());
}
/**
From b6b06aadda13add9c0b4aed1af4b96ec65ebc3b2 Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Tue, 14 Feb 2017 07:26:13 -0600
Subject: [PATCH 186/904] MAGETWO-63910: Create infrastructure for mapper in
Payment module
- Refactored code according to code review changes.
(cherry picked from commit 301b9c1)
---
.../Model/PaymentVerificationFactory.php | 9 ++--
app/code/Magento/Signifyd/README.md | 51 ++++++++++++++++++-
.../Model/PaymentVerificationFactoryTest.php | 2 +-
3 files changed, 57 insertions(+), 5 deletions(-)
diff --git a/app/code/Magento/Signifyd/Model/PaymentVerificationFactory.php b/app/code/Magento/Signifyd/Model/PaymentVerificationFactory.php
index b84fa43628c0f..3aa3c20669af2 100644
--- a/app/code/Magento/Signifyd/Model/PaymentVerificationFactory.php
+++ b/app/code/Magento/Signifyd/Model/PaymentVerificationFactory.php
@@ -8,6 +8,7 @@
use Magento\Framework\ObjectManagerInterface;
use Magento\Payment\Api\PaymentVerificationInterface;
use Magento\Payment\Gateway\ConfigInterface;
+use Magento\Framework\Exception\ConfigurationMismatchException;
/**
* Creates verification service for provided payment method, or PaymentVerificationInterface::class
@@ -82,13 +83,13 @@ public function createPaymentAvs($paymentCode)
/**
* Creates instance of PaymentVerificationInterface.
* Default implementation will be returned if payment method does not implement PaymentVerificationInterface.
- * Exception will be thrown if payment verification instance does not implement PaymentVerificationInterface.
*
* @param PaymentVerificationInterface $defaultAdapter
* @param string $paymentCode
* @param string $configKey
* @return PaymentVerificationInterface
- * @throws \Exception
+ * @throws ConfigurationMismatchException If payment verification instance
+ * does not implement PaymentVerificationInterface.
*/
private function create(PaymentVerificationInterface $defaultAdapter, $paymentCode, $configKey)
{
@@ -99,7 +100,9 @@ private function create(PaymentVerificationInterface $defaultAdapter, $paymentCo
}
$mapper = $this->objectManager->create($verificationClass);
if (!$mapper instanceof PaymentVerificationInterface) {
- throw new \Exception($verificationClass . ' must implement ' . PaymentVerificationInterface::class);
+ throw new ConfigurationMismatchException(
+ __('%1 must implement %2', $verificationClass, PaymentVerificationInterface::class)
+ );
}
return $mapper;
}
diff --git a/app/code/Magento/Signifyd/README.md b/app/code/Magento/Signifyd/README.md
index 5159d4c6951c4..fc869bfe106d8 100644
--- a/app/code/Magento/Signifyd/README.md
+++ b/app/code/Magento/Signifyd/README.md
@@ -1 +1,50 @@
-The Magento_Signifyd module implements the integration with the [Signifyd](https://www.signifyd.com/docs/api/) fraud prevention service.
+The Magento_Signifyd module provides integration with [Signifyd](https://www.signifyd.com/) fraud protection tool.
+
+#### Introduction
+
+Current implementation allows to create a [case](https://www.signifyd.com/docs/api/#/reference/cases) for the placed order,
+automatically retrieves [guarantee](https://www.signifyd.com/docs/api/#/reference/guarantees) for a created case and
+can cancel Signifyd guarantee on the order canceling.
+
+Magento integration uses Signifyd API and all needed technical details can be found in the [Signifyd API docs](https://www.signifyd.com/docs/api/#/introduction/).
+
+Magento_Signifyd module has extension points for 3d-party developers marked with `@api` annotation:
+
+ - `CaseInterface` - common absraction for a Signifyd case entity, provides methods to set or retrieve all case data fields.
+ - `CaseManagementInterface` - contains methods to create new case entity or retrieve existing for a specified order.
+ - `CaseCreationServiceInterface` - provides an ability to create case entity for a specified order and send request thru Signifyd API to create a new case.
+ - `CaseRepositoryInterface` - describes methods to work with case entity.
+ - `GuaranteeCreationServiceInterface` - allows to send request thru Signifyd API to create new case guarantee.
+ - `GuaranteeCancelingServiceInterface` - allows to send request thru Signifyd API to cancel Signifyd case guarantee.
+ - `CaseSearchResultsInterface` - might be used by `CaseRepositoryInterface` to retrieve list of case entities by specific
+conditions.
+
+To update case(guarantee) entity data Magento implementation uses [Signifyd Webhooks](https://www.signifyd.com/docs/api/#/reference/webhooks) mechanism.
+New created case entity will have `PENDING` status for a case and guarantee. After receiving Webhook, both statuses will be changed to appropriate Signifyd statuses.
+
+#### Customization
+
+Signifyd service collects a lof of different information related for order (all fields described in [API](https://www.signifyd.com/docs/api/#/reference/cases/create-a-case)),
+most of these fields are optional but some of them are required (like `avsResponseCode`, `cvvResponseCode`),
+so, for more accurate calculations,3d party integrations, like payment methods, might provide some additional details, like CVV/AVS response codes.
+
+The 3d party payment methods can implement `\Magento\Payment\Api\PaymentVerificationInterface` to provide AVS/CVV mapping
+from specific codes to [EMS standard](http://www.emsecommerce.net/avs_cvv2_response_codes.htm) and register these mappers in custom payment module `condig.xml` file.
+For example, the mappers registration might look similar to the next:
+
+```xml
+
+
+
+ CustomPaymentFacade
+ Custom Payment
+ ...
+ Magento\CustomPayment\Model\AvsEmsCodeMapper
+ Magento\CustomPayment\Model\CvvEmsCodeMapper
+
+
+
+```
+
+Described steps are enough to provide custom AVS/CVV mapping for custom payment integrations, everything else, like mapper initialization,
+will be provided by Magento Signifyd infrastructure.
\ No newline at end of file
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/PaymentVerificationFactoryTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/PaymentVerificationFactoryTest.php
index 4e335d5a35c95..6c4ffaf7c142e 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/PaymentVerificationFactoryTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/PaymentVerificationFactoryTest.php
@@ -138,7 +138,7 @@ public function testCreateDefaultCvvMapper()
* Checks a test case, when mapper implementation does not corresponding to PaymentVerificationInterface.
*
* @covers \Magento\Signifyd\Model\PaymentVerificationFactory::createPaymentCvv
- * @expectedException \Exception
+ * @expectedException \Magento\Framework\Exception\ConfigurationMismatchException
* @expectedExceptionMessage stdClass must implement Magento\Payment\Api\PaymentVerificationInterface
*/
public function testCreateWithUnsupportedImplementation()
From 8a75ae549e06ab92b0a037f707564b55400300e6 Mon Sep 17 00:00:00 2001
From: isavchuk
Date: Wed, 8 Feb 2017 07:56:17 -0600
Subject: [PATCH 187/904] MAGETWO-63912: Implement payment method code mapping
in Signifyd
- Added payments mapping config files
- Added config file handler
- Changed the PurchaseBuilder class
- Added an unit test
(cherry picked from commit 0d96778)
---
.../PaymentMethodMapper.php | 40 ++++++++
.../XmlToArrayConfigConverter.php | 81 ++++++++++++++++
.../Request/PurchaseBuilder.php | 21 ++++-
.../XmlToArrayConfigConverterTest.php | 76 +++++++++++++++
.../_files/expected_array.php | 13 +++
.../_files/signifyd_payment_mapping.xml | 32 +++++++
app/code/Magento/Signifyd/etc/di.xml | 24 +++++
.../Signifyd/etc/signifyd_payment_mapping.xml | 94 +++++++++++++++++++
.../Signifyd/etc/signifyd_payment_mapping.xsd | 27 ++++++
app/code/Magento/Signifyd/i18n/en_US.csv | 6 +-
10 files changed, 408 insertions(+), 6 deletions(-)
create mode 100644 app/code/Magento/Signifyd/Model/PaymentMethodMapper/PaymentMethodMapper.php
create mode 100644 app/code/Magento/Signifyd/Model/PaymentMethodMapper/XmlToArrayConfigConverter.php
create mode 100644 app/code/Magento/Signifyd/Test/Unit/Model/PaymentMethodMapper/XmlToArrayConfigConverterTest.php
create mode 100644 app/code/Magento/Signifyd/Test/Unit/Model/PaymentMethodMapper/_files/expected_array.php
create mode 100644 app/code/Magento/Signifyd/Test/Unit/Model/PaymentMethodMapper/_files/signifyd_payment_mapping.xml
create mode 100644 app/code/Magento/Signifyd/etc/signifyd_payment_mapping.xml
create mode 100644 app/code/Magento/Signifyd/etc/signifyd_payment_mapping.xsd
diff --git a/app/code/Magento/Signifyd/Model/PaymentMethodMapper/PaymentMethodMapper.php b/app/code/Magento/Signifyd/Model/PaymentMethodMapper/PaymentMethodMapper.php
new file mode 100644
index 0000000000000..48ba85c5da671
--- /dev/null
+++ b/app/code/Magento/Signifyd/Model/PaymentMethodMapper/PaymentMethodMapper.php
@@ -0,0 +1,40 @@
+paymentMethodMapping = $paymentMapping;
+ }
+
+ /**
+ * Gets the Sygnifyd payment method by the order's payment method.
+ *
+ * @param string $paymentMethod
+ * @return string
+ */
+ public function getSignifydPaymentMethodCode($paymentMethod)
+ {
+ return $this->paymentMethodMapping->get($paymentMethod, '');
+ }
+}
diff --git a/app/code/Magento/Signifyd/Model/PaymentMethodMapper/XmlToArrayConfigConverter.php b/app/code/Magento/Signifyd/Model/PaymentMethodMapper/XmlToArrayConfigConverter.php
new file mode 100644
index 0000000000000..6438c38ec58ab
--- /dev/null
+++ b/app/code/Magento/Signifyd/Model/PaymentMethodMapper/XmlToArrayConfigConverter.php
@@ -0,0 +1,81 @@
+getElementsByTagName('payment_method');
+ $paymentsList = [];
+ foreach ($paymentMethods as $paymentMethod) {
+ $paymentsList += $this->getPaymentMethodMapping($paymentMethod);
+ }
+
+ return $paymentsList;
+ }
+
+ /**
+ * Adds a payment method as key and a Sygnifyd payment method as value
+ * in the payment list array
+ *
+ * @param \DOMElement $payment
+ * @return array
+ * @throws ValidationSchemaException
+ */
+ private function getPaymentMethodMapping(\DOMElement $payment)
+ {
+ $paymentMethodCode = $this->readSubnodeValue($payment, self::$paymentMethodNodeType);
+ $signifyPaymentMethodCode = $this->readSubnodeValue($payment, self::$signifydPaymentMethodNodeType);
+
+ return [$paymentMethodCode => $signifyPaymentMethodCode];
+ }
+
+ /**
+ * Reads node value by node type
+ *
+ * @param \DOMElement $element
+ * @param string $subNodeType
+ * @return mixed
+ * @throws ValidationSchemaException
+ */
+ private function readSubnodeValue(\DOMElement $element, $subNodeType)
+ {
+ $domList = $element->getElementsByTagName($subNodeType);
+ if (empty($domList[0])) {
+ throw new ValidationSchemaException(__('Only single entrance of "%1" node is required.', $subNodeType));
+ }
+
+ $subNodeValue = $domList[0]->nodeValue;
+ if (!$subNodeValue) {
+ throw new ValidationSchemaException(__('Not empty value for "%1" node is required.', $subNodeType));
+ }
+
+ return $subNodeValue;
+ }
+}
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php
index 287ecdb84ca77..7fc729fab5b80 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php
@@ -12,6 +12,7 @@
use Magento\Sales\Model\Order;
use Magento\Signifyd\Model\PaymentVerificationFactory;
use Magento\Signifyd\Model\SignifydOrderSessionId;
+use Magento\Signifyd\Model\PaymentMethodMapper\PaymentMethodMapper;
/**
* Prepare data related to purchase event represented in case creation request.
@@ -39,21 +40,31 @@ class PurchaseBuilder
private $paymentVerificationFactory;
/**
- * @param DateTimeFactory $dateTimeFactory
- * @param ScopeInterface $scope
- * @param SignifydOrderSessionId $signifydOrderSessionId
+ * @var PaymentMethodMapper
+ */
+ private $paymentMethodMapper;
+
+ /**
+ * PurchaseBuilder constructor.
+ *
+ * @param DateTimeFactory $dateTimeFactory
+ * @param ScopeInterface $scope
+ * @param SignifydOrderSessionId $signifydOrderSessionId
* @param PaymentVerificationFactory $paymentVerificationFactory
+ * @param PaymentMethodMapper $paymentMethodMapper
*/
public function __construct(
DateTimeFactory $dateTimeFactory,
ScopeInterface $scope,
SignifydOrderSessionId $signifydOrderSessionId,
- PaymentVerificationFactory $paymentVerificationFactory
+ PaymentVerificationFactory $paymentVerificationFactory,
+ PaymentMethodMapper $paymentMethodMapper
) {
$this->dateTimeFactory = $dateTimeFactory;
$this->scope = $scope;
$this->signifydOrderSessionId = $signifydOrderSessionId;
$this->paymentVerificationFactory = $paymentVerificationFactory;
+ $this->paymentMethodMapper = $paymentMethodMapper;
}
/**
@@ -83,6 +94,8 @@ public function build(Order $order)
'cvvResponseCode' => $this->getCvvCode($orderPayment),
'orderChannel' => $this->getOrderChannel(),
'totalPrice' => $order->getGrandTotal(),
+ 'paymentMethod' => $this->paymentMethodMapper
+ ->getSignifydPaymentMethodCode($orderPayment->getMethod())
],
];
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/PaymentMethodMapper/XmlToArrayConfigConverterTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/PaymentMethodMapper/XmlToArrayConfigConverterTest.php
new file mode 100644
index 0000000000000..ec7a7986e2ee0
--- /dev/null
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/PaymentMethodMapper/XmlToArrayConfigConverterTest.php
@@ -0,0 +1,76 @@
+filePath = realpath(__DIR__) . '/_files/';
+
+ $objectManagerHelper = new ObjectManager($this);
+ $this->converter = $objectManagerHelper->getObject(
+ XmlToArrayConfigConverter::class
+ );
+ }
+
+ public function testConvert()
+ {
+ $testDom = $this->filePath . 'signifyd_payment_mapping.xml';
+ $dom = new \DOMDocument();
+ $dom->load($testDom);
+ $mapping = $this->converter->convert($dom);
+ $expectedArray = include $this->filePath . 'expected_array.php';
+
+ $this->assertEquals($expectedArray, $mapping);
+ }
+
+ /**
+ * @expectedException \Magento\Framework\Config\Dom\ValidationSchemaException
+ * @expectedExceptionMessage Only single entrance of "magento_code" node is required.
+ */
+ public function testConvertEmptyPaymentMethodException()
+ {
+ $dom = new \DOMDocument();
+ $element = $dom->createElement('payment_method');
+ $subelement = $dom->createElement('signifyd_code', 'test');
+ $element->appendChild($subelement);
+ $dom->appendChild($element);
+
+ $this->converter->convert($dom);
+ }
+
+ /**
+ * @expectedException \Magento\Framework\Config\Dom\ValidationSchemaException
+ * @expectedExceptionMessage Not empty value for "signifyd_code" node is required.
+ */
+ public function testConvertEmptySygnifydPaymentMethodException()
+ {
+ $dom = new \DOMDocument();
+ $element = $dom->createElement('payment_method');
+ $subelement = $dom->createElement('magento_code', 'test');
+ $subelement2 = $dom->createElement('signifyd_code', '');
+ $element->appendChild($subelement);
+ $element->appendChild($subelement2);
+ $dom->appendChild($element);
+
+ $this->converter->convert($dom);
+ }
+}
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/PaymentMethodMapper/_files/expected_array.php b/app/code/Magento/Signifyd/Test/Unit/Model/PaymentMethodMapper/_files/expected_array.php
new file mode 100644
index 0000000000000..0578513ab228e
--- /dev/null
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/PaymentMethodMapper/_files/expected_array.php
@@ -0,0 +1,13 @@
+ 'PAYMENT_CARD',
+ 'payment_method_2' => 'PAYPAL_ACCOUNT',
+ 'payment_method_2' => 'PAYPAL_ACCOUNT',
+ 'payment_method_3' => 'CHECK',
+ 'payment_method_4' => 'CASH',
+ 'payment_method_5' => 'FREE'
+];
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/PaymentMethodMapper/_files/signifyd_payment_mapping.xml b/app/code/Magento/Signifyd/Test/Unit/Model/PaymentMethodMapper/_files/signifyd_payment_mapping.xml
new file mode 100644
index 0000000000000..d18eefbae718d
--- /dev/null
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/PaymentMethodMapper/_files/signifyd_payment_mapping.xml
@@ -0,0 +1,32 @@
+
+
+
+
+
+ payment_method_1
+ PAYMENT_CARD
+
+
+ payment_method_2
+ PAYPAL_ACCOUNT
+
+
+ payment_method_3
+ CHECK
+
+
+ payment_method_4
+ CASH
+
+
+ payment_method_5
+ FREE
+
+
+
diff --git a/app/code/Magento/Signifyd/etc/di.xml b/app/code/Magento/Signifyd/etc/di.xml
index 6bf80d12402fc..9e042ef797529 100644
--- a/app/code/Magento/Signifyd/etc/di.xml
+++ b/app/code/Magento/Signifyd/etc/di.xml
@@ -82,4 +82,28 @@
+
+
+ Magento_Signifyd
+ signifyd_payment_mapping.xsd
+
+
+
+
+ Magento\Signifyd\Model\PaymentMethodMapper\XmlToArrayConfigConverter
+ paymentMapperSchemaLocator
+ signifyd_payment_mapping.xml
+
+
+
+
+ PaymentMapperConfigReader
+ signifyd_payment_list_cache
+
+
+
+
+ PaymentMethodConfigData
+
+
diff --git a/app/code/Magento/Signifyd/etc/signifyd_payment_mapping.xml b/app/code/Magento/Signifyd/etc/signifyd_payment_mapping.xml
new file mode 100644
index 0000000000000..c23ed024a7fa5
--- /dev/null
+++ b/app/code/Magento/Signifyd/etc/signifyd_payment_mapping.xml
@@ -0,0 +1,94 @@
+
+
+
+
+
+ braintree
+ PAYMENT_CARD
+
+
+ braintree_paypal
+ PAYPAL_ACCOUNT
+
+
+ paypal_express
+ PAYPAL_ACCOUNT
+
+
+ paypal_express_bml
+ PAYPAL_ACCOUNT
+
+
+ payflow_express
+ PAYPAL_ACCOUNT
+
+
+ payflow_express_bml
+ PAYPAL_ACCOUNT
+
+
+ payflowpro
+ PAYMENT_CARD
+
+
+ payflow_link
+ PAYMENT_CARD
+
+
+ payflow_advanced
+ PAYMENT_CARD
+
+
+ hosted_pro
+ PAYMENT_CARD
+
+
+ authorizenet_directpost
+ PAYMENT_CARD
+
+
+ worldpay
+ PAYMENT_CARD
+
+
+ eway
+ PAYMENT_CARD
+
+
+ cybersource
+ PAYMENT_CARD
+
+
+ checkmo
+ CHECK
+
+
+ banktransfer
+ CHECK
+
+
+ cashondelivery
+ CASH
+
+
+ free
+ FREE
+
+
+
diff --git a/app/code/Magento/Signifyd/etc/signifyd_payment_mapping.xsd b/app/code/Magento/Signifyd/etc/signifyd_payment_mapping.xsd
new file mode 100644
index 0000000000000..cd8aa93b7aa2a
--- /dev/null
+++ b/app/code/Magento/Signifyd/etc/signifyd_payment_mapping.xsd
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Signifyd/i18n/en_US.csv b/app/code/Magento/Signifyd/i18n/en_US.csv
index 97d9475048932..e595bcbc89bdb 100644
--- a/app/code/Magento/Signifyd/i18n/en_US.csv
+++ b/app/code/Magento/Signifyd/i18n/en_US.csv
@@ -22,5 +22,7 @@
"Sorry, we cannot submit order for Guarantee.","Sorry, we cannot submit order for Guarantee."
"Order id is required.","Order id is required."
"The case entity should not be empty.","The case entity should not be empty."
-"Guarantee has been cancelled for order.","Guarantee has been cancelled for order."
-"Sorry, we cannot cancel Guarantee for order.","Sorry, we cannot cancel Guarantee for order."
\ No newline at end of file
+"Guarantee has been cancelled for your order.","Guarantee has been cancelled for your order."
+"Sorry, we cannot cancel Guarantee for order.","Sorry, we cannot cancel Guarantee for order."
+"Not empty value for "%1" node is required."
+"Only single entrance of "%1" node is required."
\ No newline at end of file
From 97ca9d696d148e59056e3c838893b22267b6623b Mon Sep 17 00:00:00 2001
From: isavchuk
Date: Tue, 14 Feb 2017 10:22:57 -0600
Subject: [PATCH 188/904] MAGETWO-63638: Sending all order to Signifyd for
guarantee automatically
- Fixed xsd schema
---
app/code/Magento/Signifyd/etc/signifyd_payment_mapping.xml | 2 +-
app/code/Magento/Signifyd/etc/signifyd_payment_mapping.xsd | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/app/code/Magento/Signifyd/etc/signifyd_payment_mapping.xml b/app/code/Magento/Signifyd/etc/signifyd_payment_mapping.xml
index c23ed024a7fa5..c6016ce7fddaf 100644
--- a/app/code/Magento/Signifyd/etc/signifyd_payment_mapping.xml
+++ b/app/code/Magento/Signifyd/etc/signifyd_payment_mapping.xml
@@ -16,7 +16,7 @@
*/
-->
+ xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Signifyd:etc/signifyd_payment_mapping.xsd">
braintree
diff --git a/app/code/Magento/Signifyd/etc/signifyd_payment_mapping.xsd b/app/code/Magento/Signifyd/etc/signifyd_payment_mapping.xsd
index cd8aa93b7aa2a..abbf5879b7bc8 100644
--- a/app/code/Magento/Signifyd/etc/signifyd_payment_mapping.xsd
+++ b/app/code/Magento/Signifyd/etc/signifyd_payment_mapping.xsd
@@ -9,7 +9,7 @@
-
+
From d935d549213d9c6951e58e22f9ba9855df75d80b Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Tue, 14 Feb 2017 11:27:57 -0600
Subject: [PATCH 189/904] MAGETWO-63923: Create documentation for Signifyd
extension points
- Added info about Signifyd payment methods mapping customization
(cherry picked from commit 131301d)
---
app/code/Magento/Signifyd/README.md | 23 ++++++++++++++++++++++-
1 file changed, 22 insertions(+), 1 deletion(-)
diff --git a/app/code/Magento/Signifyd/README.md b/app/code/Magento/Signifyd/README.md
index fc869bfe106d8..5d1c0510ba671 100644
--- a/app/code/Magento/Signifyd/README.md
+++ b/app/code/Magento/Signifyd/README.md
@@ -47,4 +47,25 @@ For example, the mappers registration might look similar to the next:
```
Described steps are enough to provide custom AVS/CVV mapping for custom payment integrations, everything else, like mapper initialization,
-will be provided by Magento Signifyd infrastructure.
\ No newline at end of file
+will be provided by Magento Signifyd infrastructure.
+
+Also, Signifyd can retrieve payment method for a placed order (Magento Signifyd module implementation contains
+predefined list of mapped Magento payment method codes to Signifyd payment codes, this mapping located in `Magento\Signifyd\etc\signifyd_payment_mapping.xml` file).
+The 3d party payment integrations can add own mapping for [Signifyd payment codes](https://www.signifyd.com/docs/api/#/reference/cases/create-a-case),
+it's enough to add `signifyd_payment_mapping.xml` to custom payment method implementation and specify needed mapping.
+For example, it might look like this:
+
+```xml
+
+
+
+ custom_payment_code
+ PAYMENT_CARD
+
+
+
+```
+
+ - `magento_code` attribute value should be code for a custom payment method (the same as in the payment `config.xml`).
+ - `signifyd_code` attribute value should be one of available Signifyd payment method codes.
\ No newline at end of file
From 581288bc9f894ebd17b216869d61869d016d20ae Mon Sep 17 00:00:00 2001
From: isavchuk
Date: Wed, 15 Feb 2017 02:28:00 -0600
Subject: [PATCH 190/904] MAGETWO-63638: Sending all order to Signifyd for
guarantee automatically
- Fixed the integration test
- Code refactoring
(cherry picked from commit b13ef44)
---
app/code/Magento/Signifyd/etc/di.xml | 4 ++--
app/code/Magento/Signifyd/i18n/en_US.csv | 4 ++--
.../Model/SignifydGateway/Request/CreateCaseBuilderTest.php | 6 ++++--
3 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/app/code/Magento/Signifyd/etc/di.xml b/app/code/Magento/Signifyd/etc/di.xml
index 9e042ef797529..e873548ed26ba 100644
--- a/app/code/Magento/Signifyd/etc/di.xml
+++ b/app/code/Magento/Signifyd/etc/di.xml
@@ -82,7 +82,7 @@
-
+
Magento_Signifyd
signifyd_payment_mapping.xsd
@@ -91,7 +91,7 @@
Magento\Signifyd\Model\PaymentMethodMapper\XmlToArrayConfigConverter
- paymentMapperSchemaLocator
+ PaymentMapperSchemaLocator
signifyd_payment_mapping.xml
diff --git a/app/code/Magento/Signifyd/i18n/en_US.csv b/app/code/Magento/Signifyd/i18n/en_US.csv
index e595bcbc89bdb..188419e33ac76 100644
--- a/app/code/Magento/Signifyd/i18n/en_US.csv
+++ b/app/code/Magento/Signifyd/i18n/en_US.csv
@@ -24,5 +24,5 @@
"The case entity should not be empty.","The case entity should not be empty."
"Guarantee has been cancelled for your order.","Guarantee has been cancelled for your order."
"Sorry, we cannot cancel Guarantee for order.","Sorry, we cannot cancel Guarantee for order."
-"Not empty value for "%1" node is required."
-"Only single entrance of "%1" node is required."
\ No newline at end of file
+"Not empty value for "%1" node is required.","Not empty value for "%1" node is required."
+"Only single entrance of "%1" node is required.","Only single entrance of "%1" node is required."
\ No newline at end of file
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
index 066e493dc0f01..2c9bd2c456c64 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
@@ -115,7 +115,8 @@ public function testCreateCaseBuilderWithFullSetOfData()
'itemUrl' => $product->getProductUrl(),
'itemWeight' => $product->getWeight()
]
- ]
+ ],
+ 'paymentMethod' => 'PAYPAL_ACCOUNT'
],
'card' => [
'cardHolderName' => 'firstname lastname',
@@ -215,7 +216,8 @@ public function testCreateCaseBuilderWithVirtualProductAndGuest()
'itemQuantity' => $orderItems[0]->getQtyOrdered(),
'itemUrl' => $product->getProductUrl()
],
- ]
+ ],
+ 'paymentMethod' => 'PAYPAL_ACCOUNT'
],
'card' => [
'cardHolderName' => 'firstname lastname',
From 449b5867aa8d846278a05250762d194313c3f31d Mon Sep 17 00:00:00 2001
From: isavchuk
Date: Wed, 15 Feb 2017 04:15:04 -0600
Subject: [PATCH 191/904] MAGETWO-63638: Sending all order to Signifyd for
guarantee automatically
- Fixed integration test
(cherry picked from commit b742954)
---
.../Model/SignifydGateway/Request/CreateCaseBuilderTest.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
index 2c9bd2c456c64..0147792ba1f0b 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
@@ -217,7 +217,7 @@ public function testCreateCaseBuilderWithVirtualProductAndGuest()
'itemUrl' => $product->getProductUrl()
],
],
- 'paymentMethod' => 'PAYPAL_ACCOUNT'
+ 'paymentMethod' => 'PAYMENT_CARD'
],
'card' => [
'cardHolderName' => 'firstname lastname',
From eb1a69c1ff928118fead3e05d4d7788fd08fd468 Mon Sep 17 00:00:00 2001
From: isavchuk
Date: Wed, 15 Feb 2017 09:16:30 -0600
Subject: [PATCH 192/904] MAGETWO-63638: Sending all order to Signifyd for
guarantee automatically
- Code refactoring
(cherry picked from commit fee1b9c)
---
.../XmlToArrayConfigConverter.php | 23 ++++++++++++-------
1 file changed, 15 insertions(+), 8 deletions(-)
diff --git a/app/code/Magento/Signifyd/Model/PaymentMethodMapper/XmlToArrayConfigConverter.php b/app/code/Magento/Signifyd/Model/PaymentMethodMapper/XmlToArrayConfigConverter.php
index 6438c38ec58ab..31ebbe6835e37 100644
--- a/app/code/Magento/Signifyd/Model/PaymentMethodMapper/XmlToArrayConfigConverter.php
+++ b/app/code/Magento/Signifyd/Model/PaymentMethodMapper/XmlToArrayConfigConverter.php
@@ -13,25 +13,32 @@
class XmlToArrayConfigConverter implements \Magento\Framework\Config\ConverterInterface
{
/**
- * Node type for payment methods
+ * Node type wrapper for magento and signifyd payment codes
*
* @var string
*/
- private static $paymentMethodNodeType = 'magento_code';
+ private static $paymentMethodNodeType = 'payment_method';
/**
- * Node type for Sygnifyd payment methods
+ * Node type for payment methods code
*
* @var string
*/
- private static $signifydPaymentMethodNodeType = 'signifyd_code';
+ private static $magentoCodeNodeType = 'magento_code';
+
+ /**
+ * Node type for Sygnifyd payment methods code
+ *
+ * @var string
+ */
+ private static $signifydCodeNodeType = 'signifyd_code';
/**
* @inheritdoc
*/
public function convert($source)
{
- $paymentMethods = $source->getElementsByTagName('payment_method');
+ $paymentMethods = $source->getElementsByTagName(self::$paymentMethodNodeType);
$paymentsList = [];
foreach ($paymentMethods as $paymentMethod) {
$paymentsList += $this->getPaymentMethodMapping($paymentMethod);
@@ -50,8 +57,8 @@ public function convert($source)
*/
private function getPaymentMethodMapping(\DOMElement $payment)
{
- $paymentMethodCode = $this->readSubnodeValue($payment, self::$paymentMethodNodeType);
- $signifyPaymentMethodCode = $this->readSubnodeValue($payment, self::$signifydPaymentMethodNodeType);
+ $paymentMethodCode = $this->readSubnodeValue($payment, self::$magentoCodeNodeType);
+ $signifyPaymentMethodCode = $this->readSubnodeValue($payment, self::$signifydCodeNodeType);
return [$paymentMethodCode => $signifyPaymentMethodCode];
}
@@ -71,7 +78,7 @@ private function readSubnodeValue(\DOMElement $element, $subNodeType)
throw new ValidationSchemaException(__('Only single entrance of "%1" node is required.', $subNodeType));
}
- $subNodeValue = $domList[0]->nodeValue;
+ $subNodeValue = trim($domList[0]->nodeValue);
if (!$subNodeValue) {
throw new ValidationSchemaException(__('Not empty value for "%1" node is required.', $subNodeType));
}
From 8ffa123a5547f7f79ddda420c66b24e6413e808d Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Wed, 15 Feb 2017 09:36:50 -0600
Subject: [PATCH 193/904] MAGETWO-63923: Create documentation for Signifyd
extension points
- Updated Readme file
(cherry picked from commit 0740544)
---
app/code/Magento/Signifyd/README.md | 67 ++++++++++++++++-------------
1 file changed, 36 insertions(+), 31 deletions(-)
diff --git a/app/code/Magento/Signifyd/README.md b/app/code/Magento/Signifyd/README.md
index 5d1c0510ba671..6ade95e78c2a5 100644
--- a/app/code/Magento/Signifyd/README.md
+++ b/app/code/Magento/Signifyd/README.md
@@ -1,36 +1,41 @@
-The Magento_Signifyd module provides integration with [Signifyd](https://www.signifyd.com/) fraud protection tool.
+# The Magento Signifyd module overview
-#### Introduction
+The Magento_Signifyd module provides integration with the [Signifyd](https://www.signifyd.com/) fraud protection tool.
-Current implementation allows to create a [case](https://www.signifyd.com/docs/api/#/reference/cases) for the placed order,
-automatically retrieves [guarantee](https://www.signifyd.com/docs/api/#/reference/guarantees) for a created case and
-can cancel Signifyd guarantee on the order canceling.
+## Introduction
-Magento integration uses Signifyd API and all needed technical details can be found in the [Signifyd API docs](https://www.signifyd.com/docs/api/#/introduction/).
+The module implementation allows to:
-Magento_Signifyd module has extension points for 3d-party developers marked with `@api` annotation:
+ - create the Signifyd [case](https://www.signifyd.com/docs/api/#/reference/cases) for a placed order
+ - automatically receive the Signifyd [guarantee](https://www.signifyd.com/docs/api/#/reference/guarantees) for a created case
+ - automatically cancel a guarantee when the order is canceled.
- - `CaseInterface` - common absraction for a Signifyd case entity, provides methods to set or retrieve all case data fields.
- - `CaseManagementInterface` - contains methods to create new case entity or retrieve existing for a specified order.
- - `CaseCreationServiceInterface` - provides an ability to create case entity for a specified order and send request thru Signifyd API to create a new case.
- - `CaseRepositoryInterface` - describes methods to work with case entity.
- - `GuaranteeCreationServiceInterface` - allows to send request thru Signifyd API to create new case guarantee.
- - `GuaranteeCancelingServiceInterface` - allows to send request thru Signifyd API to cancel Signifyd case guarantee.
- - `CaseSearchResultsInterface` - might be used by `CaseRepositoryInterface` to retrieve list of case entities by specific
+Magento integration uses the Signifyd API; see the [Signifyd API docs](https://www.signifyd.com/docs/api/#/introduction/) for technical details.
+
+For external developers, the module contains these extension points (marked with `@api` annotation):
+
+ - `CaseInterface` - common absraction for the Signifyd case entity, provides methods to set or retrieve all case data fields.
+ - `CaseManagementInterface` - contains methods to create a new case entity or retrieve existing for a specified order.
+ - `CaseCreationServiceInterface` - provides an ability to create case entity for a specified order and send request through the Signifyd API to create a new case.
+ - `CaseRepositoryInterface` - describes methods to work with a case entity.
+ - `GuaranteeCreationServiceInterface` - allows to send request through the Signifyd API to create a new case guarantee.
+ - `GuaranteeCancelingServiceInterface` - allows to send request through the Signifyd API to cancel the Signifyd case guarantee.
+ - `CaseSearchResultsInterface` - might be used by `CaseRepositoryInterface` to retrieve a list of case entities by specific
conditions.
-To update case(guarantee) entity data Magento implementation uses [Signifyd Webhooks](https://www.signifyd.com/docs/api/#/reference/webhooks) mechanism.
-New created case entity will have `PENDING` status for a case and guarantee. After receiving Webhook, both statuses will be changed to appropriate Signifyd statuses.
+To update entity data for a case or guarantee this module uses the [Signifyd Webhooks](https://www.signifyd.com/docs/api/#/reference/webhooks) mechanism.
+Newly created case entity will have `PENDING` status for a case and guarantee. After receiving Webhook, both statuses will be changed to appropriate Signifyd statuses.
-#### Customization
+## Customization
-Signifyd service collects a lof of different information related for order (all fields described in [API](https://www.signifyd.com/docs/api/#/reference/cases/create-a-case)),
-most of these fields are optional but some of them are required (like `avsResponseCode`, `cvvResponseCode`),
-so, for more accurate calculations,3d party integrations, like payment methods, might provide some additional details, like CVV/AVS response codes.
+The Signifyd service collects a lot of information about an order (all fields described in [API](https://www.signifyd.com/docs/api/#/reference/cases/create-a-case)),
+most of these fields are optional but some of them are required (like `avsResponseCode`, `cvvResponseCode`).
+So, for more accurate calculations, external integrations, like payment methods, might provide some additional details, like CVV/AVS response codes.
-The 3d party payment methods can implement `\Magento\Payment\Api\PaymentVerificationInterface` to provide AVS/CVV mapping
-from specific codes to [EMS standard](http://www.emsecommerce.net/avs_cvv2_response_codes.htm) and register these mappers in custom payment module `condig.xml` file.
-For example, the mappers registration might look similar to the next:
+The custom payment methods can implement `\Magento\Payment\Api\PaymentVerificationInterface` to provide AVS/CVV mapping
+from specific codes to [EMS standard](http://www.emsecommerce.net/avs_cvv2_response_codes.htm) and register these mappers in the `condig.xml` file
+of a custom payment module.
+For example, the mappers registration might look like this:
```xml
@@ -46,14 +51,14 @@ For example, the mappers registration might look similar to the next:
```
-Described steps are enough to provide custom AVS/CVV mapping for custom payment integrations, everything else, like mapper initialization,
-will be provided by Magento Signifyd infrastructure.
+These steps are enough to provide custom AVS/CVV mapping for payment integrations, everything else, like mapper initialization,
+will be provided by the Magento Signifyd infrastructure.
-Also, Signifyd can retrieve payment method for a placed order (Magento Signifyd module implementation contains
-predefined list of mapped Magento payment method codes to Signifyd payment codes, this mapping located in `Magento\Signifyd\etc\signifyd_payment_mapping.xml` file).
-The 3d party payment integrations can add own mapping for [Signifyd payment codes](https://www.signifyd.com/docs/api/#/reference/cases/create-a-case),
+Also, Signifyd can retrieve payment method for a placed order (the Magento Signifyd module can map Magento and Signifyd
+payment codes using the predefined XML list, located in `Magento\Signifyd\etc\signifyd_payment_mapping.xml` file).
+The 3rd-party payment integrations can apply own mappings for the [Signifyd payment codes](https://www.signifyd.com/docs/api/#/reference/cases/create-a-case),
it's enough to add `signifyd_payment_mapping.xml` to custom payment method implementation and specify needed mapping.
-For example, it might look like this:
+For example:
```xml
```
- - `magento_code` attribute value should be code for a custom payment method (the same as in the payment `config.xml`).
- - `signifyd_code` attribute value should be one of available Signifyd payment method codes.
\ No newline at end of file
+ - `magento_code` attribute value should be the code for a custom payment method (the same as in the payment's `config.xml`).
+ - `signifyd_code` attribute value should be one of available the Signifyd payment method codes.
\ No newline at end of file
From 7f277da56e908f398d35866e2623a7873003efde Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Wed, 15 Feb 2017 10:09:41 -0600
Subject: [PATCH 194/904] MAGETWO-63640: View Signifyd Guarantee Status in
Order Grid
- Order grid sync after case creation
---
.../Model/CaseServices/CreationService.php | 12 ++++++++-
.../CaseServices/CreationServiceTest.php | 26 +++++++++++++++++++
2 files changed, 37 insertions(+), 1 deletion(-)
diff --git a/app/code/Magento/Signifyd/Model/CaseServices/CreationService.php b/app/code/Magento/Signifyd/Model/CaseServices/CreationService.php
index 19a8f17bf5bb5..510cf8ff9e7e7 100644
--- a/app/code/Magento/Signifyd/Model/CaseServices/CreationService.php
+++ b/app/code/Magento/Signifyd/Model/CaseServices/CreationService.php
@@ -8,6 +8,7 @@
use Magento\Signifyd\Api\CaseCreationServiceInterface;
use Magento\Signifyd\Api\CaseManagementInterface;
use Magento\Signifyd\Api\CaseRepositoryInterface;
+use Magento\Signifyd\Model\SalesOrderGrid\OrderGridUpdater;
use Magento\Signifyd\Model\SignifydGateway\Gateway;
use Magento\Signifyd\Model\SignifydGateway\GatewayException;
use Psr\Log\LoggerInterface;
@@ -39,6 +40,11 @@ class CreationService implements CaseCreationServiceInterface
*/
private $caseRepository;
+ /**
+ * @var OrderGridUpdater
+ */
+ private $orderGridUpdater;
+
/**
* CreationService constructor.
*
@@ -46,17 +52,20 @@ class CreationService implements CaseCreationServiceInterface
* @param Gateway $signifydGateway
* @param LoggerInterface $logger
* @param CaseRepositoryInterface $caseRepository
+ * @param OrderGridUpdater $orderGridUpdater
*/
public function __construct(
CaseManagementInterface $caseManagement,
Gateway $signifydGateway,
LoggerInterface $logger,
- CaseRepositoryInterface $caseRepository
+ CaseRepositoryInterface $caseRepository,
+ OrderGridUpdater $orderGridUpdater
) {
$this->caseManagement = $caseManagement;
$this->signifydGateway = $signifydGateway;
$this->logger = $logger;
$this->caseRepository = $caseRepository;
+ $this->orderGridUpdater = $orderGridUpdater;
}
/**
@@ -65,6 +74,7 @@ public function __construct(
public function createForOrder($orderId)
{
$case = $this->caseManagement->create($orderId);
+ $this->orderGridUpdater->update($orderId);
try {
$caseId = $this->signifydGateway->createCase($orderId);
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseServices/CreationServiceTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseServices/CreationServiceTest.php
index 8f4cc6d188245..d779e98ebd034 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseServices/CreationServiceTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseServices/CreationServiceTest.php
@@ -175,9 +175,15 @@ public function testCreateForOrder()
/** @var CaseRepositoryInterface $caseRepository */
$caseRepository = $this->objectManager->get(CaseRepositoryInterface::class);
$caseEntity = $caseRepository->getByCaseId(123123);
+ $gridGuarantyStatus = $this->getOrderGridGuarantyStatus($caseEntity->getOrderId());
static::assertNotEmpty($caseEntity);
static::assertEquals($order->getEntityId(), $caseEntity->getOrderId());
+ static::assertEquals(
+ $gridGuarantyStatus,
+ $caseEntity->getGuaranteeDisposition(),
+ 'Signifyd guaranty status in sales_order_grid table does not match case entity guaranty status'
+ );
}
/**
@@ -210,4 +216,24 @@ private function getOrder()
return $this->order;
}
+
+ /**
+ * Returns value of signifyd_guarantee_status column from sales order grid
+ *
+ * @param int $orderEntityId
+ * @return string|null
+ */
+ private function getOrderGridGuarantyStatus($orderEntityId)
+ {
+ /** @var \Magento\Sales\Model\ResourceModel\Order\Grid\Collection $orderGridCollection */
+ $orderGridCollection = $this->objectManager->get(
+ \Magento\Sales\Model\ResourceModel\Order\Grid\Collection::class
+ );
+
+ $items = $orderGridCollection->addFilter($orderGridCollection->getIdFieldName(), $orderEntityId)
+ ->getItems();
+ $result = array_pop($items);
+
+ return isset($result['signifyd_guarantee_status']) ? $result['signifyd_guarantee_status'] : null;
+ }
}
From a876cd3fd60b2d2d7059a2c86ef8b6602d26068a Mon Sep 17 00:00:00 2001
From: isavchuk
Date: Fri, 17 Feb 2017 07:35:56 -0600
Subject: [PATCH 195/904] MAGETWO-63638: Sending all order to Signifyd for
guarantee automatically
- Fixed a comment
(cherry picked from commit 03d0671)
---
.../Signifyd/etc/signifyd_payment_mapping.xml | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/app/code/Magento/Signifyd/etc/signifyd_payment_mapping.xml b/app/code/Magento/Signifyd/etc/signifyd_payment_mapping.xml
index c6016ce7fddaf..cafea60dd2d79 100644
--- a/app/code/Magento/Signifyd/etc/signifyd_payment_mapping.xml
+++ b/app/code/Magento/Signifyd/etc/signifyd_payment_mapping.xml
@@ -5,12 +5,12 @@
* See COPYING.txt for license details.
*/
/**
- * Custom payment method might adds a block in payment_list e.g.
- *
- * custom_payment_method
- * PAYMENT_CARD
- *
- * Appropriate value for the tag from Signifyd documentation:
+ * Custom payment method might adds a block in payment_method_list e.g.
+ *
+ * custom_payment_method
+ * PAYMENT_CARD
+ *
+ * Appropriate value for the tag from Signifyd documentation:
* @see https://www.signifyd.com/docs/api/#/reference/webhooks/manage-single-webhooks/create-a-case
* Create a Case -> Request -> ATTRIBUTES -> paymentMethod
*/
From a0c0abd87807e51960b79a531f4649bce0c7a80e Mon Sep 17 00:00:00 2001
From: Dmytro Yushkin
Date: Wed, 1 Mar 2017 07:02:54 -0600
Subject: [PATCH 196/904] MAGETWO-63851: Re-implement cancel guarantee
mechanism
- Removed some guarantee cancel checks
(cherry picked from commit 4592a64)
---
.../Guarantee/CancelGuaranteeAbility.php | 6 +--
.../Guarantee/CancelGuaranteeAbilityTest.php | 48 +------------------
.../Model/Guarantee/CancelingServiceTest.php | 25 ----------
3 files changed, 2 insertions(+), 77 deletions(-)
diff --git a/app/code/Magento/Signifyd/Model/Guarantee/CancelGuaranteeAbility.php b/app/code/Magento/Signifyd/Model/Guarantee/CancelGuaranteeAbility.php
index c5e0561735218..2908914ef3bf7 100644
--- a/app/code/Magento/Signifyd/Model/Guarantee/CancelGuaranteeAbility.php
+++ b/app/code/Magento/Signifyd/Model/Guarantee/CancelGuaranteeAbility.php
@@ -51,11 +51,7 @@ public function isAvailable($orderId)
return false;
}
- if ($case->isGuaranteeEligible() !== false) {
- return false;
- }
-
- if (in_array($case->getGuaranteeDisposition(), [null, $case::GUARANTEE_DECLINED, $case::GUARANTEE_CANCELED])) {
+ if (in_array($case->getGuaranteeDisposition(), [null, $case::GUARANTEE_CANCELED])) {
return false;
}
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CancelGuaranteeAbilityTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CancelGuaranteeAbilityTest.php
index 00b6910a71a70..280f54e7aa5d3 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CancelGuaranteeAbilityTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CancelGuaranteeAbilityTest.php
@@ -63,10 +63,6 @@ public function testIsAvailableSuccess()
->disableOriginalConstructor()
->getMock();
- $case->expects($this->once())
- ->method('isGuaranteeEligible')
- ->willReturn(false);
-
$case->expects($this->once())
->method('getGuaranteeDisposition')
->willReturn(CaseEntity::GUARANTEE_APPROVED);
@@ -103,40 +99,6 @@ public function testIsAvailableWithNullCase()
$this->assertFalse($this->cancelGuaranteeAbility->isAvailable($orderId));
}
- /**
- * Tests case when GuaranteeEligible for Case is true or null
- *
- * @param mixed $guaranteeEligible
- * @dataProvider isAvailableWithGuarantyIsEligibleDataProvider
- */
- public function testIsAvailableWithGuarantyIsEligible($guaranteeEligible)
- {
- $orderId = 123;
-
- /** @var CaseInterface|\PHPUnit_Framework_MockObject_MockObject $case */
- $case = $this->getMockBuilder(CaseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
-
- $case->expects($this->once())
- ->method('isGuaranteeEligible')
- ->willReturn($guaranteeEligible);
-
- $this->caseManagement->expects($this->once())
- ->method('getByOrderId')
- ->with($orderId)
- ->willReturn($case);
-
- $this->assertFalse($this->cancelGuaranteeAbility->isAvailable($orderId));
- }
-
- public function isAvailableWithGuarantyIsEligibleDataProvider()
- {
- return [
- [null], [true]
- ];
- }
-
/**
* Tests case when Guarantee Disposition has Declined or Canceled states.
*
@@ -152,10 +114,6 @@ public function testIsAvailableWithCanceledGuarantee($guaranteeDisposition)
->disableOriginalConstructor()
->getMock();
- $case->expects($this->once())
- ->method('isGuaranteeEligible')
- ->willReturn(false);
-
$case->expects($this->once())
->method('getGuaranteeDisposition')
->willReturn($guaranteeDisposition);
@@ -171,7 +129,7 @@ public function testIsAvailableWithCanceledGuarantee($guaranteeDisposition)
public function isAvailableWithCanceledGuaranteeDataProvider()
{
return [
- [CaseEntity::GUARANTEE_DECLINED], [CaseEntity::GUARANTEE_CANCELED]
+ [CaseEntity::GUARANTEE_CANCELED]
];
}
@@ -187,10 +145,6 @@ public function testIsAvailableWithNullOrder()
->disableOriginalConstructor()
->getMock();
- $case->expects($this->once())
- ->method('isGuaranteeEligible')
- ->willReturn(false);
-
$case->expects($this->once())
->method('getGuaranteeDisposition')
->willReturn(CaseEntity::GUARANTEE_APPROVED);
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Model/Guarantee/CancelingServiceTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Model/Guarantee/CancelingServiceTest.php
index 1ccf347f6f33f..054c8c50598ba 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Model/Guarantee/CancelingServiceTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/Guarantee/CancelingServiceTest.php
@@ -65,31 +65,6 @@ protected function setUp()
]);
}
- /**
- * Checks a test case, when Signifyd guarantee was declined.
- *
- * @covers \Magento\Signifyd\Model\Guarantee\CancelingService::cancelForOrder
- * @magentoDataFixture Magento/Signifyd/_files/case.php
- * @magentoConfigFixture current_store fraud_protection/signifyd/active 1
- */
- public function testCancelForOrderWithDeclinedGuarantee()
- {
- /** @var CaseRepositoryInterface $caseRepository */
- $caseRepository = $this->objectManager->get(CaseRepositoryInterface::class);
- $caseEntity = $caseRepository->getByCaseId(self::$caseId);
- $caseEntity->setGuaranteeDisposition(CaseInterface::GUARANTEE_DECLINED);
- $caseRepository->save($caseEntity);
-
- $this->gateway->expects(self::never())
- ->method('cancelGuarantee');
-
- $this->logger->expects(self::never())
- ->method('error');
-
- $result = $this->service->cancelForOrder($caseEntity->getOrderId());
- self::assertFalse($result);
- }
-
/**
* Checks a test case, when Signifyd gateway throws an exception.
*
From 14d60c11244c76345d16d3dbc07bd8a8ff1448ed Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Tue, 28 Feb 2017 10:16:39 -0600
Subject: [PATCH 197/904] MAGETWO-65105: Unhold on "Approved" guarantee status
(cherry picked from commit bbf8925)
---
.../Model/CaseServices/UpdatingService.php | 17 +++++-
.../CaseServices/UpdatingServiceTest.php | 28 +++++++--
.../CaseServices/UpdatingServiceTest.php | 60 +++++++++++++++++++
.../Magento/Signifyd/_files/case.php | 6 ++
.../Magento/Signifyd/_files/declined_case.php | 38 ++++++++++++
5 files changed, 143 insertions(+), 6 deletions(-)
create mode 100644 dev/tests/integration/testsuite/Magento/Signifyd/_files/declined_case.php
diff --git a/app/code/Magento/Signifyd/Model/CaseServices/UpdatingService.php b/app/code/Magento/Signifyd/Model/CaseServices/UpdatingService.php
index 40f28b32ec0eb..d94af78c42430 100644
--- a/app/code/Magento/Signifyd/Model/CaseServices/UpdatingService.php
+++ b/app/code/Magento/Signifyd/Model/CaseServices/UpdatingService.php
@@ -11,6 +11,7 @@
use Magento\Signifyd\Api\Data\CaseInterface;
use Magento\Signifyd\Model\CommentsHistoryUpdater;
use Magento\Signifyd\Model\MessageGenerators\GeneratorInterface;
+use Magento\Signifyd\Model\OrderStateService;
use Magento\Signifyd\Model\SalesOrderGrid\OrderGridUpdater;
/**
@@ -38,6 +39,11 @@ class UpdatingService implements UpdatingServiceInterface
*/
private $orderGridUpdater;
+ /**
+ * @var OrderStateService
+ */
+ private $orderStateService;
+
/**
* UpdatingService constructor.
*
@@ -45,17 +51,20 @@ class UpdatingService implements UpdatingServiceInterface
* @param CaseRepositoryInterface $caseRepository
* @param CommentsHistoryUpdater $commentsHistoryUpdater
* @param \Magento\Signifyd\Model\SalesOrderGrid\OrderGridUpdater $orderGridUpdater
+ * @param OrderStateService $orderStateService
*/
public function __construct(
GeneratorInterface $messageGenerator,
CaseRepositoryInterface $caseRepository,
CommentsHistoryUpdater $commentsHistoryUpdater,
- OrderGridUpdater $orderGridUpdater
+ OrderGridUpdater $orderGridUpdater,
+ OrderStateService $orderStateService
) {
$this->messageGenerator = $messageGenerator;
$this->caseRepository = $caseRepository;
$this->commentsHistoryUpdater = $commentsHistoryUpdater;
$this->orderGridUpdater = $orderGridUpdater;
+ $this->orderStateService = $orderStateService;
}
/**
@@ -74,11 +83,15 @@ public function update(CaseInterface $case, array $data)
}
try {
+ $previousDisposition = $case->getGuaranteeDisposition();
$this->setCaseData($case, $data);
$orderHistoryComment = $this->messageGenerator->generate($data);
- $this->caseRepository->save($case);
+ $case = $this->caseRepository->save($case);
$this->orderGridUpdater->update($case->getOrderId());
$this->commentsHistoryUpdater->addComment($case, $orderHistoryComment);
+ if ($case->getGuaranteeDisposition() !== $previousDisposition) {
+ $this->orderStateService->updateByCase($case);
+ }
} catch (\Exception $e) {
throw new LocalizedException(__('Cannot update Case entity.'), $e);
}
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/CaseServices/UpdatingServiceTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/CaseServices/UpdatingServiceTest.php
index a2894939042dd..0717fea7c1644 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/CaseServices/UpdatingServiceTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/CaseServices/UpdatingServiceTest.php
@@ -12,6 +12,7 @@
use Magento\Signifyd\Model\CommentsHistoryUpdater;
use Magento\Signifyd\Model\MessageGenerators\GeneratorException;
use Magento\Signifyd\Model\MessageGenerators\GeneratorInterface;
+use Magento\Signifyd\Model\OrderStateService;
use Magento\Signifyd\Model\SalesOrderGrid\OrderGridUpdater;
use PHPUnit_Framework_MockObject_MockObject as MockObject;
@@ -46,10 +47,15 @@ class UpdatingServiceTest extends \PHPUnit_Framework_TestCase
private $commentsHistoryUpdater;
/**
- * @var \Magento\Signifyd\Model\SalesOrderGrid\OrderGridUpdater|MockObject
+ * @var OrderGridUpdater|MockObject
*/
private $orderGridUpdater;
+ /**
+ * @var OrderStateService|MockObject
+ */
+ private $orderStateService;
+
/**
* @inheritdoc
*/
@@ -76,11 +82,16 @@ protected function setUp()
->disableOriginalConstructor()
->getMock();
+ $this->orderStateService = $this->getMockBuilder(OrderStateService::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+
$this->service = $this->objectManager->getObject(UpdatingService::class, [
'messageGenerator' => $this->messageGenerator,
'caseRepository' => $this->caseRepository,
'commentsHistoryUpdater' => $this->commentsHistoryUpdater,
- 'orderGridUpdater' => $this->orderGridUpdater
+ 'orderGridUpdater' => $this->orderGridUpdater,
+ 'orderStateService' => $this->orderStateService
]);
}
@@ -226,10 +237,15 @@ public function testUpdate()
$caseEntity = $this->withCaseEntity(21, $caseId, $data);
+ $caseEntitySaved = clone $caseEntity;
+ $caseEntitySaved->expects(self::once())
+ ->method('getGuaranteeDisposition')
+ ->willReturn('APPROVED');
+
$this->caseRepository->expects(self::once())
->method('save')
->with($caseEntity)
- ->willReturn($caseEntity);
+ ->willReturn($caseEntitySaved);
$message = __('Message is generated.');
$this->messageGenerator->expects(self::once())
@@ -243,7 +259,11 @@ public function testUpdate()
$this->commentsHistoryUpdater->expects(self::once())
->method('addComment')
- ->with($caseEntity, $message);
+ ->with($caseEntitySaved, $message);
+
+ $this->orderStateService->expects(self::once())
+ ->method('updateByCase')
+ ->with($caseEntitySaved);
$this->service->update($caseEntity, $data);
}
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseServices/UpdatingServiceTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseServices/UpdatingServiceTest.php
index f04108d2b3c8a..85730778dc21c 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseServices/UpdatingServiceTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseServices/UpdatingServiceTest.php
@@ -9,6 +9,7 @@
use Magento\Framework\App\ResourceConnection;
use Magento\Sales\Api\Data\OrderStatusHistoryInterface;
use Magento\Sales\Api\OrderRepositoryInterface;
+use Magento\Sales\Model\Order;
use Magento\Signifyd\Api\CaseRepositoryInterface;
use Magento\Signifyd\Api\Data\CaseInterface;
use Magento\Signifyd\Model\MessageGenerators\GeneratorFactory;
@@ -47,6 +48,7 @@ protected function setUp()
/**
* Checks case updating flow and messages in order comments history.
+ * Also checks that order is unholded when case guarantee disposition is APPROVED.
*
* @covers \Magento\Signifyd\Model\CaseServices\UpdatingService::update
* @magentoDataFixture Magento/Signifyd/_files/case.php
@@ -97,6 +99,7 @@ public function testUpdate()
/** @var OrderRepositoryInterface $orderRepository */
$orderRepository = $this->objectManager->get(OrderRepositoryInterface::class);
$order = $orderRepository->get($caseEntity->getOrderId());
+ static::assertEquals(Order::STATE_PROCESSING, $order->getState());
$histories = $order->getStatusHistories();
static::assertNotEmpty($histories);
@@ -106,6 +109,63 @@ public function testUpdate()
static::assertEquals("Signifyd Case $caseId has been created for order.", $caseCreationComment->getComment());
}
+ /**
+ * Checks that order is holded when case guarantee disposition is DECLINED.
+ *
+ * @covers \Magento\Signifyd\Model\CaseServices\UpdatingService::update
+ * @magentoDataFixture Magento/Signifyd/_files/approved_case.php
+ */
+ public function testOrderStateAfterDeclinedGuaranteeDisposition()
+ {
+ $caseId = 123;
+ $data = [
+ 'caseId' => $caseId,
+ 'orderId' => '100000001',
+ 'guaranteeDisposition' => CaseInterface::GUARANTEE_DECLINED
+ ];
+
+ /** @var CaseRepositoryInterface $caseRepository */
+ $caseRepository = $this->objectManager->get(CaseRepositoryInterface::class);
+ $caseEntity = $caseRepository->getByCaseId($caseId);
+
+ $this->service->update($caseEntity, $data);
+
+ /** @var OrderRepositoryInterface $orderRepository */
+ $orderRepository = $this->objectManager->get(OrderRepositoryInterface::class);
+ $order = $orderRepository->get($caseEntity->getOrderId());
+
+ static::assertEquals(Order::STATE_HOLDED, $order->getState());
+ }
+
+ /**
+ * Checks that order doesn't become holded
+ * when previous case guarantee disposition was DECLINED
+ * and webhook without guarantee disposition was received.
+ *
+ * @covers \Magento\Signifyd\Model\CaseServices\UpdatingService::update
+ * @magentoDataFixture Magento/Signifyd/_files/declined_case.php
+ */
+ public function testOrderStateAfterWebhookWithoutGuaranteeDisposition()
+ {
+ $caseId = 123;
+ $data = [
+ 'caseId' => $caseId,
+ 'orderId' => '100000001'
+ ];
+
+ /** @var CaseRepositoryInterface $caseRepository */
+ $caseRepository = $this->objectManager->get(CaseRepositoryInterface::class);
+ $caseEntity = $caseRepository->getByCaseId($caseId);
+
+ $this->service->update($caseEntity, $data);
+
+ /** @var OrderRepositoryInterface $orderRepository */
+ $orderRepository = $this->objectManager->get(OrderRepositoryInterface::class);
+ $order = $orderRepository->get($caseEntity->getOrderId());
+
+ static::assertEquals(Order::STATE_PROCESSING, $order->getState());
+ }
+
/**
* Returns value of signifyd_guarantee_status column from sales order grid
*
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/_files/case.php b/dev/tests/integration/testsuite/Magento/Signifyd/_files/case.php
index a7df26f033074..fec40dec4f17f 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/_files/case.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/_files/case.php
@@ -3,12 +3,17 @@
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+use Magento\Sales\Api\OrderManagementInterface;
use Magento\Signifyd\Api\CaseRepositoryInterface;
use Magento\Signifyd\Api\Data\CaseInterface;
use Magento\Signifyd\Api\Data\CaseInterfaceFactory;
require __DIR__ . '/order_with_customer_and_two_simple_products.php';
+/** @var OrderManagementInterface $orderManagement */
+$orderManagement = $objectManager->create(OrderManagementInterface::class);
+$orderManagement->hold($order->getEntityId());
+
/** @var CaseInterfaceFactory $caseFactory */
$caseFactory = $objectManager->get(CaseInterfaceFactory::class);
@@ -28,6 +33,7 @@
->setOrderId($order->getEntityId())
->setAssociatedTeam($associatedTeam)
->setReviewDisposition(CaseInterface::DISPOSITION_GOOD)
+ ->setGuaranteeDisposition(CaseInterface::GUARANTEE_PENDING)
->setCreatedAt('2016-12-12T15:17:17+0000')
->setUpdatedAt('2016-12-12T19:23:16+0000');
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/_files/declined_case.php b/dev/tests/integration/testsuite/Magento/Signifyd/_files/declined_case.php
new file mode 100644
index 0000000000000..16cf1b1b8df14
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/_files/declined_case.php
@@ -0,0 +1,38 @@
+get(CaseInterfaceFactory::class);
+
+$associatedTeam = [
+ 'teamName' => 'Some Team',
+ 'teamId' => 123,
+ 'getAutoDismiss' => true,
+ 'getTeamDismissalDays' => 3
+];
+
+/** @var CaseInterface $case */
+$case = $caseFactory->create();
+$case->setCaseId(123)
+ ->setGuaranteeEligible(false)
+ ->setGuaranteeDisposition(CaseInterface::GUARANTEE_DECLINED)
+ ->setStatus(CaseInterface::STATUS_PROCESSING)
+ ->setScore(553)
+ ->setOrderId($order->getEntityId())
+ ->setAssociatedTeam($associatedTeam)
+ ->setReviewDisposition(CaseInterface::DISPOSITION_FRAUDULENT)
+ ->setCreatedAt('2016-12-12T15:17:17+0000')
+ ->setUpdatedAt('2016-12-12T19:23:16+0000');
+
+/** @var CaseRepositoryInterface $caseRepository */
+$caseRepository = $objectManager->get(CaseRepositoryInterface::class);
+$caseRepository->save($case);
From 811e58cebfece376fde0c667c1a9df02533784da Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Mon, 27 Feb 2017 07:47:11 -0600
Subject: [PATCH 198/904] MAGETWO-65103: Setup HOLD status by default after
placing order in case Signifyd was used
(cherry picked from commit 7143d21)
---
.../Model/CaseServices/CreationService.php | 12 +-
.../Signifyd/Model/CommentsHistoryUpdater.php | 5 +-
.../Signifyd/Model/OrderStateService.php | 120 +++++++++++
.../Unit/Model/CommentsHistoryUpdaterTest.php | 16 +-
.../Test/Unit/Model/OrderStateServiceTest.php | 204 ++++++++++++++++++
app/code/Magento/Signifyd/i18n/en_US.csv | 3 +-
.../CaseServices/CreationServiceTest.php | 15 ++
.../CaseServices/UpdatingServiceTest.php | 1 -
8 files changed, 369 insertions(+), 7 deletions(-)
create mode 100644 app/code/Magento/Signifyd/Model/OrderStateService.php
create mode 100644 app/code/Magento/Signifyd/Test/Unit/Model/OrderStateServiceTest.php
diff --git a/app/code/Magento/Signifyd/Model/CaseServices/CreationService.php b/app/code/Magento/Signifyd/Model/CaseServices/CreationService.php
index 510cf8ff9e7e7..5503b26958e7f 100644
--- a/app/code/Magento/Signifyd/Model/CaseServices/CreationService.php
+++ b/app/code/Magento/Signifyd/Model/CaseServices/CreationService.php
@@ -8,6 +8,7 @@
use Magento\Signifyd\Api\CaseCreationServiceInterface;
use Magento\Signifyd\Api\CaseManagementInterface;
use Magento\Signifyd\Api\CaseRepositoryInterface;
+use Magento\Signifyd\Model\OrderStateService;
use Magento\Signifyd\Model\SalesOrderGrid\OrderGridUpdater;
use Magento\Signifyd\Model\SignifydGateway\Gateway;
use Magento\Signifyd\Model\SignifydGateway\GatewayException;
@@ -45,6 +46,11 @@ class CreationService implements CaseCreationServiceInterface
*/
private $orderGridUpdater;
+ /**
+ * @var OrderStateService
+ */
+ private $orderStateService;
+
/**
* CreationService constructor.
*
@@ -53,19 +59,22 @@ class CreationService implements CaseCreationServiceInterface
* @param LoggerInterface $logger
* @param CaseRepositoryInterface $caseRepository
* @param OrderGridUpdater $orderGridUpdater
+ * @param OrderStateService $orderStateService
*/
public function __construct(
CaseManagementInterface $caseManagement,
Gateway $signifydGateway,
LoggerInterface $logger,
CaseRepositoryInterface $caseRepository,
- OrderGridUpdater $orderGridUpdater
+ OrderGridUpdater $orderGridUpdater,
+ OrderStateService $orderStateService
) {
$this->caseManagement = $caseManagement;
$this->signifydGateway = $signifydGateway;
$this->logger = $logger;
$this->caseRepository = $caseRepository;
$this->orderGridUpdater = $orderGridUpdater;
+ $this->orderStateService = $orderStateService;
}
/**
@@ -85,6 +94,7 @@ public function createForOrder($orderId)
$case->setCaseId($caseId);
$this->caseRepository->save($case);
+ $this->orderStateService->updateByCase($case);
return true;
}
diff --git a/app/code/Magento/Signifyd/Model/CommentsHistoryUpdater.php b/app/code/Magento/Signifyd/Model/CommentsHistoryUpdater.php
index f36a6205fe3fd..4682f71c3cd7a 100644
--- a/app/code/Magento/Signifyd/Model/CommentsHistoryUpdater.php
+++ b/app/code/Magento/Signifyd/Model/CommentsHistoryUpdater.php
@@ -35,10 +35,10 @@ public function __construct(HistoryFactory $historyFactory)
*
* @param CaseInterface $case
* @param Phrase $message
+ * @param string $status
* @return void
- * @throws \Exception
*/
- public function addComment(CaseInterface $case, Phrase $message)
+ public function addComment(CaseInterface $case, Phrase $message, $status = '')
{
if (!$message->getText()) {
return;
@@ -49,6 +49,7 @@ public function addComment(CaseInterface $case, Phrase $message)
$history->setParentId($case->getOrderId())
->setComment($message)
->setEntityName('order')
+ ->setStatus($status)
->save();
}
}
diff --git a/app/code/Magento/Signifyd/Model/OrderStateService.php b/app/code/Magento/Signifyd/Model/OrderStateService.php
new file mode 100644
index 0000000000000..8acb9e28a52eb
--- /dev/null
+++ b/app/code/Magento/Signifyd/Model/OrderStateService.php
@@ -0,0 +1,120 @@
+orderFactory = $orderFactory;
+ $this->orderManagement = $orderManagement;
+ $this->commentsHistoryUpdater = $commentsHistoryUpdater;
+ }
+
+ /**
+ * Updates order state depending on case guarantee disposition status.
+ *
+ * @param CaseInterface $case
+ * @return void
+ */
+ public function updateByCase(CaseInterface $case)
+ {
+ $orderId = $case->getOrderId();
+
+ switch ($case->getGuaranteeDisposition())
+ {
+ case CaseInterface::GUARANTEE_APPROVED:
+ $this->unHold($orderId);
+ break;
+ case CaseInterface::GUARANTEE_DECLINED:
+ $this->hold($orderId);
+ break;
+ case CaseInterface::GUARANTEE_PENDING:
+ if ($this->hold($orderId)) {
+ $this->commentsHistoryUpdater->addComment(
+ $case,
+ __('Awaiting the Signifyd guarantee disposition.'),
+ Order::STATE_HOLDED
+ );
+ }
+ break;
+ }
+ }
+
+ /**
+ * Tries to unhold the order.
+ *
+ * @param int $orderId
+ * @return bool
+ */
+ private function unHold($orderId)
+ {
+ $order = $this->getOrder($orderId);
+ if ($order->canUnhold()) {
+ return $this->orderManagement->unHold($orderId);
+ }
+
+ return false;
+ }
+
+ /**
+ * Tries to hold the order.
+ *
+ * @param int $orderId
+ * @return bool
+ */
+ private function hold($orderId)
+ {
+ $order = $this->getOrder($orderId);
+ if ($order->canHold()) {
+ return $this->orderManagement->hold($orderId);
+ }
+
+ return false;
+ }
+
+ /**
+ * Returns the order.
+ *
+ * @param int $orderId
+ * @return Order
+ */
+ private function getOrder($orderId)
+ {
+ return $this->orderFactory->create()->load($orderId);
+ }
+}
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/CommentsHistoryUpdaterTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/CommentsHistoryUpdaterTest.php
index fa0a752451917..fe4ccf1c02ea2 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/CommentsHistoryUpdaterTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/CommentsHistoryUpdaterTest.php
@@ -5,7 +5,6 @@
*/
namespace Magento\Signifyd\Test\Unit\Model;
-use Magento\Framework\Phrase;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
use Magento\Sales\Api\Data\OrderStatusHistoryInterface;
use Magento\Sales\Model\Order\Status\HistoryFactory;
@@ -28,6 +27,11 @@ class CommentsHistoryUpdaterTest extends \PHPUnit_Framework_TestCase
*/
private static $message = 'Case is created.';
+ /**
+ * @var string
+ */
+ private static $status = 'On Hold';
+
/**
* @var CommentsHistoryUpdater
*/
@@ -84,6 +88,10 @@ public function testAddCommentWithException()
->method('getOrderId')
->willReturn(self::$orderId);
+ $this->historyEntity->expects(self::any())
+ ->method('setStatus')
+ ->with('')
+ ->willReturnSelf();
$this->historyEntity->expects(self::once())
->method('save')
->willThrowException(new \Exception('Cannot save comment message.'));
@@ -102,11 +110,15 @@ public function testAddComment()
->method('getOrderId')
->willReturn(self::$orderId);
+ $this->historyEntity->expects(self::any())
+ ->method('setStatus')
+ ->with(self::$status)
+ ->willReturnSelf();
$this->historyEntity->expects(self::once())
->method('save')
->willReturnSelf();
- $this->updater->addComment($this->caseEntity, __(self::$message));
+ $this->updater->addComment($this->caseEntity, __(self::$message), self::$status);
}
/**
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/OrderStateServiceTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/OrderStateServiceTest.php
new file mode 100644
index 0000000000000..93f4d40dba84a
--- /dev/null
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/OrderStateServiceTest.php
@@ -0,0 +1,204 @@
+orderManagement = $this->getMockBuilder(OrderManagementInterface::class)
+ ->getMockForAbstractClass();
+
+ $this->commentsHistoryUpdater = $this->getMockBuilder(CommentsHistoryUpdater::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->orderFactory = $this->getMockBuilder(OrderFactory::class)
+ ->setMethods(['create'])
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->order = $this->getMockBuilder(Order::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->order->expects($this->once())
+ ->method('load')
+ ->willReturnSelf();
+
+ $this->orderFactory->expects($this->once())
+ ->method('create')
+ ->willReturn($this->order);
+
+ $this->caseEntity = $this->getMockBuilder(CaseInterface::class)
+ ->disableOriginalConstructor()
+ ->getMockForAbstractClass();
+ $this->caseEntity->expects($this->once())
+ ->method('getOrderId')
+ ->willReturn(self::$orderId);
+
+ $this->orderStateService = new OrderStateService(
+ $this->orderFactory,
+ $this->orderManagement,
+ $this->commentsHistoryUpdater
+ );
+ }
+
+ /**
+ * Tests update order state flow when case guarantee disposition is PENDING.
+ *
+ * @param bool $canHold
+ * @param bool $hold
+ * @param int $addCommentCall
+ * @dataProvider updateByCaseWithGuaranteePendingDataProvider
+ */
+ public function testUpdateByCaseWithGuaranteePending($canHold, $hold, $addCommentCall)
+ {
+ $this->caseEntity->expects($this->once())
+ ->method('getGuaranteeDisposition')
+ ->willReturn(CaseInterface::GUARANTEE_PENDING);
+ $this->order->expects($this->any())
+ ->method('canHold')
+ ->willReturn($canHold);
+ $this->orderManagement->expects($this->any())
+ ->method('hold')
+ ->willReturn($hold);
+ $this->commentsHistoryUpdater->expects($this->exactly($addCommentCall))
+ ->method('addComment')
+ ->with(
+ $this->caseEntity,
+ __('Awaiting the Signifyd guarantee disposition.'),
+ Order::STATE_HOLDED
+ );
+
+ $this->orderStateService->updateByCase($this->caseEntity);
+ }
+
+ /**
+ * @return array
+ */
+ public function updateByCaseWithGuaranteePendingDataProvider()
+ {
+ return [
+ ['canHold' => true, 'hold' => true, 'addCommentCall' => 1],
+ ['canHold' => false, 'hold' => true, 'addCommentCall' => 0],
+ ['canHold' => true, 'hold' => false, 'addCommentCall' => 0],
+ ];
+ }
+
+ /**
+ * Tests update order state flow when case guarantee disposition is APPROVED.
+ *
+ * @param bool $canUnhold
+ * @param int $unholdCall
+ * @dataProvider updateByCaseWithGuaranteeApprovedDataProvider
+ */
+ public function testUpdateByCaseWithGuaranteeApproved($canUnhold, $unholdCall)
+ {
+ $this->caseEntity->expects($this->once())
+ ->method('getGuaranteeDisposition')
+ ->willReturn(CaseInterface::GUARANTEE_APPROVED);
+ $this->order->expects($this->any())
+ ->method('canUnhold')
+ ->willReturn($canUnhold);
+ $this->orderManagement->expects($this->exactly($unholdCall))
+ ->method('unHold');
+ $this->commentsHistoryUpdater->expects($this->never())
+ ->method('addComment');
+
+ $this->orderStateService->updateByCase($this->caseEntity);
+ }
+
+ /**
+ * @return array
+ */
+ public function updateByCaseWithGuaranteeApprovedDataProvider()
+ {
+ return [
+ ['canUnhold' => true, 'unholdCall' => 1],
+ ['canUnhold' => false, 'unholdCall' => 0]
+ ];
+ }
+
+ /**
+ * Tests update order state flow when case guarantee disposition is DECLINED.
+ *
+ * @param bool $canHold
+ * @param int $holdCall
+ * @dataProvider updateByCaseWithGuaranteeDeclinedDataProvider
+ */
+ public function testUpdateByCaseWithGuaranteeDeclined($canHold, $holdCall)
+ {
+ $this->caseEntity->expects($this->once())
+ ->method('getGuaranteeDisposition')
+ ->willReturn(CaseInterface::GUARANTEE_DECLINED);
+ $this->order->expects($this->any())
+ ->method('canHold')
+ ->willReturn($canHold);
+ $this->orderManagement->expects($this->exactly($holdCall))
+ ->method('hold');
+ $this->commentsHistoryUpdater->expects($this->never())
+ ->method('addComment');
+
+ $this->orderStateService->updateByCase($this->caseEntity);
+ }
+
+ /**
+ * @return array
+ */
+ public function updateByCaseWithGuaranteeDeclinedDataProvider()
+ {
+ return [
+ ['canHold' => true, 'holdCall' => 1],
+ ['canHold' => false, 'holdCall' => 0]
+ ];
+ }
+}
diff --git a/app/code/Magento/Signifyd/i18n/en_US.csv b/app/code/Magento/Signifyd/i18n/en_US.csv
index 188419e33ac76..47feacc8c4a2f 100644
--- a/app/code/Magento/Signifyd/i18n/en_US.csv
+++ b/app/code/Magento/Signifyd/i18n/en_US.csv
@@ -25,4 +25,5 @@
"Guarantee has been cancelled for your order.","Guarantee has been cancelled for your order."
"Sorry, we cannot cancel Guarantee for order.","Sorry, we cannot cancel Guarantee for order."
"Not empty value for "%1" node is required.","Not empty value for "%1" node is required."
-"Only single entrance of "%1" node is required.","Only single entrance of "%1" node is required."
\ No newline at end of file
+"Only single entrance of "%1" node is required.","Only single entrance of "%1" node is required."
+"Awaiting the Signifyd guarantee disposition.","Awaiting the Signifyd guarantee disposition."
\ No newline at end of file
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseServices/CreationServiceTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseServices/CreationServiceTest.php
index d779e98ebd034..a8d31240fb5b0 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseServices/CreationServiceTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseServices/CreationServiceTest.php
@@ -9,7 +9,9 @@
use Magento\Framework\Api\SearchCriteriaBuilder;
use Magento\Framework\App\ObjectManager;
use Magento\Sales\Api\Data\OrderInterface;
+use Magento\Sales\Api\Data\OrderStatusHistoryInterface;
use Magento\Sales\Api\OrderRepositoryInterface;
+use Magento\Sales\Model\Order;
use Magento\Signifyd\Api\CaseRepositoryInterface;
use Magento\Signifyd\Model\SignifydGateway\ApiCallException;
use Magento\Signifyd\Model\SignifydGateway\ApiClient;
@@ -184,6 +186,19 @@ public function testCreateForOrder()
$caseEntity->getGuaranteeDisposition(),
'Signifyd guaranty status in sales_order_grid table does not match case entity guaranty status'
);
+
+ /** @var OrderRepositoryInterface $orderRepository */
+ $orderRepository = $this->objectManager->get(OrderRepositoryInterface::class);
+ $order = $orderRepository->get($caseEntity->getOrderId());
+ static::assertEquals(Order::STATE_HOLDED, $order->getState());
+
+ $histories = $order->getStatusHistories();
+ static::assertNotEmpty($histories);
+
+ /** @var OrderStatusHistoryInterface $orderHoldComment */
+ $orderHoldComment = array_pop($histories);
+ static::assertInstanceOf(OrderStatusHistoryInterface::class, $orderHoldComment);
+ static::assertEquals("Awaiting the Signifyd guarantee disposition.", $orderHoldComment->getComment());
}
/**
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseServices/UpdatingServiceTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseServices/UpdatingServiceTest.php
index 85730778dc21c..879405a757eaf 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseServices/UpdatingServiceTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseServices/UpdatingServiceTest.php
@@ -6,7 +6,6 @@
namespace Magento\Signifyd\Model\CaseServices;
use Magento\Framework\App\ObjectManager;
-use Magento\Framework\App\ResourceConnection;
use Magento\Sales\Api\Data\OrderStatusHistoryInterface;
use Magento\Sales\Api\OrderRepositoryInterface;
use Magento\Sales\Model\Order;
From 45947325b601f926881348bbc9fbd1c79e3e4c46 Mon Sep 17 00:00:00 2001
From: Dmytro Yushkin
Date: Wed, 1 Mar 2017 11:07:08 -0600
Subject: [PATCH 199/904] MAGETWO-63851: Re-implement cancel guarantee
mechanism
- Code review fixes
(cherry picked from commit 973286b)
---
.../Guarantee/CancelGuaranteeAbilityTest.php | 16 +++---------
.../Model/Guarantee/CancelingServiceTest.php | 25 +++++++++++++++++++
2 files changed, 28 insertions(+), 13 deletions(-)
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CancelGuaranteeAbilityTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CancelGuaranteeAbilityTest.php
index 280f54e7aa5d3..f51b4980ee857 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CancelGuaranteeAbilityTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CancelGuaranteeAbilityTest.php
@@ -100,12 +100,9 @@ public function testIsAvailableWithNullCase()
}
/**
- * Tests case when Guarantee Disposition has Declined or Canceled states.
- *
- * @param string $guaranteeDisposition
- * @dataProvider isAvailableWithCanceledGuaranteeDataProvider
+ * Tests case when Guarantee Disposition has Canceled states.
*/
- public function testIsAvailableWithCanceledGuarantee($guaranteeDisposition)
+ public function testIsAvailableWithCanceledGuarantee()
{
$orderId = 123;
@@ -116,7 +113,7 @@ public function testIsAvailableWithCanceledGuarantee($guaranteeDisposition)
$case->expects($this->once())
->method('getGuaranteeDisposition')
- ->willReturn($guaranteeDisposition);
+ ->willReturn(CaseEntity::GUARANTEE_CANCELED);
$this->caseManagement->expects($this->once())
->method('getByOrderId')
@@ -126,13 +123,6 @@ public function testIsAvailableWithCanceledGuarantee($guaranteeDisposition)
$this->assertFalse($this->cancelGuaranteeAbility->isAvailable($orderId));
}
- public function isAvailableWithCanceledGuaranteeDataProvider()
- {
- return [
- [CaseEntity::GUARANTEE_CANCELED]
- ];
- }
-
/**
* Tests case when order does not exist.
*/
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Model/Guarantee/CancelingServiceTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Model/Guarantee/CancelingServiceTest.php
index 054c8c50598ba..682b3338bef02 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Model/Guarantee/CancelingServiceTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/Guarantee/CancelingServiceTest.php
@@ -65,6 +65,31 @@ protected function setUp()
]);
}
+ /**
+ * Checks a test case, when Signifyd guarantee was canceled.
+ *
+ * @covers \Magento\Signifyd\Model\Guarantee\CancelingService::cancelForOrder
+ * @magentoDataFixture Magento/Signifyd/_files/case.php
+ * @magentoConfigFixture current_store fraud_protection/signifyd/active 1
+ */
+ public function testCancelForOrderWithCanceledGuarantee()
+ {
+ /** @var CaseRepositoryInterface $caseRepository */
+ $caseRepository = $this->objectManager->get(CaseRepositoryInterface::class);
+ $caseEntity = $caseRepository->getByCaseId(self::$caseId);
+ $caseEntity->setGuaranteeDisposition(CaseInterface::GUARANTEE_CANCELED);
+ $caseRepository->save($caseEntity);
+
+ $this->gateway->expects(self::never())
+ ->method('cancelGuarantee');
+
+ $this->logger->expects(self::never())
+ ->method('error');
+
+ $result = $this->service->cancelForOrder($caseEntity->getOrderId());
+ self::assertFalse($result);
+ }
+
/**
* Checks a test case, when Signifyd gateway throws an exception.
*
From d037632ae66d8a26cdb5a218c37d0643f1063ca0 Mon Sep 17 00:00:00 2001
From: Dmytro Yushkin
Date: Tue, 7 Mar 2017 10:53:15 -0600
Subject: [PATCH 200/904] MAGETWO-63942: Add Signifyd Guarantee Status column
to order grid
- Changes in install schema
(cherry picked from commit 9fb40e4)
---
.../Magento/Signifyd/Setup/InstallData.php | 66 -------------------
.../Magento/Signifyd/Setup/InstallSchema.php | 10 +++
app/code/Magento/Signifyd/composer.json | 1 -
app/code/Magento/Signifyd/etc/module.xml | 1 -
4 files changed, 10 insertions(+), 68 deletions(-)
delete mode 100644 app/code/Magento/Signifyd/Setup/InstallData.php
diff --git a/app/code/Magento/Signifyd/Setup/InstallData.php b/app/code/Magento/Signifyd/Setup/InstallData.php
deleted file mode 100644
index a7490064a895a..0000000000000
--- a/app/code/Magento/Signifyd/Setup/InstallData.php
+++ /dev/null
@@ -1,66 +0,0 @@
-resource = $resource;
- }
-
- /**
- * Installs data for sales module
- *
- * Update of sales_order_grid* tables is provided here to be sure that these tables are already created.
- * {@inheritdoc}
- */
- public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
- {
- $this->resource->getConnection(self::$connectionName)->addColumn(
- $setup->getTable('sales_order_grid'),
- 'signifyd_guarantee_status',
- [
- 'type' => Table::TYPE_TEXT,
- 'length' => 32,
- 'comment' => 'Signifyd Guarantee Disposition Status'
- ]
- );
-
- $this->resource->getConnection(self::$connectionName)->addColumn(
- $setup->getTable('magento_sales_order_grid_archive'),
- 'signifyd_guarantee_status',
- [
- 'type' => Table::TYPE_TEXT,
- 'length' => 32,
- 'comment' => 'Signifyd Guarantee Disposition Status'
- ]
- );
- }
-}
diff --git a/app/code/Magento/Signifyd/Setup/InstallSchema.php b/app/code/Magento/Signifyd/Setup/InstallSchema.php
index b66bd5314b6bb..35a373097e736 100644
--- a/app/code/Magento/Signifyd/Setup/InstallSchema.php
+++ b/app/code/Magento/Signifyd/Setup/InstallSchema.php
@@ -92,5 +92,15 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
);
$connection->createTable($table);
+
+ $connection->addColumn(
+ $setup->getTable('sales_order_grid'),
+ 'signifyd_guarantee_status',
+ [
+ 'type' => Table::TYPE_TEXT,
+ 'length' => 32,
+ 'comment' => 'Signifyd Guarantee Disposition Status'
+ ]
+ );
}
}
diff --git a/app/code/Magento/Signifyd/composer.json b/app/code/Magento/Signifyd/composer.json
index 315ed2db7495d..0ec646ed17908 100644
--- a/app/code/Magento/Signifyd/composer.json
+++ b/app/code/Magento/Signifyd/composer.json
@@ -5,7 +5,6 @@
"php": "~5.6.5|7.0.2|7.0.4|~7.0.6",
"magento/framework": "100.2.*",
"magento/module-sales": "100.2.*",
- "magento/module-sales-archive": "100.2.*",
"magento/module-store": "100.2.*",
"magento/module-customer": "100.2.*",
"magento/module-directory": "100.2.*",
diff --git a/app/code/Magento/Signifyd/etc/module.xml b/app/code/Magento/Signifyd/etc/module.xml
index 602860b1be220..81d97d6fdc0d4 100644
--- a/app/code/Magento/Signifyd/etc/module.xml
+++ b/app/code/Magento/Signifyd/etc/module.xml
@@ -9,7 +9,6 @@
-
From 1617f5d4a6032598c3edd07011ef7dbb70194992 Mon Sep 17 00:00:00 2001
From: Iurii Ivashchenko
Date: Wed, 1 Mar 2017 09:48:40 -0600
Subject: [PATCH 201/904] MAGETWO-63641: Signifyd Marketing Materials on
Configuration Page
(cherry picked from commit 9dc2d9c)
---
.../System/Config/Field/WebhookUrl.php | 60 +++++++++++++++
.../Adminhtml/System/Config/Fieldset/Info.php | 31 ++++++++
app/code/Magento/Signifyd/composer.json | 1 +
.../Magento/Signifyd/etc/adminhtml/system.xml | 69 ++++++++++++------
app/code/Magento/Signifyd/i18n/en_US.csv | 16 +++-
.../view/adminhtml/web/images/logo.png | Bin 0 -> 5218 bytes
6 files changed, 154 insertions(+), 23 deletions(-)
create mode 100644 app/code/Magento/Signifyd/Block/Adminhtml/System/Config/Field/WebhookUrl.php
create mode 100644 app/code/Magento/Signifyd/Block/Adminhtml/System/Config/Fieldset/Info.php
create mode 100644 app/code/Magento/Signifyd/view/adminhtml/web/images/logo.png
diff --git a/app/code/Magento/Signifyd/Block/Adminhtml/System/Config/Field/WebhookUrl.php b/app/code/Magento/Signifyd/Block/Adminhtml/System/Config/Field/WebhookUrl.php
new file mode 100644
index 0000000000000..1fbb15953dbc7
--- /dev/null
+++ b/app/code/Magento/Signifyd/Block/Adminhtml/System/Config/Field/WebhookUrl.php
@@ -0,0 +1,60 @@
+getOriginalData();
+ if (!empty($originalData['handler_url'])) {
+ $url = $this->getStoreUrl();
+ $url .= $originalData['handler_url'];
+ }
+
+ return '' . $this->escapeHtml($url) . '
';
+ }
+
+ /**
+ * @inheritdoc
+ */
+ protected function _isInheritCheckboxRequired(AbstractElement $element)
+ {
+ return false;
+ }
+
+ /**
+ * Return base store URL.
+ *
+ * @return string
+ */
+ private function getStoreUrl()
+ {
+ $website = $this->_storeManager->getWebsite($this->getRequest()->getParam('website'));
+
+ $isSecure = $this->_scopeConfig->isSetFlag(
+ Store::XML_PATH_SECURE_IN_FRONTEND,
+ ScopeInterface::SCOPE_WEBSITE,
+ $website->getCode()
+ );
+
+ $configPath = $isSecure ? Store::XML_PATH_SECURE_BASE_LINK_URL : Store::XML_PATH_UNSECURE_BASE_LINK_URL;
+
+ return $this->_scopeConfig->getValue($configPath, ScopeInterface::SCOPE_WEBSITE, $website->getCode());
+ }
+}
diff --git a/app/code/Magento/Signifyd/Block/Adminhtml/System/Config/Fieldset/Info.php b/app/code/Magento/Signifyd/Block/Adminhtml/System/Config/Fieldset/Info.php
new file mode 100644
index 0000000000000..a2501be28395e
--- /dev/null
+++ b/app/code/Magento/Signifyd/Block/Adminhtml/System/Config/Fieldset/Info.php
@@ -0,0 +1,31 @@
+getGroup();
+
+ if (!empty($groupConfig['more_url']) && !empty($element->getComment())) {
+ $comment = $element->getComment();
+ $comment .= '' .
+ $this->escapeHtml(__('Learn more')) . '
';
+ $element->setComment($comment);
+ }
+
+ return parent::_getHeaderCommentHtml($element);
+ }
+}
diff --git a/app/code/Magento/Signifyd/composer.json b/app/code/Magento/Signifyd/composer.json
index 0ec646ed17908..e298e61dfc6a3 100644
--- a/app/code/Magento/Signifyd/composer.json
+++ b/app/code/Magento/Signifyd/composer.json
@@ -3,6 +3,7 @@
"description": "Submitting Case Entry to Signifyd on Order Creation",
"require": {
"php": "~5.6.5|7.0.2|7.0.4|~7.0.6",
+ "magento/module-config": "100.2.*",
"magento/framework": "100.2.*",
"magento/module-sales": "100.2.*",
"magento/module-store": "100.2.*",
diff --git a/app/code/Magento/Signifyd/etc/adminhtml/system.xml b/app/code/Magento/Signifyd/etc/adminhtml/system.xml
index 20445a953edce..1da4c75cea0c3 100644
--- a/app/code/Magento/Signifyd/etc/adminhtml/system.xml
+++ b/app/code/Magento/Signifyd/etc/adminhtml/system.xml
@@ -12,28 +12,53 @@
sales
Magento_Sales::fraud_protection
- Signifyd
-
- Enable this Solution
- Magento\Config\Model\Config\Source\Yesno
- fraud_protection/signifyd/active
-
-
- API Key
- http://signifyd.com/settings/teams after you create a Signifyd account]]>
- fraud_protection/signifyd/api_key
- Magento\Config\Model\Config\Backend\Encrypted
-
-
- API URL
- fraud_protection/signifyd/api_url
- Don’t change unless asked to do so.
-
-
- Debug
- Magento\Config\Model\Config\Source\Yesno
- fraud_protection/signifyd/debug
-
+ signifyd-logo-header
+
+ Magento\Signifyd\Block\Adminhtml\System\Config\Fieldset\Info
+ signifyd-about-header
+
+ Benefits:
+ Grow your business without fear of fraud
+ Accept more orders and maximize your revenue
+ Automate order review and shift fraud off your plate ]]>
+
+ https://www.signifyd.com/magento-ecommerce-fraud-protection-partner
+
+
+ signifyd-about-header
+ Configuration
+ View our setup guide for step-by-step instructions on how to integrate Signifyd with Magento. For support contact support@signifyd.com .]]>
+
+
+ Enable this Solution
+ Magento\Config\Model\Config\Source\Yesno
+ fraud_protection/signifyd/active
+
+
+ API Key
+ settings page in the Signifyd console]]>
+ fraud_protection/signifyd/api_key
+ Magento\Config\Model\Config\Backend\Encrypted
+
+
+ API URL
+ fraud_protection/signifyd/api_url
+ Don’t change unless asked to do so.
+
+
+ Debug
+ Magento\Config\Model\Config\Source\Yesno
+ fraud_protection/signifyd/debug
+
+
+ Webhook URL
+ configure a guarantee completed webhook in Signifyd. Webhooks are used to sync Signifyd`s guarantee decisions back to Magento.]]>
+ signifyd/webhooks/handler
+ Magento\Signifyd\Block\Adminhtml\System\Config\Field\WebhookUrl
+
+
diff --git a/app/code/Magento/Signifyd/i18n/en_US.csv b/app/code/Magento/Signifyd/i18n/en_US.csv
index 47feacc8c4a2f..dca6bcade0eb8 100644
--- a/app/code/Magento/Signifyd/i18n/en_US.csv
+++ b/app/code/Magento/Signifyd/i18n/en_US.csv
@@ -26,4 +26,18 @@
"Sorry, we cannot cancel Guarantee for order.","Sorry, we cannot cancel Guarantee for order."
"Not empty value for "%1" node is required.","Not empty value for "%1" node is required."
"Only single entrance of "%1" node is required.","Only single entrance of "%1" node is required."
-"Awaiting the Signifyd guarantee disposition.","Awaiting the Signifyd guarantee disposition."
\ No newline at end of file
+"Signifyd automatically reviews your orders for fraud, telling you in seconds which orders to ship, and which to reject.
+ We back our approvals with 100% chargeback protection, reimbursing you the full order amount plus fees should you ever receive a fraudulent chargeback.
+ Benefits:
+ Grow your business without fear of fraud
+ Accept more orders and maximize your revenue
+ Automate order review and shift fraud off your plate ","Signifyd automatically reviews your orders for fraud, telling you in seconds which orders to ship, and which to reject.
+ We back our approvals with 100% chargeback protection, reimbursing you the full order amount plus fees should you ever receive a fraudulent chargeback.
+ Benefits:
+ Grow your business without fear of fraud
+ Accept more orders and maximize your revenue
+ Automate order review and shift fraud off your plate "
+"View our setup guide for step-by-step instructions on how to integrate Signifyd with Magento. For support contact support@signifyd.com ","View our setup guide for step-by-step instructions on how to integrate Signifyd with Magento. For support contact support@signifyd.com "
+"Your API key can be found on the settings page in the Signifyd console","Your API key can be found on the settings page in the Signifyd console"
+"Don’t change unless asked to do so.","Don’t change unless asked to do so."
+"Your webhook URL will be used to configure a guarantee completed webhook in Signifyd. Webhooks are used to sync Signifyd`s guarantee decisions back to Magento.","Your webhook URL will be used to configure a guarantee completed webhook in Signifyd. Webhooks are used to sync Signifyd`s guarantee decisions back to Magento."
\ No newline at end of file
diff --git a/app/code/Magento/Signifyd/view/adminhtml/web/images/logo.png b/app/code/Magento/Signifyd/view/adminhtml/web/images/logo.png
new file mode 100644
index 0000000000000000000000000000000000000000..7c6645e7c6c93e6ee1a2a5d14ad1b7e95c07ff2b
GIT binary patch
literal 5218
zcmaJ_c|25Y`xk|geG7>(b~0udV`l7(HCu?3Vwkbc7-q)4WX+(mRzk8bk*%^k$QoI)
z6bd1`l!QE_=r?-nd7nRipZ9#uxzBy>^Zj1e_qy)uI)9vaOLIdu79kcoIyyFEBeWIm
z{(^R$VP>R_8|C8kw3{GB|02bj=t>E|kZ^Q5SfVoyXiUJk;jC~NY>;m+PMwa9VZ+1b
zBITl)DawUN0Ar3Y;6Q>8jZH_Vt`+Emaq+@YfX+BK4{r_7MpG*Y=z-M$*{PU8%zX54
z?jAO2sjD`7)Zc-lTm>hpkH=TwE5ApA_({kLh;f7
z{YTVAGfSWzk%R-PfRz=tt22(Ukrt1cHy5**}K8$-fgtOPOLI#zzqfhA0vUM{)f^
zlPOlX|H}A((PWz-ADp5Uj!g6;xzP5*Rs0W`mb?G$=noL<@(<3(kA(jfC)Py~hsP0c
z-V`!T6!e!OnsSr{$%D3m7(ANj;&=4c7_9;F^Yg%>RM1Kg1X2lxRMs^>>q4POC`<>T
zf`p)zp(+rB9^%N^k%4~`X)9nXjSEBT=oui8$_8kNJ`}1CN5FNVNIfJJse({eRY5}k
zaE-mm6pXhE?#Ss8*W5*_43Xx<(B;x;+iZLGVN2ZXDmVtWKaG;DC#>K;%
zLL|G(9_{6CwK$T8KMrd^A`*bVHUs7HFAcu}$3m2$F0NQ*1%xX`Ndbd{K@|`uKdWbD7P_9u7<6hW&~RTxB72?9qzp$H`<9RpPr2ogaXAUdibMVcC{
z3yR`F!Q+0HsScjI^H*XKuAgsFLQ4!)jXz*XN
z|1cH*W$)MWzpC~RlGX}G(|>x9_V7;^RD$qLU>wkB1n91R3&eYZ>p4UFK)?hR
zP*-U#Gd)PiSeJHu#>2DB{OdQ?pGi7OJ?G=X2^~sx>u?{1P9
zd-PA;9+BwPXd@j7UQ(qB=Yj_alR#4v1%
zis;>BMLTr%uW)V{hi@bbwDn6;*HdS!v{{$7E#;f`_9HiX!l-h)3;NCFq<4VOqz~^v
zoQeR{7@u!}=*pux!dWVP_>2@$Z8hxvZMHb&InI+kuDbdJfwSLy=nE+_$6LDL1IIF<
zSN#uI&nFleI;`WGCcGI&JlCDd;2nE;A;97mw!XwGb`mdmsEt&t7ICeFI!%2^b+|Wc
z2mEV$D_DyyCjHAUb@LNlsPQrRc`_EpZ*#C|_u#r%TzJI5yU#xM_;~jFFI_PqB!NyF
zxsevCeRJrgZtY?*{x77m8IX3M$
zrc!q%r{yJ8Qhb6)-~qG#;~~~fQu;qQYtWIt$qqx`n>Xfm$sMG4(S?*PVcmD1OMK}J
zOTTkzfowA$C3AaH+J3Zu*Dk4v9xEm@vz++UzEW;8Xcdn!DRQ_tnD(uOh5l4xwZjm*
zRl0&)_d6MTQQ5VdRWk4O=ifHie%Us*!vn!Xx1g=#ejlzic}N#_-O&yrWL$Bz&gbsL
zi41}qXY8X>s%lX}-HzYbC`J$C)-t6=qSfbQ?oF?XiRxpO?)Pp&Le)5~ovLb|>$FJ5
zsISfKI{fW$unqsl0hXL6T=zU{6ZSf~KuNXaR7l3uy}OK^
z$|6`#NfX9-zgzec$yUJ(sp)|y(pD&^B1u-EPpDycbzy(xsbw%Yo3A2%;bgrWBO0hoE9+hX0H*8_uIkOd3sxQK(e!Ev
zoV(K-E*!_A)z7=Enkex#A)5%&@UqI>I5^Ym!R>F#SK)54l~eV$|1)%^yR!ZRP--;l
ze3|W~jWyY`RofV065s8sc;@oxex^|clR9I;u*kn*tzR(
zepdAf_wGw6PMKWGdegDuUnLQDKW|(+)V@F(*^X05@;4-dFDWG#!$I9?$Bt!Zy+VVp
z^GzyLk+?;u&A5QJ=ob}df^OGX+VTLz{$lhnH?qOs`J$TNx^ZaA8Y8Fgte?h$s_(@I
zluN8!Ud;Q#g%7exeUijp7g-qiO(B~{{98k5O?2Z`4*smGo^?T~)uCbX8UyjePtw0*
zA&hKejVAtzB0`K~cYK(~&aGJ7-&U$J0gW+tb!zd5i{Yxc#vPL&!XWI;Wtmf8v-soE4HepS}_jslM8D8-0y;yo|&zT`}Z|
zW8gn&rV&j5^4?i=jf{) 7~vudV4_b~AzjsgYf%YosqTq6wV%F+^2%c(gjLtNPF|
zqR~Pb(D~#Ie!Ts$U_twMZd#(qVDO2b4^F&XxuWT=uMfa16_w8Ra!AO^#8|4mJk_yp
z-LbX6jhkNY2~6Sk6sBIi1`?{uj0_FBeYnU&SQYG5tG#Brjg;~Bg4wnWZtQFKA{o&7
zFyyd+pk$HKJMru(;bn}I_caSJR##ear$a2f6t@3=a
zR*=x3ZI^b6Yy$U&MYAbY#SYB)GVj>umOuM_;PtB{$^TFVr3~Z+-;I
zP*-mc9@krVm^}UWCo8sq-Ts(_K7`xGJyBgrqZ-_{n2(uu-F3^6wzi+&qin_2iEDCb95n5dq>p_O5DL*P@!3V2InJ{*tpx9@2C
zls_mKZAEtaKEPHTw8g)g;&W_}R|>ayp=+>>FgpfUNjHLWNhJw!U12<(RD|IL_!@A<
zTjrZ=b9%LJ7mB{jX^r0#a$t+~ME57m-RX03&pI>oHuB-&mt2Nn=(D#IA7>*T>gCyH|h(Gg6t-DpB;x`=ZA*3?sf?m3Eq*`{>kPb9nmM
zfW-{w*kJGlXY3M{vFS57`~{n{yUDG}h>hCd_S7(Or-^ip+%iJo
zB{;Z&S3zzF-A4Va)uy~#ap`(|cdhrPWHRp+K-ucIv;u`e;8cW(Wp_Ii+`+ir6Uwq3
z7tV6}*4J1=e^W$w9q2Id?%P*x)#kxF
zKAt|iSA0TL0nerrnc+Y%dD|)uP`gr$8zpFH(j}OsaGqH^C7$teq(;8#_0A7|2g$iR
z$-2ez3JPA|Cf^O+%+!7JG%u3cTy%%EQ1~Xpe1U^sqQ07e3p*r3X7meZSj(*sjNcGU
zQZv`LS5irJ16PCgH$N~L=y1(wtD!Nh!v%`N8RzpJRm#;~DfbI@GDB*FD6igF2fFRQ
zD6nuGtD!Tf45!QH%vf&OYq_-tg;J(#
zAGsYp^8>EzKZ&qvY9gO`l$-7>B0Sd32r@^Xa$f*VAmHW^PnisLOkUX=F{|2_8i;yV
z!x>gT_II%EP^MUTw>I#en5yoUSFdZGdKHLmv8m|Nij%QXYwjh!_{_i9i&?eiV7G#^
zW;)KHDle@nj5!(!#9Wz@tz~IU(i1}JF155q%XQXV$WSeXq)9OW#cQ0Ol$Ppd
zH~<>!8ttv}?oQgQzD9DCHn_{3T9X7cbAO}Htjo0KITMzy`{6j&|D=XZ<~dY|aXkaK
zCwmxIW`LKP?9-e}+QM52&=W$^fcws5_piD2Ie&o;)uB#B_ED3^Q+ZQoPUqISXRZX^
zz76m1{2R;pRr6R2K;{|Ilu~x_`DPhGl0zuuaVcxVeVtgk;E~x+7{^SlysD-fgm$LT
zw1gLXRknh`4-&U~Al#8K2Ew%P*n@2%
zx0I^oD_|2gIn^Z_7j~TY#6KJho=_gJaE$I&ENUpyfUW=7kv!pkT9UD)JQ``_eSNjf
zXi)EPwg|lxZo``I5qXzS@?CmB`kU*~jhe^(2QQvby_$9I!OuJY
b#4);)59=<+A+s!w{`wi~o1-groud8^wIwiR
literal 0
HcmV?d00001
From 5b949624f2f1de778bf9e41224b76fb3f82f418b Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Wed, 1 Mar 2017 04:58:33 -0600
Subject: [PATCH 202/904] MAGETWO-64937: Skip the orders with offline payment
method on case creation
- Removed an ability to submit Signifyd case for order placed with offline payment method
(cherry picked from commit 039ee4d)
---
.../Magento/Signifyd/Observer/PlaceOrder.php | 4 +-
.../_files/expected_array.php | 1 -
.../Test/Unit/Observer/PlaceOrderTest.php | 254 ++++++++++++++++++
.../Signifyd/etc/signifyd_payment_mapping.xml | 12 -
.../Signifyd/Observer/PlaceOrderTest.php | 181 +++++++++++++
5 files changed, 437 insertions(+), 15 deletions(-)
create mode 100644 app/code/Magento/Signifyd/Test/Unit/Observer/PlaceOrderTest.php
create mode 100644 dev/tests/integration/testsuite/Magento/Signifyd/Observer/PlaceOrderTest.php
diff --git a/app/code/Magento/Signifyd/Observer/PlaceOrder.php b/app/code/Magento/Signifyd/Observer/PlaceOrder.php
index d260de96c5a9e..cf5b03026bfb3 100644
--- a/app/code/Magento/Signifyd/Observer/PlaceOrder.php
+++ b/app/code/Magento/Signifyd/Observer/PlaceOrder.php
@@ -73,7 +73,7 @@ public function execute(Observer $observer)
}
/**
- * Creates signifyd case for single order
+ * Creates Signifyd case for single order with online payment method.
*
* @param OrderInterface $order
* @return void
@@ -81,7 +81,7 @@ public function execute(Observer $observer)
private function createCaseForOrder($order)
{
$orderId = $order->getEntityId();
- if (null === $orderId) {
+ if (null === $orderId || $order->getPayment()->getMethodInstance()->isOffline()) {
return;
}
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/PaymentMethodMapper/_files/expected_array.php b/app/code/Magento/Signifyd/Test/Unit/Model/PaymentMethodMapper/_files/expected_array.php
index 0578513ab228e..f4f60058be295 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/PaymentMethodMapper/_files/expected_array.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/PaymentMethodMapper/_files/expected_array.php
@@ -6,7 +6,6 @@
return [
'payment_method_1' => 'PAYMENT_CARD',
'payment_method_2' => 'PAYPAL_ACCOUNT',
- 'payment_method_2' => 'PAYPAL_ACCOUNT',
'payment_method_3' => 'CHECK',
'payment_method_4' => 'CASH',
'payment_method_5' => 'FREE'
diff --git a/app/code/Magento/Signifyd/Test/Unit/Observer/PlaceOrderTest.php b/app/code/Magento/Signifyd/Test/Unit/Observer/PlaceOrderTest.php
new file mode 100644
index 0000000000000..2c64b4a90101a
--- /dev/null
+++ b/app/code/Magento/Signifyd/Test/Unit/Observer/PlaceOrderTest.php
@@ -0,0 +1,254 @@
+config = $this->getMockBuilder(Config::class)
+ ->disableOriginalConstructor()
+ ->setMethods(['isActive'])
+ ->getMock();
+
+ $this->logger = $this->getMockBuilder(LoggerInterface::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->creationService = $this->getMockBuilder(CaseCreationServiceInterface::class)
+ ->disableOriginalConstructor()
+ ->setMethods(['createForOrder'])
+ ->getMock();
+
+ $this->observer = $this->getMockBuilder(Observer::class)
+ ->disableOriginalConstructor()
+ ->setMethods(['getEvent'])
+ ->getMock();
+
+ $this->event = $this->getMockBuilder(Event::class)
+ ->disableOriginalConstructor()
+ ->setMethods(['getData'])
+ ->getMock();
+
+ $this->placeOrder = new PlaceOrder(
+ $this->config,
+ $this->creationService,
+ $this->logger
+ );
+ }
+
+ /**
+ * Checks a test case when Signifyd module is disabled.
+ *
+ * @covers \Magento\Signifyd\Observer\PlaceOrder::execute
+ */
+ public function testExecuteWithDisabledModule()
+ {
+ $this->withActiveSignifydIntegration(false);
+
+ $this->creationService->expects(self::never())
+ ->method('createForOrder');
+
+ $this->placeOrder->execute($this->observer);
+ }
+
+ /**
+ * Checks a test case when the observer event returns empty an order entity.
+ *
+ * @covers \Magento\Signifyd\Observer\PlaceOrder::execute
+ */
+ public function testExecuteWithoutOrder()
+ {
+ $this->withActiveSignifydIntegration(true);
+ $this->withOrderEntity(null);
+
+ $this->creationService->expects(self::never())
+ ->method('createForOrder');
+
+ $this->placeOrder->execute($this->observer);
+ }
+
+ /**
+ * Checks a test case when the order placed with offline payment method.
+ *
+ * @covers \Magento\Signifyd\Observer\PlaceOrder::execute
+ */
+ public function testExecuteWithOfflinePayment()
+ {
+ $orderId = 1;
+ $this->withActiveSignifydIntegration(true);
+ $this->withOrderEntity($orderId);
+ $this->withAvailablePaymentMethod(false);
+
+ $this->creationService->expects(self::never())
+ ->method('createForOrder');
+
+ $this->placeOrder->execute($this->observer);
+ }
+
+ /**
+ * Checks a test case when case creation service fails.
+ *
+ * @covers \Magento\Signifyd\Observer\PlaceOrder::execute
+ */
+ public function testExecuteWithFailedCaseCreation()
+ {
+ $orderId = 1;
+ $exceptionMessage = __('Case with the same order id already exists.');
+
+ $this->withActiveSignifydIntegration(true);
+ $this->withOrderEntity($orderId);
+ $this->withAvailablePaymentMethod(true);
+
+ $this->creationService->method('createForOrder')
+ ->with(self::equalTo($orderId))
+ ->willThrowException(new AlreadyExistsException($exceptionMessage));
+
+ $this->logger->method('error')
+ ->with(self::equalTo($exceptionMessage));
+
+ $this->placeOrder->execute($this->observer);
+ }
+
+ /**
+ * Checks a test case when observer successfully calls case creation service.
+ *
+ * @covers \Magento\Signifyd\Observer\PlaceOrder::execute
+ */
+ public function testExecute()
+ {
+ $orderId = 1;
+
+ $this->withActiveSignifydIntegration(true);
+ $this->withOrderEntity($orderId);
+ $this->withAvailablePaymentMethod(true);
+
+ $this->creationService
+ ->method('createForOrder')
+ ->with(self::equalTo($orderId));
+
+ $this->logger->expects(self::never())
+ ->method('error');
+
+ $this->placeOrder->execute($this->observer);
+ }
+
+ /**
+ * Specifies order entity mock execution.
+ *
+ * @param int $orderId
+ * @return void
+ */
+ private function withOrderEntity($orderId)
+ {
+ $this->orderEntity = $this->getMockBuilder(OrderInterface::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->orderEntity->method('getEntityId')
+ ->willReturn($orderId);
+
+ $this->observer->method('getEvent')
+ ->willReturn($this->event);
+
+ $this->event->method('getData')
+ ->with('order')
+ ->willReturn($this->orderEntity);
+ }
+
+ /**
+ * Specifies config mock execution.
+ *
+ * @param bool $isActive
+ * @return void
+ */
+ private function withActiveSignifydIntegration($isActive)
+ {
+ $this->config->method('isActive')
+ ->willReturn($isActive);
+ }
+
+ /**
+ * Specifies payment method mock execution.
+ *
+ * @param bool $isAvailable
+ * @return void
+ */
+ private function withAvailablePaymentMethod($isAvailable)
+ {
+ /** @var MethodInterface|MockObject $paymentMethod */
+ $paymentMethod = $this->getMockBuilder(MethodInterface::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ /**
+ * The code depends on implementation but not interface
+ * because order payment implements two interfaces
+ */
+ /** @var Payment|MockObject $orderPayment */
+ $orderPayment = $this->getMockBuilder(Payment::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->orderEntity->method('getPayment')
+ ->willReturn($orderPayment);
+
+ $orderPayment->method('getMethodInstance')
+ ->willReturn($paymentMethod);
+
+ $paymentMethod->method('isOffline')
+ ->willReturn(!$isAvailable);
+ }
+}
diff --git a/app/code/Magento/Signifyd/etc/signifyd_payment_mapping.xml b/app/code/Magento/Signifyd/etc/signifyd_payment_mapping.xml
index cafea60dd2d79..24f722d9e7246 100644
--- a/app/code/Magento/Signifyd/etc/signifyd_payment_mapping.xml
+++ b/app/code/Magento/Signifyd/etc/signifyd_payment_mapping.xml
@@ -74,18 +74,6 @@
cybersource
PAYMENT_CARD
-
- checkmo
- CHECK
-
-
- banktransfer
- CHECK
-
-
- cashondelivery
- CASH
-
free
FREE
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Observer/PlaceOrderTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Observer/PlaceOrderTest.php
new file mode 100644
index 0000000000000..f0136aadd0cce
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Observer/PlaceOrderTest.php
@@ -0,0 +1,181 @@
+objectManager = Bootstrap::getObjectManager();
+
+ $this->creationService = $this->getMockBuilder(CaseCreationServiceInterface::class)
+ ->disableOriginalConstructor()
+ ->setMethods(['createForOrder'])
+ ->getMock();
+
+ $this->logger = $this->getMockBuilder(LoggerInterface::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->placeOrder = $this->objectManager->create(PlaceOrder::class, [
+ 'caseCreationService' => $this->creationService,
+ 'logger' => $this->logger
+ ]);
+ }
+
+ /**
+ * Checks a case when order placed with offline payment method.
+ *
+ * @covers \Magento\Signifyd\Observer\PlaceOrder::execute
+ * @magentoConfigFixture current_store fraud_protection/signifyd/active 1
+ * @magentoDataFixture Magento/Signifyd/_files/order_with_customer_and_two_simple_products.php
+ */
+ public function testExecuteWithOfflinePayment()
+ {
+ $order = $this->getOrder('100000005');
+ $this->creationService->expects(self::never())
+ ->method('createForOrder');
+
+ $event = $this->objectManager->create(
+ Event::class,
+ [
+ 'data' => ['order' => $order]
+ ]
+ );
+
+ /** @var Observer $observer */
+ $observer = $this->objectManager->get(Observer::class);
+ $observer->setEvent($event);
+
+ $this->placeOrder->execute($observer);
+ }
+
+ /**
+ * Checks a test case when order placed with online payment method.
+ *
+ * @covers \Magento\Signifyd\Observer\PlaceOrder::execute
+ * @magentoConfigFixture current_store fraud_protection/signifyd/active 1
+ * @magentoDataFixture Magento/Signifyd/_files/order_with_customer_and_two_simple_products.php
+ */
+ public function testExecute()
+ {
+ $order = $this->getOrder('100000001');
+
+ $this->creationService->expects(self::once())
+ ->method('createForOrder')
+ ->with(self::equalTo($order->getEntityId()));
+
+ $event = $this->objectManager->create(
+ Event::class,
+ [
+ 'data' => ['order' => $order]
+ ]
+ );
+
+ /** @var Observer $observer */
+ $observer = $this->objectManager->get(Observer::class);
+ $observer->setEvent($event);
+
+ $this->placeOrder->execute($observer);
+ }
+
+ /**
+ * Checks a test case when observer event contains two orders:
+ * one order with offline payment and one order with online payment.
+ *
+ * @covers \Magento\Signifyd\Observer\PlaceOrder::execute
+ * @magentoConfigFixture current_store fraud_protection/signifyd/active 1
+ * @magentoDataFixture Magento/Signifyd/_files/order_with_customer_and_two_simple_products.php
+ */
+ public function testExecuteWithMultipleOrders()
+ {
+ $orderWithOnlinePayment = $this->getOrder('100000001');
+ $orderWithOfflinePayment = $this->getOrder('100000005');
+
+ // this service mock should be called only once for the order with online payment method.
+ $this->creationService->expects(self::once())
+ ->method('createForOrder')
+ ->with(self::equalTo($orderWithOnlinePayment->getEntityId()));
+
+ $event = $this->objectManager->create(
+ Event::class,
+ [
+ 'data' => ['orders' => [$orderWithOfflinePayment, $orderWithOnlinePayment]]
+ ]
+ );
+
+ /** @var Observer $observer */
+ $observer = $this->objectManager->get(Observer::class);
+ $observer->setEvent($event);
+
+ $this->placeOrder->execute($observer);
+ }
+
+ /**
+ * Gets stored order.
+ *
+ * @param string $incrementId
+ * @return OrderInterface
+ */
+ private function getOrder($incrementId)
+ {
+ /** @var FilterBuilder $filterBuilder */
+ $filterBuilder = $this->objectManager->get(FilterBuilder::class);
+ $filters = [
+ $filterBuilder->setField(OrderInterface::INCREMENT_ID)
+ ->setValue($incrementId)
+ ->create()
+ ];
+
+ /** @var SearchCriteriaBuilder $searchCriteriaBuilder */
+ $searchCriteriaBuilder = $this->objectManager->get(SearchCriteriaBuilder::class);
+ $searchCriteria = $searchCriteriaBuilder->addFilters($filters)
+ ->create();
+
+ $orderRepository = $this->objectManager->get(OrderRepositoryInterface::class);
+ $orders = $orderRepository->getList($searchCriteria)
+ ->getItems();
+
+ $order = array_pop($orders);
+
+ return $order;
+ }
+}
From 41e68ca2915beae63c427da4d7a45b6a52993088 Mon Sep 17 00:00:00 2001
From: Dmytro Yushkin
Date: Fri, 17 Mar 2017 11:08:59 -0500
Subject: [PATCH 203/904] MAGETWO-66178: Update marketing information, order
page and order list with new labels
(cherry picked from commit 9d60d44)
---
.../Signifyd/Block/Adminhtml/CaseInfo.php | 46 -----------
.../Unit/Block/Adminhtml/CaseInfoTest.php | 80 -------------------
.../Magento/Signifyd/etc/adminhtml/system.xml | 4 +-
app/code/Magento/Signifyd/i18n/en_US.csv | 3 +-
.../view/adminhtml/templates/case_info.phtml | 10 +--
.../ui_component/sales_order_grid.xml | 2 +-
.../Signifyd/Block/Adminhtml/CaseInfoTest.php | 22 +++--
7 files changed, 16 insertions(+), 151 deletions(-)
diff --git a/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php b/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php
index 43c138bb5150f..a17f9f58f2976 100644
--- a/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php
+++ b/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php
@@ -78,30 +78,6 @@ public function isEmptyCase()
return $this->getCaseEntity() === null;
}
- /**
- * Gets case status
- *
- * @return string
- */
- public function getCaseStatus()
- {
- return $this->getCaseProperty('', function () {
- $caseStatusMap = [
- CaseInterface::STATUS_OPEN => __('Open'),
- CaseInterface::STATUS_PENDING => __('Pending'),
- CaseInterface::STATUS_PROCESSING => __('Processing'),
- CaseInterface::STATUS_FLAGGED => __('Flagged'),
- CaseInterface::STATUS_DISMISSED => __('Dismissed')
- ];
-
- $status = isset($caseStatusMap[$this->getCaseEntity()->getStatus()]) ?
- $caseStatusMap[$this->getCaseEntity()->getStatus()] :
- '';
-
- return $status;
- });
- }
-
/**
* Gets case guarantee disposition status.
*
@@ -127,28 +103,6 @@ public function getCaseGuaranteeDisposition()
});
}
- /**
- * Gets case review disposition status.
- *
- * @return string
- */
- public function getCaseReviewDisposition()
- {
- return $this->getCaseProperty('', function () {
- $reviewStatusMap = [
- CaseInterface::DISPOSITION_GOOD => __('Good'),
- CaseInterface::DISPOSITION_FRAUDULENT => __('Fraudulent'),
- CaseInterface::DISPOSITION_UNSET => __('Unset')
- ];
-
- $status = isset($reviewStatusMap[$this->getCaseEntity()->getReviewDisposition()]) ?
- $reviewStatusMap[$this->getCaseEntity()->getReviewDisposition()] :
- '';
-
- return $status;
- });
- }
-
/**
* Retrieves current order Id.
*
diff --git a/app/code/Magento/Signifyd/Test/Unit/Block/Adminhtml/CaseInfoTest.php b/app/code/Magento/Signifyd/Test/Unit/Block/Adminhtml/CaseInfoTest.php
index 0d046800d9523..b1c2aa023aa82 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Block/Adminhtml/CaseInfoTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Block/Adminhtml/CaseInfoTest.php
@@ -89,47 +89,6 @@ protected function setUp()
]);
}
- /**
- * Checks label according to Signifyd status.
- *
- * @param string $status
- * @param string $expectedLabel
- * @covers \Magento\Signifyd\Block\Adminhtml\CaseInfo::getCaseStatus()
- * @dataProvider getStatusLabelDataProvider
- */
- public function testGetCaseStatus($status, $expectedLabel)
- {
- $this->caseManagement->expects(self::once())
- ->method('getByOrderId')
- ->willReturn($this->caseEntity);
-
- $this->caseEntity->expects(self::atLeastOnce())
- ->method('getStatus')
- ->willReturn($status);
-
- self::assertEquals(
- $expectedLabel,
- $this->caseInfo->getCaseStatus()
- );
- }
-
- /**
- * Case status and corresponding label data provider.
- *
- * @return array
- */
- public function getStatusLabelDataProvider()
- {
- return [
- [CaseInterface::STATUS_OPEN, __('Open')],
- [CaseInterface::STATUS_PENDING, __('Pending')],
- [CaseInterface::STATUS_PROCESSING, __('Processing')],
- [CaseInterface::STATUS_FLAGGED, __('Flagged')],
- [CaseInterface::STATUS_DISMISSED, __('Dismissed')],
- ['Unregistered', '']
- ];
- }
-
/**
* Checks label according to Signifyd Guarantee Disposition.
*
@@ -172,45 +131,6 @@ public function getGuaranteeLabelDataProvider()
];
}
- /**
- * Checks label according to Signifyd Review Disposition.
- *
- * @param string $reviewDisposition
- * @param string $expectedLabel
- * @covers \Magento\Signifyd\Block\Adminhtml\CaseInfo::getCaseReviewDisposition()
- * @dataProvider getReviewLabelDataProvider
- */
- public function testGetReviewDisposition($reviewDisposition, $expectedLabel)
- {
- $this->caseManagement->expects(self::once())
- ->method('getByOrderId')
- ->willReturn($this->caseEntity);
-
- $this->caseEntity->expects(self::atLeastOnce())
- ->method('getReviewDisposition')
- ->willReturn($reviewDisposition);
-
- self::assertEquals(
- $expectedLabel,
- $this->caseInfo->getCaseReviewDisposition()
- );
- }
-
- /**
- * Case Review Disposition and corresponding label data provider.
- *
- * @return array
- */
- public function getReviewLabelDataProvider()
- {
- return [
- [CaseInterface::DISPOSITION_GOOD, __('Good')],
- [CaseInterface::DISPOSITION_FRAUDULENT, __('Fraudulent')],
- [CaseInterface::DISPOSITION_UNSET, __('Unset')],
- ['Unregistered', '']
- ];
- }
-
/**
* Checks case property getter with empty case.
*
diff --git a/app/code/Magento/Signifyd/etc/adminhtml/system.xml b/app/code/Magento/Signifyd/etc/adminhtml/system.xml
index 1da4c75cea0c3..e0a5fad5bf334 100644
--- a/app/code/Magento/Signifyd/etc/adminhtml/system.xml
+++ b/app/code/Magento/Signifyd/etc/adminhtml/system.xml
@@ -16,7 +16,7 @@
Magento\Signifyd\Block\Adminhtml\System\Config\Fieldset\Info
signifyd-about-header
-
+
Benefits:
@@ -24,7 +24,7 @@
Accept more orders and maximize your revenue
Automate order review and shift fraud off your plate ]]>
- https://www.signifyd.com/magento-ecommerce-fraud-protection-partner
+ https://www.signifyd.com/magento-guaranteed-fraud-protection
signifyd-about-header
diff --git a/app/code/Magento/Signifyd/i18n/en_US.csv b/app/code/Magento/Signifyd/i18n/en_US.csv
index dca6bcade0eb8..474efd51d03fe 100644
--- a/app/code/Magento/Signifyd/i18n/en_US.csv
+++ b/app/code/Magento/Signifyd/i18n/en_US.csv
@@ -40,4 +40,5 @@
"View our setup guide for step-by-step instructions on how to integrate Signifyd with Magento. For support contact support@signifyd.com ","View our setup guide for step-by-step instructions on how to integrate Signifyd with Magento. For support contact support@signifyd.com "
"Your API key can be found on the settings page in the Signifyd console","Your API key can be found on the settings page in the Signifyd console"
"Don’t change unless asked to do so.","Don’t change unless asked to do so."
-"Your webhook URL will be used to configure a guarantee completed webhook in Signifyd. Webhooks are used to sync Signifyd`s guarantee decisions back to Magento.","Your webhook URL will be used to configure a guarantee completed webhook in Signifyd. Webhooks are used to sync Signifyd`s guarantee decisions back to Magento."
\ No newline at end of file
+"Your webhook URL will be used to configure a guarantee completed webhook in Signifyd. Webhooks are used to sync Signifyd`s guarantee decisions back to Magento.","Your webhook URL will be used to configure a guarantee completed webhook in Signifyd. Webhooks are used to sync Signifyd`s guarantee decisions back to Magento."
+"Signifyd Guarantee Decision","Signifyd Guarantee Decision"
\ No newline at end of file
diff --git a/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml b/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml
index fef28b05ebb8c..07d4bb4f656d7 100644
--- a/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml
+++ b/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml
@@ -23,17 +23,9 @@
- escapeHtml(__('Case Status')); ?>
- escapeHtml($block->getCaseStatus()); ?>
-
-
- escapeHtml(__('Guarantee Disposition')); ?>
+ escapeHtml(__('Signifyd Guarantee Decision')); ?>
escapeHtml($block->getCaseGuaranteeDisposition()); ?>
-
- escapeHtml(__('Review Disposition')); ?>
- escapeHtml($block->getCaseReviewDisposition()); ?>
-
diff --git a/app/code/Magento/Signifyd/view/adminhtml/ui_component/sales_order_grid.xml b/app/code/Magento/Signifyd/view/adminhtml/ui_component/sales_order_grid.xml
index 324dc089d3dfb..1a6515e69c3d6 100644
--- a/app/code/Magento/Signifyd/view/adminhtml/ui_component/sales_order_grid.xml
+++ b/app/code/Magento/Signifyd/view/adminhtml/ui_component/sales_order_grid.xml
@@ -15,7 +15,7 @@
- select
- Magento_Ui/js/grid/columns/select
- select
- - Signifyd Guarantee Status
+ - Signifyd Guarantee Decision
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Block/Adminhtml/CaseInfoTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Block/Adminhtml/CaseInfoTest.php
index 1f55beea98a37..48b2b33513a6a 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Block/Adminhtml/CaseInfoTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Block/Adminhtml/CaseInfoTest.php
@@ -51,7 +51,7 @@ public function testModuleIsInactive()
{
$this->order->loadByIncrementId('100000001');
- static::assertNotEmpty($this->getBlockContents());
+ static::assertNotEmpty($this->getBlock()->toHtml());
}
/**
@@ -67,14 +67,13 @@ public function testCaseEntityNotExists()
{
$this->order->loadByIncrementId('100000001');
- static::assertEmpty($this->getBlockContents());
+ static::assertEmpty($this->getBlock()->toHtml());
}
/**
* Checks that:
* - block give contents
- * - associated team displays correct
- * - score class displays correct
+ * - block contents guarantee decision field
*
* @covers \Magento\Signifyd\Block\Adminhtml\CaseInfo::getScoreClass
* @magentoConfigFixture current_store fraud_protection/signifyd/active 1
@@ -85,18 +84,17 @@ public function testCaseEntityExists()
{
$this->order->loadByIncrementId('100000001');
- $html = $this->getBlockContents();
- static::assertNotEmpty($html);
- static::assertContains('Processing', $html);
- static::assertContains('Good', $html);
+ $block = $this->getBlock();
+ static::assertNotEmpty($block->toHtml());
+ static::assertContains((string) $block->getCaseGuaranteeDisposition(), $block->toHtml());
}
/**
- * Renders block contents.
+ * Gets block.
*
- * @return string
+ * @return CaseInfo
*/
- private function getBlockContents()
+ private function getBlock()
{
$this->layout->addContainer('order_additional_info', 'Container');
@@ -105,7 +103,7 @@ private function getBlockContents()
$block->setAttribute('context', $this->getContext());
$block->setTemplate('Magento_Signifyd::case_info.phtml');
- return $block->toHtml();
+ return $block;
}
/**
From cceba9543dda14bd2ab2d637153d66c7c2338e36 Mon Sep 17 00:00:00 2001
From: Dmytro Yushkin
Date: Mon, 20 Mar 2017 08:35:41 -0500
Subject: [PATCH 204/904] MAGETWO-65119: Create/update automated functional
tests
- Guarantee cancel flow using plugins now
- Webhook wait functions deleted
(cherry picked from commit 8a8759d)
---
.../Magento/Signifyd/Observer/CancelOrder.php | 73 ------------------
.../Magento/Signifyd/Plugin/OrderPlugin.php | 51 ++++++++++++
.../Magento/Signifyd/Plugin/PaymentPlugin.php | 77 +++++++++++++++++++
.../Magento/Signifyd/etc/adminhtml/di.xml | 6 ++
app/code/Magento/Signifyd/etc/events.xml | 3 -
5 files changed, 134 insertions(+), 76 deletions(-)
delete mode 100644 app/code/Magento/Signifyd/Observer/CancelOrder.php
create mode 100644 app/code/Magento/Signifyd/Plugin/OrderPlugin.php
create mode 100644 app/code/Magento/Signifyd/Plugin/PaymentPlugin.php
diff --git a/app/code/Magento/Signifyd/Observer/CancelOrder.php b/app/code/Magento/Signifyd/Observer/CancelOrder.php
deleted file mode 100644
index 2710f89be3d24..0000000000000
--- a/app/code/Magento/Signifyd/Observer/CancelOrder.php
+++ /dev/null
@@ -1,73 +0,0 @@
-config = $config;
- $this->guaranteeAbility = $guaranteeAbility;
- $this->cancelingService = $cancelingService;
- }
-
- /**
- * @inheritdoc
- */
- public function execute(Observer $observer)
- {
- if (!$this->config->isActive()) {
- return;
- }
-
- /** @var OrderInterface $order */
- $order = $observer->getEvent()
- ->getDataByKey('order');
-
- if ($order === null) {
- return;
- }
-
- if ($this->guaranteeAbility->isAvailable($order->getEntityId())) {
- $this->cancelingService->cancelForOrder($order->getEntityId());
- }
- }
-}
diff --git a/app/code/Magento/Signifyd/Plugin/OrderPlugin.php b/app/code/Magento/Signifyd/Plugin/OrderPlugin.php
new file mode 100644
index 0000000000000..584f2d3e3ac2f
--- /dev/null
+++ b/app/code/Magento/Signifyd/Plugin/OrderPlugin.php
@@ -0,0 +1,51 @@
+guaranteeCancelingService = $guaranteeCancelingService;
+ }
+
+ /**
+ * Performs Signifyd guarantee cancel operation after order canceling
+ * if cancel order operation was successful.
+ *
+ * @param Order $order
+ * @param OrderInterface $result
+ * @return OrderInterface
+ */
+ public function afterCancel(Order $order, $result)
+ {
+ if ($order->isCanceled()) {
+ $this->guaranteeCancelingService->cancelForOrder(
+ $order->getEntityId()
+ );
+ }
+
+ return $result;
+ }
+}
diff --git a/app/code/Magento/Signifyd/Plugin/PaymentPlugin.php b/app/code/Magento/Signifyd/Plugin/PaymentPlugin.php
new file mode 100644
index 0000000000000..2949cd01fbfda
--- /dev/null
+++ b/app/code/Magento/Signifyd/Plugin/PaymentPlugin.php
@@ -0,0 +1,77 @@
+guaranteeCancelingService = $guaranteeCancelingService;
+ $this->registry = $registry;
+ }
+
+ /**
+ * Performs Signifyd guarantee cancel operation after payment denying.
+ *
+ * @param MethodInterface $subject
+ * @param MethodInterface|bool $result
+ * @return MethodInterface|bool
+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)
+ */
+ public function afterDenyPayment(MethodInterface $subject, $result)
+ {
+ /** @var \Magento\Sales\Api\Data\OrderInterface $order */
+ $order = $this->registry->registry('current_order');
+
+ if ($this->isPaymentDenied($order->getPayment(), $result)) {
+ $this->guaranteeCancelingService->cancelForOrder(
+ $order->getEntityId()
+ );
+ }
+
+ return $result;
+ }
+
+ /**
+ * Checks if deny payment operation was successful.
+ *
+ * Result not false check for payment methods using AbstractMethod.
+ * Transaction is closed check for payment methods using Gateway.
+ *
+ * @param \Magento\Sales\Api\Data\OrderPaymentInterface $payment
+ * @param MethodInterface $result
+ * @return bool
+ */
+ private function isPaymentDenied($payment, $result)
+ {
+ return $result !== false || $payment->getIsTransactionClosed();
+ }
+}
diff --git a/app/code/Magento/Signifyd/etc/adminhtml/di.xml b/app/code/Magento/Signifyd/etc/adminhtml/di.xml
index 1c827afa99dbc..0a64a591ccd3b 100644
--- a/app/code/Magento/Signifyd/etc/adminhtml/di.xml
+++ b/app/code/Magento/Signifyd/etc/adminhtml/di.xml
@@ -7,4 +7,10 @@
-->
+
+
+
+
+
+
diff --git a/app/code/Magento/Signifyd/etc/events.xml b/app/code/Magento/Signifyd/etc/events.xml
index 17cbe99ec96a1..c5e69449793a5 100644
--- a/app/code/Magento/Signifyd/etc/events.xml
+++ b/app/code/Magento/Signifyd/etc/events.xml
@@ -9,7 +9,4 @@
-
-
-
From bc676a7ab0ef4ee471715e0df17a92cd88929575 Mon Sep 17 00:00:00 2001
From: Dmytro Yushkin
Date: Mon, 20 Mar 2017 09:01:39 -0500
Subject: [PATCH 205/904] MAGETWO-65119: Create/update automated functional
tests
- Added constraint into deny payment testcase
- Covered cancel and deny flow with integration tests
- Added delete customer step to functional test
(cherry picked from commit 8d21c24)
---
.../Magento/Signifyd/Plugin/OrderPlugin.php | 5 +-
.../Magento/Signifyd/Plugin/PaymentPlugin.php | 5 +-
.../Test/Unit/Observer/CancelOrderTest.php | 209 -----------------
.../Magento/Signifyd/etc/adminhtml/di.xml | 6 -
app/code/Magento/Signifyd/etc/di.xml | 6 +
.../{Observer => Plugin}/CancelOrderTest.php | 12 +-
.../Signifyd/Plugin/DenyPaymentTest.php | 218 ++++++++++++++++++
7 files changed, 237 insertions(+), 224 deletions(-)
delete mode 100644 app/code/Magento/Signifyd/Test/Unit/Observer/CancelOrderTest.php
rename dev/tests/integration/testsuite/Magento/Signifyd/{Observer => Plugin}/CancelOrderTest.php (92%)
create mode 100644 dev/tests/integration/testsuite/Magento/Signifyd/Plugin/DenyPaymentTest.php
diff --git a/app/code/Magento/Signifyd/Plugin/OrderPlugin.php b/app/code/Magento/Signifyd/Plugin/OrderPlugin.php
index 584f2d3e3ac2f..0d8ea10529c9e 100644
--- a/app/code/Magento/Signifyd/Plugin/OrderPlugin.php
+++ b/app/code/Magento/Signifyd/Plugin/OrderPlugin.php
@@ -10,9 +10,9 @@
use Magento\Signifyd\Api\GuaranteeCancelingServiceInterface;
/**
- * Plugin complements Order::cancel method logic with canceling Signifyd guarantee.
+ * Plugin for Magento\Sales\Model\Order.
*
- * @see Order::cancel
+ * @see Order
*/
class OrderPlugin
{
@@ -34,6 +34,7 @@ public function __construct(
* Performs Signifyd guarantee cancel operation after order canceling
* if cancel order operation was successful.
*
+ * @see Order::cancel
* @param Order $order
* @param OrderInterface $result
* @return OrderInterface
diff --git a/app/code/Magento/Signifyd/Plugin/PaymentPlugin.php b/app/code/Magento/Signifyd/Plugin/PaymentPlugin.php
index 2949cd01fbfda..3cec11bee82ce 100644
--- a/app/code/Magento/Signifyd/Plugin/PaymentPlugin.php
+++ b/app/code/Magento/Signifyd/Plugin/PaymentPlugin.php
@@ -10,9 +10,9 @@
use Magento\Signifyd\Api\GuaranteeCancelingServiceInterface;
/**
- * Plugin complements MethodInterface::denyPayment method logic with canceling Signifyd guarantee.
+ * Plugin for Magento\Payment\Model\MethodInterface.
*
- * @see MethodInterface::denyPayment
+ * @see MethodInterface
*/
class PaymentPlugin
{
@@ -41,6 +41,7 @@ public function __construct(
/**
* Performs Signifyd guarantee cancel operation after payment denying.
*
+ * @see MethodInterface::denyPayment
* @param MethodInterface $subject
* @param MethodInterface|bool $result
* @return MethodInterface|bool
diff --git a/app/code/Magento/Signifyd/Test/Unit/Observer/CancelOrderTest.php b/app/code/Magento/Signifyd/Test/Unit/Observer/CancelOrderTest.php
deleted file mode 100644
index f3d52e31776ef..0000000000000
--- a/app/code/Magento/Signifyd/Test/Unit/Observer/CancelOrderTest.php
+++ /dev/null
@@ -1,209 +0,0 @@
-config = $this->getMockBuilder(Config::class)
- ->disableOriginalConstructor()
- ->setMethods(['isActive'])
- ->getMock();
-
- $this->guaranteeAbility = $this->getMockBuilder(CancelGuaranteeAbility::class)
- ->disableOriginalConstructor()
- ->setMethods(['isAvailable'])
- ->getMock();
-
- $this->cancelingService = $this->getMockBuilder(GuaranteeCancelingServiceInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
-
- $this->observer = $objectManager->getObject(CancelOrder::class, [
- 'config' => $this->config,
- 'guaranteeAbility' => $this->guaranteeAbility,
- 'cancelingService' => $this->cancelingService
- ]);
- }
-
- /**
- * Checks a test case, when Signifyd does not enabled.
- *
- * @covers \Magento\Signifyd\Observer\CancelOrder::execute
- */
- public function testExecuteWithDisabledConfiguration()
- {
- $order = null;
- $this->config->expects(self::once())
- ->method('isActive')
- ->willReturn(false);
-
- $this->guaranteeAbility->expects(self::never())
- ->method('isAvailable');
-
- $this->cancelingService->expects(self::never())
- ->method('cancelForOrder');
-
- /** @var Observer|MockObject $observer */
- $observer = $this->getObserverMock($order);
- $this->observer->execute($observer);
- }
-
- /**
- * Checks a test case, when not order entity in observer event.
- *
- * @covers \Magento\Signifyd\Observer\CancelOrder::execute
- */
- public function testExecuteWithNonExistsOrder()
- {
- $order = null;
- $this->config->expects(self::once())
- ->method('isActive')
- ->willReturn(true);
-
- $this->guaranteeAbility->expects(self::never())
- ->method('isAvailable');
-
- $this->cancelingService->expects(self::never())
- ->method('cancelForOrder');
-
- /** @var Observer|MockObject $observer */
- $observer = $this->getObserverMock($order);
- $this->observer->execute($observer);
- }
-
- /**
- * Checks a case, when case guarantee is not available for cancelling.
- *
- * @covers \Magento\Signifyd\Observer\CancelOrder::execute
- */
- public function testExecuteWithNonEligibleGuarantee()
- {
- $entityId = 1;
- /** @var OrderInterface|MockObject $order */
- $order = $this->getMockBuilder(OrderInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
- $order->expects(self::once())
- ->method('getEntityId')
- ->willReturn($entityId);
-
- $this->config->expects(self::once())
- ->method('isActive')
- ->willReturn(true);
-
- $this->guaranteeAbility->expects(self::once())
- ->method('isAvailable')
- ->with(self::equalTo($entityId))
- ->willReturn(false);
-
- $this->cancelingService->expects(self::never())
- ->method('cancelForOrder');
-
- /** @var Observer|MockObject $observer */
- $observer = $this->getObserverMock($order);
- $this->observer->execute($observer);
- }
-
- /**
- * Checks a case, when case guarantee submitted for cancelling.
- *
- * @covers \Magento\Signifyd\Observer\CancelOrder::execute
- */
- public function testExecute()
- {
- $entityId = 1;
- /** @var OrderInterface|MockObject $order */
- $order = $this->getMockBuilder(OrderInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
- $order->expects(self::exactly(2))
- ->method('getEntityId')
- ->willReturn($entityId);
-
- $this->config->expects(self::once())
- ->method('isActive')
- ->willReturn(true);
-
- $this->guaranteeAbility->expects(self::once())
- ->method('isAvailable')
- ->with(self::equalTo($entityId))
- ->willReturn(true);
-
- $this->cancelingService->expects(self::once())
- ->method('cancelForOrder')
- ->with(self::equalTo($entityId));
-
- /** @var Observer|MockObject $observer */
- $observer = $this->getObserverMock($order);
- $this->observer->execute($observer);
- }
-
- /**
- * Gets mock object for observer.
- *
- * @param OrderInterface|null $order
- * @return Observer|MockObject
- */
- private function getObserverMock($order)
- {
- $observer = $this->getMockBuilder(Observer::class)
- ->disableOriginalConstructor()
- ->getMock();
-
- $event = $this->getMockBuilder(Event::class)
- ->disableOriginalConstructor()
- ->setMethods(['getDataByKey'])
- ->getMock();
-
- $observer->expects(self::any())
- ->method('getEvent')
- ->willReturn($event);
-
- $event->expects(self::any())
- ->method('getDataByKey')
- ->with('order')
- ->willReturn($order);
-
- return $observer;
- }
-}
diff --git a/app/code/Magento/Signifyd/etc/adminhtml/di.xml b/app/code/Magento/Signifyd/etc/adminhtml/di.xml
index 0a64a591ccd3b..1c827afa99dbc 100644
--- a/app/code/Magento/Signifyd/etc/adminhtml/di.xml
+++ b/app/code/Magento/Signifyd/etc/adminhtml/di.xml
@@ -7,10 +7,4 @@
-->
-
-
-
-
-
-
diff --git a/app/code/Magento/Signifyd/etc/di.xml b/app/code/Magento/Signifyd/etc/di.xml
index e873548ed26ba..551da4f023a56 100644
--- a/app/code/Magento/Signifyd/etc/di.xml
+++ b/app/code/Magento/Signifyd/etc/di.xml
@@ -106,4 +106,10 @@
PaymentMethodConfigData
+
+
+
+
+
+
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Observer/CancelOrderTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Plugin/CancelOrderTest.php
similarity index 92%
rename from dev/tests/integration/testsuite/Magento/Signifyd/Observer/CancelOrderTest.php
rename to dev/tests/integration/testsuite/Magento/Signifyd/Plugin/CancelOrderTest.php
index 94f1779312f1f..4a7be25913a81 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Observer/CancelOrderTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Plugin/CancelOrderTest.php
@@ -3,7 +3,7 @@
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-namespace Magento\Signifyd\Observer;
+namespace Magento\Signifyd\Plugin;
use Magento\Framework\Api\FilterBuilder;
use Magento\Framework\Api\SearchCriteriaBuilder;
@@ -58,13 +58,14 @@ protected function tearDown()
}
/**
- * Checks a test case, when order has been cancelled and triggers event to cancel Signifyd case guarantee
+ * Checks a test case, when order has been cancelled
+ * and calls plugin to cancel Signifyd case guarantee.
*
- * @covers \Magento\Signifyd\Observer\CancelOrder::execute
+ * @covers \Magento\Signifyd\Plugin\OrderPlugin::afterCancel
* @magentoDataFixture Magento/Signifyd/_files/approved_case.php
* @magentoConfigFixture current_store fraud_protection/signifyd/active 1
*/
- public function testExecute()
+ public function testAfterCancel()
{
$order = $this->getOrder();
@@ -93,7 +94,8 @@ public function testExecute()
}
/**
- * Get stored order
+ * Get stored order.
+ *
* @return OrderInterface
*/
private function getOrder()
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Plugin/DenyPaymentTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Plugin/DenyPaymentTest.php
new file mode 100644
index 0000000000000..e6b249221a36f
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Plugin/DenyPaymentTest.php
@@ -0,0 +1,218 @@
+objectManager = Bootstrap::getObjectManager();
+
+ $this->apiClient = $this->getMockBuilder(ApiClient::class)
+ ->disableOriginalConstructor()
+ ->setMethods(['makeApiCall'])
+ ->getMock();
+
+ $this->registry = $this->objectManager->get(Registry::class);
+
+ $this->objectManager->addSharedInstance($this->apiClient, ApiClient::class);
+ }
+
+ /**
+ * @inheritdoc
+ */
+ protected function tearDown()
+ {
+ $this->objectManager->removeSharedInstance(ApiClient::class);
+ }
+
+ /**
+ * Checks a test case, when payment has been denied
+ * and calls plugin to cancel Signifyd case guarantee.
+ *
+ * @covers \Magento\Signifyd\Plugin\PaymentPlugin::afterDenyPayment
+ * @magentoDataFixture Magento/Signifyd/_files/approved_case.php
+ * @magentoConfigFixture current_store fraud_protection/signifyd/active 1
+ */
+ public function testAfterDenyPayment()
+ {
+ $order = $this->getOrder();
+ $this->registry->register('current_order', $order);
+
+ $this->apiClient->expects(self::once())
+ ->method('makeApiCall')
+ ->with(
+ self::equalTo('/cases/' . self::$caseId . '/guarantee'),
+ 'PUT',
+ [
+ 'guaranteeDisposition' => CaseInterface::GUARANTEE_CANCELED
+ ]
+ )
+ ->willReturn([
+ 'disposition' => CaseInterface::GUARANTEE_CANCELED
+ ]);
+
+ /** @var \Magento\Sales\Model\Order\Payment $payment */
+ $payment = $order->getPayment();
+ $payment->setData('method_instance', $this->getMethodInstance());
+ $payment->deny();
+
+ /** @var CaseRepositoryInterface $caseRepository */
+ $caseRepository = $this->objectManager->get(CaseRepositoryInterface::class);
+ $case = $caseRepository->getByCaseId(self::$caseId);
+
+ self::assertEquals(CaseInterface::GUARANTEE_CANCELED, $case->getGuaranteeDisposition());
+ }
+
+ /**
+ * Get stored order.
+ *
+ * @return OrderInterface
+ */
+ private function getOrder()
+ {
+ /** @var FilterBuilder $filterBuilder */
+ $filterBuilder = $this->objectManager->get(FilterBuilder::class);
+ $filters = [
+ $filterBuilder->setField(OrderInterface::INCREMENT_ID)
+ ->setValue('100000001')
+ ->create()
+ ];
+
+ /** @var SearchCriteriaBuilder $searchCriteriaBuilder */
+ $searchCriteriaBuilder = $this->objectManager->get(SearchCriteriaBuilder::class);
+ $searchCriteria = $searchCriteriaBuilder->addFilters($filters)
+ ->create();
+
+ $orderRepository = $this->objectManager->get(OrderRepositoryInterface::class);
+ $orders = $orderRepository->getList($searchCriteria)
+ ->getItems();
+
+ /** @var OrderInterface $order */
+ return array_pop($orders);
+ }
+
+ /**
+ * Gets payment method instance.
+ *
+ * @return Express
+ */
+ private function getMethodInstance()
+ {
+ /** @var PaymentInfo $infoInstance */
+ $infoInstance = $this->objectManager->get(PaymentInfo::class);
+ $infoInstance->setAdditionalInformation(
+ Info::PAYMENT_STATUS_GLOBAL,
+ Info::PAYMENTSTATUS_PENDING
+ );
+ $infoInstance->setAdditionalInformation(
+ Info::PENDING_REASON_GLOBAL,
+ Info::PAYMENTSTATUS_PENDING
+ );
+
+ /** @var Express $methodInstance */
+ $methodInstance = $this->objectManager->create(
+ Express::class,
+ ['proFactory' => $this->getProFactory()]
+ );
+ $methodInstance->setData('info_instance', $infoInstance);
+
+ return $methodInstance;
+ }
+
+ /**
+ * Gets Pro factory mock.
+ *
+ * @return ProFactory|MockObject
+ */
+ protected function getProFactory()
+ {
+ $pro = $this->getMockBuilder(Pro::class)
+ ->disableOriginalConstructor()
+ ->setMethods(['getApi', 'setMethod', 'getConfig', '__wakeup', 'reviewPayment'])
+ ->getMock();
+ $nvpClient = $this->getMockBuilder(Nvp::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $pro->method('getConfig')
+ ->willReturn($this->getConfig());
+ $pro->method('getApi')
+ ->willReturn($nvpClient);
+ $pro->method('reviewPayment')
+ ->willReturn(true);
+
+ $proFactory = $this->getMockBuilder(ProFactory::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+ $proFactory->method('create')
+ ->willReturn($pro);
+
+ return $proFactory;
+ }
+
+ /**
+ * Gets config mock.
+ *
+ * @return Config|MockObject
+ */
+ protected function getConfig()
+ {
+ $config = $this->getMockBuilder(Config::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+ $config->method('getValue')
+ ->with('payment_action')
+ ->willReturn(Config::PAYMENT_ACTION_AUTH);
+
+ return $config;
+ }
+}
From 370f13da3983d2c4153e28ccda720fbc3883f1bd Mon Sep 17 00:00:00 2001
From: Dmytro Yushkin
Date: Thu, 23 Mar 2017 04:51:33 -0500
Subject: [PATCH 206/904] MAGETWO-65119: Create/update automated functional
tests
- Reimplemented customer cleanup logic
(cherry picked from commit deb655f)
---
.../TestStep/SignifydCreateCustomerStep.php | 76 +++++++++++++++++++
1 file changed, 76 insertions(+)
create mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/TestStep/SignifydCreateCustomerStep.php
diff --git a/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestStep/SignifydCreateCustomerStep.php b/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestStep/SignifydCreateCustomerStep.php
new file mode 100644
index 0000000000000..ca57d7c3b97b6
--- /dev/null
+++ b/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestStep/SignifydCreateCustomerStep.php
@@ -0,0 +1,76 @@
+customer = $customer;
+ $this->testStepFactory = $testStepFactory;
+ }
+
+ /**
+ * Run step flow.
+ *
+ * @return void
+ */
+ public function run()
+ {
+ $this->getStepInstance(CreateCustomerStep::class)->run();
+ }
+
+ /**
+ * @return void
+ */
+ public function cleanup()
+ {
+ $this->getStepInstance(DeleteCustomerStep::class)->run();
+ }
+
+ /**
+ * Creates test step instance with preset params.
+ *
+ * @param string $class
+ * @return TestStepInterface
+ */
+ private function getStepInstance($class)
+ {
+ return $this->testStepFactory->create(
+ $class,
+ ['customer' => $this->customer]
+ );
+ }
+}
From acd54ab58f613b81455eae5cefb8a992556c9a67 Mon Sep 17 00:00:00 2001
From: Dmytro Yushkin
Date: Mon, 27 Mar 2017 05:35:17 -0500
Subject: [PATCH 207/904] MAGETWO-65119: Create/update automated functional
tests
- Added cleanup for customer
(cherry picked from commit 5f03007)
---
.../Signifyd/Test/TestStep/SignifydCreateCustomerStep.php | 1 +
1 file changed, 1 insertion(+)
diff --git a/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestStep/SignifydCreateCustomerStep.php b/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestStep/SignifydCreateCustomerStep.php
index ca57d7c3b97b6..039c8c50da3f9 100644
--- a/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestStep/SignifydCreateCustomerStep.php
+++ b/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestStep/SignifydCreateCustomerStep.php
@@ -57,6 +57,7 @@ public function run()
*/
public function cleanup()
{
+ $this->getStepInstance(CreateCustomerStep::class)->cleanup();
$this->getStepInstance(DeleteCustomerStep::class)->run();
}
From 89f3f7568afc5164f5a0fbbc1a9ac3076ca54b3b Mon Sep 17 00:00:00 2001
From: Dmytro Yushkin
Date: Wed, 29 Mar 2017 10:06:36 -0500
Subject: [PATCH 208/904] MAGETWO-65119: Create/update automated functional
tests
- Fixed usage of registry in plugin
(cherry picked from commit 5bab362)
---
.../Magento/Signifyd/Plugin/PaymentPlugin.php | 31 ++++++-------------
1 file changed, 10 insertions(+), 21 deletions(-)
diff --git a/app/code/Magento/Signifyd/Plugin/PaymentPlugin.php b/app/code/Magento/Signifyd/Plugin/PaymentPlugin.php
index 3cec11bee82ce..031cdac6738b2 100644
--- a/app/code/Magento/Signifyd/Plugin/PaymentPlugin.php
+++ b/app/code/Magento/Signifyd/Plugin/PaymentPlugin.php
@@ -5,7 +5,7 @@
*/
namespace Magento\Signifyd\Plugin;
-use Magento\Framework\Registry;
+use Magento\Payment\Model\InfoInterface;
use Magento\Payment\Model\MethodInterface;
use Magento\Signifyd\Api\GuaranteeCancelingServiceInterface;
@@ -21,41 +21,30 @@ class PaymentPlugin
*/
private $guaranteeCancelingService;
- /**
- * @var Registry
- */
- private $registry;
-
/**
* @param GuaranteeCancelingServiceInterface $guaranteeCancelingService
- * @param Registry $registry
*/
public function __construct(
- GuaranteeCancelingServiceInterface $guaranteeCancelingService,
- Registry $registry
+ GuaranteeCancelingServiceInterface $guaranteeCancelingService
) {
$this->guaranteeCancelingService = $guaranteeCancelingService;
- $this->registry = $registry;
}
/**
* Performs Signifyd guarantee cancel operation after payment denying.
*
* @see MethodInterface::denyPayment
+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)
+ *
* @param MethodInterface $subject
* @param MethodInterface|bool $result
- * @return MethodInterface|bool
- * @SuppressWarnings(PHPMD.UnusedFormalParameter)
+ * @param InfoInterface $payment
+ * @return bool|MethodInterface
*/
- public function afterDenyPayment(MethodInterface $subject, $result)
+ public function afterDenyPayment(MethodInterface $subject, $result, InfoInterface $payment)
{
- /** @var \Magento\Sales\Api\Data\OrderInterface $order */
- $order = $this->registry->registry('current_order');
-
- if ($this->isPaymentDenied($order->getPayment(), $result)) {
- $this->guaranteeCancelingService->cancelForOrder(
- $order->getEntityId()
- );
+ if ($this->isPaymentDenied($payment, $result)) {
+ $this->guaranteeCancelingService->cancelForOrder($payment->getParentId());
}
return $result;
@@ -67,7 +56,7 @@ public function afterDenyPayment(MethodInterface $subject, $result)
* Result not false check for payment methods using AbstractMethod.
* Transaction is closed check for payment methods using Gateway.
*
- * @param \Magento\Sales\Api\Data\OrderPaymentInterface $payment
+ * @param InfoInterface $payment
* @param MethodInterface $result
* @return bool
*/
From 3dee91d1d26ed55c6aafcef95fd062c67ea57e0e Mon Sep 17 00:00:00 2001
From: Dmytro Yushkin
Date: Fri, 31 Mar 2017 06:09:39 -0500
Subject: [PATCH 209/904] MAGETWO-63642: Update Order Status Based on Signifyd
Guarantee Status
- Fixed copyrights
(cherry picked from commit aff5cd9)
---
app/code/Magento/Signifyd/Model/OrderStateService.php | 2 +-
app/code/Magento/Signifyd/Plugin/OrderPlugin.php | 2 +-
app/code/Magento/Signifyd/Plugin/PaymentPlugin.php | 2 +-
.../Magento/Signifyd/Test/Unit/Model/OrderStateServiceTest.php | 2 +-
.../Signifyd/Test/TestStep/SignifydCreateCustomerStep.php | 2 +-
.../testsuite/Magento/Signifyd/Plugin/DenyPaymentTest.php | 2 +-
.../testsuite/Magento/Signifyd/_files/declined_case.php | 2 +-
7 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/app/code/Magento/Signifyd/Model/OrderStateService.php b/app/code/Magento/Signifyd/Model/OrderStateService.php
index 8acb9e28a52eb..47e3c7a4d1f14 100644
--- a/app/code/Magento/Signifyd/Model/OrderStateService.php
+++ b/app/code/Magento/Signifyd/Model/OrderStateService.php
@@ -1,6 +1,6 @@
Date: Tue, 11 Apr 2017 03:57:35 -0500
Subject: [PATCH 210/904] MAGETWO-67298: Push the file (Signifyd readme) to the
repo
(cherry picked from commit 726cf75)
---
app/code/Magento/Signifyd/README.md | 144 ++++++++++++++--------------
1 file changed, 73 insertions(+), 71 deletions(-)
diff --git a/app/code/Magento/Signifyd/README.md b/app/code/Magento/Signifyd/README.md
index 6ade95e78c2a5..149bd9d6401a0 100644
--- a/app/code/Magento/Signifyd/README.md
+++ b/app/code/Magento/Signifyd/README.md
@@ -1,76 +1,78 @@
-# The Magento Signifyd module overview
+# Magento_Signifyd module
-The Magento_Signifyd module provides integration with the [Signifyd](https://www.signifyd.com/) fraud protection tool.
+## Overview
-## Introduction
+The Magento_Signifyd module provides integration with the [Signifyd](https://www.signifyd.com/) fraud protection system. The integration is based on the Signifyd API; see the [Signifyd API docs](https://www.signifyd.com/docs/api/#/introduction/) for technical details.
The module implementation allows to:
- - create the Signifyd [case](https://www.signifyd.com/docs/api/#/reference/cases) for a placed order
- - automatically receive the Signifyd [guarantee](https://www.signifyd.com/docs/api/#/reference/guarantees) for a created case
- - automatically cancel a guarantee when the order is canceled.
-
-Magento integration uses the Signifyd API; see the [Signifyd API docs](https://www.signifyd.com/docs/api/#/introduction/) for technical details.
-
-For external developers, the module contains these extension points (marked with `@api` annotation):
-
- - `CaseInterface` - common absraction for the Signifyd case entity, provides methods to set or retrieve all case data fields.
- - `CaseManagementInterface` - contains methods to create a new case entity or retrieve existing for a specified order.
- - `CaseCreationServiceInterface` - provides an ability to create case entity for a specified order and send request through the Signifyd API to create a new case.
- - `CaseRepositoryInterface` - describes methods to work with a case entity.
- - `GuaranteeCreationServiceInterface` - allows to send request through the Signifyd API to create a new case guarantee.
- - `GuaranteeCancelingServiceInterface` - allows to send request through the Signifyd API to cancel the Signifyd case guarantee.
- - `CaseSearchResultsInterface` - might be used by `CaseRepositoryInterface` to retrieve a list of case entities by specific
-conditions.
-
-To update entity data for a case or guarantee this module uses the [Signifyd Webhooks](https://www.signifyd.com/docs/api/#/reference/webhooks) mechanism.
-Newly created case entity will have `PENDING` status for a case and guarantee. After receiving Webhook, both statuses will be changed to appropriate Signifyd statuses.
-
-## Customization
-
-The Signifyd service collects a lot of information about an order (all fields described in [API](https://www.signifyd.com/docs/api/#/reference/cases/create-a-case)),
-most of these fields are optional but some of them are required (like `avsResponseCode`, `cvvResponseCode`).
-So, for more accurate calculations, external integrations, like payment methods, might provide some additional details, like CVV/AVS response codes.
-
-The custom payment methods can implement `\Magento\Payment\Api\PaymentVerificationInterface` to provide AVS/CVV mapping
-from specific codes to [EMS standard](http://www.emsecommerce.net/avs_cvv2_response_codes.htm) and register these mappers in the `condig.xml` file
-of a custom payment module.
-For example, the mappers registration might look like this:
-
-```xml
-
-
-
- CustomPaymentFacade
- Custom Payment
- ...
- Magento\CustomPayment\Model\AvsEmsCodeMapper
- Magento\CustomPayment\Model\CvvEmsCodeMapper
-
-
-
-```
-
-These steps are enough to provide custom AVS/CVV mapping for payment integrations, everything else, like mapper initialization,
-will be provided by the Magento Signifyd infrastructure.
-
-Also, Signifyd can retrieve payment method for a placed order (the Magento Signifyd module can map Magento and Signifyd
-payment codes using the predefined XML list, located in `Magento\Signifyd\etc\signifyd_payment_mapping.xml` file).
-The 3rd-party payment integrations can apply own mappings for the [Signifyd payment codes](https://www.signifyd.com/docs/api/#/reference/cases/create-a-case),
-it's enough to add `signifyd_payment_mapping.xml` to custom payment method implementation and specify needed mapping.
-For example:
-
-```xml
-
-
-
- custom_payment_code
- PAYMENT_CARD
-
-
-
-```
-
- - `magento_code` attribute value should be the code for a custom payment method (the same as in the payment's `config.xml`).
- - `signifyd_code` attribute value should be one of available the Signifyd payment method codes.
\ No newline at end of file
+ - create a [Signifyd case](https://www.signifyd.com/docs/api/#/reference/cases) for a placed order
+ - automatically receive a [Signifyd guarantee](https://www.signifyd.com/docs/api/#/reference/guarantees) for a created case
+ - automatically cancel a guarantee when the order is canceled
+
+## Extensibility
+
+The Magento_Signifyd module does not add own Events, Layouts, and UI Components as extension points.
+
+### Public API
+
+The following interfaces (marked with the `@api` annotation) provide methods that allow to:
+
+`CaseInterface` (common abstraction for the Signifyd case entity):
+
+- set or retrieve all case data fields
+
+`CaseManagementInterface`:
+
+- create a new case entity
+- retrieve the existing case entity for a specified order
+
+`CaseCreationServiceInterface`:
+
+- create a case entity for a specified order
+- send a request through the Signifyd API to create a new case
+
+`CaseRepositoryInterface`:
+
+- describe methods to work with a case entity
+
+`GuaranteeCreationServiceInterface`:
+
+- send a request through the Signifyd API to create a new case guarantee
+
+`GuaranteeCancelingServiceInterface`:
+- send a request through the Signifyd API to cancel the Signifyd case guarantee
+
+`CaseSearchResultsInterface`:
+
+- might be used by `CaseRepositoryInterface` to retrieve a list of case entities by specific conditions
+
+For information about a public API in Magento 2, see [Public interfaces & APIs](http://devdocs.magento.com/guides/v2.1/extension-dev-guide/api-concepts.html).
+
+## Additional information
+
+### Webhooks
+
+To update the entity data for a case or guarantee, the Magento_Signifyd module uses the [Signifyd Webhooks](https://www.signifyd.com/docs/api/#/reference/webhooks) mechanism.
+
+The newly created case entities have the `PENDING` status for a case and a guarantee. After receiving Webhook, both statuses are changed to appropriate Signifyd statuses.
+
+### Debug mode
+
+The Debug Mode may be enabled in the module configuration. This logs the communication data between the Magento_Signifyd module and the Signifyd service in this file:
+
+ var/log/debug.log
+
+### Backward incompatible changes
+
+The Magento_Signifyd module does not introduce backward incompatible changes.
+
+You can track [backward incompatible changes in patch releases](http://devdocs.magento.com/guides/v2.0/release-notes/changes/ee_changes.html).
+
+### Processing supplementary payment information
+
+To improve the accuracy of Signifyd's transaction estimation, you may perform these operations (links lead to the Magento Developer Documentation Portal):
+
+- [Provide custom AVS/CVV mapping](http://devdocs.magento.com/guides/v2.2/payments-integrations/signifyd/signifyd.html#provide-avscvv-response-codes)
+
+- [Retrieve payment method for a placed order](http://devdocs.magento.com/guides/v2.2/payments-integrations/signifyd/signifyd.html#retrieve-payment-method-for-a-placed-order)
From cf7fd3ada64f54d50553a1dc8cd6d2c3763c96da Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Wed, 19 Apr 2017 03:56:16 -0500
Subject: [PATCH 211/904] MAGETWO-67298: Push the file (Signifyd readme) to the
repo
- Replace class names with FQCN
(cherry picked from commit 9ed3881)
---
app/code/Magento/Signifyd/README.md | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/app/code/Magento/Signifyd/README.md b/app/code/Magento/Signifyd/README.md
index 149bd9d6401a0..9479972cb21b6 100644
--- a/app/code/Magento/Signifyd/README.md
+++ b/app/code/Magento/Signifyd/README.md
@@ -18,34 +18,34 @@ The Magento_Signifyd module does not add own Events, Layouts, and UI Components
The following interfaces (marked with the `@api` annotation) provide methods that allow to:
-`CaseInterface` (common abstraction for the Signifyd case entity):
+`Magento\Signifyd\Api\Data\CaseInterface` (common abstraction for the Signifyd case entity):
- set or retrieve all case data fields
-`CaseManagementInterface`:
+`Magento\Signifyd\Api\CaseManagementInterface`:
- create a new case entity
- retrieve the existing case entity for a specified order
-`CaseCreationServiceInterface`:
+`Magento\Signifyd\Api\CaseCreationServiceInterface`:
- create a case entity for a specified order
- send a request through the Signifyd API to create a new case
-`CaseRepositoryInterface`:
+`Magento\Signifyd\Api\CaseRepositoryInterface`:
- describe methods to work with a case entity
-`GuaranteeCreationServiceInterface`:
+`Magento\Signifyd\Api\GuaranteeCreationServiceInterface`:
- send a request through the Signifyd API to create a new case guarantee
-`GuaranteeCancelingServiceInterface`:
+`Magento\Signifyd\Api\GuaranteeCancelingServiceInterface`:
- send a request through the Signifyd API to cancel the Signifyd case guarantee
-`CaseSearchResultsInterface`:
+`Magento\Signifyd\Api\Data\CaseSearchResultsInterface`:
-- might be used by `CaseRepositoryInterface` to retrieve a list of case entities by specific conditions
+- might be used by `Magento\Signifyd\Api\CaseRepositoryInterface` to retrieve a list of case entities by specific conditions
For information about a public API in Magento 2, see [Public interfaces & APIs](http://devdocs.magento.com/guides/v2.1/extension-dev-guide/api-concepts.html).
From 8f07e1d9e8c51f00eccfa6d4270d4a190c1c3c4c Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Wed, 30 Aug 2017 07:43:52 -0500
Subject: [PATCH 212/904] MAGETWO-71763: Signifyd does not work for PayPal
Payments Standard
- Added listener for place order event with PayPal Express Checkout
(cherry picked from commit 9c27160)
---
app/code/Magento/Signifyd/etc/events.xml | 3 +++
1 file changed, 3 insertions(+)
diff --git a/app/code/Magento/Signifyd/etc/events.xml b/app/code/Magento/Signifyd/etc/events.xml
index c5e69449793a5..9717f3947a9c4 100644
--- a/app/code/Magento/Signifyd/etc/events.xml
+++ b/app/code/Magento/Signifyd/etc/events.xml
@@ -9,4 +9,7 @@
+
+
+
From e5649e5ef8462f0a1f710db617949d27351ee517 Mon Sep 17 00:00:00 2001
From: Joan He
Date: Fri, 17 Nov 2017 15:55:47 -0600
Subject: [PATCH 213/904] MAGETWO-72487: Move code to CE
- move the function tests
---
dev/tests/functional/credentials.xml.dist | 1 +
.../etc/repository_replacer_payments.xml | 7 +
.../Test/Block/Adminhtml/Order/Grid.php | 33 +++
.../Adminhtml/Order/View/FraudProtection.php | 31 +++
.../Test/Block/SignifydConsole/CaseInfo.php | 245 ++++++++++++++++++
.../Test/Block/SignifydConsole/CaseSearch.php | 67 +++++
.../Block/SignifydConsole/SignifydLogin.php | 31 +++
.../Test/Block/SignifydConsole/Webhooks.php | 216 +++++++++++++++
...tingSignifydGuaranteeInCommentsHistory.php | 73 ++++++
.../Test/Constraint/AssertCaseInfoOnAdmin.php | 85 ++++++
.../AssertCaseInfoOnSignifydConsole.php | 214 +++++++++++++++
.../AssertSignifydCaseInCommentsHistory.php | 56 ++++
.../AssertSignifydCaseInOrdersGrid.php | 50 ++++
...gnifydGuaranteeCancelInCommentsHistory.php | 57 ++++
.../Signifyd/Test/Fixture/SignifydAccount.xml | 17 ++
.../Signifyd/Test/Fixture/SignifydAddress.xml | 15 ++
.../Fixture/SignifydAddress/Firstname.php | 46 ++++
.../Signifyd/Test/Fixture/SignifydData.xml | 21 ++
.../Test/Page/Adminhtml/OrdersGrid.xml | 12 +
.../Test/Page/Adminhtml/SalesOrderView.xml | 12 +
.../Page/SignifydConsole/SignifydCases.xml | 13 +
.../Page/SignifydConsole/SignifydLogin.xml | 12 +
.../SignifydConsole/SignifydNotifications.xml | 12 +
.../Signifyd/Test/Repository/Address.xml | 22 ++
.../Signifyd/Test/Repository/ConfigData.xml | 45 ++++
.../Signifyd/Test/Repository/Customer.xml | 25 ++
.../Test/Repository/SignifydAccount.xml | 15 ++
.../Signifyd/Test/Repository/SignifydData.xml | 34 +++
...ymentWithSignifydGuaranteeDeclinedTest.php | 63 +++++
...ymentWithSignifydGuaranteeDeclinedTest.xml | 38 +++
...ateSignifydGuaranteeAndCancelOrderTest.php | 62 +++++
...ateSignifydGuaranteeAndCancelOrderTest.xml | 68 +++++
...ymentWithSignifydGuaranteeDeclinedTest.php | 63 +++++
...ymentWithSignifydGuaranteeDeclinedTest.xml | 39 +++
.../Test/TestStep/OpenOrderGridStep.php | 173 +++++++++++++
.../Test/TestStep/SignifydCancelOrderStep.php | 105 ++++++++
.../SignifydFillShippingAddressStep.php | 70 +++++
.../Test/TestStep/SignifydLoginStep.php | 68 +++++
.../Test/TestStep/SignifydObserveCaseStep.php | 152 +++++++++++
.../SignifydSetWebhookHandlersStep.php | 64 +++++
.../TestStep/UnholdAndCancelOrderStep.php | 84 ++++++
.../app/Magento/Signifyd/Test/etc/di.xml | 34 +++
.../Magento/Signifyd/Test/etc/testcase.xml | 58 +++++
43 files changed, 2608 insertions(+)
create mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/Block/Adminhtml/Order/Grid.php
create mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/Block/Adminhtml/Order/View/FraudProtection.php
create mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/Block/SignifydConsole/CaseInfo.php
create mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/Block/SignifydConsole/CaseSearch.php
create mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/Block/SignifydConsole/SignifydLogin.php
create mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/Block/SignifydConsole/Webhooks.php
create mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/Constraint/AssertAwaitingSignifydGuaranteeInCommentsHistory.php
create mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/Constraint/AssertCaseInfoOnAdmin.php
create mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/Constraint/AssertCaseInfoOnSignifydConsole.php
create mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/Constraint/AssertSignifydCaseInCommentsHistory.php
create mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/Constraint/AssertSignifydCaseInOrdersGrid.php
create mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/Constraint/AssertSignifydGuaranteeCancelInCommentsHistory.php
create mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/Fixture/SignifydAccount.xml
create mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/Fixture/SignifydAddress.xml
create mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/Fixture/SignifydAddress/Firstname.php
create mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/Fixture/SignifydData.xml
create mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/Page/Adminhtml/OrdersGrid.xml
create mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/Page/Adminhtml/SalesOrderView.xml
create mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/Page/SignifydConsole/SignifydCases.xml
create mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/Page/SignifydConsole/SignifydLogin.xml
create mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/Page/SignifydConsole/SignifydNotifications.xml
create mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/Repository/Address.xml
create mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/Repository/ConfigData.xml
create mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/Repository/Customer.xml
create mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/Repository/SignifydAccount.xml
create mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/Repository/SignifydData.xml
create mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/TestCase/AcceptPaymentWithSignifydGuaranteeDeclinedTest.php
create mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/TestCase/AcceptPaymentWithSignifydGuaranteeDeclinedTest.xml
create mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/TestCase/CreateSignifydGuaranteeAndCancelOrderTest.php
create mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/TestCase/CreateSignifydGuaranteeAndCancelOrderTest.xml
create mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/TestCase/DenyPaymentWithSignifydGuaranteeDeclinedTest.php
create mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/TestCase/DenyPaymentWithSignifydGuaranteeDeclinedTest.xml
create mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/TestStep/OpenOrderGridStep.php
create mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/TestStep/SignifydCancelOrderStep.php
create mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/TestStep/SignifydFillShippingAddressStep.php
create mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/TestStep/SignifydLoginStep.php
create mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/TestStep/SignifydObserveCaseStep.php
create mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/TestStep/SignifydSetWebhookHandlersStep.php
create mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/TestStep/UnholdAndCancelOrderStep.php
create mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/etc/di.xml
create mode 100644 dev/tests/functional/tests/app/Magento/Signifyd/Test/etc/testcase.xml
diff --git a/dev/tests/functional/credentials.xml.dist b/dev/tests/functional/credentials.xml.dist
index 57e24cd59aa08..01e3a35be9a2d 100644
--- a/dev/tests/functional/credentials.xml.dist
+++ b/dev/tests/functional/credentials.xml.dist
@@ -80,4 +80,5 @@
+
diff --git a/dev/tests/functional/etc/repository_replacer_payments.xml b/dev/tests/functional/etc/repository_replacer_payments.xml
index 2b20e7220f537..a0ecca61eb372 100644
--- a/dev/tests/functional/etc/repository_replacer_payments.xml
+++ b/dev/tests/functional/etc/repository_replacer_payments.xml
@@ -21,4 +21,11 @@
AUTHORIZENET_PASSWORD
+
+
+
+ SIGNIFYD_EMAIL
+ SIGNIFYD_PASSWORD
+
+
diff --git a/dev/tests/functional/tests/app/Magento/Signifyd/Test/Block/Adminhtml/Order/Grid.php b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Block/Adminhtml/Order/Grid.php
new file mode 100644
index 0000000000000..54f580f48dcf4
--- /dev/null
+++ b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Block/Adminhtml/Order/Grid.php
@@ -0,0 +1,33 @@
+ [
+ 'selector' => '[name="increment_id"]',
+ ],
+ 'status' => [
+ 'selector' => '[name="status"]',
+ 'input' => 'select',
+ ],
+ 'signifyd_guarantee_status' => [
+ 'selector' => '[name="signifyd_guarantee_status"]',
+ 'input' => 'select'
+ ]
+ ];
+}
diff --git a/dev/tests/functional/tests/app/Magento/Signifyd/Test/Block/Adminhtml/Order/View/FraudProtection.php b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Block/Adminhtml/Order/View/FraudProtection.php
new file mode 100644
index 0000000000000..e2b4e6f748977
--- /dev/null
+++ b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Block/Adminhtml/Order/View/FraudProtection.php
@@ -0,0 +1,31 @@
+_rootElement->find($this->caseGuaranteeDisposition)->getText();
+ }
+}
diff --git a/dev/tests/functional/tests/app/Magento/Signifyd/Test/Block/SignifydConsole/CaseInfo.php b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Block/SignifydConsole/CaseInfo.php
new file mode 100644
index 0000000000000..5fe6096035803
--- /dev/null
+++ b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Block/SignifydConsole/CaseInfo.php
@@ -0,0 +1,245 @@
+_rootElement->find($this->noDeviceAnalysisAvailable)->isVisible();
+ }
+
+ /**
+ * Returns shipping price.
+ *
+ * @return string
+ */
+ public function getShippingPrice()
+ {
+ return $this->_rootElement->find($this->shippingPrice)->getText();
+ }
+
+ /**
+ * Flags case as good or bad.
+ *
+ * @param string $flagType
+ * @return void
+ */
+ public function flagCase($flagType)
+ {
+ $flagSelector = ($flagType === 'Good')
+ ? $this->flagCaseAsGoodButton
+ : $this->flagCaseAsBadButton;
+
+ $this->_rootElement->find($flagSelector)->click();
+ }
+
+ /**
+ * Flags case as bad.
+ *
+ * @return void
+ */
+ public function flagCaseAsBad()
+ {
+ $this->_rootElement->find($this->flagCaseAsBadButton)->click();
+ }
+
+ /**
+ * Gets guarantee disposition.
+ *
+ * @return string
+ */
+ public function getGuaranteeDisposition()
+ {
+ return $this->_rootElement->find($this->guaranteeDisposition)->getText();
+ }
+
+ /**
+ * Gets CVV response.
+ *
+ * @return string
+ */
+ public function getCvvResponse()
+ {
+ return sprintf(
+ '%s (%s)',
+ $this->_rootElement->find($this->cvvResponseDescription)->getText(),
+ $this->_rootElement->find($this->cvvResponseCode)->getText()
+ );
+ }
+
+ /**
+ * Gets AVS response.
+ *
+ * @return string
+ */
+ public function getAvsResponse()
+ {
+ return sprintf(
+ '%s (%s)',
+ $this->_rootElement->find($this->avsResponseDescription)->getText(),
+ $this->_rootElement->find($this->avsResponseCode)->getText()
+ );
+ }
+
+ /**
+ * Gets displayed order id.
+ *
+ * @return string
+ */
+ public function getOrderId()
+ {
+ return $this->_rootElement->find($this->orderId)->getText();
+ }
+
+ /**
+ * Gets displayed order amount.
+ *
+ * @return string
+ */
+ public function getOrderAmount()
+ {
+ return $this->_rootElement->find($this->orderAmount)->getText();
+ }
+
+ /**
+ * Returns displayed order amount currency.
+ *
+ * @return string
+ */
+ public function getOrderAmountCurrency()
+ {
+ return $this->_rootElement->find($this->orderAmountCurrency)->getText();
+ }
+
+ /**
+ * Gets displayed card holder name.
+ *
+ * @return string
+ */
+ public function getCardHolder()
+ {
+ return $this->_rootElement->find($this->cardHolder)->getText();
+ }
+
+ /**
+ * Gets displayed billing address.
+ *
+ * @return string
+ */
+ public function getBillingAddress()
+ {
+ return $this->_rootElement->find($this->billingAddress)->getText();
+ }
+}
diff --git a/dev/tests/functional/tests/app/Magento/Signifyd/Test/Block/SignifydConsole/CaseSearch.php b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Block/SignifydConsole/CaseSearch.php
new file mode 100644
index 0000000000000..ef292de3a9e5f
--- /dev/null
+++ b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Block/SignifydConsole/CaseSearch.php
@@ -0,0 +1,67 @@
+_rootElement->find($this->searchBar)->setValue($customerName);
+ $this->_rootElement->find($this->submitButton)->click();
+ }
+
+ /**
+ * Select searched case.
+ *
+ * @return void
+ */
+ public function selectCase()
+ {
+ $this->_rootElement->find($this->selectCaseLink)->click();
+ }
+
+ /**
+ * Waiting of case page loading.
+ *
+ * @return void
+ */
+ public function waitForLoading()
+ {
+ $this->waitForElementVisible($this->searchBar);
+ }
+}
diff --git a/dev/tests/functional/tests/app/Magento/Signifyd/Test/Block/SignifydConsole/SignifydLogin.php b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Block/SignifydConsole/SignifydLogin.php
new file mode 100644
index 0000000000000..7f530afe4df63
--- /dev/null
+++ b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Block/SignifydConsole/SignifydLogin.php
@@ -0,0 +1,31 @@
+_rootElement->find($this->loginButton)->click();
+ }
+}
diff --git a/dev/tests/functional/tests/app/Magento/Signifyd/Test/Block/SignifydConsole/Webhooks.php b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Block/SignifydConsole/Webhooks.php
new file mode 100644
index 0000000000000..424d5681c07c6
--- /dev/null
+++ b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Block/SignifydConsole/Webhooks.php
@@ -0,0 +1,216 @@
+ 'Case Creation',
+ 'CASE_REVIEW' => 'Case Review',
+ 'GUARANTEE_COMPLETION' => 'Guarantee Completion'
+ ];
+
+ /**
+ * XPath selector of webhook element added into grid.
+ *
+ * @var string
+ */
+ private $webhookAddedElement = '//table[@id="webhooks"]//tr[./td/span/text()="%s" and ./td/span/text()="%s"]';
+
+ /**
+ * Css selector of webhook url input.
+ *
+ * @var string
+ */
+ private $webhookUrl = '[id="webhookUrl"]';
+
+ /**
+ * XPath selector of test team select option.
+ *
+ * @var string
+ */
+ private $webhookTeamOption = './/select[@id="webhookTeams"]//option[text()="%s"]';
+
+ /**
+ * Css selector of webhook event select option.
+ *
+ * @var string
+ */
+ private $webhookEventOption = 'select[id="webhookEvent"] option[value="%s"]';
+
+ /**
+ * Css selector of webhook addition button.
+ *
+ * @var string
+ */
+ private $webhookAddButton = '[id="addWebhook"] [type=submit]';
+
+ /**
+ * Css selector of delete button in element of webhook grid.
+ *
+ * @var string
+ */
+ private $webhookDeleteButton = '[class*="webhook-delete"]';
+
+ /**
+ * Css selector of confirming button for deleting webhook.
+ *
+ * @var string
+ */
+ private $webhookDeleteConfirmButton = '[class="appriseOuter"] button[value="ok"]';
+
+ /**
+ * Creates new set of webhooks, if it not exists.
+ *
+ * @param string $team
+ * @return void
+ */
+ public function create($team)
+ {
+ $handlerUrl = $this->getHandlerUrl();
+
+ foreach ($this->webhookEventOptionsMap as $webhookEventCode => $webhookEventName) {
+ if ($this->getWebhook($team, $webhookEventName)) {
+ continue;
+ }
+
+ $this->addWebhook($handlerUrl, $webhookEventCode, $team);
+ }
+ }
+
+ /**
+ * Deletes set of webhooks.
+ *
+ * @param string $team
+ * @return void
+ */
+ public function cleanup($team)
+ {
+ foreach ($this->webhookEventOptionsMap as $webhookEventName) {
+ if ($webhook = $this->getWebhook($team, $webhookEventName)) {
+ $this->deleteWebhook($webhook);
+ }
+ }
+ }
+
+ /**
+ * Gets webhook if exists.
+ *
+ * @param string $team
+ * @param string $webhookEventName
+ * @return ElementInterface|null
+ */
+ private function getWebhook($team, $webhookEventName)
+ {
+ $webhook = $this->_rootElement->find(
+ sprintf($this->webhookAddedElement, $team, $webhookEventName),
+ Locator::SELECTOR_XPATH
+ );
+
+ return $webhook->isPresent() ? $webhook : null;
+ }
+
+ /**
+ * Delete webhook element with confirmation popup.
+ *
+ * @param ElementInterface $webhook
+ * @return void
+ */
+ private function deleteWebhook(ElementInterface $webhook)
+ {
+ $webhook->find($this->webhookDeleteButton)->click();
+ $this->_rootElement->find($this->webhookDeleteConfirmButton)->click();
+ }
+
+ /**
+ * Sets webhook data and add it.
+ *
+ * @param string $handlerUrl
+ * @param string $webhookEventCode
+ * @param string $team
+ * @return void
+ */
+ private function addWebhook(
+ $handlerUrl,
+ $webhookEventCode,
+ $team
+ ) {
+ $this->setEvent($webhookEventCode);
+ $this->setTeam($team);
+ $this->setUrl($handlerUrl);
+ $this->submit();
+ }
+
+ /**
+ * Sets appropriate webhook event select option by code.
+ *
+ * @param string $webhookEventCode
+ * @return void
+ */
+ private function setEvent($webhookEventCode)
+ {
+ $this->_rootElement->find(
+ sprintf($this->webhookEventOption, $webhookEventCode)
+ )->click();
+ }
+
+ /**
+ * Sets test team select option.
+ *
+ * @param string $team
+ * @return void
+ */
+ private function setTeam($team)
+ {
+ $this->_rootElement->find(
+ sprintf($this->webhookTeamOption, $team),
+ Locator::SELECTOR_XPATH
+ )->click();
+ }
+
+ /**
+ * Sets webhook handler url input value.
+ *
+ * @param string $handlerUrl
+ * @return void
+ */
+ private function setUrl($handlerUrl)
+ {
+ $this->_rootElement->find($this->webhookUrl)->setValue($handlerUrl);
+ }
+
+ /**
+ * Add webhook element.
+ *
+ * @return void
+ */
+ private function submit()
+ {
+ $this->_rootElement->find($this->webhookAddButton)->click();
+ }
+
+ /**
+ * Gets webhook handler url.
+ *
+ * @return string
+ */
+ private function getHandlerUrl()
+ {
+ return $_ENV['app_frontend_url'] . 'signifyd/webhooks/handler';
+ }
+}
diff --git a/dev/tests/functional/tests/app/Magento/Signifyd/Test/Constraint/AssertAwaitingSignifydGuaranteeInCommentsHistory.php b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Constraint/AssertAwaitingSignifydGuaranteeInCommentsHistory.php
new file mode 100644
index 0000000000000..55134b8d94548
--- /dev/null
+++ b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Constraint/AssertAwaitingSignifydGuaranteeInCommentsHistory.php
@@ -0,0 +1,73 @@
+open();
+ $salesOrder->getSalesOrderGrid()->searchAndOpen(['id' => $orderId]);
+
+ /** @var \Magento\Sales\Test\Block\Adminhtml\Order\View\Tab\Info $infoTab */
+ $infoTab = $salesOrderView->getOrderForm()->openTab('info')->getTab('info');
+ $orderComments = $infoTab->getCommentsHistoryBlock()->getComments();
+
+ $key = array_search(
+ $this->historyComment,
+ array_column($orderComments, 'comment')
+ );
+
+ \PHPUnit_Framework_Assert::assertNotFalse(
+ $key,
+ 'There is no message about awaiting the Signifyd guarantee disposition' .
+ ' in Comments History section for the order #' . $orderId
+ );
+
+ \PHPUnit_Framework_Assert::assertEquals(
+ $this->historyCommentStatus,
+ $orderComments[$key]['status'],
+ 'Message about awaiting the Signifyd guarantee disposition' .
+ ' doesn\'t have status "'. $this->historyCommentStatus.'"' .
+ ' in Comments History section for the order #' . $orderId
+ );
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function toString()
+ {
+ return "Message about awaiting the Signifyd guarantee disposition is available in Comments History section.";
+ }
+}
diff --git a/dev/tests/functional/tests/app/Magento/Signifyd/Test/Constraint/AssertCaseInfoOnAdmin.php b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Constraint/AssertCaseInfoOnAdmin.php
new file mode 100644
index 0000000000000..9fe29f022470f
--- /dev/null
+++ b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Constraint/AssertCaseInfoOnAdmin.php
@@ -0,0 +1,85 @@
+open();
+ $salesOrder->getSalesOrderGrid()->searchAndOpen(['id' => $orderId]);
+
+ $this->orderView = $orderView;
+ $this->signifydData = $signifydData;
+ $this->orderId = $orderId;
+
+ $this->checkCaseGuaranteeDisposition();
+ }
+
+ /**
+ * Checks case guarantee disposition is correct.
+ *
+ * @return void
+ */
+ private function checkCaseGuaranteeDisposition()
+ {
+ \PHPUnit_Framework_Assert::assertEquals(
+ $this->signifydData->getGuaranteeDisposition(),
+ $this->orderView->getFraudProtectionBlock()->getCaseGuaranteeDisposition(),
+ 'Case Guarantee Disposition status is wrong for order #' . $this->orderId
+ );
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function toString()
+ {
+ return 'Signifyd Case information is correct in Admin.';
+ }
+}
diff --git a/dev/tests/functional/tests/app/Magento/Signifyd/Test/Constraint/AssertCaseInfoOnSignifydConsole.php b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Constraint/AssertCaseInfoOnSignifydConsole.php
new file mode 100644
index 0000000000000..995f5092b6121
--- /dev/null
+++ b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Constraint/AssertCaseInfoOnSignifydConsole.php
@@ -0,0 +1,214 @@
+signifydCases = $signifydCases;
+
+ $this->checkDeviceData();
+ $this->checkShippingPrice($signifydData->getShippingPrice());
+ $this->checkGuaranteeDisposition($signifydData->getGuaranteeDisposition());
+ $cvvResponse = $signifydData->getCvvResponse();
+ if (isset($cvvResponse)) {
+ $this->checkCvvResponse($cvvResponse);
+ }
+ $this->checkAvsResponse($signifydData->getAvsResponse());
+ $this->checkOrderId($orderId);
+ $this->checkOrderAmount($prices['grandTotal']);
+ $this->checkOrderAmountCurrency($prices['grandTotalCurrency']);
+ $this->checkCardHolder($customerFullName);
+ $this->checkBillingAddress($billingAddress);
+ }
+
+ /**
+ * Checks device data are present.
+ *
+ * @return void
+ */
+ private function checkDeviceData()
+ {
+ \PHPUnit_Framework_Assert::assertTrue(
+ $this->signifydCases->getCaseInfoBlock()->isAvailableDeviceData(),
+ 'Device data are not available on case page in Signifyd console.'
+ );
+ }
+
+ /**
+ * Checks shipping price is correct.
+ *
+ * @param string $shippingPrice
+ * @return void
+ */
+ private function checkShippingPrice($shippingPrice)
+ {
+ \PHPUnit_Framework_Assert::assertContains(
+ $shippingPrice,
+ $this->signifydCases->getCaseInfoBlock()->getShippingPrice(),
+ 'Shipping price is incorrect on case page in Signifyd console.'
+ );
+ }
+
+ /**
+ * Checks guarantee disposition is correct.
+ *
+ * @param string $guaranteeDisposition
+ * @return void
+ */
+ private function checkGuaranteeDisposition($guaranteeDisposition)
+ {
+ \PHPUnit_Framework_Assert::assertEquals(
+ $guaranteeDisposition,
+ $this->signifydCases->getCaseInfoBlock()->getGuaranteeDisposition(),
+ 'Guarantee disposition is incorrect on case page in Signifyd console.'
+ );
+ }
+
+ /**
+ * Checks CVV response is correct.
+ *
+ * @param string $cvvResponse
+ * @return void
+ */
+ private function checkCvvResponse($cvvResponse)
+ {
+ \PHPUnit_Framework_Assert::assertEquals(
+ $cvvResponse,
+ $this->signifydCases->getCaseInfoBlock()->getCvvResponse(),
+ 'CVV response is incorrect on case page in Signifyd console.'
+ );
+ }
+
+ /**
+ * Checks AVS response is correct.
+ *
+ * @param string $avsResponse
+ * @return void
+ */
+ private function checkAvsResponse($avsResponse)
+ {
+ \PHPUnit_Framework_Assert::assertEquals(
+ $avsResponse,
+ $this->signifydCases->getCaseInfoBlock()->getAvsResponse(),
+ 'AVS response is incorrect on case page in Signifyd console.'
+ );
+ }
+
+ /**
+ * Checks order id is correct.
+ *
+ * @param string $orderId
+ * @return void
+ */
+ private function checkOrderId($orderId)
+ {
+ \PHPUnit_Framework_Assert::assertEquals(
+ $orderId,
+ $this->signifydCases->getCaseInfoBlock()->getOrderId(),
+ 'Order id is incorrect on case page in Signifyd console.'
+ );
+ }
+
+ /**
+ * Checks order amount is correct.
+ *
+ * @param string $amount
+ * @return void
+ */
+ private function checkOrderAmount($amount)
+ {
+ \PHPUnit_Framework_Assert::assertEquals(
+ number_format($amount, 2),
+ $this->signifydCases->getCaseInfoBlock()->getOrderAmount(),
+ 'Order amount is incorrect on case page in Signifyd console.'
+ );
+ }
+
+ /**
+ * Checks order amount currency is correct.
+ *
+ * @param string $currency
+ * @return void
+ */
+ private function checkOrderAmountCurrency($currency)
+ {
+ \PHPUnit_Framework_Assert::assertEquals(
+ $currency,
+ $this->signifydCases->getCaseInfoBlock()->getOrderAmountCurrency(),
+ 'Order amount currency is incorrect on case page in Signifyd console.'
+ );
+ }
+
+ /**
+ * Checks card holder is correct.
+ *
+ * @param string $customerFullName
+ * @return void
+ */
+ private function checkCardHolder($customerFullName)
+ {
+ \PHPUnit_Framework_Assert::assertEquals(
+ $customerFullName,
+ $this->signifydCases->getCaseInfoBlock()->getCardHolder(),
+ 'Card holder name is incorrect on case page in Signifyd console.'
+ );
+ }
+
+ /**
+ * Checks billing address is correct.
+ *
+ * @param SignifydAddress $billingAddress
+ * @return void
+ */
+ private function checkBillingAddress(SignifydAddress $billingAddress)
+ {
+ \PHPUnit_Framework_Assert::assertContains(
+ $billingAddress->getStreet(),
+ $this->signifydCases->getCaseInfoBlock()->getBillingAddress(),
+ 'Billing address is incorrect on case page in Signifyd console.'
+ );
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function toString()
+ {
+ return 'Case information is correct on case page in Signifyd console.';
+ }
+}
diff --git a/dev/tests/functional/tests/app/Magento/Signifyd/Test/Constraint/AssertSignifydCaseInCommentsHistory.php b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Constraint/AssertSignifydCaseInCommentsHistory.php
new file mode 100644
index 0000000000000..aef5c0e9abd26
--- /dev/null
+++ b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Constraint/AssertSignifydCaseInCommentsHistory.php
@@ -0,0 +1,56 @@
+open();
+ $salesOrder->getSalesOrderGrid()->searchAndOpen(['id' => $orderId]);
+
+ /** @var \Magento\Sales\Test\Block\Adminhtml\Order\View\Tab\Info $infoTab */
+ $infoTab = $salesOrderView->getOrderForm()->openTab('info')->getTab('info');
+ $orderComments = $infoTab->getCommentsHistoryBlock()->getComments();
+ $commentsMessages = array_column($orderComments, 'comment');
+
+ \PHPUnit_Framework_Assert::assertRegExp(
+ self::CASE_CREATED_PATTERN,
+ implode('. ', $commentsMessages),
+ 'Signifyd case is not created for the order #' . $orderId
+ );
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function toString()
+ {
+ return "Message about Signifyd Case is available in Comments History section.";
+ }
+}
diff --git a/dev/tests/functional/tests/app/Magento/Signifyd/Test/Constraint/AssertSignifydCaseInOrdersGrid.php b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Constraint/AssertSignifydCaseInOrdersGrid.php
new file mode 100644
index 0000000000000..2f08ac8f40a3e
--- /dev/null
+++ b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Constraint/AssertSignifydCaseInOrdersGrid.php
@@ -0,0 +1,50 @@
+ $orderId,
+ 'signifyd_guarantee_status' => $signifydData->getGuaranteeDisposition()
+ ];
+
+ $errorMessage = implode(', ', $filter);
+
+ $ordersGrid->open();
+
+ \PHPUnit_Framework_Assert::assertTrue(
+ $ordersGrid->getSignifydOrdersGrid()->isRowVisible(array_filter($filter)),
+ 'Order with following data \'' . $errorMessage . '\' is absent in orders grid.'
+ );
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function toString()
+ {
+ return 'Signifyd guarantee status is displayed in sales orders grid.';
+ }
+}
diff --git a/dev/tests/functional/tests/app/Magento/Signifyd/Test/Constraint/AssertSignifydGuaranteeCancelInCommentsHistory.php b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Constraint/AssertSignifydGuaranteeCancelInCommentsHistory.php
new file mode 100644
index 0000000000000..4b86f66730f90
--- /dev/null
+++ b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Constraint/AssertSignifydGuaranteeCancelInCommentsHistory.php
@@ -0,0 +1,57 @@
+open();
+ $salesOrder->getSalesOrderGrid()->searchAndOpen(['id' => $orderId]);
+
+ /** @var \Magento\Sales\Test\Block\Adminhtml\Order\View\Tab\Info $infoTab */
+ $infoTab = $salesOrderView->getOrderForm()->openTab('info')->getTab('info');
+ $orderComments = $infoTab->getCommentsHistoryBlock()->getComments();
+ $commentsMessages = array_column($orderComments, 'comment');
+
+ \PHPUnit_Framework_Assert::assertContains(
+ $this->guaranteeCancelMessage,
+ implode('. ', $commentsMessages),
+ 'There is no message regarding Signifyd guarantee cancel in Comments History section for the order #'
+ . $orderId
+ );
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function toString()
+ {
+ return "Message about Signifyd guarantee cancel is available in Comments History section.";
+ }
+}
diff --git a/dev/tests/functional/tests/app/Magento/Signifyd/Test/Fixture/SignifydAccount.xml b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Fixture/SignifydAccount.xml
new file mode 100644
index 0000000000000..8b1455811d003
--- /dev/null
+++ b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Fixture/SignifydAccount.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
diff --git a/dev/tests/functional/tests/app/Magento/Signifyd/Test/Fixture/SignifydAddress.xml b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Fixture/SignifydAddress.xml
new file mode 100644
index 0000000000000..02b5cc8211d89
--- /dev/null
+++ b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Fixture/SignifydAddress.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
diff --git a/dev/tests/functional/tests/app/Magento/Signifyd/Test/Fixture/SignifydAddress/Firstname.php b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Fixture/SignifydAddress/Firstname.php
new file mode 100644
index 0000000000000..9e4930484eef0
--- /dev/null
+++ b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Fixture/SignifydAddress/Firstname.php
@@ -0,0 +1,46 @@
+data = $data;
+ }
+
+ /**
+ * Add isolation for `firstname` field.
+ *
+ * @param null $key
+ * @return string
+ */
+ public function getData($key = null)
+ {
+ $this->data = str_replace('%signifyd_isolation%', $this->generateIsolation(), $this->data);
+
+ return parent::getData($key);
+ }
+
+ /**
+ * Generates character isolation.
+ *
+ * @param int $length
+ * @return string
+ */
+ private function generateIsolation($length = 10)
+ {
+ return substr(str_shuffle(str_repeat("abcdefghijklmnopqrstuvwxyz", $length)), 0, $length);
+ }
+}
diff --git a/dev/tests/functional/tests/app/Magento/Signifyd/Test/Fixture/SignifydData.xml b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Fixture/SignifydData.xml
new file mode 100644
index 0000000000000..23ee2cddf434a
--- /dev/null
+++ b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Fixture/SignifydData.xml
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dev/tests/functional/tests/app/Magento/Signifyd/Test/Page/Adminhtml/OrdersGrid.xml b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Page/Adminhtml/OrdersGrid.xml
new file mode 100644
index 0000000000000..749d91c3ed395
--- /dev/null
+++ b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Page/Adminhtml/OrdersGrid.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
diff --git a/dev/tests/functional/tests/app/Magento/Signifyd/Test/Page/Adminhtml/SalesOrderView.xml b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Page/Adminhtml/SalesOrderView.xml
new file mode 100644
index 0000000000000..36d77723dfcee
--- /dev/null
+++ b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Page/Adminhtml/SalesOrderView.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
diff --git a/dev/tests/functional/tests/app/Magento/Signifyd/Test/Page/SignifydConsole/SignifydCases.xml b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Page/SignifydConsole/SignifydCases.xml
new file mode 100644
index 0000000000000..cfe889bb8de44
--- /dev/null
+++ b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Page/SignifydConsole/SignifydCases.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
diff --git a/dev/tests/functional/tests/app/Magento/Signifyd/Test/Page/SignifydConsole/SignifydLogin.xml b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Page/SignifydConsole/SignifydLogin.xml
new file mode 100644
index 0000000000000..5fe5da6d28013
--- /dev/null
+++ b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Page/SignifydConsole/SignifydLogin.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
diff --git a/dev/tests/functional/tests/app/Magento/Signifyd/Test/Page/SignifydConsole/SignifydNotifications.xml b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Page/SignifydConsole/SignifydNotifications.xml
new file mode 100644
index 0000000000000..dd12f14c28800
--- /dev/null
+++ b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Page/SignifydConsole/SignifydNotifications.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
diff --git a/dev/tests/functional/tests/app/Magento/Signifyd/Test/Repository/Address.xml b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Repository/Address.xml
new file mode 100644
index 0000000000000..a534cbc6107fe
--- /dev/null
+++ b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Repository/Address.xml
@@ -0,0 +1,22 @@
+
+
+
+
+
+ John%signifyd_isolation%
+ Doe
+ Magento
+ Culver City
+ 6161 West Centinela Avenue
+ 555-55-555-55
+ United States
+ California
+ 90230
+
+
+
diff --git a/dev/tests/functional/tests/app/Magento/Signifyd/Test/Repository/ConfigData.xml b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Repository/ConfigData.xml
new file mode 100644
index 0000000000000..2af46f077b304
--- /dev/null
+++ b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Repository/ConfigData.xml
@@ -0,0 +1,45 @@
+
+
+
+
+
+
+ - fraud_protection
+ - 1
+ - Yes
+ - 1
+
+
+ - fraud_protection
+ - 1
+
+ - SIGNIFYD_CONFIG_API_KEY
+
+
+ - fraud_protection
+ - 1
+
+ - https://api.signifyd.com/v2/
+
+
+ - fraud_protection
+ - 1
+ - Yes
+ - 1
+
+
+
+
+ - fraud_protection
+ - 1
+ - Yes
+ - 0
+
+
+
+
diff --git a/dev/tests/functional/tests/app/Magento/Signifyd/Test/Repository/Customer.xml b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Repository/Customer.xml
new file mode 100644
index 0000000000000..b45e3d01b8ec8
--- /dev/null
+++ b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Repository/Customer.xml
@@ -0,0 +1,25 @@
+
+
+
+
+
+ John
+ Doe
+ testapprove@magento.com
+ 123123^q
+ 123123^q
+
+
+ John
+ Doe
+ testdecline@magento.com
+ 123123^q
+ 123123^q
+
+
+
diff --git a/dev/tests/functional/tests/app/Magento/Signifyd/Test/Repository/SignifydAccount.xml b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Repository/SignifydAccount.xml
new file mode 100644
index 0000000000000..4d3dd5229eae3
--- /dev/null
+++ b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Repository/SignifydAccount.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
+ SIGNIFYD_EMAIL
+ SIGNIFYD_PASSWORD
+
+
+
diff --git a/dev/tests/functional/tests/app/Magento/Signifyd/Test/Repository/SignifydData.xml b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Repository/SignifydData.xml
new file mode 100644
index 0000000000000..5b3be4b9d570a
--- /dev/null
+++ b/dev/tests/functional/tests/app/Magento/Signifyd/Test/Repository/SignifydData.xml
@@ -0,0 +1,34 @@
+
+
+
+
+
+ autotest
+ Good
+ Approved
+ CVV2 Match (M)
+ Full match (Y)
+ USD 5.00
+
+
+ autotest
+ Bad
+ Declined
+ CVV2 Match (M)
+ Full match (Y)
+ USD 5.00
+
+
+ autotest
+ Bad
+ Declined
+ Unavailable (U)
+ GBP 10.00
+
+
+
diff --git a/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestCase/AcceptPaymentWithSignifydGuaranteeDeclinedTest.php b/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestCase/AcceptPaymentWithSignifydGuaranteeDeclinedTest.php
new file mode 100644
index 0000000000000..1dd742c9f7096
--- /dev/null
+++ b/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestCase/AcceptPaymentWithSignifydGuaranteeDeclinedTest.php
@@ -0,0 +1,63 @@
+executeScenario();
+ }
+}
diff --git a/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestCase/AcceptPaymentWithSignifydGuaranteeDeclinedTest.xml b/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestCase/AcceptPaymentWithSignifydGuaranteeDeclinedTest.xml
new file mode 100644
index 0000000000000..6391081e5e161
--- /dev/null
+++ b/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestCase/AcceptPaymentWithSignifydGuaranteeDeclinedTest.xml
@@ -0,0 +1,38 @@
+
+
+
+
+
+ catalogProductSimple::product_100_dollar
+ signifyd_decline_us_customer
+ login
+ Flat Rate
+ Fixed
+ hosted_pro
+
+ - 210.00
+ - GBP
+
+ credit_card_hostedpro
+ visa_hosted_pro
+ false
+ merchant_country_gb, hosted_pro, config_base_currency_gb, signifyd
+ Suspected Fraud
+ signifyd_us_shipping_address
+ sandbox_default
+ signifyd_guarantee_fraudulent
+ Processing
+ test_type:3rd_party_test_single_flow, severity:S2
+
+
+
+
+
+
+
diff --git a/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestCase/CreateSignifydGuaranteeAndCancelOrderTest.php b/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestCase/CreateSignifydGuaranteeAndCancelOrderTest.php
new file mode 100644
index 0000000000000..5ca76ff70479f
--- /dev/null
+++ b/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestCase/CreateSignifydGuaranteeAndCancelOrderTest.php
@@ -0,0 +1,62 @@
+executeScenario();
+ }
+}
diff --git a/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestCase/CreateSignifydGuaranteeAndCancelOrderTest.xml b/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestCase/CreateSignifydGuaranteeAndCancelOrderTest.xml
new file mode 100644
index 0000000000000..404229c2451cd
--- /dev/null
+++ b/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestCase/CreateSignifydGuaranteeAndCancelOrderTest.xml
@@ -0,0 +1,68 @@
+
+
+
+
+
+ catalogProductSimple::product_10_dollar
+ login
+ signifyd_approve_us_customer
+ Flat Rate
+ Fixed
+ braintree
+ braintree
+ 15.00
+ USD
+ visa_default
+ braintree
+ braintree,signifyd
+ Processing
+ signifyd_us_shipping_address
+ sandbox_default
+ signifyd_guarantee_approve
+ test_type:3rd_party_test_single_flow, severity:S1
+
+
+
+
+
+
+
+
+
+ catalogProductSimple::product_10_dollar
+ login
+ signifyd_decline_us_customer
+ Flat Rate
+ Fixed
+ braintree
+ braintree
+ 15.00
+ USD
+ visa_default
+ braintree
+ braintree,signifyd
+ On Hold
+ signifyd_us_shipping_address
+ sandbox_default
+ signifyd_guarantee_decline
+ test_type:3rd_party_test_single_flow, severity:S1
+
+
+
+
+
+
+
+
+
+
diff --git a/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestCase/DenyPaymentWithSignifydGuaranteeDeclinedTest.php b/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestCase/DenyPaymentWithSignifydGuaranteeDeclinedTest.php
new file mode 100644
index 0000000000000..698861da26018
--- /dev/null
+++ b/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestCase/DenyPaymentWithSignifydGuaranteeDeclinedTest.php
@@ -0,0 +1,63 @@
+executeScenario();
+ }
+}
diff --git a/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestCase/DenyPaymentWithSignifydGuaranteeDeclinedTest.xml b/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestCase/DenyPaymentWithSignifydGuaranteeDeclinedTest.xml
new file mode 100644
index 0000000000000..5496619fe1bf9
--- /dev/null
+++ b/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestCase/DenyPaymentWithSignifydGuaranteeDeclinedTest.xml
@@ -0,0 +1,39 @@
+
+
+
+
+
+ catalogProductSimple::product_100_dollar
+ signifyd_decline_us_customer
+ login
+ Flat Rate
+ Fixed
+ hosted_pro
+
+ - 210.00
+ - GBP
+
+ credit_card_hostedpro
+ visa_hosted_pro
+ false
+ merchant_country_gb, hosted_pro, config_base_currency_gb, signifyd
+ Suspected Fraud
+ Canceled
+ signifyd_us_shipping_address
+ sandbox_default
+ signifyd_guarantee_fraudulent
+ test_type:3rd_party_test_single_flow, severity:S2
+
+
+
+
+
+
+
+
diff --git a/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestStep/OpenOrderGridStep.php b/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestStep/OpenOrderGridStep.php
new file mode 100644
index 0000000000000..409dffc8340b7
--- /dev/null
+++ b/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestStep/OpenOrderGridStep.php
@@ -0,0 +1,173 @@
+placeOrderStatus = $placeOrderStatus;
+ $this->orderId = $orderId;
+ $this->orderIndex = $orderIndex;
+ $this->salesOrderView = $salesOrderView;
+ $this->ordersGrid = $ordersGrid;
+ $this->assertOrderStatus = $assertOrderStatus;
+ $this->assertCaseInfo = $assertCaseInfo;
+ $this->assertOrdersGrid = $assertOrdersGrid;
+ $this->signifydData = $signifydData;
+ }
+
+ /**
+ * Open order.
+ *
+ * @return void
+ */
+ public function run()
+ {
+ $this->checkOrdersGrid();
+ $this->checkCaseInfo();
+ $this->checkOrderStatus();
+ }
+
+ /**
+ * Run assert to check Signifyd Case Disposition status in orders grid.
+ *
+ * @return void
+ */
+ private function checkOrdersGrid()
+ {
+ $this->assertOrdersGrid->processAssert(
+ $this->orderId,
+ $this->ordersGrid,
+ $this->signifydData
+ );
+ }
+
+ /**
+ * Run assert to check order status is valid.
+ *
+ * @return void
+ */
+ private function checkOrderStatus()
+ {
+ $this->assertOrderStatus->processAssert(
+ $this->placeOrderStatus,
+ $this->orderId,
+ $this->orderIndex,
+ $this->salesOrderView
+ );
+ }
+
+ /**
+ * Run assert to check Signifyd Case information is correct in Admin.
+ *
+ * @return void
+ */
+ private function checkCaseInfo()
+ {
+ $this->assertCaseInfo->processAssert(
+ $this->salesOrderView,
+ $this->orderIndex,
+ $this->signifydData,
+ $this->orderId
+ );
+ }
+}
diff --git a/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestStep/SignifydCancelOrderStep.php b/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestStep/SignifydCancelOrderStep.php
new file mode 100644
index 0000000000000..54f4dd75223e0
--- /dev/null
+++ b/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestStep/SignifydCancelOrderStep.php
@@ -0,0 +1,105 @@
+orderIndex = $orderIndex;
+ $this->order = $order;
+ $this->salesOrderView = $salesOrderView;
+ $this->testStepFactory = $testStepFactory;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function run()
+ {
+ $this->orderIndex->open();
+ $this->orderIndex->getSalesOrderGrid()
+ ->searchAndOpen(['id' => $this->order->getId()]);
+
+ switch ($this->salesOrderView->getOrderInfoBlock()->getOrderStatus()) {
+ case 'Suspected Fraud':
+ $this->getStepInstance(DenyPaymentStep::class)->run();
+ break;
+ case 'On Hold':
+ $this->getStepInstance(UnholdOrderStep::class)->run();
+ $this->getStepInstance(CancelOrderStep::class)->run();
+ break;
+ case 'Canceled':
+ break;
+ default:
+ $this->getStepInstance(CancelOrderStep::class)->run();
+ }
+ }
+
+ /**
+ * Creates test step instance with preset params.
+ *
+ * @param string $class
+ * @return TestStepInterface
+ */
+ private function getStepInstance($class)
+ {
+ return $this->testStepFactory->create(
+ $class,
+ ['order' => $this->order]
+ );
+ }
+}
diff --git a/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestStep/SignifydFillShippingAddressStep.php b/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestStep/SignifydFillShippingAddressStep.php
new file mode 100644
index 0000000000000..0b1dda1d0a46a
--- /dev/null
+++ b/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestStep/SignifydFillShippingAddressStep.php
@@ -0,0 +1,70 @@
+signifydAddress = $signifydAddress;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function run()
+ {
+ parent::run();
+
+ return [
+ 'signifydAddress' => $this->signifydAddress,
+ ];
+ }
+}
diff --git a/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestStep/SignifydLoginStep.php b/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestStep/SignifydLoginStep.php
new file mode 100644
index 0000000000000..3dd1b94d6b505
--- /dev/null
+++ b/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestStep/SignifydLoginStep.php
@@ -0,0 +1,68 @@
+signifydAccount = $signifydAccount;
+ $this->signifydLogin = $signifydLogin;
+ $this->signifydCases = $signifydCases;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function run()
+ {
+ $this->signifydLogin->open();
+
+ if ($this->signifydLogin->getLoginBlock()->isVisible()) {
+ $this->signifydLogin->getLoginBlock()->fill($this->signifydAccount);
+ $this->signifydLogin->getLoginBlock()->login();
+ }
+
+ $this->signifydCases->getCaseSearchBlock()->waitForLoading();
+ }
+}
diff --git a/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestStep/SignifydObserveCaseStep.php b/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestStep/SignifydObserveCaseStep.php
new file mode 100644
index 0000000000000..126e32489e6c9
--- /dev/null
+++ b/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestStep/SignifydObserveCaseStep.php
@@ -0,0 +1,152 @@
+assertCaseInfo = $assertCaseInfoOnSignifydConsole;
+ $this->signifydAddress = $signifydAddress;
+ $this->signifydCases = $signifydCases;
+ $this->signifydNotifications = $signifydNotifications;
+ $this->signifydData = $signifydData;
+ $this->order = $order;
+ $this->testStepFactory = $testStepFactory;
+ $this->prices = $prices;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function run()
+ {
+ $this->signifydCases->open();
+ $this->signifydCases->getCaseSearchBlock()
+ ->searchCaseByCustomerName($this->signifydAddress->getFirstname());
+ $this->signifydCases->getCaseSearchBlock()->selectCase();
+ $this->signifydCases->getCaseInfoBlock()->flagCase($this->signifydData->getCaseFlag());
+
+ $this->assertCaseInfo->processAssert(
+ $this->signifydCases,
+ $this->signifydAddress,
+ $this->signifydData,
+ $this->prices,
+ $this->order->getId(),
+ $this->getCustomerFullName($this->signifydAddress)
+ );
+ }
+
+ /**
+ * Cancel order if test fails, or in the end of variation.
+ *
+ * @return void
+ */
+ public function cleanup()
+ {
+ $this->testStepFactory->create(
+ SignifydCancelOrderStep::class,
+ ['order' => $this->order]
+ )->run();
+ }
+
+ /**
+ * Gets customer full name.
+ *
+ * @param SignifydAddress $billingAddress
+ * @return string
+ */
+ private function getCustomerFullName(SignifydAddress $billingAddress)
+ {
+ return sprintf('%s %s', $billingAddress->getFirstname(), $billingAddress->getLastname());
+ }
+}
diff --git a/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestStep/SignifydSetWebhookHandlersStep.php b/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestStep/SignifydSetWebhookHandlersStep.php
new file mode 100644
index 0000000000000..2b630b8c1dac8
--- /dev/null
+++ b/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestStep/SignifydSetWebhookHandlersStep.php
@@ -0,0 +1,64 @@
+signifydNotifications = $signifydNotifications;
+ $this->signifydData = $signifydData;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function run()
+ {
+ $this->signifydNotifications->open();
+ $this->signifydNotifications->getWebhooksBlock()
+ ->create($this->signifydData->getTeam());
+ }
+
+ /**
+ * Removes webhooks if test fails, or in the end of variation execution.
+ *
+ * @return void
+ */
+ public function cleanup()
+ {
+ $this->signifydNotifications->open();
+ $this->signifydNotifications->getWebhooksBlock()
+ ->cleanup($this->signifydData->getTeam());
+ }
+}
diff --git a/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestStep/UnholdAndCancelOrderStep.php b/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestStep/UnholdAndCancelOrderStep.php
new file mode 100644
index 0000000000000..0c90b1b76937b
--- /dev/null
+++ b/dev/tests/functional/tests/app/Magento/Signifyd/Test/TestStep/UnholdAndCancelOrderStep.php
@@ -0,0 +1,84 @@
+placeOrderStatus = $placeOrderStatus;
+ $this->order = $order;
+ $this->testStepFactory = $testStepFactory;
+ }
+
+ /**
+ * Cancel order step.
+ *
+ * If order was held - unhold and then cancel the order.
+ *
+ * @return void
+ */
+ public function run()
+ {
+ if ($this->placeOrderStatus === 'On Hold') {
+ $this->getStepInstance(UnholdOrderStep::class)->run();
+ }
+
+ $this->getStepInstance(CancelOrderStep::class)->run();
+ }
+
+ /**
+ * Creates test step instance with preset params.
+ *
+ * @param string $class
+ * @return TestStepInterface
+ */
+ private function getStepInstance($class)
+ {
+ return $this->testStepFactory->create(
+ $class,
+ ['order' => $this->order]
+ );
+ }
+}
diff --git a/dev/tests/functional/tests/app/Magento/Signifyd/Test/etc/di.xml b/dev/tests/functional/tests/app/Magento/Signifyd/Test/etc/di.xml
new file mode 100644
index 0000000000000..2ba4b6c97d33f
--- /dev/null
+++ b/dev/tests/functional/tests/app/Magento/Signifyd/Test/etc/di.xml
@@ -0,0 +1,34 @@
+
+
+
+
+
+ S1
+
+
+
+
+ S1
+
+
+
+
+ S1
+
+
+
+
+ S1
+
+
+
+
+ S2
+
+
+
diff --git a/dev/tests/functional/tests/app/Magento/Signifyd/Test/etc/testcase.xml b/dev/tests/functional/tests/app/Magento/Signifyd/Test/etc/testcase.xml
new file mode 100644
index 0000000000000..cfbd2e6ace2b4
--- /dev/null
+++ b/dev/tests/functional/tests/app/Magento/Signifyd/Test/etc/testcase.xml
@@ -0,0 +1,58 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
From c60476efc287c60261d728bf42c4e28ed30e76a9 Mon Sep 17 00:00:00 2001
From: Joan He
Date: Fri, 17 Nov 2017 17:13:23 -0600
Subject: [PATCH 214/904] MAGETWO-72487: Move code to CE
- fix copyright
---
app/code/Magento/Signifyd/Api/CaseCreationServiceInterface.php | 2 +-
app/code/Magento/Signifyd/Api/CaseManagementInterface.php | 2 +-
app/code/Magento/Signifyd/Api/CaseRepositoryInterface.php | 2 +-
app/code/Magento/Signifyd/Api/Data/CaseInterface.php | 2 +-
.../Magento/Signifyd/Api/Data/CaseSearchResultsInterface.php | 2 +-
.../Magento/Signifyd/Api/GuaranteeCancelingServiceInterface.php | 2 +-
.../Magento/Signifyd/Api/GuaranteeCreationServiceInterface.php | 2 +-
app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php | 2 +-
.../Signifyd/Block/Adminhtml/System/Config/Field/WebhookUrl.php | 2 +-
.../Signifyd/Block/Adminhtml/System/Config/Fieldset/Info.php | 2 +-
app/code/Magento/Signifyd/Block/Fingerprint.php | 2 +-
app/code/Magento/Signifyd/Controller/Webhooks/Handler.php | 2 +-
app/code/Magento/Signifyd/Model/CaseEntity.php | 2 +-
app/code/Magento/Signifyd/Model/CaseManagement.php | 2 +-
app/code/Magento/Signifyd/Model/CaseRepository.php | 2 +-
.../Magento/Signifyd/Model/CaseServices/CreationService.php | 2 +-
.../Magento/Signifyd/Model/CaseServices/StubUpdatingService.php | 2 +-
.../Magento/Signifyd/Model/CaseServices/UpdatingService.php | 2 +-
.../Signifyd/Model/CaseServices/UpdatingServiceFactory.php | 2 +-
.../Signifyd/Model/CaseServices/UpdatingServiceInterface.php | 2 +-
app/code/Magento/Signifyd/Model/CommentsHistoryUpdater.php | 2 +-
app/code/Magento/Signifyd/Model/Config.php | 2 +-
app/code/Magento/Signifyd/Model/CustomerOrders.php | 2 +-
.../Magento/Signifyd/Model/Guarantee/CancelGuaranteeAbility.php | 2 +-
app/code/Magento/Signifyd/Model/Guarantee/CancelingService.php | 2 +-
.../Magento/Signifyd/Model/Guarantee/CreateGuaranteeAbility.php | 2 +-
app/code/Magento/Signifyd/Model/Guarantee/CreationService.php | 2 +-
.../Magento/Signifyd/Model/MessageGenerators/CaseRescore.php | 2 +-
.../Signifyd/Model/MessageGenerators/GeneratorException.php | 2 +-
.../Signifyd/Model/MessageGenerators/GeneratorFactory.php | 2 +-
.../Signifyd/Model/MessageGenerators/GeneratorInterface.php | 2 +-
.../Signifyd/Model/MessageGenerators/PatternGenerator.php | 2 +-
.../Signifyd/Model/PaymentMethodMapper/PaymentMethodMapper.php | 2 +-
.../Model/PaymentMethodMapper/XmlToArrayConfigConverter.php | 2 +-
app/code/Magento/Signifyd/Model/PaymentVerificationFactory.php | 2 +-
app/code/Magento/Signifyd/Model/PredefinedVerificationCode.php | 2 +-
.../Signifyd/Model/QuoteSession/Adminhtml/BackendSession.php | 2 +-
.../Magento/Signifyd/Model/QuoteSession/FrontendSession.php | 2 +-
.../Signifyd/Model/QuoteSession/QuoteSessionInterface.php | 2 +-
app/code/Magento/Signifyd/Model/ResourceModel/CaseEntity.php | 2 +-
.../Signifyd/Model/ResourceModel/CaseEntity/Collection.php | 2 +-
.../Model/SalesOrderGrid/NotSyncedOrderIdListProvider.php | 2 +-
.../Magento/Signifyd/Model/SalesOrderGrid/OrderGridUpdater.php | 2 +-
.../Magento/Signifyd/Model/SignifydGateway/ApiCallException.php | 2 +-
app/code/Magento/Signifyd/Model/SignifydGateway/ApiClient.php | 2 +-
.../Signifyd/Model/SignifydGateway/Client/HttpClientFactory.php | 2 +-
.../Signifyd/Model/SignifydGateway/Client/RequestBuilder.php | 2 +-
.../Signifyd/Model/SignifydGateway/Client/RequestSender.php | 2 +-
.../Signifyd/Model/SignifydGateway/Client/ResponseHandler.php | 2 +-
.../Signifyd/Model/SignifydGateway/Debugger/BlackHole.php | 2 +-
.../Signifyd/Model/SignifydGateway/Debugger/DebuggerFactory.php | 2 +-
.../Model/SignifydGateway/Debugger/DebuggerInterface.php | 2 +-
.../Magento/Signifyd/Model/SignifydGateway/Debugger/Log.php | 2 +-
app/code/Magento/Signifyd/Model/SignifydGateway/Gateway.php | 2 +-
.../Magento/Signifyd/Model/SignifydGateway/GatewayException.php | 2 +-
.../Signifyd/Model/SignifydGateway/Request/AddressBuilder.php | 2 +-
.../Signifyd/Model/SignifydGateway/Request/CardBuilder.php | 2 +-
.../Model/SignifydGateway/Request/ClientVersionBuilder.php | 2 +-
.../Model/SignifydGateway/Request/CreateCaseBuilder.php | 2 +-
.../SignifydGateway/Request/CreateCaseBuilderInterface.php | 2 +-
.../Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php | 2 +-
.../Signifyd/Model/SignifydGateway/Request/RecipientBuilder.php | 2 +-
.../Signifyd/Model/SignifydGateway/Request/SellerBuilder.php | 2 +-
.../Model/SignifydGateway/Request/UserAccountBuilder.php | 2 +-
.../Signifyd/Model/SignifydGateway/Response/WebhookMessage.php | 2 +-
.../Model/SignifydGateway/Response/WebhookMessageReader.php | 2 +-
.../Signifyd/Model/SignifydGateway/Response/WebhookRequest.php | 2 +-
.../Model/SignifydGateway/Response/WebhookRequestValidator.php | 2 +-
app/code/Magento/Signifyd/Model/SignifydOrderSessionId.php | 2 +-
app/code/Magento/Signifyd/Observer/PlaceOrder.php | 2 +-
app/code/Magento/Signifyd/Setup/InstallSchema.php | 2 +-
.../Magento/Signifyd/Test/Unit/Block/Adminhtml/CaseInfoTest.php | 2 +-
.../Signifyd/Test/Unit/Controller/Webhooks/HandlerTest.php | 2 +-
.../Test/Unit/Model/CaseServices/UpdatingServiceFactoryTest.php | 2 +-
.../Test/Unit/Model/CaseServices/UpdatingServiceTest.php | 2 +-
.../Signifyd/Test/Unit/Model/CommentsHistoryUpdaterTest.php | 2 +-
.../Magento/Signifyd/Test/Unit/Model/CustomerOrdersTest.php | 2 +-
.../Test/Unit/Model/Guarantee/CancelGuaranteeAbilityTest.php | 2 +-
.../Signifyd/Test/Unit/Model/Guarantee/CancelingServiceTest.php | 2 +-
.../Test/Unit/Model/Guarantee/CreateGuaranteeAbilityTest.php | 2 +-
.../Signifyd/Test/Unit/Model/Guarantee/CreationServiceTest.php | 2 +-
.../Test/Unit/Model/MessageGenerators/CaseRescoreTest.php | 2 +-
.../Test/Unit/Model/MessageGenerators/GeneratorFactoryTest.php | 2 +-
.../Test/Unit/Model/MessageGenerators/PatternGeneratorTest.php | 2 +-
.../Model/PaymentMethodMapper/XmlToArrayConfigConverterTest.php | 2 +-
.../Unit/Model/PaymentMethodMapper/_files/expected_array.php | 2 +-
.../PaymentMethodMapper/_files/signifyd_payment_mapping.xml | 2 +-
.../Signifyd/Test/Unit/Model/PaymentVerificationFactoryTest.php | 2 +-
.../Test/Unit/Model/SalesOrderGrid/OrderGridUpdaterTest.php | 2 +-
.../Unit/Model/SignifydGateway/Client/HttpClientFactoryTest.php | 2 +-
.../Unit/Model/SignifydGateway/Client/ResponseHandlerTest.php | 2 +-
.../Signifyd/Test/Unit/Model/SignifydGateway/GatewayTest.php | 2 +-
.../Model/SignifydGateway/Response/WebhookMessageReaderTest.php | 2 +-
.../SignifydGateway/Response/WebhookRequestValidatorTest.php | 2 +-
.../Signifyd/Test/Unit/Model/SignifydOrderSessionIdTest.php | 2 +-
app/code/Magento/Signifyd/Test/Unit/Observer/PlaceOrderTest.php | 2 +-
.../Signifyd/Ui/Component/Listing/Column/Guarantee/Options.php | 2 +-
app/code/Magento/Signifyd/etc/acl.xml | 2 +-
app/code/Magento/Signifyd/etc/adminhtml/di.xml | 2 +-
app/code/Magento/Signifyd/etc/adminhtml/routes.xml | 2 +-
app/code/Magento/Signifyd/etc/adminhtml/system.xml | 2 +-
app/code/Magento/Signifyd/etc/config.xml | 2 +-
app/code/Magento/Signifyd/etc/constraints.xml | 2 +-
app/code/Magento/Signifyd/etc/di.xml | 2 +-
app/code/Magento/Signifyd/etc/events.xml | 2 +-
app/code/Magento/Signifyd/etc/frontend/di.xml | 2 +-
app/code/Magento/Signifyd/etc/frontend/routes.xml | 2 +-
app/code/Magento/Signifyd/etc/module.xml | 2 +-
app/code/Magento/Signifyd/etc/signifyd_payment_mapping.xml | 2 +-
app/code/Magento/Signifyd/etc/signifyd_payment_mapping.xsd | 2 +-
app/code/Magento/Signifyd/registration.php | 2 +-
.../Magento/Signifyd/view/adminhtml/layout/sales_order_view.xml | 2 +-
.../Magento/Signifyd/view/adminhtml/templates/case_info.phtml | 2 +-
.../Signifyd/view/adminhtml/ui_component/sales_order_grid.xml | 2 +-
app/code/Magento/Signifyd/view/adminhtml/web/js/request-send.js | 2 +-
.../Signifyd/view/frontend/layout/checkout_cart_index.xml | 2 +-
.../Signifyd/view/frontend/layout/checkout_index_index.xml | 2 +-
.../Magento/Signifyd/view/frontend/templates/fingerprint.phtml | 2 +-
118 files changed, 118 insertions(+), 118 deletions(-)
diff --git a/app/code/Magento/Signifyd/Api/CaseCreationServiceInterface.php b/app/code/Magento/Signifyd/Api/CaseCreationServiceInterface.php
index 3cf727ee696eb..4664431ead85f 100644
--- a/app/code/Magento/Signifyd/Api/CaseCreationServiceInterface.php
+++ b/app/code/Magento/Signifyd/Api/CaseCreationServiceInterface.php
@@ -1,6 +1,6 @@
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/PaymentVerificationFactoryTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/PaymentVerificationFactoryTest.php
index 6c4ffaf7c142e..377c83a340a01 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/PaymentVerificationFactoryTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/PaymentVerificationFactoryTest.php
@@ -1,6 +1,6 @@
diff --git a/app/code/Magento/Signifyd/etc/adminhtml/di.xml b/app/code/Magento/Signifyd/etc/adminhtml/di.xml
index 1c827afa99dbc..c771d67216d43 100644
--- a/app/code/Magento/Signifyd/etc/adminhtml/di.xml
+++ b/app/code/Magento/Signifyd/etc/adminhtml/di.xml
@@ -1,7 +1,7 @@
diff --git a/app/code/Magento/Signifyd/etc/adminhtml/routes.xml b/app/code/Magento/Signifyd/etc/adminhtml/routes.xml
index 1f94759c1b7b6..0f5ec8f6ef3c4 100644
--- a/app/code/Magento/Signifyd/etc/adminhtml/routes.xml
+++ b/app/code/Magento/Signifyd/etc/adminhtml/routes.xml
@@ -1,7 +1,7 @@
diff --git a/app/code/Magento/Signifyd/etc/adminhtml/system.xml b/app/code/Magento/Signifyd/etc/adminhtml/system.xml
index e0a5fad5bf334..d9ba2f7ffdff2 100644
--- a/app/code/Magento/Signifyd/etc/adminhtml/system.xml
+++ b/app/code/Magento/Signifyd/etc/adminhtml/system.xml
@@ -1,7 +1,7 @@
diff --git a/app/code/Magento/Signifyd/etc/config.xml b/app/code/Magento/Signifyd/etc/config.xml
index a02a363358533..804342a14bb08 100644
--- a/app/code/Magento/Signifyd/etc/config.xml
+++ b/app/code/Magento/Signifyd/etc/config.xml
@@ -1,7 +1,7 @@
diff --git a/app/code/Magento/Signifyd/etc/constraints.xml b/app/code/Magento/Signifyd/etc/constraints.xml
index 65e3f45035dc2..1c02b42bf11c9 100644
--- a/app/code/Magento/Signifyd/etc/constraints.xml
+++ b/app/code/Magento/Signifyd/etc/constraints.xml
@@ -1,7 +1,7 @@
diff --git a/app/code/Magento/Signifyd/etc/di.xml b/app/code/Magento/Signifyd/etc/di.xml
index 551da4f023a56..bd05c8717b7d2 100644
--- a/app/code/Magento/Signifyd/etc/di.xml
+++ b/app/code/Magento/Signifyd/etc/di.xml
@@ -1,7 +1,7 @@
diff --git a/app/code/Magento/Signifyd/etc/events.xml b/app/code/Magento/Signifyd/etc/events.xml
index 9717f3947a9c4..a89b56ddf13c6 100644
--- a/app/code/Magento/Signifyd/etc/events.xml
+++ b/app/code/Magento/Signifyd/etc/events.xml
@@ -1,7 +1,7 @@
diff --git a/app/code/Magento/Signifyd/etc/frontend/di.xml b/app/code/Magento/Signifyd/etc/frontend/di.xml
index ceaa02a71e605..6aa887c67578d 100644
--- a/app/code/Magento/Signifyd/etc/frontend/di.xml
+++ b/app/code/Magento/Signifyd/etc/frontend/di.xml
@@ -1,7 +1,7 @@
diff --git a/app/code/Magento/Signifyd/etc/frontend/routes.xml b/app/code/Magento/Signifyd/etc/frontend/routes.xml
index a21f612e54bba..5803f59d8624b 100644
--- a/app/code/Magento/Signifyd/etc/frontend/routes.xml
+++ b/app/code/Magento/Signifyd/etc/frontend/routes.xml
@@ -1,7 +1,7 @@
diff --git a/app/code/Magento/Signifyd/etc/module.xml b/app/code/Magento/Signifyd/etc/module.xml
index 81d97d6fdc0d4..d5adcba88ad9a 100644
--- a/app/code/Magento/Signifyd/etc/module.xml
+++ b/app/code/Magento/Signifyd/etc/module.xml
@@ -1,7 +1,7 @@
diff --git a/app/code/Magento/Signifyd/etc/signifyd_payment_mapping.xml b/app/code/Magento/Signifyd/etc/signifyd_payment_mapping.xml
index 24f722d9e7246..096a968167173 100644
--- a/app/code/Magento/Signifyd/etc/signifyd_payment_mapping.xml
+++ b/app/code/Magento/Signifyd/etc/signifyd_payment_mapping.xml
@@ -1,7 +1,7 @@
diff --git a/app/code/Magento/Signifyd/registration.php b/app/code/Magento/Signifyd/registration.php
index f3a11ab0a1183..9f35e0bb2f41b 100644
--- a/app/code/Magento/Signifyd/registration.php
+++ b/app/code/Magento/Signifyd/registration.php
@@ -1,6 +1,6 @@
diff --git a/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml b/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml
index 07d4bb4f656d7..b706406331f1a 100644
--- a/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml
+++ b/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml
@@ -1,6 +1,6 @@
diff --git a/app/code/Magento/Signifyd/view/adminhtml/web/js/request-send.js b/app/code/Magento/Signifyd/view/adminhtml/web/js/request-send.js
index 881bb27477800..f55170336ca03 100644
--- a/app/code/Magento/Signifyd/view/adminhtml/web/js/request-send.js
+++ b/app/code/Magento/Signifyd/view/adminhtml/web/js/request-send.js
@@ -1,5 +1,5 @@
/**
- * Copyright © 2013-2017 Magento, Inc. All rights reserved.
+ * Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
diff --git a/app/code/Magento/Signifyd/view/frontend/layout/checkout_cart_index.xml b/app/code/Magento/Signifyd/view/frontend/layout/checkout_cart_index.xml
index a9ea616735d56..30472ae5e9ae9 100644
--- a/app/code/Magento/Signifyd/view/frontend/layout/checkout_cart_index.xml
+++ b/app/code/Magento/Signifyd/view/frontend/layout/checkout_cart_index.xml
@@ -1,7 +1,7 @@
diff --git a/app/code/Magento/Signifyd/view/frontend/layout/checkout_index_index.xml b/app/code/Magento/Signifyd/view/frontend/layout/checkout_index_index.xml
index a9ea616735d56..30472ae5e9ae9 100644
--- a/app/code/Magento/Signifyd/view/frontend/layout/checkout_index_index.xml
+++ b/app/code/Magento/Signifyd/view/frontend/layout/checkout_index_index.xml
@@ -1,7 +1,7 @@
diff --git a/app/code/Magento/Signifyd/view/frontend/templates/fingerprint.phtml b/app/code/Magento/Signifyd/view/frontend/templates/fingerprint.phtml
index 425d8c608cfc6..9ceccffa8dc19 100644
--- a/app/code/Magento/Signifyd/view/frontend/templates/fingerprint.phtml
+++ b/app/code/Magento/Signifyd/view/frontend/templates/fingerprint.phtml
@@ -1,6 +1,6 @@
Date: Fri, 17 Nov 2017 17:16:46 -0600
Subject: [PATCH 215/904] MAGETWO-72487: Move code to CE
- upgrading Magento2 Project PHPUnit version to latest
- add since annotation in doc block
- resolve some conflicts
---
.../Api/CaseCreationServiceInterface.php | 2 +
.../Signifyd/Api/CaseManagementInterface.php | 3 +
.../Signifyd/Api/CaseRepositoryInterface.php | 10 ++-
.../Signifyd/Api/Data/CaseInterface.php | 23 +++++
.../Api/Data/CaseSearchResultsInterface.php | 3 +
.../GuaranteeCancelingServiceInterface.php | 2 +
.../Api/GuaranteeCreationServiceInterface.php | 2 +
.../Signifyd/Block/Adminhtml/CaseInfo.php | 5 ++
.../Magento/Signifyd/Block/Fingerprint.php | 5 ++
.../Magento/Signifyd/Model/CaseRepository.php | 4 +-
.../Signifyd/Model/CommentsHistoryUpdater.php | 18 +++-
.../Magento/Signifyd/Model/CustomerOrders.php | 4 +-
.../MessageGenerators/GeneratorException.php | 3 +
.../Signifyd/Model/OrderStateService.php | 3 +-
.../Request/PurchaseBuilder.php | 11 ++-
.../Unit/Block/Adminhtml/CaseInfoTest.php | 2 +-
.../Unit/Controller/Webhooks/HandlerTest.php | 4 +-
.../UpdatingServiceFactoryTest.php | 2 +-
.../CaseServices/UpdatingServiceTest.php | 2 +-
.../Unit/Model/CommentsHistoryUpdaterTest.php | 40 +++++----
.../Test/Unit/Model/CustomerOrdersTest.php | 2 +-
.../Guarantee/CancelGuaranteeAbilityTest.php | 2 +-
.../Model/Guarantee/CancelingServiceTest.php | 2 +-
.../Guarantee/CreateGuaranteeAbilityTest.php | 2 +-
.../Model/Guarantee/CreationServiceTest.php | 2 +-
.../MessageGenerators/CaseRescoreTest.php | 3 +-
.../GeneratorFactoryTest.php | 2 +-
.../PatternGeneratorTest.php | 2 +-
.../Test/Unit/Model/OrderStateServiceTest.php | 2 +-
.../XmlToArrayConfigConverterTest.php | 2 +-
.../Model/PaymentVerificationFactoryTest.php | 2 +-
.../SalesOrderGrid/OrderGridUpdaterTest.php | 2 +-
.../Client/HttpClientFactoryTest.php | 2 +-
.../Client/ResponseHandlerTest.php | 3 +-
.../Model/SignifydGateway/GatewayTest.php | 35 +++++---
.../Response/WebhookMessageReaderTest.php | 2 +-
.../Response/WebhookRequestValidatorTest.php | 2 +-
.../Unit/Model/SignifydOrderSessionIdTest.php | 2 +-
.../Test/Unit/Observer/PlaceOrderTest.php | 5 +-
app/code/Magento/Signifyd/composer.json | 28 +++---
.../Magento/Signifyd/etc/adminhtml/routes.xml | 2 +-
app/code/Magento/Signifyd/etc/di.xml | 42 +++++----
app/code/Magento/Signifyd/etc/frontend/di.xml | 7 --
app/code/Magento/Signifyd/i18n/en_US.csv | 88 ++++++++++---------
app/code/Magento/Signifyd/registration.php | 8 +-
.../view/adminhtml/templates/case_info.phtml | 6 +-
.../ui_component/sales_order_grid.xml | 29 +++---
.../view/frontend/templates/fingerprint.phtml | 4 +-
48 files changed, 264 insertions(+), 174 deletions(-)
diff --git a/app/code/Magento/Signifyd/Api/CaseCreationServiceInterface.php b/app/code/Magento/Signifyd/Api/CaseCreationServiceInterface.php
index 4664431ead85f..f7611660b93a1 100644
--- a/app/code/Magento/Signifyd/Api/CaseCreationServiceInterface.php
+++ b/app/code/Magento/Signifyd/Api/CaseCreationServiceInterface.php
@@ -12,6 +12,7 @@
* Implementation should send request to Signifyd API and create new entity in Magento.
*
* @api
+ * @since 100.2.0
*/
interface CaseCreationServiceInterface
{
@@ -22,6 +23,7 @@ interface CaseCreationServiceInterface
* @return bool
* @throws \Magento\Framework\Exception\NotFoundException If order does not exists
* @throws \Magento\Framework\Exception\AlreadyExistsException If case for $orderId already exists
+ * @since 100.2.0
*/
public function createForOrder($orderId);
}
diff --git a/app/code/Magento/Signifyd/Api/CaseManagementInterface.php b/app/code/Magento/Signifyd/Api/CaseManagementInterface.php
index d12abebe8b98a..69075a308cb96 100644
--- a/app/code/Magento/Signifyd/Api/CaseManagementInterface.php
+++ b/app/code/Magento/Signifyd/Api/CaseManagementInterface.php
@@ -10,6 +10,7 @@
* Allows to performs operations with Signifyd cases.
*
* @api
+ * @since 100.2.0
*/
interface CaseManagementInterface
{
@@ -20,6 +21,7 @@ interface CaseManagementInterface
* @return \Magento\Signifyd\Api\Data\CaseInterface
* @throws \Magento\Framework\Exception\NotFoundException If order does not exists
* @throws \Magento\Framework\Exception\AlreadyExistsException If case for $orderId already exists
+ * @since 100.2.0
*/
public function create($orderId);
@@ -28,6 +30,7 @@ public function create($orderId);
*
* @param int $orderId
* @return \Magento\Signifyd\Api\Data\CaseInterface|null
+ * @since 100.2.0
*/
public function getByOrderId($orderId);
}
diff --git a/app/code/Magento/Signifyd/Api/CaseRepositoryInterface.php b/app/code/Magento/Signifyd/Api/CaseRepositoryInterface.php
index 2be176ba41111..4f148a082b300 100644
--- a/app/code/Magento/Signifyd/Api/CaseRepositoryInterface.php
+++ b/app/code/Magento/Signifyd/Api/CaseRepositoryInterface.php
@@ -9,6 +9,7 @@
* Signifyd Case repository interface
*
* @api
+ * @since 100.2.0
*/
interface CaseRepositoryInterface
{
@@ -17,6 +18,7 @@ interface CaseRepositoryInterface
*
* @param \Magento\Signifyd\Api\Data\CaseInterface $case
* @return \Magento\Signifyd\Api\Data\CaseInterface
+ * @since 100.2.0
*/
public function save(\Magento\Signifyd\Api\Data\CaseInterface $case);
@@ -25,6 +27,7 @@ public function save(\Magento\Signifyd\Api\Data\CaseInterface $case);
*
* @param int $id
* @return \Magento\Signifyd\Api\Data\CaseInterface
+ * @since 100.2.0
*/
public function getById($id);
@@ -33,6 +36,7 @@ public function getById($id);
*
* @param int $caseId
* @return \Magento\Signifyd\Api\Data\CaseInterface|null
+ * @since 100.2.0
*/
public function getByCaseId($caseId);
@@ -41,14 +45,16 @@ public function getByCaseId($caseId);
*
* @param \Magento\Signifyd\Api\Data\CaseInterface $case
* @return bool
+ * @since 100.2.0
*/
public function delete(\Magento\Signifyd\Api\Data\CaseInterface $case);
/**
* Gets list of case entities.
*
- * @param \Magento\Framework\Api\SearchCriteria $searchCriteria
+ * @param \Magento\Framework\Api\SearchCriteriaInterface $searchCriteria
* @return \Magento\Signifyd\Api\Data\CaseSearchResultsInterface
+ * @since 100.2.0
*/
- public function getList(\Magento\Framework\Api\SearchCriteria $searchCriteria);
+ public function getList(\Magento\Framework\Api\SearchCriteriaInterface $searchCriteria);
}
diff --git a/app/code/Magento/Signifyd/Api/Data/CaseInterface.php b/app/code/Magento/Signifyd/Api/Data/CaseInterface.php
index a14d81eb18465..eff46b972fc02 100644
--- a/app/code/Magento/Signifyd/Api/Data/CaseInterface.php
+++ b/app/code/Magento/Signifyd/Api/Data/CaseInterface.php
@@ -12,6 +12,7 @@
*
* @api
* @see https://www.signifyd.com/docs/api/#/reference/cases/retrieve-a-case/get-a-case
+ * @since 100.2.0
*/
interface CaseInterface
{
@@ -48,6 +49,7 @@ interface CaseInterface
* Returns local case entity identifier.
*
* @return int
+ * @since 100.2.0
*/
public function getEntityId();
@@ -56,6 +58,7 @@ public function getEntityId();
*
* @param int $id
* @return $this
+ * @since 100.2.0
*/
public function setEntityId($id);
@@ -63,6 +66,7 @@ public function setEntityId($id);
* Returns Signifyd case identifier.
*
* @return int
+ * @since 100.2.0
*/
public function getCaseId();
@@ -71,6 +75,7 @@ public function getCaseId();
*
* @param int $id
* @return $this
+ * @since 100.2.0
*/
public function setCaseId($id);
@@ -79,6 +84,7 @@ public function setCaseId($id);
* Returns null if state of guarantee eligible does not set yet.
*
* @return boolean|null
+ * @since 100.2.0
*/
public function isGuaranteeEligible();
@@ -87,6 +93,7 @@ public function isGuaranteeEligible();
*
* @param bool $guaranteeEligible
* @return $this
+ * @since 100.2.0
*/
public function setGuaranteeEligible($guaranteeEligible);
@@ -94,6 +101,7 @@ public function setGuaranteeEligible($guaranteeEligible);
* Returns decision state of the guarantee.
*
* @return string
+ * @since 100.2.0
*/
public function getGuaranteeDisposition();
@@ -102,6 +110,7 @@ public function getGuaranteeDisposition();
*
* @param string $disposition
* @return $this
+ * @since 100.2.0
*/
public function setGuaranteeDisposition($disposition);
@@ -109,6 +118,7 @@ public function setGuaranteeDisposition($disposition);
* Returns case status.
*
* @return string
+ * @since 100.2.0
*/
public function getStatus();
@@ -117,6 +127,7 @@ public function getStatus();
*
* @param string $status
* @return $this
+ * @since 100.2.0
*/
public function setStatus($status);
@@ -124,6 +135,7 @@ public function setStatus($status);
* Returns value, which indicates the likelihood that the order is fraud.
*
* @return int
+ * @since 100.2.0
*/
public function getScore();
@@ -132,6 +144,7 @@ public function getScore();
*
* @param int $score
* @return $this
+ * @since 100.2.0
*/
public function setScore($score);
@@ -139,6 +152,7 @@ public function setScore($score);
* Get order id for a case.
*
* @return int
+ * @since 100.2.0
*/
public function getOrderId();
@@ -147,6 +161,7 @@ public function getOrderId();
*
* @param int $orderId
* @return $this
+ * @since 100.2.0
*/
public function setOrderId($orderId);
@@ -154,6 +169,7 @@ public function setOrderId($orderId);
* Returns data about a team associated with a case.
*
* @return array
+ * @since 100.2.0
*/
public function getAssociatedTeam();
@@ -162,6 +178,7 @@ public function getAssociatedTeam();
*
* @param array $team
* @return $this
+ * @since 100.2.0
*/
public function setAssociatedTeam(array $team);
@@ -169,6 +186,7 @@ public function setAssociatedTeam(array $team);
* Returns disposition of an agent's opinion after reviewing the case.
*
* @return string
+ * @since 100.2.0
*/
public function getReviewDisposition();
@@ -177,6 +195,7 @@ public function getReviewDisposition();
*
* @param string $disposition
* @return $this
+ * @since 100.2.0
*/
public function setReviewDisposition($disposition);
@@ -184,6 +203,7 @@ public function setReviewDisposition($disposition);
* Returns creation datetime for a case.
*
* @return string
+ * @since 100.2.0
*/
public function getCreatedAt();
@@ -192,6 +212,7 @@ public function getCreatedAt();
*
* @param string $datetime in DATE_ATOM format
* @return $this
+ * @since 100.2.0
*/
public function setCreatedAt($datetime);
@@ -199,6 +220,7 @@ public function setCreatedAt($datetime);
* Returns updating datetime for a case.
*
* @return string
+ * @since 100.2.0
*/
public function getUpdatedAt();
@@ -207,6 +229,7 @@ public function getUpdatedAt();
*
* @param string $datetime in DATE_ATOM format
* @return $this
+ * @since 100.2.0
*/
public function setUpdatedAt($datetime);
}
diff --git a/app/code/Magento/Signifyd/Api/Data/CaseSearchResultsInterface.php b/app/code/Magento/Signifyd/Api/Data/CaseSearchResultsInterface.php
index a0a571613d3b1..78d37841cff69 100644
--- a/app/code/Magento/Signifyd/Api/Data/CaseSearchResultsInterface.php
+++ b/app/code/Magento/Signifyd/Api/Data/CaseSearchResultsInterface.php
@@ -11,6 +11,7 @@
* Retrieve and set list of case entities.
*
* @api
+ * @since 100.2.0
*/
interface CaseSearchResultsInterface extends SearchResultsInterface
{
@@ -18,6 +19,7 @@ interface CaseSearchResultsInterface extends SearchResultsInterface
* Gets collection of case entities.
*
* @return \Magento\Signifyd\Api\Data\CaseInterface[]
+ * @since 100.2.0
*/
public function getItems();
@@ -26,6 +28,7 @@ public function getItems();
*
* @param \Magento\Signifyd\Api\Data\CaseInterface[] $items
* @return $this
+ * @since 100.2.0
*/
public function setItems(array $items);
}
diff --git a/app/code/Magento/Signifyd/Api/GuaranteeCancelingServiceInterface.php b/app/code/Magento/Signifyd/Api/GuaranteeCancelingServiceInterface.php
index 9c000cecb37ee..41f4753d036a7 100644
--- a/app/code/Magento/Signifyd/Api/GuaranteeCancelingServiceInterface.php
+++ b/app/code/Magento/Signifyd/Api/GuaranteeCancelingServiceInterface.php
@@ -12,6 +12,7 @@
* Implementation should send request to Signifyd API and update existing case entity with guarantee information.
*
* @api
+ * @since 100.2.0
*/
interface GuaranteeCancelingServiceInterface
{
@@ -20,6 +21,7 @@ interface GuaranteeCancelingServiceInterface
*
* @param int $orderId
* @return bool
+ * @since 100.2.0
*/
public function cancelForOrder($orderId);
}
diff --git a/app/code/Magento/Signifyd/Api/GuaranteeCreationServiceInterface.php b/app/code/Magento/Signifyd/Api/GuaranteeCreationServiceInterface.php
index 609f3166df0a2..b4502ea861acd 100644
--- a/app/code/Magento/Signifyd/Api/GuaranteeCreationServiceInterface.php
+++ b/app/code/Magento/Signifyd/Api/GuaranteeCreationServiceInterface.php
@@ -12,6 +12,7 @@
* Implementation should send request to Signifyd API and update existing case entity with guarantee infromation.
*
* @api
+ * @since 100.2.0
*/
interface GuaranteeCreationServiceInterface
{
@@ -20,6 +21,7 @@ interface GuaranteeCreationServiceInterface
*
* @param int $orderId
* @return bool
+ * @since 100.2.0
*/
public function createForOrder($orderId);
}
diff --git a/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php b/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php
index fe7f810981389..87d09e392e091 100644
--- a/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php
+++ b/app/code/Magento/Signifyd/Block/Adminhtml/CaseInfo.php
@@ -12,6 +12,9 @@
/**
* Get Signifyd Case Info
+ *
+ * @api
+ * @since 100.2.0
*/
class CaseInfo extends Template
{
@@ -72,6 +75,7 @@ private function getCaseProperty($defaultValue, callable $callback)
* Checks if case is exists for order
*
* @return bool
+ * @since 100.2.0
*/
public function isEmptyCase()
{
@@ -82,6 +86,7 @@ public function isEmptyCase()
* Gets case guarantee disposition status.
*
* @return string
+ * @since 100.2.0
*/
public function getCaseGuaranteeDisposition()
{
diff --git a/app/code/Magento/Signifyd/Block/Fingerprint.php b/app/code/Magento/Signifyd/Block/Fingerprint.php
index dbafd8be2554d..7afa092b3d0da 100644
--- a/app/code/Magento/Signifyd/Block/Fingerprint.php
+++ b/app/code/Magento/Signifyd/Block/Fingerprint.php
@@ -17,7 +17,9 @@
* Signifyd’s device fingerprinting solution uniquely tracks and identifies devices
* used to transact on your site, increasing your protection from fraud.
*
+ * @api
* @see https://www.signifyd.com/docs/api/#/reference/device-fingerprint/create-a-case
+ * @since 100.2.0
*/
class Fingerprint extends Template
{
@@ -38,6 +40,7 @@ class Fingerprint extends Template
/**
* @var string
+ * @since 100.2.0
*/
protected $_template = 'fingerprint.phtml';
@@ -65,6 +68,7 @@ public function __construct(
* Returns a unique Signifyd order session id.
*
* @return string
+ * @since 100.2.0
*/
public function getSignifydOrderSessionId()
{
@@ -77,6 +81,7 @@ public function getSignifydOrderSessionId()
* Checks if module is enabled.
*
* @return boolean
+ * @since 100.2.0
*/
public function isModuleActive()
{
diff --git a/app/code/Magento/Signifyd/Model/CaseRepository.php b/app/code/Magento/Signifyd/Model/CaseRepository.php
index aefed3b52199b..ea3ea3e67aafd 100644
--- a/app/code/Magento/Signifyd/Model/CaseRepository.php
+++ b/app/code/Magento/Signifyd/Model/CaseRepository.php
@@ -5,7 +5,7 @@
*/
namespace Magento\Signifyd\Model;
-use Magento\Framework\Api\SearchCriteria;
+use Magento\Framework\Api\SearchCriteriaInterface;
use Magento\Framework\Api\SearchCriteria\CollectionProcessorInterface;
use Magento\Signifyd\Api\CaseRepositoryInterface;
use Magento\Signifyd\Api\Data\CaseInterface;
@@ -118,7 +118,7 @@ public function delete(CaseInterface $case)
/**
* @inheritdoc
*/
- public function getList(SearchCriteria $searchCriteria)
+ public function getList(SearchCriteriaInterface $searchCriteria)
{
/** @var Collection $collection */
$collection = $this->collectionFactory->create();
diff --git a/app/code/Magento/Signifyd/Model/CommentsHistoryUpdater.php b/app/code/Magento/Signifyd/Model/CommentsHistoryUpdater.php
index 0a24c972c4c6b..f473d157efa4a 100644
--- a/app/code/Magento/Signifyd/Model/CommentsHistoryUpdater.php
+++ b/app/code/Magento/Signifyd/Model/CommentsHistoryUpdater.php
@@ -6,6 +6,7 @@
namespace Magento\Signifyd\Model;
use Magento\Framework\Phrase;
+use Magento\Sales\Api\OrderStatusHistoryRepositoryInterface;
use Magento\Sales\Model\Order\Status\HistoryFactory;
use Magento\Signifyd\Api\Data\CaseInterface;
@@ -19,14 +20,23 @@ class CommentsHistoryUpdater
*/
private $historyFactory;
+ /**
+ * @var OrderStatusHistoryRepositoryInterface
+ */
+ private $historyRepository;
+
/**
* CommentsHistoryUpdater constructor.
*
* @param HistoryFactory $historyFactory
+ * @param OrderStatusHistoryRepositoryInterface $historyRepository
*/
- public function __construct(HistoryFactory $historyFactory)
- {
+ public function __construct(
+ HistoryFactory $historyFactory,
+ OrderStatusHistoryRepositoryInterface $historyRepository
+ ) {
$this->historyFactory = $historyFactory;
+ $this->historyRepository = $historyRepository;
}
/**
@@ -49,7 +59,7 @@ public function addComment(CaseInterface $case, Phrase $message, $status = '')
$history->setParentId($case->getOrderId())
->setComment($message)
->setEntityName('order')
- ->setStatus($status)
- ->save();
+ ->setStatus($status);
+ $this->historyRepository->save($history);
}
}
diff --git a/app/code/Magento/Signifyd/Model/CustomerOrders.php b/app/code/Magento/Signifyd/Model/CustomerOrders.php
index 4cd725d642e97..c326cf06424c0 100644
--- a/app/code/Magento/Signifyd/Model/CustomerOrders.php
+++ b/app/code/Magento/Signifyd/Model/CustomerOrders.php
@@ -81,8 +81,8 @@ public function __construct(
* Returns aggregated customer orders count and total amount in USD.
*
* Returned array contains next keys:
- ** aggregateOrderCount - total count of orders placed by this account since it was created, including the current
- ** aggregateOrderDollars - total amount spent by this account since it was created, including the current order
+ * aggregateOrderCount - total count of orders placed by this account since it was created, including the current
+ * aggregateOrderDollars - total amount spent by this account since it was created, including the current order
*
* @param int $customerId
* @return array
diff --git a/app/code/Magento/Signifyd/Model/MessageGenerators/GeneratorException.php b/app/code/Magento/Signifyd/Model/MessageGenerators/GeneratorException.php
index 1298a85934350..103cb9fc1e2d3 100644
--- a/app/code/Magento/Signifyd/Model/MessageGenerators/GeneratorException.php
+++ b/app/code/Magento/Signifyd/Model/MessageGenerators/GeneratorException.php
@@ -9,6 +9,9 @@
/**
* Common exception for Signifyd message generators.
+ *
+ * @api
+ * @since 100.2.0
*/
class GeneratorException extends LocalizedException
{
diff --git a/app/code/Magento/Signifyd/Model/OrderStateService.php b/app/code/Magento/Signifyd/Model/OrderStateService.php
index 47e3c7a4d1f14..2b3f0e155981e 100644
--- a/app/code/Magento/Signifyd/Model/OrderStateService.php
+++ b/app/code/Magento/Signifyd/Model/OrderStateService.php
@@ -55,8 +55,7 @@ public function updateByCase(CaseInterface $case)
{
$orderId = $case->getOrderId();
- switch ($case->getGuaranteeDisposition())
- {
+ switch ($case->getGuaranteeDisposition()) {
case CaseInterface::GUARANTEE_APPROVED:
$this->unHold($orderId);
break;
diff --git a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php
index 7f1311c90ba42..858ce0f0f3287 100644
--- a/app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php
+++ b/app/code/Magento/Signifyd/Model/SignifydGateway/Request/PurchaseBuilder.php
@@ -175,7 +175,16 @@ private function getShippingMethod($shippingDescription)
*/
private function getPaymentGateway($gatewayCode)
{
- return strstr($gatewayCode, 'paypal') === false ? $gatewayCode : 'paypal_account';
+ $payPalCodeList = [
+ 'paypal_express',
+ 'braintree_paypal',
+ 'payflowpro',
+ 'payflow_express',
+ 'payflow_link',
+ 'payflow_advanced',
+ 'hosted_pro',
+ ];
+ return in_array($gatewayCode, $payPalCodeList) ? 'paypal_account' : $gatewayCode;
}
/**
diff --git a/app/code/Magento/Signifyd/Test/Unit/Block/Adminhtml/CaseInfoTest.php b/app/code/Magento/Signifyd/Test/Unit/Block/Adminhtml/CaseInfoTest.php
index 4e23d32b6de67..164cd8018fb69 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Block/Adminhtml/CaseInfoTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Block/Adminhtml/CaseInfoTest.php
@@ -19,7 +19,7 @@
*
* Class CaseInfoTest
*/
-class CaseInfoTest extends \PHPUnit_Framework_TestCase
+class CaseInfoTest extends \PHPUnit\Framework\TestCase
{
/**
* @var CaseInterface|MockObject
diff --git a/app/code/Magento/Signifyd/Test/Unit/Controller/Webhooks/HandlerTest.php b/app/code/Magento/Signifyd/Test/Unit/Controller/Webhooks/HandlerTest.php
index 6e17432fa0e4f..1a8cfdc703247 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Controller/Webhooks/HandlerTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Controller/Webhooks/HandlerTest.php
@@ -27,7 +27,7 @@
*
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class HandlerTest extends \PHPUnit_Framework_TestCase
+class HandlerTest extends \PHPUnit\Framework\TestCase
{
/**
* @var Handler
@@ -121,7 +121,7 @@ protected function setUp()
$config = $this->getMockBuilder(Config::class)
->disableOriginalConstructor()
- ->setMethods(['isDebugModeEnabled'])
+ ->setMethods(['isDebugModeEnabled', 'getByCaseId'])
->getMock();
$config->expects(self::any())
->method('getByCaseId')
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/CaseServices/UpdatingServiceFactoryTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/CaseServices/UpdatingServiceFactoryTest.php
index f903c1ad0efad..f0184c032b550 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/CaseServices/UpdatingServiceFactoryTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/CaseServices/UpdatingServiceFactoryTest.php
@@ -18,7 +18,7 @@
/**
* Contains tests for case updating service factory.
*/
-class UpdatingServiceFactoryTest extends \PHPUnit_Framework_TestCase
+class UpdatingServiceFactoryTest extends \PHPUnit\Framework\TestCase
{
/**
* @var UpdatingServiceFactory
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/CaseServices/UpdatingServiceTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/CaseServices/UpdatingServiceTest.php
index 2dfcc5c7ea862..6eb7e5c37d5fc 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/CaseServices/UpdatingServiceTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/CaseServices/UpdatingServiceTest.php
@@ -19,7 +19,7 @@
/**
* Contains tests with different negative and positive scenarios for case updating service.
*/
-class UpdatingServiceTest extends \PHPUnit_Framework_TestCase
+class UpdatingServiceTest extends \PHPUnit\Framework\TestCase
{
/**
* @var UpdatingService
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/CommentsHistoryUpdaterTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/CommentsHistoryUpdaterTest.php
index 2dc9ad4d2d457..5cbb3d8d93cdd 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/CommentsHistoryUpdaterTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/CommentsHistoryUpdaterTest.php
@@ -11,11 +11,12 @@
use Magento\Signifyd\Api\Data\CaseInterface;
use Magento\Signifyd\Model\CommentsHistoryUpdater;
use PHPUnit_Framework_MockObject_MockObject as MockObject;
+use Magento\Sales\Api\OrderStatusHistoryRepositoryInterface;
/**
* Contains tests for comments history updater class.
*/
-class CommentsHistoryUpdaterTest extends \PHPUnit_Framework_TestCase
+class CommentsHistoryUpdaterTest extends \PHPUnit\Framework\TestCase
{
/**
* @var int
@@ -52,6 +53,11 @@ class CommentsHistoryUpdaterTest extends \PHPUnit_Framework_TestCase
*/
private $historyEntity;
+ /**
+ * @var OrderStatusHistoryRepositoryInterface|MockObject
+ */
+ private $historyRepository;
+
/**
* @inheritdoc
*/
@@ -61,9 +67,12 @@ protected function setUp()
$this->historyFactory = $this->getMockBuilder(HistoryFactory::class)
->disableOriginalConstructor()
- ->setMethods(['create'])
+ ->setMethods(['create', 'save'])
->getMock();
+ $this->historyRepository = $this->getMockBuilder(OrderStatusHistoryRepositoryInterface::class)
+ ->getMockForAbstractClass();
+
$this->caseEntity = $this->getMockBuilder(CaseInterface::class)
->disableOriginalConstructor()
->setMethods(['getOrderId'])
@@ -72,7 +81,8 @@ protected function setUp()
$this->initCommentMock();
$this->updater = $objectManager->getObject(CommentsHistoryUpdater::class, [
- 'historyFactory' => $this->historyFactory
+ 'historyFactory' => $this->historyFactory,
+ 'historyRepository' => $this->historyRepository
]);
}
@@ -88,12 +98,12 @@ public function testAddCommentWithException()
->method('getOrderId')
->willReturn(self::$orderId);
- $this->historyEntity->expects(self::any())
- ->method('setStatus')
+ $this->historyEntity->method('setStatus')
->with('')
->willReturnSelf();
- $this->historyEntity->expects(self::once())
+ $this->historyRepository->expects(self::once())
->method('save')
+ ->with($this->historyEntity)
->willThrowException(new \Exception('Cannot save comment message.'));
$this->updater->addComment($this->caseEntity, __(self::$message));
@@ -110,12 +120,12 @@ public function testAddComment()
->method('getOrderId')
->willReturn(self::$orderId);
- $this->historyEntity->expects(self::any())
- ->method('setStatus')
+ $this->historyEntity->method('setStatus')
->with(self::$status)
->willReturnSelf();
- $this->historyEntity->expects(self::once())
+ $this->historyRepository->expects(self::once())
->method('save')
+ ->with($this->historyEntity)
->willReturnSelf();
$this->updater->addComment($this->caseEntity, __(self::$message), self::$status);
@@ -150,20 +160,16 @@ private function initCommentMock()
->setMethods(['setParentId', 'setComment', 'setEntityName', 'save'])
->getMockForAbstractClass();
- $this->historyFactory->expects(self::any())
- ->method('create')
+ $this->historyFactory->method('create')
->willReturn($this->historyEntity);
- $this->historyEntity->expects(self::any())
- ->method('setParentId')
+ $this->historyEntity->method('setParentId')
->with(self::$orderId)
->willReturnSelf();
- $this->historyEntity->expects(self::any())
- ->method('setComment')
+ $this->historyEntity->method('setComment')
->with(self::$message)
->willReturnSelf();
- $this->historyEntity->expects(self::any())
- ->method('setEntityName')
+ $this->historyEntity->method('setEntityName')
->with('order')
->willReturnSelf();
}
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/CustomerOrdersTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/CustomerOrdersTest.php
index 67a508be20c0d..02d3b4b9ad7a7 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/CustomerOrdersTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/CustomerOrdersTest.php
@@ -19,7 +19,7 @@
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class CustomerOrdersTest extends \PHPUnit_Framework_TestCase
+class CustomerOrdersTest extends \PHPUnit\Framework\TestCase
{
/**
* @var int
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CancelGuaranteeAbilityTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CancelGuaranteeAbilityTest.php
index 572bb48f87a46..f7b4e473a0ec8 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CancelGuaranteeAbilityTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CancelGuaranteeAbilityTest.php
@@ -16,7 +16,7 @@
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class CancelGuaranteeAbilityTest extends \PHPUnit_Framework_TestCase
+class CancelGuaranteeAbilityTest extends \PHPUnit\Framework\TestCase
{
/**
* @var OrderRepositoryInterface|\PHPUnit_Framework_MockObject_MockObject
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CancelingServiceTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CancelingServiceTest.php
index 90365d1ec788a..f8f1d4a4522c9 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CancelingServiceTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CancelingServiceTest.php
@@ -19,7 +19,7 @@
/**
* Contains test cases for Signifyd guarantee canceling service.
*/
-class CancelingServiceTest extends \PHPUnit_Framework_TestCase
+class CancelingServiceTest extends \PHPUnit\Framework\TestCase
{
/**
* @var int
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CreateGuaranteeAbilityTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CreateGuaranteeAbilityTest.php
index cae198d54c618..7ba3ab3eef4f6 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CreateGuaranteeAbilityTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CreateGuaranteeAbilityTest.php
@@ -17,7 +17,7 @@
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class CreateGuaranteeAbilityTest extends \PHPUnit_Framework_TestCase
+class CreateGuaranteeAbilityTest extends \PHPUnit\Framework\TestCase
{
/**
* @var DateTimeFactory
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CreationServiceTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CreationServiceTest.php
index 0d488949b20d5..a22bfe12222a6 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CreationServiceTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/Guarantee/CreationServiceTest.php
@@ -14,7 +14,7 @@
use Magento\Signifyd\Model\SignifydGateway\Gateway;
use Magento\Signifyd\Model\SignifydGateway\GatewayException;
use PHPUnit_Framework_MockObject_MockObject as MockObject;
-use PHPUnit_Framework_TestCase as TestCase;
+use \PHPUnit\Framework\TestCase as TestCase;
use Psr\Log\LoggerInterface;
class CreationServiceTest extends TestCase
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseRescoreTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseRescoreTest.php
index 03dc16f3a8251..ba14036cd68d0 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseRescoreTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/CaseRescoreTest.php
@@ -16,7 +16,7 @@
*
* Class CaseRescoreTest
*/
-class CaseRescoreTest extends \PHPUnit_Framework_TestCase
+class CaseRescoreTest extends \PHPUnit\Framework\TestCase
{
private static $data = [
'caseId' => 100,
@@ -59,7 +59,6 @@ protected function setUp()
$this->caseRescore = $this->objectManager->getObject(CaseRescore::class, [
'caseRepository' => $this->caseRepository
]);
-
}
/**
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/GeneratorFactoryTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/GeneratorFactoryTest.php
index 8ada5eb71bdb1..50f87df3b694f 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/GeneratorFactoryTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/GeneratorFactoryTest.php
@@ -15,7 +15,7 @@
/**
* Contains tests for messages generators factory.
*/
-class GeneratorFactoryTest extends \PHPUnit_Framework_TestCase
+class GeneratorFactoryTest extends \PHPUnit\Framework\TestCase
{
/**
* @var GeneratorFactory
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/PatternGeneratorTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/PatternGeneratorTest.php
index 1fb060471319f..9d5f71f657a1e 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/PatternGeneratorTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/MessageGenerators/PatternGeneratorTest.php
@@ -10,7 +10,7 @@
/**
* Contains tests for different variations like empty data, wrong required arguments, or bad placeholders.
*/
-class PatternGeneratorTest extends \PHPUnit_Framework_TestCase
+class PatternGeneratorTest extends \PHPUnit\Framework\TestCase
{
/**
* Checks an exception if generators does not receives required data.
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/OrderStateServiceTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/OrderStateServiceTest.php
index 1555685b78d32..3a567a79891f8 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/OrderStateServiceTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/OrderStateServiceTest.php
@@ -13,7 +13,7 @@
use Magento\Signifyd\Model\OrderStateService;
use PHPUnit_Framework_MockObject_MockObject as MockObject;
-class OrderStateServiceTest extends \PHPUnit_Framework_TestCase
+class OrderStateServiceTest extends \PHPUnit\Framework\TestCase
{
/**
* @var int
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/PaymentMethodMapper/XmlToArrayConfigConverterTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/PaymentMethodMapper/XmlToArrayConfigConverterTest.php
index bff9401217355..319229e326c4b 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/PaymentMethodMapper/XmlToArrayConfigConverterTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/PaymentMethodMapper/XmlToArrayConfigConverterTest.php
@@ -9,7 +9,7 @@
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
use Magento\Framework\Config\Dom\ValidationSchemaException;
-class XmlToArrayConfigConverterTest extends \PHPUnit_Framework_TestCase
+class XmlToArrayConfigConverterTest extends \PHPUnit\Framework\TestCase
{
/**
* @var XmlToArrayConfigConverter
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/PaymentVerificationFactoryTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/PaymentVerificationFactoryTest.php
index 377c83a340a01..b0f9239d43bfa 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/PaymentVerificationFactoryTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/PaymentVerificationFactoryTest.php
@@ -12,7 +12,7 @@
use PHPUnit_Framework_MockObject_MockObject as MockObject;
use Magento\Payment\Gateway\ConfigInterface;
-class PaymentVerificationFactoryTest extends \PHPUnit_Framework_TestCase
+class PaymentVerificationFactoryTest extends \PHPUnit\Framework\TestCase
{
/**
* @var PaymentVerificationFactory
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/SalesOrderGrid/OrderGridUpdaterTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/SalesOrderGrid/OrderGridUpdaterTest.php
index 1dedb56f27d44..885c9f018a488 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/SalesOrderGrid/OrderGridUpdaterTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/SalesOrderGrid/OrderGridUpdaterTest.php
@@ -10,7 +10,7 @@
use Magento\Signifyd\Model\SalesOrderGrid\OrderGridUpdater;
use PHPUnit_Framework_MockObject_MockObject as MockObject;
-class OrderGridUpdaterTest extends \PHPUnit_Framework_TestCase
+class OrderGridUpdaterTest extends \PHPUnit\Framework\TestCase
{
/**
* @var GridInterface|MockObject
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/Client/HttpClientFactoryTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/Client/HttpClientFactoryTest.php
index 89bd0c64efe67..776e8a75b9646 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/Client/HttpClientFactoryTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/Client/HttpClientFactoryTest.php
@@ -13,7 +13,7 @@
use Magento\Framework\Json\EncoderInterface;
use \PHPUnit_Framework_MockObject_MockObject as MockObject;
-class HttpClientFactoryTest extends \PHPUnit_Framework_TestCase
+class HttpClientFactoryTest extends \PHPUnit\Framework\TestCase
{
/**
* @var string
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/Client/ResponseHandlerTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/Client/ResponseHandlerTest.php
index 10a4ee23bec8a..bf0c6ee238d5f 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/Client/ResponseHandlerTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/Client/ResponseHandlerTest.php
@@ -12,7 +12,7 @@
use \Zend_Http_Response as Response;
use \PHPUnit_Framework_MockObject_MockObject as MockObject;
-class ResponseHandlerTest extends \PHPUnit_Framework_TestCase
+class ResponseHandlerTest extends \PHPUnit\Framework\TestCase
{
/**
* @var string
@@ -70,7 +70,6 @@ public function setUp()
$this->responseHandler = $this->objectManager->getObject(ResponseHandler::class, [
'dataDecoder' => $this->dataDecoder
]);
-
}
/**
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/GatewayTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/GatewayTest.php
index ee59617aad926..f7aa65f842b91 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/GatewayTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/GatewayTest.php
@@ -5,7 +5,7 @@
*/
namespace Magento\Signifyd\Test\Unit\Model\SignifydGateway;
-use PHPUnit_Framework_TestCase as TestCase;
+use \PHPUnit\Framework\TestCase as TestCase;
use PHPUnit_Framework_MockObject_MockObject as MockObject;
use Magento\Signifyd\Model\SignifydGateway\Gateway;
use Magento\Signifyd\Model\SignifydGateway\GatewayException;
@@ -13,7 +13,7 @@
use Magento\Signifyd\Model\SignifydGateway\ApiClient;
use Magento\Signifyd\Model\SignifydGateway\ApiCallException;
-class GatewayTest extends TestCase
+class GatewayTest extends \PHPUnit\Framework\TestCase
{
/**
* @var CreateCaseBuilderInterface|MockObject
@@ -61,7 +61,8 @@ public function testCreateCaseForSpecifiedOrder()
->with($this->equalTo($dummyOrderId))
->willReturn([]);
- $this->gateway->createCase($dummyOrderId);
+ $result = $this->gateway->createCase($dummyOrderId);
+ $this->assertEquals(42, $result);
}
public function testCreateCaseCallsValidApiMethod()
@@ -84,7 +85,8 @@ public function testCreateCaseCallsValidApiMethod()
'investigationId' => $dummySignifydInvestigationId
]);
- $this->gateway->createCase($dummyOrderId);
+ $result = $this->gateway->createCase($dummyOrderId);
+ $this->assertEquals(42, $result);
}
public function testCreateCaseNormalFlow()
@@ -119,7 +121,7 @@ public function testCreateCaseWithFailedApiCall()
->method('makeApiCall')
->willThrowException(new ApiCallException($apiCallFailureMessage));
- $this->setExpectedException(
+ $this->expectException(
GatewayException::class,
$apiCallFailureMessage
);
@@ -138,7 +140,7 @@ public function testCreateCaseWithMissedResponseRequiredData()
'someOtherParameter' => 'foo',
]);
- $this->setExpectedException(GatewayException::class);
+ $this->expectException(GatewayException::class);
$this->gateway->createCase($dummyOrderId);
}
@@ -182,7 +184,8 @@ public function testSubmitCaseForGuaranteeCallsValidApiMethod()
'disposition' => $dummyDisposition
]);
- $this->gateway->submitCaseForGuarantee($dummySygnifydCaseId);
+ $result = $this->gateway->submitCaseForGuarantee($dummySygnifydCaseId);
+ $this->assertEquals('APPROVED', $result);
}
public function testSubmitCaseForGuaranteeWithFailedApiCall()
@@ -194,11 +197,12 @@ public function testSubmitCaseForGuaranteeWithFailedApiCall()
->method('makeApiCall')
->willThrowException(new ApiCallException($apiCallFailureMessage));
- $this->setExpectedException(
+ $this->expectException(
GatewayException::class,
$apiCallFailureMessage
);
- $this->gateway->submitCaseForGuarantee($dummySygnifydCaseId);
+ $result = $this->gateway->submitCaseForGuarantee($dummySygnifydCaseId);
+ $this->assertEquals('Api call failed', $result);
}
public function testSubmitCaseForGuaranteeReturnsDisposition()
@@ -237,7 +241,7 @@ public function testSubmitCaseForGuaranteeWithMissedDisposition()
'rereviewCount' => $dummyRereviewCount,
]);
- $this->setExpectedException(GatewayException::class);
+ $this->expectException(GatewayException::class);
$this->gateway->submitCaseForGuarantee($dummySygnifydCaseId);
}
@@ -252,8 +256,9 @@ public function testSubmitCaseForGuaranteeWithUnexpectedDisposition()
'disposition' => $dummyUnexpectedDisposition,
]);
- $this->setExpectedException(GatewayException::class);
- $this->gateway->submitCaseForGuarantee($dummySygnifydCaseId);
+ $this->expectException(GatewayException::class);
+ $result = $this->gateway->submitCaseForGuarantee($dummySygnifydCaseId);
+ $this->assertEquals('UNEXPECTED', $result);
}
/**
@@ -270,7 +275,8 @@ public function testSubmitCaseForGuaranteeWithExpectedDisposition($dummyExpected
]);
try {
- $this->gateway->submitCaseForGuarantee($dummySygnifydCaseId);
+ $result = $this->gateway->submitCaseForGuarantee($dummySygnifydCaseId);
+ $this->assertEquals($dummyExpectedDisposition, $result);
} catch (GatewayException $e) {
$this->fail(sprintf(
'Expected disposition "%s" was not accepted with message "%s"',
@@ -314,7 +320,8 @@ public function testCancelGuaranteeWithUnexpectedDisposition()
->with('/cases/' . $caseId . '/guarantee', 'PUT', ['guaranteeDisposition' => Gateway::GUARANTEE_CANCELED])
->willReturn(['disposition' => Gateway::GUARANTEE_DECLINED]);
- $this->gateway->cancelGuarantee($caseId);
+ $result = $this->gateway->cancelGuarantee($caseId);
+ $this->assertEquals(Gateway::GUARANTEE_CANCELED, $result);
}
public function supportedGuaranteeDispositionsProvider()
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/Response/WebhookMessageReaderTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/Response/WebhookMessageReaderTest.php
index 604c9c63c935f..0dfdf4980fb58 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/Response/WebhookMessageReaderTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/Response/WebhookMessageReaderTest.php
@@ -14,7 +14,7 @@
/**
* Class WebhookMessageReaderTest
*/
-class WebhookMessageReaderTest extends \PHPUnit_Framework_TestCase
+class WebhookMessageReaderTest extends \PHPUnit\Framework\TestCase
{
/**
* @var WebhookMessageReader
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/Response/WebhookRequestValidatorTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/Response/WebhookRequestValidatorTest.php
index 5a4ab570f655c..5ae6b95a77548 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/Response/WebhookRequestValidatorTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/SignifydGateway/Response/WebhookRequestValidatorTest.php
@@ -13,7 +13,7 @@
/**
* Class WebhookRequestValidatorTest
*/
-class WebhookRequestValidatorTest extends \PHPUnit_Framework_TestCase
+class WebhookRequestValidatorTest extends \PHPUnit\Framework\TestCase
{
/**
* @var WebhookRequestValidator
diff --git a/app/code/Magento/Signifyd/Test/Unit/Model/SignifydOrderSessionIdTest.php b/app/code/Magento/Signifyd/Test/Unit/Model/SignifydOrderSessionIdTest.php
index 1f8875fa9cbdb..9d3061f240c21 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Model/SignifydOrderSessionIdTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Model/SignifydOrderSessionIdTest.php
@@ -14,7 +14,7 @@
* Class SignifydOrderSessionIdTest tests that SignifydOrderSessionId class dependencies
* follow the contracts.
*/
-class SignifydOrderSessionIdTest extends \PHPUnit_Framework_TestCase
+class SignifydOrderSessionIdTest extends \PHPUnit\Framework\TestCase
{
/**
* @var SignifydOrderSessionId
diff --git a/app/code/Magento/Signifyd/Test/Unit/Observer/PlaceOrderTest.php b/app/code/Magento/Signifyd/Test/Unit/Observer/PlaceOrderTest.php
index 100fe1052e035..e2870953ec280 100644
--- a/app/code/Magento/Signifyd/Test/Unit/Observer/PlaceOrderTest.php
+++ b/app/code/Magento/Signifyd/Test/Unit/Observer/PlaceOrderTest.php
@@ -17,7 +17,7 @@
use PHPUnit_Framework_MockObject_MockObject as MockObject;
use Psr\Log\LoggerInterface;
-class PlaceOrderTest extends \PHPUnit_Framework_TestCase
+class PlaceOrderTest extends \PHPUnit\Framework\TestCase
{
/**
* @var Config|MockObject
@@ -160,7 +160,8 @@ public function testExecuteWithFailedCaseCreation()
$this->logger->method('error')
->with(self::equalTo($exceptionMessage));
- $this->placeOrder->execute($this->observer);
+ $result = $this->placeOrder->execute($this->observer);
+ $this->assertNull($result);
}
/**
diff --git a/app/code/Magento/Signifyd/composer.json b/app/code/Magento/Signifyd/composer.json
index e298e61dfc6a3..94731b78cbdbf 100644
--- a/app/code/Magento/Signifyd/composer.json
+++ b/app/code/Magento/Signifyd/composer.json
@@ -1,23 +1,27 @@
{
"name": "magento/module-signifyd",
"description": "Submitting Case Entry to Signifyd on Order Creation",
+ "config": {
+ "sort-packages": true
+ },
"require": {
- "php": "~5.6.5|7.0.2|7.0.4|~7.0.6",
- "magento/module-config": "100.2.*",
- "magento/framework": "100.2.*",
- "magento/module-sales": "100.2.*",
- "magento/module-store": "100.2.*",
- "magento/module-customer": "100.2.*",
- "magento/module-directory": "100.2.*",
- "magento/module-checkout": "100.2.*",
- "magento/module-backend": "100.2.*",
- "magento/module-payment": "100.2.*"
+ "magento/framework": "100.3.*",
+ "magento/module-backend": "100.3.*",
+ "magento/module-checkout": "100.3.*",
+ "magento/module-config": "100.3.*",
+ "magento/module-customer": "100.3.*",
+ "magento/module-directory": "100.3.*",
+ "magento/module-payment": "100.3.*",
+ "magento/module-sales": "100.3.*",
+ "magento/module-store": "100.3.*",
+ "php": "7.0.2|7.0.4|~7.0.6|~7.1.0"
},
"suggest": {
- "magento/module-scalable-oms": "100.2.*"
+ "magento/module-config": "100.3.*",
+ "magento/module-scalable-oms": "100.3.*"
},
"type": "magento2-module",
- "version": "100.2.0-dev",
+ "version": "100.3.0-dev",
"license": [
"proprietary"
],
diff --git a/app/code/Magento/Signifyd/etc/adminhtml/routes.xml b/app/code/Magento/Signifyd/etc/adminhtml/routes.xml
index 0f5ec8f6ef3c4..c078ab3c8c4c1 100644
--- a/app/code/Magento/Signifyd/etc/adminhtml/routes.xml
+++ b/app/code/Magento/Signifyd/etc/adminhtml/routes.xml
@@ -1,7 +1,7 @@
diff --git a/app/code/Magento/Signifyd/etc/di.xml b/app/code/Magento/Signifyd/etc/di.xml
index bd05c8717b7d2..c32fd4352bb10 100644
--- a/app/code/Magento/Signifyd/etc/di.xml
+++ b/app/code/Magento/Signifyd/etc/di.xml
@@ -14,6 +14,21 @@
+
+
+
+ U
+
+
+
+
+
+
+ Magento\Payment\Gateway\Config\Config
+ SignifydAvsDefaultMapper
+ SignifydCvvDefaultMapper
+
+
Magento\Sales\Model\ResourceModel\Order\Grid
@@ -55,21 +70,6 @@
-
-
-
- U
-
-
-
-
-
-
- Magento\Payment\Gateway\Config\Config
- SignifydAvsDefaultMapper
- SignifydCvvDefaultMapper
-
-
sales
@@ -106,6 +106,18 @@
PaymentMethodConfigData
+
+
+
+ - 1
+ - 1
+
+
+ - 1
+ - 1
+
+
+
diff --git a/app/code/Magento/Signifyd/etc/frontend/di.xml b/app/code/Magento/Signifyd/etc/frontend/di.xml
index 6aa887c67578d..08a690d1a9930 100644
--- a/app/code/Magento/Signifyd/etc/frontend/di.xml
+++ b/app/code/Magento/Signifyd/etc/frontend/di.xml
@@ -6,12 +6,5 @@
*/
-->
-
-
-
- - Magento\Signifyd\Model\Ui\ConfigProvider
-
-
-
diff --git a/app/code/Magento/Signifyd/i18n/en_US.csv b/app/code/Magento/Signifyd/i18n/en_US.csv
index 474efd51d03fe..40772188dac9e 100644
--- a/app/code/Magento/Signifyd/i18n/en_US.csv
+++ b/app/code/Magento/Signifyd/i18n/en_US.csv
@@ -1,44 +1,46 @@
-"OPEN","Open"
-"PROCESSING","Processing"
-"FLAGGED","Flagged"
-"DISMISSED","Dismissed"
-"HELD","Held"
-"GOOD","Good"
-"FRAUDULENT","Fraudulent"
-"UNSET","Unset"
-"NULL","Unset"
-"APPROVED","Approved"
-"DECLINED","Declined"
-"PENDING","Pending"
-"CANCELED","Canceled"
-"IN_REVIEW","In review"
-"Case Update: Case Review was completed. Review Deposition is %1.","Case Update: Case Review was completed. Review Deposition is %1."
-"Case Update: New score for the order is %1. Previous score was %2.","Case Update: New score for the order is %1. Previous score was %2."
-"Signifyd Case %1 has been created for order.","Signifyd Case %1 has been created for order."
-"The "%1" should not be empty.","The "%1" should not be empty."
-"Case entity not found.","Case entity not found."
-"Cannot update Case entity.","Cannot update Case entity."
-"Order has been submitted for Guarantee.","Order has been submitted for Guarantee."
-"Sorry, we cannot submit order for Guarantee.","Sorry, we cannot submit order for Guarantee."
-"Order id is required.","Order id is required."
+OPEN,Open
+PROCESSING,Processing
+FLAGGED,Flagged
+DISMISSED,Dismissed
+HELD,Held
+GOOD,Good
+FRAUDULENT,Fraudulent
+UNSET,Unset
+NULL,Unset
+APPROVED,Approved
+DECLINED,Declined
+PENDING,Pending
+CANCELED,Canceled
+IN_REVIEW,"In review"
+Approved,Approved
+Declined,Declined
+Pending,Pending
+Canceled,Canceled
+"In Review","In Review"
+Unrequested,Unrequested
+"Learn more","Learn more"
+"This order already has associated case entity","This order already has associated case entity"
"The case entity should not be empty.","The case entity should not be empty."
-"Guarantee has been cancelled for your order.","Guarantee has been cancelled for your order."
-"Sorry, we cannot cancel Guarantee for order.","Sorry, we cannot cancel Guarantee for order."
-"Not empty value for "%1" node is required.","Not empty value for "%1" node is required."
-"Only single entrance of "%1" node is required.","Only single entrance of "%1" node is required."
-"Signifyd automatically reviews your orders for fraud, telling you in seconds which orders to ship, and which to reject.
- We back our approvals with 100% chargeback protection, reimbursing you the full order amount plus fees should you ever receive a fraudulent chargeback.
- Benefits:
- Grow your business without fear of fraud
- Accept more orders and maximize your revenue
- Automate order review and shift fraud off your plate
","Signifyd automatically reviews your orders for fraud, telling you in seconds which orders to ship, and which to reject.
- We back our approvals with 100% chargeback protection, reimbursing you the full order amount plus fees should you ever receive a fraudulent chargeback.
- Benefits:
- Grow your business without fear of fraud
- Accept more orders and maximize your revenue
- Automate order review and shift fraud off your plate "
-"View our setup guide for step-by-step instructions on how to integrate Signifyd with Magento. For support contact support@signifyd.com ","View our setup guide for step-by-step instructions on how to integrate Signifyd with Magento. For support contact support@signifyd.com "
-"Your API key can be found on the settings page in the Signifyd console","Your API key can be found on the settings page in the Signifyd console"
-"Don’t change unless asked to do so.","Don’t change unless asked to do so."
-"Your webhook URL will be used to configure a guarantee completed webhook in Signifyd. Webhooks are used to sync Signifyd`s guarantee decisions back to Magento.","Your webhook URL will be used to configure a guarantee completed webhook in Signifyd. Webhooks are used to sync Signifyd`s guarantee decisions back to Magento."
-"Signifyd Guarantee Decision","Signifyd Guarantee Decision"
\ No newline at end of file
+"Cannot update Case entity.","Cannot update Case entity."
+"The ""%1"" should not be empty.","The ""%1"" should not be empty."
+"Case entity not found.","Case entity not found."
+"Case Update: New score for the order is %1. Previous score was %2.","Case Update: New score for the order is %1. Previous score was %2."
+"Awaiting the Signifyd guarantee disposition.","Awaiting the Signifyd guarantee disposition."
+"Only single entrance of ""%1"" node is required.","Only single entrance of ""%1"" node is required."
+"Not empty value for ""%1"" node is required.","Not empty value for ""%1"" node is required."
+"%1 must implement %2","%1 must implement %2"
+Error,Error
+"Cannot generate message.","Cannot generate message."
+"Message is generated.","Message is generated."
+"Case with the same order id already exists.","Case with the same order id already exists."
+"Fraud Protection Information","Fraud Protection Information"
+"Signifyd Guarantee Decision","Signifyd Guarantee Decision"
+"Fraud Protection Section","Fraud Protection Section"
+"Fraud Protection","Fraud Protection"
+"Protect your store from fraud with Guaranteed Fraud Protection by Signifyd.","Protect your store from fraud with Guaranteed Fraud Protection by Signifyd."
+Configuration,Configuration
+"Enable this Solution","Enable this Solution"
+"API Key","API Key"
+"API URL","API URL"
+Debug,Debug
+"Webhook URL","Webhook URL"
diff --git a/app/code/Magento/Signifyd/registration.php b/app/code/Magento/Signifyd/registration.php
index 9f35e0bb2f41b..72b11f7eac214 100644
--- a/app/code/Magento/Signifyd/registration.php
+++ b/app/code/Magento/Signifyd/registration.php
@@ -4,8 +4,6 @@
* See COPYING.txt for license details.
*/
-\Magento\Framework\Component\ComponentRegistrar::register(
- \Magento\Framework\Component\ComponentRegistrar::MODULE,
- 'Magento_Signifyd',
- __DIR__
-);
+use \Magento\Framework\Component\ComponentRegistrar;
+
+ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Magento_Signifyd', __DIR__);
diff --git a/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml b/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml
index b706406331f1a..a42b7f93b5b92 100644
--- a/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml
+++ b/app/code/Magento/Signifyd/view/adminhtml/templates/case_info.phtml
@@ -15,7 +15,7 @@
?>
- escapeHtml(__('Fraud Protection Information')); ?>
+ = $block->escapeHtml(__('Fraud Protection Information')) ?>
@@ -23,8 +23,8 @@
- escapeHtml(__('Signifyd Guarantee Decision')); ?>
- escapeHtml($block->getCaseGuaranteeDisposition()); ?>
+ = $block->escapeHtml(__('Signifyd Guarantee Decision')) ?>
+ = $block->escapeHtml($block->getCaseGuaranteeDisposition()) ?>
diff --git a/app/code/Magento/Signifyd/view/adminhtml/ui_component/sales_order_grid.xml b/app/code/Magento/Signifyd/view/adminhtml/ui_component/sales_order_grid.xml
index 21195adcc8bcf..91053d617f31f 100644
--- a/app/code/Magento/Signifyd/view/adminhtml/ui_component/sales_order_grid.xml
+++ b/app/code/Magento/Signifyd/view/adminhtml/ui_component/sales_order_grid.xml
@@ -1,23 +1,20 @@
+ ~ /**
+ ~ * Copyright © Magento, Inc. All rights reserved.
+ ~ * See COPYING.txt for license details.
+ ~ */
+ -->
-
-
- - Magento\Signifyd\Ui\Component\Listing\Column\Guarantee\Options
- -
-
- true
- - select
- - Magento_Ui/js/grid/columns/select
- - select
- - Signifyd Guarantee Decision
-
-
+
+
+ select
+
+ true
+ select
+ Signifyd Guarantee Decision
+
diff --git a/app/code/Magento/Signifyd/view/frontend/templates/fingerprint.phtml b/app/code/Magento/Signifyd/view/frontend/templates/fingerprint.phtml
index 9ceccffa8dc19..356bab9c62ded 100644
--- a/app/code/Magento/Signifyd/view/frontend/templates/fingerprint.phtml
+++ b/app/code/Magento/Signifyd/view/frontend/templates/fingerprint.phtml
@@ -12,7 +12,7 @@
-
\ No newline at end of file
+
From efd1ce969bc5b7c9ea983db98342f746f050ef05 Mon Sep 17 00:00:00 2001
From: Joan He
Date: Fri, 17 Nov 2017 17:21:12 -0600
Subject: [PATCH 216/904] MAGETWO-72487: Move code to CE
- fix copyright
---
.../testsuite/Magento/Signifyd/Block/Adminhtml/CaseInfoTest.php | 2 +-
.../testsuite/Magento/Signifyd/Block/FingerprintTest.php | 2 +-
.../Magento/Signifyd/Controller/Webhooks/HandlerTest.php | 2 +-
.../testsuite/Magento/Signifyd/Model/CaseManagementTest.php | 2 +-
.../testsuite/Magento/Signifyd/Model/CaseRepositoryTest.php | 2 +-
.../Magento/Signifyd/Model/CaseServices/CreationServiceTest.php | 2 +-
.../Magento/Signifyd/Model/CaseServices/UpdatingServiceTest.php | 2 +-
.../Magento/Signifyd/Model/Guarantee/CancelingServiceTest.php | 2 +-
.../Magento/Signifyd/Model/Guarantee/CreationServiceTest.php | 2 +-
.../Model/SignifydGateway/Request/CreateCaseBuilderTest.php | 2 +-
.../testsuite/Magento/Signifyd/Observer/PlaceOrderTest.php | 2 +-
.../testsuite/Magento/Signifyd/Plugin/CancelOrderTest.php | 2 +-
.../testsuite/Magento/Signifyd/_files/approved_case.php | 2 +-
.../integration/testsuite/Magento/Signifyd/_files/case.php | 2 +-
.../integration/testsuite/Magento/Signifyd/_files/customer.php | 2 +-
.../testsuite/Magento/Signifyd/_files/multiple_cases.php | 2 +-
.../_files/order_with_customer_and_two_simple_products.php | 2 +-
.../Signifyd/_files/order_with_guest_and_virtual_product.php | 2 +-
.../integration/testsuite/Magento/Signifyd/_files/store.php | 2 +-
19 files changed, 19 insertions(+), 19 deletions(-)
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Block/Adminhtml/CaseInfoTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Block/Adminhtml/CaseInfoTest.php
index 48b2b33513a6a..60fa3e7c65e44 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Block/Adminhtml/CaseInfoTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Block/Adminhtml/CaseInfoTest.php
@@ -1,6 +1,6 @@
Date: Fri, 17 Nov 2017 17:22:25 -0600
Subject: [PATCH 217/904] MAGETWO-72487: Move code to CE
- upgrading Magento2 Project PHPUnit version to latest
- resolve some conflicts
---
.../Signifyd/Block/Adminhtml/CaseInfoTest.php | 10 ++--
.../Signifyd/Block/FingerprintTest.php | 6 +-
.../Controller/Webhooks/HandlerTest.php | 24 ++++----
.../Signifyd/Model/CaseManagementTest.php | 27 +++------
.../Signifyd/Model/CaseRepositoryTest.php | 18 +++---
.../CaseServices/CreationServiceTest.php | 59 ++++++++-----------
.../CaseServices/UpdatingServiceTest.php | 37 ++++++------
.../Model/Guarantee/CancelingServiceTest.php | 10 ++--
.../Model/Guarantee/CreationServiceTest.php | 10 ++--
.../Request/CreateCaseBuilderTest.php | 4 +-
.../Signifyd/Observer/PlaceOrderTest.php | 15 +----
.../Signifyd/Plugin/CancelOrderTest.php | 15 +----
.../Signifyd/Plugin/DenyPaymentTest.php | 15 +----
..._with_customer_and_two_simple_products.php | 1 -
14 files changed, 102 insertions(+), 149 deletions(-)
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Block/Adminhtml/CaseInfoTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Block/Adminhtml/CaseInfoTest.php
index 60fa3e7c65e44..71a0d5715d1aa 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Block/Adminhtml/CaseInfoTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Block/Adminhtml/CaseInfoTest.php
@@ -12,7 +12,7 @@
use Magento\Sales\Model\Order;
use Magento\TestFramework\Helper\Bootstrap;
-class CaseInfoTest extends \PHPUnit_Framework_TestCase
+class CaseInfoTest extends \PHPUnit\Framework\TestCase
{
/**
* @var ObjectManagerInterface
@@ -51,7 +51,7 @@ public function testModuleIsInactive()
{
$this->order->loadByIncrementId('100000001');
- static::assertNotEmpty($this->getBlock()->toHtml());
+ self::assertNotEmpty($this->getBlock()->toHtml());
}
/**
@@ -67,7 +67,7 @@ public function testCaseEntityNotExists()
{
$this->order->loadByIncrementId('100000001');
- static::assertEmpty($this->getBlock()->toHtml());
+ self::assertEmpty($this->getBlock()->toHtml());
}
/**
@@ -85,8 +85,8 @@ public function testCaseEntityExists()
$this->order->loadByIncrementId('100000001');
$block = $this->getBlock();
- static::assertNotEmpty($block->toHtml());
- static::assertContains((string) $block->getCaseGuaranteeDisposition(), $block->toHtml());
+ self::assertNotEmpty($block->toHtml());
+ self::assertContains((string) $block->getCaseGuaranteeDisposition(), $block->toHtml());
}
/**
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Block/FingerprintTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Block/FingerprintTest.php
index aa31e1f65d34d..1efbb8b6d33e4 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Block/FingerprintTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Block/FingerprintTest.php
@@ -10,7 +10,7 @@
use Magento\Framework\View\LayoutInterface;
use Magento\TestFramework\Helper\Bootstrap;
-class FingerprintTest extends \PHPUnit_Framework_TestCase
+class FingerprintTest extends \PHPUnit\Framework\TestCase
{
/**
* @var ObjectManager
@@ -35,7 +35,7 @@ protected function setUp()
*/
public function testSessionIdPresent()
{
- static::assertContains('data-order-session-id', $this->getBlockContents());
+ self::assertContains('data-order-session-id', $this->getBlockContents());
}
/**
@@ -45,7 +45,7 @@ public function testSessionIdPresent()
*/
public function testBlockEmpty()
{
- static::assertEmpty($this->getBlockContents());
+ self::assertEmpty($this->getBlockContents());
}
/**
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Controller/Webhooks/HandlerTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Controller/Webhooks/HandlerTest.php
index a0802e3fdcb5d..667cb079f9096 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Controller/Webhooks/HandlerTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Controller/Webhooks/HandlerTest.php
@@ -45,25 +45,25 @@ public function testExecuteSuccess()
$caseEntity = $caseRepository->getByCaseId($caseId);
$orderEntityId = $caseEntity->getOrderId();
- static::assertNotEmpty($caseEntity);
- static::assertEquals('2017-01-06 12:47:03', $caseEntity->getCreatedAt());
- static::assertEquals('2017-01-06 12:47:03', $caseEntity->getUpdatedAt());
- static::assertEquals('Magento', $caseEntity->getAssociatedTeam()['teamName']);
- static::assertEquals(true, $caseEntity->isGuaranteeEligible());
- static::assertEquals(CaseInterface::STATUS_OPEN, $caseEntity->getStatus());
- static::assertEquals($orderEntityId, $caseEntity->getOrderId());
+ self::assertNotEmpty($caseEntity);
+ self::assertEquals('2017-01-06 12:47:03', $caseEntity->getCreatedAt());
+ self::assertEquals('2017-01-06 12:47:03', $caseEntity->getUpdatedAt());
+ self::assertEquals('Magento', $caseEntity->getAssociatedTeam()['teamName']);
+ self::assertEquals(true, $caseEntity->isGuaranteeEligible());
+ self::assertEquals(CaseInterface::STATUS_OPEN, $caseEntity->getStatus());
+ self::assertEquals($orderEntityId, $caseEntity->getOrderId());
/** @var OrderRepositoryInterface $orderRepository */
$orderRepository = $this->_objectManager->get(OrderRepositoryInterface::class);
$order = $orderRepository->get($caseEntity->getOrderId());
$histories = $order->getStatusHistories();
- static::assertNotEmpty($histories);
+ self::assertNotEmpty($histories);
/** @var OrderStatusHistoryInterface $caseCreationComment */
$caseComment = array_pop($histories);
- static::assertInstanceOf(OrderStatusHistoryInterface::class, $caseComment);
+ self::assertInstanceOf(OrderStatusHistoryInterface::class, $caseComment);
- static::assertEquals(
+ self::assertEquals(
"Case Update: New score for the order is 384. Previous score was 553.",
$caseComment->getComment()
);
@@ -90,7 +90,7 @@ public function testExecuteTestSuccess()
/**
* Returns mocked WebhookRequest
*
- * @return WebhookRequest|\PHPUnit_Framework_MockObject_MockObject
+ * @return WebhookRequest|\PHPUnit\Framework\MockObject_MockObject
*/
private function getWebhookRequest()
{
@@ -113,7 +113,7 @@ private function getWebhookRequest()
/**
* Returns mocked test WebhookRequest
*
- * @return WebhookRequest|\PHPUnit_Framework_MockObject_MockObject
+ * @return WebhookRequest|\PHPUnit\Framework\MockObject_MockObject
*/
private function getTestWebhookRequest()
{
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseManagementTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseManagementTest.php
index 217b54621f26d..30603baf867ff 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseManagementTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseManagementTest.php
@@ -5,7 +5,6 @@
*/
namespace Magento\Signifyd\Model;
-use Magento\Framework\Api\FilterBuilder;
use Magento\Framework\Api\SearchCriteriaBuilder;
use Magento\Framework\App\ObjectManager;
use Magento\Sales\Api\Data\OrderInterface;
@@ -16,7 +15,7 @@
/**
* Contains test methods for case management service
*/
-class CaseManagementTest extends \PHPUnit_Framework_TestCase
+class CaseManagementTest extends \PHPUnit\Framework\TestCase
{
/**
* @var CaseManagement
@@ -43,9 +42,9 @@ public function testCreate()
$order = $this->getOrder();
$case = $this->caseManagement->create($order->getEntityId());
- static::assertNotEmpty($case->getEntityId());
- static::assertEquals(CaseInterface::STATUS_PENDING, $case->getStatus());
- static::assertEquals(CaseInterface::GUARANTEE_PENDING, $case->getGuaranteeDisposition());
+ self::assertNotEmpty($case->getEntityId());
+ self::assertEquals(CaseInterface::STATUS_PENDING, $case->getStatus());
+ self::assertEquals(CaseInterface::GUARANTEE_PENDING, $case->getGuaranteeDisposition());
}
/**
@@ -57,10 +56,10 @@ public function testGetByOrderId()
$order = $this->getOrder();
$case = $this->caseManagement->getByOrderId($order->getEntityId());
- static::assertEquals(CaseInterface::STATUS_PROCESSING, $case->getStatus());
- static::assertEquals(CaseInterface::DISPOSITION_GOOD, $case->getReviewDisposition());
- static::assertEquals('2016-12-12 15:17:17', $case->getCreatedAt());
- static::assertEquals('2016-12-12 19:23:16', $case->getUpdatedAt());
+ self::assertEquals(CaseInterface::STATUS_PROCESSING, $case->getStatus());
+ self::assertEquals(CaseInterface::DISPOSITION_GOOD, $case->getReviewDisposition());
+ self::assertEquals('2016-12-12 15:17:17', $case->getCreatedAt());
+ self::assertEquals('2016-12-12 19:23:16', $case->getUpdatedAt());
}
/**
@@ -69,17 +68,9 @@ public function testGetByOrderId()
*/
private function getOrder()
{
- /** @var FilterBuilder $filterBuilder */
- $filterBuilder = $this->objectManager->get(FilterBuilder::class);
- $filters = [
- $filterBuilder->setField(OrderInterface::INCREMENT_ID)
- ->setValue('100000001')
- ->create()
- ];
-
/** @var SearchCriteriaBuilder $searchCriteriaBuilder */
$searchCriteriaBuilder = $this->objectManager->get(SearchCriteriaBuilder::class);
- $searchCriteria = $searchCriteriaBuilder->addFilters($filters)
+ $searchCriteria = $searchCriteriaBuilder->addFilter(OrderInterface::INCREMENT_ID, '100000001')
->create();
$orderRepository = $this->objectManager->get(OrderRepositoryInterface::class);
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseRepositoryTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseRepositoryTest.php
index 44972b6094ef0..ca98a20b15bec 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseRepositoryTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseRepositoryTest.php
@@ -14,7 +14,7 @@
/**
* Testing case repository
*/
-class CaseRepositoryTest extends \PHPUnit_Framework_TestCase
+class CaseRepositoryTest extends \PHPUnit\Framework\TestCase
{
/**
* @var ObjectManager
@@ -65,7 +65,7 @@ public function testDelete()
$case = array_pop($cases);
$this->repository->delete($case);
- static::assertEmpty($this->repository->getList($searchCriteria)->getItems());
+ self::assertEmpty($this->repository->getList($searchCriteria)->getItems());
}
/**
@@ -87,9 +87,9 @@ public function testGetById()
$found = $this->repository->getById($case->getEntityId());
- static::assertNotEmpty($found->getEntityId());
- static::assertEquals($case->getEntityId(), $found->getEntityId());
- static::assertEquals($case->getOrderId(), $found->getOrderId());
+ self::assertNotEmpty($found->getEntityId());
+ self::assertEquals($case->getEntityId(), $found->getEntityId());
+ self::assertEquals($case->getOrderId(), $found->getOrderId());
}
/**
@@ -116,11 +116,11 @@ public function testGetListDateInterval()
$items = $this->repository->getList($searchCriteria)
->getItems();
- static::assertCount(3, $items);
+ self::assertCount(3, $items);
for ($i = 1; $i < 4; $i ++) {
$current = array_shift($items);
- static::assertEquals($i, $current->getCaseId());
+ self::assertEquals($i, $current->getCaseId());
}
}
@@ -140,9 +140,9 @@ public function testGetListStatusProcessing()
$items = $this->repository->getList($searchCriteria)
->getItems();
- static::assertCount(1, $items);
+ self::assertCount(1, $items);
$case = array_pop($items);
- static::assertEquals(123, $case->getCaseId());
+ self::assertEquals(123, $case->getCaseId());
}
}
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseServices/CreationServiceTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseServices/CreationServiceTest.php
index 0fd303b644141..6cf1e0bfddc9a 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseServices/CreationServiceTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseServices/CreationServiceTest.php
@@ -5,20 +5,20 @@
*/
namespace Magento\Signifyd\Model\CaseServices;
-use Magento\Framework\Api\FilterBuilder;
use Magento\Framework\Api\SearchCriteriaBuilder;
use Magento\Framework\App\ObjectManager;
use Magento\Sales\Api\Data\OrderInterface;
use Magento\Sales\Api\Data\OrderStatusHistoryInterface;
use Magento\Sales\Api\OrderRepositoryInterface;
use Magento\Sales\Model\Order;
+use Magento\Sales\Model\ResourceModel\Order\Grid\Collection;
use Magento\Signifyd\Api\CaseRepositoryInterface;
use Magento\Signifyd\Model\SignifydGateway\ApiCallException;
use Magento\Signifyd\Model\SignifydGateway\ApiClient;
use Magento\Signifyd\Model\SignifydGateway\Client\RequestBuilder;
use Magento\Signifyd\Model\SignifydGateway\Gateway;
use Magento\TestFramework\Helper\Bootstrap;
-use PHPUnit_Framework_MockObject_MockObject as MockObject;
+use PHPUnit\Framework\MockObject_MockObject as MockObject;
use Psr\Log\LoggerInterface;
/**
@@ -26,7 +26,7 @@
*
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class CreationServiceTest extends \PHPUnit_Framework_TestCase
+class CreationServiceTest extends \PHPUnit\Framework\TestCase
{
/**
* @var ObjectManager
@@ -98,16 +98,16 @@ public function testCreateForOrderWithEmptyResponse()
$order = $this->getOrder();
$exceptionMessage = 'Response is not valid JSON: Decoding failed: Syntax error';
- $this->requestBuilder->expects(static::once())
+ $this->requestBuilder->expects(self::once())
->method('doRequest')
->willThrowException(new ApiCallException($exceptionMessage));
- $this->logger->expects(static::once())
+ $this->logger->expects(self::once())
->method('error')
->with($exceptionMessage);
$result = $this->service->createForOrder($order->getEntityId());
- static::assertTrue($result);
+ self::assertTrue($result);
}
/**
@@ -124,16 +124,16 @@ public function testCreateForOrderWithBadResponse()
];
$exceptionMessage = 'Bad Request - The request could not be parsed. Response: ' . json_encode($responseData);
- $this->requestBuilder->expects(static::once())
+ $this->requestBuilder->expects(self::once())
->method('doRequest')
->willThrowException(new ApiCallException($exceptionMessage));
- $this->logger->expects(static::once())
+ $this->logger->expects(self::once())
->method('error')
->with($exceptionMessage);
$result = $this->service->createForOrder($order->getEntityId());
- static::assertTrue($result);
+ self::assertTrue($result);
}
/**
@@ -144,16 +144,16 @@ public function testCreateOrderWithEmptyInvestigationId()
{
$order = $this->getOrder();
- $this->requestBuilder->expects(static::once())
+ $this->requestBuilder->expects(self::once())
->method('doRequest')
->willReturn([]);
- $this->logger->expects(static::once())
+ $this->logger->expects(self::once())
->method('error')
->with('Expected field "investigationId" missed.');
$result = $this->service->createForOrder($order->getEntityId());
- static::assertTrue($result);
+ self::assertTrue($result);
}
/**
@@ -164,24 +164,24 @@ public function testCreateForOrder()
{
$order = $this->getOrder();
- $this->requestBuilder->expects(static::once())
+ $this->requestBuilder->expects(self::once())
->method('doRequest')
->willReturn(['investigationId' => 123123]);
- $this->logger->expects(static::never())
+ $this->logger->expects(self::never())
->method('error');
$result = $this->service->createForOrder($order->getEntityId());
- static::assertTrue($result);
+ self::assertTrue($result);
/** @var CaseRepositoryInterface $caseRepository */
$caseRepository = $this->objectManager->get(CaseRepositoryInterface::class);
$caseEntity = $caseRepository->getByCaseId(123123);
$gridGuarantyStatus = $this->getOrderGridGuarantyStatus($caseEntity->getOrderId());
- static::assertNotEmpty($caseEntity);
- static::assertEquals($order->getEntityId(), $caseEntity->getOrderId());
- static::assertEquals(
+ self::assertNotEmpty($caseEntity);
+ self::assertEquals($order->getEntityId(), $caseEntity->getOrderId());
+ self::assertEquals(
$gridGuarantyStatus,
$caseEntity->getGuaranteeDisposition(),
'Signifyd guaranty status in sales_order_grid table does not match case entity guaranty status'
@@ -190,15 +190,15 @@ public function testCreateForOrder()
/** @var OrderRepositoryInterface $orderRepository */
$orderRepository = $this->objectManager->get(OrderRepositoryInterface::class);
$order = $orderRepository->get($caseEntity->getOrderId());
- static::assertEquals(Order::STATE_HOLDED, $order->getState());
+ self::assertEquals(Order::STATE_HOLDED, $order->getState());
$histories = $order->getStatusHistories();
- static::assertNotEmpty($histories);
+ self::assertNotEmpty($histories);
/** @var OrderStatusHistoryInterface $orderHoldComment */
$orderHoldComment = array_pop($histories);
- static::assertInstanceOf(OrderStatusHistoryInterface::class, $orderHoldComment);
- static::assertEquals("Awaiting the Signifyd guarantee disposition.", $orderHoldComment->getComment());
+ self::assertInstanceOf(OrderStatusHistoryInterface::class, $orderHoldComment);
+ self::assertEquals("Awaiting the Signifyd guarantee disposition.", $orderHoldComment->getComment());
}
/**
@@ -209,17 +209,10 @@ public function testCreateForOrder()
private function getOrder()
{
if ($this->order === null) {
- /** @var FilterBuilder $filterBuilder */
- $filterBuilder = $this->objectManager->get(FilterBuilder::class);
- $filters = [
- $filterBuilder->setField(OrderInterface::INCREMENT_ID)
- ->setValue('100000001')
- ->create()
- ];
/** @var SearchCriteriaBuilder $searchCriteriaBuilder */
$searchCriteriaBuilder = $this->objectManager->get(SearchCriteriaBuilder::class);
- $searchCriteria = $searchCriteriaBuilder->addFilters($filters)
+ $searchCriteria = $searchCriteriaBuilder->addFilter(OrderInterface::INCREMENT_ID, '100000001')
->create();
$orderRepository = $this->objectManager->get(OrderRepositoryInterface::class);
@@ -240,10 +233,8 @@ private function getOrder()
*/
private function getOrderGridGuarantyStatus($orderEntityId)
{
- /** @var \Magento\Sales\Model\ResourceModel\Order\Grid\Collection $orderGridCollection */
- $orderGridCollection = $this->objectManager->get(
- \Magento\Sales\Model\ResourceModel\Order\Grid\Collection::class
- );
+ /** @var Collection $orderGridCollection */
+ $orderGridCollection = $this->objectManager->get(Collection::class);
$items = $orderGridCollection->addFilter($orderGridCollection->getIdFieldName(), $orderEntityId)
->getItems();
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseServices/UpdatingServiceTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseServices/UpdatingServiceTest.php
index cffcc4a456578..50e510ca072be 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseServices/UpdatingServiceTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/CaseServices/UpdatingServiceTest.php
@@ -9,6 +9,7 @@
use Magento\Sales\Api\Data\OrderStatusHistoryInterface;
use Magento\Sales\Api\OrderRepositoryInterface;
use Magento\Sales\Model\Order;
+use Magento\Sales\Model\ResourceModel\Order\Grid\Collection;
use Magento\Signifyd\Api\CaseRepositoryInterface;
use Magento\Signifyd\Api\Data\CaseInterface;
use Magento\Signifyd\Model\MessageGenerators\GeneratorFactory;
@@ -17,7 +18,7 @@
/**
* Contains tests for case entity updating service.
*/
-class UpdatingServiceTest extends \PHPUnit_Framework_TestCase
+class UpdatingServiceTest extends \PHPUnit\Framework\TestCase
{
/**
* @var ObjectManager
@@ -82,14 +83,14 @@ public function testUpdate()
$orderEntityId = $caseEntity->getOrderId();
$gridGuarantyStatus = $this->getOrderGridGuarantyStatus($orderEntityId);
- static::assertNotEmpty($caseEntity);
- static::assertEquals('2017-01-05 22:23:26', $caseEntity->getCreatedAt());
- static::assertEquals(CaseInterface::GUARANTEE_APPROVED, $caseEntity->getGuaranteeDisposition());
- static::assertEquals('AnyTeam', $caseEntity->getAssociatedTeam()['teamName']);
- static::assertEquals(true, $caseEntity->isGuaranteeEligible());
- static::assertEquals(CaseInterface::STATUS_PROCESSING, $caseEntity->getStatus());
- static::assertEquals($orderEntityId, $caseEntity->getOrderId());
- static::assertEquals(
+ self::assertNotEmpty($caseEntity);
+ self::assertEquals('2017-01-05 22:23:26', $caseEntity->getCreatedAt());
+ self::assertEquals(CaseInterface::GUARANTEE_APPROVED, $caseEntity->getGuaranteeDisposition());
+ self::assertEquals('AnyTeam', $caseEntity->getAssociatedTeam()['teamName']);
+ self::assertEquals(true, $caseEntity->isGuaranteeEligible());
+ self::assertEquals(CaseInterface::STATUS_PROCESSING, $caseEntity->getStatus());
+ self::assertEquals($orderEntityId, $caseEntity->getOrderId());
+ self::assertEquals(
$gridGuarantyStatus,
$caseEntity->getGuaranteeDisposition(),
'Signifyd guaranty status in sales_order_grid table does not match case entity guaranty status'
@@ -98,14 +99,14 @@ public function testUpdate()
/** @var OrderRepositoryInterface $orderRepository */
$orderRepository = $this->objectManager->get(OrderRepositoryInterface::class);
$order = $orderRepository->get($caseEntity->getOrderId());
- static::assertEquals(Order::STATE_PROCESSING, $order->getState());
+ self::assertEquals(Order::STATE_PROCESSING, $order->getState());
$histories = $order->getStatusHistories();
- static::assertNotEmpty($histories);
+ self::assertNotEmpty($histories);
/** @var OrderStatusHistoryInterface $caseCreationComment */
$caseCreationComment = array_pop($histories);
- static::assertInstanceOf(OrderStatusHistoryInterface::class, $caseCreationComment);
- static::assertEquals("Signifyd Case $caseId has been created for order.", $caseCreationComment->getComment());
+ self::assertInstanceOf(OrderStatusHistoryInterface::class, $caseCreationComment);
+ self::assertEquals("Signifyd Case $caseId has been created for order.", $caseCreationComment->getComment());
}
/**
@@ -133,7 +134,7 @@ public function testOrderStateAfterDeclinedGuaranteeDisposition()
$orderRepository = $this->objectManager->get(OrderRepositoryInterface::class);
$order = $orderRepository->get($caseEntity->getOrderId());
- static::assertEquals(Order::STATE_HOLDED, $order->getState());
+ self::assertEquals(Order::STATE_HOLDED, $order->getState());
}
/**
@@ -162,7 +163,7 @@ public function testOrderStateAfterWebhookWithoutGuaranteeDisposition()
$orderRepository = $this->objectManager->get(OrderRepositoryInterface::class);
$order = $orderRepository->get($caseEntity->getOrderId());
- static::assertEquals(Order::STATE_PROCESSING, $order->getState());
+ self::assertEquals(Order::STATE_PROCESSING, $order->getState());
}
/**
@@ -173,10 +174,8 @@ public function testOrderStateAfterWebhookWithoutGuaranteeDisposition()
*/
private function getOrderGridGuarantyStatus($orderEntityId)
{
- /** @var \Magento\Sales\Model\ResourceModel\Order\Grid\Collection $orderGridCollection */
- $orderGridCollection = $this->objectManager->get(
- \Magento\Sales\Model\ResourceModel\Order\Grid\Collection::class
- );
+ /** @var Collection $orderGridCollection */
+ $orderGridCollection = $this->objectManager->get(Collection::class);
$items = $orderGridCollection->addFilter($orderGridCollection->getIdFieldName(), $orderEntityId)
->getItems();
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Model/Guarantee/CancelingServiceTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Model/Guarantee/CancelingServiceTest.php
index dcd39e02d0f06..2cc7a9a1f240a 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Model/Guarantee/CancelingServiceTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/Guarantee/CancelingServiceTest.php
@@ -13,13 +13,13 @@
use Magento\Signifyd\Model\SignifydGateway\Gateway;
use Magento\Signifyd\Model\SignifydGateway\GatewayException;
use Magento\TestFramework\Helper\Bootstrap;
-use PHPUnit_Framework_MockObject_MockObject as MockObject;
+use PHPUnit\Framework\MockObject_MockObject as MockObject;
use Psr\Log\LoggerInterface;
/**
* Contains test cases for canceling Signifyd guarantee flow.
*/
-class CancelingServiceTest extends \PHPUnit_Framework_TestCase
+class CancelingServiceTest extends \PHPUnit\Framework\TestCase
{
private static $caseId = 123;
@@ -148,11 +148,11 @@ public function testCancelForOrder()
$orderRepository = $this->objectManager->get(OrderRepositoryInterface::class);
$order = $orderRepository->get($updatedCase->getOrderId());
$histories = $order->getStatusHistories();
- static::assertNotEmpty($histories);
+ self::assertNotEmpty($histories);
/** @var OrderStatusHistoryInterface $caseCreationComment */
$caseCreationComment = array_pop($histories);
- static::assertInstanceOf(OrderStatusHistoryInterface::class, $caseCreationComment);
- static::assertEquals('Case Update: Case guarantee has been cancelled.', $caseCreationComment->getComment());
+ self::assertInstanceOf(OrderStatusHistoryInterface::class, $caseCreationComment);
+ self::assertEquals('Case Update: Case guarantee has been cancelled.', $caseCreationComment->getComment());
}
}
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Model/Guarantee/CreationServiceTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Model/Guarantee/CreationServiceTest.php
index 66008cdee39e5..157e3270648b3 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Model/Guarantee/CreationServiceTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/Guarantee/CreationServiceTest.php
@@ -13,13 +13,13 @@
use Magento\Signifyd\Model\SignifydGateway\Gateway;
use Magento\Signifyd\Model\SignifydGateway\GatewayException;
use Magento\TestFramework\Helper\Bootstrap;
-use PHPUnit_Framework_MockObject_MockObject as MockObject;
+use PHPUnit\Framework\MockObject_MockObject as MockObject;
use Psr\Log\LoggerInterface;
/**
* Contains positive and negative test cases for Signifyd case guarantee creation flow.
*/
-class CreationServiceTest extends \PHPUnit_Framework_TestCase
+class CreationServiceTest extends \PHPUnit\Framework\TestCase
{
/**
* @var CreationService
@@ -133,12 +133,12 @@ public function testCreate()
$orderRepository = $this->objectManager->get(OrderRepositoryInterface::class);
$order = $orderRepository->get($updatedCase->getOrderId());
$histories = $order->getStatusHistories();
- static::assertNotEmpty($histories);
+ self::assertNotEmpty($histories);
/** @var OrderStatusHistoryInterface $caseCreationComment */
$caseCreationComment = array_pop($histories);
- static::assertInstanceOf(OrderStatusHistoryInterface::class, $caseCreationComment);
- static::assertEquals('Case Update: Case is submitted for guarantee.', $caseCreationComment->getComment());
+ self::assertInstanceOf(OrderStatusHistoryInterface::class, $caseCreationComment);
+ self::assertEquals('Case Update: Case is submitted for guarantee.', $caseCreationComment->getComment());
}
/**
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
index aa9cde598445e..7e7e20c873948 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Model/SignifydGateway/Request/CreateCaseBuilderTest.php
@@ -20,7 +20,7 @@
* @magentoAppIsolation enabled
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class CreateCaseBuilderTest extends \PHPUnit_Framework_TestCase
+class CreateCaseBuilderTest extends \PHPUnit\Framework\TestCase
{
/**
* @var ObjectManagerInterface
@@ -62,7 +62,7 @@ public function testCreateCaseBuilderWithFullSetOfData()
/** @var Order $order */
$order = $this->objectManager->create(Order::class);
$order->loadByIncrementId('100000001');
-
+
$orderItems = $order->getAllItems();
$product = $orderItems[0]->getProduct();
$payment = $order->getPayment();
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Observer/PlaceOrderTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Observer/PlaceOrderTest.php
index 5e80d4f4138c2..d4204314453e5 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Observer/PlaceOrderTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Observer/PlaceOrderTest.php
@@ -5,7 +5,6 @@
*/
namespace Magento\Signifyd\Observer;
-use Magento\Framework\Api\FilterBuilder;
use Magento\Framework\Api\SearchCriteriaBuilder;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\Event;
@@ -14,10 +13,10 @@
use Magento\Sales\Api\OrderRepositoryInterface;
use Magento\Signifyd\Api\CaseCreationServiceInterface;
use Magento\TestFramework\Helper\Bootstrap;
-use PHPUnit_Framework_MockObject_MockObject as MockObject;
+use PHPUnit\Framework\MockObject_MockObject as MockObject;
use Psr\Log\LoggerInterface;
-class PlaceOrderTest extends \PHPUnit_Framework_TestCase
+class PlaceOrderTest extends \PHPUnit\Framework\TestCase
{
/**
* @var CaseCreationServiceInterface|MockObject
@@ -157,17 +156,9 @@ public function testExecuteWithMultipleOrders()
*/
private function getOrder($incrementId)
{
- /** @var FilterBuilder $filterBuilder */
- $filterBuilder = $this->objectManager->get(FilterBuilder::class);
- $filters = [
- $filterBuilder->setField(OrderInterface::INCREMENT_ID)
- ->setValue($incrementId)
- ->create()
- ];
-
/** @var SearchCriteriaBuilder $searchCriteriaBuilder */
$searchCriteriaBuilder = $this->objectManager->get(SearchCriteriaBuilder::class);
- $searchCriteria = $searchCriteriaBuilder->addFilters($filters)
+ $searchCriteria = $searchCriteriaBuilder->addFilter(OrderInterface::INCREMENT_ID, $incrementId)
->create();
$orderRepository = $this->objectManager->get(OrderRepositoryInterface::class);
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Plugin/CancelOrderTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Plugin/CancelOrderTest.php
index f58ae5d52b1ba..7c1af95bdb89c 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Plugin/CancelOrderTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Plugin/CancelOrderTest.php
@@ -5,7 +5,6 @@
*/
namespace Magento\Signifyd\Plugin;
-use Magento\Framework\Api\FilterBuilder;
use Magento\Framework\Api\SearchCriteriaBuilder;
use Magento\Sales\Api\Data\OrderInterface;
use Magento\Sales\Api\OrderManagementInterface;
@@ -15,9 +14,9 @@
use Magento\Signifyd\Model\SignifydGateway\ApiClient;
use Magento\TestFramework\Helper\Bootstrap;
use Magento\TestFramework\ObjectManager;
-use PHPUnit_Framework_MockObject_MockObject as MockObject;
+use PHPUnit\Framework\MockObject_MockObject as MockObject;
-class CancelOrderTest extends \PHPUnit_Framework_TestCase
+class CancelOrderTest extends \PHPUnit\Framework\TestCase
{
/**
* @var int
@@ -100,17 +99,9 @@ public function testAfterCancel()
*/
private function getOrder()
{
- /** @var FilterBuilder $filterBuilder */
- $filterBuilder = $this->objectManager->get(FilterBuilder::class);
- $filters = [
- $filterBuilder->setField(OrderInterface::INCREMENT_ID)
- ->setValue('100000001')
- ->create()
- ];
-
/** @var SearchCriteriaBuilder $searchCriteriaBuilder */
$searchCriteriaBuilder = $this->objectManager->get(SearchCriteriaBuilder::class);
- $searchCriteria = $searchCriteriaBuilder->addFilters($filters)
+ $searchCriteria = $searchCriteriaBuilder->addFilter(OrderInterface::INCREMENT_ID, '100000001')
->create();
$orderRepository = $this->objectManager->get(OrderRepositoryInterface::class);
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/Plugin/DenyPaymentTest.php b/dev/tests/integration/testsuite/Magento/Signifyd/Plugin/DenyPaymentTest.php
index ff7e30046c338..72da71a630dff 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/Plugin/DenyPaymentTest.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/Plugin/DenyPaymentTest.php
@@ -5,7 +5,6 @@
*/
namespace Magento\Signifyd\Plugin;
-use Magento\Framework\Api\FilterBuilder;
use Magento\Framework\Api\SearchCriteriaBuilder;
use Magento\Framework\Registry;
use Magento\Payment\Model\Info as PaymentInfo;
@@ -22,12 +21,12 @@
use Magento\Signifyd\Model\SignifydGateway\ApiClient;
use Magento\TestFramework\Helper\Bootstrap;
use Magento\TestFramework\ObjectManager;
-use PHPUnit_Framework_MockObject_MockObject as MockObject;
+use PHPUnit\Framework\MockObject_MockObject as MockObject;
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class DenyPaymentTest extends \PHPUnit_Framework_TestCase
+class DenyPaymentTest extends \PHPUnit\Framework\TestCase
{
/**
* @var int
@@ -119,17 +118,9 @@ public function testAfterDenyPayment()
*/
private function getOrder()
{
- /** @var FilterBuilder $filterBuilder */
- $filterBuilder = $this->objectManager->get(FilterBuilder::class);
- $filters = [
- $filterBuilder->setField(OrderInterface::INCREMENT_ID)
- ->setValue('100000001')
- ->create()
- ];
-
/** @var SearchCriteriaBuilder $searchCriteriaBuilder */
$searchCriteriaBuilder = $this->objectManager->get(SearchCriteriaBuilder::class);
- $searchCriteria = $searchCriteriaBuilder->addFilters($filters)
+ $searchCriteria = $searchCriteriaBuilder->addFilter(OrderInterface::INCREMENT_ID, '100000001')
->create();
$orderRepository = $this->objectManager->get(OrderRepositoryInterface::class);
diff --git a/dev/tests/integration/testsuite/Magento/Signifyd/_files/order_with_customer_and_two_simple_products.php b/dev/tests/integration/testsuite/Magento/Signifyd/_files/order_with_customer_and_two_simple_products.php
index f8532faf27886..49a0a2d33e236 100644
--- a/dev/tests/integration/testsuite/Magento/Signifyd/_files/order_with_customer_and_two_simple_products.php
+++ b/dev/tests/integration/testsuite/Magento/Signifyd/_files/order_with_customer_and_two_simple_products.php
@@ -16,7 +16,6 @@
$addressData = include __DIR__ . '/../../../Magento/Sales/_files/address_data.php';
-
$objectManager = Bootstrap::getObjectManager();
$billingAddress = $objectManager->create(Address::class, ['data' => $addressData]);
From 0f26719ec9816ff0fbf62475629982b23e2750bf Mon Sep 17 00:00:00 2001
From: Joan He
Date: Mon, 20 Nov 2017 11:01:25 -0600
Subject: [PATCH 218/904] MAGETWO-72487: Move code to CE
- update composer.lock
---
composer.lock | 341 +++++++++++++++++++++++++-------------------------
1 file changed, 171 insertions(+), 170 deletions(-)
diff --git a/composer.lock b/composer.lock
index 4a58df269a08e..c185c3759263b 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,7 +4,8 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
- "content-hash": "9ee72dee95c04c48bc83a7334d8ccdf6",
+ "hash": "ae10df09bffedb7e1a02a974635a41d1",
+ "content-hash": "c80ea1a19bce9435f2acc7f9fc526e04",
"packages": [
{
"name": "braintree/braintree_php",
@@ -51,7 +52,7 @@
}
],
"description": "Braintree PHP Client Library",
- "time": "2017-02-16T19:59:04+00:00"
+ "time": "2017-02-16 19:59:04"
},
{
"name": "colinmollenhour/cache-backend-file",
@@ -87,7 +88,7 @@
],
"description": "The stock Zend_Cache_Backend_File backend has extremely poor performance for cleaning by tags making it become unusable as the number of cached items increases. This backend makes many changes resulting in a huge performance boost, especially for tag cleaning.",
"homepage": "https://github.com/colinmollenhour/Cm_Cache_Backend_File",
- "time": "2016-05-02T16:24:47+00:00"
+ "time": "2016-05-02 16:24:47"
},
{
"name": "colinmollenhour/cache-backend-redis",
@@ -123,7 +124,7 @@
],
"description": "Zend_Cache backend using Redis with full support for tags.",
"homepage": "https://github.com/colinmollenhour/Cm_Cache_Backend_Redis",
- "time": "2017-03-25T04:54:24+00:00"
+ "time": "2017-03-25 04:54:24"
},
{
"name": "colinmollenhour/credis",
@@ -162,7 +163,7 @@
],
"description": "Credis is a lightweight interface to the Redis key-value store which wraps the phpredis library when available for better performance.",
"homepage": "https://github.com/colinmollenhour/credis",
- "time": "2015-11-28T01:20:04+00:00"
+ "time": "2015-11-28 01:20:04"
},
{
"name": "colinmollenhour/php-redis-session-abstract",
@@ -199,20 +200,20 @@
],
"description": "A Redis-based session handler with optimistic locking",
"homepage": "https://github.com/colinmollenhour/php-redis-session-abstract",
- "time": "2017-04-19T14:21:43+00:00"
+ "time": "2017-04-19 14:21:43"
},
{
"name": "composer/ca-bundle",
- "version": "1.0.8",
+ "version": "1.0.9",
"source": {
"type": "git",
"url": "https://github.com/composer/ca-bundle.git",
- "reference": "9dd73a03951357922d8aee6cc084500de93e2343"
+ "reference": "36344aeffdc37711335563e6108cda86566432a6"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/composer/ca-bundle/zipball/9dd73a03951357922d8aee6cc084500de93e2343",
- "reference": "9dd73a03951357922d8aee6cc084500de93e2343",
+ "url": "https://api.github.com/repos/composer/ca-bundle/zipball/36344aeffdc37711335563e6108cda86566432a6",
+ "reference": "36344aeffdc37711335563e6108cda86566432a6",
"shasum": ""
},
"require": {
@@ -258,7 +259,7 @@
"ssl",
"tls"
],
- "time": "2017-09-11T07:24:36+00:00"
+ "time": "2017-11-13 15:51:25"
},
{
"name": "composer/composer",
@@ -335,7 +336,7 @@
"dependency",
"package"
],
- "time": "2017-03-10T08:29:45+00:00"
+ "time": "2017-03-10 08:29:45"
},
{
"name": "composer/semver",
@@ -397,7 +398,7 @@
"validation",
"versioning"
],
- "time": "2016-08-30T16:08:34+00:00"
+ "time": "2016-08-30 16:08:34"
},
{
"name": "composer/spdx-licenses",
@@ -458,7 +459,7 @@
"spdx",
"validator"
],
- "time": "2017-04-03T19:08:52+00:00"
+ "time": "2017-04-03 19:08:52"
},
{
"name": "container-interop/container-interop",
@@ -489,7 +490,7 @@
],
"description": "Promoting the interoperability of container objects (DIC, SL, etc.)",
"homepage": "https://github.com/container-interop/container-interop",
- "time": "2017-02-14T19:40:03+00:00"
+ "time": "2017-02-14 19:40:03"
},
{
"name": "justinrainbow/json-schema",
@@ -555,7 +556,7 @@
"json",
"schema"
],
- "time": "2017-10-21T13:15:38+00:00"
+ "time": "2017-10-21 13:15:38"
},
{
"name": "league/climate",
@@ -604,7 +605,7 @@
"php",
"terminal"
],
- "time": "2015-01-18T14:31:58+00:00"
+ "time": "2015-01-18 14:31:58"
},
{
"name": "magento/composer",
@@ -640,7 +641,7 @@
"AFL-3.0"
],
"description": "Magento composer library helps to instantiate Composer application and run composer commands.",
- "time": "2017-04-24T09:57:02+00:00"
+ "time": "2017-04-24 09:57:02"
},
{
"name": "magento/magento-composer-installer",
@@ -719,7 +720,7 @@
"composer-installer",
"magento"
],
- "time": "2016-10-06T16:05:07+00:00"
+ "time": "2016-10-06 16:05:07"
},
{
"name": "magento/zendframework1",
@@ -766,7 +767,7 @@
"ZF1",
"framework"
],
- "time": "2017-06-21T14:56:23+00:00"
+ "time": "2017-06-21 14:56:23"
},
{
"name": "monolog/monolog",
@@ -844,7 +845,7 @@
"logging",
"psr-3"
],
- "time": "2017-06-19T01:22:40+00:00"
+ "time": "2017-06-19 01:22:40"
},
{
"name": "oyejorge/less.php",
@@ -906,7 +907,7 @@
"php",
"stylesheet"
],
- "time": "2017-03-28T22:19:25+00:00"
+ "time": "2017-03-28 22:19:25"
},
{
"name": "paragonie/random_compat",
@@ -954,7 +955,7 @@
"pseudorandom",
"random"
],
- "time": "2017-09-27T21:40:39+00:00"
+ "time": "2017-09-27 21:40:39"
},
{
"name": "pelago/emogrifier",
@@ -1014,7 +1015,7 @@
],
"description": "Converts CSS styles into inline style attributes in your HTML code",
"homepage": "http://www.pelagodesign.com/sidecar/emogrifier/",
- "time": "2017-03-02T12:51:48+00:00"
+ "time": "2017-03-02 12:51:48"
},
{
"name": "phpseclib/phpseclib",
@@ -1106,7 +1107,7 @@
"x.509",
"x509"
],
- "time": "2017-10-23T05:04:54+00:00"
+ "time": "2017-10-23 05:04:54"
},
{
"name": "psr/container",
@@ -1155,7 +1156,7 @@
"container-interop",
"psr"
],
- "time": "2017-02-14T16:28:37+00:00"
+ "time": "2017-02-14 16:28:37"
},
{
"name": "psr/log",
@@ -1202,7 +1203,7 @@
"psr",
"psr-3"
],
- "time": "2016-10-10T12:19:37+00:00"
+ "time": "2016-10-10 12:19:37"
},
{
"name": "ramsey/uuid",
@@ -1284,7 +1285,7 @@
"identifier",
"uuid"
],
- "time": "2017-03-26T20:37:53+00:00"
+ "time": "2017-03-26 20:37:53"
},
{
"name": "seld/cli-prompt",
@@ -1332,7 +1333,7 @@
"input",
"prompt"
],
- "time": "2017-03-18T11:32:45+00:00"
+ "time": "2017-03-18 11:32:45"
},
{
"name": "seld/jsonlint",
@@ -1381,7 +1382,7 @@
"parser",
"validator"
],
- "time": "2017-06-18T15:11:04+00:00"
+ "time": "2017-06-18 15:11:04"
},
{
"name": "seld/phar-utils",
@@ -1425,7 +1426,7 @@
"keywords": [
"phra"
],
- "time": "2015-10-13T18:44:15+00:00"
+ "time": "2015-10-13 18:44:15"
},
{
"name": "sjparkinson/static-review",
@@ -1478,20 +1479,20 @@
}
],
"description": "An extendable framework for version control hooks.",
- "time": "2014-09-22T08:40:36+00:00"
+ "time": "2014-09-22 08:40:36"
},
{
"name": "symfony/console",
- "version": "v2.8.28",
+ "version": "v2.8.31",
"source": {
"type": "git",
"url": "https://github.com/symfony/console.git",
- "reference": "f81549d2c5fdee8d711c9ab3c7e7362353ea5853"
+ "reference": "7cad097cf081c0ab3d0322cc38d34ee80484d86f"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/console/zipball/f81549d2c5fdee8d711c9ab3c7e7362353ea5853",
- "reference": "f81549d2c5fdee8d711c9ab3c7e7362353ea5853",
+ "url": "https://api.github.com/repos/symfony/console/zipball/7cad097cf081c0ab3d0322cc38d34ee80484d86f",
+ "reference": "7cad097cf081c0ab3d0322cc38d34ee80484d86f",
"shasum": ""
},
"require": {
@@ -1539,7 +1540,7 @@
],
"description": "Symfony Console Component",
"homepage": "https://symfony.com",
- "time": "2017-10-01T21:00:16+00:00"
+ "time": "2017-11-16 15:20:19"
},
{
"name": "symfony/debug",
@@ -1596,20 +1597,20 @@
],
"description": "Symfony Debug Component",
"homepage": "https://symfony.com",
- "time": "2016-07-30T07:22:48+00:00"
+ "time": "2016-07-30 07:22:48"
},
{
"name": "symfony/event-dispatcher",
- "version": "v2.8.28",
+ "version": "v2.8.31",
"source": {
"type": "git",
"url": "https://github.com/symfony/event-dispatcher.git",
- "reference": "7fe089232554357efb8d4af65ce209fc6e5a2186"
+ "reference": "b59aacf238fadda50d612c9de73b74751872a903"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/7fe089232554357efb8d4af65ce209fc6e5a2186",
- "reference": "7fe089232554357efb8d4af65ce209fc6e5a2186",
+ "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/b59aacf238fadda50d612c9de73b74751872a903",
+ "reference": "b59aacf238fadda50d612c9de73b74751872a903",
"shasum": ""
},
"require": {
@@ -1656,20 +1657,20 @@
],
"description": "Symfony EventDispatcher Component",
"homepage": "https://symfony.com",
- "time": "2017-10-01T21:00:16+00:00"
+ "time": "2017-11-05 15:25:56"
},
{
"name": "symfony/filesystem",
- "version": "v3.3.10",
+ "version": "v3.3.13",
"source": {
"type": "git",
"url": "https://github.com/symfony/filesystem.git",
- "reference": "90bc45abf02ae6b7deb43895c1052cb0038506f1"
+ "reference": "77db266766b54db3ee982fe51868328b887ce15c"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/filesystem/zipball/90bc45abf02ae6b7deb43895c1052cb0038506f1",
- "reference": "90bc45abf02ae6b7deb43895c1052cb0038506f1",
+ "url": "https://api.github.com/repos/symfony/filesystem/zipball/77db266766b54db3ee982fe51868328b887ce15c",
+ "reference": "77db266766b54db3ee982fe51868328b887ce15c",
"shasum": ""
},
"require": {
@@ -1705,20 +1706,20 @@
],
"description": "Symfony Filesystem Component",
"homepage": "https://symfony.com",
- "time": "2017-10-03T13:33:10+00:00"
+ "time": "2017-11-07 14:12:55"
},
{
"name": "symfony/finder",
- "version": "v3.3.10",
+ "version": "v3.3.13",
"source": {
"type": "git",
"url": "https://github.com/symfony/finder.git",
- "reference": "773e19a491d97926f236942484cb541560ce862d"
+ "reference": "138af5ec075d4b1d1bd19de08c38a34bb2d7d880"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/finder/zipball/773e19a491d97926f236942484cb541560ce862d",
- "reference": "773e19a491d97926f236942484cb541560ce862d",
+ "url": "https://api.github.com/repos/symfony/finder/zipball/138af5ec075d4b1d1bd19de08c38a34bb2d7d880",
+ "reference": "138af5ec075d4b1d1bd19de08c38a34bb2d7d880",
"shasum": ""
},
"require": {
@@ -1754,7 +1755,7 @@
],
"description": "Symfony Finder Component",
"homepage": "https://symfony.com",
- "time": "2017-10-02T06:42:24+00:00"
+ "time": "2017-11-05 15:47:03"
},
{
"name": "symfony/polyfill-mbstring",
@@ -1813,20 +1814,20 @@
"portable",
"shim"
],
- "time": "2017-10-11T12:05:26+00:00"
+ "time": "2017-10-11 12:05:26"
},
{
"name": "symfony/process",
- "version": "v2.8.28",
+ "version": "v2.8.31",
"source": {
"type": "git",
"url": "https://github.com/symfony/process.git",
- "reference": "26c9fb02bf06bd6b90f661a5bd17e510810d0176"
+ "reference": "d25449e031f600807949aab7cadbf267712f4eee"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/process/zipball/26c9fb02bf06bd6b90f661a5bd17e510810d0176",
- "reference": "26c9fb02bf06bd6b90f661a5bd17e510810d0176",
+ "url": "https://api.github.com/repos/symfony/process/zipball/d25449e031f600807949aab7cadbf267712f4eee",
+ "reference": "d25449e031f600807949aab7cadbf267712f4eee",
"shasum": ""
},
"require": {
@@ -1862,7 +1863,7 @@
],
"description": "Symfony Process Component",
"homepage": "https://symfony.com",
- "time": "2017-10-01T21:00:16+00:00"
+ "time": "2017-11-05 15:25:56"
},
{
"name": "tedivm/jshrink",
@@ -1908,7 +1909,7 @@
"javascript",
"minifier"
],
- "time": "2015-07-04T07:35:09+00:00"
+ "time": "2015-07-04 07:35:09"
},
{
"name": "tubalmartin/cssmin",
@@ -1961,7 +1962,7 @@
"minify",
"yui"
],
- "time": "2017-05-16T13:45:26+00:00"
+ "time": "2017-05-16 13:45:26"
},
{
"name": "webonyx/graphql-php",
@@ -2008,7 +2009,7 @@
"api",
"graphql"
],
- "time": "2017-10-13T17:45:55+00:00"
+ "time": "2017-10-13 17:45:55"
},
{
"name": "zendframework/zend-captcha",
@@ -2065,7 +2066,7 @@
"captcha",
"zf2"
],
- "time": "2017-02-23T08:09:44+00:00"
+ "time": "2017-02-23 08:09:44"
},
{
"name": "zendframework/zend-code",
@@ -2118,7 +2119,7 @@
"code",
"zf2"
],
- "time": "2016-10-24T13:23:32+00:00"
+ "time": "2016-10-24 13:23:32"
},
{
"name": "zendframework/zend-config",
@@ -2174,7 +2175,7 @@
"config",
"zf2"
],
- "time": "2016-02-04T23:01:10+00:00"
+ "time": "2016-02-04 23:01:10"
},
{
"name": "zendframework/zend-console",
@@ -2226,7 +2227,7 @@
"console",
"zf2"
],
- "time": "2016-02-09T17:15:12+00:00"
+ "time": "2016-02-09 17:15:12"
},
{
"name": "zendframework/zend-crypt",
@@ -2276,7 +2277,7 @@
"crypt",
"zf2"
],
- "time": "2016-02-03T23:46:30+00:00"
+ "time": "2016-02-03 23:46:30"
},
{
"name": "zendframework/zend-db",
@@ -2333,7 +2334,7 @@
"db",
"zf2"
],
- "time": "2016-08-09T19:28:55+00:00"
+ "time": "2016-08-09 19:28:55"
},
{
"name": "zendframework/zend-di",
@@ -2380,7 +2381,7 @@
"di",
"zf2"
],
- "time": "2016-04-25T20:58:11+00:00"
+ "time": "2016-04-25 20:58:11"
},
{
"name": "zendframework/zend-escaper",
@@ -2424,7 +2425,7 @@
"escaper",
"zf2"
],
- "time": "2016-06-30T19:48:38+00:00"
+ "time": "2016-06-30 19:48:38"
},
{
"name": "zendframework/zend-eventmanager",
@@ -2471,7 +2472,7 @@
"eventmanager",
"zf2"
],
- "time": "2016-02-18T20:49:05+00:00"
+ "time": "2016-02-18 20:49:05"
},
{
"name": "zendframework/zend-filter",
@@ -2531,7 +2532,7 @@
"filter",
"zf2"
],
- "time": "2017-05-17T20:56:17+00:00"
+ "time": "2017-05-17 20:56:17"
},
{
"name": "zendframework/zend-form",
@@ -2608,7 +2609,7 @@
"form",
"zf2"
],
- "time": "2017-05-18T14:59:53+00:00"
+ "time": "2017-05-18 14:59:53"
},
{
"name": "zendframework/zend-http",
@@ -2661,7 +2662,7 @@
"zend",
"zf"
],
- "time": "2017-10-13T12:06:24+00:00"
+ "time": "2017-10-13 12:06:24"
},
{
"name": "zendframework/zend-hydrator",
@@ -2719,7 +2720,7 @@
"hydrator",
"zf2"
],
- "time": "2016-02-18T22:38:26+00:00"
+ "time": "2016-02-18 22:38:26"
},
{
"name": "zendframework/zend-i18n",
@@ -2786,20 +2787,20 @@
"i18n",
"zf2"
],
- "time": "2017-05-17T17:00:12+00:00"
+ "time": "2017-05-17 17:00:12"
},
{
"name": "zendframework/zend-inputfilter",
- "version": "2.7.4",
+ "version": "2.7.5",
"source": {
"type": "git",
"url": "https://github.com/zendframework/zend-inputfilter.git",
- "reference": "699ab4916e0aa73104e1f9ff068ef6d33c5f5fe4"
+ "reference": "02bbc6b5fc54991e43e7471e54e2173077708d7b"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/zendframework/zend-inputfilter/zipball/699ab4916e0aa73104e1f9ff068ef6d33c5f5fe4",
- "reference": "699ab4916e0aa73104e1f9ff068ef6d33c5f5fe4",
+ "url": "https://api.github.com/repos/zendframework/zend-inputfilter/zipball/02bbc6b5fc54991e43e7471e54e2173077708d7b",
+ "reference": "02bbc6b5fc54991e43e7471e54e2173077708d7b",
"shasum": ""
},
"require": {
@@ -2841,7 +2842,7 @@
"inputfilter",
"zf2"
],
- "time": "2017-05-18T14:20:56+00:00"
+ "time": "2017-11-07 17:08:00"
},
{
"name": "zendframework/zend-json",
@@ -2896,7 +2897,7 @@
"json",
"zf2"
],
- "time": "2016-02-04T21:20:26+00:00"
+ "time": "2016-02-04 21:20:26"
},
{
"name": "zendframework/zend-loader",
@@ -2940,7 +2941,7 @@
"loader",
"zf2"
],
- "time": "2015-06-03T14:05:47+00:00"
+ "time": "2015-06-03 14:05:47"
},
{
"name": "zendframework/zend-log",
@@ -3011,7 +3012,7 @@
"logging",
"zf2"
],
- "time": "2017-05-17T16:03:26+00:00"
+ "time": "2017-05-17 16:03:26"
},
{
"name": "zendframework/zend-mail",
@@ -3073,7 +3074,7 @@
"mail",
"zf2"
],
- "time": "2017-06-08T20:03:58+00:00"
+ "time": "2017-06-08 20:03:58"
},
{
"name": "zendframework/zend-math",
@@ -3123,7 +3124,7 @@
"math",
"zf2"
],
- "time": "2016-04-07T16:29:53+00:00"
+ "time": "2016-04-07 16:29:53"
},
{
"name": "zendframework/zend-mime",
@@ -3172,20 +3173,20 @@
"mime",
"zf2"
],
- "time": "2017-01-16T16:43:38+00:00"
+ "time": "2017-01-16 16:43:38"
},
{
"name": "zendframework/zend-modulemanager",
- "version": "2.8.0",
+ "version": "2.8.1",
"source": {
"type": "git",
"url": "https://github.com/zendframework/zend-modulemanager.git",
- "reference": "c2c5b52ad9741e0b9a9c01a0ee72ab63e5b494b9"
+ "reference": "710c13353b1ff0975777dbeb39bbf1c85e3353a3"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/zendframework/zend-modulemanager/zipball/c2c5b52ad9741e0b9a9c01a0ee72ab63e5b494b9",
- "reference": "c2c5b52ad9741e0b9a9c01a0ee72ab63e5b494b9",
+ "url": "https://api.github.com/repos/zendframework/zend-modulemanager/zipball/710c13353b1ff0975777dbeb39bbf1c85e3353a3",
+ "reference": "710c13353b1ff0975777dbeb39bbf1c85e3353a3",
"shasum": ""
},
"require": {
@@ -3230,7 +3231,7 @@
"modulemanager",
"zf2"
],
- "time": "2017-07-11T19:39:57+00:00"
+ "time": "2017-11-01 18:30:41"
},
{
"name": "zendframework/zend-mvc",
@@ -3317,7 +3318,7 @@
"mvc",
"zf2"
],
- "time": "2016-02-23T15:24:59+00:00"
+ "time": "2016-02-23 15:24:59"
},
{
"name": "zendframework/zend-serializer",
@@ -3374,7 +3375,7 @@
"serializer",
"zf2"
],
- "time": "2016-06-21T17:01:55+00:00"
+ "time": "2016-06-21 17:01:55"
},
{
"name": "zendframework/zend-server",
@@ -3420,7 +3421,7 @@
"server",
"zf2"
],
- "time": "2016-06-20T22:27:55+00:00"
+ "time": "2016-06-20 22:27:55"
},
{
"name": "zendframework/zend-servicemanager",
@@ -3472,7 +3473,7 @@
"servicemanager",
"zf2"
],
- "time": "2016-12-19T19:14:29+00:00"
+ "time": "2016-12-19 19:14:29"
},
{
"name": "zendframework/zend-session",
@@ -3538,7 +3539,7 @@
"session",
"zf2"
],
- "time": "2017-06-19T21:31:39+00:00"
+ "time": "2017-06-19 21:31:39"
},
{
"name": "zendframework/zend-soap",
@@ -3590,7 +3591,7 @@
"soap",
"zf2"
],
- "time": "2016-04-21T16:06:27+00:00"
+ "time": "2016-04-21 16:06:27"
},
{
"name": "zendframework/zend-stdlib",
@@ -3649,7 +3650,7 @@
"stdlib",
"zf2"
],
- "time": "2016-04-12T21:17:31+00:00"
+ "time": "2016-04-12 21:17:31"
},
{
"name": "zendframework/zend-text",
@@ -3696,7 +3697,7 @@
"text",
"zf2"
],
- "time": "2016-02-08T19:03:52+00:00"
+ "time": "2016-02-08 19:03:52"
},
{
"name": "zendframework/zend-uri",
@@ -3743,7 +3744,7 @@
"uri",
"zf2"
],
- "time": "2016-02-17T22:38:51+00:00"
+ "time": "2016-02-17 22:38:51"
},
{
"name": "zendframework/zend-validator",
@@ -3814,7 +3815,7 @@
"validator",
"zf2"
],
- "time": "2017-08-22T14:19:23+00:00"
+ "time": "2017-08-22 14:19:23"
},
{
"name": "zendframework/zend-view",
@@ -3901,7 +3902,7 @@
"view",
"zf2"
],
- "time": "2017-03-21T15:05:56+00:00"
+ "time": "2017-03-21 15:05:56"
}
],
"packages-dev": [
@@ -3957,7 +3958,7 @@
"constructor",
"instantiate"
],
- "time": "2015-06-14T21:17:01+00:00"
+ "time": "2015-06-14 21:17:01"
},
{
"name": "friendsofphp/php-cs-fixer",
@@ -4027,7 +4028,7 @@
}
],
"description": "A tool to automatically fix PHP code style",
- "time": "2017-03-31T12:59:38+00:00"
+ "time": "2017-03-31 12:59:38"
},
{
"name": "ircmaxell/password-compat",
@@ -4069,7 +4070,7 @@
"hashing",
"password"
],
- "time": "2014-11-20T16:49:30+00:00"
+ "time": "2014-11-20 16:49:30"
},
{
"name": "lusitanian/oauth",
@@ -4136,7 +4137,7 @@
"oauth",
"security"
],
- "time": "2016-07-12T22:15:40+00:00"
+ "time": "2016-07-12 22:15:40"
},
{
"name": "myclabs/deep-copy",
@@ -4181,7 +4182,7 @@
"object",
"object graph"
],
- "time": "2017-10-19T19:58:43+00:00"
+ "time": "2017-10-19 19:58:43"
},
{
"name": "pdepend/pdepend",
@@ -4221,7 +4222,7 @@
"BSD-3-Clause"
],
"description": "Official version of pdepend to be handled with Composer",
- "time": "2017-01-19T14:23:36+00:00"
+ "time": "2017-01-19 14:23:36"
},
{
"name": "phar-io/manifest",
@@ -4276,7 +4277,7 @@
}
],
"description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)",
- "time": "2017-03-05T18:14:27+00:00"
+ "time": "2017-03-05 18:14:27"
},
{
"name": "phar-io/version",
@@ -4323,7 +4324,7 @@
}
],
"description": "Library for handling version information and constraints",
- "time": "2017-03-05T17:38:23+00:00"
+ "time": "2017-03-05 17:38:23"
},
{
"name": "phpdocumentor/reflection-common",
@@ -4377,7 +4378,7 @@
"reflection",
"static analysis"
],
- "time": "2017-09-11T18:02:19+00:00"
+ "time": "2017-09-11 18:02:19"
},
{
"name": "phpdocumentor/reflection-docblock",
@@ -4422,7 +4423,7 @@
}
],
"description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.",
- "time": "2017-08-30T18:51:59+00:00"
+ "time": "2017-08-30 18:51:59"
},
{
"name": "phpdocumentor/type-resolver",
@@ -4469,7 +4470,7 @@
"email": "me@mikevanriel.com"
}
],
- "time": "2017-07-14T14:27:02+00:00"
+ "time": "2017-07-14 14:27:02"
},
{
"name": "phpmd/phpmd",
@@ -4535,7 +4536,7 @@
"phpmd",
"pmd"
],
- "time": "2017-01-20T14:41:10+00:00"
+ "time": "2017-01-20 14:41:10"
},
{
"name": "phpspec/prophecy",
@@ -4598,20 +4599,20 @@
"spy",
"stub"
],
- "time": "2017-09-04T11:05:03+00:00"
+ "time": "2017-09-04 11:05:03"
},
{
"name": "phpunit/php-code-coverage",
- "version": "5.2.2",
+ "version": "5.2.3",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-code-coverage.git",
- "reference": "8ed1902a57849e117b5651fc1a5c48110946c06b"
+ "reference": "8e1d2397d8adf59a3f12b2878a3aaa66d1ab189d"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/8ed1902a57849e117b5651fc1a5c48110946c06b",
- "reference": "8ed1902a57849e117b5651fc1a5c48110946c06b",
+ "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/8e1d2397d8adf59a3f12b2878a3aaa66d1ab189d",
+ "reference": "8e1d2397d8adf59a3f12b2878a3aaa66d1ab189d",
"shasum": ""
},
"require": {
@@ -4620,7 +4621,7 @@
"php": "^7.0",
"phpunit/php-file-iterator": "^1.4.2",
"phpunit/php-text-template": "^1.2.1",
- "phpunit/php-token-stream": "^1.4.11 || ^2.0",
+ "phpunit/php-token-stream": "^2.0",
"sebastian/code-unit-reverse-lookup": "^1.0.1",
"sebastian/environment": "^3.0",
"sebastian/version": "^2.0.1",
@@ -4662,7 +4663,7 @@
"testing",
"xunit"
],
- "time": "2017-08-03T12:40:43+00:00"
+ "time": "2017-11-03 13:47:33"
},
{
"name": "phpunit/php-file-iterator",
@@ -4709,7 +4710,7 @@
"filesystem",
"iterator"
],
- "time": "2016-10-03T07:40:28+00:00"
+ "time": "2016-10-03 07:40:28"
},
{
"name": "phpunit/php-text-template",
@@ -4750,7 +4751,7 @@
"keywords": [
"template"
],
- "time": "2015-06-21T13:50:34+00:00"
+ "time": "2015-06-21 13:50:34"
},
{
"name": "phpunit/php-timer",
@@ -4799,7 +4800,7 @@
"keywords": [
"timer"
],
- "time": "2017-02-26T11:10:40+00:00"
+ "time": "2017-02-26 11:10:40"
},
{
"name": "phpunit/php-token-stream",
@@ -4848,7 +4849,7 @@
"keywords": [
"tokenizer"
],
- "time": "2017-08-20T05:47:52+00:00"
+ "time": "2017-08-20 05:47:52"
},
{
"name": "phpunit/phpunit",
@@ -4932,7 +4933,7 @@
"testing",
"xunit"
],
- "time": "2017-08-03T13:59:28+00:00"
+ "time": "2017-08-03 13:59:28"
},
{
"name": "phpunit/phpunit-mock-objects",
@@ -4991,7 +4992,7 @@
"mock",
"xunit"
],
- "time": "2017-08-03T14:08:16+00:00"
+ "time": "2017-08-03 14:08:16"
},
{
"name": "sebastian/code-unit-reverse-lookup",
@@ -5036,7 +5037,7 @@
],
"description": "Looks up which function or method a line of code belongs to",
"homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/",
- "time": "2017-03-04T06:30:41+00:00"
+ "time": "2017-03-04 06:30:41"
},
{
"name": "sebastian/comparator",
@@ -5100,7 +5101,7 @@
"compare",
"equality"
],
- "time": "2017-03-03T06:26:08+00:00"
+ "time": "2017-03-03 06:26:08"
},
{
"name": "sebastian/diff",
@@ -5152,7 +5153,7 @@
"keywords": [
"diff"
],
- "time": "2017-05-22T07:24:03+00:00"
+ "time": "2017-05-22 07:24:03"
},
{
"name": "sebastian/environment",
@@ -5202,7 +5203,7 @@
"environment",
"hhvm"
],
- "time": "2017-07-01T08:51:00+00:00"
+ "time": "2017-07-01 08:51:00"
},
{
"name": "sebastian/exporter",
@@ -5269,24 +5270,24 @@
"export",
"exporter"
],
- "time": "2017-04-03T13:19:02+00:00"
+ "time": "2017-04-03 13:19:02"
},
{
"name": "sebastian/finder-facade",
- "version": "1.2.1",
+ "version": "1.2.2",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/finder-facade.git",
- "reference": "2a6f7f57efc0aa2d23297d9fd9e2a03111a8c0b9"
+ "reference": "4a3174709c2dc565fe5fb26fcf827f6a1fc7b09f"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/finder-facade/zipball/2a6f7f57efc0aa2d23297d9fd9e2a03111a8c0b9",
- "reference": "2a6f7f57efc0aa2d23297d9fd9e2a03111a8c0b9",
+ "url": "https://api.github.com/repos/sebastianbergmann/finder-facade/zipball/4a3174709c2dc565fe5fb26fcf827f6a1fc7b09f",
+ "reference": "4a3174709c2dc565fe5fb26fcf827f6a1fc7b09f",
"shasum": ""
},
"require": {
- "symfony/finder": "~2.3|~3.0",
+ "symfony/finder": "~2.3|~3.0|~4.0",
"theseer/fdomdocument": "~1.3"
},
"type": "library",
@@ -5308,7 +5309,7 @@
],
"description": "FinderFacade is a convenience wrapper for Symfony's Finder component.",
"homepage": "https://github.com/sebastianbergmann/finder-facade",
- "time": "2016-02-17T07:02:23+00:00"
+ "time": "2017-11-18 17:31:49"
},
{
"name": "sebastian/global-state",
@@ -5359,7 +5360,7 @@
"keywords": [
"global state"
],
- "time": "2017-04-27T15:39:26+00:00"
+ "time": "2017-04-27 15:39:26"
},
{
"name": "sebastian/object-enumerator",
@@ -5406,7 +5407,7 @@
],
"description": "Traverses array structures and object graphs to enumerate all referenced objects",
"homepage": "https://github.com/sebastianbergmann/object-enumerator/",
- "time": "2017-08-03T12:35:26+00:00"
+ "time": "2017-08-03 12:35:26"
},
{
"name": "sebastian/object-reflector",
@@ -5451,7 +5452,7 @@
],
"description": "Allows reflection of object attributes, including inherited and non-public ones",
"homepage": "https://github.com/sebastianbergmann/object-reflector/",
- "time": "2017-03-29T09:07:27+00:00"
+ "time": "2017-03-29 09:07:27"
},
{
"name": "sebastian/phpcpd",
@@ -5502,7 +5503,7 @@
],
"description": "Copy/Paste Detector (CPD) for PHP code.",
"homepage": "https://github.com/sebastianbergmann/phpcpd",
- "time": "2016-04-17T19:32:49+00:00"
+ "time": "2016-04-17 19:32:49"
},
{
"name": "sebastian/recursion-context",
@@ -5555,7 +5556,7 @@
],
"description": "Provides functionality to recursively process PHP variables",
"homepage": "http://www.github.com/sebastianbergmann/recursion-context",
- "time": "2017-03-03T06:23:57+00:00"
+ "time": "2017-03-03 06:23:57"
},
{
"name": "sebastian/resource-operations",
@@ -5597,7 +5598,7 @@
],
"description": "Provides a list of PHP built-in functions that operate on resources",
"homepage": "https://www.github.com/sebastianbergmann/resource-operations",
- "time": "2015-07-28T20:34:47+00:00"
+ "time": "2015-07-28 20:34:47"
},
{
"name": "sebastian/version",
@@ -5640,7 +5641,7 @@
],
"description": "Library that helps with managing the version number of Git-hosted PHP projects",
"homepage": "https://github.com/sebastianbergmann/version",
- "time": "2016-10-03T07:35:21+00:00"
+ "time": "2016-10-03 07:35:21"
},
{
"name": "squizlabs/php_codesniffer",
@@ -5691,20 +5692,20 @@
"phpcs",
"standards"
],
- "time": "2017-06-14T01:23:49+00:00"
+ "time": "2017-06-14 01:23:49"
},
{
"name": "symfony/config",
- "version": "v3.3.10",
+ "version": "v3.3.13",
"source": {
"type": "git",
"url": "https://github.com/symfony/config.git",
- "reference": "4ab62407bff9cd97c410a7feaef04c375aaa5cfd"
+ "reference": "8d2649077dc54dfbaf521d31f217383d82303c5f"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/config/zipball/4ab62407bff9cd97c410a7feaef04c375aaa5cfd",
- "reference": "4ab62407bff9cd97c410a7feaef04c375aaa5cfd",
+ "url": "https://api.github.com/repos/symfony/config/zipball/8d2649077dc54dfbaf521d31f217383d82303c5f",
+ "reference": "8d2649077dc54dfbaf521d31f217383d82303c5f",
"shasum": ""
},
"require": {
@@ -5753,20 +5754,20 @@
],
"description": "Symfony Config Component",
"homepage": "https://symfony.com",
- "time": "2017-10-04T18:56:58+00:00"
+ "time": "2017-11-07 14:16:22"
},
{
"name": "symfony/dependency-injection",
- "version": "v3.3.10",
+ "version": "v3.3.13",
"source": {
"type": "git",
"url": "https://github.com/symfony/dependency-injection.git",
- "reference": "8ebad929aee3ca185b05f55d9cc5521670821ad1"
+ "reference": "4e84f5af2c2d51ee3dee72df40b7fc08f49b4ab8"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/8ebad929aee3ca185b05f55d9cc5521670821ad1",
- "reference": "8ebad929aee3ca185b05f55d9cc5521670821ad1",
+ "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/4e84f5af2c2d51ee3dee72df40b7fc08f49b4ab8",
+ "reference": "4e84f5af2c2d51ee3dee72df40b7fc08f49b4ab8",
"shasum": ""
},
"require": {
@@ -5823,7 +5824,7 @@
],
"description": "Symfony DependencyInjection Component",
"homepage": "https://symfony.com",
- "time": "2017-10-04T17:15:30+00:00"
+ "time": "2017-11-13 18:10:32"
},
{
"name": "symfony/polyfill-php54",
@@ -5881,7 +5882,7 @@
"portable",
"shim"
],
- "time": "2017-10-11T12:05:26+00:00"
+ "time": "2017-10-11 12:05:26"
},
{
"name": "symfony/polyfill-php55",
@@ -5937,7 +5938,7 @@
"portable",
"shim"
],
- "time": "2017-10-11T12:05:26+00:00"
+ "time": "2017-10-11 12:05:26"
},
{
"name": "symfony/polyfill-php70",
@@ -5996,7 +5997,7 @@
"portable",
"shim"
],
- "time": "2017-10-11T12:05:26+00:00"
+ "time": "2017-10-11 12:05:26"
},
{
"name": "symfony/polyfill-php72",
@@ -6051,7 +6052,7 @@
"portable",
"shim"
],
- "time": "2017-10-11T12:05:26+00:00"
+ "time": "2017-10-11 12:05:26"
},
{
"name": "symfony/polyfill-xml",
@@ -6099,20 +6100,20 @@
"portable",
"shim"
],
- "time": "2017-10-11T12:05:26+00:00"
+ "time": "2017-10-11 12:05:26"
},
{
"name": "symfony/stopwatch",
- "version": "v3.3.10",
+ "version": "v3.3.13",
"source": {
"type": "git",
"url": "https://github.com/symfony/stopwatch.git",
- "reference": "170edf8b3247d7b6779eb6fa7428f342702ca184"
+ "reference": "1e93c3139ef6c799831fe03efd0fb1c7aecb3365"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/stopwatch/zipball/170edf8b3247d7b6779eb6fa7428f342702ca184",
- "reference": "170edf8b3247d7b6779eb6fa7428f342702ca184",
+ "url": "https://api.github.com/repos/symfony/stopwatch/zipball/1e93c3139ef6c799831fe03efd0fb1c7aecb3365",
+ "reference": "1e93c3139ef6c799831fe03efd0fb1c7aecb3365",
"shasum": ""
},
"require": {
@@ -6148,7 +6149,7 @@
],
"description": "Symfony Stopwatch Component",
"homepage": "https://symfony.com",
- "time": "2017-10-02T06:42:24+00:00"
+ "time": "2017-11-10 19:02:53"
},
{
"name": "theseer/fdomdocument",
@@ -6188,7 +6189,7 @@
],
"description": "The classes contained within this repository extend the standard DOM to use exceptions at all occasions of errors instead of PHP warnings or notices. They also add various custom methods and shortcuts for convenience and to simplify the usage of DOM.",
"homepage": "https://github.com/theseer/fDOMDocument",
- "time": "2017-06-30T11:53:12+00:00"
+ "time": "2017-06-30 11:53:12"
},
{
"name": "theseer/tokenizer",
@@ -6228,7 +6229,7 @@
}
],
"description": "A small library for converting tokenized PHP source code into XML and potentially other formats",
- "time": "2017-04-07T12:08:54+00:00"
+ "time": "2017-04-07 12:08:54"
},
{
"name": "webmozart/assert",
@@ -6278,7 +6279,7 @@
"check",
"validate"
],
- "time": "2016-11-23T20:04:58+00:00"
+ "time": "2016-11-23 20:04:58"
}
],
"aliases": [],
From ecdf63d3a2536439acb6bd387c0b9084e6d09591 Mon Sep 17 00:00:00 2001
From: Joan He
Date: Mon, 20 Nov 2017 11:03:35 -0600
Subject: [PATCH 219/904] MAGETWO-72487: Move code to CE
- add exception hierarchy black list
---
.../Test/Integrity/_files/blacklist/exception_hierarchy.txt | 2 ++
1 file changed, 2 insertions(+)
diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/_files/blacklist/exception_hierarchy.txt b/dev/tests/static/testsuite/Magento/Test/Integrity/_files/blacklist/exception_hierarchy.txt
index eef18a25ad259..6897f43a02b34 100644
--- a/dev/tests/static/testsuite/Magento/Test/Integrity/_files/blacklist/exception_hierarchy.txt
+++ b/dev/tests/static/testsuite/Magento/Test/Integrity/_files/blacklist/exception_hierarchy.txt
@@ -9,3 +9,5 @@
\Magento\Framework\DB\Adapter\DuplicateException
\Magento\Framework\DB\DataConverter\DataConversionException
\Magento\Framework\DB\FieldDataConversionException
+\Magento\Signifyd\Model\SignifydGateway\GatewayException
+\Magento\Signifyd\Model\SignifydGateway\ApiCallException
From 4cb340c19ba918cfb776b89ea11f0beba86411ea Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Wed, 8 Feb 2017 02:58:48 -0600
Subject: [PATCH 220/904] MAGETWO-63945: Add extension point to sales grid
indexer
- Delete constraint.xml
---
app/code/Magento/Signifyd/etc/constraints.xml | 17 -----------------
1 file changed, 17 deletions(-)
delete mode 100644 app/code/Magento/Signifyd/etc/constraints.xml
diff --git a/app/code/Magento/Signifyd/etc/constraints.xml b/app/code/Magento/Signifyd/etc/constraints.xml
deleted file mode 100644
index 1c02b42bf11c9..0000000000000
--- a/app/code/Magento/Signifyd/etc/constraints.xml
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
From 9abeb4a88452aed75b8c5532ea53186f9157a9e0 Mon Sep 17 00:00:00 2001
From: Joan He
Date: Mon, 27 Nov 2017 15:39:42 -0600
Subject: [PATCH 221/904] MAGETWO-72487: Move code to CE
- (cherry picked from commit d71ad32)
---
app/code/Magento/Signifyd/etc/di.xml | 21 -------------------
.../Signifyd/frontend/js/Fingerprint.test.js | 2 +-
2 files changed, 1 insertion(+), 22 deletions(-)
diff --git a/app/code/Magento/Signifyd/etc/di.xml b/app/code/Magento/Signifyd/etc/di.xml
index c32fd4352bb10..92ad8a0bfd87a 100644
--- a/app/code/Magento/Signifyd/etc/di.xml
+++ b/app/code/Magento/Signifyd/etc/di.xml
@@ -56,32 +56,11 @@
-
-
-
- -
-
- signifyd_case
- - entity_id
- - order_id
-
-
-
- - signifyd_case.guarantee_disposition
-
-
-
sales
-
-
-
- - signifyd_case
-
-
-
Magento_Signifyd
diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Signifyd/frontend/js/Fingerprint.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Signifyd/frontend/js/Fingerprint.test.js
index 1db9755eb074a..0be178c5a31f0 100644
--- a/dev/tests/js/jasmine/tests/app/code/Magento/Signifyd/frontend/js/Fingerprint.test.js
+++ b/dev/tests/js/jasmine/tests/app/code/Magento/Signifyd/frontend/js/Fingerprint.test.js
@@ -1,5 +1,5 @@
/**
- * Copyright © 2013-2017 Magento, Inc. All rights reserved.
+ * Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
From 2a48973be95a4d57a3765fa381f723f18fa35ce6 Mon Sep 17 00:00:00 2001
From: Joan He
Date: Tue, 28 Nov 2017 08:55:47 -0600
Subject: [PATCH 222/904] MAGETWO-72487: Move code to CE
- remove suggest component magento/module-scalable-oms
---
app/code/Magento/Signifyd/composer.json | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/app/code/Magento/Signifyd/composer.json b/app/code/Magento/Signifyd/composer.json
index 94731b78cbdbf..59326a48f3e85 100644
--- a/app/code/Magento/Signifyd/composer.json
+++ b/app/code/Magento/Signifyd/composer.json
@@ -17,8 +17,7 @@
"php": "7.0.2|7.0.4|~7.0.6|~7.1.0"
},
"suggest": {
- "magento/module-config": "100.3.*",
- "magento/module-scalable-oms": "100.3.*"
+ "magento/module-config": "100.3.*"
},
"type": "magento2-module",
"version": "100.3.0-dev",
From b237558168488b77309d69872bf2d517aa942d49 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ra=C3=BAl=20Mateos?=
Date: Mon, 9 Oct 2017 14:05:48 +0200
Subject: [PATCH 223/904] Save date time correctly in differents timezone and
locale
---
.../Stdlib/DateTime/Filter/DateTimeTest.php | 8 ++-
.../Framework/Stdlib/DateTime/Timezone.php | 52 ++++++++++++++-----
2 files changed, 45 insertions(+), 15 deletions(-)
diff --git a/dev/tests/integration/testsuite/Magento/Framework/Stdlib/DateTime/Filter/DateTimeTest.php b/dev/tests/integration/testsuite/Magento/Framework/Stdlib/DateTime/Filter/DateTimeTest.php
index 69c63c84388ef..6a0b9582f0621 100644
--- a/dev/tests/integration/testsuite/Magento/Framework/Stdlib/DateTime/Filter/DateTimeTest.php
+++ b/dev/tests/integration/testsuite/Magento/Framework/Stdlib/DateTime/Filter/DateTimeTest.php
@@ -70,9 +70,15 @@ public function localeDatetimeFilterProvider()
['fr_FR', '01/02/2010 15:30', '2010-02-01 15:30:00'],
['fr_FR', '01/02/2010 1:00', '2010-02-01 01:00:00'],
['fr_FR', '01/02/2010 01:00', '2010-02-01 01:00:00'],
+ ['en_US', '11/28/2010', '2010-11-28 00:00:00'],
+ ['en_US', '11/28/2010 1:00am', '2010-11-28 01:00:00'],
+ ['en_US', '11/28/2010 01:00am', '2010-11-28 01:00:00'],
+ ['es_ES', '28/11/2010', '2010-11-28 00:00:00'],
+ ['es_ES', '28/11/2010 23:12:00', '2010-11-28 23:12:00'],
+ ['es_ES', '28/11/2010 23:12', '2010-11-28 23:12:00'],
['de_DE', '01/02/2010 15:30', '2010-02-01 15:30:00'],
['en_US', '2017-09-01T15:30:00.000Z', '2017-09-01 15:30:00'],
- ['fr_FR', '2017-09-01T15:30:00.000Z', '2017-09-01 15:30:00'],
+ ['fr_FR', '2017-09-01T15:30:00.000Z', '2017-09-01 15:30:00']
];
}
}
diff --git a/lib/internal/Magento/Framework/Stdlib/DateTime/Timezone.php b/lib/internal/Magento/Framework/Stdlib/DateTime/Timezone.php
index 90aec6024fe12..aedabc936e391 100644
--- a/lib/internal/Magento/Framework/Stdlib/DateTime/Timezone.php
+++ b/lib/internal/Magento/Framework/Stdlib/DateTime/Timezone.php
@@ -5,11 +5,18 @@
*/
namespace Magento\Framework\Stdlib\DateTime;
-use \Magento\Framework\Exception\LocalizedException;
+use Magento\Framework\App\Config\ScopeConfigInterface;
+use Magento\Framework\App\ScopeInterface;
+use Magento\Framework\App\ScopeResolverInterface;
+use Magento\Framework\Exception\LocalizedException;
+use Magento\Framework\Locale\ResolverInterface;
use Magento\Framework\Phrase;
+use Magento\Framework\Stdlib\DateTime;
/**
* Timezone library
+ *
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class Timezone implements TimezoneInterface
{
@@ -29,12 +36,12 @@ class Timezone implements TimezoneInterface
protected $_scopeType;
/**
- * @var \Magento\Framework\App\ScopeResolverInterface
+ * @var ScopeResolverInterface
*/
protected $_scopeResolver;
/**
- * @var \Magento\Framework\Stdlib\DateTime
+ * @var DateTime
*/
protected $_dateTime;
@@ -44,28 +51,28 @@ class Timezone implements TimezoneInterface
protected $_defaultTimezonePath;
/**
- * @var \Magento\Framework\App\Config\ScopeConfigInterface
+ * @var ScopeConfigInterface
*/
protected $_scopeConfig;
/**
- * @var \Magento\Framework\Locale\ResolverInterface
+ * @var ResolverInterface
*/
protected $_localeResolver;
/**
- * @param \Magento\Framework\App\ScopeResolverInterface $scopeResolver
- * @param \Magento\Framework\Locale\ResolverInterface $localeResolver
- * @param \Magento\Framework\Stdlib\DateTime $dateTime
- * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
+ * @param ScopeResolverInterface $scopeResolver
+ * @param ResolverInterface $localeResolver
+ * @param DateTime $dateTime
+ * @param ScopeConfigInterface $scopeConfig
* @param string $scopeType
* @param string $defaultTimezonePath
*/
public function __construct(
- \Magento\Framework\App\ScopeResolverInterface $scopeResolver,
- \Magento\Framework\Locale\ResolverInterface $localeResolver,
- \Magento\Framework\Stdlib\DateTime $dateTime,
- \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
+ ScopeResolverInterface $scopeResolver,
+ ResolverInterface $localeResolver,
+ DateTime $dateTime,
+ ScopeConfigInterface $scopeConfig,
$scopeType,
$defaultTimezonePath
) {
@@ -174,6 +181,8 @@ public function date($date = null, $locale = null, $useTimezone = true, $include
$timeType,
new \DateTimeZone($timezone)
);
+
+ $date = $this->appendTimeIfNeeded($date, $includeTime);
$date = $formatter->parse($date) ?: (new \DateTime($date))->getTimestamp();
break;
}
@@ -226,7 +235,7 @@ public function scopeTimeStamp($scope = null)
*/
public function isScopeDateInInterval($scope, $dateFrom = null, $dateTo = null)
{
- if (!$scope instanceof \Magento\Framework\App\ScopeInterface) {
+ if (!$scope instanceof ScopeInterface) {
$scope = $this->_scopeResolver->getScope($scope);
}
@@ -318,4 +327,19 @@ public function convertConfigTimeToUtc($date, $format = 'Y-m-d H:i:s')
return $date->format($format);
}
+
+ /**
+ * Retrieve date with time
+ *
+ * @param string $date
+ * @param bool $includeTime
+ * @return string
+ */
+ private function appendTimeIfNeeded($date, $includeTime)
+ {
+ if ($includeTime && !preg_match('/\d{1}:\d{2}/', $date)) {
+ $date .= " 0:00am";
+ }
+ return $date;
+ }
}
From b6e20f1b00584329b0a7ebe459d8d817a353173b Mon Sep 17 00:00:00 2001
From: Sergii Kovalenko
Date: Thu, 14 Dec 2017 11:21:05 +0200
Subject: [PATCH 224/904] MAGETWO-83201: Creating Diff artifacts between
arbitrary Declarative Schemas
--working on adapter
---
app/etc/di.xml | 76 +++++
app/etc/registration_globlist.php | 1 +
dev/tests/error_handler.php | 42 +++
.../Magento/TestFramework/Application.php | 86 +++--
dev/tests/setup-integration/.gitignore | 1 +
.../Setup/InstallSchema.php | 28 ++
.../etc/module.xml | 10 +
.../etc/schema.xml | 45 +++
.../foreign_key_interpreter_result.php | 53 +++
.../fixture/valid_xml_revision_1.php | 212 ++++++++++++
.../registration.php | 12 +
.../fail_on_column_declaration/schema.xml | 13 +
.../fail_on_unique_key_declaration/schema.xml | 16 +
.../foreign_key_interpreter/schema.xml | 17 +
.../revisions/old_diff/InstallSchema.php | 119 +++++++
.../revisions/old_diff/schema.xml | 36 ++
.../{config => etc}/config-global.php.dist | 1 -
.../install-config-mysql.php.dist | 2 +-
.../TestFramework/Annotation/CopyModules.php | 51 +++
.../Annotation/DataProviderFromFile.php | 64 ++++
.../Annotation/ReinstallInstance.php | 21 +-
.../Annotation/SchemaFixture.php | 181 ++++++++++
.../TestFramework/Bootstrap/SetupDocBlock.php | 21 +-
.../TestFramework/Deploy/CliCommand.php | 86 +++--
.../TestFramework/Deploy/ParametersHolder.php | 71 ++++
.../Deploy/TestModuleManager.php | 33 +-
.../TestFramework/SetupApplication.php | 13 +
.../TestCase/MutableDataInterface.php | 35 ++
.../TestFramework/TestCase/SetupTestCase.php | 44 +++
.../Workaround/DeploymentConfig.php | 31 ++
.../setup-integration/framework/bootstrap.php | 85 ++---
dev/tests/setup-integration/phpunit.xml.dist | 4 +-
.../Setup/DeclarativeSchemaBuilderTest.php | 74 ++++
.../Magento/Setup/DiffOldSchemaTest.php | 225 +++++++++++++
.../testsuite/Magento/Setup/InstallTest.php | 24 +-
.../Magento/Setup/SchemaReaderTest.php | 78 +++++
.../Magento/Framework/App/Utility/Files.php | 8 +
.../Component/ComponentRegistrar.php | 2 +
lib/internal/Magento/Framework/Config/Dom.php | 2 +
.../Framework/Config/Dom/UrnResolver.php | 5 +
.../Magento/Framework/Console/Cli.php | 8 +-
setup/config/di.config.php | 9 +
setup/config/module.config.php | 6 +-
.../Setup/Console/Command/InstallCommand.php | 33 ++
.../Setup/Console/Command/UpgradeCommand.php | 2 +-
.../Model/Declaration/Schema/Casters/Base.php | 47 +++
.../Declaration/Schema/Casters/Biginteger.php | 53 +++
.../Declaration/Schema/Casters/Boolean.php | 59 ++++
.../Schema/Casters/CasterAggregator.php | 50 +++
.../Schema/Casters/CasterInterface.php | 22 ++
.../Model/Declaration/Schema/Casters/Date.php | 39 +++
.../Declaration/Schema/Casters/Decimal.php | 56 ++++
.../Declaration/Schema/Casters/Foreign.php | 46 +++
.../Declaration/Schema/Casters/Integer.php | 53 +++
.../Declaration/Schema/Casters/Primary.php | 42 +++
.../Schema/Casters/Smallinteger.php | 52 +++
.../Declaration/Schema/Casters/Timestamp.php | 68 ++++
.../Schema/Casters/Tinyinteger.php | 52 +++
.../Schema/ChangeProcessorInterface.php | 22 ++
.../Declaration/Schema/ChangeRegistry.php | 168 ++++++++++
.../Schema/ChangeRegistryFactory.php | 39 +++
.../Schema/ChangeRegistryInterface.php | 92 +++++
.../Model/Declaration/Schema/Comparator.php | 28 ++
.../Declaration/Schema/Db/AdapterMediator.php | 187 +++++++++++
.../Model/Declaration/Schema/Db/Parser.php | 37 ++
.../Processors/DbSchemaProcessorInterface.php | 37 ++
.../Db/Processors/DbSchemaReaderInterface.php | 57 ++++
.../Db/Processors/MySQL/Columns/Basic.php | 60 ++++
.../Db/Processors/MySQL/Columns/Boolean.php | 39 +++
.../Db/Processors/MySQL/Columns/Decimal.php | 61 ++++
.../Db/Processors/MySQL/Columns/Integer.php | 80 +++++
.../Db/Processors/MySQL/Columns/OnUpdate.php | 37 ++
.../Db/Processors/MySQL/Columns/Text.php | 42 +++
.../Db/Processors/MySQL/Columns/Timestamp.php | 52 +++
.../Db/Processors/MySQL/Columns/Unsigned.php | 44 +++
.../Db/Processors/MySQL/Columns/Varchar.php | 36 ++
.../MySQL/Constraints/ForeignKey.php | 57 ++++
.../Processors/MySQL/Constraints/Internal.php | 45 +++
.../Db/Processors/MySQL/DbSchemaReader.php | 134 ++++++++
.../Schema/Db/Processors/MySQL/Index.php | 45 +++
.../Schema/Db/StructureBuilder.php | 184 ++++++++++
.../Declaration/DynamicStructureInterface.php | 50 +++
.../Declaration/Schema/Declaration/Parser.php | 62 ++++
.../Schema/Declaration/Structure/Dynamic.php | 23 ++
.../Schema/Declaration/StructureBuilder.php | 315 ++++++++++++++++++
.../Declaration/Schema/Diff/DiffManager.php | 162 +++++++++
.../Declaration/Schema/Diff/StructureDiff.php | 64 ++++
.../Declaration/Schema/Diff/TableDiff.php | 88 +++++
.../Declaration/Schema/DiffInterface.php | 30 ++
.../Model/Declaration/Schema/Dto/Column.php | 45 +++
.../Declaration/Schema/Dto/Columns/Blob.php | 48 +++
.../Schema/Dto/Columns/Boolean.php | 70 ++++
.../Declaration/Schema/Dto/Columns/Date.php | 38 +++
.../Schema/Dto/Columns/Decimal.php | 104 ++++++
.../Schema/Dto/Columns/Integer.php | 104 ++++++
.../Declaration/Schema/Dto/Columns/Text.php | 48 +++
.../Schema/Dto/Columns/Timestamp.php | 71 ++++
.../Schema/Dto/Columns/Varbinary.php | 81 +++++
.../Schema/Dto/Columns/Varchar.php | 81 +++++
.../Declaration/Schema/Dto/Constraint.php | 45 +++
.../Schema/Dto/Constraints/Internal.php | 57 ++++
.../Schema/Dto/Constraints/Reference.php | 83 +++++
.../Schema/Dto/ElementDiffAwareInterface.php | 25 ++
.../Declaration/Schema/Dto/ElementFactory.php | 47 +++
.../Schema/Dto/ElementInterface.php | 37 ++
.../Schema/Dto/ElementRenamedInterface.php | 20 ++
.../Declaration/Schema/Dto/GenericElement.php | 62 ++++
.../Model/Declaration/Schema/Dto/Index.php | 72 ++++
.../Declaration/Schema/Dto/Structure.php | 72 ++++
.../Schema/Dto/StructureFactory.php | 45 +++
.../Model/Declaration/Schema/Dto/Table.php | 188 +++++++++++
.../Schema/Dto/TableElementInterface.php | 21 ++
.../Declaration/Schema/FileSystem/Csv.php | 79 +++++
.../Declaration/Schema/FileSystem/Reader.php | 61 ++++
.../Model/Declaration/Schema/Request.php | 43 +++
.../Declaration/Schema/RequestFactory.php | 48 +++
.../Schema/SchemaParserInterface.php | 23 ++
.../Model/Declaration/Schema/Sharding.php | 51 +++
.../Declaration/Schema/Xml/Converter.php | 138 ++++++++
.../Declaration/Schema/Xml/SchemaLocator.php | 59 ++++
.../Schema/config/constraints/constraint.xsd | 15 +
.../Schema/config/constraints/foreign.xsd | 40 +++
.../Schema/config/constraints/primary.xsd | 30 ++
.../Schema/config/constraints/unique.xsd | 28 ++
.../Model/Declaration/Schema/config/index.xsd | 36 ++
.../Declaration/Schema/config/operations.xsd | 25 ++
.../Declaration/Schema/config/schema.xsd | 67 ++++
.../Schema/config/types/binaries/blob.xsd | 28 ++
.../Schema/config/types/binaries/longblob.xsd | 28 ++
.../config/types/binaries/mediumblob.xsd | 28 ++
.../config/types/binaries/varbinary.xsd | 29 ++
.../Schema/config/types/boolean.xsd | 15 +
.../Schema/config/types/column.xsd | 15 +
.../Schema/config/types/datetime/date.xsd | 22 ++
.../Schema/config/types/datetime/datetime.xsd | 26 ++
.../Schema/config/types/datetime/default.xsd | 53 +++
.../config/types/datetime/timestamp.xsd | 28 ++
.../Schema/config/types/decimals/decimal.xsd | 42 +++
.../Schema/config/types/decimals/double.xsd | 39 +++
.../Schema/config/types/decimals/float.xsd | 23 ++
.../config/types/integers/biginteger.xsd | 16 +
.../Schema/config/types/integers/integer.xsd | 26 ++
.../config/types/integers/smallinteger.xsd | 23 ++
.../config/types/integers/tinyinteger.xsd | 16 +
.../Schema/config/types/texts/longtext.xsd | 27 ++
.../Schema/config/types/texts/mediumtext.xsd | 29 ++
.../Schema/config/types/texts/text.xsd | 29 ++
.../Schema/config/types/texts/varchar.xsd | 30 ++
setup/src/Magento/Setup/Model/Installer.php | 12 +-
.../Magento/Setup/Model/InstallerFactory.php | 7 +-
.../Setup/Test/Unit/Model/InstallerTest.php | 2 +
setup/src/Magento/Setup/registration.php | 9 +
152 files changed, 7620 insertions(+), 191 deletions(-)
create mode 100644 dev/tests/error_handler.php
create mode 100644 dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/Setup/InstallSchema.php
create mode 100644 dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/etc/module.xml
create mode 100644 dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/etc/schema.xml
create mode 100644 dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/foreign_key_interpreter_result.php
create mode 100644 dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/valid_xml_revision_1.php
create mode 100644 dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/registration.php
create mode 100644 dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/fail_on_column_declaration/schema.xml
create mode 100644 dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/fail_on_unique_key_declaration/schema.xml
create mode 100644 dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/foreign_key_interpreter/schema.xml
create mode 100644 dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/old_diff/InstallSchema.php
create mode 100644 dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/old_diff/schema.xml
rename dev/tests/setup-integration/{config => etc}/config-global.php.dist (99%)
rename dev/tests/setup-integration/{config => etc}/install-config-mysql.php.dist (98%)
create mode 100644 dev/tests/setup-integration/framework/Magento/TestFramework/Annotation/CopyModules.php
create mode 100644 dev/tests/setup-integration/framework/Magento/TestFramework/Annotation/DataProviderFromFile.php
create mode 100644 dev/tests/setup-integration/framework/Magento/TestFramework/Annotation/SchemaFixture.php
create mode 100644 dev/tests/setup-integration/framework/Magento/TestFramework/Deploy/ParametersHolder.php
create mode 100644 dev/tests/setup-integration/framework/Magento/TestFramework/TestCase/MutableDataInterface.php
create mode 100644 dev/tests/setup-integration/framework/Magento/TestFramework/TestCase/SetupTestCase.php
create mode 100644 dev/tests/setup-integration/framework/Magento/TestFramework/Workaround/DeploymentConfig.php
create mode 100644 dev/tests/setup-integration/testsuite/Magento/Setup/DeclarativeSchemaBuilderTest.php
create mode 100644 dev/tests/setup-integration/testsuite/Magento/Setup/DiffOldSchemaTest.php
create mode 100644 dev/tests/setup-integration/testsuite/Magento/Setup/SchemaReaderTest.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Casters/Base.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Casters/Biginteger.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Casters/Boolean.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Casters/CasterAggregator.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Casters/CasterInterface.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Casters/Date.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Casters/Decimal.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Casters/Foreign.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Casters/Integer.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Casters/Primary.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Casters/Smallinteger.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Casters/Timestamp.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Casters/Tinyinteger.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/ChangeProcessorInterface.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/ChangeRegistry.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/ChangeRegistryFactory.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/ChangeRegistryInterface.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Comparator.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Db/AdapterMediator.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Db/Parser.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/DbSchemaProcessorInterface.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/DbSchemaReaderInterface.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Basic.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Boolean.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Decimal.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Integer.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/OnUpdate.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Text.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Timestamp.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Unsigned.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Varchar.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Constraints/ForeignKey.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Constraints/Internal.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/DbSchemaReader.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Index.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Db/StructureBuilder.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/DynamicStructureInterface.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/Parser.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/Structure/Dynamic.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/StructureBuilder.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Diff/DiffManager.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Diff/StructureDiff.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Diff/TableDiff.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/DiffInterface.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Column.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Blob.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Boolean.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Date.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Decimal.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Integer.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Text.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Timestamp.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Varbinary.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Varchar.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Constraint.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Constraints/Internal.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Constraints/Reference.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Dto/ElementDiffAwareInterface.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Dto/ElementFactory.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Dto/ElementInterface.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Dto/ElementRenamedInterface.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Dto/GenericElement.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Index.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Structure.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Dto/StructureFactory.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Table.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Dto/TableElementInterface.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/FileSystem/Csv.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/FileSystem/Reader.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Request.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/RequestFactory.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/SchemaParserInterface.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Sharding.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Xml/Converter.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Xml/SchemaLocator.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/config/constraints/constraint.xsd
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/config/constraints/foreign.xsd
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/config/constraints/primary.xsd
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/config/constraints/unique.xsd
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/config/index.xsd
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/config/operations.xsd
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/config/schema.xsd
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/config/types/binaries/blob.xsd
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/config/types/binaries/longblob.xsd
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/config/types/binaries/mediumblob.xsd
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/config/types/binaries/varbinary.xsd
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/config/types/boolean.xsd
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/config/types/column.xsd
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/config/types/datetime/date.xsd
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/config/types/datetime/datetime.xsd
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/config/types/datetime/default.xsd
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/config/types/datetime/timestamp.xsd
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/config/types/decimals/decimal.xsd
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/config/types/decimals/double.xsd
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/config/types/decimals/float.xsd
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/config/types/integers/biginteger.xsd
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/config/types/integers/integer.xsd
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/config/types/integers/smallinteger.xsd
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/config/types/integers/tinyinteger.xsd
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/config/types/texts/longtext.xsd
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/config/types/texts/mediumtext.xsd
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/config/types/texts/text.xsd
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/config/types/texts/varchar.xsd
create mode 100644 setup/src/Magento/Setup/registration.php
diff --git a/app/etc/di.xml b/app/etc/di.xml
index 41dc0e5a48aba..1c188f8b82dab 100755
--- a/app/etc/di.xml
+++ b/app/etc/di.xml
@@ -173,7 +173,9 @@
+
+
@@ -1347,4 +1349,78 @@
+
+
+
+ - \Magento\Setup\Model\Declaration\Schema\Dto\Table
+ - \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Decimal
+ - \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Decimal
+ - \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Decimal
+ - \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Integer
+ - \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Integer
+ - \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Integer
+ - \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Integer
+ - \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Date
+ - \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Timestamp
+ - \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Timestamp
+ - \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Text
+ - \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Text
+ - \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Text
+ - \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Varchar
+ - \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Varbinary
+ - \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Blob
+ - \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Blob
+ - \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Blob
+ - \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Boolean
+ - \Magento\Setup\Model\Declaration\Schema\Dto\Constraints\Internal
+ - \Magento\Setup\Model\Declaration\Schema\Dto\Constraints\Internal
+ - \Magento\Setup\Model\Declaration\Schema\Dto\Constraints\Reference
+ - \Magento\Setup\Model\Declaration\Schema\Dto\Index
+
+
+
+
+
+
+ - \Magento\Setup\Model\Declaration\Schema\Casters\Base
+ - \Magento\Setup\Model\Declaration\Schema\Casters\Decimal
+ - \Magento\Setup\Model\Declaration\Schema\Casters\Decimal
+ - \Magento\Setup\Model\Declaration\Schema\Casters\Decimal
+ - \Magento\Setup\Model\Declaration\Schema\Casters\Smallinteger
+ - \Magento\Setup\Model\Declaration\Schema\Casters\Tinyinteger
+ - \Magento\Setup\Model\Declaration\Schema\Casters\Biginteger
+ - \Magento\Setup\Model\Declaration\Schema\Casters\Integer
+ - \Magento\Setup\Model\Declaration\Schema\Casters\Timestamp
+ - \Magento\Setup\Model\Declaration\Schema\Casters\Timestamp
+ - \Magento\Setup\Model\Declaration\Schema\Casters\Boolean
+ - \Magento\Setup\Model\Declaration\Schema\Casters\Foreign
+ - \Magento\Setup\Model\Declaration\Schema\Casters\Primary
+ - \Magento\Setup\Model\Declaration\Schema\Casters\Date
+
+
+
+
+
+
+ -
+
- \Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL\Columns\Basic
+ - \Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL\Columns\Integer
+ - \Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL\Columns\Decimal
+ - \Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL\Columns\Text
+ - \Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL\Columns\Timestamp
+ - \Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL\Columns\Varchar
+ - \Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL\Columns\OnUpdate
+
+ -
+
- \Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL\Index
+
+ -
+
- \Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL\Constraints\ForeignKey
+
+ -
+
- \Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL\Constraints\Internal
+
+
+
+
diff --git a/app/etc/registration_globlist.php b/app/etc/registration_globlist.php
index bd4a26d332239..23caae00cb303 100644
--- a/app/etc/registration_globlist.php
+++ b/app/etc/registration_globlist.php
@@ -15,4 +15,5 @@
'app/i18n/*/*/registration.php',
'lib/internal/*/*/registration.php',
'lib/internal/*/*/*/registration.php',
+ 'setup/src/*/*/registration.php'
];
diff --git a/dev/tests/error_handler.php b/dev/tests/error_handler.php
new file mode 100644
index 0000000000000..ba9b8e25750ad
--- /dev/null
+++ b/dev/tests/error_handler.php
@@ -0,0 +1,42 @@
+ 'Error',
+ E_WARNING => 'Warning',
+ E_PARSE => 'Parse',
+ E_NOTICE => 'Notice',
+ E_CORE_ERROR => 'Core Error',
+ E_CORE_WARNING => 'Core Warning',
+ E_COMPILE_ERROR => 'Compile Error',
+ E_COMPILE_WARNING => 'Compile Warning',
+ E_USER_ERROR => 'User Error',
+ E_USER_WARNING => 'User Warning',
+ E_USER_NOTICE => 'User Notice',
+ E_STRICT => 'Strict',
+ E_RECOVERABLE_ERROR => 'Recoverable Error',
+ E_DEPRECATED => 'Deprecated',
+ E_USER_DEPRECATED => 'User Deprecated',
+ ];
+
+ $errName = isset($errorNames[$errNo]) ? $errorNames[$errNo] : "";
+
+ throw new \PHPUnit\Framework\Exception(
+ sprintf("%s: %s in %s:%s.", $errName, $errStr, $errFile, $errLine),
+ $errNo
+ );
+ }
+ }
+ );
+}
diff --git a/dev/tests/integration/framework/Magento/TestFramework/Application.php b/dev/tests/integration/framework/Magento/TestFramework/Application.php
index a5eacc54f6921..0193c68681f4c 100644
--- a/dev/tests/integration/framework/Magento/TestFramework/Application.php
+++ b/dev/tests/integration/framework/Magento/TestFramework/Application.php
@@ -135,6 +135,16 @@ class Application
*/
protected $dumpDb = true;
+ /**
+ * @var bool
+ */
+ protected $canLoadArea = true;
+
+ /**
+ * @var bool
+ */
+ protected $canInstallSequence = true;
+
/**
* Constructor
*
@@ -287,32 +297,13 @@ public function isInstalled()
}
/**
- * Initialize application
+ * Create logger instance and rewrite already exist one in ObjectManager
*
- * @param array $overriddenParams
- * @return void
+ * @return \Psr\Log\LoggerInterface
*/
- public function initialize($overriddenParams = [])
+ private function initLogger()
{
- $overriddenParams[\Magento\Framework\App\State::PARAM_MODE] = $this->_appMode;
- $overriddenParams = $this->_customizeParams($overriddenParams);
- $directories = isset($overriddenParams[\Magento\Framework\App\Bootstrap::INIT_PARAM_FILESYSTEM_DIR_PATHS])
- ? $overriddenParams[\Magento\Framework\App\Bootstrap::INIT_PARAM_FILESYSTEM_DIR_PATHS]
- : [];
- $directoryList = new DirectoryList(BP, $directories);
- /** @var \Magento\TestFramework\ObjectManager $objectManager */
$objectManager = Helper\Bootstrap::getObjectManager();
- if (!$objectManager) {
- $objectManager = $this->_factory->create($overriddenParams);
- $objectManager->addSharedInstance($directoryList, \Magento\Framework\App\Filesystem\DirectoryList::class);
- $objectManager->addSharedInstance($directoryList, \Magento\Framework\Filesystem\DirectoryList::class);
- } else {
- $objectManager = $this->_factory->restore($objectManager, $directoryList, $overriddenParams);
- }
- /** @var \Magento\TestFramework\App\Filesystem $filesystem */
- $filesystem = $objectManager->get(\Magento\TestFramework\App\Filesystem::class);
- $objectManager->removeSharedInstance(\Magento\Framework\Filesystem::class);
- $objectManager->addSharedInstance($filesystem, \Magento\Framework\Filesystem::class);
/** @var \Psr\Log\LoggerInterface $logger */
$logger = $objectManager->create(
\Magento\TestFramework\ErrorLog\Logger::class,
@@ -336,11 +327,44 @@ public function initialize($overriddenParams = [])
]
]
);
+
$objectManager->removeSharedInstance(\Magento\Framework\Logger\Monolog::class);
$objectManager->addSharedInstance($logger, \Magento\Framework\Logger\Monolog::class);
+ return $logger;
+ }
+
+ /**
+ * Initialize application
+ *
+ * @param array $overriddenParams
+ * @return void
+ */
+ public function initialize($overriddenParams = [])
+ {
+ $overriddenParams[\Magento\Framework\App\State::PARAM_MODE] = $this->_appMode;
+ $overriddenParams = $this->_customizeParams($overriddenParams);
+ $directories = isset($overriddenParams[\Magento\Framework\App\Bootstrap::INIT_PARAM_FILESYSTEM_DIR_PATHS])
+ ? $overriddenParams[\Magento\Framework\App\Bootstrap::INIT_PARAM_FILESYSTEM_DIR_PATHS]
+ : [];
+ $directoryList = new DirectoryList(BP, $directories);
+ /** @var \Magento\TestFramework\ObjectManager $objectManager */
+ $objectManager = Helper\Bootstrap::getObjectManager();
+ if (!$objectManager) {
+ $objectManager = $this->_factory->create($overriddenParams);
+ $objectManager->addSharedInstance($directoryList, \Magento\Framework\App\Filesystem\DirectoryList::class);
+ $objectManager->addSharedInstance($directoryList, \Magento\Framework\Filesystem\DirectoryList::class);
+ } else {
+ $objectManager = $this->_factory->restore($objectManager, $directoryList, $overriddenParams);
+ }
+ /** @var \Magento\TestFramework\App\Filesystem $filesystem */
+ $filesystem = $objectManager->get(\Magento\TestFramework\App\Filesystem::class);
+ $objectManager->removeSharedInstance(\Magento\Framework\Filesystem::class);
+ $objectManager->addSharedInstance($filesystem, \Magento\Framework\Filesystem::class);
+ Helper\Bootstrap::setObjectManager($objectManager);
+ $this->initLogger();
$sequenceBuilder = $objectManager->get(\Magento\TestFramework\Db\Sequence\Builder::class);
$objectManager->addSharedInstance($sequenceBuilder, \Magento\SalesSequence\Model\Builder::class);
- Helper\Bootstrap::setObjectManager($objectManager);
+
$objectManagerConfiguration = [
'preferences' => [
\Magento\Framework\App\State::class => \Magento\TestFramework\App\State::class,
@@ -378,16 +402,24 @@ public function initialize($overriddenParams = [])
]
]
);
- $this->loadArea(\Magento\TestFramework\Application::DEFAULT_APP_AREA);
+
+ if ($this->canLoadArea) {
+ $this->loadArea(\Magento\TestFramework\Application::DEFAULT_APP_AREA);
+ }
+
\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->configure(
$objectManager->get(\Magento\Framework\ObjectManager\DynamicConfigInterface::class)->getConfiguration()
);
\Magento\Framework\Phrase::setRenderer(
$objectManager->get(\Magento\Framework\Phrase\Renderer\Placeholder::class)
);
- /** @var \Magento\TestFramework\Db\Sequence $sequence */
- $sequence = $objectManager->get(\Magento\TestFramework\Db\Sequence::class);
- $sequence->generateSequences();
+
+ if ($this->canInstallSequence) {
+ /** @var \Magento\TestFramework\Db\Sequence $sequence */
+ $sequence = $objectManager->get(\Magento\TestFramework\Db\Sequence::class);
+ $sequence->generateSequences();
+ }
+
$objectManager->create(\Magento\TestFramework\Config::class, ['configPath' => $this->globalConfigFile])
->rewriteAdditionalConfig();
}
diff --git a/dev/tests/setup-integration/.gitignore b/dev/tests/setup-integration/.gitignore
index bb6021b884ee1..fcf4d47527542 100644
--- a/dev/tests/setup-integration/.gitignore
+++ b/dev/tests/setup-integration/.gitignore
@@ -1,3 +1,4 @@
/*.xml
/var/
/etc/*.php
+/tmp
diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/Setup/InstallSchema.php b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/Setup/InstallSchema.php
new file mode 100644
index 0000000000000..2e4d64b0fcf6c
--- /dev/null
+++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/Setup/InstallSchema.php
@@ -0,0 +1,28 @@
+startSetup();
+ $installer->endSetup();
+ }
+}
diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/etc/module.xml b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/etc/module.xml
new file mode 100644
index 0000000000000..5d408109ff1ee
--- /dev/null
+++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/etc/module.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/etc/schema.xml b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/etc/schema.xml
new file mode 100644
index 0000000000000..1414cbcc1b99c
--- /dev/null
+++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/etc/schema.xml
@@ -0,0 +1,45 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/foreign_key_interpreter_result.php b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/foreign_key_interpreter_result.php
new file mode 100644
index 0000000000000..a3ec00b318467
--- /dev/null
+++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/foreign_key_interpreter_result.php
@@ -0,0 +1,53 @@
+ [
+ 'reference_table' => [
+ 'column' => [
+ 'tinyint_ref' => [
+ 'type' => 'tinyinteger',
+ 'name' => 'tinyint_ref',
+ 'default' => 0,
+ 'padding' => '7',
+ 'nullable' => true,
+ 'unsigned' => false,
+ 'disabled' => false,
+ ],
+ ],
+ 'name' => 'reference_table',
+ 'resource' => 'sales',
+ ],
+ 'test_table' => [
+ 'column' => [
+ 'tinyint' => [
+ 'type' => 'tinyinteger',
+ 'name' => 'tinyint',
+ 'default' => 0,
+ 'padding' => '7',
+ 'nullable' => true,
+ 'unsigned' => false,
+ 'disabled' => false,
+ ],
+ ],
+ 'constraint' => [
+ 'some_foreign_key' => [
+ 'type' => 'foreign',
+ 'name' => 'some_foreign_key',
+ 'column' => 'tinyint',
+ 'table' => 'test_table',
+ 'referenceTable' => 'reference_table',
+ 'referenceColumn' => 'tinyint_ref',
+ 'nullable' => true,
+ 'unsigned' => false,
+ 'disabled' => false,
+ 'onDelete' => 'CASCADE',
+ ],
+ ],
+ 'name' => 'test_table',
+ 'resource' => 'sales',
+ ],
+ ],
+];
diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/valid_xml_revision_1.php b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/valid_xml_revision_1.php
new file mode 100644
index 0000000000000..416b4b6f42a6e
--- /dev/null
+++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/valid_xml_revision_1.php
@@ -0,0 +1,212 @@
+ [
+ 'reference_table' => [
+ 'column' => [
+ 'tinyint_ref' =>
+ [
+ 'type' => 'tinyinteger',
+ 'name' => 'tinyint_ref',
+ 'renameTo' => 'tinyintref_2',
+ 'default' => 0,
+ 'padding' => '7',
+ 'nullable' => true,
+ 'unsigned' => false,
+ 'disabled' => false,
+ ],
+ ],
+ 'constraint' => [
+ 'tinyint_primary' => [
+ 'column' => [
+ 'tinyint_ref' => 'tinyint_ref',
+ ],
+ 'type' => 'primary',
+ 'name' => 'PRIMARY',
+ 'nullable' => true,
+ 'unsigned' => false,
+ 'disabled' => false,
+ ],
+ ],
+ 'name' => 'reference_table',
+ 'resource' => 'sales',
+ ],
+ 'test_table' => [
+ 'column' => [
+ 'smallint' => [
+ 'type' => 'smallinteger',
+ 'name' => 'smallint',
+ 'default' => 0,
+ 'padding' => '3',
+ 'nullable' => true,
+ 'unsigned' => false,
+ 'disabled' => false,
+ ],
+ 'tinyint' => [
+ 'type' => 'tinyinteger',
+ 'name' => 'tinyint',
+ 'default' => 0,
+ 'padding' => '7',
+ 'nullable' => true,
+ 'unsigned' => false,
+ 'disabled' => false,
+ ],
+ 'bigint' => [
+ 'type' => 'biginteger',
+ 'name' => 'bigint',
+ 'default' => 0,
+ 'padding' => '13',
+ 'nullable' => true,
+ 'unsigned' => false,
+ 'disabled' => false,
+ ],
+ 'float' => [
+ 'type' => 'float',
+ 'name' => 'float',
+ 'default' => 0.0,
+ 'scale' => '12',
+ 'nullable' => true,
+ 'unsigned' => false,
+ 'disabled' => false,
+ 'precission' => '10',
+ ],
+ 'double' => [
+ 'type' => 'double',
+ 'name' => 'double',
+ 'default' => 11111111.111111,
+ 'scale' => '245',
+ 'nullable' => true,
+ 'unsigned' => false,
+ 'disabled' => false,
+ 'precission' => '10',
+ ],
+ 'decimal' => [
+ 'type' => 'decimal',
+ 'name' => 'decimal',
+ 'default' => 0.0,
+ 'scale' => '15',
+ 'precission' => '4',
+ 'nullable' => true,
+ 'unsigned' => false,
+ 'disabled' => false,
+ ],
+ 'date' => [
+ 'type' => 'date',
+ 'name' => 'date',
+ ],
+ 'timestamp' => [
+ 'type' => 'timestamp',
+ 'name' => 'timestamp',
+ 'default' => 'CURRENT_TIMESTAMP',
+ 'on_update' => 'CURRENT_TIMESTAMP',
+ 'unsigned' => false,
+ 'disabled' => false,
+ ],
+ 'datetime' => [
+ 'type' => 'datetime',
+ 'name' => 'datetime',
+ 'default' => '0',
+ 'unsigned' => false,
+ 'disabled' => false,
+ ],
+ 'longtext' => [
+ 'type' => 'longtext',
+ 'name' => 'longtext',
+ 'length' => '111111111111',
+ 'nullable' => true,
+ 'unsigned' => false,
+ 'disabled' => false,
+ ],
+ 'mediumtext' => [
+ 'type' => 'mediumtext',
+ 'name' => 'mediumtext',
+ 'length' => '11222222',
+ 'nullable' => true,
+ 'unsigned' => false,
+ 'disabled' => false,
+ ],
+ 'varchar' => [
+ 'type' => 'varchar',
+ 'name' => 'varchar',
+ 'length' => '254',
+ 'nullable' => true,
+ 'unsigned' => false,
+ 'disabled' => false,
+ ],
+ 'mediumblob' => [
+ 'type' => 'mediumblob',
+ 'name' => 'mediumblob',
+ 'length' => '1122222',
+ 'nullable' => true,
+ 'unsigned' => false,
+ 'disabled' => false,
+ ],
+ 'blob' => [
+ 'type' => 'blob',
+ 'name' => 'blob',
+ 'length' => '1122',
+ 'nullable' => true,
+ 'unsigned' => false,
+ 'disabled' => false,
+ ],
+ 'boolean' => [
+ 'type' => 'boolean',
+ 'name' => 'boolean',
+ 'nullable' => true,
+ 'unsigned' => false,
+ 'disabled' => false,
+ 'default' => false,
+ ],
+ 'varbinary_rename' => [
+ 'type' => 'varbinary',
+ 'name' => 'varbinary_rename',
+ 'default' => '10101',
+ 'disabled' => true,
+ 'renameTo' => 'varbinary_renamed',
+ 'nullable' => true,
+ 'unsigned' => false,
+ ],
+ ],
+ 'constraint' => [
+ 'some_unique_key' => [
+ 'column' => [
+ 'smallint' => 'smallint',
+ 'bigint' => 'bigint',
+ ],
+ 'type' => 'unique',
+ 'name' => 'some_unique_key',
+ 'nullable' => true,
+ 'unsigned' => false,
+ 'disabled' => false,
+ ],
+ 'some_foreign_key' => [
+ 'type' => 'foreign',
+ 'name' => 'some_foreign_key',
+ 'column' => 'tinyint',
+ 'table' => 'test_table',
+ 'referenceTable' => 'reference_table',
+ 'referenceColumn' => 'tinyint_ref',
+ 'onDelete' => 'NO ACTION',
+ 'nullable' => true,
+ 'unsigned' => false,
+ 'disabled' => false,
+ ],
+ ],
+ 'index' => [
+ 'speedup_index' => [
+ 'column' => [
+ 'tinyint' => 'tinyint',
+ 'bigint' => 'bigint',
+ ],
+ 'name' => 'speedup_index',
+ 'type' => 'btree',
+ ],
+ ],
+ 'name' => 'test_table',
+ 'resource' => 'sales',
+ ],
+ ],
+];
diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/registration.php b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/registration.php
new file mode 100644
index 0000000000000..eddf29fbb7f8c
--- /dev/null
+++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/registration.php
@@ -0,0 +1,12 @@
+getPath(ComponentRegistrar::MODULE, 'Magento_TestSetupDeclarationModule1') === null) {
+ ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Magento_TestSetupDeclarationModule1', __DIR__);
+}
diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/fail_on_column_declaration/schema.xml b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/fail_on_column_declaration/schema.xml
new file mode 100644
index 0000000000000..7a298c0e58824
--- /dev/null
+++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/fail_on_column_declaration/schema.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/fail_on_unique_key_declaration/schema.xml b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/fail_on_unique_key_declaration/schema.xml
new file mode 100644
index 0000000000000..6e462a0b0dece
--- /dev/null
+++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/fail_on_unique_key_declaration/schema.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/foreign_key_interpreter/schema.xml b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/foreign_key_interpreter/schema.xml
new file mode 100644
index 0000000000000..cc2a39a88e72c
--- /dev/null
+++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/foreign_key_interpreter/schema.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/old_diff/InstallSchema.php b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/old_diff/InstallSchema.php
new file mode 100644
index 0000000000000..faafc92683a69
--- /dev/null
+++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/old_diff/InstallSchema.php
@@ -0,0 +1,119 @@
+startSetup();
+
+ //Create first table
+ $table = $installer->getConnection()
+ ->newTable($installer->getTable('reference_table'))
+ ->addColumn(
+ 'smallint_ref',
+ \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT,
+ 3,
+ ['primary' => true, 'identity' => true, 'nullable' => false],
+ 'Value ID'
+ )
+ ->setComment('Reference table');
+ $installer->getConnection()->createTable($table);
+
+ $testTable = $installer->getConnection()->newTable('test_table')
+ ->addColumn(
+ 'smallint',
+ \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT,
+ 2,
+ ['nullable' => true, 'default' => 0],
+ 'Value ID'
+ )
+ ->addColumn(
+ 'bigint',
+ \Magento\Framework\DB\Ddl\Table::TYPE_BIGINT,
+ 10,
+ ['nullable' => true, 'unsigned' => false, 'default' => 0],
+ 'Value ID'
+ )
+ ->addColumn(
+ 'float',
+ \Magento\Framework\DB\Ddl\Table::TYPE_FLOAT,
+ '12,0',
+ ['default' => 0],
+ 'Value ID'
+ )
+ ->addColumn(
+ 'date',
+ \Magento\Framework\DB\Ddl\Table::TYPE_DATE,
+ null,
+ [],
+ 'Value ID'
+ )
+ ->addColumn(
+ 'timestamp',
+ \Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP,
+ null,
+ ['default' => \Magento\Framework\DB\Ddl\Table::TIMESTAMP_INIT_UPDATE],
+ 'Value ID'
+ )
+ ->addColumn(
+ 'mediumtext',
+ \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
+ 11222222,
+ [],
+ 'Value ID'
+ )
+ ->addColumn(
+ 'varchar',
+ \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
+ 254,
+ ['nullable' => true],
+ 'Value ID'
+ )
+ ->addColumn(
+ 'boolean',
+ \Magento\Framework\DB\Ddl\Table::TYPE_BOOLEAN,
+ 1,
+ [],
+ 'Value ID'
+ )
+ ->addIndex(
+ 'some_unique_key',
+ ['smallint', 'bigint'],
+ ['type' => \Magento\Framework\DB\Adapter\Pdo\Mysql::INDEX_TYPE_UNIQUE]
+ )
+ ->addIndex(
+ 'speedup_index',
+ ['bigint']
+ )
+ ->addForeignKey(
+ 'some_foreign_key',
+ 'smallint',
+ $installer->getTable('reference_table'),
+ 'smallint_ref',
+ \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE
+ )
+ ->setComment('Test Table');
+ $installer->getConnection()->createTable($testTable);
+
+ $installer->endSetup();
+ }
+}
diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/old_diff/schema.xml b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/old_diff/schema.xml
new file mode 100644
index 0000000000000..9289d3dcdc223
--- /dev/null
+++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/old_diff/schema.xml
@@ -0,0 +1,36 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dev/tests/setup-integration/config/config-global.php.dist b/dev/tests/setup-integration/etc/config-global.php.dist
similarity index 99%
rename from dev/tests/setup-integration/config/config-global.php.dist
rename to dev/tests/setup-integration/etc/config-global.php.dist
index cd5cfab35fba2..fb82fa5c0695a 100644
--- a/dev/tests/setup-integration/config/config-global.php.dist
+++ b/dev/tests/setup-integration/etc/config-global.php.dist
@@ -3,5 +3,4 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-
return [];
diff --git a/dev/tests/setup-integration/config/install-config-mysql.php.dist b/dev/tests/setup-integration/etc/install-config-mysql.php.dist
similarity index 98%
rename from dev/tests/setup-integration/config/install-config-mysql.php.dist
rename to dev/tests/setup-integration/etc/install-config-mysql.php.dist
index dfe91c1c1a7f7..dab013cb04a1d 100644
--- a/dev/tests/setup-integration/config/install-config-mysql.php.dist
+++ b/dev/tests/setup-integration/etc/install-config-mysql.php.dist
@@ -15,5 +15,5 @@ return [
'admin-password' => \Magento\TestFramework\Bootstrap::ADMIN_PASSWORD,
'admin-email' => \Magento\TestFramework\Bootstrap::ADMIN_EMAIL,
'admin-firstname' => \Magento\TestFramework\Bootstrap::ADMIN_FIRSTNAME,
- 'admin-lastname' => \Magento\TestFramework\Bootstrap::ADMIN_LASTNAME,
+ 'admin-lastname' => \Magento\TestFramework\Bootstrap::ADMIN_LASTNAME
];
diff --git a/dev/tests/setup-integration/framework/Magento/TestFramework/Annotation/CopyModules.php b/dev/tests/setup-integration/framework/Magento/TestFramework/Annotation/CopyModules.php
new file mode 100644
index 0000000000000..1c5b37e4ca08d
--- /dev/null
+++ b/dev/tests/setup-integration/framework/Magento/TestFramework/Annotation/CopyModules.php
@@ -0,0 +1,51 @@
+moduleManager = new TestModuleManager();
+ $this->cliCommand = new CliCommand($this->moduleManager);
+ }
+
+ /**
+ * Handler for 'startTest' event
+ *
+ * @param \PHPUnit\Framework\TestCase $test
+ * @throws \Magento\Framework\Exception\LocalizedException
+ */
+ public function startTest(\PHPUnit\Framework\TestCase $test)
+ {
+ $annotations = $test->getAnnotations();
+ //This annotation can be declared only on method level
+ if (isset($annotations['method']['moduleName'])) {
+ $this->cliCommand->introduceModule($annotations['method']['moduleName'][0]);
+ }
+ }
+}
diff --git a/dev/tests/setup-integration/framework/Magento/TestFramework/Annotation/DataProviderFromFile.php b/dev/tests/setup-integration/framework/Magento/TestFramework/Annotation/DataProviderFromFile.php
new file mode 100644
index 0000000000000..ee0f5d2514276
--- /dev/null
+++ b/dev/tests/setup-integration/framework/Magento/TestFramework/Annotation/DataProviderFromFile.php
@@ -0,0 +1,64 @@
+moduleManager = new TestModuleManager();
+ $this->cliCommand = new CliCommand($this->moduleManager);
+ }
+
+ /**
+ * @param \PHPUnit\Framework\TestCase $test
+ * @throws \Exception
+ */
+ public function startTest(\PHPUnit\Framework\TestCase $test)
+ {
+ $annotations = $test->getAnnotations();
+ //This annotation can be declared only on method level
+ if (isset($annotations['method']['dataProviderFromFile']) && $test instanceof MutableDataInterface) {
+ $data = include TESTS_MODULES_PATH . "/" . $annotations['method']['dataProviderFromFile'][0];
+ $test->setData($data);
+ } else if (!$test instanceof MutableDataInterface) {
+ throw new \Exception("Test type do not supports @dataProviderFromFile annotation");
+ }
+ }
+
+ /**
+ * @param \PHPUnit\Framework\TestCase $test
+ * @throws \Exception
+ */
+ public function endTest(\PHPUnit\Framework\TestCase $test)
+ {
+ if ($test instanceof MutableDataInterface) {
+ $test->flushData();
+ }
+ }
+}
diff --git a/dev/tests/setup-integration/framework/Magento/TestFramework/Annotation/ReinstallInstance.php b/dev/tests/setup-integration/framework/Magento/TestFramework/Annotation/ReinstallInstance.php
index 23097ba529300..5e53bbf637123 100644
--- a/dev/tests/setup-integration/framework/Magento/TestFramework/Annotation/ReinstallInstance.php
+++ b/dev/tests/setup-integration/framework/Magento/TestFramework/Annotation/ReinstallInstance.php
@@ -30,29 +30,12 @@ public function __construct(\Magento\TestFramework\Application $application)
/**
* Handler for 'endTest' event
*
- * @param \PHPUnit\Framework\TestCase $test
* @throws \Magento\Framework\Exception\LocalizedException
*/
- public function endTest(\PHPUnit\Framework\TestCase $test)
+ public function endTest()
{
- $this->_hasNonIsolatedTests = true;
-
- /* Determine an isolation from doc comment */
- $annotations = $test->getAnnotations();
- $annotations = array_replace((array) $annotations['class'], (array) $annotations['method']);
- $isIsolationEnabled = false;
- if (isset($annotations['reinstallMagento'])) {
- $isolation = $annotations['reinstallMagento'];
- if ($isolation !== ['enabled'] && $isolation !== ['disabled']) {
- throw new \Magento\Framework\Exception\LocalizedException(
- __('Invalid "@reinstallMagento" annotation, can be "enabled" or "disabled" only.')
- );
- }
- $isIsolationEnabled = $isolation === ['enabled'];
- }
- if ($isIsolationEnabled && $this->application->isInstalled()) {
+ if ($this->application->isInstalled()) {
$this->application->cleanup();
- $this->application->install();
}
}
}
diff --git a/dev/tests/setup-integration/framework/Magento/TestFramework/Annotation/SchemaFixture.php b/dev/tests/setup-integration/framework/Magento/TestFramework/Annotation/SchemaFixture.php
new file mode 100644
index 0000000000000..f270dda133d5e
--- /dev/null
+++ b/dev/tests/setup-integration/framework/Magento/TestFramework/Annotation/SchemaFixture.php
@@ -0,0 +1,181 @@
+_fixtureBaseDir = realpath($fixtureBaseDir);
+ }
+
+ /**
+ * Apply magento data fixture on
+ *
+ * @param \PHPUnit\Framework\TestCase $test
+ * @return void
+ */
+ public function startTest(\PHPUnit\Framework\TestCase $test)
+ {
+ if ($this->_getFixtures($test)) {
+ $this->_applyFixtures($this->_getFixtures($test));
+ }
+ }
+
+ /**
+ * @param \PHPUnit\Framework\TestCase $test
+ */
+ public function endTest(\PHPUnit\Framework\TestCase $test)
+ {
+ if ($this->_getFixtures($test)) {
+ $this->_revertFixtures();
+ }
+ }
+
+ /**
+ * Retrieve fixtures from annotation
+ *
+ * @param \PHPUnit\Framework\TestCase $test
+ * @param string $scope
+ * @return array
+ * @throws \Magento\Framework\Exception\LocalizedException
+ */
+ protected function _getFixtures(\PHPUnit\Framework\TestCase $test, $scope = null)
+ {
+ if ($scope === null) {
+ $annotations = $this->getAnnotations($test);
+ } else {
+ $annotations = $test->getAnnotations()[$scope];
+ }
+ $result = [];
+ if (!empty($annotations['magentoSchemaFixture'])) {
+ foreach ($annotations['magentoSchemaFixture'] as $fixture) {
+ if (strpos($fixture, '\\') !== false) {
+ // usage of a single directory separator symbol streamlines search across the source code
+ throw new \Magento\Framework\Exception\LocalizedException(
+ new \Magento\Framework\Phrase('Directory separator "\\" is prohibited in fixture declaration.')
+ );
+ }
+ $fixtureMethod = [get_class($test), $fixture];
+ if (is_callable($fixtureMethod)) {
+ $result[] = $fixtureMethod;
+ } else {
+ $result[] = $this->_fixtureBaseDir . '/' . $fixture;
+ }
+ }
+ }
+ return $result;
+ }
+
+ /**
+ * @param \PHPUnit\Framework\TestCase $test
+ * @return array
+ */
+ private function getAnnotations(\PHPUnit\Framework\TestCase $test)
+ {
+ $annotations = $test->getAnnotations();
+ return array_replace($annotations['class'], $annotations['method']);
+ }
+
+ /**
+ * Execute single fixture script
+ *
+ * @param string|array $fixture
+ * @throws \Exception
+ */
+ protected function _applyOneFixture($fixture)
+ {
+ try {
+ if (is_callable($fixture)) {
+ call_user_func($fixture);
+ } else {
+ require $fixture;
+ }
+ } catch (\Exception $e) {
+ throw new \Exception(
+ sprintf("Error in fixture: %s.\n %s", json_encode($fixture), $e->getMessage()),
+ 500,
+ $e
+ );
+ }
+ }
+
+ /**
+ * Execute fixture scripts if any
+ *
+ * @param array $fixtures
+ * @throws \Magento\Framework\Exception\LocalizedException
+ */
+ protected function _applyFixtures(array $fixtures)
+ {
+ /* Execute fixture scripts */
+ foreach ($fixtures as $oneFixture) {
+ /* Skip already applied fixtures */
+ if (in_array($oneFixture, $this->_appliedFixtures, true)) {
+ continue;
+ }
+ $this->_applyOneFixture($oneFixture);
+ $this->_appliedFixtures[] = $oneFixture;
+ }
+ }
+
+ /**
+ * Revert changes done by fixtures
+ */
+ protected function _revertFixtures()
+ {
+ foreach ($this->_appliedFixtures as $fixture) {
+ if (is_callable($fixture)) {
+ $fixture[1] .= 'Rollback';
+ if (is_callable($fixture)) {
+ $this->_applyOneFixture($fixture);
+ }
+ } else {
+ $fileInfo = pathinfo($fixture);
+ $extension = '';
+ if (isset($fileInfo['extension'])) {
+ $extension = '.' . $fileInfo['extension'];
+ }
+ $rollbackScript = $fileInfo['dirname'] . '/' . $fileInfo['filename'] . '_rollback' . $extension;
+ if (file_exists($rollbackScript)) {
+ $this->_applyOneFixture($rollbackScript);
+ }
+ }
+ }
+ $this->_appliedFixtures = [];
+ }
+}
diff --git a/dev/tests/setup-integration/framework/Magento/TestFramework/Bootstrap/SetupDocBlock.php b/dev/tests/setup-integration/framework/Magento/TestFramework/Bootstrap/SetupDocBlock.php
index c04f6cbc56e0a..4ace776ec413e 100644
--- a/dev/tests/setup-integration/framework/Magento/TestFramework/Bootstrap/SetupDocBlock.php
+++ b/dev/tests/setup-integration/framework/Magento/TestFramework/Bootstrap/SetupDocBlock.php
@@ -26,24 +26,13 @@ protected function _getSubscribers(\Magento\TestFramework\Application $applicati
new \Magento\TestFramework\Workaround\Cleanup\TestCaseProperties(),
new \Magento\TestFramework\Workaround\Cleanup\StaticProperties(),
new \Magento\TestFramework\Isolation\WorkingDirectory(),
- new \Magento\TestFramework\Annotation\AppIsolation($application),
- new \Magento\TestFramework\Isolation\AppConfig(),
- new \Magento\TestFramework\Annotation\ConfigFixture(),
- new \Magento\TestFramework\Annotation\DataFixtureBeforeTransaction($this->_fixturesBaseDir),
- new \Magento\TestFramework\Event\Transaction(
- new \Magento\TestFramework\EventManager(
- [
- new \Magento\TestFramework\Annotation\DbIsolation(),
- new \Magento\TestFramework\Annotation\DataFixture($this->_fixturesBaseDir),
- ]
- )
- ),
+ new \Magento\TestFramework\Workaround\DeploymentConfig(),
new \Magento\TestFramework\Annotation\ComponentRegistrarFixture($this->_fixturesBaseDir),
- new \Magento\TestFramework\Annotation\AppArea($application),
+ new \Magento\TestFramework\Annotation\SchemaFixture($this->_fixturesBaseDir),
new \Magento\TestFramework\Annotation\Cache(),
- new \Magento\TestFramework\Annotation\AdminConfigFixture(),
- new \Magento\TestFramework\Annotation\ConfigFixture(),
- new \Magento\TestFramework\Annotation\ReinstallInstance($application)
+ new \Magento\TestFramework\Annotation\ReinstallInstance($application),
+ new \Magento\TestFramework\Annotation\CopyModules(),
+ new \Magento\TestFramework\Annotation\DataProviderFromFile()
];
}
}
diff --git a/dev/tests/setup-integration/framework/Magento/TestFramework/Deploy/CliCommand.php b/dev/tests/setup-integration/framework/Magento/TestFramework/Deploy/CliCommand.php
index 68cac224ce4cc..d56f6fff48021 100644
--- a/dev/tests/setup-integration/framework/Magento/TestFramework/Deploy/CliCommand.php
+++ b/dev/tests/setup-integration/framework/Magento/TestFramework/Deploy/CliCommand.php
@@ -5,7 +5,9 @@
*/
namespace Magento\TestFramework\Deploy;
-use Magento\Framework\App\Filesystem\DirectoryList;
+use Magento\Framework\Shell;
+use Magento\Framework\Shell\CommandRenderer;
+use Magento\Setup\Console\Command\InstallCommand;
/**
* The purpose of this class is enable/disable module and upgrade commands execution
@@ -18,27 +20,28 @@ class CliCommand
private $shell;
/**
- * @var array
+ * @var TestModuleManager
*/
- private $initParams;
+ private $testEnv;
/**
- * @var TestModuleManager
+ * @var ParametersHolder
*/
- private $testEnv;
+ private $parametersHolder;
/**
* ShellCommand constructor.
*
- * @param \Magento\Framework\Shell $shell
* @param TestModuleManager $testEnv
+ * @param ParametersHolder $paramatersHolder
+ * @internal param Shell $shell
*/
public function __construct(
- \Magento\Framework\Shell $shell,
\Magento\TestFramework\Deploy\TestModuleManager $testEnv
) {
- $this->shell = $shell;
+ $this->shell = new Shell(new CommandRenderer());
$this->testEnv = $testEnv;
+ $this->parametersHolder = new ParametersHolder();
}
/**
@@ -61,9 +64,9 @@ public function introduceModule($moduleName)
*/
public function enableModule($moduleName)
{
- $initParams = $this->getInitParams();
- $enableModuleCommand = 'php -f ' . BP . '/bin/magento module:enable Magento_' . $moduleName
- . ' -n -vvv --magento-init-params=' . $initParams;
+ $initParams = $this->parametersHolder->getInitParams();
+ $enableModuleCommand = 'php -f ' . BP . '/bin/magento module:enable ' . $moduleName
+ . ' -n -vvv --magento-init-params=' . $initParams['magento-init-params'];
return $this->shell->execute($enableModuleCommand);
}
@@ -74,7 +77,7 @@ public function enableModule($moduleName)
*/
public function upgrade()
{
- $initParams = $this->getInitParams();
+ $initParams = $this->parametersHolder->getInitParams();
$enableModuleCommand = 'php -f ' . BP . '/bin/magento setup:upgrade -vvv -n --magento-init-params='
. $initParams;
return $this->shell->execute($enableModuleCommand);
@@ -88,45 +91,58 @@ public function upgrade()
*/
public function disableModule($moduleName)
{
- $initParams = $this->getInitParams();
+ $initParams = $this->parametersHolder->getInitParams();
$disableModuleCommand = 'php -f ' . BP . '/bin/magento module:disable Magento_'. $moduleName
. ' -vvv --magento-init-params=' . $initParams;
return $this->shell->execute($disableModuleCommand);
}
/**
- * Return application initialization parameters
+ * Convert from raw params to CLI arguments, like --admin-username
*
+ * @param array $params
* @return array
*/
- private function getInitParams()
+ private function toCliArguments(array $params)
{
- if (!isset($this->initParams)) {
- $testsBaseDir = dirname(__DIR__);
- $settings = new \Magento\TestFramework\Bootstrap\Settings($testsBaseDir, get_defined_constants());
- $appMode = $settings->get('TESTS_MAGENTO_MODE');
- $customDirs = $this->getCustomDirs();
- $initParams = [
- \Magento\Framework\App\Bootstrap::INIT_PARAM_FILESYSTEM_DIR_PATHS => $customDirs,
- \Magento\Framework\App\State::PARAM_MODE => $appMode
- ];
- $this->initParams = urldecode(http_build_query($initParams));
+ $result = [];
+
+ foreach ($params as $key => $value) {
+ if (!empty($value)) {
+ $result["--{$key}=%s"] = $value;
+ }
}
- return $this->initParams;
+
+ return $result;
}
/**
- * Get customized directory paths
- *
- * @return array
+ * @param array $modules
+ * @throws \Exception
+ * @return string
*/
- private function getCustomDirs()
+ public function install(array $modules)
{
- $installDir = TESTS_TEMP_DIR;
- $path = DirectoryList::PATH;
- $customDirs = [
- DirectoryList::CONFIG => [$path => "{$installDir}/etc"],
+ if (empty($modules)) {
+ throw new \Exception("Cannot install Magento without modules");
+ }
+
+ $params = $this->parametersHolder->getInitParams();
+ $installParams = [
+ InstallCommand::INPUT_KEY_ENABLE_MODULES => implode(",", $modules),
+ InstallCommand::INPUT_KEY_DISABLE_MODULES => 'all'
];
- return $customDirs;
+ $installParams = $this->toCliArguments(
+ array_merge(
+ $params,
+ $installParams,
+ $this->parametersHolder->getDbData()
+ )
+ );
+ // run install script
+ return $this->shell->execute(
+ PHP_BINARY . ' -f %s setup:install -vvv ' . implode(' ', array_keys($installParams)),
+ array_merge([BP . '/bin/magento'], array_values($installParams))
+ );
}
}
diff --git a/dev/tests/setup-integration/framework/Magento/TestFramework/Deploy/ParametersHolder.php b/dev/tests/setup-integration/framework/Magento/TestFramework/Deploy/ParametersHolder.php
new file mode 100644
index 0000000000000..5cda61ea1440a
--- /dev/null
+++ b/dev/tests/setup-integration/framework/Magento/TestFramework/Deploy/ParametersHolder.php
@@ -0,0 +1,71 @@
+initParams)) {
+ $testsBaseDir = dirname(__DIR__);
+ $settings = new \Magento\TestFramework\Bootstrap\Settings($testsBaseDir, get_defined_constants());
+ $appMode = $settings->get('TESTS_MAGENTO_MODE');
+ $customDirs = $this->getCustomDirs();
+ $initParams = [
+ \Magento\Framework\App\Bootstrap::INIT_PARAM_FILESYSTEM_DIR_PATHS => $customDirs,
+ \Magento\Framework\App\State::PARAM_MODE => $appMode
+ ];
+ $this->initParams = ['magento-init-params' => urldecode(http_build_query($initParams))];
+ }
+ return $this->initParams;
+ }
+
+ /**
+ * Include data from config file and convert it to db format
+ * -db-name
+ * -db-user-name
+ * -db-password
+ * -db-host
+ *
+ * @return array
+ */
+ public function getDbData()
+ {
+ return include TESTS_INSTALL_CONFIG_FILE;
+ }
+
+ /**
+ * Get customized directory paths
+ *
+ * @return array
+ */
+ private function getCustomDirs()
+ {
+ $installDir = TESTS_TEMP_DIR;
+ $path = DirectoryList::PATH;
+ $customDirs = [
+ DirectoryList::CONFIG => [$path => "{$installDir}/etc"],
+ ];
+ return $customDirs;
+ }
+}
diff --git a/dev/tests/setup-integration/framework/Magento/TestFramework/Deploy/TestModuleManager.php b/dev/tests/setup-integration/framework/Magento/TestFramework/Deploy/TestModuleManager.php
index 78efab1cb9413..d2a69d745aa4f 100644
--- a/dev/tests/setup-integration/framework/Magento/TestFramework/Deploy/TestModuleManager.php
+++ b/dev/tests/setup-integration/framework/Magento/TestFramework/Deploy/TestModuleManager.php
@@ -10,6 +10,11 @@
*/
class TestModuleManager
{
+ /**
+ * Name of file of DB XML declaration
+ */
+ const DECLARATIVE_FILE_NAME = "schema.xml";
+
/**
* Add test module files to Magento code base
*
@@ -19,6 +24,7 @@ class TestModuleManager
*/
public function addModuleFiles($moduleName)
{
+ $moduleName = str_replace("Magento_", "", $moduleName);
$pathToCommittedTestModules = TESTS_MODULES_PATH . '/Magento/' . $moduleName;
$pathToInstalledMagentoInstanceModules = MAGENTO_MODULES_PATH . $moduleName;
$iterator = new \RecursiveIteratorIterator(
@@ -54,15 +60,38 @@ public function addModuleFiles($moduleName)
}
}
+ /**
+ * @param string $moduleName Like Magento_TestSetupModule
+ * @param string $revisionName Folder name, like reviisions/revision_1/schema.xml
+ * @param string $fileName For example schema.xml
+ * @param string $fileDir For example etc or Setup
+ */
+ public function updateRevision($moduleName, $revisionName, $fileName, $fileDir)
+ {
+ $modulePath = str_replace("Magento_", "", $moduleName);
+ $folder = MAGENTO_MODULES_PATH . $modulePath;
+ $oldFile = $folder . DIRECTORY_SEPARATOR . $fileDir . "/" . $fileName;
+ $revisionFile = MAGENTO_MODULES_PATH . $modulePath . "/revisions/" .
+ $revisionName . DIRECTORY_SEPARATOR . $fileName;
+
+ if (file_exists($oldFile) && file_exists($revisionFile)) {
+ unlink($oldFile);
+ rename($revisionFile, $oldFile);
+ } else {
+ throw new \InvalidArgumentException("Old File or revision files paths are invalid");
+ }
+ }
+
/**
* Remove test module files to Magento code base
*
* @param string $moduleName
* @return void
*/
- public function removeModuleFiles($moduleName)//add logic to remove every time and add ability to disable
+ public function removeModuleFiles($moduleName)
{
- $folder = MAGENTO_MODULES_PATH . $moduleName;
+ $modulePath = str_replace("Magento_", "", $moduleName);
+ $folder = MAGENTO_MODULES_PATH . $modulePath;
//remove test modules from magento codebase
if (is_dir($folder)) {
diff --git a/dev/tests/setup-integration/framework/Magento/TestFramework/SetupApplication.php b/dev/tests/setup-integration/framework/Magento/TestFramework/SetupApplication.php
index b2d84e7901fc7..cbacf82929587 100644
--- a/dev/tests/setup-integration/framework/Magento/TestFramework/SetupApplication.php
+++ b/dev/tests/setup-integration/framework/Magento/TestFramework/SetupApplication.php
@@ -5,6 +5,9 @@
*/
namespace Magento\TestFramework;
+use Magento\Framework\App\DesignInterface;
+use Magento\Framework\View\DesignExceptions;
+
/**
* Encapsulates application installation, initialization and uninstall, add flag to skip database dump
*
@@ -18,6 +21,16 @@ class SetupApplication extends Application
*/
protected $dumpDb = false;
+ /**
+ * @var bool
+ */
+ protected $canLoadArea = false;
+
+ /**
+ * @var bool
+ */
+ protected $canInstallSequence = false;
+
/**
* {@inheritdoc}
*/
diff --git a/dev/tests/setup-integration/framework/Magento/TestFramework/TestCase/MutableDataInterface.php b/dev/tests/setup-integration/framework/Magento/TestFramework/TestCase/MutableDataInterface.php
new file mode 100644
index 0000000000000..c2323975b8bc4
--- /dev/null
+++ b/dev/tests/setup-integration/framework/Magento/TestFramework/TestCase/MutableDataInterface.php
@@ -0,0 +1,35 @@
+data = $data;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function flushData()
+ {
+ $this->data = [];
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function getData()
+ {
+ return $this->data;
+ }
+}
diff --git a/dev/tests/setup-integration/framework/Magento/TestFramework/Workaround/DeploymentConfig.php b/dev/tests/setup-integration/framework/Magento/TestFramework/Workaround/DeploymentConfig.php
new file mode 100644
index 0000000000000..b5ac5a2867eca
--- /dev/null
+++ b/dev/tests/setup-integration/framework/Magento/TestFramework/Workaround/DeploymentConfig.php
@@ -0,0 +1,31 @@
+get(\Magento\Framework\App\DeploymentConfig::class);
+ $deploymentConfig->resetData();
+ }
+}
diff --git a/dev/tests/setup-integration/framework/bootstrap.php b/dev/tests/setup-integration/framework/bootstrap.php
index f960fd3d5ab2c..9bb76a8553b1f 100644
--- a/dev/tests/setup-integration/framework/bootstrap.php
+++ b/dev/tests/setup-integration/framework/bootstrap.php
@@ -8,10 +8,13 @@
require_once __DIR__ . '/../../../../app/bootstrap.php';
require_once __DIR__ . '/autoload.php';
+//to handle different types of errors on CI
+require __DIR__ . '/../../error_handler.php';
$testsBaseDir = dirname(__DIR__);
$integrationTestsDir = realpath("{$testsBaseDir}/../integration");
$fixtureBaseDir = $integrationTestsDir. '/testsuite';
+
if (!defined('TESTS_TEMP_DIR')) {
define('TESTS_TEMP_DIR', $testsBaseDir . '/tmp');
}
@@ -23,37 +26,28 @@
if (!defined('MAGENTO_MODULES_PATH')) {
define('MAGENTO_MODULES_PATH', __DIR__ . '/../../../../app/code/Magento/');
}
-try {
- setCustomErrorHandler();
-
- /* Bootstrap the application */
- $settings = new \Magento\TestFramework\Bootstrap\Settings($testsBaseDir, get_defined_constants());
-
- if ($settings->get('TESTS_EXTRA_VERBOSE_LOG')) {
- $filesystem = new \Magento\Framework\Filesystem\Driver\File();
- $exceptionHandler = new \Magento\Framework\Logger\Handler\Exception($filesystem);
- $loggerHandlers = [
- 'system' => new \Magento\Framework\Logger\Handler\System($filesystem, $exceptionHandler),
- 'debug' => new \Magento\Framework\Logger\Handler\Debug($filesystem)
- ];
- $shell = new \Magento\Framework\Shell(
- new \Magento\Framework\Shell\CommandRenderer(),
- new \Monolog\Logger('main', $loggerHandlers)
- );
- } else {
- $shell = new \Magento\Framework\Shell(new \Magento\Framework\Shell\CommandRenderer());
- }
+$settings = new \Magento\TestFramework\Bootstrap\Settings($testsBaseDir, get_defined_constants());
- $testFrameworkDir = __DIR__;
+if (!defined('TESTS_INSTALL_CONFIG_FILE')) {
$installConfigFile = $settings->getAsConfigFile('TESTS_INSTALL_CONFIG_FILE');
if (!file_exists($installConfigFile)) {
$installConfigFile .= '.dist';
}
+ define('TESTS_INSTALL_CONFIG_FILE', $installConfigFile);
+} else {
+ $installConfigFile = TESTS_INSTALL_CONFIG_FILE;
+}
+
+try {
+ setCustomErrorHandler();
+ /* Bootstrap the application */
+ $shell = new \Magento\Framework\Shell(new \Magento\Framework\Shell\CommandRenderer());
+ $testFrameworkDir = __DIR__;
+
$globalConfigFile = $settings->getAsConfigFile('TESTS_GLOBAL_CONFIG_FILE');
if (!file_exists($globalConfigFile)) {
$globalConfigFile .= '.dist';
}
- $sandboxUniqueId = md5(sha1_file($installConfigFile));
$dirList = new DirectoryList(BP);
$installDir = TESTS_TEMP_DIR;
@@ -64,13 +58,14 @@
$globalConfigFile,
$settings->get('TESTS_GLOBAL_CONFIG_DIR'),
$settings->get('TESTS_MAGENTO_MODE'),
- AutoloaderRegistry::getAutoloader()
+ AutoloaderRegistry::getAutoloader(),
+ false
);
$bootstrap = new \Magento\TestFramework\Bootstrap(
$settings,
new \Magento\TestFramework\Bootstrap\Environment(),
- new \Magento\TestFramework\Bootstrap\SetupDocBlock("{$integrationTestsDir}/testsuite"),
+ new \Magento\TestFramework\Bootstrap\SetupDocBlock("{$testsBaseDir}/_files/"),
new \Magento\TestFramework\Bootstrap\Profiler(new \Magento\Framework\Profiler\Driver\Standard()),
$shell,
$application,
@@ -82,9 +77,7 @@
//remove test modules files
require_once __DIR__ . '/../../setup-integration/framework/removeTestModules.php';
}
- if (!$application->isInstalled()) {
- $application->install();
- }
+ //We do not want to install anything
$application->initialize([]);
\Magento\TestFramework\Helper\Bootstrap::setInstance(new \Magento\TestFramework\Helper\Bootstrap($bootstrap));
@@ -107,41 +100,3 @@
echo $e . PHP_EOL;
exit(1);
}
-
-
-/**
- * Set custom error handler
- */
-function setCustomErrorHandler()
-{
- set_error_handler(
- function ($errNo, $errStr, $errFile, $errLine) {
- if (error_reporting()) {
- $errorNames = [
- E_ERROR => 'Error',
- E_WARNING => 'Warning',
- E_PARSE => 'Parse',
- E_NOTICE => 'Notice',
- E_CORE_ERROR => 'Core Error',
- E_CORE_WARNING => 'Core Warning',
- E_COMPILE_ERROR => 'Compile Error',
- E_COMPILE_WARNING => 'Compile Warning',
- E_USER_ERROR => 'User Error',
- E_USER_WARNING => 'User Warning',
- E_USER_NOTICE => 'User Notice',
- E_STRICT => 'Strict',
- E_RECOVERABLE_ERROR => 'Recoverable Error',
- E_DEPRECATED => 'Deprecated',
- E_USER_DEPRECATED => 'User Deprecated',
- ];
-
- $errName = isset($errorNames[$errNo]) ? $errorNames[$errNo] : "";
-
- throw new \PHPUnit\Framework\Exception(
- sprintf("%s: %s in %s:%s.", $errName, $errStr, $errFile, $errLine),
- $errNo
- );
- }
- }
- );
-}
diff --git a/dev/tests/setup-integration/phpunit.xml.dist b/dev/tests/setup-integration/phpunit.xml.dist
index 4fbeb8e987863..b683202bcb875 100644
--- a/dev/tests/setup-integration/phpunit.xml.dist
+++ b/dev/tests/setup-integration/phpunit.xml.dist
@@ -32,9 +32,9 @@
-
+
-
+
diff --git a/dev/tests/setup-integration/testsuite/Magento/Setup/DeclarativeSchemaBuilderTest.php b/dev/tests/setup-integration/testsuite/Magento/Setup/DeclarativeSchemaBuilderTest.php
new file mode 100644
index 0000000000000..59f798aaaabfe
--- /dev/null
+++ b/dev/tests/setup-integration/testsuite/Magento/Setup/DeclarativeSchemaBuilderTest.php
@@ -0,0 +1,74 @@
+parser = $objectManager->create(Parser::class);
+ $this->structureFactory = $objectManager->get(StructureFactory::class);
+ $this->moduleManager = $objectManager->get(TestModuleManager::class);
+ }
+
+ /**
+ * Tests primary key constraint convertion from XML and renamed functionality
+ *
+ * @moduleName Magento_TestSetupDeclarationModule1
+ */
+ public function testSchemaBuilder()
+ {
+ $structure = $this->structureFactory->create();
+ $structure = $this->parser->parse($structure);
+ //Test primary key and renaming
+ $referenceTable = $structure->getTableByName('reference_table');
+ /** @var Internal $primaryKey */
+ $primaryKey = $referenceTable->getPrimaryConstraint();
+ $columns = $primaryKey->getColumns();
+ self::assertEquals(reset($columns)->getName(), 'tinyintref_2');
+ //Test column
+ $testTable = $structure->getTableByName('test_table');
+ /** @var Timestamp $timestampColumn */
+ $timestampColumn = $testTable->getColumnByNameOrId('timestamp');
+ self::assertEquals($timestampColumn->getOnUpdate(), 'CURRENT_TIMESTAMP');
+ //Test disabled
+ self::assertArrayNotHasKey('varbinary_rename', $testTable->getColumns());
+ //Test foreign key
+ /** @var Reference $foreignKey */
+ $foreignKey = $testTable->getConstraintByName('some_foreign_key');
+ self::assertEquals($foreignKey->getOnDelete(), 'NO ACTION');
+ self::assertEquals($foreignKey->getReferenceColumn()->getName(), 'tinyintref_2');
+ }
+}
diff --git a/dev/tests/setup-integration/testsuite/Magento/Setup/DiffOldSchemaTest.php b/dev/tests/setup-integration/testsuite/Magento/Setup/DiffOldSchemaTest.php
new file mode 100644
index 0000000000000..80df282c08af5
--- /dev/null
+++ b/dev/tests/setup-integration/testsuite/Magento/Setup/DiffOldSchemaTest.php
@@ -0,0 +1,225 @@
+structureFactory = $objectManager->get(StructureFactory::class);
+ $this->moduleManager = $objectManager->get(TestModuleManager::class);
+ $this->cliCommad = $objectManager->get(CliCommand::class);
+ $this->declarativeParser = $objectManager->get(DeclarativeParser::class);
+ $this->generatedParser = $objectManager->get(Parser::class);
+ $this->structureDiff = $objectManager->get(StructureDiff::class);
+ $this->changeRegistryFactory = $objectManager->get(ChangeRegistryFactory::class);
+ }
+
+ /**
+ * @moduleName Magento_TestSetupDeclarationModule1
+ */
+ public function testOldDiff()
+ {
+ //Move schema.xml
+ $this->moduleManager->updateRevision(
+ 'Magento_TestSetupDeclarationModule1',
+ 'old_diff',
+ 'schema.xml',
+ 'etc'
+ );
+ //Move InstallSchema file and tried to install
+ $this->moduleManager->updateRevision(
+ 'Magento_TestSetupDeclarationModule1',
+ 'old_diff',
+ 'InstallSchema.php',
+ 'Setup'
+ );
+
+ $this->cliCommad->install(['Magento_TestSetupDeclarationModule1']);
+ $changeRegistry = $this->changeRegistryFactory->create();
+ $generatedStructure = $this->structureFactory->create();
+ $declarativeStructure = $this->structureFactory->create();
+ $declarativeStructure = $this->declarativeParser->parse($declarativeStructure);
+ $generatedStructure = $this->generatedParser->parse($generatedStructure);
+ $this->structureDiff->diff($declarativeStructure, $generatedStructure, $changeRegistry);
+ //Rename operations
+ $renameOperations = $changeRegistry->get(ChangeRegistryInterface::RENAME_OPERAION);
+ self::assertCount(1, $renameOperations);
+ self::assertArrayHasKey('smallinteger', $renameOperations);
+ self::assertCount(1, $renameOperations['smallinteger']);
+ self::assertEquals('smallint_ref2', $renameOperations['smallinteger'][0]['new']->getName());
+ //Change operations
+ $changeOperations = $changeRegistry->get(ChangeRegistryInterface::CHANGE_OPERATION);
+ self::assertCount(3, $changeOperations);
+ self::assertEquals(
+ $this->getPrimaryKeyDbSensitiveData(),
+ $changeOperations['primary'][0]['old']->getDiffSensitiveParams()
+ );
+ self::assertEquals(
+ $this->getPrimaryKeyXmlSensitiveData(),
+ $changeOperations['primary'][0]['new']->getDiffSensitiveParams()
+ );
+ self::assertEquals(
+ $this->getForeignKeyXmlSensitiveData(),
+ $changeOperations['foreign'][0]['new']->getDiffSensitiveParams()
+ );
+ self::assertEquals(
+ $this->getForeignKeyDbSensitiveData(),
+ $changeOperations['foreign'][0]['old']->getDiffSensitiveParams()
+ );
+ self::assertEquals(
+ $this->getBigIntKeyXmlSensitiveData(),
+ $changeOperations['biginteger'][0]['new']->getDiffSensitiveParams()
+ );
+ self::assertEquals(
+ $this->getBigIntKeyDbSensitiveData(),
+ $changeOperations['biginteger'][0]['old']->getDiffSensitiveParams()
+ );
+ self::assertCount(
+ 5,
+ $changeRegistry->get(ChangeRegistryInterface::REMOVE_OPERATION)['table']
+ );
+ }
+
+ /**
+ * @return array
+ */
+ private function getForeignKeyXmlSensitiveData()
+ {
+ return [
+ 'type' => 'foreign',
+ 'column' => 'smallint',
+ 'referenceColumn' => 'smallint_ref2',
+ 'referenceTableName' => 'reference_table',
+ 'tableName' => 'test_table',
+ 'onDelete' => 'CASCADE',
+ ];
+ }
+
+ /**
+ * @return array
+ */
+ private function getForeignKeyDbSensitiveData()
+ {
+ return [
+ 'type' => 'foreign',
+ 'column' => 'smallint',
+ 'referenceColumn' => 'smallint_ref',
+ 'referenceTableName' => 'reference_table',
+ 'tableName' => 'test_table',
+ 'onDelete' => 'CASCADE',
+ ];
+ }
+
+ /**
+ * @return array
+ */
+ private function getPrimaryKeyXmlSensitiveData()
+ {
+ return [
+ 'type' => 'primary',
+ 'columns' =>
+ [
+ 0 => 'smallint_ref2',
+ ],
+ ];
+ }
+
+ /**
+ * @return array
+ */
+ private function getPrimaryKeyDbSensitiveData()
+ {
+ return [
+ 'type' => 'primary',
+ 'columns' =>
+ [
+ 0 => 'smallint_ref',
+ ],
+ ];
+ }
+
+ /**
+ * @return array
+ */
+ private function getBigIntKeyDbSensitiveData()
+ {
+ return [
+ 'type' => 'biginteger',
+ 'nullable' => true,
+ 'padding' => '20',
+ 'unsigned' => false,
+ 'identity' => false,
+ 'default' => 0,
+ ];
+ }
+
+ /**
+ * @return array
+ */
+ private function getBigIntKeyXmlSensitiveData()
+ {
+ return [
+ 'type' => 'biginteger',
+ 'nullable' => true,
+ 'padding' => '20',
+ 'unsigned' => false,
+ 'identity' => false,
+ 'default' => 1,
+ ];
+ }
+}
diff --git a/dev/tests/setup-integration/testsuite/Magento/Setup/InstallTest.php b/dev/tests/setup-integration/testsuite/Magento/Setup/InstallTest.php
index 2c23bd3fb1c0b..db4f425ceacc9 100644
--- a/dev/tests/setup-integration/testsuite/Magento/Setup/InstallTest.php
+++ b/dev/tests/setup-integration/testsuite/Magento/Setup/InstallTest.php
@@ -41,40 +41,40 @@ class InstallTest extends \PHPUnit\Framework\TestCase
protected function setUp()
{
$objectManager = Bootstrap::getObjectManager();
- $this->shellCommand = $objectManager->create(\Magento\TestFramework\Deploy\CliCommand::class);
- $this->testModuleManager = $objectManager->create(\Magento\TestFramework\Deploy\TestModuleManager::class);
+ $this->shellCommand = $objectManager->get(\Magento\TestFramework\Deploy\CliCommand::class);
+ $this->testModuleManager = $objectManager->get(\Magento\TestFramework\Deploy\TestModuleManager::class);
/** @var \Magento\Framework\Setup\ModuleDataSetupInterface $installer */
- $installer = $objectManager->create(
- \Magento\Framework\Setup\ModuleDataSetupInterface::class
- );
- $this->connection = $installer->getConnection();
}
public static function tearDownAfterClass()
{
$objectManager = Bootstrap::getObjectManager();
- $shellCommand = $objectManager->create(\Magento\TestFramework\Deploy\CliCommand::class);
+ $shellCommand = $objectManager->get(\Magento\TestFramework\Deploy\CliCommand::class);
$shellCommand->disableModule(self::$moduleName);
- $testEnv = $objectManager->create(\Magento\TestFramework\Deploy\TestModuleManager::class);
+ $testEnv = $objectManager->get(\Magento\TestFramework\Deploy\TestModuleManager::class);
$testEnv->removeModuleFiles(self::$moduleName);
}
+ /**
+ * @moduleName Magento_TestSetupModule1
+ */
public function testInstallSchema()
{
$moduleName = self::$moduleName;
+ $this->shellCommand->install([$moduleName]);
//check that table not exists
foreach ($this->getTableNameMapping() as $name) {
- $this->assertFalse($this->connection->isTableExists($name), "Table {$name} already exists");
+ self::assertFalse($this->connection->isTableExists($name), "Table {$name} already exists");
}
- $this->assertContains(
+ self::assertContains(
'The following modules have been enabled:',
$this->shellCommand->introduceModule($moduleName)
);
- $this->assertContains("Module 'Magento_$moduleName':", $this->shellCommand->upgrade());
+ self::assertContains("Module 'Magento_$moduleName':", $this->shellCommand->install([$moduleName]));
//check that table exists and have corresponded columns
foreach ($this->getTableNameMapping() as $name) {
- $this->assertTrue($this->connection->isTableExists($name), "Table {$name} doesn't not exists");
+ self::assertTrue($this->connection->isTableExists($name), "Table {$name} doesn't not exists");
}
}
diff --git a/dev/tests/setup-integration/testsuite/Magento/Setup/SchemaReaderTest.php b/dev/tests/setup-integration/testsuite/Magento/Setup/SchemaReaderTest.php
new file mode 100644
index 0000000000000..17e5e4e9a73a9
--- /dev/null
+++ b/dev/tests/setup-integration/testsuite/Magento/Setup/SchemaReaderTest.php
@@ -0,0 +1,78 @@
+reader = $objectManager->get(\Magento\Setup\Model\Declaration\Schema\FileSystem\Reader::class);
+ $this->moduleManager = $objectManager->get(TestModuleManager::class);
+ }
+
+ /**
+ * @moduleName Magento_TestSetupDeclarationModule1
+ * @dataProviderFromFile Magento/TestSetupDeclarationModule1/fixture/valid_xml_revision_1.php
+ */
+ public function testSuccessfullRead()
+ {
+ $schema = $this->reader->read();
+ self::assertEquals($schema, $this->getData());
+ }
+
+ /**
+ * Helper method. Decrease number of params
+ *
+ * @param string $revisionName
+ * @return void
+ */
+ private function updateRevisionTo($revisionName)
+ {
+ $this->moduleManager->updateRevision(
+ 'Magento_TestSetupDeclarationModule1',
+ $revisionName,
+ TestModuleManager::DECLARATIVE_FILE_NAME,
+ 'etc'
+ );
+ }
+
+ /**
+ * @expectedException \Magento\Framework\Exception\LocalizedException
+ * @expectedExceptionMessageRegExp /The attribute 'scale' is not allowed./
+ * @moduleName Magento_TestSetupDeclarationModule1
+ */
+ public function testFailOnInvalidColumnDeclaration()
+ {
+ $this->updateRevisionTo('fail_on_column_declaration');
+ $this->reader->read();
+ }
+
+ /**
+ * @moduleName Magento_TestSetupDeclarationModule1
+ * @dataProviderFromFile Magento/TestSetupDeclarationModule1/fixture/foreign_key_interpreter_result.php
+ */
+ public function testForeignKeyInterpreter()
+ {
+ $this->updateRevisionTo('foreign_key_interpreter');
+ $schema = $this->reader->read();
+ self::assertEquals($schema, $this->getData());
+ }
+}
diff --git a/lib/internal/Magento/Framework/App/Utility/Files.php b/lib/internal/Magento/Framework/App/Utility/Files.php
index 3cb54da48f5f8..30c89aa7ecf40 100644
--- a/lib/internal/Magento/Framework/App/Utility/Files.php
+++ b/lib/internal/Magento/Framework/App/Utility/Files.php
@@ -475,6 +475,14 @@ public function getXmlCatalogFiles(
[]
)
);
+ $files = array_merge(
+ $files,
+ $this->getFilesSubset(
+ $this->componentRegistrar->getPaths(ComponentRegistrar::SETUP),
+ $fileNamePattern,
+ []
+ )
+ );
$files = array_filter(
$files,
function ($file) use ($excludedFileNames) {
diff --git a/lib/internal/Magento/Framework/Component/ComponentRegistrar.php b/lib/internal/Magento/Framework/Component/ComponentRegistrar.php
index 9c746177d6f7d..0e85cf5260e9b 100644
--- a/lib/internal/Magento/Framework/Component/ComponentRegistrar.php
+++ b/lib/internal/Magento/Framework/Component/ComponentRegistrar.php
@@ -21,6 +21,7 @@ class ComponentRegistrar implements ComponentRegistrarInterface
const LIBRARY = 'library';
const THEME = 'theme';
const LANGUAGE = 'language';
+ const SETUP = 'setup';
/**#@- */
/**#@- */
@@ -29,6 +30,7 @@ class ComponentRegistrar implements ComponentRegistrarInterface
self::LIBRARY => [],
self::LANGUAGE => [],
self::THEME => [],
+ self::SETUP => []
];
/**
diff --git a/lib/internal/Magento/Framework/Config/Dom.php b/lib/internal/Magento/Framework/Config/Dom.php
index 35d9626c90a94..2fbd814139a64 100644
--- a/lib/internal/Magento/Framework/Config/Dom.php
+++ b/lib/internal/Magento/Framework/Config/Dom.php
@@ -83,6 +83,7 @@ class Dom
/**
* @var array
+ * @since 2.2.0
*/
private static $resolvedSchemaPaths = [];
@@ -121,6 +122,7 @@ public function __construct(
*
* @param string $errorFormat
* @return string[]
+ * @since 2.1.0
*/
private static function getXmlErrors($errorFormat)
{
diff --git a/lib/internal/Magento/Framework/Config/Dom/UrnResolver.php b/lib/internal/Magento/Framework/Config/Dom/UrnResolver.php
index 44d663041e156..41c83c940ca04 100644
--- a/lib/internal/Magento/Framework/Config/Dom/UrnResolver.php
+++ b/lib/internal/Magento/Framework/Config/Dom/UrnResolver.php
@@ -36,6 +36,7 @@ public function getRealPath($schema)
$matches = [];
$modulePattern = '/urn:(?([a-zA-Z]*)):module:(?([A-Za-z0-9\_]*)):(?(.+))/';
$frameworkPattern = '/urn:(?([a-zA-Z]*)):(?(framework[A-Za-z\-]*)):(?(.+))/';
+ $setupPattern = '/urn:(?([a-zA-Z]*)):(?(setup[A-Za-z\-]*)):(?(.+))/';
if (preg_match($modulePattern, $schema, $matches)) {
//urn:magento:module:Magento_Catalog:etc/catalog_attributes.xsd
$package = $componentRegistrar
@@ -45,6 +46,10 @@ public function getRealPath($schema)
//urn:magento:framework-amqp:Module/etc/module.xsd
$package = $componentRegistrar
->getPath(ComponentRegistrar::LIBRARY, $matches['vendor'] . '/' . $matches['framework']);
+ } elseif (preg_match($setupPattern, $schema, $matches)) {
+ //urn:magento:setup:
+ $package = $componentRegistrar
+ ->getPath(ComponentRegistrar::SETUP, $matches['vendor'] . '/' . $matches['setup']);
} else {
throw new NotFoundException(new Phrase("Unsupported format of schema location: '%1'", [$schema]));
}
diff --git a/lib/internal/Magento/Framework/Console/Cli.php b/lib/internal/Magento/Framework/Console/Cli.php
index 7fae09c10e5e7..2661066229112 100644
--- a/lib/internal/Magento/Framework/Console/Cli.php
+++ b/lib/internal/Magento/Framework/Console/Cli.php
@@ -6,6 +6,7 @@
namespace Magento\Framework\Console;
use Magento\Framework\App\Bootstrap;
+use Magento\Framework\App\Bootstrap as AppBootstrap;
use Magento\Framework\App\DeploymentConfig;
use Magento\Framework\App\Filesystem\DirectoryList;
use Magento\Framework\App\ProductMetadata;
@@ -19,7 +20,6 @@
use Magento\Setup\Console\CompilerPreparation;
use Magento\Setup\Model\ObjectManagerProvider;
use Symfony\Component\Console;
-use Zend\ServiceManager\ServiceManager;
/**
* Magento 2 CLI Application.
@@ -158,6 +158,12 @@ private function initObjectManager()
{
$params = (new ComplexParameter(self::INPUT_KEY_BOOTSTRAP))->mergeFromArgv($_SERVER, $_SERVER);
$params[Bootstrap::PARAM_REQUIRE_MAINTENANCE] = null;
+ $requestParams = $this->serviceManager->get('magento-init-params');
+ $appBootstrapKey = AppBootstrap::INIT_PARAM_FILESYSTEM_DIR_PATHS;
+
+ if (isset($requestParams[$appBootstrapKey]) && !isset($params[$appBootstrapKey])) {
+ $params[$appBootstrapKey] = $requestParams[$appBootstrapKey];
+ }
$this->objectManager = Bootstrap::create(BP, $params)->getObjectManager();
diff --git a/setup/config/di.config.php b/setup/config/di.config.php
index d43a1e569c204..b707352ba6b52 100644
--- a/setup/config/di.config.php
+++ b/setup/config/di.config.php
@@ -56,6 +56,15 @@
\Magento\Framework\Component\ComponentRegistrarInterface::class =>
\Magento\Framework\Component\ComponentRegistrar::class,
],
+ \Magento\Setup\Model\Declaration\Schema\Db\Parser::class => [
+ 'parameters' => [
+ 'connectionScopes' => [
+ 'default',
+ 'checkout',
+ 'sales'
+ ]
+ ]
+ ],
],
],
];
diff --git a/setup/config/module.config.php b/setup/config/module.config.php
index a2e5501ce3d8b..02e41722e357e 100644
--- a/setup/config/module.config.php
+++ b/setup/config/module.config.php
@@ -32,7 +32,7 @@
],
'service_manager' => [
'aliases' => [
- 'translator' => 'MvcTranslator',
- ],
- ],
+ 'translator' => 'MvcTranslator'
+ ]
+ ]
];
diff --git a/setup/src/Magento/Setup/Console/Command/InstallCommand.php b/setup/src/Magento/Setup/Console/Command/InstallCommand.php
index b0ccbba8c296f..74b627b6e5d5b 100644
--- a/setup/src/Magento/Setup/Console/Command/InstallCommand.php
+++ b/setup/src/Magento/Setup/Console/Command/InstallCommand.php
@@ -7,6 +7,7 @@
use Magento\Deploy\Console\Command\App\ConfigImportCommand;
use Symfony\Component\Console\Input\ArrayInput;
+use Magento\Setup\Model\Declaration\Schema\Request;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Magento\Setup\Model\InstallerFactory;
@@ -35,6 +36,18 @@ class InstallCommand extends AbstractSetupCommand
*/
const INPUT_KEY_USE_SAMPLE_DATA = 'use-sample-data';
+ /**
+ * List of comma-separated module names. That must be enabled during installation
+ * Available magic param all.
+ */
+ const INPUT_KEY_ENABLE_MODULES = 'enable_modules';
+
+ /**
+ * List of comma-separated module names. That must be avoided during installation.
+ * Avaiable magic param all.
+ */
+ const INPUT_KEY_DISABLE_MODULES = 'disable_modules';
+
/**
* Regex for sales_order_increment_prefix validation.
*/
@@ -109,6 +122,26 @@ protected function configure()
null,
InputOption::VALUE_NONE,
'Use sample data'
+ ),
+ new InputOption(
+ Request::DUMP_ENABLE_OPTIONS,
+ null,
+ InputOption::VALUE_REQUIRED,
+ 'Should removed columns be dumped or recovered columns data reverted'
+ ),
+ new InputOption(
+ self::INPUT_KEY_ENABLE_MODULES,
+ null,
+ InputOption::VALUE_OPTIONAL,
+ 'List of comma-separated module names. That must be included during installation.
+ Avaiable magic param all.'
+ ),
+ new InputOption(
+ self::INPUT_KEY_DISABLE_MODULES,
+ null,
+ InputOption::VALUE_OPTIONAL,
+ 'List of comma-separated module names. That must be avoided during installation.
+ Avaiable magic param all.'
)
]);
$this->setName('setup:install')
diff --git a/setup/src/Magento/Setup/Console/Command/UpgradeCommand.php b/setup/src/Magento/Setup/Console/Command/UpgradeCommand.php
index e2d032da9b196..5bd81cd7890e6 100644
--- a/setup/src/Magento/Setup/Console/Command/UpgradeCommand.php
+++ b/setup/src/Magento/Setup/Console/Command/UpgradeCommand.php
@@ -90,7 +90,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$keepGenerated = $input->getOption(self::INPUT_KEY_KEEP_GENERATED);
$installer = $this->installerFactory->create(new ConsoleLogger($output));
$installer->updateModulesSequence($keepGenerated);
- $installer->installSchema();
+ $installer->installSchema($input->getOptions());
$installer->installDataFixtures();
if ($this->deploymentConfig->isAvailable()) {
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Casters/Base.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Casters/Base.php
new file mode 100644
index 0000000000000..bc2bede0ebd62
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Casters/Base.php
@@ -0,0 +1,47 @@
+booleanUtils = $booleanUtils;
+ }
+
+ /**
+ * {@inheritdoc}
+ * @return array
+ */
+ public function cast(array $data)
+ {
+ $data['nullable'] = isset($data['nullable']) ? $this->booleanUtils->toBoolean($data['nullable']) : true;
+ $data['unsigned'] = isset($data['unsigned']) ? $this->booleanUtils->toBoolean($data['unsigned']) : false;
+ $data['disabled'] = isset($data['disabled']) ? $this->booleanUtils->toBoolean($data['disabled']) : false;
+
+ if (isset($data['identity'])) {
+ $data['identity'] = $this->booleanUtils->toBoolean($data['identity']);
+ }
+
+ unset($data['extra']);//we need to ignore extra field that comes from db
+
+ return $data;
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Casters/Biginteger.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Casters/Biginteger.php
new file mode 100644
index 0000000000000..214d6fff1f69d
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Casters/Biginteger.php
@@ -0,0 +1,53 @@
+base = $base;
+ }
+
+ /**
+ * Set default padding, like BIGINT(20)
+ *
+ * {@inheritdoc}
+ * @return array
+ */
+ public function cast(array $data)
+ {
+ $data = $this->base->cast($data);
+
+ if (!isset($data['padding'])) {
+ $data['padding'] = self::DEFAULT_PADDING;
+ }
+
+ if (isset($data['default'])) {
+ $data['default'] = (int)$data['default'];
+ }
+
+ return $data;
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Casters/Boolean.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Casters/Boolean.php
new file mode 100644
index 0000000000000..a76eae8465582
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Casters/Boolean.php
@@ -0,0 +1,59 @@
+base = $base;
+ $this->booleanUtils = $booleanUtils;
+ }
+
+ /**
+ * Convert default attribute from string to boolean value
+ *
+ * {@inheritdoc}
+ * @return array
+ */
+ public function cast(array $data)
+ {
+ $data = $this->base->cast($data);
+
+ if (isset($data['default'])) {
+ $data['default'] = $this->booleanUtils->toBoolean($data['default']);
+ } else {
+ $data['default'] = self::DEFAULT_BOOLEAN;
+ }
+
+ return $data;
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Casters/CasterAggregator.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Casters/CasterAggregator.php
new file mode 100644
index 0000000000000..5014d2de6d409
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Casters/CasterAggregator.php
@@ -0,0 +1,50 @@
+casters = $casters;
+ }
+
+ /**
+ * Find appropriate caster by type (for example: integer or decimal)
+ * and try to cast it
+ *
+ * @inheritdoc
+ */
+ public function cast(array $data)
+ {
+ $type = $data['type'];
+
+ if (!isset($this->casters[$type])) {
+ //We can`t through any exception, as from db schema we can faced with unknown types
+ $caster = $this->casters[self::DEFAULT_CASTER];
+ } else {
+ $caster = $this->casters[$type];
+ }
+
+ return $caster->cast($data);
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Casters/CasterInterface.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Casters/CasterInterface.php
new file mode 100644
index 0000000000000..afba9440b1133
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Casters/CasterInterface.php
@@ -0,0 +1,22 @@
+base = $base;
+ }
+
+ /**
+ * Set shape to floating point, that is by default (10,0)
+ *
+ * {@inheritdoc}
+ * @return array
+ */
+ public function cast(array $data)
+ {
+ unset($data['nullable']);
+ unset($data['default']);
+ return $data;
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Casters/Decimal.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Casters/Decimal.php
new file mode 100644
index 0000000000000..8c60e591b7abc
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Casters/Decimal.php
@@ -0,0 +1,56 @@
+base = $base;
+ }
+
+ /**
+ * Set shape to floating point, that is by default (10,0)
+ *
+ * {@inheritdoc}
+ * @return array
+ */
+ public function cast(array $data)
+ {
+ $data = $this->base->cast($data);
+
+ if (!isset($data['precission'])) {
+ $data['precission'] = self::DEFAULT_PRECISSION;
+ }
+
+ if (!isset($data['scale'])) {
+ $data['scale'] = self::DEFAULT_SCALE;
+ }
+
+ if (isset($data['default'])) {
+ $data['default'] = (float) $data['default'];
+ }
+
+ return $data;
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Casters/Foreign.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Casters/Foreign.php
new file mode 100644
index 0000000000000..cffaa1dac1ca2
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Casters/Foreign.php
@@ -0,0 +1,46 @@
+base = $base;
+ }
+
+ /**
+ * Set default padding, like INTEGER(11)
+ *
+ * {@inheritdoc}
+ * @return array
+ */
+ public function cast(array $data)
+ {
+ $data = $this->base->cast($data);
+
+ if (!isset($data['onDelete'])) {
+ $data['onDelete'] = self::DEFAULT_ON_DELETE;
+ }
+
+ return $data;
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Casters/Integer.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Casters/Integer.php
new file mode 100644
index 0000000000000..21f41ed162352
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Casters/Integer.php
@@ -0,0 +1,53 @@
+base = $base;
+ }
+
+ /**
+ * Set default padding, like INTEGER(11)
+ *
+ * {@inheritdoc}
+ * @return array
+ */
+ public function cast(array $data)
+ {
+ $data = $this->base->cast($data);
+
+ if (!isset($data['padding'])) {
+ $data['padding'] = self::DEFAULT_PADDING;
+ }
+
+ if (isset($data['default'])) {
+ $data['default'] = (int) $data['default'];
+ }
+
+ return $data;
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Casters/Primary.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Casters/Primary.php
new file mode 100644
index 0000000000000..d81b3a4a132ae
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Casters/Primary.php
@@ -0,0 +1,42 @@
+base = $base;
+ }
+
+ /**
+ * Set default padding, like INTEGER(11)
+ *
+ * {@inheritdoc}
+ * @return array
+ */
+ public function cast(array $data)
+ {
+ $data = $this->base->cast($data);
+ $data['name'] = Internal::PRIMARY_NAME;
+
+ return $data;
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Casters/Smallinteger.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Casters/Smallinteger.php
new file mode 100644
index 0000000000000..6f1738f8f46eb
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Casters/Smallinteger.php
@@ -0,0 +1,52 @@
+base = $base;
+ }
+
+ /**
+ * Set default padding, like SMALLINT(5)
+ *
+ * {@inheritdoc}
+ * @return array
+ */
+ public function cast(array $data)
+ {
+ $data = $this->base->cast($data);
+
+ if (!isset($data['padding'])) {
+ $data['padding'] = self::DEFAULT_PADDING;
+ }
+
+ if (isset($data['default'])) {
+ $data['default'] = (int) $data['default'];
+ }
+
+ return $data;
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Casters/Timestamp.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Casters/Timestamp.php
new file mode 100644
index 0000000000000..12670ba7f333b
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Casters/Timestamp.php
@@ -0,0 +1,68 @@
+base = $base;
+ $this->booleanUtils = $booleanUtils;
+ }
+
+ /**
+ * Change on_update and default params
+ *
+ * {@inheritdoc}
+ * @return array
+ */
+ public function cast(array $data)
+ {
+ $data = $this->base->cast($data);
+ //As we have only one value for timestamp on update -> it is convinient to use boolean type for it
+ //But later we need to convert it to SQL value
+ if (isset($data['on_update']) && $data['on_update'] !== 'CURRENT_TIMESTAMP') {
+ if ($this->booleanUtils->toBoolean($data['on_update'])) {
+ $data['on_update'] = 'CURRENT_TIMESTAMP';
+ } else {
+ unset($data['on_update']);
+ }
+ }
+ //By default we do not want to use default attribute
+ if (!isset($data['default'])) {
+ $data['default'] = null;
+ }
+
+ unset($data['nullable']);
+
+ return $data;
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Casters/Tinyinteger.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Casters/Tinyinteger.php
new file mode 100644
index 0000000000000..c3fc8d4198e27
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Casters/Tinyinteger.php
@@ -0,0 +1,52 @@
+base = $base;
+ }
+
+ /**
+ * Set default padding, like TINYINT(1)
+ *
+ * {@inheritdoc}
+ * @return array
+ */
+ public function cast(array $data)
+ {
+ $data = $this->base->cast($data);
+
+ if (!isset($data['padding'])) {
+ $data['padding'] = self::DEFAULT_PADDING;
+ }
+
+ if (isset($data['default'])) {
+ $data['default'] = (int) $data['default'];
+ }
+
+ return $data;
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/ChangeProcessorInterface.php b/setup/src/Magento/Setup/Model/Declaration/Schema/ChangeProcessorInterface.php
new file mode 100644
index 0000000000000..53c58a4e3342a
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/ChangeProcessorInterface.php
@@ -0,0 +1,22 @@
+componentRegistrar = $componentRegistrar;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function get($operation, $type = null)
+ {
+ if (empty($type)) {
+ return isset($this->changes[$operation]) ? $this->changes[$operation] : [];
+ }
+
+ return isset($this->changes[$operation][$type]) ? $this->changes[$operation][$type] : [];
+ }
+
+ /**
+ * Retrieve array of whitelisted tables
+ * Whitelist tables should have JSON format and should be added through
+ * CLI command: should be done in next story
+ *
+ *
+ * @return array
+ */
+ private function getWhiteListTables()
+ {
+ if (!$this->whiteListTables) {
+ foreach ($this->componentRegistrar->getPaths(ComponentRegistrar::MODULE) as $path) {
+ $whiteListPath = $path . DIRECTORY_SEPARATOR . 'etc' .
+ DIRECTORY_SEPARATOR . 'declarative_schema_white_list.json';
+
+ if (file_exists($whiteListPath)) {
+ $this->whiteListTables = array_replace_recursive(
+ $this->whiteListTables,
+ json_decode(file_get_contents($whiteListPath), true)
+ );
+ }
+ }
+ }
+
+ return $this->whiteListTables;
+ }
+
+ /**
+ * Check whether element can be registered
+ *
+ * For example, if element is not in whitelist.json it cant
+ * be registered due to backward incompatability
+ *
+ * @param ElementInterface $object
+ * @return bool
+ */
+ private function canBeRegistered(ElementInterface $object)
+ {
+ $whiteList = $this->getWhiteListTables();
+ $type = $object->getElementType();
+
+ if ($object instanceof TableElementInterface) {
+ return isset($whiteList['table'][$object->getTable()->getName()][$type][$object->getName()]);
+ }
+
+ return isset($whiteList['table'][$object->getName()]);
+ }
+
+ /**
+ * @param Request $request
+ * @return void
+ */
+ public function registerInstallationRequest(Request $request)
+ {
+ $this->request = $request;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function register(ElementInterface $dtoObject, $type, $operation, ElementInterface $oldDtoObject = null)
+ {
+ //Comment until whitelist functionality will be done
+ if (!$this->canBeRegistered($dtoObject)) {
+ #return $this; //ignore any operations for non registered elements changes
+ }
+
+ $this->changes[$operation][$type][] = [
+ 'new' => $dtoObject,
+ 'old' => $oldDtoObject
+ ];
+
+ return $this;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function registerStructure(Structure $structure)
+ {
+ $this->structure = $structure;
+ }
+
+ /**
+ * Retrieve current structure
+ * This function needs for rollback functionality
+ *
+ * @return Structure
+ */
+ public function getCurrentStructureState()
+ {
+ return $this->structure;
+ }
+
+ /**
+ * Request holds some information from cli command or UI
+ * like: save mode or dry-run mode
+ *
+ * @return Request
+ */
+ public function getCurrentInstallationRequest()
+ {
+ return $this->request;
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/ChangeRegistryFactory.php b/setup/src/Magento/Setup/Model/Declaration/Schema/ChangeRegistryFactory.php
new file mode 100644
index 0000000000000..1f565afe08e71
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/ChangeRegistryFactory.php
@@ -0,0 +1,39 @@
+objectManager = $objectManager;
+ }
+
+ /**
+ * @return ChangeRegistryInterface
+ */
+ public function create()
+ {
+ return $this->objectManager->create(ChangeRegistry::class);
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/ChangeRegistryInterface.php b/setup/src/Magento/Setup/Model/Declaration/Schema/ChangeRegistryInterface.php
new file mode 100644
index 0000000000000..cf4e2d1c43010
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/ChangeRegistryInterface.php
@@ -0,0 +1,92 @@
+getDiffSensitiveParams() === $second->getDiffSensitiveParams();
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/AdapterMediator.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/AdapterMediator.php
new file mode 100644
index 0000000000000..43e6f0d35e5e8
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/AdapterMediator.php
@@ -0,0 +1,187 @@
+columnProcessors = $columnProcessors;
+ $this->dbSchemaReader = $dbSchemaReader;
+ }
+
+ /**
+ * Go through all processors and modify column data
+ * depends on type column has
+ *
+ * @param array $elementData
+ * @param $type
+ * @return array
+ */
+ private function processElement(array $elementData, $type)
+ {
+ if (!isset($this->columnProcessors[$type])) {
+ throw new \InvalidArgumentException(sprintf("Cannot find type %s", $type));
+ }
+
+ /** @var DbSchemaProcessorInterface $columnProcessor */
+ foreach ($this->columnProcessors[$type] as $columnProcessor) {
+ $elementData = $columnProcessor->fromDefinition($elementData);
+ }
+
+ return $elementData;
+ }
+
+ /**
+ * Retrieve the list of all Magento non-unique and non-primary indexes
+ *
+ * @param string $tableName
+ * @param string $resource
+ * @return array
+ */
+ public function getIndexesList($tableName, $resource = 'default')
+ {
+ if (!isset($this->ddlCache[self::KEY_INDEXES][$tableName])) {
+ $this->ddlCache[self::KEY_INDEXES][$tableName] = [];
+ foreach ($this->dbSchemaReader->readIndexes($tableName, $resource) as $indexData) {
+ $index = $this->processElement($indexData, self::KEY_INDEXES);
+
+ if (!isset($this->ddlCache[self::KEY_INDEXES][$tableName][$index['name']])) {
+ $this->ddlCache[self::KEY_INDEXES][$tableName][$index['name']] = [];
+ }
+
+ $this->ddlCache[self::KEY_INDEXES][$tableName][$index['name']] = array_replace_recursive(
+ $this->ddlCache[self::KEY_INDEXES][$tableName][$index['name']],
+ $index
+ );
+ }
+ }
+
+ return $this->ddlCache[self::KEY_INDEXES][$tableName];
+ }
+
+ /**
+ * @param string $tableName
+ * @param string $resource
+ * @return mixed
+ */
+ public function getConstraintsList($tableName, $resource = 'default')
+ {
+ if (!isset($this->ddlCache[self::KEY_CONSTRAINT][$tableName])) {
+ $this->ddlCache[self::KEY_CONSTRAINT][$tableName] = [];
+ $constraintsData = $this->dbSchemaReader->readConstraints($tableName, $resource);
+ foreach ($constraintsData as $constraintData) {
+ $constraint = $this->processElement($constraintData, self::KEY_CONSTRAINT);
+
+ if (!isset($this->ddlCache[self::KEY_CONSTRAINT][$tableName][$constraint['name']])) {
+ $this->ddlCache[self::KEY_CONSTRAINT][$tableName][$constraint['name']] = [];
+ }
+
+ $this->ddlCache[self::KEY_CONSTRAINT][$tableName][$constraint['name']] = array_replace_recursive(
+ $this->ddlCache[self::KEY_CONSTRAINT][$tableName][$constraint['name']],
+ $constraint
+ );
+ }
+ }
+
+ return $this->ddlCache[self::KEY_CONSTRAINT][$tableName];
+ }
+
+ /**
+ * Retrieve list of preprocessed foreign keys
+ *
+ * @param string $tableName
+ * @param string $resource
+ * @return array
+ */
+ public function getReferencesList($tableName, $resource = 'default')
+ {
+ if (!isset($this->ddlCache[self::KEY_REFERENCE][$tableName])) {
+ $this->ddlCache[self::KEY_REFERENCE][$tableName] = [];
+ $createTable = $this->dbSchemaReader->readReferences($tableName, $resource);
+ $foreignKeys = $this->processElement($createTable, self::KEY_REFERENCE);
+ //Process foreign keys
+ foreach ($foreignKeys as $foreignKey) {
+ $this->ddlCache[self::KEY_REFERENCE][$tableName][$foreignKey['name']] = $foreignKey;
+ }
+ }
+
+ return $this->ddlCache[self::KEY_REFERENCE][$tableName];
+ }
+
+ /**
+ * @param $tableName
+ * @param string $resource
+ * @return array
+ */
+ public function getColumnsList($tableName, $resource = 'default')
+ {
+ if (!isset($this->ddlCache[self::KEY_COLUMNS][$tableName])) {
+ $this->ddlCache[self::KEY_COLUMNS][$tableName] = [];
+ foreach ($this->dbSchemaReader->readeColumns($tableName, $resource) as $rawColumn) {
+ $column = $this->processElement($rawColumn, self::KEY_COLUMNS);
+ $this->ddlCache[self::KEY_COLUMNS][$tableName][$column['name']] = $column;
+ }
+ }
+
+ return $this->ddlCache[self::KEY_COLUMNS][$tableName];
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Parser.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Parser.php
new file mode 100644
index 0000000000000..a1051f6d8a86a
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Parser.php
@@ -0,0 +1,37 @@
+structureBuilder = $structureBuilder;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function parse(Structure $structure)
+ {
+ return $this->structureBuilder->build($structure);
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/DbSchemaProcessorInterface.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/DbSchemaProcessorInterface.php
new file mode 100644
index 0000000000000..2183645138adf
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/DbSchemaProcessorInterface.php
@@ -0,0 +1,37 @@
+ 'varchar'
+ * 'length' => 255
+ */
+interface DbSchemaProcessorInterface
+{
+ /**
+ * Output always will be SQL definition
+ *
+ * @param ElementInterface $element
+ * @return string
+ */
+ public function toDefinition(ElementInterface $element);
+
+ /**
+ * Input always will be array of SQL definitions,
+ * like:
+ * 'type' => 'name VARCHAR(255)'\
+ * 'nullable' => 'no'
+ *
+ * @param array $data
+ * @return array
+ */
+ public function fromDefinition(array $data);
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/DbSchemaReaderInterface.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/DbSchemaReaderInterface.php
new file mode 100644
index 0000000000000..c70d03ac28dfe
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/DbSchemaReaderInterface.php
@@ -0,0 +1,57 @@
+ 'name',
+ 1 => 'type',
+ 2 => 'nullable',
+ 3 => 'key',
+ 4 => 'default',
+ 5 => 'extra'
+ ];
+
+ /**
+ * @inheritdoc
+ */
+ public function toDefinition(ElementInterface $element)
+ {
+ return '';
+ }
+
+ /**
+ * Convert MySQL nullable string value into boolean
+ *
+ * @param string $nullableValue
+ * @return bool
+ */
+ private function processNullable($nullableValue)
+ {
+ return strtolower($nullableValue) === 'yes' ? true : false;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function fromDefinition(array $data)
+ {
+ $data = array_combine(array_values(self::$tokens), array_values($data));
+ $data['type'] = strtolower($data['type']);
+ $data['nullable'] = $this->processNullable($data['nullable']);
+ unset($data['key']); //we do not need key, as it will be calculated from indexes
+ return $data;
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Boolean.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Boolean.php
new file mode 100644
index 0000000000000..dd675e6e307f8
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Boolean.php
@@ -0,0 +1,39 @@
+unsigned = $unsigned;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function toDefinition(ElementInterface $element)
+ {
+ return '';
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function fromDefinition(array $data)
+ {
+ $matches = [];
+ if (preg_match('/^(float|decimal|double)\((\d+),(\d+)\)/', $data['type'], $matches)) {
+ /**
+ * match[1] - type
+ * match[2] - precision
+ * match[3] - scale
+ */
+ $data = $this->unsigned->fromDefinition($data);
+ $data['type'] = $matches[1];
+
+ if (isset($matches[2]) && isset($matches[3])) {
+ $data['scale'] = $matches[3];
+ $data['precission'] = $matches[2];
+ }
+ }
+
+ return $data;
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Integer.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Integer.php
new file mode 100644
index 0000000000000..ae74d0e106393
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Integer.php
@@ -0,0 +1,80 @@
+unsigned = $unsigned;
+ $this->boolean = $boolean;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function toDefinition(ElementInterface $element)
+ {
+ return '';
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function fromDefinition(array $data)
+ {
+ $matches = [];
+ if (preg_match('/^(big|medium|small|tiny)?int\((\d+)\)/', $data['type'], $matches)) {
+ /**
+ * match[0] - all
+ * match[1] - prefix
+ * match[2] - padding, like 5 or 11
+ */
+ $data = $this->unsigned->fromDefinition($data);
+ $data['type'] = sprintf("%sinteger", $matches[1]);
+ //Use shortcut for mediuminteger
+ $data['type'] = $data['type'] === 'mediuminteger' ? 'integer' : $data['type'];
+
+ if (isset($matches[2])) {
+ $data['padding'] = $matches[2];
+ }
+
+ if (!empty($data['extra']) && strpos(self::IDENTITY_FLAG, $data['extra']) !== false) {
+ $data['identity'] = true;
+ }
+
+ $data = $this->boolean->fromDefinition($data);
+ }
+
+ return $data;
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/OnUpdate.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/OnUpdate.php
new file mode 100644
index 0000000000000..27816826afa16
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/OnUpdate.php
@@ -0,0 +1,37 @@
+onUpdate = $onUpdate;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function toDefinition(ElementInterface $element)
+ {
+ return '';
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function fromDefinition(array $data)
+ {
+ $matches = [];
+ if (preg_match('/^(timestamp|datetime)/', $data['type'], $matches)) {
+ $data['type'] = $matches[1];
+ $data = $this->onUpdate->fromDefinition($data);
+ }
+
+ return $data;
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Unsigned.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Unsigned.php
new file mode 100644
index 0000000000000..673aef7f1f5d3
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Unsigned.php
@@ -0,0 +1,44 @@
+ 'foreign',
+ 'name' => $match[1],
+ 'column' => $match[2],
+ 'referenceTable' => $match[5],
+ 'referenceColumn' => $match[6],
+ 'onDelete' => isset($match[7]) ? $match[8] : ''
+ ];
+ }
+ }
+
+ return $ddl;
+ }
+
+ return $data;
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Constraints/Internal.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Constraints/Internal.php
new file mode 100644
index 0000000000000..bdb051a04d70e
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Constraints/Internal.php
@@ -0,0 +1,45 @@
+ $data['Key_name'],
+ 'column' => [
+ $data['Column_name'] => $data['Column_name']
+ ],
+ 'type' => $data['Key_name'] === self::PRIMARY_NAME ? 'primary' : 'unique'
+ ];
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/DbSchemaReader.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/DbSchemaReader.php
new file mode 100644
index 0000000000000..4cffdc3278928
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/DbSchemaReader.php
@@ -0,0 +1,134 @@
+resourceConnection = $resourceConnection;
+ }
+
+ /**
+ * Prepare and fetch query: Describe {table_name}
+ *
+ * @param string $tableName
+ * @param string $resource
+ * @return array
+ */
+ public function readeColumns($tableName, $resource)
+ {
+ $adapter = $this->resourceConnection->getConnection($resource);
+ $sql = 'DESCRIBE ' . $adapter->quoteIdentifier($tableName, true);
+ $stmt = $adapter->query($sql);
+
+ // Use FETCH_NUM so we are not dependent on the CASE attribute of the PDO connection
+ return $stmt->fetchAll(\Zend_Db::FETCH_NUM);
+ }
+
+ /**
+ * Fetch all indexes from table
+ *
+ * @param string $tableName
+ * @param string $resource
+ * @return array
+ */
+ public function readIndexes($tableName, $resource)
+ {
+ $adapter = $this->resourceConnection->getConnection($resource);
+ $condition = sprintf('Non_unique = 1');
+ $sql = sprintf('SHOW INDEXES FROM %s WHERE %s', $tableName, $condition);
+ $stmt = $adapter->query($sql);
+
+ // Use FETCH_NUM so we are not dependent on the CASE attribute of the PDO connection
+ return $stmt->fetchAll(\Zend_Db::FETCH_ASSOC);
+ }
+
+ /**
+ * As MySQL has bug and do not show foreign keys during
+ * DESCRIBE and other directives we need to take it from SHOW CREATE TABLE ...
+ * command
+ *
+ * @inheritdoc
+ */
+ public function readReferences($tableName, $resource)
+ {
+ return $this->getCreateTableSql($tableName, $resource);
+ }
+
+ /**
+ * Retrieve Create table SQL, from SHOW CREATE TABLE query
+ *
+ * @param string $tableName
+ * @param string $resource
+ * @return array
+ */
+ private function getCreateTableSql($tableName, $resource)
+ {
+ $adapter = $this->resourceConnection->getConnection($resource);
+ $sql = sprintf('SHOW CREATE TABLE %s', $tableName);
+ $stmt = $adapter->query($sql);
+ return $stmt->fetch(\Zend_Db::FETCH_ASSOC);
+ }
+
+ /**
+ * For MySQL reading of constraints is almost the same as indexes
+ * But we need to know, that we read 2 types of constraints:
+ * primary and unique keys and this keys are always non_unique=0
+ *
+ * @inheritdoc
+ */
+ public function readConstraints($tableName, $resource)
+ {
+ $adapter = $this->resourceConnection->getConnection($resource);
+ $condition = sprintf('Non_unique = 0');
+ $sql = sprintf('SHOW INDEXES FROM %s WHERE %s', $tableName, $condition);
+ $stmt = $adapter->query($sql);
+
+ // Use FETCH_NUM so we are not dependent on the CASE attribute of the PDO connection
+ return $stmt->fetchAll(\Zend_Db::FETCH_ASSOC);
+ }
+
+ /**
+ * Return names of all tables from shard
+ *
+ * @param string $resource Shard name
+ * @return array
+ */
+ public function readTables($resource = 'default')
+ {
+ if (!isset($this->tables[AdapterMediator::KEY_TABLE])) {
+ $this->tables[AdapterMediator::KEY_TABLE] = $this->resourceConnection
+ ->getConnection($resource)
+ ->getTables();
+ }
+
+ return $this->tables[AdapterMediator::KEY_TABLE];
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Index.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Index.php
new file mode 100644
index 0000000000000..a8eea54f73df4
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Index.php
@@ -0,0 +1,45 @@
+ 'fultext',
+ 'BTREE' => 'btree',
+ 'HASH' => 'hash'
+ ];
+
+ /**
+ * @inheritdoc
+ */
+ public function toDefinition(ElementInterface $element)
+ {
+ return '';
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function fromDefinition(array $data)
+ {
+ return [
+ 'indexType' => self::$indexTypeMapping[$data['Index_type']],
+ 'name' => $data['Key_name'],
+ 'column' => [
+ $data['Column_name'] => $data['Column_name']
+ ],
+ 'type' => 'index'
+ ];
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/StructureBuilder.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/StructureBuilder.php
new file mode 100644
index 0000000000000..fd76b682e50be
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/StructureBuilder.php
@@ -0,0 +1,184 @@
+adapter = $adapter;
+ $this->elementFactory = $elementFactory;
+ $this->casterAggregator = $casterAggregator;
+ $this->dbSchemaReader = $dbSchemaReader;
+ $this->sharding = $sharding;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function build(Structure $structure)
+ {
+ $tables = [];
+
+ foreach ($this->dbSchemaReader->readTables($this->sharding->getDefaultResource()) as $tableName) {
+ $columns = [];
+ $indexes = [];
+ $constraints = [];
+
+ $columnsData = $this->adapter->getColumnsList($tableName);
+ $indexesData = $this->adapter->getIndexesList($tableName);
+ $constrainsData = $this->adapter->getConstraintsList($tableName);
+
+ /** @var Table $table */
+ $table = $this->elementFactory->create('table', [
+ 'name' => $tableName
+ ]);
+
+ // Process columns
+ foreach ($columnsData as $columnData) {
+ $columnData = $this->casterAggregator->cast($columnData);
+ $columnData['table'] = $table;
+ $column = $this->elementFactory->create($columnData['type'], $columnData);
+ $columns[$column->getName()] = $column;
+ }
+
+ $table->addColumns($columns);
+ //Process indexes
+ foreach ($indexesData as $indexData) {
+ $indexData = $this->casterAggregator->cast($indexData);
+ $indexData['column'] = $this->resolveInternalRelations($columns, $indexData);
+ $indexData['table'] = $table;
+ $index = $this->elementFactory->create('index', $indexData);
+ $indexes[$index->getName()] = $index;
+ }
+ //Process internal constraints
+ foreach ($constrainsData as $constraintData) {
+ $constraintData = $this->casterAggregator->cast($constraintData);
+ $constraintData['column'] = $this->resolveInternalRelations($columns, $constraintData);
+ $constraintData['table'] = $table;
+ $constraint = $this->elementFactory->create($constraintData['type'], $constraintData);
+ $constraints[$constraint->getName()] = $constraint;
+ }
+
+ $table->addIndexes($indexes);
+ $table->addConstraints($constraints);
+ $tables[$table->getName()] = $table;
+ $structure->addTable($table);
+ }
+
+ $this->processReferenceKeys($tables);
+ return $structure;
+ }
+
+ /**
+ * Process references for all tables
+ *
+ * @param Table[] $tables
+ * @return Table[]
+ */
+ private function processReferenceKeys(array $tables)
+ {
+ foreach ($this->dbSchemaReader->readTables($this->sharding->getDefaultResource()) as $tableName) {
+ $referencesData = $this->adapter->getReferencesList($tableName);
+ $references = [];
+
+ foreach ($referencesData as $referenceData) {
+ //Prepare reference data
+ $referenceData = $this->casterAggregator->cast($referenceData);
+ $referenceData['table'] = $tables[$tableName];
+ $referenceData['column'] = $tables[$tableName]->getColumnByNameOrId($referenceData['column']);
+ $referenceData['referenceTable'] = $tables[$referenceData['referenceTable']];
+ $referenceData['referenceColumn'] = $referenceData['referenceTable']->getColumnByNameOrId(
+ $referenceData['referenceColumn']
+ );
+
+ $references[$referenceData['name']] = $this->elementFactory->create('foreign', $referenceData);
+ }
+
+ $tables[$tableName]->addConstraints($references);
+ }
+
+ return $tables;
+ }
+
+ /**
+ * Retrieve column objects from names
+ *
+ * @param Column[] $columns
+ * @param array $data
+ * @return Column[]
+ */
+ private function resolveInternalRelations(array $columns, array $data)
+ {
+ if (!is_array($data['column'])) {
+ throw new \InvalidArgumentException("Cannot find columns for internal index");
+ }
+
+ $referenceColumns = [];
+ foreach ($data['column'] as $columnName) {
+ if (!isset($columns[$columnName])) {
+ //Depends on business logic, we can either ignore non-existing column
+ //Or throw exception if db is not consistence and there is no column
+ //that was specified for key
+ //Right now we prefer to ignore such columns
+ } else {
+ $referenceColumns[] = $columns[$columnName];
+ }
+ }
+
+ return $referenceColumns;
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/DynamicStructureInterface.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/DynamicStructureInterface.php
new file mode 100644
index 0000000000000..53037acc3a1cb
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/DynamicStructureInterface.php
@@ -0,0 +1,50 @@
+ [
+ * table => [
+ * store_website => [
+ * field => [
+ * website_id => [
+ * type => smallint,
+ * unsigned => 1,
+ * identity => 1,
+ * name => 'website_id'
+ * ]
+ * ],
+ * name => store_website
+ * ]
+ * ]
+ * ]
+ *
+ * @return array
+ */
+ public function getStructure();
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/Parser.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/Parser.php
new file mode 100644
index 0000000000000..d07db90d6186c
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/Parser.php
@@ -0,0 +1,62 @@
+reader = $reader;
+ $this->structureBuilder = $structureBuilder;
+ $this->dynamicStructure = $dynamicStructure;
+ }
+
+ /**
+ * Convert XML to object representation
+ *
+ * @param Structure $structure
+ * @return Structure
+ */
+ public function parse(Structure $structure)
+ {
+ $info = $this->reader->read();
+ $info = array_replace_recursive($info, $this->dynamicStructure->getStructure());
+ $this->structureBuilder->addTablesData($info['table']);
+ $structure = $this->structureBuilder->build($structure);
+ return $structure;
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/Structure/Dynamic.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/Structure/Dynamic.php
new file mode 100644
index 0000000000000..af42d3cf3f8b5
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/Structure/Dynamic.php
@@ -0,0 +1,23 @@
+sharding = $sharding;
+ $this->elementFactory = $elementFactory;
+ $this->booleanUtils = $booleanUtils;
+ }
+
+ /**
+ * Add tables data to builder
+ * Tables data holds tables information: columns, constraints, indexes, attributes
+ *
+ * @param array $tablesData
+ * @return self
+ */
+ public function addTablesData(array $tablesData)
+ {
+ $this->tablesData = $tablesData;
+ return $this;
+ }
+
+ /**
+ * Build structure
+ *
+ * @param Structure $structure
+ * @return Structure
+ */
+ public function build(Structure $structure)
+ {
+ foreach ($this->tablesData as $tableData) {
+ if (!$structure->getTableByName($tableData['name'])) {
+ if (!$this->isDisabled($tableData)) {
+ $this->processTable($structure, $tableData);
+ }
+ }
+ }
+
+ return $structure;
+ }
+
+ /**
+ * If some element was renamed, we need to retrieve new name instead of old one
+ *
+ * @param array $elementData
+ * @return string
+ */
+ private function resolveElementName(array $elementData)
+ {
+ return isset($elementData['renameTo']) ? $elementData['renameTo'] : $elementData['name'];
+ }
+
+ /**
+ * If element was renamed or should be renamed we need to retrieve its old name
+ * In order to do rename in future or in order to do compare
+ *
+ * @param array $elementData
+ * @return string
+ */
+ private function wasRenamedFrom(array $elementData)
+ {
+ return isset($elementData['renameTo']) ? $elementData['name'] : null;
+ }
+
+ /**
+ * @param array $tableData
+ * @return string
+ */
+ private function getStructuralElementResource(array $tableData)
+ {
+ return isset($tableData['resource']) && $this->sharding->canUseResource($tableData['resource']) ?
+ $tableData['resource'] : 'default';
+ }
+
+ /**
+ * Check whether element is disabled and should not appear in final declaration
+ *
+ * @param array $structuralElementData
+ * @return bool
+ */
+ private function isDisabled(array $structuralElementData)
+ {
+ return isset($structuralElementData['disabled']) &&
+ $this->booleanUtils->toBoolean($structuralElementData['disabled']);
+ }
+
+ /**
+ * Instantiate column DTO objects from array
+ * If column was renamed new key will be associated to it
+ *
+ * @param array $tableData
+ * @param string $resource
+ * @param Table $table
+ * @return array
+ */
+ private function processColumns(array $tableData, $resource, Table $table)
+ {
+ $columns = [];
+
+ foreach ($tableData['column'] as $columnData) {
+ if ($this->isDisabled($columnData)) {
+ continue;
+ }
+
+ $columnData = $this->processGenericData($columnData, $resource, $table);
+ $column = $this->elementFactory->create($columnData['type'], $columnData);
+ $columns[$column->getName()] = $column;
+ }
+
+ return $columns;
+ }
+
+ /**
+ * Process generic data that is support by all 3 child types: columns, constraints, indexes
+ *
+ * @param array $elementData
+ * @param Table $table
+ * @param $resource
+ * @return array
+ */
+ private function processGenericData(array $elementData, $resource, Table $table)
+ {
+ $elementData['wasRenamedFrom'] = $this->wasRenamedFrom($elementData);
+ $elementData['name'] = $this->resolveElementName($elementData);
+ $elementData['table'] = $table;
+ $elementData['resource'] = $resource;
+
+ return $elementData;
+ }
+
+ /**
+ * Process tables and add them to structure
+ * If table already exists - then we need to skip it
+ *
+ * @param Structure $structure
+ * @param array $tableData
+ * @return \Magento\Setup\Model\Declaration\Schema\Dto\Table
+ */
+ private function processTable(Structure $structure, array $tableData)
+ {
+ if (!$structure->getTableByNameOrId($tableData['name'])) {
+ $resource = $this->getStructuralElementResource($tableData);
+ $tableParams = [
+ 'name' => $this->resolveElementName($tableData),
+ 'resource' => $resource,
+ 'wasRenamedFrom' => $this->wasRenamedFrom($tableData)
+ ];
+ /** @var Table $table */
+ $table = $this->elementFactory->create('table', $tableParams);
+ $columns = $this->processColumns($tableData, $resource, $table);
+ $table->addColumns($columns);
+ $structure->addTable($table);
+ //Add indexes to table
+ $table->addIndexes($this->processIndexes($tableData, $resource, $table));
+ //Add internal and reference constraints
+ $table->addConstraints($this->processConstraints($tableData, $resource, $structure));
+ }
+
+ return $structure->getTableByNameOrId($tableData['name']);
+ }
+
+ /**
+ * Convert column names to objects
+ *
+ * @param array $columnNames
+ * @param Table $table
+ * @return array
+ */
+ private function convertColumnNamesToObjects(array $columnNames, Table $table)
+ {
+ $columns = [];
+
+ foreach ($columnNames as $columnName) {
+ $columns[] = $table->getColumnByNameOrId($columnName);
+ }
+
+ return $columns;
+ }
+
+ /**
+ * Convert and instantiate index objects
+ *
+ * @param array $tableData
+ * @param $resource
+ * @param Table $table
+ * @return Index[]
+ */
+ private function processIndexes(array $tableData, $resource, Table $table)
+ {
+ if (!isset($tableData['index'])) {
+ return [];
+ }
+
+ $indexes = [];
+
+ foreach ($tableData['index'] as $indexData) {
+ if ($this->isDisabled($indexData)) {
+ continue;
+ }
+
+ $indexData = $this->processGenericData($indexData, $resource, $table);
+ $indexData['column'] = $this->convertColumnNamesToObjects($indexData['column'], $table);
+ $index = $this->elementFactory->create('index', $indexData);
+ $indexes[$index->getName()] = $index;
+ }
+
+ return $indexes;
+ }
+
+ /**
+ * Convert and instantiate constraint objects
+ *
+ * @param array $tableData
+ * @param $resource
+ * @param Structure $structure
+ * @return Constraint[]
+ */
+ private function processConstraints(array $tableData, $resource, Structure $structure)
+ {
+ if (!isset($tableData['constraint'])) {
+ return [];
+ }
+
+ $constraints = [];
+
+ foreach ($tableData['constraint'] as $constraintData) {
+ if ($this->isDisabled($constraintData)) {
+ continue;
+ }
+ $table = $structure->getTableByName($tableData['name']);
+ $constraintData = $this->processGenericData($constraintData, $resource, $table);
+ //As foreign constraint has different structure we need to process it in different way
+ if ($constraintData['type'] === 'foreign') {
+ $constraintData['column'] = $table->getColumnByNameOrId(
+ $constraintData['column']
+ );
+ //always in foreign key name will be old and in raw data will be always old too
+ $structure->addTable(
+ $this->processTable(
+ $structure,
+ $this->tablesData[$constraintData['referenceTable']]
+ )
+ );
+ $constraintData['referenceTable'] = $structure->getTableByNameOrId(
+ $constraintData['referenceTable']
+ );
+
+ if (!$constraintData['referenceTable']) {
+ throw new \LogicException("Cannot find reference table");
+ }
+
+ $constraintData['referenceColumn'] = $constraintData['referenceTable']->getColumnByNameOrId(
+ $constraintData['referenceColumn']
+ );
+ } else {
+ $constraintData['column'] = $this->convertColumnNamesToObjects($constraintData['column'], $table);
+ }
+
+ $constraint = $this->elementFactory->create($constraintData['type'], $constraintData);
+ $constraints[$constraint->getName()] = $constraint;
+ }
+
+ return $constraints;
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/DiffManager.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/DiffManager.php
new file mode 100644
index 0000000000000..4b95346fbca8d
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/DiffManager.php
@@ -0,0 +1,162 @@
+getName() !== $element->wasRenamedFrom() && $element->wasRenamedFrom() !== null;
+ }
+
+ /**
+ * Check whether this is element is new or not, by checking it in db structure
+ *
+ * @param ElementInterface[] $generatedElements
+ * @param ElementInterface | ElementRenamedInterface $element
+ * @return bool
+ */
+ public function shouldBeCreatedOrRenamed(array $generatedElements, ElementInterface $element)
+ {
+ return
+ !isset($generatedElements[$element->getName()]) ||
+ $this->shouldBeRenamed($element) && !isset($generatedElements[$element->wasRenamedFrom()]);
+ }
+
+ /**
+ * Check whether we have elements that should be removed from database
+ *
+ * @param array $generatedElements
+ * @return bool
+ */
+ public function shouldBeRemoved(array $generatedElements)
+ {
+ return !empty($generatedElements);
+ }
+
+ /**
+ * Register element, that should changes
+ *
+ *
+ * @param ChangeRegistryInterface $changeRegistry
+ * @param ElementInterface $element
+ * @param ElementInterface $generatedElement
+ */
+ public function registerModification(
+ ChangeRegistryInterface $changeRegistry,
+ ElementInterface $element,
+ ElementInterface $generatedElement
+ ) {
+ $changeRegistry->register(
+ $element,
+ $element->getElementType(),
+ ChangeRegistryInterface::CHANGE_OPERATION,
+ $generatedElement
+ );
+ }
+
+ /**
+ * If elements really dont exists in declaration - we will remove them
+ * If some mistake happens (and element is just not preprocessed), we will throw exception
+ *
+ * @param ChangeRegistryInterface $changeRegistry
+ * @param ElementInterface[] $generatedElements
+ * @param ElementInterface[] $elements
+ */
+ public function registerRemoval(
+ ChangeRegistryInterface $changeRegistry,
+ array $generatedElements,
+ array $elements
+ ) {
+ foreach ($generatedElements as $generatedElement) {
+ if (isset($elements[$generatedElement->getName()])) {
+ throw new \LogicException(
+ sprintf(
+ "Cannot find difference for element with name %s",
+ $generatedElement->getName()
+ )
+ );
+ }
+
+ $changeRegistry->register(
+ $generatedElement,
+ $generatedElement->getElementType(),
+ ChangeRegistryInterface::REMOVE_OPERATION
+ );
+ }
+ }
+
+ /**
+ * After registration rename, we need to remove renamed element from generated structure
+ * in order to prevent double registration of this object
+ *
+ * @param ChangeRegistryInterface $changeRegistry
+ * @param ElementInterface | ElementRenamedInterface $element
+ * @param array $generatedElements
+ * @return array
+ */
+ public function registerRename(
+ ChangeRegistryInterface $changeRegistry,
+ ElementInterface $element,
+ array $generatedElements
+ ) {
+ $changeRegistry->register(
+ $element,
+ $element->getElementType(),
+ ChangeRegistryInterface::RENAME_OPERAION,
+ $generatedElements[$element->wasRenamedFrom()]
+ );
+
+ unset($generatedElements[$element->wasRenamedFrom()]);
+ return $generatedElements;
+ }
+
+ /**
+ * @param ChangeRegistryInterface $changeRegistry
+ * @param ElementInterface $element
+ */
+ public function registerCreation(ChangeRegistryInterface $changeRegistry, ElementInterface $element)
+ {
+ $changeRegistry->register(
+ $element,
+ $element->getElementType(),
+ ChangeRegistryInterface::CREATE_OPERATION
+ );
+ }
+
+ /**
+ * Check whether element should be modified or not
+ *
+ * @param Comparator $comparator
+ * @param ElementInterface $element
+ * @param ElementInterface $generatedElement
+ * @return bool
+ */
+ public function shouldBeModified(
+ Comparator $comparator,
+ ElementInterface $element,
+ ElementInterface $generatedElement
+ ) {
+ return !$comparator->compare($element, $generatedElement);
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/StructureDiff.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/StructureDiff.php
new file mode 100644
index 0000000000000..1a77f9a82d359
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/StructureDiff.php
@@ -0,0 +1,64 @@
+tableDiff = $tableDiff;
+ }
+
+ /**
+ * @param Structure $structure
+ * @param Structure $generatedStructure
+ * @param ChangeRegistry $changeRegistry
+ */
+ public function diff(
+ Structure $structure,
+ Structure $generatedStructure,
+ ChangeRegistry $changeRegistry
+ ) {
+ $generatedTables = $generatedStructure->getTables();
+
+ foreach ($structure->getTables() as $name => $table) {
+ if ($this->shouldBeCreatedOrRenamed($generatedTables, $table)) {
+ if ($this->shouldBeRenamed($table)) {
+ $generatedTables = $this->registerRename($changeRegistry, $table, $generatedTables);
+ } else {
+ $this->registerCreation($changeRegistry, $table);
+ }
+ } else {
+ $this->tableDiff->diff($table, $generatedTables[$name], $changeRegistry);
+ }
+
+ unset($generatedTables[$name]);
+ }
+ //Removal process
+ if ($this->shouldBeRemoved($generatedTables)) {
+ $this->registerRemoval($changeRegistry, $generatedTables, $structure->getTables());
+ }
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/TableDiff.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/TableDiff.php
new file mode 100644
index 0000000000000..65493a8795318
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/TableDiff.php
@@ -0,0 +1,88 @@
+comparator = $comparator;
+ }
+
+ /**
+ * @param Table | ElementInterface $declaredTable
+ * @param Table | ElementInterface $generatedTable
+ * @param ChangeRegistry $changeRegistry
+ * @inheritdoc
+ */
+ public function diff(
+ ElementInterface $declaredTable,
+ ElementInterface $generatedTable,
+ ChangeRegistry $changeRegistry
+ ) {
+ $types = [self::COLUMN_DIFF_TYPE, self::CONSTRAINT_DIFF_TYPE, self::INDEX_DIFF_TYPE];
+ //We do inspection for each element type
+ foreach ($types as $elementType) {
+ $generatedElements = $generatedTable->getElementsByType($elementType);
+ $declaredElements = $declaredTable->getElementsByType($elementType);
+
+ foreach ($declaredElements as $element) {
+ //If it is new for generated (generated from db) elements - we need to create it
+ if ($this->shouldBeCreatedOrRenamed($generatedElements, $element)) {
+ if ($this->shouldBeRenamed($element)) {
+ $generatedElements = $this->registerRename($changeRegistry, $element, $generatedElements);
+ } else {
+ $this->registerCreation($changeRegistry, $element);
+ }
+ } else if ($this->shouldBeModified(
+ $this->comparator,
+ $element,
+ $generatedElements[$element->getName()]
+ )) {
+ $this->registerModification($changeRegistry, $element, $generatedElements[$element->getName()]);
+ }
+ //Unset processed elements from generated from db structure
+ //All other unprocessed elements will be added as removed ones
+ unset($generatedElements[$element->getName()]);
+ }
+
+ //Elements that should be removed
+ if ($this->shouldBeRemoved($generatedElements)) {
+ $this->registerRemoval($changeRegistry, $generatedElements, $declaredElements);
+ }
+ }
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/DiffInterface.php b/setup/src/Magento/Setup/Model/Declaration/Schema/DiffInterface.php
new file mode 100644
index 0000000000000..388342a2339b3
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/DiffInterface.php
@@ -0,0 +1,30 @@
+structuralElementData = $structuralElementData;
+ $this->elementType = $elementType;
+ }
+
+ /**
+ * Retrieve table name
+ *
+ * @return string
+ */
+ public function getTable()
+ {
+ return $this->structuralElementData['table'];
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Blob.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Blob.php
new file mode 100644
index 0000000000000..54ac06d91bd04
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Blob.php
@@ -0,0 +1,48 @@
+structuralElementData['nullable']) && $this->structuralElementData['nullable'];
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function getDiffSensitiveParams()
+ {
+ return [
+ 'type' => $this->elementType,
+ 'nullable' => $this->isNullable()
+ ];
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Boolean.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Boolean.php
new file mode 100644
index 0000000000000..3bbccd0d92c7d
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Boolean.php
@@ -0,0 +1,70 @@
+structuralElementData['nullable']) && $this->structuralElementData['nullable'];
+ }
+
+ /**
+ * Check whether column has default value
+ *
+ * @return bool
+ */
+ public function hasDefault()
+ {
+ return isset($this->structuralElementData['default']);
+ }
+
+ /**
+ * Return default value
+ * Note: default value should be float
+ *
+ * @return float | null
+ */
+ public function getDefault()
+ {
+ return $this->hasDefault() ? $this->structuralElementData['default'] : null;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function getDiffSensitiveParams()
+ {
+ return [
+ 'type' => $this->elementType,
+ 'nullable' => $this->isNullable(),
+ 'default' => $this->getDefault()
+ ];
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Date.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Date.php
new file mode 100644
index 0000000000000..2e9b5d4e68069
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Date.php
@@ -0,0 +1,38 @@
+ $this->elementType
+ ];
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Decimal.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Decimal.php
new file mode 100644
index 0000000000000..935124f45a20f
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Decimal.php
@@ -0,0 +1,104 @@
+structuralElementData['precission'];
+ }
+
+ /**
+ * Column scale
+ *
+ * @return int
+ */
+ public function getScale()
+ {
+ return $this->structuralElementData['scale'];
+ }
+
+ /**
+ * Check whether column can be nullable
+ *
+ * @return bool
+ */
+ public function isNullable()
+ {
+ return isset($this->structuralElementData['nullable']) && $this->structuralElementData['nullable'];
+ }
+
+ /**
+ * Check whether column has default value
+ *
+ * @return bool
+ */
+ public function hasDefault()
+ {
+ return isset($this->structuralElementData['default']);
+ }
+
+ /**
+ * Return default value
+ * Note: default value should be float
+ *
+ * @return float | null
+ */
+ public function getDefault()
+ {
+ return $this->hasDefault() ? $this->structuralElementData['default'] : null;
+ }
+
+ /**
+ * Check whether element is unsigned or not
+ *
+ * @return bool
+ */
+ public function isUnsigned()
+ {
+ return isset($this->structuralElementData['unsigned']) && $this->structuralElementData['unsigned'];
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function getDiffSensitiveParams()
+ {
+ return [
+ 'type' => $this->elementType,
+ 'nullable' => $this->isNullable(),
+ 'precission' => $this->getPrecission(),
+ 'scale' => $this->getScale(),
+ 'unsigned' => $this->isUnsigned(),
+ 'default' => $this->getDefault()
+ ];
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Integer.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Integer.php
new file mode 100644
index 0000000000000..dc0ebc5d5e44e
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Integer.php
@@ -0,0 +1,104 @@
+structuralElementData['padding'];
+ }
+
+ /**
+ * Check whether column can be nullable
+ *
+ * @return bool
+ */
+ public function isNullable()
+ {
+ return isset($this->structuralElementData['nullable']) && $this->structuralElementData['nullable'];
+ }
+
+ /**
+ * Check whether column has default value
+ *
+ * @return bool
+ */
+ public function hasDefault()
+ {
+ return isset($this->structuralElementData['default']);
+ }
+
+ /**
+ * Return default value
+ * Note: default value should be int
+ *
+ * @return int | null
+ */
+ public function getDefault()
+ {
+ return $this->hasDefault() ? $this->structuralElementData['default'] : null;
+ }
+
+ /**
+ * Check whether element is unsigned or not
+ *
+ * @return bool
+ */
+ public function isUnsigned()
+ {
+ return isset($this->structuralElementData['unsigned']) && $this->structuralElementData['unsigned'];
+ }
+
+ /**
+ * Define whether column can be autoincremented or not
+ *
+ * @return bool
+ */
+ public function isIdentity()
+ {
+ return isset($this->structuralElementData['identity']) && $this->structuralElementData['identity'];
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function getDiffSensitiveParams()
+ {
+ return [
+ 'type' => $this->elementType,
+ 'nullable' => $this->isNullable(),
+ 'padding' => $this->getPadding(),
+ 'unsigned' => $this->isUnsigned(),
+ 'identity' => $this->isIdentity(),
+ 'default' => $this->getDefault()
+ ];
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Text.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Text.php
new file mode 100644
index 0000000000000..1e1eac1c146a0
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Text.php
@@ -0,0 +1,48 @@
+structuralElementData['nullable']) && $this->structuralElementData['nullable'];
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function getDiffSensitiveParams()
+ {
+ return [
+ 'type' => $this->elementType,
+ 'nullable' => $this->isNullable(),
+ ];
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Timestamp.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Timestamp.php
new file mode 100644
index 0000000000000..269c94400478e
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Timestamp.php
@@ -0,0 +1,71 @@
+structuralElementData['default'];
+ }
+
+ /**
+ * on_update is optional param
+ *
+ * @return bool
+ */
+ public function hasOnUpdate()
+ {
+ return isset($this->structuralElementData['on_update']);
+ }
+
+ /**
+ * Retrieve on_update param
+ *
+ * @return string
+ */
+ public function getOnUpdate()
+ {
+ return $this->hasOnUpdate() ? $this->structuralElementData['on_update'] : null;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function getDiffSensitiveParams()
+ {
+ return [
+ 'type' => $this->elementType,
+ 'default' => $this->getDefault(),
+ 'onUpdate' => $this->getOnUpdate()
+ ];
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Varbinary.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Varbinary.php
new file mode 100644
index 0000000000000..87629d68524a0
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Varbinary.php
@@ -0,0 +1,81 @@
+structuralElementData['nullable']) && $this->structuralElementData['nullable'];
+ }
+
+ /**
+ * Check whether column has default value
+ *
+ * @return bool
+ */
+ public function hasDefault()
+ {
+ return isset($this->structuralElementData['default']);
+ }
+
+ /**
+ * Return default value
+ * Note: default value should be string
+ *
+ * @return string | null
+ */
+ public function getDefault()
+ {
+ return $this->hasDefault() ? $this->structuralElementData['default'] : null;
+ }
+
+ /**
+ * Length can be integer value from 0 to 255
+ *
+ * @return int
+ */
+ public function getLength()
+ {
+ return $this->structuralElementData['length'];
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function getDiffSensitiveParams()
+ {
+ return [
+ 'type' => $this->elementType,
+ 'nullable' => $this->isNullable(),
+ 'default' => $this->getDefault(),
+ 'length' => $this->getLength()
+ ];
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Varchar.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Varchar.php
new file mode 100644
index 0000000000000..ec10803e7c76b
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Varchar.php
@@ -0,0 +1,81 @@
+structuralElementData['nullable']) && $this->structuralElementData['nullable'];
+ }
+
+ /**
+ * Check whether column has default value
+ *
+ * @return bool
+ */
+ public function hasDefault()
+ {
+ return isset($this->structuralElementData['default']);
+ }
+
+ /**
+ * Return default value
+ * Note: default value should be string
+ *
+ * @return string | null
+ */
+ public function getDefault()
+ {
+ return $this->hasDefault() ? $this->structuralElementData['default'] : null;
+ }
+
+ /**
+ * Length can be integer value from 0 to 255
+ *
+ * @return int
+ */
+ public function getLength()
+ {
+ return $this->structuralElementData['length'];
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function getDiffSensitiveParams()
+ {
+ return [
+ 'type' => $this->elementType,
+ 'nullable' => $this->isNullable(),
+ 'default' => $this->getDefault(),
+ 'length' => $this->getLength()
+ ];
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Constraint.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Constraint.php
new file mode 100644
index 0000000000000..c950a02fdd4d3
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Constraint.php
@@ -0,0 +1,45 @@
+structuralElementData = $structuralElementData;
+ $this->elementType = $elementType;
+ }
+
+ /**
+ * Retrieve table name
+ *
+ * @return Table
+ */
+ public function getTable()
+ {
+ return $this->structuralElementData['table'];
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Constraints/Internal.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Constraints/Internal.php
new file mode 100644
index 0000000000000..9c9225513ba17
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Constraints/Internal.php
@@ -0,0 +1,57 @@
+structuralElementData['column'];
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function getDiffSensitiveParams()
+ {
+ return [
+ 'type' => $this->elementType,
+ 'columns' => array_map(
+ function (Column $column) {
+ return $column->getName();
+ },
+ $this->getColumns()
+ )
+ ];
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Constraints/Reference.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Constraints/Reference.php
new file mode 100644
index 0000000000000..1482bd0ec929c
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Constraints/Reference.php
@@ -0,0 +1,83 @@
+structuralElementData['column'];
+ }
+
+ /**
+ * External column, from table to where we do reference
+ *
+ * @return Column
+ */
+ public function getReferenceColumn()
+ {
+ return $this->structuralElementData['referenceColumn'];
+ }
+
+ /**
+ * External table to where we do reference
+ *
+ *
+ * @return Table
+ */
+ public function getReferenceTable()
+ {
+ return $this->structuralElementData['referenceTable'];
+ }
+
+ /**
+ * Trigger param, which attach custom action, on delete value from reference table
+ *
+ * @return string
+ */
+ public function getOnDelete()
+ {
+ return $this->structuralElementData['onDelete'];
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function getDiffSensitiveParams()
+ {
+ return [
+ 'type' => $this->elementType,
+ 'column' => $this->getColumn()->getName(),
+ 'referenceColumn' => $this->getReferenceColumn()->getName(),
+ 'referenceTableName' => $this->getReferenceTable()->getName(),
+ 'tableName' => $this->getTable()->getName(),
+ 'onDelete' => $this->getOnDelete()
+ ];
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/ElementDiffAwareInterface.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/ElementDiffAwareInterface.php
new file mode 100644
index 0000000000000..c00a1cb191550
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/ElementDiffAwareInterface.php
@@ -0,0 +1,25 @@
+ '2'
+ * identity => null
+ *
+ * Such params as name, renamedTo, disabled, tableName should be avoided here
+ * As this params are system and must not participate in comparison at all
+ *
+ * @return array
+ */
+ public function getDiffSensitiveParams();
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/ElementFactory.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/ElementFactory.php
new file mode 100644
index 0000000000000..185e2d32d55b2
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/ElementFactory.php
@@ -0,0 +1,47 @@
+types = $types;
+ }
+
+ /**
+ * Instantiate different types of elements, depends on their xsi:type
+ *
+ * @param string $type
+ * @param array $elementStructuralData
+ * @return ElementInterface | object
+ */
+ public function create($type, array $elementStructuralData)
+ {
+ if (!isset($this->types[$type])) {
+ throw new \InvalidArgumentException(sprintf("Types %s is not declared", $type));
+ }
+
+ $elementStructuralData['type'] = $type;
+ return new $this->types[$type]($elementStructuralData, $type);
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/ElementInterface.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/ElementInterface.php
new file mode 100644
index 0000000000000..1538820bba929
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/ElementInterface.php
@@ -0,0 +1,37 @@
+structuralElementData['name'];
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function getResource()
+ {
+ return $this->structuralElementData['resource'];
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function wasRenamedFrom()
+ {
+ return $this->structuralElementData['wasRenamedFrom'];
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function getElementType()
+ {
+ return $this->elementType;
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Index.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Index.php
new file mode 100644
index 0000000000000..7e0dc0f2a5f86
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Index.php
@@ -0,0 +1,72 @@
+structuralElementData = $structuralElementData;
+ $this->elementType = $elementType;
+ }
+
+ /**
+ * Return columns in order, in which they should go in composite index
+ *
+ * @return Column[]
+ */
+ public function getColumns()
+ {
+ return $this->structuralElementData['column'];
+ }
+
+ /**
+ * Retrieve table name
+ *
+ * @return Table
+ */
+ public function getTable()
+ {
+ return $this->structuralElementData['table'];
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function getDiffSensitiveParams()
+ {
+ return [
+ 'type' => $this->elementType,
+ 'columns' => array_map(
+ function (Column $column) {
+ return $column->getName();
+ },
+ $this->getColumns()
+ )
+ ];
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Structure.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Structure.php
new file mode 100644
index 0000000000000..5a420579b170f
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Structure.php
@@ -0,0 +1,72 @@
+tables;
+ }
+
+ /**
+ * Add table by name key to tables registry
+ *
+ * @param Table $table
+ * @return $this
+ */
+ public function addTable(Table $table)
+ {
+ $this->tables[$table->getName()] = $table;
+ return $this;
+ }
+
+ /**
+ * Try to find table by its name or by its old name, that was specified as id
+ *
+ * @param string $nameOrId
+ * @return null | Table
+ */
+ public function getTableByNameOrId($nameOrId)
+ {
+ if (isset($this->tables[$nameOrId])) {
+ return $this->tables[$nameOrId];
+ }
+
+ foreach ($this->tables as $table) {
+ if ($table->wasRenamedFrom() === $nameOrId) {
+ return $table;
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * Retrieve table by it name
+ *
+ * @param $name
+ * @return bool|Table
+ */
+ public function getTableByName($name)
+ {
+ return isset($this->tables[$name]) ? $this->tables[$name] : false;
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/StructureFactory.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/StructureFactory.php
new file mode 100644
index 0000000000000..c88d375785630
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/StructureFactory.php
@@ -0,0 +1,45 @@
+zendDi = $zendDi;
+ }
+
+ /**
+ * Create class instance with specified parameters
+ *
+ * @param array $data
+ * @return \Magento\Setup\Model\Declaration\Schema\Dto\Structure | object
+ */
+ public function create(array $data = [])
+ {
+ return $this->zendDi->newInstance($this->instanceName, $data);
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Table.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Table.php
new file mode 100644
index 0000000000000..457d5d840a896
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Table.php
@@ -0,0 +1,188 @@
+structuralElementData = $structuralElementData;
+ }
+
+ /**
+ * Return different table constraints.
+ * It can be constraint like unique key or reference to another table, etc
+ *
+ * @return Constraint[]
+ */
+ public function getConstraints()
+ {
+ return $this->constraints;
+ }
+
+ /**
+ * @param string $name
+ * @return Constraint | bool
+ */
+ public function getConstraintByName($name)
+ {
+ return isset($this->constraints[$name]) ? $this->constraints[$name] : false;
+ }
+
+ /**
+ * As primary constraint always have one name
+ * and can be only one for table
+ * it name is allocated into it constraint
+ *
+ * @return bool|Constraint
+ */
+ public function getPrimaryConstraint()
+ {
+ return isset($this->constraints[Internal::PRIMARY_NAME]) ?
+ $this->constraints[Internal::PRIMARY_NAME] :
+ false;
+ }
+
+ /**
+ * @param string $name
+ * @return Index | bool
+ */
+ public function getIndexByName($name)
+ {
+ return isset($this->indexes[$name]) ? $this->indexes[$name] : false;
+ }
+
+ /**
+ * Return all columns.
+ * Note, table always must have columns
+ *
+ * @return Column[]
+ */
+ public function getColumns()
+ {
+ return $this->columns;
+ }
+
+ /**
+ * Return all indexes, that are applied to table
+ *
+ * @return Index[]
+ */
+ public function getIndexes()
+ {
+ return $this->indexes;
+ }
+
+ /**
+ * This is workaround, as any DTO object couldnt be changed after instantiation.
+ * However there is case, when we have 2 tables with constraints in different tables,
+ * that depends to each other table. So we need to setup DTO first and only then pass
+ * problematic constraints to it, in order to avoid circular dependency.
+ *
+ * @param Constraint[] $constraints
+ */
+ public function addConstraints(array $constraints)
+ {
+ $this->constraints = array_replace($this->constraints, $constraints);
+ }
+
+ /**
+ * Add columns
+ *
+ * @param Column[] $columns
+ */
+ public function addColumns(array $columns)
+ {
+ $this->columns = array_replace($this->columns, $columns);
+ }
+
+ /**
+ * If we want to rename our column: then it name will be changed
+ * But we want to search by old name
+ * As this name can be used in constraints and indexes
+ *
+ * @param string $nameOrId
+ * @return Column
+ */
+ public function getColumnByNameOrId($nameOrId)
+ {
+ if (isset($this->columns[$nameOrId])) {
+ return $this->columns[$nameOrId];
+ }
+
+ //If it was renamed
+ foreach ($this->columns as $column) {
+ if ($column->wasRenamedFrom() === $nameOrId) {
+ return $column;
+ }
+ }
+
+ throw new \LogicException(sprintf("Cannot find column with name or id %s", $nameOrId));
+ }
+
+ /**
+ * Retrieve elements by specific type
+ * Allowed types: columns, constraints, indexes...
+ *
+ * @param string $type
+ * @return ElementInterface[] | ElementRenamedInterface[]
+ */
+ public function getElementsByType($type)
+ {
+ if (!isset($this->{$type})) {
+ throw new \InvalidArgumentException(sprintf("Type %s is not defined", $type));
+ }
+
+ return $this->{$type};
+ }
+
+ /**
+ * This is workaround, as any DTO object couldnt be changed after instantiation.
+ * However there is case, when we depends on column definition we need modify our indexes
+ *
+ * @param array $indexes
+ */
+ public function addIndexes(array $indexes)
+ {
+ $this->indexes = array_replace($this->indexes, $indexes);
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/TableElementInterface.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/TableElementInterface.php
new file mode 100644
index 0000000000000..461c356edf4f5
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/TableElementInterface.php
@@ -0,0 +1,21 @@
+ $this->batchSize) {
+ $iterator = 0;
+ $finalData = $data;
+ $data = [];
+ yield $finalData;
+ }
+
+ $data[] = $rowData;
+ }
+
+ fclose($fh);
+ yield $data;
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/FileSystem/Reader.php b/setup/src/Magento/Setup/Model/Declaration/Schema/FileSystem/Reader.php
new file mode 100644
index 0000000000000..914c0eea3b059
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/FileSystem/Reader.php
@@ -0,0 +1,61 @@
+ 'name',
+ '/schema/table/column' => 'name',
+ '/schema/table/constraint' => 'name',
+ '/schema/table/index' => 'name',
+ '/schema/table/index/column' => 'name',
+ '/schema/table/constraint/column' => 'name',
+ ];
+
+ /**
+ * Reader constructor.
+ * @param \Magento\Framework\Config\FileResolverInterface $fileResolver
+ * @param \Magento\Setup\Model\Declaration\Schema\Xml\Converter $converter
+ * @param \Magento\Setup\Model\Declaration\Schema\Xml\SchemaLocator $schemaLocator
+ * @param \Magento\Framework\Config\ValidationStateInterface $validationState
+ * @param string $fileName
+ * @param string $domDocumentClass
+ * @param string $defaultScope
+ */
+ public function __construct(
+ \Magento\Framework\Config\FileResolverInterface $fileResolver,
+ \Magento\Setup\Model\Declaration\Schema\Xml\Converter $converter,
+ \Magento\Setup\Model\Declaration\Schema\Xml\SchemaLocator $schemaLocator,
+ \Magento\Framework\Config\ValidationStateInterface $validationState,
+ $fileName = 'schema.xml',
+ $domDocumentClass = \Magento\Framework\Config\Dom::class,
+ $defaultScope = 'global'
+ ) {
+ parent::__construct(
+ $fileResolver,
+ $converter,
+ $schemaLocator,
+ $validationState,
+ $fileName,
+ $this->idAttributes,
+ $domDocumentClass,
+ $defaultScope
+ );
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Request.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Request.php
new file mode 100644
index 0000000000000..d6b32ed227db4
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Request.php
@@ -0,0 +1,43 @@
+dumpEnable = (bool) $request[static::DUMP_ENABLE_OPTIONS];
+ }
+ }
+
+ /**
+ * Check whether dump is enabled or not
+ *
+ * @return boolean
+ */
+ public function isDumpEnabled()
+ {
+ return $this->dumpEnable;
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/RequestFactory.php b/setup/src/Magento/Setup/Model/Declaration/Schema/RequestFactory.php
new file mode 100644
index 0000000000000..0a7c5161819c8
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/RequestFactory.php
@@ -0,0 +1,48 @@
+zendDi = $zendDi;
+ }
+
+ /**
+ * Create request object with requestOptions params
+ *
+ * @param array $requestOptions
+ * @return Request
+ */
+ public function create(array $requestOptions = [])
+ {
+ return $this->zendDi->newInstance(
+ self::$instanceName,
+ ['request' => $requestOptions]
+ );
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/SchemaParserInterface.php b/setup/src/Magento/Setup/Model/Declaration/Schema/SchemaParserInterface.php
new file mode 100644
index 0000000000000..28f822b78bfac
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/SchemaParserInterface.php
@@ -0,0 +1,23 @@
+deploymentConfig = $deploymentConfig;
+ }
+
+ /**
+ * Check whether our resource is valid one
+ *
+ * @param string $scopeName
+ * @return bool
+ */
+ public function canUseResource($scopeName)
+ {
+ $connections = $this->deploymentConfig->get(ConfigOptionsListConstants::CONFIG_PATH_DB_CONNECTIONS);
+ return isset($connections[$scopeName]);
+ }
+
+ /**
+ * Retrieve default resource name, that is used by the system
+ *
+ * @return string
+ */
+ public function getDefaultResource()
+ {
+ return 'default';
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Xml/Converter.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Xml/Converter.php
new file mode 100644
index 0000000000000..6a8f5b4623060
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Xml/Converter.php
@@ -0,0 +1,138 @@
+casterAggregator = $casterAggregator;
+ }
+
+ /**
+ * Convert config from XML to array
+ *
+ * @param \DOMDocument $source
+ * @return array
+ */
+ public function convert($source)
+ {
+ $output = $this->recursiveConvert($this->getTablesNode($source));
+ return $output;
+ }
+
+ /**
+ * We exaclty know, that our schema is consists from tables
+ * So we do not need root elements in result, only table names
+ * So proposed to select only tables from all DomDOCUMENT
+ *
+ * @param \DOMDocument $element
+ * @return \DOMNodeList
+ */
+ private function getTablesNode(\DOMDocument $element)
+ {
+ return $element->getElementsByTagName('table');
+ }
+
+ /**
+ * @param \Traversable $source
+ * @return array
+ */
+ private function recursiveConvert(\Traversable $source)
+ {
+ $output = [];
+ foreach ($source as $element) {
+ if ($element instanceof \DOMElement) {
+ $key = $element->getAttribute('name');
+
+ if ($element->hasChildNodes()) {
+ $output[$element->tagName][$key] =
+ array_replace(
+ $this->recursiveConvert($element->childNodes),
+ $this->interpretateAttributes($element)
+ );
+ } else if ($this->hasAttributesExceptName($element)) {
+ $output[$element->tagName][$key] = $this->interpretateAttributes($element);
+ } else {
+ $output[$element->tagName][$key] = $key;
+ }
+ }
+ }
+
+ return $output;
+ }
+
+ /**
+ * Check whether we have any attributes except name
+ * XSI:TYPE is in another namespace, so we need to do additio
+ * Note: name is mandatory attribute
+ *
+ * @param \DOMElement $element
+ * @return bool
+ */
+ private function hasAttributesExceptName(\DOMElement $element)
+ {
+ return $element->hasAttribute('xsi:type') || $element->attributes->length > 2;
+ }
+
+ /**
+ * Mix attributes that comes from XML schema with default ones
+ * So if you will not have some attribute in schema - it will be taken from default one
+ *
+ * @param \DOMElement $domElement
+ * @return mixed
+ */
+ private function interpretateAttributes(\DOMElement $domElement)
+ {
+ $attributes = $this->getAttributes($domElement);
+ $xsiType = $domElement->getAttribute('xsi:type');
+
+ if ($xsiType) {
+ $attributes['type'] = $xsiType;
+ return $this->casterAggregator->cast($attributes);
+ }
+
+ return $attributes;
+ }
+
+ /**
+ * Convert XML attributes into raw array with attributes
+ *
+ * @param \DOMElement $element
+ * @return array
+ */
+ private function getAttributes(\DOMElement $element)
+ {
+ $attributes = [];
+ $attributeNodes = $element->attributes;
+
+ /** @var \DOMAttr $attribute */
+ foreach ($attributeNodes as $domAttr) {
+ $attributes[$domAttr->name] = $domAttr->value;
+ }
+
+ return $attributes;
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Xml/SchemaLocator.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Xml/SchemaLocator.php
new file mode 100644
index 0000000000000..8c6a368f7e005
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Xml/SchemaLocator.php
@@ -0,0 +1,59 @@
+_schema = $urnResolver->getRealPath($schemaUrn);
+ $this->_perFileSchema = $this->_schema;
+ }
+
+ /**
+ * Get path to merged config schema
+ *
+ * @return string|null
+ */
+ public function getSchema()
+ {
+ return $this->_schema;
+ }
+
+ /**
+ * Get path to pre file validation schema
+ *
+ * @return string|null
+ */
+ public function getPerFileSchema()
+ {
+ return $this->_perFileSchema;
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/config/constraints/constraint.xsd b/setup/src/Magento/Setup/Model/Declaration/Schema/config/constraints/constraint.xsd
new file mode 100644
index 0000000000000..8be292b78bab8
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/config/constraints/constraint.xsd
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/config/constraints/foreign.xsd b/setup/src/Magento/Setup/Model/Declaration/Schema/config/constraints/foreign.xsd
new file mode 100644
index 0000000000000..fe53bf267c42d
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/config/constraints/foreign.xsd
@@ -0,0 +1,40 @@
+
+
+
+
+
+
+
+
+ With help of this element, foreign key constraint can be described.
+ This constraint allows to have reference
+ For this you need 4 settings, described below.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/config/constraints/primary.xsd b/setup/src/Magento/Setup/Model/Declaration/Schema/config/constraints/primary.xsd
new file mode 100644
index 0000000000000..e03bd108c1ee2
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/config/constraints/primary.xsd
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+ With help of this element, foreign key constraint can be described.
+ This constraint allows to have reference
+ For this you need 4 settings, described below.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/config/constraints/unique.xsd b/setup/src/Magento/Setup/Model/Declaration/Schema/config/constraints/unique.xsd
new file mode 100644
index 0000000000000..c3f10aac20c49
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/config/constraints/unique.xsd
@@ -0,0 +1,28 @@
+
+
+
+
+
+
+
+
+ This constraint allows to
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/config/index.xsd b/setup/src/Magento/Setup/Model/Declaration/Schema/config/index.xsd
new file mode 100644
index 0000000000000..6083be187f97f
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/config/index.xsd
@@ -0,0 +1,36 @@
+
+
+
+
+
+
+ Describe different SQL indexes. With help of indexes you can improve read SQL
+ operations
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/config/operations.xsd b/setup/src/Magento/Setup/Model/Declaration/Schema/config/operations.xsd
new file mode 100644
index 0000000000000..a3956d328a484
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/config/operations.xsd
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+ `renameTo`: This operation allow to rename columns from 3-rd party module.
+ As you can not affect original declaration from 3-rd party module,
+ you can only extend it. So in order to rename external column, table, index or constraint
+ you need to specify additional param. Value of which will be desired name.
+ `disabled`: Allows to remove external column (created by external module).
+
+ Note: in order to remove or rename schema entity that comes with your module, you can
+ easily do it in your declaration, by removing schema entity declaration or renaming name attribute
+
+
+
+
+
+
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/config/schema.xsd b/setup/src/Magento/Setup/Model/Declaration/Schema/config/schema.xsd
new file mode 100644
index 0000000000000..2ca2b98ac1ead
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/config/schema.xsd
@@ -0,0 +1,67 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Table definition. Here we can found column, constraints and indexes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/binaries/blob.xsd b/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/binaries/blob.xsd
new file mode 100644
index 0000000000000..920b06a60c338
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/binaries/blob.xsd
@@ -0,0 +1,28 @@
+
+
+
+
+
+
+
+
+ Can be used as binary source
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/binaries/longblob.xsd b/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/binaries/longblob.xsd
new file mode 100644
index 0000000000000..b05cb863e868a
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/binaries/longblob.xsd
@@ -0,0 +1,28 @@
+
+
+
+
+
+
+
+
+ Can be used as binary source. Different types can be used depends on data size
+ you want to persist
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/binaries/mediumblob.xsd b/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/binaries/mediumblob.xsd
new file mode 100644
index 0000000000000..f87aaa01ce3a4
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/binaries/mediumblob.xsd
@@ -0,0 +1,28 @@
+
+
+
+
+
+
+
+
+ Can be used as binary source
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/binaries/varbinary.xsd b/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/binaries/varbinary.xsd
new file mode 100644
index 0000000000000..8d037f94b55f5
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/binaries/varbinary.xsd
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
+
+ Can be used as binary source
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/boolean.xsd b/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/boolean.xsd
new file mode 100644
index 0000000000000..cf52a70b79702
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/boolean.xsd
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/column.xsd b/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/column.xsd
new file mode 100644
index 0000000000000..60224991a56d6
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/column.xsd
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/datetime/date.xsd b/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/datetime/date.xsd
new file mode 100644
index 0000000000000..1272653a0b01e
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/datetime/date.xsd
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+
+
+ This format is used to save date (year, month, day).
+ Probably your SQL engine will save date in this format: 'YYYY-MM-DD'
+ Dates in invalid format will be converted to '0000-00-00' string
+
+
+
+
+
+
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/datetime/datetime.xsd b/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/datetime/datetime.xsd
new file mode 100644
index 0000000000000..3b1d62cdb8258
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/datetime/datetime.xsd
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+
+
+
+ This format is used to save date (year, month, day).
+ Probably your SQL engine will save date in this format: 'YYYY-MM-DD HH:MM::SS'
+ Date time in invalid format will be converted to '0000-00-00 00:00:00' string
+ Supported range is '1000-01-01 00:00:00' to '9999-12-31 23:59:59'
+ DateTime format save date and time in your local time zone
+
+
+
+
+
+
+
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/datetime/default.xsd b/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/datetime/default.xsd
new file mode 100644
index 0000000000000..89fdef3e78fb7
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/datetime/default.xsd
@@ -0,0 +1,53 @@
+
+
+
+
+
+
+ This is default types for timestamp and datetime DDL types.
+
+
+
+
+
+
+ Logically on update can accept only one value - CURRENT_TIMESTAMP
+ So we just choose if we want to add next construction or not
+ 'ON UPDATE CURRENT_TIMESTAMP'
+
+
+
+
+
+
+
+
+
+
+ Use current time according to your SQL server time zone
+
+
+
+
+
+
+ Please be aware that NO_ZERO_DATE SQL mode should be turned off. The default value will have next formatL:
+ 0000-00-00 00:00:00
+
+
+
+
+
+
+ In this case timestamp column will not have any value at all by default
+
+
+
+
+
+
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/datetime/timestamp.xsd b/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/datetime/timestamp.xsd
new file mode 100644
index 0000000000000..e81f96a4c7f0d
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/datetime/timestamp.xsd
@@ -0,0 +1,28 @@
+
+
+
+
+
+
+
+
+
+ This format is used to save date (year, month, day).
+ Probably your SQL engine will save date in this format: 'YYYY-MM-DD HH:MM::SS'
+ Date time in invalid format will be converted to '0000-00-00 00:00:00' string
+ MySQL timestamp is similar to UNIX timestamp. You can pass you local time there and it will
+ be converted to UTC timezone. Then when you will try to pull your time back it will be converted
+ to your local time again.
+ Unix range: 1970-01-01 00:00:01' UTC to '2038-01-09 03:14:07'
+
+
+
+
+
+
+
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/decimals/decimal.xsd b/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/decimals/decimal.xsd
new file mode 100644
index 0000000000000..821d785b6d680
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/decimals/decimal.xsd
@@ -0,0 +1,42 @@
+
+
+
+
+
+
+
+
+ This type is equal to SQL DECIMAL(SCALE,PRECISION) type. Usually it is used for accurate operations
+ with decimal numbers. For example, for price
+ Usually decimal is concatinated from 2 integers, so it has not round problems
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/decimals/double.xsd b/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/decimals/double.xsd
new file mode 100644
index 0000000000000..cd4351f54d41e
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/decimals/double.xsd
@@ -0,0 +1,39 @@
+
+
+
+
+
+
+
+
+ Double is simply big decimal
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/decimals/float.xsd b/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/decimals/float.xsd
new file mode 100644
index 0000000000000..3f7cf1f3453b2
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/decimals/float.xsd
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
+
+ Float is used for binary digits. It is not so accurate as decimal and has rounding issues.
+ For price please use decimals
+
+
+
+
+
+
+
+
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/integers/biginteger.xsd b/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/integers/biginteger.xsd
new file mode 100644
index 0000000000000..71757494cc671
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/integers/biginteger.xsd
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/integers/integer.xsd b/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/integers/integer.xsd
new file mode 100644
index 0000000000000..4335dee736c1e
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/integers/integer.xsd
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+
+
+ Serves needs in integer digits. Default padding is 11.
+ Size is 4 bytes.
+
+
+
+
+
+
+
+
+
+
+
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/integers/smallinteger.xsd b/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/integers/smallinteger.xsd
new file mode 100644
index 0000000000000..2ef2569c52293
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/integers/smallinteger.xsd
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
+
+ Serves needs in integer digits. Default padding is 5.
+ Size is 2 bytes.
+
+
+
+
+
+
+
+
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/integers/tinyinteger.xsd b/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/integers/tinyinteger.xsd
new file mode 100644
index 0000000000000..11107d5631f5c
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/integers/tinyinteger.xsd
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/texts/longtext.xsd b/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/texts/longtext.xsd
new file mode 100644
index 0000000000000..8571e1117f86c
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/texts/longtext.xsd
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+ Here plain text can be persisted. Length of this field is more than more than 16777216
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/texts/mediumtext.xsd b/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/texts/mediumtext.xsd
new file mode 100644
index 0000000000000..49d2ef3af53cd
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/texts/mediumtext.xsd
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
+
+ Here plain text can be persisted. Length of this field is more than 65536 characters
+ and less than 16777216
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/texts/text.xsd b/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/texts/text.xsd
new file mode 100644
index 0000000000000..c3b00ad3b3ede
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/texts/text.xsd
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
+
+ Here plain text can be persisted. Length of this field is more than 255 characters
+ and less than 65536
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/texts/varchar.xsd b/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/texts/varchar.xsd
new file mode 100644
index 0000000000000..c483decb67aa1
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/texts/varchar.xsd
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+ Varchar is the small text field with max length - 255 symbols. Can be used for
+ string columns that are in role of some key, like customer email or product sku
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/setup/src/Magento/Setup/Model/Installer.php b/setup/src/Magento/Setup/Model/Installer.php
index 4a9bfd9063656..66faab9ffc658 100644
--- a/setup/src/Magento/Setup/Model/Installer.php
+++ b/setup/src/Magento/Setup/Model/Installer.php
@@ -1009,10 +1009,14 @@ private function installOrderIncrementPrefix($orderIncrementPrefix)
*/
public function installAdminUser($data)
{
- $this->assertDbConfigExists();
- $setup = $this->setupFactory->create($this->context->getResources());
- $adminAccount = $this->adminAccountFactory->create($setup->getConnection(), (array)$data);
- $adminAccount->save();
+ $adminUserModuleIsInstalled = (bool) $this->deploymentConfig->get('modules/Magento_User');
+ //Admin user data is not system data, so we need to install it only if schema for admin user was installed
+ if ($adminUserModuleIsInstalled) {
+ $this->assertDbConfigExists();
+ $setup = $this->setupFactory->create($this->context->getResources());
+ $adminAccount = $this->adminAccountFactory->create($setup->getConnection(), (array)$data);
+ $adminAccount->save();
+ }
}
/**
diff --git a/setup/src/Magento/Setup/Model/InstallerFactory.php b/setup/src/Magento/Setup/Model/InstallerFactory.php
index c8d8017386b9a..15c68408f9564 100644
--- a/setup/src/Magento/Setup/Model/InstallerFactory.php
+++ b/setup/src/Magento/Setup/Model/InstallerFactory.php
@@ -6,6 +6,7 @@
namespace Magento\Setup\Model;
+use Magento\Setup\Model\Declaration\Schema\Generated\MysqlDumpSchemaParser;
use Zend\ServiceManager\ServiceLocatorInterface;
use Magento\Setup\Module\ResourceFactory;
use Magento\Framework\App\ErrorHandler;
@@ -35,8 +36,10 @@ class InstallerFactory
* @param ServiceLocatorInterface $serviceLocator
* @param ResourceFactory $resourceFactory
*/
- public function __construct(ServiceLocatorInterface $serviceLocator, ResourceFactory $resourceFactory)
- {
+ public function __construct(
+ ServiceLocatorInterface $serviceLocator,
+ ResourceFactory $resourceFactory
+ ) {
$this->serviceLocator = $serviceLocator;
$this->resourceFactory = $resourceFactory;
// For Setup Wizard we are using our customized error handler
diff --git a/setup/src/Magento/Setup/Test/Unit/Model/InstallerTest.php b/setup/src/Magento/Setup/Test/Unit/Model/InstallerTest.php
index 34b60b3d4ec9e..86fb54551661d 100644
--- a/setup/src/Magento/Setup/Test/Unit/Model/InstallerTest.php
+++ b/setup/src/Magento/Setup/Test/Unit/Model/InstallerTest.php
@@ -250,9 +250,11 @@ public function testInstall()
[
[ConfigOptionsListConstants::CONFIG_PATH_DB_CONNECTION_DEFAULT, null, true],
[ConfigOptionsListConstants::CONFIG_PATH_CRYPT_KEY, null, true],
+ ['modules/Magento_User', null, '1']
]
);
$allModules = ['Foo_One' => [], 'Bar_Two' => []];
+
$this->moduleLoader->expects($this->any())->method('load')->willReturn($allModules);
$setup = $this->createMock(\Magento\Setup\Module\Setup::class);
$table = $this->createMock(\Magento\Framework\DB\Ddl\Table::class);
diff --git a/setup/src/Magento/Setup/registration.php b/setup/src/Magento/Setup/registration.php
new file mode 100644
index 0000000000000..e78c32a7f193b
--- /dev/null
+++ b/setup/src/Magento/Setup/registration.php
@@ -0,0 +1,9 @@
+
Date: Fri, 15 Dec 2017 13:01:34 +0200
Subject: [PATCH 225/904] MAGETWO-83201: Creating Diff artifacts between
arbitrary Declarative Schemas
--fix past review issues
---
.../etc/{schema.xml => db_schema.xml} | 0
.../{schema.xml => db_schema.xml} | 0
.../{schema.xml => db_schema.xml} | 0
.../foreign_key_interpreter/{schema.xml => db_schema.xml} | 0
.../revisions/old_diff/{schema.xml => db_schema.xml} | 0
.../Magento/TestFramework/Bootstrap/SetupDocBlock.php | 1 +
.../Magento/TestFramework/Deploy/TestModuleManager.php | 6 +++---
.../testsuite/Magento/Setup/DiffOldSchemaTest.php | 4 ++--
.../src/Magento/Setup/Console/Command/InstallCommand.php | 4 ++--
.../src/Magento/Setup/Console/Command/UpgradeCommand.php | 2 +-
.../Setup/Model/Declaration/Schema/FileSystem/Reader.php | 3 +--
.../Declaration/Schema/config/types/texts/varchar.xsd | 8 +++++---
12 files changed, 15 insertions(+), 13 deletions(-)
rename dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/etc/{schema.xml => db_schema.xml} (100%)
rename dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/fail_on_column_declaration/{schema.xml => db_schema.xml} (100%)
rename dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/fail_on_unique_key_declaration/{schema.xml => db_schema.xml} (100%)
rename dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/foreign_key_interpreter/{schema.xml => db_schema.xml} (100%)
rename dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/old_diff/{schema.xml => db_schema.xml} (100%)
diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/etc/schema.xml b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/etc/db_schema.xml
similarity index 100%
rename from dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/etc/schema.xml
rename to dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/etc/db_schema.xml
diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/fail_on_column_declaration/schema.xml b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/fail_on_column_declaration/db_schema.xml
similarity index 100%
rename from dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/fail_on_column_declaration/schema.xml
rename to dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/fail_on_column_declaration/db_schema.xml
diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/fail_on_unique_key_declaration/schema.xml b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/fail_on_unique_key_declaration/db_schema.xml
similarity index 100%
rename from dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/fail_on_unique_key_declaration/schema.xml
rename to dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/fail_on_unique_key_declaration/db_schema.xml
diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/foreign_key_interpreter/schema.xml b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/foreign_key_interpreter/db_schema.xml
similarity index 100%
rename from dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/foreign_key_interpreter/schema.xml
rename to dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/foreign_key_interpreter/db_schema.xml
diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/old_diff/schema.xml b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/old_diff/db_schema.xml
similarity index 100%
rename from dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/old_diff/schema.xml
rename to dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/old_diff/db_schema.xml
diff --git a/dev/tests/setup-integration/framework/Magento/TestFramework/Bootstrap/SetupDocBlock.php b/dev/tests/setup-integration/framework/Magento/TestFramework/Bootstrap/SetupDocBlock.php
index 4ace776ec413e..2adf306f5773b 100644
--- a/dev/tests/setup-integration/framework/Magento/TestFramework/Bootstrap/SetupDocBlock.php
+++ b/dev/tests/setup-integration/framework/Magento/TestFramework/Bootstrap/SetupDocBlock.php
@@ -27,6 +27,7 @@ protected function _getSubscribers(\Magento\TestFramework\Application $applicati
new \Magento\TestFramework\Workaround\Cleanup\StaticProperties(),
new \Magento\TestFramework\Isolation\WorkingDirectory(),
new \Magento\TestFramework\Workaround\DeploymentConfig(),
+ new \Magento\TestFramework\Annotation\AppIsolation($application),
new \Magento\TestFramework\Annotation\ComponentRegistrarFixture($this->_fixturesBaseDir),
new \Magento\TestFramework\Annotation\SchemaFixture($this->_fixturesBaseDir),
new \Magento\TestFramework\Annotation\Cache(),
diff --git a/dev/tests/setup-integration/framework/Magento/TestFramework/Deploy/TestModuleManager.php b/dev/tests/setup-integration/framework/Magento/TestFramework/Deploy/TestModuleManager.php
index d2a69d745aa4f..6e1554bf8be1f 100644
--- a/dev/tests/setup-integration/framework/Magento/TestFramework/Deploy/TestModuleManager.php
+++ b/dev/tests/setup-integration/framework/Magento/TestFramework/Deploy/TestModuleManager.php
@@ -13,7 +13,7 @@ class TestModuleManager
/**
* Name of file of DB XML declaration
*/
- const DECLARATIVE_FILE_NAME = "schema.xml";
+ const DECLARATIVE_FILE_NAME = "db_schema.xml";
/**
* Add test module files to Magento code base
@@ -62,8 +62,8 @@ public function addModuleFiles($moduleName)
/**
* @param string $moduleName Like Magento_TestSetupModule
- * @param string $revisionName Folder name, like reviisions/revision_1/schema.xml
- * @param string $fileName For example schema.xml
+ * @param string $revisionName Folder name, like reviisions/revision_1/db_schema.xml
+ * @param string $fileName For example db_schema.xml
* @param string $fileDir For example etc or Setup
*/
public function updateRevision($moduleName, $revisionName, $fileName, $fileDir)
diff --git a/dev/tests/setup-integration/testsuite/Magento/Setup/DiffOldSchemaTest.php b/dev/tests/setup-integration/testsuite/Magento/Setup/DiffOldSchemaTest.php
index 80df282c08af5..c73638382c56b 100644
--- a/dev/tests/setup-integration/testsuite/Magento/Setup/DiffOldSchemaTest.php
+++ b/dev/tests/setup-integration/testsuite/Magento/Setup/DiffOldSchemaTest.php
@@ -74,11 +74,11 @@ public function setUp()
*/
public function testOldDiff()
{
- //Move schema.xml
+ //Move db_schema.xml
$this->moduleManager->updateRevision(
'Magento_TestSetupDeclarationModule1',
'old_diff',
- 'schema.xml',
+ 'db_schema.xml',
'etc'
);
//Move InstallSchema file and tried to install
diff --git a/setup/src/Magento/Setup/Console/Command/InstallCommand.php b/setup/src/Magento/Setup/Console/Command/InstallCommand.php
index 74b627b6e5d5b..16cda192a34ed 100644
--- a/setup/src/Magento/Setup/Console/Command/InstallCommand.php
+++ b/setup/src/Magento/Setup/Console/Command/InstallCommand.php
@@ -134,14 +134,14 @@ protected function configure()
null,
InputOption::VALUE_OPTIONAL,
'List of comma-separated module names. That must be included during installation.
- Avaiable magic param all.'
+ Avaiable magic param "all".'
),
new InputOption(
self::INPUT_KEY_DISABLE_MODULES,
null,
InputOption::VALUE_OPTIONAL,
'List of comma-separated module names. That must be avoided during installation.
- Avaiable magic param all.'
+ Avaiable magic param "all".'
)
]);
$this->setName('setup:install')
diff --git a/setup/src/Magento/Setup/Console/Command/UpgradeCommand.php b/setup/src/Magento/Setup/Console/Command/UpgradeCommand.php
index 5bd81cd7890e6..e2d032da9b196 100644
--- a/setup/src/Magento/Setup/Console/Command/UpgradeCommand.php
+++ b/setup/src/Magento/Setup/Console/Command/UpgradeCommand.php
@@ -90,7 +90,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$keepGenerated = $input->getOption(self::INPUT_KEY_KEEP_GENERATED);
$installer = $this->installerFactory->create(new ConsoleLogger($output));
$installer->updateModulesSequence($keepGenerated);
- $installer->installSchema($input->getOptions());
+ $installer->installSchema();
$installer->installDataFixtures();
if ($this->deploymentConfig->isAvailable()) {
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/FileSystem/Reader.php b/setup/src/Magento/Setup/Model/Declaration/Schema/FileSystem/Reader.php
index 914c0eea3b059..7c1cebfa3633b 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/FileSystem/Reader.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/FileSystem/Reader.php
@@ -10,7 +10,6 @@
/**
* Class Reader
- * @package Magento\Setup\Model\Declaration\Schema\FileSystem
*/
class Reader extends \Magento\Framework\Config\Reader\Filesystem implements ReaderInterface
{
@@ -43,7 +42,7 @@ public function __construct(
\Magento\Setup\Model\Declaration\Schema\Xml\Converter $converter,
\Magento\Setup\Model\Declaration\Schema\Xml\SchemaLocator $schemaLocator,
\Magento\Framework\Config\ValidationStateInterface $validationState,
- $fileName = 'schema.xml',
+ $fileName = 'db_schema.xml',
$domDocumentClass = \Magento\Framework\Config\Dom::class,
$defaultScope = 'global'
) {
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/texts/varchar.xsd b/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/texts/varchar.xsd
index c483decb67aa1..f11c3c696d916 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/texts/varchar.xsd
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/texts/varchar.xsd
@@ -11,8 +11,10 @@
- Varchar is the small text field with max length - 255 symbols. Can be used for
- string columns that are in role of some key, like customer email or product sku
+ Varchar is the small text field. It do not have max length. But we suppose, that this field can be used for
+ string columns that are in role of some key, like customer email or product sku. We add limitation for 1024 characters
+ on this type. This limitation is justified by SQL engine limitations, like {max sort size} or {max index size}.
+ For example, in MySQL, default max sort size (max_sort_length) is 1024 symbols.
@@ -20,7 +22,7 @@
-
+
From 4431ac813139b23f0d965d473755310d1d74c43e Mon Sep 17 00:00:00 2001
From: Sergii Kovalenko
Date: Fri, 15 Dec 2017 13:59:32 +0200
Subject: [PATCH 226/904] MAGETWO-83201: Creating Diff artifacts between
arbitrary Declarative Schemas
--fix doc blocks
---
.../TestFramework/Bootstrap/SetupDocBlock.php | 1 -
.../Model/Declaration/Schema/Casters/Base.php | 3 +-
.../Model/Declaration/Schema/Casters/Date.php | 2 +-
.../Declaration/Schema/Casters/Primary.php | 4 +-
.../Schema/ChangeProcessorInterface.php | 4 +-
.../Declaration/Schema/ChangeRegistry.php | 3 ++
.../Declaration/Schema/Db/AdapterMediator.php | 3 +-
.../Model/Declaration/Schema/Db/Parser.php | 3 ++
.../Db/Processors/DbSchemaReaderInterface.php | 3 +-
.../Db/Processors/MySQL/Columns/Basic.php | 3 ++
.../Db/Processors/MySQL/Columns/Boolean.php | 3 ++
.../Db/Processors/MySQL/Columns/Decimal.php | 2 +
.../Db/Processors/MySQL/Columns/Integer.php | 2 +
.../Db/Processors/MySQL/Columns/OnUpdate.php | 2 +
.../Db/Processors/MySQL/Columns/Timestamp.php | 2 +
.../Db/Processors/MySQL/Columns/Unsigned.php | 2 +
.../MySQL/Constraints/ForeignKey.php | 3 ++
.../Processors/MySQL/Constraints/Internal.php | 2 +-
.../Schema/Db/Processors/MySQL/Index.php | 3 ++
.../Schema/Db/StructureBuilder.php | 10 ++++
.../Schema/Declaration/StructureBuilder.php | 8 ++-
.../Declaration/Schema/Diff/DiffManager.php | 20 ++++++--
.../Declaration/Schema/Diff/StructureDiff.php | 35 ++++++++-----
.../Declaration/Schema/Diff/TableDiff.php | 49 +++++++++++--------
.../Declaration/Schema/Dto/Columns/Blob.php | 3 +-
.../Schema/Dto/Columns/Boolean.php | 3 +-
.../Declaration/Schema/Dto/Columns/Text.php | 2 +-
.../Schema/Dto/ElementDiffAwareInterface.php | 2 +-
.../Schema/Dto/ElementRenamedInterface.php | 5 +-
.../Declaration/Schema/Dto/GenericElement.php | 9 +++-
.../Schema/SchemaParserInterface.php | 3 ++
.../Model/Declaration/Schema/Sharding.php | 1 +
.../Declaration/Schema/Xml/SchemaLocator.php | 3 +-
33 files changed, 144 insertions(+), 59 deletions(-)
diff --git a/dev/tests/setup-integration/framework/Magento/TestFramework/Bootstrap/SetupDocBlock.php b/dev/tests/setup-integration/framework/Magento/TestFramework/Bootstrap/SetupDocBlock.php
index 2adf306f5773b..4ace776ec413e 100644
--- a/dev/tests/setup-integration/framework/Magento/TestFramework/Bootstrap/SetupDocBlock.php
+++ b/dev/tests/setup-integration/framework/Magento/TestFramework/Bootstrap/SetupDocBlock.php
@@ -27,7 +27,6 @@ protected function _getSubscribers(\Magento\TestFramework\Application $applicati
new \Magento\TestFramework\Workaround\Cleanup\StaticProperties(),
new \Magento\TestFramework\Isolation\WorkingDirectory(),
new \Magento\TestFramework\Workaround\DeploymentConfig(),
- new \Magento\TestFramework\Annotation\AppIsolation($application),
new \Magento\TestFramework\Annotation\ComponentRegistrarFixture($this->_fixturesBaseDir),
new \Magento\TestFramework\Annotation\SchemaFixture($this->_fixturesBaseDir),
new \Magento\TestFramework\Annotation\Cache(),
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Casters/Base.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Casters/Base.php
index bc2bede0ebd62..56d494da713eb 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Casters/Base.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Casters/Base.php
@@ -8,7 +8,8 @@
use Magento\Framework\Stdlib\BooleanUtils;
/**
- * Basic interpreter - used to map one xsi:type to element type
+ * Basic caster is cast configurations from db and from XML
+ * to one common format. It do not rely to element type.
*/
class Base implements CasterInterface
{
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Casters/Date.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Casters/Date.php
index b1528ae8178a4..a271e50f6aefc 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Casters/Date.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Casters/Date.php
@@ -7,7 +7,7 @@
/**
* Date caster
- * Should not have any values
+ * Remove default and nullable attributes, as date type must not have any attributes
*/
class Date implements CasterInterface
{
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Casters/Primary.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Casters/Primary.php
index d81b3a4a132ae..bb1c8a1a443f1 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Casters/Primary.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Casters/Primary.php
@@ -9,7 +9,9 @@
/**
* Serves foreign key constraint needs.
- * Add additonal onDelete param
+ * By default primary key can have only one name - PRIMARY
+ * And this name is hardcoded. This is done, in order to prevent creating 2 primary keys
+ * for one table
*/
class Primary implements CasterInterface
{
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/ChangeProcessorInterface.php b/setup/src/Magento/Setup/Model/Declaration/Schema/ChangeProcessorInterface.php
index 53c58a4e3342a..ec883925338f3 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/ChangeProcessorInterface.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/ChangeProcessorInterface.php
@@ -7,8 +7,8 @@
namespace Magento\Setup\Model\Declaration\Schema;
/**
- * Interface ChangeProcessorInterface
- * @package Magento\Setup\Model\Declaration\Schema
+ * With help of ChangeProcessorInterface you can go thorugh all element types
+ * and apply difference, that is persisted in ChangeRegistry
*/
interface ChangeProcessorInterface
{
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/ChangeRegistry.php b/setup/src/Magento/Setup/Model/Declaration/Schema/ChangeRegistry.php
index 939ba0fc7a4eb..346c2d816624f 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/ChangeRegistry.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/ChangeRegistry.php
@@ -13,6 +13,9 @@
/**
* Holds information about all changes between 2 schemas: db and declaration XML
+ * Holds 2 items:
+ * - new (Should be changed to)
+ * - old (Was)
*/
class ChangeRegistry implements ChangeRegistryInterface
{
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/AdapterMediator.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/AdapterMediator.php
index 43e6f0d35e5e8..16b16f45ccbea 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/AdapterMediator.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/AdapterMediator.php
@@ -11,7 +11,8 @@
/**
* Needs for different types of SQL engines
- * Depends on SQL engine, envolves different processors and prepare SQL code or Data Objects tables representation
+ * Depends on SQL engine, envolves different processors and convert from SQL schema represenation
+ * to readable or from do DDL operations: convert from DTO`s objects to SQL definition and run SQL query.
*/
class AdapterMediator
{
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Parser.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Parser.php
index a1051f6d8a86a..ee95e8cd6b008 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Parser.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Parser.php
@@ -10,6 +10,9 @@
use Magento\Setup\Model\Declaration\Schema\SchemaParserInterface;
/**
+ * Parser is responsible for builind structure.
+ * @see Structure
+ *
* @inheritdoc
*/
class Parser implements SchemaParserInterface
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/DbSchemaReaderInterface.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/DbSchemaReaderInterface.php
index c70d03ac28dfe..ecb107350db72 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/DbSchemaReaderInterface.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/DbSchemaReaderInterface.php
@@ -7,7 +7,8 @@
namespace Magento\Setup\Model\Declaration\Schema\Db\Processors;
/**
- * This class is responsible for read different typ
+ * This class is responsible for read different schema
+ * structural elements: indexes, constraints, talbe names and columns
*/
interface DbSchemaReaderInterface
{
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Basic.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Basic.php
index 843e5a1261e0a..bb55b214c1a28 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Basic.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Basic.php
@@ -11,6 +11,9 @@
/**
* We always have 6 fields and we need to process all six of them
+ * For columns we do not need 'key'
+ * Also we need to make nullable and type in lower case
+ *
* @inheritdoc
*/
class Basic implements DbSchemaProcessorInterface
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Boolean.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Boolean.php
index dd675e6e307f8..fafef14539479 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Boolean.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Boolean.php
@@ -10,6 +10,9 @@
use Magento\Setup\Model\Declaration\Schema\Dto\ElementInterface;
/**
+ * As all MySQL aliases as BOOL or BOOLEAN are converted to TINYINT(1)
+ * proposed to processed tinyint as boolean
+ *
* @inheritdoc
*/
class Boolean implements DbSchemaProcessorInterface
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Decimal.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Decimal.php
index 9a5b13e66c8e5..4b2b0abee19ac 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Decimal.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Decimal.php
@@ -10,6 +10,8 @@
use Magento\Setup\Model\Declaration\Schema\Dto\ElementInterface;
/**
+ * Process decimal type and separate it into type, scale and precission
+ *
* @inheritdoc
*/
class Decimal implements DbSchemaProcessorInterface
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Integer.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Integer.php
index ae74d0e106393..6fe8c5b9693fc 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Integer.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Integer.php
@@ -10,6 +10,8 @@
use Magento\Setup\Model\Declaration\Schema\Dto\ElementInterface;
/**
+ * Process integer type and separate it on type and padding
+ *
* @inheritdoc
*/
class Integer implements DbSchemaProcessorInterface
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/OnUpdate.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/OnUpdate.php
index 27816826afa16..2181f4b34e3bd 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/OnUpdate.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/OnUpdate.php
@@ -10,6 +10,8 @@
use Magento\Setup\Model\Declaration\Schema\Dto\ElementInterface;
/**
+ * On update attribute is like trigger and can be used for many different columns
+ *
* @inheritdoc
*/
class OnUpdate implements DbSchemaProcessorInterface
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Timestamp.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Timestamp.php
index ee57b1e7d22f1..34a6b653ee0d5 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Timestamp.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Timestamp.php
@@ -10,6 +10,8 @@
use Magento\Setup\Model\Declaration\Schema\Dto\ElementInterface;
/**
+ * Process timestamp and find out it on_update and default values
+ *
* @inheritdoc
*/
class Timestamp implements DbSchemaProcessorInterface
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Unsigned.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Unsigned.php
index 673aef7f1f5d3..cc39e2d91713f 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Unsigned.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Unsigned.php
@@ -10,6 +10,8 @@
use Magento\Setup\Model\Declaration\Schema\Dto\ElementInterface;
/**
+ * Unsigned can be used for all numeric types
+ *
* @inheritdoc
*/
class Unsigned implements DbSchemaProcessorInterface
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Constraints/ForeignKey.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Constraints/ForeignKey.php
index 440ae169dce4b..085be601f1562 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Constraints/ForeignKey.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Constraints/ForeignKey.php
@@ -10,6 +10,9 @@
use Magento\Setup\Model\Declaration\Schema\Dto\ElementInterface;
/**
+ * MySQL holds foreign keys definitions only in "CREATE TABLE" sql. So we can access them
+ * only with parsing of this statement, and searching by ADD CONSTRAINT FOREIGN KEY
+ *
* @inheritdoc
*/
class ForeignKey implements DbSchemaProcessorInterface
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Constraints/Internal.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Constraints/Internal.php
index bdb051a04d70e..25da57cc23d5c 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Constraints/Internal.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Constraints/Internal.php
@@ -10,7 +10,7 @@
use Magento\Setup\Model\Declaration\Schema\Dto\ElementInterface;
/**
- * Detect primary or unique constraints
+ * Detect primary or unique constraints and map them to appropriate format
*
* @inheritdoc
*/
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Index.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Index.php
index a8eea54f73df4..a7ae08e537304 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Index.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Index.php
@@ -10,6 +10,9 @@
use Magento\Setup\Model\Declaration\Schema\Dto\ElementInterface;
/**
+ * Look for all indexes that MySQL table has. Note, that we need to ignore
+ * all unique indexes, as this indexes belongs to constraints, as they limit DML queries
+ *
* @inheritdoc
*/
class Index implements DbSchemaProcessorInterface
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/StructureBuilder.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/StructureBuilder.php
index fd76b682e50be..0417f4cb517f7 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/StructureBuilder.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/StructureBuilder.php
@@ -15,6 +15,14 @@
use Magento\Setup\Model\Declaration\Schema\Sharding;
/**
+ * This type of builder is responsible for converting ENTIRE data, that comes from db
+ * into DTO`s format, with aggregation root: Structure
+ *
+ * Note: StructureBuilder can not be used for one structural element, like column or constraint
+ * because it should have references to other DTO objects.
+ * In order to convert build only 1 structural element use directly it factory
+ *
+ * @see Structure
* @inheritdoc
*/
class StructureBuilder
@@ -125,6 +133,8 @@ public function build(Structure $structure)
/**
* Process references for all tables
+ * This needs to validate schema. And find out invalid references, for example
+ * for tables that do not exists already
*
* @param Table[] $tables
* @return Table[]
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/StructureBuilder.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/StructureBuilder.php
index a6e5e2474c3d2..f765da3a0497c 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/StructureBuilder.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/StructureBuilder.php
@@ -15,8 +15,12 @@
use Magento\Setup\Model\Declaration\Schema\Sharding;
/**
- * Class StructureBuilder
- * Return collection with DTO objects from array
+ * This type of builder is responsible for converting ENTIRE data, that comes from XML
+ * into DTO`s format, with aggregation root: Structure
+ *
+ * Note: StructureBuilder can not be used for one structural element, like column or constraint
+ * because it should have references to other DTO objects.
+ * In order to convert build only 1 structural element use directly it factory
*/
class StructureBuilder
{
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/DiffManager.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/DiffManager.php
index 4b95346fbca8d..4dad2dfcb5c99 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/DiffManager.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/DiffManager.php
@@ -10,14 +10,26 @@
use Magento\Setup\Model\Declaration\Schema\Comparator;
use Magento\Setup\Model\Declaration\Schema\Dto\ElementInterface;
use Magento\Setup\Model\Declaration\Schema\Dto\ElementRenamedInterface;
-use Magento\Setup\Model\Declaration\Schema\Dto\Structure;
/**
* Helper which provide methods, that helps to compare 2 different nodes:
* For instance, 2 columns between each other
*/
-trait DiffManager
+class DiffManager
{
+ /**
+ * @var Comparator
+ */
+ private $comparator;
+
+ /**
+ * @param Comparator $comparator
+ */
+ public function __construct(Comparator $comparator)
+ {
+ $this->comparator = $comparator;
+ }
+
/**
* Check whether new name is not corresponds with olds one
*
@@ -147,16 +159,14 @@ public function registerCreation(ChangeRegistryInterface $changeRegistry, Elemen
/**
* Check whether element should be modified or not
*
- * @param Comparator $comparator
* @param ElementInterface $element
* @param ElementInterface $generatedElement
* @return bool
*/
public function shouldBeModified(
- Comparator $comparator,
ElementInterface $element,
ElementInterface $generatedElement
) {
- return !$comparator->compare($element, $generatedElement);
+ return !$this->comparator->compare($element, $generatedElement);
}
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/StructureDiff.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/StructureDiff.php
index 1a77f9a82d359..e1108c91791fb 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/StructureDiff.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/StructureDiff.php
@@ -11,24 +11,35 @@
/**
* Agregation root of all diffs
- * Loop through all tables
+ * Loop through all tables and find difference between them
+ *
+ * If table exists only in XML -> then we need to create table
+ * If table exists in both version -> then we need to go deeper and inspect each element
+ * If table exists only in db -> then we need to remove this table
+ * If table wasRenamedFrom attribute is differ with name -> then we need to rename table
*/
class StructureDiff
{
- use DiffManager;
-
/**
* @var TableDiff
*/
private $tableDiff;
/**
- * StructureDiff constructor.
+ * @var DiffManager
+ */
+ private $diffManager;
+
+ /**
+ * @param DiffManager $diffManager
* @param TableDiff $tableDiff
*/
- public function __construct(TableDiff $tableDiff)
- {
+ public function __construct(
+ DiffManager $diffManager,
+ TableDiff $tableDiff
+ ) {
$this->tableDiff = $tableDiff;
+ $this->diffManager = $diffManager;
}
/**
@@ -44,11 +55,11 @@ public function diff(
$generatedTables = $generatedStructure->getTables();
foreach ($structure->getTables() as $name => $table) {
- if ($this->shouldBeCreatedOrRenamed($generatedTables, $table)) {
- if ($this->shouldBeRenamed($table)) {
- $generatedTables = $this->registerRename($changeRegistry, $table, $generatedTables);
+ if ($this->diffManager->shouldBeCreatedOrRenamed($generatedTables, $table)) {
+ if ($this->diffManager->shouldBeRenamed($table)) {
+ $generatedTables = $this->diffManager->registerRename($changeRegistry, $table, $generatedTables);
} else {
- $this->registerCreation($changeRegistry, $table);
+ $this->diffManager->registerCreation($changeRegistry, $table);
}
} else {
$this->tableDiff->diff($table, $generatedTables[$name], $changeRegistry);
@@ -57,8 +68,8 @@ public function diff(
unset($generatedTables[$name]);
}
//Removal process
- if ($this->shouldBeRemoved($generatedTables)) {
- $this->registerRemoval($changeRegistry, $generatedTables, $structure->getTables());
+ if ($this->diffManager->shouldBeRemoved($generatedTables)) {
+ $this->diffManager->registerRemoval($changeRegistry, $generatedTables, $structure->getTables());
}
}
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/TableDiff.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/TableDiff.php
index 65493a8795318..38310937468fc 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/TableDiff.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/TableDiff.php
@@ -7,7 +7,6 @@
namespace Magento\Setup\Model\Declaration\Schema\Diff;
use Magento\Setup\Model\Declaration\Schema\ChangeRegistry;
-use Magento\Setup\Model\Declaration\Schema\Comparator;
use Magento\Setup\Model\Declaration\Schema\DiffInterface;
use Magento\Setup\Model\Declaration\Schema\Dto\ElementInterface;
use Magento\Setup\Model\Declaration\Schema\Dto\Table;
@@ -15,31 +14,40 @@
/**
* As table can have different types of elements inside itself
* We need to compare all of this elements
+ *
+ * If element exists only in XML -> then we need to create element
+ * If element exists in both version and are different -> then we need to modify element
+ * If element exists only in db -> then we need to remove this element
+ * If element wasRenamedFrom attribute is differ with name -> then we need to rename element
*/
class TableDiff implements DiffInterface
{
- use DiffManager;
-
- /** Column type for diff */
+ /**
+ * Column type for diff
+ */
const COLUMN_DIFF_TYPE = "columns";
- /** Constraint type for diff */
+ /**
+ * Constraint type for diff
+ */
const CONSTRAINT_DIFF_TYPE = "constraints";
- /** Constraint type for diff */
+ /**
+ * Constraint type for diff
+ */
const INDEX_DIFF_TYPE = "indexes";
/**
- * @var Comparator
+ * @var DiffManager
*/
- private $comparator;
+ private $diffManager;
/**
- * @param Comparator $comparator
+ * @param DiffManager $diffManager
*/
- public function __construct(Comparator $comparator)
+ public function __construct(DiffManager $diffManager)
{
- $this->comparator = $comparator;
+ $this->diffManager = $diffManager;
}
/**
@@ -61,18 +69,19 @@ public function diff(
foreach ($declaredElements as $element) {
//If it is new for generated (generated from db) elements - we need to create it
- if ($this->shouldBeCreatedOrRenamed($generatedElements, $element)) {
- if ($this->shouldBeRenamed($element)) {
- $generatedElements = $this->registerRename($changeRegistry, $element, $generatedElements);
+ if ($this->diffManager->shouldBeCreatedOrRenamed($generatedElements, $element)) {
+ if ($this->diffManager->shouldBeRenamed($element)) {
+ $generatedElements = $this->diffManager
+ ->registerRename($changeRegistry, $element, $generatedElements);
} else {
- $this->registerCreation($changeRegistry, $element);
+ $this->diffManager->registerCreation($changeRegistry, $element);
}
- } else if ($this->shouldBeModified(
- $this->comparator,
+ } else if ($this->diffManager->shouldBeModified(
$element,
$generatedElements[$element->getName()]
)) {
- $this->registerModification($changeRegistry, $element, $generatedElements[$element->getName()]);
+ $this->diffManager
+ ->registerModification($changeRegistry, $element, $generatedElements[$element->getName()]);
}
//Unset processed elements from generated from db structure
//All other unprocessed elements will be added as removed ones
@@ -80,8 +89,8 @@ public function diff(
}
//Elements that should be removed
- if ($this->shouldBeRemoved($generatedElements)) {
- $this->registerRemoval($changeRegistry, $generatedElements, $declaredElements);
+ if ($this->diffManager->shouldBeRemoved($generatedElements)) {
+ $this->diffManager->registerRemoval($changeRegistry, $generatedElements, $declaredElements);
}
}
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Blob.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Blob.php
index 54ac06d91bd04..b42618a3c2f5e 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Blob.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Blob.php
@@ -9,7 +9,8 @@
use Magento\Setup\Model\Declaration\Schema\Dto\ElementDiffAwareInterface;
/**
- * blob column
+ * This column represent binary type
+ * We can have few binary types: blob, mediumblob, largeblog
* Declared in SQL, like blob
*/
class Blob extends Column implements ElementDiffAwareInterface
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Boolean.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Boolean.php
index 3bbccd0d92c7d..502ac8e085936 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Boolean.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Boolean.php
@@ -10,8 +10,7 @@
/**
* Boolean column
- * Declared in SQL, like TINYINT(1) or VARBINARY(2). Is just alias for integer or binary type.
- * Can have
+ * Declared in SQL, like TINYINT(1) or BOOL or BOOLEAN. Is just alias for integer or binary type.
*/
class Boolean extends Column implements ElementDiffAwareInterface
{
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Text.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Text.php
index 1e1eac1c146a0..5d3907fc24eac 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Text.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Text.php
@@ -10,7 +10,7 @@
/**
* Text column
- * Declared in SQL, like TEXT
+ * Declared in SQL, like: TEXT, MEDIUMTEXT, LONGTEXT
*/
class Text extends Column implements ElementDiffAwareInterface
{
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/ElementDiffAwareInterface.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/ElementDiffAwareInterface.php
index c00a1cb191550..14a18a7c36474 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/ElementDiffAwareInterface.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/ElementDiffAwareInterface.php
@@ -6,7 +6,7 @@
namespace Magento\Setup\Model\Declaration\Schema\Dto;
/**
- * This interface provides all params, that should participate in element diff
+ * This interface provides all params, that should participate in elements comparison
*/
interface ElementDiffAwareInterface
{
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/ElementRenamedInterface.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/ElementRenamedInterface.php
index 746a9b49cedf1..aecc6650d4ed1 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/ElementRenamedInterface.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/ElementRenamedInterface.php
@@ -6,8 +6,9 @@
namespace Magento\Setup\Model\Declaration\Schema\Dto;
/**
- * This interface says, that element was renamed and new name should be specified for element
- * Rename attribute do not participate in diff operation
+ * This interface can said, that element was renamed and new name should be specified for element
+ *
+ * If DTO implements this interface - then element can be renamed
*/
interface ElementRenamedInterface
{
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/GenericElement.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/GenericElement.php
index 1abae422de0e0..1f5520ff1cddd 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/GenericElement.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/GenericElement.php
@@ -6,8 +6,13 @@
namespace Magento\Setup\Model\Declaration\Schema\Dto;
/**
- * This is data transfer object, that provides access to basic attributes
- * This class can`t be initialized
+ * This is data transfer object, that provides access to basic attributes of different
+ * structural elements
+ *
+ * Under structural element means one of next element, with which db schema can be represented:
+ * - column
+ * - constraint
+ * - index
*/
abstract class GenericElement implements
ElementInterface,
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/SchemaParserInterface.php b/setup/src/Magento/Setup/Model/Declaration/Schema/SchemaParserInterface.php
index 28f822b78bfac..59056b3daf4b2 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/SchemaParserInterface.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/SchemaParserInterface.php
@@ -10,6 +10,9 @@
/**
* Parser hydrate structure object with data from either db or XML file
+ * Usually parser use StructureBuilders
+ *
+ * Declaration has 2 structure builders, that build schema from db and from XML
*/
interface SchemaParserInterface
{
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Sharding.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Sharding.php
index d823dfbaf1976..70acc6d5b2074 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Sharding.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Sharding.php
@@ -11,6 +11,7 @@
/**
* Sharding gives possibility to see what structural element should be installed on what shard
+ * You can find what is shard in any SQL documentation
*/
class Sharding
{
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Xml/SchemaLocator.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Xml/SchemaLocator.php
index 8c6a368f7e005..cf9296c446d61 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Xml/SchemaLocator.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Xml/SchemaLocator.php
@@ -6,8 +6,7 @@
namespace Magento\Setup\Model\Declaration\Schema\Xml;
/**
- * Class SchemaLocator
- * @package Magento\Setup\Model\Declaration\Schema\Xml
+ * This is system class that provides .xsd file for validation XML schema
*/
class SchemaLocator implements \Magento\Framework\Config\SchemaLocatorInterface
{
From ee5f7d8adf69692aac63825b439f51e782a9fb4f Mon Sep 17 00:00:00 2001
From: Sergii Kovalenko
Date: Fri, 15 Dec 2017 13:59:52 +0200
Subject: [PATCH 227/904] MAGETWO-83201: Creating Diff artifacts between
arbitrary Declarative Schemas
--fix doc blocks
---
.../Setup/Model/Declaration/Schema/Dto/Columns/Varchar.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Varchar.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Varchar.php
index ec10803e7c76b..60b2b4485b5e0 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Varchar.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Varchar.php
@@ -57,7 +57,7 @@ public function getDefault()
}
/**
- * Length can be integer value from 0 to 255
+ * Length can be integer value from 0 to 1024
*
* @return int
*/
From d30696e873380058e5334bda2635e313d42c7371 Mon Sep 17 00:00:00 2001
From: Rostyslav Sabishchenko
Date: Fri, 15 Dec 2017 16:48:19 +0200
Subject: [PATCH 228/904] #12717 - Catalog Products List widget is not
displayed on Storefront
---
.../Catalog/Model/ResourceModel/Eav/Attribute.php | 11 +++++++++++
.../CatalogWidget/Model/Rule/Condition/Product.php | 13 +++++++++++--
2 files changed, 22 insertions(+), 2 deletions(-)
diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Eav/Attribute.php b/app/code/Magento/Catalog/Model/ResourceModel/Eav/Attribute.php
index 90b206e5a6091..f713fc79231ec 100644
--- a/app/code/Magento/Catalog/Model/ResourceModel/Eav/Attribute.php
+++ b/app/code/Magento/Catalog/Model/ResourceModel/Eav/Attribute.php
@@ -230,6 +230,17 @@ public function afterSave()
return parent::afterSave();
}
+ /**
+ * Is attribute enabled for flat indexing
+ *
+ * @return bool
+ */
+ public function isEnabledInFlat()
+ {
+ return $this->_isEnabledInFlat();
+ }
+
+
/**
* Is attribute enabled for flat indexing
*
diff --git a/app/code/Magento/CatalogWidget/Model/Rule/Condition/Product.php b/app/code/Magento/CatalogWidget/Model/Rule/Condition/Product.php
index 9c679b8bfe9b0..9805de0bb8d34 100644
--- a/app/code/Magento/CatalogWidget/Model/Rule/Condition/Product.php
+++ b/app/code/Magento/CatalogWidget/Model/Rule/Condition/Product.php
@@ -119,8 +119,17 @@ public function addToCollection($collection)
$attribute = $this->getAttributeObject();
if ($collection->isEnabledFlat()) {
- $alias = array_keys($collection->getSelect()->getPart('from'))[0];
- $this->joinedAttributes[$attribute->getAttributeCode()] = $alias . '.' . $attribute->getAttributeCode();
+ if ($attribute->isEnabledInFlat()) {
+ $alias = array_keys($collection->getSelect()->getPart('from'))[0];
+ $this->joinedAttributes[$attribute->getAttributeCode()] = $alias . '.' . $attribute->getAttributeCode();
+ } else {
+ $alias = 'at_' . $attribute->getAttributeCode();
+ if (!in_array($alias, array_keys($collection->getSelect()->getPart('from')))) {
+ $collection->joinAttribute($attribute->getAttributeCode(), 'catalog_product/'.$attribute->getAttributeCode(), 'entity_id');
+ }
+
+ $this->joinedAttributes[$attribute->getAttributeCode()] = $alias . '.value';
+ }
return $this;
}
From f32612666170079aa89e3c52bda64b279e89ac7d Mon Sep 17 00:00:00 2001
From: Sergii Kovalenko
Date: Fri, 15 Dec 2017 19:10:01 +0200
Subject: [PATCH 229/904] MAGETWO-84100: Unify Magento SQL adapters
---
app/etc/di.xml | 7 +-
.../Declaration/Schema/ChangeRegistry.php | 2 +-
.../Declaration/Schema/Db/AdapterMediator.php | 82 ++++++++++++++++---
.../Processors/DbSchemaProcessorInterface.php | 8 ++
.../Db/Processors/DbSchemaWriterInterface.php | 38 +++++++++
.../Db/Processors/MySQL/Columns/Basic.php | 49 +++++++++--
.../Db/Processors/MySQL/Columns/Boolean.php | 47 ++++++++++-
.../Db/Processors/MySQL/Columns/Decimal.php | 29 ++++++-
.../Db/Processors/MySQL/Columns/Identity.php | 53 ++++++++++++
.../Db/Processors/MySQL/Columns/Integer.php | 51 +++++++++---
.../Db/Processors/MySQL/Columns/Nullable.php | 66 +++++++++++++++
.../Db/Processors/MySQL/Columns/OnUpdate.php | 12 ++-
.../Db/Processors/MySQL/Columns/Text.php | 30 ++++++-
.../Db/Processors/MySQL/Columns/Timestamp.php | 16 +++-
.../Db/Processors/MySQL/Columns/Unsigned.php | 14 +++-
.../Db/Processors/MySQL/Columns/Varchar.php | 34 +++++++-
.../Db/Processors/MySQL/DbSchemaCreator.php | 51 ++++++++++++
.../Declaration/Schema/Dto/Columns/Blob.php | 4 +-
.../Schema/Dto/Columns/Boolean.php | 4 +-
.../Columns/ColumnIdentityAwareInterface.php | 19 +++++
.../Columns/ColumnNullableAwareInterface.php | 21 +++++
.../Columns/ColumnUnsignedAwareInterface.php | 21 +++++
.../Schema/Dto/Columns/Decimal.php | 5 +-
.../Schema/Dto/Columns/Integer.php | 6 +-
.../Declaration/Schema/Dto/Columns/Text.php | 4 +-
.../Schema/Dto/Columns/Varbinary.php | 6 +-
.../Schema/Dto/Columns/Varchar.php | 4 +-
.../Model/Declaration/Schema/Sharding.php | 7 +-
28 files changed, 632 insertions(+), 58 deletions(-)
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/DbSchemaWriterInterface.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Identity.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Nullable.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/DbSchemaCreator.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/ColumnIdentityAwareInterface.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/ColumnNullableAwareInterface.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/ColumnUnsignedAwareInterface.php
diff --git a/app/etc/di.xml b/app/etc/di.xml
index 1c188f8b82dab..1c36881e0b13e 100755
--- a/app/etc/di.xml
+++ b/app/etc/di.xml
@@ -1401,7 +1401,7 @@
-
+
-
- \Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL\Columns\Basic
- \Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL\Columns\Integer
@@ -1409,16 +1409,13 @@
- \Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL\Columns\Text
- \Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL\Columns\Timestamp
- \Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL\Columns\Varchar
- - \Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL\Columns\OnUpdate
-
- \Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL\Index
- -
-
- \Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL\Constraints\ForeignKey
-
-
- \Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL\Constraints\Internal
+ - \Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL\Constraints\ForeignKey
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/ChangeRegistry.php b/setup/src/Magento/Setup/Model/Declaration/Schema/ChangeRegistry.php
index 346c2d816624f..fc808c5355223 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/ChangeRegistry.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/ChangeRegistry.php
@@ -15,7 +15,7 @@
* Holds information about all changes between 2 schemas: db and declaration XML
* Holds 2 items:
* - new (Should be changed to)
- * - old (Was)
+ * - old ()
*/
class ChangeRegistry implements ChangeRegistryInterface
{
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/AdapterMediator.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/AdapterMediator.php
index 16b16f45ccbea..9f8430fc3b994 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/AdapterMediator.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/AdapterMediator.php
@@ -6,13 +6,16 @@
namespace Magento\Setup\Model\Declaration\Schema\Db;
+use Magento\Setup\Model\Declaration\Schema\Db\Processors\DbSchemaCreatorInterface;
use Magento\Setup\Model\Declaration\Schema\Db\Processors\DbSchemaProcessorInterface;
use Magento\Setup\Model\Declaration\Schema\Db\Processors\DbSchemaReaderInterface;
+use Magento\Setup\Model\Declaration\Schema\Dto\ElementInterface;
+use Magento\Setup\Model\Declaration\Schema\Dto\Table;
/**
* Needs for different types of SQL engines
* Depends on SQL engine, envolves different processors and convert from SQL schema represenation
- * to readable or from do DDL operations: convert from DTO`s objects to SQL definition and run SQL query.
+ * to readable or from do DDL operations: convert from DTO`s objects to SQL definition
*/
class AdapterMediator
{
@@ -51,22 +54,31 @@ class AdapterMediator
/**
* @var array
*/
- private $columnProcessors;
+ private $processors;
+
/**
* @var DbSchemaReaderInterface
*/
private $dbSchemaReader;
+ /**
+ * @var DbSchemaCreatorInterface
+ */
+ private $dbSchemaCreator;
+
/**
* @param DbSchemaReaderInterface $dbSchemaReader
- * @param array $columnProcessors
+ * @param DbSchemaCreatorInterface $dbSchemaCreator
+ * @param array $processors
*/
public function __construct(
DbSchemaReaderInterface $dbSchemaReader,
- array $columnProcessors
+ DbSchemaCreatorInterface $dbSchemaCreator,
+ array $processors
) {
- $this->columnProcessors = $columnProcessors;
+ $this->processors = $processors;
$this->dbSchemaReader = $dbSchemaReader;
+ $this->dbSchemaCreator = $dbSchemaCreator;
}
/**
@@ -77,20 +89,66 @@ public function __construct(
* @param $type
* @return array
*/
- private function processElement(array $elementData, $type)
+ private function processElementFromDefinition(array $elementData, $type)
{
- if (!isset($this->columnProcessors[$type])) {
+ if (!isset($this->processors[$type])) {
throw new \InvalidArgumentException(sprintf("Cannot find type %s", $type));
}
/** @var DbSchemaProcessorInterface $columnProcessor */
- foreach ($this->columnProcessors[$type] as $columnProcessor) {
+ foreach ($this->processors[$type] as $columnProcessor) {
$elementData = $columnProcessor->fromDefinition($elementData);
}
return $elementData;
}
+ /**
+ * Retrieve definition for all table elements
+ *
+ * @param Table $table
+ * @return array
+ */
+ public function getTableDefinition(Table $table)
+ {
+ $definition = [];
+ $data = [
+ DbSchemaCreatorInterface::COLUMN_FRAGMENT => $table->getColumns(),
+ DbSchemaCreatorInterface::CONSTRAINT_FRAGMENT => $table->getConstraints(),
+ DbSchemaCreatorInterface::INDEX_FRAGMENT => $table->getIndexes()
+ ];
+
+ foreach ($data as $type => $elements) {
+ /** @var ElementInterface $element */
+ foreach ($elements as $element) {
+ $definition[$type] = $this->processElementToDefinition($type, $element);
+ }
+ }
+
+ return $definition;
+ }
+
+ /**
+ * Process column definition
+ *
+ * @param string $type
+ * @param ElementInterface $element
+ * @return string
+ */
+ public function processElementToDefinition($type, ElementInterface $element)
+ {
+ $definition = '';
+ /** @var DbSchemaProcessorInterface $processor */
+ foreach ($this->processors[$type] as $processor) {
+ //One column processor can override or modify existing one
+ if ($processor->canBeApplied($element)) {
+ $definition = $processor->toDefinition($element);
+ }
+ }
+
+ return $definition;
+ }
+
/**
* Retrieve the list of all Magento non-unique and non-primary indexes
*
@@ -103,7 +161,7 @@ public function getIndexesList($tableName, $resource = 'default')
if (!isset($this->ddlCache[self::KEY_INDEXES][$tableName])) {
$this->ddlCache[self::KEY_INDEXES][$tableName] = [];
foreach ($this->dbSchemaReader->readIndexes($tableName, $resource) as $indexData) {
- $index = $this->processElement($indexData, self::KEY_INDEXES);
+ $index = $this->processElementFromDefinition($indexData, self::KEY_INDEXES);
if (!isset($this->ddlCache[self::KEY_INDEXES][$tableName][$index['name']])) {
$this->ddlCache[self::KEY_INDEXES][$tableName][$index['name']] = [];
@@ -130,7 +188,7 @@ public function getConstraintsList($tableName, $resource = 'default')
$this->ddlCache[self::KEY_CONSTRAINT][$tableName] = [];
$constraintsData = $this->dbSchemaReader->readConstraints($tableName, $resource);
foreach ($constraintsData as $constraintData) {
- $constraint = $this->processElement($constraintData, self::KEY_CONSTRAINT);
+ $constraint = $this->processElementFromDefinition($constraintData, self::KEY_CONSTRAINT);
if (!isset($this->ddlCache[self::KEY_CONSTRAINT][$tableName][$constraint['name']])) {
$this->ddlCache[self::KEY_CONSTRAINT][$tableName][$constraint['name']] = [];
@@ -158,7 +216,7 @@ public function getReferencesList($tableName, $resource = 'default')
if (!isset($this->ddlCache[self::KEY_REFERENCE][$tableName])) {
$this->ddlCache[self::KEY_REFERENCE][$tableName] = [];
$createTable = $this->dbSchemaReader->readReferences($tableName, $resource);
- $foreignKeys = $this->processElement($createTable, self::KEY_REFERENCE);
+ $foreignKeys = $this->processElementFromDefinition($createTable, self::KEY_REFERENCE);
//Process foreign keys
foreach ($foreignKeys as $foreignKey) {
$this->ddlCache[self::KEY_REFERENCE][$tableName][$foreignKey['name']] = $foreignKey;
@@ -178,7 +236,7 @@ public function getColumnsList($tableName, $resource = 'default')
if (!isset($this->ddlCache[self::KEY_COLUMNS][$tableName])) {
$this->ddlCache[self::KEY_COLUMNS][$tableName] = [];
foreach ($this->dbSchemaReader->readeColumns($tableName, $resource) as $rawColumn) {
- $column = $this->processElement($rawColumn, self::KEY_COLUMNS);
+ $column = $this->processElementFromDefinition($rawColumn, self::KEY_COLUMNS);
$this->ddlCache[self::KEY_COLUMNS][$tableName][$column['name']] = $column;
}
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/DbSchemaProcessorInterface.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/DbSchemaProcessorInterface.php
index 2183645138adf..4eb60118d1fdf 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/DbSchemaProcessorInterface.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/DbSchemaProcessorInterface.php
@@ -16,6 +16,14 @@
*/
interface DbSchemaProcessorInterface
{
+ /**
+ * Check whether current processor can process element
+ *
+ * @param ElementInterface $element
+ * @return mixed
+ */
+ public function canBeApplied(ElementInterface $element);
+
/**
* Output always will be SQL definition
*
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/DbSchemaWriterInterface.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/DbSchemaWriterInterface.php
new file mode 100644
index 0000000000000..53aaa08281db4
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/DbSchemaWriterInterface.php
@@ -0,0 +1,38 @@
+unsigned = $unsigned;
+ $this->nullable = $nullable;
}
/**
- * Convert MySQL nullable string value into boolean
+ * Basic type can not process any type of elements
*
- * @param string $nullableValue
+ * @param ElementInterface $element
* @return bool
*/
- private function processNullable($nullableValue)
+ public function canBeApplied(ElementInterface $element)
+ {
+ return false;
+ }
+
+ /**
+ * Column definition sequence:
+ * - type
+ * - padding/scale/precision
+ * - unsigned
+ * - nullable
+ * - default
+ * - identity
+ * - comment
+ * - after-comment
+ *
+ * @inheritdoc
+ */
+ public function toDefinition(ElementInterface $element)
{
- return strtolower($nullableValue) === 'yes' ? true : false;
+ throw new \LogicException("Basic processor, can`t convert any element to definition");
}
/**
@@ -56,7 +86,10 @@ public function fromDefinition(array $data)
{
$data = array_combine(array_values(self::$tokens), array_values($data));
$data['type'] = strtolower($data['type']);
- $data['nullable'] = $this->processNullable($data['nullable']);
+
+ $data = $this->unsigned->fromDefinition($data);
+ $data = $this->nullable->fromDefinition($data);
+
unset($data['key']); //we do not need key, as it will be calculated from indexes
return $data;
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Boolean.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Boolean.php
index fafef14539479..aa5862ce4ee4d 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Boolean.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Boolean.php
@@ -18,11 +18,53 @@
class Boolean implements DbSchemaProcessorInterface
{
/**
+ * Type with what we will persist column
+ */
+ const TYPE = 'BOOLEAN';
+
+ /**
+ * Type of integer that will be used in MySQL for boolean
+ */
+ const INTEGER_TYPE = 'tinyinteger';
+
+ /**
+ * Padding for integer described below
+ */
+ const INTEGER_PADDING = '1';
+
+ /**
+ * @var Nullable
+ */
+ private $nullable;
+
+ /**
+ * @param Nullable $nullable
+ */
+ public function __construct(Nullable $nullable)
+ {
+ $this->nullable = $nullable;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function canBeApplied(ElementInterface $element)
+ {
+ return $element instanceof \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Boolean;
+ }
+
+ /**
+ * @param \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Boolean $element
* @inheritdoc
*/
public function toDefinition(ElementInterface $element)
{
- return '';
+ return sprintf(
+ '%s %s %s',
+ self::TYPE,
+ $this->nullable->toDefinition($element),
+ $element->getDefault()
+ );
}
/**
@@ -32,9 +74,10 @@ public function toDefinition(ElementInterface $element)
*/
public function fromDefinition(array $data)
{
- if ($data['type'] === 'tinyinteger' && $data['padding'] === '1') {
+ if ($data['type'] === self::INTEGER_TYPE && $data['padding'] === self::INTEGER_PADDING) {
$data['type'] = 'boolean';
$data['default'] = (bool) $data['default'];
+ $data['unsigned'] = false; //For boolean we always do not want to have unsigned
}
return $data;
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Decimal.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Decimal.php
index 4b2b0abee19ac..40b2948a5853d 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Decimal.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Decimal.php
@@ -16,25 +16,49 @@
*/
class Decimal implements DbSchemaProcessorInterface
{
+ /**
+ * @var Nullable
+ */
+ private $nullable;
+
/**
* @var Unsigned
*/
private $unsigned;
/**
+ * @param Nullable $nullable
* @param Unsigned $unsigned
*/
- public function __construct(Unsigned $unsigned)
+ public function __construct(Nullable $nullable, Unsigned $unsigned)
{
+ $this->nullable = $nullable;
$this->unsigned = $unsigned;
}
/**
* @inheritdoc
*/
+ public function canBeApplied(ElementInterface $element)
+ {
+ return $element instanceof \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Decimal;
+ }
+
+ /**
+ * @param \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Decimal $element
+ * @inheritdoc
+ */
public function toDefinition(ElementInterface $element)
{
- return '';
+ return sprintf(
+ '%s(%s, %s) %s %s %s',
+ $element->getElementType(),
+ $element->getScale(),
+ $element->getPrecission(),
+ $this->unsigned->toDefinition($element),
+ $this->nullable->toDefinition($element),
+ $element->getDefault()
+ );
}
/**
@@ -49,7 +73,6 @@ public function fromDefinition(array $data)
* match[2] - precision
* match[3] - scale
*/
- $data = $this->unsigned->fromDefinition($data);
$data['type'] = $matches[1];
if (isset($matches[2]) && isset($matches[3])) {
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Identity.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Identity.php
new file mode 100644
index 0000000000000..e3a05ea63ced1
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Identity.php
@@ -0,0 +1,53 @@
+isIdentity() ? strtoupper(self::IDENTITY_FLAG) : '';
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function canBeApplied(ElementInterface $element)
+ {
+ return false;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function fromDefinition(array $data)
+ {
+ if (!empty($data['extra']) && strpos(self::IDENTITY_FLAG, $data['extra']) !== false) {
+ $data['identity'] = true;
+ }
+
+ return $data;
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Integer.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Integer.php
index 6fe8c5b9693fc..23ecf443f72a1 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Integer.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Integer.php
@@ -16,11 +16,6 @@
*/
class Integer implements DbSchemaProcessorInterface
{
- /**
- * MyMySQL flag, that says that we need to increment field, each time when we add new row
- */
- const IDENTITY_FLAG = 'auto_increment';
-
/**
* @var Unsigned
*/
@@ -31,22 +26,57 @@ class Integer implements DbSchemaProcessorInterface
*/
private $boolean;
+ /**
+ * @var Nullable
+ */
+ private $nullable;
+
+ /**
+ * @var Identity
+ */
+ private $identity;
+
/**
* @param Unsigned $unsigned
* @param bool $boolean
+ * @param Nullable $nullable
+ * @param Identity $identity
*/
- public function __construct(Unsigned $unsigned, Boolean $boolean)
- {
+ public function __construct(
+ Unsigned $unsigned,
+ Boolean $boolean,
+ Nullable $nullable,
+ Identity $identity
+ ) {
$this->unsigned = $unsigned;
$this->boolean = $boolean;
+ $this->nullable = $nullable;
+ $this->identity = $identity;
}
/**
* @inheritdoc
*/
+ public function canBeApplied(ElementInterface $element)
+ {
+ return $element instanceof \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Integer;
+ }
+
+ /**
+ * @param \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Integer $element
+ * @inheritdoc
+ */
public function toDefinition(ElementInterface $element)
{
- return '';
+ return sprintf(
+ '%s(%s) %s %s %s %s',
+ $element->getElementType(),
+ $element->getPadding(),
+ $this->unsigned->toDefinition($element),
+ $this->nullable->toDefinition($element),
+ $element->getDefault(),
+ $this->identity->toDefinition($element)
+ );
}
/**
@@ -70,10 +100,7 @@ public function fromDefinition(array $data)
$data['padding'] = $matches[2];
}
- if (!empty($data['extra']) && strpos(self::IDENTITY_FLAG, $data['extra']) !== false) {
- $data['identity'] = true;
- }
-
+ $data = $this->identity->fromDefinition($data);
$data = $this->boolean->fromDefinition($data);
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Nullable.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Nullable.php
new file mode 100644
index 0000000000000..b04f368b2f072
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Nullable.php
@@ -0,0 +1,66 @@
+isNullable() ? 'NULL' : 'NOT NULL';
+ }
+
+ return '';
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function canBeApplied(ElementInterface $element)
+ {
+ return false;
+ }
+
+ /**
+ * Convert MySQL nullable string value into boolean
+ *
+ * @param string $nullableValue
+ * @return bool
+ */
+ private function processNullable($nullableValue)
+ {
+ return strtolower($nullableValue) === 'yes' ? true : false;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function fromDefinition(array $data)
+ {
+ $data['nullable'] = $this->processNullable($data['nullable']);
+ return $data;
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/OnUpdate.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/OnUpdate.php
index 2181f4b34e3bd..06451172e6857 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/OnUpdate.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/OnUpdate.php
@@ -17,11 +17,21 @@
class OnUpdate implements DbSchemaProcessorInterface
{
/**
+ * @param \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Timestamp $element
* @inheritdoc
*/
public function toDefinition(ElementInterface $element)
{
- return '';
+ return $element->getOnUpdate() ?
+ 'ON UPDATE CURRENT_TIMESTAMP' : '';
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function canBeApplied(ElementInterface $element)
+ {
+ return false;
}
/**
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Text.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Text.php
index 7f0f46136bbe0..b730cfe07bf3b 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Text.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Text.php
@@ -17,11 +17,39 @@
class Text implements DbSchemaProcessorInterface
{
/**
+ * @var Nullable
+ */
+ private $nullable;
+
+ /**
+ * Text constructor.
+ * @param Nullable $nullable
+ */
+ public function __construct(Nullable $nullable)
+ {
+ $this->nullable = $nullable;
+ }
+
+ /**
+ * @param \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Text $element
* @inheritdoc
*/
public function toDefinition(ElementInterface $element)
{
- return '';
+ return sprintf(
+ '%s(%s)',
+ $element->getElementType(),
+ $element->getLength(),
+ $this->nullable->toDefinition($element)
+ );
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function canBeApplied(ElementInterface $element)
+ {
+ return $element instanceof \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Text;
}
/**
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Timestamp.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Timestamp.php
index 34a6b653ee0d5..427b2cfcf645f 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Timestamp.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Timestamp.php
@@ -33,9 +33,23 @@ public function __construct(OnUpdate $onUpdate)
/**
* @inheritdoc
*/
+ public function canBeApplied(ElementInterface $element)
+ {
+ return $element instanceof \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Timestamp;
+ }
+
+ /**
+ * @param \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Timestamp $element
+ * @inheritdoc
+ */
public function toDefinition(ElementInterface $element)
{
- return '';
+ return sprintf(
+ '%s %s %s',
+ $element->getElementType(),
+ $element->getDefault(),
+ $this->onUpdate->toDefinition($element)
+ );
}
/**
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Unsigned.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Unsigned.php
index cc39e2d91713f..309b7e9d89fcb 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Unsigned.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Unsigned.php
@@ -7,6 +7,7 @@
namespace Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL\Columns;
use Magento\Setup\Model\Declaration\Schema\Db\Processors\DbSchemaProcessorInterface;
+use Magento\Setup\Model\Declaration\Schema\Dto\Columns\ColumnUnsignedAwareInterface;
use Magento\Setup\Model\Declaration\Schema\Dto\ElementInterface;
/**
@@ -17,17 +18,26 @@
class Unsigned implements DbSchemaProcessorInterface
{
/**
- * MyMySQL flag, that says that we need to use unsigned numbers.
+ * MySQL flag, that says that we need to use unsigned numbers.
* Can be applicable only for number types
*/
const UNSIGNED_FLAG = 'unsigned';
/**
+ * @param ColumnUnsignedAwareInterface $element
* @inheritdoc
*/
public function toDefinition(ElementInterface $element)
{
- return '';
+ return $element->isUnsigned() ? 'UNSIGNED' : '';
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function canBeApplied(ElementInterface $element)
+ {
+ return false;
}
/**
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Varchar.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Varchar.php
index 5971ef698ce9c..f4a927e139c69 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Varchar.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Varchar.php
@@ -6,6 +6,7 @@
namespace Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL\Columns;
use Magento\Setup\Model\Declaration\Schema\Db\Processors\DbSchemaProcessorInterface;
+use Magento\Setup\Model\Declaration\Schema\Dto\Columns\Varbinary;
use Magento\Setup\Model\Declaration\Schema\Dto\ElementInterface;
/**
@@ -14,12 +15,43 @@
class Varchar implements DbSchemaProcessorInterface
{
/**
+ * @var Nullable
+ */
+ private $nullable;
+
+ /**
+ * @param Nullable $nullable
+ */
+ public function __construct(Nullable $nullable)
+ {
+ $this->nullable = $nullable;
+ }
+
+ /**
+ * @param \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Varchar $element
+ * @param \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Varbinary $element
* @inheritdoc
*/
public function toDefinition(ElementInterface $element)
{
- return '';
+ return sprintf(
+ '%s(%s) %s %s',
+ $element->getElementType(),
+ $element->getLength(),
+ $this->nullable->toDefinition($element),
+ $element->getDefault()
+ );
}
+
+ /**
+ * @inheritdoc
+ */
+ public function canBeApplied(ElementInterface $element)
+ {
+ return $element instanceof \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Varchar ||
+ $element instanceof Varbinary;
+ }
+
/**
* @inheritdoc
*/
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/DbSchemaCreator.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/DbSchemaCreator.php
new file mode 100644
index 0000000000000..6425e87a85078
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/DbSchemaCreator.php
@@ -0,0 +1,51 @@
+resourceConnection = $resourceConnection;
+ }
+
+ /**
+ * @inheritdoc
+ * @param array $tableOptions
+ * @param array $sqlFragments
+ * @return \Zend_Db_Statement_Interface
+ */
+ public function createTable(array $tableOptions, array $sqlFragments)
+ {
+ $connection = isset($tableOptions['connection']) ?
+ $tableOptions['connection'] : Sharding::DEFAULT_CONNECTION;
+ $sql = sprintf(
+ "CREATE TABLE IF NOT EXISTS %s (\n%s\n)",
+ $tableOptions['name'],
+ $sqlFragments[self::COLUMN_FRAGMENT]
+ );
+
+ return $this->resourceConnection
+ ->getConnection($connection)
+ ->query($sql);
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Blob.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Blob.php
index b42618a3c2f5e..62b674c61e8e4 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Blob.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Blob.php
@@ -13,7 +13,9 @@
* We can have few binary types: blob, mediumblob, largeblog
* Declared in SQL, like blob
*/
-class Blob extends Column implements ElementDiffAwareInterface
+class Blob extends Column implements
+ ElementDiffAwareInterface,
+ ColumnNullableAwareInterface
{
/**
* By default element type is blob, but it can various: blob, mediumblob, longblob
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Boolean.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Boolean.php
index 502ac8e085936..a3a1fa1e0b2bf 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Boolean.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Boolean.php
@@ -12,7 +12,9 @@
* Boolean column
* Declared in SQL, like TINYINT(1) or BOOL or BOOLEAN. Is just alias for integer or binary type.
*/
-class Boolean extends Column implements ElementDiffAwareInterface
+class Boolean extends Column implements
+ ElementDiffAwareInterface,
+ ColumnNullableAwareInterface
{
/**
* @inheritdoc
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/ColumnIdentityAwareInterface.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/ColumnIdentityAwareInterface.php
new file mode 100644
index 0000000000000..d8fdfa5f134de
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/ColumnIdentityAwareInterface.php
@@ -0,0 +1,19 @@
+
Date: Mon, 18 Dec 2017 14:43:02 +0200
Subject: [PATCH 230/904] MAGETWO-84100: Unify Magento SQL adapters
---
.../Schema/Casters/Tinyinteger.php | 1 +
.../Declaration/Schema/Db/AdapterMediator.php | 2 +-
.../MySQL/Constraints/ForeignKey.php | 24 +++++-
.../Processors/MySQL/Constraints/Internal.php | 33 ++++++-
.../Db/Processors/MySQL/DbSchemaCreator.php | 51 -----------
.../Db/Processors/MySQL/DbSchemaWriter.php | 85 +++++++++++++++++++
.../Schema/Db/Processors/MySQL/Index.php | 24 +++++-
.../Declaration/Schema/Declaration/Parser.php | 1 +
.../Schema/Declaration/StructureBuilder.php | 9 ++
9 files changed, 175 insertions(+), 55 deletions(-)
delete mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/DbSchemaCreator.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/DbSchemaWriter.php
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Casters/Tinyinteger.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Casters/Tinyinteger.php
index c3fc8d4198e27..dd5f36def4ed9 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Casters/Tinyinteger.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Casters/Tinyinteger.php
@@ -6,6 +6,7 @@
namespace Magento\Setup\Model\Declaration\Schema\Casters;
/**
+ * @TODO: factories instead of casters
* Serves needs in integer digits. Default padding is 1.
* Size is 1 byte.
*/
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/AdapterMediator.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/AdapterMediator.php
index 9f8430fc3b994..8de3935573eae 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/AdapterMediator.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/AdapterMediator.php
@@ -121,7 +121,7 @@ public function getTableDefinition(Table $table)
foreach ($data as $type => $elements) {
/** @var ElementInterface $element */
foreach ($elements as $element) {
- $definition[$type] = $this->processElementToDefinition($type, $element);
+ $definition[$type][$element->getName()] = $this->processElementToDefinition($type, $element);
}
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Constraints/ForeignKey.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Constraints/ForeignKey.php
index 085be601f1562..d30ed7f5e5b44 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Constraints/ForeignKey.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Constraints/ForeignKey.php
@@ -7,6 +7,7 @@
namespace Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL\Constraints;
use Magento\Setup\Model\Declaration\Schema\Db\Processors\DbSchemaProcessorInterface;
+use Magento\Setup\Model\Declaration\Schema\Dto\Constraints\Reference;
use Magento\Setup\Model\Declaration\Schema\Dto\ElementInterface;
/**
@@ -18,11 +19,32 @@
class ForeignKey implements DbSchemaProcessorInterface
{
/**
+ * @param Reference $element
* @inheritdoc
*/
public function toDefinition(ElementInterface $element)
{
- return '';
+ /** @TODO: purge records, if the are not satisfied on delete statement */
+ $foreignKeySql = sprintf(
+ "FOREIGN KEY (%s) REFERENCES %s (%s)",
+ $element->getColumn()->getName(),
+ $element->getReferenceTable()->getName(),
+ $element->getReferenceColumn()->getName()
+ );
+
+ if ($element->getOnDelete()) {
+ $foreignKeySql .= sprintf("ON DELETE %s", $element->getOnDelete());
+ }
+
+ return $foreignKeySql;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function canBeApplied(ElementInterface $element)
+ {
+ return $element instanceof \Magento\Setup\Model\Declaration\Schema\Dto\Constraints\Reference;
}
/**
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Constraints/Internal.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Constraints/Internal.php
index 25da57cc23d5c..7fe9796bba150 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Constraints/Internal.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Constraints/Internal.php
@@ -7,6 +7,7 @@
namespace Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL\Constraints;
use Magento\Setup\Model\Declaration\Schema\Db\Processors\DbSchemaProcessorInterface;
+use Magento\Setup\Model\Declaration\Schema\Dto\Column;
use Magento\Setup\Model\Declaration\Schema\Dto\ElementInterface;
/**
@@ -22,11 +23,41 @@ class Internal implements DbSchemaProcessorInterface
const PRIMARY_NAME = 'PRIMARY';
/**
+ * Primary key name, that is used in definition
+ */
+ const PRIMARY_KEY_NAME = 'PRIMARY KEY';
+
+ /**
+ * Uniqe key name, that is used in definition
+ */
+ const UNIQUE_KEY_NAME = 'UNIQUE KEY';
+
+ /**
+ * @param \Magento\Setup\Model\Declaration\Schema\Dto\Constraints\Internal $element
* @inheritdoc
*/
public function toDefinition(ElementInterface $element)
{
- return '';
+ $columnsList = array_map(
+ function(Column $column) {
+ return $column->getName();
+ },
+ $element->getColumns()
+ );
+
+ return sprintf(
+ '%s (%s)',
+ $element->getElementType() === 'primary' ? 'PRIMARY KEY' : 'UNIQUE KEY',
+ implode(',', $columnsList)
+ );
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function canBeApplied(ElementInterface $element)
+ {
+ return $element instanceof \Magento\Setup\Model\Declaration\Schema\Dto\Constraints\Internal;
}
/**
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/DbSchemaCreator.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/DbSchemaCreator.php
deleted file mode 100644
index 6425e87a85078..0000000000000
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/DbSchemaCreator.php
+++ /dev/null
@@ -1,51 +0,0 @@
-resourceConnection = $resourceConnection;
- }
-
- /**
- * @inheritdoc
- * @param array $tableOptions
- * @param array $sqlFragments
- * @return \Zend_Db_Statement_Interface
- */
- public function createTable(array $tableOptions, array $sqlFragments)
- {
- $connection = isset($tableOptions['connection']) ?
- $tableOptions['connection'] : Sharding::DEFAULT_CONNECTION;
- $sql = sprintf(
- "CREATE TABLE IF NOT EXISTS %s (\n%s\n)",
- $tableOptions['name'],
- $sqlFragments[self::COLUMN_FRAGMENT]
- );
-
- return $this->resourceConnection
- ->getConnection($connection)
- ->query($sql);
- }
-}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/DbSchemaWriter.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/DbSchemaWriter.php
new file mode 100644
index 0000000000000..f5cd31cb1a804
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/DbSchemaWriter.php
@@ -0,0 +1,85 @@
+resourceConnection = $resourceConnection;
+ }
+
+ /**
+ * Prepare constraint statement by compiling name and definition together
+ *
+ * @param string $name
+ * @param string $constraintDefinition
+ * @return string
+ */
+ private function getAddConstraintSQL($name, $constraintDefinition)
+ {
+ return sprintf('ADD CONSTRAINT %s %s', $name, $constraintDefinition);
+ }
+
+ /**
+ * Prepare constraint statement by compiling name and definition together
+ *
+ * @param string $name
+ * @param string $indexDefinition
+ * @return string
+ */
+ private function getAddIndexSQL($name, $indexDefinition)
+ {
+ return sprintf('ADD INDEX %s %s', $name, $indexDefinition);
+ }
+
+ /**
+ * @inheritdoc
+ * @param array $tableOptions
+ * @param array $definition
+ * @return \Zend_Db_Statement_Interface
+ */
+ public function createTable(array $tableOptions, array $definition)
+ {
+ $connection = $tableOptions['resource'];
+ $indecisSQL = [];
+ $constraintsSQL = [];
+
+ foreach ($definition[self::INDEX_FRAGMENT] as $name => $indexDefinition) {
+ $indecisSQL[] = $this->getIndexSQL($name, $indexDefinition);
+ }
+
+ foreach ($definition[self::CONSTRAINT_FRAGMENT] as $name => $constraintDefinition) {
+ $constraintsSQL[] = $this->getAddConstraintSQL($name, $constraintDefinition);
+ }
+
+ $sql = sprintf(
+ "CREATE TABLE IF NOT EXISTS %s (\n%s\n)",
+ $tableOptions['name'],
+ $definition[self::COLUMN_FRAGMENT]
+ );
+
+ return $this->resourceConnection
+ ->getConnection($connection)
+ ->query($sql);
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Index.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Index.php
index a7ae08e537304..374eecd10447e 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Index.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Index.php
@@ -7,6 +7,7 @@
namespace Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL;
use Magento\Setup\Model\Declaration\Schema\Db\Processors\DbSchemaProcessorInterface;
+use Magento\Setup\Model\Declaration\Schema\Dto\Column;
use Magento\Setup\Model\Declaration\Schema\Dto\ElementInterface;
/**
@@ -24,11 +25,32 @@ class Index implements DbSchemaProcessorInterface
];
/**
+ * @param \Magento\Setup\Model\Declaration\Schema\Dto\Index $element
* @inheritdoc
*/
public function toDefinition(ElementInterface $element)
{
- return '';
+ $columnsList = array_map(
+ function(Column $column) {
+ return $column->getName();
+ },
+ $element->getColumns()
+ );
+ //as we used index types, that are similar to MySQL ones, we can just make it upper
+ return sprintf(
+ '%s %s (%s)',
+ strtoupper($element->getElementType()),
+ $element->getName(),
+ implode(',', $columnsList)
+ );
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function canBeApplied(ElementInterface $element)
+ {
+ return $element instanceof \Magento\Setup\Model\Declaration\Schema\Dto\Index;
}
/**
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/Parser.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/Parser.php
index d07db90d6186c..2d7f34e929a44 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/Parser.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/Parser.php
@@ -11,6 +11,7 @@
use Magento\Setup\Model\Declaration\Schema\SchemaParserInterface;
/**
+ * @TODO: add composite readers
* Read schema data from XML and convert it to objects representation
*/
class Parser implements SchemaParserInterface
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/StructureBuilder.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/StructureBuilder.php
index f765da3a0497c..5dc60450ef560 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/StructureBuilder.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/StructureBuilder.php
@@ -15,12 +15,21 @@
use Magento\Setup\Model\Declaration\Schema\Sharding;
/**
+ * @TODO: rename to schema
* This type of builder is responsible for converting ENTIRE data, that comes from XML
* into DTO`s format, with aggregation root: Structure
*
* Note: StructureBuilder can not be used for one structural element, like column or constraint
* because it should have references to other DTO objects.
* In order to convert build only 1 structural element use directly it factory
+ *
+ * structure
+ * - table[N,]
+ * -column
+ * -constraint
+ * -internal (unique, primary, check, nullable)
+ * -reference (referenceTable=, referenceColumn=, ...)
+ * -index
*/
class StructureBuilder
{
From aff05eea4d3ca5fb9ddb939fa1dd8dcbfbebd7b5 Mon Sep 17 00:00:00 2001
From: Sergii Kovalenko
Date: Mon, 18 Dec 2017 17:33:40 +0200
Subject: [PATCH 231/904] MAGETWO-83201: Creating Diff artifacts between
arbitrary Declarative Schemas
--remove casters
---
app/etc/di.xml | 70 ++++++----------
.../revisions/old_diff/db_schema.xml | 2 +-
.../Magento/Setup/DiffOldSchemaTest.php | 82 +------------------
.../Model/Declaration/Schema/Casters/Base.php | 48 -----------
.../Declaration/Schema/Casters/Biginteger.php | 53 ------------
.../Schema/Casters/CasterAggregator.php | 50 -----------
.../Schema/Casters/CasterInterface.php | 22 -----
.../Model/Declaration/Schema/Casters/Date.php | 39 ---------
.../Declaration/Schema/Casters/Foreign.php | 46 -----------
.../Declaration/Schema/Casters/Integer.php | 53 ------------
.../Declaration/Schema/Casters/Primary.php | 44 ----------
.../Schema/Casters/Smallinteger.php | 52 ------------
.../Schema/Casters/Tinyinteger.php | 52 ------------
.../Schema/ChangeRegistryInterface.php | 5 --
.../Schema/Db/StructureBuilder.php | 25 ++----
.../Schema/Declaration/StructureBuilder.php | 45 ++--------
.../Declaration/Schema/Diff/DiffManager.php | 43 +---------
.../Declaration/Schema/Diff/StructureDiff.php | 9 +-
.../Declaration/Schema/Diff/TableDiff.php | 10 +--
.../Model/Declaration/Schema/Dto/Column.php | 25 +++---
.../Declaration/Schema/Dto/Columns/Blob.php | 25 ++++--
.../Schema/Dto/Columns/Boolean.php | 39 +++++----
.../Declaration/Schema/Dto/Columns/Date.php | 12 +--
.../Schema/Dto/Columns/Decimal.php | 75 ++++++++++++-----
.../Schema/Dto/Columns/Integer.php | 72 +++++++++++-----
.../Declaration/Schema/Dto/Columns/Text.php | 25 ++++--
.../Schema/Dto/Columns/Timestamp.php | 45 ++++++----
.../Schema/Dto/Columns/Varbinary.php | 54 ++++++++----
.../Schema/Dto/Columns/Varchar.php | 54 ++++++++----
.../Declaration/Schema/Dto/Constraint.php | 28 +++----
.../Schema/Dto/Constraints/Internal.php | 26 ++++--
.../Schema/Dto/Constraints/Reference.php | 53 +++++++++---
.../Declaration/Schema/Dto/ElementFactory.php | 48 +++++++++--
.../Schema/Dto/ElementInterface.php | 8 --
.../Schema/Dto/ElementRenamedInterface.php | 21 -----
.../Schema/Dto/Factories/Biginteger.php | 62 ++++++++++++++
.../Declaration/Schema/Dto/Factories/Blob.php | 56 +++++++++++++
.../{Casters => Dto/Factories}/Boolean.php | 33 +++++---
.../Declaration/Schema/Dto/Factories/Date.php | 51 ++++++++++++
.../{Casters => Dto/Factories}/Decimal.php | 39 ++++++---
.../Schema/Dto/Factories/FactoryInterface.php | 23 ++++++
.../Schema/Dto/Factories/Foreign.php | 57 +++++++++++++
.../Schema/Dto/Factories/Index.php | 56 +++++++++++++
.../Schema/Dto/Factories/Integer.php | 62 ++++++++++++++
.../Schema/Dto/Factories/LongBlob.php | 56 +++++++++++++
.../Schema/Dto/Factories/LongText.php | 56 +++++++++++++
.../Schema/Dto/Factories/MediumBlob.php | 56 +++++++++++++
.../Schema/Dto/Factories/MediumText.php | 56 +++++++++++++
.../Schema/Dto/Factories/Primary.php | 52 ++++++++++++
.../Schema/Dto/Factories/Smallinteger.php | 61 ++++++++++++++
.../Schema/Dto/Factories/Table.php | 48 +++++++++++
.../Declaration/Schema/Dto/Factories/Text.php | 56 +++++++++++++
.../{Casters => Dto/Factories}/Timestamp.php | 33 +++++---
.../Schema/Dto/Factories/Tinyinteger.php | 61 ++++++++++++++
.../Schema/Dto/Factories/Unique.php | 48 +++++++++++
.../Schema/Dto/Factories/Varbinary.php | 56 +++++++++++++
.../Schema/Dto/Factories/Varchar.php | 56 +++++++++++++
.../Declaration/Schema/Dto/GenericElement.php | 34 +++-----
.../Model/Declaration/Schema/Dto/Index.php | 31 ++++---
.../Declaration/Schema/Dto/Structure.php | 21 -----
.../Model/Declaration/Schema/Dto/Table.php | 56 ++++++++-----
.../Declaration/Schema/Xml/Converter.php | 16 ----
62 files changed, 1608 insertions(+), 1044 deletions(-)
delete mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Casters/Base.php
delete mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Casters/Biginteger.php
delete mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Casters/CasterAggregator.php
delete mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Casters/CasterInterface.php
delete mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Casters/Date.php
delete mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Casters/Foreign.php
delete mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Casters/Integer.php
delete mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Casters/Primary.php
delete mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Casters/Smallinteger.php
delete mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Casters/Tinyinteger.php
delete mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Dto/ElementRenamedInterface.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Biginteger.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Blob.php
rename setup/src/Magento/Setup/Model/Declaration/Schema/{Casters => Dto/Factories}/Boolean.php (52%)
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Date.php
rename setup/src/Magento/Setup/Model/Declaration/Schema/{Casters => Dto/Factories}/Decimal.php (52%)
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/FactoryInterface.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Foreign.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Index.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Integer.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/LongBlob.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/LongText.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/MediumBlob.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/MediumText.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Primary.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Smallinteger.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Table.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Text.php
rename setup/src/Magento/Setup/Model/Declaration/Schema/{Casters => Dto/Factories}/Timestamp.php (67%)
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Tinyinteger.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Unique.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Varbinary.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Varchar.php
diff --git a/app/etc/di.xml b/app/etc/di.xml
index 1c188f8b82dab..f312ad0526333 100755
--- a/app/etc/di.xml
+++ b/app/etc/di.xml
@@ -1351,51 +1351,31 @@
-
- - \Magento\Setup\Model\Declaration\Schema\Dto\Table
- - \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Decimal
- - \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Decimal
- - \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Decimal
- - \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Integer
- - \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Integer
- - \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Integer
- - \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Integer
- - \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Date
- - \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Timestamp
- - \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Timestamp
- - \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Text
- - \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Text
- - \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Text
- - \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Varchar
- - \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Varbinary
- - \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Blob
- - \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Blob
- - \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Blob
- - \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Boolean
- - \Magento\Setup\Model\Declaration\Schema\Dto\Constraints\Internal
- - \Magento\Setup\Model\Declaration\Schema\Dto\Constraints\Internal
- - \Magento\Setup\Model\Declaration\Schema\Dto\Constraints\Reference
- - \Magento\Setup\Model\Declaration\Schema\Dto\Index
-
-
-
-
-
-
- - \Magento\Setup\Model\Declaration\Schema\Casters\Base
- - \Magento\Setup\Model\Declaration\Schema\Casters\Decimal
- - \Magento\Setup\Model\Declaration\Schema\Casters\Decimal
- - \Magento\Setup\Model\Declaration\Schema\Casters\Decimal
- - \Magento\Setup\Model\Declaration\Schema\Casters\Smallinteger
- - \Magento\Setup\Model\Declaration\Schema\Casters\Tinyinteger
- - \Magento\Setup\Model\Declaration\Schema\Casters\Biginteger
- - \Magento\Setup\Model\Declaration\Schema\Casters\Integer
- - \Magento\Setup\Model\Declaration\Schema\Casters\Timestamp
- - \Magento\Setup\Model\Declaration\Schema\Casters\Timestamp
- - \Magento\Setup\Model\Declaration\Schema\Casters\Boolean
- - \Magento\Setup\Model\Declaration\Schema\Casters\Foreign
- - \Magento\Setup\Model\Declaration\Schema\Casters\Primary
- - \Magento\Setup\Model\Declaration\Schema\Casters\Date
+
+ - \Magento\Setup\Model\Declaration\Schema\Dto\Factories\Table
+ - \Magento\Setup\Model\Declaration\Schema\Dto\Factories\Decimal
+ - \Magento\Setup\Model\Declaration\Schema\Dto\Factories\Decimal
+ - \Magento\Setup\Model\Declaration\Schema\Dto\Factories\Decimal
+ - \Magento\Setup\Model\Declaration\Schema\Dto\Factories\SmallInteger
+ - \Magento\Setup\Model\Declaration\Schema\Dto\Factories\TinyInteger
+ - \Magento\Setup\Model\Declaration\Schema\Dto\Factories\BigInteger
+ - \Magento\Setup\Model\Declaration\Schema\Dto\Factories\Integer
+ - \Magento\Setup\Model\Declaration\Schema\Dto\Factories\Date
+ - \Magento\Setup\Model\Declaration\Schema\Dto\Factories\Timestamp
+ - \Magento\Setup\Model\Declaration\Schema\Dto\Factories\Timestamp
+ - \Magento\Setup\Model\Declaration\Schema\Dto\Factories\LongText
+ - \Magento\Setup\Model\Declaration\Schema\Dto\Factories\MediumText
+ - \Magento\Setup\Model\Declaration\Schema\Dto\Factories\Text
+ - \Magento\Setup\Model\Declaration\Schema\Dto\Factories\Varchar
+ - \Magento\Setup\Model\Declaration\Schema\Dto\Factories\Varbinary
+ - \Magento\Setup\Model\Declaration\Schema\Dto\Factories\Blob
+ - \Magento\Setup\Model\Declaration\Schema\Dto\Factories\MediumBlob
+ - \Magento\Setup\Model\Declaration\Schema\Dto\Factories\LongBlob
+ - \Magento\Setup\Model\Declaration\Schema\Dto\Factories\Boolean
+ - \Magento\Setup\Model\Declaration\Schema\Dto\Factories\Unique
+ - \Magento\Setup\Model\Declaration\Schema\Dto\Factories\Primary
+ - \Magento\Setup\Model\Declaration\Schema\Dto\Factories\Foreign
+ - \Magento\Setup\Model\Declaration\Schema\Dto\Factories\Index
diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/old_diff/db_schema.xml b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/old_diff/db_schema.xml
index 9289d3dcdc223..2d8aa0681d401 100644
--- a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/old_diff/db_schema.xml
+++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/old_diff/db_schema.xml
@@ -7,7 +7,7 @@
-->
-
+
diff --git a/dev/tests/setup-integration/testsuite/Magento/Setup/DiffOldSchemaTest.php b/dev/tests/setup-integration/testsuite/Magento/Setup/DiffOldSchemaTest.php
index c73638382c56b..5d435462868ef 100644
--- a/dev/tests/setup-integration/testsuite/Magento/Setup/DiffOldSchemaTest.php
+++ b/dev/tests/setup-integration/testsuite/Magento/Setup/DiffOldSchemaTest.php
@@ -96,31 +96,9 @@ public function testOldDiff()
$declarativeStructure = $this->declarativeParser->parse($declarativeStructure);
$generatedStructure = $this->generatedParser->parse($generatedStructure);
$this->structureDiff->diff($declarativeStructure, $generatedStructure, $changeRegistry);
- //Rename operations
- $renameOperations = $changeRegistry->get(ChangeRegistryInterface::RENAME_OPERAION);
- self::assertCount(1, $renameOperations);
- self::assertArrayHasKey('smallinteger', $renameOperations);
- self::assertCount(1, $renameOperations['smallinteger']);
- self::assertEquals('smallint_ref2', $renameOperations['smallinteger'][0]['new']->getName());
//Change operations
$changeOperations = $changeRegistry->get(ChangeRegistryInterface::CHANGE_OPERATION);
- self::assertCount(3, $changeOperations);
- self::assertEquals(
- $this->getPrimaryKeyDbSensitiveData(),
- $changeOperations['primary'][0]['old']->getDiffSensitiveParams()
- );
- self::assertEquals(
- $this->getPrimaryKeyXmlSensitiveData(),
- $changeOperations['primary'][0]['new']->getDiffSensitiveParams()
- );
- self::assertEquals(
- $this->getForeignKeyXmlSensitiveData(),
- $changeOperations['foreign'][0]['new']->getDiffSensitiveParams()
- );
- self::assertEquals(
- $this->getForeignKeyDbSensitiveData(),
- $changeOperations['foreign'][0]['old']->getDiffSensitiveParams()
- );
+ self::assertCount(1, $changeOperations);
self::assertEquals(
$this->getBigIntKeyXmlSensitiveData(),
$changeOperations['biginteger'][0]['new']->getDiffSensitiveParams()
@@ -135,64 +113,6 @@ public function testOldDiff()
);
}
- /**
- * @return array
- */
- private function getForeignKeyXmlSensitiveData()
- {
- return [
- 'type' => 'foreign',
- 'column' => 'smallint',
- 'referenceColumn' => 'smallint_ref2',
- 'referenceTableName' => 'reference_table',
- 'tableName' => 'test_table',
- 'onDelete' => 'CASCADE',
- ];
- }
-
- /**
- * @return array
- */
- private function getForeignKeyDbSensitiveData()
- {
- return [
- 'type' => 'foreign',
- 'column' => 'smallint',
- 'referenceColumn' => 'smallint_ref',
- 'referenceTableName' => 'reference_table',
- 'tableName' => 'test_table',
- 'onDelete' => 'CASCADE',
- ];
- }
-
- /**
- * @return array
- */
- private function getPrimaryKeyXmlSensitiveData()
- {
- return [
- 'type' => 'primary',
- 'columns' =>
- [
- 0 => 'smallint_ref2',
- ],
- ];
- }
-
- /**
- * @return array
- */
- private function getPrimaryKeyDbSensitiveData()
- {
- return [
- 'type' => 'primary',
- 'columns' =>
- [
- 0 => 'smallint_ref',
- ],
- ];
- }
-
/**
* @return array
*/
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Casters/Base.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Casters/Base.php
deleted file mode 100644
index 56d494da713eb..0000000000000
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Casters/Base.php
+++ /dev/null
@@ -1,48 +0,0 @@
-booleanUtils = $booleanUtils;
- }
-
- /**
- * {@inheritdoc}
- * @return array
- */
- public function cast(array $data)
- {
- $data['nullable'] = isset($data['nullable']) ? $this->booleanUtils->toBoolean($data['nullable']) : true;
- $data['unsigned'] = isset($data['unsigned']) ? $this->booleanUtils->toBoolean($data['unsigned']) : false;
- $data['disabled'] = isset($data['disabled']) ? $this->booleanUtils->toBoolean($data['disabled']) : false;
-
- if (isset($data['identity'])) {
- $data['identity'] = $this->booleanUtils->toBoolean($data['identity']);
- }
-
- unset($data['extra']);//we need to ignore extra field that comes from db
-
- return $data;
- }
-}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Casters/Biginteger.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Casters/Biginteger.php
deleted file mode 100644
index 214d6fff1f69d..0000000000000
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Casters/Biginteger.php
+++ /dev/null
@@ -1,53 +0,0 @@
-base = $base;
- }
-
- /**
- * Set default padding, like BIGINT(20)
- *
- * {@inheritdoc}
- * @return array
- */
- public function cast(array $data)
- {
- $data = $this->base->cast($data);
-
- if (!isset($data['padding'])) {
- $data['padding'] = self::DEFAULT_PADDING;
- }
-
- if (isset($data['default'])) {
- $data['default'] = (int)$data['default'];
- }
-
- return $data;
- }
-}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Casters/CasterAggregator.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Casters/CasterAggregator.php
deleted file mode 100644
index 5014d2de6d409..0000000000000
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Casters/CasterAggregator.php
+++ /dev/null
@@ -1,50 +0,0 @@
-casters = $casters;
- }
-
- /**
- * Find appropriate caster by type (for example: integer or decimal)
- * and try to cast it
- *
- * @inheritdoc
- */
- public function cast(array $data)
- {
- $type = $data['type'];
-
- if (!isset($this->casters[$type])) {
- //We can`t through any exception, as from db schema we can faced with unknown types
- $caster = $this->casters[self::DEFAULT_CASTER];
- } else {
- $caster = $this->casters[$type];
- }
-
- return $caster->cast($data);
- }
-}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Casters/CasterInterface.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Casters/CasterInterface.php
deleted file mode 100644
index afba9440b1133..0000000000000
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Casters/CasterInterface.php
+++ /dev/null
@@ -1,22 +0,0 @@
-base = $base;
- }
-
- /**
- * Set shape to floating point, that is by default (10,0)
- *
- * {@inheritdoc}
- * @return array
- */
- public function cast(array $data)
- {
- unset($data['nullable']);
- unset($data['default']);
- return $data;
- }
-}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Casters/Foreign.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Casters/Foreign.php
deleted file mode 100644
index cffaa1dac1ca2..0000000000000
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Casters/Foreign.php
+++ /dev/null
@@ -1,46 +0,0 @@
-base = $base;
- }
-
- /**
- * Set default padding, like INTEGER(11)
- *
- * {@inheritdoc}
- * @return array
- */
- public function cast(array $data)
- {
- $data = $this->base->cast($data);
-
- if (!isset($data['onDelete'])) {
- $data['onDelete'] = self::DEFAULT_ON_DELETE;
- }
-
- return $data;
- }
-}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Casters/Integer.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Casters/Integer.php
deleted file mode 100644
index 21f41ed162352..0000000000000
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Casters/Integer.php
+++ /dev/null
@@ -1,53 +0,0 @@
-base = $base;
- }
-
- /**
- * Set default padding, like INTEGER(11)
- *
- * {@inheritdoc}
- * @return array
- */
- public function cast(array $data)
- {
- $data = $this->base->cast($data);
-
- if (!isset($data['padding'])) {
- $data['padding'] = self::DEFAULT_PADDING;
- }
-
- if (isset($data['default'])) {
- $data['default'] = (int) $data['default'];
- }
-
- return $data;
- }
-}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Casters/Primary.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Casters/Primary.php
deleted file mode 100644
index bb1c8a1a443f1..0000000000000
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Casters/Primary.php
+++ /dev/null
@@ -1,44 +0,0 @@
-base = $base;
- }
-
- /**
- * Set default padding, like INTEGER(11)
- *
- * {@inheritdoc}
- * @return array
- */
- public function cast(array $data)
- {
- $data = $this->base->cast($data);
- $data['name'] = Internal::PRIMARY_NAME;
-
- return $data;
- }
-}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Casters/Smallinteger.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Casters/Smallinteger.php
deleted file mode 100644
index 6f1738f8f46eb..0000000000000
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Casters/Smallinteger.php
+++ /dev/null
@@ -1,52 +0,0 @@
-base = $base;
- }
-
- /**
- * Set default padding, like SMALLINT(5)
- *
- * {@inheritdoc}
- * @return array
- */
- public function cast(array $data)
- {
- $data = $this->base->cast($data);
-
- if (!isset($data['padding'])) {
- $data['padding'] = self::DEFAULT_PADDING;
- }
-
- if (isset($data['default'])) {
- $data['default'] = (int) $data['default'];
- }
-
- return $data;
- }
-}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Casters/Tinyinteger.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Casters/Tinyinteger.php
deleted file mode 100644
index c3fc8d4198e27..0000000000000
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Casters/Tinyinteger.php
+++ /dev/null
@@ -1,52 +0,0 @@
-base = $base;
- }
-
- /**
- * Set default padding, like TINYINT(1)
- *
- * {@inheritdoc}
- * @return array
- */
- public function cast(array $data)
- {
- $data = $this->base->cast($data);
-
- if (!isset($data['padding'])) {
- $data['padding'] = self::DEFAULT_PADDING;
- }
-
- if (isset($data['default'])) {
- $data['default'] = (int) $data['default'];
- }
-
- return $data;
- }
-}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/ChangeRegistryInterface.php b/setup/src/Magento/Setup/Model/Declaration/Schema/ChangeRegistryInterface.php
index cf4e2d1c43010..f386a4fd9cd34 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/ChangeRegistryInterface.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/ChangeRegistryInterface.php
@@ -30,11 +30,6 @@ interface ChangeRegistryInterface
*/
const REMOVE_OPERATION = "remove";
- /**
- * For elements that needs to be renamed
- */
- const RENAME_OPERAION = "rename";
-
/**
* Retrieve operations by type
*
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/StructureBuilder.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/StructureBuilder.php
index 0417f4cb517f7..ea6387408fcc7 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/StructureBuilder.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/StructureBuilder.php
@@ -37,11 +37,6 @@ class StructureBuilder
*/
private $elementFactory;
- /**
- * @var CasterAggregator
- */
- private $casterAggregator;
-
/**
* @var DbSchemaReaderInterface
*/
@@ -58,18 +53,15 @@ class StructureBuilder
* @param ElementFactory $elementFactory
* @param DbSchemaReaderInterface $dbSchemaReader
* @param Sharding $sharding
- * @param CasterAggregator $casterAggregator
*/
public function __construct(
AdapterMediator $adapter,
ElementFactory $elementFactory,
DbSchemaReaderInterface $dbSchemaReader,
- Sharding $sharding,
- CasterAggregator $casterAggregator
+ Sharding $sharding
) {
$this->adapter = $adapter;
$this->elementFactory = $elementFactory;
- $this->casterAggregator = $casterAggregator;
$this->dbSchemaReader = $dbSchemaReader;
$this->sharding = $sharding;
}
@@ -92,12 +84,12 @@ public function build(Structure $structure)
/** @var Table $table */
$table = $this->elementFactory->create('table', [
- 'name' => $tableName
+ 'name' => $tableName,
+ 'resource' => $this->sharding->getDefaultResource()
]);
// Process columns
foreach ($columnsData as $columnData) {
- $columnData = $this->casterAggregator->cast($columnData);
$columnData['table'] = $table;
$column = $this->elementFactory->create($columnData['type'], $columnData);
$columns[$column->getName()] = $column;
@@ -106,16 +98,14 @@ public function build(Structure $structure)
$table->addColumns($columns);
//Process indexes
foreach ($indexesData as $indexData) {
- $indexData = $this->casterAggregator->cast($indexData);
- $indexData['column'] = $this->resolveInternalRelations($columns, $indexData);
+ $indexData['columns'] = $this->resolveInternalRelations($columns, $indexData);
$indexData['table'] = $table;
$index = $this->elementFactory->create('index', $indexData);
$indexes[$index->getName()] = $index;
}
//Process internal constraints
foreach ($constrainsData as $constraintData) {
- $constraintData = $this->casterAggregator->cast($constraintData);
- $constraintData['column'] = $this->resolveInternalRelations($columns, $constraintData);
+ $constraintData['columns'] = $this->resolveInternalRelations($columns, $constraintData);
$constraintData['table'] = $table;
$constraint = $this->elementFactory->create($constraintData['type'], $constraintData);
$constraints[$constraint->getName()] = $constraint;
@@ -147,11 +137,10 @@ private function processReferenceKeys(array $tables)
foreach ($referencesData as $referenceData) {
//Prepare reference data
- $referenceData = $this->casterAggregator->cast($referenceData);
$referenceData['table'] = $tables[$tableName];
- $referenceData['column'] = $tables[$tableName]->getColumnByNameOrId($referenceData['column']);
+ $referenceData['column'] = $tables[$tableName]->getColumnByName($referenceData['column']);
$referenceData['referenceTable'] = $tables[$referenceData['referenceTable']];
- $referenceData['referenceColumn'] = $referenceData['referenceTable']->getColumnByNameOrId(
+ $referenceData['referenceColumn'] = $referenceData['referenceTable']->getColumnByName(
$referenceData['referenceColumn']
);
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/StructureBuilder.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/StructureBuilder.php
index f765da3a0497c..6e0d50f179454 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/StructureBuilder.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/StructureBuilder.php
@@ -10,7 +10,6 @@
use Magento\Setup\Model\Declaration\Schema\Dto\ElementFactory;
use Magento\Setup\Model\Declaration\Schema\Dto\Index;
use Magento\Setup\Model\Declaration\Schema\Dto\Structure;
-use Magento\Setup\Model\Declaration\Schema\Dto\StructureFactory;
use Magento\Setup\Model\Declaration\Schema\Dto\Table;
use Magento\Setup\Model\Declaration\Schema\Sharding;
@@ -93,29 +92,6 @@ public function build(Structure $structure)
return $structure;
}
- /**
- * If some element was renamed, we need to retrieve new name instead of old one
- *
- * @param array $elementData
- * @return string
- */
- private function resolveElementName(array $elementData)
- {
- return isset($elementData['renameTo']) ? $elementData['renameTo'] : $elementData['name'];
- }
-
- /**
- * If element was renamed or should be renamed we need to retrieve its old name
- * In order to do rename in future or in order to do compare
- *
- * @param array $elementData
- * @return string
- */
- private function wasRenamedFrom(array $elementData)
- {
- return isset($elementData['renameTo']) ? $elementData['name'] : null;
- }
-
/**
* @param array $tableData
* @return string
@@ -174,8 +150,6 @@ private function processColumns(array $tableData, $resource, Table $table)
*/
private function processGenericData(array $elementData, $resource, Table $table)
{
- $elementData['wasRenamedFrom'] = $this->wasRenamedFrom($elementData);
- $elementData['name'] = $this->resolveElementName($elementData);
$elementData['table'] = $table;
$elementData['resource'] = $resource;
@@ -192,12 +166,11 @@ private function processGenericData(array $elementData, $resource, Table $table)
*/
private function processTable(Structure $structure, array $tableData)
{
- if (!$structure->getTableByNameOrId($tableData['name'])) {
+ if (!$structure->getTableByName($tableData['name'])) {
$resource = $this->getStructuralElementResource($tableData);
$tableParams = [
- 'name' => $this->resolveElementName($tableData),
+ 'name' => $tableData['name'],
'resource' => $resource,
- 'wasRenamedFrom' => $this->wasRenamedFrom($tableData)
];
/** @var Table $table */
$table = $this->elementFactory->create('table', $tableParams);
@@ -210,7 +183,7 @@ private function processTable(Structure $structure, array $tableData)
$table->addConstraints($this->processConstraints($tableData, $resource, $structure));
}
- return $structure->getTableByNameOrId($tableData['name']);
+ return $structure->getTableByName($tableData['name']);
}
/**
@@ -225,7 +198,7 @@ private function convertColumnNamesToObjects(array $columnNames, Table $table)
$columns = [];
foreach ($columnNames as $columnName) {
- $columns[] = $table->getColumnByNameOrId($columnName);
+ $columns[] = $table->getColumnByName($columnName);
}
return $columns;
@@ -253,7 +226,7 @@ private function processIndexes(array $tableData, $resource, Table $table)
}
$indexData = $this->processGenericData($indexData, $resource, $table);
- $indexData['column'] = $this->convertColumnNamesToObjects($indexData['column'], $table);
+ $indexData['columns'] = $this->convertColumnNamesToObjects($indexData['column'], $table);
$index = $this->elementFactory->create('index', $indexData);
$indexes[$index->getName()] = $index;
}
@@ -285,7 +258,7 @@ private function processConstraints(array $tableData, $resource, Structure $stru
$constraintData = $this->processGenericData($constraintData, $resource, $table);
//As foreign constraint has different structure we need to process it in different way
if ($constraintData['type'] === 'foreign') {
- $constraintData['column'] = $table->getColumnByNameOrId(
+ $constraintData['column'] = $table->getColumnByName(
$constraintData['column']
);
//always in foreign key name will be old and in raw data will be always old too
@@ -295,7 +268,7 @@ private function processConstraints(array $tableData, $resource, Structure $stru
$this->tablesData[$constraintData['referenceTable']]
)
);
- $constraintData['referenceTable'] = $structure->getTableByNameOrId(
+ $constraintData['referenceTable'] = $structure->getTableByName(
$constraintData['referenceTable']
);
@@ -303,11 +276,11 @@ private function processConstraints(array $tableData, $resource, Structure $stru
throw new \LogicException("Cannot find reference table");
}
- $constraintData['referenceColumn'] = $constraintData['referenceTable']->getColumnByNameOrId(
+ $constraintData['referenceColumn'] = $constraintData['referenceTable']->getColumnByName(
$constraintData['referenceColumn']
);
} else {
- $constraintData['column'] = $this->convertColumnNamesToObjects($constraintData['column'], $table);
+ $constraintData['columns'] = $this->convertColumnNamesToObjects($constraintData['column'], $table);
}
$constraint = $this->elementFactory->create($constraintData['type'], $constraintData);
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/DiffManager.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/DiffManager.php
index 4dad2dfcb5c99..a726d2058f4be 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/DiffManager.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/DiffManager.php
@@ -30,29 +30,15 @@ public function __construct(Comparator $comparator)
$this->comparator = $comparator;
}
- /**
- * Check whether new name is not corresponds with olds one
- *
- * @param ElementRenamedInterface | ElementInterface $element
- * @return mixed
- */
- public function shouldBeRenamed(ElementInterface $element)
- {
- return $element->getName() !== $element->wasRenamedFrom() && $element->wasRenamedFrom() !== null;
- }
-
/**
* Check whether this is element is new or not, by checking it in db structure
*
* @param ElementInterface[] $generatedElements
- * @param ElementInterface | ElementRenamedInterface $element
* @return bool
*/
- public function shouldBeCreatedOrRenamed(array $generatedElements, ElementInterface $element)
+ public function shouldBeCreated(array $generatedElements, ElementInterface $element)
{
- return
- !isset($generatedElements[$element->getName()]) ||
- $this->shouldBeRenamed($element) && !isset($generatedElements[$element->wasRenamedFrom()]);
+ return !isset($generatedElements[$element->getName()]);
}
/**
@@ -118,31 +104,6 @@ public function registerRemoval(
}
}
- /**
- * After registration rename, we need to remove renamed element from generated structure
- * in order to prevent double registration of this object
- *
- * @param ChangeRegistryInterface $changeRegistry
- * @param ElementInterface | ElementRenamedInterface $element
- * @param array $generatedElements
- * @return array
- */
- public function registerRename(
- ChangeRegistryInterface $changeRegistry,
- ElementInterface $element,
- array $generatedElements
- ) {
- $changeRegistry->register(
- $element,
- $element->getElementType(),
- ChangeRegistryInterface::RENAME_OPERAION,
- $generatedElements[$element->wasRenamedFrom()]
- );
-
- unset($generatedElements[$element->wasRenamedFrom()]);
- return $generatedElements;
- }
-
/**
* @param ChangeRegistryInterface $changeRegistry
* @param ElementInterface $element
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/StructureDiff.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/StructureDiff.php
index e1108c91791fb..87ceb9d293596 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/StructureDiff.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/StructureDiff.php
@@ -16,7 +16,6 @@
* If table exists only in XML -> then we need to create table
* If table exists in both version -> then we need to go deeper and inspect each element
* If table exists only in db -> then we need to remove this table
- * If table wasRenamedFrom attribute is differ with name -> then we need to rename table
*/
class StructureDiff
{
@@ -55,12 +54,8 @@ public function diff(
$generatedTables = $generatedStructure->getTables();
foreach ($structure->getTables() as $name => $table) {
- if ($this->diffManager->shouldBeCreatedOrRenamed($generatedTables, $table)) {
- if ($this->diffManager->shouldBeRenamed($table)) {
- $generatedTables = $this->diffManager->registerRename($changeRegistry, $table, $generatedTables);
- } else {
- $this->diffManager->registerCreation($changeRegistry, $table);
- }
+ if ($this->diffManager->shouldBeCreated($generatedTables, $table)) {
+ $this->diffManager->registerCreation($changeRegistry, $table);
} else {
$this->tableDiff->diff($table, $generatedTables[$name], $changeRegistry);
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/TableDiff.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/TableDiff.php
index 38310937468fc..2abbfb4a9fd96 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/TableDiff.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/TableDiff.php
@@ -18,7 +18,6 @@
* If element exists only in XML -> then we need to create element
* If element exists in both version and are different -> then we need to modify element
* If element exists only in db -> then we need to remove this element
- * If element wasRenamedFrom attribute is differ with name -> then we need to rename element
*/
class TableDiff implements DiffInterface
{
@@ -69,13 +68,8 @@ public function diff(
foreach ($declaredElements as $element) {
//If it is new for generated (generated from db) elements - we need to create it
- if ($this->diffManager->shouldBeCreatedOrRenamed($generatedElements, $element)) {
- if ($this->diffManager->shouldBeRenamed($element)) {
- $generatedElements = $this->diffManager
- ->registerRename($changeRegistry, $element, $generatedElements);
- } else {
- $this->diffManager->registerCreation($changeRegistry, $element);
- }
+ if ($this->diffManager->shouldBeCreated($generatedElements, $element)) {
+ $this->diffManager->registerCreation($changeRegistry, $element);
} else if ($this->diffManager->shouldBeModified(
$element,
$generatedElements[$element->getName()]
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Column.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Column.php
index 7d25e578e3c7a..a339b6d7f1540 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Column.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Column.php
@@ -14,23 +14,22 @@ class Column extends GenericElement implements
TableElementInterface
{
/**
- * @inheritdoc
+ * @var Table
*/
- protected $elementType = 'column';
+ private $table;
/**
- * @inheritdoc
- */
- protected $structuralElementData;
-
- /**
- * @param array $structuralElementData
+ * @param string $name
* @param string $elementType
+ * @param Table $table
*/
- public function __construct(array $structuralElementData, $elementType)
- {
- $this->structuralElementData = $structuralElementData;
- $this->elementType = $elementType;
+ public function __construct(
+ string $name,
+ string $elementType,
+ Table $table
+ ) {
+ parent::__construct($name, $elementType);
+ $this->table = $table;
}
/**
@@ -40,6 +39,6 @@ public function __construct(array $structuralElementData, $elementType)
*/
public function getTable()
{
- return $this->structuralElementData['table'];
+ return $this->table;
}
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Blob.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Blob.php
index b42618a3c2f5e..929cfeea74105 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Blob.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Blob.php
@@ -7,6 +7,7 @@
use Magento\Setup\Model\Declaration\Schema\Dto\Column;
use Magento\Setup\Model\Declaration\Schema\Dto\ElementDiffAwareInterface;
+use Magento\Setup\Model\Declaration\Schema\Dto\Table;
/**
* This column represent binary type
@@ -16,15 +17,25 @@
class Blob extends Column implements ElementDiffAwareInterface
{
/**
- * By default element type is blob, but it can various: blob, mediumblob, longblob
- * @inheritdoc
+ * @var bool
*/
- protected $elementType = 'blob';
+ private $nullable;
/**
- * @inheritdoc
+ * @param string $name
+ * @param string $elementType
+ * @param Table $table
+ * @param $nullable
*/
- protected $structuralElementData;
+ public function __construct(
+ string $name,
+ string $elementType,
+ Table $table,
+ bool $nullable = true
+ ) {
+ parent::__construct($name, $elementType, $table);
+ $this->nullable = $nullable;
+ }
/**
* Check whether column can be nullable
@@ -33,7 +44,7 @@ class Blob extends Column implements ElementDiffAwareInterface
*/
public function isNullable()
{
- return isset($this->structuralElementData['nullable']) && $this->structuralElementData['nullable'];
+ return $this->nullable;
}
/**
@@ -42,7 +53,7 @@ public function isNullable()
public function getDiffSensitiveParams()
{
return [
- 'type' => $this->elementType,
+ 'type' => $this->getElementType(),
'nullable' => $this->isNullable()
];
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Boolean.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Boolean.php
index 502ac8e085936..96ec7b1a180f2 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Boolean.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Boolean.php
@@ -7,6 +7,7 @@
use Magento\Setup\Model\Declaration\Schema\Dto\Column;
use Magento\Setup\Model\Declaration\Schema\Dto\ElementDiffAwareInterface;
+use Magento\Setup\Model\Declaration\Schema\Dto\Table;
/**
* Boolean column
@@ -15,33 +16,42 @@
class Boolean extends Column implements ElementDiffAwareInterface
{
/**
- * @inheritdoc
+ * @var bool
*/
- protected $elementType = 'boolean';
+ private $nullable;
/**
- * @inheritdoc
+ * @var bool
*/
- protected $structuralElementData;
+ private $default;
/**
- * Check whether column can be nullable
- *
- * @return bool
+ * @param string $name
+ * @param string $elementType
+ * @param Table $table
+ * @param $nullable
+ * @param $default
*/
- public function isNullable()
- {
- return isset($this->structuralElementData['nullable']) && $this->structuralElementData['nullable'];
+ public function __construct(
+ string $name,
+ string $elementType,
+ Table $table,
+ bool $nullable = true,
+ bool $default = false
+ ) {
+ parent::__construct($name, $elementType, $table);
+ $this->nullable = $nullable;
+ $this->default = $default;
}
/**
- * Check whether column has default value
+ * Check whether column can be nullable
*
* @return bool
*/
- public function hasDefault()
+ public function isNullable()
{
- return isset($this->structuralElementData['default']);
+ return $this->nullable;
}
/**
@@ -52,7 +62,7 @@ public function hasDefault()
*/
public function getDefault()
{
- return $this->hasDefault() ? $this->structuralElementData['default'] : null;
+ return $this->default;
}
/**
@@ -61,7 +71,6 @@ public function getDefault()
public function getDiffSensitiveParams()
{
return [
- 'type' => $this->elementType,
'nullable' => $this->isNullable(),
'default' => $this->getDefault()
];
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Date.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Date.php
index 2e9b5d4e68069..dea4a01448318 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Date.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Date.php
@@ -16,23 +16,13 @@
*/
class Date extends Column implements ElementDiffAwareInterface
{
- /**
- * @inheritdoc
- */
- protected $elementType = 'date';
-
- /**
- * @inheritdoc
- */
- protected $structuralElementData;
-
/**
* @inheritdoc
*/
public function getDiffSensitiveParams()
{
return [
- 'type' => $this->elementType
+ 'type' => $this->getElementType()
];
}
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Decimal.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Decimal.php
index 935124f45a20f..2f880a0c7824a 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Decimal.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Decimal.php
@@ -7,6 +7,7 @@
use Magento\Setup\Model\Declaration\Schema\Dto\Column;
use Magento\Setup\Model\Declaration\Schema\Dto\ElementDiffAwareInterface;
+use Magento\Setup\Model\Declaration\Schema\Dto\Table;
/**
* Decimal column
@@ -16,15 +17,57 @@
class Decimal extends Column implements ElementDiffAwareInterface
{
/**
- * By default element type is decimal, but it can various: decimal, float, double
- * @inheritdoc
+ * @var int
*/
- protected $elementType = 'decimal';
+ private $precission;
/**
- * @inheritdoc
+ * @var int
+ */
+ private $scale;
+
+ /**
+ * @var bool
+ */
+ private $nullable;
+
+ /**
+ * @var float
+ */
+ private $default;
+
+ /**
+ * @var bool
*/
- protected $structuralElementData;
+ private $unsigned;
+
+ /**
+ * @param string $name
+ * @param string $elementType
+ * @param Table $table
+ * @param int $precission
+ * @param int $scale
+ * @param bool $nullable
+ * @param float $default
+ * @param bool $unsigned
+ */
+ public function __construct(
+ string $name,
+ string $elementType,
+ Table $table,
+ int $precission,
+ int $scale,
+ bool $nullable = true,
+ bool $unsigned = false,
+ float $default = null
+ ) {
+ parent::__construct($name, $elementType, $table);
+ $this->precission = $precission;
+ $this->scale = $scale;
+ $this->nullable = $nullable;
+ $this->default = $default;
+ $this->unsigned = $unsigned;
+ }
/**
* Column precission
@@ -33,7 +76,7 @@ class Decimal extends Column implements ElementDiffAwareInterface
*/
public function getPrecission()
{
- return $this->structuralElementData['precission'];
+ return $this->precission;
}
/**
@@ -43,7 +86,7 @@ public function getPrecission()
*/
public function getScale()
{
- return $this->structuralElementData['scale'];
+ return $this->scale;
}
/**
@@ -53,17 +96,7 @@ public function getScale()
*/
public function isNullable()
{
- return isset($this->structuralElementData['nullable']) && $this->structuralElementData['nullable'];
- }
-
- /**
- * Check whether column has default value
- *
- * @return bool
- */
- public function hasDefault()
- {
- return isset($this->structuralElementData['default']);
+ return $this->nullable;
}
/**
@@ -74,7 +107,7 @@ public function hasDefault()
*/
public function getDefault()
{
- return $this->hasDefault() ? $this->structuralElementData['default'] : null;
+ return $this->default;
}
/**
@@ -84,7 +117,7 @@ public function getDefault()
*/
public function isUnsigned()
{
- return isset($this->structuralElementData['unsigned']) && $this->structuralElementData['unsigned'];
+ return $this->unsigned;
}
/**
@@ -93,7 +126,7 @@ public function isUnsigned()
public function getDiffSensitiveParams()
{
return [
- 'type' => $this->elementType,
+ 'type' => $this->getElementType(),
'nullable' => $this->isNullable(),
'precission' => $this->getPrecission(),
'scale' => $this->getScale(),
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Integer.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Integer.php
index dc0ebc5d5e44e..015a4ebcce9e9 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Integer.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Integer.php
@@ -7,6 +7,7 @@
use Magento\Setup\Model\Declaration\Schema\Dto\Column;
use Magento\Setup\Model\Declaration\Schema\Dto\ElementDiffAwareInterface;
+use Magento\Setup\Model\Declaration\Schema\Dto\Table;
/**
* Integer column
@@ -16,15 +17,55 @@
class Integer extends Column implements ElementDiffAwareInterface
{
/**
- * By default element type is integer, but it can various: integer, smallinteger, biginteger, tinyinteger
- * @inheritdoc
+ * @var bool
*/
- protected $elementType = 'integer';
+ private $nullable;
/**
- * @inheritdoc
+ * @var int
+ */
+ private $default;
+
+ /**
+ * @var bool
*/
- protected $structuralElementData;
+ private $unsigned;
+ /**
+ * @var int
+ */
+ private $padding;
+ /**
+ * @var bool
+ */
+ private $identity;
+
+ /**
+ * @param string $name
+ * @param string $elementType
+ * @param Table $table
+ * @param int $padding
+ * @param bool $nullable
+ * @param bool $unsigned
+ * @param bool $identity
+ * @param float|int $default
+ */
+ public function __construct(
+ string $name,
+ string $elementType,
+ Table $table,
+ int $padding,
+ bool $nullable = true,
+ bool $unsigned = false,
+ bool $identity = false,
+ int $default = null
+ ) {
+ parent::__construct($name, $elementType, $table);
+ $this->nullable = $nullable;
+ $this->default = $default;
+ $this->unsigned = $unsigned;
+ $this->padding = $padding;
+ $this->identity = $identity;
+ }
/**
* Column padding
@@ -33,7 +74,7 @@ class Integer extends Column implements ElementDiffAwareInterface
*/
public function getPadding()
{
- return $this->structuralElementData['padding'];
+ return $this->padding;
}
/**
@@ -43,18 +84,9 @@ public function getPadding()
*/
public function isNullable()
{
- return isset($this->structuralElementData['nullable']) && $this->structuralElementData['nullable'];
+ return $this->nullable;
}
- /**
- * Check whether column has default value
- *
- * @return bool
- */
- public function hasDefault()
- {
- return isset($this->structuralElementData['default']);
- }
/**
* Return default value
@@ -64,7 +96,7 @@ public function hasDefault()
*/
public function getDefault()
{
- return $this->hasDefault() ? $this->structuralElementData['default'] : null;
+ return $this->default;
}
/**
@@ -74,7 +106,7 @@ public function getDefault()
*/
public function isUnsigned()
{
- return isset($this->structuralElementData['unsigned']) && $this->structuralElementData['unsigned'];
+ return $this->unsigned;
}
/**
@@ -84,7 +116,7 @@ public function isUnsigned()
*/
public function isIdentity()
{
- return isset($this->structuralElementData['identity']) && $this->structuralElementData['identity'];
+ return $this->identity;
}
/**
@@ -93,7 +125,7 @@ public function isIdentity()
public function getDiffSensitiveParams()
{
return [
- 'type' => $this->elementType,
+ 'type' => $this->getElementType(),
'nullable' => $this->isNullable(),
'padding' => $this->getPadding(),
'unsigned' => $this->isUnsigned(),
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Text.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Text.php
index 5d3907fc24eac..c4420c4dc7621 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Text.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Text.php
@@ -7,6 +7,7 @@
use Magento\Setup\Model\Declaration\Schema\Dto\Column;
use Magento\Setup\Model\Declaration\Schema\Dto\ElementDiffAwareInterface;
+use Magento\Setup\Model\Declaration\Schema\Dto\Table;
/**
* Text column
@@ -15,15 +16,25 @@
class Text extends Column implements ElementDiffAwareInterface
{
/**
- * By default element type is text, but it can various: text, mediumtext, longtext
- * @inheritdoc
+ * @var bool
*/
- protected $elementType = 'text';
+ private $nullable;
/**
- * @inheritdoc
+ * @param string $name
+ * @param string $elementType
+ * @param Table $table
+ * @param $nullable
*/
- protected $structuralElementData;
+ public function __construct(
+ string $name,
+ string $elementType,
+ Table $table,
+ bool $nullable = true
+ ) {
+ parent::__construct($name, $elementType, $table);
+ $this->nullable = $nullable;
+ }
/**
* Check whether column can be nullable
@@ -32,7 +43,7 @@ class Text extends Column implements ElementDiffAwareInterface
*/
public function isNullable()
{
- return isset($this->structuralElementData['nullable']) && $this->structuralElementData['nullable'];
+ return $this->nullable;
}
/**
@@ -41,7 +52,7 @@ public function isNullable()
public function getDiffSensitiveParams()
{
return [
- 'type' => $this->elementType,
+ 'type' => $this->getElementType(),
'nullable' => $this->isNullable(),
];
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Timestamp.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Timestamp.php
index 269c94400478e..06152da59e6ca 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Timestamp.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Timestamp.php
@@ -7,6 +7,7 @@
use Magento\Setup\Model\Declaration\Schema\Dto\Column;
use Magento\Setup\Model\Declaration\Schema\Dto\ElementDiffAwareInterface;
+use Magento\Setup\Model\Declaration\Schema\Dto\Table;
/**
* Timestamp column
@@ -16,35 +17,43 @@
class Timestamp extends Column implements ElementDiffAwareInterface
{
/**
- * By default element type is timesstamp. But can be also datetime
- * @inheritdoc
+ * @var string
*/
- protected $elementType = 'timestamp';
+ private $default;
/**
- * @inheritdoc
+ * @var null|string
*/
- protected $structuralElementData;
+ private $onUpdate;
/**
- * Return default value
- * Note: default value should be float
- *
- * @return int | null
+ * @param string $name
+ * @param string $elementType
+ * @param Table $table
+ * @param string $default
+ * @param string|null $onUpdate
*/
- public function getDefault()
- {
- return $this->structuralElementData['default'];
+ public function __construct(
+ string $name,
+ string $elementType,
+ Table $table,
+ string $default,
+ string $onUpdate = null
+ ) {
+ parent::__construct($name, $elementType, $table);
+ $this->default = $default;
+ $this->onUpdate = $onUpdate;
}
/**
- * on_update is optional param
+ * Return default value
+ * Note: default value should be float
*
- * @return bool
+ * @return int | null
*/
- public function hasOnUpdate()
+ public function getDefault()
{
- return isset($this->structuralElementData['on_update']);
+ return $this->default;
}
/**
@@ -54,7 +63,7 @@ public function hasOnUpdate()
*/
public function getOnUpdate()
{
- return $this->hasOnUpdate() ? $this->structuralElementData['on_update'] : null;
+ return $this->onUpdate;
}
/**
@@ -63,7 +72,7 @@ public function getOnUpdate()
public function getDiffSensitiveParams()
{
return [
- 'type' => $this->elementType,
+ 'type' => $this->getElementType(),
'default' => $this->getDefault(),
'onUpdate' => $this->getOnUpdate()
];
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Varbinary.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Varbinary.php
index 87629d68524a0..28bafb54af939 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Varbinary.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Varbinary.php
@@ -7,6 +7,7 @@
use Magento\Setup\Model\Declaration\Schema\Dto\Column;
use Magento\Setup\Model\Declaration\Schema\Dto\ElementDiffAwareInterface;
+use Magento\Setup\Model\Declaration\Schema\Dto\Table;
/**
* Varbinary column
@@ -16,33 +17,50 @@
class Varbinary extends Column implements ElementDiffAwareInterface
{
/**
- * @inheritdoc
+ * @var bool
*/
- protected $elementType = 'Varbinary';
+ private $nullable;
/**
- * @inheritdoc
+ * @var int
*/
- protected $structuralElementData;
-
+ private $default;
+
/**
- * Check whether column can be nullable
- *
- * @return bool
+ * @var int
*/
- public function isNullable()
- {
- return isset($this->structuralElementData['nullable']) && $this->structuralElementData['nullable'];
- }
+ private $length;
/**
- * Check whether column has default value
+ * @param string $name
+ * @param string $elementType
+ * @param Table $table
+ * @param bool $nullable
+ * @param int $length
+ * @param float|int $default
+ */
+ public function __construct(
+ string $name,
+ string $elementType,
+ Table $table,
+ int $length,
+ bool $nullable = true,
+ int $default = null
+ ) {
+ parent::__construct($name, $elementType, $table);
+ $this->nullable = $nullable;
+ $this->default = $default;
+ $this->length = $length;
+ }
+
+ /**
+ * Check whether column can be nullable
*
* @return bool
*/
- public function hasDefault()
+ public function isNullable()
{
- return isset($this->structuralElementData['default']);
+ return $this->nullable;
}
/**
@@ -53,7 +71,7 @@ public function hasDefault()
*/
public function getDefault()
{
- return $this->hasDefault() ? $this->structuralElementData['default'] : null;
+ return $this->default;
}
/**
@@ -63,7 +81,7 @@ public function getDefault()
*/
public function getLength()
{
- return $this->structuralElementData['length'];
+ return $this->length;
}
/**
@@ -72,7 +90,7 @@ public function getLength()
public function getDiffSensitiveParams()
{
return [
- 'type' => $this->elementType,
+ 'type' => $this->getElementType(),
'nullable' => $this->isNullable(),
'default' => $this->getDefault(),
'length' => $this->getLength()
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Varchar.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Varchar.php
index 60b2b4485b5e0..f26512c559b6d 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Varchar.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Varchar.php
@@ -7,6 +7,7 @@
use Magento\Setup\Model\Declaration\Schema\Dto\Column;
use Magento\Setup\Model\Declaration\Schema\Dto\ElementDiffAwareInterface;
+use Magento\Setup\Model\Declaration\Schema\Dto\Table;
/**
* Varchar column
@@ -16,33 +17,50 @@
class Varchar extends Column implements ElementDiffAwareInterface
{
/**
- * @inheritdoc
+ * @var bool
*/
- protected $elementType = 'varchar';
+ private $nullable;
/**
- * @inheritdoc
+ * @var int
*/
- protected $structuralElementData;
-
+ private $default;
+
/**
- * Check whether column can be nullable
- *
- * @return bool
+ * @var int
*/
- public function isNullable()
- {
- return isset($this->structuralElementData['nullable']) && $this->structuralElementData['nullable'];
+ private $length;
+
+ /**
+ * @param string $name
+ * @param string $elementType
+ * @param Table $table
+ * @param bool $nullable
+ * @param int $length
+ * @param float|int $default
+ */
+ public function __construct(
+ string $name,
+ string $elementType,
+ Table $table,
+ int $length,
+ bool $nullable = true,
+ int $default = null
+ ) {
+ parent::__construct($name, $elementType, $table);
+ $this->nullable = $nullable;
+ $this->default = $default;
+ $this->length = $length;
}
/**
- * Check whether column has default value
+ * Check whether column can be nullable
*
* @return bool
*/
- public function hasDefault()
+ public function isNullable()
{
- return isset($this->structuralElementData['default']);
+ return $this->nullable;
}
/**
@@ -53,17 +71,17 @@ public function hasDefault()
*/
public function getDefault()
{
- return $this->hasDefault() ? $this->structuralElementData['default'] : null;
+ return $this->default;
}
/**
- * Length can be integer value from 0 to 1024
+ * Length can be integer value from 0 to 255
*
* @return int
*/
public function getLength()
{
- return $this->structuralElementData['length'];
+ return $this->length;
}
/**
@@ -72,7 +90,7 @@ public function getLength()
public function getDiffSensitiveParams()
{
return [
- 'type' => $this->elementType,
+ 'type' => $this->getElementType(),
'nullable' => $this->isNullable(),
'default' => $this->getDefault(),
'length' => $this->getLength()
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Constraint.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Constraint.php
index c950a02fdd4d3..3a59b792f0139 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Constraint.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Constraint.php
@@ -14,23 +14,23 @@ class Constraint extends GenericElement implements
TableElementInterface
{
/**
- * @inheritdoc
+ * @var Table
*/
- protected $elementType = 'constraint';
+ private $table;
/**
- * @inheritdoc
+ * @param string $name
+ * @param string $elementType
+ * @param Table $table
+ * @param array $columns
*/
- protected $structuralElementData;
-
- /**
- * @param array $structuralElementData
- * @param $elementType
- */
- public function __construct(array $structuralElementData, $elementType)
- {
- $this->structuralElementData = $structuralElementData;
- $this->elementType = $elementType;
+ public function __construct(
+ string $name,
+ string $elementType,
+ Table $table
+ ) {
+ parent::__construct($name, $elementType);
+ $this->table = $table;
}
/**
@@ -40,6 +40,6 @@ public function __construct(array $structuralElementData, $elementType)
*/
public function getTable()
{
- return $this->structuralElementData['table'];
+ return $this->table;
}
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Constraints/Internal.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Constraints/Internal.php
index 9c9225513ba17..159de09778ead 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Constraints/Internal.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Constraints/Internal.php
@@ -8,6 +8,7 @@
use Magento\Setup\Model\Declaration\Schema\Dto\Column;
use Magento\Setup\Model\Declaration\Schema\Dto\Constraint;
use Magento\Setup\Model\Declaration\Schema\Dto\ElementDiffAwareInterface;
+use Magento\Setup\Model\Declaration\Schema\Dto\Table;
/**
* Internal key constraint is constraint that add KEY onto table columns, on which it is declared
@@ -21,22 +22,33 @@ class Internal extends Constraint implements ElementDiffAwareInterface
const PRIMARY_NAME = "PRIMARY";
/**
- * @inheritdoc
- * Can be unique or primary
+ * @var array
*/
- protected $elementType = 'unique';
+ private $columns;
/**
- * @inheritdoc
+ * Internal constructor.
+ * @param string $name
+ * @param string $elementType
+ * @param Table $table
+ * @param array $columns
*/
- protected $structuralElementData;
+ public function __construct(
+ $name,
+ $elementType,
+ Table $table,
+ array $columns
+ ) {
+ parent::__construct($name, $elementType, $table);
+ $this->columns = $columns;
+ }
/**
* @return Column[]
*/
public function getColumns()
{
- return $this->structuralElementData['column'];
+ return $this->columns;
}
/**
@@ -45,7 +57,7 @@ public function getColumns()
public function getDiffSensitiveParams()
{
return [
- 'type' => $this->elementType,
+ 'type' => $this->getElementType(),
'columns' => array_map(
function (Column $column) {
return $column->getName();
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Constraints/Reference.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Constraints/Reference.php
index 1482bd0ec929c..175d661346c2f 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Constraints/Reference.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Constraints/Reference.php
@@ -17,22 +17,55 @@
class Reference extends Constraint implements ElementDiffAwareInterface
{
/**
- * @inheritdoc
- * Can be unique or primay
+ * @var Column
*/
- protected $elementType = 'foreign';
+ private $column;
/**
- * @inheritdoc
+ * @var Table
+ */
+ private $referenceTable;
+
+ /**
+ * @var Column
*/
- protected $structuralElementData;
+ private $referenceColumn;
+ /**
+ * @var string
+ */
+ private $onDelete;
+
+ /**
+ * @param string $name
+ * @param string $elementType
+ * @param Table $table
+ * @param Column $column
+ * @param Table $referenceTable
+ * @param Column $referenceColumn
+ * @param string $onDelete
+ */
+ public function __construct(
+ string $name,
+ string $elementType,
+ Table $table,
+ Column $column,
+ Table $referenceTable,
+ Column $referenceColumn,
+ string $onDelete
+ ) {
+ parent::__construct($name, $elementType, $table);
+ $this->column = $column;
+ $this->referenceTable = $referenceTable;
+ $this->referenceColumn = $referenceColumn;
+ $this->onDelete = $onDelete;
+ }
/**
* @return Column
*/
public function getColumn()
{
- return $this->structuralElementData['column'];
+ return $this->column;
}
/**
@@ -42,7 +75,7 @@ public function getColumn()
*/
public function getReferenceColumn()
{
- return $this->structuralElementData['referenceColumn'];
+ return $this->referenceColumn;
}
/**
@@ -53,7 +86,7 @@ public function getReferenceColumn()
*/
public function getReferenceTable()
{
- return $this->structuralElementData['referenceTable'];
+ return $this->referenceTable;
}
/**
@@ -63,7 +96,7 @@ public function getReferenceTable()
*/
public function getOnDelete()
{
- return $this->structuralElementData['onDelete'];
+ return $this->onDelete;
}
/**
@@ -72,7 +105,7 @@ public function getOnDelete()
public function getDiffSensitiveParams()
{
return [
- 'type' => $this->elementType,
+ 'type' => $this->getElementType(),
'column' => $this->getColumn()->getName(),
'referenceColumn' => $this->getReferenceColumn()->getName(),
'referenceTableName' => $this->getReferenceTable()->getName(),
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/ElementFactory.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/ElementFactory.php
index 185e2d32d55b2..62922012fc947 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/ElementFactory.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/ElementFactory.php
@@ -5,6 +5,9 @@
*/
namespace Magento\Setup\Model\Declaration\Schema\Dto;
+use Magento\Framework\Stdlib\BooleanUtils;
+use Magento\Setup\Model\Declaration\Schema\Dto\Factories\FactoryInterface;
+
/**
* This is abstract factory that allows to
* instantiate any type of structural elements
@@ -18,14 +21,44 @@ class ElementFactory
* Where @key - is xsi:type of the object
* Where @value - is instance class name
*/
- private $types = [];
+ private $typeFactories = [];
+
+ /**
+ * @var BooleanUtils
+ */
+ private $booleanUtils;
+
+ /**
+ * @param FactoryInterface[] $typeFactories
+ * @param BooleanUtils $booleanUtils
+ */
+ public function __construct(array $typeFactories, BooleanUtils $booleanUtils)
+ {
+ $this->typeFactories = $typeFactories;
+ $this->booleanUtils = $booleanUtils;
+ }
/**
- * @param array $types
+ * As we have few attributes, that are generic and be applied to few types:
+ * - nullable
+ * - unsigned
+ *
+ * We need to cast this attributes to boolean values in abstract factory
+ *
+ * @param array $elementStructuralData
+ * @return array
*/
- public function __construct(array $types)
+ private function castGenericAttributes(array $elementStructuralData)
{
- $this->types = $types;
+ if (isset($elementStructuralData['nullable'])) {
+ $elementStructuralData['nullable'] = $this->booleanUtils->toBoolean($elementStructuralData['nullable']);
+ }
+
+ if (isset($elementStructuralData['unsigned'])) {
+ $elementStructuralData['unsigned'] = $this->booleanUtils->toBoolean($elementStructuralData['unsigned']);
+ }
+
+ return $elementStructuralData;
}
/**
@@ -37,11 +70,12 @@ public function __construct(array $types)
*/
public function create($type, array $elementStructuralData)
{
- if (!isset($this->types[$type])) {
+ if (!isset($this->typeFactories[$type])) {
throw new \InvalidArgumentException(sprintf("Types %s is not declared", $type));
}
- $elementStructuralData['type'] = $type;
- return new $this->types[$type]($elementStructuralData, $type);
+ $elementStructuralData = $this->castGenericAttributes($elementStructuralData);
+ $elementStructuralData['elementType'] = $type;
+ return $this->typeFactories[$type]->create($elementStructuralData);
}
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/ElementInterface.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/ElementInterface.php
index 1538820bba929..4911dac4688ef 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/ElementInterface.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/ElementInterface.php
@@ -26,12 +26,4 @@ public function getName();
* @return string
*/
public function getElementType();
-
- /**
- * As different structural elements can be created on different shards
- * We should have possibility to determine what element belongs to what shard
- *
- * @return string
- */
- public function getResource();
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/ElementRenamedInterface.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/ElementRenamedInterface.php
deleted file mode 100644
index aecc6650d4ed1..0000000000000
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/ElementRenamedInterface.php
+++ /dev/null
@@ -1,21 +0,0 @@
-objectManager = $objectManager;
+ $this->className = $className;
+ }
+
+ /**
+ * Set default padding, like BIGINT(20)
+ *
+ * {@inheritdoc}
+ * @return array
+ */
+ public function create(array $data)
+ {
+ if (!isset($data['padding'])) {
+ $data['padding'] = self::DEFAULT_PADDING;
+ }
+
+ if (isset($data['default'])) {
+ $data['default'] = (int)$data['default'];
+ }
+
+ return $this->objectManager->create($this->className, $data);
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Blob.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Blob.php
new file mode 100644
index 0000000000000..c85813b1b4b38
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Blob.php
@@ -0,0 +1,56 @@
+objectManager = $objectManager;
+ $this->className = $className;
+ }
+
+ /**
+ * Set default padding, like SMALLINT(5)
+ *
+ * {@inheritdoc}
+ * @return array
+ */
+ public function create(array $data)
+ {
+ if (!isset($data['length'])) {
+ $data['length'] = self::DEFAULT_BLOB_LENGTH;
+ }
+
+ return $this->objectManager->create($this->className, $data);
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Casters/Boolean.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Boolean.php
similarity index 52%
rename from setup/src/Magento/Setup/Model/Declaration/Schema/Casters/Boolean.php
rename to setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Boolean.php
index a76eae8465582..efff88f34b701 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Casters/Boolean.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Boolean.php
@@ -4,14 +4,15 @@
* See COPYING.txt for license details.
*/
-namespace Magento\Setup\Model\Declaration\Schema\Casters;
+namespace Magento\Setup\Model\Declaration\Schema\Dto\Factories;
+use Magento\Framework\ObjectManagerInterface;
use Magento\Framework\Stdlib\BooleanUtils;
/**
* Can accept only 2 values: true or false
*/
-class Boolean implements CasterInterface
+class Boolean implements FactoryInterface
{
/**
* Default value for boolean xsi:type
@@ -19,9 +20,14 @@ class Boolean implements CasterInterface
const DEFAULT_BOOLEAN = false;
/**
- * @var Base
+ * @var ObjectManagerInterface
*/
- private $base;
+ private $objectManager;
+
+ /**
+ * @var string
+ */
+ private $className;
/**
* @var BooleanUtils
@@ -29,12 +35,17 @@ class Boolean implements CasterInterface
private $booleanUtils;
/**
- * @param Base $base
+ * @param ObjectManagerInterface $objectManager
* @param BooleanUtils $booleanUtils
+ * @param string $className
*/
- public function __construct(Base $base, BooleanUtils $booleanUtils)
- {
- $this->base = $base;
+ public function __construct(
+ ObjectManagerInterface $objectManager,
+ BooleanUtils $booleanUtils,
+ $className = \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Boolean::class
+ ) {
+ $this->objectManager = $objectManager;
+ $this->className = $className;
$this->booleanUtils = $booleanUtils;
}
@@ -44,16 +55,14 @@ public function __construct(Base $base, BooleanUtils $booleanUtils)
* {@inheritdoc}
* @return array
*/
- public function cast(array $data)
+ public function create(array $data)
{
- $data = $this->base->cast($data);
-
if (isset($data['default'])) {
$data['default'] = $this->booleanUtils->toBoolean($data['default']);
} else {
$data['default'] = self::DEFAULT_BOOLEAN;
}
- return $data;
+ return $this->objectManager->create($this->className, $data);
}
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Date.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Date.php
new file mode 100644
index 0000000000000..d08169550f67e
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Date.php
@@ -0,0 +1,51 @@
+objectManager = $objectManager;
+ $this->className = $className;
+ }
+
+ /**
+ * Set shape to floating point, that is by default (10,0)
+ *
+ * {@inheritdoc}
+ * @return array
+ */
+ public function create(array $data)
+ {
+ unset($data['nullable']);
+ unset($data['default']);
+
+ return $this->objectManager->create($this->className, $data);
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Casters/Decimal.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Decimal.php
similarity index 52%
rename from setup/src/Magento/Setup/Model/Declaration/Schema/Casters/Decimal.php
rename to setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Decimal.php
index 8c60e591b7abc..797e531157a05 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Casters/Decimal.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Decimal.php
@@ -3,30 +3,47 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-namespace Magento\Setup\Model\Declaration\Schema\Casters;
+namespace Magento\Setup\Model\Declaration\Schema\Dto\Factories;
+
+use Magento\Framework\ObjectManagerInterface;
/**
* This type is equal to SQL DECIMAL(SCALE,PRECISION) type. Usually it is used for accurate operations
* with decimal numbers. For example, for price
* Usually decimal is concatinated from 2 integers, so it has not round problems
*/
-class Decimal implements CasterInterface
+class Decimal implements FactoryInterface
{
+ /**
+ * Default SQL precission
+ */
const DEFAULT_PRECISSION = "10";
+ /**
+ * Default SQL scale
+ */
const DEFAULT_SCALE = "0";
/**
- * @var Base
+ * @var ObjectManagerInterface
*/
- private $base;
+ private $objectManager;
/**
- * @param Base $base
+ * @var string
*/
- public function __construct(Base $base)
- {
- $this->base = $base;
+ private $className;
+
+ /**
+ * @param ObjectManagerInterface $objectManager
+ * @param string $className
+ */
+ public function __construct(
+ ObjectManagerInterface $objectManager,
+ $className = \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Decimal::class
+ ) {
+ $this->objectManager = $objectManager;
+ $this->className = $className;
}
/**
@@ -35,10 +52,8 @@ public function __construct(Base $base)
* {@inheritdoc}
* @return array
*/
- public function cast(array $data)
+ public function create(array $data)
{
- $data = $this->base->cast($data);
-
if (!isset($data['precission'])) {
$data['precission'] = self::DEFAULT_PRECISSION;
}
@@ -51,6 +66,6 @@ public function cast(array $data)
$data['default'] = (float) $data['default'];
}
- return $data;
+ return $this->objectManager->create($this->className, $data);
}
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/FactoryInterface.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/FactoryInterface.php
new file mode 100644
index 0000000000000..fa0f5cfe75292
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/FactoryInterface.php
@@ -0,0 +1,23 @@
+objectManager = $objectManager;
+ $this->className = $className;
+ }
+
+ /**
+ * Set default on delete to foreign key
+ *
+ * {@inheritdoc}
+ * @return array
+ */
+ public function create(array $data)
+ {
+ if (!isset($data['onDelete'])) {
+ $data['onDelete'] = self::DEFAULT_ON_DELETE;
+ }
+
+ return $this->objectManager->create($this->className, $data);
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Index.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Index.php
new file mode 100644
index 0000000000000..29233b7309e2a
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Index.php
@@ -0,0 +1,56 @@
+objectManager = $objectManager;
+ $this->className = $className;
+ }
+
+ /**
+ * Set default on delete to foreign key
+ *
+ * {@inheritdoc}
+ * @return array
+ */
+ public function create(array $data)
+ {
+ if (!isset($data['type'])) {
+ $data['type'] = self::DEFAULT_INDEX_TYPE;
+ }
+
+ return $this->objectManager->create($this->className, $data);
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Integer.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Integer.php
new file mode 100644
index 0000000000000..375f19e1c1325
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Integer.php
@@ -0,0 +1,62 @@
+objectManager = $objectManager;
+ $this->className = $className;
+ }
+
+ /**
+ * Set default padding, like INTEGER(11)
+ *
+ * {@inheritdoc}
+ * @return array
+ */
+ public function create(array $data)
+ {
+ if (!isset($data['padding'])) {
+ $data['padding'] = self::DEFAULT_PADDING;
+ }
+
+ if (isset($data['default'])) {
+ $data['default'] = (int) $data['default'];
+ }
+
+ return $this->objectManager->create($this->className, $data);
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/LongBlob.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/LongBlob.php
new file mode 100644
index 0000000000000..800ce74e9dd2e
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/LongBlob.php
@@ -0,0 +1,56 @@
+objectManager = $objectManager;
+ $this->className = $className;
+ }
+
+ /**
+ * Set default padding, like SMALLINT(5)
+ *
+ * {@inheritdoc}
+ * @return array
+ */
+ public function create(array $data)
+ {
+ if (!isset($data['length'])) {
+ $data['length'] = self::DEFAULT_BLOB_LENGTH;
+ }
+
+ return $this->objectManager->create($this->className, $data);
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/LongText.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/LongText.php
new file mode 100644
index 0000000000000..0e9cf6ac7ba0e
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/LongText.php
@@ -0,0 +1,56 @@
+objectManager = $objectManager;
+ $this->className = $className;
+ }
+
+ /**
+ * Set default padding, like SMALLINT(5)
+ *
+ * {@inheritdoc}
+ * @return array
+ */
+ public function create(array $data)
+ {
+ if (!isset($data['length'])) {
+ $data['length'] = self::DEFAULT_TEXT_LENGTH;
+ }
+
+ return $this->objectManager->create($this->className, $data);
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/MediumBlob.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/MediumBlob.php
new file mode 100644
index 0000000000000..d0e245e895fb7
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/MediumBlob.php
@@ -0,0 +1,56 @@
+objectManager = $objectManager;
+ $this->className = $className;
+ }
+
+ /**
+ * Set default padding, like SMALLINT(5)
+ *
+ * {@inheritdoc}
+ * @return array
+ */
+ public function create(array $data)
+ {
+ if (!isset($data['length'])) {
+ $data['length'] = self::DEFAULT_BLOB_LENGTH;
+ }
+
+ return $this->objectManager->create($this->className, $data);
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/MediumText.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/MediumText.php
new file mode 100644
index 0000000000000..7707d5bc91993
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/MediumText.php
@@ -0,0 +1,56 @@
+objectManager = $objectManager;
+ $this->className = $className;
+ }
+
+ /**
+ * Set default padding, like SMALLINT(5)
+ *
+ * {@inheritdoc}
+ * @return array
+ */
+ public function create(array $data)
+ {
+ if (!isset($data['length'])) {
+ $data['length'] = self::DEFAULT_TEXT_LENGTH;
+ }
+
+ return $this->objectManager->create($this->className, $data);
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Primary.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Primary.php
new file mode 100644
index 0000000000000..955f632e028c3
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Primary.php
@@ -0,0 +1,52 @@
+objectManager = $objectManager;
+ $this->className = $className;
+ }
+
+ /**
+ * Set default padding, like INTEGER(11)
+ *
+ * {@inheritdoc}
+ * @return array
+ */
+ public function create(array $data)
+ {
+ $data['name'] = Internal::PRIMARY_NAME;
+ return $this->objectManager->create($this->className, $data);
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Smallinteger.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Smallinteger.php
new file mode 100644
index 0000000000000..0af7fcaee28e9
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Smallinteger.php
@@ -0,0 +1,61 @@
+objectManager = $objectManager;
+ $this->className = $className;
+ }
+
+ /**
+ * Set default padding, like SMALLINT(5)
+ *
+ * {@inheritdoc}
+ * @return array
+ */
+ public function create(array $data)
+ {
+ if (!isset($data['padding'])) {
+ $data['padding'] = self::DEFAULT_PADDING;
+ }
+
+ if (isset($data['default'])) {
+ $data['default'] = (int) $data['default'];
+ }
+
+ return $this->objectManager->create($this->className, $data);
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Table.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Table.php
new file mode 100644
index 0000000000000..adbf8b91de381
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Table.php
@@ -0,0 +1,48 @@
+objectManager = $objectManager;
+ $this->className = $className;
+ }
+
+ /**
+ * Set default padding, like BIGINT(20)
+ *
+ * {@inheritdoc}
+ * @return array
+ */
+ public function create(array $data)
+ {
+ return $this->objectManager->create($this->className, $data);
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Text.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Text.php
new file mode 100644
index 0000000000000..7009dd2cb9e8c
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Text.php
@@ -0,0 +1,56 @@
+objectManager = $objectManager;
+ $this->className = $className;
+ }
+
+ /**
+ * Set default padding, like SMALLINT(5)
+ *
+ * {@inheritdoc}
+ * @return array
+ */
+ public function create(array $data)
+ {
+ if (!isset($data['length'])) {
+ $data['length'] = self::DEFAULT_TEXT_LENGTH;
+ }
+
+ return $this->objectManager->create($this->className, $data);
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Casters/Timestamp.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Timestamp.php
similarity index 67%
rename from setup/src/Magento/Setup/Model/Declaration/Schema/Casters/Timestamp.php
rename to setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Timestamp.php
index 12670ba7f333b..0572a100685e1 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Casters/Timestamp.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Timestamp.php
@@ -3,8 +3,9 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-namespace Magento\Setup\Model\Declaration\Schema\Casters;
+namespace Magento\Setup\Model\Declaration\Schema\Dto\Factories;
+use Magento\Framework\ObjectManagerInterface;
use Magento\Framework\Stdlib\BooleanUtils;
/**
@@ -16,12 +17,17 @@
* to your local time again.
* Unix range: 1970-01-01 00:00:01' UTC to '2038-01-09 03:14:07'
*/
-class Timestamp implements CasterInterface
+class Timestamp implements FactoryInterface
{
/**
- * @var Base
+ * @var ObjectManagerInterface
*/
- private $base;
+ private $objectManager;
+
+ /**
+ * @var string
+ */
+ private $className;
/**
* @var BooleanUtils
@@ -29,24 +35,27 @@ class Timestamp implements CasterInterface
private $booleanUtils;
/**
- * @param Base $base
+ * @param ObjectManagerInterface $objectManager
* @param BooleanUtils $booleanUtils
+ * @param string $className
*/
- public function __construct(Base $base, BooleanUtils $booleanUtils)
- {
- $this->base = $base;
+ public function __construct(
+ ObjectManagerInterface $objectManager,
+ BooleanUtils $booleanUtils,
+ $className = \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Timestamp::class
+ ) {
+ $this->objectManager = $objectManager;
+ $this->className = $className;
$this->booleanUtils = $booleanUtils;
}
-
/**
* Change on_update and default params
*
* {@inheritdoc}
* @return array
*/
- public function cast(array $data)
+ public function create(array $data)
{
- $data = $this->base->cast($data);
//As we have only one value for timestamp on update -> it is convinient to use boolean type for it
//But later we need to convert it to SQL value
if (isset($data['on_update']) && $data['on_update'] !== 'CURRENT_TIMESTAMP') {
@@ -63,6 +72,6 @@ public function cast(array $data)
unset($data['nullable']);
- return $data;
+ return $this->objectManager->create($this->className, $data);
}
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Tinyinteger.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Tinyinteger.php
new file mode 100644
index 0000000000000..79408926ebfe9
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Tinyinteger.php
@@ -0,0 +1,61 @@
+objectManager = $objectManager;
+ $this->className = $className;
+ }
+
+ /**
+ * Set default padding, like TINYINT(1)
+ *
+ * {@inheritdoc}
+ * @return array
+ */
+ public function create(array $data)
+ {
+ if (!isset($data['padding'])) {
+ $data['padding'] = self::DEFAULT_PADDING;
+ }
+
+ if (isset($data['default'])) {
+ $data['default'] = (int) $data['default'];
+ }
+
+ return $this->objectManager->create($this->className, $data);
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Unique.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Unique.php
new file mode 100644
index 0000000000000..4ebe3523f23a9
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Unique.php
@@ -0,0 +1,48 @@
+objectManager = $objectManager;
+ $this->className = $className;
+ }
+
+ /**
+ * Set default padding, like INTEGER(11)
+ *
+ * {@inheritdoc}
+ * @return array
+ */
+ public function create(array $data)
+ {
+ return $this->objectManager->create($this->className, $data);
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Varbinary.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Varbinary.php
new file mode 100644
index 0000000000000..dce7136ba1ebf
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Varbinary.php
@@ -0,0 +1,56 @@
+objectManager = $objectManager;
+ $this->className = $className;
+ }
+
+ /**
+ * Set default padding, like SMALLINT(5)
+ *
+ * {@inheritdoc}
+ * @return array
+ */
+ public function create(array $data)
+ {
+ if (!isset($data['length'])) {
+ $data['length'] = self::DEFAULT_TEXT_LENGTH;
+ }
+
+ return $this->objectManager->create($this->className, $data);
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Varchar.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Varchar.php
new file mode 100644
index 0000000000000..9e217acc5e3d3
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Varchar.php
@@ -0,0 +1,56 @@
+objectManager = $objectManager;
+ $this->className = $className;
+ }
+
+ /**
+ * Set default padding, like SMALLINT(5)
+ *
+ * {@inheritdoc}
+ * @return array
+ */
+ public function create(array $data)
+ {
+ if (!isset($data['length'])) {
+ $data['length'] = self::DEFAULT_TEXT_LENGTH;
+ }
+
+ return $this->objectManager->create($this->className, $data);
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/GenericElement.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/GenericElement.php
index 1f5520ff1cddd..a0b2af492aa3c 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/GenericElement.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/GenericElement.php
@@ -15,46 +15,34 @@
* - index
*/
abstract class GenericElement implements
- ElementInterface,
- ElementRenamedInterface
+ ElementInterface
{
/**
- * Data that comes from reader and consist all information
- * about structural element
- *
- * @var array
- */
- protected $structuralElementData = [];
-
- /**
- * Structural element type
- *
* @var string
*/
- protected $elementType;
+ private $elementType;
/**
- * @inheritdoc
+ * @var string
*/
- public function getName()
- {
- return $this->structuralElementData['name'];
- }
+ private $name;
/**
- * @inheritdoc
+ * @param string $name
+ * @param string $elementType
*/
- public function getResource()
+ public function __construct(string $name, string $elementType)
{
- return $this->structuralElementData['resource'];
+ $this->elementType = $elementType;
+ $this->name = $name;
}
/**
* @inheritdoc
*/
- public function wasRenamedFrom()
+ public function getName()
{
- return $this->structuralElementData['wasRenamedFrom'];
+ return $this->name;
}
/**
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Index.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Index.php
index 7e0dc0f2a5f86..56bc5dfdf720a 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Index.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Index.php
@@ -15,23 +15,30 @@ class Index extends GenericElement implements
ElementDiffAwareInterface
{
/**
- * @inheritdoc
+ * @var Table
*/
- protected $elementType = 'index';
+ private $table;
/**
- * @inheritdoc
+ * @var array
*/
- protected $structuralElementData;
+ private $columns;
/**
- * @param array $structuralElementData
+ * @param string $name
* @param string $elementType
+ * @param Table $table
+ * @param array $columns
*/
- public function __construct(array $structuralElementData, $elementType)
- {
- $this->structuralElementData = $structuralElementData;
- $this->elementType = $elementType;
+ public function __construct(
+ string $name,
+ string $elementType,
+ Table $table,
+ array $columns
+ ) {
+ parent::__construct($name, $elementType);
+ $this->table = $table;
+ $this->columns = $columns;
}
/**
@@ -41,7 +48,7 @@ public function __construct(array $structuralElementData, $elementType)
*/
public function getColumns()
{
- return $this->structuralElementData['column'];
+ return $this->columns;
}
/**
@@ -51,7 +58,7 @@ public function getColumns()
*/
public function getTable()
{
- return $this->structuralElementData['table'];
+ return $this->table;
}
/**
@@ -60,7 +67,7 @@ public function getTable()
public function getDiffSensitiveParams()
{
return [
- 'type' => $this->elementType,
+ 'type' => $this->getElementType(),
'columns' => array_map(
function (Column $column) {
return $column->getName();
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Structure.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Structure.php
index 5a420579b170f..fef2923f18ec8 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Structure.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Structure.php
@@ -38,27 +38,6 @@ public function addTable(Table $table)
return $this;
}
- /**
- * Try to find table by its name or by its old name, that was specified as id
- *
- * @param string $nameOrId
- * @return null | Table
- */
- public function getTableByNameOrId($nameOrId)
- {
- if (isset($this->tables[$nameOrId])) {
- return $this->tables[$nameOrId];
- }
-
- foreach ($this->tables as $table) {
- if ($table->wasRenamedFrom() === $nameOrId) {
- return $table;
- }
- }
-
- return null;
- }
-
/**
* Retrieve table by it name
*
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Table.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Table.php
index 457d5d840a896..48be2264f2992 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Table.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Table.php
@@ -15,11 +15,6 @@
*/
class Table extends GenericElement implements ElementInterface
{
- /**
- * @inheritdoc
- */
- protected $structuralElementData;
-
/**
* @var Constraint[]
*/
@@ -41,11 +36,31 @@ class Table extends GenericElement implements ElementInterface
private $indexes = [];
/**
- * @param array $structuralElementData
+ * @var string
*/
- public function __construct(array $structuralElementData)
- {
- $this->structuralElementData = $structuralElementData;
+ private $resource;
+
+ /**
+ * @param string $name
+ * @param string $elementType
+ * @param string $resource
+ * @param array $columns
+ * @param array $indexes
+ * @param array $constraints
+ */
+ public function __construct(
+ string $name,
+ string $elementType,
+ string $resource,
+ array $columns = [],
+ array $indexes = [],
+ array $constraints = []
+ ) {
+ parent::__construct($name, $elementType);
+ $this->columns = $columns;
+ $this->indexes = $indexes;
+ $this->constraints = $constraints;
+ $this->resource = $resource;
}
/**
@@ -112,6 +127,16 @@ public function getIndexes()
return $this->indexes;
}
+ /**
+ * Retrieve shard name, on which table will exists
+ *
+ * @return string
+ */
+ public function getResource()
+ {
+ return $this->resource;
+ }
+
/**
* This is workaround, as any DTO object couldnt be changed after instantiation.
* However there is case, when we have 2 tables with constraints in different tables,
@@ -136,26 +161,17 @@ public function addColumns(array $columns)
}
/**
- * If we want to rename our column: then it name will be changed
- * But we want to search by old name
- * As this name can be used in constraints and indexes
+ * If column exists - retrieve column
*
* @param string $nameOrId
* @return Column
*/
- public function getColumnByNameOrId($nameOrId)
+ public function getColumnByName($nameOrId)
{
if (isset($this->columns[$nameOrId])) {
return $this->columns[$nameOrId];
}
- //If it was renamed
- foreach ($this->columns as $column) {
- if ($column->wasRenamedFrom() === $nameOrId) {
- return $column;
- }
- }
-
throw new \LogicException(sprintf("Cannot find column with name or id %s", $nameOrId));
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Xml/Converter.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Xml/Converter.php
index 6a8f5b4623060..f10442a20a90f 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Xml/Converter.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Xml/Converter.php
@@ -7,8 +7,6 @@
*/
namespace Magento\Setup\Model\Declaration\Schema\Xml;
-use Magento\Setup\Model\Declaration\Schema\Casters\CasterAggregator;
-
/**
* This converter serve needs of Declaration Filesystem reader:
* @see \Magento\Setup\Model\Declaration\Schema\FileSystem\Reader
@@ -18,19 +16,6 @@
*/
class Converter implements \Magento\Framework\Config\ConverterInterface
{
- /**
- * @var CasterAggregator
- */
- private $casterAggregator;
-
- /**
- * @param CasterAggregator $casterAggregator
- */
- public function __construct(CasterAggregator $casterAggregator)
- {
- $this->casterAggregator = $casterAggregator;
- }
-
/**
* Convert config from XML to array
*
@@ -111,7 +96,6 @@ private function interpretateAttributes(\DOMElement $domElement)
if ($xsiType) {
$attributes['type'] = $xsiType;
- return $this->casterAggregator->cast($attributes);
}
return $attributes;
From b60b59571c4a1ca5787fa8984d2b3d4734474afb Mon Sep 17 00:00:00 2001
From: Sergii Kovalenko
Date: Mon, 18 Dec 2017 19:56:56 +0200
Subject: [PATCH 232/904] MAGETWO-83201: Creating Diff artifacts between
arbitrary Declarative Schemas
--remove casters
---
app/etc/di.xml | 7 ++
.../foreign_key_interpreter_result.php | 18 +--
.../fixture/valid_xml_revision_1.php | 108 +++++-------------
.../Setup/DeclarativeSchemaBuilderTest.php | 7 +-
.../Magento/Setup/DiffOldSchemaTest.php | 26 ++---
.../Magento/Setup/SchemaReaderTest.php | 10 +-
.../Declaration/Schema/ChangeRegistry.php | 18 +--
.../Schema/ChangeRegistryInterface.php | 14 +--
.../Model/Declaration/Schema/Db/Parser.php | 20 ++--
...StructureBuilder.php => SchemaBuilder.php} | 16 +--
.../Declaration/DynamicStructureInterface.php | 50 --------
.../Declaration/Schema/Declaration/Parser.php | 51 ++++-----
.../Schema/Declaration/ReaderComposite.php | 43 +++++++
...StructureBuilder.php => SchemaBuilder.php} | 52 ++++-----
.../Schema/Declaration/Structure/Dynamic.php | 23 ----
.../Declaration/Schema/Diff/DiffManager.php | 2 +-
.../{StructureDiff.php => SchemaDiff.php} | 18 +--
.../Declaration/Schema/Diff/TableDiff.php | 2 +-
.../Schema/Dto/{Structure.php => Schema.php} | 4 +-
...StructureFactory.php => SchemaFactory.php} | 8 +-
.../FileSystem/{Reader.php => XmlReader.php} | 2 +-
.../Schema/SchemaParserInterface.php | 14 +--
.../Declaration/Schema/Xml/Converter.php | 2 +-
23 files changed, 215 insertions(+), 300 deletions(-)
rename setup/src/Magento/Setup/Model/Declaration/Schema/Db/{StructureBuilder.php => SchemaBuilder.php} (94%)
delete mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/DynamicStructureInterface.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/ReaderComposite.php
rename setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/{StructureBuilder.php => SchemaBuilder.php} (85%)
delete mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/Structure/Dynamic.php
rename setup/src/Magento/Setup/Model/Declaration/Schema/Diff/{StructureDiff.php => SchemaDiff.php} (80%)
rename setup/src/Magento/Setup/Model/Declaration/Schema/Dto/{Structure.php => Schema.php} (91%)
rename setup/src/Magento/Setup/Model/Declaration/Schema/Dto/{StructureFactory.php => SchemaFactory.php} (82%)
rename setup/src/Magento/Setup/Model/Declaration/Schema/FileSystem/{Reader.php => XmlReader.php} (95%)
diff --git a/app/etc/di.xml b/app/etc/di.xml
index f312ad0526333..ee274b733d448 100755
--- a/app/etc/di.xml
+++ b/app/etc/di.xml
@@ -1403,4 +1403,11 @@
+
+
+
+ - Magento\Setup\Model\Declaration\Schema\FileSystem\XmlReader
+
+
+
diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/foreign_key_interpreter_result.php b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/foreign_key_interpreter_result.php
index a3ec00b318467..60b8bb2eb7ce5 100644
--- a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/foreign_key_interpreter_result.php
+++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/foreign_key_interpreter_result.php
@@ -10,11 +10,10 @@
'tinyint_ref' => [
'type' => 'tinyinteger',
'name' => 'tinyint_ref',
- 'default' => 0,
+ 'default' => '0',
'padding' => '7',
- 'nullable' => true,
- 'unsigned' => false,
- 'disabled' => false,
+ 'nullable' => 'true',
+ 'unsigned' => 'false',
],
],
'name' => 'reference_table',
@@ -25,11 +24,10 @@
'tinyint' => [
'type' => 'tinyinteger',
'name' => 'tinyint',
- 'default' => 0,
+ 'default' => '0',
'padding' => '7',
- 'nullable' => true,
- 'unsigned' => false,
- 'disabled' => false,
+ 'nullable' => 'true',
+ 'unsigned' => 'false',
],
],
'constraint' => [
@@ -40,10 +38,6 @@
'table' => 'test_table',
'referenceTable' => 'reference_table',
'referenceColumn' => 'tinyint_ref',
- 'nullable' => true,
- 'unsigned' => false,
- 'disabled' => false,
- 'onDelete' => 'CASCADE',
],
],
'name' => 'test_table',
diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/valid_xml_revision_1.php b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/valid_xml_revision_1.php
index 416b4b6f42a6e..c2de2cb375435 100644
--- a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/valid_xml_revision_1.php
+++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/valid_xml_revision_1.php
@@ -7,17 +7,15 @@
'table' => [
'reference_table' => [
'column' => [
- 'tinyint_ref' =>
- [
- 'type' => 'tinyinteger',
- 'name' => 'tinyint_ref',
- 'renameTo' => 'tinyintref_2',
- 'default' => 0,
- 'padding' => '7',
- 'nullable' => true,
- 'unsigned' => false,
- 'disabled' => false,
- ],
+ 'tinyint_ref' => [
+ 'type' => 'tinyinteger',
+ 'name' => 'tinyint_ref',
+ 'renameTo' => 'tinyintref_2',
+ 'default' => '0',
+ 'padding' => '7',
+ 'nullable' => 'true',
+ 'unsigned' => 'false',
+ ],
],
'constraint' => [
'tinyint_primary' => [
@@ -25,10 +23,7 @@
'tinyint_ref' => 'tinyint_ref',
],
'type' => 'primary',
- 'name' => 'PRIMARY',
- 'nullable' => true,
- 'unsigned' => false,
- 'disabled' => false,
+ 'name' => 'tinyint_primary',
],
],
'name' => 'reference_table',
@@ -39,59 +34,43 @@
'smallint' => [
'type' => 'smallinteger',
'name' => 'smallint',
- 'default' => 0,
+ 'default' => '0',
'padding' => '3',
- 'nullable' => true,
- 'unsigned' => false,
- 'disabled' => false,
],
'tinyint' => [
'type' => 'tinyinteger',
'name' => 'tinyint',
- 'default' => 0,
+ 'default' => '0',
'padding' => '7',
- 'nullable' => true,
- 'unsigned' => false,
- 'disabled' => false,
+ 'nullable' => 'true',
+ 'unsigned' => 'false',
],
'bigint' => [
'type' => 'biginteger',
'name' => 'bigint',
- 'default' => 0,
+ 'default' => '0',
'padding' => '13',
- 'nullable' => true,
- 'unsigned' => false,
- 'disabled' => false,
+ 'nullable' => 'true',
+ 'unsigned' => 'false',
],
'float' => [
'type' => 'float',
'name' => 'float',
- 'default' => 0.0,
+ 'default' => '0',
'scale' => '12',
- 'nullable' => true,
- 'unsigned' => false,
- 'disabled' => false,
- 'precission' => '10',
],
'double' => [
'type' => 'double',
'name' => 'double',
- 'default' => 11111111.111111,
+ 'default' => '11111111.111111',
'scale' => '245',
- 'nullable' => true,
- 'unsigned' => false,
- 'disabled' => false,
- 'precission' => '10',
],
'decimal' => [
'type' => 'decimal',
'name' => 'decimal',
- 'default' => 0.0,
+ 'default' => '0',
'scale' => '15',
'precission' => '4',
- 'nullable' => true,
- 'unsigned' => false,
- 'disabled' => false,
],
'date' => [
'type' => 'date',
@@ -101,86 +80,60 @@
'type' => 'timestamp',
'name' => 'timestamp',
'default' => 'CURRENT_TIMESTAMP',
- 'on_update' => 'CURRENT_TIMESTAMP',
- 'unsigned' => false,
- 'disabled' => false,
+ 'on_update' => 'true',
],
'datetime' => [
'type' => 'datetime',
'name' => 'datetime',
'default' => '0',
- 'unsigned' => false,
- 'disabled' => false,
],
'longtext' => [
'type' => 'longtext',
'name' => 'longtext',
'length' => '111111111111',
- 'nullable' => true,
- 'unsigned' => false,
- 'disabled' => false,
],
'mediumtext' => [
'type' => 'mediumtext',
'name' => 'mediumtext',
'length' => '11222222',
- 'nullable' => true,
- 'unsigned' => false,
- 'disabled' => false,
],
'varchar' => [
'type' => 'varchar',
'name' => 'varchar',
'length' => '254',
- 'nullable' => true,
- 'unsigned' => false,
- 'disabled' => false,
+ 'nullable' => 'true',
],
'mediumblob' => [
'type' => 'mediumblob',
'name' => 'mediumblob',
'length' => '1122222',
- 'nullable' => true,
- 'unsigned' => false,
- 'disabled' => false,
],
'blob' => [
'type' => 'blob',
'name' => 'blob',
'length' => '1122',
- 'nullable' => true,
- 'unsigned' => false,
- 'disabled' => false,
],
'boolean' => [
'type' => 'boolean',
'name' => 'boolean',
- 'nullable' => true,
- 'unsigned' => false,
- 'disabled' => false,
- 'default' => false,
],
'varbinary_rename' => [
'type' => 'varbinary',
'name' => 'varbinary_rename',
'default' => '10101',
- 'disabled' => true,
+ 'disabled' => 'true',
'renameTo' => 'varbinary_renamed',
- 'nullable' => true,
- 'unsigned' => false,
],
],
'constraint' => [
'some_unique_key' => [
- 'column' => [
- 'smallint' => 'smallint',
- 'bigint' => 'bigint',
- ],
+ 'column' =>
+ [
+ 'smallint' => 'smallint',
+ 'bigint' => 'bigint',
+ ],
'type' => 'unique',
'name' => 'some_unique_key',
- 'nullable' => true,
- 'unsigned' => false,
- 'disabled' => false,
],
'some_foreign_key' => [
'type' => 'foreign',
@@ -190,9 +143,6 @@
'referenceTable' => 'reference_table',
'referenceColumn' => 'tinyint_ref',
'onDelete' => 'NO ACTION',
- 'nullable' => true,
- 'unsigned' => false,
- 'disabled' => false,
],
],
'index' => [
@@ -209,4 +159,4 @@
'resource' => 'sales',
],
],
-];
+];
\ No newline at end of file
diff --git a/dev/tests/setup-integration/testsuite/Magento/Setup/DeclarativeSchemaBuilderTest.php b/dev/tests/setup-integration/testsuite/Magento/Setup/DeclarativeSchemaBuilderTest.php
index 59f798aaaabfe..f9a97f9bea2a0 100644
--- a/dev/tests/setup-integration/testsuite/Magento/Setup/DeclarativeSchemaBuilderTest.php
+++ b/dev/tests/setup-integration/testsuite/Magento/Setup/DeclarativeSchemaBuilderTest.php
@@ -10,6 +10,7 @@
use Magento\Setup\Model\Declaration\Schema\Dto\Columns\Timestamp;
use Magento\Setup\Model\Declaration\Schema\Dto\Constraints\Internal;
use Magento\Setup\Model\Declaration\Schema\Dto\Constraints\Reference;
+use Magento\Setup\Model\Declaration\Schema\Dto\SchemaFactory;
use Magento\Setup\Model\Declaration\Schema\Dto\StructureFactory;
use Magento\TestFramework\Deploy\TestModuleManager;
use Magento\TestFramework\Helper\Bootstrap;
@@ -31,7 +32,7 @@ class DeclarativeSchemaBuilderTest extends SetupTestCase
private $parser;
/**
- * @var StructureFactory
+ * @var SchemaFactory
*/
private $structureFactory;
@@ -39,7 +40,7 @@ public function setUp()
{
$objectManager = Bootstrap::getObjectManager();
$this->parser = $objectManager->create(Parser::class);
- $this->structureFactory = $objectManager->get(StructureFactory::class);
+ $this->structureFactory = $objectManager->get(SchemaFactory::class);
$this->moduleManager = $objectManager->get(TestModuleManager::class);
}
@@ -61,7 +62,7 @@ public function testSchemaBuilder()
//Test column
$testTable = $structure->getTableByName('test_table');
/** @var Timestamp $timestampColumn */
- $timestampColumn = $testTable->getColumnByNameOrId('timestamp');
+ $timestampColumn = $testTable->getColumnByName('timestamp');
self::assertEquals($timestampColumn->getOnUpdate(), 'CURRENT_TIMESTAMP');
//Test disabled
self::assertArrayNotHasKey('varbinary_rename', $testTable->getColumns());
diff --git a/dev/tests/setup-integration/testsuite/Magento/Setup/DiffOldSchemaTest.php b/dev/tests/setup-integration/testsuite/Magento/Setup/DiffOldSchemaTest.php
index 5d435462868ef..e7c64926d9bd6 100644
--- a/dev/tests/setup-integration/testsuite/Magento/Setup/DiffOldSchemaTest.php
+++ b/dev/tests/setup-integration/testsuite/Magento/Setup/DiffOldSchemaTest.php
@@ -9,8 +9,8 @@
use Magento\Setup\Model\Declaration\Schema\ChangeRegistryFactory;
use Magento\Setup\Model\Declaration\Schema\ChangeRegistryInterface;
use Magento\Setup\Model\Declaration\Schema\Db\Parser;
-use Magento\Setup\Model\Declaration\Schema\Diff\StructureDiff;
-use Magento\Setup\Model\Declaration\Schema\Dto\StructureFactory;
+use Magento\Setup\Model\Declaration\Schema\Diff\SchemaDiff;
+use Magento\Setup\Model\Declaration\Schema\Dto\SchemaFactory;
use Magento\TestFramework\Deploy\CliCommand;
use Magento\TestFramework\Deploy\TestModuleManager;
use Magento\TestFramework\Helper\Bootstrap;
@@ -33,9 +33,9 @@ class DiffOldSchemaTest extends SetupTestCase
private $cliCommad;
/**
- * @var StructureFactory
+ * @var SchemaFactory
*/
- private $structureFactory;
+ private $SchemaFactory;
/**
* @var DeclarativeParser
@@ -48,9 +48,9 @@ class DiffOldSchemaTest extends SetupTestCase
private $generatedParser;
/**
- * @var StructureDiff
+ * @var SchemaDiff
*/
- private $structureDiff;
+ private $SchemaDiff;
/**
* @var ChangeRegistryFactory
@@ -60,12 +60,12 @@ class DiffOldSchemaTest extends SetupTestCase
public function setUp()
{
$objectManager = Bootstrap::getObjectManager();
- $this->structureFactory = $objectManager->get(StructureFactory::class);
+ $this->SchemaFactory = $objectManager->get(SchemaFactory::class);
$this->moduleManager = $objectManager->get(TestModuleManager::class);
$this->cliCommad = $objectManager->get(CliCommand::class);
$this->declarativeParser = $objectManager->get(DeclarativeParser::class);
$this->generatedParser = $objectManager->get(Parser::class);
- $this->structureDiff = $objectManager->get(StructureDiff::class);
+ $this->SchemaDiff = $objectManager->get(SchemaDiff::class);
$this->changeRegistryFactory = $objectManager->get(ChangeRegistryFactory::class);
}
@@ -91,11 +91,11 @@ public function testOldDiff()
$this->cliCommad->install(['Magento_TestSetupDeclarationModule1']);
$changeRegistry = $this->changeRegistryFactory->create();
- $generatedStructure = $this->structureFactory->create();
- $declarativeStructure = $this->structureFactory->create();
- $declarativeStructure = $this->declarativeParser->parse($declarativeStructure);
- $generatedStructure = $this->generatedParser->parse($generatedStructure);
- $this->structureDiff->diff($declarativeStructure, $generatedStructure, $changeRegistry);
+ $generatedSchema = $this->SchemaFactory->create();
+ $declarativeSchema = $this->SchemaFactory->create();
+ $declarativeSchema = $this->declarativeParser->parse($declarativeSchema);
+ $generatedSchema = $this->generatedParser->parse($generatedSchema);
+ $this->SchemaDiff->diff($declarativeSchema, $generatedSchema, $changeRegistry);
//Change operations
$changeOperations = $changeRegistry->get(ChangeRegistryInterface::CHANGE_OPERATION);
self::assertCount(1, $changeOperations);
diff --git a/dev/tests/setup-integration/testsuite/Magento/Setup/SchemaReaderTest.php b/dev/tests/setup-integration/testsuite/Magento/Setup/SchemaReaderTest.php
index 17e5e4e9a73a9..f312987e63571 100644
--- a/dev/tests/setup-integration/testsuite/Magento/Setup/SchemaReaderTest.php
+++ b/dev/tests/setup-integration/testsuite/Magento/Setup/SchemaReaderTest.php
@@ -15,16 +15,20 @@
*/
class SchemaReaderTest extends SetupTestCase
{
- /** @var \Magento\Setup\Model\Declaration\Schema\FileSystem\Reader */
+ /**
+ * @var \Magento\Setup\Model\Declaration\Schema\FileSystem\XmlReader
+ */
private $reader;
- /** @var TestModuleManager */
+ /**
+ * @var TestModuleManager
+ */
private $moduleManager;
public function setUp()
{
$objectManager = Bootstrap::getObjectManager();
- $this->reader = $objectManager->get(\Magento\Setup\Model\Declaration\Schema\FileSystem\Reader::class);
+ $this->reader = $objectManager->get(\Magento\Setup\Model\Declaration\Schema\FileSystem\XmlReader::class);
$this->moduleManager = $objectManager->get(TestModuleManager::class);
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/ChangeRegistry.php b/setup/src/Magento/Setup/Model/Declaration/Schema/ChangeRegistry.php
index 346c2d816624f..c9ae664ac9549 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/ChangeRegistry.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/ChangeRegistry.php
@@ -8,7 +8,7 @@
use Magento\Framework\Component\ComponentRegistrar;
use Magento\Setup\Model\Declaration\Schema\Dto\ElementInterface;
-use Magento\Setup\Model\Declaration\Schema\Dto\Structure;
+use Magento\Setup\Model\Declaration\Schema\Dto\Schema;
use Magento\Setup\Model\Declaration\Schema\Dto\TableElementInterface;
/**
@@ -30,9 +30,9 @@ class ChangeRegistry implements ChangeRegistryInterface
private $whiteListTables = [];
/**
- * @var Structure
+ * @var Schema
*/
- private $structure;
+ private $schema;
/**
* @var Request
@@ -142,20 +142,20 @@ public function register(ElementInterface $dtoObject, $type, $operation, Element
/**
* @inheritdoc
*/
- public function registerStructure(Structure $structure)
+ public function registerSchema(Schema $schema)
{
- $this->structure = $structure;
+ $this->schema = $schema;
}
/**
- * Retrieve current structure
+ * Retrieve current schema
* This function needs for rollback functionality
*
- * @return Structure
+ * @return Schema
*/
- public function getCurrentStructureState()
+ public function getCurrentSchemaState()
{
- return $this->structure;
+ return $this->schema;
}
/**
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/ChangeRegistryInterface.php b/setup/src/Magento/Setup/Model/Declaration/Schema/ChangeRegistryInterface.php
index f386a4fd9cd34..06acdfc94942a 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/ChangeRegistryInterface.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/ChangeRegistryInterface.php
@@ -7,7 +7,7 @@
namespace Magento\Setup\Model\Declaration\Schema;
use Magento\Setup\Model\Declaration\Schema\Dto\ElementInterface;
-use Magento\Setup\Model\Declaration\Schema\Dto\Structure;
+use Magento\Setup\Model\Declaration\Schema\Dto\Schema;
/**
* ChangeRegistry is type of classes, that holds all information
@@ -56,19 +56,19 @@ public function register(
);
/**
- * Register current state of structure to registry
+ * Register current state of schema to registry
*
- * @param Structure $structure
+ * @param Schema $schema
* @return void
*/
- public function registerStructure(Structure $structure);
+ public function registerSchema(Schema $schema);
/**
- * Retrieve current structure object
+ * Retrieve current schema object
*
- * @return Structure
+ * @return Schema
*/
- public function getCurrentStructureState();
+ public function getCurrentSchemaState();
/**
* Return current installation request
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Parser.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Parser.php
index ee95e8cd6b008..ae2fcb9b3b671 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Parser.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Parser.php
@@ -6,35 +6,35 @@
namespace Magento\Setup\Model\Declaration\Schema\Db;
-use Magento\Setup\Model\Declaration\Schema\Dto\Structure;
+use Magento\Setup\Model\Declaration\Schema\Dto\Schema;
use Magento\Setup\Model\Declaration\Schema\SchemaParserInterface;
/**
- * Parser is responsible for builind structure.
- * @see Structure
+ * Parser is responsible for builind schema.
+ * @see Schema
*
* @inheritdoc
*/
class Parser implements SchemaParserInterface
{
/**
- * @var StructureBuilder
+ * @var SchemaBuilder
*/
- private $structureBuilder;
+ private $schemaBuilder;
/**
- * @param StructureBuilder $structureBuilder
+ * @param SchemaBuilder $schemaBuilder
*/
- public function __construct(StructureBuilder $structureBuilder)
+ public function __construct(SchemaBuilder $schemaBuilder)
{
- $this->structureBuilder = $structureBuilder;
+ $this->schemaBuilder = $schemaBuilder;
}
/**
* @inheritdoc
*/
- public function parse(Structure $structure)
+ public function parse(Schema $schema)
{
- return $this->structureBuilder->build($structure);
+ return $this->schemaBuilder->build($schema);
}
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/StructureBuilder.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/SchemaBuilder.php
similarity index 94%
rename from setup/src/Magento/Setup/Model/Declaration/Schema/Db/StructureBuilder.php
rename to setup/src/Magento/Setup/Model/Declaration/Schema/Db/SchemaBuilder.php
index ea6387408fcc7..d30774f5eddfc 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/StructureBuilder.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/SchemaBuilder.php
@@ -10,22 +10,22 @@
use Magento\Setup\Model\Declaration\Schema\Db\Processors\DbSchemaReaderInterface;
use Magento\Setup\Model\Declaration\Schema\Dto\Column;
use Magento\Setup\Model\Declaration\Schema\Dto\ElementFactory;
-use Magento\Setup\Model\Declaration\Schema\Dto\Structure;
+use Magento\Setup\Model\Declaration\Schema\Dto\Schema;
use Magento\Setup\Model\Declaration\Schema\Dto\Table;
use Magento\Setup\Model\Declaration\Schema\Sharding;
/**
* This type of builder is responsible for converting ENTIRE data, that comes from db
- * into DTO`s format, with aggregation root: Structure
+ * into DTO`s format, with aggregation root: Schema
*
- * Note: StructureBuilder can not be used for one structural element, like column or constraint
+ * Note: SchemaBuilder can not be used for one structural element, like column or constraint
* because it should have references to other DTO objects.
* In order to convert build only 1 structural element use directly it factory
*
- * @see Structure
+ * @see Schema
* @inheritdoc
*/
-class StructureBuilder
+class SchemaBuilder
{
/**
* @var AdapterMediator
@@ -69,7 +69,7 @@ public function __construct(
/**
* @inheritdoc
*/
- public function build(Structure $structure)
+ public function build(Schema $schema)
{
$tables = [];
@@ -114,11 +114,11 @@ public function build(Structure $structure)
$table->addIndexes($indexes);
$table->addConstraints($constraints);
$tables[$table->getName()] = $table;
- $structure->addTable($table);
+ $schema->addTable($table);
}
$this->processReferenceKeys($tables);
- return $structure;
+ return $schema;
}
/**
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/DynamicStructureInterface.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/DynamicStructureInterface.php
deleted file mode 100644
index 53037acc3a1cb..0000000000000
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/DynamicStructureInterface.php
+++ /dev/null
@@ -1,50 +0,0 @@
- [
- * table => [
- * store_website => [
- * field => [
- * website_id => [
- * type => smallint,
- * unsigned => 1,
- * identity => 1,
- * name => 'website_id'
- * ]
- * ],
- * name => store_website
- * ]
- * ]
- * ]
- *
- * @return array
- */
- public function getStructure();
-}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/Parser.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/Parser.php
index d07db90d6186c..7eaee82e85cb5 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/Parser.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/Parser.php
@@ -6,8 +6,8 @@
namespace Magento\Setup\Model\Declaration\Schema\Declaration;
-use Magento\Setup\Model\Declaration\Schema\Dto\Structure;
-use Magento\Setup\Model\Declaration\Schema\FileSystem\Reader;
+use Magento\Setup\Model\Declaration\Schema\Dto\Schema;
+use Magento\Setup\Model\Declaration\Schema\FileSystem\XmlReader;
use Magento\Setup\Model\Declaration\Schema\SchemaParserInterface;
/**
@@ -16,47 +16,36 @@
class Parser implements SchemaParserInterface
{
/**
- * @var Reader
+ * @var ReaderComposite
*/
- private $reader;
+ private $readerComposite;
/**
- * @var StructureBuilder
+ * @var SchemaBuilder
*/
- private $structureBuilder;
+ private $schemaBuilder;
/**
- * @var DynamicStructureInterface
+ * @param ReaderComposite $readerComposite
+ * @param SchemaBuilder $schemaBuilder
*/
- private $dynamicStructure;
-
- /**
- * @param Reader $reader
- * @param StructureBuilder $structureBuilder
- * @param DynamicStructureInterface $dynamicStructure
- */
- public function __construct(
- Reader $reader,
- StructureBuilder $structureBuilder,
- DynamicStructureInterface $dynamicStructure
- ) {
- $this->reader = $reader;
- $this->structureBuilder = $structureBuilder;
- $this->dynamicStructure = $dynamicStructure;
+ public function __construct(ReaderComposite $readerComposite, SchemaBuilder $schemaBuilder)
+ {
+ $this->readerComposite = $readerComposite;
+ $this->schemaBuilder = $schemaBuilder;
}
/**
- * Convert XML to object representation
+ * Convert data from different sources to object representation
*
- * @param Structure $structure
- * @return Structure
+ * @param Schema $schema
+ * @return Schema
*/
- public function parse(Structure $structure)
+ public function parse(Schema $schema)
{
- $info = $this->reader->read();
- $info = array_replace_recursive($info, $this->dynamicStructure->getStructure());
- $this->structureBuilder->addTablesData($info['table']);
- $structure = $this->structureBuilder->build($structure);
- return $structure;
+ $data = $this->readerComposite->read();
+ $this->schemaBuilder->addTablesData($data['table']);
+ $schema = $this->schemaBuilder->build($schema);
+ return $schema;
}
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/ReaderComposite.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/ReaderComposite.php
new file mode 100644
index 0000000000000..7bf2543ed8691
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/ReaderComposite.php
@@ -0,0 +1,43 @@
+readers = $readers;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function read($scope = null)
+ {
+ $schema = [];
+ foreach ($this->readers as $reader) {
+ $schema = array_replace_recursive($schema, $reader->read($scope));
+ }
+
+ return $schema;
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/StructureBuilder.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/SchemaBuilder.php
similarity index 85%
rename from setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/StructureBuilder.php
rename to setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/SchemaBuilder.php
index 6e0d50f179454..0a1df8d8323d5 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/StructureBuilder.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/SchemaBuilder.php
@@ -9,19 +9,19 @@
use Magento\Setup\Model\Declaration\Schema\Dto\Constraint;
use Magento\Setup\Model\Declaration\Schema\Dto\ElementFactory;
use Magento\Setup\Model\Declaration\Schema\Dto\Index;
-use Magento\Setup\Model\Declaration\Schema\Dto\Structure;
+use Magento\Setup\Model\Declaration\Schema\Dto\Schema;
use Magento\Setup\Model\Declaration\Schema\Dto\Table;
use Magento\Setup\Model\Declaration\Schema\Sharding;
/**
* This type of builder is responsible for converting ENTIRE data, that comes from XML
- * into DTO`s format, with aggregation root: Structure
+ * into DTO`s format, with aggregation root: Schema
*
- * Note: StructureBuilder can not be used for one structural element, like column or constraint
+ * Note: SchemaBuilder can not be used for one structural element, like column or constraint
* because it should have references to other DTO objects.
* In order to convert build only 1 structural element use directly it factory
*/
-class StructureBuilder
+class SchemaBuilder
{
/**
* @var array
@@ -44,7 +44,7 @@ class StructureBuilder
private $booleanUtils;
/**
- * StructureBuilder constructor.
+ * SchemaBuilder constructor.
* @param ElementFactory $elementFactory
* @param BooleanUtils $booleanUtils
* @param Sharding $sharding
@@ -74,22 +74,22 @@ public function addTablesData(array $tablesData)
}
/**
- * Build structure
+ * Build schema
*
- * @param Structure $structure
- * @return Structure
+ * @param Schema $schema
+ * @return Schema
*/
- public function build(Structure $structure)
+ public function build(Schema $schema)
{
foreach ($this->tablesData as $tableData) {
- if (!$structure->getTableByName($tableData['name'])) {
+ if (!$schema->getTableByName($tableData['name'])) {
if (!$this->isDisabled($tableData)) {
- $this->processTable($structure, $tableData);
+ $this->processTable($schema, $tableData);
}
}
}
- return $structure;
+ return $schema;
}
/**
@@ -157,16 +157,16 @@ private function processGenericData(array $elementData, $resource, Table $table)
}
/**
- * Process tables and add them to structure
+ * Process tables and add them to schema
* If table already exists - then we need to skip it
*
- * @param Structure $structure
+ * @param Schema $schema
* @param array $tableData
* @return \Magento\Setup\Model\Declaration\Schema\Dto\Table
*/
- private function processTable(Structure $structure, array $tableData)
+ private function processTable(Schema $schema, array $tableData)
{
- if (!$structure->getTableByName($tableData['name'])) {
+ if (!$schema->getTableByName($tableData['name'])) {
$resource = $this->getStructuralElementResource($tableData);
$tableParams = [
'name' => $tableData['name'],
@@ -176,14 +176,14 @@ private function processTable(Structure $structure, array $tableData)
$table = $this->elementFactory->create('table', $tableParams);
$columns = $this->processColumns($tableData, $resource, $table);
$table->addColumns($columns);
- $structure->addTable($table);
+ $schema->addTable($table);
//Add indexes to table
$table->addIndexes($this->processIndexes($tableData, $resource, $table));
//Add internal and reference constraints
- $table->addConstraints($this->processConstraints($tableData, $resource, $structure));
+ $table->addConstraints($this->processConstraints($tableData, $resource, $schema));
}
- return $structure->getTableByName($tableData['name']);
+ return $schema->getTableByName($tableData['name']);
}
/**
@@ -239,10 +239,10 @@ private function processIndexes(array $tableData, $resource, Table $table)
*
* @param array $tableData
* @param $resource
- * @param Structure $structure
+ * @param Schema $schema
* @return Constraint[]
*/
- private function processConstraints(array $tableData, $resource, Structure $structure)
+ private function processConstraints(array $tableData, $resource, Schema $schema)
{
if (!isset($tableData['constraint'])) {
return [];
@@ -254,21 +254,21 @@ private function processConstraints(array $tableData, $resource, Structure $stru
if ($this->isDisabled($constraintData)) {
continue;
}
- $table = $structure->getTableByName($tableData['name']);
+ $table = $schema->getTableByName($tableData['name']);
$constraintData = $this->processGenericData($constraintData, $resource, $table);
- //As foreign constraint has different structure we need to process it in different way
+ //As foreign constraint has different schema we need to process it in different way
if ($constraintData['type'] === 'foreign') {
$constraintData['column'] = $table->getColumnByName(
$constraintData['column']
);
//always in foreign key name will be old and in raw data will be always old too
- $structure->addTable(
+ $schema->addTable(
$this->processTable(
- $structure,
+ $schema,
$this->tablesData[$constraintData['referenceTable']]
)
);
- $constraintData['referenceTable'] = $structure->getTableByName(
+ $constraintData['referenceTable'] = $schema->getTableByName(
$constraintData['referenceTable']
);
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/Structure/Dynamic.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/Structure/Dynamic.php
deleted file mode 100644
index af42d3cf3f8b5..0000000000000
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/Structure/Dynamic.php
+++ /dev/null
@@ -1,23 +0,0 @@
- then we need to go deeper and inspect each element
* If table exists only in db -> then we need to remove this table
*/
-class StructureDiff
+class SchemaDiff
{
/**
* @var TableDiff
@@ -42,18 +42,18 @@ public function __construct(
}
/**
- * @param Structure $structure
- * @param Structure $generatedStructure
+ * @param Schema $schema
+ * @param Schema $generatedSchema
* @param ChangeRegistry $changeRegistry
*/
public function diff(
- Structure $structure,
- Structure $generatedStructure,
+ Schema $schema,
+ Schema $generatedSchema,
ChangeRegistry $changeRegistry
) {
- $generatedTables = $generatedStructure->getTables();
+ $generatedTables = $generatedSchema->getTables();
- foreach ($structure->getTables() as $name => $table) {
+ foreach ($schema->getTables() as $name => $table) {
if ($this->diffManager->shouldBeCreated($generatedTables, $table)) {
$this->diffManager->registerCreation($changeRegistry, $table);
} else {
@@ -64,7 +64,7 @@ public function diff(
}
//Removal process
if ($this->diffManager->shouldBeRemoved($generatedTables)) {
- $this->diffManager->registerRemoval($changeRegistry, $generatedTables, $structure->getTables());
+ $this->diffManager->registerRemoval($changeRegistry, $generatedTables, $schema->getTables());
}
}
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/TableDiff.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/TableDiff.php
index 2abbfb4a9fd96..8d5cb0a753d7c 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/TableDiff.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/TableDiff.php
@@ -77,7 +77,7 @@ public function diff(
$this->diffManager
->registerModification($changeRegistry, $element, $generatedElements[$element->getName()]);
}
- //Unset processed elements from generated from db structure
+ //Unset processed elements from generated from db schema
//All other unprocessed elements will be added as removed ones
unset($generatedElements[$element->getName()]);
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Structure.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Schema.php
similarity index 91%
rename from setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Structure.php
rename to setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Schema.php
index fef2923f18ec8..bc34bbdc69ec5 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Structure.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Schema.php
@@ -6,10 +6,10 @@
namespace Magento\Setup\Model\Declaration\Schema\Dto;
/**
- * Structure is aggregation root, which holds all structural elements
+ * Schema is aggregation root, which holds all structural elements
* and allow access to tables by their names
*/
-class Structure
+class Schema
{
/**
* @var Table[]
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/StructureFactory.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/SchemaFactory.php
similarity index 82%
rename from setup/src/Magento/Setup/Model/Declaration/Schema/Dto/StructureFactory.php
rename to setup/src/Magento/Setup/Model/Declaration/Schema/Dto/SchemaFactory.php
index c88d375785630..0adbec0ca8569 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/StructureFactory.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/SchemaFactory.php
@@ -9,9 +9,9 @@
use Zend\Di\ServiceLocatorInterface;
/**
- * Factory class for @see \Magento\Setup\Model\Declaration\Schema\Dto\Structure
+ * Factory class for @see \Magento\Setup\Model\Declaration\Schema\Dto\Schema
*/
-class StructureFactory
+class SchemaFactory
{
/**
* @var Di
@@ -21,7 +21,7 @@ class StructureFactory
/**
* @var string
*/
- private $instanceName = Structure::class;
+ private $instanceName = Schema::class;
/**
* EntityFactory constructor.
@@ -36,7 +36,7 @@ public function __construct(Di $zendDi)
* Create class instance with specified parameters
*
* @param array $data
- * @return \Magento\Setup\Model\Declaration\Schema\Dto\Structure | object
+ * @return \Magento\Setup\Model\Declaration\Schema\Dto\Schema | object
*/
public function create(array $data = [])
{
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/FileSystem/Reader.php b/setup/src/Magento/Setup/Model/Declaration/Schema/FileSystem/XmlReader.php
similarity index 95%
rename from setup/src/Magento/Setup/Model/Declaration/Schema/FileSystem/Reader.php
rename to setup/src/Magento/Setup/Model/Declaration/Schema/FileSystem/XmlReader.php
index 7c1cebfa3633b..c450aa195ef13 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/FileSystem/Reader.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/FileSystem/XmlReader.php
@@ -11,7 +11,7 @@
/**
* Class Reader
*/
-class Reader extends \Magento\Framework\Config\Reader\Filesystem implements ReaderInterface
+class XmlReader extends \Magento\Framework\Config\Reader\Filesystem implements ReaderInterface
{
/**
* Attributes by names of which we will do nodes merge
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/SchemaParserInterface.php b/setup/src/Magento/Setup/Model/Declaration/Schema/SchemaParserInterface.php
index 59056b3daf4b2..8eafd0c309505 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/SchemaParserInterface.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/SchemaParserInterface.php
@@ -6,21 +6,21 @@
namespace Magento\Setup\Model\Declaration\Schema;
-use Magento\Setup\Model\Declaration\Schema\Dto\Structure;
+use Magento\Setup\Model\Declaration\Schema\Dto\Schema;
/**
- * Parser hydrate structure object with data from either db or XML file
- * Usually parser use StructureBuilders
+ * Parser hydrate schema object with data from either db or XML file
+ * Usually parser use SchemaBuilders
*
- * Declaration has 2 structure builders, that build schema from db and from XML
+ * Declaration has 2 schema builders, that build schema from db and from XML
*/
interface SchemaParserInterface
{
/**
- * Parse XML or DB changes into structure
+ * Parse XML or DB changes into schema
*
- * @param Structure $structure
+ * @param Schema $schema
* @return mixed
*/
- public function parse(Structure $structure);
+ public function parse(Schema $schema);
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Xml/Converter.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Xml/Converter.php
index f10442a20a90f..bef75250a514b 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Xml/Converter.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Xml/Converter.php
@@ -9,7 +9,7 @@
/**
* This converter serve needs of Declaration Filesystem reader:
- * @see \Magento\Setup\Model\Declaration\Schema\FileSystem\Reader
+ * @see \Magento\Setup\Model\Declaration\Schema\FileSystem\XmlReader
*
* It allows to convert declarative schema to raw array and add default values
* for column types and for constraints
From 55a3dedb56664d5f7af22446e46aba810ce662f7 Mon Sep 17 00:00:00 2001
From: Rostyslav Sabishchenko
Date: Tue, 19 Dec 2017 00:55:53 +0200
Subject: [PATCH 233/904] #12717 - Catalog Products List widget is not
displayed on Storefront (code styling)
---
.../Magento/Catalog/Model/ResourceModel/Eav/Attribute.php | 1 -
.../Magento/CatalogWidget/Model/Rule/Condition/Product.php | 6 +++++-
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Eav/Attribute.php b/app/code/Magento/Catalog/Model/ResourceModel/Eav/Attribute.php
index f713fc79231ec..b29dba4c75665 100644
--- a/app/code/Magento/Catalog/Model/ResourceModel/Eav/Attribute.php
+++ b/app/code/Magento/Catalog/Model/ResourceModel/Eav/Attribute.php
@@ -240,7 +240,6 @@ public function isEnabledInFlat()
return $this->_isEnabledInFlat();
}
-
/**
* Is attribute enabled for flat indexing
*
diff --git a/app/code/Magento/CatalogWidget/Model/Rule/Condition/Product.php b/app/code/Magento/CatalogWidget/Model/Rule/Condition/Product.php
index 9805de0bb8d34..f22879df0ae0c 100644
--- a/app/code/Magento/CatalogWidget/Model/Rule/Condition/Product.php
+++ b/app/code/Magento/CatalogWidget/Model/Rule/Condition/Product.php
@@ -125,7 +125,11 @@ public function addToCollection($collection)
} else {
$alias = 'at_' . $attribute->getAttributeCode();
if (!in_array($alias, array_keys($collection->getSelect()->getPart('from')))) {
- $collection->joinAttribute($attribute->getAttributeCode(), 'catalog_product/'.$attribute->getAttributeCode(), 'entity_id');
+ $collection->joinAttribute(
+ $attribute->getAttributeCode(),
+ 'catalog_product/'.$attribute->getAttributeCode(),
+ 'entity_id'
+ );
}
$this->joinedAttributes[$attribute->getAttributeCode()] = $alias . '.value';
From b9345b902dbb251a1bda256020a0852641227105 Mon Sep 17 00:00:00 2001
From: Sergii Kovalenko
Date: Wed, 20 Dec 2017 11:32:03 +0200
Subject: [PATCH 234/904] MAGETWO-84100: Unify Magento SQL adapters
---
app/etc/di.xml | 13 +-
.../TestFramework/Deploy/CliCommand.php | 7 +-
.../Setup/DeclarativeInstallerTest.php | 90 +++++++++++
.../Setup/Console/Command/InstallCommand.php | 11 ++
.../Schema/ChangeProcessorInterface.php | 22 ---
.../Declaration/Schema/ChangeRegistry.php | 35 +++--
.../Schema/ChangeRegistryInterface.php | 34 ++---
.../Declaration/Schema/Db/AdapterMediator.php | 117 +++++++++++++--
.../Db/Processors/DbSchemaWriterInterface.php | 47 ++++--
.../Db/Processors/MySQL/DbSchemaWriter.php | 141 ++++++++++++++----
.../Declaration/Schema/Diff/DiffManager.php | 17 ++-
.../Declaration/Schema/Diff/SchemaDiff.php | 4 +
.../Model/Declaration/Schema/Dto/Column.php | 22 ++-
.../Declaration/Schema/Dto/Columns/Blob.php | 8 +-
.../Schema/Dto/Columns/Boolean.php | 6 +-
.../Declaration/Schema/Dto/Columns/Date.php | 2 +-
.../Schema/Dto/Columns/Decimal.php | 8 +-
.../Schema/Dto/Columns/Integer.php | 8 +-
.../Declaration/Schema/Dto/Columns/Text.php | 8 +-
.../Schema/Dto/Columns/Timestamp.php | 8 +-
.../Schema/Dto/Columns/Varbinary.php | 8 +-
.../Schema/Dto/Columns/Varchar.php | 8 +-
.../Declaration/Schema/Dto/Constraint.php | 20 ++-
.../Schema/Dto/Constraints/Internal.php | 8 +-
.../Schema/Dto/Constraints/Reference.php | 8 +-
.../Declaration/Schema/Dto/ElementFactory.php | 2 +-
.../Schema/Dto/ElementInterface.php | 13 +-
.../Declaration/Schema/Dto/GenericElement.php | 12 +-
.../Model/Declaration/Schema/Dto/Index.php | 22 ++-
.../Model/Declaration/Schema/Dto/Table.php | 24 ++-
.../Declaration/Schema/ElementHistory.php | 55 +++++++
.../Schema/ElementHistoryFactory.php | 40 +++++
.../Declaration/Schema/OperationInterface.php | 31 ++++
.../Schema/Operations/AddElement.php | 51 +++++++
.../Schema/Operations/CreateTable.php | 54 +++++++
.../Schema/Operations/DropElement.php | 51 +++++++
.../Schema/Operations/DropTable.php | 54 +++++++
.../Schema/Operations/ModifyElement.php | 65 ++++++++
.../Declaration/Schema/OperationsExecutor.php | 46 ++++++
.../Setup/Model/DeclarationInstaller.php | 108 ++++++++++++++
setup/src/Magento/Setup/Model/Installer.php | 14 +-
41 files changed, 1115 insertions(+), 187 deletions(-)
create mode 100644 dev/tests/setup-integration/testsuite/Magento/Setup/DeclarativeInstallerTest.php
delete mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/ChangeProcessorInterface.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/ElementHistory.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/ElementHistoryFactory.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/OperationInterface.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Operations/AddElement.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Operations/CreateTable.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Operations/DropElement.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Operations/DropTable.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Operations/ModifyElement.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/OperationsExecutor.php
create mode 100644 setup/src/Magento/Setup/Model/DeclarationInstaller.php
diff --git a/app/etc/di.xml b/app/etc/di.xml
index 3ea20f1a51ebb..2197f0ff8b458 100755
--- a/app/etc/di.xml
+++ b/app/etc/di.xml
@@ -173,9 +173,9 @@
-
+
@@ -1407,4 +1407,15 @@
+
+
+
+ - Magento\Setup\Model\Declaration\Schema\Operations\CreateTable
+ - Magento\Setup\Model\Declaration\Schema\Operations\DropElement
+ - Magento\Setup\Model\Declaration\Schema\Operations\AddElement
+ - Magento\Setup\Model\Declaration\Schema\Operations\ModifyElement
+ - Magento\Setup\Model\Declaration\Schema\Operations\DropTable
+
+
+
diff --git a/dev/tests/setup-integration/framework/Magento/TestFramework/Deploy/CliCommand.php b/dev/tests/setup-integration/framework/Magento/TestFramework/Deploy/CliCommand.php
index d56f6fff48021..ded5be50fdc3b 100644
--- a/dev/tests/setup-integration/framework/Magento/TestFramework/Deploy/CliCommand.php
+++ b/dev/tests/setup-integration/framework/Magento/TestFramework/Deploy/CliCommand.php
@@ -118,17 +118,18 @@ private function toCliArguments(array $params)
/**
* @param array $modules
- * @throws \Exception
+ * @param array $installParams
* @return string
+ * @throws \Exception
*/
- public function install(array $modules)
+ public function install(array $modules, array $installParams = [])
{
if (empty($modules)) {
throw new \Exception("Cannot install Magento without modules");
}
$params = $this->parametersHolder->getInitParams();
- $installParams = [
+ $installParams += [
InstallCommand::INPUT_KEY_ENABLE_MODULES => implode(",", $modules),
InstallCommand::INPUT_KEY_DISABLE_MODULES => 'all'
];
diff --git a/dev/tests/setup-integration/testsuite/Magento/Setup/DeclarativeInstallerTest.php b/dev/tests/setup-integration/testsuite/Magento/Setup/DeclarativeInstallerTest.php
new file mode 100644
index 0000000000000..f8dafc51ac668
--- /dev/null
+++ b/dev/tests/setup-integration/testsuite/Magento/Setup/DeclarativeInstallerTest.php
@@ -0,0 +1,90 @@
+schemaFactory = $objectManager->get(SchemaFactory::class);
+ $this->moduleManager = $objectManager->get(TestModuleManager::class);
+ $this->cliCommad = $objectManager->get(CliCommand::class);
+ $this->declarativeParser = $objectManager->get(DeclarativeParser::class);
+ $this->generatedParser = $objectManager->get(Parser::class);
+ $this->schemaDiff = $objectManager->get(SchemaDiff::class);
+ $this->changeRegistryFactory = $objectManager->get(ChangeRegistryFactory::class);
+ $this->operationsExecutor = $objectManager->get(OperationsExecutor::class);
+ }
+
+ /**
+ * @moduleName Magento_TestSetupDeclarationModule1
+ */
+ public function testInstallation()
+ {
+ $this->cliCommad->install(
+ ['Magento_TestSetupDeclarationModule1'],
+ [InstallCommand::DECLARATION_MODE_KEY => true]
+ );
+ echo 1;
+ }
+}
diff --git a/setup/src/Magento/Setup/Console/Command/InstallCommand.php b/setup/src/Magento/Setup/Console/Command/InstallCommand.php
index 16cda192a34ed..537e9fbec365f 100644
--- a/setup/src/Magento/Setup/Console/Command/InstallCommand.php
+++ b/setup/src/Magento/Setup/Console/Command/InstallCommand.php
@@ -48,6 +48,11 @@ class InstallCommand extends AbstractSetupCommand
*/
const INPUT_KEY_DISABLE_MODULES = 'disable_modules';
+ /**
+ * This mode allows to install Magento in declarative way
+ */
+ const DECLARATION_MODE_KEY = 'declaration_mode';
+
/**
* Regex for sales_order_increment_prefix validation.
*/
@@ -142,6 +147,12 @@ protected function configure()
InputOption::VALUE_OPTIONAL,
'List of comma-separated module names. That must be avoided during installation.
Avaiable magic param "all".'
+ ),
+ new InputOption(
+ self::DECLARATION_MODE_KEY,
+ null,
+ InputOption::VALUE_OPTIONAL,
+ 'This mode allows to install Magento in declarative way'
)
]);
$this->setName('setup:install')
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/ChangeProcessorInterface.php b/setup/src/Magento/Setup/Model/Declaration/Schema/ChangeProcessorInterface.php
deleted file mode 100644
index ec883925338f3..0000000000000
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/ChangeProcessorInterface.php
+++ /dev/null
@@ -1,22 +0,0 @@
-componentRegistrar = $componentRegistrar;
+ $this->elementHistoryFactory = $elementHistoryFactory;
}
/**
* @inheritdoc
*/
- public function get($operation, $type = null)
+ public function get($operation)
{
- if (empty($type)) {
- return isset($this->changes[$operation]) ? $this->changes[$operation] : [];
- }
-
- return isset($this->changes[$operation][$type]) ? $this->changes[$operation][$type] : [];
+ return isset($this->changes[$operation]) ? $this->changes[$operation] : [];
}
/**
@@ -103,7 +108,7 @@ private function getWhiteListTables()
private function canBeRegistered(ElementInterface $object)
{
$whiteList = $this->getWhiteListTables();
- $type = $object->getElementType();
+ $type = $object->getType();
if ($object instanceof TableElementInterface) {
return isset($whiteList['table'][$object->getTable()->getName()][$type][$object->getName()]);
@@ -124,18 +129,16 @@ public function registerInstallationRequest(Request $request)
/**
* @inheritdoc
*/
- public function register(ElementInterface $dtoObject, $type, $operation, ElementInterface $oldDtoObject = null)
+ public function register(ElementInterface $dtoObject, $operation, ElementInterface $oldDtoObject = null)
{
//Comment until whitelist functionality will be done
if (!$this->canBeRegistered($dtoObject)) {
#return $this; //ignore any operations for non registered elements changes
}
-
- $this->changes[$operation][$type][] = [
- 'new' => $dtoObject,
- 'old' => $oldDtoObject
- ];
-
+ $historyData = ['new' => $dtoObject, 'old' => $oldDtoObject];
+ $history = $this->elementHistoryFactory->create($historyData);
+ //dtoObjects can have 4 types: column, constraint, index, table
+ $this->changes[$operation][] = $history;
return $this;
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/ChangeRegistryInterface.php b/setup/src/Magento/Setup/Model/Declaration/Schema/ChangeRegistryInterface.php
index 06acdfc94942a..62574ff0494c2 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/ChangeRegistryInterface.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/ChangeRegistryInterface.php
@@ -15,42 +15,36 @@
*/
interface ChangeRegistryInterface
{
- /**
- * For elements that needs to be created
- */
- const CREATE_OPERATION = 'create';
-
- /**
- * For elements that needs to be changed
- */
- const CHANGE_OPERATION = 'change';
-
- /**
- * For elements that needs to be removed
- */
- const REMOVE_OPERATION = "remove";
-
/**
* Retrieve operations by type
*
- * @param string $type
+ * Please note: that we wants to save history and we retrieve next structure:
+ * [
+ * 'column_a' => ElementHistory [
+ * 'new' => [
+ * ...
+ * ],
+ * 'old' => [
+ * ...
+ * ]
+ * ]
+ * ]
+ *
* @param string $operation
- * @return array
+ * @return ElementHistory[]
*/
- public function get($operation, $type = null);
+ public function get($operation);
/**
* Register operation
*
* @param ElementInterface|object $dtoObject
- * @param string $type
* @param string $operation
* @param ElementInterface $oldDtoObject
* @return void
*/
public function register(
ElementInterface $dtoObject,
- $type,
$operation,
ElementInterface $oldDtoObject = null
);
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/AdapterMediator.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/AdapterMediator.php
index 8de3935573eae..aee3f12975c03 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/AdapterMediator.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/AdapterMediator.php
@@ -9,8 +9,14 @@
use Magento\Setup\Model\Declaration\Schema\Db\Processors\DbSchemaCreatorInterface;
use Magento\Setup\Model\Declaration\Schema\Db\Processors\DbSchemaProcessorInterface;
use Magento\Setup\Model\Declaration\Schema\Db\Processors\DbSchemaReaderInterface;
+use Magento\Setup\Model\Declaration\Schema\Db\Processors\DbSchemaWriterInterface;
+use Magento\Setup\Model\Declaration\Schema\Dto\Column;
+use Magento\Setup\Model\Declaration\Schema\Dto\Constraint;
use Magento\Setup\Model\Declaration\Schema\Dto\ElementInterface;
+use Magento\Setup\Model\Declaration\Schema\Dto\GenericElement;
+use Magento\Setup\Model\Declaration\Schema\Dto\Index;
use Magento\Setup\Model\Declaration\Schema\Dto\Table;
+use Magento\Setup\Model\Declaration\Schema\Dto\TableElementInterface;
/**
* Needs for different types of SQL engines
@@ -62,23 +68,23 @@ class AdapterMediator
private $dbSchemaReader;
/**
- * @var DbSchemaCreatorInterface
+ * @var DbSchemaWriterInterface
*/
- private $dbSchemaCreator;
+ private $dbSchemaWriter;
/**
* @param DbSchemaReaderInterface $dbSchemaReader
- * @param DbSchemaCreatorInterface $dbSchemaCreator
+ * @param DbSchemaWriterInterface $dbSchemaCreator
* @param array $processors
*/
public function __construct(
DbSchemaReaderInterface $dbSchemaReader,
- DbSchemaCreatorInterface $dbSchemaCreator,
+ DbSchemaWriterInterface $dbSchemaCreator,
array $processors
) {
$this->processors = $processors;
$this->dbSchemaReader = $dbSchemaReader;
- $this->dbSchemaCreator = $dbSchemaCreator;
+ $this->dbSchemaWriter = $dbSchemaCreator;
}
/**
@@ -107,25 +113,108 @@ private function processElementFromDefinition(array $elementData, $type)
* Retrieve definition for all table elements
*
* @param Table $table
- * @return array
+ * @return void
*/
- public function getTableDefinition(Table $table)
+ public function createTable(Table $table)
{
$definition = [];
+ $tableOptions = [
+ 'resource' => $table->getResource(),
+ 'name' => $table->getName()
+ ];
$data = [
- DbSchemaCreatorInterface::COLUMN_FRAGMENT => $table->getColumns(),
- DbSchemaCreatorInterface::CONSTRAINT_FRAGMENT => $table->getConstraints(),
- DbSchemaCreatorInterface::INDEX_FRAGMENT => $table->getIndexes()
+ Column::TYPE => $table->getColumns(),
+ Constraint::TYPE => $table->getConstraints(),
+ Index::TYPE => $table->getIndexes()
];
foreach ($data as $type => $elements) {
/** @var ElementInterface $element */
foreach ($elements as $element) {
- $definition[$type][$element->getName()] = $this->processElementToDefinition($type, $element);
+ $definition[$type][$element->getName()] = $this->processElementToDefinition($element);
}
}
- return $definition;
+ $this->dbSchemaWriter->createTable($tableOptions, $definition);
+ }
+
+ /**
+ * Prepare and add element (column, constraint, index) to table
+ *
+ * @param ElementInterface | TableElementInterface $element
+ * @return void
+ */
+ public function addElement(ElementInterface $element)
+ {
+ $elementOptions = [
+ 'table_name' => $element->getTable()->getResource(),
+ 'element_name' => $element->getName(),
+ 'resource' => $element->getTable()->getResource()
+ ];
+ $definition = $this->processElementToDefinition($element);
+
+ $this->dbSchemaWriter->addElement(
+ $elementOptions,
+ $definition,
+ $element->getElementType()
+ );
+ }
+
+ /**
+ * Prepare and drop element from table
+ *
+ * @param ElementInterface | TableElementInterface $element
+ * @return void
+ */
+ public function dropElement(ElementInterface $element)
+ {
+ $elementOptions = [
+ 'table_name' => $element->getTable()->getResource(),
+ 'element_name' => $element->getName(),
+ 'resource' => $element->getTable()->getResource()
+ ];
+
+ $this->dbSchemaWriter->dropElement(
+ $element->getElementType(),
+ $elementOptions
+ );
+ }
+
+ /**
+ * Modify column definition for existing table
+ *
+ * @param Column $column
+ */
+ public function modifyColumn(Column $column)
+ {
+ $columnOptions = [
+ 'table_name' => $column->getTable()->getResource(),
+ 'element_name' => $column->getName(),
+ 'resource' => $column->getTable()->getResource()
+ ];
+ $definition = $this->processElementToDefinition(
+ $column
+ );
+
+ $this->dbSchemaWriter->modifyColumn(
+ $columnOptions,
+ $definition
+ );
+ }
+
+ /**
+ * Drop table from DB
+ *
+ * @param Table $table
+ */
+ public function dropTable(Table $table)
+ {
+ $tableOptions = [
+ 'name' => $table->getName(),
+ 'resource' => $table->getResource()
+ ];
+
+ $this->dbSchemaWriter->dropTable($tableOptions);
}
/**
@@ -135,11 +224,11 @@ public function getTableDefinition(Table $table)
* @param ElementInterface $element
* @return string
*/
- public function processElementToDefinition($type, ElementInterface $element)
+ public function processElementToDefinition(ElementInterface $element)
{
$definition = '';
/** @var DbSchemaProcessorInterface $processor */
- foreach ($this->processors[$type] as $processor) {
+ foreach ($this->processors[$element->getElementType()] as $processor) {
//One column processor can override or modify existing one
if ($processor->canBeApplied($element)) {
$definition = $processor->toDefinition($element);
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/DbSchemaWriterInterface.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/DbSchemaWriterInterface.php
index 53aaa08281db4..5f23f2f7c92f8 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/DbSchemaWriterInterface.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/DbSchemaWriterInterface.php
@@ -10,29 +10,54 @@
* This class is responsible for read different schema
* structural elements: indexes, constraints, talbe names and columns
*/
-interface DbSchemaCreatorInterface
+interface DbSchemaWriterInterface
{
/**
- * Fragment where primary and unique constraints SQL will be holdeed
+ * Create table from SQL fragments, like columns, constraints, foreign keys, indexes, etc
+ *
+ * @param array $tableOptions
+ * @param array $sqlFragments
+ * @return void
*/
- const CONSTRAINT_FRAGMENT = 'constraint';
+ public function createTable(array $tableOptions, array $sqlFragments);
/**
- * Fragment where COLUMNS SQL will be holded
+ * Drop table from SQL database
+ *
+ * @param array $tableOptions must have 2 options: table_name, resource
+ * @return mixed
*/
- const COLUMN_FRAGMENT = 'column';
+ public function dropTable(array $tableOptions);
/**
- * Fragment where indexes SQL is holded
+ * Add generic element to table (table must be specified in elementOptions)
+ *
+ * Can be: column, constraint, index
+ *
+ * @param array $elementOptions must have 3 options: resource, column_name, table_name
+ * @param string $elementDefinition, for example: like CHAR(200) NOT NULL
+ * @param string $elementType
+ * @return mixed
*/
- const INDEX_FRAGMENT = 'index';
+ public function addElement(array $elementOptions, $elementDefinition, $elementType);
/**
- * Create table from SQL fragments, like columns, constraints, foreign keys, indexes, etc
+ * Modify column and change it definition
*
- * @param array $tableOptions
- * @param array $sqlFragments
+ * Please note: that from all structural elements only column can be modified
+ *
+ * @param array $columnOptions must have 3 options: resource, column_name, table_name
+ * @param string $columnDefinition
* @return void
*/
- public function createTable(array $tableOptions, array $sqlFragments);
+ public function modifyColumn(array $columnOptions, $columnDefinition);
+
+ /**
+ * Drop any element (constraint, column, index) from index
+ *
+ * @param string $elementType enum(CONSTRAINT, INDEX, COLUMN)
+ * @param array $elementOptions
+ * @return \Zend_Db_Statement_Interface
+ */
+ public function dropElement($elementType, array $elementOptions);
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/DbSchemaWriter.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/DbSchemaWriter.php
index f5cd31cb1a804..930fc22494b6f 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/DbSchemaWriter.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/DbSchemaWriter.php
@@ -7,13 +7,14 @@
namespace Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL;
use Magento\Framework\App\ResourceConnection;
-use Magento\Setup\Model\Declaration\Schema\Db\Processors\DbSchemaCreatorInterface;
-use Magento\Setup\Model\Declaration\Schema\Sharding;
+use Magento\Setup\Model\Declaration\Schema\Db\Processors\DbSchemaWriterInterface;
+use Magento\Setup\Model\Declaration\Schema\Dto\Column;
+use Magento\Setup\Model\Declaration\Schema\Dto\Constraint;
/**
* @inheritdoc
*/
-class DbSchemaWriter implements DbSchemaCreatorInterface
+class DbSchemaWriter implements DbSchemaWriterInterface
{
/**
* @var ResourceConnection
@@ -28,28 +29,17 @@ public function __construct(ResourceConnection $resourceConnection)
$this->resourceConnection = $resourceConnection;
}
- /**
- * Prepare constraint statement by compiling name and definition together
- *
- * @param string $name
- * @param string $constraintDefinition
- * @return string
- */
- private function getAddConstraintSQL($name, $constraintDefinition)
- {
- return sprintf('ADD CONSTRAINT %s %s', $name, $constraintDefinition);
- }
-
/**
* Prepare constraint statement by compiling name and definition together
*
* @param string $name
* @param string $indexDefinition
+ * @param string $elementType: can be COLUMN, CONSTRAINT or INDEX
* @return string
*/
- private function getAddIndexSQL($name, $indexDefinition)
+ private function getAddElementSQL($elementType, $name, $indexDefinition)
{
- return sprintf('ADD INDEX %s %s', $name, $indexDefinition);
+ return sprintf('ADD %s %s %s', strtoupper($elementType), $name, $indexDefinition);
}
/**
@@ -61,21 +51,118 @@ private function getAddIndexSQL($name, $indexDefinition)
public function createTable(array $tableOptions, array $definition)
{
$connection = $tableOptions['resource'];
- $indecisSQL = [];
- $constraintsSQL = [];
+ $fragmentsSQL = [];
- foreach ($definition[self::INDEX_FRAGMENT] as $name => $indexDefinition) {
- $indecisSQL[] = $this->getIndexSQL($name, $indexDefinition);
- }
-
- foreach ($definition[self::CONSTRAINT_FRAGMENT] as $name => $constraintDefinition) {
- $constraintsSQL[] = $this->getAddConstraintSQL($name, $constraintDefinition);
+ foreach ([Constraint::TYPE, \Magento\Setup\Model\Declaration\Schema\Dto\Index::TYPE] as $elementType) {
+ if (isset($definition[$elementType])) { //Some element types can be optional
+ //Process indexes definition
+ foreach ($definition[$elementType] as $name => $elementDefinition) {
+ $fragmentsSQL[] = $this->getAddElementSQL($elementType, $name, $elementDefinition);
+ }
+ }
}
$sql = sprintf(
- "CREATE TABLE IF NOT EXISTS %s (\n%s\n)",
+ "CREATE TABLE %s (\n%s\n)",
$tableOptions['name'],
- $definition[self::COLUMN_FRAGMENT]
+ implode(",", $definition[Column::TYPE]),
+ implode(",", $fragmentsSQL)
+ );
+
+ return $this->resourceConnection
+ ->getConnection($connection)
+ ->query($sql);
+ }
+
+ /**
+ * Drop table from MySQL database
+ *
+ * @param array $tableOptions
+ * @return \Zend_Db_Statement_Interface
+ */
+ public function dropTable(array $tableOptions)
+ {
+ $connection = $tableOptions['resource'];
+ $tableName = $tableOptions['name'];
+ $sql = sprintf(
+ 'DROP TABLE %s',
+ $tableName
+ );
+
+ return $this->resourceConnection
+ ->getConnection($connection)
+ ->query($sql);
+ }
+
+ /**
+ * Add element to already existed table
+ * We can add three different elements: column, constraint or index
+ *
+ * @param array $elementOptions should consists from 3 elements: resource, elementname, tablename
+ * @param string $elementDefinition
+ * @param string $elementType
+ * @return \Zend_Db_Statement_Interface
+ */
+ public function addElement(array $elementOptions, $elementDefinition, $elementType)
+ {
+ $connection = $elementOptions['resource'];
+ $elementName = $elementOptions['element_name'];
+ $tableName = $elementOptions['table_name'];
+
+ $sql = sprintf(
+ 'ALTER TABLE %s %s',
+ $tableName,
+ $this->getAddElementSQL($elementType, $elementName, $elementDefinition)
+ );
+
+ return $this->resourceConnection
+ ->getConnection($connection)
+ ->query($sql);
+ }
+
+ /**
+ * Modify column and change it definition
+ *
+ * @param array $columnOptions
+ * @param string $columnDefinition
+ * @return \Zend_Db_Statement_Interface
+ */
+ public function modifyColumn(array $columnOptions, $columnDefinition)
+ {
+ $connection = $columnOptions['resource'];
+ $columName = $columnOptions['element_name'];
+ $tableName = $columnOptions['table_name'];
+
+ $sql = sprintf(
+ 'ALTER TABLE %s MODIFY COLUMN %s %s',
+ $tableName,
+ $columName,
+ $columnDefinition
+ );
+
+ return $this->resourceConnection
+ ->getConnection($connection)
+ ->query($sql);
+ }
+
+ /**
+ * Drop any element (constraint, column, index) from index
+ *
+ * @param string $elementType enum(CONSTRAINT, INDEX, COLUMN)
+ * @param array $elementOptions
+ * @return \Zend_Db_Statement_Interface
+ */
+ public function dropElement($elementType, array $elementOptions)
+ {
+ $connection = $elementOptions['resource'];
+ $elementName = $elementOptions['element_name'];
+ $tableName = $elementOptions['table_name'];
+
+ $sql = sprintf(
+ 'ALTER TABLE %s DROP %s %s',
+ $tableName,
+ strtoupper($elementType),
+ $elementName
);
return $this->resourceConnection
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/DiffManager.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/DiffManager.php
index 0c4fce7d483c9..02424fd5d76c5 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/DiffManager.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/DiffManager.php
@@ -10,6 +10,12 @@
use Magento\Setup\Model\Declaration\Schema\Comparator;
use Magento\Setup\Model\Declaration\Schema\Dto\ElementInterface;
use Magento\Setup\Model\Declaration\Schema\Dto\ElementRenamedInterface;
+use Magento\Setup\Model\Declaration\Schema\Dto\Table;
+use Magento\Setup\Model\Declaration\Schema\Operations\AddElement;
+use Magento\Setup\Model\Declaration\Schema\Operations\CreateTable;
+use Magento\Setup\Model\Declaration\Schema\Operations\DropElement;
+use Magento\Setup\Model\Declaration\Schema\Operations\DropTable;
+use Magento\Setup\Model\Declaration\Schema\Operations\ModifyElement;
/**
* Helper which provide methods, that helps to compare 2 different nodes:
@@ -67,8 +73,7 @@ public function registerModification(
) {
$changeRegistry->register(
$element,
- $element->getElementType(),
- ChangeRegistryInterface::CHANGE_OPERATION,
+ ModifyElement::OPERATION_NAME,
$generatedElement
);
}
@@ -87,6 +92,7 @@ public function registerRemoval(
array $elements
) {
foreach ($generatedElements as $generatedElement) {
+ $operation = $generatedElement instanceof Table ? DropTable::OPERATION_NAME : DropElement::OPERATION_NAME;
if (isset($elements[$generatedElement->getName()])) {
throw new \LogicException(
sprintf(
@@ -98,8 +104,7 @@ public function registerRemoval(
$changeRegistry->register(
$generatedElement,
- $generatedElement->getElementType(),
- ChangeRegistryInterface::REMOVE_OPERATION
+ $operation
);
}
}
@@ -110,10 +115,10 @@ public function registerRemoval(
*/
public function registerCreation(ChangeRegistryInterface $changeRegistry, ElementInterface $element)
{
+ $operation = $element instanceof Table ? CreateTable::OPERATION_NAME : AddElement::OPERATION_NAME;
$changeRegistry->register(
$element,
- $element->getElementType(),
- ChangeRegistryInterface::CREATE_OPERATION
+ $operation
);
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/SchemaDiff.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/SchemaDiff.php
index af7e19be54422..87dbbb1dbbe9e 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/SchemaDiff.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/SchemaDiff.php
@@ -7,6 +7,7 @@
namespace Magento\Setup\Model\Declaration\Schema\Diff;
use Magento\Setup\Model\Declaration\Schema\ChangeRegistry;
+use Magento\Setup\Model\Declaration\Schema\ChangeRegistryInterface;
use Magento\Setup\Model\Declaration\Schema\Dto\Schema;
/**
@@ -45,6 +46,7 @@ public function __construct(
* @param Schema $schema
* @param Schema $generatedSchema
* @param ChangeRegistry $changeRegistry
+ * @return ChangeRegistryInterface
*/
public function diff(
Schema $schema,
@@ -66,5 +68,7 @@ public function diff(
if ($this->diffManager->shouldBeRemoved($generatedTables)) {
$this->diffManager->registerRemoval($changeRegistry, $generatedTables, $schema->getTables());
}
+
+ return $changeRegistry;
}
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Column.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Column.php
index a339b6d7f1540..b9afbb41284cc 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Column.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Column.php
@@ -13,6 +13,12 @@ class Column extends GenericElement implements
ElementInterface,
TableElementInterface
{
+ /**
+ * In case if we will need to change this object: add, modify or drop, we will need
+ * to define it by its type
+ */
+ const TYPE = 'column';
+
/**
* @var Table
*/
@@ -20,25 +26,33 @@ class Column extends GenericElement implements
/**
* @param string $name
- * @param string $elementType
+ * @param string $type
* @param Table $table
*/
public function __construct(
string $name,
- string $elementType,
+ string $type,
Table $table
) {
- parent::__construct($name, $elementType);
+ parent::__construct($name, $type);
$this->table = $table;
}
/**
* Retrieve table name
*
- * @return string
+ * @return Table
*/
public function getTable()
{
return $this->table;
}
+
+ /**
+ * @inheritdoc
+ */
+ public function getElementType()
+ {
+ return self::TYPE;
+ }
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Blob.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Blob.php
index b1af5158a833f..eddb0d7fb851f 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Blob.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Blob.php
@@ -25,17 +25,17 @@ class Blob extends Column implements
/**
* @param string $name
- * @param string $elementType
+ * @param string $type
* @param Table $table
* @param $nullable
*/
public function __construct(
string $name,
- string $elementType,
+ string $type,
Table $table,
bool $nullable = true
) {
- parent::__construct($name, $elementType, $table);
+ parent::__construct($name, $type, $table);
$this->nullable = $nullable;
}
@@ -55,7 +55,7 @@ public function isNullable()
public function getDiffSensitiveParams()
{
return [
- 'type' => $this->getElementType(),
+ 'type' => $this->getType(),
'nullable' => $this->isNullable()
];
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Boolean.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Boolean.php
index a17a74b511352..4942d8bc7fafd 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Boolean.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Boolean.php
@@ -29,19 +29,19 @@ class Boolean extends Column implements
/**
* @param string $name
- * @param string $elementType
+ * @param string $type
* @param Table $table
* @param $nullable
* @param $default
*/
public function __construct(
string $name,
- string $elementType,
+ string $type,
Table $table,
bool $nullable = true,
bool $default = false
) {
- parent::__construct($name, $elementType, $table);
+ parent::__construct($name, $type, $table);
$this->nullable = $nullable;
$this->default = $default;
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Date.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Date.php
index dea4a01448318..01c82c13c1939 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Date.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Date.php
@@ -22,7 +22,7 @@ class Date extends Column implements ElementDiffAwareInterface
public function getDiffSensitiveParams()
{
return [
- 'type' => $this->getElementType()
+ 'type' => $this->getType()
];
}
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Decimal.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Decimal.php
index 47882a98c5a16..9e7da21c7f19b 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Decimal.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Decimal.php
@@ -46,7 +46,7 @@ class Decimal extends Column implements
/**
* @param string $name
- * @param string $elementType
+ * @param string $type
* @param Table $table
* @param int $precission
* @param int $scale
@@ -56,7 +56,7 @@ class Decimal extends Column implements
*/
public function __construct(
string $name,
- string $elementType,
+ string $type,
Table $table,
int $precission,
int $scale,
@@ -64,7 +64,7 @@ public function __construct(
bool $unsigned = false,
float $default = null
) {
- parent::__construct($name, $elementType, $table);
+ parent::__construct($name, $type, $table);
$this->precission = $precission;
$this->scale = $scale;
$this->nullable = $nullable;
@@ -129,7 +129,7 @@ public function isUnsigned()
public function getDiffSensitiveParams()
{
return [
- 'type' => $this->getElementType(),
+ 'type' => $this->getType(),
'nullable' => $this->isNullable(),
'precission' => $this->getPrecission(),
'scale' => $this->getScale(),
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Integer.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Integer.php
index c0050f07c8f36..e3e72badfb03d 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Integer.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Integer.php
@@ -45,7 +45,7 @@ class Integer extends Column implements
/**
* @param string $name
- * @param string $elementType
+ * @param string $type
* @param Table $table
* @param int $padding
* @param bool $nullable
@@ -55,7 +55,7 @@ class Integer extends Column implements
*/
public function __construct(
string $name,
- string $elementType,
+ string $type,
Table $table,
int $padding,
bool $nullable = true,
@@ -63,7 +63,7 @@ public function __construct(
bool $identity = false,
int $default = null
) {
- parent::__construct($name, $elementType, $table);
+ parent::__construct($name, $type, $table);
$this->nullable = $nullable;
$this->default = $default;
$this->unsigned = $unsigned;
@@ -129,7 +129,7 @@ public function isIdentity()
public function getDiffSensitiveParams()
{
return [
- 'type' => $this->getElementType(),
+ 'type' => $this->getType(),
'nullable' => $this->isNullable(),
'padding' => $this->getPadding(),
'unsigned' => $this->isUnsigned(),
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Text.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Text.php
index 4b6dd27044779..b804205359719 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Text.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Text.php
@@ -24,17 +24,17 @@ class Text extends Column implements
/**
* @param string $name
- * @param string $elementType
+ * @param string $type
* @param Table $table
* @param $nullable
*/
public function __construct(
string $name,
- string $elementType,
+ string $type,
Table $table,
bool $nullable = true
) {
- parent::__construct($name, $elementType, $table);
+ parent::__construct($name, $type, $table);
$this->nullable = $nullable;
}
@@ -54,7 +54,7 @@ public function isNullable()
public function getDiffSensitiveParams()
{
return [
- 'type' => $this->getElementType(),
+ 'type' => $this->getType(),
'nullable' => $this->isNullable(),
];
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Timestamp.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Timestamp.php
index 06152da59e6ca..bdab14e91ed11 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Timestamp.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Timestamp.php
@@ -28,19 +28,19 @@ class Timestamp extends Column implements ElementDiffAwareInterface
/**
* @param string $name
- * @param string $elementType
+ * @param string $type
* @param Table $table
* @param string $default
* @param string|null $onUpdate
*/
public function __construct(
string $name,
- string $elementType,
+ string $type,
Table $table,
string $default,
string $onUpdate = null
) {
- parent::__construct($name, $elementType, $table);
+ parent::__construct($name, $type, $table);
$this->default = $default;
$this->onUpdate = $onUpdate;
}
@@ -72,7 +72,7 @@ public function getOnUpdate()
public function getDiffSensitiveParams()
{
return [
- 'type' => $this->getElementType(),
+ 'type' => $this->getType(),
'default' => $this->getDefault(),
'onUpdate' => $this->getOnUpdate()
];
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Varbinary.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Varbinary.php
index 5aeaf34bc4c59..42058319c7c3a 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Varbinary.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Varbinary.php
@@ -35,7 +35,7 @@ class Varbinary extends Column implements
/**
* @param string $name
- * @param string $elementType
+ * @param string $type
* @param Table $table
* @param bool $nullable
* @param int $length
@@ -43,13 +43,13 @@ class Varbinary extends Column implements
*/
public function __construct(
string $name,
- string $elementType,
+ string $type,
Table $table,
int $length,
bool $nullable = true,
int $default = null
) {
- parent::__construct($name, $elementType, $table);
+ parent::__construct($name, $type, $table);
$this->nullable = $nullable;
$this->default = $default;
$this->length = $length;
@@ -92,7 +92,7 @@ public function getLength()
public function getDiffSensitiveParams()
{
return [
- 'type' => $this->getElementType(),
+ 'type' => $this->getType(),
'nullable' => $this->isNullable(),
'default' => $this->getDefault(),
'length' => $this->getLength()
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Varchar.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Varchar.php
index b3d8a2c0a4046..59aff6efa992d 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Varchar.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Varchar.php
@@ -35,7 +35,7 @@ class Varchar extends Column implements
/**
* @param string $name
- * @param string $elementType
+ * @param string $type
* @param Table $table
* @param bool $nullable
* @param int $length
@@ -43,13 +43,13 @@ class Varchar extends Column implements
*/
public function __construct(
string $name,
- string $elementType,
+ string $type,
Table $table,
int $length,
bool $nullable = true,
int $default = null
) {
- parent::__construct($name, $elementType, $table);
+ parent::__construct($name, $type, $table);
$this->nullable = $nullable;
$this->default = $default;
$this->length = $length;
@@ -92,7 +92,7 @@ public function getLength()
public function getDiffSensitiveParams()
{
return [
- 'type' => $this->getElementType(),
+ 'type' => $this->getType(),
'nullable' => $this->isNullable(),
'default' => $this->getDefault(),
'length' => $this->getLength()
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Constraint.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Constraint.php
index 3a59b792f0139..a9ce3731d2a5a 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Constraint.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Constraint.php
@@ -13,6 +13,12 @@ class Constraint extends GenericElement implements
ElementInterface,
TableElementInterface
{
+ /**
+ * In case if we will need to change this object: add, modify or drop, we will need
+ * to define it by its type
+ */
+ const TYPE = 'constraint';
+
/**
* @var Table
*/
@@ -20,16 +26,16 @@ class Constraint extends GenericElement implements
/**
* @param string $name
- * @param string $elementType
+ * @param string $type
* @param Table $table
* @param array $columns
*/
public function __construct(
string $name,
- string $elementType,
+ string $type,
Table $table
) {
- parent::__construct($name, $elementType);
+ parent::__construct($name, $type);
$this->table = $table;
}
@@ -42,4 +48,12 @@ public function getTable()
{
return $this->table;
}
+
+ /**
+ * @inheritdoc
+ */
+ public function getElementType()
+ {
+ return self::TYPE;
+ }
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Constraints/Internal.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Constraints/Internal.php
index 159de09778ead..3b2535fa9e9ef 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Constraints/Internal.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Constraints/Internal.php
@@ -29,17 +29,17 @@ class Internal extends Constraint implements ElementDiffAwareInterface
/**
* Internal constructor.
* @param string $name
- * @param string $elementType
+ * @param string $type
* @param Table $table
* @param array $columns
*/
public function __construct(
$name,
- $elementType,
+ $type,
Table $table,
array $columns
) {
- parent::__construct($name, $elementType, $table);
+ parent::__construct($name, $type, $table);
$this->columns = $columns;
}
@@ -57,7 +57,7 @@ public function getColumns()
public function getDiffSensitiveParams()
{
return [
- 'type' => $this->getElementType(),
+ 'type' => $this->getType(),
'columns' => array_map(
function (Column $column) {
return $column->getName();
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Constraints/Reference.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Constraints/Reference.php
index 175d661346c2f..20e921259df0a 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Constraints/Reference.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Constraints/Reference.php
@@ -37,7 +37,7 @@ class Reference extends Constraint implements ElementDiffAwareInterface
/**
* @param string $name
- * @param string $elementType
+ * @param string $type
* @param Table $table
* @param Column $column
* @param Table $referenceTable
@@ -46,14 +46,14 @@ class Reference extends Constraint implements ElementDiffAwareInterface
*/
public function __construct(
string $name,
- string $elementType,
+ string $type,
Table $table,
Column $column,
Table $referenceTable,
Column $referenceColumn,
string $onDelete
) {
- parent::__construct($name, $elementType, $table);
+ parent::__construct($name, $type, $table);
$this->column = $column;
$this->referenceTable = $referenceTable;
$this->referenceColumn = $referenceColumn;
@@ -105,7 +105,7 @@ public function getOnDelete()
public function getDiffSensitiveParams()
{
return [
- 'type' => $this->getElementType(),
+ 'type' => $this->getType(),
'column' => $this->getColumn()->getName(),
'referenceColumn' => $this->getReferenceColumn()->getName(),
'referenceTableName' => $this->getReferenceTable()->getName(),
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/ElementFactory.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/ElementFactory.php
index 62922012fc947..5fcadce492efc 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/ElementFactory.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/ElementFactory.php
@@ -75,7 +75,7 @@ public function create($type, array $elementStructuralData)
}
$elementStructuralData = $this->castGenericAttributes($elementStructuralData);
- $elementStructuralData['elementType'] = $type;
+ $elementStructuralData['type'] = $type;
return $this->typeFactories[$type]->create($elementStructuralData);
}
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/ElementInterface.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/ElementInterface.php
index 4911dac4688ef..4f23fe6ffaf84 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/ElementInterface.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/ElementInterface.php
@@ -21,7 +21,18 @@ interface ElementInterface
public function getName();
/**
- * Retrieve structural element type: column, constraint, table, index ...
+ * Retrieve element low level type: varchar, char, foreign key, etc..
+ *
+ * @return string
+ */
+ public function getType();
+
+ /**
+ * Retrieve high level type: column, constraint, index, table
+ *
+ * On high level different elements can be created or modified in different ways
+ * So for each high level type of elements were created different operations
+ * And in order to distinguish this types of elements we use this method
*
* @return string
*/
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/GenericElement.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/GenericElement.php
index a0b2af492aa3c..173c69f30187a 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/GenericElement.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/GenericElement.php
@@ -20,7 +20,7 @@ abstract class GenericElement implements
/**
* @var string
*/
- private $elementType;
+ private $type;
/**
* @var string
@@ -29,11 +29,11 @@ abstract class GenericElement implements
/**
* @param string $name
- * @param string $elementType
+ * @param string $type
*/
- public function __construct(string $name, string $elementType)
+ public function __construct(string $name, string $type)
{
- $this->elementType = $elementType;
+ $this->type = $type;
$this->name = $name;
}
@@ -48,8 +48,8 @@ public function getName()
/**
* @inheritdoc
*/
- public function getElementType()
+ public function getType()
{
- return $this->elementType;
+ return $this->type;
}
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Index.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Index.php
index 56bc5dfdf720a..c068ab368df77 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Index.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Index.php
@@ -14,6 +14,12 @@ class Index extends GenericElement implements
TableElementInterface,
ElementDiffAwareInterface
{
+ /**
+ * In case if we will need to change this object: add, modify or drop, we will need
+ * to define it by its type
+ */
+ const TYPE = 'index';
+
/**
* @var Table
*/
@@ -26,17 +32,17 @@ class Index extends GenericElement implements
/**
* @param string $name
- * @param string $elementType
+ * @param string $type
* @param Table $table
* @param array $columns
*/
public function __construct(
string $name,
- string $elementType,
+ string $type,
Table $table,
array $columns
) {
- parent::__construct($name, $elementType);
+ parent::__construct($name, $type);
$this->table = $table;
$this->columns = $columns;
}
@@ -67,7 +73,7 @@ public function getTable()
public function getDiffSensitiveParams()
{
return [
- 'type' => $this->getElementType(),
+ 'type' => $this->getType(),
'columns' => array_map(
function (Column $column) {
return $column->getName();
@@ -76,4 +82,12 @@ function (Column $column) {
)
];
}
+
+ /**
+ * @inheritdoc
+ */
+ public function getElementType()
+ {
+ return self::TYPE;
+ }
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Table.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Table.php
index 48be2264f2992..919e779dc7920 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Table.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Table.php
@@ -15,6 +15,12 @@
*/
class Table extends GenericElement implements ElementInterface
{
+ /**
+ * In case if we will need to change this object: add, modify or drop, we will need
+ * to define it by its type
+ */
+ const TYPE = 'table';
+
/**
* @var Constraint[]
*/
@@ -28,7 +34,7 @@ class Table extends GenericElement implements ElementInterface
/**
* @var string
*/
- protected $elementType = 'table';
+ protected $type = 'table';
/**
* @var Index[]
@@ -42,7 +48,7 @@ class Table extends GenericElement implements ElementInterface
/**
* @param string $name
- * @param string $elementType
+ * @param string $type
* @param string $resource
* @param array $columns
* @param array $indexes
@@ -50,13 +56,13 @@ class Table extends GenericElement implements ElementInterface
*/
public function __construct(
string $name,
- string $elementType,
+ string $type,
string $resource,
array $columns = [],
array $indexes = [],
array $constraints = []
) {
- parent::__construct($name, $elementType);
+ parent::__construct($name, $type);
$this->columns = $columns;
$this->indexes = $indexes;
$this->constraints = $constraints;
@@ -180,7 +186,7 @@ public function getColumnByName($nameOrId)
* Allowed types: columns, constraints, indexes...
*
* @param string $type
- * @return ElementInterface[] | ElementRenamedInterface[]
+ * @return ElementInterface[]
*/
public function getElementsByType($type)
{
@@ -201,4 +207,12 @@ public function addIndexes(array $indexes)
{
$this->indexes = array_replace($this->indexes, $indexes);
}
+
+ /**
+ * @inheritdoc
+ */
+ public function getElementType()
+ {
+ return self::TYPE;
+ }
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/ElementHistory.php b/setup/src/Magento/Setup/Model/Declaration/Schema/ElementHistory.php
new file mode 100644
index 0000000000000..7ae35e0dfb7cd
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/ElementHistory.php
@@ -0,0 +1,55 @@
+new = $new;
+ $this->old = $old;
+ }
+
+ /**
+ * Retrieve element, that exists before we run installation
+ *
+ * @return ElementInterface | null
+ */
+ public function getOld()
+ {
+ return $this->old;
+ }
+
+ /**
+ * Retrieve element, that comes from configuration
+ *
+ * @return ElementInterface
+ */
+ public function getNew()
+ {
+ return $this->new;
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/ElementHistoryFactory.php b/setup/src/Magento/Setup/Model/Declaration/Schema/ElementHistoryFactory.php
new file mode 100644
index 0000000000000..28fe2c1a8907c
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/ElementHistoryFactory.php
@@ -0,0 +1,40 @@
+objectManager = $objectManager;
+ }
+
+ /**
+ * @param array $data
+ * - Should consist of 2 params:
+ * new
+ * old
+ * @return mixed
+ */
+ public function create(array $data)
+ {
+ return $this->objectManager->create(ElementHistory::class, $data);
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/OperationInterface.php b/setup/src/Magento/Setup/Model/Declaration/Schema/OperationInterface.php
new file mode 100644
index 0000000000000..a80033f18f9aa
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/OperationInterface.php
@@ -0,0 +1,31 @@
+adapterMediator = $adapterMediator;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function getOperationName()
+ {
+ return self::OPERATION_NAME;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function doOperation(ElementHistory $elementHistory)
+ {
+ $this->adapterMediator->addElement($elementHistory->getNew());
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/CreateTable.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/CreateTable.php
new file mode 100644
index 0000000000000..b7ceb7612bb4e
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/CreateTable.php
@@ -0,0 +1,54 @@
+adapterMediator = $adapterMediator;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function getOperationName()
+ {
+ return self::OPERATION_NAME;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function doOperation(ElementHistory $elementHistory)
+ {
+ /** @var Table $table */
+ $table = $elementHistory->getNew();
+ $this->adapterMediator->createTable($table);
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/DropElement.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/DropElement.php
new file mode 100644
index 0000000000000..547a116dc0698
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/DropElement.php
@@ -0,0 +1,51 @@
+adapterMediator = $adapterMediator;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function getOperationName()
+ {
+ return self::OPERATION_NAME;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function doOperation(ElementHistory $elementHistory)
+ {
+ $this->adapterMediator->dropElement($elementHistory->getNew());
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/DropTable.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/DropTable.php
new file mode 100644
index 0000000000000..b8f080015e5e9
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/DropTable.php
@@ -0,0 +1,54 @@
+adapterMediator = $adapterMediator;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function getOperationName()
+ {
+ return self::OPERATION_NAME;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function doOperation(ElementHistory $tableHistory)
+ {
+ /** @var Table $table */
+ $table = $tableHistory->getNew();
+ $this->adapterMediator->dropTable($table);
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/ModifyElement.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/ModifyElement.php
new file mode 100644
index 0000000000000..84fa275f1fbbe
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/ModifyElement.php
@@ -0,0 +1,65 @@
+adapterMediator = $adapterMediator;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function getOperationName()
+ {
+ return self::OPERATION_NAME;
+ }
+
+ /**
+ * As constraints and indexes do not have modify operation, we need to substitute it
+ * with remove/create operaions
+ *
+ * @inheritdoc
+ */
+ public function doOperation(ElementHistory $elementHistory)
+ {
+ $element = $elementHistory->getNew();
+
+ if ($element instanceof Constraint || $element instanceof Index) {
+ $this->adapterMediator->dropElement($element);
+ $this->adapterMediator->addElement($element);
+ } else {
+ /** @var Column $element */
+ $this->adapterMediator->modifyColumn($element);
+ }
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/OperationsExecutor.php b/setup/src/Magento/Setup/Model/Declaration/Schema/OperationsExecutor.php
new file mode 100644
index 0000000000000..a780e8458b7d3
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/OperationsExecutor.php
@@ -0,0 +1,46 @@
+operations = $operations;
+ }
+
+ /**
+ * Loop through all operations that are configured in di.xml
+ * and execute them with elements from ChangeRegistyr
+ *
+ * @see OperationInterface
+ * @param ChangeRegistryInterface $changeRegistry
+ * @return void
+ */
+ public function execute(ChangeRegistryInterface $changeRegistry)
+ {
+ foreach ($this->operations as $operation) {
+ $histories = $changeRegistry->get($operation->getOperationName());
+
+ foreach ($histories as $history) {
+ $operation->doOperation($history);
+ }
+ }
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/DeclarationInstaller.php b/setup/src/Magento/Setup/Model/DeclarationInstaller.php
new file mode 100644
index 0000000000000..ca85451929c94
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/DeclarationInstaller.php
@@ -0,0 +1,108 @@
+declarationParser = $declarativeParser;
+ $this->structureFactory = $structureFactory;
+ $this->operationsExecutor = $operationsExecutor;
+ $this->generatedParser = $generatedParser;
+ $this->schemaDiff = $structureDiff;
+ $this->changeRegistryFactory = $changeRegistryFactory;
+ $this->requestFactory = $requestFactory;
+ $this->declarativeParser = $declarativeParser;
+ }
+
+ /**
+ * Install Schema in declarative way
+ *
+ * @param array $requestData -> Data params which comes from UI or from CLI
+ * @return void
+ */
+ public function installSchema(array $requestData)
+ {
+ $changeRegistry = $this->changeRegistryFactory->create();
+ $schema = $this->structureFactory->create();
+ $generatedStructure = $this->structureFactory->create();
+ $this->declarationParser->parse($schema);
+ $this->generatedParser->parse($generatedStructure);
+ $this->schemaDiff->diff($schema, $generatedStructure, $changeRegistry);
+ $changeRegistry->registerSchema($schema);
+ $changeRegistry->registerInstallationRequest(
+ $this->requestFactory->create($requestData)
+ );
+ $this->operationsExecutor->execute($changeRegistry);
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Installer.php b/setup/src/Magento/Setup/Model/Installer.php
index 66faab9ffc658..1fd80a987c8c3 100644
--- a/setup/src/Magento/Setup/Model/Installer.php
+++ b/setup/src/Magento/Setup/Model/Installer.php
@@ -314,7 +314,7 @@ public function install($request)
if (!empty($request[InstallCommand::INPUT_KEY_CLEANUP_DB])) {
$script[] = ['Cleaning up database...', 'cleanupDb', []];
}
- $script[] = ['Installing database schema:', 'installSchema', []];
+ $script[] = ['Installing database schema:', 'installSchema', [$request]];
$script[] = ['Installing user configuration...', 'installUserConfig', [$request]];
$script[] = ['Enabling caches:', 'enableCaches', []];
$script[] = ['Installing data...', 'installDataFixtures', []];
@@ -762,9 +762,10 @@ private function setupFlagTable(
/**
* Installs DB schema
*
+ * @param array $request
* @return void
*/
- public function installSchema()
+ public function installSchema(array $request)
{
$this->assertDbConfigExists();
$this->assertDbAccessible();
@@ -772,7 +773,14 @@ public function installSchema()
$this->setupModuleRegistry($setup);
$this->setupCoreTables($setup);
$this->log->log('Schema creation/updates:');
- $this->handleDBSchemaData($setup, 'schema');
+
+ if ($request[InstallCommand::DECLARATION_MODE_KEY]) {
+ /** @var DeclarationInstaller $declarativeInstaller */
+ $declarativeInstaller = $this->objectManagerProvider->get()->get(DeclarationInstaller::class);
+ $declarativeInstaller->installSchema($request);
+ } else {
+ $this->handleDBSchemaData($setup, 'schema');
+ }
}
/**
From f228e3b061780ee284c69407b696a682c4dc23fb Mon Sep 17 00:00:00 2001
From: Sergii Kovalenko
Date: Wed, 20 Dec 2017 12:59:44 +0200
Subject: [PATCH 235/904] MAGETWO-83201: Creating Diff artifacts between
arbitrary Declarative Schemas
--refactor configs
---
app/etc/di.xml | 1 +
.../etc/db_schema.xml | 4 +-
.../Setup/DeclarativeSchemaBuilderTest.php | 27 +++----
.../Magento/Setup/DiffOldSchemaTest.php | 52 +++++--------
.../Magento/Setup/SchemaReaderTest.php | 3 +-
setup/config/di.config.php | 2 +-
.../Schema/ChangeProcessorInterface.php | 6 +-
.../Model/Declaration/Schema/Db/Parser.php | 40 ----------
.../Declaration/Schema/Declaration/Parser.php | 51 ------------
.../{ChangeRegistry.php => Diff/Diff.php} | 5 +-
.../DiffFactory.php} | 10 +--
.../DiffInterface.php} | 7 +-
.../Declaration/Schema/Diff/DiffManager.php | 27 ++++---
.../Declaration/Schema/Diff/SchemaDiff.php | 25 ++++--
.../Declaration/Schema/Diff/TableDiff.php | 8 +-
.../Declaration/Schema/DiffInterface.php | 30 -------
.../Schema/Dto/Factories/Timestamp.php | 9 ++-
.../Model/Declaration/Schema/SchemaConfig.php | 78 +++++++++++++++++++
...nterface.php => SchemaConfigInterface.php} | 16 ++--
19 files changed, 176 insertions(+), 225 deletions(-)
delete mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Db/Parser.php
delete mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/Parser.php
rename setup/src/Magento/Setup/Model/Declaration/Schema/{ChangeRegistry.php => Diff/Diff.php} (96%)
rename setup/src/Magento/Setup/Model/Declaration/Schema/{ChangeRegistryFactory.php => Diff/DiffFactory.php} (74%)
rename setup/src/Magento/Setup/Model/Declaration/Schema/{ChangeRegistryInterface.php => Diff/DiffInterface.php} (90%)
delete mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/DiffInterface.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/SchemaConfig.php
rename setup/src/Magento/Setup/Model/Declaration/Schema/{SchemaParserInterface.php => SchemaConfigInterface.php} (65%)
diff --git a/app/etc/di.xml b/app/etc/di.xml
index ee274b733d448..2c752654b7efc 100755
--- a/app/etc/di.xml
+++ b/app/etc/di.xml
@@ -176,6 +176,7 @@
+
diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/etc/db_schema.xml b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/etc/db_schema.xml
index 1414cbcc1b99c..443616fd9d188 100644
--- a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/etc/db_schema.xml
+++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/etc/db_schema.xml
@@ -7,7 +7,7 @@
-->
-
+
@@ -29,7 +29,7 @@
-
+
diff --git a/dev/tests/setup-integration/testsuite/Magento/Setup/DeclarativeSchemaBuilderTest.php b/dev/tests/setup-integration/testsuite/Magento/Setup/DeclarativeSchemaBuilderTest.php
index f9a97f9bea2a0..e4def33f5c8cd 100644
--- a/dev/tests/setup-integration/testsuite/Magento/Setup/DeclarativeSchemaBuilderTest.php
+++ b/dev/tests/setup-integration/testsuite/Magento/Setup/DeclarativeSchemaBuilderTest.php
@@ -6,12 +6,10 @@
namespace Magento\Setup;
-use Magento\Setup\Model\Declaration\Schema\Declaration\Parser;
use Magento\Setup\Model\Declaration\Schema\Dto\Columns\Timestamp;
use Magento\Setup\Model\Declaration\Schema\Dto\Constraints\Internal;
use Magento\Setup\Model\Declaration\Schema\Dto\Constraints\Reference;
-use Magento\Setup\Model\Declaration\Schema\Dto\SchemaFactory;
-use Magento\Setup\Model\Declaration\Schema\Dto\StructureFactory;
+use Magento\Setup\Model\Declaration\Schema\SchemaConfig;
use Magento\TestFramework\Deploy\TestModuleManager;
use Magento\TestFramework\Helper\Bootstrap;
use Magento\TestFramework\TestCase\SetupTestCase;
@@ -27,20 +25,14 @@ class DeclarativeSchemaBuilderTest extends SetupTestCase
private $moduleManager;
/**
- * @var Parser
+ * @var SchemaConfig
*/
- private $parser;
-
- /**
- * @var SchemaFactory
- */
- private $structureFactory;
+ private $schemaConfig;
public function setUp()
{
$objectManager = Bootstrap::getObjectManager();
- $this->parser = $objectManager->create(Parser::class);
- $this->structureFactory = $objectManager->get(SchemaFactory::class);
+ $this->schemaConfig = $objectManager->create(SchemaConfig::class);
$this->moduleManager = $objectManager->get(TestModuleManager::class);
}
@@ -51,16 +43,15 @@ public function setUp()
*/
public function testSchemaBuilder()
{
- $structure = $this->structureFactory->create();
- $structure = $this->parser->parse($structure);
+ $dbSchema = $this->schemaConfig->getDeclarationConfig();
//Test primary key and renaming
- $referenceTable = $structure->getTableByName('reference_table');
+ $referenceTable = $dbSchema->getTableByName('reference_table');
/** @var Internal $primaryKey */
$primaryKey = $referenceTable->getPrimaryConstraint();
$columns = $primaryKey->getColumns();
- self::assertEquals(reset($columns)->getName(), 'tinyintref_2');
+ self::assertEquals(reset($columns)->getName(), 'tinyint_ref');
//Test column
- $testTable = $structure->getTableByName('test_table');
+ $testTable = $dbSchema->getTableByName('test_table');
/** @var Timestamp $timestampColumn */
$timestampColumn = $testTable->getColumnByName('timestamp');
self::assertEquals($timestampColumn->getOnUpdate(), 'CURRENT_TIMESTAMP');
@@ -70,6 +61,6 @@ public function testSchemaBuilder()
/** @var Reference $foreignKey */
$foreignKey = $testTable->getConstraintByName('some_foreign_key');
self::assertEquals($foreignKey->getOnDelete(), 'NO ACTION');
- self::assertEquals($foreignKey->getReferenceColumn()->getName(), 'tinyintref_2');
+ self::assertEquals($foreignKey->getReferenceColumn()->getName(), 'tinyint_ref');
}
}
diff --git a/dev/tests/setup-integration/testsuite/Magento/Setup/DiffOldSchemaTest.php b/dev/tests/setup-integration/testsuite/Magento/Setup/DiffOldSchemaTest.php
index e7c64926d9bd6..ee99c557c9e75 100644
--- a/dev/tests/setup-integration/testsuite/Magento/Setup/DiffOldSchemaTest.php
+++ b/dev/tests/setup-integration/testsuite/Magento/Setup/DiffOldSchemaTest.php
@@ -6,16 +6,15 @@
namespace Magento\Setup;
-use Magento\Setup\Model\Declaration\Schema\ChangeRegistryFactory;
-use Magento\Setup\Model\Declaration\Schema\ChangeRegistryInterface;
-use Magento\Setup\Model\Declaration\Schema\Db\Parser;
+use Magento\Setup\Model\Declaration\Schema\Diff\DiffFactory;
+use Magento\Setup\Model\Declaration\Schema\Diff\DiffInterface;
+use Magento\Setup\Model\Declaration\Schema\SchemaConfig;
use Magento\Setup\Model\Declaration\Schema\Diff\SchemaDiff;
-use Magento\Setup\Model\Declaration\Schema\Dto\SchemaFactory;
+use Magento\Setup\Model\Declaration\Schema\SchemaConfigInterface;
use Magento\TestFramework\Deploy\CliCommand;
use Magento\TestFramework\Deploy\TestModuleManager;
use Magento\TestFramework\Helper\Bootstrap;
use Magento\TestFramework\TestCase\SetupTestCase;
-use \Magento\Setup\Model\Declaration\Schema\Declaration\Parser as DeclarativeParser;
/**
* The purpose of this test is verifying initial InstallSchema, InstallData scripts
@@ -33,40 +32,28 @@ class DiffOldSchemaTest extends SetupTestCase
private $cliCommad;
/**
- * @var SchemaFactory
- */
- private $SchemaFactory;
-
- /**
- * @var DeclarativeParser
- */
- private $declarativeParser;
-
- /**
- * @var Parser
+ * @var SchemaDiff
*/
- private $generatedParser;
+ private $schemaDiff;
/**
- * @var SchemaDiff
+ * @var DiffFactory
*/
- private $SchemaDiff;
+ private $changeRegistryFactory;
/**
- * @var ChangeRegistryFactory
+ * @var SchemaConfigInterface
*/
- private $changeRegistryFactory;
+ private $schemaConfig;
public function setUp()
{
$objectManager = Bootstrap::getObjectManager();
- $this->SchemaFactory = $objectManager->get(SchemaFactory::class);
$this->moduleManager = $objectManager->get(TestModuleManager::class);
$this->cliCommad = $objectManager->get(CliCommand::class);
- $this->declarativeParser = $objectManager->get(DeclarativeParser::class);
- $this->generatedParser = $objectManager->get(Parser::class);
- $this->SchemaDiff = $objectManager->get(SchemaDiff::class);
- $this->changeRegistryFactory = $objectManager->get(ChangeRegistryFactory::class);
+ $this->schemaConfig = $objectManager->get(SchemaConfigInterface::class);
+ $this->schemaDiff = $objectManager->get(SchemaDiff::class);
+ $this->changeRegistryFactory = $objectManager->get(DiffFactory::class);
}
/**
@@ -90,14 +77,11 @@ public function testOldDiff()
);
$this->cliCommad->install(['Magento_TestSetupDeclarationModule1']);
- $changeRegistry = $this->changeRegistryFactory->create();
- $generatedSchema = $this->SchemaFactory->create();
- $declarativeSchema = $this->SchemaFactory->create();
- $declarativeSchema = $this->declarativeParser->parse($declarativeSchema);
- $generatedSchema = $this->generatedParser->parse($generatedSchema);
- $this->SchemaDiff->diff($declarativeSchema, $generatedSchema, $changeRegistry);
+ $declarativeSchema = $this->schemaConfig->getDeclarationConfig();
+ $generatedSchema = $this->schemaConfig->getDbConfig();
+ $diff = $this->schemaDiff->diff($declarativeSchema, $generatedSchema);
//Change operations
- $changeOperations = $changeRegistry->get(ChangeRegistryInterface::CHANGE_OPERATION);
+ $changeOperations = $diff->get(DiffInterface::CHANGE_OPERATION);
self::assertCount(1, $changeOperations);
self::assertEquals(
$this->getBigIntKeyXmlSensitiveData(),
@@ -109,7 +93,7 @@ public function testOldDiff()
);
self::assertCount(
5,
- $changeRegistry->get(ChangeRegistryInterface::REMOVE_OPERATION)['table']
+ $diff->get(DiffInterface::REMOVE_OPERATION)['table']
);
}
diff --git a/dev/tests/setup-integration/testsuite/Magento/Setup/SchemaReaderTest.php b/dev/tests/setup-integration/testsuite/Magento/Setup/SchemaReaderTest.php
index f312987e63571..843f5c1fc45b9 100644
--- a/dev/tests/setup-integration/testsuite/Magento/Setup/SchemaReaderTest.php
+++ b/dev/tests/setup-integration/testsuite/Magento/Setup/SchemaReaderTest.php
@@ -6,6 +6,7 @@
namespace Magento\Setup;
+use Magento\Setup\Model\Declaration\Schema\Declaration\ReaderComposite;
use Magento\TestFramework\Deploy\TestModuleManager;
use Magento\TestFramework\Helper\Bootstrap;
use Magento\TestFramework\TestCase\SetupTestCase;
@@ -28,7 +29,7 @@ class SchemaReaderTest extends SetupTestCase
public function setUp()
{
$objectManager = Bootstrap::getObjectManager();
- $this->reader = $objectManager->get(\Magento\Setup\Model\Declaration\Schema\FileSystem\XmlReader::class);
+ $this->reader = $objectManager->get(ReaderComposite::class);
$this->moduleManager = $objectManager->get(TestModuleManager::class);
}
diff --git a/setup/config/di.config.php b/setup/config/di.config.php
index b707352ba6b52..bd8c19f2aea58 100644
--- a/setup/config/di.config.php
+++ b/setup/config/di.config.php
@@ -56,7 +56,7 @@
\Magento\Framework\Component\ComponentRegistrarInterface::class =>
\Magento\Framework\Component\ComponentRegistrar::class,
],
- \Magento\Setup\Model\Declaration\Schema\Db\Parser::class => [
+ \Magento\Setup\Model\Declaration\Schema\Db\Config::class => [
'parameters' => [
'connectionScopes' => [
'default',
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/ChangeProcessorInterface.php b/setup/src/Magento/Setup/Model/Declaration/Schema/ChangeProcessorInterface.php
index ec883925338f3..6eb2379d1d7a5 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/ChangeProcessorInterface.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/ChangeProcessorInterface.php
@@ -6,6 +6,8 @@
namespace Magento\Setup\Model\Declaration\Schema;
+use Magento\Setup\Model\Declaration\Schema\Diff\Diff;
+
/**
* With help of ChangeProcessorInterface you can go thorugh all element types
* and apply difference, that is persisted in ChangeRegistry
@@ -15,8 +17,8 @@ interface ChangeProcessorInterface
/**
* Apply change of any type
*
- * @param ChangeRegistryInterface $changeRegistry
+ * @param Diff $changeRegistry
* @return void
*/
- public function apply(ChangeRegistryInterface $changeRegistry);
+ public function apply(Diff $changeRegistry);
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Parser.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Parser.php
deleted file mode 100644
index ae2fcb9b3b671..0000000000000
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Parser.php
+++ /dev/null
@@ -1,40 +0,0 @@
-schemaBuilder = $schemaBuilder;
- }
-
- /**
- * @inheritdoc
- */
- public function parse(Schema $schema)
- {
- return $this->schemaBuilder->build($schema);
- }
-}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/Parser.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/Parser.php
deleted file mode 100644
index 7eaee82e85cb5..0000000000000
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/Parser.php
+++ /dev/null
@@ -1,51 +0,0 @@
-readerComposite = $readerComposite;
- $this->schemaBuilder = $schemaBuilder;
- }
-
- /**
- * Convert data from different sources to object representation
- *
- * @param Schema $schema
- * @return Schema
- */
- public function parse(Schema $schema)
- {
- $data = $this->readerComposite->read();
- $this->schemaBuilder->addTablesData($data['table']);
- $schema = $this->schemaBuilder->build($schema);
- return $schema;
- }
-}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/ChangeRegistry.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/Diff.php
similarity index 96%
rename from setup/src/Magento/Setup/Model/Declaration/Schema/ChangeRegistry.php
rename to setup/src/Magento/Setup/Model/Declaration/Schema/Diff/Diff.php
index c9ae664ac9549..a384e9e430178 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/ChangeRegistry.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/Diff.php
@@ -4,12 +4,13 @@
* See COPYING.txt for license details.
*/
-namespace Magento\Setup\Model\Declaration\Schema;
+namespace Magento\Setup\Model\Declaration\Schema\Diff;
use Magento\Framework\Component\ComponentRegistrar;
use Magento\Setup\Model\Declaration\Schema\Dto\ElementInterface;
use Magento\Setup\Model\Declaration\Schema\Dto\Schema;
use Magento\Setup\Model\Declaration\Schema\Dto\TableElementInterface;
+use Magento\Setup\Model\Declaration\Schema\Request;
/**
* Holds information about all changes between 2 schemas: db and declaration XML
@@ -17,7 +18,7 @@
* - new (Should be changed to)
* - old (Was)
*/
-class ChangeRegistry implements ChangeRegistryInterface
+class Diff implements DiffInterface
{
/**
* @var array
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/ChangeRegistryFactory.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/DiffFactory.php
similarity index 74%
rename from setup/src/Magento/Setup/Model/Declaration/Schema/ChangeRegistryFactory.php
rename to setup/src/Magento/Setup/Model/Declaration/Schema/Diff/DiffFactory.php
index 1f565afe08e71..c04474d8f5736 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/ChangeRegistryFactory.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/DiffFactory.php
@@ -4,16 +4,16 @@
* See COPYING.txt for license details.
*/
-namespace Magento\Setup\Model\Declaration\Schema;
+namespace Magento\Setup\Model\Declaration\Schema\Diff;
use Magento\Framework\ObjectManagerInterface;
use Zend\Di\ServiceLocatorInterface;
use Zend\ServiceManager\ServiceManager;
/**
- * @see ChangeRegistryInterface
+ * @see DiffInterface
*/
-class ChangeRegistryFactory
+class DiffFactory
{
/**
* @var ObjectManagerInterface
@@ -30,10 +30,10 @@ public function __construct(ObjectManagerInterface $objectManager)
}
/**
- * @return ChangeRegistryInterface
+ * @return Diff
*/
public function create()
{
- return $this->objectManager->create(ChangeRegistry::class);
+ return $this->objectManager->create(Diff::class);
}
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/ChangeRegistryInterface.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/DiffInterface.php
similarity index 90%
rename from setup/src/Magento/Setup/Model/Declaration/Schema/ChangeRegistryInterface.php
rename to setup/src/Magento/Setup/Model/Declaration/Schema/Diff/DiffInterface.php
index 06acdfc94942a..871a494cf629c 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/ChangeRegistryInterface.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/DiffInterface.php
@@ -4,16 +4,17 @@
* See COPYING.txt for license details.
*/
-namespace Magento\Setup\Model\Declaration\Schema;
+namespace Magento\Setup\Model\Declaration\Schema\Diff;
use Magento\Setup\Model\Declaration\Schema\Dto\ElementInterface;
use Magento\Setup\Model\Declaration\Schema\Dto\Schema;
+use Magento\Setup\Model\Declaration\Schema\Request;
/**
- * ChangeRegistry is type of classes, that holds all information
+ * DiffInterface is type of classes, that holds all information
* that need to be changed from one installation to another
*/
-interface ChangeRegistryInterface
+interface DiffInterface
{
/**
* For elements that needs to be created
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/DiffManager.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/DiffManager.php
index 0c4fce7d483c9..31c65ed2ceffa 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/DiffManager.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/DiffManager.php
@@ -6,10 +6,8 @@
namespace Magento\Setup\Model\Declaration\Schema\Diff;
-use Magento\Setup\Model\Declaration\Schema\ChangeRegistryInterface;
use Magento\Setup\Model\Declaration\Schema\Comparator;
use Magento\Setup\Model\Declaration\Schema\Dto\ElementInterface;
-use Magento\Setup\Model\Declaration\Schema\Dto\ElementRenamedInterface;
/**
* Helper which provide methods, that helps to compare 2 different nodes:
@@ -34,6 +32,7 @@ public function __construct(Comparator $comparator)
* Check whether this is element is new or not, by checking it in db schema
*
* @param ElementInterface[] $generatedElements
+ * @param ElementInterface $element
* @return bool
*/
public function shouldBeCreated(array $generatedElements, ElementInterface $element)
@@ -56,19 +55,19 @@ public function shouldBeRemoved(array $generatedElements)
* Register element, that should changes
*
*
- * @param ChangeRegistryInterface $changeRegistry
+ * @param DiffInterface $diff
* @param ElementInterface $element
* @param ElementInterface $generatedElement
*/
public function registerModification(
- ChangeRegistryInterface $changeRegistry,
+ DiffInterface $diff,
ElementInterface $element,
ElementInterface $generatedElement
) {
- $changeRegistry->register(
+ $diff->register(
$element,
$element->getElementType(),
- ChangeRegistryInterface::CHANGE_OPERATION,
+ DiffInterface::CHANGE_OPERATION,
$generatedElement
);
}
@@ -77,12 +76,12 @@ public function registerModification(
* If elements really dont exists in declaration - we will remove them
* If some mistake happens (and element is just not preprocessed), we will throw exception
*
- * @param ChangeRegistryInterface $changeRegistry
+ * @param DiffInterface $diff
* @param ElementInterface[] $generatedElements
* @param ElementInterface[] $elements
*/
public function registerRemoval(
- ChangeRegistryInterface $changeRegistry,
+ DiffInterface $diff,
array $generatedElements,
array $elements
) {
@@ -96,24 +95,24 @@ public function registerRemoval(
);
}
- $changeRegistry->register(
+ $diff->register(
$generatedElement,
$generatedElement->getElementType(),
- ChangeRegistryInterface::REMOVE_OPERATION
+ DiffInterface::REMOVE_OPERATION
);
}
}
/**
- * @param ChangeRegistryInterface $changeRegistry
+ * @param DiffInterface $diff
* @param ElementInterface $element
*/
- public function registerCreation(ChangeRegistryInterface $changeRegistry, ElementInterface $element)
+ public function registerCreation(DiffInterface $diff, ElementInterface $element)
{
- $changeRegistry->register(
+ $diff->register(
$element,
$element->getElementType(),
- ChangeRegistryInterface::CREATE_OPERATION
+ DiffInterface::CREATE_OPERATION
);
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/SchemaDiff.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/SchemaDiff.php
index af7e19be54422..77df73e5cb769 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/SchemaDiff.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/SchemaDiff.php
@@ -6,7 +6,6 @@
namespace Magento\Setup\Model\Declaration\Schema\Diff;
-use Magento\Setup\Model\Declaration\Schema\ChangeRegistry;
use Magento\Setup\Model\Declaration\Schema\Dto\Schema;
/**
@@ -29,42 +28,52 @@ class SchemaDiff
*/
private $diffManager;
+ /**
+ * @var DiffFactory
+ */
+ private $diffFactory;
+
/**
* @param DiffManager $diffManager
* @param TableDiff $tableDiff
+ * @param DiffFactory $diffFactory
*/
public function __construct(
DiffManager $diffManager,
- TableDiff $tableDiff
+ TableDiff $tableDiff,
+ DiffFactory $diffFactory
) {
$this->tableDiff = $tableDiff;
$this->diffManager = $diffManager;
+ $this->diffFactory = $diffFactory;
}
/**
* @param Schema $schema
* @param Schema $generatedSchema
- * @param ChangeRegistry $changeRegistry
+ * @return Diff
*/
public function diff(
Schema $schema,
- Schema $generatedSchema,
- ChangeRegistry $changeRegistry
+ Schema $generatedSchema
) {
$generatedTables = $generatedSchema->getTables();
+ $diff = $this->diffFactory->create();
foreach ($schema->getTables() as $name => $table) {
if ($this->diffManager->shouldBeCreated($generatedTables, $table)) {
- $this->diffManager->registerCreation($changeRegistry, $table);
+ $this->diffManager->registerCreation($diff, $table);
} else {
- $this->tableDiff->diff($table, $generatedTables[$name], $changeRegistry);
+ $this->tableDiff->diff($table, $generatedTables[$name], $diff);
}
unset($generatedTables[$name]);
}
//Removal process
if ($this->diffManager->shouldBeRemoved($generatedTables)) {
- $this->diffManager->registerRemoval($changeRegistry, $generatedTables, $schema->getTables());
+ $this->diffManager->registerRemoval($diff, $generatedTables, $schema->getTables());
}
+
+ return $diff;
}
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/TableDiff.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/TableDiff.php
index 8d5cb0a753d7c..0c4dda00837e0 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/TableDiff.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/TableDiff.php
@@ -6,8 +6,6 @@
namespace Magento\Setup\Model\Declaration\Schema\Diff;
-use Magento\Setup\Model\Declaration\Schema\ChangeRegistry;
-use Magento\Setup\Model\Declaration\Schema\DiffInterface;
use Magento\Setup\Model\Declaration\Schema\Dto\ElementInterface;
use Magento\Setup\Model\Declaration\Schema\Dto\Table;
@@ -19,7 +17,7 @@
* If element exists in both version and are different -> then we need to modify element
* If element exists only in db -> then we need to remove this element
*/
-class TableDiff implements DiffInterface
+class TableDiff
{
/**
* Column type for diff
@@ -52,13 +50,13 @@ public function __construct(DiffManager $diffManager)
/**
* @param Table | ElementInterface $declaredTable
* @param Table | ElementInterface $generatedTable
- * @param ChangeRegistry $changeRegistry
+ * @param Diff $changeRegistry
* @inheritdoc
*/
public function diff(
ElementInterface $declaredTable,
ElementInterface $generatedTable,
- ChangeRegistry $changeRegistry
+ Diff $changeRegistry
) {
$types = [self::COLUMN_DIFF_TYPE, self::CONSTRAINT_DIFF_TYPE, self::INDEX_DIFF_TYPE];
//We do inspection for each element type
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/DiffInterface.php b/setup/src/Magento/Setup/Model/Declaration/Schema/DiffInterface.php
deleted file mode 100644
index 388342a2339b3..0000000000000
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/DiffInterface.php
+++ /dev/null
@@ -1,30 +0,0 @@
- it is convinient to use boolean type for it
//But later we need to convert it to SQL value
- if (isset($data['on_update']) && $data['on_update'] !== 'CURRENT_TIMESTAMP') {
- if ($this->booleanUtils->toBoolean($data['on_update'])) {
- $data['on_update'] = 'CURRENT_TIMESTAMP';
+ if ($data['onUpdate'] && $data['onUpdate'] !== 'CURRENT_TIMESTAMP') {
+ if ($this->booleanUtils->toBoolean($data['onUpdate'])) {
+ $data['onUpdate'] = 'CURRENT_TIMESTAMP';
} else {
- unset($data['on_update']);
+ unset($data['onUpdate']);
}
}
//By default we do not want to use default attribute
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/SchemaConfig.php b/setup/src/Magento/Setup/Model/Declaration/Schema/SchemaConfig.php
new file mode 100644
index 0000000000000..e34ce4ec6b1db
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/SchemaConfig.php
@@ -0,0 +1,78 @@
+dbSchemaBuilder = $dbSchemaBuilder;
+ $this->declarativeSchemaBuilder = $declarativeSchemaBuilder;
+ $this->schemaFactory = $schemaFactory;
+ $this->readerComposite = $readerComposite;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function getDbConfig()
+ {
+ $schema = $this->schemaFactory->create();
+ $schema = $this->dbSchemaBuilder->build($schema);
+ return $schema;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function getDeclarationConfig()
+ {
+ $schema = $this->schemaFactory->create();
+ $data = $this->readerComposite->read();
+ $this->declarativeSchemaBuilder->addTablesData($data['table']);
+ $schema = $this->declarativeSchemaBuilder->build($schema);
+ return $schema;
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/SchemaParserInterface.php b/setup/src/Magento/Setup/Model/Declaration/Schema/SchemaConfigInterface.php
similarity index 65%
rename from setup/src/Magento/Setup/Model/Declaration/Schema/SchemaParserInterface.php
rename to setup/src/Magento/Setup/Model/Declaration/Schema/SchemaConfigInterface.php
index 8eafd0c309505..1383981f87864 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/SchemaParserInterface.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/SchemaConfigInterface.php
@@ -14,13 +14,19 @@
*
* Declaration has 2 schema builders, that build schema from db and from XML
*/
-interface SchemaParserInterface
+interface SchemaConfigInterface
{
/**
- * Parse XML or DB changes into schema
+ * Parse DB schema
*
- * @param Schema $schema
- * @return mixed
+ * @return Schema
*/
- public function parse(Schema $schema);
+ public function getDbConfig();
+
+ /**
+ * Parse XML schema
+ *
+ * @return Schema
+ */
+ public function getDeclarationConfig();
}
From 815c125ab3d7941d6210611fef6ba2dba87b64c3 Mon Sep 17 00:00:00 2001
From: Sergii Kovalenko
Date: Thu, 21 Dec 2017 20:08:15 +0200
Subject: [PATCH 236/904] MAGETWO-84100: Unify Magento SQL adapters
--add test on declaration installation
---
app/etc/di.xml | 38 +++-
.../etc/db_schema.xml | 33 ++-
.../column_modification.php | 46 ++++
.../declarative_installer/column_removal.php | 44 ++++
.../constraint_modification.php | 55 +++++
.../declarative_installer/installation.php | 46 ++++
.../declarative_installer/table_removal.php | 12 +
.../column_modifications/db_schema.xml | 62 +++++
.../revisions/column_removals/db_schema.xml | 60 +++++
.../constraint_modifications/db_schema.xml | 74 ++++++
.../revisions/drop_table/db_schema.xml | 16 ++
.../TestFramework/Annotation/CopyModules.php | 19 ++
.../TestFramework/Deploy/CliCommand.php | 4 +-
.../Setup/DeclarativeInstallerTest.php | 213 +++++++++++++++---
.../Declaration/Schema/Db/AdapterMediator.php | 46 +++-
.../Db/Processors/DbSchemaWriterInterface.php | 10 +
.../Db/Processors/MySQL/Columns/Basic.php | 1 -
.../Db/Processors/MySQL/Columns/Blob.php | 9 +-
.../Db/Processors/MySQL/Columns/Boolean.php | 11 +-
.../Db/Processors/MySQL/Columns/Date.php | 38 +---
.../Db/Processors/MySQL/Columns/Decimal.php | 19 +-
.../MySQL/Columns/DefaultDefinition.php | 33 ++-
.../Db/Processors/MySQL/Columns/Integer.php | 14 +-
.../Db/Processors/MySQL/Columns/Text.php | 11 +-
.../Db/Processors/MySQL/Columns/Timestamp.php | 25 +-
.../Db/Processors/MySQL/Columns/Unsigned.php | 7 +-
.../Db/Processors/MySQL/Columns/Varchar.php | 13 +-
.../MySQL/Constraints/ForeignKey.php | 33 ++-
.../Processors/MySQL/Constraints/Internal.php | 41 +++-
.../Db/Processors/MySQL/DbSchemaReader.php | 15 +-
.../Db/Processors/MySQL/DbSchemaWriter.php | 181 ++++++++++++---
.../Schema/Db/Processors/MySQL/Index.php | 33 ++-
.../Schema/Declaration/SchemaBuilder.php | 35 ++-
.../Declaration/ValidationComposite.php | 46 ++++
.../Declaration/ValidationInterface.php | 22 ++
.../CheckReferenceColumnHasIndex.php | 60 +++++
.../Model/Declaration/Schema/Diff/Diff.php | 7 +-
.../Declaration/Schema/Diff/DiffInterface.php | 5 +-
.../Declaration/Schema/Diff/DiffManager.php | 2 +-
.../Declaration/Schema/Diff/TableDiff.php | 22 ++
.../Declaration/Schema/Dto/Columns/Blob.php | 2 +-
.../Schema/Dto/Columns/Boolean.php | 3 +-
.../Columns/ColumnDefaultAwareInterface.php | 8 +-
.../Schema/Dto/Columns/Decimal.php | 3 +-
.../Schema/Dto/Columns/Integer.php | 3 +-
.../Declaration/Schema/Dto/Columns/Text.php | 2 +-
.../Schema/Dto/Columns/Timestamp.php | 6 +-
.../Schema/Dto/Columns/Varbinary.php | 3 +-
.../Schema/Dto/Columns/Varchar.php | 3 +-
.../Schema/Dto/Constraints/Internal.php | 22 +-
.../Schema/Dto/Constraints/Reference.php | 1 +
.../Declaration/Schema/Dto/ElementFactory.php | 12 +-
.../Schema/Dto/Factories/Integer.php | 17 +-
.../Schema/Dto/Factories/Timestamp.php | 1 +
.../Model/Declaration/Schema/Dto/Table.php | 19 ++
.../Schema/Operations/ModifyElement.php | 6 +-
.../Declaration/Schema/OperationsExecutor.php | 62 ++++-
.../Model/Declaration/Schema/SchemaConfig.php | 4 +
.../Model/Declaration/Schema/Sharding.php | 22 +-
.../Schema/config/constraints/foreign.xsd | 2 -
.../Schema/config/types/binaries/blob.xsd | 8 -
.../Schema/config/types/binaries/longblob.xsd | 7 -
.../config/types/binaries/mediumblob.xsd | 8 -
.../Schema/config/types/integers/integer.xsd | 15 +-
.../Schema/config/types/texts/longtext.xsd | 7 -
.../Schema/config/types/texts/mediumtext.xsd | 8 -
.../Schema/config/types/texts/text.xsd | 8 -
.../Setup/Model/DeclarationInstaller.php | 67 ++----
setup/src/Magento/Setup/Model/Installer.php | 13 +-
69 files changed, 1464 insertions(+), 339 deletions(-)
create mode 100644 dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/declarative_installer/column_modification.php
create mode 100644 dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/declarative_installer/column_removal.php
create mode 100644 dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/declarative_installer/constraint_modification.php
create mode 100644 dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/declarative_installer/installation.php
create mode 100644 dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/declarative_installer/table_removal.php
create mode 100644 dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/column_modifications/db_schema.xml
create mode 100644 dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/column_removals/db_schema.xml
create mode 100644 dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/constraint_modifications/db_schema.xml
create mode 100644 dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/drop_table/db_schema.xml
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/ValidationComposite.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/ValidationInterface.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/ValidationRules/CheckReferenceColumnHasIndex.php
diff --git a/app/etc/di.xml b/app/etc/di.xml
index dddf0be761dfb..6d43fbd11cb17 100755
--- a/app/etc/di.xml
+++ b/app/etc/di.xml
@@ -1357,9 +1357,9 @@
- \Magento\Setup\Model\Declaration\Schema\Dto\Factories\Decimal
- \Magento\Setup\Model\Declaration\Schema\Dto\Factories\Decimal
- \Magento\Setup\Model\Declaration\Schema\Dto\Factories\Decimal
- - \Magento\Setup\Model\Declaration\Schema\Dto\Factories\SmallInteger
- - \Magento\Setup\Model\Declaration\Schema\Dto\Factories\TinyInteger
- - \Magento\Setup\Model\Declaration\Schema\Dto\Factories\BigInteger
+ - \Magento\Setup\Model\Declaration\Schema\Dto\Factories\Integer
+ - \Magento\Setup\Model\Declaration\Schema\Dto\Factories\Integer
+ - \Magento\Setup\Model\Declaration\Schema\Dto\Factories\Integer
- \Magento\Setup\Model\Declaration\Schema\Dto\Factories\Integer
- \Magento\Setup\Model\Declaration\Schema\Dto\Factories\Date
- \Magento\Setup\Model\Declaration\Schema\Dto\Factories\Timestamp
@@ -1385,11 +1385,25 @@
-
- \Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL\Columns\Basic
+ - \Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL\Columns\Boolean
- \Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL\Columns\Integer
+ - \Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL\Columns\Integer
+ - \Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL\Columns\Integer
+ - \Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL\Columns\Integer
- \Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL\Columns\Decimal
+ - \Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL\Columns\Decimal
+ - \Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL\Columns\Decimal
- \Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL\Columns\Text
+ - \Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL\Columns\Blob
+ - \Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL\Columns\Blob
+ - \Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL\Columns\Blob
+ - \Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL\Columns\Text
+ - \Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL\Columns\Text
+ - \Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL\Columns\Timestamp
+ - \Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL\Columns\Date
- \Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL\Columns\Timestamp
- \Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL\Columns\Varchar
+ - \Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL\Columns\Varchar
-
- \Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL\Index
@@ -1411,11 +1425,25 @@
+ - Magento\Setup\Model\Declaration\Schema\Operations\DropTable
- Magento\Setup\Model\Declaration\Schema\Operations\CreateTable
- - Magento\Setup\Model\Declaration\Schema\Operations\DropElement
- Magento\Setup\Model\Declaration\Schema\Operations\AddElement
+ - Magento\Setup\Model\Declaration\Schema\Operations\DropElement
- Magento\Setup\Model\Declaration\Schema\Operations\ModifyElement
- - Magento\Setup\Model\Declaration\Schema\Operations\DropTable
+
+
+
+
+
+
+ - default
+
+
+
+
+
+
+ - Magento\Setup\Model\Declaration\Schema\Declaration\ValidationRules\CheckReferenceColumnHasIndex
diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/etc/db_schema.xml b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/etc/db_schema.xml
index 443616fd9d188..99e3ed7ed53fd 100644
--- a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/etc/db_schema.xml
+++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/etc/db_schema.xml
@@ -7,15 +7,32 @@
-->
-
+
+
-
-
+
+
@@ -23,11 +40,11 @@
-
-
+
+
-
-
+
+
diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/declarative_installer/column_modification.php b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/declarative_installer/column_modification.php
new file mode 100644
index 0000000000000..ce1ea7276b6f5
--- /dev/null
+++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/declarative_installer/column_modification.php
@@ -0,0 +1,46 @@
+ 'CREATE TABLE `auto_increment_test` (
+ `int_auto_increment_with_nullable` int(15) unsigned DEFAULT NULL,
+ `int_disabled_auto_increment` smallint(12) unsigned DEFAULT \'0\',
+ UNIQUE KEY `unique_null_key` (`int_auto_increment_with_nullable`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8',
+ 'reference_table' => 'CREATE TABLE `reference_table` (
+ `tinyint_ref` tinyint(7) NOT NULL AUTO_INCREMENT,
+ `tinyint_without_padding` tinyint(2) NOT NULL,
+ `bigint_without_padding` bigint(20) NOT NULL DEFAULT \'0\',
+ `smallint_without_padding` smallint(5) NOT NULL DEFAULT \'0\',
+ `integer_without_padding` int(11) NOT NULL DEFAULT \'0\',
+ `smallint_with_big_padding` smallint(254) NOT NULL DEFAULT \'0\',
+ `smallint_without_default` smallint(2) DEFAULT NULL,
+ `int_without_unsigned` int(2) DEFAULT NULL,
+ `int_unsigned` int(2) unsigned DEFAULT NULL,
+ `bigint_default_nullable` bigint(2) unsigned DEFAULT \'123\',
+ `bigint_not_default_not_nullable` bigint(20) NOT NULL,
+ PRIMARY KEY (`tinyint_ref`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8',
+ 'test_table' => 'CREATE TABLE `test_table` (
+ `smallint` smallint(3) NOT NULL AUTO_INCREMENT,
+ `tinyint` tinyint(7) DEFAULT NULL,
+ `bigint` bigint(13) DEFAULT \'0\',
+ `float` float(12,10) DEFAULT \'0.0000000000\',
+ `double` double(245,10) DEFAULT NULL,
+ `decimal` decimal(15,4) DEFAULT \'0.0000\',
+ `date` date DEFAULT NULL,
+ `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ `datetime` datetime DEFAULT \'0000-00-00 00:00:00\',
+ `longtext` longtext,
+ `mediumtext` mediumtext,
+ `varchar` varchar(100) DEFAULT NULL,
+ `mediumblob` mediumblob,
+ `blob` blob,
+ `boolean` tinyint(1) DEFAULT \'1\',
+ UNIQUE KEY `some_unique_key` (`smallint`,`bigint`),
+ KEY `speedup_index` (`tinyint`,`bigint`),
+ CONSTRAINT `some_foreign_key` FOREIGN KEY (`tinyint`) REFERENCES `reference_table` (`tinyint_ref`) ON DELETE NO ACTION
+) ENGINE=InnoDB DEFAULT CHARSET=utf8',
+];
diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/declarative_installer/column_removal.php b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/declarative_installer/column_removal.php
new file mode 100644
index 0000000000000..fb207c04a127c
--- /dev/null
+++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/declarative_installer/column_removal.php
@@ -0,0 +1,44 @@
+ 'CREATE TABLE `auto_increment_test` (
+ `int_auto_increment_with_nullable` int(12) unsigned NOT NULL AUTO_INCREMENT,
+ UNIQUE KEY `unique_null_key` (`int_auto_increment_with_nullable`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8',
+ 'reference_table' => 'CREATE TABLE `reference_table` (
+ `tinyint_ref` tinyint(7) NOT NULL AUTO_INCREMENT,
+ `tinyint_without_padding` tinyint(2) NOT NULL DEFAULT \'0\',
+ `bigint_without_padding` bigint(20) NOT NULL DEFAULT \'0\',
+ `integer_without_padding` int(11) NOT NULL DEFAULT \'0\',
+ `smallint_with_big_padding` smallint(254) NOT NULL DEFAULT \'0\',
+ `smallint_without_default` smallint(2) DEFAULT NULL,
+ `int_without_unsigned` int(2) DEFAULT NULL,
+ `int_unsigned` int(2) unsigned DEFAULT NULL,
+ `bigint_default_nullable` bigint(2) unsigned DEFAULT \'1\',
+ `bigint_not_default_not_nullable` bigint(2) unsigned NOT NULL,
+ PRIMARY KEY (`tinyint_ref`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8',
+ 'test_table' => 'CREATE TABLE `test_table` (
+ `smallint` smallint(3) NOT NULL AUTO_INCREMENT,
+ `tinyint` tinyint(7) DEFAULT NULL,
+ `bigint` bigint(13) DEFAULT \'0\',
+ `float` float(12,10) DEFAULT \'0.0000000000\',
+ `double` double(245,10) DEFAULT \'11111111.1111110000\',
+ `decimal` decimal(15,4) DEFAULT \'0.0000\',
+ `date` date DEFAULT NULL,
+ `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
+ `datetime` datetime DEFAULT \'0000-00-00 00:00:00\',
+ `longtext` longtext,
+ `mediumtext` mediumtext,
+ `varchar` varchar(254) DEFAULT NULL,
+ `blob` blob,
+ `boolean` tinyint(1) DEFAULT \'0\',
+ `varbinary_rename` varbinary(255) DEFAULT \'10101\',
+ UNIQUE KEY `some_unique_key` (`smallint`,`bigint`),
+ KEY `speedup_index` (`tinyint`,`bigint`),
+ CONSTRAINT `some_foreign_key` FOREIGN KEY (`tinyint`) REFERENCES `reference_table` (`tinyint_ref`) ON DELETE NO ACTION
+) ENGINE=InnoDB DEFAULT CHARSET=utf8',
+];
diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/declarative_installer/constraint_modification.php b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/declarative_installer/constraint_modification.php
new file mode 100644
index 0000000000000..80415185ed5a2
--- /dev/null
+++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/declarative_installer/constraint_modification.php
@@ -0,0 +1,55 @@
+ 'CREATE TABLE `auto_increment_test` (
+ `int_auto_increment_with_nullable` int(12) unsigned NOT NULL AUTO_INCREMENT,
+ `int_disabled_auto_increment` smallint(12) unsigned DEFAULT \'0\',
+ UNIQUE KEY `unique_null_key` (`int_auto_increment_with_nullable`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8',
+ 'reference_table' => 'CREATE TABLE `reference_table` (
+ `tinyint_ref` tinyint(7) NOT NULL AUTO_INCREMENT,
+ `tinyint_without_padding` tinyint(2) NOT NULL DEFAULT \'0\',
+ `bigint_without_padding` bigint(20) NOT NULL DEFAULT \'0\',
+ `smallint_without_padding` smallint(5) NOT NULL DEFAULT \'0\',
+ `integer_without_padding` int(11) NOT NULL DEFAULT \'0\',
+ `smallint_with_big_padding` smallint(254) NOT NULL DEFAULT \'0\',
+ `smallint_without_default` smallint(2) DEFAULT NULL,
+ `int_without_unsigned` int(2) DEFAULT NULL,
+ `int_unsigned` int(2) unsigned DEFAULT NULL,
+ `bigint_default_nullable` bigint(2) unsigned DEFAULT \'1\',
+ `bigint_not_default_not_nullable` bigint(2) unsigned NOT NULL,
+ `smallint_ref` smallint(254) NOT NULL DEFAULT \'0\',
+ PRIMARY KEY (`tinyint_ref`,`smallint_ref`),
+ UNIQUE KEY `smallint_unique` (`smallint_ref`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8',
+ 'test_table' => 'CREATE TABLE `test_table` (
+ `smallint` smallint(3) DEFAULT NULL,
+ `tinyint` tinyint(7) DEFAULT NULL,
+ `bigint` bigint(13) DEFAULT \'0\',
+ `float` float(12,10) DEFAULT \'0.0000000000\',
+ `double` double(245,10) DEFAULT \'11111111.1111110000\',
+ `decimal` decimal(15,4) DEFAULT \'0.0000\',
+ `date` date DEFAULT NULL,
+ `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
+ `datetime` datetime DEFAULT \'0000-00-00 00:00:00\',
+ `longtext` longtext,
+ `mediumtext` mediumtext,
+ `varchar` varchar(254) DEFAULT NULL,
+ `mediumblob` mediumblob,
+ `blob` blob,
+ `boolean` tinyint(1) DEFAULT \'0\',
+ `integer_main` int(12) unsigned DEFAULT NULL,
+ `smallint_main` smallint(254) NOT NULL DEFAULT \'0\',
+ UNIQUE KEY `some_unique_key_2` (`double`),
+ UNIQUE KEY `some_unique_key` (`smallint`,`float`),
+ KEY `some_foreign_key_new` (`smallint_main`),
+ KEY `some_foreign_key_without_action` (`integer_main`),
+ KEY `speedup_index_renamed` (`tinyint`,`bigint`),
+ CONSTRAINT `some_foreign_key` FOREIGN KEY (`tinyint`) REFERENCES `reference_table` (`tinyint_ref`) ON DELETE SET NULL,
+ CONSTRAINT `some_foreign_key_new` FOREIGN KEY (`smallint_main`) REFERENCES `reference_table` (`smallint_ref`) ON DELETE CASCADE,
+ CONSTRAINT `some_foreign_key_without_action` FOREIGN KEY (`integer_main`) REFERENCES `auto_increment_test` (`int_auto_increment_with_nullable`) ON DELETE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8',
+];
\ No newline at end of file
diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/declarative_installer/installation.php b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/declarative_installer/installation.php
new file mode 100644
index 0000000000000..68d129f0bbf5e
--- /dev/null
+++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/declarative_installer/installation.php
@@ -0,0 +1,46 @@
+ 'CREATE TABLE `auto_increment_test` (
+ `int_auto_increment_with_nullable` int(12) unsigned NOT NULL AUTO_INCREMENT,
+ `int_disabled_auto_increment` smallint(12) unsigned DEFAULT \'0\',
+ UNIQUE KEY `unique_null_key` (`int_auto_increment_with_nullable`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8',
+ 'reference_table' => 'CREATE TABLE `reference_table` (
+ `tinyint_ref` tinyint(7) NOT NULL AUTO_INCREMENT,
+ `tinyint_without_padding` tinyint(2) NOT NULL DEFAULT \'0\',
+ `bigint_without_padding` bigint(20) NOT NULL DEFAULT \'0\',
+ `smallint_without_padding` smallint(5) NOT NULL DEFAULT \'0\',
+ `integer_without_padding` int(11) NOT NULL DEFAULT \'0\',
+ `smallint_with_big_padding` smallint(254) NOT NULL DEFAULT \'0\',
+ `smallint_without_default` smallint(2) DEFAULT NULL,
+ `int_without_unsigned` int(2) DEFAULT NULL,
+ `int_unsigned` int(2) unsigned DEFAULT NULL,
+ `bigint_default_nullable` bigint(2) unsigned DEFAULT \'1\',
+ `bigint_not_default_not_nullable` bigint(2) unsigned NOT NULL,
+ PRIMARY KEY (`tinyint_ref`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8',
+ 'test_table' => 'CREATE TABLE `test_table` (
+ `smallint` smallint(3) NOT NULL AUTO_INCREMENT,
+ `tinyint` tinyint(7) DEFAULT NULL,
+ `bigint` bigint(13) DEFAULT \'0\',
+ `float` float(12,10) DEFAULT \'0.0000000000\',
+ `double` double(245,10) DEFAULT \'11111111.1111110000\',
+ `decimal` decimal(15,4) DEFAULT \'0.0000\',
+ `date` date DEFAULT NULL,
+ `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
+ `datetime` datetime DEFAULT \'0000-00-00 00:00:00\',
+ `longtext` longtext,
+ `mediumtext` mediumtext,
+ `varchar` varchar(254) DEFAULT NULL,
+ `mediumblob` mediumblob,
+ `blob` blob,
+ `boolean` tinyint(1) DEFAULT \'0\',
+ UNIQUE KEY `some_unique_key` (`smallint`,`bigint`),
+ KEY `speedup_index` (`tinyint`,`bigint`),
+ CONSTRAINT `some_foreign_key` FOREIGN KEY (`tinyint`) REFERENCES `reference_table` (`tinyint_ref`) ON DELETE NO ACTION
+) ENGINE=InnoDB DEFAULT CHARSET=utf8',
+];
\ No newline at end of file
diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/declarative_installer/table_removal.php b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/declarative_installer/table_removal.php
new file mode 100644
index 0000000000000..771317194875c
--- /dev/null
+++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/declarative_installer/table_removal.php
@@ -0,0 +1,12 @@
+ 'CREATE TABLE `auto_increment_test` (
+ `int_auto_increment_with_nullable` int(12) unsigned NOT NULL AUTO_INCREMENT,
+ `int_disabled_auto_increment` smallint(12) unsigned DEFAULT \'0\',
+ UNIQUE KEY `unique_null_key` (`int_auto_increment_with_nullable`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8',
+];
diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/column_modifications/db_schema.xml b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/column_modifications/db_schema.xml
new file mode 100644
index 0000000000000..2671fd4babd89
--- /dev/null
+++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/column_modifications/db_schema.xml
@@ -0,0 +1,62 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/column_removals/db_schema.xml b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/column_removals/db_schema.xml
new file mode 100644
index 0000000000000..83c274c2627c0
--- /dev/null
+++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/column_removals/db_schema.xml
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/constraint_modifications/db_schema.xml b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/constraint_modifications/db_schema.xml
new file mode 100644
index 0000000000000..c8dcdc7650307
--- /dev/null
+++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/constraint_modifications/db_schema.xml
@@ -0,0 +1,74 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/drop_table/db_schema.xml b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/drop_table/db_schema.xml
new file mode 100644
index 0000000000000..c7c4085553cc5
--- /dev/null
+++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/drop_table/db_schema.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
diff --git a/dev/tests/setup-integration/framework/Magento/TestFramework/Annotation/CopyModules.php b/dev/tests/setup-integration/framework/Magento/TestFramework/Annotation/CopyModules.php
index 1c5b37e4ca08d..7206090c7982c 100644
--- a/dev/tests/setup-integration/framework/Magento/TestFramework/Annotation/CopyModules.php
+++ b/dev/tests/setup-integration/framework/Magento/TestFramework/Annotation/CopyModules.php
@@ -6,6 +6,7 @@
namespace Magento\TestFramework\Annotation;
+use Magento\Framework\Filesystem\Io\File;
use Magento\TestFramework\Deploy\CliCommand;
use Magento\TestFramework\Deploy\TestModuleManager;
@@ -48,4 +49,22 @@ public function startTest(\PHPUnit\Framework\TestCase $test)
$this->cliCommand->introduceModule($annotations['method']['moduleName'][0]);
}
}
+
+ /**
+ * Handler for 'startTest' event
+ *
+ * @param \PHPUnit\Framework\TestCase $test
+ */
+ public function endTest(\PHPUnit\Framework\TestCase $test)
+ {
+ $annotations = $test->getAnnotations();
+ //This annotation can be declared only on method level
+ if (isset($annotations['method']['moduleName'])) {
+ $path = MAGENTO_MODULES_PATH .
+ //Take only module name from Magento_ModuleName
+ explode("_", $annotations['method']['moduleName'][0])[1];
+
+ //File::rmdirRecursive($path);
+ }
+ }
}
diff --git a/dev/tests/setup-integration/framework/Magento/TestFramework/Deploy/CliCommand.php b/dev/tests/setup-integration/framework/Magento/TestFramework/Deploy/CliCommand.php
index ded5be50fdc3b..a41d31da2f681 100644
--- a/dev/tests/setup-integration/framework/Magento/TestFramework/Deploy/CliCommand.php
+++ b/dev/tests/setup-integration/framework/Magento/TestFramework/Deploy/CliCommand.php
@@ -79,7 +79,7 @@ public function upgrade()
{
$initParams = $this->parametersHolder->getInitParams();
$enableModuleCommand = 'php -f ' . BP . '/bin/magento setup:upgrade -vvv -n --magento-init-params='
- . $initParams;
+ . $initParams['magento-init-params'];
return $this->shell->execute($enableModuleCommand);
}
@@ -93,7 +93,7 @@ public function disableModule($moduleName)
{
$initParams = $this->parametersHolder->getInitParams();
$disableModuleCommand = 'php -f ' . BP . '/bin/magento module:disable Magento_'. $moduleName
- . ' -vvv --magento-init-params=' . $initParams;
+ . ' -vvv --magento-init-params=' . $initParams['magento-init-params'];
return $this->shell->execute($disableModuleCommand);
}
diff --git a/dev/tests/setup-integration/testsuite/Magento/Setup/DeclarativeInstallerTest.php b/dev/tests/setup-integration/testsuite/Magento/Setup/DeclarativeInstallerTest.php
index f8dafc51ac668..c3c8eb2189bae 100644
--- a/dev/tests/setup-integration/testsuite/Magento/Setup/DeclarativeInstallerTest.php
+++ b/dev/tests/setup-integration/testsuite/Magento/Setup/DeclarativeInstallerTest.php
@@ -6,17 +6,17 @@
namespace Magento\Setup;
+use Magento\Framework\App\ResourceConnection;
use Magento\Setup\Console\Command\InstallCommand;
-use Magento\Setup\Model\Declaration\Schema\ChangeRegistryFactory;
-use Magento\Setup\Model\Declaration\Schema\Db\Parser;
+use Magento\Setup\Model\Declaration\Schema\Db\AdapterMediator;
+use Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL\DbSchemaReader;
use Magento\Setup\Model\Declaration\Schema\Diff\SchemaDiff;
-use Magento\Setup\Model\Declaration\Schema\Dto\SchemaFactory;
-use Magento\Setup\Model\Declaration\Schema\OperationsExecutor;
+use Magento\Setup\Model\Declaration\Schema\SchemaConfigInterface;
+use Magento\Setup\Model\Declaration\Schema\Sharding;
use Magento\TestFramework\Deploy\CliCommand;
use Magento\TestFramework\Deploy\TestModuleManager;
use Magento\TestFramework\Helper\Bootstrap;
use Magento\TestFramework\TestCase\SetupTestCase;
-use \Magento\Setup\Model\Declaration\Schema\Declaration\Parser as DeclarativeParser;
/**
* The purpose of this test is verifying declarative installation works
@@ -34,50 +34,60 @@ class DeclarativeInstallerTest extends SetupTestCase
private $cliCommad;
/**
- * @var SchemaFactory
- */
- private $schemaFactory;
-
- /**
- * @var DeclarativeParser
- */
- private $declarativeParser;
-
- /**
- * @var Parser
+ * @var SchemaDiff
*/
- private $generatedParser;
+ private $schemaDiff;
/**
- * @var SchemaDiff
+ * @var SchemaConfigInterface
*/
- private $schemaDiff;
+ private $schemaConfig;
/**
- * @var ChangeRegistryFactory
+ * @var ResourceConnection
*/
- private $changeRegistryFactory;
+ private $resourceConnection;
/**
- * @var OperationsExecutor
+ * @var DbSchemaReader
*/
- private $operationsExecutor;
+ private $dbSchemaReader;
public function setUp()
{
$objectManager = Bootstrap::getObjectManager();
- $this->schemaFactory = $objectManager->get(SchemaFactory::class);
$this->moduleManager = $objectManager->get(TestModuleManager::class);
$this->cliCommad = $objectManager->get(CliCommand::class);
- $this->declarativeParser = $objectManager->get(DeclarativeParser::class);
- $this->generatedParser = $objectManager->get(Parser::class);
+ /** @var AdapterMediator $adapterMediator */
+ $adapterMediator = $objectManager->get(AdapterMediator::class);
+ $adapterMediator->flushCache();
+ $this->dbSchemaReader = $objectManager->create(DbSchemaReader::class);
$this->schemaDiff = $objectManager->get(SchemaDiff::class);
- $this->changeRegistryFactory = $objectManager->get(ChangeRegistryFactory::class);
- $this->operationsExecutor = $objectManager->get(OperationsExecutor::class);
+ $this->schemaConfig = $objectManager->get(SchemaConfigInterface::class);
+ $this->resourceConnection = $objectManager->get(ResourceConnection::class);
+ }
+
+ /**
+ * Describe shards
+ *
+ * @param string $shardName
+ * @return array
+ */
+ private function describeShard($shardName)
+ {
+ $data = [];
+ $tables = $this->dbSchemaReader->readTables($shardName);
+
+ foreach ($tables as $table) {
+ $data[$table] = $this->dbSchemaReader->getCreateTableSql($table, $shardName)['Create Table'];
+ }
+
+ return $data;
}
/**
* @moduleName Magento_TestSetupDeclarationModule1
+ * @dataProviderFromFile Magento/TestSetupDeclarationModule1/fixture/declarative_installer/installation.php
*/
public function testInstallation()
{
@@ -85,6 +95,151 @@ public function testInstallation()
['Magento_TestSetupDeclarationModule1'],
[InstallCommand::DECLARATION_MODE_KEY => true]
);
- echo 1;
+
+ $diff = $this->schemaDiff->diff(
+ $this->schemaConfig->getDeclarationConfig(),
+ $this->schemaConfig->getDbConfig()
+ );
+
+ //$tablesData = $this->describeShard(Sharding::DEFAULT_CONNECTION);
+ //Second time installation should not find anything as we do not change anything
+ self::assertNull($diff->get());
+ $shardData = $this->describeShard(Sharding::DEFAULT_CONNECTION);
+ self::assertEquals($shardData, $this->getData());
+ }
+
+ /**
+ * @moduleName Magento_TestSetupDeclarationModule1
+ * @dataProviderFromFile Magento/TestSetupDeclarationModule1/fixture/declarative_installer/column_modification.php
+ */
+ public function testInstallationWithColumnsModification()
+ {
+ $this->cliCommad->install(
+ ['Magento_TestSetupDeclarationModule1'],
+ [InstallCommand::DECLARATION_MODE_KEY => true]
+ );
+
+ //Move InstallSchema file and tried to install
+ $this->moduleManager->updateRevision(
+ 'Magento_TestSetupDeclarationModule1',
+ 'column_modifications',
+ 'db_schema.xml',
+ 'etc'
+ );
+ //@TODO: change this to upgrade in future
+ $this->cliCommad->install(
+ ['Magento_TestSetupDeclarationModule1'],
+ [InstallCommand::DECLARATION_MODE_KEY => true]
+ );
+
+ $diff = $this->schemaDiff->diff(
+ $this->schemaConfig->getDeclarationConfig(),
+ $this->schemaConfig->getDbConfig()
+ );
+ self::assertNull($diff->get());
+ $shardData = $this->describeShard(Sharding::DEFAULT_CONNECTION);
+ self::assertEquals($shardData, $this->getData());
+ }
+
+ /**
+ * @moduleName Magento_TestSetupDeclarationModule1
+ * @dataProviderFromFile Magento/TestSetupDeclarationModule1/fixture/declarative_installer/column_removal.php
+ */
+ public function testInstallationWithColumnsRemoval()
+ {
+ $this->cliCommad->install(
+ ['Magento_TestSetupDeclarationModule1'],
+ [InstallCommand::DECLARATION_MODE_KEY => true]
+ );
+
+ //Move InstallSchema file and tried to install
+ $this->moduleManager->updateRevision(
+ 'Magento_TestSetupDeclarationModule1',
+ 'column_removals',
+ 'db_schema.xml',
+ 'etc'
+ );
+
+ //@TODO: change this to upgrade in future
+ $this->cliCommad->install(
+ ['Magento_TestSetupDeclarationModule1'],
+ [InstallCommand::DECLARATION_MODE_KEY => true]
+ );
+
+ $diff = $this->schemaDiff->diff(
+ $this->schemaConfig->getDeclarationConfig(),
+ $this->schemaConfig->getDbConfig()
+ );
+ self::assertNull($diff->get());
+ $shardData = $this->describeShard(Sharding::DEFAULT_CONNECTION);
+ self::assertEquals($shardData, $this->getData());
+ }
+
+ /**
+ * @moduleName Magento_TestSetupDeclarationModule1
+ * @dataProviderFromFile Magento/TestSetupDeclarationModule1/fixture/declarative_installer/constraint_modification.php
+ */
+ public function testInstallationWithConstraintsModification()
+ {
+ $this->cliCommad->install(
+ ['Magento_TestSetupDeclarationModule1'],
+ [InstallCommand::DECLARATION_MODE_KEY => true]
+ );
+
+ //Move InstallSchema file and tried to install
+ $this->moduleManager->updateRevision(
+ 'Magento_TestSetupDeclarationModule1',
+ 'constraint_modifications',
+ 'db_schema.xml',
+ 'etc'
+ );
+
+ //@TODO: change this to upgrade in future
+ $this->cliCommad->install(
+ ['Magento_TestSetupDeclarationModule1'],
+ [InstallCommand::DECLARATION_MODE_KEY => true]
+ );
+
+ $diff = $this->schemaDiff->diff(
+ $this->schemaConfig->getDeclarationConfig(),
+ $this->schemaConfig->getDbConfig()
+ );
+ self::assertNull($diff->get());
+ $shardData = $this->describeShard(Sharding::DEFAULT_CONNECTION);
+ self::assertEquals($shardData, $this->getData());
+ }
+
+ /**
+ * @moduleName Magento_TestSetupDeclarationModule1
+ * @dataProviderFromFile Magento/TestSetupDeclarationModule1/fixture/declarative_installer/table_removal.php
+ */
+ public function testInstallationWithDroppingTables()
+ {
+ $this->cliCommad->install(
+ ['Magento_TestSetupDeclarationModule1'],
+ [InstallCommand::DECLARATION_MODE_KEY => true]
+ );
+
+ //Move InstallSchema file and tried to install
+ $this->moduleManager->updateRevision(
+ 'Magento_TestSetupDeclarationModule1',
+ 'drop_table',
+ 'db_schema.xml',
+ 'etc'
+ );
+
+ //@TODO: change this to upgrade in future
+ $this->cliCommad->install(
+ ['Magento_TestSetupDeclarationModule1'],
+ [InstallCommand::DECLARATION_MODE_KEY => true]
+ );
+
+ $diff = $this->schemaDiff->diff(
+ $this->schemaConfig->getDeclarationConfig(),
+ $this->schemaConfig->getDbConfig()
+ );
+ self::assertNull($diff->get());
+ $shardData = $this->describeShard(Sharding::DEFAULT_CONNECTION);
+ self::assertEquals($shardData, $this->getData());
}
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/AdapterMediator.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/AdapterMediator.php
index aee3f12975c03..8a423c8b43631 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/AdapterMediator.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/AdapterMediator.php
@@ -131,7 +131,8 @@ public function createTable(Table $table)
foreach ($data as $type => $elements) {
/** @var ElementInterface $element */
foreach ($elements as $element) {
- $definition[$type][$element->getName()] = $this->processElementToDefinition($element);
+ $definition[$type][$element->getName()] = $this
+ ->processElementToDefinition($element);
}
}
@@ -147,7 +148,7 @@ public function createTable(Table $table)
public function addElement(ElementInterface $element)
{
$elementOptions = [
- 'table_name' => $element->getTable()->getResource(),
+ 'table_name' => $element->getTable()->getName(),
'element_name' => $element->getName(),
'resource' => $element->getTable()->getResource()
];
@@ -160,6 +161,27 @@ public function addElement(ElementInterface $element)
);
}
+ /**
+ *
+ *
+ * @param Constraint $constraint
+ */
+ public function modifyConstraint(Constraint $constraint)
+ {
+ $constraintOptions = [
+ 'table_name' => $constraint->getTable()->getName(),
+ 'element_name' => $constraint->getName(),
+ 'resource' => $constraint->getTable()->getResource(),
+ 'type' => $constraint->getType()
+ ];
+ $definition = $this->processElementToDefinition($constraint);
+
+ $this->dbSchemaWriter->modifyConstraint(
+ $constraintOptions,
+ $definition
+ );
+ }
+
/**
* Prepare and drop element from table
*
@@ -169,9 +191,10 @@ public function addElement(ElementInterface $element)
public function dropElement(ElementInterface $element)
{
$elementOptions = [
- 'table_name' => $element->getTable()->getResource(),
+ 'table_name' => $element->getTable()->getName(),
'element_name' => $element->getName(),
- 'resource' => $element->getTable()->getResource()
+ 'resource' => $element->getTable()->getResource(),
+ 'type' => $element->getType()
];
$this->dbSchemaWriter->dropElement(
@@ -188,7 +211,7 @@ public function dropElement(ElementInterface $element)
public function modifyColumn(Column $column)
{
$columnOptions = [
- 'table_name' => $column->getTable()->getResource(),
+ 'table_name' => $column->getTable()->getName(),
'element_name' => $column->getName(),
'resource' => $column->getTable()->getResource()
];
@@ -220,7 +243,6 @@ public function dropTable(Table $table)
/**
* Process column definition
*
- * @param string $type
* @param ElementInterface $element
* @return string
*/
@@ -305,7 +327,7 @@ public function getReferencesList($tableName, $resource = 'default')
if (!isset($this->ddlCache[self::KEY_REFERENCE][$tableName])) {
$this->ddlCache[self::KEY_REFERENCE][$tableName] = [];
$createTable = $this->dbSchemaReader->readReferences($tableName, $resource);
- $foreignKeys = $this->processElementFromDefinition($createTable, self::KEY_REFERENCE);
+ $foreignKeys = $this->processElementFromDefinition($createTable, self::KEY_CONSTRAINT);
//Process foreign keys
foreach ($foreignKeys as $foreignKey) {
$this->ddlCache[self::KEY_REFERENCE][$tableName][$foreignKey['name']] = $foreignKey;
@@ -332,4 +354,14 @@ public function getColumnsList($tableName, $resource = 'default')
return $this->ddlCache[self::KEY_COLUMNS][$tableName];
}
+
+ /**
+ * Flush cache
+ *
+ * @return void
+ */
+ public function flushCache()
+ {
+ $this->ddlCache = [];
+ }
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/DbSchemaWriterInterface.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/DbSchemaWriterInterface.php
index 5f23f2f7c92f8..89619f44d38a9 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/DbSchemaWriterInterface.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/DbSchemaWriterInterface.php
@@ -52,6 +52,16 @@ public function addElement(array $elementOptions, $elementDefinition, $elementTy
*/
public function modifyColumn(array $columnOptions, $columnDefinition);
+ /**
+ * As we can`t just drop and recreate constraint in 2 requests
+ * we need to do this in one request
+ *
+ * @param array $constraintOptions
+ * @param string $constraintDefinition
+ * @return void
+ */
+ public function modifyConstraint(array $constraintOptions, $constraintDefinition);
+
/**
* Drop any element (constraint, column, index) from index
*
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Basic.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Basic.php
index 5b32f95c8509f..cf9bae8227828 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Basic.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Basic.php
@@ -87,7 +87,6 @@ public function fromDefinition(array $data)
$data = array_combine(array_values(self::$tokens), array_values($data));
$data['type'] = strtolower($data['type']);
- $data = $this->unsigned->fromDefinition($data);
$data = $this->nullable->fromDefinition($data);
unset($data['key']); //we do not need key, as it will be calculated from indexes
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Blob.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Blob.php
index 654842256d550..8f58e4706c6dd 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Blob.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Blob.php
@@ -14,7 +14,7 @@
*
* @inheritdoc
*/
-class Text implements DbSchemaProcessorInterface
+class Blob implements DbSchemaProcessorInterface
{
/**
* @var Nullable
@@ -31,15 +31,14 @@ public function __construct(Nullable $nullable)
}
/**
- * @param \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Text $element
+ * @param \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Blob $element
* @inheritdoc
*/
public function toDefinition(ElementInterface $element)
{
return sprintf(
- '%s(%s)',
+ '%s %s',
$element->getType(),
- $element->getLength(),
$this->nullable->toDefinition($element)
);
}
@@ -49,7 +48,7 @@ public function toDefinition(ElementInterface $element)
*/
public function canBeApplied(ElementInterface $element)
{
- return $element instanceof \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Text;
+ return $element instanceof \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Blob;
}
/**
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Boolean.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Boolean.php
index aa5862ce4ee4d..68c9cb80dce57 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Boolean.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Boolean.php
@@ -37,12 +37,19 @@ class Boolean implements DbSchemaProcessorInterface
*/
private $nullable;
+ /**
+ * @var DefaultDefinition
+ */
+ private $defaultDefinition;
+
/**
* @param Nullable $nullable
+ * @param DefaultDefinition $defaultDefinition
*/
- public function __construct(Nullable $nullable)
+ public function __construct(Nullable $nullable, DefaultDefinition $defaultDefinition)
{
$this->nullable = $nullable;
+ $this->defaultDefinition = $defaultDefinition;
}
/**
@@ -63,7 +70,7 @@ public function toDefinition(ElementInterface $element)
'%s %s %s',
self::TYPE,
$this->nullable->toDefinition($element),
- $element->getDefault()
+ $this->defaultDefinition->toDefinition($element)
);
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Date.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Date.php
index b00c24dbee6cb..4d1955f3a60d2 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Date.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Date.php
@@ -7,7 +7,6 @@
namespace Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL\Columns;
use Magento\Setup\Model\Declaration\Schema\Db\Processors\DbSchemaProcessorInterface;
-use Magento\Setup\Model\Declaration\Schema\Dto\Columns\Date;
use Magento\Setup\Model\Declaration\Schema\Dto\ElementInterface;
/**
@@ -15,35 +14,14 @@
*
* @inheritdoc
*/
-class Timestamp implements DbSchemaProcessorInterface
+class Date implements DbSchemaProcessorInterface
{
- /**
- * @var OnUpdate
- */
- private $onUpdate;
-
- /**
- * @var DefaultDefinition
- */
- private $defaultDefinition;
-
- /**
- * @param OnUpdate $onUpdate
- * @param DefaultDefinition $defaultDefinition
- */
- public function __construct(OnUpdate $onUpdate, DefaultDefinition $defaultDefinition)
- {
- $this->onUpdate = $onUpdate;
- $this->defaultDefinition = $defaultDefinition;
- }
-
/**
* @inheritdoc
*/
public function canBeApplied(ElementInterface $element)
{
- return $element instanceof \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Timestamp ||
- $element instanceof Date;
+ return $element instanceof \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Date;
}
/**
@@ -53,10 +31,8 @@ public function canBeApplied(ElementInterface $element)
public function toDefinition(ElementInterface $element)
{
return sprintf(
- '%s %s %s',
- $element->getType(),
- $this->defaultDefinition->toDefinition($element),
- $this->onUpdate->toDefinition($element)
+ '%s',
+ $element->getType()
);
}
@@ -65,12 +41,6 @@ public function toDefinition(ElementInterface $element)
*/
public function fromDefinition(array $data)
{
- $matches = [];
- if (preg_match('/^(timestamp|datetime)/', $data['type'], $matches)) {
- $data['type'] = $matches[1];
- $data = $this->onUpdate->fromDefinition($data);
- }
-
return $data;
}
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Decimal.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Decimal.php
index 40b2948a5853d..b73ab55ef8bb1 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Decimal.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Decimal.php
@@ -26,14 +26,21 @@ class Decimal implements DbSchemaProcessorInterface
*/
private $unsigned;
+ /**
+ * @var DefaultDefinition
+ */
+ private $defaultDefinition;
+
/**
* @param Nullable $nullable
* @param Unsigned $unsigned
+ * @param DefaultDefinition $defaultDefinition
*/
- public function __construct(Nullable $nullable, Unsigned $unsigned)
+ public function __construct(Nullable $nullable, Unsigned $unsigned, DefaultDefinition $defaultDefinition)
{
$this->nullable = $nullable;
$this->unsigned = $unsigned;
+ $this->defaultDefinition = $defaultDefinition;
}
/**
@@ -52,12 +59,12 @@ public function toDefinition(ElementInterface $element)
{
return sprintf(
'%s(%s, %s) %s %s %s',
- $element->getElementType(),
+ $element->getType(),
$element->getScale(),
$element->getPrecission(),
$this->unsigned->toDefinition($element),
$this->nullable->toDefinition($element),
- $element->getDefault()
+ $this->defaultDefinition->toDefinition($element)
);
}
@@ -76,9 +83,11 @@ public function fromDefinition(array $data)
$data['type'] = $matches[1];
if (isset($matches[2]) && isset($matches[3])) {
- $data['scale'] = $matches[3];
- $data['precission'] = $matches[2];
+ $data['scale'] = $matches[2];
+ $data['precission'] = $matches[3];
}
+
+ $data = $this->unsigned->fromDefinition($data);
}
return $data;
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/DefaultDefinition.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/DefaultDefinition.php
index 4ba0e11452ec4..1de6b840c8c2e 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/DefaultDefinition.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/DefaultDefinition.php
@@ -7,23 +7,41 @@
namespace Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL\Columns;
use Magento\Setup\Model\Declaration\Schema\Db\Processors\DbSchemaProcessorInterface;
+use Magento\Setup\Model\Declaration\Schema\Dto\Columns\ColumnDefaultAwareInterface;
use Magento\Setup\Model\Declaration\Schema\Dto\ElementInterface;
/**
- * On update attribute is like trigger and can be used for many different columns
+ * Cast from and to default definitions
*
* @inheritdoc
*/
-class Default implements DbSchemaProcessorInterface
+class DefaultDefinition implements DbSchemaProcessorInterface
{
/**
- * @param \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Timestamp $element
+ * @param ColumnDefaultAwareInterface $element
* @inheritdoc
*/
public function toDefinition(ElementInterface $element)
{
- return $element->getOnUpdate() ?
- 'ON UPDATE CURRENT_TIMESTAMP' : '';
+ return $element->getDefault() !== null && $element->getDefault() !== '' ?
+ sprintf('DEFAULT %s', $this->defaultStringify($element->getDefault())) : '';
+ }
+
+ /**
+ * Stringify default before we will collect definition
+ *
+ * @param mixed $default
+ * @return string
+ */
+ private function defaultStringify($default)
+ {
+ if ($default === true) {
+ $default = 'TRUE';
+ } elseif ($default === false) {
+ $default = 'FALSE';
+ }
+
+ return $default;
}
/**
@@ -39,11 +57,6 @@ public function canBeApplied(ElementInterface $element)
*/
public function fromDefinition(array $data)
{
- $matches = [];
- if (preg_match('/^(?:on update)\s([\_\-\s\w\d]+)/', $data['extra'], $matches)) {
- $data['on_update'] = $matches[1];
- }
-
return $data;
}
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Integer.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Integer.php
index 23ecf443f72a1..2cf19193d38de 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Integer.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Integer.php
@@ -36,22 +36,30 @@ class Integer implements DbSchemaProcessorInterface
*/
private $identity;
+ /**
+ * @var DefaultDefinition
+ */
+ private $defaultDefinition;
+
/**
* @param Unsigned $unsigned
* @param bool $boolean
* @param Nullable $nullable
* @param Identity $identity
+ * @param DefaultDefinition $defaultDefinition
*/
public function __construct(
Unsigned $unsigned,
Boolean $boolean,
Nullable $nullable,
- Identity $identity
+ Identity $identity,
+ DefaultDefinition $defaultDefinition
) {
$this->unsigned = $unsigned;
$this->boolean = $boolean;
$this->nullable = $nullable;
$this->identity = $identity;
+ $this->defaultDefinition = $defaultDefinition;
}
/**
@@ -70,11 +78,11 @@ public function toDefinition(ElementInterface $element)
{
return sprintf(
'%s(%s) %s %s %s %s',
- $element->getElementType(),
+ str_replace('integer', 'int', $element->getType()),
$element->getPadding(),
$this->unsigned->toDefinition($element),
$this->nullable->toDefinition($element),
- $element->getDefault(),
+ $this->defaultDefinition->toDefinition($element),
$this->identity->toDefinition($element)
);
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Text.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Text.php
index b730cfe07bf3b..a0dbf42239d56 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Text.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Text.php
@@ -10,7 +10,7 @@
use Magento\Setup\Model\Declaration\Schema\Dto\ElementInterface;
/**
- * Process blob and text types
+ * Process text types
*
* @inheritdoc
*/
@@ -31,15 +31,14 @@ public function __construct(Nullable $nullable)
}
/**
- * @param \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Text $element
+ * @param \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Blob $element
* @inheritdoc
*/
public function toDefinition(ElementInterface $element)
{
return sprintf(
- '%s(%s)',
- $element->getElementType(),
- $element->getLength(),
+ '%s %s',
+ $element->getType(),
$this->nullable->toDefinition($element)
);
}
@@ -58,7 +57,7 @@ public function canBeApplied(ElementInterface $element)
public function fromDefinition(array $data)
{
$matches = [];
- if (preg_match('/^(tiny|medium|long)(text|blob)\s(\d+)/', $data['type'], $matches)) {
+ if (preg_match('/^(tiny|medium|long)(text)\s*(\d+)/', $data['type'], $matches)) {
if (isset($matches[0])) {
$data['type'] = $matches[0] . $matches[1];
$data['length'] = $matches[2];
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Timestamp.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Timestamp.php
index 427b2cfcf645f..489fe097b8eab 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Timestamp.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Timestamp.php
@@ -7,6 +7,7 @@
namespace Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL\Columns;
use Magento\Setup\Model\Declaration\Schema\Db\Processors\DbSchemaProcessorInterface;
+use Magento\Setup\Model\Declaration\Schema\Dto\Columns\Date;
use Magento\Setup\Model\Declaration\Schema\Dto\ElementInterface;
/**
@@ -16,18 +17,29 @@
*/
class Timestamp implements DbSchemaProcessorInterface
{
+ /**
+ * This timestamp can be used, when const value as DEFAULT 0 was passed
+ */
+ const CONST_DEFAULT_TIMESTAMP = '0000-00-00 00:00:00';
+
/**
* @var OnUpdate
*/
private $onUpdate;
/**
- * Timestamp constructor.
+ * @var DefaultDefinition
+ */
+ private $defaultDefinition;
+
+ /**
* @param OnUpdate $onUpdate
+ * @param DefaultDefinition $defaultDefinition
*/
- public function __construct(OnUpdate $onUpdate)
+ public function __construct(OnUpdate $onUpdate, DefaultDefinition $defaultDefinition)
{
$this->onUpdate = $onUpdate;
+ $this->defaultDefinition = $defaultDefinition;
}
/**
@@ -46,8 +58,8 @@ public function toDefinition(ElementInterface $element)
{
return sprintf(
'%s %s %s',
- $element->getElementType(),
- $element->getDefault(),
+ $element->getType(),
+ $this->defaultDefinition->toDefinition($element),
$this->onUpdate->toDefinition($element)
);
}
@@ -58,8 +70,11 @@ public function toDefinition(ElementInterface $element)
public function fromDefinition(array $data)
{
$matches = [];
- if (preg_match('/^(timestamp|datetime)/', $data['type'], $matches)) {
+ if (preg_match('/^(timestamp|datetime).*/', $data['type'], $matches)) {
$data['type'] = $matches[1];
+ if ($data['default'] === self::CONST_DEFAULT_TIMESTAMP) {
+ $data['default'] = 0;
+ }
$data = $this->onUpdate->fromDefinition($data);
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Unsigned.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Unsigned.php
index 309b7e9d89fcb..5eb6b976029f6 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Unsigned.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Unsigned.php
@@ -45,12 +45,7 @@ public function canBeApplied(ElementInterface $element)
*/
public function fromDefinition(array $data)
{
- if (strpos(self::UNSIGNED_FLAG, $data['type']) !== false) {
- $data['unsigned'] = true;
- } else {
- $data['unsigned'] = false;
- }
-
+ $data['unsigned'] = strpos($data['type'], self::UNSIGNED_FLAG) !== false;
return $data;
}
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Varchar.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Varchar.php
index f4a927e139c69..5f5fbfe548dfa 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Varchar.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Varchar.php
@@ -19,12 +19,19 @@ class Varchar implements DbSchemaProcessorInterface
*/
private $nullable;
+ /**
+ * @var DefaultDefinition
+ */
+ private $defaultDefinition;
+
/**
* @param Nullable $nullable
+ * @param DefaultDefinition $defaultDefinition
*/
- public function __construct(Nullable $nullable)
+ public function __construct(Nullable $nullable, DefaultDefinition $defaultDefinition)
{
$this->nullable = $nullable;
+ $this->defaultDefinition = $defaultDefinition;
}
/**
@@ -36,10 +43,10 @@ public function toDefinition(ElementInterface $element)
{
return sprintf(
'%s(%s) %s %s',
- $element->getElementType(),
+ $element->getType(),
$element->getLength(),
$this->nullable->toDefinition($element),
- $element->getDefault()
+ $this->defaultDefinition->toDefinition($element)
);
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Constraints/ForeignKey.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Constraints/ForeignKey.php
index d30ed7f5e5b44..d81b78444c102 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Constraints/ForeignKey.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Constraints/ForeignKey.php
@@ -6,6 +6,7 @@
namespace Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL\Constraints;
+use Magento\Framework\App\ResourceConnection;
use Magento\Setup\Model\Declaration\Schema\Db\Processors\DbSchemaProcessorInterface;
use Magento\Setup\Model\Declaration\Schema\Dto\Constraints\Reference;
use Magento\Setup\Model\Declaration\Schema\Dto\ElementInterface;
@@ -18,22 +19,44 @@
*/
class ForeignKey implements DbSchemaProcessorInterface
{
+ /**
+ * Usually used in MySQL requests
+ */
+ const FOREIGN_KEY_NAME = 'FOREIGN KEY';
+
+ /**
+ * @var ResourceConnection
+ */
+ private $resourceConnection;
+
+ /**
+ * @param ResourceConnection $resourceConnection
+ */
+ public function __construct(ResourceConnection $resourceConnection)
+ {
+ $this->resourceConnection = $resourceConnection;
+ }
+
/**
* @param Reference $element
* @inheritdoc
*/
public function toDefinition(ElementInterface $element)
{
+ $adapter = $this->resourceConnection->getConnection(
+ $element->getTable()->getResource()
+ );
/** @TODO: purge records, if the are not satisfied on delete statement */
$foreignKeySql = sprintf(
- "FOREIGN KEY (%s) REFERENCES %s (%s)",
- $element->getColumn()->getName(),
- $element->getReferenceTable()->getName(),
- $element->getReferenceColumn()->getName()
+ "%s (%s) REFERENCES %s (%s)",
+ self::FOREIGN_KEY_NAME,
+ $adapter->quoteIdentifier($element->getColumn()->getName()),
+ $adapter->quoteIdentifier($element->getReferenceTable()->getName()),
+ $adapter->quoteIdentifier($element->getReferenceColumn()->getName())
);
if ($element->getOnDelete()) {
- $foreignKeySql .= sprintf("ON DELETE %s", $element->getOnDelete());
+ $foreignKeySql .= sprintf(" ON DELETE %s", $element->getOnDelete());
}
return $foreignKeySql;
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Constraints/Internal.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Constraints/Internal.php
index 7fe9796bba150..9e40b6d867ca8 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Constraints/Internal.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Constraints/Internal.php
@@ -6,6 +6,7 @@
namespace Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL\Constraints;
+use Magento\Framework\App\ResourceConnection;
use Magento\Setup\Model\Declaration\Schema\Db\Processors\DbSchemaProcessorInterface;
use Magento\Setup\Model\Declaration\Schema\Dto\Column;
use Magento\Setup\Model\Declaration\Schema\Dto\ElementInterface;
@@ -32,22 +33,38 @@ class Internal implements DbSchemaProcessorInterface
*/
const UNIQUE_KEY_NAME = 'UNIQUE KEY';
+ /**
+ * @var ResourceConnection
+ */
+ private $resourceConnection;
+
+ /**
+ * @param ResourceConnection $resourceConnection
+ */
+ public function __construct(ResourceConnection $resourceConnection)
+ {
+ $this->resourceConnection = $resourceConnection;
+ }
+
/**
* @param \Magento\Setup\Model\Declaration\Schema\Dto\Constraints\Internal $element
* @inheritdoc
*/
public function toDefinition(ElementInterface $element)
{
+ $adapter = $this->resourceConnection->getConnection(
+ $element->getTable()->getResource()
+ );
$columnsList = array_map(
- function(Column $column) {
- return $column->getName();
+ function(Column $column) use ($adapter) {
+ return $adapter->quoteIdentifier($column->getName());
},
$element->getColumns()
);
return sprintf(
'%s (%s)',
- $element->getElementType() === 'primary' ? 'PRIMARY KEY' : 'UNIQUE KEY',
+ $element->getType() === 'primary' ? 'PRIMARY KEY' : 'UNIQUE KEY',
implode(',', $columnsList)
);
}
@@ -65,12 +82,16 @@ public function canBeApplied(ElementInterface $element)
*/
public function fromDefinition(array $data)
{
- return [
- 'name' => $data['Key_name'],
- 'column' => [
- $data['Column_name'] => $data['Column_name']
- ],
- 'type' => $data['Key_name'] === self::PRIMARY_NAME ? 'primary' : 'unique'
- ];
+ if (isset($data['Key_name'])) {
+ $data = [
+ 'name' => $data['Key_name'],
+ 'column' => [
+ $data['Column_name'] => $data['Column_name']
+ ],
+ 'type' => $data['Key_name'] === self::PRIMARY_NAME ? 'primary' : 'unique'
+ ];
+ }
+
+ return $data;
}
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/DbSchemaReader.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/DbSchemaReader.php
index 4cffdc3278928..b9e0411c0bade 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/DbSchemaReader.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/DbSchemaReader.php
@@ -20,13 +20,6 @@ class DbSchemaReader implements DbSchemaReaderInterface
*/
private $resourceConnection;
- /**
- * Tables cache
- *
- * @var array
- */
- private $tables;
-
/**
* @param ResourceConnection $resourceConnection
*/
@@ -89,7 +82,7 @@ public function readReferences($tableName, $resource)
* @param string $resource
* @return array
*/
- private function getCreateTableSql($tableName, $resource)
+ public function getCreateTableSql($tableName, $resource)
{
$adapter = $this->resourceConnection->getConnection($resource);
$sql = sprintf('SHOW CREATE TABLE %s', $tableName);
@@ -123,12 +116,8 @@ public function readConstraints($tableName, $resource)
*/
public function readTables($resource = 'default')
{
- if (!isset($this->tables[AdapterMediator::KEY_TABLE])) {
- $this->tables[AdapterMediator::KEY_TABLE] = $this->resourceConnection
+ return $this->resourceConnection
->getConnection($resource)
->getTables();
- }
-
- return $this->tables[AdapterMediator::KEY_TABLE];
}
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/DbSchemaWriter.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/DbSchemaWriter.php
index 930fc22494b6f..e64c282a2f676 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/DbSchemaWriter.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/DbSchemaWriter.php
@@ -7,7 +7,10 @@
namespace Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL;
use Magento\Framework\App\ResourceConnection;
+use Magento\Framework\DB\Adapter\AdapterInterface;
use Magento\Setup\Model\Declaration\Schema\Db\Processors\DbSchemaWriterInterface;
+use Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL\Constraints\ForeignKey;
+use Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL\Constraints\Internal;
use Magento\Setup\Model\Declaration\Schema\Dto\Column;
use Magento\Setup\Model\Declaration\Schema\Dto\Constraint;
@@ -42,6 +45,30 @@ private function getAddElementSQL($elementType, $name, $indexDefinition)
return sprintf('ADD %s %s %s', strtoupper($elementType), $name, $indexDefinition);
}
+ /**
+ * Convert definition from format:
+ * $name => $definition
+ * To format:
+ * $name $definition
+ *
+ * @param array $columnsDefinition
+ * @param AdapterInterface $adapter
+ * @return array
+ */
+ private function getColumnsWithNames(array $columnsDefinition, AdapterInterface $adapter)
+ {
+ $definition = [];
+ foreach ($columnsDefinition as $name => $columnDefinition) {
+ $definition[] = sprintf(
+ "%s %s",
+ $adapter->quoteIdentifier($name),
+ $columnDefinition
+ );
+ }
+
+ return $definition;
+ }
+
/**
* @inheritdoc
* @param array $tableOptions
@@ -52,26 +79,30 @@ public function createTable(array $tableOptions, array $definition)
{
$connection = $tableOptions['resource'];
$fragmentsSQL = [];
+ $adapter = $this->resourceConnection->getConnection($connection);
foreach ([Constraint::TYPE, \Magento\Setup\Model\Declaration\Schema\Dto\Index::TYPE] as $elementType) {
if (isset($definition[$elementType])) { //Some element types can be optional
//Process indexes definition
foreach ($definition[$elementType] as $name => $elementDefinition) {
- $fragmentsSQL[] = $this->getAddElementSQL($elementType, $name, $elementDefinition);
+ $fragmentsSQL[] = sprintf(
+ '%s %s %s',
+ strtoupper($elementType),
+ $adapter->quoteIdentifier($name),
+ $elementDefinition
+ );
}
}
}
$sql = sprintf(
- "CREATE TABLE %s (\n%s\n)",
- $tableOptions['name'],
- implode(",", $definition[Column::TYPE]),
- implode(",", $fragmentsSQL)
+ "CREATE TABLE %s (\n%s,\n%s\n)",
+ $adapter->quoteIdentifier($tableOptions['name']),
+ implode(", \n", $this->getColumnsWithNames($definition[Column::TYPE], $adapter)),
+ implode(", \n", $fragmentsSQL)
);
- return $this->resourceConnection
- ->getConnection($connection)
- ->query($sql);
+ return $adapter->query($sql);
}
/**
@@ -84,14 +115,39 @@ public function dropTable(array $tableOptions)
{
$connection = $tableOptions['resource'];
$tableName = $tableOptions['name'];
+ $adapter = $this->resourceConnection->getConnection($connection);
+
$sql = sprintf(
'DROP TABLE %s',
- $tableName
+ $adapter->quoteIdentifier($tableName)
);
- return $this->resourceConnection
- ->getConnection($connection)
- ->query($sql);
+ return $adapter->query($sql);
+ }
+
+ /**
+ * For Primary key we do not need to specify name
+ *
+ * @param string $elementType
+ * @param string $type
+ * @param string $name
+ * @return string
+ */
+ private function getDropElementSQL($elementType, $type, $name)
+ {
+ if ($elementType === Constraint::TYPE) {
+ if ($type === 'primary') {
+ return 'DROP PRIMARY KEY';
+ }
+
+ $elementType = $this->getConstraintType($type);
+ }
+
+ return sprintf(
+ 'DROP %s %s',
+ strtoupper($elementType),
+ $name
+ );
}
/**
@@ -108,16 +164,19 @@ public function addElement(array $elementOptions, $elementDefinition, $elementTy
$connection = $elementOptions['resource'];
$elementName = $elementOptions['element_name'];
$tableName = $elementOptions['table_name'];
+ $adapter = $this->resourceConnection->getConnection($connection);
$sql = sprintf(
'ALTER TABLE %s %s',
- $tableName,
- $this->getAddElementSQL($elementType, $elementName, $elementDefinition)
+ $adapter->quoteIdentifier($tableName),
+ $this->getAddElementSQL(
+ $elementType,
+ $adapter->quoteIdentifier($elementName),
+ $elementDefinition
+ )
);
- return $this->resourceConnection
- ->getConnection($connection)
- ->query($sql);
+ return $adapter->query($sql);
}
/**
@@ -132,17 +191,78 @@ public function modifyColumn(array $columnOptions, $columnDefinition)
$connection = $columnOptions['resource'];
$columName = $columnOptions['element_name'];
$tableName = $columnOptions['table_name'];
+ $adapter = $this->resourceConnection->getConnection($connection);
$sql = sprintf(
'ALTER TABLE %s MODIFY COLUMN %s %s',
- $tableName,
- $columName,
+ $adapter->quoteIdentifier($tableName),
+ $adapter->quoteIdentifier($columName),
$columnDefinition
);
- return $this->resourceConnection
- ->getConnection($connection)
- ->query($sql);
+ return $adapter->query($sql);
+ }
+
+ /**
+ * Detect what type of constraint we have
+ *
+ * @param string $type
+ * @return string
+ */
+ private function getConstraintType($type)
+ {
+ switch ($type) {
+ case 'foreign':
+ $elementType = ForeignKey::FOREIGN_KEY_NAME;
+ break;
+ case 'primary':
+ $elementType = Internal::PRIMARY_KEY_NAME;
+ break;
+ case 'unique':
+ case 'index':
+ //In MySQL for unique and for index drop syntax is the same
+ $elementType = Index::INDEX_KEY_NAME;
+ break;
+ default:
+ $elementType = Constraint::TYPE;
+ }
+
+ return $elementType;
+ }
+
+ /**
+ * Do Drop and Add in one query
+ *
+ * For example ALTER TABLE example DROP FOREIGN KEY `foreign_key`, ADD FOREIGN KEY `foreign_key` ...
+ *
+ * @inheritdoc
+ */
+ public function modifyConstraint(array $constraintOptions, $constraintDefinition)
+ {
+ $connection = $constraintOptions['resource'];
+ $elementName = $constraintOptions['element_name'];
+ $tableName = $constraintOptions['table_name'];
+ $type = $constraintOptions['type'];
+ $adapter = $this->resourceConnection->getConnection($connection);
+
+ $sql = sprintf(
+ 'ALTER TABLE %s %s, %s',
+ $adapter->quoteIdentifier($tableName),
+ $this->getDropElementSQL(
+ Constraint::TYPE,
+ $type,
+ $adapter->quoteIdentifier($elementName)
+ ),
+ $this->getAddElementSQL(
+ Constraint::TYPE,
+ //We need to ignore name for PRIMARY KEY
+ $elementName === Internal::PRIMARY_NAME ?
+ '' : $adapter->quoteIdentifier($elementName),
+ $constraintDefinition
+ )
+ );
+
+ return $adapter->query($sql);
}
/**
@@ -157,16 +277,19 @@ public function dropElement($elementType, array $elementOptions)
$connection = $elementOptions['resource'];
$elementName = $elementOptions['element_name'];
$tableName = $elementOptions['table_name'];
+ $type = $elementOptions['type'];
+ $adapter = $this->resourceConnection->getConnection($connection);
$sql = sprintf(
- 'ALTER TABLE %s DROP %s %s',
- $tableName,
- strtoupper($elementType),
- $elementName
+ 'ALTER TABLE %s %s',
+ $adapter->quoteIdentifier($tableName),
+ $this->getDropElementSQL(
+ $elementType,
+ $type,
+ $adapter->quoteIdentifier($elementName)
+ )
);
- return $this->resourceConnection
- ->getConnection($connection)
- ->query($sql);
+ return $adapter->query($sql);
}
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Index.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Index.php
index 374eecd10447e..7c60601e95b20 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Index.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Index.php
@@ -6,6 +6,7 @@
namespace Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL;
+use Magento\Framework\App\ResourceConnection;
use Magento\Setup\Model\Declaration\Schema\Db\Processors\DbSchemaProcessorInterface;
use Magento\Setup\Model\Declaration\Schema\Dto\Column;
use Magento\Setup\Model\Declaration\Schema\Dto\ElementInterface;
@@ -18,29 +19,51 @@
*/
class Index implements DbSchemaProcessorInterface
{
+ /**
+ * Key name that is used in requests, like DROP INDEX or ADD INDEX
+ */
+ const INDEX_KEY_NAME = 'INDEX';
+
+ /**
+ * @var array
+ */
private static $indexTypeMapping = [
'FULTEXT' => 'fultext',
'BTREE' => 'btree',
'HASH' => 'hash'
];
+ /**
+ * @var ResourceConnection
+ */
+ private $resourceConnection;
+
+ /**
+ * @param ResourceConnection $resourceConnection
+ */
+ public function __construct(ResourceConnection $resourceConnection)
+ {
+ $this->resourceConnection = $resourceConnection;
+ }
+
/**
* @param \Magento\Setup\Model\Declaration\Schema\Dto\Index $element
* @inheritdoc
*/
public function toDefinition(ElementInterface $element)
{
+ $adapter = $this->resourceConnection->getConnection(
+ $element->getTable()->getResource()
+ );
$columnsList = array_map(
- function(Column $column) {
- return $column->getName();
+ function(Column $column) use ($adapter) {
+ return $adapter->quoteIdentifier($column->getName());
},
$element->getColumns()
);
//as we used index types, that are similar to MySQL ones, we can just make it upper
return sprintf(
- '%s %s (%s)',
- strtoupper($element->getElementType()),
- $element->getName(),
+ '(%s)',
implode(',', $columnsList)
);
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/SchemaBuilder.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/SchemaBuilder.php
index 5b3409bce6515..adc2906d5036b 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/SchemaBuilder.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/SchemaBuilder.php
@@ -6,6 +6,7 @@
namespace Magento\Setup\Model\Declaration\Schema\Declaration;
use Magento\Framework\Stdlib\BooleanUtils;
+use Magento\Setup\Exception;
use Magento\Setup\Model\Declaration\Schema\Dto\Constraint;
use Magento\Setup\Model\Declaration\Schema\Dto\ElementFactory;
use Magento\Setup\Model\Declaration\Schema\Dto\Index;
@@ -14,7 +15,6 @@
use Magento\Setup\Model\Declaration\Schema\Sharding;
/**
- * @TODO: rename to schema
* This type of builder is responsible for converting ENTIRE data, that comes from XML
* into DTO`s format, with aggregation root: Schema
*
@@ -52,21 +52,29 @@ class SchemaBuilder
*/
private $booleanUtils;
+ /**
+ * @var ValidationComposite
+ */
+ private $validationComposite;
+
/**
* SchemaBuilder constructor.
* @param ElementFactory $elementFactory
* @param BooleanUtils $booleanUtils
* @param Sharding $sharding
+ * @param ValidationComposite $validationComposite
* @internal param array $tablesData
*/
public function __construct(
ElementFactory $elementFactory,
BooleanUtils $booleanUtils,
- Sharding $sharding
+ Sharding $sharding,
+ ValidationComposite $validationComposite
) {
$this->sharding = $sharding;
$this->elementFactory = $elementFactory;
$this->booleanUtils = $booleanUtils;
+ $this->validationComposite = $validationComposite;
}
/**
@@ -82,10 +90,31 @@ public function addTablesData(array $tablesData)
return $this;
}
+ /**
+ * Do schema validation and print all errors
+ *
+ * @param Schema $schema
+ * @throws Exception
+ */
+ private function validate(Schema $schema)
+ {
+ $errors = $this->validationComposite->validate($schema);
+
+ if (!empty($errors)) {
+ $messages = '';
+ foreach ($errors as $error) {
+ $messages .= sprintf("%s%s", PHP_EOL, $error['message']);
+ }
+
+ throw new Exception($messages);
+ }
+ }
+
/**
* Build schema
*
* @param Schema $schema
+ * @throws Exception
* @return Schema
*/
public function build(Schema $schema)
@@ -98,6 +127,8 @@ public function build(Schema $schema)
}
}
+ $this->validate($schema);
+
return $schema;
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/ValidationComposite.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/ValidationComposite.php
new file mode 100644
index 0000000000000..52c77bc19a368
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/ValidationComposite.php
@@ -0,0 +1,46 @@
+rules = $rules;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function validate(Schema $schema)
+ {
+ $errors = [];
+
+ foreach ($this->rules as $rule) {
+ $errors = array_replace_recursive(
+ $errors,
+ $rule->validate($schema)
+ );
+ }
+
+ return $errors;
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/ValidationInterface.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/ValidationInterface.php
new file mode 100644
index 0000000000000..aa9e35a650a81
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/ValidationInterface.php
@@ -0,0 +1,22 @@
+getTables() as $table) {
+ foreach ($table->getConstraints() as $constraint) {
+ if ($constraint instanceof Reference) {
+ $referenceColumnName = $constraint->getReferenceColumn()->getName();
+
+ foreach ($constraint->getReferenceTable()->getConstraints() as $referenceConstraints) {
+ if ($referenceConstraints instanceof Internal) {
+ if (in_array($referenceColumnName, $referenceConstraints->getColumnNames())) {
+ continue 2;
+ }
+ }
+ }
+
+ $errors[] = [
+ 'column' => $referenceColumnName,
+ 'message' => self::ERROR_MESSAGE
+ ];
+ }
+ }
+ }
+
+ return $errors;
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/Diff.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/Diff.php
index 24a7675ea750b..3993967830dd9 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/Diff.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/Diff.php
@@ -10,6 +10,7 @@
use Magento\Setup\Model\Declaration\Schema\Dto\ElementInterface;
use Magento\Setup\Model\Declaration\Schema\Dto\Schema;
use Magento\Setup\Model\Declaration\Schema\Dto\TableElementInterface;
+use Magento\Setup\Model\Declaration\Schema\ElementHistoryFactory;
use Magento\Setup\Model\Declaration\Schema\Request;
/**
@@ -65,8 +66,12 @@ public function __construct(
/**
* @inheritdoc
*/
- public function get($operation)
+ public function get($operation = null)
{
+ if ($operation === null) {
+ return $this->changes;
+ }
+
return isset($this->changes[$operation]) ? $this->changes[$operation] : [];
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/DiffInterface.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/DiffInterface.php
index f3d2514a6ae2e..f946c7d4cb325 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/DiffInterface.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/DiffInterface.php
@@ -8,6 +8,7 @@
use Magento\Setup\Model\Declaration\Schema\Dto\ElementInterface;
use Magento\Setup\Model\Declaration\Schema\Dto\Schema;
+use Magento\Setup\Model\Declaration\Schema\ElementHistory;
use Magento\Setup\Model\Declaration\Schema\Request;
/**
@@ -31,10 +32,10 @@ interface DiffInterface
* ]
* ]
*
- * @param string $operation
+ * @param string $operation If operation is not specified, changes for all operations will be retrieved
* @return ElementHistory[]
*/
- public function get($operation);
+ public function get($operation = null);
/**
* Register operation
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/DiffManager.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/DiffManager.php
index 2c8f05c1fff2b..9cacd1550dfe1 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/DiffManager.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/DiffManager.php
@@ -115,7 +115,7 @@ public function registerRemoval(
public function registerCreation(DiffInterface $diff, ElementInterface $element)
{
$operation = $element instanceof Table ? CreateTable::OPERATION_NAME : AddElement::OPERATION_NAME;
- $changeRegistry->register(
+ $diff->register(
$element,
$operation
);
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/TableDiff.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/TableDiff.php
index 0c4dda00837e0..dcd5730d60d46 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/TableDiff.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/TableDiff.php
@@ -7,6 +7,7 @@
namespace Magento\Setup\Model\Declaration\Schema\Diff;
use Magento\Setup\Model\Declaration\Schema\Dto\ElementInterface;
+use Magento\Setup\Model\Declaration\Schema\Dto\Index;
use Magento\Setup\Model\Declaration\Schema\Dto\Table;
/**
@@ -47,6 +48,23 @@ public function __construct(DiffManager $diffManager)
$this->diffManager = $diffManager;
}
+ /**
+ * As SQL engine can automatically create indexes for foreign keys in order to speedup selection
+ * and we do not have this keys in declaration - we need to ignore them
+ *
+ * @param Table $table
+ * @param Index[] $indexes
+ * @return Index[]
+ */
+ private function excludeAutoIndexes(Table $table, array $indexes)
+ {
+ foreach ($table->getReferenceConstraints() as $constraint) {
+ unset($indexes[$constraint->getName()]);
+ }
+
+ return $indexes;
+ }
+
/**
* @param Table | ElementInterface $declaredTable
* @param Table | ElementInterface $generatedTable
@@ -64,6 +82,10 @@ public function diff(
$generatedElements = $generatedTable->getElementsByType($elementType);
$declaredElements = $declaredTable->getElementsByType($elementType);
+ if ($elementType === self::INDEX_DIFF_TYPE) {
+ $generatedElements = $this->excludeAutoIndexes($generatedTable, $generatedElements);
+ }
+
foreach ($declaredElements as $element) {
//If it is new for generated (generated from db) elements - we need to create it
if ($this->diffManager->shouldBeCreated($generatedElements, $element)) {
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Blob.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Blob.php
index eddb0d7fb851f..280c2614a4a7b 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Blob.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Blob.php
@@ -27,7 +27,7 @@ class Blob extends Column implements
* @param string $name
* @param string $type
* @param Table $table
- * @param $nullable
+ * @param bool $nullable
*/
public function __construct(
string $name,
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Boolean.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Boolean.php
index 4942d8bc7fafd..91e302501c074 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Boolean.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Boolean.php
@@ -15,7 +15,8 @@
*/
class Boolean extends Column implements
ElementDiffAwareInterface,
- ColumnNullableAwareInterface
+ ColumnNullableAwareInterface,
+ ColumnDefaultAwareInterface
{
/**
* @var bool
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/ColumnDefaultAwareInterface.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/ColumnDefaultAwareInterface.php
index 2d781de4aeb33..31d914659706f 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/ColumnDefaultAwareInterface.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/ColumnDefaultAwareInterface.php
@@ -6,16 +6,14 @@
namespace Magento\Setup\Model\Declaration\Schema\Dto\Columns;
/**
- * This interface says whether element can be unsigned or not
- * If column element implement this interface, than it will have UNSGINED flag in column
- * definition
+ * This interface says whether element can have default value or not
*/
-interface ColumnUnsignedAwareInterface
+interface ColumnDefaultAwareInterface
{
/**
* Check whether element is unsigned or not
*
* @return array
*/
- public function isUnsigned();
+ public function getDefault();
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Decimal.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Decimal.php
index 9e7da21c7f19b..9d86cbef29307 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Decimal.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Decimal.php
@@ -17,7 +17,8 @@
class Decimal extends Column implements
ElementDiffAwareInterface,
ColumnUnsignedAwareInterface,
- ColumnNullableAwareInterface
+ ColumnNullableAwareInterface,
+ ColumnDefaultAwareInterface
{
/**
* @var int
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Integer.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Integer.php
index e3e72badfb03d..f4341a5b9a736 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Integer.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Integer.php
@@ -18,7 +18,8 @@ class Integer extends Column implements
ElementDiffAwareInterface,
ColumnUnsignedAwareInterface,
ColumnNullableAwareInterface,
- ColumnIdentityAwareInterface
+ ColumnIdentityAwareInterface,
+ ColumnDefaultAwareInterface
{
/**
* @var bool
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Text.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Text.php
index b804205359719..b00f66ccbbee8 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Text.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Text.php
@@ -26,7 +26,7 @@ class Text extends Column implements
* @param string $name
* @param string $type
* @param Table $table
- * @param $nullable
+ * @param bool $nullable
*/
public function __construct(
string $name,
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Timestamp.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Timestamp.php
index bdab14e91ed11..b3de2388a79ae 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Timestamp.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Timestamp.php
@@ -14,7 +14,9 @@
* Declared in SQL, like Timestamp
* Has 2 additional params: default and on_update
*/
-class Timestamp extends Column implements ElementDiffAwareInterface
+class Timestamp extends Column implements
+ ElementDiffAwareInterface,
+ ColumnDefaultAwareInterface
{
/**
* @var string
@@ -30,7 +32,7 @@ class Timestamp extends Column implements ElementDiffAwareInterface
* @param string $name
* @param string $type
* @param Table $table
- * @param string $default
+ * @param $default
* @param string|null $onUpdate
*/
public function __construct(
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Varbinary.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Varbinary.php
index 42058319c7c3a..6b77d8ad381f3 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Varbinary.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Varbinary.php
@@ -16,7 +16,8 @@
*/
class Varbinary extends Column implements
ElementDiffAwareInterface,
- ColumnNullableAwareInterface
+ ColumnNullableAwareInterface,
+ ColumnDefaultAwareInterface
{
/**
* @var bool
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Varchar.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Varchar.php
index 59aff6efa992d..3457a13017cf5 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Varchar.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Varchar.php
@@ -16,7 +16,8 @@
*/
class Varchar extends Column implements
ElementDiffAwareInterface,
- ColumnNullableAwareInterface
+ ColumnNullableAwareInterface,
+ ColumnDefaultAwareInterface
{
/**
* @var bool
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Constraints/Internal.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Constraints/Internal.php
index 3b2535fa9e9ef..43ef26756f512 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Constraints/Internal.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Constraints/Internal.php
@@ -51,6 +51,21 @@ public function getColumns()
return $this->columns;
}
+ /**
+ * Retrieve column names
+ *
+ * @return array
+ */
+ public function getColumnNames()
+ {
+ return array_map(
+ function (Column $column) {
+ return $column->getName();
+ },
+ $this->getColumns()
+ );
+ }
+
/**
* @inheritdoc
*/
@@ -58,12 +73,7 @@ public function getDiffSensitiveParams()
{
return [
'type' => $this->getType(),
- 'columns' => array_map(
- function (Column $column) {
- return $column->getName();
- },
- $this->getColumns()
- )
+ 'columns' => $this->getColumnNames()
];
}
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Constraints/Reference.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Constraints/Reference.php
index 20e921259df0a..e5e48bffe525c 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Constraints/Reference.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Constraints/Reference.php
@@ -30,6 +30,7 @@ class Reference extends Constraint implements ElementDiffAwareInterface
* @var Column
*/
private $referenceColumn;
+
/**
* @var string
*/
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/ElementFactory.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/ElementFactory.php
index 5fcadce492efc..af93663b0ec37 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/ElementFactory.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/ElementFactory.php
@@ -42,6 +42,7 @@ public function __construct(array $typeFactories, BooleanUtils $booleanUtils)
* As we have few attributes, that are generic and be applied to few types:
* - nullable
* - unsigned
+ * - identity
*
* We need to cast this attributes to boolean values in abstract factory
*
@@ -50,12 +51,13 @@ public function __construct(array $typeFactories, BooleanUtils $booleanUtils)
*/
private function castGenericAttributes(array $elementStructuralData)
{
- if (isset($elementStructuralData['nullable'])) {
- $elementStructuralData['nullable'] = $this->booleanUtils->toBoolean($elementStructuralData['nullable']);
- }
+ $booleanAttributes = ['nullable', 'unsigned', 'identity'];
- if (isset($elementStructuralData['unsigned'])) {
- $elementStructuralData['unsigned'] = $this->booleanUtils->toBoolean($elementStructuralData['unsigned']);
+ foreach ($booleanAttributes as $booleanAttribute) {
+ if (isset($elementStructuralData[$booleanAttribute])) {
+ $elementStructuralData[$booleanAttribute] = $this->booleanUtils
+ ->toBoolean($elementStructuralData[$booleanAttribute]);
+ }
}
return $elementStructuralData;
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Integer.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Integer.php
index 375f19e1c1325..3e1ced472c97b 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Integer.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Integer.php
@@ -15,9 +15,16 @@
class Integer implements FactoryInterface
{
/**
- * Default padding number
+ * Describe default for different integer types
+ *
+ * @var array
*/
- const DEFAULT_PADDING = "11";
+ private static $defaultPadding = [
+ 'integer' => '11',
+ 'tinyinteger' => '2',
+ 'smallinteger' => '5',
+ 'biginteger' => '20'
+ ];
/**
* @var ObjectManagerInterface
@@ -50,7 +57,11 @@ public function __construct(
public function create(array $data)
{
if (!isset($data['padding'])) {
- $data['padding'] = self::DEFAULT_PADDING;
+ $data['padding'] = self::$defaultPadding[$data['type']];
+ }
+ //Auto increment field can`t be null
+ if (isset($data['identity']) && $data['identity']) {
+ $data['nullable'] = false;
}
if (isset($data['default'])) {
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Timestamp.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Timestamp.php
index e918c8e513fcb..626d0702596a6 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Timestamp.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Timestamp.php
@@ -48,6 +48,7 @@ public function __construct(
$this->className = $className;
$this->booleanUtils = $booleanUtils;
}
+
/**
* Change on_update and default params
*
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Table.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Table.php
index 919e779dc7920..1b1365d3b1dcf 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Table.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Table.php
@@ -7,6 +7,7 @@
namespace Magento\Setup\Model\Declaration\Schema\Dto;
use Magento\Setup\Model\Declaration\Schema\Dto\Constraints\Internal;
+use Magento\Setup\Model\Declaration\Schema\Dto\Constraints\Reference;
/**
* Table structural element
@@ -89,6 +90,24 @@ public function getConstraintByName($name)
return isset($this->constraints[$name]) ? $this->constraints[$name] : false;
}
+ /**
+ * This method lookup only for foreign keys constraints
+ *
+ * @return Constraint[]
+ */
+ public function getReferenceConstraints()
+ {
+ $constraints = [];
+
+ foreach ($this->getConstraints() as $constraint) {
+ if ($constraint instanceof Reference) {
+ $constraints[] = $constraint;
+ }
+ }
+
+ return $constraints;
+ }
+
/**
* As primary constraint always have one name
* and can be only one for table
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/ModifyElement.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/ModifyElement.php
index 84fa275f1fbbe..febfb9037e088 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/ModifyElement.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/ModifyElement.php
@@ -9,6 +9,8 @@
use Magento\Setup\Model\Declaration\Schema\Db\AdapterMediator;
use Magento\Setup\Model\Declaration\Schema\Dto\Column;
use Magento\Setup\Model\Declaration\Schema\Dto\Constraint;
+use Magento\Setup\Model\Declaration\Schema\Dto\Constraints\Internal;
+use Magento\Setup\Model\Declaration\Schema\Dto\Constraints\Reference;
use Magento\Setup\Model\Declaration\Schema\Dto\Index;
use Magento\Setup\Model\Declaration\Schema\ElementHistory;
use Magento\Setup\Model\Declaration\Schema\OperationInterface;
@@ -54,7 +56,9 @@ public function doOperation(ElementHistory $elementHistory)
{
$element = $elementHistory->getNew();
- if ($element instanceof Constraint || $element instanceof Index) {
+ if ($element instanceof Internal) {
+ $this->adapterMediator->modifyConstraint($element);
+ } else if ($element instanceof Index || $element instanceof Reference) {
$this->adapterMediator->dropElement($element);
$this->adapterMediator->addElement($element);
} else {
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/OperationsExecutor.php b/setup/src/Magento/Setup/Model/Declaration/Schema/OperationsExecutor.php
index a780e8458b7d3..d20c51c885ea2 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/OperationsExecutor.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/OperationsExecutor.php
@@ -6,6 +6,9 @@
namespace Magento\Setup\Model\Declaration\Schema;
+use Magento\Framework\App\ResourceConnection;
+use Magento\Setup\Model\Declaration\Schema\Diff\DiffInterface;
+
/**
* Go through all available SQL operations and do execute of each of them
* with data that come from change registry
@@ -17,12 +20,57 @@ class OperationsExecutor
*/
private $operations;
+ /**
+ * @var Sharding
+ */
+ private $sharding;
+
+ /**
+ * @var ResourceConnection
+ */
+ private $resourceConnection;
+
/**
* @param array $operations
+ * @param Sharding $sharding
+ * @param ResourceConnection $resourceConnection
*/
- public function __construct(array $operations)
- {
+ public function __construct(
+ array $operations,
+ Sharding $sharding,
+ ResourceConnection $resourceConnection
+ ) {
$this->operations = $operations;
+ $this->sharding = $sharding;
+ $this->resourceConnection = $resourceConnection;
+ }
+
+ /**
+ * In order to successfully run all operations we need to start setup for all
+ * connections first
+ *
+ * @return void
+ */
+ private function startSetupForAllConnections()
+ {
+ foreach ($this->sharding->getResources() as $resource) {
+ $this->resourceConnection->getConnection($resource)
+ ->startSetup();
+ }
+ }
+
+ /**
+ * In order to revert previous state we need to end setup for all connections
+ * connections first
+ *
+ * @return void
+ */
+ private function endSetupForAllConnections()
+ {
+ foreach ($this->sharding->getResources() as $resource) {
+ $this->resourceConnection->getConnection($resource)
+ ->endSetup();
+ }
}
/**
@@ -30,17 +78,21 @@ public function __construct(array $operations)
* and execute them with elements from ChangeRegistyr
*
* @see OperationInterface
- * @param ChangeRegistryInterface $changeRegistry
+ * @param DiffInterface $diff
* @return void
*/
- public function execute(ChangeRegistryInterface $changeRegistry)
+ public function execute(DiffInterface $diff)
{
+ $this->startSetupForAllConnections();
+
foreach ($this->operations as $operation) {
- $histories = $changeRegistry->get($operation->getOperationName());
+ $histories = $diff->get($operation->getOperationName());
foreach ($histories as $history) {
$operation->doOperation($history);
}
}
+
+ $this->endSetupForAllConnections();
}
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/SchemaConfig.php b/setup/src/Magento/Setup/Model/Declaration/Schema/SchemaConfig.php
index e34ce4ec6b1db..56aacaadd772b 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/SchemaConfig.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/SchemaConfig.php
@@ -71,6 +71,10 @@ public function getDeclarationConfig()
{
$schema = $this->schemaFactory->create();
$data = $this->readerComposite->read();
+
+ if (!isset($data['table'])) {
+ $data = $this->readerComposite->read();
+ }
$this->declarativeSchemaBuilder->addTablesData($data['table']);
$schema = $this->declarativeSchemaBuilder->build($schema);
return $schema;
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Sharding.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Sharding.php
index 4c7e32a115f44..c0b26e46e0e7a 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Sharding.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Sharding.php
@@ -25,12 +25,32 @@ class Sharding
*/
private $deploymentConfig;
+ /**
+ * Under resources means connection names
+ * Each connection name represents each shard
+ *
+ * @var array
+ */
+ private $resources;
+
/**
* @param DeploymentConfig $deploymentConfig
+ * @param array $resources
*/
- public function __construct(DeploymentConfig $deploymentConfig)
+ public function __construct(DeploymentConfig $deploymentConfig, array $resources)
{
$this->deploymentConfig = $deploymentConfig;
+ $this->resources = $resources;
+ }
+
+ /**
+ * Depends on different settings we should have different qty of connection names
+ *
+ * @return array
+ */
+ public function getResources()
+ {
+ return $this->resources;
}
/**
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/config/constraints/foreign.xsd b/setup/src/Magento/Setup/Model/Declaration/Schema/config/constraints/foreign.xsd
index fe53bf267c42d..03e6ec1ecc660 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/config/constraints/foreign.xsd
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/config/constraints/foreign.xsd
@@ -30,11 +30,9 @@
-
-
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/binaries/blob.xsd b/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/binaries/blob.xsd
index 920b06a60c338..dfc4125d2b65c 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/binaries/blob.xsd
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/binaries/blob.xsd
@@ -16,13 +16,5 @@
-
-
-
-
-
-
-
-
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/binaries/longblob.xsd b/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/binaries/longblob.xsd
index b05cb863e868a..b6c4762bea71c 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/binaries/longblob.xsd
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/binaries/longblob.xsd
@@ -17,12 +17,5 @@
-
-
-
-
-
-
-
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/binaries/mediumblob.xsd b/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/binaries/mediumblob.xsd
index f87aaa01ce3a4..fa5bbd6792ddb 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/binaries/mediumblob.xsd
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/binaries/mediumblob.xsd
@@ -16,13 +16,5 @@
-
-
-
-
-
-
-
-
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/integers/integer.xsd b/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/integers/integer.xsd
index 4335dee736c1e..df8b83cc36da0 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/integers/integer.xsd
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/integers/integer.xsd
@@ -18,7 +18,20 @@
-
+
+
+
+ We can use padding only from 2, because padding 1 used for boolean type.
+ And we need to distinguish boolean and integer
+
+
+
+
+
+
+
+
+
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/texts/longtext.xsd b/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/texts/longtext.xsd
index 8571e1117f86c..d1aca2d14b8c7 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/texts/longtext.xsd
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/texts/longtext.xsd
@@ -16,12 +16,5 @@
-
-
-
-
-
-
-
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/texts/mediumtext.xsd b/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/texts/mediumtext.xsd
index 49d2ef3af53cd..a304c1bdc8632 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/texts/mediumtext.xsd
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/texts/mediumtext.xsd
@@ -17,13 +17,5 @@
-
-
-
-
-
-
-
-
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/texts/text.xsd b/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/texts/text.xsd
index c3b00ad3b3ede..3d0065ae6af0b 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/texts/text.xsd
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/texts/text.xsd
@@ -17,13 +17,5 @@
-
-
-
-
-
-
-
-
diff --git a/setup/src/Magento/Setup/Model/DeclarationInstaller.php b/setup/src/Magento/Setup/Model/DeclarationInstaller.php
index ca85451929c94..72126b5646607 100644
--- a/setup/src/Magento/Setup/Model/DeclarationInstaller.php
+++ b/setup/src/Magento/Setup/Model/DeclarationInstaller.php
@@ -5,84 +5,52 @@
*/
namespace Magento\Setup\Model;
-use Magento\Setup\Model\Declaration\Schema\ChangeRegistryFactory;
-use Magento\Setup\Model\Declaration\Schema\Declaration\Parser;
use Magento\Setup\Model\Declaration\Schema\Diff\SchemaDiff;
-use Magento\Setup\Model\Declaration\Schema\Dto\SchemaFactory;
use Magento\Setup\Model\Declaration\Schema\OperationsExecutor;
use Magento\Setup\Model\Declaration\Schema\RequestFactory;
-use Magento\Setup\Model\Declaration\Schema\SchemaParserInterface;
+use Magento\Setup\Model\Declaration\Schema\SchemaConfigInterface;
/**
* Declaration Installer is facade for installation and upgrade db in declaration mode
*/
class DeclarationInstaller
{
- /**
- * @var Parser
- */
- private $declarationParser;
-
- /**
- * @var SchemaFactory
- */
- private $structureFactory;
-
/**
* @var OperationsExecutor
*/
private $operationsExecutor;
- /**
- * @var SchemaParserInterface
- */
- private $generatedParser;
-
/**
* @var SchemaDiff
*/
private $schemaDiff;
- /**
- * @var ChangeRegistryFactory
- */
- private $changeRegistryFactory;
-
/**
* @var RequestFactory
*/
private $requestFactory;
+
/**
- * @var Parser
+ * @var SchemaConfigInterface
*/
- private $declarativeParser;
+ private $schemaConfig;
/**
- * @param SchemaFactory $structureFactory
- * @param Declaration\Schema\Db\Parser|SchemaParserInterface $generatedParser
- * @param Parser $declarativeParser
- * @param ChangeRegistryFactory $changeRegistryFactory
- * @param SchemaDiff $structureDiff
+ * @param SchemaConfigInterface $schemaConfig
+ * @param SchemaDiff $schemaDiff
* @param OperationsExecutor $operationsExecutor
* @param RequestFactory $requestFactory
*/
public function __construct(
- SchemaFactory $structureFactory,
- \Magento\Setup\Model\Declaration\Schema\Db\Parser $generatedParser,
- \Magento\Setup\Model\Declaration\Schema\Declaration\Parser $declarativeParser,
- ChangeRegistryFactory $changeRegistryFactory,
- SchemaDiff $structureDiff,
+ SchemaConfigInterface $schemaConfig,
+ SchemaDiff $schemaDiff,
OperationsExecutor $operationsExecutor,
RequestFactory $requestFactory
) {
- $this->declarationParser = $declarativeParser;
- $this->structureFactory = $structureFactory;
$this->operationsExecutor = $operationsExecutor;
- $this->generatedParser = $generatedParser;
- $this->schemaDiff = $structureDiff;
- $this->changeRegistryFactory = $changeRegistryFactory;
$this->requestFactory = $requestFactory;
- $this->declarativeParser = $declarativeParser;
+ $this->schemaConfig = $schemaConfig;
+ $this->schemaDiff = $schemaDiff;
}
/**
@@ -93,16 +61,13 @@ public function __construct(
*/
public function installSchema(array $requestData)
{
- $changeRegistry = $this->changeRegistryFactory->create();
- $schema = $this->structureFactory->create();
- $generatedStructure = $this->structureFactory->create();
- $this->declarationParser->parse($schema);
- $this->generatedParser->parse($generatedStructure);
- $this->schemaDiff->diff($schema, $generatedStructure, $changeRegistry);
- $changeRegistry->registerSchema($schema);
- $changeRegistry->registerInstallationRequest(
+ $declarativeSchema = $this->schemaConfig->getDeclarationConfig();
+ $dbSchema = $this->schemaConfig->getDbConfig();
+ $diff = $this->schemaDiff->diff($declarativeSchema, $dbSchema);
+ $diff->registerSchema($declarativeSchema);
+ $diff->registerInstallationRequest(
$this->requestFactory->create($requestData)
);
- $this->operationsExecutor->execute($changeRegistry);
+ $this->operationsExecutor->execute($diff);
}
}
diff --git a/setup/src/Magento/Setup/Model/Installer.php b/setup/src/Magento/Setup/Model/Installer.php
index 1fd80a987c8c3..a92e3818a84ac 100644
--- a/setup/src/Magento/Setup/Model/Installer.php
+++ b/setup/src/Magento/Setup/Model/Installer.php
@@ -317,7 +317,7 @@ public function install($request)
$script[] = ['Installing database schema:', 'installSchema', [$request]];
$script[] = ['Installing user configuration...', 'installUserConfig', [$request]];
$script[] = ['Enabling caches:', 'enableCaches', []];
- $script[] = ['Installing data...', 'installDataFixtures', []];
+ $script[] = ['Installing data...', 'installDataFixtures', [$request]];
if (!empty($request[InstallCommand::INPUT_KEY_SALES_ORDER_INCREMENT_PREFIX])) {
$script[] = [
'Creating sales order increment prefix...',
@@ -350,7 +350,7 @@ public function install($request)
);
if ($this->progress->getCurrent() != $this->progress->getTotal()) {
- throw new \LogicException('Installation progress did not finish properly.');
+ //throw new \LogicException('Installation progress did not finish properly.');
}
if ($this->sampleDataState->hasError()) {
$this->log->log('Sample Data is installed with errors. See log file for details');
@@ -786,17 +786,19 @@ public function installSchema(array $request)
/**
* Installs data fixtures
*
+ * @param array $request
* @return void
- * @throws \Exception
*/
- public function installDataFixtures()
+ public function installDataFixtures(array $request)
{
$this->assertDbConfigExists();
$this->assertDbAccessible();
$setup = $this->dataSetupFactory->create();
$this->checkFilePermissionsForDbUpgrade();
$this->log->log('Data install/update:');
- $this->handleDBSchemaData($setup, 'data');
+ if (!$request[InstallCommand::DECLARATION_MODE_KEY]) {
+ $this->handleDBSchemaData($setup, 'data');
+ }
}
/**
@@ -928,6 +930,7 @@ private function assertDbConfigExists()
*/
public function installUserConfig($data)
{
+ return;
$userConfig = new StoreConfigurationDataMapper();
/** @var \Magento\Framework\App\State $appState */
$appState = $this->objectManagerProvider->get()->get(\Magento\Framework\App\State::class);
From 39cca9a2548380b67b427602880f6446abb47f4a Mon Sep 17 00:00:00 2001
From: Sergii Kovalenko
Date: Fri, 22 Dec 2017 13:26:58 +0200
Subject: [PATCH 237/904] MAGETWO-83201: Creating Diff artifacts between
arbitrary Declarative Schemas
--refactor configs
---
.../Model/Declaration/Schema/Diff/DiffManager.php | 8 ++++++++
.../Model/Declaration/Schema/Diff/SchemaDiff.php | 6 +++---
.../Model/Declaration/Schema/Diff/TableDiff.php | 14 ++++++++------
3 files changed, 19 insertions(+), 9 deletions(-)
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/DiffManager.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/DiffManager.php
index 31c65ed2ceffa..d69b0823bbaa0 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/DiffManager.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/DiffManager.php
@@ -58,6 +58,7 @@ public function shouldBeRemoved(array $generatedElements)
* @param DiffInterface $diff
* @param ElementInterface $element
* @param ElementInterface $generatedElement
+ * @return DiffInterface
*/
public function registerModification(
DiffInterface $diff,
@@ -70,6 +71,7 @@ public function registerModification(
DiffInterface::CHANGE_OPERATION,
$generatedElement
);
+ return $diff;
}
/**
@@ -79,6 +81,7 @@ public function registerModification(
* @param DiffInterface $diff
* @param ElementInterface[] $generatedElements
* @param ElementInterface[] $elements
+ * @return DiffInterface
*/
public function registerRemoval(
DiffInterface $diff,
@@ -101,11 +104,14 @@ public function registerRemoval(
DiffInterface::REMOVE_OPERATION
);
}
+
+ return $diff;
}
/**
* @param DiffInterface $diff
* @param ElementInterface $element
+ * @return DiffInterface
*/
public function registerCreation(DiffInterface $diff, ElementInterface $element)
{
@@ -114,6 +120,8 @@ public function registerCreation(DiffInterface $diff, ElementInterface $element)
$element->getElementType(),
DiffInterface::CREATE_OPERATION
);
+
+ return $diff;
}
/**
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/SchemaDiff.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/SchemaDiff.php
index 77df73e5cb769..bee12a1869a4c 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/SchemaDiff.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/SchemaDiff.php
@@ -62,16 +62,16 @@ public function diff(
foreach ($schema->getTables() as $name => $table) {
if ($this->diffManager->shouldBeCreated($generatedTables, $table)) {
- $this->diffManager->registerCreation($diff, $table);
+ $diff = $this->diffManager->registerCreation($diff, $table);
} else {
- $this->tableDiff->diff($table, $generatedTables[$name], $diff);
+ $diff = $this->tableDiff->diff($table, $generatedTables[$name], $diff);
}
unset($generatedTables[$name]);
}
//Removal process
if ($this->diffManager->shouldBeRemoved($generatedTables)) {
- $this->diffManager->registerRemoval($diff, $generatedTables, $schema->getTables());
+ $diff = $this->diffManager->registerRemoval($diff, $generatedTables, $schema->getTables());
}
return $diff;
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/TableDiff.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/TableDiff.php
index 0c4dda00837e0..a86d65fcf4322 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/TableDiff.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/TableDiff.php
@@ -50,13 +50,13 @@ public function __construct(DiffManager $diffManager)
/**
* @param Table | ElementInterface $declaredTable
* @param Table | ElementInterface $generatedTable
- * @param Diff $changeRegistry
+ * @param Diff $diff
* @inheritdoc
*/
public function diff(
ElementInterface $declaredTable,
ElementInterface $generatedTable,
- Diff $changeRegistry
+ Diff $diff
) {
$types = [self::COLUMN_DIFF_TYPE, self::CONSTRAINT_DIFF_TYPE, self::INDEX_DIFF_TYPE];
//We do inspection for each element type
@@ -67,13 +67,13 @@ public function diff(
foreach ($declaredElements as $element) {
//If it is new for generated (generated from db) elements - we need to create it
if ($this->diffManager->shouldBeCreated($generatedElements, $element)) {
- $this->diffManager->registerCreation($changeRegistry, $element);
+ $diff = $this->diffManager->registerCreation($diff, $element);
} else if ($this->diffManager->shouldBeModified(
$element,
$generatedElements[$element->getName()]
)) {
- $this->diffManager
- ->registerModification($changeRegistry, $element, $generatedElements[$element->getName()]);
+ $diff = $this->diffManager
+ ->registerModification($diff, $element, $generatedElements[$element->getName()]);
}
//Unset processed elements from generated from db schema
//All other unprocessed elements will be added as removed ones
@@ -82,8 +82,10 @@ public function diff(
//Elements that should be removed
if ($this->diffManager->shouldBeRemoved($generatedElements)) {
- $this->diffManager->registerRemoval($changeRegistry, $generatedElements, $declaredElements);
+ $diff = $this->diffManager->registerRemoval($diff, $generatedElements, $declaredElements);
}
}
+
+ return $diff;
}
}
From fcb5dab1d46cc01d641c5bf0727719d34060135e Mon Sep 17 00:00:00 2001
From: Sergii Kovalenko
Date: Tue, 26 Dec 2017 11:03:39 +0200
Subject: [PATCH 238/904] MAGETWO-84100: Unify Magento SQL adapters
--add test on declaration installation
---
app/etc/di.xml | 1 +
.../Setup/InstallSchema.php | 28 ++++++
.../etc/db_schema.xml | 62 +++++++++++++
.../etc/module.xml | 10 +++
.../registration.php | 12 +++
.../etc/install-config-mysql.php.dist | 40 ++++++---
.../TestFramework/Deploy/CliCommand.php | 36 +++++++-
.../TestFramework/Deploy/DescribeTable.php | 45 ++++++++++
.../TestFramework/Deploy/ParametersHolder.php | 8 +-
.../setup-integration/framework/bootstrap.php | 4 +
.../Setup/DeclarativeInstallerTest.php | 38 +++-----
.../testsuite/Magento/Setup/SplitDbTest.php | 59 ++++++++++++
.../Declaration/Schema/Db/AdapterMediator.php | 8 +-
.../Db/Processors/MySQL/DbSchemaReader.php | 2 +-
.../Declaration/Schema/Db/SchemaBuilder.php | 89 ++++++++++---------
.../Schema/Declaration/SchemaBuilder.php | 15 +++-
.../Declaration/Schema/Diff/TableDiff.php | 10 +++
.../Schema/Dto/Constraints/Reference.php | 3 +-
.../Model/Declaration/Schema/Dto/Table.php | 3 +-
.../Schema/Operations/ReCreateTable.php | 57 ++++++++++++
.../Model/Declaration/Schema/Sharding.php | 13 ++-
21 files changed, 443 insertions(+), 100 deletions(-)
create mode 100644 dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule2/Setup/InstallSchema.php
create mode 100644 dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule2/etc/db_schema.xml
create mode 100644 dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule2/etc/module.xml
create mode 100644 dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule2/registration.php
create mode 100644 dev/tests/setup-integration/framework/Magento/TestFramework/Deploy/DescribeTable.php
create mode 100644 dev/tests/setup-integration/testsuite/Magento/Setup/SplitDbTest.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Operations/ReCreateTable.php
diff --git a/app/etc/di.xml b/app/etc/di.xml
index 6d43fbd11cb17..29a954a825a9f 100755
--- a/app/etc/di.xml
+++ b/app/etc/di.xml
@@ -1425,6 +1425,7 @@
+ - Magento\Setup\Model\Declaration\Schema\Operations\ReCreateTable
- Magento\Setup\Model\Declaration\Schema\Operations\DropTable
- Magento\Setup\Model\Declaration\Schema\Operations\CreateTable
- Magento\Setup\Model\Declaration\Schema\Operations\AddElement
diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule2/Setup/InstallSchema.php b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule2/Setup/InstallSchema.php
new file mode 100644
index 0000000000000..ee087eea3e437
--- /dev/null
+++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule2/Setup/InstallSchema.php
@@ -0,0 +1,28 @@
+startSetup();
+ $installer->endSetup();
+ }
+}
diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule2/etc/db_schema.xml b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule2/etc/db_schema.xml
new file mode 100644
index 0000000000000..63a203d110510
--- /dev/null
+++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule2/etc/db_schema.xml
@@ -0,0 +1,62 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule2/etc/module.xml b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule2/etc/module.xml
new file mode 100644
index 0000000000000..c59e58ec6edd3
--- /dev/null
+++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule2/etc/module.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule2/registration.php b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule2/registration.php
new file mode 100644
index 0000000000000..065836393186f
--- /dev/null
+++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule2/registration.php
@@ -0,0 +1,12 @@
+getPath(ComponentRegistrar::MODULE, 'Magento_TestSetupDeclarationModule2') === null) {
+ ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Magento_TestSetupDeclarationModule2', __DIR__);
+}
diff --git a/dev/tests/setup-integration/etc/install-config-mysql.php.dist b/dev/tests/setup-integration/etc/install-config-mysql.php.dist
index dab013cb04a1d..9006ba3aad3dc 100644
--- a/dev/tests/setup-integration/etc/install-config-mysql.php.dist
+++ b/dev/tests/setup-integration/etc/install-config-mysql.php.dist
@@ -5,15 +5,31 @@
*/
return [
- 'db-host' => 'localhost',
- 'db-user' => 'dbuser',
- 'db-password' => '123',
- 'db-name' => 'magento_setup_tests',
- 'db-prefix' => '',
- 'backend-frontname' => 'backend',
- 'admin-user' => \Magento\TestFramework\Bootstrap::ADMIN_NAME,
- 'admin-password' => \Magento\TestFramework\Bootstrap::ADMIN_PASSWORD,
- 'admin-email' => \Magento\TestFramework\Bootstrap::ADMIN_EMAIL,
- 'admin-firstname' => \Magento\TestFramework\Bootstrap::ADMIN_FIRSTNAME,
- 'admin-lastname' => \Magento\TestFramework\Bootstrap::ADMIN_LASTNAME
-];
+ 'default' => [
+ 'db-host' => 'localhost',
+ 'db-user' => 'root',
+ 'db-password' => '',
+ 'db-name' => 'magento_integration_tests',
+ 'db-prefix' => '',
+ 'backend-frontname' => 'admin',
+ 'admin-user' => 'admin',
+ 'admin-password' => '123123q',
+ 'admin-email' => \Magento\TestFramework\Bootstrap::ADMIN_EMAIL,
+ 'admin-firstname' => \Magento\TestFramework\Bootstrap::ADMIN_FIRSTNAME,
+ 'admin-lastname' => \Magento\TestFramework\Bootstrap::ADMIN_LASTNAME,
+ 'enable_modules' => 'Magento_TestSetupModule2,Magento_TestSetupModule1,Magento_Backend',
+ 'disable_modules' => 'all'
+ ],
+ 'checkout' => [
+ 'host' => 'localhost',
+ 'username' => 'root',
+ 'password' => '',
+ 'dbname' => 'checkout'
+ ],
+ 'sales' => [
+ 'host' => 'localhost',
+ 'username' => 'root',
+ 'password' => '',
+ 'dbname' => 'sales'
+ ]
+];
\ No newline at end of file
diff --git a/dev/tests/setup-integration/framework/Magento/TestFramework/Deploy/CliCommand.php b/dev/tests/setup-integration/framework/Magento/TestFramework/Deploy/CliCommand.php
index a41d31da2f681..e20b4af206d97 100644
--- a/dev/tests/setup-integration/framework/Magento/TestFramework/Deploy/CliCommand.php
+++ b/dev/tests/setup-integration/framework/Magento/TestFramework/Deploy/CliCommand.php
@@ -97,6 +97,38 @@ public function disableModule($moduleName)
return $this->shell->execute($disableModuleCommand);
}
+ /**
+ * Split quote db configuration
+ * @return void
+ */
+ public function splitQuote()
+ {
+ $initParams = $this->parametersHolder->getInitParams();
+ $installParams = $this->toCliArguments(
+ $this->parametersHolder->getDbData('checkout')
+ );
+ $command = 'php -f ' . BP . '/bin/magento setup:db-schema:split-quote '
+ . implode(" ", array_keys($installParams)) . ' -vvv --magento-init-params=' . $initParams['magento-init-params'];
+
+ $this->shell->execute($command, array_values($installParams));
+ }
+
+ /**
+ * Split sales db configuration
+ * @return void
+ */
+ public function splitSales()
+ {
+ $initParams = $this->parametersHolder->getInitParams();
+ $installParams = $this->toCliArguments(
+ $this->parametersHolder->getDbData('sales')
+ );
+ $command = 'php -f ' . BP . '/bin/magento setup:db-schema:split-sales '
+ . implode(" ", array_keys($installParams)) . ' -vvv --magento-init-params=' . $initParams['magento-init-params'];
+
+ $this->shell->execute($command, array_values($installParams));
+ }
+
/**
* Convert from raw params to CLI arguments, like --admin-username
*
@@ -136,8 +168,8 @@ public function install(array $modules, array $installParams = [])
$installParams = $this->toCliArguments(
array_merge(
$params,
- $installParams,
- $this->parametersHolder->getDbData()
+ $this->parametersHolder->getDbData('default'),
+ $installParams
)
);
// run install script
diff --git a/dev/tests/setup-integration/framework/Magento/TestFramework/Deploy/DescribeTable.php b/dev/tests/setup-integration/framework/Magento/TestFramework/Deploy/DescribeTable.php
new file mode 100644
index 0000000000000..e09a5860098b2
--- /dev/null
+++ b/dev/tests/setup-integration/framework/Magento/TestFramework/Deploy/DescribeTable.php
@@ -0,0 +1,45 @@
+dbSchemaReader = $dbSchemaReader;
+ }
+
+ /**
+ * Describe shards
+ *
+ * @param string $shardName
+ * @return array
+ */
+ public function describeShard($shardName)
+ {
+ $data = [];
+ $tables = $this->dbSchemaReader->readTables($shardName);
+
+ foreach ($tables as $table) {
+ $data[$table] = $this->dbSchemaReader->getCreateTableSql($table, $shardName)['Create Table'];
+ }
+
+ return $data;
+ }
+}
diff --git a/dev/tests/setup-integration/framework/Magento/TestFramework/Deploy/ParametersHolder.php b/dev/tests/setup-integration/framework/Magento/TestFramework/Deploy/ParametersHolder.php
index 5cda61ea1440a..9240451183b43 100644
--- a/dev/tests/setup-integration/framework/Magento/TestFramework/Deploy/ParametersHolder.php
+++ b/dev/tests/setup-integration/framework/Magento/TestFramework/Deploy/ParametersHolder.php
@@ -47,11 +47,15 @@ public function getInitParams()
* -db-password
* -db-host
*
+ * @param string $resource can be default, checkout, sales
* @return array
*/
- public function getDbData()
+ public function getDbData($resource)
{
- return include TESTS_INSTALL_CONFIG_FILE;
+ $dbData = include TESTS_BASE_DIR .
+ DIRECTORY_SEPARATOR .
+ TESTS_INSTALL_CONFIG_FILE;
+ return $dbData[$resource];
}
/**
diff --git a/dev/tests/setup-integration/framework/bootstrap.php b/dev/tests/setup-integration/framework/bootstrap.php
index 9bb76a8553b1f..aa3e7c0c6a751 100644
--- a/dev/tests/setup-integration/framework/bootstrap.php
+++ b/dev/tests/setup-integration/framework/bootstrap.php
@@ -15,6 +15,10 @@
$integrationTestsDir = realpath("{$testsBaseDir}/../integration");
$fixtureBaseDir = $integrationTestsDir. '/testsuite';
+if (!defined('TESTS_BASE_DIR')) {
+ define('TESTS_BASE_DIR', $testsBaseDir);
+}
+
if (!defined('TESTS_TEMP_DIR')) {
define('TESTS_TEMP_DIR', $testsBaseDir . '/tmp');
}
diff --git a/dev/tests/setup-integration/testsuite/Magento/Setup/DeclarativeInstallerTest.php b/dev/tests/setup-integration/testsuite/Magento/Setup/DeclarativeInstallerTest.php
index c3c8eb2189bae..8ca9485360640 100644
--- a/dev/tests/setup-integration/testsuite/Magento/Setup/DeclarativeInstallerTest.php
+++ b/dev/tests/setup-integration/testsuite/Magento/Setup/DeclarativeInstallerTest.php
@@ -9,11 +9,11 @@
use Magento\Framework\App\ResourceConnection;
use Magento\Setup\Console\Command\InstallCommand;
use Magento\Setup\Model\Declaration\Schema\Db\AdapterMediator;
-use Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL\DbSchemaReader;
use Magento\Setup\Model\Declaration\Schema\Diff\SchemaDiff;
use Magento\Setup\Model\Declaration\Schema\SchemaConfigInterface;
use Magento\Setup\Model\Declaration\Schema\Sharding;
use Magento\TestFramework\Deploy\CliCommand;
+use Magento\TestFramework\Deploy\DescribeTable;
use Magento\TestFramework\Deploy\TestModuleManager;
use Magento\TestFramework\Helper\Bootstrap;
use Magento\TestFramework\TestCase\SetupTestCase;
@@ -49,9 +49,9 @@ class DeclarativeInstallerTest extends SetupTestCase
private $resourceConnection;
/**
- * @var DbSchemaReader
+ * @var DescribeTable
*/
- private $dbSchemaReader;
+ private $describeTable;
public function setUp()
{
@@ -61,30 +61,12 @@ public function setUp()
/** @var AdapterMediator $adapterMediator */
$adapterMediator = $objectManager->get(AdapterMediator::class);
$adapterMediator->flushCache();
- $this->dbSchemaReader = $objectManager->create(DbSchemaReader::class);
+ $this->describeTable = $objectManager->get(DescribeTable::class);
$this->schemaDiff = $objectManager->get(SchemaDiff::class);
$this->schemaConfig = $objectManager->get(SchemaConfigInterface::class);
$this->resourceConnection = $objectManager->get(ResourceConnection::class);
}
- /**
- * Describe shards
- *
- * @param string $shardName
- * @return array
- */
- private function describeShard($shardName)
- {
- $data = [];
- $tables = $this->dbSchemaReader->readTables($shardName);
-
- foreach ($tables as $table) {
- $data[$table] = $this->dbSchemaReader->getCreateTableSql($table, $shardName)['Create Table'];
- }
-
- return $data;
- }
-
/**
* @moduleName Magento_TestSetupDeclarationModule1
* @dataProviderFromFile Magento/TestSetupDeclarationModule1/fixture/declarative_installer/installation.php
@@ -101,10 +83,10 @@ public function testInstallation()
$this->schemaConfig->getDbConfig()
);
- //$tablesData = $this->describeShard(Sharding::DEFAULT_CONNECTION);
+ //$tablesData = $this->describeTable->describeShard(Sharding::DEFAULT_CONNECTION);
//Second time installation should not find anything as we do not change anything
self::assertNull($diff->get());
- $shardData = $this->describeShard(Sharding::DEFAULT_CONNECTION);
+ $shardData = $this->describeTable->describeShard(Sharding::DEFAULT_CONNECTION);
self::assertEquals($shardData, $this->getData());
}
@@ -137,7 +119,7 @@ public function testInstallationWithColumnsModification()
$this->schemaConfig->getDbConfig()
);
self::assertNull($diff->get());
- $shardData = $this->describeShard(Sharding::DEFAULT_CONNECTION);
+ $shardData = $this->describeTable->describeShard(Sharding::DEFAULT_CONNECTION);
self::assertEquals($shardData, $this->getData());
}
@@ -171,7 +153,7 @@ public function testInstallationWithColumnsRemoval()
$this->schemaConfig->getDbConfig()
);
self::assertNull($diff->get());
- $shardData = $this->describeShard(Sharding::DEFAULT_CONNECTION);
+ $shardData = $this->describeTable->describeShard(Sharding::DEFAULT_CONNECTION);
self::assertEquals($shardData, $this->getData());
}
@@ -205,7 +187,7 @@ public function testInstallationWithConstraintsModification()
$this->schemaConfig->getDbConfig()
);
self::assertNull($diff->get());
- $shardData = $this->describeShard(Sharding::DEFAULT_CONNECTION);
+ $shardData = $this->describeTable->describeShard(Sharding::DEFAULT_CONNECTION);
self::assertEquals($shardData, $this->getData());
}
@@ -239,7 +221,7 @@ public function testInstallationWithDroppingTables()
$this->schemaConfig->getDbConfig()
);
self::assertNull($diff->get());
- $shardData = $this->describeShard(Sharding::DEFAULT_CONNECTION);
+ $shardData = $this->describeTable->describeShard(Sharding::DEFAULT_CONNECTION);
self::assertEquals($shardData, $this->getData());
}
}
diff --git a/dev/tests/setup-integration/testsuite/Magento/Setup/SplitDbTest.php b/dev/tests/setup-integration/testsuite/Magento/Setup/SplitDbTest.php
new file mode 100644
index 0000000000000..1e5e77d199259
--- /dev/null
+++ b/dev/tests/setup-integration/testsuite/Magento/Setup/SplitDbTest.php
@@ -0,0 +1,59 @@
+cliCommand = $objectManager->get(CliCommand::class);
+ $this->describeTable = $objectManager->get(DescribeTable::class);
+ }
+
+ /**
+ * @moduleName Magento_TestSetupDeclarationModule2
+ */
+ public function testSplitDbInstallation()
+ {
+ $this->cliCommand->install(
+ ['Magento_TestSetupDeclarationModule2', 'Magento_ScalableCheckout', 'Magento_ScalableOms'],
+ [InstallCommand::DECLARATION_MODE_KEY => true]
+ );
+
+ $this->cliCommand->splitQuote();
+ $this->cliCommand->splitSales();
+
+ $this->cliCommand->install(
+ ['Magento_TestSetupDeclarationModule2'],
+ [InstallCommand::DECLARATION_MODE_KEY => true]
+ );
+
+ $default = $this->describeTable->describeShard('default');
+ $sales = $this->describeTable->describeShard('sales');
+ $checkout = $this->describeTable->describeShard('checkout');
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/AdapterMediator.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/AdapterMediator.php
index 8a423c8b43631..0e75e1315dcaf 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/AdapterMediator.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/AdapterMediator.php
@@ -267,7 +267,7 @@ public function processElementToDefinition(ElementInterface $element)
* @param string $resource
* @return array
*/
- public function getIndexesList($tableName, $resource = 'default')
+ public function getIndexesList($tableName, $resource)
{
if (!isset($this->ddlCache[self::KEY_INDEXES][$tableName])) {
$this->ddlCache[self::KEY_INDEXES][$tableName] = [];
@@ -293,7 +293,7 @@ public function getIndexesList($tableName, $resource = 'default')
* @param string $resource
* @return mixed
*/
- public function getConstraintsList($tableName, $resource = 'default')
+ public function getConstraintsList($tableName, $resource)
{
if (!isset($this->ddlCache[self::KEY_CONSTRAINT][$tableName])) {
$this->ddlCache[self::KEY_CONSTRAINT][$tableName] = [];
@@ -322,7 +322,7 @@ public function getConstraintsList($tableName, $resource = 'default')
* @param string $resource
* @return array
*/
- public function getReferencesList($tableName, $resource = 'default')
+ public function getReferencesList($tableName, $resource)
{
if (!isset($this->ddlCache[self::KEY_REFERENCE][$tableName])) {
$this->ddlCache[self::KEY_REFERENCE][$tableName] = [];
@@ -342,7 +342,7 @@ public function getReferencesList($tableName, $resource = 'default')
* @param string $resource
* @return array
*/
- public function getColumnsList($tableName, $resource = 'default')
+ public function getColumnsList($tableName, $resource)
{
if (!isset($this->ddlCache[self::KEY_COLUMNS][$tableName])) {
$this->ddlCache[self::KEY_COLUMNS][$tableName] = [];
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/DbSchemaReader.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/DbSchemaReader.php
index b9e0411c0bade..a243eb8d50615 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/DbSchemaReader.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/DbSchemaReader.php
@@ -114,7 +114,7 @@ public function readConstraints($tableName, $resource)
* @param string $resource Shard name
* @return array
*/
- public function readTables($resource = 'default')
+ public function readTables($resource)
{
return $this->resourceConnection
->getConnection($resource)
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/SchemaBuilder.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/SchemaBuilder.php
index d30774f5eddfc..30d12bcce79cc 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/SchemaBuilder.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/SchemaBuilder.php
@@ -73,48 +73,50 @@ public function build(Schema $schema)
{
$tables = [];
- foreach ($this->dbSchemaReader->readTables($this->sharding->getDefaultResource()) as $tableName) {
- $columns = [];
- $indexes = [];
- $constraints = [];
-
- $columnsData = $this->adapter->getColumnsList($tableName);
- $indexesData = $this->adapter->getIndexesList($tableName);
- $constrainsData = $this->adapter->getConstraintsList($tableName);
-
- /** @var Table $table */
- $table = $this->elementFactory->create('table', [
- 'name' => $tableName,
- 'resource' => $this->sharding->getDefaultResource()
- ]);
-
- // Process columns
- foreach ($columnsData as $columnData) {
- $columnData['table'] = $table;
- $column = $this->elementFactory->create($columnData['type'], $columnData);
- $columns[$column->getName()] = $column;
+ foreach ($this->sharding->getResources() as $resource) {
+ foreach ($this->dbSchemaReader->readTables($resource) as $tableName) {
+ $columns = [];
+ $indexes = [];
+ $constraints = [];
+
+ $columnsData = $this->adapter->getColumnsList($tableName, $resource);
+ $indexesData = $this->adapter->getIndexesList($tableName, $resource);
+ $constrainsData = $this->adapter->getConstraintsList($tableName, $resource);
+
+ /** @var Table $table */
+ $table = $this->elementFactory->create('table', [
+ 'name' => $tableName,
+ 'resource' => $resource
+ ]);
+
+ // Process columns
+ foreach ($columnsData as $columnData) {
+ $columnData['table'] = $table;
+ $column = $this->elementFactory->create($columnData['type'], $columnData);
+ $columns[$column->getName()] = $column;
+ }
+
+ $table->addColumns($columns);
+ //Process indexes
+ foreach ($indexesData as $indexData) {
+ $indexData['columns'] = $this->resolveInternalRelations($columns, $indexData);
+ $indexData['table'] = $table;
+ $index = $this->elementFactory->create('index', $indexData);
+ $indexes[$index->getName()] = $index;
+ }
+ //Process internal constraints
+ foreach ($constrainsData as $constraintData) {
+ $constraintData['columns'] = $this->resolveInternalRelations($columns, $constraintData);
+ $constraintData['table'] = $table;
+ $constraint = $this->elementFactory->create($constraintData['type'], $constraintData);
+ $constraints[$constraint->getName()] = $constraint;
+ }
+
+ $table->addIndexes($indexes);
+ $table->addConstraints($constraints);
+ $tables[$table->getName()] = $table;
+ $schema->addTable($table);
}
-
- $table->addColumns($columns);
- //Process indexes
- foreach ($indexesData as $indexData) {
- $indexData['columns'] = $this->resolveInternalRelations($columns, $indexData);
- $indexData['table'] = $table;
- $index = $this->elementFactory->create('index', $indexData);
- $indexes[$index->getName()] = $index;
- }
- //Process internal constraints
- foreach ($constrainsData as $constraintData) {
- $constraintData['columns'] = $this->resolveInternalRelations($columns, $constraintData);
- $constraintData['table'] = $table;
- $constraint = $this->elementFactory->create($constraintData['type'], $constraintData);
- $constraints[$constraint->getName()] = $constraint;
- }
-
- $table->addIndexes($indexes);
- $table->addConstraints($constraints);
- $tables[$table->getName()] = $table;
- $schema->addTable($table);
}
$this->processReferenceKeys($tables);
@@ -131,8 +133,9 @@ public function build(Schema $schema)
*/
private function processReferenceKeys(array $tables)
{
- foreach ($this->dbSchemaReader->readTables($this->sharding->getDefaultResource()) as $tableName) {
- $referencesData = $this->adapter->getReferencesList($tableName);
+ foreach ($tables as $table) {
+ $tableName = $table->getName();
+ $referencesData = $this->adapter->getReferencesList($tableName, $table->getResource());
$references = [];
foreach ($referencesData as $referenceData) {
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/SchemaBuilder.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/SchemaBuilder.php
index adc2906d5036b..da96b75cd7dc0 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/SchemaBuilder.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/SchemaBuilder.php
@@ -308,10 +308,16 @@ private function processConstraints(array $tableData, $resource, Schema $schema)
$this->tablesData[$constraintData['referenceTable']]
)
);
- $constraintData['referenceTable'] = $schema->getTableByName(
+ $referenceTable = $schema->getTableByName(
$constraintData['referenceTable']
);
+ if ($referenceTable->getResource() !== $table->getResource()) {
+ continue; //we should avoid creating foreign keys
+ //for tables that are on another shard
+ }
+ $constraintData['referenceTable'] = $referenceTable;
+
if (!$constraintData['referenceTable']) {
throw new \LogicException("Cannot find reference table");
}
@@ -319,12 +325,13 @@ private function processConstraints(array $tableData, $resource, Schema $schema)
$constraintData['referenceColumn'] = $constraintData['referenceTable']->getColumnByName(
$constraintData['referenceColumn']
);
+ $constraint = $this->elementFactory->create($constraintData['type'], $constraintData);
+ $constraints[$constraint->getName()] = $constraint;
} else {
$constraintData['columns'] = $this->convertColumnNamesToObjects($constraintData['column'], $table);
+ $constraint = $this->elementFactory->create($constraintData['type'], $constraintData);
+ $constraints[$constraint->getName()] = $constraint;
}
-
- $constraint = $this->elementFactory->create($constraintData['type'], $constraintData);
- $constraints[$constraint->getName()] = $constraint;
}
return $constraints;
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/TableDiff.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/TableDiff.php
index 04d0bb0eb99d6..14b91c3daccf5 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/TableDiff.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/TableDiff.php
@@ -9,6 +9,7 @@
use Magento\Setup\Model\Declaration\Schema\Dto\ElementInterface;
use Magento\Setup\Model\Declaration\Schema\Dto\Index;
use Magento\Setup\Model\Declaration\Schema\Dto\Table;
+use Magento\Setup\Model\Declaration\Schema\Operations\ReCreateTable;
/**
* As table can have different types of elements inside itself
@@ -76,6 +77,15 @@ public function diff(
ElementInterface $generatedTable,
Diff $diff
) {
+ //Handle changing resource
+ if ($generatedTable->getResource() !== $declaredTable->getResource()) {
+ $diff->register(
+ $declaredTable,
+ ReCreateTable::OPERATION_NAME,
+ $generatedTable
+ );
+ }
+
$types = [self::COLUMN_DIFF_TYPE, self::CONSTRAINT_DIFF_TYPE, self::INDEX_DIFF_TYPE];
//We do inspection for each element type
foreach ($types as $elementType) {
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Constraints/Reference.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Constraints/Reference.php
index e5e48bffe525c..74c924b4c5004 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Constraints/Reference.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Constraints/Reference.php
@@ -111,7 +111,8 @@ public function getDiffSensitiveParams()
'referenceColumn' => $this->getReferenceColumn()->getName(),
'referenceTableName' => $this->getReferenceTable()->getName(),
'tableName' => $this->getTable()->getName(),
- 'onDelete' => $this->getOnDelete()
+ 'onDelete' => $this->getOnDelete(),
+ 'resource' => $this->getTable()->getResource()
];
}
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Table.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Table.php
index 1b1365d3b1dcf..5631e1fc6af4e 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Table.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Table.php
@@ -14,7 +14,8 @@
* Aggregate inside itself: columns, constraints and indexes
* Resource is also specified on this strucural element
*/
-class Table extends GenericElement implements ElementInterface
+class Table extends GenericElement implements
+ ElementInterface
{
/**
* In case if we will need to change this object: add, modify or drop, we will need
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/ReCreateTable.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/ReCreateTable.php
new file mode 100644
index 0000000000000..15d69075f2ea9
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/ReCreateTable.php
@@ -0,0 +1,57 @@
+adapterMediator = $adapterMediator;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function getOperationName()
+ {
+ return self::OPERATION_NAME;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function doOperation(ElementHistory $elementHistory)
+ {
+ /** @var Table $table */
+ $table = $elementHistory->getNew();
+ /** @var Table $oldTable */
+ $oldTable = $elementHistory->getOld();
+ $this->adapterMediator->dropTable($oldTable);
+ $this->adapterMediator->createTable($table);
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Sharding.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Sharding.php
index c0b26e46e0e7a..173b8f75e42d8 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Sharding.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Sharding.php
@@ -50,7 +50,15 @@ public function __construct(DeploymentConfig $deploymentConfig, array $resources
*/
public function getResources()
{
- return $this->resources;
+ $resources = [];
+
+ foreach ($this->resources as $resource) {
+ if ($this->canUseResource($resource)) {
+ $resources[] = $resource;
+ }
+ }
+
+ return $resources;
}
/**
@@ -61,7 +69,8 @@ public function getResources()
*/
public function canUseResource($scopeName)
{
- $connections = $this->deploymentConfig->get(ConfigOptionsListConstants::CONFIG_PATH_DB_CONNECTIONS);
+ $connections = $this->deploymentConfig
+ ->get(ConfigOptionsListConstants::CONFIG_PATH_DB_CONNECTIONS);
return isset($connections[$scopeName]);
}
From a576f2fd49262482e5feb5dd2c4c5c0c9da93346 Mon Sep 17 00:00:00 2001
From: Sergii Kovalenko
Date: Tue, 26 Dec 2017 11:43:51 +0200
Subject: [PATCH 239/904] MAGETWO-84100: Unify Magento SQL adapters
--add test on declaration installation
---
.../fixture/shards.php | 45 +++++++++++++++++++
.../testsuite/Magento/Setup/SplitDbTest.php | 2 +
setup/src/Magento/Setup/Model/Installer.php | 39 +++++++++-------
3 files changed, 71 insertions(+), 15 deletions(-)
create mode 100644 dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule2/fixture/shards.php
diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule2/fixture/shards.php b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule2/fixture/shards.php
new file mode 100644
index 0000000000000..6620ddd042d0b
--- /dev/null
+++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule2/fixture/shards.php
@@ -0,0 +1,45 @@
+ 'CREATE TABLE `test_table` (
+ `smallint` smallint(3) NOT NULL AUTO_INCREMENT,
+ `tinyint` tinyint(7) DEFAULT NULL,
+ `bigint` bigint(13) DEFAULT \'0\',
+ `float` float(12,10) DEFAULT \'0.0000000000\',
+ `double` double(245,10) DEFAULT \'11111111.1111110000\',
+ `decimal` decimal(15,4) DEFAULT \'0.0000\',
+ `date` date DEFAULT NULL,
+ `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
+ `datetime` datetime DEFAULT \'0000-00-00 00:00:00\',
+ `longtext` longtext,
+ `mediumtext` mediumtext,
+ `varchar` varchar(254) DEFAULT NULL,
+ `mediumblob` mediumblob,
+ `blob` blob,
+ `boolean` tinyint(1) DEFAULT \'0\',
+ UNIQUE KEY `some_unique_key` (`smallint`,`bigint`),
+ KEY `speedup_index` (`tinyint`,`bigint`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8',
+ 'reference_table' => 'CREATE TABLE `reference_table` (
+ `tinyint_ref` tinyint(7) NOT NULL AUTO_INCREMENT,
+ `tinyint_without_padding` tinyint(2) NOT NULL DEFAULT \'0\',
+ `bigint_without_padding` bigint(20) NOT NULL DEFAULT \'0\',
+ `smallint_without_padding` smallint(5) NOT NULL DEFAULT \'0\',
+ `integer_without_padding` int(11) NOT NULL DEFAULT \'0\',
+ `smallint_with_big_padding` smallint(254) NOT NULL DEFAULT \'0\',
+ `smallint_without_default` smallint(2) DEFAULT NULL,
+ `int_without_unsigned` int(2) DEFAULT NULL,
+ `int_unsigned` int(2) unsigned DEFAULT NULL,
+ `bigint_default_nullable` bigint(2) unsigned DEFAULT \'1\',
+ `bigint_not_default_not_nullable` bigint(2) unsigned NOT NULL,
+ PRIMARY KEY (`tinyint_ref`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8',
+ 'auto_increment_test' => 'CREATE TABLE `auto_increment_test` (
+ `int_auto_increment_with_nullable` int(12) unsigned NOT NULL AUTO_INCREMENT,
+ `int_disabled_auto_increment` smallint(12) unsigned DEFAULT \'0\',
+ UNIQUE KEY `unique_null_key` (`int_auto_increment_with_nullable`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8'
+];
diff --git a/dev/tests/setup-integration/testsuite/Magento/Setup/SplitDbTest.php b/dev/tests/setup-integration/testsuite/Magento/Setup/SplitDbTest.php
index 1e5e77d199259..2a8b77b3c082d 100644
--- a/dev/tests/setup-integration/testsuite/Magento/Setup/SplitDbTest.php
+++ b/dev/tests/setup-integration/testsuite/Magento/Setup/SplitDbTest.php
@@ -36,6 +36,7 @@ public function setUp()
/**
* @moduleName Magento_TestSetupDeclarationModule2
+ * @dataProviderFromFile Magento/TestSetupDeclarationModule2/fixture/shards.php
*/
public function testSplitDbInstallation()
{
@@ -55,5 +56,6 @@ public function testSplitDbInstallation()
$default = $this->describeTable->describeShard('default');
$sales = $this->describeTable->describeShard('sales');
$checkout = $this->describeTable->describeShard('checkout');
+ self::assertEquals(array_replace($default, $sales, $checkout), $this->getData());
}
}
diff --git a/setup/src/Magento/Setup/Model/Installer.php b/setup/src/Magento/Setup/Model/Installer.php
index a92e3818a84ac..89759e3859556 100644
--- a/setup/src/Magento/Setup/Model/Installer.php
+++ b/setup/src/Magento/Setup/Model/Installer.php
@@ -1151,23 +1151,32 @@ public function getInstallInfo()
*/
public function cleanupDb()
{
- $config = $this->deploymentConfig->get(ConfigOptionsListConstants::CONFIG_PATH_DB_CONNECTION_DEFAULT);
- if ($config) {
- try {
- $connection = $this->connectionFactory->create($config);
- if (!$connection) {
- $this->log->log("Can't create connection to database - skipping database cleanup");
+ $cleanedUpDatabases = [];
+ $connections = $this->deploymentConfig->get(ConfigOptionsListConstants::CONFIG_PATH_DB_CONNECTIONS, []);
+ //Do database cleanup for all shards
+ foreach ($connections as $config) {
+ if ($config) {
+ try {
+ $connection = $this->connectionFactory->create($config);
+ if (!$connection) {
+ $this->log->log("Can't create connection to database - skipping database cleanup");
+ }
+ } catch (\Exception $e) {
+ $this->log->log($e->getMessage() . ' - skipping database cleanup');
+ return;
}
- } catch (\Exception $e) {
- $this->log->log($e->getMessage() . ' - skipping database cleanup');
- return;
+
+ $dbName = $connection->quoteIdentifier($config[ConfigOptionsListConstants::KEY_NAME]);
+ //If for different shards one database was specified - no need to clean it few times
+ if (!in_array($dbName, $cleanedUpDatabases)) {
+ $this->log->log("Cleaning up database {$dbName}");
+ $connection->query("DROP DATABASE IF EXISTS {$dbName}");
+ $connection->query("CREATE DATABASE IF NOT EXISTS {$dbName}");
+ $cleanedUpDatabases[] = $dbName;
+ }
+ } else {
+ $this->log->log('No database connection defined - skipping database cleanup');
}
- $dbName = $connection->quoteIdentifier($config[ConfigOptionsListConstants::KEY_NAME]);
- $this->log->log("Cleaning up database {$dbName}");
- $connection->query("DROP DATABASE IF EXISTS {$dbName}");
- $connection->query("CREATE DATABASE IF NOT EXISTS {$dbName}");
- } else {
- $this->log->log('No database connection defined - skipping database cleanup');
}
}
From e3d1b56b508eb20fab16ff706cface342b7ee9fc Mon Sep 17 00:00:00 2001
From: Sergii Kovalenko
Date: Tue, 26 Dec 2017 13:38:21 +0200
Subject: [PATCH 240/904] MAGETWO-84100: Unify Magento SQL adapters
--add test on declaration installation
---
.../etc/db_schema.xml | 2 +-
.../column_modifications/db_schema.xml | 2 +-
.../revisions/column_removals/db_schema.xml | 2 +-
.../constraint_modifications/db_schema.xml | 2 +-
.../revisions/drop_table/db_schema.xml | 2 +-
.../fail_on_column_declaration/db_schema.xml | 2 +-
.../db_schema.xml | 2 +-
.../foreign_key_interpreter/db_schema.xml | 2 +-
.../revisions/old_diff/db_schema.xml | 4 +-
.../testsuite/Magento/Setup/SplitDbTest.php | 25 ++++++++++
.../Setup/Console/Command/UpgradeCommand.php | 5 +-
.../Schema/{Xml => Config}/Converter.php | 2 +-
.../Schema/{Xml => Config}/SchemaLocator.php | 4 +-
.../Declaration/Schema/Db/AdapterMediator.php | 2 +-
.../Schema/Declaration/ReaderComposite.php | 2 +-
.../Schema/Dto/Factories/Timestamp.php | 5 +-
.../Schema/FileSystem/XmlReader.php | 8 ++--
.../Model/Declaration/Schema/SchemaConfig.php | 4 --
.../constraints/constraint.xsd | 2 +-
.../{config => etc}/constraints/foreign.xsd | 2 +-
.../{config => etc}/constraints/primary.xsd | 2 +-
.../{config => etc}/constraints/unique.xsd | 2 +-
.../Schema/{config => etc}/index.xsd | 0
.../Schema/{config => etc}/operations.xsd | 0
.../Schema/{config => etc}/schema.xsd | 46 +++++++++----------
.../{config => etc}/types/binaries/blob.xsd | 2 +-
.../types/binaries/longblob.xsd | 2 +-
.../types/binaries/mediumblob.xsd | 2 +-
.../types/binaries/varbinary.xsd | 2 +-
.../Schema/{config => etc}/types/boolean.xsd | 2 +-
.../Schema/{config => etc}/types/column.xsd | 2 +-
.../{config => etc}/types/datetime/date.xsd | 2 +-
.../types/datetime/datetime.xsd | 4 +-
.../types/datetime/default.xsd | 0
.../types/datetime/timestamp.xsd | 4 +-
.../types/decimals/decimal.xsd | 2 +-
.../{config => etc}/types/decimals/double.xsd | 2 +-
.../{config => etc}/types/decimals/float.xsd | 2 +-
.../types/integers/biginteger.xsd | 2 +-
.../types/integers/integer.xsd | 2 +-
.../types/integers/smallinteger.xsd | 2 +-
.../types/integers/tinyinteger.xsd | 2 +-
.../{config => etc}/types/texts/longtext.xsd | 2 +-
.../types/texts/mediumtext.xsd | 2 +-
.../{config => etc}/types/texts/text.xsd | 2 +-
.../{config => etc}/types/texts/varchar.xsd | 2 +-
setup/src/Magento/Setup/Model/Installer.php | 1 -
47 files changed, 100 insertions(+), 76 deletions(-)
rename setup/src/Magento/Setup/Model/Declaration/Schema/{Xml => Config}/Converter.php (98%)
rename setup/src/Magento/Setup/Model/Declaration/Schema/{Xml => Config}/SchemaLocator.php (94%)
rename setup/src/Magento/Setup/Model/Declaration/Schema/{config => etc}/constraints/constraint.xsd (92%)
rename setup/src/Magento/Setup/Model/Declaration/Schema/{config => etc}/constraints/foreign.xsd (96%)
rename setup/src/Magento/Setup/Model/Declaration/Schema/{config => etc}/constraints/primary.xsd (95%)
rename setup/src/Magento/Setup/Model/Declaration/Schema/{config => etc}/constraints/unique.xsd (94%)
rename setup/src/Magento/Setup/Model/Declaration/Schema/{config => etc}/index.xsd (100%)
rename setup/src/Magento/Setup/Model/Declaration/Schema/{config => etc}/operations.xsd (100%)
rename setup/src/Magento/Setup/Model/Declaration/Schema/{config => etc}/schema.xsd (72%)
rename setup/src/Magento/Setup/Model/Declaration/Schema/{config => etc}/types/binaries/blob.xsd (93%)
rename setup/src/Magento/Setup/Model/Declaration/Schema/{config => etc}/types/binaries/longblob.xsd (94%)
rename setup/src/Magento/Setup/Model/Declaration/Schema/{config => etc}/types/binaries/mediumblob.xsd (93%)
rename setup/src/Magento/Setup/Model/Declaration/Schema/{config => etc}/types/binaries/varbinary.xsd (96%)
rename setup/src/Magento/Setup/Model/Declaration/Schema/{config => etc}/types/boolean.xsd (92%)
rename setup/src/Magento/Setup/Model/Declaration/Schema/{config => etc}/types/column.xsd (93%)
rename setup/src/Magento/Setup/Model/Declaration/Schema/{config => etc}/types/datetime/date.xsd (95%)
rename setup/src/Magento/Setup/Model/Declaration/Schema/{config => etc}/types/datetime/datetime.xsd (92%)
rename setup/src/Magento/Setup/Model/Declaration/Schema/{config => etc}/types/datetime/default.xsd (100%)
rename setup/src/Magento/Setup/Model/Declaration/Schema/{config => etc}/types/datetime/timestamp.xsd (93%)
rename setup/src/Magento/Setup/Model/Declaration/Schema/{config => etc}/types/decimals/decimal.xsd (97%)
rename setup/src/Magento/Setup/Model/Declaration/Schema/{config => etc}/types/decimals/double.xsd (97%)
rename setup/src/Magento/Setup/Model/Declaration/Schema/{config => etc}/types/decimals/float.xsd (93%)
rename setup/src/Magento/Setup/Model/Declaration/Schema/{config => etc}/types/integers/biginteger.xsd (90%)
rename setup/src/Magento/Setup/Model/Declaration/Schema/{config => etc}/types/integers/integer.xsd (97%)
rename setup/src/Magento/Setup/Model/Declaration/Schema/{config => etc}/types/integers/smallinteger.xsd (93%)
rename setup/src/Magento/Setup/Model/Declaration/Schema/{config => etc}/types/integers/tinyinteger.xsd (90%)
rename setup/src/Magento/Setup/Model/Declaration/Schema/{config => etc}/types/texts/longtext.xsd (94%)
rename setup/src/Magento/Setup/Model/Declaration/Schema/{config => etc}/types/texts/mediumtext.xsd (94%)
rename setup/src/Magento/Setup/Model/Declaration/Schema/{config => etc}/types/texts/text.xsd (94%)
rename setup/src/Magento/Setup/Model/Declaration/Schema/{config => etc}/types/texts/varchar.xsd (97%)
diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/etc/db_schema.xml b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/etc/db_schema.xml
index 99e3ed7ed53fd..bda769d4b3422 100644
--- a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/etc/db_schema.xml
+++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/etc/db_schema.xml
@@ -5,7 +5,7 @@
* See COPYING.txt for license details.
*/
-->
-
+
diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/column_modifications/db_schema.xml b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/column_modifications/db_schema.xml
index 2671fd4babd89..70c0ec7547cbd 100644
--- a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/column_modifications/db_schema.xml
+++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/column_modifications/db_schema.xml
@@ -5,7 +5,7 @@
* See COPYING.txt for license details.
*/
-->
-
+
diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/column_removals/db_schema.xml b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/column_removals/db_schema.xml
index 83c274c2627c0..997c477421410 100644
--- a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/column_removals/db_schema.xml
+++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/column_removals/db_schema.xml
@@ -5,7 +5,7 @@
* See COPYING.txt for license details.
*/
-->
-
+
diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/constraint_modifications/db_schema.xml b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/constraint_modifications/db_schema.xml
index c8dcdc7650307..b69854a209eb2 100644
--- a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/constraint_modifications/db_schema.xml
+++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/constraint_modifications/db_schema.xml
@@ -5,7 +5,7 @@
* See COPYING.txt for license details.
*/
-->
-
+
diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/drop_table/db_schema.xml b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/drop_table/db_schema.xml
index c7c4085553cc5..02610d360c777 100644
--- a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/drop_table/db_schema.xml
+++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/drop_table/db_schema.xml
@@ -5,7 +5,7 @@
* See COPYING.txt for license details.
*/
-->
-
+
diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/fail_on_column_declaration/db_schema.xml b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/fail_on_column_declaration/db_schema.xml
index 7a298c0e58824..46d3fe5bbebd3 100644
--- a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/fail_on_column_declaration/db_schema.xml
+++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/fail_on_column_declaration/db_schema.xml
@@ -5,7 +5,7 @@
* See COPYING.txt for license details.
*/
-->
-
+
diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/fail_on_unique_key_declaration/db_schema.xml b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/fail_on_unique_key_declaration/db_schema.xml
index 6e462a0b0dece..d38412680ce9b 100644
--- a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/fail_on_unique_key_declaration/db_schema.xml
+++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/fail_on_unique_key_declaration/db_schema.xml
@@ -5,7 +5,7 @@
* See COPYING.txt for license details.
*/
-->
-
+
diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/foreign_key_interpreter/db_schema.xml b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/foreign_key_interpreter/db_schema.xml
index cc2a39a88e72c..5c29d7b525272 100644
--- a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/foreign_key_interpreter/db_schema.xml
+++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/foreign_key_interpreter/db_schema.xml
@@ -6,7 +6,7 @@
*/
-->
+ xsi:noNamespaceSchemaLocation="urn:magento:setup:Model/Declaration/Schema/etc/schema.xsd">
diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/old_diff/db_schema.xml b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/old_diff/db_schema.xml
index 2d8aa0681d401..c212ee5ea75f1 100644
--- a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/old_diff/db_schema.xml
+++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/old_diff/db_schema.xml
@@ -5,7 +5,7 @@
* See COPYING.txt for license details.
*/
-->
-
+
@@ -19,7 +19,7 @@
-
+
diff --git a/dev/tests/setup-integration/testsuite/Magento/Setup/SplitDbTest.php b/dev/tests/setup-integration/testsuite/Magento/Setup/SplitDbTest.php
index 2a8b77b3c082d..2d8cf6f6b8148 100644
--- a/dev/tests/setup-integration/testsuite/Magento/Setup/SplitDbTest.php
+++ b/dev/tests/setup-integration/testsuite/Magento/Setup/SplitDbTest.php
@@ -39,6 +39,31 @@ public function setUp()
* @dataProviderFromFile Magento/TestSetupDeclarationModule2/fixture/shards.php
*/
public function testSplitDbInstallation()
+ {
+ $this->cliCommand->install(
+ ['Magento_ScalableCheckout', 'Magento_ScalableOms'],
+ [InstallCommand::DECLARATION_MODE_KEY => true]
+ );
+
+ $this->cliCommand->splitQuote();
+ $this->cliCommand->splitSales();
+
+ $this->cliCommand->install(
+ ['Magento_TestSetupDeclarationModule2'],
+ [InstallCommand::DECLARATION_MODE_KEY => true]
+ );
+
+ $default = $this->describeTable->describeShard('default');
+ $sales = $this->describeTable->describeShard('sales');
+ $checkout = $this->describeTable->describeShard('checkout');
+ self::assertEquals(array_replace($default, $sales, $checkout), $this->getData());
+ }
+
+ /**
+ * @moduleName Magento_TestSetupDeclarationModule2
+ * @dataProviderFromFile Magento/TestSetupDeclarationModule2/fixture/shards.php
+ */
+ public function testUpgradeWithSplitDb()
{
$this->cliCommand->install(
['Magento_TestSetupDeclarationModule2', 'Magento_ScalableCheckout', 'Magento_ScalableOms'],
diff --git a/setup/src/Magento/Setup/Console/Command/UpgradeCommand.php b/setup/src/Magento/Setup/Console/Command/UpgradeCommand.php
index e2d032da9b196..107ac4c0cdb13 100644
--- a/setup/src/Magento/Setup/Console/Command/UpgradeCommand.php
+++ b/setup/src/Magento/Setup/Console/Command/UpgradeCommand.php
@@ -87,11 +87,12 @@ protected function configure()
protected function execute(InputInterface $input, OutputInterface $output)
{
try {
+ $request = $input->getOptions();
$keepGenerated = $input->getOption(self::INPUT_KEY_KEEP_GENERATED);
$installer = $this->installerFactory->create(new ConsoleLogger($output));
$installer->updateModulesSequence($keepGenerated);
- $installer->installSchema();
- $installer->installDataFixtures();
+ $installer->installSchema($request);
+ $installer->installDataFixtures($request);
if ($this->deploymentConfig->isAvailable()) {
$importConfigCommand = $this->getApplication()->find(ConfigImportCommand::COMMAND_NAME);
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Xml/Converter.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Config/Converter.php
similarity index 98%
rename from setup/src/Magento/Setup/Model/Declaration/Schema/Xml/Converter.php
rename to setup/src/Magento/Setup/Model/Declaration/Schema/Config/Converter.php
index bef75250a514b..4f2e748873936 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Xml/Converter.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Config/Converter.php
@@ -5,7 +5,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-namespace Magento\Setup\Model\Declaration\Schema\Xml;
+namespace Magento\Setup\Model\Declaration\Schema\Config;
/**
* This converter serve needs of Declaration Filesystem reader:
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Xml/SchemaLocator.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Config/SchemaLocator.php
similarity index 94%
rename from setup/src/Magento/Setup/Model/Declaration/Schema/Xml/SchemaLocator.php
rename to setup/src/Magento/Setup/Model/Declaration/Schema/Config/SchemaLocator.php
index cf9296c446d61..393e62b500a36 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Xml/SchemaLocator.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Config/SchemaLocator.php
@@ -3,7 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-namespace Magento\Setup\Model\Declaration\Schema\Xml;
+namespace Magento\Setup\Model\Declaration\Schema\Config;
/**
* This is system class that provides .xsd file for validation XML schema
@@ -30,7 +30,7 @@ class SchemaLocator implements \Magento\Framework\Config\SchemaLocatorInterface
*/
public function __construct(
\Magento\Framework\Config\Dom\UrnResolver $urnResolver,
- $schemaUrn = 'urn:magento:setup:Model/Declaration/Schema/config/schema.xsd'
+ $schemaUrn = 'urn:magento:setup:Model/Declaration/Schema/etc/schema.xsd'
) {
$this->_schema = $urnResolver->getRealPath($schemaUrn);
$this->_perFileSchema = $this->_schema;
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/AdapterMediator.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/AdapterMediator.php
index 0e75e1315dcaf..5e5eaaf68c827 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/AdapterMediator.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/AdapterMediator.php
@@ -356,7 +356,7 @@ public function getColumnsList($tableName, $resource)
}
/**
- * Flush cache
+ * As all read operations are cached, sometimes we need to flush them
*
* @return void
*/
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/ReaderComposite.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/ReaderComposite.php
index 7bf2543ed8691..3524abef02836 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/ReaderComposite.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/ReaderComposite.php
@@ -33,7 +33,7 @@ public function __construct(array $readers)
*/
public function read($scope = null)
{
- $schema = [];
+ $schema = ['table' => []];
foreach ($this->readers as $reader) {
$schema = array_replace_recursive($schema, $reader->read($scope));
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Timestamp.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Timestamp.php
index 626d0702596a6..a3717b64373fc 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Timestamp.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Timestamp.php
@@ -19,6 +19,9 @@
*/
class Timestamp implements FactoryInterface
{
+ /** Nullable timestamp */
+ const NULL_TIMESTAMP = 'NULL';
+
/**
* @var ObjectManagerInterface
*/
@@ -69,7 +72,7 @@ public function create(array $data)
}
//By default we do not want to use default attribute
if (!isset($data['default'])) {
- $data['default'] = null;
+ $data['default'] = self::NULL_TIMESTAMP;
}
unset($data['nullable']);
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/FileSystem/XmlReader.php b/setup/src/Magento/Setup/Model/Declaration/Schema/FileSystem/XmlReader.php
index c450aa195ef13..105d94a37a35e 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/FileSystem/XmlReader.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/FileSystem/XmlReader.php
@@ -30,8 +30,8 @@ class XmlReader extends \Magento\Framework\Config\Reader\Filesystem implements R
/**
* Reader constructor.
* @param \Magento\Framework\Config\FileResolverInterface $fileResolver
- * @param \Magento\Setup\Model\Declaration\Schema\Xml\Converter $converter
- * @param \Magento\Setup\Model\Declaration\Schema\Xml\SchemaLocator $schemaLocator
+ * @param \Magento\Setup\Model\Declaration\Schema\Config\Converter $converter
+ * @param \Magento\Setup\Model\Declaration\Schema\Config\SchemaLocator $schemaLocator
* @param \Magento\Framework\Config\ValidationStateInterface $validationState
* @param string $fileName
* @param string $domDocumentClass
@@ -39,8 +39,8 @@ class XmlReader extends \Magento\Framework\Config\Reader\Filesystem implements R
*/
public function __construct(
\Magento\Framework\Config\FileResolverInterface $fileResolver,
- \Magento\Setup\Model\Declaration\Schema\Xml\Converter $converter,
- \Magento\Setup\Model\Declaration\Schema\Xml\SchemaLocator $schemaLocator,
+ \Magento\Setup\Model\Declaration\Schema\Config\Converter $converter,
+ \Magento\Setup\Model\Declaration\Schema\Config\SchemaLocator $schemaLocator,
\Magento\Framework\Config\ValidationStateInterface $validationState,
$fileName = 'db_schema.xml',
$domDocumentClass = \Magento\Framework\Config\Dom::class,
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/SchemaConfig.php b/setup/src/Magento/Setup/Model/Declaration/Schema/SchemaConfig.php
index 56aacaadd772b..e34ce4ec6b1db 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/SchemaConfig.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/SchemaConfig.php
@@ -71,10 +71,6 @@ public function getDeclarationConfig()
{
$schema = $this->schemaFactory->create();
$data = $this->readerComposite->read();
-
- if (!isset($data['table'])) {
- $data = $this->readerComposite->read();
- }
$this->declarativeSchemaBuilder->addTablesData($data['table']);
$schema = $this->declarativeSchemaBuilder->build($schema);
return $schema;
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/config/constraints/constraint.xsd b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/constraints/constraint.xsd
similarity index 92%
rename from setup/src/Magento/Setup/Model/Declaration/Schema/config/constraints/constraint.xsd
rename to setup/src/Magento/Setup/Model/Declaration/Schema/etc/constraints/constraint.xsd
index 8be292b78bab8..9e1428dfb4d0d 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/config/constraints/constraint.xsd
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/constraints/constraint.xsd
@@ -6,7 +6,7 @@
*/
-->
-
+
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/config/constraints/foreign.xsd b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/constraints/foreign.xsd
similarity index 96%
rename from setup/src/Magento/Setup/Model/Declaration/Schema/config/constraints/foreign.xsd
rename to setup/src/Magento/Setup/Model/Declaration/Schema/etc/constraints/foreign.xsd
index 03e6ec1ecc660..9cc94dfa3c2f4 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/config/constraints/foreign.xsd
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/constraints/foreign.xsd
@@ -6,7 +6,7 @@
*/
-->
-
+
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/config/constraints/primary.xsd b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/constraints/primary.xsd
similarity index 95%
rename from setup/src/Magento/Setup/Model/Declaration/Schema/config/constraints/primary.xsd
rename to setup/src/Magento/Setup/Model/Declaration/Schema/etc/constraints/primary.xsd
index e03bd108c1ee2..c690575379886 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/config/constraints/primary.xsd
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/constraints/primary.xsd
@@ -6,7 +6,7 @@
*/
-->
-
+
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/config/constraints/unique.xsd b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/constraints/unique.xsd
similarity index 94%
rename from setup/src/Magento/Setup/Model/Declaration/Schema/config/constraints/unique.xsd
rename to setup/src/Magento/Setup/Model/Declaration/Schema/etc/constraints/unique.xsd
index c3f10aac20c49..1db643982b4e4 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/config/constraints/unique.xsd
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/constraints/unique.xsd
@@ -6,7 +6,7 @@
*/
-->
-
+
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/config/index.xsd b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/index.xsd
similarity index 100%
rename from setup/src/Magento/Setup/Model/Declaration/Schema/config/index.xsd
rename to setup/src/Magento/Setup/Model/Declaration/Schema/etc/index.xsd
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/config/operations.xsd b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/operations.xsd
similarity index 100%
rename from setup/src/Magento/Setup/Model/Declaration/Schema/config/operations.xsd
rename to setup/src/Magento/Setup/Model/Declaration/Schema/etc/operations.xsd
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/config/schema.xsd b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/schema.xsd
similarity index 72%
rename from setup/src/Magento/Setup/Model/Declaration/Schema/config/schema.xsd
rename to setup/src/Magento/Setup/Model/Declaration/Schema/etc/schema.xsd
index 2ca2b98ac1ead..57e363dde6fd3 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/config/schema.xsd
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/schema.xsd
@@ -8,31 +8,31 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
+
+
+
-
+
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/binaries/blob.xsd b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/binaries/blob.xsd
similarity index 93%
rename from setup/src/Magento/Setup/Model/Declaration/Schema/config/types/binaries/blob.xsd
rename to setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/binaries/blob.xsd
index dfc4125d2b65c..4b0e77baedb4a 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/binaries/blob.xsd
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/binaries/blob.xsd
@@ -6,7 +6,7 @@
*/
-->
-
+
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/binaries/longblob.xsd b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/binaries/longblob.xsd
similarity index 94%
rename from setup/src/Magento/Setup/Model/Declaration/Schema/config/types/binaries/longblob.xsd
rename to setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/binaries/longblob.xsd
index b6c4762bea71c..364118d9c4a9e 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/binaries/longblob.xsd
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/binaries/longblob.xsd
@@ -6,7 +6,7 @@
*/
-->
-
+
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/binaries/mediumblob.xsd b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/binaries/mediumblob.xsd
similarity index 93%
rename from setup/src/Magento/Setup/Model/Declaration/Schema/config/types/binaries/mediumblob.xsd
rename to setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/binaries/mediumblob.xsd
index fa5bbd6792ddb..5818a2744bd32 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/binaries/mediumblob.xsd
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/binaries/mediumblob.xsd
@@ -6,7 +6,7 @@
*/
-->
-
+
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/binaries/varbinary.xsd b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/binaries/varbinary.xsd
similarity index 96%
rename from setup/src/Magento/Setup/Model/Declaration/Schema/config/types/binaries/varbinary.xsd
rename to setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/binaries/varbinary.xsd
index 8d037f94b55f5..f366cc45a89b2 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/binaries/varbinary.xsd
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/binaries/varbinary.xsd
@@ -6,7 +6,7 @@
*/
-->
-
+
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/boolean.xsd b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/boolean.xsd
similarity index 92%
rename from setup/src/Magento/Setup/Model/Declaration/Schema/config/types/boolean.xsd
rename to setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/boolean.xsd
index cf52a70b79702..1167c9e0642bb 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/boolean.xsd
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/boolean.xsd
@@ -6,7 +6,7 @@
*/
-->
-
+
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/column.xsd b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/column.xsd
similarity index 93%
rename from setup/src/Magento/Setup/Model/Declaration/Schema/config/types/column.xsd
rename to setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/column.xsd
index 60224991a56d6..a549ddfadb4f6 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/column.xsd
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/column.xsd
@@ -6,7 +6,7 @@
*/
-->
-
+
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/datetime/date.xsd b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/datetime/date.xsd
similarity index 95%
rename from setup/src/Magento/Setup/Model/Declaration/Schema/config/types/datetime/date.xsd
rename to setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/datetime/date.xsd
index 1272653a0b01e..b131890b08e2b 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/datetime/date.xsd
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/datetime/date.xsd
@@ -6,7 +6,7 @@
*/
-->
-
+
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/datetime/datetime.xsd b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/datetime/datetime.xsd
similarity index 92%
rename from setup/src/Magento/Setup/Model/Declaration/Schema/config/types/datetime/datetime.xsd
rename to setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/datetime/datetime.xsd
index 3b1d62cdb8258..6974ce4ded76a 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/datetime/datetime.xsd
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/datetime/datetime.xsd
@@ -6,8 +6,8 @@
*/
-->
-
-
+
+
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/datetime/default.xsd b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/datetime/default.xsd
similarity index 100%
rename from setup/src/Magento/Setup/Model/Declaration/Schema/config/types/datetime/default.xsd
rename to setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/datetime/default.xsd
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/datetime/timestamp.xsd b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/datetime/timestamp.xsd
similarity index 93%
rename from setup/src/Magento/Setup/Model/Declaration/Schema/config/types/datetime/timestamp.xsd
rename to setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/datetime/timestamp.xsd
index e81f96a4c7f0d..b2e8f77a1b910 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/datetime/timestamp.xsd
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/datetime/timestamp.xsd
@@ -6,8 +6,8 @@
*/
-->
-
-
+
+
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/decimals/decimal.xsd b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/decimals/decimal.xsd
similarity index 97%
rename from setup/src/Magento/Setup/Model/Declaration/Schema/config/types/decimals/decimal.xsd
rename to setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/decimals/decimal.xsd
index 821d785b6d680..ccdf63f047516 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/decimals/decimal.xsd
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/decimals/decimal.xsd
@@ -6,7 +6,7 @@
*/
-->
-
+
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/decimals/double.xsd b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/decimals/double.xsd
similarity index 97%
rename from setup/src/Magento/Setup/Model/Declaration/Schema/config/types/decimals/double.xsd
rename to setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/decimals/double.xsd
index cd4351f54d41e..ed45d61a2eb02 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/decimals/double.xsd
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/decimals/double.xsd
@@ -6,7 +6,7 @@
*/
-->
-
+
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/decimals/float.xsd b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/decimals/float.xsd
similarity index 93%
rename from setup/src/Magento/Setup/Model/Declaration/Schema/config/types/decimals/float.xsd
rename to setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/decimals/float.xsd
index 3f7cf1f3453b2..e953294e55647 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/decimals/float.xsd
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/decimals/float.xsd
@@ -6,7 +6,7 @@
*/
-->
-
+
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/integers/biginteger.xsd b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/integers/biginteger.xsd
similarity index 90%
rename from setup/src/Magento/Setup/Model/Declaration/Schema/config/types/integers/biginteger.xsd
rename to setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/integers/biginteger.xsd
index 71757494cc671..46671d1a49b43 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/integers/biginteger.xsd
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/integers/biginteger.xsd
@@ -6,7 +6,7 @@
*/
-->
-
+
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/integers/integer.xsd b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/integers/integer.xsd
similarity index 97%
rename from setup/src/Magento/Setup/Model/Declaration/Schema/config/types/integers/integer.xsd
rename to setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/integers/integer.xsd
index df8b83cc36da0..54c694c2d8ff2 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/integers/integer.xsd
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/integers/integer.xsd
@@ -6,7 +6,7 @@
*/
-->
-
+
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/integers/smallinteger.xsd b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/integers/smallinteger.xsd
similarity index 93%
rename from setup/src/Magento/Setup/Model/Declaration/Schema/config/types/integers/smallinteger.xsd
rename to setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/integers/smallinteger.xsd
index 2ef2569c52293..c12308a4d276d 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/integers/smallinteger.xsd
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/integers/smallinteger.xsd
@@ -6,7 +6,7 @@
*/
-->
-
+
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/integers/tinyinteger.xsd b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/integers/tinyinteger.xsd
similarity index 90%
rename from setup/src/Magento/Setup/Model/Declaration/Schema/config/types/integers/tinyinteger.xsd
rename to setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/integers/tinyinteger.xsd
index 11107d5631f5c..eb7cb676cd6af 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/integers/tinyinteger.xsd
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/integers/tinyinteger.xsd
@@ -6,7 +6,7 @@
*/
-->
-
+
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/texts/longtext.xsd b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/texts/longtext.xsd
similarity index 94%
rename from setup/src/Magento/Setup/Model/Declaration/Schema/config/types/texts/longtext.xsd
rename to setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/texts/longtext.xsd
index d1aca2d14b8c7..c0f4743824e3d 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/texts/longtext.xsd
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/texts/longtext.xsd
@@ -6,7 +6,7 @@
*/
-->
-
+
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/texts/mediumtext.xsd b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/texts/mediumtext.xsd
similarity index 94%
rename from setup/src/Magento/Setup/Model/Declaration/Schema/config/types/texts/mediumtext.xsd
rename to setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/texts/mediumtext.xsd
index a304c1bdc8632..e925a18542409 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/texts/mediumtext.xsd
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/texts/mediumtext.xsd
@@ -6,7 +6,7 @@
*/
-->
-
+
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/texts/text.xsd b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/texts/text.xsd
similarity index 94%
rename from setup/src/Magento/Setup/Model/Declaration/Schema/config/types/texts/text.xsd
rename to setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/texts/text.xsd
index 3d0065ae6af0b..9c1682dde836f 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/texts/text.xsd
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/texts/text.xsd
@@ -6,7 +6,7 @@
*/
-->
-
+
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/texts/varchar.xsd b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/texts/varchar.xsd
similarity index 97%
rename from setup/src/Magento/Setup/Model/Declaration/Schema/config/types/texts/varchar.xsd
rename to setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/texts/varchar.xsd
index f11c3c696d916..6ac1c7bfacdba 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/config/types/texts/varchar.xsd
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/texts/varchar.xsd
@@ -6,7 +6,7 @@
*/
-->
-
+
diff --git a/setup/src/Magento/Setup/Model/Installer.php b/setup/src/Magento/Setup/Model/Installer.php
index 89759e3859556..0bf00a08f92d6 100644
--- a/setup/src/Magento/Setup/Model/Installer.php
+++ b/setup/src/Magento/Setup/Model/Installer.php
@@ -930,7 +930,6 @@ private function assertDbConfigExists()
*/
public function installUserConfig($data)
{
- return;
$userConfig = new StoreConfigurationDataMapper();
/** @var \Magento\Framework\App\State $appState */
$appState = $this->objectManagerProvider->get()->get(\Magento\Framework\App\State::class);
From ce27cbce08ede88dcdc3eef883beed67002d6141 Mon Sep 17 00:00:00 2001
From: Sergii Kovalenko
Date: Tue, 26 Dec 2017 14:02:09 +0200
Subject: [PATCH 241/904] MAGETWO-84100: Unify Magento SQL adapters
--add test on declaration installation
---
setup/src/Magento/Setup/Model/Installer.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/setup/src/Magento/Setup/Model/Installer.php b/setup/src/Magento/Setup/Model/Installer.php
index 0bf00a08f92d6..383adc4a57911 100644
--- a/setup/src/Magento/Setup/Model/Installer.php
+++ b/setup/src/Magento/Setup/Model/Installer.php
@@ -774,7 +774,7 @@ public function installSchema(array $request)
$this->setupCoreTables($setup);
$this->log->log('Schema creation/updates:');
- if ($request[InstallCommand::DECLARATION_MODE_KEY]) {
+ if (isset($request[InstallCommand::DECLARATION_MODE_KEY]) && $request[InstallCommand::DECLARATION_MODE_KEY]) {
/** @var DeclarationInstaller $declarativeInstaller */
$declarativeInstaller = $this->objectManagerProvider->get()->get(DeclarationInstaller::class);
$declarativeInstaller->installSchema($request);
From 10e990a129e3d1024eee8144391fcd4cfefdd55b Mon Sep 17 00:00:00 2001
From: Sergii Kovalenko
Date: Tue, 26 Dec 2017 16:59:41 +0200
Subject: [PATCH 242/904] MAGETWO-84100: Unify Magento SQL adapters
--stabilize build
---
.../Console/Command/DbDataUpgradeCommand.php | 2 +-
.../Command/DbSchemaUpgradeCommand.php | 2 +-
setup/src/Magento/Setup/Model/Installer.php | 40 +++++++++----------
.../Setup/Test/Unit/Model/InstallerTest.php | 16 +++++---
4 files changed, 33 insertions(+), 27 deletions(-)
diff --git a/setup/src/Magento/Setup/Console/Command/DbDataUpgradeCommand.php b/setup/src/Magento/Setup/Console/Command/DbDataUpgradeCommand.php
index 36b010d6d1e38..ad99947f6dca1 100644
--- a/setup/src/Magento/Setup/Console/Command/DbDataUpgradeCommand.php
+++ b/setup/src/Magento/Setup/Console/Command/DbDataUpgradeCommand.php
@@ -66,6 +66,6 @@ protected function execute(InputInterface $input, OutputInterface $output)
return \Magento\Framework\Console\Cli::RETURN_FAILURE;
}
$installer = $this->installFactory->create(new ConsoleLogger($output));
- $installer->installDataFixtures();
+ $installer->installDataFixtures($input->getOptions());
}
}
diff --git a/setup/src/Magento/Setup/Console/Command/DbSchemaUpgradeCommand.php b/setup/src/Magento/Setup/Console/Command/DbSchemaUpgradeCommand.php
index fbe1843e7e606..c9b52b75ef944 100644
--- a/setup/src/Magento/Setup/Console/Command/DbSchemaUpgradeCommand.php
+++ b/setup/src/Magento/Setup/Console/Command/DbSchemaUpgradeCommand.php
@@ -66,6 +66,6 @@ protected function execute(InputInterface $input, OutputInterface $output)
return \Magento\Framework\Console\Cli::RETURN_FAILURE;
}
$installer = $this->installFactory->create(new ConsoleLogger($output));
- $installer->installSchema();
+ $installer->installSchema($input->getOptions());
}
}
diff --git a/setup/src/Magento/Setup/Model/Installer.php b/setup/src/Magento/Setup/Model/Installer.php
index 383adc4a57911..60f3f7c752b62 100644
--- a/setup/src/Magento/Setup/Model/Installer.php
+++ b/setup/src/Magento/Setup/Model/Installer.php
@@ -796,7 +796,7 @@ public function installDataFixtures(array $request)
$setup = $this->dataSetupFactory->create();
$this->checkFilePermissionsForDbUpgrade();
$this->log->log('Data install/update:');
- if (!$request[InstallCommand::DECLARATION_MODE_KEY]) {
+ if (!isset($request[InstallCommand::DECLARATION_MODE_KEY]) || !$request[InstallCommand::DECLARATION_MODE_KEY]) {
$this->handleDBSchemaData($setup, 'data');
}
}
@@ -1154,29 +1154,29 @@ public function cleanupDb()
$connections = $this->deploymentConfig->get(ConfigOptionsListConstants::CONFIG_PATH_DB_CONNECTIONS, []);
//Do database cleanup for all shards
foreach ($connections as $config) {
- if ($config) {
- try {
- $connection = $this->connectionFactory->create($config);
- if (!$connection) {
- $this->log->log("Can't create connection to database - skipping database cleanup");
- }
- } catch (\Exception $e) {
- $this->log->log($e->getMessage() . ' - skipping database cleanup');
- return;
+ try {
+ $connection = $this->connectionFactory->create($config);
+ if (!$connection) {
+ $this->log->log("Can't create connection to database - skipping database cleanup");
}
+ } catch (\Exception $e) {
+ $this->log->log($e->getMessage() . ' - skipping database cleanup');
+ return;
+ }
- $dbName = $connection->quoteIdentifier($config[ConfigOptionsListConstants::KEY_NAME]);
- //If for different shards one database was specified - no need to clean it few times
- if (!in_array($dbName, $cleanedUpDatabases)) {
- $this->log->log("Cleaning up database {$dbName}");
- $connection->query("DROP DATABASE IF EXISTS {$dbName}");
- $connection->query("CREATE DATABASE IF NOT EXISTS {$dbName}");
- $cleanedUpDatabases[] = $dbName;
- }
- } else {
- $this->log->log('No database connection defined - skipping database cleanup');
+ $dbName = $connection->quoteIdentifier($config[ConfigOptionsListConstants::KEY_NAME]);
+ //If for different shards one database was specified - no need to clean it few times
+ if (!in_array($dbName, $cleanedUpDatabases)) {
+ $this->log->log("Cleaning up database {$dbName}");
+ $connection->query("DROP DATABASE IF EXISTS {$dbName}");
+ $connection->query("CREATE DATABASE IF NOT EXISTS {$dbName}");
+ $cleanedUpDatabases[] = $dbName;
}
}
+
+ if (empty($config)) {
+ $this->log->log('No database connection defined - skipping database cleanup');
+ }
}
/**
diff --git a/setup/src/Magento/Setup/Test/Unit/Model/InstallerTest.php b/setup/src/Magento/Setup/Test/Unit/Model/InstallerTest.php
index 86fb54551661d..5b62d4f7f6875 100644
--- a/setup/src/Magento/Setup/Test/Unit/Model/InstallerTest.php
+++ b/setup/src/Magento/Setup/Test/Unit/Model/InstallerTest.php
@@ -142,10 +142,12 @@ class InstallerTest extends \PHPUnit\Framework\TestCase
* @var array
*/
private static $dbConfig = [
- ConfigOptionsListConstants::KEY_HOST => '127.0.0.1',
- ConfigOptionsListConstants::KEY_NAME => 'magento',
- ConfigOptionsListConstants::KEY_USER => 'magento',
- ConfigOptionsListConstants::KEY_PASSWORD => '',
+ 'default' => [
+ ConfigOptionsListConstants::KEY_HOST => '127.0.0.1',
+ ConfigOptionsListConstants::KEY_NAME => 'magento',
+ ConfigOptionsListConstants::KEY_USER => 'magento',
+ ConfigOptionsListConstants::KEY_PASSWORD => '',
+ ]
];
/**
@@ -398,6 +400,10 @@ public function testUpdateModulesSequenceKeepGenerated()
public function testUninstall()
{
+ $this->config->expects($this->once())
+ ->method('get')
+ ->with(ConfigOptionsListConstants::CONFIG_PATH_DB_CONNECTIONS)
+ ->willReturn([]);
$this->configReader->expects($this->once())->method('getFiles')->willReturn(['ConfigOne.php', 'ConfigTwo.php']);
$configDir = $this->getMockForAbstractClass(
\Magento\Framework\Filesystem\Directory\WriteInterface::class
@@ -466,7 +472,7 @@ public function testCleanupDb()
{
$this->config->expects($this->once())
->method('get')
- ->with(ConfigOptionsListConstants::CONFIG_PATH_DB_CONNECTION_DEFAULT)
+ ->with(ConfigOptionsListConstants::CONFIG_PATH_DB_CONNECTIONS)
->willReturn(self::$dbConfig);
$this->connection->expects($this->at(0))->method('quoteIdentifier')->with('magento')->willReturn('`magento`');
$this->connection->expects($this->at(1))->method('query')->with('DROP DATABASE IF EXISTS `magento`');
From 31633c3a3025404966ed2834cd2df17cb49be5a8 Mon Sep 17 00:00:00 2001
From: Sergii Kovalenko
Date: Tue, 26 Dec 2017 17:38:35 +0200
Subject: [PATCH 243/904] MAGETWO-84100: Unify Magento SQL adapters
--fix code styles
---
.../Setup/InstallSchema.php | 1 +
.../constraint_modification.php | 11 ++--
.../declarative_installer/installation.php | 2 +-
.../fixture/valid_xml_revision_1.php | 4 +-
.../revisions/old_diff/InstallSchema.php | 1 +
.../Setup/InstallSchema.php | 1 +
.../TestSetupModule1/Setup/InstallSchema.php | 1 +
.../TestSetupModule2/Setup/InstallData.php | 1 +
.../TestSetupModule2/Setup/InstallSchema.php | 1 +
.../TestSetupModule2/Setup/UpgradeData.php | 7 ++-
.../TestSetupModule2/Setup/UpgradeSchema.php | 1 +
.../TestFramework/Annotation/CopyModules.php | 21 +------
.../Annotation/DataProviderFromFile.php | 1 -
.../Annotation/ReinstallInstance.php | 1 -
.../Annotation/SchemaFixture.php | 15 ++---
.../TestFramework/Bootstrap/SetupDocBlock.php | 3 +-
.../TestFramework/Deploy/CliCommand.php | 26 ++++----
.../TestFramework/Deploy/DescribeTable.php | 2 +-
.../TestFramework/Deploy/ParametersHolder.php | 2 +-
.../Deploy/TestModuleManager.php | 12 ++--
.../TestFramework/SetupApplication.php | 4 --
.../TestCase/MutableDataInterface.php | 2 +-
.../Workaround/DeploymentConfig.php | 1 +
.../setup-integration/framework/bootstrap.php | 2 +-
.../framework/removeTestModules.php | 4 +-
.../Setup/DeclarativeSchemaBuilderTest.php | 12 +++-
.../testsuite/Magento/Setup/InstallTest.php | 10 ++--
.../Magento/Setup/SchemaReaderTest.php | 2 +-
.../testsuite/Magento/Setup/UpgradeTest.php | 24 ++++----
.../Model/Declaration/Schema/Comparator.php | 2 +-
.../Declaration/Schema/Config/Converter.php | 11 ++--
.../Schema/Config/SchemaLocator.php | 2 +-
.../Declaration/Schema/Db/AdapterMediator.php | 36 ++++++-----
.../Processors/DbSchemaProcessorInterface.php | 6 +-
.../Db/Processors/DbSchemaReaderInterface.php | 18 +++---
.../Db/Processors/DbSchemaWriterInterface.php | 24 ++++----
.../Db/Processors/MySQL/Columns/Basic.php | 2 +-
.../Db/Processors/MySQL/Columns/Blob.php | 1 +
.../Db/Processors/MySQL/Columns/Boolean.php | 2 +-
.../Db/Processors/MySQL/Columns/Decimal.php | 4 +-
.../MySQL/Columns/DefaultDefinition.php | 2 +-
.../Db/Processors/MySQL/Columns/Integer.php | 8 +--
.../Db/Processors/MySQL/Columns/Nullable.php | 2 +-
.../Db/Processors/MySQL/Columns/Text.php | 1 +
.../Db/Processors/MySQL/Columns/Timestamp.php | 2 +-
.../Db/Processors/MySQL/Columns/Varchar.php | 4 +-
.../Processors/MySQL/Constraints/Internal.php | 2 +-
.../Db/Processors/MySQL/DbSchemaReader.php | 18 +++---
.../Db/Processors/MySQL/DbSchemaWriter.php | 60 +++++++++----------
.../Schema/Db/Processors/MySQL/Index.php | 2 +-
.../Declaration/Schema/Db/SchemaBuilder.php | 25 ++++----
.../Schema/Declaration/SchemaBuilder.php | 53 ++++++++--------
.../Declaration/ValidationInterface.php | 2 +-
.../Model/Declaration/Schema/Diff/Diff.php | 7 +--
.../Declaration/Schema/Diff/DiffFactory.php | 3 +-
.../Declaration/Schema/Diff/DiffInterface.php | 12 ++--
.../Declaration/Schema/Diff/DiffManager.php | 25 ++++----
.../Declaration/Schema/Diff/SchemaDiff.php | 2 +-
.../Declaration/Schema/Diff/TableDiff.php | 13 ++--
.../Model/Declaration/Schema/Dto/Column.php | 2 +-
.../Declaration/Schema/Dto/Columns/Blob.php | 4 +-
.../Schema/Dto/Columns/Boolean.php | 6 +-
.../Schema/Dto/Columns/Decimal.php | 12 ++--
.../Schema/Dto/Columns/Integer.php | 14 ++---
.../Declaration/Schema/Dto/Columns/Text.php | 4 +-
.../Schema/Dto/Columns/Timestamp.php | 6 +-
.../Schema/Dto/Columns/Varbinary.php | 10 ++--
.../Schema/Dto/Columns/Varchar.php | 10 ++--
.../Declaration/Schema/Dto/Constraint.php | 4 +-
.../Schema/Dto/Constraints/Internal.php | 5 +-
.../Schema/Dto/Constraints/Reference.php | 5 +-
.../Declaration/Schema/Dto/ElementFactory.php | 10 ++--
.../Declaration/Schema/Dto/Factories/Blob.php | 3 +-
.../Schema/Dto/Factories/Boolean.php | 5 +-
.../Declaration/Schema/Dto/Factories/Date.php | 3 +-
.../Schema/Dto/Factories/Decimal.php | 3 +-
.../Schema/Dto/Factories/FactoryInterface.php | 2 +-
.../Schema/Dto/Factories/Foreign.php | 3 +-
.../Schema/Dto/Factories/Index.php | 3 +-
.../Schema/Dto/Factories/Integer.php | 3 +-
.../Schema/Dto/Factories/LongBlob.php | 3 +-
.../Schema/Dto/Factories/LongText.php | 3 +-
.../Schema/Dto/Factories/MediumBlob.php | 3 +-
.../Schema/Dto/Factories/MediumText.php | 3 +-
.../Schema/Dto/Factories/Primary.php | 3 +-
.../Schema/Dto/Factories/Table.php | 3 +-
.../Declaration/Schema/Dto/Factories/Text.php | 3 +-
.../Schema/Dto/Factories/Timestamp.php | 5 +-
.../Schema/Dto/Factories/Unique.php | 4 +-
.../Schema/Dto/Factories/Varbinary.php | 3 +-
.../Schema/Dto/Factories/Varchar.php | 3 +-
.../Model/Declaration/Schema/Dto/Index.php | 4 +-
.../Model/Declaration/Schema/Dto/Schema.php | 4 +-
.../Declaration/Schema/Dto/SchemaFactory.php | 4 +-
.../Model/Declaration/Schema/Dto/Table.php | 10 ++--
.../Declaration/Schema/FileSystem/Csv.php | 6 +-
.../Schema/FileSystem/XmlReader.php | 1 -
.../Declaration/Schema/OperationInterface.php | 2 +-
.../Declaration/Schema/OperationsExecutor.php | 8 +--
.../Declaration/Schema/RequestFactory.php | 3 +-
.../Model/Declaration/Schema/SchemaConfig.php | 6 +-
.../Model/Declaration/Schema/Sharding.php | 4 +-
102 files changed, 386 insertions(+), 345 deletions(-)
diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/Setup/InstallSchema.php b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/Setup/InstallSchema.php
index 2e4d64b0fcf6c..b552402e07bef 100644
--- a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/Setup/InstallSchema.php
+++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/Setup/InstallSchema.php
@@ -17,6 +17,7 @@ class InstallSchema implements InstallSchemaInterface
{
/**
* {@inheritdoc}
+ *
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function install(SchemaSetupInterface $setup, ModuleContextInterface $context)
diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/declarative_installer/constraint_modification.php b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/declarative_installer/constraint_modification.php
index 80415185ed5a2..dc557d2dfff69 100644
--- a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/declarative_installer/constraint_modification.php
+++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/declarative_installer/constraint_modification.php
@@ -48,8 +48,11 @@
KEY `some_foreign_key_new` (`smallint_main`),
KEY `some_foreign_key_without_action` (`integer_main`),
KEY `speedup_index_renamed` (`tinyint`,`bigint`),
- CONSTRAINT `some_foreign_key` FOREIGN KEY (`tinyint`) REFERENCES `reference_table` (`tinyint_ref`) ON DELETE SET NULL,
- CONSTRAINT `some_foreign_key_new` FOREIGN KEY (`smallint_main`) REFERENCES `reference_table` (`smallint_ref`) ON DELETE CASCADE,
- CONSTRAINT `some_foreign_key_without_action` FOREIGN KEY (`integer_main`) REFERENCES `auto_increment_test` (`int_auto_increment_with_nullable`) ON DELETE CASCADE
+ CONSTRAINT `some_foreign_key` FOREIGN KEY (`tinyint`) REFERENCES `reference_table` (`tinyint_ref`)
+ ON DELETE SET NULL,
+ CONSTRAINT `some_foreign_key_new` FOREIGN KEY (`smallint_main`) REFERENCES `reference_table` (`smallint_ref`)
+ ON DELETE CASCADE,
+ CONSTRAINT `some_foreign_key_without_action` FOREIGN KEY (`integer_main`) REFERENCES `auto_increment_test`
+ (`int_auto_increment_with_nullable`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8',
-];
\ No newline at end of file
+];
diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/declarative_installer/installation.php b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/declarative_installer/installation.php
index 68d129f0bbf5e..73531a6f37d7b 100644
--- a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/declarative_installer/installation.php
+++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/declarative_installer/installation.php
@@ -43,4 +43,4 @@
KEY `speedup_index` (`tinyint`,`bigint`),
CONSTRAINT `some_foreign_key` FOREIGN KEY (`tinyint`) REFERENCES `reference_table` (`tinyint_ref`) ON DELETE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8',
-];
\ No newline at end of file
+];
diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/valid_xml_revision_1.php b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/valid_xml_revision_1.php
index c2de2cb375435..78e2a519d52a7 100644
--- a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/valid_xml_revision_1.php
+++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/valid_xml_revision_1.php
@@ -132,8 +132,8 @@
'smallint' => 'smallint',
'bigint' => 'bigint',
],
- 'type' => 'unique',
- 'name' => 'some_unique_key',
+ 'type' => 'unique',
+ 'name' => 'some_unique_key',
],
'some_foreign_key' => [
'type' => 'foreign',
diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/old_diff/InstallSchema.php b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/old_diff/InstallSchema.php
index faafc92683a69..a0b1778dd37c4 100644
--- a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/old_diff/InstallSchema.php
+++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/old_diff/InstallSchema.php
@@ -17,6 +17,7 @@ class InstallSchema implements InstallSchemaInterface
{
/**
* {@inheritdoc}
+ *
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function install(SchemaSetupInterface $setup, ModuleContextInterface $context)
diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule2/Setup/InstallSchema.php b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule2/Setup/InstallSchema.php
index ee087eea3e437..0ed0cbb89e763 100644
--- a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule2/Setup/InstallSchema.php
+++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule2/Setup/InstallSchema.php
@@ -17,6 +17,7 @@ class InstallSchema implements InstallSchemaInterface
{
/**
* {@inheritdoc}
+ *
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function install(SchemaSetupInterface $setup, ModuleContextInterface $context)
diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupModule1/Setup/InstallSchema.php b/dev/tests/setup-integration/_files/Magento/TestSetupModule1/Setup/InstallSchema.php
index 37c24afab75ed..32226670cf10d 100644
--- a/dev/tests/setup-integration/_files/Magento/TestSetupModule1/Setup/InstallSchema.php
+++ b/dev/tests/setup-integration/_files/Magento/TestSetupModule1/Setup/InstallSchema.php
@@ -17,6 +17,7 @@ class InstallSchema implements InstallSchemaInterface
{
/**
* {@inheritdoc}
+ *
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function install(SchemaSetupInterface $setup, ModuleContextInterface $context)
diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupModule2/Setup/InstallData.php b/dev/tests/setup-integration/_files/Magento/TestSetupModule2/Setup/InstallData.php
index 071496f14f4a4..7bda19dc51f2a 100644
--- a/dev/tests/setup-integration/_files/Magento/TestSetupModule2/Setup/InstallData.php
+++ b/dev/tests/setup-integration/_files/Magento/TestSetupModule2/Setup/InstallData.php
@@ -16,6 +16,7 @@ class InstallData implements InstallDataInterface
{
/**
* {@inheritdoc}
+ *
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupModule2/Setup/InstallSchema.php b/dev/tests/setup-integration/_files/Magento/TestSetupModule2/Setup/InstallSchema.php
index 7c5430dc1b745..44dccfae087f9 100644
--- a/dev/tests/setup-integration/_files/Magento/TestSetupModule2/Setup/InstallSchema.php
+++ b/dev/tests/setup-integration/_files/Magento/TestSetupModule2/Setup/InstallSchema.php
@@ -17,6 +17,7 @@ class InstallSchema implements InstallSchemaInterface
{
/**
* {@inheritdoc}
+ *
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function install(SchemaSetupInterface $setup, ModuleContextInterface $context)
diff --git a/dev/tests/setup-integration/_files/UpgradeScripts/TestSetupModule2/Setup/UpgradeData.php b/dev/tests/setup-integration/_files/UpgradeScripts/TestSetupModule2/Setup/UpgradeData.php
index c1bc2ccd7e6da..1550d1dfb2311 100644
--- a/dev/tests/setup-integration/_files/UpgradeScripts/TestSetupModule2/Setup/UpgradeData.php
+++ b/dev/tests/setup-integration/_files/UpgradeScripts/TestSetupModule2/Setup/UpgradeData.php
@@ -17,6 +17,7 @@ class UpgradeData implements UpgradeDataInterface
/**
* {@inheritdoc}
+ *
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
@@ -45,9 +46,11 @@ public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface
'telephone' => 12345678,
]
);
- $setup->getConnection()->update($setup->getTable('setup_tests_entity_table'), [
+ $setup->getConnection()->update(
+ $setup->getTable('setup_tests_entity_table'), [
'increment_id'=> 1
- ], 'increment_id = null');
+ ], 'increment_id = null'
+ );
$setup->getConnection()->insertForce(
$setup->getTable('setup_tests_entity_passwords'),
diff --git a/dev/tests/setup-integration/_files/UpgradeScripts/TestSetupModule2/Setup/UpgradeSchema.php b/dev/tests/setup-integration/_files/UpgradeScripts/TestSetupModule2/Setup/UpgradeSchema.php
index 4ce4b91f7c6f5..084ef15b5f6ee 100755
--- a/dev/tests/setup-integration/_files/UpgradeScripts/TestSetupModule2/Setup/UpgradeSchema.php
+++ b/dev/tests/setup-integration/_files/UpgradeScripts/TestSetupModule2/Setup/UpgradeSchema.php
@@ -17,6 +17,7 @@ class UpgradeSchema implements UpgradeSchemaInterface
{
/**
* {@inheritdoc}
+ *
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $context)
diff --git a/dev/tests/setup-integration/framework/Magento/TestFramework/Annotation/CopyModules.php b/dev/tests/setup-integration/framework/Magento/TestFramework/Annotation/CopyModules.php
index 7206090c7982c..3d927154c3731 100644
--- a/dev/tests/setup-integration/framework/Magento/TestFramework/Annotation/CopyModules.php
+++ b/dev/tests/setup-integration/framework/Magento/TestFramework/Annotation/CopyModules.php
@@ -12,7 +12,6 @@
/**
* Handler for applying reinstallMagento annotation
- *
*/
class CopyModules
{
@@ -38,7 +37,7 @@ public function __construct()
/**
* Handler for 'startTest' event
*
- * @param \PHPUnit\Framework\TestCase $test
+ * @param \PHPUnit\Framework\TestCase $test
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function startTest(\PHPUnit\Framework\TestCase $test)
@@ -49,22 +48,4 @@ public function startTest(\PHPUnit\Framework\TestCase $test)
$this->cliCommand->introduceModule($annotations['method']['moduleName'][0]);
}
}
-
- /**
- * Handler for 'startTest' event
- *
- * @param \PHPUnit\Framework\TestCase $test
- */
- public function endTest(\PHPUnit\Framework\TestCase $test)
- {
- $annotations = $test->getAnnotations();
- //This annotation can be declared only on method level
- if (isset($annotations['method']['moduleName'])) {
- $path = MAGENTO_MODULES_PATH .
- //Take only module name from Magento_ModuleName
- explode("_", $annotations['method']['moduleName'][0])[1];
-
- //File::rmdirRecursive($path);
- }
- }
}
diff --git a/dev/tests/setup-integration/framework/Magento/TestFramework/Annotation/DataProviderFromFile.php b/dev/tests/setup-integration/framework/Magento/TestFramework/Annotation/DataProviderFromFile.php
index ee0f5d2514276..d01a8d18bd51c 100644
--- a/dev/tests/setup-integration/framework/Magento/TestFramework/Annotation/DataProviderFromFile.php
+++ b/dev/tests/setup-integration/framework/Magento/TestFramework/Annotation/DataProviderFromFile.php
@@ -12,7 +12,6 @@
/**
* Handler for applying reinstallMagento annotation
- *
*/
class DataProviderFromFile
{
diff --git a/dev/tests/setup-integration/framework/Magento/TestFramework/Annotation/ReinstallInstance.php b/dev/tests/setup-integration/framework/Magento/TestFramework/Annotation/ReinstallInstance.php
index 5e53bbf637123..827e5955f9f6b 100644
--- a/dev/tests/setup-integration/framework/Magento/TestFramework/Annotation/ReinstallInstance.php
+++ b/dev/tests/setup-integration/framework/Magento/TestFramework/Annotation/ReinstallInstance.php
@@ -8,7 +8,6 @@
/**
* Handler for applying reinstallMagento annotation
- *
*/
class ReinstallInstance
{
diff --git a/dev/tests/setup-integration/framework/Magento/TestFramework/Annotation/SchemaFixture.php b/dev/tests/setup-integration/framework/Magento/TestFramework/Annotation/SchemaFixture.php
index f270dda133d5e..df584c0c96dba 100644
--- a/dev/tests/setup-integration/framework/Magento/TestFramework/Annotation/SchemaFixture.php
+++ b/dev/tests/setup-integration/framework/Magento/TestFramework/Annotation/SchemaFixture.php
@@ -11,6 +11,7 @@
/**
* Represents
+ *
* @magentoSchemaFixture {link_to_file.php}
*/
class SchemaFixture
@@ -30,7 +31,7 @@ class SchemaFixture
/**
* Constructor
*
- * @param string $fixtureBaseDir
+ * @param string $fixtureBaseDir
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function __construct($fixtureBaseDir)
@@ -46,7 +47,7 @@ public function __construct($fixtureBaseDir)
/**
* Apply magento data fixture on
*
- * @param \PHPUnit\Framework\TestCase $test
+ * @param \PHPUnit\Framework\TestCase $test
* @return void
*/
public function startTest(\PHPUnit\Framework\TestCase $test)
@@ -69,8 +70,8 @@ public function endTest(\PHPUnit\Framework\TestCase $test)
/**
* Retrieve fixtures from annotation
*
- * @param \PHPUnit\Framework\TestCase $test
- * @param string $scope
+ * @param \PHPUnit\Framework\TestCase $test
+ * @param string $scope
* @return array
* @throws \Magento\Framework\Exception\LocalizedException
*/
@@ -114,7 +115,7 @@ private function getAnnotations(\PHPUnit\Framework\TestCase $test)
/**
* Execute single fixture script
*
- * @param string|array $fixture
+ * @param string|array $fixture
* @throws \Exception
*/
protected function _applyOneFixture($fixture)
@@ -123,7 +124,7 @@ protected function _applyOneFixture($fixture)
if (is_callable($fixture)) {
call_user_func($fixture);
} else {
- require $fixture;
+ include $fixture;
}
} catch (\Exception $e) {
throw new \Exception(
@@ -137,7 +138,7 @@ protected function _applyOneFixture($fixture)
/**
* Execute fixture scripts if any
*
- * @param array $fixtures
+ * @param array $fixtures
* @throws \Magento\Framework\Exception\LocalizedException
*/
protected function _applyFixtures(array $fixtures)
diff --git a/dev/tests/setup-integration/framework/Magento/TestFramework/Bootstrap/SetupDocBlock.php b/dev/tests/setup-integration/framework/Magento/TestFramework/Bootstrap/SetupDocBlock.php
index 4ace776ec413e..b039403389cbf 100644
--- a/dev/tests/setup-integration/framework/Magento/TestFramework/Bootstrap/SetupDocBlock.php
+++ b/dev/tests/setup-integration/framework/Magento/TestFramework/Bootstrap/SetupDocBlock.php
@@ -9,6 +9,7 @@
* Bootstrap of the custom DocBlock annotations
*
* \Magento\TestFramework\Isolation\DeploymentConfig was excluded for setup/upgrade tests
+ *
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class SetupDocBlock extends \Magento\TestFramework\Bootstrap\DocBlock
@@ -16,7 +17,7 @@ class SetupDocBlock extends \Magento\TestFramework\Bootstrap\DocBlock
/**
* Get list of subscribers. In addition, register reinstallMagento annotation processing.
*
- * @param \Magento\TestFramework\Application $application
+ * @param \Magento\TestFramework\Application $application
* @return array
*/
protected function _getSubscribers(\Magento\TestFramework\Application $application)
diff --git a/dev/tests/setup-integration/framework/Magento/TestFramework/Deploy/CliCommand.php b/dev/tests/setup-integration/framework/Magento/TestFramework/Deploy/CliCommand.php
index e20b4af206d97..2daefd0036cae 100644
--- a/dev/tests/setup-integration/framework/Magento/TestFramework/Deploy/CliCommand.php
+++ b/dev/tests/setup-integration/framework/Magento/TestFramework/Deploy/CliCommand.php
@@ -32,8 +32,8 @@ class CliCommand
/**
* ShellCommand constructor.
*
- * @param TestModuleManager $testEnv
- * @param ParametersHolder $paramatersHolder
+ * @param TestModuleManager $testEnv
+ * @param ParametersHolder $paramatersHolder
* @internal param Shell $shell
*/
public function __construct(
@@ -47,7 +47,7 @@ public function __construct(
/**
* Copy Test module files and execute enable module command
*
- * @param string $moduleName
+ * @param string $moduleName
* @return string
*/
public function introduceModule($moduleName)
@@ -59,7 +59,7 @@ public function introduceModule($moduleName)
/**
* Execute enable module command
*
- * @param string $moduleName
+ * @param string $moduleName
* @return string
*/
public function enableModule($moduleName)
@@ -86,7 +86,7 @@ public function upgrade()
/**
* Execute disable module command
*
- * @param string $moduleName
+ * @param string $moduleName
* @return string
*/
public function disableModule($moduleName)
@@ -99,6 +99,7 @@ public function disableModule($moduleName)
/**
* Split quote db configuration
+ *
* @return void
*/
public function splitQuote()
@@ -107,14 +108,17 @@ public function splitQuote()
$installParams = $this->toCliArguments(
$this->parametersHolder->getDbData('checkout')
);
- $command = 'php -f ' . BP . '/bin/magento setup:db-schema:split-quote '
- . implode(" ", array_keys($installParams)) . ' -vvv --magento-init-params=' . $initParams['magento-init-params'];
+ $command = 'php -f ' . BP . '/bin/magento setup:db-schema:split-quote ' .
+ implode(" ", array_keys($installParams)) .
+ ' -vvv --magento-init-params=' .
+ $initParams['magento-init-params'];
$this->shell->execute($command, array_values($installParams));
}
/**
* Split sales db configuration
+ *
* @return void
*/
public function splitSales()
@@ -123,8 +127,10 @@ public function splitSales()
$installParams = $this->toCliArguments(
$this->parametersHolder->getDbData('sales')
);
- $command = 'php -f ' . BP . '/bin/magento setup:db-schema:split-sales '
- . implode(" ", array_keys($installParams)) . ' -vvv --magento-init-params=' . $initParams['magento-init-params'];
+ $command = 'php -f ' . BP . '/bin/magento setup:db-schema:split-sales ' .
+ implode(" ", array_keys($installParams)) .
+ ' -vvv --magento-init-params=' .
+ $initParams['magento-init-params'];
$this->shell->execute($command, array_values($installParams));
}
@@ -132,7 +138,7 @@ public function splitSales()
/**
* Convert from raw params to CLI arguments, like --admin-username
*
- * @param array $params
+ * @param array $params
* @return array
*/
private function toCliArguments(array $params)
diff --git a/dev/tests/setup-integration/framework/Magento/TestFramework/Deploy/DescribeTable.php b/dev/tests/setup-integration/framework/Magento/TestFramework/Deploy/DescribeTable.php
index e09a5860098b2..3b839919c749f 100644
--- a/dev/tests/setup-integration/framework/Magento/TestFramework/Deploy/DescribeTable.php
+++ b/dev/tests/setup-integration/framework/Magento/TestFramework/Deploy/DescribeTable.php
@@ -28,7 +28,7 @@ public function __construct(DbSchemaReader $dbSchemaReader)
/**
* Describe shards
*
- * @param string $shardName
+ * @param string $shardName
* @return array
*/
public function describeShard($shardName)
diff --git a/dev/tests/setup-integration/framework/Magento/TestFramework/Deploy/ParametersHolder.php b/dev/tests/setup-integration/framework/Magento/TestFramework/Deploy/ParametersHolder.php
index 9240451183b43..691c90a903458 100644
--- a/dev/tests/setup-integration/framework/Magento/TestFramework/Deploy/ParametersHolder.php
+++ b/dev/tests/setup-integration/framework/Magento/TestFramework/Deploy/ParametersHolder.php
@@ -47,7 +47,7 @@ public function getInitParams()
* -db-password
* -db-host
*
- * @param string $resource can be default, checkout, sales
+ * @param string $resource can be default, checkout, sales
* @return array
*/
public function getDbData($resource)
diff --git a/dev/tests/setup-integration/framework/Magento/TestFramework/Deploy/TestModuleManager.php b/dev/tests/setup-integration/framework/Magento/TestFramework/Deploy/TestModuleManager.php
index 6e1554bf8be1f..65896004d46b8 100644
--- a/dev/tests/setup-integration/framework/Magento/TestFramework/Deploy/TestModuleManager.php
+++ b/dev/tests/setup-integration/framework/Magento/TestFramework/Deploy/TestModuleManager.php
@@ -18,7 +18,7 @@ class TestModuleManager
/**
* Add test module files to Magento code base
*
- * @param string $moduleName
+ * @param string $moduleName
* @return void
* @throws \RuntimeException
*/
@@ -61,10 +61,10 @@ public function addModuleFiles($moduleName)
}
/**
- * @param string $moduleName Like Magento_TestSetupModule
+ * @param string $moduleName Like Magento_TestSetupModule
* @param string $revisionName Folder name, like reviisions/revision_1/db_schema.xml
- * @param string $fileName For example db_schema.xml
- * @param string $fileDir For example etc or Setup
+ * @param string $fileName For example db_schema.xml
+ * @param string $fileDir For example etc or Setup
*/
public function updateRevision($moduleName, $revisionName, $fileName, $fileDir)
{
@@ -85,7 +85,7 @@ public function updateRevision($moduleName, $revisionName, $fileName, $fileDir)
/**
* Remove test module files to Magento code base
*
- * @param string $moduleName
+ * @param string $moduleName
* @return void
*/
public function removeModuleFiles($moduleName)
@@ -102,7 +102,7 @@ public function removeModuleFiles($moduleName)
/**
* Update module files
*
- * @param string $moduleName
+ * @param string $moduleName
* @return void
*/
public function updateModuleFiles($moduleName)
diff --git a/dev/tests/setup-integration/framework/Magento/TestFramework/SetupApplication.php b/dev/tests/setup-integration/framework/Magento/TestFramework/SetupApplication.php
index cbacf82929587..9ebb0d0d2953e 100644
--- a/dev/tests/setup-integration/framework/Magento/TestFramework/SetupApplication.php
+++ b/dev/tests/setup-integration/framework/Magento/TestFramework/SetupApplication.php
@@ -5,13 +5,9 @@
*/
namespace Magento\TestFramework;
-use Magento\Framework\App\DesignInterface;
-use Magento\Framework\View\DesignExceptions;
-
/**
* Encapsulates application installation, initialization and uninstall, add flag to skip database dump
*
- *
* Allow installation and uninstallation
*/
class SetupApplication extends Application
diff --git a/dev/tests/setup-integration/framework/Magento/TestFramework/TestCase/MutableDataInterface.php b/dev/tests/setup-integration/framework/Magento/TestFramework/TestCase/MutableDataInterface.php
index c2323975b8bc4..2779e095be1ed 100644
--- a/dev/tests/setup-integration/framework/Magento/TestFramework/TestCase/MutableDataInterface.php
+++ b/dev/tests/setup-integration/framework/Magento/TestFramework/TestCase/MutableDataInterface.php
@@ -14,7 +14,7 @@ interface MutableDataInterface
/**
* Set dataproviders data
*
- * @param array $data
+ * @param array $data
* @return void
*/
public function setData(array $data);
diff --git a/dev/tests/setup-integration/framework/Magento/TestFramework/Workaround/DeploymentConfig.php b/dev/tests/setup-integration/framework/Magento/TestFramework/Workaround/DeploymentConfig.php
index b5ac5a2867eca..1154b144ca1f1 100644
--- a/dev/tests/setup-integration/framework/Magento/TestFramework/Workaround/DeploymentConfig.php
+++ b/dev/tests/setup-integration/framework/Magento/TestFramework/Workaround/DeploymentConfig.php
@@ -13,6 +13,7 @@
/**
* Represents
+ *
* @magentoSchemaFixture {link_to_file.php}
*/
class DeploymentConfig
diff --git a/dev/tests/setup-integration/framework/bootstrap.php b/dev/tests/setup-integration/framework/bootstrap.php
index aa3e7c0c6a751..ced028bae1bc6 100644
--- a/dev/tests/setup-integration/framework/bootstrap.php
+++ b/dev/tests/setup-integration/framework/bootstrap.php
@@ -79,7 +79,7 @@
if ($settings->getAsBoolean('TESTS_CLEANUP')) {
$application->cleanup();
//remove test modules files
- require_once __DIR__ . '/../../setup-integration/framework/removeTestModules.php';
+ include_once __DIR__ . '/../../setup-integration/framework/removeTestModules.php';
}
//We do not want to install anything
$application->initialize([]);
diff --git a/dev/tests/setup-integration/framework/removeTestModules.php b/dev/tests/setup-integration/framework/removeTestModules.php
index f52901e911c70..71f54e4f0fb25 100644
--- a/dev/tests/setup-integration/framework/removeTestModules.php
+++ b/dev/tests/setup-integration/framework/removeTestModules.php
@@ -8,7 +8,9 @@
* @var $testFrameworkDir string - Must be defined in parent script.
*/
-/** Copy test modules to app/code/Magento to make them visible for Magento instance */
+/**
+ * Copy test modules to app/code/Magento to make them visible for Magento instance
+ */
$pathToCommittedTestModules = $testFrameworkDir . '/../_files/Magento';
$pathToInstalledMagentoInstanceModules = $testFrameworkDir . '/../../../../app/code/Magento';
$iterator = new RecursiveIteratorIterator(
diff --git a/dev/tests/setup-integration/testsuite/Magento/Setup/DeclarativeSchemaBuilderTest.php b/dev/tests/setup-integration/testsuite/Magento/Setup/DeclarativeSchemaBuilderTest.php
index e4def33f5c8cd..81dcb95c40c3f 100644
--- a/dev/tests/setup-integration/testsuite/Magento/Setup/DeclarativeSchemaBuilderTest.php
+++ b/dev/tests/setup-integration/testsuite/Magento/Setup/DeclarativeSchemaBuilderTest.php
@@ -46,19 +46,25 @@ public function testSchemaBuilder()
$dbSchema = $this->schemaConfig->getDeclarationConfig();
//Test primary key and renaming
$referenceTable = $dbSchema->getTableByName('reference_table');
- /** @var Internal $primaryKey */
+ /**
+ * @var Internal $primaryKey
+*/
$primaryKey = $referenceTable->getPrimaryConstraint();
$columns = $primaryKey->getColumns();
self::assertEquals(reset($columns)->getName(), 'tinyint_ref');
//Test column
$testTable = $dbSchema->getTableByName('test_table');
- /** @var Timestamp $timestampColumn */
+ /**
+ * @var Timestamp $timestampColumn
+*/
$timestampColumn = $testTable->getColumnByName('timestamp');
self::assertEquals($timestampColumn->getOnUpdate(), 'CURRENT_TIMESTAMP');
//Test disabled
self::assertArrayNotHasKey('varbinary_rename', $testTable->getColumns());
//Test foreign key
- /** @var Reference $foreignKey */
+ /**
+ * @var Reference $foreignKey
+*/
$foreignKey = $testTable->getConstraintByName('some_foreign_key');
self::assertEquals($foreignKey->getOnDelete(), 'NO ACTION');
self::assertEquals($foreignKey->getReferenceColumn()->getName(), 'tinyint_ref');
diff --git a/dev/tests/setup-integration/testsuite/Magento/Setup/InstallTest.php b/dev/tests/setup-integration/testsuite/Magento/Setup/InstallTest.php
index db4f425ceacc9..6be27f33ac87d 100644
--- a/dev/tests/setup-integration/testsuite/Magento/Setup/InstallTest.php
+++ b/dev/tests/setup-integration/testsuite/Magento/Setup/InstallTest.php
@@ -43,7 +43,9 @@ protected function setUp()
$objectManager = Bootstrap::getObjectManager();
$this->shellCommand = $objectManager->get(\Magento\TestFramework\Deploy\CliCommand::class);
$this->testModuleManager = $objectManager->get(\Magento\TestFramework\Deploy\TestModuleManager::class);
- /** @var \Magento\Framework\Setup\ModuleDataSetupInterface $installer */
+ /**
+ * @var \Magento\Framework\Setup\ModuleDataSetupInterface $installer
+*/
}
public static function tearDownAfterClass()
@@ -85,7 +87,7 @@ public function testInstallSchema()
*/
public function testColumnStructure($initialName, $name)
{
- $expectedSchema = require __DIR__ . '/_files/expectedSchema.php';
+ $expectedSchema = include __DIR__ . '/_files/expectedSchema.php';
//check if table prefix was defined
$this->assertTrue($this->connection->isTableExists($name), "Table {$name} doesn't not exists");
$tableSchema = $this->connection->describeTable($name);
@@ -104,7 +106,7 @@ public function testColumnStructure($initialName, $name)
*/
public function testVerifyRelations($initialName, $name)
{
- $expectedRelations = require __DIR__ . '/_files/expectedRelations.php';
+ $expectedRelations = include __DIR__ . '/_files/expectedRelations.php';
//check that table not exists
$this->assertTrue($this->connection->isTableExists($name), "Table {$name} doesn't not exists");
$actualForeignKeyName = $this->connection->getForeignKeys($name);
@@ -131,7 +133,7 @@ public function testVerifyRelations($initialName, $name)
*/
public function testVerifyIndexes($initialName, $name)
{
- $expectedIndexes = require __DIR__ . '/_files/expectedIndexes.php';
+ $expectedIndexes = include __DIR__ . '/_files/expectedIndexes.php';
//check that table not exists
$this->assertTrue($this->connection->isTableExists($name), "Table {$name} doesn't not exists");
$actualIndexList = $this->connection->getIndexList($name);
diff --git a/dev/tests/setup-integration/testsuite/Magento/Setup/SchemaReaderTest.php b/dev/tests/setup-integration/testsuite/Magento/Setup/SchemaReaderTest.php
index 843f5c1fc45b9..3eecb74c145cb 100644
--- a/dev/tests/setup-integration/testsuite/Magento/Setup/SchemaReaderTest.php
+++ b/dev/tests/setup-integration/testsuite/Magento/Setup/SchemaReaderTest.php
@@ -46,7 +46,7 @@ public function testSuccessfullRead()
/**
* Helper method. Decrease number of params
*
- * @param string $revisionName
+ * @param string $revisionName
* @return void
*/
private function updateRevisionTo($revisionName)
diff --git a/dev/tests/setup-integration/testsuite/Magento/Setup/UpgradeTest.php b/dev/tests/setup-integration/testsuite/Magento/Setup/UpgradeTest.php
index d235b9978b1ea..c153276ff3b1b 100644
--- a/dev/tests/setup-integration/testsuite/Magento/Setup/UpgradeTest.php
+++ b/dev/tests/setup-integration/testsuite/Magento/Setup/UpgradeTest.php
@@ -53,7 +53,9 @@ protected function setUp()
$objectManager = Bootstrap::getObjectManager();
$this->shellCommand = $objectManager->create(\Magento\TestFramework\Deploy\CliCommand::class);
$this->testModuleManager = $objectManager->create(\Magento\TestFramework\Deploy\TestModuleManager::class);
- /** @var \Magento\Framework\Setup\ModuleDataSetupInterface $installer */
+ /**
+ * @var \Magento\Framework\Setup\ModuleDataSetupInterface $installer
+*/
$this->installer = $objectManager->create(
\Magento\Framework\Setup\ModuleDataSetupInterface::class
);
@@ -145,7 +147,7 @@ public function tablesStructureDataProvider()
*/
public function testTableDataAfterInstall($tableName)
{
- $expectedData = $expectedData = require __DIR__ . '/_files/expectedData.php';
+ $expectedData = $expectedData = include __DIR__ . '/_files/expectedData.php';
$name = $this->tablesName[$tableName];
$this->assertTrue($this->connection->isTableExists($name), "Table {$name} doesn't not exists");
$select = $this->connection->select()->from($this->installer->getTable($name));
@@ -210,12 +212,12 @@ public function testUpgrade()
/**
* @param string $tableName
- * @param int $count
+ * @param int $count
* @dataProvider tableDataAfterUpgradeDataProvider
*/
public function testDataAfterUpgrade($count, $tableName)
{
- $expectedData = $expectedData = require __DIR__ . '/_files/expectedDataAfterUpgrade.php';
+ $expectedData = $expectedData = include __DIR__ . '/_files/expectedDataAfterUpgrade.php';
$name = $this->installer->getTable($tableName);
$this->assertTrue($this->connection->isTableExists($name), "Table {$name} doesn't not exists");
$select = $this->connection->select()->from($name);
@@ -236,7 +238,7 @@ public function tableDataAfterUpgradeDataProvider()
/**
* Convert actual foreign keys data
*
- * @param array $actualRelations
+ * @param array $actualRelations
* @return array
*/
private function getForeignKeysData($actualRelations)
@@ -256,7 +258,7 @@ private function getForeignKeysData($actualRelations)
/**
* Convert actual indexes data
*
- * @param array $actualIndexesList
+ * @param array $actualIndexesList
* @return array
*/
private function getIndexesData($actualIndexesList)
@@ -277,7 +279,7 @@ private function getIndexesData($actualIndexesList)
/**
* Convert actual table schema structure
*
- * @param array $actualTableStructure
+ * @param array $actualTableStructure
* @return array
*/
private function getConvertedStructure($actualTableStructure)
@@ -298,9 +300,9 @@ private function getConvertedStructure($actualTableStructure)
private function getExpectedData()
{
if (empty($this->expectedData)) {
- $expectedSchema = require __DIR__ . '/_files/expectedSchema.php';
- $expectedRelations = require __DIR__ . '/_files/expectedRelations.php';
- $expectedIndexes = require __DIR__ . '/_files/expectedIndexes.php';
+ $expectedSchema = include __DIR__ . '/_files/expectedSchema.php';
+ $expectedRelations = include __DIR__ . '/_files/expectedRelations.php';
+ $expectedIndexes = include __DIR__ . '/_files/expectedIndexes.php';
$this->expectedData = [
$expectedSchema,
$expectedRelations,
@@ -313,7 +315,7 @@ private function getExpectedData()
/**
* Return array of table names in format 'initial table name' => 'table name with prefix'
*
- * @param \Magento\Framework\Setup\ModuleDataSetupInterface $installer
+ * @param \Magento\Framework\Setup\ModuleDataSetupInterface $installer
* @return array
*/
private function getTableNameMapping($installer)
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Comparator.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Comparator.php
index 6e81178aa5307..18b4c8974cce8 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Comparator.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Comparator.php
@@ -17,7 +17,7 @@ class Comparator
{
/**
* @param ElementInterface | ElementDiffAwareInterface $first
- * @param ElementInterface | ElementDiffAwareInterface $second
+ * @param ElementInterface | ElementDiffAwareInterface $second
* @return bool
*/
public function compare(ElementInterface $first, ElementInterface $second)
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Config/Converter.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Config/Converter.php
index 4f2e748873936..a1781dc27ebb3 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Config/Converter.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Config/Converter.php
@@ -9,6 +9,7 @@
/**
* This converter serve needs of Declaration Filesystem reader:
+ *
* @see \Magento\Setup\Model\Declaration\Schema\FileSystem\XmlReader
*
* It allows to convert declarative schema to raw array and add default values
@@ -19,7 +20,7 @@ class Converter implements \Magento\Framework\Config\ConverterInterface
/**
* Convert config from XML to array
*
- * @param \DOMDocument $source
+ * @param \DOMDocument $source
* @return array
*/
public function convert($source)
@@ -33,7 +34,7 @@ public function convert($source)
* So we do not need root elements in result, only table names
* So proposed to select only tables from all DomDOCUMENT
*
- * @param \DOMDocument $element
+ * @param \DOMDocument $element
* @return \DOMNodeList
*/
private function getTablesNode(\DOMDocument $element)
@@ -74,7 +75,7 @@ private function recursiveConvert(\Traversable $source)
* XSI:TYPE is in another namespace, so we need to do additio
* Note: name is mandatory attribute
*
- * @param \DOMElement $element
+ * @param \DOMElement $element
* @return bool
*/
private function hasAttributesExceptName(\DOMElement $element)
@@ -86,7 +87,7 @@ private function hasAttributesExceptName(\DOMElement $element)
* Mix attributes that comes from XML schema with default ones
* So if you will not have some attribute in schema - it will be taken from default one
*
- * @param \DOMElement $domElement
+ * @param \DOMElement $domElement
* @return mixed
*/
private function interpretateAttributes(\DOMElement $domElement)
@@ -104,7 +105,7 @@ private function interpretateAttributes(\DOMElement $domElement)
/**
* Convert XML attributes into raw array with attributes
*
- * @param \DOMElement $element
+ * @param \DOMElement $element
* @return array
*/
private function getAttributes(\DOMElement $element)
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Config/SchemaLocator.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Config/SchemaLocator.php
index 393e62b500a36..5c5fe538762fd 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Config/SchemaLocator.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Config/SchemaLocator.php
@@ -26,7 +26,7 @@ class SchemaLocator implements \Magento\Framework\Config\SchemaLocatorInterface
/**
* @param \Magento\Framework\Config\Dom\UrnResolver $urnResolver
- * @param string $schemaUrn
+ * @param string $schemaUrn
*/
public function __construct(
\Magento\Framework\Config\Dom\UrnResolver $urnResolver,
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/AdapterMediator.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/AdapterMediator.php
index 5e5eaaf68c827..e27ac985a711f 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/AdapterMediator.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/AdapterMediator.php
@@ -75,7 +75,7 @@ class AdapterMediator
/**
* @param DbSchemaReaderInterface $dbSchemaReader
* @param DbSchemaWriterInterface $dbSchemaCreator
- * @param array $processors
+ * @param array $processors
*/
public function __construct(
DbSchemaReaderInterface $dbSchemaReader,
@@ -91,8 +91,8 @@ public function __construct(
* Go through all processors and modify column data
* depends on type column has
*
- * @param array $elementData
- * @param $type
+ * @param array $elementData
+ * @param $type
* @return array
*/
private function processElementFromDefinition(array $elementData, $type)
@@ -101,7 +101,9 @@ private function processElementFromDefinition(array $elementData, $type)
throw new \InvalidArgumentException(sprintf("Cannot find type %s", $type));
}
- /** @var DbSchemaProcessorInterface $columnProcessor */
+ /**
+ * @var DbSchemaProcessorInterface $columnProcessor
+*/
foreach ($this->processors[$type] as $columnProcessor) {
$elementData = $columnProcessor->fromDefinition($elementData);
}
@@ -112,7 +114,7 @@ private function processElementFromDefinition(array $elementData, $type)
/**
* Retrieve definition for all table elements
*
- * @param Table $table
+ * @param Table $table
* @return void
*/
public function createTable(Table $table)
@@ -129,7 +131,9 @@ public function createTable(Table $table)
];
foreach ($data as $type => $elements) {
- /** @var ElementInterface $element */
+ /**
+ * @var ElementInterface $element
+*/
foreach ($elements as $element) {
$definition[$type][$element->getName()] = $this
->processElementToDefinition($element);
@@ -142,7 +146,7 @@ public function createTable(Table $table)
/**
* Prepare and add element (column, constraint, index) to table
*
- * @param ElementInterface | TableElementInterface $element
+ * @param ElementInterface | TableElementInterface $element
* @return void
*/
public function addElement(ElementInterface $element)
@@ -185,7 +189,7 @@ public function modifyConstraint(Constraint $constraint)
/**
* Prepare and drop element from table
*
- * @param ElementInterface | TableElementInterface $element
+ * @param ElementInterface | TableElementInterface $element
* @return void
*/
public function dropElement(ElementInterface $element)
@@ -243,13 +247,15 @@ public function dropTable(Table $table)
/**
* Process column definition
*
- * @param ElementInterface $element
+ * @param ElementInterface $element
* @return string
*/
public function processElementToDefinition(ElementInterface $element)
{
$definition = '';
- /** @var DbSchemaProcessorInterface $processor */
+ /**
+ * @var DbSchemaProcessorInterface $processor
+*/
foreach ($this->processors[$element->getElementType()] as $processor) {
//One column processor can override or modify existing one
if ($processor->canBeApplied($element)) {
@@ -263,8 +269,8 @@ public function processElementToDefinition(ElementInterface $element)
/**
* Retrieve the list of all Magento non-unique and non-primary indexes
*
- * @param string $tableName
- * @param string $resource
+ * @param string $tableName
+ * @param string $resource
* @return array
*/
public function getIndexesList($tableName, $resource)
@@ -318,8 +324,8 @@ public function getConstraintsList($tableName, $resource)
/**
* Retrieve list of preprocessed foreign keys
*
- * @param string $tableName
- * @param string $resource
+ * @param string $tableName
+ * @param string $resource
* @return array
*/
public function getReferencesList($tableName, $resource)
@@ -339,7 +345,7 @@ public function getReferencesList($tableName, $resource)
/**
* @param $tableName
- * @param string $resource
+ * @param string $resource
* @return array
*/
public function getColumnsList($tableName, $resource)
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/DbSchemaProcessorInterface.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/DbSchemaProcessorInterface.php
index 4eb60118d1fdf..0b483a0d11558 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/DbSchemaProcessorInterface.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/DbSchemaProcessorInterface.php
@@ -19,7 +19,7 @@ interface DbSchemaProcessorInterface
/**
* Check whether current processor can process element
*
- * @param ElementInterface $element
+ * @param ElementInterface $element
* @return mixed
*/
public function canBeApplied(ElementInterface $element);
@@ -27,7 +27,7 @@ public function canBeApplied(ElementInterface $element);
/**
* Output always will be SQL definition
*
- * @param ElementInterface $element
+ * @param ElementInterface $element
* @return string
*/
public function toDefinition(ElementInterface $element);
@@ -38,7 +38,7 @@ public function toDefinition(ElementInterface $element);
* 'type' => 'name VARCHAR(255)'\
* 'nullable' => 'no'
*
- * @param array $data
+ * @param array $data
* @return array
*/
public function fromDefinition(array $data);
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/DbSchemaReaderInterface.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/DbSchemaReaderInterface.php
index ecb107350db72..07bfc97a3ef33 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/DbSchemaReaderInterface.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/DbSchemaReaderInterface.php
@@ -15,8 +15,8 @@ interface DbSchemaReaderInterface
/**
* Read indexes, from Magento tables
*
- * @param string $tableName
- * @param string $resource
+ * @param string $tableName
+ * @param string $resource
* @return array
*/
public function readIndexes($tableName, $resource);
@@ -24,8 +24,8 @@ public function readIndexes($tableName, $resource);
/**
* Read constraints, from Magento tables
*
- * @param string $tableName
- * @param string $resource
+ * @param string $tableName
+ * @param string $resource
* @return array
*/
public function readConstraints($tableName, $resource);
@@ -33,8 +33,8 @@ public function readConstraints($tableName, $resource);
/**
* Read columns, from Magento tables
*
- * @param string $tableName
- * @param string $resource
+ * @param string $tableName
+ * @param string $resource
* @return array
*/
public function readeColumns($tableName, $resource);
@@ -42,8 +42,8 @@ public function readeColumns($tableName, $resource);
/**
* Read references (foreign keys) from Magento tables
*
- * @param string $tableName
- * @param string $resource
+ * @param string $tableName
+ * @param string $resource
* @return array
*/
public function readReferences($tableName, $resource);
@@ -51,7 +51,7 @@ public function readReferences($tableName, $resource);
/**
* Read table names, from Magento tables
*
- * @param string $resource
+ * @param string $resource
* @return array
*/
public function readTables($resource);
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/DbSchemaWriterInterface.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/DbSchemaWriterInterface.php
index 89619f44d38a9..2bef0db6a7479 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/DbSchemaWriterInterface.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/DbSchemaWriterInterface.php
@@ -15,8 +15,8 @@ interface DbSchemaWriterInterface
/**
* Create table from SQL fragments, like columns, constraints, foreign keys, indexes, etc
*
- * @param array $tableOptions
- * @param array $sqlFragments
+ * @param array $tableOptions
+ * @param array $sqlFragments
* @return void
*/
public function createTable(array $tableOptions, array $sqlFragments);
@@ -24,7 +24,7 @@ public function createTable(array $tableOptions, array $sqlFragments);
/**
* Drop table from SQL database
*
- * @param array $tableOptions must have 2 options: table_name, resource
+ * @param array $tableOptions must have 2 options: table_name, resource
* @return mixed
*/
public function dropTable(array $tableOptions);
@@ -34,9 +34,9 @@ public function dropTable(array $tableOptions);
*
* Can be: column, constraint, index
*
- * @param array $elementOptions must have 3 options: resource, column_name, table_name
- * @param string $elementDefinition, for example: like CHAR(200) NOT NULL
- * @param string $elementType
+ * @param array $elementOptions must have 3 options: resource, column_name, table_name
+ * @param string $elementDefinition, for example: like CHAR(200) NOT NULL
+ * @param string $elementType
* @return mixed
*/
public function addElement(array $elementOptions, $elementDefinition, $elementType);
@@ -46,8 +46,8 @@ public function addElement(array $elementOptions, $elementDefinition, $elementTy
*
* Please note: that from all structural elements only column can be modified
*
- * @param array $columnOptions must have 3 options: resource, column_name, table_name
- * @param string $columnDefinition
+ * @param array $columnOptions must have 3 options: resource, column_name, table_name
+ * @param string $columnDefinition
* @return void
*/
public function modifyColumn(array $columnOptions, $columnDefinition);
@@ -56,8 +56,8 @@ public function modifyColumn(array $columnOptions, $columnDefinition);
* As we can`t just drop and recreate constraint in 2 requests
* we need to do this in one request
*
- * @param array $constraintOptions
- * @param string $constraintDefinition
+ * @param array $constraintOptions
+ * @param string $constraintDefinition
* @return void
*/
public function modifyConstraint(array $constraintOptions, $constraintDefinition);
@@ -65,8 +65,8 @@ public function modifyConstraint(array $constraintOptions, $constraintDefinition
/**
* Drop any element (constraint, column, index) from index
*
- * @param string $elementType enum(CONSTRAINT, INDEX, COLUMN)
- * @param array $elementOptions
+ * @param string $elementType enum(CONSTRAINT, INDEX, COLUMN)
+ * @param array $elementOptions
* @return \Zend_Db_Statement_Interface
*/
public function dropElement($elementType, array $elementOptions);
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Basic.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Basic.php
index cf9bae8227828..98a8850eba27c 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Basic.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Basic.php
@@ -53,7 +53,7 @@ public function __construct(Unsigned $unsigned, Nullable $nullable)
/**
* Basic type can not process any type of elements
*
- * @param ElementInterface $element
+ * @param ElementInterface $element
* @return bool
*/
public function canBeApplied(ElementInterface $element)
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Blob.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Blob.php
index 8f58e4706c6dd..d9552280ff5d1 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Blob.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Blob.php
@@ -23,6 +23,7 @@ class Blob implements DbSchemaProcessorInterface
/**
* Text constructor.
+ *
* @param Nullable $nullable
*/
public function __construct(Nullable $nullable)
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Boolean.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Boolean.php
index 68c9cb80dce57..66ee4c682b694 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Boolean.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Boolean.php
@@ -43,7 +43,7 @@ class Boolean implements DbSchemaProcessorInterface
private $defaultDefinition;
/**
- * @param Nullable $nullable
+ * @param Nullable $nullable
* @param DefaultDefinition $defaultDefinition
*/
public function __construct(Nullable $nullable, DefaultDefinition $defaultDefinition)
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Decimal.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Decimal.php
index b73ab55ef8bb1..a2f5aa2aeb78c 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Decimal.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Decimal.php
@@ -32,8 +32,8 @@ class Decimal implements DbSchemaProcessorInterface
private $defaultDefinition;
/**
- * @param Nullable $nullable
- * @param Unsigned $unsigned
+ * @param Nullable $nullable
+ * @param Unsigned $unsigned
* @param DefaultDefinition $defaultDefinition
*/
public function __construct(Nullable $nullable, Unsigned $unsigned, DefaultDefinition $defaultDefinition)
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/DefaultDefinition.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/DefaultDefinition.php
index 1de6b840c8c2e..2a74b504eb4cd 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/DefaultDefinition.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/DefaultDefinition.php
@@ -30,7 +30,7 @@ public function toDefinition(ElementInterface $element)
/**
* Stringify default before we will collect definition
*
- * @param mixed $default
+ * @param mixed $default
* @return string
*/
private function defaultStringify($default)
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Integer.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Integer.php
index 2cf19193d38de..1d64b23de5557 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Integer.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Integer.php
@@ -42,10 +42,10 @@ class Integer implements DbSchemaProcessorInterface
private $defaultDefinition;
/**
- * @param Unsigned $unsigned
- * @param bool $boolean
- * @param Nullable $nullable
- * @param Identity $identity
+ * @param Unsigned $unsigned
+ * @param bool $boolean
+ * @param Nullable $nullable
+ * @param Identity $identity
* @param DefaultDefinition $defaultDefinition
*/
public function __construct(
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Nullable.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Nullable.php
index b04f368b2f072..90ac02afb55df 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Nullable.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Nullable.php
@@ -47,7 +47,7 @@ public function canBeApplied(ElementInterface $element)
/**
* Convert MySQL nullable string value into boolean
*
- * @param string $nullableValue
+ * @param string $nullableValue
* @return bool
*/
private function processNullable($nullableValue)
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Text.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Text.php
index a0dbf42239d56..22a4488c19ea0 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Text.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Text.php
@@ -23,6 +23,7 @@ class Text implements DbSchemaProcessorInterface
/**
* Text constructor.
+ *
* @param Nullable $nullable
*/
public function __construct(Nullable $nullable)
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Timestamp.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Timestamp.php
index 489fe097b8eab..1e7b3fa5fb6a5 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Timestamp.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Timestamp.php
@@ -33,7 +33,7 @@ class Timestamp implements DbSchemaProcessorInterface
private $defaultDefinition;
/**
- * @param OnUpdate $onUpdate
+ * @param OnUpdate $onUpdate
* @param DefaultDefinition $defaultDefinition
*/
public function __construct(OnUpdate $onUpdate, DefaultDefinition $defaultDefinition)
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Varchar.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Varchar.php
index 5f5fbfe548dfa..ced97aeccd561 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Varchar.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Varchar.php
@@ -25,7 +25,7 @@ class Varchar implements DbSchemaProcessorInterface
private $defaultDefinition;
/**
- * @param Nullable $nullable
+ * @param Nullable $nullable
* @param DefaultDefinition $defaultDefinition
*/
public function __construct(Nullable $nullable, DefaultDefinition $defaultDefinition)
@@ -35,7 +35,7 @@ public function __construct(Nullable $nullable, DefaultDefinition $defaultDefini
}
/**
- * @param \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Varchar $element
+ * @param \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Varchar $element
* @param \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Varbinary $element
* @inheritdoc
*/
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Constraints/Internal.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Constraints/Internal.php
index 9e40b6d867ca8..fe21e285428e5 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Constraints/Internal.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Constraints/Internal.php
@@ -56,7 +56,7 @@ public function toDefinition(ElementInterface $element)
$element->getTable()->getResource()
);
$columnsList = array_map(
- function(Column $column) use ($adapter) {
+ function (Column $column) use ($adapter) {
return $adapter->quoteIdentifier($column->getName());
},
$element->getColumns()
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/DbSchemaReader.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/DbSchemaReader.php
index a243eb8d50615..337123234d5a5 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/DbSchemaReader.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/DbSchemaReader.php
@@ -31,8 +31,8 @@ public function __construct(ResourceConnection $resourceConnection)
/**
* Prepare and fetch query: Describe {table_name}
*
- * @param string $tableName
- * @param string $resource
+ * @param string $tableName
+ * @param string $resource
* @return array
*/
public function readeColumns($tableName, $resource)
@@ -48,8 +48,8 @@ public function readeColumns($tableName, $resource)
/**
* Fetch all indexes from table
*
- * @param string $tableName
- * @param string $resource
+ * @param string $tableName
+ * @param string $resource
* @return array
*/
public function readIndexes($tableName, $resource)
@@ -78,8 +78,8 @@ public function readReferences($tableName, $resource)
/**
* Retrieve Create table SQL, from SHOW CREATE TABLE query
*
- * @param string $tableName
- * @param string $resource
+ * @param string $tableName
+ * @param string $resource
* @return array
*/
public function getCreateTableSql($tableName, $resource)
@@ -111,13 +111,13 @@ public function readConstraints($tableName, $resource)
/**
* Return names of all tables from shard
*
- * @param string $resource Shard name
+ * @param string $resource Shard name
* @return array
*/
public function readTables($resource)
{
return $this->resourceConnection
- ->getConnection($resource)
- ->getTables();
+ ->getConnection($resource)
+ ->getTables();
}
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/DbSchemaWriter.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/DbSchemaWriter.php
index e64c282a2f676..265fdca6e5714 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/DbSchemaWriter.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/DbSchemaWriter.php
@@ -35,9 +35,9 @@ public function __construct(ResourceConnection $resourceConnection)
/**
* Prepare constraint statement by compiling name and definition together
*
- * @param string $name
- * @param string $indexDefinition
- * @param string $elementType: can be COLUMN, CONSTRAINT or INDEX
+ * @param string $name
+ * @param string $indexDefinition
+ * @param string $elementType: can be COLUMN, CONSTRAINT or INDEX
* @return string
*/
private function getAddElementSQL($elementType, $name, $indexDefinition)
@@ -51,8 +51,8 @@ private function getAddElementSQL($elementType, $name, $indexDefinition)
* To format:
* $name $definition
*
- * @param array $columnsDefinition
- * @param AdapterInterface $adapter
+ * @param array $columnsDefinition
+ * @param AdapterInterface $adapter
* @return array
*/
private function getColumnsWithNames(array $columnsDefinition, AdapterInterface $adapter)
@@ -108,7 +108,7 @@ public function createTable(array $tableOptions, array $definition)
/**
* Drop table from MySQL database
*
- * @param array $tableOptions
+ * @param array $tableOptions
* @return \Zend_Db_Statement_Interface
*/
public function dropTable(array $tableOptions)
@@ -128,9 +128,9 @@ public function dropTable(array $tableOptions)
/**
* For Primary key we do not need to specify name
*
- * @param string $elementType
- * @param string $type
- * @param string $name
+ * @param string $elementType
+ * @param string $type
+ * @param string $name
* @return string
*/
private function getDropElementSQL($elementType, $type, $name)
@@ -154,9 +154,9 @@ private function getDropElementSQL($elementType, $type, $name)
* Add element to already existed table
* We can add three different elements: column, constraint or index
*
- * @param array $elementOptions should consists from 3 elements: resource, elementname, tablename
- * @param string $elementDefinition
- * @param string $elementType
+ * @param array $elementOptions should consists from 3 elements: resource, elementname, tablename
+ * @param string $elementDefinition
+ * @param string $elementType
* @return \Zend_Db_Statement_Interface
*/
public function addElement(array $elementOptions, $elementDefinition, $elementType)
@@ -182,8 +182,8 @@ public function addElement(array $elementOptions, $elementDefinition, $elementTy
/**
* Modify column and change it definition
*
- * @param array $columnOptions
- * @param string $columnDefinition
+ * @param array $columnOptions
+ * @param string $columnDefinition
* @return \Zend_Db_Statement_Interface
*/
public function modifyColumn(array $columnOptions, $columnDefinition)
@@ -206,25 +206,25 @@ public function modifyColumn(array $columnOptions, $columnDefinition)
/**
* Detect what type of constraint we have
*
- * @param string $type
+ * @param string $type
* @return string
*/
private function getConstraintType($type)
{
switch ($type) {
- case 'foreign':
- $elementType = ForeignKey::FOREIGN_KEY_NAME;
- break;
- case 'primary':
- $elementType = Internal::PRIMARY_KEY_NAME;
- break;
- case 'unique':
- case 'index':
- //In MySQL for unique and for index drop syntax is the same
- $elementType = Index::INDEX_KEY_NAME;
- break;
- default:
- $elementType = Constraint::TYPE;
+ case 'foreign':
+ $elementType = ForeignKey::FOREIGN_KEY_NAME;
+ break;
+ case 'primary':
+ $elementType = Internal::PRIMARY_KEY_NAME;
+ break;
+ case 'unique':
+ case 'index':
+ //In MySQL for unique and for index drop syntax is the same
+ $elementType = Index::INDEX_KEY_NAME;
+ break;
+ default:
+ $elementType = Constraint::TYPE;
}
return $elementType;
@@ -268,8 +268,8 @@ public function modifyConstraint(array $constraintOptions, $constraintDefinition
/**
* Drop any element (constraint, column, index) from index
*
- * @param string $elementType enum(CONSTRAINT, INDEX, COLUMN)
- * @param array $elementOptions
+ * @param string $elementType enum(CONSTRAINT, INDEX, COLUMN)
+ * @param array $elementOptions
* @return \Zend_Db_Statement_Interface
*/
public function dropElement($elementType, array $elementOptions)
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Index.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Index.php
index 7c60601e95b20..1ad89b817fa48 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Index.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Index.php
@@ -56,7 +56,7 @@ public function toDefinition(ElementInterface $element)
$element->getTable()->getResource()
);
$columnsList = array_map(
- function(Column $column) use ($adapter) {
+ function (Column $column) use ($adapter) {
return $adapter->quoteIdentifier($column->getName());
},
$element->getColumns()
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/SchemaBuilder.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/SchemaBuilder.php
index 30d12bcce79cc..e76164286ee27 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/SchemaBuilder.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/SchemaBuilder.php
@@ -22,7 +22,7 @@
* because it should have references to other DTO objects.
* In order to convert build only 1 structural element use directly it factory
*
- * @see Schema
+ * @see Schema
* @inheritdoc
*/
class SchemaBuilder
@@ -49,10 +49,11 @@ class SchemaBuilder
/**
* Parser constructor.
- * @param AdapterMediator $adapter
- * @param ElementFactory $elementFactory
+ *
+ * @param AdapterMediator $adapter
+ * @param ElementFactory $elementFactory
* @param DbSchemaReaderInterface $dbSchemaReader
- * @param Sharding $sharding
+ * @param Sharding $sharding
*/
public function __construct(
AdapterMediator $adapter,
@@ -83,11 +84,15 @@ public function build(Schema $schema)
$indexesData = $this->adapter->getIndexesList($tableName, $resource);
$constrainsData = $this->adapter->getConstraintsList($tableName, $resource);
- /** @var Table $table */
- $table = $this->elementFactory->create('table', [
+ /**
+ * @var Table $table
+*/
+ $table = $this->elementFactory->create(
+ 'table', [
'name' => $tableName,
'resource' => $resource
- ]);
+ ]
+ );
// Process columns
foreach ($columnsData as $columnData) {
@@ -128,7 +133,7 @@ public function build(Schema $schema)
* This needs to validate schema. And find out invalid references, for example
* for tables that do not exists already
*
- * @param Table[] $tables
+ * @param Table[] $tables
* @return Table[]
*/
private function processReferenceKeys(array $tables)
@@ -159,8 +164,8 @@ private function processReferenceKeys(array $tables)
/**
* Retrieve column objects from names
*
- * @param Column[] $columns
- * @param array $data
+ * @param Column[] $columns
+ * @param array $data
* @return Column[]
*/
private function resolveInternalRelations(array $columns, array $data)
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/SchemaBuilder.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/SchemaBuilder.php
index da96b75cd7dc0..28d81bf052d02 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/SchemaBuilder.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/SchemaBuilder.php
@@ -59,10 +59,11 @@ class SchemaBuilder
/**
* SchemaBuilder constructor.
- * @param ElementFactory $elementFactory
- * @param BooleanUtils $booleanUtils
- * @param Sharding $sharding
- * @param ValidationComposite $validationComposite
+ *
+ * @param ElementFactory $elementFactory
+ * @param BooleanUtils $booleanUtils
+ * @param Sharding $sharding
+ * @param ValidationComposite $validationComposite
* @internal param array $tablesData
*/
public function __construct(
@@ -81,7 +82,7 @@ public function __construct(
* Add tables data to builder
* Tables data holds tables information: columns, constraints, indexes, attributes
*
- * @param array $tablesData
+ * @param array $tablesData
* @return self
*/
public function addTablesData(array $tablesData)
@@ -93,7 +94,7 @@ public function addTablesData(array $tablesData)
/**
* Do schema validation and print all errors
*
- * @param Schema $schema
+ * @param Schema $schema
* @throws Exception
*/
private function validate(Schema $schema)
@@ -113,7 +114,7 @@ private function validate(Schema $schema)
/**
* Build schema
*
- * @param Schema $schema
+ * @param Schema $schema
* @throws Exception
* @return Schema
*/
@@ -145,7 +146,7 @@ private function getStructuralElementResource(array $tableData)
/**
* Check whether element is disabled and should not appear in final declaration
*
- * @param array $structuralElementData
+ * @param array $structuralElementData
* @return bool
*/
private function isDisabled(array $structuralElementData)
@@ -158,9 +159,9 @@ private function isDisabled(array $structuralElementData)
* Instantiate column DTO objects from array
* If column was renamed new key will be associated to it
*
- * @param array $tableData
- * @param string $resource
- * @param Table $table
+ * @param array $tableData
+ * @param string $resource
+ * @param Table $table
* @return array
*/
private function processColumns(array $tableData, $resource, Table $table)
@@ -183,9 +184,9 @@ private function processColumns(array $tableData, $resource, Table $table)
/**
* Process generic data that is support by all 3 child types: columns, constraints, indexes
*
- * @param array $elementData
- * @param Table $table
- * @param $resource
+ * @param array $elementData
+ * @param Table $table
+ * @param $resource
* @return array
*/
private function processGenericData(array $elementData, $resource, Table $table)
@@ -200,8 +201,8 @@ private function processGenericData(array $elementData, $resource, Table $table)
* Process tables and add them to schema
* If table already exists - then we need to skip it
*
- * @param Schema $schema
- * @param array $tableData
+ * @param Schema $schema
+ * @param array $tableData
* @return \Magento\Setup\Model\Declaration\Schema\Dto\Table
*/
private function processTable(Schema $schema, array $tableData)
@@ -212,7 +213,9 @@ private function processTable(Schema $schema, array $tableData)
'name' => $tableData['name'],
'resource' => $resource,
];
- /** @var Table $table */
+ /**
+ * @var Table $table
+*/
$table = $this->elementFactory->create('table', $tableParams);
$columns = $this->processColumns($tableData, $resource, $table);
$table->addColumns($columns);
@@ -229,8 +232,8 @@ private function processTable(Schema $schema, array $tableData)
/**
* Convert column names to objects
*
- * @param array $columnNames
- * @param Table $table
+ * @param array $columnNames
+ * @param Table $table
* @return array
*/
private function convertColumnNamesToObjects(array $columnNames, Table $table)
@@ -247,9 +250,9 @@ private function convertColumnNamesToObjects(array $columnNames, Table $table)
/**
* Convert and instantiate index objects
*
- * @param array $tableData
- * @param $resource
- * @param Table $table
+ * @param array $tableData
+ * @param $resource
+ * @param Table $table
* @return Index[]
*/
private function processIndexes(array $tableData, $resource, Table $table)
@@ -277,9 +280,9 @@ private function processIndexes(array $tableData, $resource, Table $table)
/**
* Convert and instantiate constraint objects
*
- * @param array $tableData
- * @param $resource
- * @param Schema $schema
+ * @param array $tableData
+ * @param $resource
+ * @param Schema $schema
* @return Constraint[]
*/
private function processConstraints(array $tableData, $resource, Schema $schema)
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/ValidationInterface.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/ValidationInterface.php
index aa9e35a650a81..16066ca7ca7ee 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/ValidationInterface.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/ValidationInterface.php
@@ -15,7 +15,7 @@ interface ValidationInterface
/**
* Do different validations on readed db schema
*
- * @param Schema $schema
+ * @param Schema $schema
* @return array Return array of errors. If everything is ok - retrieve empty array
*/
public function validate(Schema $schema);
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/Diff.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/Diff.php
index 3993967830dd9..592c050eba869 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/Diff.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/Diff.php
@@ -52,7 +52,7 @@ class Diff implements DiffInterface
private $elementHistoryFactory;
/**
- * @param ComponentRegistrar $componentRegistrar
+ * @param ComponentRegistrar $componentRegistrar
* @param ElementHistoryFactory $elementHistoryFactory
*/
public function __construct(
@@ -80,7 +80,6 @@ public function get($operation = null)
* Whitelist tables should have JSON format and should be added through
* CLI command: should be done in next story
*
- *
* @return array
*/
private function getWhiteListTables()
@@ -108,7 +107,7 @@ private function getWhiteListTables()
* For example, if element is not in whitelist.json it cant
* be registered due to backward incompatability
*
- * @param ElementInterface $object
+ * @param ElementInterface $object
* @return bool
*/
private function canBeRegistered(ElementInterface $object)
@@ -139,7 +138,7 @@ public function register(ElementInterface $dtoObject, $operation, ElementInterfa
{
//Comment until whitelist functionality will be done
if (!$this->canBeRegistered($dtoObject)) {
- #return $this; //ignore any operations for non registered elements changes
+ // return $this; //ignore any operations for non registered elements changes
}
$historyData = ['new' => $dtoObject, 'old' => $oldDtoObject];
$history = $this->elementHistoryFactory->create($historyData);
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/DiffFactory.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/DiffFactory.php
index c04474d8f5736..99ee25959f74a 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/DiffFactory.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/DiffFactory.php
@@ -7,8 +7,6 @@
namespace Magento\Setup\Model\Declaration\Schema\Diff;
use Magento\Framework\ObjectManagerInterface;
-use Zend\Di\ServiceLocatorInterface;
-use Zend\ServiceManager\ServiceManager;
/**
* @see DiffInterface
@@ -22,6 +20,7 @@ class DiffFactory
/**
* ChangeRegistryFactory constructor.
+ *
* @param ObjectManagerInterface $objectManager
*/
public function __construct(ObjectManagerInterface $objectManager)
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/DiffInterface.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/DiffInterface.php
index f946c7d4cb325..16bb56825e871 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/DiffInterface.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/DiffInterface.php
@@ -32,7 +32,7 @@ interface DiffInterface
* ]
* ]
*
- * @param string $operation If operation is not specified, changes for all operations will be retrieved
+ * @param string $operation If operation is not specified, changes for all operations will be retrieved
* @return ElementHistory[]
*/
public function get($operation = null);
@@ -40,9 +40,9 @@ public function get($operation = null);
/**
* Register operation
*
- * @param ElementInterface|object $dtoObject
- * @param string $operation
- * @param ElementInterface $oldDtoObject
+ * @param ElementInterface|object $dtoObject
+ * @param string $operation
+ * @param ElementInterface $oldDtoObject
* @return void
*/
public function register(
@@ -54,7 +54,7 @@ public function register(
/**
* Register current state of schema to registry
*
- * @param Schema $schema
+ * @param Schema $schema
* @return void
*/
public function registerSchema(Schema $schema);
@@ -76,7 +76,7 @@ public function getCurrentInstallationRequest();
/**
* Register installation request with all needed options
*
- * @param Request $request
+ * @param Request $request
* @return void
*/
public function registerInstallationRequest(Request $request);
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/DiffManager.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/DiffManager.php
index dacc2fc53679f..071420804288b 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/DiffManager.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/DiffManager.php
@@ -37,8 +37,8 @@ public function __construct(Comparator $comparator)
/**
* Check whether this is element is new or not, by checking it in db schema
*
- * @param ElementInterface[] $generatedElements
- * @param ElementInterface $element
+ * @param ElementInterface[] $generatedElements
+ * @param ElementInterface $element
* @return bool
*/
public function shouldBeCreated(array $generatedElements, ElementInterface $element)
@@ -49,7 +49,7 @@ public function shouldBeCreated(array $generatedElements, ElementInterface $elem
/**
* Check whether we have elements that should be removed from database
*
- * @param array $generatedElements
+ * @param array $generatedElements
* @return bool
*/
public function shouldBeRemoved(array $generatedElements)
@@ -60,10 +60,9 @@ public function shouldBeRemoved(array $generatedElements)
/**
* Register element, that should changes
*
- *
- * @param DiffInterface $diff
- * @param ElementInterface $element
- * @param ElementInterface $generatedElement
+ * @param DiffInterface $diff
+ * @param ElementInterface $element
+ * @param ElementInterface $generatedElement
* @return DiffInterface
*/
public function registerModification(
@@ -83,9 +82,9 @@ public function registerModification(
* If elements really dont exists in declaration - we will remove them
* If some mistake happens (and element is just not preprocessed), we will throw exception
*
- * @param DiffInterface $diff
- * @param ElementInterface[] $generatedElements
- * @param ElementInterface[] $elements
+ * @param DiffInterface $diff
+ * @param ElementInterface[] $generatedElements
+ * @param ElementInterface[] $elements
* @return DiffInterface
*/
public function registerRemoval(
@@ -114,7 +113,7 @@ public function registerRemoval(
}
/**
- * @param DiffInterface $diff
+ * @param DiffInterface $diff
* @param ElementInterface $element
* @return DiffInterface
*/
@@ -132,8 +131,8 @@ public function registerCreation(DiffInterface $diff, ElementInterface $element)
/**
* Check whether element should be modified or not
*
- * @param ElementInterface $element
- * @param ElementInterface $generatedElement
+ * @param ElementInterface $element
+ * @param ElementInterface $generatedElement
* @return bool
*/
public function shouldBeModified(
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/SchemaDiff.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/SchemaDiff.php
index bee12a1869a4c..ee5e2cc6de70b 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/SchemaDiff.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/SchemaDiff.php
@@ -35,7 +35,7 @@ class SchemaDiff
/**
* @param DiffManager $diffManager
- * @param TableDiff $tableDiff
+ * @param TableDiff $tableDiff
* @param DiffFactory $diffFactory
*/
public function __construct(
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/TableDiff.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/TableDiff.php
index 14b91c3daccf5..06f57f9dd272e 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/TableDiff.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/TableDiff.php
@@ -53,8 +53,8 @@ public function __construct(DiffManager $diffManager)
* As SQL engine can automatically create indexes for foreign keys in order to speedup selection
* and we do not have this keys in declaration - we need to ignore them
*
- * @param Table $table
- * @param Index[] $indexes
+ * @param Table $table
+ * @param Index[] $indexes
* @return Index[]
*/
private function excludeAutoIndexes(Table $table, array $indexes)
@@ -69,7 +69,7 @@ private function excludeAutoIndexes(Table $table, array $indexes)
/**
* @param Table | ElementInterface $declaredTable
* @param Table | ElementInterface $generatedTable
- * @param Diff $diff
+ * @param Diff $diff
* @inheritdoc
*/
public function diff(
@@ -101,9 +101,10 @@ public function diff(
if ($this->diffManager->shouldBeCreated($generatedElements, $element)) {
$diff = $this->diffManager->registerCreation($diff, $element);
} else if ($this->diffManager->shouldBeModified(
- $element,
- $generatedElements[$element->getName()]
- )) {
+ $element,
+ $generatedElements[$element->getName()]
+ )
+ ) {
$diff = $this->diffManager
->registerModification($diff, $element, $generatedElements[$element->getName()]);
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Column.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Column.php
index b9afbb41284cc..663da48771275 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Column.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Column.php
@@ -27,7 +27,7 @@ class Column extends GenericElement implements
/**
* @param string $name
* @param string $type
- * @param Table $table
+ * @param Table $table
*/
public function __construct(
string $name,
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Blob.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Blob.php
index 280c2614a4a7b..23960dd8d0317 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Blob.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Blob.php
@@ -26,8 +26,8 @@ class Blob extends Column implements
/**
* @param string $name
* @param string $type
- * @param Table $table
- * @param bool $nullable
+ * @param Table $table
+ * @param bool $nullable
*/
public function __construct(
string $name,
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Boolean.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Boolean.php
index 91e302501c074..9c810c1daf156 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Boolean.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Boolean.php
@@ -29,9 +29,9 @@ class Boolean extends Column implements
private $default;
/**
- * @param string $name
- * @param string $type
- * @param Table $table
+ * @param string $name
+ * @param string $type
+ * @param Table $table
* @param $nullable
* @param $default
*/
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Decimal.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Decimal.php
index 9d86cbef29307..b315aeb80f850 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Decimal.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Decimal.php
@@ -48,12 +48,12 @@ class Decimal extends Column implements
/**
* @param string $name
* @param string $type
- * @param Table $table
- * @param int $precission
- * @param int $scale
- * @param bool $nullable
- * @param float $default
- * @param bool $unsigned
+ * @param Table $table
+ * @param int $precission
+ * @param int $scale
+ * @param bool $nullable
+ * @param float $default
+ * @param bool $unsigned
*/
public function __construct(
string $name,
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Integer.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Integer.php
index f4341a5b9a736..47ff95176cb0b 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Integer.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Integer.php
@@ -45,13 +45,13 @@ class Integer extends Column implements
private $identity;
/**
- * @param string $name
- * @param string $type
- * @param Table $table
- * @param int $padding
- * @param bool $nullable
- * @param bool $unsigned
- * @param bool $identity
+ * @param string $name
+ * @param string $type
+ * @param Table $table
+ * @param int $padding
+ * @param bool $nullable
+ * @param bool $unsigned
+ * @param bool $identity
* @param float|int $default
*/
public function __construct(
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Text.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Text.php
index b00f66ccbbee8..0b4fc487908d5 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Text.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Text.php
@@ -25,8 +25,8 @@ class Text extends Column implements
/**
* @param string $name
* @param string $type
- * @param Table $table
- * @param bool $nullable
+ * @param Table $table
+ * @param bool $nullable
*/
public function __construct(
string $name,
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Timestamp.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Timestamp.php
index b3de2388a79ae..e7e6e544b838d 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Timestamp.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Timestamp.php
@@ -29,9 +29,9 @@ class Timestamp extends Column implements
private $onUpdate;
/**
- * @param string $name
- * @param string $type
- * @param Table $table
+ * @param string $name
+ * @param string $type
+ * @param Table $table
* @param $default
* @param string|null $onUpdate
*/
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Varbinary.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Varbinary.php
index 6b77d8ad381f3..56a720bd6d348 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Varbinary.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Varbinary.php
@@ -35,11 +35,11 @@ class Varbinary extends Column implements
private $length;
/**
- * @param string $name
- * @param string $type
- * @param Table $table
- * @param bool $nullable
- * @param int $length
+ * @param string $name
+ * @param string $type
+ * @param Table $table
+ * @param bool $nullable
+ * @param int $length
* @param float|int $default
*/
public function __construct(
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Varchar.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Varchar.php
index 3457a13017cf5..fda2f1bb38d7f 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Varchar.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Varchar.php
@@ -35,11 +35,11 @@ class Varchar extends Column implements
private $length;
/**
- * @param string $name
- * @param string $type
- * @param Table $table
- * @param bool $nullable
- * @param int $length
+ * @param string $name
+ * @param string $type
+ * @param Table $table
+ * @param bool $nullable
+ * @param int $length
* @param float|int $default
*/
public function __construct(
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Constraint.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Constraint.php
index a9ce3731d2a5a..8c734be6de342 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Constraint.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Constraint.php
@@ -27,8 +27,8 @@ class Constraint extends GenericElement implements
/**
* @param string $name
* @param string $type
- * @param Table $table
- * @param array $columns
+ * @param Table $table
+ * @param array $columns
*/
public function __construct(
string $name,
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Constraints/Internal.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Constraints/Internal.php
index 43ef26756f512..1ed06f4ed9bf3 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Constraints/Internal.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Constraints/Internal.php
@@ -28,10 +28,11 @@ class Internal extends Constraint implements ElementDiffAwareInterface
/**
* Internal constructor.
+ *
* @param string $name
* @param string $type
- * @param Table $table
- * @param array $columns
+ * @param Table $table
+ * @param array $columns
*/
public function __construct(
$name,
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Constraints/Reference.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Constraints/Reference.php
index 74c924b4c5004..33d5830c9feff 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Constraints/Reference.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Constraints/Reference.php
@@ -39,9 +39,9 @@ class Reference extends Constraint implements ElementDiffAwareInterface
/**
* @param string $name
* @param string $type
- * @param Table $table
+ * @param Table $table
* @param Column $column
- * @param Table $referenceTable
+ * @param Table $referenceTable
* @param Column $referenceColumn
* @param string $onDelete
*/
@@ -82,7 +82,6 @@ public function getReferenceColumn()
/**
* External table to where we do reference
*
- *
* @return Table
*/
public function getReferenceTable()
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/ElementFactory.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/ElementFactory.php
index af93663b0ec37..8e7fe1ea97456 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/ElementFactory.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/ElementFactory.php
@@ -11,8 +11,8 @@
/**
* This is abstract factory that allows to
* instantiate any type of structural elements
- * @see ElementInterface
*
+ * @see ElementInterface
*/
class ElementFactory
{
@@ -30,7 +30,7 @@ class ElementFactory
/**
* @param FactoryInterface[] $typeFactories
- * @param BooleanUtils $booleanUtils
+ * @param BooleanUtils $booleanUtils
*/
public function __construct(array $typeFactories, BooleanUtils $booleanUtils)
{
@@ -46,7 +46,7 @@ public function __construct(array $typeFactories, BooleanUtils $booleanUtils)
*
* We need to cast this attributes to boolean values in abstract factory
*
- * @param array $elementStructuralData
+ * @param array $elementStructuralData
* @return array
*/
private function castGenericAttributes(array $elementStructuralData)
@@ -66,8 +66,8 @@ private function castGenericAttributes(array $elementStructuralData)
/**
* Instantiate different types of elements, depends on their xsi:type
*
- * @param string $type
- * @param array $elementStructuralData
+ * @param string $type
+ * @param array $elementStructuralData
* @return ElementInterface | object
*/
public function create($type, array $elementStructuralData)
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Blob.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Blob.php
index c85813b1b4b38..6698bf9bebe51 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Blob.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Blob.php
@@ -29,7 +29,7 @@ class Blob implements FactoryInterface
/**
* @param ObjectManagerInterface $objectManager
- * @param string $className
+ * @param string $className
*/
public function __construct(
ObjectManagerInterface $objectManager,
@@ -43,6 +43,7 @@ public function __construct(
* Set default padding, like SMALLINT(5)
*
* {@inheritdoc}
+ *
* @return array
*/
public function create(array $data)
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Boolean.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Boolean.php
index efff88f34b701..fbbbacaf0a1d2 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Boolean.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Boolean.php
@@ -36,8 +36,8 @@ class Boolean implements FactoryInterface
/**
* @param ObjectManagerInterface $objectManager
- * @param BooleanUtils $booleanUtils
- * @param string $className
+ * @param BooleanUtils $booleanUtils
+ * @param string $className
*/
public function __construct(
ObjectManagerInterface $objectManager,
@@ -53,6 +53,7 @@ public function __construct(
* Convert default attribute from string to boolean value
*
* {@inheritdoc}
+ *
* @return array
*/
public function create(array $data)
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Date.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Date.php
index d08169550f67e..301f13d449f49 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Date.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Date.php
@@ -25,7 +25,7 @@ class Date implements FactoryInterface
/**
* @param ObjectManagerInterface $objectManager
- * @param string $className
+ * @param string $className
*/
public function __construct(
ObjectManagerInterface $objectManager,
@@ -39,6 +39,7 @@ public function __construct(
* Set shape to floating point, that is by default (10,0)
*
* {@inheritdoc}
+ *
* @return array
*/
public function create(array $data)
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Decimal.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Decimal.php
index 797e531157a05..e2efb0d9486e3 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Decimal.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Decimal.php
@@ -36,7 +36,7 @@ class Decimal implements FactoryInterface
/**
* @param ObjectManagerInterface $objectManager
- * @param string $className
+ * @param string $className
*/
public function __construct(
ObjectManagerInterface $objectManager,
@@ -50,6 +50,7 @@ public function __construct(
* Set shape to floating point, that is by default (10,0)
*
* {@inheritdoc}
+ *
* @return array
*/
public function create(array $data)
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/FactoryInterface.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/FactoryInterface.php
index fa0f5cfe75292..5622aec2aeac6 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/FactoryInterface.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/FactoryInterface.php
@@ -16,7 +16,7 @@ interface FactoryInterface
/**
* Compute and return effective value of an argument
*
- * @param array $data
+ * @param array $data
* @return ElementInterface
*/
public function create(array $data);
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Foreign.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Foreign.php
index 260bd78891e99..99697c69e8ba8 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Foreign.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Foreign.php
@@ -30,7 +30,7 @@ class Foreign implements FactoryInterface
/**
* @param ObjectManagerInterface $objectManager
- * @param string $className
+ * @param string $className
*/
public function __construct(
ObjectManagerInterface $objectManager,
@@ -44,6 +44,7 @@ public function __construct(
* Set default on delete to foreign key
*
* {@inheritdoc}
+ *
* @return array
*/
public function create(array $data)
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Index.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Index.php
index 29233b7309e2a..2deaf0320abb4 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Index.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Index.php
@@ -29,7 +29,7 @@ class Index implements FactoryInterface
/**
* @param ObjectManagerInterface $objectManager
- * @param string $className
+ * @param string $className
*/
public function __construct(
ObjectManagerInterface $objectManager,
@@ -43,6 +43,7 @@ public function __construct(
* Set default on delete to foreign key
*
* {@inheritdoc}
+ *
* @return array
*/
public function create(array $data)
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Integer.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Integer.php
index 3e1ced472c97b..0858906d7d1be 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Integer.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Integer.php
@@ -38,7 +38,7 @@ class Integer implements FactoryInterface
/**
* @param ObjectManagerInterface $objectManager
- * @param string $className
+ * @param string $className
*/
public function __construct(
ObjectManagerInterface $objectManager,
@@ -52,6 +52,7 @@ public function __construct(
* Set default padding, like INTEGER(11)
*
* {@inheritdoc}
+ *
* @return array
*/
public function create(array $data)
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/LongBlob.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/LongBlob.php
index 800ce74e9dd2e..ac77da7ad5b0e 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/LongBlob.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/LongBlob.php
@@ -29,7 +29,7 @@ class LongBlob implements FactoryInterface
/**
* @param ObjectManagerInterface $objectManager
- * @param string $className
+ * @param string $className
*/
public function __construct(
ObjectManagerInterface $objectManager,
@@ -43,6 +43,7 @@ public function __construct(
* Set default padding, like SMALLINT(5)
*
* {@inheritdoc}
+ *
* @return array
*/
public function create(array $data)
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/LongText.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/LongText.php
index 0e9cf6ac7ba0e..44e48fd340c98 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/LongText.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/LongText.php
@@ -29,7 +29,7 @@ class LongText implements FactoryInterface
/**
* @param ObjectManagerInterface $objectManager
- * @param string $className
+ * @param string $className
*/
public function __construct(
ObjectManagerInterface $objectManager,
@@ -43,6 +43,7 @@ public function __construct(
* Set default padding, like SMALLINT(5)
*
* {@inheritdoc}
+ *
* @return array
*/
public function create(array $data)
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/MediumBlob.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/MediumBlob.php
index d0e245e895fb7..9d7e0da1f12bc 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/MediumBlob.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/MediumBlob.php
@@ -29,7 +29,7 @@ class MediumBlob implements FactoryInterface
/**
* @param ObjectManagerInterface $objectManager
- * @param string $className
+ * @param string $className
*/
public function __construct(
ObjectManagerInterface $objectManager,
@@ -43,6 +43,7 @@ public function __construct(
* Set default padding, like SMALLINT(5)
*
* {@inheritdoc}
+ *
* @return array
*/
public function create(array $data)
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/MediumText.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/MediumText.php
index 7707d5bc91993..5e9fb18fdda69 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/MediumText.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/MediumText.php
@@ -29,7 +29,7 @@ class MediumText implements FactoryInterface
/**
* @param ObjectManagerInterface $objectManager
- * @param string $className
+ * @param string $className
*/
public function __construct(
ObjectManagerInterface $objectManager,
@@ -43,6 +43,7 @@ public function __construct(
* Set default padding, like SMALLINT(5)
*
* {@inheritdoc}
+ *
* @return array
*/
public function create(array $data)
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Primary.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Primary.php
index 955f632e028c3..6492e0b890db7 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Primary.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Primary.php
@@ -28,7 +28,7 @@ class Primary implements FactoryInterface
/**
* @param ObjectManagerInterface $objectManager
- * @param string $className
+ * @param string $className
*/
public function __construct(
ObjectManagerInterface $objectManager,
@@ -42,6 +42,7 @@ public function __construct(
* Set default padding, like INTEGER(11)
*
* {@inheritdoc}
+ *
* @return array
*/
public function create(array $data)
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Table.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Table.php
index adbf8b91de381..e93dded9f3fc2 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Table.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Table.php
@@ -25,7 +25,7 @@ class Table implements FactoryInterface
/**
* @param ObjectManagerInterface $objectManager
- * @param string $className
+ * @param string $className
*/
public function __construct(
ObjectManagerInterface $objectManager,
@@ -39,6 +39,7 @@ public function __construct(
* Set default padding, like BIGINT(20)
*
* {@inheritdoc}
+ *
* @return array
*/
public function create(array $data)
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Text.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Text.php
index 7009dd2cb9e8c..60cb6ea6ef656 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Text.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Text.php
@@ -29,7 +29,7 @@ class Text implements FactoryInterface
/**
* @param ObjectManagerInterface $objectManager
- * @param string $className
+ * @param string $className
*/
public function __construct(
ObjectManagerInterface $objectManager,
@@ -43,6 +43,7 @@ public function __construct(
* Set default padding, like SMALLINT(5)
*
* {@inheritdoc}
+ *
* @return array
*/
public function create(array $data)
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Timestamp.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Timestamp.php
index a3717b64373fc..783db24af4f22 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Timestamp.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Timestamp.php
@@ -39,8 +39,8 @@ class Timestamp implements FactoryInterface
/**
* @param ObjectManagerInterface $objectManager
- * @param BooleanUtils $booleanUtils
- * @param string $className
+ * @param BooleanUtils $booleanUtils
+ * @param string $className
*/
public function __construct(
ObjectManagerInterface $objectManager,
@@ -56,6 +56,7 @@ public function __construct(
* Change on_update and default params
*
* {@inheritdoc}
+ *
* @return array
*/
public function create(array $data)
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Unique.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Unique.php
index 4ebe3523f23a9..505e39a227825 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Unique.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Unique.php
@@ -6,7 +6,6 @@
namespace Magento\Setup\Model\Declaration\Schema\Dto\Factories;
use Magento\Framework\ObjectManagerInterface;
-use Magento\Setup\Model\Declaration\Schema\Dto\Constraints\Internal;
/**
* Serves unique key constraint needs
@@ -25,7 +24,7 @@ class Unique implements FactoryInterface
/**
* @param ObjectManagerInterface $objectManager
- * @param string $className
+ * @param string $className
*/
public function __construct(
ObjectManagerInterface $objectManager,
@@ -39,6 +38,7 @@ public function __construct(
* Set default padding, like INTEGER(11)
*
* {@inheritdoc}
+ *
* @return array
*/
public function create(array $data)
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Varbinary.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Varbinary.php
index dce7136ba1ebf..fa5c93edbc971 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Varbinary.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Varbinary.php
@@ -29,7 +29,7 @@ class Varbinary implements FactoryInterface
/**
* @param ObjectManagerInterface $objectManager
- * @param string $className
+ * @param string $className
*/
public function __construct(
ObjectManagerInterface $objectManager,
@@ -43,6 +43,7 @@ public function __construct(
* Set default padding, like SMALLINT(5)
*
* {@inheritdoc}
+ *
* @return array
*/
public function create(array $data)
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Varchar.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Varchar.php
index 9e217acc5e3d3..3e6f2da398e10 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Varchar.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Varchar.php
@@ -29,7 +29,7 @@ class Varchar implements FactoryInterface
/**
* @param ObjectManagerInterface $objectManager
- * @param string $className
+ * @param string $className
*/
public function __construct(
ObjectManagerInterface $objectManager,
@@ -43,6 +43,7 @@ public function __construct(
* Set default padding, like SMALLINT(5)
*
* {@inheritdoc}
+ *
* @return array
*/
public function create(array $data)
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Index.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Index.php
index c068ab368df77..0cf340fa0f908 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Index.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Index.php
@@ -33,8 +33,8 @@ class Index extends GenericElement implements
/**
* @param string $name
* @param string $type
- * @param Table $table
- * @param array $columns
+ * @param Table $table
+ * @param array $columns
*/
public function __construct(
string $name,
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Schema.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Schema.php
index bc34bbdc69ec5..2250590a9a94c 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Schema.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Schema.php
@@ -29,7 +29,7 @@ public function getTables()
/**
* Add table by name key to tables registry
*
- * @param Table $table
+ * @param Table $table
* @return $this
*/
public function addTable(Table $table)
@@ -41,7 +41,7 @@ public function addTable(Table $table)
/**
* Retrieve table by it name
*
- * @param $name
+ * @param $name
* @return bool|Table
*/
public function getTableByName($name)
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/SchemaFactory.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/SchemaFactory.php
index 0adbec0ca8569..c92486710906e 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/SchemaFactory.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/SchemaFactory.php
@@ -6,7 +6,6 @@
namespace Magento\Setup\Model\Declaration\Schema\Dto;
use Zend\Di\Di;
-use Zend\Di\ServiceLocatorInterface;
/**
* Factory class for @see \Magento\Setup\Model\Declaration\Schema\Dto\Schema
@@ -25,6 +24,7 @@ class SchemaFactory
/**
* EntityFactory constructor.
+ *
* @param Di $zendDi
*/
public function __construct(Di $zendDi)
@@ -35,7 +35,7 @@ public function __construct(Di $zendDi)
/**
* Create class instance with specified parameters
*
- * @param array $data
+ * @param array $data
* @return \Magento\Setup\Model\Declaration\Schema\Dto\Schema | object
*/
public function create(array $data = [])
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Table.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Table.php
index 5631e1fc6af4e..9fac88e0ce0fe 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Table.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Table.php
@@ -52,9 +52,9 @@ class Table extends GenericElement implements
* @param string $name
* @param string $type
* @param string $resource
- * @param array $columns
- * @param array $indexes
- * @param array $constraints
+ * @param array $columns
+ * @param array $indexes
+ * @param array $constraints
*/
public function __construct(
string $name,
@@ -189,7 +189,7 @@ public function addColumns(array $columns)
/**
* If column exists - retrieve column
*
- * @param string $nameOrId
+ * @param string $nameOrId
* @return Column
*/
public function getColumnByName($nameOrId)
@@ -205,7 +205,7 @@ public function getColumnByName($nameOrId)
* Retrieve elements by specific type
* Allowed types: columns, constraints, indexes...
*
- * @param string $type
+ * @param string $type
* @return ElementInterface[]
*/
public function getElementsByType($type)
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/FileSystem/Csv.php b/setup/src/Magento/Setup/Model/Declaration/Schema/FileSystem/Csv.php
index cf7f01e704df2..4b70181a58f14 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/FileSystem/Csv.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/FileSystem/Csv.php
@@ -21,8 +21,8 @@ class Csv
/**
* Save to csv data with batches
*
- * @param $file
- * @param array $data
+ * @param $file
+ * @param array $data
* @return $this
*/
public function save($file, array $data)
@@ -48,7 +48,7 @@ public function save($file, array $data)
/**
* Generator which allows to read file
*
- * @param $file
+ * @param $file
* @return \Generator
*/
public function readGenerator($file)
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/FileSystem/XmlReader.php b/setup/src/Magento/Setup/Model/Declaration/Schema/FileSystem/XmlReader.php
index 105d94a37a35e..9a55e0ba26267 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/FileSystem/XmlReader.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/FileSystem/XmlReader.php
@@ -28,7 +28,6 @@ class XmlReader extends \Magento\Framework\Config\Reader\Filesystem implements R
];
/**
- * Reader constructor.
* @param \Magento\Framework\Config\FileResolverInterface $fileResolver
* @param \Magento\Setup\Model\Declaration\Schema\Config\Converter $converter
* @param \Magento\Setup\Model\Declaration\Schema\Config\SchemaLocator $schemaLocator
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/OperationInterface.php b/setup/src/Magento/Setup/Model/Declaration/Schema/OperationInterface.php
index a80033f18f9aa..0071e600a8261 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/OperationInterface.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/OperationInterface.php
@@ -24,7 +24,7 @@ public function getOperationName();
/**
* Apply change of any type
*
- * @param ElementHistory $elementHistory
+ * @param ElementHistory $elementHistory
* @return void
*/
public function doOperation(ElementHistory $elementHistory);
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/OperationsExecutor.php b/setup/src/Magento/Setup/Model/Declaration/Schema/OperationsExecutor.php
index d20c51c885ea2..7c9581ff5ed04 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/OperationsExecutor.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/OperationsExecutor.php
@@ -31,8 +31,8 @@ class OperationsExecutor
private $resourceConnection;
/**
- * @param array $operations
- * @param Sharding $sharding
+ * @param array $operations
+ * @param Sharding $sharding
* @param ResourceConnection $resourceConnection
*/
public function __construct(
@@ -77,8 +77,8 @@ private function endSetupForAllConnections()
* Loop through all operations that are configured in di.xml
* and execute them with elements from ChangeRegistyr
*
- * @see OperationInterface
- * @param DiffInterface $diff
+ * @see OperationInterface
+ * @param DiffInterface $diff
* @return void
*/
public function execute(DiffInterface $diff)
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/RequestFactory.php b/setup/src/Magento/Setup/Model/Declaration/Schema/RequestFactory.php
index 0a7c5161819c8..ca40418c68906 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/RequestFactory.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/RequestFactory.php
@@ -25,6 +25,7 @@ class RequestFactory
/**
* RequestFactory constructor.
+ *
* @param Di $zendDi
*/
public function __construct(Di $zendDi)
@@ -35,7 +36,7 @@ public function __construct(Di $zendDi)
/**
* Create request object with requestOptions params
*
- * @param array $requestOptions
+ * @param array $requestOptions
* @return Request
*/
public function create(array $requestOptions = [])
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/SchemaConfig.php b/setup/src/Magento/Setup/Model/Declaration/Schema/SchemaConfig.php
index e34ce4ec6b1db..88ee46ec87ff0 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/SchemaConfig.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/SchemaConfig.php
@@ -37,10 +37,10 @@ class SchemaConfig implements SchemaConfigInterface
private $readerComposite;
/**
- * @param DbSchemaBuilder $dbSchemaBuilder
+ * @param DbSchemaBuilder $dbSchemaBuilder
* @param DeclarativeSchemaBuilder $declarativeSchemaBuilder
- * @param SchemaFactory $schemaFactory
- * @param ReaderComposite $readerComposite
+ * @param SchemaFactory $schemaFactory
+ * @param ReaderComposite $readerComposite
*/
public function __construct(
DbSchemaBuilder $dbSchemaBuilder,
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Sharding.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Sharding.php
index 173b8f75e42d8..1e1c66b869321 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Sharding.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Sharding.php
@@ -35,7 +35,7 @@ class Sharding
/**
* @param DeploymentConfig $deploymentConfig
- * @param array $resources
+ * @param array $resources
*/
public function __construct(DeploymentConfig $deploymentConfig, array $resources)
{
@@ -64,7 +64,7 @@ public function getResources()
/**
* Check whether our resource is valid one
*
- * @param string $scopeName
+ * @param string $scopeName
* @return bool
*/
public function canUseResource($scopeName)
From e71e2d7685380a5e26fbb975d31ca48cd09272a2 Mon Sep 17 00:00:00 2001
From: Krissy Hiserote
Date: Tue, 26 Dec 2017 12:09:31 -0600
Subject: [PATCH 244/904] MAGETWO-85007: Add Content Section
- fix ui component wysiwyg element setDisabled
---
.../view/base/web/js/form/element/wysiwyg.js | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)
diff --git a/app/code/Magento/Ui/view/base/web/js/form/element/wysiwyg.js b/app/code/Magento/Ui/view/base/web/js/form/element/wysiwyg.js
index 9e9427f5ce72c..ee3c414140fb5 100644
--- a/app/code/Magento/Ui/view/base/web/js/form/element/wysiwyg.js
+++ b/app/code/Magento/Ui/view/base/web/js/form/element/wysiwyg.js
@@ -7,12 +7,13 @@
* @api
*/
define([
+ 'wysiwygAdapter',
'Magento_Ui/js/lib/view/utils/async',
'underscore',
'ko',
'./abstract',
- 'Magento_Variable/variables'
-], function ($, _, ko, Abstract) {
+ 'Magento_Variable/variables',
+], function (wysiwyg, $, _, ko, Abstract) {
'use strict';
return Abstract.extend({
@@ -94,14 +95,16 @@ define([
this.$wysiwygEditorButton.attr('disabled', status);
/* eslint-disable no-undef */
- if (wysiwygAdapter) {
- _.each(wysiwygAdapter.activeEditor().controlManager.controls, function (property, index, controls) {
- controls[property.id].setDisabled(status);
- });
+ if (typeof wysiwyg != 'undefined' && wysiwyg.activeEditor()) {
- wysiwygAdapter.activeEditor().getBody().setAttribute('contenteditable', !status);
- }
+ if(typeof wysiwyg.activeEditor().controlManager !== 'undefined') {
+ _.each(wysiwyg.activeEditor().controlManager.controls, function (property, index, controls) {
+ controls[property.id].setDisabled(status);
+ });
+ }
+ wysiwyg.activeEditor().getBody().setAttribute('contenteditable', !status);
+ }
/* eslint-enable no-undef*/
}
});
From 2603f91e3d470873c012c054f3e72916f79336ed Mon Sep 17 00:00:00 2001
From: Krissy Hiserote
Date: Tue, 26 Dec 2017 17:05:28 -0600
Subject: [PATCH 245/904] MAGETWO-85007: Add Content Section
- make sure the wysiwygEditorButton is not empty
---
app/code/Magento/Ui/view/base/web/js/form/element/wysiwyg.js | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/app/code/Magento/Ui/view/base/web/js/form/element/wysiwyg.js b/app/code/Magento/Ui/view/base/web/js/form/element/wysiwyg.js
index ee3c414140fb5..30d90be661d34 100644
--- a/app/code/Magento/Ui/view/base/web/js/form/element/wysiwyg.js
+++ b/app/code/Magento/Ui/view/base/web/js/form/element/wysiwyg.js
@@ -92,7 +92,9 @@ define([
* @param {Boolean} status
*/
setDisabled: function (status) {
- this.$wysiwygEditorButton.attr('disabled', status);
+ if (this.$wysiwygEditorButton != '') {
+ this.$wysiwygEditorButton.attr('disabled', status);
+ }
/* eslint-disable no-undef */
if (typeof wysiwyg != 'undefined' && wysiwyg.activeEditor()) {
From 0565e08f1ca2c3eef5429c597b8f698c852d4077 Mon Sep 17 00:00:00 2001
From: Sergii Kovalenko
Date: Wed, 27 Dec 2017 12:06:42 +0200
Subject: [PATCH 246/904] MAGETWO-84100: Unify Magento SQL adapters
--fix code styles
---
.../fixture/valid_xml_revision_1.php | 2 +-
.../TestSetupModule2/Setup/UpgradeData.php | 6 +-
.../framework/removeTestModules.php | 2 +-
.../Setup/DeclarativeSchemaBuilderTest.php | 12 +--
.../testsuite/Magento/Setup/InstallTest.php | 3 -
.../testsuite/Magento/Setup/UpgradeTest.php | 4 +-
.../Component/ComponentRegistrar.php | 2 +
.../Declaration/Schema/Db/AdapterMediator.php | 10 +-
.../Db/Processors/MySQL/Columns/Varchar.php | 5 +-
.../Db/Processors/MySQL/DbSchemaWriter.php | 26 ++---
.../Declaration/Schema/Db/SchemaBuilder.php | 11 +-
.../Schema/Declaration/SchemaBuilder.php | 4 +-
.../Declaration/Schema/Diff/TableDiff.php | 8 +-
.../Schema/Dto/Columns/Integer.php | 1 -
.../Schema/Dto/Columns/Varbinary.php | 102 ------------------
.../Schema/Dto/Factories/Varbinary.php | 57 ----------
16 files changed, 46 insertions(+), 209 deletions(-)
delete mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Varbinary.php
delete mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Varbinary.php
diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/valid_xml_revision_1.php b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/valid_xml_revision_1.php
index 78e2a519d52a7..a1dc91de1aee1 100644
--- a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/valid_xml_revision_1.php
+++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/valid_xml_revision_1.php
@@ -159,4 +159,4 @@
'resource' => 'sales',
],
],
-];
\ No newline at end of file
+];
diff --git a/dev/tests/setup-integration/_files/UpgradeScripts/TestSetupModule2/Setup/UpgradeData.php b/dev/tests/setup-integration/_files/UpgradeScripts/TestSetupModule2/Setup/UpgradeData.php
index 1550d1dfb2311..9aff0091d2ace 100644
--- a/dev/tests/setup-integration/_files/UpgradeScripts/TestSetupModule2/Setup/UpgradeData.php
+++ b/dev/tests/setup-integration/_files/UpgradeScripts/TestSetupModule2/Setup/UpgradeData.php
@@ -47,9 +47,11 @@ public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface
]
);
$setup->getConnection()->update(
- $setup->getTable('setup_tests_entity_table'), [
+ $setup->getTable('setup_tests_entity_table'),
+ [
'increment_id'=> 1
- ], 'increment_id = null'
+ ],
+ 'increment_id = null'
);
$setup->getConnection()->insertForce(
diff --git a/dev/tests/setup-integration/framework/removeTestModules.php b/dev/tests/setup-integration/framework/removeTestModules.php
index 71f54e4f0fb25..050f536fdde10 100644
--- a/dev/tests/setup-integration/framework/removeTestModules.php
+++ b/dev/tests/setup-integration/framework/removeTestModules.php
@@ -9,7 +9,7 @@
*/
/**
- * Copy test modules to app/code/Magento to make them visible for Magento instance
+ * Copy test modules to app/code/Magento to make them visible for Magento instance
*/
$pathToCommittedTestModules = $testFrameworkDir . '/../_files/Magento';
$pathToInstalledMagentoInstanceModules = $testFrameworkDir . '/../../../../app/code/Magento';
diff --git a/dev/tests/setup-integration/testsuite/Magento/Setup/DeclarativeSchemaBuilderTest.php b/dev/tests/setup-integration/testsuite/Magento/Setup/DeclarativeSchemaBuilderTest.php
index 81dcb95c40c3f..0afe2dd89938d 100644
--- a/dev/tests/setup-integration/testsuite/Magento/Setup/DeclarativeSchemaBuilderTest.php
+++ b/dev/tests/setup-integration/testsuite/Magento/Setup/DeclarativeSchemaBuilderTest.php
@@ -47,24 +47,24 @@ public function testSchemaBuilder()
//Test primary key and renaming
$referenceTable = $dbSchema->getTableByName('reference_table');
/**
- * @var Internal $primaryKey
-*/
+ * @var Internal $primaryKey
+ */
$primaryKey = $referenceTable->getPrimaryConstraint();
$columns = $primaryKey->getColumns();
self::assertEquals(reset($columns)->getName(), 'tinyint_ref');
//Test column
$testTable = $dbSchema->getTableByName('test_table');
/**
- * @var Timestamp $timestampColumn
-*/
+ * @var Timestamp $timestampColumn
+ */
$timestampColumn = $testTable->getColumnByName('timestamp');
self::assertEquals($timestampColumn->getOnUpdate(), 'CURRENT_TIMESTAMP');
//Test disabled
self::assertArrayNotHasKey('varbinary_rename', $testTable->getColumns());
//Test foreign key
/**
- * @var Reference $foreignKey
-*/
+ * @var Reference $foreignKey
+ */
$foreignKey = $testTable->getConstraintByName('some_foreign_key');
self::assertEquals($foreignKey->getOnDelete(), 'NO ACTION');
self::assertEquals($foreignKey->getReferenceColumn()->getName(), 'tinyint_ref');
diff --git a/dev/tests/setup-integration/testsuite/Magento/Setup/InstallTest.php b/dev/tests/setup-integration/testsuite/Magento/Setup/InstallTest.php
index 6be27f33ac87d..6c1dc0e54cdc7 100644
--- a/dev/tests/setup-integration/testsuite/Magento/Setup/InstallTest.php
+++ b/dev/tests/setup-integration/testsuite/Magento/Setup/InstallTest.php
@@ -43,9 +43,6 @@ protected function setUp()
$objectManager = Bootstrap::getObjectManager();
$this->shellCommand = $objectManager->get(\Magento\TestFramework\Deploy\CliCommand::class);
$this->testModuleManager = $objectManager->get(\Magento\TestFramework\Deploy\TestModuleManager::class);
- /**
- * @var \Magento\Framework\Setup\ModuleDataSetupInterface $installer
-*/
}
public static function tearDownAfterClass()
diff --git a/dev/tests/setup-integration/testsuite/Magento/Setup/UpgradeTest.php b/dev/tests/setup-integration/testsuite/Magento/Setup/UpgradeTest.php
index c153276ff3b1b..0b79b59deaabe 100644
--- a/dev/tests/setup-integration/testsuite/Magento/Setup/UpgradeTest.php
+++ b/dev/tests/setup-integration/testsuite/Magento/Setup/UpgradeTest.php
@@ -54,8 +54,8 @@ protected function setUp()
$this->shellCommand = $objectManager->create(\Magento\TestFramework\Deploy\CliCommand::class);
$this->testModuleManager = $objectManager->create(\Magento\TestFramework\Deploy\TestModuleManager::class);
/**
- * @var \Magento\Framework\Setup\ModuleDataSetupInterface $installer
-*/
+ * @var \Magento\Framework\Setup\ModuleDataSetupInterface $installer
+ */
$this->installer = $objectManager->create(
\Magento\Framework\Setup\ModuleDataSetupInterface::class
);
diff --git a/lib/internal/Magento/Framework/Component/ComponentRegistrar.php b/lib/internal/Magento/Framework/Component/ComponentRegistrar.php
index 0e85cf5260e9b..0e1940d55c02b 100644
--- a/lib/internal/Magento/Framework/Component/ComponentRegistrar.php
+++ b/lib/internal/Magento/Framework/Component/ComponentRegistrar.php
@@ -44,6 +44,8 @@ class ComponentRegistrar implements ComponentRegistrarInterface
*/
public static function register($type, $componentName, $path)
{
+ $path = str_replace("magento2ee", "magento2ce", $path);
+ $path = str_replace("magento2b2b", "magento2ce", $path);
self::validateType($type);
if (isset(self::$paths[$type][$componentName])) {
throw new \LogicException(
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/AdapterMediator.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/AdapterMediator.php
index e27ac985a711f..cc47268ce09f5 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/AdapterMediator.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/AdapterMediator.php
@@ -102,7 +102,7 @@ private function processElementFromDefinition(array $elementData, $type)
}
/**
- * @var DbSchemaProcessorInterface $columnProcessor
+ * @var DbSchemaProcessorInterface $columnProcessor
*/
foreach ($this->processors[$type] as $columnProcessor) {
$elementData = $columnProcessor->fromDefinition($elementData);
@@ -132,8 +132,8 @@ public function createTable(Table $table)
foreach ($data as $type => $elements) {
/**
- * @var ElementInterface $element
-*/
+ * @var ElementInterface $element
+ */
foreach ($elements as $element) {
$definition[$type][$element->getName()] = $this
->processElementToDefinition($element);
@@ -254,8 +254,8 @@ public function processElementToDefinition(ElementInterface $element)
{
$definition = '';
/**
- * @var DbSchemaProcessorInterface $processor
-*/
+ * @var DbSchemaProcessorInterface $processor
+ */
foreach ($this->processors[$element->getElementType()] as $processor) {
//One column processor can override or modify existing one
if ($processor->canBeApplied($element)) {
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Varchar.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Varchar.php
index ced97aeccd561..668778631b77d 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Varchar.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Varchar.php
@@ -6,7 +6,6 @@
namespace Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL\Columns;
use Magento\Setup\Model\Declaration\Schema\Db\Processors\DbSchemaProcessorInterface;
-use Magento\Setup\Model\Declaration\Schema\Dto\Columns\Varbinary;
use Magento\Setup\Model\Declaration\Schema\Dto\ElementInterface;
/**
@@ -36,7 +35,6 @@ public function __construct(Nullable $nullable, DefaultDefinition $defaultDefini
/**
* @param \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Varchar $element
- * @param \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Varbinary $element
* @inheritdoc
*/
public function toDefinition(ElementInterface $element)
@@ -55,8 +53,7 @@ public function toDefinition(ElementInterface $element)
*/
public function canBeApplied(ElementInterface $element)
{
- return $element instanceof \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Varchar ||
- $element instanceof Varbinary;
+ return $element instanceof \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Varchar;
}
/**
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/DbSchemaWriter.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/DbSchemaWriter.php
index 265fdca6e5714..771d6c5f980da 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/DbSchemaWriter.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/DbSchemaWriter.php
@@ -212,19 +212,19 @@ public function modifyColumn(array $columnOptions, $columnDefinition)
private function getConstraintType($type)
{
switch ($type) {
- case 'foreign':
- $elementType = ForeignKey::FOREIGN_KEY_NAME;
- break;
- case 'primary':
- $elementType = Internal::PRIMARY_KEY_NAME;
- break;
- case 'unique':
- case 'index':
- //In MySQL for unique and for index drop syntax is the same
- $elementType = Index::INDEX_KEY_NAME;
- break;
- default:
- $elementType = Constraint::TYPE;
+ case 'foreign':
+ $elementType = ForeignKey::FOREIGN_KEY_NAME;
+ break;
+ case 'primary':
+ $elementType = Internal::PRIMARY_KEY_NAME;
+ break;
+ case 'unique':
+ case 'index':
+ //In MySQL for unique and for index drop syntax is the same
+ $elementType = Index::INDEX_KEY_NAME;
+ break;
+ default:
+ $elementType = Constraint::TYPE;
}
return $elementType;
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/SchemaBuilder.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/SchemaBuilder.php
index e76164286ee27..4c2a28b90ab81 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/SchemaBuilder.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/SchemaBuilder.php
@@ -85,12 +85,13 @@ public function build(Schema $schema)
$constrainsData = $this->adapter->getConstraintsList($tableName, $resource);
/**
- * @var Table $table
-*/
+ * @var Table $table
+ */
$table = $this->elementFactory->create(
- 'table', [
- 'name' => $tableName,
- 'resource' => $resource
+ 'table',
+ [
+ 'name' => $tableName,
+ 'resource' => $resource
]
);
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/SchemaBuilder.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/SchemaBuilder.php
index 28d81bf052d02..b37e0ba2c12e5 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/SchemaBuilder.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/SchemaBuilder.php
@@ -213,9 +213,7 @@ private function processTable(Schema $schema, array $tableData)
'name' => $tableData['name'],
'resource' => $resource,
];
- /**
- * @var Table $table
-*/
+ /** @var Table $table */
$table = $this->elementFactory->create('table', $tableParams);
$columns = $this->processColumns($tableData, $resource, $table);
$table->addColumns($columns);
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/TableDiff.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/TableDiff.php
index 06f57f9dd272e..79888c564d677 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/TableDiff.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/TableDiff.php
@@ -100,10 +100,10 @@ public function diff(
//If it is new for generated (generated from db) elements - we need to create it
if ($this->diffManager->shouldBeCreated($generatedElements, $element)) {
$diff = $this->diffManager->registerCreation($diff, $element);
- } else if ($this->diffManager->shouldBeModified(
- $element,
- $generatedElements[$element->getName()]
- )
+ } elseif ($this->diffManager->shouldBeModified(
+ $element,
+ $generatedElements[$element->getName()]
+ )
) {
$diff = $this->diffManager
->registerModification($diff, $element, $generatedElements[$element->getName()]);
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Integer.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Integer.php
index 47ff95176cb0b..47b69334ce68e 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Integer.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Integer.php
@@ -92,7 +92,6 @@ public function isNullable()
return $this->nullable;
}
-
/**
* Return default value
* Note: default value should be int
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Varbinary.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Varbinary.php
deleted file mode 100644
index 56a720bd6d348..0000000000000
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Varbinary.php
+++ /dev/null
@@ -1,102 +0,0 @@
-nullable = $nullable;
- $this->default = $default;
- $this->length = $length;
- }
-
- /**
- * Check whether column can be nullable
- *
- * @return bool
- */
- public function isNullable()
- {
- return $this->nullable;
- }
-
- /**
- * Return default value
- * Note: default value should be string
- *
- * @return string | null
- */
- public function getDefault()
- {
- return $this->default;
- }
-
- /**
- * Length can be integer value from 0 to 255
- *
- * @return int
- */
- public function getLength()
- {
- return $this->length;
- }
-
- /**
- * @inheritdoc
- */
- public function getDiffSensitiveParams()
- {
- return [
- 'type' => $this->getType(),
- 'nullable' => $this->isNullable(),
- 'default' => $this->getDefault(),
- 'length' => $this->getLength()
- ];
- }
-}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Varbinary.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Varbinary.php
deleted file mode 100644
index fa5c93edbc971..0000000000000
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Varbinary.php
+++ /dev/null
@@ -1,57 +0,0 @@
-objectManager = $objectManager;
- $this->className = $className;
- }
-
- /**
- * Set default padding, like SMALLINT(5)
- *
- * {@inheritdoc}
- *
- * @return array
- */
- public function create(array $data)
- {
- if (!isset($data['length'])) {
- $data['length'] = self::DEFAULT_TEXT_LENGTH;
- }
-
- return $this->objectManager->create($this->className, $data);
- }
-}
From 0af8c232ef791ca3a14fbfabcd16a2c4d7ae90f3 Mon Sep 17 00:00:00 2001
From: Sergii Kovalenko
Date: Wed, 27 Dec 2017 17:20:24 +0200
Subject: [PATCH 247/904] MAGETWO-84100: Unify Magento SQL adapters
--refactor adapter and remove adapter mediator
---
app/etc/di.xml | 73 ++--
.../etc/db_schema.xml | 32 +-
.../constraint_modification.php | 6 +-
.../column_modifications/db_schema.xml | 32 +-
.../revisions/column_removals/db_schema.xml | 28 +-
.../constraint_modifications/db_schema.xml | 38 +-
.../revisions/drop_table/db_schema.xml | 4 +-
.../fail_on_column_declaration/db_schema.xml | 2 +-
.../db_schema.xml | 2 +-
.../foreign_key_interpreter/db_schema.xml | 4 +-
.../revisions/old_diff/db_schema.xml | 6 +-
.../etc/db_schema.xml | 32 +-
.../TestFramework/Deploy/DescribeTable.php | 2 +-
.../Setup/DeclarativeInstallerTest.php | 21 +-
.../Framework/App/ResourceConnection.php | 19 +
.../Declaration/Schema/Db/AdapterMediator.php | 373 ------------------
...php => DbDefinitionProcessorInterface.php} | 12 +-
.../DbSchemaReaderInterface.php | 4 +-
.../DbSchemaWriterInterface.php | 6 +-
.../Schema/Db/DefinitionAggregator.php | 63 +++
.../Schema/Db/MySQL/DbSchemaReader.php | 185 +++++++++
.../{Processors => }/MySQL/DbSchemaWriter.php | 11 +-
.../Definition}/Columns/Blob.php | 21 +-
.../Definition}/Columns/Boolean.php | 35 +-
.../Definition}/Columns/Date.php | 14 +-
.../Definition}/Columns/Decimal.php | 26 +-
.../Definition}/Columns/DefaultDefinition.php | 14 +-
.../Definition}/Columns/Identity.php | 14 +-
.../Definition}/Columns/Integer.php | 32 +-
.../Db/MySQL/Definition/Columns/Nullable.php | 40 ++
.../Definition}/Columns/OnUpdate.php | 22 +-
.../Definition}/Columns/Timestamp.php | 24 +-
.../Definition}/Columns/Unsigned.php | 18 +-
.../Definition}/Columns/Varchar.php | 19 +-
.../Definition}/Constraints/ForeignKey.php | 54 +--
.../Definition}/Constraints/Internal.php | 22 +-
.../MySQL => MySQL/Definition}/Index.php | 6 +-
.../Db/Processors/MySQL/Columns/Basic.php | 95 -----
.../Db/Processors/MySQL/Columns/Nullable.php | 66 ----
.../Db/Processors/MySQL/Columns/Text.php | 70 ----
.../Db/Processors/MySQL/DbSchemaReader.php | 123 ------
.../Declaration/Schema/Db/SchemaBuilder.php | 20 +-
.../Declaration/Schema/Diff/DiffManager.php | 3 +-
.../Declaration/Schema/Dto/Constraint.php | 1 -
.../Schema/Dto/Constraints/Reference.php | 16 +
.../Schema/Dto/Factories/Integer.php | 8 +-
.../Schema/Operations/AddElement.php | 43 +-
.../Schema/Operations/CreateTable.php | 51 ++-
.../Schema/Operations/DropElement.php | 41 +-
.../Schema/Operations/DropTable.php | 37 +-
.../Schema/Operations/ModifyElement.php | 92 ++++-
.../Schema/Operations/ReCreateTable.php | 27 +-
.../Schema/etc/types/integers/biginteger.xsd | 4 +-
.../Schema/etc/types/integers/integer.xsd | 2 +-
.../etc/types/integers/smallinteger.xsd | 4 +-
.../Schema/etc/types/integers/tinyinteger.xsd | 4 +-
56 files changed, 835 insertions(+), 1188 deletions(-)
delete mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Db/AdapterMediator.php
rename setup/src/Magento/Setup/Model/Declaration/Schema/Db/{Processors/DbSchemaProcessorInterface.php => DbDefinitionProcessorInterface.php} (71%)
rename setup/src/Magento/Setup/Model/Declaration/Schema/Db/{Processors => }/DbSchemaReaderInterface.php (91%)
rename setup/src/Magento/Setup/Model/Declaration/Schema/Db/{Processors => }/DbSchemaWriterInterface.php (92%)
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Db/DefinitionAggregator.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/DbSchemaReader.php
rename setup/src/Magento/Setup/Model/Declaration/Schema/Db/{Processors => }/MySQL/DbSchemaWriter.php (96%)
rename setup/src/Magento/Setup/Model/Declaration/Schema/Db/{Processors/MySQL => MySQL/Definition}/Columns/Blob.php (62%)
rename setup/src/Magento/Setup/Model/Declaration/Schema/Db/{Processors/MySQL => MySQL/Definition}/Columns/Boolean.php (72%)
rename setup/src/Magento/Setup/Model/Declaration/Schema/Db/{Processors/MySQL => MySQL/Definition}/Columns/Date.php (61%)
rename setup/src/Magento/Setup/Model/Declaration/Schema/Db/{Processors/MySQL => MySQL/Definition}/Columns/Decimal.php (73%)
rename setup/src/Magento/Setup/Model/Declaration/Schema/Db/{Processors/MySQL => MySQL/Definition}/Columns/DefaultDefinition.php (76%)
rename setup/src/Magento/Setup/Model/Declaration/Schema/Db/{Processors/MySQL => MySQL/Definition}/Columns/Identity.php (74%)
rename setup/src/Magento/Setup/Model/Declaration/Schema/Db/{Processors/MySQL => MySQL/Definition}/Columns/Integer.php (69%)
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Columns/Nullable.php
rename setup/src/Magento/Setup/Model/Declaration/Schema/Db/{Processors/MySQL => MySQL/Definition}/Columns/OnUpdate.php (59%)
rename setup/src/Magento/Setup/Model/Declaration/Schema/Db/{Processors/MySQL => MySQL/Definition}/Columns/Timestamp.php (65%)
rename setup/src/Magento/Setup/Model/Declaration/Schema/Db/{Processors/MySQL => MySQL/Definition}/Columns/Unsigned.php (61%)
rename setup/src/Magento/Setup/Model/Declaration/Schema/Db/{Processors/MySQL => MySQL/Definition}/Columns/Varchar.php (73%)
rename setup/src/Magento/Setup/Model/Declaration/Schema/Db/{Processors/MySQL => MySQL/Definition}/Constraints/ForeignKey.php (56%)
rename setup/src/Magento/Setup/Model/Declaration/Schema/Db/{Processors/MySQL => MySQL/Definition}/Constraints/Internal.php (79%)
rename setup/src/Magento/Setup/Model/Declaration/Schema/Db/{Processors/MySQL => MySQL/Definition}/Index.php (91%)
delete mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Basic.php
delete mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Nullable.php
delete mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Text.php
delete mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/DbSchemaReader.php
diff --git a/app/etc/di.xml b/app/etc/di.xml
index 29a954a825a9f..8a1f65192e76d 100755
--- a/app/etc/di.xml
+++ b/app/etc/di.xml
@@ -174,8 +174,8 @@
-
-
+
+
@@ -1357,10 +1357,10 @@
- \Magento\Setup\Model\Declaration\Schema\Dto\Factories\Decimal
- \Magento\Setup\Model\Declaration\Schema\Dto\Factories\Decimal
- \Magento\Setup\Model\Declaration\Schema\Dto\Factories\Decimal
- - \Magento\Setup\Model\Declaration\Schema\Dto\Factories\Integer
- - \Magento\Setup\Model\Declaration\Schema\Dto\Factories\Integer
- - \Magento\Setup\Model\Declaration\Schema\Dto\Factories\Integer
- - \Magento\Setup\Model\Declaration\Schema\Dto\Factories\Integer
+ - \Magento\Setup\Model\Declaration\Schema\Dto\Factories\Integer
+ - \Magento\Setup\Model\Declaration\Schema\Dto\Factories\Integer
+ - \Magento\Setup\Model\Declaration\Schema\Dto\Factories\Integer
+ - \Magento\Setup\Model\Declaration\Schema\Dto\Factories\Integer
- \Magento\Setup\Model\Declaration\Schema\Dto\Factories\Date
- \Magento\Setup\Model\Declaration\Schema\Dto\Factories\Timestamp
- \Magento\Setup\Model\Declaration\Schema\Dto\Factories\Timestamp
@@ -1368,7 +1368,7 @@
- \Magento\Setup\Model\Declaration\Schema\Dto\Factories\MediumText
- \Magento\Setup\Model\Declaration\Schema\Dto\Factories\Text
- \Magento\Setup\Model\Declaration\Schema\Dto\Factories\Varchar
- - \Magento\Setup\Model\Declaration\Schema\Dto\Factories\Varbinary
+ - \Magento\Setup\Model\Declaration\Schema\Dto\Factories\Varchar
- \Magento\Setup\Model\Declaration\Schema\Dto\Factories\Blob
- \Magento\Setup\Model\Declaration\Schema\Dto\Factories\MediumBlob
- \Magento\Setup\Model\Declaration\Schema\Dto\Factories\LongBlob
@@ -1380,38 +1380,33 @@
-
-
-
- -
-
- \Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL\Columns\Basic
- - \Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL\Columns\Boolean
- - \Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL\Columns\Integer
- - \Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL\Columns\Integer
- - \Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL\Columns\Integer
- - \Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL\Columns\Integer
- - \Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL\Columns\Decimal
- - \Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL\Columns\Decimal
- - \Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL\Columns\Decimal
- - \Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL\Columns\Text
- - \Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL\Columns\Blob
- - \Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL\Columns\Blob
- - \Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL\Columns\Blob
- - \Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL\Columns\Text
- - \Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL\Columns\Text
- - \Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL\Columns\Timestamp
- - \Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL\Columns\Date
- - \Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL\Columns\Timestamp
- - \Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL\Columns\Varchar
- - \Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL\Columns\Varchar
-
- -
-
- \Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL\Index
-
- -
-
- \Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL\Constraints\Internal
- - \Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL\Constraints\ForeignKey
-
+
+
+
+ - \Magento\Setup\Model\Declaration\Schema\Db\MySQL\Definition\Columns\Boolean
+ - \Magento\Setup\Model\Declaration\Schema\Db\MySQL\Definition\Columns\Integer
+ - \Magento\Setup\Model\Declaration\Schema\Db\MySQL\Definition\Columns\Integer
+ - \Magento\Setup\Model\Declaration\Schema\Db\MySQL\Definition\Columns\Integer
+ - \Magento\Setup\Model\Declaration\Schema\Db\MySQL\Definition\Columns\Integer
+ - \Magento\Setup\Model\Declaration\Schema\Db\MySQL\Definition\Columns\Decimal
+ - \Magento\Setup\Model\Declaration\Schema\Db\MySQL\Definition\Columns\Decimal
+ - \Magento\Setup\Model\Declaration\Schema\Db\MySQL\Definition\Columns\Decimal
+ - \Magento\Setup\Model\Declaration\Schema\Db\MySQL\Definition\Columns\Blob
+ - \Magento\Setup\Model\Declaration\Schema\Db\MySQL\Definition\Columns\Blob
+ - \Magento\Setup\Model\Declaration\Schema\Db\MySQL\Definition\Columns\Blob
+ - \Magento\Setup\Model\Declaration\Schema\Db\MySQL\Definition\Columns\Blob
+ - \Magento\Setup\Model\Declaration\Schema\Db\MySQL\Definition\Columns\Blob
+ - \Magento\Setup\Model\Declaration\Schema\Db\MySQL\Definition\Columns\Blob
+ - \Magento\Setup\Model\Declaration\Schema\Db\MySQL\Definition\Columns\Timestamp
+ - \Magento\Setup\Model\Declaration\Schema\Db\MySQL\Definition\Columns\Date
+ - \Magento\Setup\Model\Declaration\Schema\Db\MySQL\Definition\Columns\Timestamp
+ - \Magento\Setup\Model\Declaration\Schema\Db\MySQL\Definition\Columns\Varchar
+ - \Magento\Setup\Model\Declaration\Schema\Db\MySQL\Definition\Columns\Varchar
+ - \Magento\Setup\Model\Declaration\Schema\Db\MySQL\Definition\Index
+ - \Magento\Setup\Model\Declaration\Schema\Db\MySQL\Definition\Constraints\Internal
+ - \Magento\Setup\Model\Declaration\Schema\Db\MySQL\Definition\Constraints\Internal
+ - \Magento\Setup\Model\Declaration\Schema\Db\MySQL\Definition\Constraints\Internal
+ - \Magento\Setup\Model\Declaration\Schema\Db\MySQL\Definition\Constraints\ForeignKey
diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/etc/db_schema.xml b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/etc/db_schema.xml
index bda769d4b3422..a0e988a67e4d8 100644
--- a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/etc/db_schema.xml
+++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/etc/db_schema.xml
@@ -7,33 +7,33 @@
-->
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
-
-
-
+
+
+
diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/declarative_installer/constraint_modification.php b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/declarative_installer/constraint_modification.php
index dc557d2dfff69..88735201fcf75 100644
--- a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/declarative_installer/constraint_modification.php
+++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/declarative_installer/constraint_modification.php
@@ -49,10 +49,10 @@
KEY `some_foreign_key_without_action` (`integer_main`),
KEY `speedup_index_renamed` (`tinyint`,`bigint`),
CONSTRAINT `some_foreign_key` FOREIGN KEY (`tinyint`) REFERENCES `reference_table` (`tinyint_ref`)
- ON DELETE SET NULL,
+ON DELETE SET NULL,
CONSTRAINT `some_foreign_key_new` FOREIGN KEY (`smallint_main`) REFERENCES `reference_table` (`smallint_ref`)
- ON DELETE CASCADE,
+ON DELETE CASCADE,
CONSTRAINT `some_foreign_key_without_action` FOREIGN KEY (`integer_main`) REFERENCES `auto_increment_test`
- (`int_auto_increment_with_nullable`) ON DELETE CASCADE
+(`int_auto_increment_with_nullable`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8',
];
diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/column_modifications/db_schema.xml b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/column_modifications/db_schema.xml
index 70c0ec7547cbd..2a6b890790b4c 100644
--- a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/column_modifications/db_schema.xml
+++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/column_modifications/db_schema.xml
@@ -7,33 +7,33 @@
-->
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
-
-
-
+
+
+
diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/column_removals/db_schema.xml b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/column_removals/db_schema.xml
index 997c477421410..2aed42e674688 100644
--- a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/column_removals/db_schema.xml
+++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/column_removals/db_schema.xml
@@ -7,31 +7,31 @@
-->
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
-
-
-
+
+
+
diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/constraint_modifications/db_schema.xml b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/constraint_modifications/db_schema.xml
index b69854a209eb2..288ed93bafcab 100644
--- a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/constraint_modifications/db_schema.xml
+++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/constraint_modifications/db_schema.xml
@@ -7,18 +7,18 @@
-->
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
@@ -28,20 +28,20 @@
-
-
-
-
+
+
+
+
-
+
diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/drop_table/db_schema.xml b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/drop_table/db_schema.xml
index 02610d360c777..24bb88137ad2a 100644
--- a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/drop_table/db_schema.xml
+++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/drop_table/db_schema.xml
@@ -7,8 +7,8 @@
-->
-
-
+
+
diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/fail_on_column_declaration/db_schema.xml b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/fail_on_column_declaration/db_schema.xml
index 46d3fe5bbebd3..faee9f8c7ecb2 100644
--- a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/fail_on_column_declaration/db_schema.xml
+++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/fail_on_column_declaration/db_schema.xml
@@ -8,6 +8,6 @@
diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/fail_on_unique_key_declaration/db_schema.xml b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/fail_on_unique_key_declaration/db_schema.xml
index d38412680ce9b..6b6e228dbbb7a 100644
--- a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/fail_on_unique_key_declaration/db_schema.xml
+++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/fail_on_unique_key_declaration/db_schema.xml
@@ -8,7 +8,7 @@
-
+
diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/foreign_key_interpreter/db_schema.xml b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/foreign_key_interpreter/db_schema.xml
index 5c29d7b525272..f58eb93dc5292 100644
--- a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/foreign_key_interpreter/db_schema.xml
+++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/foreign_key_interpreter/db_schema.xml
@@ -8,10 +8,10 @@
diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/old_diff/db_schema.xml b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/old_diff/db_schema.xml
index c212ee5ea75f1..48ed31a2c1a34 100644
--- a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/old_diff/db_schema.xml
+++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/old_diff/db_schema.xml
@@ -7,15 +7,15 @@
-->
-
-
+
+
diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule2/etc/db_schema.xml b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule2/etc/db_schema.xml
index 63a203d110510..b219a7e5269b4 100644
--- a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule2/etc/db_schema.xml
+++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule2/etc/db_schema.xml
@@ -7,33 +7,33 @@
-->
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
-
-
-
+
+
+
diff --git a/dev/tests/setup-integration/framework/Magento/TestFramework/Deploy/DescribeTable.php b/dev/tests/setup-integration/framework/Magento/TestFramework/Deploy/DescribeTable.php
index 3b839919c749f..20290b12ef91f 100644
--- a/dev/tests/setup-integration/framework/Magento/TestFramework/Deploy/DescribeTable.php
+++ b/dev/tests/setup-integration/framework/Magento/TestFramework/Deploy/DescribeTable.php
@@ -5,7 +5,7 @@
*/
namespace Magento\TestFramework\Deploy;
-use Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL\DbSchemaReader;
+use Magento\Setup\Model\Declaration\Schema\Db\MySQL\DbSchemaReader;
/**
* The purpose of this class is adding test modules files to Magento code base
diff --git a/dev/tests/setup-integration/testsuite/Magento/Setup/DeclarativeInstallerTest.php b/dev/tests/setup-integration/testsuite/Magento/Setup/DeclarativeInstallerTest.php
index 8ca9485360640..61c9d36301db6 100644
--- a/dev/tests/setup-integration/testsuite/Magento/Setup/DeclarativeInstallerTest.php
+++ b/dev/tests/setup-integration/testsuite/Magento/Setup/DeclarativeInstallerTest.php
@@ -58,9 +58,6 @@ public function setUp()
$objectManager = Bootstrap::getObjectManager();
$this->moduleManager = $objectManager->get(TestModuleManager::class);
$this->cliCommad = $objectManager->get(CliCommand::class);
- /** @var AdapterMediator $adapterMediator */
- $adapterMediator = $objectManager->get(AdapterMediator::class);
- $adapterMediator->flushCache();
$this->describeTable = $objectManager->get(DescribeTable::class);
$this->schemaDiff = $objectManager->get(SchemaDiff::class);
$this->schemaConfig = $objectManager->get(SchemaConfigInterface::class);
@@ -157,6 +154,22 @@ public function testInstallationWithColumnsRemoval()
self::assertEquals($shardData, $this->getData());
}
+ /**
+ * As sometimes we want to ignore spaces and other special characters,
+ * we need to trim data before compare it
+ *
+ * @return array
+ */
+ private function getTrimmedData()
+ {
+ $data = [];
+ foreach ($this->getData() as $key => $createTable) {
+ $data[$key] = preg_replace('/(\s)\n/', '$1', $createTable);
+ }
+
+ return $data;
+ }
+
/**
* @moduleName Magento_TestSetupDeclarationModule1
* @dataProviderFromFile Magento/TestSetupDeclarationModule1/fixture/declarative_installer/constraint_modification.php
@@ -188,7 +201,7 @@ public function testInstallationWithConstraintsModification()
);
self::assertNull($diff->get());
$shardData = $this->describeTable->describeShard(Sharding::DEFAULT_CONNECTION);
- self::assertEquals($shardData, $this->getData());
+ self::assertEquals($shardData, $this->getTrimmedData());
}
/**
diff --git a/lib/internal/Magento/Framework/App/ResourceConnection.php b/lib/internal/Magento/Framework/App/ResourceConnection.php
index 4a093dada3559..fea5c28313fc9 100644
--- a/lib/internal/Magento/Framework/App/ResourceConnection.php
+++ b/lib/internal/Magento/Framework/App/ResourceConnection.php
@@ -273,6 +273,25 @@ public function getFkName($priTableName, $priColumnName, $refTableName, $refColu
);
}
+ /**
+ * Retrieve db name
+ *
+ * That name can be needed, when we do request in information_schema
+ * to identify db
+ *
+ * @param string $resourceName
+ * @return string
+ */
+ public function getSchemaName($resourceName)
+ {
+ return $this->deploymentConfig->get(
+ ConfigOptionsListConstants::CONFIG_PATH_DB_CONNECTIONS .
+ '/' .
+ $resourceName .
+ '/dbname'
+ );
+ }
+
/**
* Get table prefix
*
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/AdapterMediator.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/AdapterMediator.php
deleted file mode 100644
index cc47268ce09f5..0000000000000
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/AdapterMediator.php
+++ /dev/null
@@ -1,373 +0,0 @@
- or from do DDL operations: convert from DTO`s objects to SQL definition
- */
-class AdapterMediator
-{
- /**
- * Show all table columns
- */
- const KEY_COLUMNS = 'column';
-
- /**
- * Under index mean only. All keys will be in constraint
- */
- const KEY_INDEXES = 'index';
-
- /**
- * Under reference mean foreign key
- */
- const KEY_CONSTRAINT = 'constraint';
-
- /**
- * Foreign key
- */
- const KEY_REFERENCE = 'reference';
-
- /**
- * Table key name
- */
- const KEY_TABLE = 'table';
-
- /**
- * Cache by table, that cached ddl raw query result
- *
- * @var array
- */
- private $ddlCache;
-
- /**
- * @var array
- */
- private $processors;
-
- /**
- * @var DbSchemaReaderInterface
- */
- private $dbSchemaReader;
-
- /**
- * @var DbSchemaWriterInterface
- */
- private $dbSchemaWriter;
-
- /**
- * @param DbSchemaReaderInterface $dbSchemaReader
- * @param DbSchemaWriterInterface $dbSchemaCreator
- * @param array $processors
- */
- public function __construct(
- DbSchemaReaderInterface $dbSchemaReader,
- DbSchemaWriterInterface $dbSchemaCreator,
- array $processors
- ) {
- $this->processors = $processors;
- $this->dbSchemaReader = $dbSchemaReader;
- $this->dbSchemaWriter = $dbSchemaCreator;
- }
-
- /**
- * Go through all processors and modify column data
- * depends on type column has
- *
- * @param array $elementData
- * @param $type
- * @return array
- */
- private function processElementFromDefinition(array $elementData, $type)
- {
- if (!isset($this->processors[$type])) {
- throw new \InvalidArgumentException(sprintf("Cannot find type %s", $type));
- }
-
- /**
- * @var DbSchemaProcessorInterface $columnProcessor
-*/
- foreach ($this->processors[$type] as $columnProcessor) {
- $elementData = $columnProcessor->fromDefinition($elementData);
- }
-
- return $elementData;
- }
-
- /**
- * Retrieve definition for all table elements
- *
- * @param Table $table
- * @return void
- */
- public function createTable(Table $table)
- {
- $definition = [];
- $tableOptions = [
- 'resource' => $table->getResource(),
- 'name' => $table->getName()
- ];
- $data = [
- Column::TYPE => $table->getColumns(),
- Constraint::TYPE => $table->getConstraints(),
- Index::TYPE => $table->getIndexes()
- ];
-
- foreach ($data as $type => $elements) {
- /**
- * @var ElementInterface $element
- */
- foreach ($elements as $element) {
- $definition[$type][$element->getName()] = $this
- ->processElementToDefinition($element);
- }
- }
-
- $this->dbSchemaWriter->createTable($tableOptions, $definition);
- }
-
- /**
- * Prepare and add element (column, constraint, index) to table
- *
- * @param ElementInterface | TableElementInterface $element
- * @return void
- */
- public function addElement(ElementInterface $element)
- {
- $elementOptions = [
- 'table_name' => $element->getTable()->getName(),
- 'element_name' => $element->getName(),
- 'resource' => $element->getTable()->getResource()
- ];
- $definition = $this->processElementToDefinition($element);
-
- $this->dbSchemaWriter->addElement(
- $elementOptions,
- $definition,
- $element->getElementType()
- );
- }
-
- /**
- *
- *
- * @param Constraint $constraint
- */
- public function modifyConstraint(Constraint $constraint)
- {
- $constraintOptions = [
- 'table_name' => $constraint->getTable()->getName(),
- 'element_name' => $constraint->getName(),
- 'resource' => $constraint->getTable()->getResource(),
- 'type' => $constraint->getType()
- ];
- $definition = $this->processElementToDefinition($constraint);
-
- $this->dbSchemaWriter->modifyConstraint(
- $constraintOptions,
- $definition
- );
- }
-
- /**
- * Prepare and drop element from table
- *
- * @param ElementInterface | TableElementInterface $element
- * @return void
- */
- public function dropElement(ElementInterface $element)
- {
- $elementOptions = [
- 'table_name' => $element->getTable()->getName(),
- 'element_name' => $element->getName(),
- 'resource' => $element->getTable()->getResource(),
- 'type' => $element->getType()
- ];
-
- $this->dbSchemaWriter->dropElement(
- $element->getElementType(),
- $elementOptions
- );
- }
-
- /**
- * Modify column definition for existing table
- *
- * @param Column $column
- */
- public function modifyColumn(Column $column)
- {
- $columnOptions = [
- 'table_name' => $column->getTable()->getName(),
- 'element_name' => $column->getName(),
- 'resource' => $column->getTable()->getResource()
- ];
- $definition = $this->processElementToDefinition(
- $column
- );
-
- $this->dbSchemaWriter->modifyColumn(
- $columnOptions,
- $definition
- );
- }
-
- /**
- * Drop table from DB
- *
- * @param Table $table
- */
- public function dropTable(Table $table)
- {
- $tableOptions = [
- 'name' => $table->getName(),
- 'resource' => $table->getResource()
- ];
-
- $this->dbSchemaWriter->dropTable($tableOptions);
- }
-
- /**
- * Process column definition
- *
- * @param ElementInterface $element
- * @return string
- */
- public function processElementToDefinition(ElementInterface $element)
- {
- $definition = '';
- /**
- * @var DbSchemaProcessorInterface $processor
- */
- foreach ($this->processors[$element->getElementType()] as $processor) {
- //One column processor can override or modify existing one
- if ($processor->canBeApplied($element)) {
- $definition = $processor->toDefinition($element);
- }
- }
-
- return $definition;
- }
-
- /**
- * Retrieve the list of all Magento non-unique and non-primary indexes
- *
- * @param string $tableName
- * @param string $resource
- * @return array
- */
- public function getIndexesList($tableName, $resource)
- {
- if (!isset($this->ddlCache[self::KEY_INDEXES][$tableName])) {
- $this->ddlCache[self::KEY_INDEXES][$tableName] = [];
- foreach ($this->dbSchemaReader->readIndexes($tableName, $resource) as $indexData) {
- $index = $this->processElementFromDefinition($indexData, self::KEY_INDEXES);
-
- if (!isset($this->ddlCache[self::KEY_INDEXES][$tableName][$index['name']])) {
- $this->ddlCache[self::KEY_INDEXES][$tableName][$index['name']] = [];
- }
-
- $this->ddlCache[self::KEY_INDEXES][$tableName][$index['name']] = array_replace_recursive(
- $this->ddlCache[self::KEY_INDEXES][$tableName][$index['name']],
- $index
- );
- }
- }
-
- return $this->ddlCache[self::KEY_INDEXES][$tableName];
- }
-
- /**
- * @param string $tableName
- * @param string $resource
- * @return mixed
- */
- public function getConstraintsList($tableName, $resource)
- {
- if (!isset($this->ddlCache[self::KEY_CONSTRAINT][$tableName])) {
- $this->ddlCache[self::KEY_CONSTRAINT][$tableName] = [];
- $constraintsData = $this->dbSchemaReader->readConstraints($tableName, $resource);
- foreach ($constraintsData as $constraintData) {
- $constraint = $this->processElementFromDefinition($constraintData, self::KEY_CONSTRAINT);
-
- if (!isset($this->ddlCache[self::KEY_CONSTRAINT][$tableName][$constraint['name']])) {
- $this->ddlCache[self::KEY_CONSTRAINT][$tableName][$constraint['name']] = [];
- }
-
- $this->ddlCache[self::KEY_CONSTRAINT][$tableName][$constraint['name']] = array_replace_recursive(
- $this->ddlCache[self::KEY_CONSTRAINT][$tableName][$constraint['name']],
- $constraint
- );
- }
- }
-
- return $this->ddlCache[self::KEY_CONSTRAINT][$tableName];
- }
-
- /**
- * Retrieve list of preprocessed foreign keys
- *
- * @param string $tableName
- * @param string $resource
- * @return array
- */
- public function getReferencesList($tableName, $resource)
- {
- if (!isset($this->ddlCache[self::KEY_REFERENCE][$tableName])) {
- $this->ddlCache[self::KEY_REFERENCE][$tableName] = [];
- $createTable = $this->dbSchemaReader->readReferences($tableName, $resource);
- $foreignKeys = $this->processElementFromDefinition($createTable, self::KEY_CONSTRAINT);
- //Process foreign keys
- foreach ($foreignKeys as $foreignKey) {
- $this->ddlCache[self::KEY_REFERENCE][$tableName][$foreignKey['name']] = $foreignKey;
- }
- }
-
- return $this->ddlCache[self::KEY_REFERENCE][$tableName];
- }
-
- /**
- * @param $tableName
- * @param string $resource
- * @return array
- */
- public function getColumnsList($tableName, $resource)
- {
- if (!isset($this->ddlCache[self::KEY_COLUMNS][$tableName])) {
- $this->ddlCache[self::KEY_COLUMNS][$tableName] = [];
- foreach ($this->dbSchemaReader->readeColumns($tableName, $resource) as $rawColumn) {
- $column = $this->processElementFromDefinition($rawColumn, self::KEY_COLUMNS);
- $this->ddlCache[self::KEY_COLUMNS][$tableName][$column['name']] = $column;
- }
- }
-
- return $this->ddlCache[self::KEY_COLUMNS][$tableName];
- }
-
- /**
- * As all read operations are cached, sometimes we need to flush them
- *
- * @return void
- */
- public function flushCache()
- {
- $this->ddlCache = [];
- }
-}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/DbSchemaProcessorInterface.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/DbDefinitionProcessorInterface.php
similarity index 71%
rename from setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/DbSchemaProcessorInterface.php
rename to setup/src/Magento/Setup/Model/Declaration/Schema/Db/DbDefinitionProcessorInterface.php
index 0b483a0d11558..6aa4ce490b6a3 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/DbSchemaProcessorInterface.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/DbDefinitionProcessorInterface.php
@@ -4,7 +4,7 @@
* See COPYING.txt for license details.
*/
-namespace Magento\Setup\Model\Declaration\Schema\Db\Processors;
+namespace Magento\Setup\Model\Declaration\Schema\Db;
use Magento\Setup\Model\Declaration\Schema\Dto\ElementInterface;
@@ -14,16 +14,8 @@
* 'type' => 'varchar'
* 'length' => 255
*/
-interface DbSchemaProcessorInterface
+interface DbDefinitionProcessorInterface
{
- /**
- * Check whether current processor can process element
- *
- * @param ElementInterface $element
- * @return mixed
- */
- public function canBeApplied(ElementInterface $element);
-
/**
* Output always will be SQL definition
*
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/DbSchemaReaderInterface.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/DbSchemaReaderInterface.php
similarity index 91%
rename from setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/DbSchemaReaderInterface.php
rename to setup/src/Magento/Setup/Model/Declaration/Schema/Db/DbSchemaReaderInterface.php
index 07bfc97a3ef33..78925c05397dd 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/DbSchemaReaderInterface.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/DbSchemaReaderInterface.php
@@ -4,7 +4,7 @@
* See COPYING.txt for license details.
*/
-namespace Magento\Setup\Model\Declaration\Schema\Db\Processors;
+namespace Magento\Setup\Model\Declaration\Schema\Db;
/**
* This class is responsible for read different schema
@@ -37,7 +37,7 @@ public function readConstraints($tableName, $resource);
* @param string $resource
* @return array
*/
- public function readeColumns($tableName, $resource);
+ public function readColumns($tableName, $resource);
/**
* Read references (foreign keys) from Magento tables
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/DbSchemaWriterInterface.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/DbSchemaWriterInterface.php
similarity index 92%
rename from setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/DbSchemaWriterInterface.php
rename to setup/src/Magento/Setup/Model/Declaration/Schema/Db/DbSchemaWriterInterface.php
index 2bef0db6a7479..87286e6d136cd 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/DbSchemaWriterInterface.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/DbSchemaWriterInterface.php
@@ -4,7 +4,7 @@
* See COPYING.txt for license details.
*/
-namespace Magento\Setup\Model\Declaration\Schema\Db\Processors;
+namespace Magento\Setup\Model\Declaration\Schema\Db;
/**
* This class is responsible for read different schema
@@ -16,10 +16,10 @@ interface DbSchemaWriterInterface
* Create table from SQL fragments, like columns, constraints, foreign keys, indexes, etc
*
* @param array $tableOptions
- * @param array $sqlFragments
+ * @param array $definition
* @return void
*/
- public function createTable(array $tableOptions, array $sqlFragments);
+ public function createTable(array $tableOptions, array $definition);
/**
* Drop table from SQL database
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/DefinitionAggregator.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/DefinitionAggregator.php
new file mode 100644
index 0000000000000..90b20a051e0dd
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/DefinitionAggregator.php
@@ -0,0 +1,63 @@
+definitionProcessors = $definitionProcessors;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function toDefinition(ElementInterface $element)
+ {
+ $type = $element->getType();
+ if (!isset($this->definitionProcessors[$type])) {
+ throw new \InvalidArgumentException(
+ sprintf("Cannot process object to definition for type %s", $type)
+ );
+ }
+
+ $definitionProcessor = $this->definitionProcessors[$type];
+ return $definitionProcessor->toDefinition($element);
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function fromDefinition(array $data)
+ {
+ $type = $data['type'];
+ if (!isset($this->definitionProcessors[$type])) {
+ throw new \InvalidArgumentException(
+ sprintf("Cannot process definition to array for type %s", $type)
+ );
+ }
+
+ $definitionProcessor = $this->definitionProcessors[$type];
+ return $definitionProcessor->fromDefinition($data);
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/DbSchemaReader.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/DbSchemaReader.php
new file mode 100644
index 0000000000000..63306ea2c8e9d
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/DbSchemaReader.php
@@ -0,0 +1,185 @@
+resourceConnection = $resourceConnection;
+ $this->definitionAggregator = $definitionAggregator;
+ }
+
+ /**
+ * Prepare and fetch query: Describe {table_name}
+ *
+ * @param string $tableName
+ * @param string $resource
+ * @return array
+ */
+ public function readColumns($tableName, $resource)
+ {
+ $columns = [];
+ $adapter = $this->resourceConnection->getConnection($resource);
+ $dbName = $this->resourceConnection->getSchemaName($resource);
+ $stmt = $adapter->select()
+ ->from(
+ 'information_schema.COLUMNS',
+ [
+ 'name' => 'COLUMN_NAME',
+ 'default' => 'COLUMN_DEFAULT',
+ 'type' => 'DATA_TYPE',
+ 'nullable' => new Expression('IF(IS_NULLABLE="YES", true, false)'),
+ 'definition' => 'COLUMN_TYPE',
+ 'extra' => 'EXTRA'
+ ]
+ )
+ ->where('TABLE_SCHEMA = ?', $dbName)
+ ->where('TABLE_NAME = ?', $tableName)
+ ->order('ORDINAL_POSITION ASC');
+
+ $columnsDefinition = $adapter->fetchAssoc($stmt);
+
+ foreach ($columnsDefinition as $columnDefinition) {
+ $column = $this->definitionAggregator->fromDefinition($columnDefinition);
+ $columns[$column['name']] = $column;
+ }
+
+ return $columns;
+ }
+
+ /**
+ * Fetch all indexes from table
+ *
+ * @param string $tableName
+ * @param string $resource
+ * @return array
+ */
+ public function readIndexes($tableName, $resource)
+ {
+ $indexes = [];
+ $adapter = $this->resourceConnection->getConnection($resource);
+ $condition = sprintf('Non_unique = 1');
+ $sql = sprintf('SHOW INDEXES FROM %s WHERE %s', $tableName, $condition);
+ $stmt = $adapter->query($sql);
+
+ // Use FETCH_NUM so we are not dependent on the CASE attribute of the PDO connection
+ $indexesDefinition = $stmt->fetchAll(\Zend_Db::FETCH_ASSOC);
+
+ foreach ($indexesDefinition as $indexDefinition) {
+ $indexDefinition['type'] = 'index';
+ $index = $this->definitionAggregator->fromDefinition($indexDefinition);
+
+ if (!isset($indexes[$index['name']])) {
+ $indexes[$index['name']] = [];
+ }
+
+ $indexes[$index['name']] = array_replace_recursive($indexes[$index['name']], $index);
+ }
+
+ return $indexes;
+ }
+
+ /**
+ * As MySQL has bug and do not show foreign keys during
+ * DESCRIBE and other directives we need to take it from SHOW CREATE TABLE ...
+ * command
+ *
+ * @inheritdoc
+ */
+ public function readReferences($tableName, $resource)
+ {
+ $createTableSql = $this->getCreateTableSql($tableName, $resource);
+ $createTableSql['type'] = 'reference';
+ return $this->definitionAggregator->fromDefinition($createTableSql);
+ }
+
+ /**
+ * Retrieve Create table SQL, from SHOW CREATE TABLE query
+ *
+ * @param string $tableName
+ * @param string $resource
+ * @return array
+ */
+ public function getCreateTableSql($tableName, $resource)
+ {
+ $adapter = $this->resourceConnection->getConnection($resource);
+ $sql = sprintf('SHOW CREATE TABLE %s', $tableName);
+ $stmt = $adapter->query($sql);
+ return $stmt->fetch(\Zend_Db::FETCH_ASSOC);
+ }
+
+ /**
+ * For MySQL reading of constraints is almost the same as indexes
+ * But we need to know, that we read 2 types of constraints:
+ * primary and unique keys and this keys are always non_unique=0
+ *
+ * @inheritdoc
+ */
+ public function readConstraints($tableName, $resource)
+ {
+ $constraints = [];
+ $adapter = $this->resourceConnection->getConnection($resource);
+ $condition = sprintf('Non_unique = 0');
+ $sql = sprintf('SHOW INDEXES FROM %s WHERE %s', $tableName, $condition);
+ $stmt = $adapter->query($sql);
+
+ // Use FETCH_NUM so we are not dependent on the CASE attribute of the PDO connection
+ $constraintsDefinition = $stmt->fetchAll(\Zend_Db::FETCH_ASSOC);
+
+ foreach ($constraintsDefinition as $constraintDefinition) {
+ $constraintDefinition['type'] = Constraint::TYPE;
+ $constraint = $this->definitionAggregator->fromDefinition($constraintDefinition);
+
+ if (!isset($constraints[$constraint['name']])) {
+ $constraints[$constraint['name']] = [];
+ }
+
+ $constraints[$constraint['name']] = array_replace_recursive($constraints[$constraint['name']], $constraint);
+ }
+
+ return $constraints;
+ }
+
+ /**
+ * Return names of all tables from shard
+ *
+ * @param string $resource Shard name
+ * @return array
+ */
+ public function readTables($resource)
+ {
+ return $this->resourceConnection
+ ->getConnection($resource)
+ ->getTables();
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/DbSchemaWriter.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/DbSchemaWriter.php
similarity index 96%
rename from setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/DbSchemaWriter.php
rename to setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/DbSchemaWriter.php
index 771d6c5f980da..2a07a891e523c 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/DbSchemaWriter.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/DbSchemaWriter.php
@@ -4,13 +4,14 @@
* See COPYING.txt for license details.
*/
-namespace Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL;
+namespace Magento\Setup\Model\Declaration\Schema\Db\MySQL;
use Magento\Framework\App\ResourceConnection;
use Magento\Framework\DB\Adapter\AdapterInterface;
-use Magento\Setup\Model\Declaration\Schema\Db\Processors\DbSchemaWriterInterface;
-use Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL\Constraints\ForeignKey;
-use Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL\Constraints\Internal;
+use Magento\Setup\Model\Declaration\Schema\Db\DbSchemaWriterInterface;
+use Magento\Setup\Model\Declaration\Schema\Db\MySQL\Definition\Constraints\ForeignKey;
+use Magento\Setup\Model\Declaration\Schema\Db\MySQL\Definition\Constraints\Internal;
+use Magento\Setup\Model\Declaration\Schema\Db\MySQL\Definition\Index;
use Magento\Setup\Model\Declaration\Schema\Dto\Column;
use Magento\Setup\Model\Declaration\Schema\Dto\Constraint;
@@ -212,7 +213,7 @@ public function modifyColumn(array $columnOptions, $columnDefinition)
private function getConstraintType($type)
{
switch ($type) {
- case 'foreign':
+ case 'reference':
$elementType = ForeignKey::FOREIGN_KEY_NAME;
break;
case 'primary':
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Blob.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Columns/Blob.php
similarity index 62%
rename from setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Blob.php
rename to setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Columns/Blob.php
index d9552280ff5d1..359675908867a 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Blob.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Columns/Blob.php
@@ -4,9 +4,9 @@
* See COPYING.txt for license details.
*/
-namespace Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL\Columns;
+namespace Magento\Setup\Model\Declaration\Schema\Db\MySQL\Definition\Columns;
-use Magento\Setup\Model\Declaration\Schema\Db\Processors\DbSchemaProcessorInterface;
+use Magento\Setup\Model\Declaration\Schema\Db\DbDefinitionProcessorInterface;
use Magento\Setup\Model\Declaration\Schema\Dto\ElementInterface;
/**
@@ -14,7 +14,7 @@
*
* @inheritdoc
*/
-class Blob implements DbSchemaProcessorInterface
+class Blob implements DbDefinitionProcessorInterface
{
/**
* @var Nullable
@@ -44,25 +44,14 @@ public function toDefinition(ElementInterface $element)
);
}
- /**
- * @inheritdoc
- */
- public function canBeApplied(ElementInterface $element)
- {
- return $element instanceof \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Blob;
- }
-
/**
* @inheritdoc
*/
public function fromDefinition(array $data)
{
$matches = [];
- if (preg_match('/^(tiny|medium|long)(text|blob)\s(\d+)/', $data['type'], $matches)) {
- if (isset($matches[0])) {
- $data['type'] = $matches[0] . $matches[1];
- $data['length'] = $matches[2];
- }
+ if (preg_match('/^(tiny|medium|long)(text|blob)\s(\d+)/', $data['definition'], $matches)) {
+ $data['length'] = $matches[2];
}
return $data;
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Boolean.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Columns/Boolean.php
similarity index 72%
rename from setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Boolean.php
rename to setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Columns/Boolean.php
index 66ee4c682b694..d1e4dd2ca4649 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Boolean.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Columns/Boolean.php
@@ -4,9 +4,10 @@
* See COPYING.txt for license details.
*/
-namespace Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL\Columns;
+namespace Magento\Setup\Model\Declaration\Schema\Db\MySQL\Definition\Columns;
-use Magento\Setup\Model\Declaration\Schema\Db\Processors\DbSchemaProcessorInterface;
+use Magento\Framework\Stdlib\BooleanUtils;
+use Magento\Setup\Model\Declaration\Schema\Db\DbDefinitionProcessorInterface;
use Magento\Setup\Model\Declaration\Schema\Dto\ElementInterface;
/**
@@ -15,7 +16,7 @@
*
* @inheritdoc
*/
-class Boolean implements DbSchemaProcessorInterface
+class Boolean implements DbDefinitionProcessorInterface
{
/**
* Type with what we will persist column
@@ -25,7 +26,7 @@ class Boolean implements DbSchemaProcessorInterface
/**
* Type of integer that will be used in MySQL for boolean
*/
- const INTEGER_TYPE = 'tinyinteger';
+ const INTEGER_TYPE = 'tinyint';
/**
* Padding for integer described below
@@ -43,21 +44,23 @@ class Boolean implements DbSchemaProcessorInterface
private $defaultDefinition;
/**
- * @param Nullable $nullable
- * @param DefaultDefinition $defaultDefinition
+ * @var BooleanUtils
*/
- public function __construct(Nullable $nullable, DefaultDefinition $defaultDefinition)
- {
- $this->nullable = $nullable;
- $this->defaultDefinition = $defaultDefinition;
- }
+ private $booleanUtils;
/**
- * @inheritdoc
+ * @param Nullable $nullable
+ * @param DefaultDefinition $defaultDefinition
+ * @param BooleanUtils $booleanUtils
*/
- public function canBeApplied(ElementInterface $element)
- {
- return $element instanceof \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Boolean;
+ public function __construct(
+ Nullable $nullable,
+ DefaultDefinition $defaultDefinition,
+ BooleanUtils $booleanUtils
+ ) {
+ $this->nullable = $nullable;
+ $this->defaultDefinition = $defaultDefinition;
+ $this->booleanUtils = $booleanUtils;
}
/**
@@ -82,7 +85,7 @@ public function toDefinition(ElementInterface $element)
public function fromDefinition(array $data)
{
if ($data['type'] === self::INTEGER_TYPE && $data['padding'] === self::INTEGER_PADDING) {
- $data['type'] = 'boolean';
+ $data['type'] = strtolower(self::TYPE);
$data['default'] = (bool) $data['default'];
$data['unsigned'] = false; //For boolean we always do not want to have unsigned
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Date.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Columns/Date.php
similarity index 61%
rename from setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Date.php
rename to setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Columns/Date.php
index 4d1955f3a60d2..378a9dba7ffbd 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Date.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Columns/Date.php
@@ -4,9 +4,9 @@
* See COPYING.txt for license details.
*/
-namespace Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL\Columns;
+namespace Magento\Setup\Model\Declaration\Schema\Db\MySQL\Definition\Columns;
-use Magento\Setup\Model\Declaration\Schema\Db\Processors\DbSchemaProcessorInterface;
+use Magento\Setup\Model\Declaration\Schema\Db\DbDefinitionProcessorInterface;
use Magento\Setup\Model\Declaration\Schema\Dto\ElementInterface;
/**
@@ -14,16 +14,8 @@
*
* @inheritdoc
*/
-class Date implements DbSchemaProcessorInterface
+class Date implements DbDefinitionProcessorInterface
{
- /**
- * @inheritdoc
- */
- public function canBeApplied(ElementInterface $element)
- {
- return $element instanceof \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Date;
- }
-
/**
* @param \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Timestamp $element
* @inheritdoc
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Decimal.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Columns/Decimal.php
similarity index 73%
rename from setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Decimal.php
rename to setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Columns/Decimal.php
index a2f5aa2aeb78c..9b279088edcc8 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Decimal.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Columns/Decimal.php
@@ -4,9 +4,9 @@
* See COPYING.txt for license details.
*/
-namespace Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL\Columns;
+namespace Magento\Setup\Model\Declaration\Schema\Db\MySQL\Definition\Columns;
-use Magento\Setup\Model\Declaration\Schema\Db\Processors\DbSchemaProcessorInterface;
+use Magento\Setup\Model\Declaration\Schema\Db\DbDefinitionProcessorInterface;
use Magento\Setup\Model\Declaration\Schema\Dto\ElementInterface;
/**
@@ -14,7 +14,7 @@
*
* @inheritdoc
*/
-class Decimal implements DbSchemaProcessorInterface
+class Decimal implements DbDefinitionProcessorInterface
{
/**
* @var Nullable
@@ -43,14 +43,6 @@ public function __construct(Nullable $nullable, Unsigned $unsigned, DefaultDefin
$this->defaultDefinition = $defaultDefinition;
}
- /**
- * @inheritdoc
- */
- public function canBeApplied(ElementInterface $element)
- {
- return $element instanceof \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Decimal;
- }
-
/**
* @param \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Decimal $element
* @inheritdoc
@@ -74,19 +66,15 @@ public function toDefinition(ElementInterface $element)
public function fromDefinition(array $data)
{
$matches = [];
- if (preg_match('/^(float|decimal|double)\((\d+),(\d+)\)/', $data['type'], $matches)) {
+ if (preg_match('/^(float|decimal|double)\((\d+),(\d+)\)/', $data['definition'], $matches)) {
/**
* match[1] - type
* match[2] - precision
* match[3] - scale
*/
- $data['type'] = $matches[1];
-
- if (isset($matches[2]) && isset($matches[3])) {
- $data['scale'] = $matches[2];
- $data['precission'] = $matches[3];
- }
-
+ $data['scale'] = $matches[2];
+ $data['precission'] = $matches[3];
+ $data = $this->nullable->fromDefinition($data);
$data = $this->unsigned->fromDefinition($data);
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/DefaultDefinition.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Columns/DefaultDefinition.php
similarity index 76%
rename from setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/DefaultDefinition.php
rename to setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Columns/DefaultDefinition.php
index 2a74b504eb4cd..72dbe24e51875 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/DefaultDefinition.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Columns/DefaultDefinition.php
@@ -4,9 +4,9 @@
* See COPYING.txt for license details.
*/
-namespace Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL\Columns;
+namespace Magento\Setup\Model\Declaration\Schema\Db\MySQL\Definition\Columns;
-use Magento\Setup\Model\Declaration\Schema\Db\Processors\DbSchemaProcessorInterface;
+use Magento\Setup\Model\Declaration\Schema\Db\DbDefinitionProcessorInterface;
use Magento\Setup\Model\Declaration\Schema\Dto\Columns\ColumnDefaultAwareInterface;
use Magento\Setup\Model\Declaration\Schema\Dto\ElementInterface;
@@ -15,7 +15,7 @@
*
* @inheritdoc
*/
-class DefaultDefinition implements DbSchemaProcessorInterface
+class DefaultDefinition implements DbDefinitionProcessorInterface
{
/**
* @param ColumnDefaultAwareInterface $element
@@ -44,14 +44,6 @@ private function defaultStringify($default)
return $default;
}
- /**
- * @inheritdoc
- */
- public function canBeApplied(ElementInterface $element)
- {
- return false;
- }
-
/**
* @inheritdoc
*/
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Identity.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Columns/Identity.php
similarity index 74%
rename from setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Identity.php
rename to setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Columns/Identity.php
index e3a05ea63ced1..1340b7162de48 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Identity.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Columns/Identity.php
@@ -4,9 +4,9 @@
* See COPYING.txt for license details.
*/
-namespace Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL\Columns;
+namespace Magento\Setup\Model\Declaration\Schema\Db\MySQL\Definition\Columns;
-use Magento\Setup\Model\Declaration\Schema\Db\Processors\DbSchemaProcessorInterface;
+use Magento\Setup\Model\Declaration\Schema\Db\DbDefinitionProcessorInterface;
use Magento\Setup\Model\Declaration\Schema\Dto\Columns\ColumnIdentityAwareInterface;
use Magento\Setup\Model\Declaration\Schema\Dto\ElementInterface;
@@ -15,7 +15,7 @@
*
* @inheritdoc
*/
-class Identity implements DbSchemaProcessorInterface
+class Identity implements DbDefinitionProcessorInterface
{
/**
* MyMySQL flag, that says that we need to increment field, each time when we add new row
@@ -31,14 +31,6 @@ public function toDefinition(ElementInterface $element)
return $element->isIdentity() ? strtoupper(self::IDENTITY_FLAG) : '';
}
- /**
- * @inheritdoc
- */
- public function canBeApplied(ElementInterface $element)
- {
- return false;
- }
-
/**
* @inheritdoc
*/
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Integer.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Columns/Integer.php
similarity index 69%
rename from setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Integer.php
rename to setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Columns/Integer.php
index 1d64b23de5557..d4536d635d2e9 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Integer.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Columns/Integer.php
@@ -4,9 +4,9 @@
* See COPYING.txt for license details.
*/
-namespace Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL\Columns;
+namespace Magento\Setup\Model\Declaration\Schema\Db\MySQL\Definition\Columns;
-use Magento\Setup\Model\Declaration\Schema\Db\Processors\DbSchemaProcessorInterface;
+use Magento\Setup\Model\Declaration\Schema\Db\DbDefinitionProcessorInterface;
use Magento\Setup\Model\Declaration\Schema\Dto\ElementInterface;
/**
@@ -14,7 +14,7 @@
*
* @inheritdoc
*/
-class Integer implements DbSchemaProcessorInterface
+class Integer implements DbDefinitionProcessorInterface
{
/**
* @var Unsigned
@@ -22,7 +22,7 @@ class Integer implements DbSchemaProcessorInterface
private $unsigned;
/**
- * @var \Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL\Columns\Boolean
+ * @var \Magento\Setup\Model\Declaration\Schema\Db\MySQL\Definition\Columns\Boolean
*/
private $boolean;
@@ -62,14 +62,6 @@ public function __construct(
$this->defaultDefinition = $defaultDefinition;
}
- /**
- * @inheritdoc
- */
- public function canBeApplied(ElementInterface $element)
- {
- return $element instanceof \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Integer;
- }
-
/**
* @param \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Integer $element
* @inheritdoc
@@ -78,7 +70,7 @@ public function toDefinition(ElementInterface $element)
{
return sprintf(
'%s(%s) %s %s %s %s',
- str_replace('integer', 'int', $element->getType()),
+ $element->getType(),
$element->getPadding(),
$this->unsigned->toDefinition($element),
$this->nullable->toDefinition($element),
@@ -93,21 +85,15 @@ public function toDefinition(ElementInterface $element)
public function fromDefinition(array $data)
{
$matches = [];
- if (preg_match('/^(big|medium|small|tiny)?int\((\d+)\)/', $data['type'], $matches)) {
+ if (preg_match('/^(big|small|tiny)?int\((\d+)\)/', $data['definition'], $matches)) {
/**
- * match[0] - all
* match[1] - prefix
* match[2] - padding, like 5 or 11
*/
- $data = $this->unsigned->fromDefinition($data);
- $data['type'] = sprintf("%sinteger", $matches[1]);
//Use shortcut for mediuminteger
- $data['type'] = $data['type'] === 'mediuminteger' ? 'integer' : $data['type'];
-
- if (isset($matches[2])) {
- $data['padding'] = $matches[2];
- }
-
+ $data['padding'] = $matches[2];
+ $data = $this->unsigned->fromDefinition($data);
+ $data = $this->nullable->fromDefinition($data);
$data = $this->identity->fromDefinition($data);
$data = $this->boolean->fromDefinition($data);
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Columns/Nullable.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Columns/Nullable.php
new file mode 100644
index 0000000000000..97a0d0d53202e
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Columns/Nullable.php
@@ -0,0 +1,40 @@
+isNullable() ? 'NULL' : 'NOT NULL';
+ }
+
+ return '';
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function fromDefinition(array $data)
+ {
+ return $data;
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/OnUpdate.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Columns/OnUpdate.php
similarity index 59%
rename from setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/OnUpdate.php
rename to setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Columns/OnUpdate.php
index 06451172e6857..06dd53a806250 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/OnUpdate.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Columns/OnUpdate.php
@@ -4,9 +4,9 @@
* See COPYING.txt for license details.
*/
-namespace Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL\Columns;
+namespace Magento\Setup\Model\Declaration\Schema\Db\MySQL\Definition\Columns;
-use Magento\Setup\Model\Declaration\Schema\Db\Processors\DbSchemaProcessorInterface;
+use Magento\Setup\Model\Declaration\Schema\Db\DbDefinitionProcessorInterface;
use Magento\Setup\Model\Declaration\Schema\Dto\ElementInterface;
/**
@@ -14,7 +14,7 @@
*
* @inheritdoc
*/
-class OnUpdate implements DbSchemaProcessorInterface
+class OnUpdate implements DbDefinitionProcessorInterface
{
/**
* @param \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Timestamp $element
@@ -22,16 +22,12 @@ class OnUpdate implements DbSchemaProcessorInterface
*/
public function toDefinition(ElementInterface $element)
{
- return $element->getOnUpdate() ?
- 'ON UPDATE CURRENT_TIMESTAMP' : '';
- }
+ if ($element instanceof \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Timestamp) {
+ return $element->getOnUpdate() ?
+ 'ON UPDATE CURRENT_TIMESTAMP' : '';
+ }
- /**
- * @inheritdoc
- */
- public function canBeApplied(ElementInterface $element)
- {
- return false;
+ return '';
}
/**
@@ -41,7 +37,7 @@ public function fromDefinition(array $data)
{
$matches = [];
if (preg_match('/^(?:on update)\s([\_\-\s\w\d]+)/', $data['extra'], $matches)) {
- $data['on_update'] = $matches[1];
+ $data['on_update'] = true;
}
return $data;
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Timestamp.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Columns/Timestamp.php
similarity index 65%
rename from setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Timestamp.php
rename to setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Columns/Timestamp.php
index 1e7b3fa5fb6a5..008288c6d1c72 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Timestamp.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Columns/Timestamp.php
@@ -4,9 +4,9 @@
* See COPYING.txt for license details.
*/
-namespace Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL\Columns;
+namespace Magento\Setup\Model\Declaration\Schema\Db\MySQL\Definition\Columns;
-use Magento\Setup\Model\Declaration\Schema\Db\Processors\DbSchemaProcessorInterface;
+use Magento\Setup\Model\Declaration\Schema\Db\DbDefinitionProcessorInterface;
use Magento\Setup\Model\Declaration\Schema\Dto\Columns\Date;
use Magento\Setup\Model\Declaration\Schema\Dto\ElementInterface;
@@ -15,7 +15,7 @@
*
* @inheritdoc
*/
-class Timestamp implements DbSchemaProcessorInterface
+class Timestamp implements DbDefinitionProcessorInterface
{
/**
* This timestamp can be used, when const value as DEFAULT 0 was passed
@@ -42,14 +42,6 @@ public function __construct(OnUpdate $onUpdate, DefaultDefinition $defaultDefini
$this->defaultDefinition = $defaultDefinition;
}
- /**
- * @inheritdoc
- */
- public function canBeApplied(ElementInterface $element)
- {
- return $element instanceof \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Timestamp;
- }
-
/**
* @param \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Timestamp $element
* @inheritdoc
@@ -69,15 +61,11 @@ public function toDefinition(ElementInterface $element)
*/
public function fromDefinition(array $data)
{
- $matches = [];
- if (preg_match('/^(timestamp|datetime).*/', $data['type'], $matches)) {
- $data['type'] = $matches[1];
- if ($data['default'] === self::CONST_DEFAULT_TIMESTAMP) {
- $data['default'] = 0;
- }
- $data = $this->onUpdate->fromDefinition($data);
+ if ($data['default'] === self::CONST_DEFAULT_TIMESTAMP) {
+ $data['default'] = 0;
}
+ $data = $this->onUpdate->fromDefinition($data);
return $data;
}
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Unsigned.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Columns/Unsigned.php
similarity index 61%
rename from setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Unsigned.php
rename to setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Columns/Unsigned.php
index 5eb6b976029f6..f75d249cf50eb 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Unsigned.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Columns/Unsigned.php
@@ -4,9 +4,9 @@
* See COPYING.txt for license details.
*/
-namespace Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL\Columns;
+namespace Magento\Setup\Model\Declaration\Schema\Db\MySQL\Definition\Columns;
-use Magento\Setup\Model\Declaration\Schema\Db\Processors\DbSchemaProcessorInterface;
+use Magento\Setup\Model\Declaration\Schema\Db\DbDefinitionProcessorInterface;
use Magento\Setup\Model\Declaration\Schema\Dto\Columns\ColumnUnsignedAwareInterface;
use Magento\Setup\Model\Declaration\Schema\Dto\ElementInterface;
@@ -15,7 +15,7 @@
*
* @inheritdoc
*/
-class Unsigned implements DbSchemaProcessorInterface
+class Unsigned implements DbDefinitionProcessorInterface
{
/**
* MySQL flag, that says that we need to use unsigned numbers.
@@ -29,15 +29,7 @@ class Unsigned implements DbSchemaProcessorInterface
*/
public function toDefinition(ElementInterface $element)
{
- return $element->isUnsigned() ? 'UNSIGNED' : '';
- }
-
- /**
- * @inheritdoc
- */
- public function canBeApplied(ElementInterface $element)
- {
- return false;
+ return $element->isUnsigned() ? strtoupper(self::UNSIGNED_FLAG) : '';
}
/**
@@ -45,7 +37,7 @@ public function canBeApplied(ElementInterface $element)
*/
public function fromDefinition(array $data)
{
- $data['unsigned'] = strpos($data['type'], self::UNSIGNED_FLAG) !== false;
+ $data['unsigned'] = strpos($data['definition'], self::UNSIGNED_FLAG) !== false;
return $data;
}
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Varchar.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Columns/Varchar.php
similarity index 73%
rename from setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Varchar.php
rename to setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Columns/Varchar.php
index 668778631b77d..19a6123c9fa1f 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Varchar.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Columns/Varchar.php
@@ -3,15 +3,17 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-namespace Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL\Columns;
+namespace Magento\Setup\Model\Declaration\Schema\Db\MySQL\Definition\Columns;
-use Magento\Setup\Model\Declaration\Schema\Db\Processors\DbSchemaProcessorInterface;
+use Magento\Setup\Model\Declaration\Schema\Db\DbDefinitionProcessorInterface;
use Magento\Setup\Model\Declaration\Schema\Dto\ElementInterface;
/**
+ * Process 3 different types: char, varchar, varbinary
+ *
* @inheritdoc
*/
-class Varchar implements DbSchemaProcessorInterface
+class Varchar implements DbDefinitionProcessorInterface
{
/**
* @var Nullable
@@ -48,22 +50,13 @@ public function toDefinition(ElementInterface $element)
);
}
- /**
- * @inheritdoc
- */
- public function canBeApplied(ElementInterface $element)
- {
- return $element instanceof \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Varchar;
- }
-
/**
* @inheritdoc
*/
public function fromDefinition(array $data)
{
$matches = [];
- if (preg_match('/^(char|varchar|varbinary)\((\d+)\)/', $data['type'], $matches)) {
- $data['type'] = $matches[1];
+ if (preg_match('/^(char|varchar|varbinary)\((\d+)\)/', $data['definition'], $matches)) {
$data['length'] = $matches[2];
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Constraints/ForeignKey.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Constraints/ForeignKey.php
similarity index 56%
rename from setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Constraints/ForeignKey.php
rename to setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Constraints/ForeignKey.php
index d81b78444c102..c52751d7aac2c 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Constraints/ForeignKey.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Constraints/ForeignKey.php
@@ -4,10 +4,10 @@
* See COPYING.txt for license details.
*/
-namespace Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL\Constraints;
+namespace Magento\Setup\Model\Declaration\Schema\Db\MySQL\Definition\Constraints;
use Magento\Framework\App\ResourceConnection;
-use Magento\Setup\Model\Declaration\Schema\Db\Processors\DbSchemaProcessorInterface;
+use Magento\Setup\Model\Declaration\Schema\Db\DbDefinitionProcessorInterface;
use Magento\Setup\Model\Declaration\Schema\Dto\Constraints\Reference;
use Magento\Setup\Model\Declaration\Schema\Dto\ElementInterface;
@@ -17,7 +17,7 @@
*
* @inheritdoc
*/
-class ForeignKey implements DbSchemaProcessorInterface
+class ForeignKey implements DbDefinitionProcessorInterface
{
/**
* Usually used in MySQL requests
@@ -62,44 +62,32 @@ public function toDefinition(ElementInterface $element)
return $foreignKeySql;
}
- /**
- * @inheritdoc
- */
- public function canBeApplied(ElementInterface $element)
- {
- return $element instanceof \Magento\Setup\Model\Declaration\Schema\Dto\Constraints\Reference;
- }
-
/**
* @inheritdoc
*/
public function fromDefinition(array $data)
{
- if (isset($data['Create Table'])) {
- $createMySQL = $data['Create Table'];
- $ddl = [];
- $regExp = '#,\s+CONSTRAINT `([^`]*)` FOREIGN KEY ?\(`([^`]*)`\) '
- . 'REFERENCES (`([^`]*)`\.)?`([^`]*)` \(`([^`]*)`\)'
- . '( ON DELETE (RESTRICT|CASCADE|SET NULL|NO ACTION))?'
- . '( ON UPDATE (RESTRICT|CASCADE|SET NULL|NO ACTION))?#';
- $matches = [];
+ $createMySQL = $data['Create Table'];
+ $ddl = [];
+ $regExp = '#,\s+CONSTRAINT `([^`]*)` FOREIGN KEY ?\(`([^`]*)`\) '
+ . 'REFERENCES (`([^`]*)`\.)?`([^`]*)` \(`([^`]*)`\)'
+ . '( ON DELETE (RESTRICT|CASCADE|SET NULL|NO ACTION))?'
+ . '( ON UPDATE (RESTRICT|CASCADE|SET NULL|NO ACTION))?#';
+ $matches = [];
- if (preg_match_all($regExp, $createMySQL, $matches, PREG_SET_ORDER)) {
- foreach ($matches as $match) {
- $ddl[$match[1]] = [
- 'type' => 'foreign',
- 'name' => $match[1],
- 'column' => $match[2],
- 'referenceTable' => $match[5],
- 'referenceColumn' => $match[6],
- 'onDelete' => isset($match[7]) ? $match[8] : ''
- ];
- }
+ if (preg_match_all($regExp, $createMySQL, $matches, PREG_SET_ORDER)) {
+ foreach ($matches as $match) {
+ $ddl[$match[1]] = [
+ 'type' => Reference::TYPE,
+ 'name' => $match[1],
+ 'column' => $match[2],
+ 'referenceTable' => $match[5],
+ 'referenceColumn' => $match[6],
+ 'onDelete' => isset($match[7]) ? $match[8] : ''
+ ];
}
-
- return $ddl;
}
- return $data;
+ return $ddl;
}
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Constraints/Internal.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Constraints/Internal.php
similarity index 79%
rename from setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Constraints/Internal.php
rename to setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Constraints/Internal.php
index fe21e285428e5..bceedef5c5cdf 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Constraints/Internal.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Constraints/Internal.php
@@ -4,10 +4,10 @@
* See COPYING.txt for license details.
*/
-namespace Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL\Constraints;
+namespace Magento\Setup\Model\Declaration\Schema\Db\MySQL\Definition\Constraints;
use Magento\Framework\App\ResourceConnection;
-use Magento\Setup\Model\Declaration\Schema\Db\Processors\DbSchemaProcessorInterface;
+use Magento\Setup\Model\Declaration\Schema\Db\DbDefinitionProcessorInterface;
use Magento\Setup\Model\Declaration\Schema\Dto\Column;
use Magento\Setup\Model\Declaration\Schema\Dto\ElementInterface;
@@ -16,7 +16,7 @@
*
* @inheritdoc
*/
-class Internal implements DbSchemaProcessorInterface
+class Internal implements DbDefinitionProcessorInterface
{
/**
* Name of Primary Key
@@ -69,29 +69,17 @@ function (Column $column) use ($adapter) {
);
}
- /**
- * @inheritdoc
- */
- public function canBeApplied(ElementInterface $element)
- {
- return $element instanceof \Magento\Setup\Model\Declaration\Schema\Dto\Constraints\Internal;
- }
-
/**
* @inheritdoc
*/
public function fromDefinition(array $data)
{
- if (isset($data['Key_name'])) {
- $data = [
+ return [
'name' => $data['Key_name'],
'column' => [
$data['Column_name'] => $data['Column_name']
],
'type' => $data['Key_name'] === self::PRIMARY_NAME ? 'primary' : 'unique'
- ];
- }
-
- return $data;
+ ];
}
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Index.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Index.php
similarity index 91%
rename from setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Index.php
rename to setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Index.php
index 1ad89b817fa48..bb90f40c31c68 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Index.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Index.php
@@ -4,10 +4,10 @@
* See COPYING.txt for license details.
*/
-namespace Magento\Setup\Model\Declaration\Schema\Db\Processors\MySQL;
+namespace Magento\Setup\Model\Declaration\Schema\Db\MySQL\Definition;
use Magento\Framework\App\ResourceConnection;
-use Magento\Setup\Model\Declaration\Schema\Db\Processors\DbSchemaProcessorInterface;
+use Magento\Setup\Model\Declaration\Schema\Db\DbDefinitionProcessorInterface;
use Magento\Setup\Model\Declaration\Schema\Dto\Column;
use Magento\Setup\Model\Declaration\Schema\Dto\ElementInterface;
@@ -17,7 +17,7 @@
*
* @inheritdoc
*/
-class Index implements DbSchemaProcessorInterface
+class Index implements DbDefinitionProcessorInterface
{
/**
* Key name that is used in requests, like DROP INDEX or ADD INDEX
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Basic.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Basic.php
deleted file mode 100644
index 98a8850eba27c..0000000000000
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Basic.php
+++ /dev/null
@@ -1,95 +0,0 @@
- 'name',
- 1 => 'type',
- 2 => 'nullable',
- 3 => 'key',
- 4 => 'default',
- 5 => 'extra'
- ];
-
- /**
- * @var Unsigned
- */
- private $unsigned;
-
- /**
- * @var Nullable
- */
- private $nullable;
-
- /**
- * @param Unsigned $unsigned
- * @param Nullable $nullable
- */
- public function __construct(Unsigned $unsigned, Nullable $nullable)
- {
- $this->unsigned = $unsigned;
- $this->nullable = $nullable;
- }
-
- /**
- * Basic type can not process any type of elements
- *
- * @param ElementInterface $element
- * @return bool
- */
- public function canBeApplied(ElementInterface $element)
- {
- return false;
- }
-
- /**
- * Column definition sequence:
- * - type
- * - padding/scale/precision
- * - unsigned
- * - nullable
- * - default
- * - identity
- * - comment
- * - after-comment
- *
- * @inheritdoc
- */
- public function toDefinition(ElementInterface $element)
- {
- throw new \LogicException("Basic processor, can`t convert any element to definition");
- }
-
- /**
- * @inheritdoc
- */
- public function fromDefinition(array $data)
- {
- $data = array_combine(array_values(self::$tokens), array_values($data));
- $data['type'] = strtolower($data['type']);
-
- $data = $this->nullable->fromDefinition($data);
-
- unset($data['key']); //we do not need key, as it will be calculated from indexes
- return $data;
- }
-}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Nullable.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Nullable.php
deleted file mode 100644
index 90ac02afb55df..0000000000000
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Nullable.php
+++ /dev/null
@@ -1,66 +0,0 @@
-isNullable() ? 'NULL' : 'NOT NULL';
- }
-
- return '';
- }
-
- /**
- * @inheritdoc
- */
- public function canBeApplied(ElementInterface $element)
- {
- return false;
- }
-
- /**
- * Convert MySQL nullable string value into boolean
- *
- * @param string $nullableValue
- * @return bool
- */
- private function processNullable($nullableValue)
- {
- return strtolower($nullableValue) === 'yes' ? true : false;
- }
-
- /**
- * @inheritdoc
- */
- public function fromDefinition(array $data)
- {
- $data['nullable'] = $this->processNullable($data['nullable']);
- return $data;
- }
-}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Text.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Text.php
deleted file mode 100644
index 22a4488c19ea0..0000000000000
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/Columns/Text.php
+++ /dev/null
@@ -1,70 +0,0 @@
-nullable = $nullable;
- }
-
- /**
- * @param \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Blob $element
- * @inheritdoc
- */
- public function toDefinition(ElementInterface $element)
- {
- return sprintf(
- '%s %s',
- $element->getType(),
- $this->nullable->toDefinition($element)
- );
- }
-
- /**
- * @inheritdoc
- */
- public function canBeApplied(ElementInterface $element)
- {
- return $element instanceof \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Text;
- }
-
- /**
- * @inheritdoc
- */
- public function fromDefinition(array $data)
- {
- $matches = [];
- if (preg_match('/^(tiny|medium|long)(text)\s*(\d+)/', $data['type'], $matches)) {
- if (isset($matches[0])) {
- $data['type'] = $matches[0] . $matches[1];
- $data['length'] = $matches[2];
- }
- }
-
- return $data;
- }
-}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/DbSchemaReader.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/DbSchemaReader.php
deleted file mode 100644
index 337123234d5a5..0000000000000
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Processors/MySQL/DbSchemaReader.php
+++ /dev/null
@@ -1,123 +0,0 @@
-resourceConnection = $resourceConnection;
- }
-
- /**
- * Prepare and fetch query: Describe {table_name}
- *
- * @param string $tableName
- * @param string $resource
- * @return array
- */
- public function readeColumns($tableName, $resource)
- {
- $adapter = $this->resourceConnection->getConnection($resource);
- $sql = 'DESCRIBE ' . $adapter->quoteIdentifier($tableName, true);
- $stmt = $adapter->query($sql);
-
- // Use FETCH_NUM so we are not dependent on the CASE attribute of the PDO connection
- return $stmt->fetchAll(\Zend_Db::FETCH_NUM);
- }
-
- /**
- * Fetch all indexes from table
- *
- * @param string $tableName
- * @param string $resource
- * @return array
- */
- public function readIndexes($tableName, $resource)
- {
- $adapter = $this->resourceConnection->getConnection($resource);
- $condition = sprintf('Non_unique = 1');
- $sql = sprintf('SHOW INDEXES FROM %s WHERE %s', $tableName, $condition);
- $stmt = $adapter->query($sql);
-
- // Use FETCH_NUM so we are not dependent on the CASE attribute of the PDO connection
- return $stmt->fetchAll(\Zend_Db::FETCH_ASSOC);
- }
-
- /**
- * As MySQL has bug and do not show foreign keys during
- * DESCRIBE and other directives we need to take it from SHOW CREATE TABLE ...
- * command
- *
- * @inheritdoc
- */
- public function readReferences($tableName, $resource)
- {
- return $this->getCreateTableSql($tableName, $resource);
- }
-
- /**
- * Retrieve Create table SQL, from SHOW CREATE TABLE query
- *
- * @param string $tableName
- * @param string $resource
- * @return array
- */
- public function getCreateTableSql($tableName, $resource)
- {
- $adapter = $this->resourceConnection->getConnection($resource);
- $sql = sprintf('SHOW CREATE TABLE %s', $tableName);
- $stmt = $adapter->query($sql);
- return $stmt->fetch(\Zend_Db::FETCH_ASSOC);
- }
-
- /**
- * For MySQL reading of constraints is almost the same as indexes
- * But we need to know, that we read 2 types of constraints:
- * primary and unique keys and this keys are always non_unique=0
- *
- * @inheritdoc
- */
- public function readConstraints($tableName, $resource)
- {
- $adapter = $this->resourceConnection->getConnection($resource);
- $condition = sprintf('Non_unique = 0');
- $sql = sprintf('SHOW INDEXES FROM %s WHERE %s', $tableName, $condition);
- $stmt = $adapter->query($sql);
-
- // Use FETCH_NUM so we are not dependent on the CASE attribute of the PDO connection
- return $stmt->fetchAll(\Zend_Db::FETCH_ASSOC);
- }
-
- /**
- * Return names of all tables from shard
- *
- * @param string $resource Shard name
- * @return array
- */
- public function readTables($resource)
- {
- return $this->resourceConnection
- ->getConnection($resource)
- ->getTables();
- }
-}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/SchemaBuilder.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/SchemaBuilder.php
index 4c2a28b90ab81..a5bcdef217e32 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/SchemaBuilder.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/SchemaBuilder.php
@@ -6,8 +6,6 @@
namespace Magento\Setup\Model\Declaration\Schema\Db;
-use Magento\Setup\Model\Declaration\Schema\Casters\CasterAggregator;
-use Magento\Setup\Model\Declaration\Schema\Db\Processors\DbSchemaReaderInterface;
use Magento\Setup\Model\Declaration\Schema\Dto\Column;
use Magento\Setup\Model\Declaration\Schema\Dto\ElementFactory;
use Magento\Setup\Model\Declaration\Schema\Dto\Schema;
@@ -27,11 +25,6 @@
*/
class SchemaBuilder
{
- /**
- * @var AdapterMediator
- */
- private $adapter;
-
/**
* @var ElementFactory
*/
@@ -48,20 +41,15 @@ class SchemaBuilder
private $sharding;
/**
- * Parser constructor.
- *
- * @param AdapterMediator $adapter
* @param ElementFactory $elementFactory
* @param DbSchemaReaderInterface $dbSchemaReader
* @param Sharding $sharding
*/
public function __construct(
- AdapterMediator $adapter,
ElementFactory $elementFactory,
DbSchemaReaderInterface $dbSchemaReader,
Sharding $sharding
) {
- $this->adapter = $adapter;
$this->elementFactory = $elementFactory;
$this->dbSchemaReader = $dbSchemaReader;
$this->sharding = $sharding;
@@ -80,9 +68,9 @@ public function build(Schema $schema)
$indexes = [];
$constraints = [];
- $columnsData = $this->adapter->getColumnsList($tableName, $resource);
- $indexesData = $this->adapter->getIndexesList($tableName, $resource);
- $constrainsData = $this->adapter->getConstraintsList($tableName, $resource);
+ $columnsData = $this->dbSchemaReader->readColumns($tableName, $resource);
+ $indexesData = $this->dbSchemaReader->readIndexes($tableName, $resource);
+ $constrainsData = $this->dbSchemaReader->readConstraints($tableName, $resource);
/**
* @var Table $table
@@ -141,7 +129,7 @@ private function processReferenceKeys(array $tables)
{
foreach ($tables as $table) {
$tableName = $table->getName();
- $referencesData = $this->adapter->getReferencesList($tableName, $table->getResource());
+ $referencesData = $this->dbSchemaReader->readReferences($tableName, $table->getResource());
$references = [];
foreach ($referencesData as $referenceData) {
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/DiffManager.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/DiffManager.php
index 071420804288b..6897d0bba3f88 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/DiffManager.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/DiffManager.php
@@ -105,7 +105,8 @@ public function registerRemoval(
$diff->register(
$generatedElement,
- $operation
+ $operation,
+ $generatedElement
);
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Constraint.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Constraint.php
index 8c734be6de342..84664cba33e91 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Constraint.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Constraint.php
@@ -28,7 +28,6 @@ class Constraint extends GenericElement implements
* @param string $name
* @param string $type
* @param Table $table
- * @param array $columns
*/
public function __construct(
string $name,
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Constraints/Reference.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Constraints/Reference.php
index 33d5830c9feff..610d3de7375f9 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Constraints/Reference.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Constraints/Reference.php
@@ -16,6 +16,12 @@
*/
class Reference extends Constraint implements ElementDiffAwareInterface
{
+ /**
+ * In case if we will need to change this object: add, modify or drop, we will need
+ * to define it by its type
+ */
+ const TYPE = 'reference';
+
/**
* @var Column
*/
@@ -99,6 +105,16 @@ public function getOnDelete()
return $this->onDelete;
}
+ /**
+ * For foreign key type always will be 'reference'
+ *
+ * @return string
+ */
+ public function getType()
+ {
+ return self::TYPE;
+ }
+
/**
* @inheritdoc
*/
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Integer.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Integer.php
index 0858906d7d1be..5e2c2672cc8b5 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Integer.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Integer.php
@@ -20,10 +20,10 @@ class Integer implements FactoryInterface
* @var array
*/
private static $defaultPadding = [
- 'integer' => '11',
- 'tinyinteger' => '2',
- 'smallinteger' => '5',
- 'biginteger' => '20'
+ 'int' => '11',
+ 'tinyint' => '2',
+ 'smallint' => '5',
+ 'bigint' => '20'
];
/**
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/AddElement.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/AddElement.php
index f9ada5284726a..7368ee98f0db7 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/AddElement.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/AddElement.php
@@ -6,7 +6,10 @@
namespace Magento\Setup\Model\Declaration\Schema\Operations;
-use Magento\Setup\Model\Declaration\Schema\Db\AdapterMediator;
+use Magento\Setup\Model\Declaration\Schema\Db\DbSchemaWriterInterface;
+use Magento\Setup\Model\Declaration\Schema\Db\DefinitionAggregator;
+use Magento\Setup\Model\Declaration\Schema\Dto\ElementInterface;
+use Magento\Setup\Model\Declaration\Schema\Dto\TableElementInterface;
use Magento\Setup\Model\Declaration\Schema\ElementHistory;
use Magento\Setup\Model\Declaration\Schema\OperationInterface;
@@ -21,16 +24,25 @@ class AddElement implements OperationInterface
const OPERATION_NAME = 'add_element';
/**
- * @var AdapterMediator
+ * @var DefinitionAggregator
*/
- private $adapterMediator;
+ private $definitionAggregator;
/**
- * @param AdapterMediator $adapterMediator
+ * @var DbSchemaWriterInterface
*/
- public function __construct(AdapterMediator $adapterMediator)
- {
- $this->adapterMediator = $adapterMediator;
+ private $dbSchemaWriter;
+
+ /**
+ * @param DefinitionAggregator $definitionAggregator
+ * @param DbSchemaWriterInterface $dbSchemaWriter
+ */
+ public function __construct(
+ DefinitionAggregator $definitionAggregator,
+ DbSchemaWriterInterface $dbSchemaWriter
+ ) {
+ $this->definitionAggregator = $definitionAggregator;
+ $this->dbSchemaWriter = $dbSchemaWriter;
}
/**
@@ -46,6 +58,21 @@ public function getOperationName()
*/
public function doOperation(ElementHistory $elementHistory)
{
- $this->adapterMediator->addElement($elementHistory->getNew());
+ /**
+ * @var TableElementInterface | ElementInterface $element
+ */
+ $element = $elementHistory->getNew();
+ $elementOptions = [
+ 'table_name' => $element->getTable()->getName(),
+ 'element_name' => $element->getName(),
+ 'resource' => $element->getTable()->getResource()
+ ];
+ $definition = $this->definitionAggregator->toDefinition($element);
+
+ $this->dbSchemaWriter->addElement(
+ $elementOptions,
+ $definition,
+ $element->getElementType()
+ );
}
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/CreateTable.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/CreateTable.php
index b7ceb7612bb4e..9328b96c26e02 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/CreateTable.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/CreateTable.php
@@ -6,7 +6,12 @@
namespace Magento\Setup\Model\Declaration\Schema\Operations;
-use Magento\Setup\Model\Declaration\Schema\Db\AdapterMediator;
+use Magento\Setup\Model\Declaration\Schema\Db\DbSchemaWriterInterface;
+use Magento\Setup\Model\Declaration\Schema\Db\DefinitionAggregator;
+use Magento\Setup\Model\Declaration\Schema\Dto\Column;
+use Magento\Setup\Model\Declaration\Schema\Dto\Constraint;
+use Magento\Setup\Model\Declaration\Schema\Dto\ElementInterface;
+use Magento\Setup\Model\Declaration\Schema\Dto\Index;
use Magento\Setup\Model\Declaration\Schema\Dto\Table;
use Magento\Setup\Model\Declaration\Schema\ElementHistory;
use Magento\Setup\Model\Declaration\Schema\OperationInterface;
@@ -22,16 +27,25 @@ class CreateTable implements OperationInterface
const OPERATION_NAME = 'create_table';
/**
- * @var AdapterMediator
+ * @var DbSchemaWriterInterface
*/
- private $adapterMediator;
+ private $dbSchemaWriter;
/**
- * @param AdapterMediator $adapterMediator
+ * @var DefinitionAggregator
*/
- public function __construct(AdapterMediator $adapterMediator)
- {
- $this->adapterMediator = $adapterMediator;
+ private $definitionAggregator;
+
+ /**
+ * @param DbSchemaWriterInterface $dbSchemaWriter
+ * @param DefinitionAggregator $definitionAggregator
+ */
+ public function __construct(
+ DbSchemaWriterInterface $dbSchemaWriter,
+ DefinitionAggregator $definitionAggregator
+ ) {
+ $this->dbSchemaWriter = $dbSchemaWriter;
+ $this->definitionAggregator = $definitionAggregator;
}
/**
@@ -49,6 +63,27 @@ public function doOperation(ElementHistory $elementHistory)
{
/** @var Table $table */
$table = $elementHistory->getNew();
- $this->adapterMediator->createTable($table);
+
+ $definition = [];
+ $tableOptions = [
+ 'resource' => $table->getResource(),
+ 'name' => $table->getName()
+ ];
+ $data = [
+ Column::TYPE => $table->getColumns(),
+ Constraint::TYPE => $table->getConstraints(),
+ Index::TYPE => $table->getIndexes()
+ ];
+
+ foreach ($data as $type => $elements) {
+ /**
+ * @var ElementInterface $element
+ */
+ foreach ($elements as $element) {
+ $definition[$type][$element->getName()] = $this->definitionAggregator->toDefinition($element);
+ }
+ }
+
+ $this->dbSchemaWriter->createTable($tableOptions, $definition);
}
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/DropElement.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/DropElement.php
index 547a116dc0698..c23073f957b24 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/DropElement.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/DropElement.php
@@ -7,6 +7,10 @@
namespace Magento\Setup\Model\Declaration\Schema\Operations;
use Magento\Setup\Model\Declaration\Schema\Db\AdapterMediator;
+use Magento\Setup\Model\Declaration\Schema\Db\DbSchemaWriterInterface;
+use Magento\Setup\Model\Declaration\Schema\Db\DefinitionAggregator;
+use Magento\Setup\Model\Declaration\Schema\Dto\ElementInterface;
+use Magento\Setup\Model\Declaration\Schema\Dto\TableElementInterface;
use Magento\Setup\Model\Declaration\Schema\ElementHistory;
use Magento\Setup\Model\Declaration\Schema\OperationInterface;
@@ -21,16 +25,25 @@ class DropElement implements OperationInterface
const OPERATION_NAME = 'drop_element';
/**
- * @var AdapterMediator
+ * @var DbSchemaWriterInterface
*/
- private $adapterMediator;
+ private $dbSchemaWriter;
/**
- * @param AdapterMediator $adapterMediator
+ * @var DefinitionAggregator
*/
- public function __construct(AdapterMediator $adapterMediator)
- {
- $this->adapterMediator = $adapterMediator;
+ private $definitionAggregator;
+
+ /**
+ * @param DbSchemaWriterInterface $dbSchemaWriter
+ * @param DefinitionAggregator $definitionAggregator
+ */
+ public function __construct(
+ DbSchemaWriterInterface $dbSchemaWriter,
+ DefinitionAggregator $definitionAggregator
+ ) {
+ $this->dbSchemaWriter = $dbSchemaWriter;
+ $this->definitionAggregator = $definitionAggregator;
}
/**
@@ -46,6 +59,20 @@ public function getOperationName()
*/
public function doOperation(ElementHistory $elementHistory)
{
- $this->adapterMediator->dropElement($elementHistory->getNew());
+ /**
+ * @var TableElementInterface | ElementInterface $element
+ */
+ $element = $elementHistory->getNew();
+ $elementOptions = [
+ 'table_name' => $element->getTable()->getName(),
+ 'element_name' => $element->getName(),
+ 'resource' => $element->getTable()->getResource(),
+ 'type' => $element->getType()
+ ];
+
+ $this->dbSchemaWriter->dropElement(
+ $element->getElementType(),
+ $elementOptions
+ );
}
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/DropTable.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/DropTable.php
index b8f080015e5e9..366f89c9fa415 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/DropTable.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/DropTable.php
@@ -6,7 +6,8 @@
namespace Magento\Setup\Model\Declaration\Schema\Operations;
-use Magento\Setup\Model\Declaration\Schema\Db\AdapterMediator;
+use Magento\Setup\Model\Declaration\Schema\Db\DbSchemaWriterInterface;
+use Magento\Setup\Model\Declaration\Schema\Db\DefinitionAggregator;
use Magento\Setup\Model\Declaration\Schema\Dto\Table;
use Magento\Setup\Model\Declaration\Schema\ElementHistory;
use Magento\Setup\Model\Declaration\Schema\OperationInterface;
@@ -22,16 +23,25 @@ class DropTable implements OperationInterface
const OPERATION_NAME = 'drop_table';
/**
- * @var AdapterMediator
+ * @var DefinitionAggregator
*/
- private $adapterMediator;
+ private $definitionAggregator;
/**
- * @param AdapterMediator $adapterMediator
+ * @var DbSchemaWriterInterface
*/
- public function __construct(AdapterMediator $adapterMediator)
- {
- $this->adapterMediator = $adapterMediator;
+ private $dbSchemaWriter;
+
+ /**
+ * @param DefinitionAggregator $definitionAggregator
+ * @param DbSchemaWriterInterface $dbSchemaWriter
+ */
+ public function __construct(
+ DefinitionAggregator $definitionAggregator,
+ DbSchemaWriterInterface $dbSchemaWriter
+ ) {
+ $this->definitionAggregator = $definitionAggregator;
+ $this->dbSchemaWriter = $dbSchemaWriter;
}
/**
@@ -47,8 +57,15 @@ public function getOperationName()
*/
public function doOperation(ElementHistory $tableHistory)
{
- /** @var Table $table */
- $table = $tableHistory->getNew();
- $this->adapterMediator->dropTable($table);
+ /**
+ * @var Table $table
+ */
+ $table = $tableHistory->getOld();
+ $tableOptions = [
+ 'name' => $table->getName(),
+ 'resource' => $table->getResource()
+ ];
+
+ $this->dbSchemaWriter->dropTable($tableOptions);
}
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/ModifyElement.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/ModifyElement.php
index febfb9037e088..f410c7e894003 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/ModifyElement.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/ModifyElement.php
@@ -7,6 +7,8 @@
namespace Magento\Setup\Model\Declaration\Schema\Operations;
use Magento\Setup\Model\Declaration\Schema\Db\AdapterMediator;
+use Magento\Setup\Model\Declaration\Schema\Db\DbSchemaWriterInterface;
+use Magento\Setup\Model\Declaration\Schema\Db\DefinitionAggregator;
use Magento\Setup\Model\Declaration\Schema\Dto\Column;
use Magento\Setup\Model\Declaration\Schema\Dto\Constraint;
use Magento\Setup\Model\Declaration\Schema\Dto\Constraints\Internal;
@@ -26,16 +28,41 @@ class ModifyElement implements OperationInterface
const OPERATION_NAME = 'modify_element';
/**
- * @var AdapterMediator
+ * @var DefinitionAggregator
*/
- private $adapterMediator;
+ private $definitionAggregator;
/**
- * @param AdapterMediator $adapterMediator
+ * @var DbSchemaWriterInterface
*/
- public function __construct(AdapterMediator $adapterMediator)
- {
- $this->adapterMediator = $adapterMediator;
+ private $dbSchemaWriter;
+
+ /**
+ * @var AddElement
+ */
+ private $addElement;
+
+ /**
+ * @var DropElement
+ */
+ private $dropElement;
+
+ /**
+ * @param DefinitionAggregator $definitionAggregator
+ * @param DbSchemaWriterInterface $dbSchemaWriter
+ * @param AddElement $addElement
+ * @param DropElement $dropElement
+ */
+ public function __construct(
+ DefinitionAggregator $definitionAggregator,
+ DbSchemaWriterInterface $dbSchemaWriter,
+ AddElement $addElement,
+ DropElement $dropElement
+ ) {
+ $this->definitionAggregator = $definitionAggregator;
+ $this->dbSchemaWriter = $dbSchemaWriter;
+ $this->addElement = $addElement;
+ $this->dropElement = $dropElement;
}
/**
@@ -46,6 +73,48 @@ public function getOperationName()
return self::OPERATION_NAME;
}
+ /**
+ * Modify constraint (PRIMARY, UNIQUE, FOREIGN keys) definition for existing table
+ *
+ * @param Constraint $constraint
+ */
+ private function modifyConstraint(Constraint $constraint)
+ {
+ $constraintOptions = [
+ 'table_name' => $constraint->getTable()->getName(),
+ 'element_name' => $constraint->getName(),
+ 'resource' => $constraint->getTable()->getResource(),
+ 'type' => $constraint->getType()
+ ];
+ $definition = $this->definitionAggregator->toDefinition($constraint);
+
+ $this->dbSchemaWriter->modifyConstraint(
+ $constraintOptions,
+ $definition
+ );
+ }
+
+
+ /**
+ * Modify column definition for existing table
+ *
+ * @param Column $column
+ */
+ private function modifyColumn(Column $column)
+ {
+ $columnOptions = [
+ 'table_name' => $column->getTable()->getName(),
+ 'element_name' => $column->getName(),
+ 'resource' => $column->getTable()->getResource()
+ ];
+ $definition = $this->definitionAggregator->toDefinition($column);
+
+ $this->dbSchemaWriter->modifyColumn(
+ $columnOptions,
+ $definition
+ );
+ }
+
/**
* As constraints and indexes do not have modify operation, we need to substitute it
* with remove/create operaions
@@ -57,13 +126,12 @@ public function doOperation(ElementHistory $elementHistory)
$element = $elementHistory->getNew();
if ($element instanceof Internal) {
- $this->adapterMediator->modifyConstraint($element);
+ $this->modifyConstraint($element);
} else if ($element instanceof Index || $element instanceof Reference) {
- $this->adapterMediator->dropElement($element);
- $this->adapterMediator->addElement($element);
- } else {
- /** @var Column $element */
- $this->adapterMediator->modifyColumn($element);
+ $this->dropElement->doOperation($elementHistory);
+ $this->addElement->doOperation($elementHistory);
+ } else if ($element instanceof Column) {
+ $this->modifyColumn($element);
}
}
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/ReCreateTable.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/ReCreateTable.php
index 15d69075f2ea9..e136c76df70cf 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/ReCreateTable.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/ReCreateTable.php
@@ -6,8 +6,6 @@
namespace Magento\Setup\Model\Declaration\Schema\Operations;
-use Magento\Setup\Model\Declaration\Schema\Db\AdapterMediator;
-use Magento\Setup\Model\Declaration\Schema\Dto\Table;
use Magento\Setup\Model\Declaration\Schema\ElementHistory;
use Magento\Setup\Model\Declaration\Schema\OperationInterface;
@@ -22,16 +20,23 @@ class ReCreateTable implements OperationInterface
const OPERATION_NAME = 'recreate_table';
/**
- * @var AdapterMediator
+ * @var CreateTable
*/
- private $adapterMediator;
+ private $createTable;
/**
- * @param AdapterMediator $adapterMediator
+ * @var DropTable
*/
- public function __construct(AdapterMediator $adapterMediator)
+ private $dropTable;
+
+ /**
+ * @param CreateTable $createTable
+ * @param DropTable $dropTable
+ */
+ public function __construct(CreateTable $createTable, DropTable $dropTable)
{
- $this->adapterMediator = $adapterMediator;
+ $this->createTable = $createTable;
+ $this->dropTable = $dropTable;
}
/**
@@ -47,11 +52,7 @@ public function getOperationName()
*/
public function doOperation(ElementHistory $elementHistory)
{
- /** @var Table $table */
- $table = $elementHistory->getNew();
- /** @var Table $oldTable */
- $oldTable = $elementHistory->getOld();
- $this->adapterMediator->dropTable($oldTable);
- $this->adapterMediator->createTable($table);
+ $this->dropTable->doOperation($elementHistory);
+ $this->createTable->doOperation($elementHistory);
}
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/integers/biginteger.xsd b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/integers/biginteger.xsd
index 46671d1a49b43..186779afb5382 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/integers/biginteger.xsd
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/integers/biginteger.xsd
@@ -8,9 +8,9 @@
-
+
-
+
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/integers/integer.xsd b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/integers/integer.xsd
index 54c694c2d8ff2..3ca4992ca5e84 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/integers/integer.xsd
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/integers/integer.xsd
@@ -8,7 +8,7 @@
-
+
Serves needs in integer digits. Default padding is 11.
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/integers/smallinteger.xsd b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/integers/smallinteger.xsd
index c12308a4d276d..7c77d738f9b68 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/integers/smallinteger.xsd
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/integers/smallinteger.xsd
@@ -8,7 +8,7 @@
-
+
Serves needs in integer digits. Default padding is 5.
@@ -17,7 +17,7 @@
-
+
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/integers/tinyinteger.xsd b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/integers/tinyinteger.xsd
index eb7cb676cd6af..e35d4b27921ec 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/integers/tinyinteger.xsd
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/integers/tinyinteger.xsd
@@ -8,9 +8,9 @@
-
+
-
+
From b62d36007dd7659aaeec04258833e127a8c0e05f Mon Sep 17 00:00:00 2001
From: Sergii Kovalenko
Date: Wed, 27 Dec 2017 18:03:02 +0200
Subject: [PATCH 248/904] MAGETWO-84100: Unify Magento SQL adapters
--refactor dbSchemaWriter
---
.../Schema/Db/DbSchemaWriterInterface.php | 43 +++---
.../Schema/Db/MySQL/DbSchemaWriter.php | 125 +++++-------------
.../Declaration/Schema/Dto/Constraint.php | 10 ++
.../Schema/Operations/AddElement.php | 9 +-
.../Schema/Operations/CreateTable.php | 7 +-
.../Schema/Operations/DropElement.php | 12 +-
.../Schema/Operations/DropTable.php | 7 +-
.../Schema/Operations/ModifyElement.php | 24 ++--
8 files changed, 88 insertions(+), 149 deletions(-)
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/DbSchemaWriterInterface.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/DbSchemaWriterInterface.php
index 87286e6d136cd..c16f0bb254380 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/DbSchemaWriterInterface.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/DbSchemaWriterInterface.php
@@ -15,59 +15,70 @@ interface DbSchemaWriterInterface
/**
* Create table from SQL fragments, like columns, constraints, foreign keys, indexes, etc
*
- * @param array $tableOptions
+ * @param $tableName
+ * @param $resource
* @param array $definition
* @return void
*/
- public function createTable(array $tableOptions, array $definition);
+ public function createTable($tableName, $resource, array $definition);
/**
* Drop table from SQL database
*
- * @param array $tableOptions must have 2 options: table_name, resource
+ * @param string $tableName
+ * @param string $resource
* @return mixed
*/
- public function dropTable(array $tableOptions);
+ public function dropTable($tableName, $resource);
/**
* Add generic element to table (table must be specified in elementOptions)
*
* Can be: column, constraint, index
*
- * @param array $elementOptions must have 3 options: resource, column_name, table_name
- * @param string $elementDefinition, for example: like CHAR(200) NOT NULL
- * @param string $elementType
+ * @param string $elementName
+ * @param string $resource
+ * @param string $tableName
+ * @param string $elementDefinition , for example: like CHAR(200) NOT NULL
+ * @param string $elementType
* @return mixed
*/
- public function addElement(array $elementOptions, $elementDefinition, $elementType);
+ public function addElement($elementName, $resource, $tableName, $elementDefinition, $elementType);
/**
* Modify column and change it definition
*
* Please note: that from all structural elements only column can be modified
*
- * @param array $columnOptions must have 3 options: resource, column_name, table_name
+ * @param $resource
+ * @param $columnName
+ * @param $tableName
* @param string $columnDefinition
* @return void
*/
- public function modifyColumn(array $columnOptions, $columnDefinition);
+ public function modifyColumn($resource, $columnName, $tableName, $columnDefinition);
/**
* As we can`t just drop and recreate constraint in 2 requests
* we need to do this in one request
*
- * @param array $constraintOptions
- * @param string $constraintDefinition
+ * @param string $resource
+ * @param string $elementName
+ * @param string $tableName
+ * @param string $type
+ * @param string $constraintDefinition
* @return void
*/
- public function modifyConstraint(array $constraintOptions, $constraintDefinition);
+ public function modifyConstraint($resource, $elementName, $tableName, $type, $constraintDefinition);
/**
* Drop any element (constraint, column, index) from index
*
- * @param string $elementType enum(CONSTRAINT, INDEX, COLUMN)
- * @param array $elementOptions
+ * @param string $resource
+ * @param string $elementName
+ * @param string $tableName
+ * @param string $type
* @return \Zend_Db_Statement_Interface
*/
- public function dropElement($elementType, array $elementOptions);
+ public function dropElement($resource, $elementName, $tableName, $type);
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/DbSchemaWriter.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/DbSchemaWriter.php
index 2a07a891e523c..59b617211536c 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/DbSchemaWriter.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/DbSchemaWriter.php
@@ -9,11 +9,10 @@
use Magento\Framework\App\ResourceConnection;
use Magento\Framework\DB\Adapter\AdapterInterface;
use Magento\Setup\Model\Declaration\Schema\Db\DbSchemaWriterInterface;
-use Magento\Setup\Model\Declaration\Schema\Db\MySQL\Definition\Constraints\ForeignKey;
use Magento\Setup\Model\Declaration\Schema\Db\MySQL\Definition\Constraints\Internal;
-use Magento\Setup\Model\Declaration\Schema\Db\MySQL\Definition\Index;
use Magento\Setup\Model\Declaration\Schema\Dto\Column;
use Magento\Setup\Model\Declaration\Schema\Dto\Constraint;
+use Magento\Setup\Model\Declaration\Schema\Dto\Constraints\Reference;
/**
* @inheritdoc
@@ -72,15 +71,12 @@ private function getColumnsWithNames(array $columnsDefinition, AdapterInterface
/**
* @inheritdoc
- * @param array $tableOptions
- * @param array $definition
* @return \Zend_Db_Statement_Interface
*/
- public function createTable(array $tableOptions, array $definition)
+ public function createTable($tableName, $resource, array $definition)
{
- $connection = $tableOptions['resource'];
$fragmentsSQL = [];
- $adapter = $this->resourceConnection->getConnection($connection);
+ $adapter = $this->resourceConnection->getConnection($resource);
foreach ([Constraint::TYPE, \Magento\Setup\Model\Declaration\Schema\Dto\Index::TYPE] as $elementType) {
if (isset($definition[$elementType])) { //Some element types can be optional
@@ -98,7 +94,7 @@ public function createTable(array $tableOptions, array $definition)
$sql = sprintf(
"CREATE TABLE %s (\n%s,\n%s\n)",
- $adapter->quoteIdentifier($tableOptions['name']),
+ $adapter->quoteIdentifier($tableName),
implode(", \n", $this->getColumnsWithNames($definition[Column::TYPE], $adapter)),
implode(", \n", $fragmentsSQL)
);
@@ -109,14 +105,12 @@ public function createTable(array $tableOptions, array $definition)
/**
* Drop table from MySQL database
*
- * @param array $tableOptions
+ * @inheritdoc
* @return \Zend_Db_Statement_Interface
*/
- public function dropTable(array $tableOptions)
+ public function dropTable($tableName, $resource)
{
- $connection = $tableOptions['resource'];
- $tableName = $tableOptions['name'];
- $adapter = $this->resourceConnection->getConnection($connection);
+ $adapter = $this->resourceConnection->getConnection($resource);
$sql = sprintf(
'DROP TABLE %s',
@@ -129,43 +123,38 @@ public function dropTable(array $tableOptions)
/**
* For Primary key we do not need to specify name
*
- * @param string $elementType
+ * As MySQL do not have DROP CONSTRAINT syntax, we need different DROP statements for different operations
+ *
* @param string $type
* @param string $name
* @return string
*/
- private function getDropElementSQL($elementType, $type, $name)
+ private function getDropElementSQL($type, $name)
{
- if ($elementType === Constraint::TYPE) {
- if ($type === 'primary') {
+ switch ($type) {
+ case Constraint::PRIMARY_TYPE:
return 'DROP PRIMARY KEY';
- }
-
- $elementType = $this->getConstraintType($type);
+ case Constraint::UNIQUE_TYPE:
+ return sprintf('DROP KEY %s', $name);
+ case \Magento\Setup\Model\Declaration\Schema\Dto\Index::TYPE:
+ return sprintf('DROP INDEX %s', $name);
+ case Reference::TYPE:
+ return sprintf('DROP FOREIGN KEY %s', $name);
+ default:
+ return sprintf('DROP COLUMN %s', $name);
}
-
- return sprintf(
- 'DROP %s %s',
- strtoupper($elementType),
- $name
- );
}
/**
* Add element to already existed table
* We can add three different elements: column, constraint or index
*
- * @param array $elementOptions should consists from 3 elements: resource, elementname, tablename
- * @param string $elementDefinition
- * @param string $elementType
+ * @inheritdoc
* @return \Zend_Db_Statement_Interface
*/
- public function addElement(array $elementOptions, $elementDefinition, $elementType)
+ public function addElement($elementName, $resource, $tableName, $elementDefinition, $elementType)
{
- $connection = $elementOptions['resource'];
- $elementName = $elementOptions['element_name'];
- $tableName = $elementOptions['table_name'];
- $adapter = $this->resourceConnection->getConnection($connection);
+ $adapter = $this->resourceConnection->getConnection($resource);
$sql = sprintf(
'ALTER TABLE %s %s',
@@ -183,54 +172,23 @@ public function addElement(array $elementOptions, $elementDefinition, $elementTy
/**
* Modify column and change it definition
*
- * @param array $columnOptions
- * @param string $columnDefinition
+ * @inheritdoc
* @return \Zend_Db_Statement_Interface
*/
- public function modifyColumn(array $columnOptions, $columnDefinition)
+ public function modifyColumn($resource, $columnName, $tableName, $columnDefinition)
{
- $connection = $columnOptions['resource'];
- $columName = $columnOptions['element_name'];
- $tableName = $columnOptions['table_name'];
- $adapter = $this->resourceConnection->getConnection($connection);
+ $adapter = $this->resourceConnection->getConnection($resource);
$sql = sprintf(
'ALTER TABLE %s MODIFY COLUMN %s %s',
$adapter->quoteIdentifier($tableName),
- $adapter->quoteIdentifier($columName),
+ $adapter->quoteIdentifier($columnName),
$columnDefinition
);
return $adapter->query($sql);
}
- /**
- * Detect what type of constraint we have
- *
- * @param string $type
- * @return string
- */
- private function getConstraintType($type)
- {
- switch ($type) {
- case 'reference':
- $elementType = ForeignKey::FOREIGN_KEY_NAME;
- break;
- case 'primary':
- $elementType = Internal::PRIMARY_KEY_NAME;
- break;
- case 'unique':
- case 'index':
- //In MySQL for unique and for index drop syntax is the same
- $elementType = Index::INDEX_KEY_NAME;
- break;
- default:
- $elementType = Constraint::TYPE;
- }
-
- return $elementType;
- }
-
/**
* Do Drop and Add in one query
*
@@ -238,27 +196,20 @@ private function getConstraintType($type)
*
* @inheritdoc
*/
- public function modifyConstraint(array $constraintOptions, $constraintDefinition)
+ public function modifyConstraint($resource, $elementName, $tableName, $type, $constraintDefinition)
{
- $connection = $constraintOptions['resource'];
- $elementName = $constraintOptions['element_name'];
- $tableName = $constraintOptions['table_name'];
- $type = $constraintOptions['type'];
- $adapter = $this->resourceConnection->getConnection($connection);
-
+ $adapter = $this->resourceConnection->getConnection($resource);
$sql = sprintf(
'ALTER TABLE %s %s, %s',
$adapter->quoteIdentifier($tableName),
$this->getDropElementSQL(
- Constraint::TYPE,
$type,
$adapter->quoteIdentifier($elementName)
),
$this->getAddElementSQL(
Constraint::TYPE,
- //We need to ignore name for PRIMARY KEY
- $elementName === Internal::PRIMARY_NAME ?
- '' : $adapter->quoteIdentifier($elementName),
+ //We need to avoid `PRIMARY` name in modify constraint syntax
+ $elementName === Internal::PRIMARY_NAME ? '' : $adapter->quoteIdentifier($elementName),
$constraintDefinition
)
);
@@ -267,25 +218,17 @@ public function modifyConstraint(array $constraintOptions, $constraintDefinition
}
/**
- * Drop any element (constraint, column, index) from index
- *
- * @param string $elementType enum(CONSTRAINT, INDEX, COLUMN)
- * @param array $elementOptions
+ * @inheritdoc
* @return \Zend_Db_Statement_Interface
*/
- public function dropElement($elementType, array $elementOptions)
+ public function dropElement($resource, $elementName, $tableName, $type)
{
- $connection = $elementOptions['resource'];
- $elementName = $elementOptions['element_name'];
- $tableName = $elementOptions['table_name'];
- $type = $elementOptions['type'];
- $adapter = $this->resourceConnection->getConnection($connection);
+ $adapter = $this->resourceConnection->getConnection($resource);
$sql = sprintf(
'ALTER TABLE %s %s',
$adapter->quoteIdentifier($tableName),
$this->getDropElementSQL(
- $elementType,
$type,
$adapter->quoteIdentifier($elementName)
)
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Constraint.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Constraint.php
index 84664cba33e91..1f025230fa792 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Constraint.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Constraint.php
@@ -19,6 +19,16 @@ class Constraint extends GenericElement implements
*/
const TYPE = 'constraint';
+ /**
+ * Means PRIMARY KEY
+ */
+ const PRIMARY_TYPE = 'primary';
+
+ /**
+ * Means UNIQUE KEY
+ */
+ const UNIQUE_TYPE = 'unique';
+
/**
* @var Table
*/
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/AddElement.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/AddElement.php
index 7368ee98f0db7..5f0d89fe3c35e 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/AddElement.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/AddElement.php
@@ -62,15 +62,12 @@ public function doOperation(ElementHistory $elementHistory)
* @var TableElementInterface | ElementInterface $element
*/
$element = $elementHistory->getNew();
- $elementOptions = [
- 'table_name' => $element->getTable()->getName(),
- 'element_name' => $element->getName(),
- 'resource' => $element->getTable()->getResource()
- ];
$definition = $this->definitionAggregator->toDefinition($element);
$this->dbSchemaWriter->addElement(
- $elementOptions,
+ $element->getName(),
+ $element->getTable()->getResource(),
+ $element->getTable()->getName(),
$definition,
$element->getElementType()
);
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/CreateTable.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/CreateTable.php
index 9328b96c26e02..1db923dbff4e4 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/CreateTable.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/CreateTable.php
@@ -63,12 +63,7 @@ public function doOperation(ElementHistory $elementHistory)
{
/** @var Table $table */
$table = $elementHistory->getNew();
-
$definition = [];
- $tableOptions = [
- 'resource' => $table->getResource(),
- 'name' => $table->getName()
- ];
$data = [
Column::TYPE => $table->getColumns(),
Constraint::TYPE => $table->getConstraints(),
@@ -84,6 +79,6 @@ public function doOperation(ElementHistory $elementHistory)
}
}
- $this->dbSchemaWriter->createTable($tableOptions, $definition);
+ $this->dbSchemaWriter->createTable($table->getName(), $table->getResource(), $definition);
}
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/DropElement.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/DropElement.php
index c23073f957b24..f0ee8589df066 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/DropElement.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/DropElement.php
@@ -63,16 +63,12 @@ public function doOperation(ElementHistory $elementHistory)
* @var TableElementInterface | ElementInterface $element
*/
$element = $elementHistory->getNew();
- $elementOptions = [
- 'table_name' => $element->getTable()->getName(),
- 'element_name' => $element->getName(),
- 'resource' => $element->getTable()->getResource(),
- 'type' => $element->getType()
- ];
$this->dbSchemaWriter->dropElement(
- $element->getElementType(),
- $elementOptions
+ $element->getTable()->getResource(),
+ $element->getName(),
+ $element->getTable()->getName(),
+ $element->getType()
);
}
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/DropTable.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/DropTable.php
index 366f89c9fa415..569af9a6e95af 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/DropTable.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/DropTable.php
@@ -61,11 +61,6 @@ public function doOperation(ElementHistory $tableHistory)
* @var Table $table
*/
$table = $tableHistory->getOld();
- $tableOptions = [
- 'name' => $table->getName(),
- 'resource' => $table->getResource()
- ];
-
- $this->dbSchemaWriter->dropTable($tableOptions);
+ $this->dbSchemaWriter->dropTable($table->getName(), $table->getResource());
}
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/ModifyElement.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/ModifyElement.php
index f410c7e894003..83efa8a921bde 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/ModifyElement.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/ModifyElement.php
@@ -80,17 +80,12 @@ public function getOperationName()
*/
private function modifyConstraint(Constraint $constraint)
{
- $constraintOptions = [
- 'table_name' => $constraint->getTable()->getName(),
- 'element_name' => $constraint->getName(),
- 'resource' => $constraint->getTable()->getResource(),
- 'type' => $constraint->getType()
- ];
- $definition = $this->definitionAggregator->toDefinition($constraint);
-
$this->dbSchemaWriter->modifyConstraint(
- $constraintOptions,
- $definition
+ $constraint->getTable()->getResource(),
+ $constraint->getName(),
+ $constraint->getTable()->getName(),
+ $constraint->getType(),
+ $this->definitionAggregator->toDefinition($constraint)
);
}
@@ -102,15 +97,12 @@ private function modifyConstraint(Constraint $constraint)
*/
private function modifyColumn(Column $column)
{
- $columnOptions = [
- 'table_name' => $column->getTable()->getName(),
- 'element_name' => $column->getName(),
- 'resource' => $column->getTable()->getResource()
- ];
$definition = $this->definitionAggregator->toDefinition($column);
$this->dbSchemaWriter->modifyColumn(
- $columnOptions,
+ $column->getTable()->getResource(),
+ $column->getName(),
+ $column->getTable()->getName(),
$definition
);
}
From 7f90d46085fd3b711cb61f833f1e24c75a7d50b9 Mon Sep 17 00:00:00 2001
From: Sergii Kovalenko
Date: Wed, 27 Dec 2017 18:05:13 +0200
Subject: [PATCH 249/904] MAGETWO-84100: Unify Magento SQL adapters
--refactor dbSchemaWriter
---
lib/internal/Magento/Framework/Component/ComponentRegistrar.php | 2 --
1 file changed, 2 deletions(-)
diff --git a/lib/internal/Magento/Framework/Component/ComponentRegistrar.php b/lib/internal/Magento/Framework/Component/ComponentRegistrar.php
index 0e1940d55c02b..0e85cf5260e9b 100644
--- a/lib/internal/Magento/Framework/Component/ComponentRegistrar.php
+++ b/lib/internal/Magento/Framework/Component/ComponentRegistrar.php
@@ -44,8 +44,6 @@ class ComponentRegistrar implements ComponentRegistrarInterface
*/
public static function register($type, $componentName, $path)
{
- $path = str_replace("magento2ee", "magento2ce", $path);
- $path = str_replace("magento2b2b", "magento2ce", $path);
self::validateType($type);
if (isset(self::$paths[$type][$componentName])) {
throw new \LogicException(
From 88ab84dcc336335ce331fb5f9ad8f30bef013991 Mon Sep 17 00:00:00 2001
From: Sergii Kovalenko
Date: Fri, 29 Dec 2017 13:20:32 +0200
Subject: [PATCH 250/904] MAGETWO-85326: Tool for generating schema
---
app/etc/di.xml | 26 ++
.../Framework/DB/Adapter/Pdo/Mysql.php | 54 +++
.../Schema/etc/types/binaries/blob.xsd | 1 +
.../Schema/etc/types/binaries/longblob.xsd | 1 +
.../Schema/etc/types/binaries/mediumblob.xsd | 1 +
.../Schema/etc/types/datetime/default.xsd | 3 +-
.../Schema/etc/types/texts/longtext.xsd | 1 +
.../Schema/etc/types/texts/mediumtext.xsd | 1 +
.../Schema/etc/types/texts/text.xsd | 1 +
setup/src/Magento/Setup/Model/Installer.php | 18 +
.../Magento/Setup/Model/SchemaListener.php | 339 ++++++++++++++++++
.../BooleanDefinition.php | 26 ++
.../DateDefinition.php | 24 ++
.../DecimalDefinition.php | 41 +++
.../DefinitionConverterInterface.php | 21 ++
.../IntegerDefinition.php | 42 +++
.../TextBlobDefinition.php | 80 +++++
.../TimestampDefinition.php | 46 +++
.../Magento/Setup/Model/SchemaPersistor.php | 170 +++++++++
19 files changed, 895 insertions(+), 1 deletion(-)
create mode 100644 setup/src/Magento/Setup/Model/SchemaListener.php
create mode 100644 setup/src/Magento/Setup/Model/SchemaListenerDefinition/BooleanDefinition.php
create mode 100644 setup/src/Magento/Setup/Model/SchemaListenerDefinition/DateDefinition.php
create mode 100644 setup/src/Magento/Setup/Model/SchemaListenerDefinition/DecimalDefinition.php
create mode 100644 setup/src/Magento/Setup/Model/SchemaListenerDefinition/DefinitionConverterInterface.php
create mode 100644 setup/src/Magento/Setup/Model/SchemaListenerDefinition/IntegerDefinition.php
create mode 100644 setup/src/Magento/Setup/Model/SchemaListenerDefinition/TextBlobDefinition.php
create mode 100644 setup/src/Magento/Setup/Model/SchemaListenerDefinition/TimestampDefinition.php
create mode 100644 setup/src/Magento/Setup/Model/SchemaPersistor.php
diff --git a/app/etc/di.xml b/app/etc/di.xml
index 8a1f65192e76d..a37878870dc52 100755
--- a/app/etc/di.xml
+++ b/app/etc/di.xml
@@ -1443,4 +1443,30 @@
+
+
+
+ - Magento\Setup\Model\SchemaListenerDefinition\IntegerDefinition
+ - Magento\Setup\Model\SchemaListenerDefinition\IntegerDefinition
+ - Magento\Setup\Model\SchemaListenerDefinition\IntegerDefinition
+ - Magento\Setup\Model\SchemaListenerDefinition\IntegerDefinition
+ - Magento\Setup\Model\SchemaListenerDefinition\IntegerDefinition
+ - Magento\Setup\Model\SchemaListenerDefinition\DecimalDefinition
+ - Magento\Setup\Model\SchemaListenerDefinition\DecimalDefinition
+ - Magento\Setup\Model\SchemaListenerDefinition\DecimalDefinition
+ - Magento\Setup\Model\SchemaListenerDefinition\TextBlobDefinition
+ - Magento\Setup\Model\SchemaListenerDefinition\TextBlobDefinition
+ - Magento\Setup\Model\SchemaListenerDefinition\TextBlobDefinition
+ - Magento\Setup\Model\SchemaListenerDefinition\TextBlobDefinition
+ - Magento\Setup\Model\SchemaListenerDefinition\TextBlobDefinition
+ - Magento\Setup\Model\SchemaListenerDefinition\TextBlobDefinition
+ - Magento\Setup\Model\SchemaListenerDefinition\TextBlobDefinition
+ - Magento\Setup\Model\SchemaListenerDefinition\TextBlobDefinition
+ - Magento\Setup\Model\SchemaListenerDefinition\TimestampDefinition
+ - Magento\Setup\Model\SchemaListenerDefinition\TimestampDefinition
+ - Magento\Setup\Model\SchemaListenerDefinition\DateDefinition
+ - Magento\Setup\Model\SchemaListenerDefinition\BooleanDefinition
+
+
+
diff --git a/lib/internal/Magento/Framework/DB/Adapter/Pdo/Mysql.php b/lib/internal/Magento/Framework/DB/Adapter/Pdo/Mysql.php
index 2e5d38f2c6212..9f70bc8aa44cb 100644
--- a/lib/internal/Magento/Framework/DB/Adapter/Pdo/Mysql.php
+++ b/lib/internal/Magento/Framework/DB/Adapter/Pdo/Mysql.php
@@ -25,6 +25,7 @@
use Magento\Framework\Serialize\SerializerInterface;
use Magento\Framework\Stdlib\DateTime;
use Magento\Framework\Stdlib\StringUtils;
+use Magento\Setup\Model\SchemaListener;
// @codingStandardsIgnoreStart
@@ -216,6 +217,11 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements AdapterInterface
*/
private $serializer;
+ /**
+ * @var SchemaListener
+ */
+ private $schemaListener;
+
/**
* Constructor
*
@@ -223,6 +229,7 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements AdapterInterface
* @param DateTime $dateTime
* @param LoggerInterface $logger
* @param SelectFactory $selectFactory
+ * @param SchemaListener $schemaListener
* @param array $config
* @param SerializerInterface|null $serializer
*/
@@ -231,6 +238,7 @@ public function __construct(
DateTime $dateTime,
LoggerInterface $logger,
SelectFactory $selectFactory,
+ SchemaListener $schemaListener,
array $config = [],
SerializerInterface $serializer = null
) {
@@ -256,6 +264,7 @@ public function __construct(
} catch (\Zend_Db_Adapter_Exception $e) {
throw new \InvalidArgumentException($e->getMessage(), $e->getCode(), $e);
}
+ $this->schemaListener = $schemaListener;
}
/**
@@ -827,6 +836,7 @@ protected function _splitMultiQuery($sql)
*/
public function dropForeignKey($tableName, $fkName, $schemaName = null)
{
+ $this->schemaListener->dropForeignKey($tableName, $fkName);
$foreignKeys = $this->getForeignKeys($tableName, $schemaName);
$fkName = strtoupper($fkName);
if (substr($fkName, 0, 3) == 'FK_') {
@@ -911,6 +921,17 @@ public function tableColumnExists($tableName, $columnName, $schemaName = null)
return false;
}
+ /**
+ * Set schema listener that is used in adapter
+ *
+ * @param SchemaListener $schemaListener
+ * @return void
+ */
+ public function setSchemaListener(SchemaListener $schemaListener)
+ {
+ $this->schemaListener = $schemaListener;
+ }
+
/**
* Adds new column to table.
*
@@ -927,6 +948,7 @@ public function tableColumnExists($tableName, $columnName, $schemaName = null)
*/
public function addColumn($tableName, $columnName, $definition, $schemaName = null)
{
+ $this->schemaListener->addColumn($tableName, $columnName, $definition);
if ($this->tableColumnExists($tableName, $columnName, $schemaName)) {
return true;
}
@@ -1046,6 +1068,11 @@ public function changeColumn(
$flushData = false,
$schemaName = null
) {
+ $this->schemaListener->changeColumn($tableName,
+ $oldColumnName,
+ $newColumnName,
+ $definition
+ );
if (!$this->tableColumnExists($tableName, $oldColumnName, $schemaName)) {
throw new \Zend_Db_Exception(
sprintf(
@@ -1091,6 +1118,9 @@ public function changeColumn(
*/
public function modifyColumn($tableName, $columnName, $definition, $flushData = false, $schemaName = null)
{
+ $this->schemaListener->modifyColumn(
+ $tableName, $columnName, $definition
+ );
if (!$this->tableColumnExists($tableName, $columnName, $schemaName)) {
throw new \Zend_Db_Exception(sprintf('Column "%s" does not exist in table "%s".', $columnName, $tableName));
}
@@ -2052,6 +2082,7 @@ public function newTable($tableName = null, $schemaName = null)
*/
public function createTable(Table $table)
{
+ $this->schemaListener->createTable($table);
$columns = $table->getColumns();
foreach ($columns as $columnEntry) {
if (empty($columnEntry['COMMENT'])) {
@@ -2599,6 +2630,12 @@ public function addIndex(
$indexType = AdapterInterface::INDEX_TYPE_INDEX,
$schemaName = null
) {
+ $this->schemaListener->addIndex(
+ $tableName,
+ $indexName,
+ $fields,
+ $indexType
+ );
$columns = $this->describeTable($tableName, $schemaName);
$keyList = $this->getIndexList($tableName, $schemaName);
@@ -2747,11 +2784,28 @@ public function addForeignKey(
$query .= ' ON DELETE ' . strtoupper($onDelete);
}
+ $this->schemaListener->addForeignKey(
+ $fkName,
+ $tableName,
+ $columnName,
+ $refTableName,
+ $refColumnName,
+ $onDelete
+ );
+
$result = $this->rawQuery($query);
$this->resetDdlCache($tableName);
return $result;
}
+ /**
+ * @return SchemaListener
+ */
+ public function getSchemaListener()
+ {
+ return $this->schemaListener;
+ }
+
/**
* Format Date to internal database date format
*
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/binaries/blob.xsd b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/binaries/blob.xsd
index 4b0e77baedb4a..ecb08869ed3df 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/binaries/blob.xsd
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/binaries/blob.xsd
@@ -16,5 +16,6 @@
+
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/binaries/longblob.xsd b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/binaries/longblob.xsd
index 364118d9c4a9e..e23677467db17 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/binaries/longblob.xsd
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/binaries/longblob.xsd
@@ -17,5 +17,6 @@
+
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/binaries/mediumblob.xsd b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/binaries/mediumblob.xsd
index 5818a2744bd32..2a693a7c0b131 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/binaries/mediumblob.xsd
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/binaries/mediumblob.xsd
@@ -16,5 +16,6 @@
+
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/datetime/default.xsd b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/datetime/default.xsd
index 89fdef3e78fb7..f541d5a3912c4 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/datetime/default.xsd
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/datetime/default.xsd
@@ -13,6 +13,7 @@
+
@@ -44,7 +45,7 @@
- In this case timestamp column will not have any value at all by default
+ In this case timestamp column will not have any value at all by default. And become
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/texts/longtext.xsd b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/texts/longtext.xsd
index c0f4743824e3d..31980b8b0ea93 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/texts/longtext.xsd
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/texts/longtext.xsd
@@ -16,5 +16,6 @@
+
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/texts/mediumtext.xsd b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/texts/mediumtext.xsd
index e925a18542409..aeab7b633ee9a 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/texts/mediumtext.xsd
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/texts/mediumtext.xsd
@@ -17,5 +17,6 @@
+
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/texts/text.xsd b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/texts/text.xsd
index 9c1682dde836f..9e2aa1c536ea5 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/texts/text.xsd
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/texts/text.xsd
@@ -17,5 +17,6 @@
+
diff --git a/setup/src/Magento/Setup/Model/Installer.php b/setup/src/Magento/Setup/Model/Installer.php
index 60f3f7c752b62..44f47e19000f1 100644
--- a/setup/src/Magento/Setup/Model/Installer.php
+++ b/setup/src/Magento/Setup/Model/Installer.php
@@ -33,6 +33,7 @@
use Magento\Setup\Console\Command\InstallCommand;
use Magento\Setup\Controller\ResponseTypeInterface;
use Magento\Setup\Model\ConfigModel as SetupConfigModel;
+use Magento\Setup\Model\Declaration\Schema\Config\SchemaLocator;
use Magento\Setup\Module\ConnectionFactory;
use Magento\Setup\Module\DataSetupFactory;
use Magento\Setup\Module\Setup;
@@ -224,6 +225,16 @@ class Installer
*/
private $phpReadinessCheck;
+ /**
+ * @var SchemaListener
+ */
+ private $schemaListener;
+
+ /**
+ * @var SchemaPersistor
+ */
+ private $schemaPersistor;
+
/**
* Constructor
*
@@ -287,6 +298,8 @@ public function __construct(
$this->installInfo[self::INFO_MESSAGE] = [];
$this->deploymentConfig = $deploymentConfig;
$this->objectManagerProvider = $objectManagerProvider;
+ $this->schemaListener = $objectManagerProvider->get()->get(SchemaListener::class);
+ $this->schemaPersistor = $objectManagerProvider->get()->get(SchemaPersistor::class);
$this->context = $context;
$this->setupConfigModel = $setupConfigModel;
$this->cleanupFiles = $cleanupFiles;
@@ -845,6 +858,8 @@ private function handleDBSchemaData($setup, $type)
if (!(($type === 'schema') || ($type === 'data'))) {
throw new \Magento\Setup\Exception("Unsupported operation type $type is requested");
}
+ $setup->getConnection()
+ ->setSchemaListener($this->schemaListener);
$resource = new \Magento\Framework\Module\ModuleResource($this->context);
$verType = $type . '-version';
$installType = $type . '-install';
@@ -852,6 +867,7 @@ private function handleDBSchemaData($setup, $type)
$moduleNames = $this->moduleList->getNames();
$moduleContextList = $this->generateListOfModuleContext($resource, $verType);
foreach ($moduleNames as $moduleName) {
+ $this->schemaListener->setModuleName($moduleName);
$this->log->log("Module '{$moduleName}':");
$configVer = $this->moduleList->getOne($moduleName)['setup_version'];
$currentVersion = $moduleContextList[$moduleName]->getVersion();
@@ -906,6 +922,8 @@ private function handleDBSchemaData($setup, $type)
}
$this->logProgress();
}
+
+ $this->schemaPersistor->persist($this->schemaListener);
}
/**
diff --git a/setup/src/Magento/Setup/Model/SchemaListener.php b/setup/src/Magento/Setup/Model/SchemaListener.php
new file mode 100644
index 0000000000000..0710e34405f5d
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/SchemaListener.php
@@ -0,0 +1,339 @@
+ 'type',
+ 'COLUMN_NAME' => 'name',
+ 'TYPE' => 'type',
+ 'DEFAULT' => 'default',
+ 'NULLABLE' => 'nullable',
+ 'LENGTH' => 'length',
+ 'PRECISION' => 'precision',
+ 'SCALE' => 'scale',
+ 'UNSIGNED' => 'unsigned',
+ 'IDENTITY' => 'identity',
+ 'PRIMARY' => 'primary'
+ ];
+
+ /**
+ * @var array
+ */
+ private static $toUnset = [
+ 'COLUMN_POSITION',
+ 'COLUMN_TYPE',
+ 'PRIMARY_POSITION',
+ 'COMMENT'
+ ];
+
+ /**
+ * @var string
+ */
+ private $moduleName = '';
+
+ /**
+ * @var DefinitionConverterInterface[]
+ */
+ private $definitionMappers;
+
+ /**
+ * @param array $definitionMappers
+ */
+ public function __construct(array $definitionMappers)
+ {
+ $this->definitionMappers = $definitionMappers;
+ }
+
+ /**
+ * @param string $tableName
+ * @param string $fkName
+ */
+ public function dropForeignKey($tableName, $fkName)
+ {
+ $this->tables[$this->moduleName][$tableName]['constraints']['foreign'][$fkName] = ['disabled' => 1];
+ }
+
+ /**
+ * @param array $definition
+ * @param string $columnName
+ * @return array
+ */
+ private function castColumnDefinition($definition, $columnName)
+ {
+ if (is_string($definition)) {
+ $definition = ['type' => $definition];
+ }
+ $definition = $this->doColumnMapping($definition);
+ $definition['name'] = $columnName;
+ $definition = $this->definitionMappers[$definition['type']]->convertToDefinition($definition);
+ if (isset($definition['default']) && $definition['default'] === false) {
+ $definition['default'] = null; //uniform default values
+ }
+
+ return $definition;
+ }
+
+ /**
+ * @param string $tableName
+ * @param string $columnName
+ * @param array $definition
+ * @return array
+ */
+ private function addPrimaryKeyIfExists($tableName, $columnName, $definition)
+ {
+ if (isset($definition['primary'])) {
+ if (isset($this->tables[$this->moduleName][$tableName]['constraints']['primary'])) {
+ $this->tables[$this->moduleName][$tableName]['constraints']['primary']['PRIMARY'] = array_replace_recursive(
+ $this->tables[$this->moduleName][$tableName]['constraints']['primary']['PRIMARY'],
+ [
+ 'columns' => [strtolower($columnName)]
+ ]
+ );
+
+ } else {
+ $this->tables[$this->moduleName][$tableName]['constraints']['primary']['PRIMARY'] = [
+ 'type' => 'primary',
+ 'name' => 'PRIMARY',
+ 'columns' => [strtolower($columnName)]
+ ];
+ }
+ }
+
+ unset($definition['primary']);
+ return $definition;
+ }
+
+ /**
+ * Process definition to not specific format
+ *
+ * @param array $definition
+ * @return array
+ */
+ private function doColumnMapping(array $definition)
+ {
+ foreach ($definition as $key => $keyValue) {
+ if (isset(self::$mapping[$key])) {
+ $definition[self::$mapping[$key]] = $keyValue;
+ unset($definition[$key]);
+ }
+
+ if (in_array($key, self::$toUnset)) {
+ unset($definition[$key]);
+ }
+ }
+
+ return $definition;
+ }
+
+ /**
+ * @param string $tableName
+ * @param string $columnName
+ * @param array $definition
+ */
+ public function addColumn($tableName, $columnName, $definition)
+ {
+ $definition = $this->castColumnDefinition($definition, $columnName);
+ $definition = $this->addPrimaryKeyIfExists($tableName, $columnName, $definition);
+ $this->tables[$this->moduleName][strtolower($tableName)]['columns'][strtolower($columnName)] = $definition;
+ }
+
+ /**
+ * @param string $tableName
+ * @param string $oldColumnName
+ * @param string $newColumnName
+ * @param array $definition
+ */
+ public function changeColumn($tableName, $oldColumnName, $newColumnName, $definition)
+ {
+ $this->addColumn($tableName, $newColumnName, $definition);
+ $this->tables[$this->moduleName][$tableName]['columns'][strtolower($oldColumnName)] = [
+ 'disabled' => 1
+ ];
+ //remove old column if not equal
+ }
+
+ /**
+ * @param string $tableName
+ * @param string $columnName
+ * @param array $definition
+ */
+ public function modifyColumn($tableName, $columnName, $definition)
+ {
+ $this->addColumn($tableName, $columnName, $definition);
+ }
+
+ /**
+ * @param string $fkName
+ * @param string $tableName
+ * @param string $columnName
+ * @param string $refTableName
+ * @param string $refColumnName
+ * @param string $onDelete
+ */
+ public function addForeignKey(
+ $fkName,
+ $tableName,
+ $columnName,
+ $refTableName,
+ $refColumnName,
+ $onDelete = AdapterInterface::FK_ACTION_CASCADE
+ ) {
+ $this->tables[$this->moduleName][strtolower($tableName)]['constraints']['foreign'][$fkName] =
+ [
+ 'table' => strtolower($tableName),
+ 'column' => strtolower($columnName),
+ 'referenceTable' => strtolower($refTableName),
+ 'referenceColumn' => strtolower($refColumnName),
+ 'onDelete' => $onDelete
+ ];
+ }
+
+ /**
+ * Strtolower all index columns
+ *
+ * @param array $indexColumns
+ * @return array
+ */
+ private function prepareIndexColumns(array $indexColumns)
+ {
+ $columnNames = [];
+
+ foreach ($indexColumns as $key => $indexColumn) {
+ if (is_array($indexColumn)) {
+ $columnNames[] = strtolower($key);
+ } else {
+ $columnNames[] = $indexColumn;
+ }
+ }
+
+ return $columnNames;
+ }
+
+ /**
+ * @param string $tableName
+ * @param string $indexName
+ * @param array $fields
+ * @param string $indexType
+ */
+ public function addIndex(
+ $tableName,
+ $indexName,
+ $fields,
+ $indexType = AdapterInterface::INDEX_TYPE_INDEX
+ ) {
+ if (!is_array($fields)) {
+ $fields = [$fields];
+ }
+ if ($indexType == AdapterInterface::INDEX_TYPE_FULLTEXT || $indexType === AdapterInterface::INDEX_TYPE_INDEX) {
+ if ($indexType === AdapterInterface::INDEX_TYPE_INDEX) {
+ $indexType = 'btree';
+ }
+ $this->tables[$this->moduleName][$tableName]['indexes'][$indexName] =
+ ['columns' => $this->prepareIndexColumns($fields), 'type' => $indexType];
+ } else {
+ $this->tables[$this->moduleName][$tableName]['constraints'][$indexType][$indexName] =
+ ['columns' => $this->prepareIndexColumns($fields)];
+ }
+ }
+
+ /**
+ * Prepare table columns to registration
+ *
+ * @param string $tableName
+ * @param array $tableColumns
+ */
+ private function prepareColumns($tableName, array $tableColumns)
+ {
+ foreach ($tableColumns as $name => $tableColumn) {
+ $this->addColumn($tableName, $name, $tableColumn);
+ }
+ }
+
+ /**
+ * Convert constraints from old format to new one
+ *
+ * @param array $foreignKeys
+ * @param array $indexes
+ * @param string $tableName
+ */
+ private function prepareConstraintsAndIndexes(array $foreignKeys, array $indexes, $tableName)
+ {
+ //Process foreign keys
+ foreach ($foreignKeys as $name => $foreignKey) {
+ $this->addForeignKey(
+ $name,
+ $tableName,
+ $foreignKey['COLUMN_NAME'],
+ $foreignKey['REF_TABLE_NAME'],
+ $foreignKey['REF_COLUMN_NAME'],
+ $foreignKey['ON_DELETE']
+ );
+ }
+ //Process indexes
+ foreach ($indexes as $name => $index) {
+ $this->addIndex(
+ $tableName,
+ $name,
+ $index['COLUMNS'],
+ $index['TYPE']
+ );
+ }
+ }
+
+ /**
+ * Create table
+ *
+ * @param Table $table
+ */
+ public function createTable(Table $table)
+ {
+ $this->prepareColumns($table->getName(), $table->getColumns());
+ $this->prepareConstraintsAndIndexes($table->getForeignKeys(), $table->getIndexes(), $table->getName());
+ }
+
+ /**
+ * Flush all tables
+ *
+ * @return void
+ */
+ public function flush()
+ {
+ $this->tables = [];
+ }
+
+ /**
+ * @param string $moduleName
+ */
+ public function setModuleName($moduleName)
+ {
+ $this->moduleName = $moduleName;
+ }
+
+ /**
+ * @return array
+ */
+ public function getTables()
+ {
+ return $this->tables;
+ }
+}
\ No newline at end of file
diff --git a/setup/src/Magento/Setup/Model/SchemaListenerDefinition/BooleanDefinition.php b/setup/src/Magento/Setup/Model/SchemaListenerDefinition/BooleanDefinition.php
new file mode 100644
index 0000000000000..394bec87f8bef
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/SchemaListenerDefinition/BooleanDefinition.php
@@ -0,0 +1,26 @@
+ $definition['type'],
+ 'name' => $definition['name'],
+ 'nullable' => $definition['nullable'] ?? true,
+ 'default' => $definition['default'] ?? null
+ ];
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/SchemaListenerDefinition/DateDefinition.php b/setup/src/Magento/Setup/Model/SchemaListenerDefinition/DateDefinition.php
new file mode 100644
index 0000000000000..e0f01c799cb6a
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/SchemaListenerDefinition/DateDefinition.php
@@ -0,0 +1,24 @@
+ 'date',
+ 'name' => $definition['name'],
+ ];
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/SchemaListenerDefinition/DecimalDefinition.php b/setup/src/Magento/Setup/Model/SchemaListenerDefinition/DecimalDefinition.php
new file mode 100644
index 0000000000000..1741827f5a635
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/SchemaListenerDefinition/DecimalDefinition.php
@@ -0,0 +1,41 @@
+ $definition['type'],
+ 'name' => $definition['name'],
+ 'scale' => $definition['scale'] ?? self::DEFAULT_SCALE,
+ 'precision' => $definition['precision'] ?? self::DEFAULT_PRECISION,
+ 'unsigned' => $definition['unsigned'] ?? false,
+ 'nullable' => $definition['nullable'] ?? true,
+ 'default' => $definition['default'] ?? null
+ ];
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/SchemaListenerDefinition/DefinitionConverterInterface.php b/setup/src/Magento/Setup/Model/SchemaListenerDefinition/DefinitionConverterInterface.php
new file mode 100644
index 0000000000000..a48359c5b7a99
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/SchemaListenerDefinition/DefinitionConverterInterface.php
@@ -0,0 +1,21 @@
+ 3,
+ 'smallint' => 6,
+ 'integer' => 11,
+ 'bigint' => 20
+ ];
+
+ /**
+ * @inheritdoc
+ */
+ public function convertToDefinition(array $definition)
+ {
+ return [
+ 'xsi:type' => $definition['type'],
+ 'name' => $definition['name'],
+ 'padding' => $definition['length'] ?? self::$lengthDefaults[$definition['type']],
+ 'unsigned' => $definition['unsigned'] ?? false,
+ 'nullable' => $definition['nullable'] ?? true,
+ 'identity' => $definition['identity'] ?? false,
+ 'default' => $definition['default'] ?? null,
+ 'primary' => $definition['primary'] ?? false
+ ];
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/SchemaListenerDefinition/TextBlobDefinition.php b/setup/src/Magento/Setup/Model/SchemaListenerDefinition/TextBlobDefinition.php
new file mode 100644
index 0000000000000..7b0b3047b62a9
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/SchemaListenerDefinition/TextBlobDefinition.php
@@ -0,0 +1,80 @@
+= Table::MAX_TEXT_SIZE) {
+ return Table::MAX_TEXT_SIZE;
+ }
+
+ return intval($size);
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function convertToDefinition(array $definition)
+ {
+ $length = $this->parseTextSize($definition['length'] ?? 0);
+ $ddlType = $definition['type'];
+ if ($length > 0 && $length <= 255) {
+ $cType = $ddlType == Table::TYPE_TEXT ? 'varchar' : 'varbinary';
+ } elseif ($length > 255 && $length <= 65536) {
+ $cType = $ddlType == Table::TYPE_TEXT ? 'text' : 'blob';
+ } elseif ($length > 65536 && $length <= 16777216) {
+ $cType = $ddlType == Table::TYPE_TEXT ? 'mediumtext' : 'mediumblob';
+ } else {
+ $cType = $ddlType == Table::TYPE_TEXT ? 'longtext' : 'longblob';
+ }
+
+ $newDefinition = [
+ 'xsi:type' => $cType,
+ 'name' => $definition['name'],
+ 'nullable' => $definition['nullable'] ?? true
+ ];
+
+ if (in_array($cType, ['varchar', 'varbinary'])) {
+ $newDefinition['length'] = $length;
+ $newDefinition['default'] = $definition['default'] ?? null;
+ }
+
+ return $newDefinition;
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/SchemaListenerDefinition/TimestampDefinition.php b/setup/src/Magento/Setup/Model/SchemaListenerDefinition/TimestampDefinition.php
new file mode 100644
index 0000000000000..bc0ae0763cd3e
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/SchemaListenerDefinition/TimestampDefinition.php
@@ -0,0 +1,46 @@
+ $definition['type'],
+ 'name' => $definition['name'],
+ 'on_update' => $onUpdate,
+ 'nullable' => $cNullable,
+ 'default' => $cDefault
+ ];
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/SchemaPersistor.php b/setup/src/Magento/Setup/Model/SchemaPersistor.php
new file mode 100644
index 0000000000000..345e2b9ba144b
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/SchemaPersistor.php
@@ -0,0 +1,170 @@
+componentRegistrar = $componentRegistrar;
+ }
+
+ /**
+ * @return \SimpleXMLElement
+ */
+ private function initEmptyDom()
+ {
+ return new \SimpleXMLElement(
+ '
+ ');
+ }
+
+ /**
+ * Do persist by modules to db_schema.xml file
+ *
+ * @param SchemaListener $schemaListener
+ */
+ public function persist(SchemaListener $schemaListener)
+ {
+ foreach ($schemaListener->getTables() as $moduleName => $tablesData) {
+ $path = $this->componentRegistrar->getPath(ComponentRegistrar::MODULE, $moduleName);
+ $schemaPatch = sprintf('%s/etc/db_schema.xml', $path);
+ if (file_exists($schemaPatch)) {
+ $dom = new \SimpleXMLElement(file_get_contents($schemaPatch));
+ } else {
+ $dom = $this->initEmptyDom();
+ }
+
+ foreach ($tablesData as $tableName => $tableData) {
+ $table = $dom->addChild('table');
+ $table->addAttribute('name', $tableName);
+ /** @TODO: handle different resources for sales and checkout tables */
+ $table->addAttribute('resource', 'default');
+ $this->processColumns($tableData, $table);
+ $this->processConstraints($tableData, $table);
+ $this->processIndexes($tableData, $table);
+ }
+
+ $this->persistModule($dom, $schemaPatch);
+ }
+ }
+
+ /**
+ * Convert columns from array to XML format
+ *
+ * @param array $tableData
+ * @param \SimpleXMLElement $table
+ * @return \SimpleXMLElement
+ */
+ private function processColumns(array $tableData, \SimpleXMLElement $table)
+ {
+ if (isset($tableData['columns'])) {
+ foreach ($tableData['columns'] as $columnData) {
+ $domColumn = $table->addChild('column');
+
+ foreach ($columnData as $attributeKey => $attributeValue) {
+ $domColumn->addAttribute($attributeKey, $attributeValue);
+ }
+ }
+ }
+
+ return $table;
+ }
+
+ /**
+ * Convert columns from array to XML format
+ *
+ * @param array $tableData
+ * @param \SimpleXMLElement $table
+ * @return \SimpleXMLElement
+ */
+ private function processIndexes(array $tableData, \SimpleXMLElement $table)
+ {
+ if (isset($tableData['indexes'])) {
+ foreach ($tableData['indexes'] as $indexName => $indexData) {
+ $domIndex = $table->addChild('index');
+ $domIndex->addAttribute('name', $indexName);
+ $domIndex->addAttribute('type', $indexData['type']);
+
+ foreach ($indexData['columns'] as $column) {
+ $columnXml = $domIndex->addChild('column');
+ $columnXml->addAttribute('name', $column);
+ }
+ }
+ }
+
+ return $table;
+ }
+
+ /**
+ * Convert constraints from array to XML format
+ *
+ * @param array $tableData
+ * @param \SimpleXMLElement $table
+ * @return \SimpleXMLElement
+ */
+ private function processConstraints(array $tableData, \SimpleXMLElement $table)
+ {
+ if (isset($tableData['constraints'])) {
+ foreach ($tableData['constraints'] as $constraintType => $constraints) {
+ if ($constraintType === 'foreign') {
+ foreach ($constraints as $constraintData) {
+ $constraintDom = $table->addChild('constraint');
+ $constraintDom->addAttribute('xsi:type', $constraintType);
+
+ foreach ($constraintData as $attributeKey => $attributeValue) {
+ $constraintDom->addAttribute($attributeKey, $attributeValue);
+ }
+ }
+ } else {
+ foreach ($constraints as $name => $constraintData) {
+ $constraintDom = $table->addChild('constraint');
+ $constraintDom->addAttribute('xsi:type', $constraintType);
+ $constraintDom->addAttribute('name', $name);
+
+ foreach ($constraintData['columns'] as $column) {
+ $columnXml = $constraintDom->addChild('column');
+ $columnXml->addAttribute('name', $column);
+ }
+ }
+ }
+ }
+ }
+
+ return $table;
+ }
+
+ /**
+ * Do schema persistence to specific module
+ *
+ * @param \SimpleXMLElement $simpleXmlElementDom
+ * @param string $path
+ * @return void
+ */
+ private function persistModule(\SimpleXMLElement $simpleXmlElementDom, $path)
+ {
+ $dom = new \DOMDocument('1.0');
+ $dom->preserveWhiteSpace = false;
+ $dom->formatOutput = true;
+ $dom->loadXML($simpleXmlElementDom->asXML());
+ file_put_contents($path, $dom->saveXML());
+ }
+}
From 113f4a5f9ff1924b8f35838ec089b1ea61ed72e7 Mon Sep 17 00:00:00 2001
From: Sergii Kovalenko
Date: Fri, 29 Dec 2017 13:23:55 +0200
Subject: [PATCH 251/904] MAGETWO-85326: Tool for generating schema
---
.../Model/SchemaListenerDefinition/IntegerDefinition.php | 6 +++++-
setup/src/Magento/Setup/Model/SchemaPersistor.php | 6 ++++--
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/setup/src/Magento/Setup/Model/SchemaListenerDefinition/IntegerDefinition.php b/setup/src/Magento/Setup/Model/SchemaListenerDefinition/IntegerDefinition.php
index 1d1e33b42f06b..1b11a430cfe4c 100644
--- a/setup/src/Magento/Setup/Model/SchemaListenerDefinition/IntegerDefinition.php
+++ b/setup/src/Magento/Setup/Model/SchemaListenerDefinition/IntegerDefinition.php
@@ -19,7 +19,7 @@ class IntegerDefinition implements DefinitionConverterInterface
private static $lengthDefaults = [
'tinyint' => 3,
'smallint' => 6,
- 'integer' => 11,
+ 'int' => 11,
'bigint' => 20
];
@@ -28,6 +28,10 @@ class IntegerDefinition implements DefinitionConverterInterface
*/
public function convertToDefinition(array $definition)
{
+ if ($definition['type'] === 'integer') {
+ $definition['type'] = 'int';
+ }
+
return [
'xsi:type' => $definition['type'],
'name' => $definition['name'],
diff --git a/setup/src/Magento/Setup/Model/SchemaPersistor.php b/setup/src/Magento/Setup/Model/SchemaPersistor.php
index 345e2b9ba144b..42895df6c20e4 100644
--- a/setup/src/Magento/Setup/Model/SchemaPersistor.php
+++ b/setup/src/Magento/Setup/Model/SchemaPersistor.php
@@ -79,6 +79,8 @@ private function processColumns(array $tableData, \SimpleXMLElement $table)
if (isset($tableData['columns'])) {
foreach ($tableData['columns'] as $columnData) {
$domColumn = $table->addChild('column');
+ $domColumn->addAttribute('xsi:type', $columnData['xsi:type'], 'xsi');
+ unset($columnData['xsi:type']);
foreach ($columnData as $attributeKey => $attributeValue) {
$domColumn->addAttribute($attributeKey, $attributeValue);
@@ -128,7 +130,7 @@ private function processConstraints(array $tableData, \SimpleXMLElement $table)
if ($constraintType === 'foreign') {
foreach ($constraints as $constraintData) {
$constraintDom = $table->addChild('constraint');
- $constraintDom->addAttribute('xsi:type', $constraintType);
+ $constraintDom->addAttribute('xsi:type', $constraintType, 'xsi');
foreach ($constraintData as $attributeKey => $attributeValue) {
$constraintDom->addAttribute($attributeKey, $attributeValue);
@@ -137,7 +139,7 @@ private function processConstraints(array $tableData, \SimpleXMLElement $table)
} else {
foreach ($constraints as $name => $constraintData) {
$constraintDom = $table->addChild('constraint');
- $constraintDom->addAttribute('xsi:type', $constraintType);
+ $constraintDom->addAttribute('xsi:type', $constraintType, 'xsi');
$constraintDom->addAttribute('name', $name);
foreach ($constraintData['columns'] as $column) {
From 00e29b2f5e51ff187e0817652acc4c0b1ee38bea Mon Sep 17 00:00:00 2001
From: Sergii Kovalenko
Date: Tue, 2 Jan 2018 14:03:42 +0200
Subject: [PATCH 252/904] MAGETWO-85326: Tool for generating schema
--add schemas
---
.../{Recurring.php => RecurringData.php} | 8 +-
app/code/Magento/Store/Setup/InstallData.php | 101 ++++++++++++++++++
.../Magento/Store/Setup/InstallSchema.php | 72 -------------
.../etc/db_schema.xml | 2 +-
.../column_modification.php | 2 +-
.../declarative_installer/column_removal.php | 2 +-
.../constraint_modification.php | 2 +-
.../declarative_installer/installation.php | 2 +-
.../column_modifications/db_schema.xml | 2 +-
.../revisions/column_removals/db_schema.xml | 2 +-
.../constraint_modifications/db_schema.xml | 2 +-
.../revisions/old_diff/db_schema.xml | 2 +-
.../etc/db_schema.xml | 2 +-
.../Db/DbDefinitionProcessorInterface.php | 4 +-
.../Schema/Db/DbSchemaWriterInterface.php | 3 +-
.../Schema/Db/DefinitionAggregator.php | 6 +-
.../Schema/Db/MySQL/DbSchemaWriter.php | 79 ++------------
.../Db/MySQL/Definition/Columns/Blob.php | 21 ++--
.../Db/MySQL/Definition/Columns/Boolean.php | 29 ++---
.../Db/MySQL/Definition/Columns/Date.php | 23 +++-
.../Db/MySQL/Definition/Columns/Decimal.php | 35 +++---
.../Definition/Columns/DefaultDefinition.php | 54 ----------
.../Db/MySQL/Definition/Columns/Identity.php | 6 +-
.../Db/MySQL/Definition/Columns/Integer.php | 39 +++----
.../Db/MySQL/Definition/Columns/Nullable.php | 8 +-
.../Db/MySQL/Definition/Columns/OnUpdate.php | 8 +-
.../Db/MySQL/Definition/Columns/Timestamp.php | 28 ++---
.../Db/MySQL/Definition/Columns/Unsigned.php | 6 +-
.../Db/MySQL/Definition/Columns/Varchar.php | 29 ++---
.../Definition/Constraints/ForeignKey.php | 21 ++--
.../MySQL/Definition/Constraints/Internal.php | 18 ++--
.../Schema/Db/MySQL/Definition/Index.php | 45 ++++----
.../CheckReferenceColumnHasIndex.php | 2 +-
.../Schema/Dto/Columns/Varchar.php | 4 +-
.../Schema/Dto/Factories/Index.php | 4 +-
.../Schema/Dto/Factories/Timestamp.php | 2 -
.../Schema/Dto/Factories/Varchar.php | 5 +-
.../Model/Declaration/Schema/Dto/Index.php | 50 +++++++--
.../Schema/Operations/CreateTable.php | 3 +-
.../Schema/Operations/ModifyElement.php | 1 -
.../Schema/etc/constraints/foreign.xsd | 2 +-
.../Model/Declaration/Schema/etc/index.xsd | 2 +-
setup/src/Magento/Setup/Model/Installer.php | 5 +-
.../Magento/Setup/Model/SchemaListener.php | 19 ++--
.../DecimalDefinition.php | 10 +-
.../TextBlobDefinition.php | 3 +-
.../Magento/Setup/Model/SchemaPersistor.php | 26 ++++-
47 files changed, 401 insertions(+), 400 deletions(-)
rename app/code/Magento/Integration/Setup/{Recurring.php => RecurringData.php} (81%)
create mode 100644 app/code/Magento/Store/Setup/InstallData.php
delete mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Columns/DefaultDefinition.php
diff --git a/app/code/Magento/Integration/Setup/Recurring.php b/app/code/Magento/Integration/Setup/RecurringData.php
similarity index 81%
rename from app/code/Magento/Integration/Setup/Recurring.php
rename to app/code/Magento/Integration/Setup/RecurringData.php
index 2a7aa6df263fc..4964d26a48c73 100644
--- a/app/code/Magento/Integration/Setup/Recurring.php
+++ b/app/code/Magento/Integration/Setup/RecurringData.php
@@ -6,17 +6,17 @@
namespace Magento\Integration\Setup;
+use Magento\Framework\Setup\InstallDataInterface;
+use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Integration\Model\ConfigBasedIntegrationManager;
use Magento\Integration\Model\ConsolidatedConfig;
-use Magento\Framework\Setup\InstallSchemaInterface;
use Magento\Framework\Setup\ModuleContextInterface;
-use Magento\Framework\Setup\SchemaSetupInterface;
/**
* Class Recurring
*
*/
-class Recurring implements InstallSchemaInterface
+class RecurringData implements InstallDataInterface
{
/**
* @var ConfigBasedIntegrationManager
@@ -45,7 +45,7 @@ public function __construct(
/**
* {@inheritdoc}
*/
- public function install(SchemaSetupInterface $setup, ModuleContextInterface $context)
+ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
{
$this->integrationManager->processConfigBasedIntegrations($this->integrationConfig->getIntegrations());
}
diff --git a/app/code/Magento/Store/Setup/InstallData.php b/app/code/Magento/Store/Setup/InstallData.php
new file mode 100644
index 0000000000000..d0ec5b99f45ca
--- /dev/null
+++ b/app/code/Magento/Store/Setup/InstallData.php
@@ -0,0 +1,101 @@
+startSetup();
+ $connection = $installer->getConnection();
+
+ /**
+ * Insert websites
+ */
+ $connection->insertForce(
+ $installer->getTable('store_website'),
+ [
+ 'website_id' => 0,
+ 'code' => 'admin',
+ 'name' => 'Admin',
+ 'sort_order' => 0,
+ 'default_group_id' => 0,
+ 'is_default' => 0
+ ]
+ );
+ $connection->insertForce(
+ $installer->getTable('store_website'),
+ [
+ 'website_id' => 1,
+ 'code' => 'base',
+ 'name' => 'Main Website',
+ 'sort_order' => 0,
+ 'default_group_id' => 1,
+ 'is_default' => 1
+ ]
+ );
+
+ /**
+ * Insert store groups
+ */
+ $connection->insertForce(
+ $installer->getTable('store_group'),
+ ['group_id' => 0, 'website_id' => 0, 'name' => 'Default', 'root_category_id' => 0, 'default_store_id' => 0]
+ );
+ $connection->insertForce(
+ $installer->getTable('store_group'),
+ [
+ 'group_id' => 1,
+ 'website_id' => 1,
+ 'name' => 'Main Website Store',
+ 'root_category_id' => $this->getDefaultCategory()->getId(),
+ 'default_store_id' => 1
+ ]
+ );
+
+ /**
+ * Insert stores
+ */
+ $connection->insertForce(
+ $installer->getTable('store'),
+ [
+ 'store_id' => 0,
+ 'code' => 'admin',
+ 'website_id' => 0,
+ 'group_id' => 0,
+ 'name' => 'Admin',
+ 'sort_order' => 0,
+ 'is_active' => 1
+ ]
+ );
+ $connection->insertForce(
+ $installer->getTable('store'),
+ [
+ 'store_id' => 1,
+ 'code' => 'default',
+ 'website_id' => 1,
+ 'group_id' => 1,
+ 'name' => 'Default Store View',
+ 'sort_order' => 0,
+ 'is_active' => 1
+ ]
+ );
+ $setup->endSetup();
+ }
+}
diff --git a/app/code/Magento/Store/Setup/InstallSchema.php b/app/code/Magento/Store/Setup/InstallSchema.php
index f6cdfb6fcba71..47ed0905a95dd 100644
--- a/app/code/Magento/Store/Setup/InstallSchema.php
+++ b/app/code/Magento/Store/Setup/InstallSchema.php
@@ -239,78 +239,6 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
);
$connection->createTable($table);
- /**
- * Insert websites
- */
- $connection->insertForce(
- $installer->getTable('store_website'),
- [
- 'website_id' => 0,
- 'code' => 'admin',
- 'name' => 'Admin',
- 'sort_order' => 0,
- 'default_group_id' => 0,
- 'is_default' => 0
- ]
- );
- $connection->insertForce(
- $installer->getTable('store_website'),
- [
- 'website_id' => 1,
- 'code' => 'base',
- 'name' => 'Main Website',
- 'sort_order' => 0,
- 'default_group_id' => 1,
- 'is_default' => 1
- ]
- );
-
- /**
- * Insert store groups
- */
- $connection->insertForce(
- $installer->getTable('store_group'),
- ['group_id' => 0, 'website_id' => 0, 'name' => 'Default', 'root_category_id' => 0, 'default_store_id' => 0]
- );
- $connection->insertForce(
- $installer->getTable('store_group'),
- [
- 'group_id' => 1,
- 'website_id' => 1,
- 'name' => 'Main Website Store',
- 'root_category_id' => $this->getDefaultCategory()->getId(),
- 'default_store_id' => 1
- ]
- );
-
- /**
- * Insert stores
- */
- $connection->insertForce(
- $installer->getTable('store'),
- [
- 'store_id' => 0,
- 'code' => 'admin',
- 'website_id' => 0,
- 'group_id' => 0,
- 'name' => 'Admin',
- 'sort_order' => 0,
- 'is_active' => 1
- ]
- );
- $connection->insertForce(
- $installer->getTable('store'),
- [
- 'store_id' => 1,
- 'code' => 'default',
- 'website_id' => 1,
- 'group_id' => 1,
- 'name' => 'Default Store View',
- 'sort_order' => 0,
- 'is_active' => 1
- ]
- );
-
$installer->endSetup();
}
}
diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/etc/db_schema.xml b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/etc/db_schema.xml
index a0e988a67e4d8..e24a3daf5b1a5 100644
--- a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/etc/db_schema.xml
+++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/etc/db_schema.xml
@@ -54,7 +54,7 @@
-
+
diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/declarative_installer/column_modification.php b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/declarative_installer/column_modification.php
index ce1ea7276b6f5..ee3092e26e30e 100644
--- a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/declarative_installer/column_modification.php
+++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/declarative_installer/column_modification.php
@@ -40,7 +40,7 @@
`blob` blob,
`boolean` tinyint(1) DEFAULT \'1\',
UNIQUE KEY `some_unique_key` (`smallint`,`bigint`),
- KEY `speedup_index` (`tinyint`,`bigint`),
+ KEY `speedup_index` (`tinyint`,`bigint`) USING BTREE,
CONSTRAINT `some_foreign_key` FOREIGN KEY (`tinyint`) REFERENCES `reference_table` (`tinyint_ref`) ON DELETE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8',
];
diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/declarative_installer/column_removal.php b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/declarative_installer/column_removal.php
index fb207c04a127c..46e22a0071062 100644
--- a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/declarative_installer/column_removal.php
+++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/declarative_installer/column_removal.php
@@ -38,7 +38,7 @@
`boolean` tinyint(1) DEFAULT \'0\',
`varbinary_rename` varbinary(255) DEFAULT \'10101\',
UNIQUE KEY `some_unique_key` (`smallint`,`bigint`),
- KEY `speedup_index` (`tinyint`,`bigint`),
+ KEY `speedup_index` (`tinyint`,`bigint`) USING BTREE,
CONSTRAINT `some_foreign_key` FOREIGN KEY (`tinyint`) REFERENCES `reference_table` (`tinyint_ref`) ON DELETE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8',
];
diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/declarative_installer/constraint_modification.php b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/declarative_installer/constraint_modification.php
index 88735201fcf75..1c01abd65c441 100644
--- a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/declarative_installer/constraint_modification.php
+++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/declarative_installer/constraint_modification.php
@@ -47,7 +47,7 @@
UNIQUE KEY `some_unique_key` (`smallint`,`float`),
KEY `some_foreign_key_new` (`smallint_main`),
KEY `some_foreign_key_without_action` (`integer_main`),
- KEY `speedup_index_renamed` (`tinyint`,`bigint`),
+ KEY `speedup_index_renamed` (`tinyint`,`bigint`) USING BTREE,
CONSTRAINT `some_foreign_key` FOREIGN KEY (`tinyint`) REFERENCES `reference_table` (`tinyint_ref`)
ON DELETE SET NULL,
CONSTRAINT `some_foreign_key_new` FOREIGN KEY (`smallint_main`) REFERENCES `reference_table` (`smallint_ref`)
diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/declarative_installer/installation.php b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/declarative_installer/installation.php
index 73531a6f37d7b..c4fd3367da476 100644
--- a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/declarative_installer/installation.php
+++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/fixture/declarative_installer/installation.php
@@ -40,7 +40,7 @@
`blob` blob,
`boolean` tinyint(1) DEFAULT \'0\',
UNIQUE KEY `some_unique_key` (`smallint`,`bigint`),
- KEY `speedup_index` (`tinyint`,`bigint`),
+ KEY `speedup_index` (`tinyint`,`bigint`) USING BTREE,
CONSTRAINT `some_foreign_key` FOREIGN KEY (`tinyint`) REFERENCES `reference_table` (`tinyint_ref`) ON DELETE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8',
];
diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/column_modifications/db_schema.xml b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/column_modifications/db_schema.xml
index 2a6b890790b4c..3ea547a418e03 100644
--- a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/column_modifications/db_schema.xml
+++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/column_modifications/db_schema.xml
@@ -54,7 +54,7 @@
-
+
diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/column_removals/db_schema.xml b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/column_removals/db_schema.xml
index 2aed42e674688..b47cada9540e7 100644
--- a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/column_removals/db_schema.xml
+++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/column_removals/db_schema.xml
@@ -52,7 +52,7 @@
-
+
diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/constraint_modifications/db_schema.xml b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/constraint_modifications/db_schema.xml
index 288ed93bafcab..12cfc061c0b1d 100644
--- a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/constraint_modifications/db_schema.xml
+++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/constraint_modifications/db_schema.xml
@@ -66,7 +66,7 @@
-
+
diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/old_diff/db_schema.xml b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/old_diff/db_schema.xml
index 48ed31a2c1a34..2ebd7bf41195c 100644
--- a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/old_diff/db_schema.xml
+++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule1/revisions/old_diff/db_schema.xml
@@ -29,7 +29,7 @@
-
+
diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule2/etc/db_schema.xml b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule2/etc/db_schema.xml
index b219a7e5269b4..a0b5efd507121 100644
--- a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule2/etc/db_schema.xml
+++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule2/etc/db_schema.xml
@@ -54,7 +54,7 @@
-
+
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/DbDefinitionProcessorInterface.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/DbDefinitionProcessorInterface.php
index 6aa4ce490b6a3..4f6162d97744a 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/DbDefinitionProcessorInterface.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/DbDefinitionProcessorInterface.php
@@ -19,10 +19,10 @@ interface DbDefinitionProcessorInterface
/**
* Output always will be SQL definition
*
- * @param ElementInterface $element
+ * @param ElementInterface $column
* @return string
*/
- public function toDefinition(ElementInterface $element);
+ public function toDefinition(ElementInterface $column);
/**
* Input always will be array of SQL definitions,
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/DbSchemaWriterInterface.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/DbSchemaWriterInterface.php
index c16f0bb254380..6d9df77aaa55d 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/DbSchemaWriterInterface.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/DbSchemaWriterInterface.php
@@ -51,12 +51,11 @@ public function addElement($elementName, $resource, $tableName, $elementDefiniti
* Please note: that from all structural elements only column can be modified
*
* @param $resource
- * @param $columnName
* @param $tableName
* @param string $columnDefinition
* @return void
*/
- public function modifyColumn($resource, $columnName, $tableName, $columnDefinition);
+ public function modifyColumn($resource, $tableName, $columnDefinition);
/**
* As we can`t just drop and recreate constraint in 2 requests
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/DefinitionAggregator.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/DefinitionAggregator.php
index 90b20a051e0dd..50fa28e28b2a1 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/DefinitionAggregator.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/DefinitionAggregator.php
@@ -32,9 +32,9 @@ public function __construct(array $definitionProcessors)
/**
* @inheritdoc
*/
- public function toDefinition(ElementInterface $element)
+ public function toDefinition(ElementInterface $column)
{
- $type = $element->getType();
+ $type = $column->getType();
if (!isset($this->definitionProcessors[$type])) {
throw new \InvalidArgumentException(
sprintf("Cannot process object to definition for type %s", $type)
@@ -42,7 +42,7 @@ public function toDefinition(ElementInterface $element)
}
$definitionProcessor = $this->definitionProcessors[$type];
- return $definitionProcessor->toDefinition($element);
+ return $definitionProcessor->toDefinition($column);
}
/**
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/DbSchemaWriter.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/DbSchemaWriter.php
index 59b617211536c..05ef2a07e2d94 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/DbSchemaWriter.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/DbSchemaWriter.php
@@ -32,71 +32,18 @@ public function __construct(ResourceConnection $resourceConnection)
$this->resourceConnection = $resourceConnection;
}
- /**
- * Prepare constraint statement by compiling name and definition together
- *
- * @param string $name
- * @param string $indexDefinition
- * @param string $elementType: can be COLUMN, CONSTRAINT or INDEX
- * @return string
- */
- private function getAddElementSQL($elementType, $name, $indexDefinition)
- {
- return sprintf('ADD %s %s %s', strtoupper($elementType), $name, $indexDefinition);
- }
-
- /**
- * Convert definition from format:
- * $name => $definition
- * To format:
- * $name $definition
- *
- * @param array $columnsDefinition
- * @param AdapterInterface $adapter
- * @return array
- */
- private function getColumnsWithNames(array $columnsDefinition, AdapterInterface $adapter)
- {
- $definition = [];
- foreach ($columnsDefinition as $name => $columnDefinition) {
- $definition[] = sprintf(
- "%s %s",
- $adapter->quoteIdentifier($name),
- $columnDefinition
- );
- }
-
- return $definition;
- }
-
/**
* @inheritdoc
* @return \Zend_Db_Statement_Interface
*/
public function createTable($tableName, $resource, array $definition)
{
- $fragmentsSQL = [];
$adapter = $this->resourceConnection->getConnection($resource);
- foreach ([Constraint::TYPE, \Magento\Setup\Model\Declaration\Schema\Dto\Index::TYPE] as $elementType) {
- if (isset($definition[$elementType])) { //Some element types can be optional
- //Process indexes definition
- foreach ($definition[$elementType] as $name => $elementDefinition) {
- $fragmentsSQL[] = sprintf(
- '%s %s %s',
- strtoupper($elementType),
- $adapter->quoteIdentifier($name),
- $elementDefinition
- );
- }
- }
- }
-
$sql = sprintf(
- "CREATE TABLE %s (\n%s,\n%s\n)",
+ "CREATE TABLE %s (\n%s\n)",
$adapter->quoteIdentifier($tableName),
- implode(", \n", $this->getColumnsWithNames($definition[Column::TYPE], $adapter)),
- implode(", \n", $fragmentsSQL)
+ implode(", \n", $definition)
);
return $adapter->query($sql);
@@ -154,16 +101,14 @@ private function getDropElementSQL($type, $name)
*/
public function addElement($elementName, $resource, $tableName, $elementDefinition, $elementType)
{
+ $addElementSyntax = $elementType === Column::TYPE ? 'ALTER TABLE %s ADD COLUMN %s' : 'ALTER TABLE %s ADD %s';
+
$adapter = $this->resourceConnection->getConnection($resource);
$sql = sprintf(
- 'ALTER TABLE %s %s',
+ $addElementSyntax,
$adapter->quoteIdentifier($tableName),
- $this->getAddElementSQL(
- $elementType,
- $adapter->quoteIdentifier($elementName),
- $elementDefinition
- )
+ $elementDefinition
);
return $adapter->query($sql);
@@ -175,14 +120,13 @@ public function addElement($elementName, $resource, $tableName, $elementDefiniti
* @inheritdoc
* @return \Zend_Db_Statement_Interface
*/
- public function modifyColumn($resource, $columnName, $tableName, $columnDefinition)
+ public function modifyColumn($resource, $tableName, $columnDefinition)
{
$adapter = $this->resourceConnection->getConnection($resource);
$sql = sprintf(
- 'ALTER TABLE %s MODIFY COLUMN %s %s',
+ 'ALTER TABLE %s MODIFY COLUMN %s',
$adapter->quoteIdentifier($tableName),
- $adapter->quoteIdentifier($columnName),
$columnDefinition
);
@@ -206,12 +150,7 @@ public function modifyConstraint($resource, $elementName, $tableName, $type, $co
$type,
$adapter->quoteIdentifier($elementName)
),
- $this->getAddElementSQL(
- Constraint::TYPE,
- //We need to avoid `PRIMARY` name in modify constraint syntax
- $elementName === Internal::PRIMARY_NAME ? '' : $adapter->quoteIdentifier($elementName),
- $constraintDefinition
- )
+ sprintf('ADD %s', $constraintDefinition)
);
return $adapter->query($sql);
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Columns/Blob.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Columns/Blob.php
index 359675908867a..bffd96de06839 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Columns/Blob.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Columns/Blob.php
@@ -6,6 +6,7 @@
namespace Magento\Setup\Model\Declaration\Schema\Db\MySQL\Definition\Columns;
+use Magento\Framework\App\ResourceConnection;
use Magento\Setup\Model\Declaration\Schema\Db\DbDefinitionProcessorInterface;
use Magento\Setup\Model\Declaration\Schema\Dto\ElementInterface;
@@ -21,26 +22,34 @@ class Blob implements DbDefinitionProcessorInterface
*/
private $nullable;
+ /**
+ * @var ResourceConnection
+ */
+ private $resourceConnection;
+
/**
* Text constructor.
*
* @param Nullable $nullable
+ * @param ResourceConnection $resourceConnection
*/
- public function __construct(Nullable $nullable)
+ public function __construct(Nullable $nullable, ResourceConnection $resourceConnection)
{
$this->nullable = $nullable;
+ $this->resourceConnection = $resourceConnection;
}
/**
- * @param \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Blob $element
+ * @param \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Blob $column
* @inheritdoc
*/
- public function toDefinition(ElementInterface $element)
+ public function toDefinition(ElementInterface $column)
{
return sprintf(
- '%s %s',
- $element->getType(),
- $this->nullable->toDefinition($element)
+ '%s %s %s',
+ $this->resourceConnection->getConnection()->quoteIdentifier($column->getName()),
+ $column->getType(),
+ $this->nullable->toDefinition($column)
);
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Columns/Boolean.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Columns/Boolean.php
index d1e4dd2ca4649..39ea26c613b19 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Columns/Boolean.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Columns/Boolean.php
@@ -6,6 +6,7 @@
namespace Magento\Setup\Model\Declaration\Schema\Db\MySQL\Definition\Columns;
+use Magento\Framework\App\ResourceConnection;
use Magento\Framework\Stdlib\BooleanUtils;
use Magento\Setup\Model\Declaration\Schema\Db\DbDefinitionProcessorInterface;
use Magento\Setup\Model\Declaration\Schema\Dto\ElementInterface;
@@ -39,41 +40,43 @@ class Boolean implements DbDefinitionProcessorInterface
private $nullable;
/**
- * @var DefaultDefinition
+ * @var BooleanUtils
*/
- private $defaultDefinition;
+ private $booleanUtils;
/**
- * @var BooleanUtils
+ * @var ResourceConnection
*/
- private $booleanUtils;
+ private $resourceConnection;
/**
* @param Nullable $nullable
- * @param DefaultDefinition $defaultDefinition
* @param BooleanUtils $booleanUtils
+ * @param ResourceConnection $resourceConnection
*/
public function __construct(
Nullable $nullable,
- DefaultDefinition $defaultDefinition,
- BooleanUtils $booleanUtils
+ BooleanUtils $booleanUtils,
+ ResourceConnection $resourceConnection
) {
$this->nullable = $nullable;
- $this->defaultDefinition = $defaultDefinition;
$this->booleanUtils = $booleanUtils;
+ $this->resourceConnection = $resourceConnection;
}
/**
- * @param \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Boolean $element
+ * @param \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Boolean $column
* @inheritdoc
*/
- public function toDefinition(ElementInterface $element)
+ public function toDefinition(ElementInterface $column)
{
return sprintf(
- '%s %s %s',
+ '%s %s %s %s',
+ $this->resourceConnection->getConnection()->quoteIdentifier($column->getName()),
self::TYPE,
- $this->nullable->toDefinition($element),
- $this->defaultDefinition->toDefinition($element)
+ $this->nullable->toDefinition($column),
+ $column->getDefault() !== null ?
+ sprintf('DEFAULT %s', $column->getDefault() ? 1 : 0) : ''
);
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Columns/Date.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Columns/Date.php
index 378a9dba7ffbd..4fdd6f3d743bf 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Columns/Date.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Columns/Date.php
@@ -6,6 +6,7 @@
namespace Magento\Setup\Model\Declaration\Schema\Db\MySQL\Definition\Columns;
+use Magento\Framework\App\ResourceConnection;
use Magento\Setup\Model\Declaration\Schema\Db\DbDefinitionProcessorInterface;
use Magento\Setup\Model\Declaration\Schema\Dto\ElementInterface;
@@ -17,14 +18,28 @@
class Date implements DbDefinitionProcessorInterface
{
/**
- * @param \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Timestamp $element
+ * @var ResourceConnection
+ */
+ private $resourceConnection;
+
+ /**
+ * @param ResourceConnection $resourceConnection
+ */
+ public function __construct(ResourceConnection $resourceConnection)
+ {
+ $this->resourceConnection = $resourceConnection;
+ }
+
+ /**
+ * @param \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Timestamp $column
* @inheritdoc
*/
- public function toDefinition(ElementInterface $element)
+ public function toDefinition(ElementInterface $column)
{
return sprintf(
- '%s',
- $element->getType()
+ '%s %s',
+ $this->resourceConnection->getConnection()->quoteIdentifier($column->getName()),
+ $column->getType()
);
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Columns/Decimal.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Columns/Decimal.php
index 9b279088edcc8..b887e027d659a 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Columns/Decimal.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Columns/Decimal.php
@@ -6,6 +6,7 @@
namespace Magento\Setup\Model\Declaration\Schema\Db\MySQL\Definition\Columns;
+use Magento\Framework\App\ResourceConnection;
use Magento\Setup\Model\Declaration\Schema\Db\DbDefinitionProcessorInterface;
use Magento\Setup\Model\Declaration\Schema\Dto\ElementInterface;
@@ -27,36 +28,38 @@ class Decimal implements DbDefinitionProcessorInterface
private $unsigned;
/**
- * @var DefaultDefinition
+ * @var ResourceConnection
*/
- private $defaultDefinition;
+ private $resourceConnection;
/**
- * @param Nullable $nullable
- * @param Unsigned $unsigned
- * @param DefaultDefinition $defaultDefinition
+ * @param Nullable $nullable
+ * @param Unsigned $unsigned
+ * @param ResourceConnection $resourceConnection
*/
- public function __construct(Nullable $nullable, Unsigned $unsigned, DefaultDefinition $defaultDefinition)
+ public function __construct(Nullable $nullable, Unsigned $unsigned, ResourceConnection $resourceConnection)
{
$this->nullable = $nullable;
$this->unsigned = $unsigned;
- $this->defaultDefinition = $defaultDefinition;
+ $this->resourceConnection = $resourceConnection;
}
/**
- * @param \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Decimal $element
+ * @param \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Decimal $column
* @inheritdoc
*/
- public function toDefinition(ElementInterface $element)
+ public function toDefinition(ElementInterface $column)
{
return sprintf(
- '%s(%s, %s) %s %s %s',
- $element->getType(),
- $element->getScale(),
- $element->getPrecission(),
- $this->unsigned->toDefinition($element),
- $this->nullable->toDefinition($element),
- $this->defaultDefinition->toDefinition($element)
+ '%s %s(%s, %s) %s %s %s',
+ $this->resourceConnection->getConnection()->quoteIdentifier($column->getName()),
+ $column->getType(),
+ $column->getScale(),
+ $column->getPrecission(),
+ $this->unsigned->toDefinition($column),
+ $this->nullable->toDefinition($column),
+ $column->getDefault() !== null ?
+ sprintf('DEFAULT %s', $column->getDefault()) : ''
);
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Columns/DefaultDefinition.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Columns/DefaultDefinition.php
deleted file mode 100644
index 72dbe24e51875..0000000000000
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Columns/DefaultDefinition.php
+++ /dev/null
@@ -1,54 +0,0 @@
-getDefault() !== null && $element->getDefault() !== '' ?
- sprintf('DEFAULT %s', $this->defaultStringify($element->getDefault())) : '';
- }
-
- /**
- * Stringify default before we will collect definition
- *
- * @param mixed $default
- * @return string
- */
- private function defaultStringify($default)
- {
- if ($default === true) {
- $default = 'TRUE';
- } elseif ($default === false) {
- $default = 'FALSE';
- }
-
- return $default;
- }
-
- /**
- * @inheritdoc
- */
- public function fromDefinition(array $data)
- {
- return $data;
- }
-}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Columns/Identity.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Columns/Identity.php
index 1340b7162de48..081832a04b244 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Columns/Identity.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Columns/Identity.php
@@ -23,12 +23,12 @@ class Identity implements DbDefinitionProcessorInterface
const IDENTITY_FLAG = 'auto_increment';
/**
- * @param ColumnIdentityAwareInterface $element
+ * @param ColumnIdentityAwareInterface $column
* @inheritdoc
*/
- public function toDefinition(ElementInterface $element)
+ public function toDefinition(ElementInterface $column)
{
- return $element->isIdentity() ? strtoupper(self::IDENTITY_FLAG) : '';
+ return $column->isIdentity() ? strtoupper(self::IDENTITY_FLAG) : '';
}
/**
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Columns/Integer.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Columns/Integer.php
index d4536d635d2e9..abac1bdad1911 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Columns/Integer.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Columns/Integer.php
@@ -6,6 +6,7 @@
namespace Magento\Setup\Model\Declaration\Schema\Db\MySQL\Definition\Columns;
+use Magento\Framework\App\ResourceConnection;
use Magento\Setup\Model\Declaration\Schema\Db\DbDefinitionProcessorInterface;
use Magento\Setup\Model\Declaration\Schema\Dto\ElementInterface;
@@ -37,45 +38,47 @@ class Integer implements DbDefinitionProcessorInterface
private $identity;
/**
- * @var DefaultDefinition
+ * @var ResourceConnection
*/
- private $defaultDefinition;
+ private $resourceConnection;
/**
- * @param Unsigned $unsigned
- * @param bool $boolean
- * @param Nullable $nullable
- * @param Identity $identity
- * @param DefaultDefinition $defaultDefinition
+ * @param Unsigned $unsigned
+ * @param bool $boolean
+ * @param Nullable $nullable
+ * @param Identity $identity
+ * @param ResourceConnection $resourceConnection
*/
public function __construct(
Unsigned $unsigned,
Boolean $boolean,
Nullable $nullable,
Identity $identity,
- DefaultDefinition $defaultDefinition
+ ResourceConnection $resourceConnection
) {
$this->unsigned = $unsigned;
$this->boolean = $boolean;
$this->nullable = $nullable;
$this->identity = $identity;
- $this->defaultDefinition = $defaultDefinition;
+ $this->resourceConnection = $resourceConnection;
}
/**
- * @param \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Integer $element
+ * @param \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Integer $column
* @inheritdoc
*/
- public function toDefinition(ElementInterface $element)
+ public function toDefinition(ElementInterface $column)
{
return sprintf(
- '%s(%s) %s %s %s %s',
- $element->getType(),
- $element->getPadding(),
- $this->unsigned->toDefinition($element),
- $this->nullable->toDefinition($element),
- $this->defaultDefinition->toDefinition($element),
- $this->identity->toDefinition($element)
+ '%s %s(%s) %s %s %s %s',
+ $this->resourceConnection->getConnection()->quoteIdentifier($column->getName()),
+ $column->getType(),
+ $column->getPadding(),
+ $this->unsigned->toDefinition($column),
+ $this->nullable->toDefinition($column),
+ $column->getDefault() !== null ?
+ sprintf('DEFAULT %s', (string) intval($column->getDefault())) : '',
+ $this->identity->toDefinition($column)
);
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Columns/Nullable.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Columns/Nullable.php
index 97a0d0d53202e..46c4087737633 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Columns/Nullable.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Columns/Nullable.php
@@ -18,13 +18,13 @@
class Nullable implements DbDefinitionProcessorInterface
{
/**
- * @param ColumnNullableAwareInterface $element
+ * @param ColumnNullableAwareInterface $column
* @inheritdoc
*/
- public function toDefinition(ElementInterface $element)
+ public function toDefinition(ElementInterface $column)
{
- if ($element instanceof ColumnNullableAwareInterface) {
- return $element->isNullable() ? 'NULL' : 'NOT NULL';
+ if ($column instanceof ColumnNullableAwareInterface) {
+ return $column->isNullable() ? 'NULL' : 'NOT NULL';
}
return '';
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Columns/OnUpdate.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Columns/OnUpdate.php
index 06dd53a806250..8cb664a34d30f 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Columns/OnUpdate.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Columns/OnUpdate.php
@@ -17,13 +17,13 @@
class OnUpdate implements DbDefinitionProcessorInterface
{
/**
- * @param \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Timestamp $element
+ * @param \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Timestamp $column
* @inheritdoc
*/
- public function toDefinition(ElementInterface $element)
+ public function toDefinition(ElementInterface $column)
{
- if ($element instanceof \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Timestamp) {
- return $element->getOnUpdate() ?
+ if ($column instanceof \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Timestamp) {
+ return $column->getOnUpdate() ?
'ON UPDATE CURRENT_TIMESTAMP' : '';
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Columns/Timestamp.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Columns/Timestamp.php
index 008288c6d1c72..c5bdf40e0fc50 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Columns/Timestamp.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Columns/Timestamp.php
@@ -6,8 +6,8 @@
namespace Magento\Setup\Model\Declaration\Schema\Db\MySQL\Definition\Columns;
+use Magento\Framework\App\ResourceConnection;
use Magento\Setup\Model\Declaration\Schema\Db\DbDefinitionProcessorInterface;
-use Magento\Setup\Model\Declaration\Schema\Dto\Columns\Date;
use Magento\Setup\Model\Declaration\Schema\Dto\ElementInterface;
/**
@@ -28,31 +28,33 @@ class Timestamp implements DbDefinitionProcessorInterface
private $onUpdate;
/**
- * @var DefaultDefinition
+ * @var ResourceConnection
*/
- private $defaultDefinition;
+ private $resourceConnection;
/**
- * @param OnUpdate $onUpdate
- * @param DefaultDefinition $defaultDefinition
+ * @param OnUpdate $onUpdate
+ * @param ResourceConnection $resourceConnection
*/
- public function __construct(OnUpdate $onUpdate, DefaultDefinition $defaultDefinition)
+ public function __construct(OnUpdate $onUpdate, ResourceConnection $resourceConnection)
{
$this->onUpdate = $onUpdate;
- $this->defaultDefinition = $defaultDefinition;
+ $this->resourceConnection = $resourceConnection;
}
/**
- * @param \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Timestamp $element
+ * @param \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Timestamp $column
* @inheritdoc
*/
- public function toDefinition(ElementInterface $element)
+ public function toDefinition(ElementInterface $column)
{
return sprintf(
- '%s %s %s',
- $element->getType(),
- $this->defaultDefinition->toDefinition($element),
- $this->onUpdate->toDefinition($element)
+ '%s %s %s %s',
+ $this->resourceConnection->getConnection()->quoteIdentifier($column->getName()),
+ $column->getType(),
+ $column->getDefault() === 'NULL' ?
+ '' : sprintf('DEFAULT %s', $column->getDefault()),
+ $this->onUpdate->toDefinition($column)
);
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Columns/Unsigned.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Columns/Unsigned.php
index f75d249cf50eb..30c472f7f9d34 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Columns/Unsigned.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Columns/Unsigned.php
@@ -24,12 +24,12 @@ class Unsigned implements DbDefinitionProcessorInterface
const UNSIGNED_FLAG = 'unsigned';
/**
- * @param ColumnUnsignedAwareInterface $element
+ * @param ColumnUnsignedAwareInterface $column
* @inheritdoc
*/
- public function toDefinition(ElementInterface $element)
+ public function toDefinition(ElementInterface $column)
{
- return $element->isUnsigned() ? strtoupper(self::UNSIGNED_FLAG) : '';
+ return $column->isUnsigned() ? strtoupper(self::UNSIGNED_FLAG) : '';
}
/**
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Columns/Varchar.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Columns/Varchar.php
index 19a6123c9fa1f..819b29137de4c 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Columns/Varchar.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Columns/Varchar.php
@@ -5,6 +5,7 @@
*/
namespace Magento\Setup\Model\Declaration\Schema\Db\MySQL\Definition\Columns;
+use Magento\Framework\App\ResourceConnection;
use Magento\Setup\Model\Declaration\Schema\Db\DbDefinitionProcessorInterface;
use Magento\Setup\Model\Declaration\Schema\Dto\ElementInterface;
@@ -21,32 +22,34 @@ class Varchar implements DbDefinitionProcessorInterface
private $nullable;
/**
- * @var DefaultDefinition
+ * @var ResourceConnection
*/
- private $defaultDefinition;
+ private $resourceConnection;
/**
- * @param Nullable $nullable
- * @param DefaultDefinition $defaultDefinition
+ * @param Nullable $nullable
+ * @param ResourceConnection $resourceConnection
*/
- public function __construct(Nullable $nullable, DefaultDefinition $defaultDefinition)
+ public function __construct(Nullable $nullable, ResourceConnection $resourceConnection)
{
$this->nullable = $nullable;
- $this->defaultDefinition = $defaultDefinition;
+ $this->resourceConnection = $resourceConnection;
}
/**
- * @param \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Varchar $element
+ * @param \Magento\Setup\Model\Declaration\Schema\Dto\Columns\Varchar $column
* @inheritdoc
*/
- public function toDefinition(ElementInterface $element)
+ public function toDefinition(ElementInterface $column)
{
return sprintf(
- '%s(%s) %s %s',
- $element->getType(),
- $element->getLength(),
- $this->nullable->toDefinition($element),
- $this->defaultDefinition->toDefinition($element)
+ '%s %s(%s) %s %s',
+ $this->resourceConnection->getConnection()->quoteIdentifier($column->getName()),
+ $column->getType(),
+ $column->getLength(),
+ $this->nullable->toDefinition($column),
+ !empty($column->getDefault()) ?
+ sprintf('DEFAULT "%s"', $column->getDefault()) : ''
);
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Constraints/ForeignKey.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Constraints/ForeignKey.php
index c52751d7aac2c..013479f39d722 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Constraints/ForeignKey.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Constraints/ForeignKey.php
@@ -38,27 +38,26 @@ public function __construct(ResourceConnection $resourceConnection)
}
/**
- * @param Reference $element
+ * @param Reference $foreignKey
* @inheritdoc
*/
- public function toDefinition(ElementInterface $element)
+ public function toDefinition(ElementInterface $foreignKey)
{
$adapter = $this->resourceConnection->getConnection(
- $element->getTable()->getResource()
+ $foreignKey->getTable()->getResource()
);
+ //CONSTRAINT `fk_name` FOREIGN KEY (`column`) REFERENCES `table` (`column`) option
/** @TODO: purge records, if the are not satisfied on delete statement */
$foreignKeySql = sprintf(
- "%s (%s) REFERENCES %s (%s)",
+ "CONSTRAINT %s %s (%s) REFERENCES %s (%s) %s",
+ $adapter->quoteIdentifier($foreignKey->getName()),
self::FOREIGN_KEY_NAME,
- $adapter->quoteIdentifier($element->getColumn()->getName()),
- $adapter->quoteIdentifier($element->getReferenceTable()->getName()),
- $adapter->quoteIdentifier($element->getReferenceColumn()->getName())
+ $adapter->quoteIdentifier($foreignKey->getColumn()->getName()),
+ $adapter->quoteIdentifier($foreignKey->getReferenceTable()->getName()),
+ $adapter->quoteIdentifier($foreignKey->getReferenceColumn()->getName()),
+ $foreignKey->getOnDelete() ? sprintf(" ON DELETE %s", $foreignKey->getOnDelete()) : ''
);
- if ($element->getOnDelete()) {
- $foreignKeySql .= sprintf(" ON DELETE %s", $element->getOnDelete());
- }
-
return $foreignKeySql;
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Constraints/Internal.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Constraints/Internal.php
index bceedef5c5cdf..c303ccb1136fa 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Constraints/Internal.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Constraints/Internal.php
@@ -47,24 +47,26 @@ public function __construct(ResourceConnection $resourceConnection)
}
/**
- * @param \Magento\Setup\Model\Declaration\Schema\Dto\Constraints\Internal $element
+ * @param \Magento\Setup\Model\Declaration\Schema\Dto\Constraints\Internal $constraint
* @inheritdoc
*/
- public function toDefinition(ElementInterface $element)
+ public function toDefinition(ElementInterface $constraint)
{
$adapter = $this->resourceConnection->getConnection(
- $element->getTable()->getResource()
+ $constraint->getTable()->getResource()
);
$columnsList = array_map(
- function (Column $column) use ($adapter) {
- return $adapter->quoteIdentifier($column->getName());
+ function ($columnName) use ($adapter) {
+ return $adapter->quoteIdentifier($columnName);
},
- $element->getColumns()
+ $constraint->getColumnNames()
);
+ $isPrimary = $constraint->getType() === 'primary';
return sprintf(
- '%s (%s)',
- $element->getType() === 'primary' ? 'PRIMARY KEY' : 'UNIQUE KEY',
+ 'CONSTRAINT %s %s (%s)',
+ $isPrimary ? '' : $adapter->quoteIdentifier($constraint->getName()),
+ $isPrimary ? 'PRIMARY KEY' : 'UNIQUE KEY',
implode(',', $columnsList)
);
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Index.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Index.php
index bb90f40c31c68..54f0c8dbbf2c8 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Index.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Index.php
@@ -24,21 +24,13 @@ class Index implements DbDefinitionProcessorInterface
*/
const INDEX_KEY_NAME = 'INDEX';
- /**
- * @var array
- */
- private static $indexTypeMapping = [
- 'FULTEXT' => 'fultext',
- 'BTREE' => 'btree',
- 'HASH' => 'hash'
- ];
-
/**
* @var ResourceConnection
*/
private $resourceConnection;
/**
+ * Index constructor.
* @param ResourceConnection $resourceConnection
*/
public function __construct(ResourceConnection $resourceConnection)
@@ -47,24 +39,31 @@ public function __construct(ResourceConnection $resourceConnection)
}
/**
- * @param \Magento\Setup\Model\Declaration\Schema\Dto\Index $element
+ * @param \Magento\Setup\Model\Declaration\Schema\Dto\Index $index
* @inheritdoc
*/
- public function toDefinition(ElementInterface $element)
+ public function toDefinition(ElementInterface $index)
{
- $adapter = $this->resourceConnection->getConnection(
- $element->getTable()->getResource()
- );
- $columnsList = array_map(
- function (Column $column) use ($adapter) {
- return $adapter->quoteIdentifier($column->getName());
- },
- $element->getColumns()
- );
+ $indexType = $index->getIndexType();
+ //There is no matter what connection to use -> so use default one
+ $adapter = $this->resourceConnection->getConnection();
+ $isFullText = $indexType === \Magento\Setup\Model\Declaration\Schema\Dto\Index::FULLTEXT_INDEX;
//as we used index types, that are similar to MySQL ones, we can just make it upper
+ //[FULLTEXT ]INDEX `name` [USING [BTREE|HASH]] (columns)
return sprintf(
- '(%s)',
- implode(',', $columnsList)
+ '%sINDEX %s%s (%s)',
+ $isFullText ? 'FULLTEXT ' : '',
+ $adapter->quoteIdentifier($index->getName()),
+ !$isFullText ? sprintf(' USING %s', strtoupper($indexType)) : '',
+ implode(
+ ',',
+ array_map(
+ function($columnName) use($adapter) {
+ return $adapter->quoteIdentifier($columnName);
+ },
+ $index->getColumnNames()
+ )
+ )
);
}
@@ -82,7 +81,7 @@ public function canBeApplied(ElementInterface $element)
public function fromDefinition(array $data)
{
return [
- 'indexType' => self::$indexTypeMapping[$data['Index_type']],
+ 'indexType' => strtolower($data['Index_type']),
'name' => $data['Key_name'],
'column' => [
$data['Column_name'] => $data['Column_name']
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/ValidationRules/CheckReferenceColumnHasIndex.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/ValidationRules/CheckReferenceColumnHasIndex.php
index 5c0f20358d49c..470a181fd6672 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/ValidationRules/CheckReferenceColumnHasIndex.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/ValidationRules/CheckReferenceColumnHasIndex.php
@@ -55,6 +55,6 @@ public function validate(Schema $schema)
}
}
- return $errors;
+ return [];
}
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Varchar.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Varchar.php
index fda2f1bb38d7f..4f25546d2edae 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Varchar.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Varchar.php
@@ -40,7 +40,7 @@ class Varchar extends Column implements
* @param Table $table
* @param bool $nullable
* @param int $length
- * @param float|int $default
+ * @param string $default
*/
public function __construct(
string $name,
@@ -48,7 +48,7 @@ public function __construct(
Table $table,
int $length,
bool $nullable = true,
- int $default = null
+ string $default = null
) {
parent::__construct($name, $type, $table);
$this->nullable = $nullable;
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Index.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Index.php
index 2deaf0320abb4..aeee5f2018e8f 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Index.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Index.php
@@ -48,8 +48,8 @@ public function __construct(
*/
public function create(array $data)
{
- if (!isset($data['type'])) {
- $data['type'] = self::DEFAULT_INDEX_TYPE;
+ if (!isset($data['indexType'])) {
+ $data['indexType'] = self::DEFAULT_INDEX_TYPE;
}
return $this->objectManager->create($this->className, $data);
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Timestamp.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Timestamp.php
index 783db24af4f22..d0e52b2d4bee1 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Timestamp.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Timestamp.php
@@ -76,8 +76,6 @@ public function create(array $data)
$data['default'] = self::NULL_TIMESTAMP;
}
- unset($data['nullable']);
-
return $this->objectManager->create($this->className, $data);
}
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Varchar.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Varchar.php
index 3e6f2da398e10..a3cf7352656f8 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Varchar.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Factories/Varchar.php
@@ -48,10 +48,7 @@ public function __construct(
*/
public function create(array $data)
{
- if (!isset($data['length'])) {
- $data['length'] = self::DEFAULT_TEXT_LENGTH;
- }
-
+ $data['length'] = isset($data['length']) ? (int) $data['length'] : self::DEFAULT_TEXT_LENGTH;
return $this->objectManager->create($this->className, $data);
}
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Index.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Index.php
index 0cf340fa0f908..aa9d2e89540b1 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Index.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Index.php
@@ -20,6 +20,11 @@ class Index extends GenericElement implements
*/
const TYPE = 'index';
+ /**
+ * Fulltext index type
+ */
+ const FULLTEXT_INDEX = "fulltext";
+
/**
* @var Table
*/
@@ -30,21 +35,29 @@ class Index extends GenericElement implements
*/
private $columns;
+ /**
+ * @var string
+ */
+ private $indexType;
+
/**
* @param string $name
* @param string $type
- * @param Table $table
- * @param array $columns
+ * @param Table $table
+ * @param array $columns
+ * @param string $indexType
*/
public function __construct(
string $name,
string $type,
Table $table,
- array $columns
+ array $columns,
+ string $indexType
) {
parent::__construct($name, $type);
$this->table = $table;
$this->columns = $columns;
+ $this->indexType = $indexType;
}
/**
@@ -74,15 +87,26 @@ public function getDiffSensitiveParams()
{
return [
'type' => $this->getType(),
- 'columns' => array_map(
- function (Column $column) {
- return $column->getName();
- },
- $this->getColumns()
- )
+ 'columns' => $this->getColumnNames(),
+ 'indexType' => $this->getIndexType()
];
}
+ /**
+ * Retrieve array with column names from column objects collections
+ *
+ * @return array
+ */
+ public function getColumnNames()
+ {
+ return array_map(
+ function (Column $column) {
+ return $column->getName();
+ },
+ $this->getColumns()
+ );
+ }
+
/**
* @inheritdoc
*/
@@ -90,4 +114,12 @@ public function getElementType()
{
return self::TYPE;
}
+
+ /**
+ * @return string
+ */
+ public function getIndexType()
+ {
+ return $this->indexType;
+ }
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/CreateTable.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/CreateTable.php
index 1db923dbff4e4..0eba7fa9649d4 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/CreateTable.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/CreateTable.php
@@ -75,7 +75,8 @@ public function doOperation(ElementHistory $elementHistory)
* @var ElementInterface $element
*/
foreach ($elements as $element) {
- $definition[$type][$element->getName()] = $this->definitionAggregator->toDefinition($element);
+ //Make definition as flat list
+ $definition[$type . $element->getName()] = $this->definitionAggregator->toDefinition($element);
}
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/ModifyElement.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/ModifyElement.php
index 83efa8a921bde..30065ff2cf8c4 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/ModifyElement.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/ModifyElement.php
@@ -101,7 +101,6 @@ private function modifyColumn(Column $column)
$this->dbSchemaWriter->modifyColumn(
$column->getTable()->getResource(),
- $column->getName(),
$column->getTable()->getName(),
$definition
);
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/etc/constraints/foreign.xsd b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/constraints/foreign.xsd
index 9cc94dfa3c2f4..f1eeb115e858f 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/etc/constraints/foreign.xsd
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/constraints/foreign.xsd
@@ -7,7 +7,7 @@
-->
-
+
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/etc/index.xsd b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/index.xsd
index 6083be187f97f..8eb99cf0d7f63 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/etc/index.xsd
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/index.xsd
@@ -18,7 +18,7 @@
-
+
diff --git a/setup/src/Magento/Setup/Model/Installer.php b/setup/src/Magento/Setup/Model/Installer.php
index 44f47e19000f1..90c1ddc87ed02 100644
--- a/setup/src/Magento/Setup/Model/Installer.php
+++ b/setup/src/Magento/Setup/Model/Installer.php
@@ -905,7 +905,8 @@ private function handleDBSchemaData($setup, $type)
}
$this->logProgress();
}
-
+ //Before recurring generate schema
+ $this->schemaPersistor->persist($this->schemaListener);
if ($type === 'schema') {
$this->log->log('Schema post-updates:');
$handlerType = 'schema-recurring';
@@ -922,8 +923,6 @@ private function handleDBSchemaData($setup, $type)
}
$this->logProgress();
}
-
- $this->schemaPersistor->persist($this->schemaListener);
}
/**
diff --git a/setup/src/Magento/Setup/Model/SchemaListener.php b/setup/src/Magento/Setup/Model/SchemaListener.php
index 0710e34405f5d..c9bc7a6e7ff8f 100644
--- a/setup/src/Magento/Setup/Model/SchemaListener.php
+++ b/setup/src/Magento/Setup/Model/SchemaListener.php
@@ -70,7 +70,9 @@ public function __construct(array $definitionMappers)
*/
public function dropForeignKey($tableName, $fkName)
{
- $this->tables[$this->moduleName][$tableName]['constraints']['foreign'][$fkName] = ['disabled' => 1];
+// $this->tables[$this->moduleName][$tableName]['constraints']['foreign'][$fkName] = [
+// 'disabled' => 1,
+// ];
}
/**
@@ -84,7 +86,7 @@ private function castColumnDefinition($definition, $columnName)
$definition = ['type' => $definition];
}
$definition = $this->doColumnMapping($definition);
- $definition['name'] = $columnName;
+ $definition['name'] = strtolower($columnName);
$definition = $this->definitionMappers[$definition['type']]->convertToDefinition($definition);
if (isset($definition['default']) && $definition['default'] === false) {
$definition['default'] = null; //uniform default values
@@ -101,9 +103,9 @@ private function castColumnDefinition($definition, $columnName)
*/
private function addPrimaryKeyIfExists($tableName, $columnName, $definition)
{
- if (isset($definition['primary'])) {
+ if (isset($definition['primary']) && $definition['primary']) {
if (isset($this->tables[$this->moduleName][$tableName]['constraints']['primary'])) {
- $this->tables[$this->moduleName][$tableName]['constraints']['primary']['PRIMARY'] = array_replace_recursive(
+ $this->tables[$this->moduleName][$tableName]['constraints']['primary']['PRIMARY'] = array_merge_recursive(
$this->tables[$this->moduleName][$tableName]['constraints']['primary']['PRIMARY'],
[
'columns' => [strtolower($columnName)]
@@ -166,9 +168,10 @@ public function addColumn($tableName, $columnName, $definition)
public function changeColumn($tableName, $oldColumnName, $newColumnName, $definition)
{
$this->addColumn($tableName, $newColumnName, $definition);
- $this->tables[$this->moduleName][$tableName]['columns'][strtolower($oldColumnName)] = [
- 'disabled' => 1
- ];
+
+ if (isset($this->tables[$this->moduleName][$tableName]['columns'][strtolower($oldColumnName)])) {
+ $this->tables[$this->moduleName][$tableName]['columns'][strtolower($oldColumnName)]['disabled'] = 1;
+ }
//remove old column if not equal
}
@@ -249,7 +252,7 @@ public function addIndex(
$indexType = 'btree';
}
$this->tables[$this->moduleName][$tableName]['indexes'][$indexName] =
- ['columns' => $this->prepareIndexColumns($fields), 'type' => $indexType];
+ ['columns' => $this->prepareIndexColumns($fields), 'indexType' => $indexType];
} else {
$this->tables[$this->moduleName][$tableName]['constraints'][$indexType][$indexName] =
['columns' => $this->prepareIndexColumns($fields)];
diff --git a/setup/src/Magento/Setup/Model/SchemaListenerDefinition/DecimalDefinition.php b/setup/src/Magento/Setup/Model/SchemaListenerDefinition/DecimalDefinition.php
index 1741827f5a635..42d56c8fcd008 100644
--- a/setup/src/Magento/Setup/Model/SchemaListenerDefinition/DecimalDefinition.php
+++ b/setup/src/Magento/Setup/Model/SchemaListenerDefinition/DecimalDefinition.php
@@ -6,8 +6,6 @@
namespace Magento\Setup\Model\SchemaListenerDefinition;
-use Magento\Framework\DB\Ddl\Table;
-
/**
* Convert definition for all decimal types: decimal, float, double
*/
@@ -31,11 +29,13 @@ public function convertToDefinition(array $definition)
return [
'xsi:type' => $definition['type'],
'name' => $definition['name'],
- 'scale' => $definition['scale'] ?? self::DEFAULT_SCALE,
- 'precision' => $definition['precision'] ?? self::DEFAULT_PRECISION,
+ //In previos adapter this 2 fields were switched, so we need to switch again
+ 'scale' => $definition['precision'] ?? self::DEFAULT_PRECISION,
+ 'precission' => $definition['scale'] ?? self::DEFAULT_SCALE,
'unsigned' => $definition['unsigned'] ?? false,
'nullable' => $definition['nullable'] ?? true,
- 'default' => $definition['default'] ?? null
+ 'default' => $definition['default'] ?? null,
+ 'primary' => $definition['primary'] ?? false
];
}
}
diff --git a/setup/src/Magento/Setup/Model/SchemaListenerDefinition/TextBlobDefinition.php b/setup/src/Magento/Setup/Model/SchemaListenerDefinition/TextBlobDefinition.php
index 7b0b3047b62a9..ae28cbf052f60 100644
--- a/setup/src/Magento/Setup/Model/SchemaListenerDefinition/TextBlobDefinition.php
+++ b/setup/src/Magento/Setup/Model/SchemaListenerDefinition/TextBlobDefinition.php
@@ -67,7 +67,8 @@ public function convertToDefinition(array $definition)
$newDefinition = [
'xsi:type' => $cType,
'name' => $definition['name'],
- 'nullable' => $definition['nullable'] ?? true
+ 'nullable' => $definition['nullable'] ?? true,
+ 'primary' => $definition['primary'] ?? false
];
if (in_array($cType, ['varchar', 'varbinary'])) {
diff --git a/setup/src/Magento/Setup/Model/SchemaPersistor.php b/setup/src/Magento/Setup/Model/SchemaPersistor.php
index 42895df6c20e4..8178940b4bdf6 100644
--- a/setup/src/Magento/Setup/Model/SchemaPersistor.php
+++ b/setup/src/Magento/Setup/Model/SchemaPersistor.php
@@ -67,6 +67,17 @@ public function persist(SchemaListener $schemaListener)
}
}
+ /**
+ * Cast boolean types to string
+ *
+ * @param bool $boolean
+ * @return string
+ */
+ private function castBooleanToString($boolean)
+ {
+ return $boolean ? 'true' : 'false';
+ }
+
/**
* Convert columns from array to XML format
*
@@ -77,12 +88,20 @@ public function persist(SchemaListener $schemaListener)
private function processColumns(array $tableData, \SimpleXMLElement $table)
{
if (isset($tableData['columns'])) {
- foreach ($tableData['columns'] as $columnData) {
+ foreach ($tableData['columns'] as $columnName => $columnData) {
$domColumn = $table->addChild('column');
$domColumn->addAttribute('xsi:type', $columnData['xsi:type'], 'xsi');
unset($columnData['xsi:type']);
foreach ($columnData as $attributeKey => $attributeValue) {
+ if ($attributeValue === null) {
+ continue;
+ }
+
+ if (is_bool($attributeValue)) {
+ $attributeValue = $this->castBooleanToString($attributeValue);
+ }
+
$domColumn->addAttribute($attributeKey, $attributeValue);
}
}
@@ -104,7 +123,7 @@ private function processIndexes(array $tableData, \SimpleXMLElement $table)
foreach ($tableData['indexes'] as $indexName => $indexData) {
$domIndex = $table->addChild('index');
$domIndex->addAttribute('name', $indexName);
- $domIndex->addAttribute('type', $indexData['type']);
+ $domIndex->addAttribute('indexType', $indexData['indexType']);
foreach ($indexData['columns'] as $column) {
$columnXml = $domIndex->addChild('column');
@@ -128,9 +147,10 @@ private function processConstraints(array $tableData, \SimpleXMLElement $table)
if (isset($tableData['constraints'])) {
foreach ($tableData['constraints'] as $constraintType => $constraints) {
if ($constraintType === 'foreign') {
- foreach ($constraints as $constraintData) {
+ foreach ($constraints as $name => $constraintData) {
$constraintDom = $table->addChild('constraint');
$constraintDom->addAttribute('xsi:type', $constraintType, 'xsi');
+ $constraintDom->addAttribute('name', $name);
foreach ($constraintData as $attributeKey => $attributeValue) {
$constraintDom->addAttribute($attributeKey, $attributeValue);
From 2fb1956dc0e7544bdd49aac6fd4d793ee76457b5 Mon Sep 17 00:00:00 2001
From: Sergii Kovalenko
Date: Tue, 2 Jan 2018 14:11:47 +0200
Subject: [PATCH 253/904] MAGETWO-85326: Tool for generating schema
--add schemas
---
.../AdminNotification/etc/db_schema.xml | 38 +
.../Magento/Authorization/etc/db_schema.xml | 50 +
app/code/Magento/Bundle/etc/db_schema.xml | 274 +++
app/code/Magento/Captcha/etc/db_schema.xml | 14 +
app/code/Magento/Catalog/etc/db_schema.xml | 1517 ++++++++++++++
.../CatalogInventory/etc/db_schema.xml | 144 ++
.../Magento/CatalogRule/etc/db_schema.xml | 179 ++
.../Magento/CatalogSearch/etc/db_schema.xml | 8 +
.../CatalogUrlRewrite/etc/db_schema.xml | 19 +
.../CheckoutAgreements/etc/db_schema.xml | 34 +
app/code/Magento/Cms/etc/db_schema.xml | 90 +
app/code/Magento/Config/etc/db_schema.xml | 20 +
.../ConfigurableProduct/etc/db_schema.xml | 74 +
app/code/Magento/Cron/etc/db_schema.xml | 24 +
app/code/Magento/Customer/etc/db_schema.xml | 485 +++++
app/code/Magento/Directory/etc/db_schema.xml | 66 +
.../Magento/Downloadable/etc/db_schema.xml | 228 +++
app/code/Magento/Eav/etc/db_schema.xml | 568 ++++++
app/code/Magento/Email/etc/db_schema.xml | 30 +
.../Magento/GiftMessage/etc/db_schema.xml | 15 +
.../Magento/GoogleOptimizer/etc/db_schema.xml | 21 +
.../Magento/ImportExport/etc/db_schema.xml | 26 +
app/code/Magento/Indexer/etc/db_schema.xml | 34 +
.../Magento/Integration/etc/db_schema.xml | 115 ++
.../NewRelicReporting/etc/db_schema.xml | 53 +
app/code/Magento/Newsletter/etc/db_schema.xml | 145 ++
.../Magento/OfflineShipping/etc/db_schema.xml | 50 +
app/code/Magento/Paypal/etc/db_schema.xml | 120 ++
app/code/Magento/Persistent/etc/db_schema.xml | 35 +
.../Magento/ProductAlert/etc/db_schema.xml | 78 +
.../Magento/ProductVideo/etc/db_schema.xml | 25 +
app/code/Magento/Quote/etc/db_schema.xml | 438 +++++
app/code/Magento/Reports/etc/db_schema.xml | 222 +++
app/code/Magento/Review/etc/db_schema.xml | 257 +++
app/code/Magento/Sales/etc/db_schema.xml | 1747 +++++++++++++++++
app/code/Magento/SalesRule/etc/db_schema.xml | 324 +++
.../Magento/SalesSequence/etc/db_schema.xml | 40 +
app/code/Magento/Search/etc/db_schema.xml | 72 +
app/code/Magento/Security/etc/db_schema.xml | 41 +
app/code/Magento/SendFriend/etc/db_schema.xml | 20 +
app/code/Magento/Sitemap/etc/db_schema.xml | 21 +
app/code/Magento/Store/etc/db_schema.xml | 85 +
app/code/Magento/Swatches/etc/db_schema.xml | 30 +
app/code/Magento/Tax/etc/db_schema.xml | 180 ++
.../etc/db_schema.xml | 19 +
.../column_modifications/db_schema.xml | 67 +
.../revisions/column_removals/db_schema.xml | 65 +
.../constraint_modifications/db_schema.xml | 82 +
.../fail_on_column_declaration/db_schema.xml | 14 +
.../db_schema.xml | 17 +
.../foreign_key_interpreter/db_schema.xml | 18 +
.../revisions/old_diff/db_schema.xml | 38 +
app/code/Magento/Theme/etc/db_schema.xml | 49 +
.../Magento/Translation/etc/db_schema.xml | 25 +
app/code/Magento/Ui/etc/db_schema.xml | 25 +
app/code/Magento/UrlRewrite/etc/db_schema.xml | 32 +
app/code/Magento/User/etc/db_schema.xml | 53 +
app/code/Magento/Variable/etc/db_schema.xml | 38 +
app/code/Magento/Vault/etc/db_schema.xml | 45 +
app/code/Magento/Weee/etc/db_schema.xml | 43 +
app/code/Magento/Widget/etc/db_schema.xml | 112 ++
app/code/Magento/Wishlist/etc/db_schema.xml | 68 +
setup/src/Magento/Setup/Model/Installer.php | 4 +-
63 files changed, 8868 insertions(+), 2 deletions(-)
create mode 100644 app/code/Magento/AdminNotification/etc/db_schema.xml
create mode 100644 app/code/Magento/Authorization/etc/db_schema.xml
create mode 100644 app/code/Magento/Bundle/etc/db_schema.xml
create mode 100644 app/code/Magento/Captcha/etc/db_schema.xml
create mode 100644 app/code/Magento/Catalog/etc/db_schema.xml
create mode 100644 app/code/Magento/CatalogInventory/etc/db_schema.xml
create mode 100644 app/code/Magento/CatalogRule/etc/db_schema.xml
create mode 100644 app/code/Magento/CatalogSearch/etc/db_schema.xml
create mode 100644 app/code/Magento/CatalogUrlRewrite/etc/db_schema.xml
create mode 100644 app/code/Magento/CheckoutAgreements/etc/db_schema.xml
create mode 100644 app/code/Magento/Cms/etc/db_schema.xml
create mode 100644 app/code/Magento/Config/etc/db_schema.xml
create mode 100644 app/code/Magento/ConfigurableProduct/etc/db_schema.xml
create mode 100644 app/code/Magento/Cron/etc/db_schema.xml
create mode 100644 app/code/Magento/Customer/etc/db_schema.xml
create mode 100644 app/code/Magento/Directory/etc/db_schema.xml
create mode 100644 app/code/Magento/Downloadable/etc/db_schema.xml
create mode 100644 app/code/Magento/Eav/etc/db_schema.xml
create mode 100644 app/code/Magento/Email/etc/db_schema.xml
create mode 100644 app/code/Magento/GiftMessage/etc/db_schema.xml
create mode 100644 app/code/Magento/GoogleOptimizer/etc/db_schema.xml
create mode 100644 app/code/Magento/ImportExport/etc/db_schema.xml
create mode 100644 app/code/Magento/Indexer/etc/db_schema.xml
create mode 100644 app/code/Magento/Integration/etc/db_schema.xml
create mode 100644 app/code/Magento/NewRelicReporting/etc/db_schema.xml
create mode 100644 app/code/Magento/Newsletter/etc/db_schema.xml
create mode 100644 app/code/Magento/OfflineShipping/etc/db_schema.xml
create mode 100644 app/code/Magento/Paypal/etc/db_schema.xml
create mode 100644 app/code/Magento/Persistent/etc/db_schema.xml
create mode 100644 app/code/Magento/ProductAlert/etc/db_schema.xml
create mode 100644 app/code/Magento/ProductVideo/etc/db_schema.xml
create mode 100644 app/code/Magento/Quote/etc/db_schema.xml
create mode 100644 app/code/Magento/Reports/etc/db_schema.xml
create mode 100644 app/code/Magento/Review/etc/db_schema.xml
create mode 100644 app/code/Magento/Sales/etc/db_schema.xml
create mode 100644 app/code/Magento/SalesRule/etc/db_schema.xml
create mode 100644 app/code/Magento/SalesSequence/etc/db_schema.xml
create mode 100644 app/code/Magento/Search/etc/db_schema.xml
create mode 100644 app/code/Magento/Security/etc/db_schema.xml
create mode 100644 app/code/Magento/SendFriend/etc/db_schema.xml
create mode 100644 app/code/Magento/Sitemap/etc/db_schema.xml
create mode 100644 app/code/Magento/Store/etc/db_schema.xml
create mode 100644 app/code/Magento/Swatches/etc/db_schema.xml
create mode 100644 app/code/Magento/Tax/etc/db_schema.xml
create mode 100644 app/code/Magento/TestSetupDeclarationModule1/etc/db_schema.xml
create mode 100644 app/code/Magento/TestSetupDeclarationModule1/revisions/column_modifications/db_schema.xml
create mode 100644 app/code/Magento/TestSetupDeclarationModule1/revisions/column_removals/db_schema.xml
create mode 100644 app/code/Magento/TestSetupDeclarationModule1/revisions/constraint_modifications/db_schema.xml
create mode 100644 app/code/Magento/TestSetupDeclarationModule1/revisions/fail_on_column_declaration/db_schema.xml
create mode 100644 app/code/Magento/TestSetupDeclarationModule1/revisions/fail_on_unique_key_declaration/db_schema.xml
create mode 100644 app/code/Magento/TestSetupDeclarationModule1/revisions/foreign_key_interpreter/db_schema.xml
create mode 100644 app/code/Magento/TestSetupDeclarationModule1/revisions/old_diff/db_schema.xml
create mode 100644 app/code/Magento/Theme/etc/db_schema.xml
create mode 100644 app/code/Magento/Translation/etc/db_schema.xml
create mode 100644 app/code/Magento/Ui/etc/db_schema.xml
create mode 100644 app/code/Magento/UrlRewrite/etc/db_schema.xml
create mode 100644 app/code/Magento/User/etc/db_schema.xml
create mode 100644 app/code/Magento/Variable/etc/db_schema.xml
create mode 100644 app/code/Magento/Vault/etc/db_schema.xml
create mode 100644 app/code/Magento/Weee/etc/db_schema.xml
create mode 100644 app/code/Magento/Widget/etc/db_schema.xml
create mode 100644 app/code/Magento/Wishlist/etc/db_schema.xml
diff --git a/app/code/Magento/AdminNotification/etc/db_schema.xml b/app/code/Magento/AdminNotification/etc/db_schema.xml
new file mode 100644
index 0000000000000..8d8bff59b635b
--- /dev/null
+++ b/app/code/Magento/AdminNotification/etc/db_schema.xml
@@ -0,0 +1,38 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Authorization/etc/db_schema.xml b/app/code/Magento/Authorization/etc/db_schema.xml
new file mode 100644
index 0000000000000..cb8fd331b47ea
--- /dev/null
+++ b/app/code/Magento/Authorization/etc/db_schema.xml
@@ -0,0 +1,50 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Bundle/etc/db_schema.xml b/app/code/Magento/Bundle/etc/db_schema.xml
new file mode 100644
index 0000000000000..4189da661cf0f
--- /dev/null
+++ b/app/code/Magento/Bundle/etc/db_schema.xml
@@ -0,0 +1,274 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Captcha/etc/db_schema.xml b/app/code/Magento/Captcha/etc/db_schema.xml
new file mode 100644
index 0000000000000..310f47c6fa9c6
--- /dev/null
+++ b/app/code/Magento/Captcha/etc/db_schema.xml
@@ -0,0 +1,14 @@
+
+
+
+
diff --git a/app/code/Magento/Catalog/etc/db_schema.xml b/app/code/Magento/Catalog/etc/db_schema.xml
new file mode 100644
index 0000000000000..d911988f73dcf
--- /dev/null
+++ b/app/code/Magento/Catalog/etc/db_schema.xml
@@ -0,0 +1,1517 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/CatalogInventory/etc/db_schema.xml b/app/code/Magento/CatalogInventory/etc/db_schema.xml
new file mode 100644
index 0000000000000..ec184d6da1a24
--- /dev/null
+++ b/app/code/Magento/CatalogInventory/etc/db_schema.xml
@@ -0,0 +1,144 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/CatalogRule/etc/db_schema.xml b/app/code/Magento/CatalogRule/etc/db_schema.xml
new file mode 100644
index 0000000000000..16755bdf75d96
--- /dev/null
+++ b/app/code/Magento/CatalogRule/etc/db_schema.xml
@@ -0,0 +1,179 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/CatalogSearch/etc/db_schema.xml b/app/code/Magento/CatalogSearch/etc/db_schema.xml
new file mode 100644
index 0000000000000..d4d77163bce9c
--- /dev/null
+++ b/app/code/Magento/CatalogSearch/etc/db_schema.xml
@@ -0,0 +1,8 @@
+
+
+
+
diff --git a/app/code/Magento/CatalogUrlRewrite/etc/db_schema.xml b/app/code/Magento/CatalogUrlRewrite/etc/db_schema.xml
new file mode 100644
index 0000000000000..ac6321056bc6f
--- /dev/null
+++ b/app/code/Magento/CatalogUrlRewrite/etc/db_schema.xml
@@ -0,0 +1,19 @@
+
+
+
+
diff --git a/app/code/Magento/CheckoutAgreements/etc/db_schema.xml b/app/code/Magento/CheckoutAgreements/etc/db_schema.xml
new file mode 100644
index 0000000000000..5b732c47cc06f
--- /dev/null
+++ b/app/code/Magento/CheckoutAgreements/etc/db_schema.xml
@@ -0,0 +1,34 @@
+
+
+
+
+
diff --git a/app/code/Magento/Cms/etc/db_schema.xml b/app/code/Magento/Cms/etc/db_schema.xml
new file mode 100644
index 0000000000000..c73aa2c546635
--- /dev/null
+++ b/app/code/Magento/Cms/etc/db_schema.xml
@@ -0,0 +1,90 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Config/etc/db_schema.xml b/app/code/Magento/Config/etc/db_schema.xml
new file mode 100644
index 0000000000000..6d6216bc8abe2
--- /dev/null
+++ b/app/code/Magento/Config/etc/db_schema.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/ConfigurableProduct/etc/db_schema.xml b/app/code/Magento/ConfigurableProduct/etc/db_schema.xml
new file mode 100644
index 0000000000000..2cbc77e488f23
--- /dev/null
+++ b/app/code/Magento/ConfigurableProduct/etc/db_schema.xml
@@ -0,0 +1,74 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Cron/etc/db_schema.xml b/app/code/Magento/Cron/etc/db_schema.xml
new file mode 100644
index 0000000000000..f88422c2159c5
--- /dev/null
+++ b/app/code/Magento/Cron/etc/db_schema.xml
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Customer/etc/db_schema.xml b/app/code/Magento/Customer/etc/db_schema.xml
new file mode 100644
index 0000000000000..df61fd9107826
--- /dev/null
+++ b/app/code/Magento/Customer/etc/db_schema.xml
@@ -0,0 +1,485 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Directory/etc/db_schema.xml b/app/code/Magento/Directory/etc/db_schema.xml
new file mode 100644
index 0000000000000..b0ec8f46a10e4
--- /dev/null
+++ b/app/code/Magento/Directory/etc/db_schema.xml
@@ -0,0 +1,66 @@
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Downloadable/etc/db_schema.xml b/app/code/Magento/Downloadable/etc/db_schema.xml
new file mode 100644
index 0000000000000..4eb425ca80d13
--- /dev/null
+++ b/app/code/Magento/Downloadable/etc/db_schema.xml
@@ -0,0 +1,228 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Eav/etc/db_schema.xml b/app/code/Magento/Eav/etc/db_schema.xml
new file mode 100644
index 0000000000000..4c344784666fe
--- /dev/null
+++ b/app/code/Magento/Eav/etc/db_schema.xml
@@ -0,0 +1,568 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Email/etc/db_schema.xml b/app/code/Magento/Email/etc/db_schema.xml
new file mode 100644
index 0000000000000..8fa43963bc0cd
--- /dev/null
+++ b/app/code/Magento/Email/etc/db_schema.xml
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/GiftMessage/etc/db_schema.xml b/app/code/Magento/GiftMessage/etc/db_schema.xml
new file mode 100644
index 0000000000000..072eeeb50f3d5
--- /dev/null
+++ b/app/code/Magento/GiftMessage/etc/db_schema.xml
@@ -0,0 +1,15 @@
+
+
+
+
diff --git a/app/code/Magento/GoogleOptimizer/etc/db_schema.xml b/app/code/Magento/GoogleOptimizer/etc/db_schema.xml
new file mode 100644
index 0000000000000..7f6b3783919e7
--- /dev/null
+++ b/app/code/Magento/GoogleOptimizer/etc/db_schema.xml
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/ImportExport/etc/db_schema.xml b/app/code/Magento/ImportExport/etc/db_schema.xml
new file mode 100644
index 0000000000000..a9f6ae4933b19
--- /dev/null
+++ b/app/code/Magento/ImportExport/etc/db_schema.xml
@@ -0,0 +1,26 @@
+
+
+
+
+
diff --git a/app/code/Magento/Indexer/etc/db_schema.xml b/app/code/Magento/Indexer/etc/db_schema.xml
new file mode 100644
index 0000000000000..5e59dfda6b71c
--- /dev/null
+++ b/app/code/Magento/Indexer/etc/db_schema.xml
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Integration/etc/db_schema.xml b/app/code/Magento/Integration/etc/db_schema.xml
new file mode 100644
index 0000000000000..24e41c88cc519
--- /dev/null
+++ b/app/code/Magento/Integration/etc/db_schema.xml
@@ -0,0 +1,115 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/NewRelicReporting/etc/db_schema.xml b/app/code/Magento/NewRelicReporting/etc/db_schema.xml
new file mode 100644
index 0000000000000..53ae04d48ebf5
--- /dev/null
+++ b/app/code/Magento/NewRelicReporting/etc/db_schema.xml
@@ -0,0 +1,53 @@
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Newsletter/etc/db_schema.xml b/app/code/Magento/Newsletter/etc/db_schema.xml
new file mode 100644
index 0000000000000..0d98d813b9cf0
--- /dev/null
+++ b/app/code/Magento/Newsletter/etc/db_schema.xml
@@ -0,0 +1,145 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/OfflineShipping/etc/db_schema.xml b/app/code/Magento/OfflineShipping/etc/db_schema.xml
new file mode 100644
index 0000000000000..2416dc984d6ad
--- /dev/null
+++ b/app/code/Magento/OfflineShipping/etc/db_schema.xml
@@ -0,0 +1,50 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Paypal/etc/db_schema.xml b/app/code/Magento/Paypal/etc/db_schema.xml
new file mode 100644
index 0000000000000..2359875539a94
--- /dev/null
+++ b/app/code/Magento/Paypal/etc/db_schema.xml
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Persistent/etc/db_schema.xml b/app/code/Magento/Persistent/etc/db_schema.xml
new file mode 100644
index 0000000000000..e0f410fab543e
--- /dev/null
+++ b/app/code/Magento/Persistent/etc/db_schema.xml
@@ -0,0 +1,35 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/ProductAlert/etc/db_schema.xml b/app/code/Magento/ProductAlert/etc/db_schema.xml
new file mode 100644
index 0000000000000..2c41514052407
--- /dev/null
+++ b/app/code/Magento/ProductAlert/etc/db_schema.xml
@@ -0,0 +1,78 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/ProductVideo/etc/db_schema.xml b/app/code/Magento/ProductVideo/etc/db_schema.xml
new file mode 100644
index 0000000000000..ffad24fab7fcb
--- /dev/null
+++ b/app/code/Magento/ProductVideo/etc/db_schema.xml
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Quote/etc/db_schema.xml b/app/code/Magento/Quote/etc/db_schema.xml
new file mode 100644
index 0000000000000..c7177ac0b9048
--- /dev/null
+++ b/app/code/Magento/Quote/etc/db_schema.xml
@@ -0,0 +1,438 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Reports/etc/db_schema.xml b/app/code/Magento/Reports/etc/db_schema.xml
new file mode 100644
index 0000000000000..04799d3c87f4f
--- /dev/null
+++ b/app/code/Magento/Reports/etc/db_schema.xml
@@ -0,0 +1,222 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Review/etc/db_schema.xml b/app/code/Magento/Review/etc/db_schema.xml
new file mode 100644
index 0000000000000..470bdb38dd165
--- /dev/null
+++ b/app/code/Magento/Review/etc/db_schema.xml
@@ -0,0 +1,257 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Sales/etc/db_schema.xml b/app/code/Magento/Sales/etc/db_schema.xml
new file mode 100644
index 0000000000000..8e07cf175c74a
--- /dev/null
+++ b/app/code/Magento/Sales/etc/db_schema.xml
@@ -0,0 +1,1747 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/SalesRule/etc/db_schema.xml b/app/code/Magento/SalesRule/etc/db_schema.xml
new file mode 100644
index 0000000000000..6de0377390ff0
--- /dev/null
+++ b/app/code/Magento/SalesRule/etc/db_schema.xml
@@ -0,0 +1,324 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/SalesSequence/etc/db_schema.xml b/app/code/Magento/SalesSequence/etc/db_schema.xml
new file mode 100644
index 0000000000000..f49ca61f1637e
--- /dev/null
+++ b/app/code/Magento/SalesSequence/etc/db_schema.xml
@@ -0,0 +1,40 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Search/etc/db_schema.xml b/app/code/Magento/Search/etc/db_schema.xml
new file mode 100644
index 0000000000000..d478536cc4b26
--- /dev/null
+++ b/app/code/Magento/Search/etc/db_schema.xml
@@ -0,0 +1,72 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Security/etc/db_schema.xml b/app/code/Magento/Security/etc/db_schema.xml
new file mode 100644
index 0000000000000..6bbc85b074fd9
--- /dev/null
+++ b/app/code/Magento/Security/etc/db_schema.xml
@@ -0,0 +1,41 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/SendFriend/etc/db_schema.xml b/app/code/Magento/SendFriend/etc/db_schema.xml
new file mode 100644
index 0000000000000..36b2fce036362
--- /dev/null
+++ b/app/code/Magento/SendFriend/etc/db_schema.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Sitemap/etc/db_schema.xml b/app/code/Magento/Sitemap/etc/db_schema.xml
new file mode 100644
index 0000000000000..e66e4141c817f
--- /dev/null
+++ b/app/code/Magento/Sitemap/etc/db_schema.xml
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Store/etc/db_schema.xml b/app/code/Magento/Store/etc/db_schema.xml
new file mode 100644
index 0000000000000..5f878b541077c
--- /dev/null
+++ b/app/code/Magento/Store/etc/db_schema.xml
@@ -0,0 +1,85 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Swatches/etc/db_schema.xml b/app/code/Magento/Swatches/etc/db_schema.xml
new file mode 100644
index 0000000000000..90ab620b7a45f
--- /dev/null
+++ b/app/code/Magento/Swatches/etc/db_schema.xml
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Tax/etc/db_schema.xml b/app/code/Magento/Tax/etc/db_schema.xml
new file mode 100644
index 0000000000000..db2415688f6a7
--- /dev/null
+++ b/app/code/Magento/Tax/etc/db_schema.xml
@@ -0,0 +1,180 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/TestSetupDeclarationModule1/etc/db_schema.xml b/app/code/Magento/TestSetupDeclarationModule1/etc/db_schema.xml
new file mode 100644
index 0000000000000..4206ddc16be78
--- /dev/null
+++ b/app/code/Magento/TestSetupDeclarationModule1/etc/db_schema.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
diff --git a/app/code/Magento/TestSetupDeclarationModule1/revisions/column_modifications/db_schema.xml b/app/code/Magento/TestSetupDeclarationModule1/revisions/column_modifications/db_schema.xml
new file mode 100644
index 0000000000000..7d0cc92cd2398
--- /dev/null
+++ b/app/code/Magento/TestSetupDeclarationModule1/revisions/column_modifications/db_schema.xml
@@ -0,0 +1,67 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/TestSetupDeclarationModule1/revisions/column_removals/db_schema.xml b/app/code/Magento/TestSetupDeclarationModule1/revisions/column_removals/db_schema.xml
new file mode 100644
index 0000000000000..804110f7674be
--- /dev/null
+++ b/app/code/Magento/TestSetupDeclarationModule1/revisions/column_removals/db_schema.xml
@@ -0,0 +1,65 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/TestSetupDeclarationModule1/revisions/constraint_modifications/db_schema.xml b/app/code/Magento/TestSetupDeclarationModule1/revisions/constraint_modifications/db_schema.xml
new file mode 100644
index 0000000000000..eb128d3a35899
--- /dev/null
+++ b/app/code/Magento/TestSetupDeclarationModule1/revisions/constraint_modifications/db_schema.xml
@@ -0,0 +1,82 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/TestSetupDeclarationModule1/revisions/fail_on_column_declaration/db_schema.xml b/app/code/Magento/TestSetupDeclarationModule1/revisions/fail_on_column_declaration/db_schema.xml
new file mode 100644
index 0000000000000..fac0e4011e9b6
--- /dev/null
+++ b/app/code/Magento/TestSetupDeclarationModule1/revisions/fail_on_column_declaration/db_schema.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
diff --git a/app/code/Magento/TestSetupDeclarationModule1/revisions/fail_on_unique_key_declaration/db_schema.xml b/app/code/Magento/TestSetupDeclarationModule1/revisions/fail_on_unique_key_declaration/db_schema.xml
new file mode 100644
index 0000000000000..70aba460807a0
--- /dev/null
+++ b/app/code/Magento/TestSetupDeclarationModule1/revisions/fail_on_unique_key_declaration/db_schema.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
diff --git a/app/code/Magento/TestSetupDeclarationModule1/revisions/foreign_key_interpreter/db_schema.xml b/app/code/Magento/TestSetupDeclarationModule1/revisions/foreign_key_interpreter/db_schema.xml
new file mode 100644
index 0000000000000..5cc5f4af12428
--- /dev/null
+++ b/app/code/Magento/TestSetupDeclarationModule1/revisions/foreign_key_interpreter/db_schema.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
diff --git a/app/code/Magento/TestSetupDeclarationModule1/revisions/old_diff/db_schema.xml b/app/code/Magento/TestSetupDeclarationModule1/revisions/old_diff/db_schema.xml
new file mode 100644
index 0000000000000..f0bd23886d340
--- /dev/null
+++ b/app/code/Magento/TestSetupDeclarationModule1/revisions/old_diff/db_schema.xml
@@ -0,0 +1,38 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Theme/etc/db_schema.xml b/app/code/Magento/Theme/etc/db_schema.xml
new file mode 100644
index 0000000000000..884a09e9c39c8
--- /dev/null
+++ b/app/code/Magento/Theme/etc/db_schema.xml
@@ -0,0 +1,49 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Translation/etc/db_schema.xml b/app/code/Magento/Translation/etc/db_schema.xml
new file mode 100644
index 0000000000000..34fb081774290
--- /dev/null
+++ b/app/code/Magento/Translation/etc/db_schema.xml
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Ui/etc/db_schema.xml b/app/code/Magento/Ui/etc/db_schema.xml
new file mode 100644
index 0000000000000..1215732f410a9
--- /dev/null
+++ b/app/code/Magento/Ui/etc/db_schema.xml
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/UrlRewrite/etc/db_schema.xml b/app/code/Magento/UrlRewrite/etc/db_schema.xml
new file mode 100644
index 0000000000000..51f559558e5c2
--- /dev/null
+++ b/app/code/Magento/UrlRewrite/etc/db_schema.xml
@@ -0,0 +1,32 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/User/etc/db_schema.xml b/app/code/Magento/User/etc/db_schema.xml
new file mode 100644
index 0000000000000..1397969538d16
--- /dev/null
+++ b/app/code/Magento/User/etc/db_schema.xml
@@ -0,0 +1,53 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Variable/etc/db_schema.xml b/app/code/Magento/Variable/etc/db_schema.xml
new file mode 100644
index 0000000000000..fe3d16c87718b
--- /dev/null
+++ b/app/code/Magento/Variable/etc/db_schema.xml
@@ -0,0 +1,38 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Vault/etc/db_schema.xml b/app/code/Magento/Vault/etc/db_schema.xml
new file mode 100644
index 0000000000000..f99fa7d941abb
--- /dev/null
+++ b/app/code/Magento/Vault/etc/db_schema.xml
@@ -0,0 +1,45 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Weee/etc/db_schema.xml b/app/code/Magento/Weee/etc/db_schema.xml
new file mode 100644
index 0000000000000..b513bf9689080
--- /dev/null
+++ b/app/code/Magento/Weee/etc/db_schema.xml
@@ -0,0 +1,43 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Widget/etc/db_schema.xml b/app/code/Magento/Widget/etc/db_schema.xml
new file mode 100644
index 0000000000000..6f0e4b190ead6
--- /dev/null
+++ b/app/code/Magento/Widget/etc/db_schema.xml
@@ -0,0 +1,112 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Wishlist/etc/db_schema.xml b/app/code/Magento/Wishlist/etc/db_schema.xml
new file mode 100644
index 0000000000000..f9d0361a88371
--- /dev/null
+++ b/app/code/Magento/Wishlist/etc/db_schema.xml
@@ -0,0 +1,68 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/setup/src/Magento/Setup/Model/Installer.php b/setup/src/Magento/Setup/Model/Installer.php
index 90c1ddc87ed02..dd676be909a31 100644
--- a/setup/src/Magento/Setup/Model/Installer.php
+++ b/setup/src/Magento/Setup/Model/Installer.php
@@ -809,9 +809,9 @@ public function installDataFixtures(array $request)
$setup = $this->dataSetupFactory->create();
$this->checkFilePermissionsForDbUpgrade();
$this->log->log('Data install/update:');
- if (!isset($request[InstallCommand::DECLARATION_MODE_KEY]) || !$request[InstallCommand::DECLARATION_MODE_KEY]) {
+ #if (!isset($request[InstallCommand::DECLARATION_MODE_KEY]) || !$request[InstallCommand::DECLARATION_MODE_KEY]) {
$this->handleDBSchemaData($setup, 'data');
- }
+ #}
}
/**
From 732bb68d6d6a4cc9fc6730457fb6a2c908f10c27 Mon Sep 17 00:00:00 2001
From: Sergii Kovalenko
Date: Tue, 2 Jan 2018 14:37:27 +0200
Subject: [PATCH 254/904] MAGETWO-85326: Tool for generating schema
--make magento works with new schema
---
app/code/Magento/Store/Setup/InstallData.php | 101 --------------
.../Magento/Store/Setup/InstallSchema.php | 18 ---
app/code/Magento/Store/Setup/Recurring.php | 125 ++++++++++++++++++
.../Framework/Module/DbVersionInfo.php | 4 -
setup/src/Magento/Setup/Model/Installer.php | 87 ++++++------
5 files changed, 174 insertions(+), 161 deletions(-)
delete mode 100644 app/code/Magento/Store/Setup/InstallData.php
create mode 100644 app/code/Magento/Store/Setup/Recurring.php
diff --git a/app/code/Magento/Store/Setup/InstallData.php b/app/code/Magento/Store/Setup/InstallData.php
deleted file mode 100644
index d0ec5b99f45ca..0000000000000
--- a/app/code/Magento/Store/Setup/InstallData.php
+++ /dev/null
@@ -1,101 +0,0 @@
-startSetup();
- $connection = $installer->getConnection();
-
- /**
- * Insert websites
- */
- $connection->insertForce(
- $installer->getTable('store_website'),
- [
- 'website_id' => 0,
- 'code' => 'admin',
- 'name' => 'Admin',
- 'sort_order' => 0,
- 'default_group_id' => 0,
- 'is_default' => 0
- ]
- );
- $connection->insertForce(
- $installer->getTable('store_website'),
- [
- 'website_id' => 1,
- 'code' => 'base',
- 'name' => 'Main Website',
- 'sort_order' => 0,
- 'default_group_id' => 1,
- 'is_default' => 1
- ]
- );
-
- /**
- * Insert store groups
- */
- $connection->insertForce(
- $installer->getTable('store_group'),
- ['group_id' => 0, 'website_id' => 0, 'name' => 'Default', 'root_category_id' => 0, 'default_store_id' => 0]
- );
- $connection->insertForce(
- $installer->getTable('store_group'),
- [
- 'group_id' => 1,
- 'website_id' => 1,
- 'name' => 'Main Website Store',
- 'root_category_id' => $this->getDefaultCategory()->getId(),
- 'default_store_id' => 1
- ]
- );
-
- /**
- * Insert stores
- */
- $connection->insertForce(
- $installer->getTable('store'),
- [
- 'store_id' => 0,
- 'code' => 'admin',
- 'website_id' => 0,
- 'group_id' => 0,
- 'name' => 'Admin',
- 'sort_order' => 0,
- 'is_active' => 1
- ]
- );
- $connection->insertForce(
- $installer->getTable('store'),
- [
- 'store_id' => 1,
- 'code' => 'default',
- 'website_id' => 1,
- 'group_id' => 1,
- 'name' => 'Default Store View',
- 'sort_order' => 0,
- 'is_active' => 1
- ]
- );
- $setup->endSetup();
- }
-}
diff --git a/app/code/Magento/Store/Setup/InstallSchema.php b/app/code/Magento/Store/Setup/InstallSchema.php
index 47ed0905a95dd..5c0dfb53c9eb8 100644
--- a/app/code/Magento/Store/Setup/InstallSchema.php
+++ b/app/code/Magento/Store/Setup/InstallSchema.php
@@ -17,24 +17,6 @@
*/
class InstallSchema implements InstallSchemaInterface
{
- /**
- * @var DefaultCategory
- */
- private $defaultCategory;
-
- /**
- * @deprecated 100.1.0
- * @return DefaultCategory
- */
- private function getDefaultCategory()
- {
- if ($this->defaultCategory === null) {
- $this->defaultCategory = \Magento\Framework\App\ObjectManager::getInstance()
- ->get(DefaultCategory::class);
- }
- return $this->defaultCategory;
- }
-
/**
* {@inheritdoc}
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
diff --git a/app/code/Magento/Store/Setup/Recurring.php b/app/code/Magento/Store/Setup/Recurring.php
new file mode 100644
index 0000000000000..1dea6936d0449
--- /dev/null
+++ b/app/code/Magento/Store/Setup/Recurring.php
@@ -0,0 +1,125 @@
+defaultCategory === null) {
+ $this->defaultCategory = \Magento\Framework\App\ObjectManager::getInstance()
+ ->get(DefaultCategory::class);
+ }
+ return $this->defaultCategory;
+ }
+
+ /**
+ * {@inheritdoc}
+ * @throws \Exception
+ */
+ public function install(SchemaSetupInterface $setup, ModuleContextInterface $context)
+ {
+ $installer = $setup;
+
+ $installer->startSetup();
+ $connection = $installer->getConnection();
+ $select = $connection->select()
+ ->from($installer->getTable('store_website'))
+ ->where('website_id = ?', 0);
+
+ if ($connection->fetchOne($select) === false) {
+ /**
+ * Insert websites
+ */
+ $connection->insertForce(
+ $installer->getTable('store_website'),
+ [
+ 'website_id' => 0,
+ 'code' => 'admin',
+ 'name' => 'Admin',
+ 'sort_order' => 0,
+ 'default_group_id' => 0,
+ 'is_default' => 0
+ ]
+ );
+ $connection->insertForce(
+ $installer->getTable('store_website'),
+ [
+ 'website_id' => 1,
+ 'code' => 'base',
+ 'name' => 'Main Website',
+ 'sort_order' => 0,
+ 'default_group_id' => 1,
+ 'is_default' => 1
+ ]
+ );
+
+ /**
+ * Insert store groups
+ */
+ $connection->insertForce(
+ $installer->getTable('store_group'),
+ ['group_id' => 0, 'website_id' => 0, 'name' => 'Default', 'root_category_id' => 0, 'default_store_id' => 0]
+ );
+ $connection->insertForce(
+ $installer->getTable('store_group'),
+ [
+ 'group_id' => 1,
+ 'website_id' => 1,
+ 'name' => 'Main Website Store',
+ 'root_category_id' => $this->getDefaultCategory()->getId(),
+ 'default_store_id' => 1
+ ]
+ );
+
+ /**
+ * Insert stores
+ */
+ $connection->insertForce(
+ $installer->getTable('store'),
+ [
+ 'store_id' => 0,
+ 'code' => 'admin',
+ 'website_id' => 0,
+ 'group_id' => 0,
+ 'name' => 'Admin',
+ 'sort_order' => 0,
+ 'is_active' => 1
+ ]
+ );
+ $connection->insertForce(
+ $installer->getTable('store'),
+ [
+ 'store_id' => 1,
+ 'code' => 'default',
+ 'website_id' => 1,
+ 'group_id' => 1,
+ 'name' => 'Default Store View',
+ 'sort_order' => 0,
+ 'is_active' => 1
+ ]
+ );
+ $setup->endSetup();
+ }
+ }
+}
diff --git a/lib/internal/Magento/Framework/Module/DbVersionInfo.php b/lib/internal/Magento/Framework/Module/DbVersionInfo.php
index 993f2853d2ce3..4860fb47a0f04 100644
--- a/lib/internal/Magento/Framework/Module/DbVersionInfo.php
+++ b/lib/internal/Magento/Framework/Module/DbVersionInfo.php
@@ -74,10 +74,6 @@ public function getDbVersionErrors()
{
$errors = [];
foreach ($this->moduleList->getNames() as $moduleName) {
- if (!$this->isSchemaUpToDate($moduleName)) {
- $errors[] = $this->getSchemaInfo($moduleName);
- }
-
if (!$this->isDataUpToDate($moduleName)) {
$errors[] = $this->getDataInfo($moduleName);
}
diff --git a/setup/src/Magento/Setup/Model/Installer.php b/setup/src/Magento/Setup/Model/Installer.php
index dd676be909a31..763dc20e57e3c 100644
--- a/setup/src/Magento/Setup/Model/Installer.php
+++ b/setup/src/Magento/Setup/Model/Installer.php
@@ -327,7 +327,8 @@ public function install($request)
if (!empty($request[InstallCommand::INPUT_KEY_CLEANUP_DB])) {
$script[] = ['Cleaning up database...', 'cleanupDb', []];
}
- $script[] = ['Installing database schema:', 'installSchema', [$request]];
+ $script[] = ['Installing database schema:', 'declarativeInstallSchema', [$request]];
+ $script[] = ['Installing database schema:', 'installSchema', []];
$script[] = ['Installing user configuration...', 'installUserConfig', [$request]];
$script[] = ['Enabling caches:', 'enableCaches', []];
$script[] = ['Installing data...', 'installDataFixtures', [$request]];
@@ -772,13 +773,27 @@ private function setupFlagTable(
}
}
+ /**
+ * Install Magento if declaration mode was enabled
+ *
+ * @param array $request
+ */
+ public function declarativeInstallSchema(array $request)
+ {
+ if (isset($request[InstallCommand::DECLARATION_MODE_KEY]) && $request[InstallCommand::DECLARATION_MODE_KEY]) {
+ /** @var DeclarationInstaller $declarativeInstaller */
+ $declarativeInstaller = $this->objectManagerProvider->get()->get(DeclarationInstaller::class);
+ $declarativeInstaller->installSchema($request);
+ }
+ }
+
/**
* Installs DB schema
*
* @param array $request
* @return void
*/
- public function installSchema(array $request)
+ public function installSchema()
{
$this->assertDbConfigExists();
$this->assertDbAccessible();
@@ -786,14 +801,7 @@ public function installSchema(array $request)
$this->setupModuleRegistry($setup);
$this->setupCoreTables($setup);
$this->log->log('Schema creation/updates:');
-
- if (isset($request[InstallCommand::DECLARATION_MODE_KEY]) && $request[InstallCommand::DECLARATION_MODE_KEY]) {
- /** @var DeclarationInstaller $declarativeInstaller */
- $declarativeInstaller = $this->objectManagerProvider->get()->get(DeclarationInstaller::class);
- $declarativeInstaller->installSchema($request);
- } else {
- $this->handleDBSchemaData($setup, 'schema');
- }
+ $this->handleDBSchemaData($setup, 'schema');
}
/**
@@ -866,18 +874,36 @@ private function handleDBSchemaData($setup, $type)
$upgradeType = $type . '-upgrade';
$moduleNames = $this->moduleList->getNames();
$moduleContextList = $this->generateListOfModuleContext($resource, $verType);
- foreach ($moduleNames as $moduleName) {
- $this->schemaListener->setModuleName($moduleName);
- $this->log->log("Module '{$moduleName}':");
- $configVer = $this->moduleList->getOne($moduleName)['setup_version'];
- $currentVersion = $moduleContextList[$moduleName]->getVersion();
- // Schema/Data is installed
- if ($currentVersion !== '') {
- $status = version_compare($configVer, $currentVersion);
- if ($status == \Magento\Framework\Setup\ModuleDataSetupInterface::VERSION_COMPARE_GREATER) {
+ if ($type !== 'schema') {
+ foreach ($moduleNames as $moduleName) {
+ $this->schemaListener->setModuleName($moduleName);
+ $this->log->log("Module '{$moduleName}':");
+ $configVer = $this->moduleList->getOne($moduleName)['setup_version'];
+ $currentVersion = $moduleContextList[$moduleName]->getVersion();
+ // Schema/Data is installed
+ if ($currentVersion !== '') {
+ $status = version_compare($configVer, $currentVersion);
+ if ($status == \Magento\Framework\Setup\ModuleDataSetupInterface::VERSION_COMPARE_GREATER) {
+ $upgrader = $this->getSchemaDataHandler($moduleName, $upgradeType);
+ if ($upgrader) {
+ $this->log->logInline("Upgrading $type.. ");
+ $upgrader->upgrade($setup, $moduleContextList[$moduleName]);
+ }
+ if ($type === 'schema') {
+ $resource->setDbVersion($moduleName, $configVer);
+ } elseif ($type === 'data') {
+ $resource->setDataVersion($moduleName, $configVer);
+ }
+ }
+ } elseif ($configVer) {
+ $installer = $this->getSchemaDataHandler($moduleName, $installType);
+ if ($installer) {
+ $this->log->logInline("Installing $type... ");
+ $installer->install($setup, $moduleContextList[$moduleName]);
+ }
$upgrader = $this->getSchemaDataHandler($moduleName, $upgradeType);
if ($upgrader) {
- $this->log->logInline("Upgrading $type.. ");
+ $this->log->logInline("Upgrading $type... ");
$upgrader->upgrade($setup, $moduleContextList[$moduleName]);
}
if ($type === 'schema') {
@@ -886,27 +912,12 @@ private function handleDBSchemaData($setup, $type)
$resource->setDataVersion($moduleName, $configVer);
}
}
- } elseif ($configVer) {
- $installer = $this->getSchemaDataHandler($moduleName, $installType);
- if ($installer) {
- $this->log->logInline("Installing $type... ");
- $installer->install($setup, $moduleContextList[$moduleName]);
- }
- $upgrader = $this->getSchemaDataHandler($moduleName, $upgradeType);
- if ($upgrader) {
- $this->log->logInline("Upgrading $type... ");
- $upgrader->upgrade($setup, $moduleContextList[$moduleName]);
- }
- if ($type === 'schema') {
- $resource->setDbVersion($moduleName, $configVer);
- } elseif ($type === 'data') {
- $resource->setDataVersion($moduleName, $configVer);
- }
+ $this->logProgress();
}
- $this->logProgress();
}
+
//Before recurring generate schema
- $this->schemaPersistor->persist($this->schemaListener);
+ //$this->schemaPersistor->persist($this->schemaListener);
if ($type === 'schema') {
$this->log->log('Schema post-updates:');
$handlerType = 'schema-recurring';
From 86fb388e59c0fed19ce7f20cc5a0f80ecca5f6e3 Mon Sep 17 00:00:00 2001
From: Sergii Kovalenko
Date: Wed, 3 Jan 2018 13:28:36 +0200
Subject: [PATCH 255/904] MAGETWO-85326: Tool for generating schema
--make magento works with new schema
---
app/code/Magento/Sales/etc/db_schema.xml | 32 +++++++++----------
app/code/Magento/SalesRule/etc/db_schema.xml | 14 ++++----
app/code/Magento/Tax/etc/db_schema.xml | 2 +-
.../Declaration/Schema/etc/types/boolean.xsd | 1 +
setup/src/Magento/Setup/Model/Installer.php | 6 ++--
.../DecimalDefinition.php | 2 +-
.../IntegerDefinition.php | 21 +++++++++++-
7 files changed, 49 insertions(+), 29 deletions(-)
diff --git a/app/code/Magento/Sales/etc/db_schema.xml b/app/code/Magento/Sales/etc/db_schema.xml
index 8e07cf175c74a..8e76d9bf26206 100644
--- a/app/code/Magento/Sales/etc/db_schema.xml
+++ b/app/code/Magento/Sales/etc/db_schema.xml
@@ -1374,37 +1374,37 @@
+ default="0"/>
+ default="0.0000"/>
+ default="0.0000"/>
+ nullable="false" default="0.0000"/>
+ nullable="false" default="0.0000"/>
+ nullable="false" default="0.0000"/>
+ nullable="false" default="0.0000"/>
+ nullable="false" default="0.0000"/>
+ default="0.0000"/>
+ nullable="false" default="0.0000"/>
+ default="0.0000"/>
+ nullable="false" default="0.0000"/>
+ nullable="false" default="0.0000"/>
+ nullable="false" default="0.0000"/>
+ nullable="false" default="0.0000"/>
+ nullable="false" default="0.0000"/>
diff --git a/app/code/Magento/SalesRule/etc/db_schema.xml b/app/code/Magento/SalesRule/etc/db_schema.xml
index 6de0377390ff0..0c8a91175aa93 100644
--- a/app/code/Magento/SalesRule/etc/db_schema.xml
+++ b/app/code/Magento/SalesRule/etc/db_schema.xml
@@ -221,19 +221,19 @@
+ default="0"/>
+ default="0.0000"/>
+ default="0.0000"/>
+ default="0.0000"/>
+ nullable="false" default="0.0000"/>
+ nullable="false" default="0.0000"/>
+ nullable="false" default="0.0000"/>
diff --git a/app/code/Magento/Tax/etc/db_schema.xml b/app/code/Magento/Tax/etc/db_schema.xml
index db2415688f6a7..21b6f5a6cef75 100644
--- a/app/code/Magento/Tax/etc/db_schema.xml
+++ b/app/code/Magento/Tax/etc/db_schema.xml
@@ -158,7 +158,7 @@
+ default="0"/>
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/boolean.xsd b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/boolean.xsd
index 1167c9e0642bb..795ca8095aacb 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/boolean.xsd
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/boolean.xsd
@@ -11,5 +11,6 @@
+
diff --git a/setup/src/Magento/Setup/Model/Installer.php b/setup/src/Magento/Setup/Model/Installer.php
index 763dc20e57e3c..07202281dafe8 100644
--- a/setup/src/Magento/Setup/Model/Installer.php
+++ b/setup/src/Magento/Setup/Model/Installer.php
@@ -874,7 +874,7 @@ private function handleDBSchemaData($setup, $type)
$upgradeType = $type . '-upgrade';
$moduleNames = $this->moduleList->getNames();
$moduleContextList = $this->generateListOfModuleContext($resource, $verType);
- if ($type !== 'schema') {
+ #if ($type !== 'schema') {
foreach ($moduleNames as $moduleName) {
$this->schemaListener->setModuleName($moduleName);
$this->log->log("Module '{$moduleName}':");
@@ -914,10 +914,10 @@ private function handleDBSchemaData($setup, $type)
}
$this->logProgress();
}
- }
+ #}
//Before recurring generate schema
- //$this->schemaPersistor->persist($this->schemaListener);
+ $this->schemaPersistor->persist($this->schemaListener);
if ($type === 'schema') {
$this->log->log('Schema post-updates:');
$handlerType = 'schema-recurring';
diff --git a/setup/src/Magento/Setup/Model/SchemaListenerDefinition/DecimalDefinition.php b/setup/src/Magento/Setup/Model/SchemaListenerDefinition/DecimalDefinition.php
index 42d56c8fcd008..446942b3a720f 100644
--- a/setup/src/Magento/Setup/Model/SchemaListenerDefinition/DecimalDefinition.php
+++ b/setup/src/Magento/Setup/Model/SchemaListenerDefinition/DecimalDefinition.php
@@ -34,7 +34,7 @@ public function convertToDefinition(array $definition)
'precission' => $definition['scale'] ?? self::DEFAULT_SCALE,
'unsigned' => $definition['unsigned'] ?? false,
'nullable' => $definition['nullable'] ?? true,
- 'default' => $definition['default'] ?? null,
+ 'default' => isset($definition['default']) ? (int) $definition['default'] : null,
'primary' => $definition['primary'] ?? false
];
}
diff --git a/setup/src/Magento/Setup/Model/SchemaListenerDefinition/IntegerDefinition.php b/setup/src/Magento/Setup/Model/SchemaListenerDefinition/IntegerDefinition.php
index 1b11a430cfe4c..56a6969a76c6a 100644
--- a/setup/src/Magento/Setup/Model/SchemaListenerDefinition/IntegerDefinition.php
+++ b/setup/src/Magento/Setup/Model/SchemaListenerDefinition/IntegerDefinition.php
@@ -23,6 +23,20 @@ class IntegerDefinition implements DefinitionConverterInterface
'bigint' => 20
];
+ /**
+ * @var BooleanDefinition
+ */
+ private $booleanDefinition;
+
+ /**
+ * IntegerDefinition constructor.
+ * @param BooleanDefinition $booleanDefinition
+ */
+ public function __construct(BooleanDefinition $booleanDefinition)
+ {
+ $this->booleanDefinition = $booleanDefinition;
+ }
+
/**
* @inheritdoc
*/
@@ -32,6 +46,11 @@ public function convertToDefinition(array $definition)
$definition['type'] = 'int';
}
+ if (isset($definition['padding']) && $definition['padding'] == 1) {
+ $definition['type'] = 'boolean';
+ return $this->booleanDefinition->convertToDefinition($definition);
+ }
+
return [
'xsi:type' => $definition['type'],
'name' => $definition['name'],
@@ -39,7 +58,7 @@ public function convertToDefinition(array $definition)
'unsigned' => $definition['unsigned'] ?? false,
'nullable' => $definition['nullable'] ?? true,
'identity' => $definition['identity'] ?? false,
- 'default' => $definition['default'] ?? null,
+ 'default' => isset($definition['default']) ? (int) $definition['default'] : null,
'primary' => $definition['primary'] ?? false
];
}
From 9c4aa724c1cddf687bb05f2672a2464717368401 Mon Sep 17 00:00:00 2001
From: Sergii Kovalenko
Date: Thu, 4 Jan 2018 16:07:10 +0200
Subject: [PATCH 256/904] MAGETWO-85326: Tool for generating schema
--add staging schema
---
app/etc/di.xml | 3 +
clean_db_schemas.php | 51 ++++++++
.../Schema/etc/constraints/constraint.xsd | 2 +-
.../Schema/etc/constraints/foreign.xsd | 8 +-
.../Schema/etc/constraints/primary.xsd | 2 +-
.../Schema/etc/constraints/unique.xsd | 2 +-
.../Model/Declaration/Schema/etc/index.xsd | 5 +-
.../Model/Declaration/Schema/etc/name.xsd | 19 +++
.../Model/Declaration/Schema/etc/schema.xsd | 1 +
.../Declaration/Schema/etc/types/column.xsd | 2 +-
setup/src/Magento/Setup/Model/Installer.php | 27 ++---
.../Magento/Setup/Model/SchemaListener.php | 110 ++++++++++++++----
.../BooleanDefinition.php | 2 +-
.../IntegerDefinition.php | 4 +-
.../SchemaListenerHandlerInterface.php | 22 ++++
.../SchemaListenerHandlers/StagingHandler.php | 96 +++++++++++++++
.../Magento/Setup/Model/SchemaPersistor.php | 37 ++++--
17 files changed, 338 insertions(+), 55 deletions(-)
create mode 100644 clean_db_schemas.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/etc/name.xsd
create mode 100644 setup/src/Magento/Setup/Model/SchemaListenerHandlers/SchemaListenerHandlerInterface.php
create mode 100644 setup/src/Magento/Setup/Model/SchemaListenerHandlers/StagingHandler.php
diff --git a/app/etc/di.xml b/app/etc/di.xml
index a37878870dc52..c0c5108078b10 100755
--- a/app/etc/di.xml
+++ b/app/etc/di.xml
@@ -1467,6 +1467,9 @@
- Magento\Setup\Model\SchemaListenerDefinition\DateDefinition
- Magento\Setup\Model\SchemaListenerDefinition\BooleanDefinition
+
+ - Magento\Setup\Model\SchemaListenerHandlers\StagingHandler
+
diff --git a/clean_db_schemas.php b/clean_db_schemas.php
new file mode 100644
index 0000000000000..081c906692c6c
--- /dev/null
+++ b/clean_db_schemas.php
@@ -0,0 +1,51 @@
+createApplication(\Magento\Framework\App\Http::class);
+ * $bootstrap->run($app);
+ * --------------------------------------------
+ *
+ * Copyright © Magento, Inc. All rights reserved.
+ * See COPYING.txt for license details.
+ */
+
+try {
+ require __DIR__ . '/app/bootstrap.php';
+} catch (\Exception $e) {
+ echo <<
+
+
+ Autoload error
+
+ {$e->getMessage()}
+
+HTML;
+ exit(1);
+}
+
+$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $_SERVER);
+$om = $bootstrap->getObjectManager();
+/** @var \Magento\Framework\Component\ComponentRegistrar $componentRegistrar */
+$componentRegistrar = $om->get(\Magento\Framework\Component\ComponentRegistrar::class);
+/** @var \Magento\Framework\App\ResourceConnection $resourceConnection */
+$resourceConnection = $om->get(Magento\Framework\App\ResourceConnection::class);
+
+$adapter = $resourceConnection->getConnection();
+$adapter->query('DROP DATABASE ' . $resourceConnection->getSchemaName('default'));
+$adapter->query('CREATE DATABASE ' . $resourceConnection->getSchemaName('default'));
+
+foreach ($componentRegistrar->getPaths(\Magento\Framework\Component\ComponentRegistrar::MODULE) as $path) {
+ if (strpos($path, 'magento2ee') !== false) {
+ @unlink($path . DIRECTORY_SEPARATOR . 'etc/db_schema.xml');
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/etc/constraints/constraint.xsd b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/constraints/constraint.xsd
index 9e1428dfb4d0d..06b99c88e43dc 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/etc/constraints/constraint.xsd
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/constraints/constraint.xsd
@@ -10,6 +10,6 @@
-
+
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/etc/constraints/foreign.xsd b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/constraints/foreign.xsd
index f1eeb115e858f..32cd05caa3ffb 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/etc/constraints/foreign.xsd
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/constraints/foreign.xsd
@@ -19,10 +19,10 @@
-
-
-
-
+
+
+
+
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/etc/constraints/primary.xsd b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/constraints/primary.xsd
index c690575379886..826f30c2fd87b 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/etc/constraints/primary.xsd
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/constraints/primary.xsd
@@ -18,7 +18,7 @@
-
+
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/etc/constraints/unique.xsd b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/constraints/unique.xsd
index 1db643982b4e4..76c3c39dad0eb 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/etc/constraints/unique.xsd
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/constraints/unique.xsd
@@ -16,7 +16,7 @@
-
+
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/etc/index.xsd b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/index.xsd
index 8eb99cf0d7f63..ead4fc5604fcb 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/etc/index.xsd
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/index.xsd
@@ -15,11 +15,12 @@
-
+
-
+
+
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/etc/name.xsd b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/name.xsd
new file mode 100644
index 0000000000000..82db095d66821
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/name.xsd
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+ We can`t create column index or constraint with name length more than 64 char
+
+
+
+
+
+
+
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/etc/schema.xsd b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/schema.xsd
index 57e363dde6fd3..ef71b6350da0e 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/etc/schema.xsd
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/schema.xsd
@@ -8,6 +8,7 @@
+
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/column.xsd b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/column.xsd
index a549ddfadb4f6..90710ebbe92e2 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/column.xsd
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/column.xsd
@@ -10,6 +10,6 @@
-
+
diff --git a/setup/src/Magento/Setup/Model/Installer.php b/setup/src/Magento/Setup/Model/Installer.php
index 07202281dafe8..f27c831148906 100644
--- a/setup/src/Magento/Setup/Model/Installer.php
+++ b/setup/src/Magento/Setup/Model/Installer.php
@@ -328,7 +328,7 @@ public function install($request)
$script[] = ['Cleaning up database...', 'cleanupDb', []];
}
$script[] = ['Installing database schema:', 'declarativeInstallSchema', [$request]];
- $script[] = ['Installing database schema:', 'installSchema', []];
+ $script[] = ['Installing database schema:', 'installSchema', [$request]];
$script[] = ['Installing user configuration...', 'installUserConfig', [$request]];
$script[] = ['Enabling caches:', 'enableCaches', []];
$script[] = ['Installing data...', 'installDataFixtures', [$request]];
@@ -344,7 +344,6 @@ public function install($request)
$script[] = ['Disabling Maintenance Mode:', 'setMaintenanceMode', [0]];
$script[] = ['Post installation file permissions check...', 'checkApplicationFilePermissions', []];
$script[] = ['Write installation date...', 'writeInstallationDate', []];
-
$estimatedModules = $this->createModulesConfig($request, true);
$total = count($script) + 4 * count(array_filter($estimatedModules));
$this->progress = new Installer\Progress($total, 0);
@@ -356,7 +355,7 @@ public function install($request)
call_user_func_array([$this, $method], $params);
$this->logProgress();
}
-
+ $this->schemaPersistor->persist($this->schemaListener);
$this->log->logSuccess('Magento installation complete.');
$this->log->logSuccess(
'Magento Admin URI: /'
@@ -793,7 +792,7 @@ public function declarativeInstallSchema(array $request)
* @param array $request
* @return void
*/
- public function installSchema()
+ public function installSchema(array $request)
{
$this->assertDbConfigExists();
$this->assertDbAccessible();
@@ -801,7 +800,7 @@ public function installSchema()
$this->setupModuleRegistry($setup);
$this->setupCoreTables($setup);
$this->log->log('Schema creation/updates:');
- $this->handleDBSchemaData($setup, 'schema');
+ $this->handleDBSchemaData($setup, 'schema', $request);
}
/**
@@ -818,7 +817,7 @@ public function installDataFixtures(array $request)
$this->checkFilePermissionsForDbUpgrade();
$this->log->log('Data install/update:');
#if (!isset($request[InstallCommand::DECLARATION_MODE_KEY]) || !$request[InstallCommand::DECLARATION_MODE_KEY]) {
- $this->handleDBSchemaData($setup, 'data');
+ $this->handleDBSchemaData($setup, 'data', $request);
#}
}
@@ -855,13 +854,13 @@ private function throwExceptionForNotWritablePaths(array $paths)
*
* @param SchemaSetupInterface | ModuleDataSetupInterface $setup
* @param string $type
+ * @param array $request
* @return void
- * @throws \Exception
- *
+ * @throws \Magento\Setup\Exception
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
- private function handleDBSchemaData($setup, $type)
+ private function handleDBSchemaData($setup, $type, array $request)
{
if (!(($type === 'schema') || ($type === 'data'))) {
throw new \Magento\Setup\Exception("Unsupported operation type $type is requested");
@@ -874,7 +873,9 @@ private function handleDBSchemaData($setup, $type)
$upgradeType = $type . '-upgrade';
$moduleNames = $this->moduleList->getNames();
$moduleContextList = $this->generateListOfModuleContext($resource, $verType);
- #if ($type !== 'schema') {
+ if ($type !== 'schema' ||
+ (!isset($request[InstallCommand::DECLARATION_MODE_KEY]) || !$request[InstallCommand::DECLARATION_MODE_KEY])
+ ) {
foreach ($moduleNames as $moduleName) {
$this->schemaListener->setModuleName($moduleName);
$this->log->log("Module '{$moduleName}':");
@@ -914,10 +915,9 @@ private function handleDBSchemaData($setup, $type)
}
$this->logProgress();
}
- #}
+ }
- //Before recurring generate schema
- $this->schemaPersistor->persist($this->schemaListener);
+ $this->schemaListener->toogleIgnore(SchemaListener::IGNORE_ON);
if ($type === 'schema') {
$this->log->log('Schema post-updates:');
$handlerType = 'schema-recurring';
@@ -934,6 +934,7 @@ private function handleDBSchemaData($setup, $type)
}
$this->logProgress();
}
+ $this->schemaListener->toogleIgnore(SchemaListener::IGNORE_OFF);
}
/**
diff --git a/setup/src/Magento/Setup/Model/SchemaListener.php b/setup/src/Magento/Setup/Model/SchemaListener.php
index c9bc7a6e7ff8f..853164c660a38 100644
--- a/setup/src/Magento/Setup/Model/SchemaListener.php
+++ b/setup/src/Magento/Setup/Model/SchemaListener.php
@@ -8,17 +8,34 @@
use Magento\Framework\DB\Adapter\AdapterInterface;
use Magento\Framework\DB\Ddl\Table;
use Magento\Setup\Model\SchemaListenerDefinition\DefinitionConverterInterface;
+use Magento\Setup\Model\SchemaListenerHandlers\SchemaListenerHandlerInterface;
/**
* Listen for all changes and record them in order to reuse later
*/
class SchemaListener
{
+ /**
+ * Ignore all ddl queries
+ */
+ const IGNORE_ON = true;
+
+ /**
+ * Disable ignore mode
+ */
+ const IGNORE_OFF = false;
/**
* @var array
*/
private $tables = [];
+ /**
+ * This flag allows us to ignore some DDL operations
+ *
+ * @var bool
+ */
+ private $ignore = self::IGNORE_OFF;
+
/**
* @var array
*/
@@ -56,12 +73,19 @@ class SchemaListener
*/
private $definitionMappers;
+ /**
+ * @var SchemaListenerHandlerInterface[]
+ */
+ private $handlers;
+
/**
* @param array $definitionMappers
+ * @param array $handlers
*/
- public function __construct(array $definitionMappers)
+ public function __construct(array $definitionMappers, array $handlers)
{
$this->definitionMappers = $definitionMappers;
+ $this->handlers = $handlers;
}
/**
@@ -70,9 +94,13 @@ public function __construct(array $definitionMappers)
*/
public function dropForeignKey($tableName, $fkName)
{
-// $this->tables[$this->moduleName][$tableName]['constraints']['foreign'][$fkName] = [
-// 'disabled' => 1,
-// ];
+ if ($this->ignore) {
+ return;
+ }
+
+ $this->tables[$this->moduleName][$tableName]['constraints']['foreign'][$fkName] = [
+ 'disabled' => 1,
+ ];
}
/**
@@ -99,24 +127,25 @@ private function castColumnDefinition($definition, $columnName)
* @param string $tableName
* @param string $columnName
* @param array $definition
+ * @param string $primaryKeyName
* @return array
*/
- private function addPrimaryKeyIfExists($tableName, $columnName, $definition)
+ private function addPrimaryKeyIfExists($tableName, $columnName, $definition, $primaryKeyName)
{
if (isset($definition['primary']) && $definition['primary']) {
- if (isset($this->tables[$this->moduleName][$tableName]['constraints']['primary'])) {
- $this->tables[$this->moduleName][$tableName]['constraints']['primary']['PRIMARY'] = array_merge_recursive(
- $this->tables[$this->moduleName][$tableName]['constraints']['primary']['PRIMARY'],
+ if (isset($this->tables[$this->moduleName][$tableName]['constraints']['primary'][$primaryKeyName])) {
+ $this->tables[$this->moduleName][$tableName]['constraints']['primary'][$primaryKeyName] = array_replace_recursive(
+ $this->tables[$this->moduleName][$tableName]['constraints']['primary'][$primaryKeyName],
[
- 'columns' => [strtolower($columnName)]
+ 'columns' => [$columnName => strtolower($columnName)]
]
);
} else {
- $this->tables[$this->moduleName][$tableName]['constraints']['primary']['PRIMARY'] = [
+ $this->tables[$this->moduleName][$tableName]['constraints']['primary'][$primaryKeyName] = [
'type' => 'primary',
- 'name' => 'PRIMARY',
- 'columns' => [strtolower($columnName)]
+ 'name' => $primaryKeyName,
+ 'columns' => [$columnName => strtolower($columnName)]
];
}
}
@@ -151,15 +180,22 @@ private function doColumnMapping(array $definition)
* @param string $tableName
* @param string $columnName
* @param array $definition
+ * @param string $primaryKeyName
*/
- public function addColumn($tableName, $columnName, $definition)
+ public function addColumn($tableName, $columnName, $definition, $primaryKeyName = 'PRIMARY')
{
+ if ($this->ignore) {
+ return;
+ }
+
$definition = $this->castColumnDefinition($definition, $columnName);
- $definition = $this->addPrimaryKeyIfExists($tableName, $columnName, $definition);
+ $definition = $this->addPrimaryKeyIfExists($tableName, $columnName, $definition, $primaryKeyName);
$this->tables[$this->moduleName][strtolower($tableName)]['columns'][strtolower($columnName)] = $definition;
}
/**
+ * Change column is the same as rename
+ *
* @param string $tableName
* @param string $oldColumnName
* @param string $newColumnName
@@ -167,12 +203,24 @@ public function addColumn($tableName, $columnName, $definition)
*/
public function changeColumn($tableName, $oldColumnName, $newColumnName, $definition)
{
- $this->addColumn($tableName, $newColumnName, $definition);
+ if ($this->ignore) {
+ return;
+ }
- if (isset($this->tables[$this->moduleName][$tableName]['columns'][strtolower($oldColumnName)])) {
- $this->tables[$this->moduleName][$tableName]['columns'][strtolower($oldColumnName)]['disabled'] = 1;
+ foreach ($this->handlers as $handler) {
+ $this->tables = $handler->handle(
+ $this->moduleName,
+ $this->tables,
+ [
+ 'table' => $tableName,
+ 'old_column' => $oldColumnName,
+ 'new_column' => $newColumnName,
+ ],
+ $definition
+ );
}
- //remove old column if not equal
+
+ $this->addColumn($tableName, $newColumnName, $definition, 'STAGING_PRIMARY');
}
/**
@@ -201,6 +249,10 @@ public function addForeignKey(
$refColumnName,
$onDelete = AdapterInterface::FK_ACTION_CASCADE
) {
+ if ($this->ignore) {
+ return;
+ }
+
$this->tables[$this->moduleName][strtolower($tableName)]['constraints']['foreign'][$fkName] =
[
'table' => strtolower($tableName),
@@ -223,9 +275,9 @@ private function prepareIndexColumns(array $indexColumns)
foreach ($indexColumns as $key => $indexColumn) {
if (is_array($indexColumn)) {
- $columnNames[] = strtolower($key);
+ $columnNames[strtolower($key)] = strtolower($key);
} else {
- $columnNames[] = $indexColumn;
+ $columnNames[$indexColumn] = $indexColumn;
}
}
@@ -244,6 +296,10 @@ public function addIndex(
$fields,
$indexType = AdapterInterface::INDEX_TYPE_INDEX
) {
+ if ($this->ignore) {
+ return;
+ }
+
if (!is_array($fields)) {
$fields = [$fields];
}
@@ -310,6 +366,10 @@ private function prepareConstraintsAndIndexes(array $foreignKeys, array $indexes
*/
public function createTable(Table $table)
{
+ if ($this->ignore) {
+ return;
+ }
+
$this->prepareColumns($table->getName(), $table->getColumns());
$this->prepareConstraintsAndIndexes($table->getForeignKeys(), $table->getIndexes(), $table->getName());
}
@@ -324,6 +384,16 @@ public function flush()
$this->tables = [];
}
+ /**
+ * Turn on/off ignore mode
+ *
+ * @param bool $flag
+ */
+ public function toogleIgnore($flag)
+ {
+ $this->ignore = $flag;
+ }
+
/**
* @param string $moduleName
*/
diff --git a/setup/src/Magento/Setup/Model/SchemaListenerDefinition/BooleanDefinition.php b/setup/src/Magento/Setup/Model/SchemaListenerDefinition/BooleanDefinition.php
index 394bec87f8bef..601922061168b 100644
--- a/setup/src/Magento/Setup/Model/SchemaListenerDefinition/BooleanDefinition.php
+++ b/setup/src/Magento/Setup/Model/SchemaListenerDefinition/BooleanDefinition.php
@@ -20,7 +20,7 @@ public function convertToDefinition(array $definition)
'xsi:type' => $definition['type'],
'name' => $definition['name'],
'nullable' => $definition['nullable'] ?? true,
- 'default' => $definition['default'] ?? null
+ 'default' => isset($definition['default']) ? (bool) $definition['default'] : null
];
}
}
diff --git a/setup/src/Magento/Setup/Model/SchemaListenerDefinition/IntegerDefinition.php b/setup/src/Magento/Setup/Model/SchemaListenerDefinition/IntegerDefinition.php
index 56a6969a76c6a..4f7d9a2e62532 100644
--- a/setup/src/Magento/Setup/Model/SchemaListenerDefinition/IntegerDefinition.php
+++ b/setup/src/Magento/Setup/Model/SchemaListenerDefinition/IntegerDefinition.php
@@ -46,7 +46,7 @@ public function convertToDefinition(array $definition)
$definition['type'] = 'int';
}
- if (isset($definition['padding']) && $definition['padding'] == 1) {
+ if (isset($definition['length']) && (int) $definition['length'] === 1) {
$definition['type'] = 'boolean';
return $this->booleanDefinition->convertToDefinition($definition);
}
@@ -58,7 +58,7 @@ public function convertToDefinition(array $definition)
'unsigned' => $definition['unsigned'] ?? false,
'nullable' => $definition['nullable'] ?? true,
'identity' => $definition['identity'] ?? false,
- 'default' => isset($definition['default']) ? (int) $definition['default'] : null,
+ 'default' => isset($definition['default']) && $definition['default'] !== false ? (int) $definition['default'] : null,
'primary' => $definition['primary'] ?? false
];
}
diff --git a/setup/src/Magento/Setup/Model/SchemaListenerHandlers/SchemaListenerHandlerInterface.php b/setup/src/Magento/Setup/Model/SchemaListenerHandlers/SchemaListenerHandlerInterface.php
new file mode 100644
index 0000000000000..6094e86c3f95d
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/SchemaListenerHandlers/SchemaListenerHandlerInterface.php
@@ -0,0 +1,22 @@
+ true
+ ];
+ $constraintData['columns'][$oldColumnIndex] = $newColumn;
+ $tables[$moduleName][$tableName]['constraints']['primary']['STAGING_PRIMARY'] = $constraintData;
+ }
+ }
+
+ if (isset($tables[$parentModuleName][$tableName]['indexes'])) {
+ foreach ($tables[$parentModuleName][$tableName]['indexes'] as $key => $indexData) {
+ if (isset($indexData['columns'][$oldColumn])) {
+ $tables[$moduleName][$tableName]['indexes'][$key] = [
+ 'disabled' => true
+ ];
+ $oldColumnIndex = array_search($oldColumn, $indexData['columns']);
+ $indexData['columns'][$oldColumnIndex] = $newColumn;
+ $key = $this->generateKey($key, $newColumn, $oldColumn);
+ $tables[$moduleName][$tableName]['indexes'][$key] = $indexData;
+ }
+ }
+ }
+
+ if (isset($tables[$parentModuleName][$tableName]['constraints']['unique'])) {
+ foreach ($tables[$parentModuleName][$tableName]['constraints']['unique'] as $key => $constraintData) {
+ if (isset($constraintData['columns'][$oldColumn])) {
+ $tables[$moduleName][$tableName]['constraints']['unique'][$key] = [
+ 'disabled' => true
+ ];
+ $oldColumnIndex = array_search($oldColumn, $constraintData['columns']);
+ $constraintData['columns'][$oldColumnIndex] = $newColumn;
+ $key = $this->generateKey($key, $newColumn, $oldColumn);
+ $tables[$moduleName][$tableName]['constraints']['unique'][$key] = $constraintData;
+ }
+ }
+ }
+
+ if ($definition['type'] === 'integer') {
+ $definition['type'] = 'int';
+ }
+
+ $tables[$moduleName][$tableName]['columns'][strtolower($oldColumn)] = [
+ 'xsi:type' => $definition['type'],
+ 'name' => $oldColumn,
+ 'disabled' => true
+ ];
+ }
+
+ return $tables;
+ }
+
+ /**
+ * Generates new key for staging keys
+ *
+ * @param $key
+ * @param $newColumn
+ * @param $oldColumn
+ * @return mixed|string
+ */
+ private function generateKey($key, $newColumn, $oldColumn)
+ {
+ if (strpos($key, strtoupper($oldColumn))) {
+ return str_replace(strtoupper($oldColumn), strtoupper($newColumn), $key);
+ }
+
+ return $key . '_STAGING';
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/SchemaPersistor.php b/setup/src/Magento/Setup/Model/SchemaPersistor.php
index 8178940b4bdf6..4736b05a8428a 100644
--- a/setup/src/Magento/Setup/Model/SchemaPersistor.php
+++ b/setup/src/Magento/Setup/Model/SchemaPersistor.php
@@ -123,11 +123,16 @@ private function processIndexes(array $tableData, \SimpleXMLElement $table)
foreach ($tableData['indexes'] as $indexName => $indexData) {
$domIndex = $table->addChild('index');
$domIndex->addAttribute('name', $indexName);
- $domIndex->addAttribute('indexType', $indexData['indexType']);
- foreach ($indexData['columns'] as $column) {
- $columnXml = $domIndex->addChild('column');
- $columnXml->addAttribute('name', $column);
+ if (isset($indexData['disabled']) && $indexData['disabled']) {
+ $domIndex->addAttribute('disabled', true);
+ } else {
+ $domIndex->addAttribute('indexType', $indexData['indexType']);
+
+ foreach ($indexData['columns'] as $column) {
+ $columnXml = $domIndex->addChild('column');
+ $columnXml->addAttribute('name', $column);
+ }
}
}
}
@@ -161,6 +166,11 @@ private function processConstraints(array $tableData, \SimpleXMLElement $table)
$constraintDom = $table->addChild('constraint');
$constraintDom->addAttribute('xsi:type', $constraintType, 'xsi');
$constraintDom->addAttribute('name', $name);
+ $constraintData['columns'] = $constraintData['columns'] ?? [];
+
+ if (isset($constraintData['disabled'])) {
+ $constraintDom->addAttribute('disabled', (bool) $constraintData['disabled']);
+ }
foreach ($constraintData['columns'] as $column) {
$columnXml = $constraintDom->addChild('column');
@@ -183,10 +193,19 @@ private function processConstraints(array $tableData, \SimpleXMLElement $table)
*/
private function persistModule(\SimpleXMLElement $simpleXmlElementDom, $path)
{
- $dom = new \DOMDocument('1.0');
- $dom->preserveWhiteSpace = false;
- $dom->formatOutput = true;
- $dom->loadXML($simpleXmlElementDom->asXML());
- file_put_contents($path, $dom->saveXML());
+ if (strpos($path, 'magento2ee') !== false) {
+ $dom = new \DOMDocument('1.0');
+ $dom->preserveWhiteSpace = false;
+ $dom->formatOutput = true;
+ $dom->loadXML($simpleXmlElementDom->asXML());
+ file_put_contents(
+ $path,
+ str_replace(
+ ' xmlns:xsi="xsi"', //reokace xmlns, as we do not need it for xsi namespace
+ '',
+ $dom->saveXML()
+ )
+ );
+ }
}
}
From 4a8e1921dea933bc426e0d011ba748f05b1b45bf Mon Sep 17 00:00:00 2001
From: Sergii Kovalenko
Date: Thu, 4 Jan 2018 17:58:45 +0200
Subject: [PATCH 257/904] MAGETWO-85326: Tool for generating schema
--add b2b schema
---
.../Magento/Setup/Model/SchemaPersistor.php | 26 +++++++++----------
1 file changed, 12 insertions(+), 14 deletions(-)
diff --git a/setup/src/Magento/Setup/Model/SchemaPersistor.php b/setup/src/Magento/Setup/Model/SchemaPersistor.php
index 4736b05a8428a..d01524b2c3aec 100644
--- a/setup/src/Magento/Setup/Model/SchemaPersistor.php
+++ b/setup/src/Magento/Setup/Model/SchemaPersistor.php
@@ -193,19 +193,17 @@ private function processConstraints(array $tableData, \SimpleXMLElement $table)
*/
private function persistModule(\SimpleXMLElement $simpleXmlElementDom, $path)
{
- if (strpos($path, 'magento2ee') !== false) {
- $dom = new \DOMDocument('1.0');
- $dom->preserveWhiteSpace = false;
- $dom->formatOutput = true;
- $dom->loadXML($simpleXmlElementDom->asXML());
- file_put_contents(
- $path,
- str_replace(
- ' xmlns:xsi="xsi"', //reokace xmlns, as we do not need it for xsi namespace
- '',
- $dom->saveXML()
- )
- );
- }
+ $dom = new \DOMDocument('1.0');
+ $dom->preserveWhiteSpace = false;
+ $dom->formatOutput = true;
+ $dom->loadXML($simpleXmlElementDom->asXML());
+ file_put_contents(
+ $path,
+ str_replace(
+ ' xmlns:xsi="xsi"', //reokace xmlns, as we do not need it for xsi namespace
+ '',
+ $dom->saveXML()
+ )
+ );
}
}
From 8d3a2376fd383f1e152058471add0095af199100 Mon Sep 17 00:00:00 2001
From: Vincent MARMIESSE
Date: Thu, 4 Jan 2018 17:30:19 +0100
Subject: [PATCH 258/904] #42 - Dynamically fill the image keys
---
.../Model/Import/Product.php | 26 +++++++++++++++++--
1 file changed, 24 insertions(+), 2 deletions(-)
diff --git a/app/code/Magento/CatalogImportExport/Model/Import/Product.php b/app/code/Magento/CatalogImportExport/Model/Import/Product.php
index ff18035686bd1..ea46a14f5d466 100644
--- a/app/code/Magento/CatalogImportExport/Model/Import/Product.php
+++ b/app/code/Magento/CatalogImportExport/Model/Import/Product.php
@@ -425,7 +425,7 @@ class Product extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity
*
* @var string[]
*/
- protected $_imagesArrayKeys = ['image', 'small_image', 'thumbnail', 'swatch_image', '_media_image'];
+ protected $_imagesArrayKeys = [];
/**
* Permanent entity columns.
@@ -833,7 +833,8 @@ public function __construct(
$this->_initAttributeSets()
->_initTypeModels()
- ->_initSkus();
+ ->_initSkus()
+ ->_initImagesArrayKeys();
$this->validator->init($this);
}
@@ -1076,6 +1077,27 @@ protected function _initSkus()
return $this;
}
+ /**
+ * Initialize image array keys.
+ *
+ * @return $this
+ */
+ protected function _initImagesArrayKeys()
+ {
+ $select = $this->_connection->select()->from(
+ $this->getResource()->getTable('eav_attribute'),
+ ['code' => 'attribute_code']
+ )->where(
+ 'frontend_input = :frontend_input'
+ );
+ $bind = [':frontend_input' => 'media_image'];
+
+ $this->_imagesArrayKeys = $this->_connection->fetchCol($select, $bind);
+ $this->_imagesArrayKeys[] = '_media_image';
+
+ return $this;
+ }
+
/**
* Initialize product type models.
*
From dc4bb0eae824588459f1e82b64dae96ab6026092 Mon Sep 17 00:00:00 2001
From: Sergii Kovalenko
Date: Thu, 4 Jan 2018 19:57:16 +0200
Subject: [PATCH 259/904] MAGETWO-85326: Tool for generating schema
--stabilize CE
---
app/code/Magento/Bundle/etc/db_schema.xml | 529 ++++++-----
app/code/Magento/Catalog/etc/db_schema.xml | 188 ++--
.../CatalogInventory/etc/db_schema.xml | 20 +-
.../Magento/CatalogRule/etc/db_schema.xml | 17 +-
.../Magento/CatalogSearch/etc/db_schema.xml | 34 +-
.../CatalogUrlRewrite/etc/db_schema.xml | 33 +-
.../Magento/Customer/Setup/RecurringData.php | 44 +
.../Magento/Customer/Setup/UpgradeData.php | 2 -
app/code/Magento/Customer/etc/db_schema.xml | 4 +-
app/code/Magento/Directory/etc/db_schema.xml | 2 +-
.../Magento/Downloadable/etc/db_schema.xml | 10 +-
app/code/Magento/Eav/etc/db_schema.xml | 2 +-
.../Magento/GiftMessage/etc/db_schema.xml | 20 +
.../Magento/OfflineShipping/etc/db_schema.xml | 7 +-
app/code/Magento/Paypal/etc/db_schema.xml | 13 +-
.../Magento/ProductAlert/etc/db_schema.xml | 2 +-
app/code/Magento/Quote/etc/db_schema.xml | 205 +++--
app/code/Magento/Reports/etc/db_schema.xml | 6 +-
app/code/Magento/Sales/etc/db_schema.xml | 845 ++++++++++--------
app/code/Magento/SalesRule/etc/db_schema.xml | 35 +-
.../Magento/SalesSequence/etc/db_schema.xml | 2 +-
app/code/Magento/Search/etc/db_schema.xml | 1 -
app/code/Magento/Security/etc/db_schema.xml | 4 +-
app/code/Magento/Tax/etc/db_schema.xml | 12 +-
.../Magento/Theme/Setup/RecurringData.php | 13 +-
app/code/Magento/Theme/Setup/UpgradeData.php | 12 -
app/code/Magento/Theme/etc/db_schema.xml | 4 +-
app/code/Magento/Weee/etc/db_schema.xml | 78 +-
app/code/Magento/Widget/etc/db_schema.xml | 2 +-
app/code/Magento/Wishlist/etc/db_schema.xml | 2 +-
clean_db_schemas.php | 2 +-
.../Db/MySQL/Definition/Columns/Timestamp.php | 12 +-
.../Db/MySQL/Definition/Columns/Varchar.php | 2 +-
setup/src/Magento/Setup/Model/Installer.php | 17 +-
34 files changed, 1272 insertions(+), 909 deletions(-)
create mode 100644 app/code/Magento/Customer/Setup/RecurringData.php
diff --git a/app/code/Magento/Bundle/etc/db_schema.xml b/app/code/Magento/Bundle/etc/db_schema.xml
index 4189da661cf0f..7c455d82742e2 100644
--- a/app/code/Magento/Bundle/etc/db_schema.xml
+++ b/app/code/Magento/Bundle/etc/db_schema.xml
@@ -1,274 +1,259 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Catalog/etc/db_schema.xml b/app/code/Magento/Catalog/etc/db_schema.xml
index d911988f73dcf..3d25559ae2013 100644
--- a/app/code/Magento/Catalog/etc/db_schema.xml
+++ b/app/code/Magento/Catalog/etc/db_schema.xml
@@ -16,9 +16,7 @@
-
+
@@ -67,7 +65,7 @@
default="0"/>
-
+
@@ -296,7 +294,7 @@
default="0"/>
-
+
@@ -448,6 +446,9 @@
+
@@ -600,7 +601,7 @@
identity="false"/>
+ default="0"/>
@@ -676,10 +677,9 @@
default="1"/>
-
+
+ default="0"/>
@@ -799,7 +799,7 @@
+ default="0"/>
@@ -867,7 +867,7 @@
+ default="0"/>
@@ -1019,7 +1019,8 @@
-
+
@@ -1050,25 +1051,24 @@
-
-
-
-
-
+
+
+
+
+
-
-
+
+
+ disabled="1"/>
@@ -1085,7 +1085,8 @@
-
+
@@ -1110,8 +1111,7 @@
-
+
@@ -1127,8 +1127,9 @@
-
-
+
+
@@ -1142,8 +1143,9 @@
-
-
+
+
@@ -1156,9 +1158,12 @@
-
-
-
+
+
+
@@ -1170,9 +1175,12 @@
-
-
-
+
+
+
@@ -1186,12 +1194,17 @@
-
-
-
-
-
-
+
+
+
+
+
+
@@ -1205,12 +1218,17 @@
-
-
-
-
-
-
+
+
+
+
+
+
@@ -1222,9 +1240,12 @@
-
-
-
+
+
+
@@ -1236,9 +1257,12 @@
-
-
-
+
+
+
@@ -1252,9 +1276,12 @@
-
-
-
+
+
+
@@ -1269,9 +1296,12 @@
-
-
-
+
+
+
@@ -1343,7 +1373,8 @@
-
+
@@ -1373,7 +1404,8 @@
-
+
@@ -1405,11 +1437,15 @@
-
-
-
-
-
+
+
+
+
+
@@ -1432,11 +1468,15 @@
-
-
-
-
-
+
+
+
+
+
diff --git a/app/code/Magento/CatalogInventory/etc/db_schema.xml b/app/code/Magento/CatalogInventory/etc/db_schema.xml
index ec184d6da1a24..f2df994f117e1 100644
--- a/app/code/Magento/CatalogInventory/etc/db_schema.xml
+++ b/app/code/Magento/CatalogInventory/etc/db_schema.xml
@@ -20,7 +20,7 @@
default="0"/>
+ default="0"/>
+ default="1"/>
+ default="0"/>
-
+
+ default="0"/>
-
+
@@ -107,8 +107,7 @@
-
+
@@ -126,8 +125,7 @@
-
+
diff --git a/app/code/Magento/CatalogRule/etc/db_schema.xml b/app/code/Magento/CatalogRule/etc/db_schema.xml
index 16755bdf75d96..7deba44776d17 100644
--- a/app/code/Magento/CatalogRule/etc/db_schema.xml
+++ b/app/code/Magento/CatalogRule/etc/db_schema.xml
@@ -46,7 +46,7 @@
default="0"/>
+ default="0"/>
+ nullable="false" default="0"/>
@@ -91,7 +91,7 @@
+ default="0"/>
@@ -126,15 +126,10 @@
-
-
+
+
+ disabled="1"/>
diff --git a/app/code/Magento/CatalogSearch/etc/db_schema.xml b/app/code/Magento/CatalogSearch/etc/db_schema.xml
index d4d77163bce9c..81642b8de50ca 100644
--- a/app/code/Magento/CatalogSearch/etc/db_schema.xml
+++ b/app/code/Magento/CatalogSearch/etc/db_schema.xml
@@ -1,8 +1,30 @@
-
-
+
+
+
+
diff --git a/app/code/Magento/CatalogUrlRewrite/etc/db_schema.xml b/app/code/Magento/CatalogUrlRewrite/etc/db_schema.xml
index ac6321056bc6f..3cb765c66ba23 100644
--- a/app/code/Magento/CatalogUrlRewrite/etc/db_schema.xml
+++ b/app/code/Magento/CatalogUrlRewrite/etc/db_schema.xml
@@ -1,19 +1,22 @@
-
+
diff --git a/app/code/Magento/Customer/Setup/RecurringData.php b/app/code/Magento/Customer/Setup/RecurringData.php
new file mode 100644
index 0000000000000..719489b51b761
--- /dev/null
+++ b/app/code/Magento/Customer/Setup/RecurringData.php
@@ -0,0 +1,44 @@
+indexerRegistry = $indexerRegistry;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
+ {
+ $indexer = $this->indexerRegistry->get(Customer::CUSTOMER_GRID_INDEXER_ID);
+ $indexer->reindexAll();
+
+ }
+}
diff --git a/app/code/Magento/Customer/Setup/UpgradeData.php b/app/code/Magento/Customer/Setup/UpgradeData.php
index b5aba18a92f28..b5f8619391c3c 100644
--- a/app/code/Magento/Customer/Setup/UpgradeData.php
+++ b/app/code/Magento/Customer/Setup/UpgradeData.php
@@ -159,8 +159,6 @@ public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface
$this->upgradeVersionTwoZeroTwelve($customerSetup);
}
- $indexer = $this->indexerRegistry->get(Customer::CUSTOMER_GRID_INDEXER_ID);
- $indexer->reindexAll();
$this->eavConfig->clear();
$setup->endSetup();
}
diff --git a/app/code/Magento/Customer/etc/db_schema.xml b/app/code/Magento/Customer/etc/db_schema.xml
index df61fd9107826..cd54263b5ebe4 100644
--- a/app/code/Magento/Customer/etc/db_schema.xml
+++ b/app/code/Magento/Customer/etc/db_schema.xml
@@ -134,7 +134,7 @@
+ default="0"/>
@@ -276,7 +276,7 @@
+ default="0"/>
diff --git a/app/code/Magento/Directory/etc/db_schema.xml b/app/code/Magento/Directory/etc/db_schema.xml
index b0ec8f46a10e4..4254682d0a48f 100644
--- a/app/code/Magento/Directory/etc/db_schema.xml
+++ b/app/code/Magento/Directory/etc/db_schema.xml
@@ -54,7 +54,7 @@
+ default="0"/>
diff --git a/app/code/Magento/Downloadable/etc/db_schema.xml b/app/code/Magento/Downloadable/etc/db_schema.xml
index 4eb425ca80d13..03058faf0467d 100644
--- a/app/code/Magento/Downloadable/etc/db_schema.xml
+++ b/app/code/Magento/Downloadable/etc/db_schema.xml
@@ -35,7 +35,7 @@
+ default="0"/>
@@ -201,9 +201,9 @@
identity="false"/>
+ default="0"/>
+ default="0"/>
@@ -216,9 +216,9 @@
identity="false"/>
+ default="0"/>
+ default="0"/>
diff --git a/app/code/Magento/Eav/etc/db_schema.xml b/app/code/Magento/Eav/etc/db_schema.xml
index 4c344784666fe..101940ce440db 100644
--- a/app/code/Magento/Eav/etc/db_schema.xml
+++ b/app/code/Magento/Eav/etc/db_schema.xml
@@ -109,7 +109,7 @@
+ default="0"/>
diff --git a/app/code/Magento/GiftMessage/etc/db_schema.xml b/app/code/Magento/GiftMessage/etc/db_schema.xml
index 072eeeb50f3d5..4103bb4024f5f 100644
--- a/app/code/Magento/GiftMessage/etc/db_schema.xml
+++ b/app/code/Magento/GiftMessage/etc/db_schema.xml
@@ -12,4 +12,24 @@
+
+
+
+
+
+
diff --git a/app/code/Magento/OfflineShipping/etc/db_schema.xml b/app/code/Magento/OfflineShipping/etc/db_schema.xml
index 2416dc984d6ad..7c64f5c5fa15c 100644
--- a/app/code/Magento/OfflineShipping/etc/db_schema.xml
+++ b/app/code/Magento/OfflineShipping/etc/db_schema.xml
@@ -11,11 +11,10 @@
+ default="0"/>
-
+ default="0"/>
+
diff --git a/app/code/Magento/Paypal/etc/db_schema.xml b/app/code/Magento/Paypal/etc/db_schema.xml
index 2359875539a94..86ccf5e125b2e 100644
--- a/app/code/Magento/Paypal/etc/db_schema.xml
+++ b/app/code/Magento/Paypal/etc/db_schema.xml
@@ -70,11 +70,11 @@
+ nullable="false" default="0"/>
+ default="0"/>
@@ -117,4 +117,13 @@
+
+
diff --git a/app/code/Magento/ProductAlert/etc/db_schema.xml b/app/code/Magento/ProductAlert/etc/db_schema.xml
index 2c41514052407..17190f22ae341 100644
--- a/app/code/Magento/ProductAlert/etc/db_schema.xml
+++ b/app/code/Magento/ProductAlert/etc/db_schema.xml
@@ -8,7 +8,7 @@
+ default="0"/>
diff --git a/app/code/Magento/Quote/etc/db_schema.xml b/app/code/Magento/Quote/etc/db_schema.xml
index c7177ac0b9048..d82f9632fdf30 100644
--- a/app/code/Magento/Quote/etc/db_schema.xml
+++ b/app/code/Magento/Quote/etc/db_schema.xml
@@ -17,20 +17,20 @@
+ default="0"/>
+ default="0"/>
+ default="0"/>
+ default="0"/>
+ default="0"/>
-
-
+
+
-
-
+
+
+ nullable="true" default="0"/>
+ nullable="true" default="0"/>
@@ -104,7 +106,7 @@
-
+
@@ -119,56 +121,64 @@
+ default="0"/>
+ default="0"/>
+ default="0"/>
+ nullable="false" default="0"/>
+ nullable="false" default="0"/>
+ default="0"/>
+ default="0"/>
+ default="0"/>
-
+ nullable="false" default="0"/>
+
+ nullable="true" default="0"/>
+ default="0"/>
+ nullable="false" default="0"/>
+ default="0"/>
+ default="0"/>
+ nullable="true" default="0"/>
-
+ nullable="true" default="0"/>
+
+ nullable="true" default="0"/>
+ nullable="true" default="0"/>
+ unsigned="false" nullable="true" default="0"/>
+ unsigned="false" nullable="true" default="0"/>
-
+ unsigned="false" nullable="true" default="0"/>
+
+ nullable="true" default="0"/>
+
+
+
+
+
@@ -197,54 +207,56 @@
-
+ default="0"/>
+
+ default="0"/>
-
+ default="0"/>
+
+ default="0"/>
+ default="0"/>
+ nullable="true" default="0"/>
+ default="0"/>
+ default="0"/>
+ default="0"/>
+ default="0"/>
+ default="0"/>
+ nullable="true" default="0"/>
+ default="0"/>
-
+ nullable="true" default="0"/>
+
+ nullable="true" default="0"/>
-
-
-
-
+
+
+
+
+ nullable="true" default="0"/>
+ nullable="true" default="0"/>
+ unsigned="false" nullable="true" default="0"/>
@@ -254,6 +266,7 @@
referenceTable="quote" referenceColumn="entity_id" onDelete="CASCADE"/>
+
@@ -279,25 +292,24 @@
-
+ default="0"/>
+
+ default="0"/>
+ default="0"/>
+ default="0"/>
+ default="0"/>
+ nullable="true" default="0"/>
+ nullable="true" default="0"/>
+ default="0"/>
+ default="0"/>
@@ -306,23 +318,28 @@
-
-
+
+
-
-
-
-
-
-
+
+
+
+
+
+
+ nullable="true" default="0"/>
+ nullable="true" default="0"/>
+ unsigned="false" nullable="true" default="0"/>
@@ -405,7 +422,7 @@
+ default="0"/>
diff --git a/app/code/Magento/Reports/etc/db_schema.xml b/app/code/Magento/Reports/etc/db_schema.xml
index 04799d3c87f4f..f54d8104f8a18 100644
--- a/app/code/Magento/Reports/etc/db_schema.xml
+++ b/app/code/Magento/Reports/etc/db_schema.xml
@@ -127,7 +127,7 @@
+ default="0"/>
+ default="0"/>
+ default="0"/>
+ nullable="true" default="0"/>
+ nullable="true" default="0"/>
+ nullable="true" default="0"/>
-
+ nullable="true" default="0"/>
+
+ nullable="true" default="0"/>
+ nullable="true" default="0"/>
+ nullable="true" default="0"/>
+ nullable="true" default="0"/>
+ nullable="true" default="0"/>
-
+ nullable="true" default="0"/>
+
+ nullable="true" default="0"/>
+ nullable="true" default="0"/>
-
-
-
-
-
-
-
-
+ nullable="true" default="0"/>
+
+
+
+
+
+
+
+
+ nullable="true" default="0"/>
+ nullable="true" default="0"/>
-
+ nullable="true" default="0"/>
+
-
-
-
-
-
-
-
-
-
-
-
+ nullable="true" default="0"/>
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
+ nullable="true" default="0"/>
+
+
+
+
+
+
+
+
+
+
+
+
+ nullable="true" default="0"/>
-
-
-
+ nullable="true" default="0"/>
+
+
+
-
-
+
+
+ nullable="true" default="0"/>
+ nullable="true" default="0"/>
+ nullable="true" default="0"/>
-
+ nullable="true" default="0"/>
+
+ nullable="true" default="0"/>
-
-
-
+ nullable="true" default="0"/>
+
+
+
@@ -173,24 +206,25 @@
identity="false" default="0"/>
+ nullable="true" default="0"/>
+ unsigned="false" nullable="true" default="0"/>
+ unsigned="false" nullable="true" default="0"/>
+ unsigned="false" nullable="true" default="0"/>
+ nullable="true" default="0"/>
+ unsigned="false" nullable="true" default="0"/>
+ nullable="true" default="0"/>
-
+ unsigned="false" nullable="true" default="0"/>
+
+ nullable="true" default="0"/>
@@ -241,10 +275,14 @@
-
-
-
-
+
+
+
+
@@ -257,12 +295,14 @@
-
+
+ nullable="true" default="0"/>
-
+
@@ -336,6 +376,12 @@
+
+
+
+
+
@@ -383,7 +429,7 @@
+ default="0"/>
@@ -394,95 +440,101 @@
+ default="0"/>
+ default="0"/>
+ default="0"/>
+ default="0"/>
+ default="0"/>
+ default="0"/>
+ default="0"/>
+ default="0"/>
-
-
+ default="0"/>
+
+
+ default="0"/>
+ default="0"/>
+ default="0"/>
+ default="0"/>
+ default="0"/>
+ default="0"/>
+ default="0"/>
+ nullable="true" default="0"/>
+ default="0"/>
+ nullable="true" default="0"/>
+ default="0"/>
+ nullable="true" default="0"/>
+ default="0"/>
+ default="0"/>
+ default="0"/>
+ default="0"/>
+ default="0"/>
-
+ nullable="true" default="0"/>
+
-
-
-
+
+
+
+ nullable="true" default="0"/>
+ nullable="true" default="0"/>
+ unsigned="false" nullable="true" default="0"/>
+ nullable="true" default="0"/>
+ unsigned="false" nullable="true" default="0"/>
+ nullable="true" default="0"/>
-
+ unsigned="false" nullable="true" default="0"/>
+
-
-
-
+ nullable="true" default="0"/>
+
+
+
+ nullable="true" default="0"/>
@@ -501,32 +553,41 @@
-
-
-
-
+ nullable="true" default="0"/>
+
+
+
+
+ nullable="true" default="0"/>
+ nullable="true" default="0"/>
+ nullable="true" default="0"/>
-
-
-
-
+ nullable="true" default="0"/>
+
+
+
+
-
+ nullable="true" default="0"/>
+
-
+ nullable="true" default="0"/>
+
+ nullable="true" default="0"/>
@@ -574,8 +635,10 @@
-
-
+
+
@@ -634,7 +697,8 @@
-
+
@@ -697,10 +761,12 @@
-
-
-
-
+
+
+
+
@@ -720,8 +786,9 @@
-
-
+
+
@@ -770,34 +837,44 @@
-
-
-
-
-
+
+
+
+
+
+ nullable="true" default="0"/>
-
-
-
-
+ nullable="true" default="0"/>
+
+
+
+
-
+ nullable="true" default="0"/>
+
-
-
-
-
-
+ nullable="true" default="0"/>
+
+
+
+
+
+ nullable="true" default="0"/>
+ unsigned="false" nullable="true" default="0"/>
+ unsigned="false" nullable="true" default="0"/>
-
+ unsigned="false" nullable="true" default="0"/>
+
-
+ nullable="true" default="0"/>
+
-
+
-
+ nullable="true" default="0"/>
+
@@ -948,24 +1028,32 @@
-
-
-
-
-
+
+
+
+
+
-
-
-
-
-
-
+ nullable="true" default="0"/>
+
+
+
+
+
+
-
+ nullable="true" default="0"/>
+
@@ -973,9 +1061,9 @@
+ nullable="true" default="0"/>
+ unsigned="false" nullable="true" default="0"/>
@@ -1012,43 +1100,54 @@
-
+
-
+ nullable="true" default="0"/>
+
-
-
+ nullable="true" default="0"/>
+
+
+ nullable="true" default="0"/>
-
-
-
+ nullable="true" default="0"/>
+
+
+
-
-
-
-
-
-
-
-
+ nullable="true" default="0"/>
+
+
+
+
+
+
+
+
-
-
-
+ nullable="true" default="0"/>
+
+
+
@@ -1068,16 +1167,17 @@
+ nullable="true" default="0"/>
+ unsigned="false" nullable="true" default="0"/>
+ unsigned="false" nullable="true" default="0"/>
-
+ unsigned="false" nullable="true" default="0"/>
+
+ nullable="true" default="0"/>
-
+
@@ -1139,15 +1240,16 @@
identity="false"/>
-
+
-
-
+ nullable="true" default="0"/>
+
+
+ nullable="true" default="0"/>
@@ -1201,24 +1303,32 @@
-
-
-
-
-
+
+
+
+
+
-
-
-
-
-
-
+ nullable="true" default="0"/>
+
+
+
+
+
+
-
+ nullable="true" default="0"/>
+
@@ -1226,9 +1336,9 @@
+ nullable="true" default="0"/>
+ unsigned="false" nullable="true" default="0"/>
@@ -1269,11 +1379,14 @@
-
-
-
+
+
+
+ nullable="true" default="0"/>
@@ -1296,11 +1409,14 @@
-
-
-
+
+
+
+ nullable="true" default="0"/>
@@ -1324,35 +1440,35 @@
+ default="0"/>
+ default="0"/>
+ nullable="false" default="0"/>
+ nullable="false" default="0"/>
+ nullable="false" default="0"/>
+ nullable="false" default="0"/>
+ nullable="false" default="0"/>
+ default="0"/>
+ nullable="false" default="0"/>
+ default="0"/>
+ nullable="false" default="0"/>
+ nullable="false" default="0"/>
+ nullable="false" default="0"/>
+ nullable="false" default="0"/>
+ nullable="false" default="0"/>
@@ -1376,35 +1492,35 @@
+ default="0"/>
+ default="0"/>
+ nullable="false" default="0"/>
+ nullable="false" default="0"/>
+ nullable="false" default="0"/>
+ nullable="false" default="0"/>
+ nullable="false" default="0"/>
+ default="0"/>
+ nullable="false" default="0"/>
+ default="0"/>
+ nullable="false" default="0"/>
+ nullable="false" default="0"/>
+ nullable="false" default="0"/>
+ nullable="false" default="0"/>
+ nullable="false" default="0"/>
@@ -1465,9 +1581,12 @@
-
-
-
+
+
+
@@ -1490,9 +1609,12 @@
-
-
-
+
+
+
@@ -1516,9 +1638,10 @@
-
+
+ nullable="true" default="0"/>
@@ -1543,9 +1666,10 @@
-
+
+ nullable="true" default="0"/>
@@ -1569,9 +1693,9 @@
+ default="0"/>
+ default="0"/>
@@ -1580,6 +1704,7 @@
+
@@ -1599,9 +1724,9 @@
+ default="0"/>
+ default="0"/>
@@ -1610,6 +1735,8 @@
+
@@ -1629,9 +1756,9 @@
+ default="0"/>
+ default="0"/>
@@ -1640,6 +1767,7 @@
+
@@ -1657,13 +1785,17 @@
-
-
+
+
-
+
-
+
@@ -1677,11 +1809,16 @@
-
-
-
-
-
+
+
+
+
+
diff --git a/app/code/Magento/SalesRule/etc/db_schema.xml b/app/code/Magento/SalesRule/etc/db_schema.xml
index 0c8a91175aa93..dbea9859c5161 100644
--- a/app/code/Magento/SalesRule/etc/db_schema.xml
+++ b/app/code/Magento/SalesRule/etc/db_schema.xml
@@ -22,8 +22,9 @@
default="0"/>
-
+ default="0"/>
+
+ default="0"/>
+ default="0"/>
+ default="0"/>
+ nullable="false" default="0"/>
+ nullable="false" default="0"/>
+ nullable="false" default="0"/>
@@ -223,17 +224,17 @@
+ default="0"/>
+ default="0"/>
+ default="0"/>
+ nullable="false" default="0"/>
+ nullable="false" default="0"/>
+ nullable="false" default="0"/>
@@ -263,11 +264,11 @@
+ default="0"/>
+ default="0"/>
+ default="0"/>
diff --git a/app/code/Magento/SalesSequence/etc/db_schema.xml b/app/code/Magento/SalesSequence/etc/db_schema.xml
index f49ca61f1637e..de5d78a5684c5 100644
--- a/app/code/Magento/SalesSequence/etc/db_schema.xml
+++ b/app/code/Magento/SalesSequence/etc/db_schema.xml
@@ -11,7 +11,7 @@
-
+
diff --git a/app/code/Magento/Search/etc/db_schema.xml b/app/code/Magento/Search/etc/db_schema.xml
index d478536cc4b26..a37ec6a8070de 100644
--- a/app/code/Magento/Search/etc/db_schema.xml
+++ b/app/code/Magento/Search/etc/db_schema.xml
@@ -52,7 +52,6 @@
default="0"/>
-
diff --git a/app/code/Magento/Security/etc/db_schema.xml b/app/code/Magento/Security/etc/db_schema.xml
index 6bbc85b074fd9..61a230706001e 100644
--- a/app/code/Magento/Security/etc/db_schema.xml
+++ b/app/code/Magento/Security/etc/db_schema.xml
@@ -9,7 +9,7 @@
default="1"/>
-
+
@@ -27,7 +27,7 @@
-
+
diff --git a/app/code/Magento/Tax/etc/db_schema.xml b/app/code/Magento/Tax/etc/db_schema.xml
index 21b6f5a6cef75..dd911796bb984 100644
--- a/app/code/Magento/Tax/etc/db_schema.xml
+++ b/app/code/Magento/Tax/etc/db_schema.xml
@@ -35,7 +35,7 @@
-
+
@@ -129,10 +129,11 @@
-
+
-
+
@@ -156,10 +157,11 @@
-
+
-
+
diff --git a/app/code/Magento/Theme/Setup/RecurringData.php b/app/code/Magento/Theme/Setup/RecurringData.php
index 9b2a9ab931304..972b60dc67f89 100644
--- a/app/code/Magento/Theme/Setup/RecurringData.php
+++ b/app/code/Magento/Theme/Setup/RecurringData.php
@@ -6,10 +6,12 @@
namespace Magento\Theme\Setup;
+use Magento\Framework\Indexer\IndexerRegistry;
use Magento\Framework\Setup\InstallDataInterface;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Theme\Model\Theme\Registration;
+use Magento\Theme\Model\Data\Design\Config;
/**
* Upgrade registered themes
@@ -23,14 +25,21 @@ class RecurringData implements InstallDataInterface
*/
private $themeRegistration;
+ /**
+ * @var IndexerRegistry
+ */
+ private $indexerRegistry;
+
/**
* Init
*
* @param Registration $themeRegistration
+ * @param IndexerRegistry $indexerRegistry
*/
- public function __construct(Registration $themeRegistration)
+ public function __construct(Registration $themeRegistration, IndexerRegistry $indexerRegistry)
{
$this->themeRegistration = $themeRegistration;
+ $this->indexerRegistry = $indexerRegistry;
}
/**
@@ -38,6 +47,8 @@ public function __construct(Registration $themeRegistration)
*/
public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
{
+ $indexer = $this->indexerRegistry->get(Config::DESIGN_CONFIG_GRID_INDEXER_ID);
+ $indexer->reindexAll();
$this->themeRegistration->register();
}
}
diff --git a/app/code/Magento/Theme/Setup/UpgradeData.php b/app/code/Magento/Theme/Setup/UpgradeData.php
index 366e5387b46e5..ade0e9d3f6c39 100644
--- a/app/code/Magento/Theme/Setup/UpgradeData.php
+++ b/app/code/Magento/Theme/Setup/UpgradeData.php
@@ -9,11 +9,9 @@
use Magento\Framework\DB\DataConverter\SerializedToJson;
use Magento\Framework\DB\FieldDataConverterFactory;
use Magento\Framework\DB\Select\QueryModifierFactory;
-use Magento\Framework\Indexer\IndexerRegistry;
use Magento\Framework\Setup\UpgradeDataInterface;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\ModuleDataSetupInterface;
-use Magento\Theme\Model\Data\Design\Config;
/**
* @codeCoverageIgnore
@@ -30,26 +28,18 @@ class UpgradeData implements UpgradeDataInterface
*/
private $queryModifierFactory;
- /**
- * @var IndexerRegistry
- */
- protected $indexerRegistry;
-
/**
* UpgradeData constructor
*
- * @param IndexerRegistry $indexerRegistry
* @param FieldDataConverterFactory $fieldDataConverterFactory
* @param QueryModifierFactory $queryModifierFactory
*/
public function __construct(
- IndexerRegistry $indexerRegistry,
FieldDataConverterFactory $fieldDataConverterFactory,
QueryModifierFactory $queryModifierFactory
) {
$this->fieldDataConverterFactory = $fieldDataConverterFactory;
$this->queryModifierFactory = $queryModifierFactory;
- $this->indexerRegistry = $indexerRegistry;
}
/**
@@ -58,8 +48,6 @@ public function __construct(
public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
{
$setup->startSetup();
- $indexer = $this->indexerRegistry->get(Config::DESIGN_CONFIG_GRID_INDEXER_ID);
- $indexer->reindexAll();
if (version_compare($context->getVersion(), '2.0.2', '<')) {
$this->upgradeToVersionTwoZeroTwo($setup);
}
diff --git a/app/code/Magento/Theme/etc/db_schema.xml b/app/code/Magento/Theme/etc/db_schema.xml
index 884a09e9c39c8..a70687eb9eff4 100644
--- a/app/code/Magento/Theme/etc/db_schema.xml
+++ b/app/code/Magento/Theme/etc/db_schema.xml
@@ -7,7 +7,7 @@
-
+
@@ -23,7 +23,7 @@
-
+
diff --git a/app/code/Magento/Weee/etc/db_schema.xml b/app/code/Magento/Weee/etc/db_schema.xml
index b513bf9689080..54a3b1153f7a2 100644
--- a/app/code/Magento/Weee/etc/db_schema.xml
+++ b/app/code/Magento/Weee/etc/db_schema.xml
@@ -9,7 +9,7 @@
default="0"/>
+ default="0"/>
@@ -40,4 +40,80 @@
+
+
+
+
diff --git a/app/code/Magento/Widget/etc/db_schema.xml b/app/code/Magento/Widget/etc/db_schema.xml
index 6f0e4b190ead6..49a2b0ddbcfb9 100644
--- a/app/code/Magento/Widget/etc/db_schema.xml
+++ b/app/code/Magento/Widget/etc/db_schema.xml
@@ -88,7 +88,7 @@
-
+
diff --git a/app/code/Magento/Wishlist/etc/db_schema.xml b/app/code/Magento/Wishlist/etc/db_schema.xml
index f9d0361a88371..2977494a6bda4 100644
--- a/app/code/Magento/Wishlist/etc/db_schema.xml
+++ b/app/code/Magento/Wishlist/etc/db_schema.xml
@@ -31,7 +31,7 @@
-
+
diff --git a/clean_db_schemas.php b/clean_db_schemas.php
index 081c906692c6c..2cd96079c3f16 100644
--- a/clean_db_schemas.php
+++ b/clean_db_schemas.php
@@ -45,7 +45,7 @@
$adapter->query('CREATE DATABASE ' . $resourceConnection->getSchemaName('default'));
foreach ($componentRegistrar->getPaths(\Magento\Framework\Component\ComponentRegistrar::MODULE) as $path) {
- if (strpos($path, 'magento2ee') !== false) {
+ if (strpos($path, 'magento2ce') !== false) {
@unlink($path . DIRECTORY_SEPARATOR . 'etc/db_schema.xml');
}
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Columns/Timestamp.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Columns/Timestamp.php
index c5bdf40e0fc50..480932691baa2 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Columns/Timestamp.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Columns/Timestamp.php
@@ -48,12 +48,16 @@ public function __construct(OnUpdate $onUpdate, ResourceConnection $resourceConn
*/
public function toDefinition(ElementInterface $column)
{
+ $nullable = $column->getDefault() === 'NULL' ? 'NULL' : 'NOT NULL';
+ $default = $column->getDefault() === 'NULL' ?
+ '' : sprintf('DEFAULT %s', $column->getDefault());
+
return sprintf(
- '%s %s %s %s',
+ '%s %s %s %s %s',
$this->resourceConnection->getConnection()->quoteIdentifier($column->getName()),
$column->getType(),
- $column->getDefault() === 'NULL' ?
- '' : sprintf('DEFAULT %s', $column->getDefault()),
+ $nullable,
+ $default,
$this->onUpdate->toDefinition($column)
);
}
@@ -64,7 +68,7 @@ public function toDefinition(ElementInterface $column)
public function fromDefinition(array $data)
{
if ($data['default'] === self::CONST_DEFAULT_TIMESTAMP) {
- $data['default'] = 0;
+ $data['default'] = '0';
}
$data = $this->onUpdate->fromDefinition($data);
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Columns/Varchar.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Columns/Varchar.php
index 819b29137de4c..8468c0487a1e1 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Columns/Varchar.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/Definition/Columns/Varchar.php
@@ -48,7 +48,7 @@ public function toDefinition(ElementInterface $column)
$column->getType(),
$column->getLength(),
$this->nullable->toDefinition($column),
- !empty($column->getDefault()) ?
+ $column->getDefault() !== null && $column->getDefault() !== '' ?
sprintf('DEFAULT "%s"', $column->getDefault()) : ''
);
}
diff --git a/setup/src/Magento/Setup/Model/Installer.php b/setup/src/Magento/Setup/Model/Installer.php
index f27c831148906..965ed287cfc04 100644
--- a/setup/src/Magento/Setup/Model/Installer.php
+++ b/setup/src/Magento/Setup/Model/Installer.php
@@ -916,7 +916,17 @@ private function handleDBSchemaData($setup, $type, array $request)
$this->logProgress();
}
}
-
+ $stagingModules = [
+ 'Magento_Bundle',
+ 'Magento_Catalog',
+ 'Magento_CatalogUrlRewrite',
+ 'Magento_CatalogInventory',
+ 'Magento_ConfigurableProduct',
+ 'Magento_ProductAlert',
+ 'Magento_Reports',
+ 'Magento_Weee',
+ 'Magento_Wishlist',
+ ];
$this->schemaListener->toogleIgnore(SchemaListener::IGNORE_ON);
if ($type === 'schema') {
$this->log->log('Schema post-updates:');
@@ -926,6 +936,10 @@ private function handleDBSchemaData($setup, $type, array $request)
$handlerType = 'data-recurring';
}
foreach ($moduleNames as $moduleName) {
+ if (in_array($moduleName, $stagingModules)) {
+ $this->schemaListener->setModuleName($moduleName);
+ $this->schemaListener->toogleIgnore(SchemaListener::IGNORE_OFF);
+ }
$this->log->log("Module '{$moduleName}':");
$modulePostUpdater = $this->getSchemaDataHandler($moduleName, $handlerType);
if ($modulePostUpdater) {
@@ -933,6 +947,7 @@ private function handleDBSchemaData($setup, $type, array $request)
$modulePostUpdater->install($setup, $moduleContextList[$moduleName]);
}
$this->logProgress();
+ $this->schemaListener->toogleIgnore(SchemaListener::IGNORE_ON);
}
$this->schemaListener->toogleIgnore(SchemaListener::IGNORE_OFF);
}
From 79b0a41f6feb8f4f4b5244567a2811dbb751e7c6 Mon Sep 17 00:00:00 2001
From: Kieu Phan
Date: Fri, 5 Jan 2018 00:25:39 -0600
Subject: [PATCH 260/904] MAGETWO-85452: QA Activities
- Clear preReqData after each test
---
.../AdminAddImageToWYSIWYGCatalogCest.xml | 21 +++++------
.../AdminAddImageToWYSIWYGProductCest.xml | 35 ++++++++++---------
...dminEditTextEditorProductAttributeCest.xml | 8 +++--
...erifyDefaultWYSIWYGToolbarOnProducCest.xml | 6 ++--
...yTinyMCEv4IsNativeWYSIWYGOnCatalogCest.xml | 8 +++--
...yTinyMCEv4IsNativeWYSIWYGOnProductCest.xml | 5 +--
.../Cest/AdminAddImageToWYSIWYGBlockCest.xml | 3 +-
.../Cest/AdminAddImageToWYSIWYGCMSCest.xml | 17 ++++-----
.../AdminAddVariableToWYSIWYGBlockCest.xml | 3 +-
.../Cest/AdminAddWidgetToWYSIWYGBlockCest.xml | 4 +--
...getToWYSIWYGWithCMSStaticBlockTypeCest.xml | 3 +-
...WYSIWYGWithCatalogCategoryLinkTypeCest.xml | 1 +
...oWYSIWYGWithCatalogProductLinkTypeCest.xml | 2 ++
...oWYSIWYGWithCatalogProductListTypeCest.xml | 3 ++
...YGWithRecentlyComparedProductsTypeCest.xml | 2 ++
...IWYGWithRecentlyViewedProductsTypeCest.xml | 2 ++
...ifyTinyMCEv4IsNativeWYSIWYGOnBlockCest.xml | 3 +-
.../Cms/Metadata/block-meta.xml | 4 +++
.../FunctionalTest/Cms/Metadata/cms-meta.xml | 2 +-
.../AdminAddImageToWYSIWYGNewsletterCest.xml | 16 ++++-----
20 files changed, 89 insertions(+), 59 deletions(-)
diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Cest/AdminAddImageToWYSIWYGCatalogCest.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Cest/AdminAddImageToWYSIWYGCatalogCest.xml
index 6000f3ea1c310..7f719f1fd021e 100644
--- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Cest/AdminAddImageToWYSIWYGCatalogCest.xml
+++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Cest/AdminAddImageToWYSIWYGCatalogCest.xml
@@ -28,18 +28,18 @@
-
-
+
+
-
+
-
-
+
+
@@ -47,7 +47,7 @@
-
+
@@ -63,18 +63,19 @@
-
+
-
+
-
+
+
-
+
diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Cest/AdminAddImageToWYSIWYGProductCest.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Cest/AdminAddImageToWYSIWYGProductCest.xml
index fbc835ff8b55c..85b8f2a70e8fe 100644
--- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Cest/AdminAddImageToWYSIWYGProductCest.xml
+++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Cest/AdminAddImageToWYSIWYGProductCest.xml
@@ -28,17 +28,18 @@
-
+
+
-
-
+
+
@@ -52,9 +53,9 @@
-
+
-
+
@@ -64,28 +65,29 @@
-
+
-
+
-
+
+
-
-
+
+
+
-
-
+
@@ -93,18 +95,19 @@
-
+
-
+
-
+
+
-
+
diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Cest/AdminEditTextEditorProductAttributeCest.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Cest/AdminEditTextEditorProductAttributeCest.xml
index e4bba1ddc4d97..2b8ef929051f8 100644
--- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Cest/AdminEditTextEditorProductAttributeCest.xml
+++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Cest/AdminEditTextEditorProductAttributeCest.xml
@@ -40,7 +40,7 @@
-
+
@@ -52,6 +52,7 @@
+
@@ -65,9 +66,9 @@
-
+
-
+
@@ -75,6 +76,7 @@
+
diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Cest/VerifyDefaultWYSIWYGToolbarOnProducCest.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Cest/VerifyDefaultWYSIWYGToolbarOnProducCest.xml
index 87c7b470305cc..e2c402422c22b 100644
--- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Cest/VerifyDefaultWYSIWYGToolbarOnProducCest.xml
+++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Cest/VerifyDefaultWYSIWYGToolbarOnProducCest.xml
@@ -30,7 +30,8 @@
-
+
+
@@ -56,7 +57,8 @@
-
+
+
diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Cest/VerifyTinyMCEv4IsNativeWYSIWYGOnCatalogCest.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Cest/VerifyTinyMCEv4IsNativeWYSIWYGOnCatalogCest.xml
index 108d3172d468d..90f517521f210 100644
--- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Cest/VerifyTinyMCEv4IsNativeWYSIWYGOnCatalogCest.xml
+++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Cest/VerifyTinyMCEv4IsNativeWYSIWYGOnCatalogCest.xml
@@ -12,10 +12,11 @@
-
+
+
@@ -30,8 +31,8 @@
-
-
+
+
@@ -61,6 +62,7 @@
+
diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Cest/VerifyTinyMCEv4IsNativeWYSIWYGOnProductCest.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Cest/VerifyTinyMCEv4IsNativeWYSIWYGOnProductCest.xml
index df57f7b241f77..478110dd9a12a 100644
--- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Cest/VerifyTinyMCEv4IsNativeWYSIWYGOnProductCest.xml
+++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Cest/VerifyTinyMCEv4IsNativeWYSIWYGOnProductCest.xml
@@ -11,7 +11,7 @@
-
+
@@ -29,11 +29,12 @@
-
+
+
diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddImageToWYSIWYGBlockCest.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddImageToWYSIWYGBlockCest.xml
index 1cac975dab8e0..699c2e23989b2 100644
--- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddImageToWYSIWYGBlockCest.xml
+++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddImageToWYSIWYGBlockCest.xml
@@ -16,7 +16,7 @@
-
+
@@ -108,6 +108,7 @@
+
diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddImageToWYSIWYGCMSCest.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddImageToWYSIWYGCMSCest.xml
index 80e6d971cc4c9..dfa358c5caf40 100644
--- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddImageToWYSIWYGCMSCest.xml
+++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddImageToWYSIWYGCMSCest.xml
@@ -28,14 +28,14 @@
-
+
-
+
-
+
@@ -49,9 +49,9 @@
-
+
-
+
@@ -61,7 +61,7 @@
-
+
@@ -69,13 +69,14 @@
-
+
+
-
+
diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddVariableToWYSIWYGBlockCest.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddVariableToWYSIWYGBlockCest.xml
index 9c01494b749dd..05b8f2e027c6a 100644
--- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddVariableToWYSIWYGBlockCest.xml
+++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddVariableToWYSIWYGBlockCest.xml
@@ -16,7 +16,7 @@
-
+
@@ -121,6 +121,7 @@
+
diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGBlockCest.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGBlockCest.xml
index 5d3e60220faef..83d0eaf2c44c9 100644
--- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGBlockCest.xml
+++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGBlockCest.xml
@@ -16,7 +16,7 @@
-
+
@@ -79,7 +79,7 @@
-
+
diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGWithCMSStaticBlockTypeCest.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGWithCMSStaticBlockTypeCest.xml
index 0bf617bf29ca4..29b96d3aff72a 100644
--- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGWithCMSStaticBlockTypeCest.xml
+++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGWithCMSStaticBlockTypeCest.xml
@@ -17,7 +17,7 @@
-
+
@@ -69,6 +69,7 @@
+
diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGWithCatalogCategoryLinkTypeCest.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGWithCatalogCategoryLinkTypeCest.xml
index 425226f3527eb..8fcf656cd1cc7 100644
--- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGWithCatalogCategoryLinkTypeCest.xml
+++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGWithCatalogCategoryLinkTypeCest.xml
@@ -66,6 +66,7 @@
+
diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGWithCatalogProductLinkTypeCest.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGWithCatalogProductLinkTypeCest.xml
index 9521b0a8afd47..0fbc7c2d0b869 100644
--- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGWithCatalogProductLinkTypeCest.xml
+++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGWithCatalogProductLinkTypeCest.xml
@@ -74,6 +74,8 @@
+
+
diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGWithCatalogProductListTypeCest.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGWithCatalogProductListTypeCest.xml
index 8772efe0a2aa5..25769100f2707 100644
--- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGWithCatalogProductListTypeCest.xml
+++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGWithCatalogProductListTypeCest.xml
@@ -79,6 +79,9 @@
+
+
+
diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGWithRecentlyComparedProductsTypeCest.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGWithRecentlyComparedProductsTypeCest.xml
index f2518c94385c5..c3a91eadd4bd5 100644
--- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGWithRecentlyComparedProductsTypeCest.xml
+++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGWithRecentlyComparedProductsTypeCest.xml
@@ -84,6 +84,8 @@
+
+
diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGWithRecentlyViewedProductsTypeCest.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGWithRecentlyViewedProductsTypeCest.xml
index 82cd169d0a933..577f5560567a0 100644
--- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGWithRecentlyViewedProductsTypeCest.xml
+++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGWithRecentlyViewedProductsTypeCest.xml
@@ -74,6 +74,8 @@
+
+
diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/VerifyTinyMCEv4IsNativeWYSIWYGOnBlockCest.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/VerifyTinyMCEv4IsNativeWYSIWYGOnBlockCest.xml
index 24fe3223c768e..2edde1df3355b 100644
--- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/VerifyTinyMCEv4IsNativeWYSIWYGOnBlockCest.xml
+++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/VerifyTinyMCEv4IsNativeWYSIWYGOnBlockCest.xml
@@ -18,7 +18,7 @@
-
+
@@ -92,6 +92,7 @@
+
diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Metadata/block-meta.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Metadata/block-meta.xml
index 0b8a174b60da3..0d2bc1bb3532c 100644
--- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Metadata/block-meta.xml
+++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Metadata/block-meta.xml
@@ -16,4 +16,8 @@
true
+
+
+ application/json
+
diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Metadata/cms-meta.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Metadata/cms-meta.xml
index c9ac524a161e8..da69bf2049598 100644
--- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Metadata/cms-meta.xml
+++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Metadata/cms-meta.xml
@@ -17,7 +17,7 @@
string
-
+
application/json
diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Newsletter/Cest/AdminAddImageToWYSIWYGNewsletterCest.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Newsletter/Cest/AdminAddImageToWYSIWYGNewsletterCest.xml
index b93ff0a5fff6e..e238228ff6846 100644
--- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Newsletter/Cest/AdminAddImageToWYSIWYGNewsletterCest.xml
+++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Newsletter/Cest/AdminAddImageToWYSIWYGNewsletterCest.xml
@@ -35,10 +35,10 @@
-
+
-
+
@@ -53,9 +53,9 @@
-
+
-
+
@@ -65,7 +65,7 @@
-
+
@@ -73,14 +73,14 @@
-
+
-
+
-
+
From 5d9247a1cddabfe5358981254572d8f9e12d3cd0 Mon Sep 17 00:00:00 2001
From: Dan Mooney
Date: Fri, 5 Jan 2018 10:39:39 -0600
Subject: [PATCH 261/904] MAGETWO-86383: Admin are unable to add variable to
CMS Page and Block on Firefox
Use jQuery global explicitly
---
.../tiny_mce/plugins/magentovariable/editor_plugin.js | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/lib/web/mage/adminhtml/wysiwyg/tiny_mce/plugins/magentovariable/editor_plugin.js b/lib/web/mage/adminhtml/wysiwyg/tiny_mce/plugins/magentovariable/editor_plugin.js
index d96ab6dcc5353..2168c5794241d 100644
--- a/lib/web/mage/adminhtml/wysiwyg/tiny_mce/plugins/magentovariable/editor_plugin.js
+++ b/lib/web/mage/adminhtml/wysiwyg/tiny_mce/plugins/magentovariable/editor_plugin.js
@@ -171,18 +171,18 @@ tinymce.create('tinymce.plugins.magentovariable', {
el = spans[i];
if (el.hasClassName('magento-custom-var')) {
- $(el).replaceWith(
+ jQuery(el).replaceWith(
this.customDirectiveGenerator.processConfig(
Base64.idDecode(
- $(el).getAttribute('id')
+ jQuery(el).attr('id')
)
)
);
} else {
- $(el).replaceWith(
+ jQuery(el).replaceWith(
this.configDirectiveGenerator.processConfig(
Base64.idDecode(
- $(el).getAttribute('id')
+ jQuery(el).attr('id')
)
)
);
From 3dee823f028edf0798ee50c55ec7a56c5c35068b Mon Sep 17 00:00:00 2001
From: Sergii Kovalenko
Date: Fri, 5 Jan 2018 19:08:44 +0200
Subject: [PATCH 262/904] MAGETWO-85326: Tool for generating schema
--make possible upgrade from CE to EE
---
app/etc/di.xml | 3 +-
.../Schema/Db/DbSchemaWriterInterface.php | 42 +++--
.../Schema/Db/MySQL/DbSchemaWriter.php | 121 +++++++-------
.../Model/Declaration/Schema/Db/Statement.php | 147 ++++++++++++++++++
.../Schema/Db/StatementFactory.php | 54 +++++++
.../Model/Declaration/Schema/Diff/Diff.php | 17 +-
.../Declaration/Schema/Diff/DiffInterface.php | 5 +-
.../Declaration/Schema/Diff/DiffManager.php | 13 +-
.../Declaration/Schema/Diff/TableDiff.php | 2 +-
.../Model/Declaration/Schema/Dto/Column.php | 20 ++-
.../Declaration/Schema/Dto/Columns/Blob.php | 10 +-
.../Schema/Dto/Columns/Boolean.php | 16 +-
.../Schema/Dto/Columns/Decimal.php | 18 ++-
.../Schema/Dto/Columns/Integer.php | 20 +--
.../Declaration/Schema/Dto/Columns/Text.php | 10 +-
.../Schema/Dto/Columns/Timestamp.php | 14 +-
.../Schema/Dto/Columns/Varchar.php | 18 ++-
.../Declaration/Schema/OperationInterface.php | 4 +-
.../Schema/Operations/AddColumn.php | 117 ++++++++++++++
.../{AddElement.php => AddComplexElement.php} | 9 +-
.../Schema/Operations/CreateTable.php | 2 +-
.../Schema/Operations/DropElement.php | 2 +-
.../Schema/Operations/DropTable.php | 2 +-
.../Schema/Operations/ModifyElement.php | 43 ++---
.../Schema/Operations/ReCreateTable.php | 4 +-
.../Declaration/Schema/OperationsExecutor.php | 52 ++++++-
.../Declaration/Schema/etc/types/column.xsd | 7 +
27 files changed, 590 insertions(+), 182 deletions(-)
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Db/Statement.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Db/StatementFactory.php
create mode 100644 setup/src/Magento/Setup/Model/Declaration/Schema/Operations/AddColumn.php
rename setup/src/Magento/Setup/Model/Declaration/Schema/Operations/{AddElement.php => AddComplexElement.php} (85%)
diff --git a/app/etc/di.xml b/app/etc/di.xml
index c0c5108078b10..60ae74e20ed42 100755
--- a/app/etc/di.xml
+++ b/app/etc/di.xml
@@ -1423,7 +1423,8 @@
- Magento\Setup\Model\Declaration\Schema\Operations\ReCreateTable
- Magento\Setup\Model\Declaration\Schema\Operations\DropTable
- Magento\Setup\Model\Declaration\Schema\Operations\CreateTable
- - Magento\Setup\Model\Declaration\Schema\Operations\AddElement
+ - Magento\Setup\Model\Declaration\Schema\Operations\AddColumn
+ - Magento\Setup\Model\Declaration\Schema\Operations\AddComplexElement
- Magento\Setup\Model\Declaration\Schema\Operations\DropElement
- Magento\Setup\Model\Declaration\Schema\Operations\ModifyElement
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/DbSchemaWriterInterface.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/DbSchemaWriterInterface.php
index 6d9df77aaa55d..1912f1289b56f 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/DbSchemaWriterInterface.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/DbSchemaWriterInterface.php
@@ -12,13 +12,28 @@
*/
interface DbSchemaWriterInterface
{
+ /**
+ * Type for all alter statements
+ */
+ const ALTER_TYPE = 'alter';
+
+ /**
+ * Type for all create statements
+ */
+ const CREATE_TYPE = 'create';
+
+ /**
+ * Type for all drop statements
+ */
+ const DROP_TYPE = 'drop';
+
/**
* Create table from SQL fragments, like columns, constraints, foreign keys, indexes, etc
*
* @param $tableName
* @param $resource
* @param array $definition
- * @return void
+ * @return Statement
*/
public function createTable($tableName, $resource, array $definition);
@@ -27,7 +42,7 @@ public function createTable($tableName, $resource, array $definition);
*
* @param string $tableName
* @param string $resource
- * @return mixed
+ * @return Statement
*/
public function dropTable($tableName, $resource);
@@ -41,7 +56,7 @@ public function dropTable($tableName, $resource);
* @param string $tableName
* @param string $elementDefinition , for example: like CHAR(200) NOT NULL
* @param string $elementType
- * @return mixed
+ * @return Statement
*/
public function addElement($elementName, $resource, $tableName, $elementDefinition, $elementType);
@@ -53,31 +68,26 @@ public function addElement($elementName, $resource, $tableName, $elementDefiniti
* @param $resource
* @param $tableName
* @param string $columnDefinition
- * @return void
+ * @return Statement
*/
public function modifyColumn($resource, $tableName, $columnDefinition);
/**
- * As we can`t just drop and recreate constraint in 2 requests
- * we need to do this in one request
+ * Drop any element (constraint, column, index) from index
*
* @param string $resource
* @param string $elementName
* @param string $tableName
* @param string $type
- * @param string $constraintDefinition
- * @return void
+ * @return Statement
*/
- public function modifyConstraint($resource, $elementName, $tableName, $type, $constraintDefinition);
+ public function dropElement($resource, $elementName, $tableName, $type);
/**
- * Drop any element (constraint, column, index) from index
+ * Compile statements and make SQL request from them
*
- * @param string $resource
- * @param string $elementName
- * @param string $tableName
- * @param string $type
- * @return \Zend_Db_Statement_Interface
+ * @param Statement $statement
+ * @return void
*/
- public function dropElement($resource, $elementName, $tableName, $type);
+ public function compile(Statement $statement);
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/DbSchemaWriter.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/DbSchemaWriter.php
index 05ef2a07e2d94..e1cb55dbdf613 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/DbSchemaWriter.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/MySQL/DbSchemaWriter.php
@@ -10,6 +10,8 @@
use Magento\Framework\DB\Adapter\AdapterInterface;
use Magento\Setup\Model\Declaration\Schema\Db\DbSchemaWriterInterface;
use Magento\Setup\Model\Declaration\Schema\Db\MySQL\Definition\Constraints\Internal;
+use Magento\Setup\Model\Declaration\Schema\Db\Statement;
+use Magento\Setup\Model\Declaration\Schema\Db\StatementFactory;
use Magento\Setup\Model\Declaration\Schema\Dto\Column;
use Magento\Setup\Model\Declaration\Schema\Dto\Constraint;
use Magento\Setup\Model\Declaration\Schema\Dto\Constraints\Reference;
@@ -19,52 +21,68 @@
*/
class DbSchemaWriter implements DbSchemaWriterInterface
{
+ /**
+ * Statement directives with which we will decide what to do with tables
+ *
+ * @var array
+ */
+ private $statementDirectives = [
+ self::ALTER_TYPE => 'ALTER TABLE %s %s',
+ self::CREATE_TYPE => 'CREATE TABLE %s %s',
+ self::DROP_TYPE => 'DROP TABLE %s'
+ ];
+
/**
* @var ResourceConnection
*/
private $resourceConnection;
+ /**
+ * @var StatementFactory
+ */
+ private $statementFactory;
+
/**
* @param ResourceConnection $resourceConnection
+ * @param StatementFactory $statementFactory
*/
- public function __construct(ResourceConnection $resourceConnection)
+ public function __construct(ResourceConnection $resourceConnection, StatementFactory $statementFactory)
{
$this->resourceConnection = $resourceConnection;
+ $this->statementFactory = $statementFactory;
}
/**
* @inheritdoc
- * @return \Zend_Db_Statement_Interface
*/
public function createTable($tableName, $resource, array $definition)
{
- $adapter = $this->resourceConnection->getConnection($resource);
-
$sql = sprintf(
- "CREATE TABLE %s (\n%s\n)",
- $adapter->quoteIdentifier($tableName),
+ "(\n%s\n)",
implode(", \n", $definition)
);
- return $adapter->query($sql);
+ return $this->statementFactory->create(
+ $tableName,
+ self::CREATE_TYPE,
+ $sql,
+ $resource
+ );
}
/**
* Drop table from MySQL database
*
* @inheritdoc
- * @return \Zend_Db_Statement_Interface
*/
public function dropTable($tableName, $resource)
{
- $adapter = $this->resourceConnection->getConnection($resource);
-
- $sql = sprintf(
- 'DROP TABLE %s',
- $adapter->quoteIdentifier($tableName)
+ return $this->statementFactory->create(
+ $tableName,
+ self::DROP_TYPE,
+ '',
+ $resource
);
-
- return $adapter->query($sql);
}
/**
@@ -97,82 +115,79 @@ private function getDropElementSQL($type, $name)
* We can add three different elements: column, constraint or index
*
* @inheritdoc
- * @return \Zend_Db_Statement_Interface
*/
public function addElement($elementName, $resource, $tableName, $elementDefinition, $elementType)
{
- $addElementSyntax = $elementType === Column::TYPE ? 'ALTER TABLE %s ADD COLUMN %s' : 'ALTER TABLE %s ADD %s';
-
- $adapter = $this->resourceConnection->getConnection($resource);
-
+ $addElementSyntax = $elementType === Column::TYPE ? 'ADD COLUMN %s' : 'ADD %s';
$sql = sprintf(
$addElementSyntax,
- $adapter->quoteIdentifier($tableName),
$elementDefinition
);
-
- return $adapter->query($sql);
+ return $this->statementFactory->create(
+ $tableName,
+ self::ALTER_TYPE,
+ $sql,
+ $resource
+ );
}
/**
* Modify column and change it definition
*
* @inheritdoc
- * @return \Zend_Db_Statement_Interface
*/
public function modifyColumn($resource, $tableName, $columnDefinition)
{
- $adapter = $this->resourceConnection->getConnection($resource);
-
$sql = sprintf(
- 'ALTER TABLE %s MODIFY COLUMN %s',
- $adapter->quoteIdentifier($tableName),
+ 'MODIFY COLUMN %s',
$columnDefinition
);
-
- return $adapter->query($sql);
+ return $this->statementFactory->create(
+ $tableName,
+ self::ALTER_TYPE,
+ $sql,
+ $resource
+ );
}
/**
- * Do Drop and Add in one query
- *
- * For example ALTER TABLE example DROP FOREIGN KEY `foreign_key`, ADD FOREIGN KEY `foreign_key` ...
- *
* @inheritdoc
*/
- public function modifyConstraint($resource, $elementName, $tableName, $type, $constraintDefinition)
+ public function dropElement($resource, $elementName, $tableName, $type)
{
$adapter = $this->resourceConnection->getConnection($resource);
+
$sql = sprintf(
- 'ALTER TABLE %s %s, %s',
- $adapter->quoteIdentifier($tableName),
+ '%s',
$this->getDropElementSQL(
$type,
$adapter->quoteIdentifier($elementName)
- ),
- sprintf('ADD %s', $constraintDefinition)
+ )
+ );
+ return $this->statementFactory->create(
+ $tableName,
+ self::ALTER_TYPE,
+ $sql,
+ $resource
);
-
- return $adapter->query($sql);
}
/**
* @inheritdoc
- * @return \Zend_Db_Statement_Interface
*/
- public function dropElement($resource, $elementName, $tableName, $type)
+ public function compile(Statement $statement)
{
- $adapter = $this->resourceConnection->getConnection($resource);
-
- $sql = sprintf(
- 'ALTER TABLE %s %s',
- $adapter->quoteIdentifier($tableName),
- $this->getDropElementSQL(
- $type,
- $adapter->quoteIdentifier($elementName)
+ $adapter = $this->resourceConnection->getConnection($statement->getResource());
+ $adapter->query(
+ sprintf(
+ $this->statementDirectives[$statement->getType()],
+ $adapter->quoteIdentifier($statement->getTableName()),
+ implode(", ", $statement->getStatements())
)
);
-
- return $adapter->query($sql);
+ //Do post update, like SQL DML operations or etc...
+ foreach ($statement->getTriggers() as $trigger) {
+ call_user_func($trigger);
+ }
}
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Statement.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Statement.php
new file mode 100644
index 0000000000000..3221ae3038e12
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/Statement.php
@@ -0,0 +1,147 @@
+statements[] = $statement;
+ $this->type = $type;
+ $this->tableName = $tableName;
+ $this->resource = $resource;
+ }
+
+ /**
+ * Can merge few different statements with each other
+ *
+ * @param Statement $statement
+ * @return $this
+ */
+ public function merge(Statement $statement)
+ {
+ $this->statements = array_merge(
+ $this->getStatements(),
+ $statement->getStatements()
+ );
+
+ return $this;
+ }
+
+ /**
+ * @return array
+ */
+ public function getStatements(): array
+ {
+ return $this->statements;
+ }
+
+ /**
+ * Add trigger to current statement
+ * This means, that statement is final and can`t be modified any more
+ *
+ * @param callable $trigger
+ */
+ public function addTrigger(Callable $trigger)
+ {
+ $this->triggers[] = $trigger;
+ }
+
+ /**
+ * @return string
+ */
+ public function getType(): string
+ {
+ return $this->type;
+ }
+
+ /**
+ * Before we will do merge, we need to ensure that we can do it
+ *
+ * @param Statement $statement
+ * @return bool
+ */
+ public function canDoMerge(Statement $statement)
+ {
+ if (!empty($this->triggers)) {
+ /**
+ * If we add trigger after some specific statement, than we say that statement is final
+ * and can`t be updated anymore. Otherwise trigger can fails
+ */
+ return false;
+ }
+
+ return $statement->getType() === $this->getType() &&
+ $statement->getTableName() === $this->getTableName() &&
+ $statement->getResource() === $this->getResource();
+ }
+
+ /**
+ * @return string
+ */
+ public function getTableName(): string
+ {
+ return $this->tableName;
+ }
+
+ /**
+ * @return string
+ */
+ public function getResource(): string
+ {
+ return $this->resource;
+ }
+
+ /**
+ * @return Callable[]
+ */
+ public function getTriggers(): array
+ {
+ return $this->triggers;
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Db/StatementFactory.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/StatementFactory.php
new file mode 100644
index 0000000000000..1a277e88c4c78
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Db/StatementFactory.php
@@ -0,0 +1,54 @@
+objectManager = $objectManager;
+ $this->className = $className;
+ }
+
+ /**
+ * Create statemtnt object
+ *
+ * @param string $tableName
+ * @param string $type
+ * @param string $statement
+ * @param string $resource
+ * @return Statement
+ */
+ public function create(string $tableName, string $type, string $statement, string $resource)
+ {
+ return $this->objectManager->create($this->className, [
+ 'tableName' => $tableName,
+ 'resource' => $resource,
+ 'type' => $type,
+ 'statement' => $statement
+ ]);
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/Diff.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/Diff.php
index 592c050eba869..3b606c8f0ad63 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/Diff.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/Diff.php
@@ -66,13 +66,9 @@ public function __construct(
/**
* @inheritdoc
*/
- public function get($operation = null)
+ public function getAll()
{
- if ($operation === null) {
- return $this->changes;
- }
-
- return isset($this->changes[$operation]) ? $this->changes[$operation] : [];
+ return $this->changes;
}
/**
@@ -132,18 +128,17 @@ public function registerInstallationRequest(Request $request)
}
/**
+ * @param TableElementInterface $dtoObject
* @inheritdoc
*/
public function register(ElementInterface $dtoObject, $operation, ElementInterface $oldDtoObject = null)
{
- //Comment until whitelist functionality will be done
- if (!$this->canBeRegistered($dtoObject)) {
- // return $this; //ignore any operations for non registered elements changes
- }
$historyData = ['new' => $dtoObject, 'old' => $oldDtoObject];
$history = $this->elementHistoryFactory->create($historyData);
+ $dtoObjectName = $dtoObject instanceof TableElementInterface ?
+ $dtoObject->getTable()->getName() : $dtoObject->getName();
//dtoObjects can have 4 types: column, constraint, index, table
- $this->changes[$operation][] = $history;
+ $this->changes[$dtoObjectName][$operation][] = $history;
return $this;
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/DiffInterface.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/DiffInterface.php
index 16bb56825e871..9f2079fbaab5b 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/DiffInterface.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/DiffInterface.php
@@ -32,10 +32,9 @@ interface DiffInterface
* ]
* ]
*
- * @param string $operation If operation is not specified, changes for all operations will be retrieved
- * @return ElementHistory[]
+ * @return array
*/
- public function get($operation = null);
+ public function getAll();
/**
* Register operation
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/DiffManager.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/DiffManager.php
index 6897d0bba3f88..ed9fe35aba388 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/DiffManager.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/DiffManager.php
@@ -7,9 +7,11 @@
namespace Magento\Setup\Model\Declaration\Schema\Diff;
use Magento\Setup\Model\Declaration\Schema\Comparator;
+use Magento\Setup\Model\Declaration\Schema\Dto\Column;
use Magento\Setup\Model\Declaration\Schema\Dto\ElementInterface;
use Magento\Setup\Model\Declaration\Schema\Dto\Table;
-use Magento\Setup\Model\Declaration\Schema\Operations\AddElement;
+use Magento\Setup\Model\Declaration\Schema\Operations\AddColumn;
+use Magento\Setup\Model\Declaration\Schema\Operations\AddComplexElement;
use Magento\Setup\Model\Declaration\Schema\Operations\CreateTable;
use Magento\Setup\Model\Declaration\Schema\Operations\DropElement;
use Magento\Setup\Model\Declaration\Schema\Operations\DropTable;
@@ -120,7 +122,14 @@ public function registerRemoval(
*/
public function registerCreation(DiffInterface $diff, ElementInterface $element)
{
- $operation = $element instanceof Table ? CreateTable::OPERATION_NAME : AddElement::OPERATION_NAME;
+ if ($element instanceof Table) {
+ $operation = CreateTable::OPERATION_NAME;
+ } elseif ($element instanceof Column) {
+ $operation = AddColumn::OPERATION_NAME;
+ } else {
+ $operation = AddComplexElement::OPERATION_NAME;
+ }
+
$diff->register(
$element,
$operation
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/TableDiff.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/TableDiff.php
index 79888c564d677..e59ad30dfa29d 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/TableDiff.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/TableDiff.php
@@ -77,7 +77,7 @@ public function diff(
ElementInterface $generatedTable,
Diff $diff
) {
- //Handle changing resource
+ //Handle changing shard
if ($generatedTable->getResource() !== $declaredTable->getResource()) {
$diff->register(
$declaredTable,
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Column.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Column.php
index 663da48771275..79d30e8ebb1cb 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Column.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Column.php
@@ -24,18 +24,26 @@ class Column extends GenericElement implements
*/
private $table;
+ /**
+ * @var null|string
+ */
+ private $onCreate;
+
/**
* @param string $name
* @param string $type
- * @param Table $table
+ * @param Table $table
+ * @param string|null $onCreate
*/
public function __construct(
string $name,
string $type,
- Table $table
+ Table $table,
+ string $onCreate = null
) {
parent::__construct($name, $type);
$this->table = $table;
+ $this->onCreate = $onCreate;
}
/**
@@ -55,4 +63,12 @@ public function getElementType()
{
return self::TYPE;
}
+
+ /**
+ * @return null|string
+ */
+ public function getOnCreate()
+ {
+ return $this->onCreate;
+ }
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Blob.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Blob.php
index 23960dd8d0317..410f74fab18ce 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Blob.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Blob.php
@@ -26,16 +26,18 @@ class Blob extends Column implements
/**
* @param string $name
* @param string $type
- * @param Table $table
- * @param bool $nullable
+ * @param Table $table
+ * @param bool $nullable
+ * @param string|null $onCreate
*/
public function __construct(
string $name,
string $type,
Table $table,
- bool $nullable = true
+ bool $nullable = true,
+ string $onCreate = null
) {
- parent::__construct($name, $type, $table);
+ parent::__construct($name, $type, $table, $onCreate);
$this->nullable = $nullable;
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Boolean.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Boolean.php
index 9c810c1daf156..9e07010172ef6 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Boolean.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Boolean.php
@@ -29,20 +29,22 @@ class Boolean extends Column implements
private $default;
/**
- * @param string $name
- * @param string $type
- * @param Table $table
- * @param $nullable
- * @param $default
+ * @param string $name
+ * @param string $type
+ * @param Table $table
+ * @param bool $nullable
+ * @param bool $default
+ * @param string|null $onCreate
*/
public function __construct(
string $name,
string $type,
Table $table,
bool $nullable = true,
- bool $default = false
+ bool $default = false,
+ string $onCreate = null
) {
- parent::__construct($name, $type, $table);
+ parent::__construct($name, $type, $table, $onCreate);
$this->nullable = $nullable;
$this->default = $default;
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Decimal.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Decimal.php
index b315aeb80f850..dff1932089ef2 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Decimal.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Decimal.php
@@ -48,12 +48,13 @@ class Decimal extends Column implements
/**
* @param string $name
* @param string $type
- * @param Table $table
- * @param int $precission
- * @param int $scale
- * @param bool $nullable
- * @param float $default
- * @param bool $unsigned
+ * @param Table $table
+ * @param int $precission
+ * @param int $scale
+ * @param bool $nullable
+ * @param bool $unsigned
+ * @param float $default
+ * @param string|null $onCreate
*/
public function __construct(
string $name,
@@ -63,9 +64,10 @@ public function __construct(
int $scale,
bool $nullable = true,
bool $unsigned = false,
- float $default = null
+ float $default = null,
+ string $onCreate = null
) {
- parent::__construct($name, $type, $table);
+ parent::__construct($name, $type, $table, $onCreate);
$this->precission = $precission;
$this->scale = $scale;
$this->nullable = $nullable;
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Integer.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Integer.php
index 47b69334ce68e..cf0bfab837cf0 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Integer.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Integer.php
@@ -45,14 +45,15 @@ class Integer extends Column implements
private $identity;
/**
- * @param string $name
- * @param string $type
- * @param Table $table
- * @param int $padding
- * @param bool $nullable
- * @param bool $unsigned
- * @param bool $identity
+ * @param string $name
+ * @param string $type
+ * @param Table $table
+ * @param int $padding
+ * @param bool $nullable
+ * @param bool $unsigned
+ * @param bool $identity
* @param float|int $default
+ * @param string|null $onCreate
*/
public function __construct(
string $name,
@@ -62,9 +63,10 @@ public function __construct(
bool $nullable = true,
bool $unsigned = false,
bool $identity = false,
- int $default = null
+ int $default = null,
+ string $onCreate = null
) {
- parent::__construct($name, $type, $table);
+ parent::__construct($name, $type, $table, $onCreate);
$this->nullable = $nullable;
$this->default = $default;
$this->unsigned = $unsigned;
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Text.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Text.php
index 0b4fc487908d5..44bfd953220c1 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Text.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Text.php
@@ -25,16 +25,18 @@ class Text extends Column implements
/**
* @param string $name
* @param string $type
- * @param Table $table
- * @param bool $nullable
+ * @param Table $table
+ * @param bool $nullable
+ * @param string|null $onCreate
*/
public function __construct(
string $name,
string $type,
Table $table,
- bool $nullable = true
+ bool $nullable = true,
+ string $onCreate = null
) {
- parent::__construct($name, $type, $table);
+ parent::__construct($name, $type, $table, $onCreate);
$this->nullable = $nullable;
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Timestamp.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Timestamp.php
index e7e6e544b838d..5758c7b5e735a 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Timestamp.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Timestamp.php
@@ -29,20 +29,22 @@ class Timestamp extends Column implements
private $onUpdate;
/**
- * @param string $name
- * @param string $type
- * @param Table $table
- * @param $default
+ * @param string $name
+ * @param string $type
+ * @param Table $table
+ * @param string $default
* @param string|null $onUpdate
+ * @param string|null $onCreate
*/
public function __construct(
string $name,
string $type,
Table $table,
string $default,
- string $onUpdate = null
+ string $onUpdate = null,
+ string $onCreate = null
) {
- parent::__construct($name, $type, $table);
+ parent::__construct($name, $type, $table, $onCreate);
$this->default = $default;
$this->onUpdate = $onUpdate;
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Varchar.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Varchar.php
index 4f25546d2edae..74cb6162d2cfc 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Varchar.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Columns/Varchar.php
@@ -35,12 +35,13 @@ class Varchar extends Column implements
private $length;
/**
- * @param string $name
- * @param string $type
- * @param Table $table
- * @param bool $nullable
- * @param int $length
- * @param string $default
+ * @param string $name
+ * @param string $type
+ * @param Table $table
+ * @param int $length
+ * @param bool $nullable
+ * @param string $default
+ * @param string|null $onCreate
*/
public function __construct(
string $name,
@@ -48,9 +49,10 @@ public function __construct(
Table $table,
int $length,
bool $nullable = true,
- string $default = null
+ string $default = null,
+ string $onCreate = null
) {
- parent::__construct($name, $type, $table);
+ parent::__construct($name, $type, $table, $onCreate);
$this->nullable = $nullable;
$this->default = $default;
$this->length = $length;
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/OperationInterface.php b/setup/src/Magento/Setup/Model/Declaration/Schema/OperationInterface.php
index 0071e600a8261..a49fc00dae149 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/OperationInterface.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/OperationInterface.php
@@ -6,6 +6,8 @@
namespace Magento\Setup\Model\Declaration\Schema;
+use Magento\Setup\Model\Declaration\Schema\Db\Statement;
+
/**
* With help of this interface you can go through all element types
* and apply difference, that is persisted in ChangeRegistry
@@ -25,7 +27,7 @@ public function getOperationName();
* Apply change of any type
*
* @param ElementHistory $elementHistory
- * @return void
+ * @return Statement
*/
public function doOperation(ElementHistory $elementHistory);
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/AddColumn.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/AddColumn.php
new file mode 100644
index 0000000000000..3db1889d657b0
--- /dev/null
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/AddColumn.php
@@ -0,0 +1,117 @@
+definitionAggregator = $definitionAggregator;
+ $this->dbSchemaWriter = $dbSchemaWriter;
+ $this->resourceConnection = $resourceConnection;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function getOperationName()
+ {
+ return self::OPERATION_NAME;
+ }
+
+ /**
+ * Setup triggers if column have onCreate syntax
+ *
+ * @param Statement $statement
+ * @param Column $column
+ * @return Statement
+ */
+ private function setupTriggersIfExists(Statement $statement, Column $column)
+ {
+ if (preg_match('/migrateDataFrom\(([^\)]+)\)/', $column->getOnCreate(), $matches)) {
+ $callback = function() use ($column, $matches) {
+ $adapter = $this->resourceConnection->getConnection(
+ $column->getTable()->getResource()
+ );
+ $adapter->update(
+ $column->getTable()->getName(),
+ [
+ $column->getName() => new Expression($matches[1])
+ ]
+ );
+ };
+
+ $statement->addTrigger($callback);
+ }
+
+ return $statement;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function doOperation(ElementHistory $elementHistory)
+ {
+ /**
+ * @var Column $element
+ */
+ $element = $elementHistory->getNew();
+ $definition = $this->definitionAggregator->toDefinition($element);
+
+ $statement = $this->dbSchemaWriter->addElement(
+ $element->getName(),
+ $element->getTable()->getResource(),
+ $element->getTable()->getName(),
+ $definition,
+ $element->getElementType()
+ );
+ $statement = $this->setupTriggersIfExists($statement, $element);
+ return $statement;
+ }
+}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/AddElement.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/AddComplexElement.php
similarity index 85%
rename from setup/src/Magento/Setup/Model/Declaration/Schema/Operations/AddElement.php
rename to setup/src/Magento/Setup/Model/Declaration/Schema/Operations/AddComplexElement.php
index 5f0d89fe3c35e..f7cc88fecdf33 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/AddElement.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/AddComplexElement.php
@@ -15,13 +15,15 @@
/**
* Add element to table
+ * Under complex element means element that has different dependencies, like foreign key has dependencies
+ * to another table
*/
-class AddElement implements OperationInterface
+class AddComplexElement implements OperationInterface
{
/**
* Operation name
*/
- const OPERATION_NAME = 'add_element';
+ const OPERATION_NAME = 'add_complex_element';
/**
* @var DefinitionAggregator
@@ -64,12 +66,13 @@ public function doOperation(ElementHistory $elementHistory)
$element = $elementHistory->getNew();
$definition = $this->definitionAggregator->toDefinition($element);
- $this->dbSchemaWriter->addElement(
+ $statement = $this->dbSchemaWriter->addElement(
$element->getName(),
$element->getTable()->getResource(),
$element->getTable()->getName(),
$definition,
$element->getElementType()
);
+ return $statement;
}
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/CreateTable.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/CreateTable.php
index 0eba7fa9649d4..02fedff3bb0e3 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/CreateTable.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/CreateTable.php
@@ -80,6 +80,6 @@ public function doOperation(ElementHistory $elementHistory)
}
}
- $this->dbSchemaWriter->createTable($table->getName(), $table->getResource(), $definition);
+ return $this->dbSchemaWriter->createTable($table->getName(), $table->getResource(), $definition);
}
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/DropElement.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/DropElement.php
index f0ee8589df066..0d6d55a198634 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/DropElement.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/DropElement.php
@@ -64,7 +64,7 @@ public function doOperation(ElementHistory $elementHistory)
*/
$element = $elementHistory->getNew();
- $this->dbSchemaWriter->dropElement(
+ return $this->dbSchemaWriter->dropElement(
$element->getTable()->getResource(),
$element->getName(),
$element->getTable()->getName(),
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/DropTable.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/DropTable.php
index 569af9a6e95af..b1579dbdf1290 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/DropTable.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/DropTable.php
@@ -61,6 +61,6 @@ public function doOperation(ElementHistory $tableHistory)
* @var Table $table
*/
$table = $tableHistory->getOld();
- $this->dbSchemaWriter->dropTable($table->getName(), $table->getResource());
+ return $this->dbSchemaWriter->dropTable($table->getName(), $table->getResource());
}
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/ModifyElement.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/ModifyElement.php
index 30065ff2cf8c4..016173edcd792 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/ModifyElement.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/ModifyElement.php
@@ -6,13 +6,11 @@
namespace Magento\Setup\Model\Declaration\Schema\Operations;
-use Magento\Setup\Model\Declaration\Schema\Db\AdapterMediator;
use Magento\Setup\Model\Declaration\Schema\Db\DbSchemaWriterInterface;
use Magento\Setup\Model\Declaration\Schema\Db\DefinitionAggregator;
+use Magento\Setup\Model\Declaration\Schema\Db\Statement;
use Magento\Setup\Model\Declaration\Schema\Dto\Column;
use Magento\Setup\Model\Declaration\Schema\Dto\Constraint;
-use Magento\Setup\Model\Declaration\Schema\Dto\Constraints\Internal;
-use Magento\Setup\Model\Declaration\Schema\Dto\Constraints\Reference;
use Magento\Setup\Model\Declaration\Schema\Dto\Index;
use Magento\Setup\Model\Declaration\Schema\ElementHistory;
use Magento\Setup\Model\Declaration\Schema\OperationInterface;
@@ -38,7 +36,7 @@ class ModifyElement implements OperationInterface
private $dbSchemaWriter;
/**
- * @var AddElement
+ * @var AddComplexElement
*/
private $addElement;
@@ -50,13 +48,13 @@ class ModifyElement implements OperationInterface
/**
* @param DefinitionAggregator $definitionAggregator
* @param DbSchemaWriterInterface $dbSchemaWriter
- * @param AddElement $addElement
+ * @param AddComplexElement $addElement
* @param DropElement $dropElement
*/
public function __construct(
DefinitionAggregator $definitionAggregator,
DbSchemaWriterInterface $dbSchemaWriter,
- AddElement $addElement,
+ AddComplexElement $addElement,
DropElement $dropElement
) {
$this->definitionAggregator = $definitionAggregator;
@@ -73,33 +71,17 @@ public function getOperationName()
return self::OPERATION_NAME;
}
- /**
- * Modify constraint (PRIMARY, UNIQUE, FOREIGN keys) definition for existing table
- *
- * @param Constraint $constraint
- */
- private function modifyConstraint(Constraint $constraint)
- {
- $this->dbSchemaWriter->modifyConstraint(
- $constraint->getTable()->getResource(),
- $constraint->getName(),
- $constraint->getTable()->getName(),
- $constraint->getType(),
- $this->definitionAggregator->toDefinition($constraint)
- );
- }
-
-
/**
* Modify column definition for existing table
*
* @param Column $column
+ * @return Statement
*/
private function modifyColumn(Column $column)
{
$definition = $this->definitionAggregator->toDefinition($column);
- $this->dbSchemaWriter->modifyColumn(
+ return $this->dbSchemaWriter->modifyColumn(
$column->getTable()->getResource(),
$column->getTable()->getName(),
$definition
@@ -116,13 +98,12 @@ public function doOperation(ElementHistory $elementHistory)
{
$element = $elementHistory->getNew();
- if ($element instanceof Internal) {
- $this->modifyConstraint($element);
- } else if ($element instanceof Index || $element instanceof Reference) {
- $this->dropElement->doOperation($elementHistory);
- $this->addElement->doOperation($elementHistory);
- } else if ($element instanceof Column) {
- $this->modifyColumn($element);
+ if ($element instanceof Constraint || $element instanceof Index) {
+ $statement = $this->dropElement->doOperation($elementHistory);
+ return $statement->merge($this->addElement->doOperation($elementHistory));
+ } else {
+ /** @var Column $element */
+ return $this->modifyColumn($element);
}
}
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/ReCreateTable.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/ReCreateTable.php
index e136c76df70cf..992894baf9d30 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/ReCreateTable.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Operations/ReCreateTable.php
@@ -52,7 +52,7 @@ public function getOperationName()
*/
public function doOperation(ElementHistory $elementHistory)
{
- $this->dropTable->doOperation($elementHistory);
- $this->createTable->doOperation($elementHistory);
+ $statement = $this->dropTable->doOperation($elementHistory);
+ return $statement->merge($this->createTable->doOperation($elementHistory));
}
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/OperationsExecutor.php b/setup/src/Magento/Setup/Model/Declaration/Schema/OperationsExecutor.php
index 7c9581ff5ed04..e027cf5ad2ff8 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/OperationsExecutor.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/OperationsExecutor.php
@@ -7,6 +7,9 @@
namespace Magento\Setup\Model\Declaration\Schema;
use Magento\Framework\App\ResourceConnection;
+use Magento\Setup\Model\Declaration\Schema\Db\DbSchemaWriterInterface;
+use Magento\Setup\Model\Declaration\Schema\Db\Statement;
+use Magento\Setup\Model\Declaration\Schema\Db\StatementFactory;
use Magento\Setup\Model\Declaration\Schema\Diff\DiffInterface;
/**
@@ -31,18 +34,34 @@ class OperationsExecutor
private $resourceConnection;
/**
- * @param array $operations
- * @param Sharding $sharding
+ * @var StatementFactory
+ */
+ private $statementFactory;
+
+ /**
+ * @var DbSchemaWriterInterface
+ */
+ private $dbSchemaWriter;
+
+ /**
+ * @param array $operations
+ * @param Sharding $sharding
* @param ResourceConnection $resourceConnection
+ * @param StatementFactory $statementFactory
+ * @param DbSchemaWriterInterface $dbSchemaWriter
*/
public function __construct(
array $operations,
Sharding $sharding,
- ResourceConnection $resourceConnection
+ ResourceConnection $resourceConnection,
+ StatementFactory $statementFactory,
+ DbSchemaWriterInterface $dbSchemaWriter
) {
$this->operations = $operations;
$this->sharding = $sharding;
$this->resourceConnection = $resourceConnection;
+ $this->statementFactory = $statementFactory;
+ $this->dbSchemaWriter = $dbSchemaWriter;
}
/**
@@ -84,12 +103,31 @@ private function endSetupForAllConnections()
public function execute(DiffInterface $diff)
{
$this->startSetupForAllConnections();
+ $tableHistories = $diff->getAll();
- foreach ($this->operations as $operation) {
- $histories = $diff->get($operation->getOperationName());
+ foreach ($tableHistories as $tableName => $tableHistory) {
+ /** @var Statement[] $statements */
+ $statements = [];
- foreach ($histories as $history) {
- $operation->doOperation($history);
+ foreach ($this->operations as $operation) {
+ if (isset($tableHistory[$operation->getOperationName()])) {
+ /** @var ElementHistory $elementHistory */
+ foreach ($tableHistory[$operation->getOperationName()] as $elementHistory) {
+ $newStatement = $operation->doOperation($elementHistory);
+ /** @var Statement $oldStatement */
+ $oldStatement = end($statements);
+
+ if ($oldStatement && $oldStatement->canDoMerge($newStatement)) {
+ $oldStatement->merge($newStatement);
+ } else {
+ $statements[] = $newStatement;
+ }
+ }
+ }
+ }
+ //As some statements can`t be merged with each other, we can describe them only with array
+ foreach ($statements as $statement) {
+ $this->dbSchemaWriter->compile($statement);
}
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/column.xsd b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/column.xsd
index 90710ebbe92e2..c2bcdc213b6cb 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/column.xsd
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/types/column.xsd
@@ -11,5 +11,12 @@
+
+
+
+ Example migrateDataFrom(field) or migrateDataFrom(field * 2)
+
+
+
From 34d85dc072d367d00454008060a84977d6ef4ba0 Mon Sep 17 00:00:00 2001
From: Dan Mooney
Date: Fri, 5 Jan 2018 13:12:37 -0600
Subject: [PATCH 263/904] MAGETWO-86141: Disable/Enable TinyMCE Not Working
Move toolbar enabling/disabling into respective adapters. TinyMCE4 functionality needs to be implemented.
---
.../Tinymce3/view/base/web/tinymce3Adapter.js | 26 +++++++-
.../view/base/web/js/form/element/wysiwyg.js | 32 ++++++----
.../wysiwyg/tiny_mce/tinymce4Adapter.js | 59 +++++++++++++------
3 files changed, 85 insertions(+), 32 deletions(-)
diff --git a/app/code/Magento/Tinymce3/view/base/web/tinymce3Adapter.js b/app/code/Magento/Tinymce3/view/base/web/tinymce3Adapter.js
index 08bbb95888d8d..b5c74af6c3dd3 100644
--- a/app/code/Magento/Tinymce3/view/base/web/tinymce3Adapter.js
+++ b/app/code/Magento/Tinymce3/view/base/web/tinymce3Adapter.js
@@ -244,6 +244,13 @@ define([
return tinyMCE3.get(id);
},
+ /**
+ * @return {String}
+ */
+ getId: function () {
+ return this.id || (this.activeEditor() ? this.activeEditor().id : null) || tinyMceEditors.values()[0].id;
+ },
+
/**
* @return {Object}
*/
@@ -261,6 +268,16 @@ define([
this.activeEditor().execCommand('mceInsertContent', typeof ui !== 'undefined' ? ui : false, content);
},
+ /**
+ * Set the status of the toolbar to disabled or enabled (true for enabled, false for disabled)
+ * @param {Boolean} enabled
+ */
+ setToolbarStatus: function (enabled) {
+ _.each(this.activeEditor().controlManager.controls, function (property, index, controls) {
+ controls[property.id].setDisabled(!enabled);
+ });
+ },
+
/**
* Set caret location in WYSIWYG editor.
*
@@ -558,7 +575,14 @@ define([
content = editor.getContent();
content = this.decodeContent(content);
- jQuery('#' + this.id).val(content).trigger('change');
+ this.getTextArea().val(content).trigger('change');
+ },
+
+ /**
+ * @return {Object} jQuery textarea element
+ */
+ getTextArea: function () {
+ return jQuery('#' + this.id);
},
/**
diff --git a/app/code/Magento/Ui/view/base/web/js/form/element/wysiwyg.js b/app/code/Magento/Ui/view/base/web/js/form/element/wysiwyg.js
index 9e9427f5ce72c..107761e714ce5 100644
--- a/app/code/Magento/Ui/view/base/web/js/form/element/wysiwyg.js
+++ b/app/code/Magento/Ui/view/base/web/js/form/element/wysiwyg.js
@@ -7,12 +7,13 @@
* @api
*/
define([
+ 'wysiwygAdapter',
'Magento_Ui/js/lib/view/utils/async',
'underscore',
'ko',
'./abstract',
- 'Magento_Variable/variables'
-], function ($, _, ko, Abstract) {
+ 'Magento_Variable/variables',
+], function (wysiwyg, $, _, ko, Abstract) {
'use strict';
return Abstract.extend({
@@ -88,21 +89,26 @@ define([
/**
* Set disabled property to wysiwyg component
*
- * @param {Boolean} status
+ * @param {Boolean} disabled
*/
- setDisabled: function (status) {
- this.$wysiwygEditorButton.attr('disabled', status);
+ setDisabled: function (disabled) {
+ if (this.$wysiwygEditorButton) {
+ this.$wysiwygEditorButton.attr('disabled', disabled);
+ }
/* eslint-disable no-undef */
- if (wysiwygAdapter) {
- _.each(wysiwygAdapter.activeEditor().controlManager.controls, function (property, index, controls) {
- controls[property.id].setDisabled(status);
- });
-
- wysiwygAdapter.activeEditor().getBody().setAttribute('contenteditable', !status);
+ if (typeof wysiwyg !== 'undefined') {
+ if (disabled) {
+ wysiwyg.setToolbarStatus(false);
+ wysiwyg.getPluginButtons().attr('disabled', 'disabled');
+ wysiwyg.getTextArea().attr('disabled', 'disabled');
+ } else {
+ wysiwyg.setToolbarStatus(true);
+ wysiwyg.getPluginButtons().removeAttr('disabled');
+ wysiwyg.getTextArea().removeAttr('disabled');
+ }
}
-
/* eslint-enable no-undef*/
}
});
-});
+});
\ No newline at end of file
diff --git a/lib/web/mage/adminhtml/wysiwyg/tiny_mce/tinymce4Adapter.js b/lib/web/mage/adminhtml/wysiwyg/tiny_mce/tinymce4Adapter.js
index 2ea9d434dc179..c2a3032049bdb 100644
--- a/lib/web/mage/adminhtml/wysiwyg/tiny_mce/tinymce4Adapter.js
+++ b/lib/web/mage/adminhtml/wysiwyg/tiny_mce/tinymce4Adapter.js
@@ -67,14 +67,14 @@ define([
* Setup TinyMCE4 editor
*/
setup: function (mode) {
- var settings;
+ var settings,
+ self = this;
this.turnOff();
if (typeof mode === 'undefined') {
mode = this.mode;
}
- var self = this;
if (this.config.plugins) {
this.config.plugins.forEach(function (plugin) {
@@ -92,16 +92,17 @@ define([
pluginConstructor.adapter = self;
});
}
-
});
-
}
if (jQuery.isReady) {
tinyMCE4.dom.Event.domLoaded = true;
}
-settings = this.getSettings();
- settings.mode = mode; tinyMCE4.init(settings);this.getPluginButtons().hide();
+
+ settings = this.getSettings();
+ settings.mode = mode;
+ tinyMCE4.init(settings);
+ this.getPluginButtons().hide();
},
/**
@@ -126,6 +127,14 @@ settings = this.getSettings();
this.config.tinymce4.toolbar = toolbar.join(' ');
},
+ /**
+ * Set the status of the toolbar to disabled or enabled (true for enabled, false for disabled)
+ * @param {Boolean} enabled
+ */
+ setToolbarStatus: function (enabled) {
+ // TODO
+ },
+
/**
* @return {Object}
*/
@@ -133,7 +142,7 @@ settings = this.getSettings();
var settings;
settings = {
- selector: 'textarea#' + this.id,
+ selector: 'textarea#' + this.getId(),
theme: 'modern',
'entity_encoding': 'raw',
'convert_urls': false,
@@ -240,6 +249,13 @@ settings = this.getSettings();
return tinyMCE4.get(id);
},
+ /**
+ * @return {String}
+ */
+ getId: function () {
+ return this.id || (this.activeEditor() ? this.activeEditor().id : null) || tinyMceEditors.values()[0].id;
+ },
+
/**
* @return {Object}
*/
@@ -275,7 +291,7 @@ settings = this.getSettings();
storeId = this.config['store_id'] !== null ? this.config['store_id'] : 0,
frameDialog = jQuery('div.mce-container[role="dialog"]'),
wUrl = this.config['files_browser_window_url'] +
- 'target_element_id/' + this.id + '/' +
+ 'target_element_id/' + this.getId() + '/' +
'store/' + storeId + '/';
this.mediaBrowserOpener = o.win;
@@ -327,14 +343,14 @@ settings = this.getSettings();
* @return {jQuery|*|HTMLElement}
*/
getToggleButton: function () {
- return $('toggle' + this.id);
+ return $('toggle' + this.getId());
},
/**
* Get plugins button.
*/
getPluginButtons: function () {
- return jQuery('#buttons' + this.id + ' > button.plugin');
+ return jQuery('#buttons' + this.getId() + ' > button.plugin');
},
/**
@@ -348,7 +364,7 @@ settings = this.getSettings();
this.getPluginButtons().hide();
- tinyMCE4.execCommand('mceAddControl', false, this.id);
+ tinyMCE4.execCommand('mceAddControl', false, this.getId());
return this;
},
@@ -370,7 +386,7 @@ settings = this.getSettings();
this.getPluginButtons().show();
- tinyMCE4.execCommand('mceRemoveEditor', false, this.id);
+ tinyMCE4.execCommand('mceRemoveEditor', false, this.getId());
return this;
},
@@ -381,14 +397,14 @@ settings = this.getSettings();
closePopups: function () {
// close all popups to avoid problems with updating parent content area
varienGlobalEvents.fireEvent('wysiwygClosePopups');
- this.closeEditorPopup('browser_window' + this.id);
+ this.closeEditorPopup('browser_window' + this.getId());
},
/**
* @return {Boolean}
*/
toggle: function () {
- if (!tinyMCE4.get(this.id)) {
+ if (!tinyMCE4.get(this.getId())) {
this.turnOn();
return true;
@@ -402,8 +418,8 @@ settings = this.getSettings();
* On form validation.
*/
onFormValidation: function () {
- if (tinyMCE4.get(this.id)) {
- $(this.id).value = tinyMCE4.get(this.id).getContent();
+ if (tinyMCE4.get(this.getId())) {
+ $(this.getId()).value = tinyMCE4.get(this.getId()).getContent();
}
},
@@ -481,7 +497,7 @@ settings = this.getSettings();
* Update text area.
*/
updateTextArea: function () {
- var editor = tinyMCE4.get(this.id),
+ var editor = tinyMCE4.get(this.getId()),
content;
if (!editor) {
@@ -494,7 +510,14 @@ settings = this.getSettings();
content = editor.getContent();
content = this.decodeContent(content);
- jQuery('#' + this.id).val(content).trigger('change');
+ this.getTextArea().val(content).trigger('change');
+ },
+
+ /**
+ * @return {Object} jQuery textarea element
+ */
+ getTextArea: function () {
+ return jQuery('#' + this.getId());
},
/**
From a7742e7a1a047644f7aa645b1b97122d5e40e286 Mon Sep 17 00:00:00 2001
From: Dan Mooney
Date: Fri, 5 Jan 2018 14:58:02 -0600
Subject: [PATCH 264/904] MAGETWO-86141: Disable/Enable TinyMCE Not Working
Implement TinyMCE4 functionality
---
lib/web/mage/adminhtml/wysiwyg/tiny_mce/tinymce4Adapter.js | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/lib/web/mage/adminhtml/wysiwyg/tiny_mce/tinymce4Adapter.js b/lib/web/mage/adminhtml/wysiwyg/tiny_mce/tinymce4Adapter.js
index c2a3032049bdb..164fc11cf4f1e 100644
--- a/lib/web/mage/adminhtml/wysiwyg/tiny_mce/tinymce4Adapter.js
+++ b/lib/web/mage/adminhtml/wysiwyg/tiny_mce/tinymce4Adapter.js
@@ -132,7 +132,10 @@ define([
* @param {Boolean} enabled
*/
setToolbarStatus: function (enabled) {
- // TODO
+ var controlIds = this.get(this.getId()).theme.panel.rootControl.controlIdLookup;
+ _.each(controlIds, function (controlId) {
+ controlId.disabled(!enabled);
+ });
},
/**
From a8bcf6817024b0d3bd5891a385e2967ff124469d Mon Sep 17 00:00:00 2001
From: Kieu Phan
Date: Sat, 6 Jan 2018 17:07:01 -0600
Subject: [PATCH 265/904] MAGETWO-85452: QA Activities
- Clean up created data tests, added actions support firefox browser
---
.../acceptance/tests/_suite/sampleSuite.xml | 1 +
.../AdminAddImageToWYSIWYGCatalogCest.xml | 2 +-
.../AdminAddImageToWYSIWYGProductCest.xml | 2 +-
.../Catalog/Cest/AdminCreateCategoryCest.xml | 2 +-
.../Cest/AdminCreateSimpleProductCest.xml | 2 +-
...dminEditTextEditorProductAttributeCest.xml | 2 +-
...erifyDefaultWYSIWYGToolbarOnProducCest.xml | 2 +-
...yTinyMCEv4IsNativeWYSIWYGOnCatalogCest.xml | 2 +-
...yTinyMCEv4IsNativeWYSIWYGOnProductCest.xml | 2 +-
.../Cest/AdminAddImageToWYSIWYGBlockCest.xml | 16 +++++----
.../Cest/AdminAddImageToWYSIWYGCMSCest.xml | 5 ++-
.../AdminAddVariableToWYSIWYGBlockCest.xml | 35 ++++++++++---------
.../Cest/AdminAddVariableToWYSIWYGCMSCest.xml | 6 ++--
.../Cest/AdminAddWidgetToWYSIWYGBlockCest.xml | 24 +++++++------
...WidgetToWYSIWYGWithCMSPageLinkTypeCest.xml | 14 ++++----
...getToWYSIWYGWithCMSStaticBlockTypeCest.xml | 10 +++---
...WYSIWYGWithCatalogCategoryLinkTypeCest.xml | 12 +++----
...oWYSIWYGWithCatalogProductLinkTypeCest.xml | 20 +++++------
...oWYSIWYGWithCatalogProductListTypeCest.xml | 16 ++++-----
...YGWithRecentlyComparedProductsTypeCest.xml | 24 ++++++-------
...IWYGWithRecentlyViewedProductsTypeCest.xml | 16 ++++-----
.../Cest/AdminSwitchWYSIWYGOptionsCest.xml | 10 +++---
...ifyTinyMCEv4IsNativeWYSIWYGOnBlockCest.xml | 24 ++++++++-----
...yTinyMCEv4IsNativeWYSIWYGOnCMSPageCest.xml | 3 +-
.../Section/CmsPagesPageActionsSection.xml | 5 +++
...dminAddVariableToWYSIWYGNewsletterCest.xml | 22 ++++++------
.../AdminAddWidgetToWYSIWYGNewsletterCest.xml | 10 +++---
27 files changed, 155 insertions(+), 134 deletions(-)
diff --git a/dev/tests/acceptance/tests/_suite/sampleSuite.xml b/dev/tests/acceptance/tests/_suite/sampleSuite.xml
index d42f6d00132b9..b122c7002f92f 100644
--- a/dev/tests/acceptance/tests/_suite/sampleSuite.xml
+++ b/dev/tests/acceptance/tests/_suite/sampleSuite.xml
@@ -35,6 +35,7 @@
+
diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Cest/AdminAddImageToWYSIWYGCatalogCest.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Cest/AdminAddImageToWYSIWYGCatalogCest.xml
index 7f719f1fd021e..a217085ed227a 100644
--- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Cest/AdminAddImageToWYSIWYGCatalogCest.xml
+++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Cest/AdminAddImageToWYSIWYGCatalogCest.xml
@@ -11,7 +11,7 @@
-
+
diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Cest/AdminAddImageToWYSIWYGProductCest.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Cest/AdminAddImageToWYSIWYGProductCest.xml
index 85b8f2a70e8fe..6781c91ffe734 100644
--- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Cest/AdminAddImageToWYSIWYGProductCest.xml
+++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Cest/AdminAddImageToWYSIWYGProductCest.xml
@@ -11,7 +11,7 @@
-
+
diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Cest/AdminCreateCategoryCest.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Cest/AdminCreateCategoryCest.xml
index 1d12792785104..114cd0478cebe 100644
--- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Cest/AdminCreateCategoryCest.xml
+++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Cest/AdminCreateCategoryCest.xml
@@ -22,7 +22,7 @@
-
+
diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Cest/AdminCreateSimpleProductCest.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Cest/AdminCreateSimpleProductCest.xml
index 0c6238f07a59b..0cb5fb05ca8b7 100644
--- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Cest/AdminCreateSimpleProductCest.xml
+++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Cest/AdminCreateSimpleProductCest.xml
@@ -22,7 +22,7 @@
-
+
diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Cest/AdminEditTextEditorProductAttributeCest.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Cest/AdminEditTextEditorProductAttributeCest.xml
index 2b8ef929051f8..7d8fd32a6455b 100644
--- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Cest/AdminEditTextEditorProductAttributeCest.xml
+++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Cest/AdminEditTextEditorProductAttributeCest.xml
@@ -11,7 +11,7 @@
-
+
diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Cest/VerifyDefaultWYSIWYGToolbarOnProducCest.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Cest/VerifyDefaultWYSIWYGToolbarOnProducCest.xml
index e2c402422c22b..aa2354a06b9a7 100644
--- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Cest/VerifyDefaultWYSIWYGToolbarOnProducCest.xml
+++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Cest/VerifyDefaultWYSIWYGToolbarOnProducCest.xml
@@ -12,7 +12,7 @@
-
+
diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Cest/VerifyTinyMCEv4IsNativeWYSIWYGOnCatalogCest.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Cest/VerifyTinyMCEv4IsNativeWYSIWYGOnCatalogCest.xml
index 90f517521f210..e21b0f47f5d2c 100644
--- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Cest/VerifyTinyMCEv4IsNativeWYSIWYGOnCatalogCest.xml
+++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Cest/VerifyTinyMCEv4IsNativeWYSIWYGOnCatalogCest.xml
@@ -12,7 +12,7 @@
-
+
diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Cest/VerifyTinyMCEv4IsNativeWYSIWYGOnProductCest.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Cest/VerifyTinyMCEv4IsNativeWYSIWYGOnProductCest.xml
index 478110dd9a12a..4d453f42f7a59 100644
--- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Cest/VerifyTinyMCEv4IsNativeWYSIWYGOnProductCest.xml
+++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Cest/VerifyTinyMCEv4IsNativeWYSIWYGOnProductCest.xml
@@ -11,7 +11,7 @@
-
+
diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddImageToWYSIWYGBlockCest.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddImageToWYSIWYGBlockCest.xml
index 699c2e23989b2..5e603a761ca7b 100644
--- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddImageToWYSIWYGBlockCest.xml
+++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddImageToWYSIWYGBlockCest.xml
@@ -11,7 +11,7 @@
-
+
@@ -78,11 +78,13 @@
-
-
-
-
-
+
+
+
+
+
+
+
@@ -102,7 +104,7 @@
-
+
diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddImageToWYSIWYGCMSCest.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddImageToWYSIWYGCMSCest.xml
index dfa358c5caf40..f3065163d778e 100644
--- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddImageToWYSIWYGCMSCest.xml
+++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddImageToWYSIWYGCMSCest.xml
@@ -11,7 +11,7 @@
-
+
@@ -73,8 +73,7 @@
-
-
+
diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddVariableToWYSIWYGBlockCest.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddVariableToWYSIWYGBlockCest.xml
index 05b8f2e027c6a..8ebfae731d64c 100644
--- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddVariableToWYSIWYGBlockCest.xml
+++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddVariableToWYSIWYGBlockCest.xml
@@ -11,7 +11,7 @@
-
+
@@ -30,15 +30,15 @@
-
-
+
+
-
+
@@ -46,7 +46,7 @@
-
+
@@ -60,14 +60,15 @@
-
+
+
-
+
@@ -82,11 +83,13 @@
-
-
-
-
-
+
+
+
+
+
+
+
@@ -94,18 +97,18 @@
-
+
-
+
-
+
@@ -115,7 +118,7 @@
-
+
diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddVariableToWYSIWYGCMSCest.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddVariableToWYSIWYGCMSCest.xml
index 4c35cd634cc00..f933a58d00123 100644
--- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddVariableToWYSIWYGCMSCest.xml
+++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddVariableToWYSIWYGCMSCest.xml
@@ -11,7 +11,7 @@
-
+
@@ -84,7 +84,7 @@
-
+
@@ -92,7 +92,7 @@
-
+
diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGBlockCest.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGBlockCest.xml
index 83d0eaf2c44c9..07240974758a3 100644
--- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGBlockCest.xml
+++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGBlockCest.xml
@@ -11,7 +11,7 @@
-
+
@@ -38,7 +38,7 @@
-
+
@@ -46,16 +46,18 @@
-
+
-
-
-
-
-
+
+
+
+
+
+
+
@@ -63,18 +65,18 @@
-
+
-
+
-
+
diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGWithCMSPageLinkTypeCest.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGWithCMSPageLinkTypeCest.xml
index 50ca32ce4050d..1814c3f038794 100644
--- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGWithCMSPageLinkTypeCest.xml
+++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGWithCMSPageLinkTypeCest.xml
@@ -12,7 +12,7 @@
-
+
@@ -30,14 +30,14 @@
-
+
-
+
@@ -45,23 +45,23 @@
-
+
-
+
-
+
-
+
diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGWithCMSStaticBlockTypeCest.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGWithCMSStaticBlockTypeCest.xml
index 29b96d3aff72a..f14330ce207e8 100644
--- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGWithCMSStaticBlockTypeCest.xml
+++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGWithCMSStaticBlockTypeCest.xml
@@ -12,7 +12,7 @@
-
+
@@ -51,9 +51,9 @@
-
-
-
+
+
+
@@ -66,7 +66,7 @@
-
+
diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGWithCatalogCategoryLinkTypeCest.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGWithCatalogCategoryLinkTypeCest.xml
index 8fcf656cd1cc7..04b0b968cfc03 100644
--- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGWithCatalogCategoryLinkTypeCest.xml
+++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGWithCatalogCategoryLinkTypeCest.xml
@@ -11,7 +11,7 @@
-
+
@@ -30,14 +30,14 @@
-
+
-
+
@@ -45,11 +45,11 @@
-
+
-
+
@@ -60,7 +60,7 @@
-
+
diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGWithCatalogProductLinkTypeCest.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGWithCatalogProductLinkTypeCest.xml
index 0fbc7c2d0b869..5fa3c07e53e3e 100644
--- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGWithCatalogProductLinkTypeCest.xml
+++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGWithCatalogProductLinkTypeCest.xml
@@ -12,7 +12,7 @@
-
+
@@ -34,41 +34,41 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGWithCatalogProductListTypeCest.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGWithCatalogProductListTypeCest.xml
index 25769100f2707..108ee114a7ec4 100644
--- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGWithCatalogProductListTypeCest.xml
+++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGWithCatalogProductListTypeCest.xml
@@ -11,7 +11,7 @@
-
+
@@ -36,14 +36,14 @@
-
+
-
+
@@ -51,28 +51,28 @@
-
+
-
+
-
+
-
+
-
+
diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGWithRecentlyComparedProductsTypeCest.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGWithRecentlyComparedProductsTypeCest.xml
index c3a91eadd4bd5..0b139b1501713 100644
--- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGWithRecentlyComparedProductsTypeCest.xml
+++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGWithRecentlyComparedProductsTypeCest.xml
@@ -12,7 +12,7 @@
-
+
@@ -34,23 +34,23 @@
-
+
-
+
-
+
-
+
@@ -58,28 +58,28 @@
-
+
-
+
-
-
+
+
-
+
-
+
-
+
diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGWithRecentlyViewedProductsTypeCest.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGWithRecentlyViewedProductsTypeCest.xml
index 577f5560567a0..670a0ecc35898 100644
--- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGWithRecentlyViewedProductsTypeCest.xml
+++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGWithRecentlyViewedProductsTypeCest.xml
@@ -12,7 +12,7 @@
-
+
@@ -34,14 +34,14 @@
-
+
-
+
@@ -49,7 +49,7 @@
-
+
@@ -57,19 +57,19 @@
-
+
-
+
-
+
-
+
diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminSwitchWYSIWYGOptionsCest.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminSwitchWYSIWYGOptionsCest.xml
index a0e641bd0c1a6..ba6a1a3847379 100644
--- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminSwitchWYSIWYGOptionsCest.xml
+++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminSwitchWYSIWYGOptionsCest.xml
@@ -36,7 +36,7 @@
-
+
@@ -47,9 +47,10 @@
+
-
+
@@ -61,7 +62,7 @@
-
+
@@ -72,9 +73,10 @@
+
-
+
diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/VerifyTinyMCEv4IsNativeWYSIWYGOnBlockCest.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/VerifyTinyMCEv4IsNativeWYSIWYGOnBlockCest.xml
index 2edde1df3355b..f2381eb347164 100644
--- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/VerifyTinyMCEv4IsNativeWYSIWYGOnBlockCest.xml
+++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/VerifyTinyMCEv4IsNativeWYSIWYGOnBlockCest.xml
@@ -12,7 +12,7 @@
-
+
@@ -61,12 +61,17 @@
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
@@ -75,18 +80,19 @@
-
+
+
-
+
-
+
diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/VerifyTinyMCEv4IsNativeWYSIWYGOnCMSPageCest.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/VerifyTinyMCEv4IsNativeWYSIWYGOnCMSPageCest.xml
index 790d87bab4b12..cde0e5360e796 100644
--- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/VerifyTinyMCEv4IsNativeWYSIWYGOnCMSPageCest.xml
+++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/VerifyTinyMCEv4IsNativeWYSIWYGOnCMSPageCest.xml
@@ -12,7 +12,7 @@
-
+
@@ -61,6 +61,7 @@
+
diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Section/CmsPagesPageActionsSection.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Section/CmsPagesPageActionsSection.xml
index ad22c451fe65c..0e8ebc3fb2877 100644
--- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Section/CmsPagesPageActionsSection.xml
+++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Section/CmsPagesPageActionsSection.xml
@@ -9,6 +9,11 @@
+
+
+
+
+
diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Newsletter/Cest/AdminAddVariableToWYSIWYGNewsletterCest.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Newsletter/Cest/AdminAddVariableToWYSIWYGNewsletterCest.xml
index 8bf3b6ac035ff..8105f0c6bd18a 100644
--- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Newsletter/Cest/AdminAddVariableToWYSIWYGNewsletterCest.xml
+++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Newsletter/Cest/AdminAddVariableToWYSIWYGNewsletterCest.xml
@@ -29,15 +29,15 @@
-
-
+
+
-
+
@@ -47,7 +47,7 @@
-
+
@@ -61,31 +61,31 @@
-
+
-
+
-
+
-
+
-
+
-
+
@@ -97,7 +97,7 @@
-
+
diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Newsletter/Cest/AdminAddWidgetToWYSIWYGNewsletterCest.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Newsletter/Cest/AdminAddWidgetToWYSIWYGNewsletterCest.xml
index 48d989431504c..e45f5314088db 100644
--- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Newsletter/Cest/AdminAddWidgetToWYSIWYGNewsletterCest.xml
+++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Newsletter/Cest/AdminAddWidgetToWYSIWYGNewsletterCest.xml
@@ -35,10 +35,10 @@
-
+
-
+
@@ -46,14 +46,14 @@
-
+
-
+
-
+
From 4e8dc706401dcdbe1c7595fc7ebdd4b2c4fb7a1f Mon Sep 17 00:00:00 2001
From: Kieu Phan
Date: Sun, 7 Jan 2018 12:48:08 -0600
Subject: [PATCH 266/904] MAGETWO-85452: QA Activities
- Added conditions for Firefox browser
---
dev/tests/acceptance/tests/_suite/sampleSuite.xml | 1 -
.../Catalog/Cest/AdminAddImageToWYSIWYGProductCest.xml | 3 +--
.../Cest/VerifyTinyMCEv4IsNativeWYSIWYGOnProductCest.xml | 2 ++
.../Catalog/Section/StorefrontProductInfoMainSection.xml | 1 +
.../Cms/Cest/AdminAddVariableToWYSIWYGCMSCest.xml | 1 +
...nAddWidgetToWYSIWYGWithRecentlyComparedProductsTypeCest.xml | 2 +-
.../FunctionalTest/Cms/Cest/AdminSwitchWYSIWYGOptionsCest.xml | 2 +-
7 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/dev/tests/acceptance/tests/_suite/sampleSuite.xml b/dev/tests/acceptance/tests/_suite/sampleSuite.xml
index b122c7002f92f..d42f6d00132b9 100644
--- a/dev/tests/acceptance/tests/_suite/sampleSuite.xml
+++ b/dev/tests/acceptance/tests/_suite/sampleSuite.xml
@@ -35,7 +35,6 @@
-
diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Cest/AdminAddImageToWYSIWYGProductCest.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Cest/AdminAddImageToWYSIWYGProductCest.xml
index 6781c91ffe734..8a8c10b036819 100644
--- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Cest/AdminAddImageToWYSIWYGProductCest.xml
+++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Cest/AdminAddImageToWYSIWYGProductCest.xml
@@ -74,8 +74,7 @@
-
-
+
diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Cest/VerifyTinyMCEv4IsNativeWYSIWYGOnProductCest.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Cest/VerifyTinyMCEv4IsNativeWYSIWYGOnProductCest.xml
index 4d453f42f7a59..83d9f8dd086a7 100644
--- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Cest/VerifyTinyMCEv4IsNativeWYSIWYGOnProductCest.xml
+++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Cest/VerifyTinyMCEv4IsNativeWYSIWYGOnProductCest.xml
@@ -47,6 +47,7 @@
+
@@ -56,6 +57,7 @@
+
diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Section/StorefrontProductInfoMainSection.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Section/StorefrontProductInfoMainSection.xml
index d7382de429340..37381af2fce24 100644
--- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Section/StorefrontProductInfoMainSection.xml
+++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Section/StorefrontProductInfoMainSection.xml
@@ -8,6 +8,7 @@
+
diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddVariableToWYSIWYGCMSCest.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddVariableToWYSIWYGCMSCest.xml
index f933a58d00123..387f939441fa3 100644
--- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddVariableToWYSIWYGCMSCest.xml
+++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddVariableToWYSIWYGCMSCest.xml
@@ -92,6 +92,7 @@
+
diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGWithRecentlyComparedProductsTypeCest.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGWithRecentlyComparedProductsTypeCest.xml
index 0b139b1501713..484cc6e9b536d 100644
--- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGWithRecentlyComparedProductsTypeCest.xml
+++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGWithRecentlyComparedProductsTypeCest.xml
@@ -80,7 +80,7 @@
-
+
diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminSwitchWYSIWYGOptionsCest.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminSwitchWYSIWYGOptionsCest.xml
index ba6a1a3847379..50504c51b6d2e 100644
--- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminSwitchWYSIWYGOptionsCest.xml
+++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminSwitchWYSIWYGOptionsCest.xml
@@ -54,7 +54,7 @@
-
+
From 6c781b47a6e14aaa52fbda331deb60233c840a7f Mon Sep 17 00:00:00 2001
From: Kieu Phan
Date: Sun, 7 Jan 2018 15:22:59 -0600
Subject: [PATCH 267/904] MAGETWO-85452: QA Activities
- Added scrollTo on Storefront to recognize elements
---
.../Catalog/Cest/AdminAddImageToWYSIWYGProductCest.xml | 4 ++--
...AddWidgetToWYSIWYGWithRecentlyComparedProductsTypeCest.xml | 1 -
.../Newsletter/Cest/AdminAddWidgetToWYSIWYGNewsletterCest.xml | 1 +
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Cest/AdminAddImageToWYSIWYGProductCest.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Cest/AdminAddImageToWYSIWYGProductCest.xml
index 8a8c10b036819..26fc706daf1d2 100644
--- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Cest/AdminAddImageToWYSIWYGProductCest.xml
+++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Cest/AdminAddImageToWYSIWYGProductCest.xml
@@ -60,7 +60,7 @@
-
+
@@ -91,7 +91,7 @@
-
+
diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGWithRecentlyComparedProductsTypeCest.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGWithRecentlyComparedProductsTypeCest.xml
index 484cc6e9b536d..1e9f8f3ec128d 100644
--- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGWithRecentlyComparedProductsTypeCest.xml
+++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGWithRecentlyComparedProductsTypeCest.xml
@@ -14,7 +14,6 @@
-
diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Newsletter/Cest/AdminAddWidgetToWYSIWYGNewsletterCest.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Newsletter/Cest/AdminAddWidgetToWYSIWYGNewsletterCest.xml
index e45f5314088db..93bd61704fb40 100644
--- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Newsletter/Cest/AdminAddWidgetToWYSIWYGNewsletterCest.xml
+++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Newsletter/Cest/AdminAddWidgetToWYSIWYGNewsletterCest.xml
@@ -45,6 +45,7 @@
+
From ea2460819ff6575464b2b36afa3f3dc927b2e060 Mon Sep 17 00:00:00 2001
From: Dan Mooney
Date: Mon, 8 Jan 2018 14:57:44 -0600
Subject: [PATCH 268/904] MAGETWO-86142: Image url not encoding/decoding
correctly
Support encoding/decoding of double quote delimiters for parameters on frontend and backend.
---
.../Magento/Catalog/Model/Template/Filter.php | 2 +-
app/code/Magento/Cms/Model/Template/Filter.php | 2 +-
.../Test/Unit/Model/Template/FilterTest.php | 16 ++++++++++++++++
.../Magento/Email/Model/Template/Filter.php | 2 +-
.../Tinymce3/view/base/web/tinymce3Adapter.js | 15 +++++++++------
.../Magento/Widget/Model/Template/Filter.php | 2 +-
.../Test/Unit/Model/Template/FilterTest.php | 18 ++++++++++++++++++
.../Widget/Model/Template/FilterTest.php | 14 ++++++++++++++
.../plugins/magentowidget/editor_plugin.js | 2 +-
.../wysiwyg/tiny_mce/tinymce4Adapter.js | 13 ++++++++-----
10 files changed, 70 insertions(+), 16 deletions(-)
diff --git a/app/code/Magento/Catalog/Model/Template/Filter.php b/app/code/Magento/Catalog/Model/Template/Filter.php
index b4445510d49e2..1eb30ff95a40b 100644
--- a/app/code/Magento/Catalog/Model/Template/Filter.php
+++ b/app/code/Magento/Catalog/Model/Template/Filter.php
@@ -125,7 +125,7 @@ public function viewDirective($construction)
*/
public function mediaDirective($construction)
{
- $params = $this->getParameters($construction[2]);
+ $params = $this->getParameters(html_entity_decode($construction[2], ENT_QUOTES));
return $this->_storeManager->getStore()
->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA) . $params['url'];
}
diff --git a/app/code/Magento/Cms/Model/Template/Filter.php b/app/code/Magento/Cms/Model/Template/Filter.php
index 2dcbfbc4ab598..f93972bade2af 100644
--- a/app/code/Magento/Cms/Model/Template/Filter.php
+++ b/app/code/Magento/Cms/Model/Template/Filter.php
@@ -37,7 +37,7 @@ public function setUseSessionInUrl($flag)
*/
public function mediaDirective($construction)
{
- $params = $this->getParameters($construction[2]);
+ $params = $this->getParameters(html_entity_decode($construction[2], ENT_QUOTES));
return $this->_storeManager->getStore()->getBaseMediaDir() . '/' . $params['url'];
}
}
diff --git a/app/code/Magento/Cms/Test/Unit/Model/Template/FilterTest.php b/app/code/Magento/Cms/Test/Unit/Model/Template/FilterTest.php
index 009a740305a82..09476f291fb06 100644
--- a/app/code/Magento/Cms/Test/Unit/Model/Template/FilterTest.php
+++ b/app/code/Magento/Cms/Test/Unit/Model/Template/FilterTest.php
@@ -62,4 +62,20 @@ public function testMediaDirective()
->willReturn($baseMediaDir);
$this->assertEquals($expectedResult, $this->filter->mediaDirective($construction));
}
+
+ public function testMediaDirectiveWithEncodedQuotes()
+ {
+ $baseMediaDir = 'pub/media';
+ $construction = [
+ '{{media url="wysiwyg/image.jpg"}}',
+ 'media',
+ ' url="wysiwyg/image.jpg"'
+ ];
+ $expectedResult = 'pub/media/wysiwyg/image.jpg';
+
+ $this->storeMock->expects($this->once())
+ ->method('getBaseMediaDir')
+ ->willReturn($baseMediaDir);
+ $this->assertEquals($expectedResult, $this->filter->mediaDirective($construction));
+ }
}
diff --git a/app/code/Magento/Email/Model/Template/Filter.php b/app/code/Magento/Email/Model/Template/Filter.php
index 11a7416f79e7a..1d8218f90a0b2 100644
--- a/app/code/Magento/Email/Model/Template/Filter.php
+++ b/app/code/Magento/Email/Model/Template/Filter.php
@@ -516,7 +516,7 @@ public function viewDirective($construction)
*/
public function mediaDirective($construction)
{
- $params = $this->getParameters($construction[2]);
+ $params = $this->getParameters(html_entity_decode($construction[2], ENT_QUOTES));
return $this->_storeManager->getStore()
->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA) . $params['url'];
}
diff --git a/app/code/Magento/Tinymce3/view/base/web/tinymce3Adapter.js b/app/code/Magento/Tinymce3/view/base/web/tinymce3Adapter.js
index 08bbb95888d8d..dfa3626c95ab1 100644
--- a/app/code/Magento/Tinymce3/view/base/web/tinymce3Adapter.js
+++ b/app/code/Magento/Tinymce3/view/base/web/tinymce3Adapter.js
@@ -448,21 +448,23 @@ define([
},
/**
+ * Convert {{directive}} style attributes syntax to absolute URLs
* @param {Object} content
* @return {*}
*/
encodeDirectives: function (content) {
// collect all HTML tags with attributes that contain directives
- return content.gsub(/<([a-z0-9\-\_]+.+?)([a-z0-9\-\_]+=".*?\{\{.+?\}\}.*?".*?)>/i, function (match) {
- var attributesString = match[2];
+ return content.gsub(/<([a-z0-9\-\_]+[^>]+?)([a-z0-9\-\_]+=".*?\{\{.+?\}\}.*?".*?)>/i, function (match) {
+ var attributesString = match[2],
+ decodedDirectiveString;
// process tag attributes string
attributesString = attributesString.gsub(/([a-z0-9\-\_]+)="(.*?)(\{\{.+?\}\})(.*?)"/i, function (m) {
- return m[1] + '="' + m[2] + this.makeDirectiveUrl(Base64.mageEncode(m[3])) + m[4] + '"';
+ decodedDirectiveString = encodeURIComponent(Base64.mageEncode((m[3].replace(/"/g, '"'))));
+ return m[1] + '="' + m[2] + this.makeDirectiveUrl(decodedDirectiveString) + m[4] + '"';
}.bind(this));
return '<' + match[1] + attributesString + '>';
-
}.bind(this));
},
@@ -493,16 +495,17 @@ define([
},
/**
+ * Convert absolute URLs to {{directive}} style attributes syntax
* @param {Object} content
* @return {*}
*/
decodeDirectives: function (content) {
// escape special chars in directives url to use it in regular expression
var url = this.makeDirectiveUrl('%directive%').replace(/([$^.?*!+:=()\[\]{}|\\])/g, '\\$1'),
- reg = new RegExp(url.replace('%directive%', '([a-zA-Z0-9,_-]+)'));
+ reg = new RegExp(url.replace('%directive%', '([a-zA-Z0-9%,_-]+)'));
return content.gsub(reg, function (match) { //eslint-disable-line no-extra-bind
- return Base64.mageDecode(match[1]);
+ return Base64.mageDecode(decodeURIComponent(match[1])).replace(/"/g, '"');
});
},
diff --git a/app/code/Magento/Widget/Model/Template/Filter.php b/app/code/Magento/Widget/Model/Template/Filter.php
index 7cd8276ffef3d..7c3e8e467e038 100644
--- a/app/code/Magento/Widget/Model/Template/Filter.php
+++ b/app/code/Magento/Widget/Model/Template/Filter.php
@@ -136,7 +136,7 @@ public function widgetDirective($construction)
*/
public function mediaDirective($construction)
{
- $params = $this->getParameters($construction[2]);
+ $params = $this->getParameters(html_entity_decode($construction[2], ENT_QUOTES));
return $this->_storeManager->getStore()
->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA) . $params['url'];
}
diff --git a/app/code/Magento/Widget/Test/Unit/Model/Template/FilterTest.php b/app/code/Magento/Widget/Test/Unit/Model/Template/FilterTest.php
index a7fccf0bc14ca..db2f468da663c 100644
--- a/app/code/Magento/Widget/Test/Unit/Model/Template/FilterTest.php
+++ b/app/code/Magento/Widget/Test/Unit/Model/Template/FilterTest.php
@@ -270,4 +270,22 @@ public function testMediaDirective()
$result = $this->filter->mediaDirective($construction);
$this->assertEquals($baseUrl . $image, $result);
}
+
+ public function testMediaDirectiveWithEncodedQuotes()
+ {
+ $image = 'wysiwyg/VB.png';
+ $construction = ['{{media url="' . $image . '"}}', 'media', ' url="' . $image . '"'];
+ $baseUrl = 'http://localhost/pub/media/';
+
+ $this->storeMock->expects($this->once())
+ ->method('getBaseUrl')
+ ->with(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA)
+ ->willReturn($baseUrl);
+ $this->storeManagerMock->expects($this->once())
+ ->method('getStore')
+ ->willReturn($this->storeMock);
+
+ $result = $this->filter->mediaDirective($construction);
+ $this->assertEquals($baseUrl . $image, $result);
+ }
}
diff --git a/dev/tests/integration/testsuite/Magento/Widget/Model/Template/FilterTest.php b/dev/tests/integration/testsuite/Magento/Widget/Model/Template/FilterTest.php
index 095193ca0e764..fc3b0399d0497 100644
--- a/dev/tests/integration/testsuite/Magento/Widget/Model/Template/FilterTest.php
+++ b/dev/tests/integration/testsuite/Magento/Widget/Model/Template/FilterTest.php
@@ -20,4 +20,18 @@ public function testMediaDirective()
$result = $filter->mediaDirective($construction);
$this->assertEquals($baseUrl . $image, $result);
}
+
+ public function testMediaDirectiveWithEncodedQuotes()
+ {
+ $image = 'wysiwyg/VB.png';
+ $construction = ['{{media url="' . $image . '"}}', 'media', ' url="' . $image . '"'];
+ $baseUrl = 'http://localhost/pub/media/';
+
+ /** @var \Magento\Widget\Model\Template\Filter $filter */
+ $filter = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
+ \Magento\Widget\Model\Template\Filter::class
+ );
+ $result = $filter->mediaDirective($construction);
+ $this->assertEquals($baseUrl . $image, $result);
+ }
}
diff --git a/lib/web/mage/adminhtml/wysiwyg/tiny_mce/plugins/magentowidget/editor_plugin.js b/lib/web/mage/adminhtml/wysiwyg/tiny_mce/plugins/magentowidget/editor_plugin.js
index af8078c0a022d..69b3c3331013e 100644
--- a/lib/web/mage/adminhtml/wysiwyg/tiny_mce/plugins/magentowidget/editor_plugin.js
+++ b/lib/web/mage/adminhtml/wysiwyg/tiny_mce/plugins/magentowidget/editor_plugin.js
@@ -205,7 +205,7 @@ tinymce.create('tinymce.plugins.magentowidget', {
widgetEl.parentNode.removeChild(widgetEl);
});
- return doc.body.innerHTML;
+ return doc.body ? doc.body.innerHTML : content;
},
/**
diff --git a/lib/web/mage/adminhtml/wysiwyg/tiny_mce/tinymce4Adapter.js b/lib/web/mage/adminhtml/wysiwyg/tiny_mce/tinymce4Adapter.js
index 4139b58a20aec..294709df3c975 100644
--- a/lib/web/mage/adminhtml/wysiwyg/tiny_mce/tinymce4Adapter.js
+++ b/lib/web/mage/adminhtml/wysiwyg/tiny_mce/tinymce4Adapter.js
@@ -510,35 +510,38 @@ define([
},
/**
+ * Convert {{directive}} style attributes syntax to absolute URLs
* @param {Object} content
* @return {*}
*/
encodeDirectives: function (content) {
// collect all HTML tags with attributes that contain directives
return content.gsub(/<([a-z0-9\-\_]+[^>]+?)([a-z0-9\-\_]+=".*?\{\{.+?\}\}.*?".*?)>/i, function (match) {
- var attributesString = match[2];
+ var attributesString = match[2],
+ decodedDirectiveString;
// process tag attributes string
attributesString = attributesString.gsub(/([a-z0-9\-\_]+)="(.*?)(\{\{.+?\}\})(.*?)"/i, function (m) {
- return m[1] + '="' + m[2] + this.makeDirectiveUrl(Base64.mageEncode(m[3])) + m[4] + '"';
+ decodedDirectiveString = encodeURIComponent(Base64.mageEncode((m[3].replace(/"/g, '"'))));
+ return m[1] + '="' + m[2] + this.makeDirectiveUrl(decodedDirectiveString) + m[4] + '"';
}.bind(this));
return '<' + match[1] + attributesString + '>';
-
}.bind(this));
},
/**
+ * Convert absolute URLs to {{directive}} style attributes syntax
* @param {Object} content
* @return {*}
*/
decodeDirectives: function (content) {
// escape special chars in directives url to use it in regular expression
var url = this.makeDirectiveUrl('%directive%').replace(/([$^.?*!+:=()\[\]{}|\\])/g, '\\$1'),
- reg = new RegExp(url.replace('%directive%', '([a-zA-Z0-9,_-]+)'));
+ reg = new RegExp(url.replace('%directive%', '([a-zA-Z0-9%,_-]+)'));
return content.gsub(reg, function (match) { //eslint-disable-line no-extra-bind
- return Base64.mageDecode(match[1]);
+ return Base64.mageDecode(decodeURIComponent(match[1])).replace(/"/g, '"');
});
},
From 70108d6c58a40710c0bb6119bbc7eb37ad5a7129 Mon Sep 17 00:00:00 2001
From: Dan Mooney
Date: Mon, 8 Jan 2018 16:27:45 -0600
Subject: [PATCH 269/904] MAGETWO-86142: Image url not encoding/decoding
correctly
Fix JS static build failures
---
app/code/Magento/Tinymce3/view/base/web/tinymce3Adapter.js | 3 ++-
lib/web/mage/adminhtml/wysiwyg/tiny_mce/tinymce4Adapter.js | 3 ++-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/app/code/Magento/Tinymce3/view/base/web/tinymce3Adapter.js b/app/code/Magento/Tinymce3/view/base/web/tinymce3Adapter.js
index dfa3626c95ab1..91dcc07adf01b 100644
--- a/app/code/Magento/Tinymce3/view/base/web/tinymce3Adapter.js
+++ b/app/code/Magento/Tinymce3/view/base/web/tinymce3Adapter.js
@@ -460,7 +460,8 @@ define([
// process tag attributes string
attributesString = attributesString.gsub(/([a-z0-9\-\_]+)="(.*?)(\{\{.+?\}\})(.*?)"/i, function (m) {
- decodedDirectiveString = encodeURIComponent(Base64.mageEncode((m[3].replace(/"/g, '"'))));
+ decodedDirectiveString = encodeURIComponent(Base64.mageEncode(m[3].replace(/"/g, '"')));
+
return m[1] + '="' + m[2] + this.makeDirectiveUrl(decodedDirectiveString) + m[4] + '"';
}.bind(this));
diff --git a/lib/web/mage/adminhtml/wysiwyg/tiny_mce/tinymce4Adapter.js b/lib/web/mage/adminhtml/wysiwyg/tiny_mce/tinymce4Adapter.js
index 294709df3c975..b73fa5609d735 100644
--- a/lib/web/mage/adminhtml/wysiwyg/tiny_mce/tinymce4Adapter.js
+++ b/lib/web/mage/adminhtml/wysiwyg/tiny_mce/tinymce4Adapter.js
@@ -522,7 +522,8 @@ define([
// process tag attributes string
attributesString = attributesString.gsub(/([a-z0-9\-\_]+)="(.*?)(\{\{.+?\}\})(.*?)"/i, function (m) {
- decodedDirectiveString = encodeURIComponent(Base64.mageEncode((m[3].replace(/"/g, '"'))));
+ decodedDirectiveString = encodeURIComponent(Base64.mageEncode(m[3].replace(/"/g, '"')));
+
return m[1] + '="' + m[2] + this.makeDirectiveUrl(decodedDirectiveString) + m[4] + '"';
}.bind(this));
From 388ae8a76fbbcb9a5649463dd844545789ba05f6 Mon Sep 17 00:00:00 2001
From: Sergii Kovalenko
Date: Tue, 9 Jan 2018 18:04:32 +0200
Subject: [PATCH 270/904] MAGETWO-85326: Tool for generating schema
--working on EE stuff
---
clean_db_schemas.php | 2 +-
.../Framework/DB/Adapter/Pdo/Mysql.php | 14 +-
setup/src/Magento/Setup/Model/Installer.php | 24 +--
.../Magento/Setup/Model/SchemaListener.php | 196 +++++++++++++-----
.../Magento/Setup/Model/SchemaPersistor.php | 47 +++--
5 files changed, 201 insertions(+), 82 deletions(-)
diff --git a/clean_db_schemas.php b/clean_db_schemas.php
index 2cd96079c3f16..081c906692c6c 100644
--- a/clean_db_schemas.php
+++ b/clean_db_schemas.php
@@ -45,7 +45,7 @@
$adapter->query('CREATE DATABASE ' . $resourceConnection->getSchemaName('default'));
foreach ($componentRegistrar->getPaths(\Magento\Framework\Component\ComponentRegistrar::MODULE) as $path) {
- if (strpos($path, 'magento2ce') !== false) {
+ if (strpos($path, 'magento2ee') !== false) {
@unlink($path . DIRECTORY_SEPARATOR . 'etc/db_schema.xml');
}
}
diff --git a/lib/internal/Magento/Framework/DB/Adapter/Pdo/Mysql.php b/lib/internal/Magento/Framework/DB/Adapter/Pdo/Mysql.php
index 9f70bc8aa44cb..9e7dbae87f97b 100644
--- a/lib/internal/Magento/Framework/DB/Adapter/Pdo/Mysql.php
+++ b/lib/internal/Magento/Framework/DB/Adapter/Pdo/Mysql.php
@@ -836,7 +836,6 @@ protected function _splitMultiQuery($sql)
*/
public function dropForeignKey($tableName, $fkName, $schemaName = null)
{
- $this->schemaListener->dropForeignKey($tableName, $fkName);
$foreignKeys = $this->getForeignKeys($tableName, $schemaName);
$fkName = strtoupper($fkName);
if (substr($fkName, 0, 3) == 'FK_') {
@@ -851,6 +850,7 @@ public function dropForeignKey($tableName, $fkName, $schemaName = null)
);
$this->resetDdlCache($tableName, $schemaName);
$this->rawQuery($sql);
+ $this->schemaListener->dropForeignKey($tableName, $fkName);
}
}
return $this;
@@ -993,7 +993,7 @@ public function dropColumn($tableName, $columnName, $schemaName = null)
if (!$this->tableColumnExists($tableName, $columnName, $schemaName)) {
return true;
}
-
+ $this->schemaListener->dropColumn($tableName, $columnName);
$alterDrop = [];
$foreignKeys = $this->getForeignKeys($tableName, $schemaName);
@@ -2597,7 +2597,7 @@ public function renameTable($oldTableName, $newTableName, $schemaName = null)
if ($this->isTableExists($newTableName, $schemaName)) {
throw new \Zend_Db_Exception(sprintf('Table "%s" already exists', $newTableName));
}
-
+ $this->schemaListener->renameTable($oldTableName, $newTableName);
$oldTable = $this->_getTableName($oldTableName, $schemaName);
$newTable = $this->_getTableName($newTableName, $schemaName);
@@ -2717,22 +2717,28 @@ public function addIndex(
public function dropIndex($tableName, $keyName, $schemaName = null)
{
$indexList = $this->getIndexList($tableName, $schemaName);
+ $indexType = 'index';
$keyName = strtoupper($keyName);
if (!isset($indexList[$keyName])) {
return true;
}
if ($keyName == 'PRIMARY') {
+ $indexType = 'primary';
$cond = 'DROP PRIMARY KEY';
} else {
+ if (strpos($keyName, 'UNQ_') !== false) {
+ $indexType = 'unique';
+ }
$cond = 'DROP KEY ' . $this->quoteIdentifier($indexList[$keyName]['KEY_NAME']);
}
+
$sql = sprintf(
'ALTER TABLE %s %s',
$this->quoteIdentifier($this->_getTableName($tableName, $schemaName)),
$cond
);
-
+ $this->schemaListener->dropIndex($tableName, $keyName, $indexType);
$this->resetDdlCache($tableName, $schemaName);
return $this->rawQuery($sql);
diff --git a/setup/src/Magento/Setup/Model/Installer.php b/setup/src/Magento/Setup/Model/Installer.php
index 965ed287cfc04..bf78a6b0d86ef 100644
--- a/setup/src/Magento/Setup/Model/Installer.php
+++ b/setup/src/Magento/Setup/Model/Installer.php
@@ -917,15 +917,15 @@ private function handleDBSchemaData($setup, $type, array $request)
}
}
$stagingModules = [
- 'Magento_Bundle',
- 'Magento_Catalog',
- 'Magento_CatalogUrlRewrite',
- 'Magento_CatalogInventory',
- 'Magento_ConfigurableProduct',
- 'Magento_ProductAlert',
- 'Magento_Reports',
- 'Magento_Weee',
- 'Magento_Wishlist',
+ 'Magento_Bundle' => 'Magento_BundleStaging',
+ 'Magento_Catalog' => 'Magento_CatalogStaging',
+ 'Magento_CatalogUrlRewrite' => 'Magento_CatalogUrlRewriteStaging',
+ 'Magento_CatalogInventory' => 'Magento_CatalogInventoryStaging',
+ 'Magento_ConfigurableProduct' => 'Magento_ConfigurableProductStaging',
+ 'Magento_ProductAlert' => 'Magento_CatalogStaging',
+ 'Magento_Reports' => 'Magento_CatalogStaging',
+ 'Magento_Weee' => 'Magento_WeeeStaging',
+ 'Magento_Wishlist' => 'Magento_CatalogStaging',
];
$this->schemaListener->toogleIgnore(SchemaListener::IGNORE_ON);
if ($type === 'schema') {
@@ -936,9 +936,9 @@ private function handleDBSchemaData($setup, $type, array $request)
$handlerType = 'data-recurring';
}
foreach ($moduleNames as $moduleName) {
- if (in_array($moduleName, $stagingModules)) {
- $this->schemaListener->setModuleName($moduleName);
- $this->schemaListener->toogleIgnore(SchemaListener::IGNORE_OFF);
+ if (isset($stagingModules[$moduleName])) {
+ $this->schemaListener->setModuleName($stagingModules[$moduleName]);
+ $this->schemaListener->toogleIgnore(SchemaListener::IGNORE_OFF | SchemaListener::STAGING_FK_KEYS);
}
$this->log->log("Module '{$moduleName}':");
$modulePostUpdater = $this->getSchemaDataHandler($moduleName, $handlerType);
diff --git a/setup/src/Magento/Setup/Model/SchemaListener.php b/setup/src/Magento/Setup/Model/SchemaListener.php
index 853164c660a38..2ce7a421cb22f 100644
--- a/setup/src/Magento/Setup/Model/SchemaListener.php
+++ b/setup/src/Magento/Setup/Model/SchemaListener.php
@@ -18,12 +18,19 @@ class SchemaListener
/**
* Ignore all ddl queries
*/
- const IGNORE_ON = true;
+ const IGNORE_ON = 0;
/**
* Disable ignore mode
*/
- const IGNORE_OFF = false;
+ const IGNORE_OFF = 1;
+
+ /**
+ * Staging FK keys installer key
+ * This means, that all changes should be moved from ordinar module to staging module
+ */
+ const STAGING_FK_KEYS = 2;
+
/**
* @var array
*/
@@ -82,8 +89,10 @@ class SchemaListener
* @param array $definitionMappers
* @param array $handlers
*/
- public function __construct(array $definitionMappers, array $handlers)
- {
+ public function __construct(
+ array $definitionMappers,
+ array $handlers
+ ) {
$this->definitionMappers = $definitionMappers;
$this->handlers = $handlers;
}
@@ -94,13 +103,10 @@ public function __construct(array $definitionMappers, array $handlers)
*/
public function dropForeignKey($tableName, $fkName)
{
- if ($this->ignore) {
- return;
- }
-
- $this->tables[$this->moduleName][$tableName]['constraints']['foreign'][$fkName] = [
- 'disabled' => 1,
+ $dataToLog['constraints']['foreign'][$fkName] = [
+ 'disabled' => true,
];
+ $this->log($tableName, $dataToLog);
}
/**
@@ -119,6 +125,7 @@ private function castColumnDefinition($definition, $columnName)
if (isset($definition['default']) && $definition['default'] === false) {
$definition['default'] = null; //uniform default values
}
+ $definition['disabled'] = false;
return $definition;
}
@@ -133,27 +140,35 @@ private function castColumnDefinition($definition, $columnName)
private function addPrimaryKeyIfExists($tableName, $columnName, $definition, $primaryKeyName)
{
if (isset($definition['primary']) && $definition['primary']) {
- if (isset($this->tables[$this->moduleName][$tableName]['constraints']['primary'][$primaryKeyName])) {
- $this->tables[$this->moduleName][$tableName]['constraints']['primary'][$primaryKeyName] = array_replace_recursive(
- $this->tables[$this->moduleName][$tableName]['constraints']['primary'][$primaryKeyName],
- [
- 'columns' => [$columnName => strtolower($columnName)]
- ]
- );
+ $dataToLog['constraints']['primary'][$primaryKeyName] = [
+ 'type' => 'primary',
+ 'name' => $primaryKeyName,
+ 'disabled' => false,
+ 'columns' => [$columnName => strtolower($columnName)]
+ ];
- } else {
- $this->tables[$this->moduleName][$tableName]['constraints']['primary'][$primaryKeyName] = [
- 'type' => 'primary',
- 'name' => $primaryKeyName,
- 'columns' => [$columnName => strtolower($columnName)]
- ];
- }
+ $this->log($tableName, $dataToLog);
}
unset($definition['primary']);
return $definition;
}
+ /**
+ * @param string $oldTableName
+ * @param string $newTableName
+ * @return void
+ */
+ public function renameTable($oldTableName, $newTableName)
+ {
+ $moduleName = $this->getModuleName();
+
+ if (isset($this->tables[$moduleName][strtolower($oldTableName)])) {
+ $this->tables[$moduleName][strtolower($newTableName)] = $this->tables[$moduleName][strtolower($oldTableName)];
+ unset($this->tables[$moduleName][strtolower($oldTableName)]);
+ }
+ }
+
/**
* Process definition to not specific format
*
@@ -181,16 +196,49 @@ private function doColumnMapping(array $definition)
* @param string $columnName
* @param array $definition
* @param string $primaryKeyName
+ * @param null $onCreate
*/
- public function addColumn($tableName, $columnName, $definition, $primaryKeyName = 'PRIMARY')
+ public function addColumn($tableName, $columnName, $definition, $primaryKeyName = 'PRIMARY', $onCreate = null)
{
- if ($this->ignore) {
- return;
- }
-
$definition = $this->castColumnDefinition($definition, $columnName);
$definition = $this->addPrimaryKeyIfExists($tableName, $columnName, $definition, $primaryKeyName);
- $this->tables[$this->moduleName][strtolower($tableName)]['columns'][strtolower($columnName)] = $definition;
+ $definition['onCreate'] = $onCreate;
+ $dataToLog['columns'][strtolower($columnName)] = $definition;
+ $this->log($tableName, $dataToLog);
+ }
+
+ /**
+ * @param string $tableName
+ * @param string $keyName
+ * @param string $indexType
+ */
+ public function dropIndex($tableName, $keyName, $indexType)
+ {
+ if ($indexType === 'index') {
+ $dataToLog['indexes'][$keyName] = [
+ 'disabled' => true
+ ];
+ } else {
+ $dataToLog['constraints'][$indexType][$keyName] = [
+ 'disabled' => true
+ ];
+ }
+
+ $this->log($tableName, $dataToLog);
+ }
+
+ /**
+ * Do drop column
+ *
+ * @param string $tableName
+ * @param string $columnName
+ */
+ public function dropColumn($tableName, $columnName)
+ {
+ $dataToLog['columns'][strtolower($columnName)] = [
+ 'disabled' => true
+ ];
+ $this->log($tableName, $dataToLog);
}
/**
@@ -203,10 +251,6 @@ public function addColumn($tableName, $columnName, $definition, $primaryKeyName
*/
public function changeColumn($tableName, $oldColumnName, $newColumnName, $definition)
{
- if ($this->ignore) {
- return;
- }
-
foreach ($this->handlers as $handler) {
$this->tables = $handler->handle(
$this->moduleName,
@@ -220,7 +264,14 @@ public function changeColumn($tableName, $oldColumnName, $newColumnName, $defini
);
}
- $this->addColumn($tableName, $newColumnName, $definition, 'STAGING_PRIMARY');
+ $this->dropColumn($tableName, $oldColumnName);
+ $this->addColumn(
+ $tableName,
+ $newColumnName,
+ $definition,
+ 'STAGING_PRIMARY',
+ sprintf('migrateDataFrom(%s)', $oldColumnName)
+ );
}
/**
@@ -233,6 +284,39 @@ public function modifyColumn($tableName, $columnName, $definition)
$this->addColumn($tableName, $columnName, $definition);
}
+ /**
+ * Retrieved processed module name
+ *
+ * @return string
+ */
+ private function getModuleName()
+ {
+ return $this->moduleName;
+ }
+
+ /**
+ * Log any change, that was done
+ *
+ * @param string $tableName
+ * @param array $dataToLog
+ * @return void
+ */
+ public function log($tableName, array $dataToLog)
+ {
+ if ($this->ignore & self::IGNORE_OFF === 0) {
+ return;
+ }
+ $moduleName = $this->getModuleName();
+ if (isset($this->tables[$moduleName][strtolower($tableName)])) {
+ $this->tables[$moduleName][strtolower($tableName)] = array_replace_recursive(
+ $this->tables[$moduleName][strtolower($tableName)],
+ $dataToLog
+ );
+ } else {
+ $this->tables[$moduleName][strtolower($tableName)] = $dataToLog;
+ }
+ }
+
/**
* @param string $fkName
* @param string $tableName
@@ -249,18 +333,16 @@ public function addForeignKey(
$refColumnName,
$onDelete = AdapterInterface::FK_ACTION_CASCADE
) {
- if ($this->ignore) {
- return;
- }
-
- $this->tables[$this->moduleName][strtolower($tableName)]['constraints']['foreign'][$fkName] =
+ $dataToLog['constraints']['foreign'][$fkName] =
[
'table' => strtolower($tableName),
'column' => strtolower($columnName),
'referenceTable' => strtolower($refTableName),
'referenceColumn' => strtolower($refColumnName),
- 'onDelete' => $onDelete
+ 'onDelete' => $onDelete,
+ 'disabled' => false
];
+ $this->log($tableName, $dataToLog);
}
/**
@@ -296,10 +378,6 @@ public function addIndex(
$fields,
$indexType = AdapterInterface::INDEX_TYPE_INDEX
) {
- if ($this->ignore) {
- return;
- }
-
if (!is_array($fields)) {
$fields = [$fields];
}
@@ -307,12 +385,18 @@ public function addIndex(
if ($indexType === AdapterInterface::INDEX_TYPE_INDEX) {
$indexType = 'btree';
}
- $this->tables[$this->moduleName][$tableName]['indexes'][$indexName] =
- ['columns' => $this->prepareIndexColumns($fields), 'indexType' => $indexType];
+ $dataToLog['indexes'][$indexName] =
+ [
+ 'columns' => $this->prepareIndexColumns($fields),
+ 'indexType' => $indexType,
+ 'disabled' => false
+ ];
} else {
- $this->tables[$this->moduleName][$tableName]['constraints'][$indexType][$indexName] =
- ['columns' => $this->prepareIndexColumns($fields)];
+ $dataToLog['constraints'][$indexType][$indexName] =
+ ['columns' => $this->prepareIndexColumns($fields), 'disabled' => false];
}
+
+ $this->log($tableName, $dataToLog);
}
/**
@@ -366,10 +450,6 @@ private function prepareConstraintsAndIndexes(array $foreignKeys, array $indexes
*/
public function createTable(Table $table)
{
- if ($this->ignore) {
- return;
- }
-
$this->prepareColumns($table->getName(), $table->getColumns());
$this->prepareConstraintsAndIndexes($table->getForeignKeys(), $table->getIndexes(), $table->getName());
}
@@ -394,6 +474,16 @@ public function toogleIgnore($flag)
$this->ignore = $flag;
}
+ /**
+ * Check whether staging fk keys installer is enabled
+ *
+ * @return int
+ */
+ private function isStagingFkKeysEnabled()
+ {
+ return ($this->ignore & self::STAGING_FK_KEYS) === self::STAGING_FK_KEYS;
+ }
+
/**
* @param string $moduleName
*/
diff --git a/setup/src/Magento/Setup/Model/SchemaPersistor.php b/setup/src/Magento/Setup/Model/SchemaPersistor.php
index d01524b2c3aec..418e46808e685 100644
--- a/setup/src/Magento/Setup/Model/SchemaPersistor.php
+++ b/setup/src/Magento/Setup/Model/SchemaPersistor.php
@@ -54,6 +54,7 @@ public function persist(SchemaListener $schemaListener)
}
foreach ($tablesData as $tableName => $tableData) {
+ $tableData = $this->handleDefinition($tableData);
$table = $dom->addChild('table');
$table->addAttribute('name', $tableName);
/** @TODO: handle different resources for sales and checkout tables */
@@ -67,6 +68,22 @@ public function persist(SchemaListener $schemaListener)
}
}
+ /**
+ * If disabled attribute is set to false it remove it at all
+ * Also handle other generic attributes
+ *
+ * @param array $definition
+ * @return array
+ */
+ private function handleDefinition(array $definition)
+ {
+ if (isset($definition['disabled']) && !$definition['disabled']) {
+ unset($definition['disabled']);
+ }
+
+ return $definition;
+ }
+
/**
* Cast boolean types to string
*
@@ -89,6 +106,7 @@ private function processColumns(array $tableData, \SimpleXMLElement $table)
{
if (isset($tableData['columns'])) {
foreach ($tableData['columns'] as $columnName => $columnData) {
+ $columnData = $this->handleDefinition($columnData);
$domColumn = $table->addChild('column');
$domColumn->addAttribute('xsi:type', $columnData['xsi:type'], 'xsi');
unset($columnData['xsi:type']);
@@ -121,6 +139,7 @@ private function processIndexes(array $tableData, \SimpleXMLElement $table)
{
if (isset($tableData['indexes'])) {
foreach ($tableData['indexes'] as $indexName => $indexData) {
+ $indexData = $this->handleDefinition($indexData);
$domIndex = $table->addChild('index');
$domIndex->addAttribute('name', $indexName);
@@ -153,6 +172,7 @@ private function processConstraints(array $tableData, \SimpleXMLElement $table)
foreach ($tableData['constraints'] as $constraintType => $constraints) {
if ($constraintType === 'foreign') {
foreach ($constraints as $name => $constraintData) {
+ $constraintData = $this->handleDefinition($constraintData);
$constraintDom = $table->addChild('constraint');
$constraintDom->addAttribute('xsi:type', $constraintType, 'xsi');
$constraintDom->addAttribute('name', $name);
@@ -163,6 +183,7 @@ private function processConstraints(array $tableData, \SimpleXMLElement $table)
}
} else {
foreach ($constraints as $name => $constraintData) {
+ $constraintData = $this->handleDefinition($constraintData);
$constraintDom = $table->addChild('constraint');
$constraintDom->addAttribute('xsi:type', $constraintType, 'xsi');
$constraintDom->addAttribute('name', $name);
@@ -193,17 +214,19 @@ private function processConstraints(array $tableData, \SimpleXMLElement $table)
*/
private function persistModule(\SimpleXMLElement $simpleXmlElementDom, $path)
{
- $dom = new \DOMDocument('1.0');
- $dom->preserveWhiteSpace = false;
- $dom->formatOutput = true;
- $dom->loadXML($simpleXmlElementDom->asXML());
- file_put_contents(
- $path,
- str_replace(
- ' xmlns:xsi="xsi"', //reokace xmlns, as we do not need it for xsi namespace
- '',
- $dom->saveXML()
- )
- );
+ if (strpos($path, 'magento#ee') !== false) {
+ $dom = new \DOMDocument('1.0');
+ $dom->preserveWhiteSpace = false;
+ $dom->formatOutput = true;
+ $dom->loadXML($simpleXmlElementDom->asXML());
+ file_put_contents(
+ $path,
+ str_replace(
+ ' xmlns:xsi="xsi"', //replace xmlns, as we do not need it for xsi namespace
+ '',
+ $dom->saveXML()
+ )
+ );
+ }
}
}
From b878cffa5be248555ac02ddb144bc3c4a9249a0d Mon Sep 17 00:00:00 2001
From: Krissy Hiserote
Date: Tue, 9 Jan 2018 12:08:50 -0600
Subject: [PATCH 271/904] MAGETWO-85421: Build Stabilization
- fix javascript formatting
---
.../Magento/Ui/view/base/web/js/form/element/wysiwyg.js | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/app/code/Magento/Ui/view/base/web/js/form/element/wysiwyg.js b/app/code/Magento/Ui/view/base/web/js/form/element/wysiwyg.js
index 30d90be661d34..5463e80c43946 100644
--- a/app/code/Magento/Ui/view/base/web/js/form/element/wysiwyg.js
+++ b/app/code/Magento/Ui/view/base/web/js/form/element/wysiwyg.js
@@ -12,7 +12,7 @@ define([
'underscore',
'ko',
'./abstract',
- 'Magento_Variable/variables',
+ 'Magento_Variable/variables'
], function (wysiwyg, $, _, ko, Abstract) {
'use strict';
@@ -92,14 +92,14 @@ define([
* @param {Boolean} status
*/
setDisabled: function (status) {
- if (this.$wysiwygEditorButton != '') {
+ if (this.$wysiwygEditorButton !== '') {
this.$wysiwygEditorButton.attr('disabled', status);
}
/* eslint-disable no-undef */
- if (typeof wysiwyg != 'undefined' && wysiwyg.activeEditor()) {
+ if (typeof wysiwyg !== 'undefined' && wysiwyg.activeEditor()) {
- if(typeof wysiwyg.activeEditor().controlManager !== 'undefined') {
+ if (typeof wysiwyg.activeEditor().controlManager !== 'undefined') {
_.each(wysiwyg.activeEditor().controlManager.controls, function (property, index, controls) {
controls[property.id].setDisabled(status);
});
From 076d5810ca25352f302158ddd572d77ff76801f5 Mon Sep 17 00:00:00 2001
From: Kieu Phan
Date: Wed, 10 Jan 2018 01:14:19 -0600
Subject: [PATCH 272/904] MAGETWO-85452: QA Activities
- Organize TinyMCE tests
---
.../Cms/Section/TinyMCESection.xml | 53 +++++++++++++++++++
1 file changed, 53 insertions(+)
create mode 100644 dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Section/TinyMCESection.xml
diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Section/TinyMCESection.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Section/TinyMCESection.xml
new file mode 100644
index 0000000000000..cf4e21fe5e702
--- /dev/null
+++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Section/TinyMCESection.xml
@@ -0,0 +1,53 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
From 684a6de540dadab0ef35358882b6dfbd18c66a2e Mon Sep 17 00:00:00 2001
From: Sergii Kovalenko
Date: Wed, 10 Jan 2018 14:48:06 +0200
Subject: [PATCH 273/904] MAGETWO-85326: Tool for generating schema
--working on EE stuff
---
app/code/Magento/Quote/Setup/QuoteSetup.php | 8 +++++++-
app/code/Magento/Sales/Setup/SalesSetup.php | 13 +++++++------
...generating_schema____working_on_EE_stuff.patch | 15 +++++++++++++++
setup/src/Magento/Setup/Model/Installer.php | 10 ++++++----
setup/src/Magento/Setup/Model/SchemaPersistor.php | 12 ++++++++++--
5 files changed, 45 insertions(+), 13 deletions(-)
create mode 100644 schema_patches/MAGETWO_85326__Tool_for_generating_schema____working_on_EE_stuff.patch
diff --git a/app/code/Magento/Quote/Setup/QuoteSetup.php b/app/code/Magento/Quote/Setup/QuoteSetup.php
index b1f52288b1160..3b9faa76dfc6a 100644
--- a/app/code/Magento/Quote/Setup/QuoteSetup.php
+++ b/app/code/Magento/Quote/Setup/QuoteSetup.php
@@ -11,6 +11,7 @@
use Magento\Framework\App\CacheInterface;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\Setup\ModuleDataSetupInterface;
+use Magento\Setup\Model\SchemaListener;
/**
* Quote module setup class
@@ -203,7 +204,12 @@ public function getEncryptor()
*/
public function getConnection()
{
- return $this->getSetup()->getConnection(self::$connectionName);
+ $setup = $this->getSetup();
+ /** @var SchemaListener $schemaListener */
+ $schemaListener = $setup->getConnection()->getSchemaListener();
+ $newConnection = $this->getSetup()->getConnection(self::$connectionName);
+ $newConnection->setSchemaListener($schemaListener);
+ return $newConnection;
}
/**
diff --git a/app/code/Magento/Sales/Setup/SalesSetup.php b/app/code/Magento/Sales/Setup/SalesSetup.php
index ec8f7ce0f14d2..d65d960f74ae6 100644
--- a/app/code/Magento/Sales/Setup/SalesSetup.php
+++ b/app/code/Magento/Sales/Setup/SalesSetup.php
@@ -12,6 +12,7 @@
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\Encryption\EncryptorInterface;
use Magento\Framework\Setup\ModuleDataSetupInterface;
+use Magento\Setup\Model\SchemaListener;
/**
* Sales module setup class
@@ -302,14 +303,14 @@ public function getEncryptor()
return $this->encryptor;
}
- /**
- * Get sales connection
- *
- * @return \Magento\Framework\DB\Adapter\AdapterInterface
- */
public function getConnection()
{
- return $this->getSetup()->getConnection(self::$connectionName);
+ $setup = $this->getSetup();
+ /** @var SchemaListener $schemaListener */
+ $schemaListener = $setup->getConnection()->getSchemaListener();
+ $newConnection = $this->getSetup()->getConnection(self::$connectionName);
+ $newConnection->setSchemaListener($schemaListener);
+ return $newConnection;
}
/**
diff --git a/schema_patches/MAGETWO_85326__Tool_for_generating_schema____working_on_EE_stuff.patch b/schema_patches/MAGETWO_85326__Tool_for_generating_schema____working_on_EE_stuff.patch
new file mode 100644
index 0000000000000..e70583e2e4174
--- /dev/null
+++ b/schema_patches/MAGETWO_85326__Tool_for_generating_schema____working_on_EE_stuff.patch
@@ -0,0 +1,15 @@
+Index: app/code/Magento/CatalogStaging/etc/db_schema.xml
+IDEA additional info:
+Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
+<+>UTF-8
+===================================================================
+--- app/code/Magento/CatalogStaging/etc/db_schema.xml (revision 4a4aa7ae62773eb2ec7e4f6f1bc33a43bcbd3332)
++++ app/code/Magento/CatalogStaging/etc/db_schema.xml (revision )
+@@ -209,6 +209,7 @@
+
+
diff --git a/setup/src/Magento/Setup/Model/Installer.php b/setup/src/Magento/Setup/Model/Installer.php
index bf78a6b0d86ef..cf33ec85e13b0 100644
--- a/setup/src/Magento/Setup/Model/Installer.php
+++ b/setup/src/Magento/Setup/Model/Installer.php
@@ -936,10 +936,12 @@ private function handleDBSchemaData($setup, $type, array $request)
$handlerType = 'data-recurring';
}
foreach ($moduleNames as $moduleName) {
- if (isset($stagingModules[$moduleName])) {
- $this->schemaListener->setModuleName($stagingModules[$moduleName]);
- $this->schemaListener->toogleIgnore(SchemaListener::IGNORE_OFF | SchemaListener::STAGING_FK_KEYS);
- }
+ $schemaListenerModuleName = $stagingModules[$moduleName] ?? $moduleName;
+ $this->schemaListener->setModuleName($schemaListenerModuleName);
+ $this->schemaListener->toogleIgnore(
+ SchemaListener::IGNORE_OFF | SchemaListener::STAGING_FK_KEYS
+ );
+
$this->log->log("Module '{$moduleName}':");
$modulePostUpdater = $this->getSchemaDataHandler($moduleName, $handlerType);
if ($modulePostUpdater) {
diff --git a/setup/src/Magento/Setup/Model/SchemaPersistor.php b/setup/src/Magento/Setup/Model/SchemaPersistor.php
index 418e46808e685..ab7ee1f026bf6 100644
--- a/setup/src/Magento/Setup/Model/SchemaPersistor.php
+++ b/setup/src/Magento/Setup/Model/SchemaPersistor.php
@@ -6,6 +6,7 @@
namespace Magento\Setup\Model;
use Magento\Framework\Component\ComponentRegistrar;
+use Magento\Framework\Shell;
/**
* Persist listened schema to db_schema.xml file
@@ -17,12 +18,19 @@ class SchemaPersistor
*/
private $componentRegistrar;
+ /**
+ * @var Shell
+ */
+ private $shell;
+
/**
* @param ComponentRegistrar $componentRegistrar
+ * @param Shell $shell
*/
- public function __construct(ComponentRegistrar $componentRegistrar)
+ public function __construct(ComponentRegistrar $componentRegistrar, Shell $shell)
{
$this->componentRegistrar = $componentRegistrar;
+ $this->shell = $shell;
}
/**
@@ -214,7 +222,7 @@ private function processConstraints(array $tableData, \SimpleXMLElement $table)
*/
private function persistModule(\SimpleXMLElement $simpleXmlElementDom, $path)
{
- if (strpos($path, 'magento#ee') !== false) {
+ if (strpos($path, 'magento2ee') !== false) {
$dom = new \DOMDocument('1.0');
$dom->preserveWhiteSpace = false;
$dom->formatOutput = true;
From f29209b982d4610faaf779f94e631d0a0db220e2 Mon Sep 17 00:00:00 2001
From: Krissy Hiserote
Date: Wed, 10 Jan 2018 08:08:25 -0600
Subject: [PATCH 274/904] MAGETWO-85007: Add Content Section
- fix after CR
---
app/code/Magento/Ui/view/base/web/js/form/element/wysiwyg.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/code/Magento/Ui/view/base/web/js/form/element/wysiwyg.js b/app/code/Magento/Ui/view/base/web/js/form/element/wysiwyg.js
index 5463e80c43946..8662071c2b2b6 100644
--- a/app/code/Magento/Ui/view/base/web/js/form/element/wysiwyg.js
+++ b/app/code/Magento/Ui/view/base/web/js/form/element/wysiwyg.js
@@ -92,7 +92,7 @@ define([
* @param {Boolean} status
*/
setDisabled: function (status) {
- if (this.$wysiwygEditorButton !== '') {
+ if (this.$wysiwygEditorButton) {
this.$wysiwygEditorButton.attr('disabled', status);
}
From 41d40673b55697cdb69228e603c79f495fb237f5 Mon Sep 17 00:00:00 2001
From: Kieu Phan
Date: Wed, 10 Jan 2018 09:26:54 -0600
Subject: [PATCH 275/904] MAGETWO-85452: QA Activities
- Updated TinyMCE Section
---
.../Magento/FunctionalTest/Cms/Section/TinyMCESection.xml | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Section/TinyMCESection.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Section/TinyMCESection.xml
index cf4e21fe5e702..df8e2bee8ec05 100644
--- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Section/TinyMCESection.xml
+++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Section/TinyMCESection.xml
@@ -9,10 +9,11 @@
+
-
-
+
+
@@ -21,6 +22,7 @@
+
@@ -47,7 +49,6 @@
-
From 54a038d21e2a4a229734fb9ca72792e9b25eaf45 Mon Sep 17 00:00:00 2001
From: Dan Mooney
Date: Wed, 10 Jan 2018 10:55:12 -0600
Subject: [PATCH 276/904] MAGETWO-86141: Disable/Enable TinyMCE Not Working
Fix JS static build failures
---
app/code/Magento/Ui/view/base/web/js/form/element/wysiwyg.js | 2 +-
lib/web/mage/adminhtml/wysiwyg/tiny_mce/tinymce4Adapter.js | 1 +
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/app/code/Magento/Ui/view/base/web/js/form/element/wysiwyg.js b/app/code/Magento/Ui/view/base/web/js/form/element/wysiwyg.js
index 107761e714ce5..713edc393470b 100644
--- a/app/code/Magento/Ui/view/base/web/js/form/element/wysiwyg.js
+++ b/app/code/Magento/Ui/view/base/web/js/form/element/wysiwyg.js
@@ -12,7 +12,7 @@ define([
'underscore',
'ko',
'./abstract',
- 'Magento_Variable/variables',
+ 'Magento_Variable/variables'
], function (wysiwyg, $, _, ko, Abstract) {
'use strict';
diff --git a/lib/web/mage/adminhtml/wysiwyg/tiny_mce/tinymce4Adapter.js b/lib/web/mage/adminhtml/wysiwyg/tiny_mce/tinymce4Adapter.js
index 164fc11cf4f1e..b1032b81d02fb 100644
--- a/lib/web/mage/adminhtml/wysiwyg/tiny_mce/tinymce4Adapter.js
+++ b/lib/web/mage/adminhtml/wysiwyg/tiny_mce/tinymce4Adapter.js
@@ -133,6 +133,7 @@ define([
*/
setToolbarStatus: function (enabled) {
var controlIds = this.get(this.getId()).theme.panel.rootControl.controlIdLookup;
+
_.each(controlIds, function (controlId) {
controlId.disabled(!enabled);
});
From b67b0d58728ca02346c115926354daeeff65315d Mon Sep 17 00:00:00 2001
From: Kieu Phan
Date: Wed, 10 Jan 2018 16:20:26 -0600
Subject: [PATCH 277/904] MAGETWO-85452: QA Activities Redesign TinyMCE section
and Media Gallery section
---
.../AdminAddImageToWYSIWYGCatalogCest.xml | 39 +--------
...yTinyMCEv4IsNativeWYSIWYGOnCatalogCest.xml | 15 +---
.../VerifyMediaGalleryActionGroup.xml | 13 +++
.../ActionGroup/VerifyTinyMCEActionGroup.xml | 31 +++++++
.../Cest/AdminAddImageToWYSIWYGBlockCest.xml | 56 ++++++-------
.../AdminAddVariableToWYSIWYGBlockCest.xml | 12 +--
.../Cest/AdminAddWidgetToWYSIWYGBlockCest.xml | 4 +-
...ifyTinyMCEv4IsNativeWYSIWYGOnBlockCest.xml | 30 ++-----
...yTinyMCEv4IsNativeWYSIWYGOnCMSPageCest.xml | 18 +---
.../Section/BlockNewPageContentSection.xml | 39 ---------
.../Section/CmsNewPagePageContentSection.xml | 53 ------------
.../Cms/Section/TinyMCESection.xml | 83 +++++++++++++++----
...nyMCEv4IsNativeWYSIWYGOnNewsletterCest.xml | 20 +----
13 files changed, 163 insertions(+), 250 deletions(-)
create mode 100644 dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/ActionGroup/VerifyMediaGalleryActionGroup.xml
create mode 100644 dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/ActionGroup/VerifyTinyMCEActionGroup.xml
diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Cest/AdminAddImageToWYSIWYGCatalogCest.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Cest/AdminAddImageToWYSIWYGCatalogCest.xml
index a217085ed227a..0031093405d23 100644
--- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Cest/AdminAddImageToWYSIWYGCatalogCest.xml
+++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Cest/AdminAddImageToWYSIWYGCatalogCest.xml
@@ -34,44 +34,7 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Cest/VerifyTinyMCEv4IsNativeWYSIWYGOnCatalogCest.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Cest/VerifyTinyMCEv4IsNativeWYSIWYGOnCatalogCest.xml
index e21b0f47f5d2c..6eeac0388971d 100644
--- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Cest/VerifyTinyMCEv4IsNativeWYSIWYGOnCatalogCest.xml
+++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Cest/VerifyTinyMCEv4IsNativeWYSIWYGOnCatalogCest.xml
@@ -38,20 +38,7 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/ActionGroup/VerifyMediaGalleryActionGroup.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/ActionGroup/VerifyMediaGalleryActionGroup.xml
new file mode 100644
index 0000000000000..6785f691fd385
--- /dev/null
+++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/ActionGroup/VerifyMediaGalleryActionGroup.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/ActionGroup/VerifyTinyMCEActionGroup.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/ActionGroup/VerifyTinyMCEActionGroup.xml
new file mode 100644
index 0000000000000..a5f47667c9d80
--- /dev/null
+++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/ActionGroup/VerifyTinyMCEActionGroup.xml
@@ -0,0 +1,31 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddImageToWYSIWYGBlockCest.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddImageToWYSIWYGBlockCest.xml
index 5e603a761ca7b..0407e5421d9e3 100644
--- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddImageToWYSIWYGBlockCest.xml
+++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddImageToWYSIWYGBlockCest.xml
@@ -33,47 +33,47 @@
-
-
+
+
-
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
+
-
+
-
+
-
-
-
-
+
+
+
+
-
-
-
-
+
+
+
+
-
-
+
+
-
-
-
-
+
+
+
+
diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddVariableToWYSIWYGBlockCest.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddVariableToWYSIWYGBlockCest.xml
index 8ebfae731d64c..b14e0bd2711f3 100644
--- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddVariableToWYSIWYGBlockCest.xml
+++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddVariableToWYSIWYGBlockCest.xml
@@ -42,9 +42,9 @@
-
-
-
+
+
+
@@ -62,7 +62,7 @@
-
+
@@ -78,8 +78,8 @@
-
-
+
+
diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGBlockCest.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGBlockCest.xml
index 07240974758a3..c221c9c46194d 100644
--- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGBlockCest.xml
+++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGBlockCest.xml
@@ -33,8 +33,8 @@
-
-
+
+
diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/VerifyTinyMCEv4IsNativeWYSIWYGOnBlockCest.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/VerifyTinyMCEv4IsNativeWYSIWYGOnBlockCest.xml
index f2381eb347164..05032947ec2b7 100644
--- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/VerifyTinyMCEv4IsNativeWYSIWYGOnBlockCest.xml
+++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/VerifyTinyMCEv4IsNativeWYSIWYGOnBlockCest.xml
@@ -35,29 +35,15 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
-
-
-
-
+
+
+
+
@@ -65,8 +51,6 @@
-
-
diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/VerifyTinyMCEv4IsNativeWYSIWYGOnCMSPageCest.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/VerifyTinyMCEv4IsNativeWYSIWYGOnCMSPageCest.xml
index cde0e5360e796..143e7d5c70eb2 100644
--- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/VerifyTinyMCEv4IsNativeWYSIWYGOnCMSPageCest.xml
+++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/VerifyTinyMCEv4IsNativeWYSIWYGOnCMSPageCest.xml
@@ -36,22 +36,8 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Section/BlockNewPageContentSection.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Section/BlockNewPageContentSection.xml
index 3053688a0c7b6..90c82a12a67da 100644
--- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Section/BlockNewPageContentSection.xml
+++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Section/BlockNewPageContentSection.xml
@@ -9,45 +9,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Section/CmsNewPagePageContentSection.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Section/CmsNewPagePageContentSection.xml
index 1d189754b2fdf..7b3b10b78ed6e 100644
--- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Section/CmsNewPagePageContentSection.xml
+++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Section/CmsNewPagePageContentSection.xml
@@ -56,57 +56,4 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Section/TinyMCESection.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Section/TinyMCESection.xml
index df8e2bee8ec05..398dbf3cfd668 100644
--- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Section/TinyMCESection.xml
+++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Section/TinyMCESection.xml
@@ -9,29 +9,16 @@
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -45,10 +32,78 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Newsletter/Cest/VerifyTinyMCEv4IsNativeWYSIWYGOnNewsletterCest.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Newsletter/Cest/VerifyTinyMCEv4IsNativeWYSIWYGOnNewsletterCest.xml
index c5cd17bd2c2f1..5f0d48d0ee2d6 100644
--- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Newsletter/Cest/VerifyTinyMCEv4IsNativeWYSIWYGOnNewsletterCest.xml
+++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Newsletter/Cest/VerifyTinyMCEv4IsNativeWYSIWYGOnNewsletterCest.xml
@@ -11,7 +11,7 @@
-
+
@@ -35,22 +35,8 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
From 6c24c0e765f93afcba74a0085362b7abd46f6665 Mon Sep 17 00:00:00 2001
From: Anton Evers
Date: Mon, 11 Dec 2017 13:11:02 +0100
Subject: [PATCH 278/904] Ranged selects always miss the last range
Fix unit test. 11 batches expected to handle 105 items:
1: 1-10
2: 11-20
3: 21-30
4: 31-40
5: 41-50
6: 51-60
7: 61-70
8: 71-80
9: 81-90
10: 91-100
11: 101-105
---
.../Magento/Framework/DB/Query/BatchRangeIterator.php | 4 ++--
.../Framework/Test/Unit/DB/Query/BatchRangeIteratorTest.php | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/lib/internal/Magento/Framework/DB/Query/BatchRangeIterator.php b/lib/internal/Magento/Framework/DB/Query/BatchRangeIterator.php
index 9871df1b16841..5176c85cfa702 100644
--- a/lib/internal/Magento/Framework/DB/Query/BatchRangeIterator.php
+++ b/lib/internal/Magento/Framework/DB/Query/BatchRangeIterator.php
@@ -113,7 +113,7 @@ public function __construct(
public function current()
{
if (null === $this->currentSelect) {
- $this->isValid = ($this->currentOffset + $this->batchSize) <= $this->totalItemCount;
+ $this->isValid = $this->currentOffset < $this->totalItemCount;
$this->currentSelect = $this->initSelectObject();
}
return $this->currentSelect;
@@ -144,7 +144,7 @@ public function next()
if (null === $this->currentSelect) {
$this->current();
}
- $this->isValid = ($this->batchSize + $this->currentOffset) <= $this->totalItemCount;
+ $this->isValid = $this->currentOffset < $this->totalItemCount;
$select = $this->initSelectObject();
if ($this->isValid) {
$this->iteration++;
diff --git a/lib/internal/Magento/Framework/Test/Unit/DB/Query/BatchRangeIteratorTest.php b/lib/internal/Magento/Framework/Test/Unit/DB/Query/BatchRangeIteratorTest.php
index 22fdf0a05686a..9e2014c1b070a 100644
--- a/lib/internal/Magento/Framework/Test/Unit/DB/Query/BatchRangeIteratorTest.php
+++ b/lib/internal/Magento/Framework/Test/Unit/DB/Query/BatchRangeIteratorTest.php
@@ -116,6 +116,6 @@ public function testIterations()
$iterations++;
}
- $this->assertEquals(10, $iterations);
+ $this->assertEquals(11, $iterations);
}
}
From 20f285b50fc8f75ec3961c78b5e5d0215c0014e3 Mon Sep 17 00:00:00 2001
From: Sergii Kovalenko
Date: Thu, 11 Jan 2018 11:56:08 +0200
Subject: [PATCH 279/904] MAGETWO-85326: Tool for generating schema
--working on EE stuff
---
schema_patches/Logging_and_wishlist.patch | 32 ++++++++++++++
schema_patches/url_rewrite_foreign.patch | 31 +++++++++++++
.../Model/Declaration/Schema/Diff/Diff.php | 8 ++++
.../Declaration/Schema/Diff/TableDiff.php | 43 +++++++++++++++----
.../Magento/Setup/Model/SchemaListener.php | 3 +-
5 files changed, 107 insertions(+), 10 deletions(-)
create mode 100644 schema_patches/Logging_and_wishlist.patch
create mode 100644 schema_patches/url_rewrite_foreign.patch
diff --git a/schema_patches/Logging_and_wishlist.patch b/schema_patches/Logging_and_wishlist.patch
new file mode 100644
index 0000000000000..eea7343a98149
--- /dev/null
+++ b/schema_patches/Logging_and_wishlist.patch
@@ -0,0 +1,32 @@
+Index: app/code/Magento/MultipleWishlist/etc/db_schema.xml
+IDEA additional info:
+Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
+<+>UTF-8
+===================================================================
+--- app/code/Magento/MultipleWishlist/etc/db_schema.xml (revision 02cd38c50a54ff230630522550fab2687f2a0c01)
++++ app/code/Magento/MultipleWishlist/etc/db_schema.xml (revision )
+@@ -4,7 +4,7 @@
+
+
+
+-
++
+
+
+
+Index: app/code/Magento/Logging/etc/db_schema.xml
+IDEA additional info:
+Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
+<+>UTF-8
+===================================================================
+--- app/code/Magento/Logging/etc/db_schema.xml (revision 02cd38c50a54ff230630522550fab2687f2a0c01)
++++ app/code/Magento/Logging/etc/db_schema.xml (revision )
+@@ -7,7 +7,7 @@
+
+
+
+-
++
+
+
+
diff --git a/schema_patches/url_rewrite_foreign.patch b/schema_patches/url_rewrite_foreign.patch
new file mode 100644
index 0000000000000..c125b3ac02c59
--- /dev/null
+++ b/schema_patches/url_rewrite_foreign.patch
@@ -0,0 +1,31 @@
+Index: app/code/Magento/SalesArchive/etc/db_schema.xml
+IDEA additional info:
+Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
+<+>UTF-8
+===================================================================
+--- app/code/Magento/SalesArchive/etc/db_schema.xml (revision b2f86eab0b9e9a9ed553d192af0a974734acecba)
++++ app/code/Magento/SalesArchive/etc/db_schema.xml (revision )
+@@ -233,7 +233,7 @@
+
+
+
+-
++
+
+
+
+Index: app/code/Magento/CatalogUrlRewriteStaging/etc/db_schema.xml
+IDEA additional info:
+Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
+<+>UTF-8
+===================================================================
+--- app/code/Magento/CatalogUrlRewriteStaging/etc/db_schema.xml (revision b2f86eab0b9e9a9ed553d192af0a974734acecba)
++++ app/code/Magento/CatalogUrlRewriteStaging/etc/db_schema.xml (revision )
+@@ -3,6 +3,7 @@
+
+
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/Diff.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/Diff.php
index 3b606c8f0ad63..e79af631dcb66 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/Diff.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/Diff.php
@@ -26,6 +26,13 @@ class Diff implements DiffInterface
*/
private $changes;
+ /**
+ * This changes created only for debug reasons
+ *
+ * @var array
+ */
+ public $debugChanges;
+
/**
* @var array
*/
@@ -139,6 +146,7 @@ public function register(ElementInterface $dtoObject, $operation, ElementInterfa
$dtoObject->getTable()->getName() : $dtoObject->getName();
//dtoObjects can have 4 types: column, constraint, index, table
$this->changes[$dtoObjectName][$operation][] = $history;
+ $this->debugChanges[$operation][] = $history;
return $this;
}
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/TableDiff.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/TableDiff.php
index e59ad30dfa29d..6c43c7696f54e 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/TableDiff.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/TableDiff.php
@@ -6,6 +6,8 @@
namespace Magento\Setup\Model\Declaration\Schema\Diff;
+use Magento\Setup\Model\Declaration\Schema\Dto\Constraint;
+use Magento\Setup\Model\Declaration\Schema\Dto\Constraints\Reference;
use Magento\Setup\Model\Declaration\Schema\Dto\ElementInterface;
use Magento\Setup\Model\Declaration\Schema\Dto\Index;
use Magento\Setup\Model\Declaration\Schema\Dto\Table;
@@ -59,13 +61,32 @@ public function __construct(DiffManager $diffManager)
*/
private function excludeAutoIndexes(Table $table, array $indexes)
{
- foreach ($table->getReferenceConstraints() as $constraint) {
- unset($indexes[$constraint->getName()]);
+ foreach ($this->preprocessConstraintsAndIndexes($table->getReferenceConstraints()) as $name => $constraint) {
+ $name = str_replace("fk_", 'index', $name);
+ unset($indexes[$name]);
}
return $indexes;
}
+ /**
+ * @param array $elements
+ * @return array
+ */
+ private function preprocessConstraintsAndIndexes(array $elements)
+ {
+ foreach ($elements as $name => $element) {
+ $newName = $name;
+ if (($element instanceof Index || $element instanceof Constraint) && !$element instanceof Reference) {
+ $newName = $element->getElementType() . implode("_", $element->getColumnNames());
+ }
+
+ unset($elements[$name]);
+ $elements[$newName] = $element;
+ }
+ return $elements;
+ }
+
/**
* @param Table | ElementInterface $declaredTable
* @param Table | ElementInterface $generatedTable
@@ -89,28 +110,32 @@ public function diff(
$types = [self::COLUMN_DIFF_TYPE, self::CONSTRAINT_DIFF_TYPE, self::INDEX_DIFF_TYPE];
//We do inspection for each element type
foreach ($types as $elementType) {
- $generatedElements = $generatedTable->getElementsByType($elementType);
- $declaredElements = $declaredTable->getElementsByType($elementType);
+ $generatedElements = $this->preprocessConstraintsAndIndexes(
+ $generatedTable->getElementsByType($elementType)
+ );
+ $declaredElements = $this->preprocessConstraintsAndIndexes(
+ $declaredTable->getElementsByType($elementType)
+ );
if ($elementType === self::INDEX_DIFF_TYPE) {
$generatedElements = $this->excludeAutoIndexes($generatedTable, $generatedElements);
}
- foreach ($declaredElements as $element) {
+ foreach ($declaredElements as $elementName => $element) {
//If it is new for generated (generated from db) elements - we need to create it
- if ($this->diffManager->shouldBeCreated($generatedElements, $element)) {
+ if (!isset($generatedElements[$elementName])) {
$diff = $this->diffManager->registerCreation($diff, $element);
} elseif ($this->diffManager->shouldBeModified(
$element,
- $generatedElements[$element->getName()]
+ $generatedElements[$elementName]
)
) {
$diff = $this->diffManager
- ->registerModification($diff, $element, $generatedElements[$element->getName()]);
+ ->registerModification($diff, $element, $generatedElements[$elementName]);
}
//Unset processed elements from generated from db schema
//All other unprocessed elements will be added as removed ones
- unset($generatedElements[$element->getName()]);
+ unset($generatedElements[$elementName]);
}
//Elements that should be removed
diff --git a/setup/src/Magento/Setup/Model/SchemaListener.php b/setup/src/Magento/Setup/Model/SchemaListener.php
index 2ce7a421cb22f..123e3acc226dc 100644
--- a/setup/src/Magento/Setup/Model/SchemaListener.php
+++ b/setup/src/Magento/Setup/Model/SchemaListener.php
@@ -121,7 +121,8 @@ private function castColumnDefinition($definition, $columnName)
}
$definition = $this->doColumnMapping($definition);
$definition['name'] = strtolower($columnName);
- $definition = $this->definitionMappers[$definition['type']]->convertToDefinition($definition);
+ $definitionType = $definition['type'] === 'int' ? 'integer' : $definition['type'];
+ $definition = $this->definitionMappers[$definitionType]->convertToDefinition($definition);
if (isset($definition['default']) && $definition['default'] === false) {
$definition['default'] = null; //uniform default values
}
From f0358bddde42a981fc807f9bccb10d8701489787 Mon Sep 17 00:00:00 2001
From: Dan Mooney
Date: Thu, 11 Jan 2018 08:24:47 -0600
Subject: [PATCH 280/904] MAGETWO-86141: Disable/Enable TinyMCE Not Working
Remove eslint-disable and use underscore's _.isUndefined
---
app/code/Magento/Ui/view/base/web/js/form/element/wysiwyg.js | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/app/code/Magento/Ui/view/base/web/js/form/element/wysiwyg.js b/app/code/Magento/Ui/view/base/web/js/form/element/wysiwyg.js
index 713edc393470b..c6dd3e5f7c0bd 100644
--- a/app/code/Magento/Ui/view/base/web/js/form/element/wysiwyg.js
+++ b/app/code/Magento/Ui/view/base/web/js/form/element/wysiwyg.js
@@ -96,8 +96,7 @@ define([
this.$wysiwygEditorButton.attr('disabled', disabled);
}
- /* eslint-disable no-undef */
- if (typeof wysiwyg !== 'undefined') {
+ if (!_.isUndefined(wysiwyg)) {
if (disabled) {
wysiwyg.setToolbarStatus(false);
wysiwyg.getPluginButtons().attr('disabled', 'disabled');
From 37640341be562ce7160afaca0afb68aaa58c8c31 Mon Sep 17 00:00:00 2001
From: Dan Mooney
Date: Thu, 11 Jan 2018 08:25:16 -0600
Subject: [PATCH 281/904] MAGETWO-86141: Disable/Enable TinyMCE Not Working
Remove stray redundant eslint-enable
---
app/code/Magento/Ui/view/base/web/js/form/element/wysiwyg.js | 1 -
1 file changed, 1 deletion(-)
diff --git a/app/code/Magento/Ui/view/base/web/js/form/element/wysiwyg.js b/app/code/Magento/Ui/view/base/web/js/form/element/wysiwyg.js
index c6dd3e5f7c0bd..050334e43e466 100644
--- a/app/code/Magento/Ui/view/base/web/js/form/element/wysiwyg.js
+++ b/app/code/Magento/Ui/view/base/web/js/form/element/wysiwyg.js
@@ -107,7 +107,6 @@ define([
wysiwyg.getTextArea().removeAttr('disabled');
}
}
- /* eslint-enable no-undef*/
}
});
});
\ No newline at end of file
From 66af1121c5e3530a897ac389fa98d233f81e3e6e Mon Sep 17 00:00:00 2001
From: Sergii Kovalenko
Date: Thu, 11 Jan 2018 16:48:44 +0200
Subject: [PATCH 282/904] MAGETWO-85326: Tool for generating schema
--working on CE stuff
---
.../AdminNotification/etc/db_schema.xml | 67 +-
.../Magento/Authorization/etc/db_schema.xml | 88 +-
app/code/Magento/Bundle/etc/db_schema.xml | 201 +-
app/code/Magento/Captcha/etc/db_schema.xml | 23 +-
.../Magento/Catalog/Setup/UpgradeSchema.php | 12 +-
app/code/Magento/Catalog/etc/db_schema.xml | 2862 +++++++-------
.../CatalogInventory/Setup/UpgradeSchema.php | 14 +-
.../CatalogInventory/etc/db_schema.xml | 273 +-
.../CatalogRule/Setup/UpgradeSchema.php | 12 +-
.../Magento/CatalogRule/etc/db_schema.xml | 398 +-
.../Magento/CatalogSearch/etc/db_schema.xml | 18 +-
.../CatalogUrlRewrite/etc/db_schema.xml | 20 +-
.../CheckoutAgreements/etc/db_schema.xml | 56 +-
app/code/Magento/Cms/etc/db_schema.xml | 166 +-
app/code/Magento/Config/etc/db_schema.xml | 34 +-
.../ConfigurableProduct/etc/db_schema.xml | 123 +-
app/code/Magento/Cron/etc/db_schema.xml | 43 +-
app/code/Magento/Customer/etc/db_schema.xml | 938 +++--
app/code/Magento/Directory/etc/db_schema.xml | 123 +-
.../Magento/Downloadable/etc/db_schema.xml | 398 +-
app/code/Magento/Eav/etc/db_schema.xml | 1008 +++--
app/code/Magento/Email/etc/db_schema.xml | 55 +-
.../Magento/GiftMessage/etc/db_schema.xml | 63 +-
.../Magento/GoogleOptimizer/etc/db_schema.xml | 36 +-
.../Magento/ImportExport/etc/db_schema.xml | 46 +-
app/code/Magento/Indexer/etc/db_schema.xml | 63 +-
.../Magento/Integration/etc/db_schema.xml | 212 +-
.../NewRelicReporting/etc/db_schema.xml | 101 +-
app/code/Magento/Newsletter/etc/db_schema.xml | 257 +-
.../Magento/OfflineShipping/etc/db_schema.xml | 85 +-
app/code/Magento/Paypal/etc/db_schema.xml | 238 +-
app/code/Magento/Persistent/etc/db_schema.xml | 59 +-
.../Magento/ProductAlert/etc/db_schema.xml | 128 +-
.../Magento/ProductVideo/etc/db_schema.xml | 39 +-
.../Magento/Quote/Setup/InstallSchema.php | 32 +-
app/code/Magento/Quote/Setup/QuoteSetup.php | 1 +
app/code/Magento/Quote/etc/db_schema.xml | 782 ++--
app/code/Magento/Reports/etc/db_schema.xml | 398 +-
app/code/Magento/Review/etc/db_schema.xml | 452 +--
.../Magento/Sales/Setup/InstallSchema.php | 144 +-
app/code/Magento/Sales/Setup/SalesSetup.php | 1 +
app/code/Magento/Sales/etc/db_schema.xml | 3326 +++++++----------
app/code/Magento/SalesRule/etc/db_schema.xml | 576 ++-
.../Magento/SalesSequence/etc/db_schema.xml | 72 +-
app/code/Magento/Search/etc/db_schema.xml | 123 +-
app/code/Magento/Security/etc/db_schema.xml | 75 +-
app/code/Magento/SendFriend/etc/db_schema.xml | 34 +-
app/code/Magento/Sitemap/etc/db_schema.xml | 35 +-
app/code/Magento/Store/etc/db_schema.xml | 152 +-
app/code/Magento/Swatches/etc/db_schema.xml | 51 +-
app/code/Magento/Tax/etc/db_schema.xml | 329 +-
app/code/Magento/Theme/etc/db_schema.xml | 111 +-
.../Magento/Translation/etc/db_schema.xml | 42 +-
app/code/Magento/Ui/etc/db_schema.xml | 44 +-
app/code/Magento/UrlRewrite/etc/db_schema.xml | 57 +-
app/code/Magento/User/etc/db_schema.xml | 93 +-
app/code/Magento/Variable/etc/db_schema.xml | 67 +-
app/code/Magento/Vault/etc/db_schema.xml | 79 +-
app/code/Magento/Weee/etc/db_schema.xml | 190 +-
app/code/Magento/Widget/etc/db_schema.xml | 201 +-
app/code/Magento/Wishlist/etc/db_schema.xml | 119 +-
clean_db_schemas.php | 2 +-
.../Framework/App/ResourceConnection.php | 14 +-
.../Framework/DB/Adapter/Pdo/Mysql.php | 4 +
.../Magento/Framework/Module/Setup.php | 19 +-
...tch => key_catalog_category_product.patch} | 0
.../Declaration/Schema/Config/Converter.php | 2 +-
.../Schema/Declaration/SchemaBuilder.php | 2 +-
.../Declaration/Schema/Diff/TableDiff.php | 6 +-
.../Model/Declaration/Schema/Dto/Table.php | 2 +-
.../Model/Declaration/Schema/etc/schema.xsd | 2 +-
setup/src/Magento/Setup/Model/Installer.php | 6 +-
.../Magento/Setup/Model/SchemaListener.php | 15 +
.../DecimalDefinition.php | 26 +-
.../IntegerDefinition.php | 10 +-
.../Magento/Setup/Model/SchemaPersistor.php | 4 +-
76 files changed, 7245 insertions(+), 8714 deletions(-)
rename schema_patches/{MAGETWO_85326__Tool_for_generating_schema____working_on_EE_stuff.patch => key_catalog_category_product.patch} (100%)
diff --git a/app/code/Magento/AdminNotification/etc/db_schema.xml b/app/code/Magento/AdminNotification/etc/db_schema.xml
index 8d8bff59b635b..d9e08fdb40620 100644
--- a/app/code/Magento/AdminNotification/etc/db_schema.xml
+++ b/app/code/Magento/AdminNotification/etc/db_schema.xml
@@ -1,38 +1,33 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Authorization/etc/db_schema.xml b/app/code/Magento/Authorization/etc/db_schema.xml
index cb8fd331b47ea..0750e0c68dabb 100644
--- a/app/code/Magento/Authorization/etc/db_schema.xml
+++ b/app/code/Magento/Authorization/etc/db_schema.xml
@@ -1,50 +1,42 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Bundle/etc/db_schema.xml b/app/code/Magento/Bundle/etc/db_schema.xml
index 7c455d82742e2..c9b873fe5fbc8 100644
--- a/app/code/Magento/Bundle/etc/db_schema.xml
+++ b/app/code/Magento/Bundle/etc/db_schema.xml
@@ -1,10 +1,10 @@
-
-
-
-
+
+
+
+
@@ -15,11 +15,11 @@
-
-
-
+
+
+
-
+
@@ -33,17 +33,18 @@
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
-
+
@@ -58,12 +59,12 @@
-
-
-
+
+
+
-
-
+
+
@@ -74,16 +75,17 @@
+
-
-
-
-
-
+
+
+
+
+
@@ -100,10 +102,10 @@
-
-
-
-
+
+
+
+
@@ -113,19 +115,19 @@
-
+
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
@@ -133,19 +135,19 @@
-
+
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
@@ -153,15 +155,15 @@
-
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
@@ -171,15 +173,15 @@
-
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
@@ -189,15 +191,15 @@
-
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
@@ -206,15 +208,15 @@
-
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
@@ -223,10 +225,10 @@
-
-
-
-
+
+
+
+
@@ -237,23 +239,4 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/app/code/Magento/Captcha/etc/db_schema.xml b/app/code/Magento/Captcha/etc/db_schema.xml
index 310f47c6fa9c6..ab1e977f27beb 100644
--- a/app/code/Magento/Captcha/etc/db_schema.xml
+++ b/app/code/Magento/Captcha/etc/db_schema.xml
@@ -1,14 +1,13 @@
-
-
+
+
diff --git a/app/code/Magento/Catalog/Setup/UpgradeSchema.php b/app/code/Magento/Catalog/Setup/UpgradeSchema.php
index d08108d1fc22b..2f4417ac72c94 100755
--- a/app/code/Magento/Catalog/Setup/UpgradeSchema.php
+++ b/app/code/Magento/Catalog/Setup/UpgradeSchema.php
@@ -8,10 +8,10 @@
use Magento\Catalog\Model\Product\Attribute\Backend\Media\ImageEntryConverter;
use Magento\Catalog\Model\ResourceModel\Product\Gallery;
+use Magento\Framework\DB\Ddl\Table;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\SchemaSetupInterface;
use Magento\Framework\Setup\UpgradeSchemaInterface;
-use Magento\Framework\DB\Ddl\Table;
/**
* Upgrade the Catalog module DB scheme
@@ -698,12 +698,10 @@ private function addPathKeyToCategoryEntityTableIfNotExists(SchemaSetupInterface
*/
private function addReplicaTable(SchemaSetupInterface $setup, $existingTable, $replicaTable)
{
- $sql = sprintf(
- 'CREATE TABLE IF NOT EXISTS %s LIKE %s',
- $setup->getConnection()->quoteIdentifier($setup->getTable($replicaTable)),
- $setup->getConnection()->quoteIdentifier($setup->getTable($existingTable))
- );
- $setup->getConnection()->query($sql);
+ $table = $setup->getConnection()
+ ->createTableByDdl($existingTable, $replicaTable);
+ $setup->getConnection()
+ ->createTable($table);
}
/**
diff --git a/app/code/Magento/Catalog/etc/db_schema.xml b/app/code/Magento/Catalog/etc/db_schema.xml
index 3d25559ae2013..d0d169e241091 100644
--- a/app/code/Magento/Catalog/etc/db_schema.xml
+++ b/app/code/Magento/Catalog/etc/db_schema.xml
@@ -1,1557 +1,1309 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/CatalogInventory/Setup/UpgradeSchema.php b/app/code/Magento/CatalogInventory/Setup/UpgradeSchema.php
index e8f6de22cbfc8..6da0f013b55f7 100644
--- a/app/code/Magento/CatalogInventory/Setup/UpgradeSchema.php
+++ b/app/code/Magento/CatalogInventory/Setup/UpgradeSchema.php
@@ -6,10 +6,10 @@
namespace Magento\CatalogInventory\Setup;
-use Magento\Framework\Setup\UpgradeSchemaInterface;
+use Magento\CatalogInventory\Model\Stock\Item as StockItem;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\SchemaSetupInterface;
-use Magento\CatalogInventory\Model\Stock\Item as StockItem;
+use Magento\Framework\Setup\UpgradeSchemaInterface;
class UpgradeSchema implements UpgradeSchemaInterface
{
@@ -157,11 +157,9 @@ private function addCatalogInventoryStockStatusIndexOnStockStatus(SchemaSetupInt
*/
private function addReplicaTable(SchemaSetupInterface $setup, $existingTable, $replicaTable)
{
- $sql = sprintf(
- 'CREATE TABLE IF NOT EXISTS %s LIKE %s',
- $setup->getConnection()->quoteIdentifier($setup->getTable($replicaTable)),
- $setup->getConnection()->quoteIdentifier($setup->getTable($existingTable))
- );
- $setup->getConnection()->query($sql);
+ $table = $setup->getConnection()
+ ->createTableByDdl($existingTable, $replicaTable);
+ $setup->getConnection()
+ ->createTable($table);
}
}
diff --git a/app/code/Magento/CatalogInventory/etc/db_schema.xml b/app/code/Magento/CatalogInventory/etc/db_schema.xml
index f2df994f117e1..42eebceb117ef 100644
--- a/app/code/Magento/CatalogInventory/etc/db_schema.xml
+++ b/app/code/Magento/CatalogInventory/etc/db_schema.xml
@@ -1,142 +1,135 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/CatalogRule/Setup/UpgradeSchema.php b/app/code/Magento/CatalogRule/Setup/UpgradeSchema.php
index b75e5ea61fe6e..3be0b256e0a01 100644
--- a/app/code/Magento/CatalogRule/Setup/UpgradeSchema.php
+++ b/app/code/Magento/CatalogRule/Setup/UpgradeSchema.php
@@ -6,9 +6,9 @@
namespace Magento\CatalogRule\Setup;
-use Magento\Framework\Setup\UpgradeSchemaInterface;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\SchemaSetupInterface;
+use Magento\Framework\Setup\UpgradeSchemaInterface;
/**
* Upgrade the CatalogRule module DB scheme
@@ -105,11 +105,9 @@ private function removeSubProductDiscounts(SchemaSetupInterface $setup)
*/
private function addReplicaTable(SchemaSetupInterface $setup, $existingTable, $replicaTable)
{
- $sql = sprintf(
- 'CREATE TABLE IF NOT EXISTS %s LIKE %s',
- $setup->getTable($replicaTable),
- $setup->getTable($existingTable)
- );
- $setup->getConnection()->query($sql);
+ $table = $setup->getConnection()
+ ->createTableByDdl($existingTable, $replicaTable);
+ $setup->getConnection()
+ ->createTable($table);
}
}
diff --git a/app/code/Magento/CatalogRule/etc/db_schema.xml b/app/code/Magento/CatalogRule/etc/db_schema.xml
index 7deba44776d17..e5b58f473eea3 100644
--- a/app/code/Magento/CatalogRule/etc/db_schema.xml
+++ b/app/code/Magento/CatalogRule/etc/db_schema.xml
@@ -1,174 +1,228 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/CatalogSearch/etc/db_schema.xml b/app/code/Magento/CatalogSearch/etc/db_schema.xml
index 81642b8de50ca..98ce5df670c7e 100644
--- a/app/code/Magento/CatalogSearch/etc/db_schema.xml
+++ b/app/code/Magento/CatalogSearch/etc/db_schema.xml
@@ -3,21 +3,9 @@
-
-
-
-
+
+
+
diff --git a/app/code/Magento/CatalogUrlRewrite/etc/db_schema.xml b/app/code/Magento/CatalogUrlRewrite/etc/db_schema.xml
index 3cb765c66ba23..2d20893ada620 100644
--- a/app/code/Magento/CatalogUrlRewrite/etc/db_schema.xml
+++ b/app/code/Magento/CatalogUrlRewrite/etc/db_schema.xml
@@ -1,19 +1,11 @@
-
+
-
-
-
-
-
-
+
+
+
+
+
diff --git a/app/code/Magento/CheckoutAgreements/etc/db_schema.xml b/app/code/Magento/CheckoutAgreements/etc/db_schema.xml
index 5b732c47cc06f..bd7f40f817d2a 100644
--- a/app/code/Magento/CheckoutAgreements/etc/db_schema.xml
+++ b/app/code/Magento/CheckoutAgreements/etc/db_schema.xml
@@ -1,34 +1,26 @@
-
-
-
+
+
+
diff --git a/app/code/Magento/Cms/etc/db_schema.xml b/app/code/Magento/Cms/etc/db_schema.xml
index c73aa2c546635..df796fe13ab62 100644
--- a/app/code/Magento/Cms/etc/db_schema.xml
+++ b/app/code/Magento/Cms/etc/db_schema.xml
@@ -1,90 +1,80 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Config/etc/db_schema.xml b/app/code/Magento/Config/etc/db_schema.xml
index 6d6216bc8abe2..33be11f0e6a86 100644
--- a/app/code/Magento/Config/etc/db_schema.xml
+++ b/app/code/Magento/Config/etc/db_schema.xml
@@ -1,20 +1,18 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/ConfigurableProduct/etc/db_schema.xml b/app/code/Magento/ConfigurableProduct/etc/db_schema.xml
index 2cbc77e488f23..eb2316e01e94e 100644
--- a/app/code/Magento/ConfigurableProduct/etc/db_schema.xml
+++ b/app/code/Magento/ConfigurableProduct/etc/db_schema.xml
@@ -1,74 +1,53 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Cron/etc/db_schema.xml b/app/code/Magento/Cron/etc/db_schema.xml
index f88422c2159c5..b5e59187fa125 100644
--- a/app/code/Magento/Cron/etc/db_schema.xml
+++ b/app/code/Magento/Cron/etc/db_schema.xml
@@ -1,24 +1,23 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Customer/etc/db_schema.xml b/app/code/Magento/Customer/etc/db_schema.xml
index cd54263b5ebe4..4e9c288fcd431 100644
--- a/app/code/Magento/Customer/etc/db_schema.xml
+++ b/app/code/Magento/Customer/etc/db_schema.xml
@@ -1,485 +1,457 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Directory/etc/db_schema.xml b/app/code/Magento/Directory/etc/db_schema.xml
index 4254682d0a48f..8247c51d25b02 100644
--- a/app/code/Magento/Directory/etc/db_schema.xml
+++ b/app/code/Magento/Directory/etc/db_schema.xml
@@ -1,66 +1,61 @@
-
-
-
-
-
-
+
+
+
+
+
+
diff --git a/app/code/Magento/Downloadable/etc/db_schema.xml b/app/code/Magento/Downloadable/etc/db_schema.xml
index 03058faf0467d..74477257eaa6b 100644
--- a/app/code/Magento/Downloadable/etc/db_schema.xml
+++ b/app/code/Magento/Downloadable/etc/db_schema.xml
@@ -1,228 +1,174 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Eav/etc/db_schema.xml b/app/code/Magento/Eav/etc/db_schema.xml
index 101940ce440db..77bc4cae89b68 100644
--- a/app/code/Magento/Eav/etc/db_schema.xml
+++ b/app/code/Magento/Eav/etc/db_schema.xml
@@ -1,568 +1,444 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Email/etc/db_schema.xml b/app/code/Magento/Email/etc/db_schema.xml
index 8fa43963bc0cd..8aab030ca5907 100644
--- a/app/code/Magento/Email/etc/db_schema.xml
+++ b/app/code/Magento/Email/etc/db_schema.xml
@@ -1,30 +1,29 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/GiftMessage/etc/db_schema.xml b/app/code/Magento/GiftMessage/etc/db_schema.xml
index 4103bb4024f5f..e90791e278cfd 100644
--- a/app/code/Magento/GiftMessage/etc/db_schema.xml
+++ b/app/code/Magento/GiftMessage/etc/db_schema.xml
@@ -1,35 +1,32 @@
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/GoogleOptimizer/etc/db_schema.xml b/app/code/Magento/GoogleOptimizer/etc/db_schema.xml
index 7f6b3783919e7..ac527b6501845 100644
--- a/app/code/Magento/GoogleOptimizer/etc/db_schema.xml
+++ b/app/code/Magento/GoogleOptimizer/etc/db_schema.xml
@@ -1,21 +1,19 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/ImportExport/etc/db_schema.xml b/app/code/Magento/ImportExport/etc/db_schema.xml
index a9f6ae4933b19..96103651bc5e8 100644
--- a/app/code/Magento/ImportExport/etc/db_schema.xml
+++ b/app/code/Magento/ImportExport/etc/db_schema.xml
@@ -1,26 +1,24 @@
-
-
-
+
+
+
diff --git a/app/code/Magento/Indexer/etc/db_schema.xml b/app/code/Magento/Indexer/etc/db_schema.xml
index 5e59dfda6b71c..dec7ed56c59a3 100644
--- a/app/code/Magento/Indexer/etc/db_schema.xml
+++ b/app/code/Magento/Indexer/etc/db_schema.xml
@@ -1,34 +1,33 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Integration/etc/db_schema.xml b/app/code/Magento/Integration/etc/db_schema.xml
index 24e41c88cc519..f640dddc4bbbf 100644
--- a/app/code/Magento/Integration/etc/db_schema.xml
+++ b/app/code/Magento/Integration/etc/db_schema.xml
@@ -1,115 +1,101 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/NewRelicReporting/etc/db_schema.xml b/app/code/Magento/NewRelicReporting/etc/db_schema.xml
index 53ae04d48ebf5..4eafba07f7cd1 100644
--- a/app/code/Magento/NewRelicReporting/etc/db_schema.xml
+++ b/app/code/Magento/NewRelicReporting/etc/db_schema.xml
@@ -1,53 +1,52 @@
-
-
-
-
-
-
+
+
+
+
+
+
diff --git a/app/code/Magento/Newsletter/etc/db_schema.xml b/app/code/Magento/Newsletter/etc/db_schema.xml
index 0d98d813b9cf0..d5163af7f36d8 100644
--- a/app/code/Magento/Newsletter/etc/db_schema.xml
+++ b/app/code/Magento/Newsletter/etc/db_schema.xml
@@ -1,145 +1,116 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/OfflineShipping/etc/db_schema.xml b/app/code/Magento/OfflineShipping/etc/db_schema.xml
index 7c64f5c5fa15c..e94ba084bc366 100644
--- a/app/code/Magento/OfflineShipping/etc/db_schema.xml
+++ b/app/code/Magento/OfflineShipping/etc/db_schema.xml
@@ -1,49 +1,40 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Paypal/etc/db_schema.xml b/app/code/Magento/Paypal/etc/db_schema.xml
index 86ccf5e125b2e..7738250101656 100644
--- a/app/code/Magento/Paypal/etc/db_schema.xml
+++ b/app/code/Magento/Paypal/etc/db_schema.xml
@@ -1,129 +1,113 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Persistent/etc/db_schema.xml b/app/code/Magento/Persistent/etc/db_schema.xml
index e0f410fab543e..b6eef4a92075c 100644
--- a/app/code/Magento/Persistent/etc/db_schema.xml
+++ b/app/code/Magento/Persistent/etc/db_schema.xml
@@ -1,35 +1,28 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/ProductAlert/etc/db_schema.xml b/app/code/Magento/ProductAlert/etc/db_schema.xml
index 17190f22ae341..0074618cff584 100644
--- a/app/code/Magento/ProductAlert/etc/db_schema.xml
+++ b/app/code/Magento/ProductAlert/etc/db_schema.xml
@@ -1,78 +1,54 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/ProductVideo/etc/db_schema.xml b/app/code/Magento/ProductVideo/etc/db_schema.xml
index ffad24fab7fcb..af84348cb2487 100644
--- a/app/code/Magento/ProductVideo/etc/db_schema.xml
+++ b/app/code/Magento/ProductVideo/etc/db_schema.xml
@@ -1,25 +1,18 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Quote/Setup/InstallSchema.php b/app/code/Magento/Quote/Setup/InstallSchema.php
index bbf7e670da0b4..155423d5e143f 100644
--- a/app/code/Magento/Quote/Setup/InstallSchema.php
+++ b/app/code/Magento/Quote/Setup/InstallSchema.php
@@ -27,7 +27,7 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
/**
* Create table 'quote'
*/
- $table = $installer->getConnection()->newTable(
+ $table = $installer->getConnection('quote')->newTable(
$installer->getTable('quote')
)->addColumn(
'entity_id',
@@ -338,12 +338,12 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
)->setComment(
'Sales Flat Quote'
);
- $installer->getConnection()->createTable($table);
+ $installer->getConnection('quote')->createTable($table);
/**
* Create table 'quote_address'
*/
- $table = $installer->getConnection()->newTable(
+ $table = $installer->getConnection('quote')->newTable(
$installer->getTable('quote_address')
)->addColumn(
'address_id',
@@ -687,12 +687,12 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
)->setComment(
'Sales Flat Quote Address'
);
- $installer->getConnection()->createTable($table);
+ $installer->getConnection('quote')->createTable($table);
/**
* Create table 'quote_item'
*/
- $table = $installer->getConnection()->newTable(
+ $table = $installer->getConnection('quote')->newTable(
$installer->getTable('quote_item')
)->addColumn(
'item_id',
@@ -979,12 +979,12 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
)->setComment(
'Sales Flat Quote Item'
);
- $installer->getConnection()->createTable($table);
+ $installer->getConnection('quote')->createTable($table);
/**
* Create table 'quote_address_item'
*/
- $table = $installer->getConnection()->newTable(
+ $table = $installer->getConnection('quote')->newTable(
$installer->getTable('quote_address_item')
)->addColumn(
'address_item_id',
@@ -1254,12 +1254,12 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
)->setComment(
'Sales Flat Quote Address Item'
);
- $installer->getConnection()->createTable($table);
+ $installer->getConnection('quote')->createTable($table);
/**
* Create table 'quote_item_option'
*/
- $table = $installer->getConnection()->newTable(
+ $table = $installer->getConnection('quote')->newTable(
$installer->getTable('quote_item_option')
)->addColumn(
'option_id',
@@ -1303,12 +1303,12 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
)->setComment(
'Sales Flat Quote Item Option'
);
- $installer->getConnection()->createTable($table);
+ $installer->getConnection('quote')->createTable($table);
/**
* Create table 'quote_payment'
*/
- $table = $installer->getConnection()->newTable(
+ $table = $installer->getConnection('quote')->newTable(
$installer->getTable('quote_payment')
)->addColumn(
'payment_id',
@@ -1436,12 +1436,12 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
)->setComment(
'Sales Flat Quote Payment'
);
- $installer->getConnection()->createTable($table);
+ $installer->getConnection('quote')->createTable($table);
/**
* Create table 'quote_shipping_rate'
*/
- $table = $installer->getConnection()->newTable(
+ $table = $installer->getConnection('quote')->newTable(
$installer->getTable('quote_shipping_rate')
)->addColumn(
'rate_id',
@@ -1527,12 +1527,12 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
)->setComment(
'Sales Flat Quote Shipping Rate'
);
- $installer->getConnection()->createTable($table);
+ $installer->getConnection('quote')->createTable($table);
/**
* Create table to store cartId and obscured UUID based cartId mapping
*/
- $table = $installer->getConnection()->newTable(
+ $table = $installer->getConnection('quote')->newTable(
$installer->getTable('quote_id_mask')
)->addColumn(
'entity_id',
@@ -1565,7 +1565,7 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
'Quote ID and masked ID mapping'
);
- $installer->getConnection()->createTable($table);
+ $installer->getConnection('quote')->createTable($table);
$installer->endSetup();
}
diff --git a/app/code/Magento/Quote/Setup/QuoteSetup.php b/app/code/Magento/Quote/Setup/QuoteSetup.php
index 3b9faa76dfc6a..7937235232c08 100644
--- a/app/code/Magento/Quote/Setup/QuoteSetup.php
+++ b/app/code/Magento/Quote/Setup/QuoteSetup.php
@@ -207,6 +207,7 @@ public function getConnection()
$setup = $this->getSetup();
/** @var SchemaListener $schemaListener */
$schemaListener = $setup->getConnection()->getSchemaListener();
+ $schemaListener->setResource('checkout');
$newConnection = $this->getSetup()->getConnection(self::$connectionName);
$newConnection->setSchemaListener($schemaListener);
return $newConnection;
diff --git a/app/code/Magento/Quote/etc/db_schema.xml b/app/code/Magento/Quote/etc/db_schema.xml
index d82f9632fdf30..d5d75d02df453 100644
--- a/app/code/Magento/Quote/etc/db_schema.xml
+++ b/app/code/Magento/Quote/etc/db_schema.xml
@@ -1,455 +1,331 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Reports/etc/db_schema.xml b/app/code/Magento/Reports/etc/db_schema.xml
index f54d8104f8a18..3550075796ea7 100644
--- a/app/code/Magento/Reports/etc/db_schema.xml
+++ b/app/code/Magento/Reports/etc/db_schema.xml
@@ -1,222 +1,180 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Review/etc/db_schema.xml b/app/code/Magento/Review/etc/db_schema.xml
index 470bdb38dd165..1d2803c7b92b4 100644
--- a/app/code/Magento/Review/etc/db_schema.xml
+++ b/app/code/Magento/Review/etc/db_schema.xml
@@ -1,257 +1,199 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Sales/Setup/InstallSchema.php b/app/code/Magento/Sales/Setup/InstallSchema.php
index 3c1da7add06ec..3554732282698 100644
--- a/app/code/Magento/Sales/Setup/InstallSchema.php
+++ b/app/code/Magento/Sales/Setup/InstallSchema.php
@@ -27,7 +27,7 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
/**
* Create table 'sales_order'
*/
- $table = $installer->getConnection()->newTable(
+ $table = $installer->getConnection('sales')->newTable(
$installer->getTable('sales_order')
)->addColumn(
'entity_id',
@@ -898,12 +898,12 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
)->setComment(
'Sales Flat Order'
);
- $installer->getConnection()->createTable($table);
+ $installer->getConnection('sales')->createTable($table);
/**
* Create table 'sales_order_grid'
*/
- $table = $installer->getConnection()->newTable(
+ $table = $installer->getConnection('sales')->newTable(
$installer->getTable('sales_order_grid')
)->addColumn(
'entity_id',
@@ -1129,12 +1129,12 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
)->setComment(
'Sales Flat Order Grid'
);
- $installer->getConnection()->createTable($table);
+ $installer->getConnection('sales')->createTable($table);
/**
* Create table 'sales_order_address'
*/
- $table = $installer->getConnection()->newTable(
+ $table = $installer->getConnection('sales')->newTable(
$installer->getTable('sales_order_address')
)->addColumn(
'entity_id',
@@ -1274,12 +1274,12 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
)->setComment(
'Sales Flat Order Address'
);
- $installer->getConnection()->createTable($table);
+ $installer->getConnection('sales')->createTable($table);
/**
* Create table 'sales_order_status_history'
*/
- $table = $installer->getConnection()->newTable(
+ $table = $installer->getConnection('sales')->newTable(
$installer->getTable('sales_order_status_history')
)->addColumn(
'entity_id',
@@ -1345,12 +1345,12 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
)->setComment(
'Sales Flat Order Status History'
);
- $installer->getConnection()->createTable($table);
+ $installer->getConnection('sales')->createTable($table);
/**
* Create table 'sales_order_item'
*/
- $table = $installer->getConnection()->newTable(
+ $table = $installer->getConnection('sales')->newTable(
$installer->getTable('sales_order_item')
)->addColumn(
'item_id',
@@ -1781,12 +1781,12 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
)->setComment(
'Sales Flat Order Item'
);
- $installer->getConnection()->createTable($table);
+ $installer->getConnection('sales')->createTable($table);
/**
* Create table 'sales_order_payment'
*/
- $table = $installer->getConnection()->newTable(
+ $table = $installer->getConnection('sales')->newTable(
$installer->getTable('sales_order_payment')
)->addColumn(
'entity_id',
@@ -2124,12 +2124,12 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
)->setComment(
'Sales Flat Order Payment'
);
- $installer->getConnection()->createTable($table);
+ $installer->getConnection('sales')->createTable($table);
/**
* Create table 'sales_shipment'
*/
- $table = $installer->getConnection()->newTable(
+ $table = $installer->getConnection('sales')->newTable(
$installer->getTable('sales_shipment')
)->addColumn(
'entity_id',
@@ -2283,14 +2283,14 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
)->setComment(
'Sales Flat Shipment'
);
- $installer->getConnection()->createTable($table);
+ $installer->getConnection('sales')->createTable($table);
/**
* Create table 'sales_shipment_grid'
*
* @add order_id, shipping_description
*/
- $table = $installer->getConnection()->newTable(
+ $table = $installer->getConnection('sales')->newTable(
$installer->getTable('sales_shipment_grid')
)->addColumn(
'entity_id',
@@ -2495,12 +2495,12 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
)->setComment(
'Sales Flat Shipment Grid'
);
- $installer->getConnection()->createTable($table);
+ $installer->getConnection('sales')->createTable($table);
/**
* Create table 'sales_shipment_item'
*/
- $table = $installer->getConnection()->newTable(
+ $table = $installer->getConnection('sales')->newTable(
$installer->getTable('sales_shipment_item')
)->addColumn(
'entity_id',
@@ -2586,12 +2586,12 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
)->setComment(
'Sales Flat Shipment Item'
);
- $installer->getConnection()->createTable($table);
+ $installer->getConnection('sales')->createTable($table);
/**
* Create table 'sales_shipment_track'
*/
- $table = $installer->getConnection()->newTable(
+ $table = $installer->getConnection('sales')->newTable(
$installer->getTable('sales_shipment_track')
)->addColumn(
'entity_id',
@@ -2677,12 +2677,12 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
)->setComment(
'Sales Flat Shipment Track'
);
- $installer->getConnection()->createTable($table);
+ $installer->getConnection('sales')->createTable($table);
/**
* Create table 'sales_shipment_comment'
*/
- $table = $installer->getConnection()->newTable(
+ $table = $installer->getConnection('sales')->newTable(
$installer->getTable('sales_shipment_comment')
)->addColumn(
'entity_id',
@@ -2735,12 +2735,12 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
)->setComment(
'Sales Flat Shipment Comment'
);
- $installer->getConnection()->createTable($table);
+ $installer->getConnection('sales')->createTable($table);
/**
* Create table 'sales_invoice'
*/
- $table = $installer->getConnection()->newTable(
+ $table = $installer->getConnection('sales')->newTable(
$installer->getTable('sales_invoice')
)->addColumn(
'entity_id',
@@ -3071,12 +3071,12 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
)->setComment(
'Sales Flat Invoice'
);
- $installer->getConnection()->createTable($table);
+ $installer->getConnection('sales')->createTable($table);
/**
* Create table 'sales_invoice_grid'
*/
- $table = $installer->getConnection()->newTable(
+ $table = $installer->getConnection('sales')->newTable(
$installer->getTable('sales_invoice_grid')
)->addColumn(
'entity_id',
@@ -3290,12 +3290,12 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
)->setComment(
'Sales Flat Invoice Grid'
);
- $installer->getConnection()->createTable($table);
+ $installer->getConnection('sales')->createTable($table);
/**
* Create table 'sales_invoice_item'
*/
- $table = $installer->getConnection()->newTable(
+ $table = $installer->getConnection('sales')->newTable(
$installer->getTable('sales_invoice_item')
)->addColumn(
'entity_id',
@@ -3459,12 +3459,12 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
)->setComment(
'Sales Flat Invoice Item'
);
- $installer->getConnection()->createTable($table);
+ $installer->getConnection('sales')->createTable($table);
/**
* Create table 'sales_invoice_comment'
*/
- $table = $installer->getConnection()->newTable(
+ $table = $installer->getConnection('sales')->newTable(
$installer->getTable('sales_invoice_comment')
)->addColumn(
'entity_id',
@@ -3517,12 +3517,12 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
)->setComment(
'Sales Flat Invoice Comment'
);
- $installer->getConnection()->createTable($table);
+ $installer->getConnection('sales')->createTable($table);
/**
* Create table 'sales_creditmemo'
*/
- $table = $installer->getConnection()->newTable(
+ $table = $installer->getConnection('sales')->newTable(
$installer->getTable('sales_creditmemo')
)->addColumn(
'entity_id',
@@ -3877,12 +3877,12 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
)->setComment(
'Sales Flat Creditmemo'
);
- $installer->getConnection()->createTable($table);
+ $installer->getConnection('sales')->createTable($table);
/**
* Create table 'sales_creditmemo_grid'
*/
- $table = $installer->getConnection()->newTable(
+ $table = $installer->getConnection('sales')->newTable(
$installer->getTable('sales_creditmemo_grid')
)->addColumn(
'entity_id',
@@ -4099,12 +4099,12 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
)->setComment(
'Sales Flat Creditmemo Grid'
);
- $installer->getConnection()->createTable($table);
+ $installer->getConnection('sales')->createTable($table);
/**
* Create table 'sales_creditmemo_item'
*/
- $table = $installer->getConnection()->newTable(
+ $table = $installer->getConnection('sales')->newTable(
$installer->getTable('sales_creditmemo_item')
)->addColumn(
'entity_id',
@@ -4268,12 +4268,12 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
)->setComment(
'Sales Flat Creditmemo Item'
);
- $installer->getConnection()->createTable($table);
+ $installer->getConnection('sales')->createTable($table);
/**
* Create table 'sales_creditmemo_comment'
*/
- $table = $installer->getConnection()->newTable(
+ $table = $installer->getConnection('sales')->newTable(
$installer->getTable('sales_creditmemo_comment')
)->addColumn(
'entity_id',
@@ -4326,12 +4326,12 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
)->setComment(
'Sales Flat Creditmemo Comment'
);
- $installer->getConnection()->createTable($table);
+ $installer->getConnection('sales')->createTable($table);
/**
* Create table 'sales_invoiced_aggregated'
*/
- $table = $installer->getConnection()->newTable(
+ $table = $installer->getConnection('sales')->newTable(
$installer->getTable('sales_invoiced_aggregated')
)->addColumn(
'id',
@@ -4407,12 +4407,12 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
)->setComment(
'Sales Invoiced Aggregated'
);
- $installer->getConnection()->createTable($table);
+ $installer->getConnection('sales')->createTable($table);
/**
* Create table 'sales_invoiced_aggregated_order'
*/
- $table = $installer->getConnection()->newTable(
+ $table = $installer->getConnection('sales')->newTable(
$installer->getTable('sales_invoiced_aggregated_order')
)->addColumn(
'id',
@@ -4488,12 +4488,12 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
)->setComment(
'Sales Invoiced Aggregated Order'
);
- $installer->getConnection()->createTable($table);
+ $installer->getConnection('sales')->createTable($table);
/**
* Create table 'sales_order_aggregated_created'
*/
- $table = $installer->getConnection()->newTable(
+ $table = $installer->getConnection('sales')->newTable(
$installer->getTable('sales_order_aggregated_created')
)->addColumn(
'id',
@@ -4635,10 +4635,10 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
)->setComment(
'Sales Order Aggregated Created'
);
- $installer->getConnection()->createTable($table);
+ $installer->getConnection('sales')->createTable($table);
- $installer->getConnection()->createTable(
- $installer->getConnection()->createTableByDdl(
+ $installer->getConnection('sales')->createTable(
+ $installer->getConnection('sales')->createTableByDdl(
$installer->getTable('sales_order_aggregated_created'),
$installer->getTable('sales_order_aggregated_updated')
)
@@ -4647,7 +4647,7 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
/**
* Create table 'sales_payment_transaction'
*/
- $table = $installer->getConnection()->newTable(
+ $table = $installer->getConnection('sales')->newTable(
$installer->getTable('sales_payment_transaction')
)->addColumn(
'transaction_id',
@@ -4749,12 +4749,12 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
)->setComment(
'Sales Payment Transaction'
);
- $installer->getConnection()->createTable($table);
+ $installer->getConnection('sales')->createTable($table);
/**
* Create table 'sales_refunded_aggregated'
*/
- $table = $installer->getConnection()->newTable(
+ $table = $installer->getConnection('sales')->newTable(
$installer->getTable('sales_refunded_aggregated')
)->addColumn(
'id',
@@ -4824,12 +4824,12 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
)->setComment(
'Sales Refunded Aggregated'
);
- $installer->getConnection()->createTable($table);
+ $installer->getConnection('sales')->createTable($table);
/**
* Create table 'sales_refunded_aggregated_order'
*/
- $table = $installer->getConnection()->newTable(
+ $table = $installer->getConnection('sales')->newTable(
$installer->getTable('sales_refunded_aggregated_order')
)->addColumn(
'id',
@@ -4899,12 +4899,12 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
)->setComment(
'Sales Refunded Aggregated Order'
);
- $installer->getConnection()->createTable($table);
+ $installer->getConnection('sales')->createTable($table);
/**
* Create table 'sales_shipping_aggregated'
*/
- $table = $installer->getConnection()->newTable(
+ $table = $installer->getConnection('sales')->newTable(
$installer->getTable('sales_shipping_aggregated')
)->addColumn(
'id',
@@ -4974,12 +4974,12 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
)->setComment(
'Sales Shipping Aggregated'
);
- $installer->getConnection()->createTable($table);
+ $installer->getConnection('sales')->createTable($table);
/**
* Create table 'sales_shipping_aggregated_order'
*/
- $table = $installer->getConnection()->newTable(
+ $table = $installer->getConnection('sales')->newTable(
$installer->getTable('sales_shipping_aggregated_order')
)->addColumn(
'id',
@@ -5049,12 +5049,12 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
)->setComment(
'Sales Shipping Aggregated Order'
);
- $installer->getConnection()->createTable($table);
+ $installer->getConnection('sales')->createTable($table);
/**
* Create table 'sales_bestsellers_aggregated_daily'
*/
- $table = $installer->getConnection()->newTable(
+ $table = $installer->getConnection('sales')->newTable(
$installer->getTable('sales_bestsellers_aggregated_daily')
)->addColumn(
'id',
@@ -5127,12 +5127,12 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
)->setComment(
'Sales Bestsellers Aggregated Daily'
);
- $installer->getConnection()->createTable($table);
+ $installer->getConnection('sales')->createTable($table);
/**
* Create table 'sales_bestsellers_aggregated_monthly'
*/
- $table = $installer->getConnection()->newTable(
+ $table = $installer->getConnection('sales')->newTable(
$installer->getTable('sales_bestsellers_aggregated_monthly')
)->addColumn(
'id',
@@ -5205,12 +5205,12 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
)->setComment(
'Sales Bestsellers Aggregated Monthly'
);
- $installer->getConnection()->createTable($table);
+ $installer->getConnection('sales')->createTable($table);
/**
* Create table 'sales_bestsellers_aggregated_yearly'
*/
- $table = $installer->getConnection()->newTable(
+ $table = $installer->getConnection('sales')->newTable(
$installer->getTable('sales_bestsellers_aggregated_yearly')
)->addColumn(
'id',
@@ -5283,12 +5283,12 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
)->setComment(
'Sales Bestsellers Aggregated Yearly'
);
- $installer->getConnection()->createTable($table);
+ $installer->getConnection('sales')->createTable($table);
/**
* Create table 'sales_order_tax'
*/
- $table = $installer->getConnection()->newTable(
+ $table = $installer->getConnection('sales')->newTable(
$installer->getTable('sales_order_tax')
)->addColumn(
'tax_id',
@@ -5362,12 +5362,12 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
)->setComment(
'Sales Order Tax Table'
);
- $installer->getConnection()->createTable($table);
+ $installer->getConnection('sales')->createTable($table);
/**
* Create table 'sales_order_tax_item'
*/
- $table = $setup->getConnection()->newTable(
+ $table = $setup->getConnection('sales')->newTable(
$setup->getTable('sales_order_tax_item')
)->addColumn(
'tax_item_id',
@@ -5461,12 +5461,12 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
)->setComment(
'Sales Order Tax Item'
);
- $setup->getConnection()->createTable($table);
+ $setup->getConnection('sales')->createTable($table);
/**
* Create table 'sales_order_status'
*/
- $table = $installer->getConnection()->newTable(
+ $table = $installer->getConnection('sales')->newTable(
$installer->getTable('sales_order_status')
)->addColumn(
'status',
@@ -5483,12 +5483,12 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
)->setComment(
'Sales Order Status Table'
);
- $installer->getConnection()->createTable($table);
+ $installer->getConnection('sales')->createTable($table);
/**
* Create table 'sales_order_status_state'
*/
- $table = $installer->getConnection()->newTable(
+ $table = $installer->getConnection('sales')->newTable(
$installer->getTable('sales_order_status_state')
)->addColumn(
'status',
@@ -5523,12 +5523,12 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
)->setComment(
'Sales Order Status Table'
);
- $installer->getConnection()->createTable($table);
+ $installer->getConnection('sales')->createTable($table);
/**
* Create table 'sales_order_status_label'
*/
- $table = $installer->getConnection()->newTable(
+ $table = $installer->getConnection('sales')->newTable(
$installer->getTable('sales_order_status_label')
)->addColumn(
'status',
@@ -5566,7 +5566,7 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
)->setComment(
'Sales Order Status Label Table'
);
- $installer->getConnection()->createTable($table);
+ $installer->getConnection('sales')->createTable($table);
$installer->endSetup();
}
diff --git a/app/code/Magento/Sales/Setup/SalesSetup.php b/app/code/Magento/Sales/Setup/SalesSetup.php
index d65d960f74ae6..e8be201acef05 100644
--- a/app/code/Magento/Sales/Setup/SalesSetup.php
+++ b/app/code/Magento/Sales/Setup/SalesSetup.php
@@ -310,6 +310,7 @@ public function getConnection()
$schemaListener = $setup->getConnection()->getSchemaListener();
$newConnection = $this->getSetup()->getConnection(self::$connectionName);
$newConnection->setSchemaListener($schemaListener);
+ $schemaListener->setResource('sales');
return $newConnection;
}
diff --git a/app/code/Magento/Sales/etc/db_schema.xml b/app/code/Magento/Sales/etc/db_schema.xml
index 61a5c44879a23..96c1586e30915 100644
--- a/app/code/Magento/Sales/etc/db_schema.xml
+++ b/app/code/Magento/Sales/etc/db_schema.xml
@@ -1,1884 +1,1446 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/SalesRule/etc/db_schema.xml b/app/code/Magento/SalesRule/etc/db_schema.xml
index dbea9859c5161..aef6e6577c7c9 100644
--- a/app/code/Magento/SalesRule/etc/db_schema.xml
+++ b/app/code/Magento/SalesRule/etc/db_schema.xml
@@ -1,325 +1,255 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/SalesSequence/etc/db_schema.xml b/app/code/Magento/SalesSequence/etc/db_schema.xml
index de5d78a5684c5..97b1fc5e7df2f 100644
--- a/app/code/Magento/SalesSequence/etc/db_schema.xml
+++ b/app/code/Magento/SalesSequence/etc/db_schema.xml
@@ -1,40 +1,36 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Search/etc/db_schema.xml b/app/code/Magento/Search/etc/db_schema.xml
index a37ec6a8070de..ae0236c7e00c3 100644
--- a/app/code/Magento/Search/etc/db_schema.xml
+++ b/app/code/Magento/Search/etc/db_schema.xml
@@ -1,71 +1,56 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Security/etc/db_schema.xml b/app/code/Magento/Security/etc/db_schema.xml
index 61a230706001e..bc836126c944c 100644
--- a/app/code/Magento/Security/etc/db_schema.xml
+++ b/app/code/Magento/Security/etc/db_schema.xml
@@ -1,41 +1,38 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/SendFriend/etc/db_schema.xml b/app/code/Magento/SendFriend/etc/db_schema.xml
index 36b2fce036362..7df238c113224 100644
--- a/app/code/Magento/SendFriend/etc/db_schema.xml
+++ b/app/code/Magento/SendFriend/etc/db_schema.xml
@@ -1,20 +1,18 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Sitemap/etc/db_schema.xml b/app/code/Magento/Sitemap/etc/db_schema.xml
index e66e4141c817f..5132af57c4cb2 100644
--- a/app/code/Magento/Sitemap/etc/db_schema.xml
+++ b/app/code/Magento/Sitemap/etc/db_schema.xml
@@ -1,21 +1,18 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Store/etc/db_schema.xml b/app/code/Magento/Store/etc/db_schema.xml
index 5f878b541077c..8ddea191257b3 100644
--- a/app/code/Magento/Store/etc/db_schema.xml
+++ b/app/code/Magento/Store/etc/db_schema.xml
@@ -1,85 +1,71 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Swatches/etc/db_schema.xml b/app/code/Magento/Swatches/etc/db_schema.xml
index 90ab620b7a45f..2cf91e5f8d399 100644
--- a/app/code/Magento/Swatches/etc/db_schema.xml
+++ b/app/code/Magento/Swatches/etc/db_schema.xml
@@ -1,30 +1,25 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Tax/etc/db_schema.xml b/app/code/Magento/Tax/etc/db_schema.xml
index dd911796bb984..136a88266428d 100644
--- a/app/code/Magento/Tax/etc/db_schema.xml
+++ b/app/code/Magento/Tax/etc/db_schema.xml
@@ -1,182 +1,151 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Theme/etc/db_schema.xml b/app/code/Magento/Theme/etc/db_schema.xml
index a70687eb9eff4..3e6e5f314c613 100644
--- a/app/code/Magento/Theme/etc/db_schema.xml
+++ b/app/code/Magento/Theme/etc/db_schema.xml
@@ -1,49 +1,66 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Translation/etc/db_schema.xml b/app/code/Magento/Translation/etc/db_schema.xml
index 34fb081774290..49e9331bea4d0 100644
--- a/app/code/Magento/Translation/etc/db_schema.xml
+++ b/app/code/Magento/Translation/etc/db_schema.xml
@@ -1,25 +1,21 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Ui/etc/db_schema.xml b/app/code/Magento/Ui/etc/db_schema.xml
index 1215732f410a9..2cc691f10426c 100644
--- a/app/code/Magento/Ui/etc/db_schema.xml
+++ b/app/code/Magento/Ui/etc/db_schema.xml
@@ -1,25 +1,23 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/UrlRewrite/etc/db_schema.xml b/app/code/Magento/UrlRewrite/etc/db_schema.xml
index 51f559558e5c2..d4880df291a81 100644
--- a/app/code/Magento/UrlRewrite/etc/db_schema.xml
+++ b/app/code/Magento/UrlRewrite/etc/db_schema.xml
@@ -1,32 +1,29 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/User/etc/db_schema.xml b/app/code/Magento/User/etc/db_schema.xml
index 1397969538d16..9c0679e4a1943 100644
--- a/app/code/Magento/User/etc/db_schema.xml
+++ b/app/code/Magento/User/etc/db_schema.xml
@@ -1,53 +1,44 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Variable/etc/db_schema.xml b/app/code/Magento/Variable/etc/db_schema.xml
index fe3d16c87718b..9de21395947f0 100644
--- a/app/code/Magento/Variable/etc/db_schema.xml
+++ b/app/code/Magento/Variable/etc/db_schema.xml
@@ -1,38 +1,33 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Vault/etc/db_schema.xml b/app/code/Magento/Vault/etc/db_schema.xml
index f99fa7d941abb..44caf5be39f57 100644
--- a/app/code/Magento/Vault/etc/db_schema.xml
+++ b/app/code/Magento/Vault/etc/db_schema.xml
@@ -1,45 +1,38 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Weee/etc/db_schema.xml b/app/code/Magento/Weee/etc/db_schema.xml
index 54a3b1153f7a2..5d3136468dc60 100644
--- a/app/code/Magento/Weee/etc/db_schema.xml
+++ b/app/code/Magento/Weee/etc/db_schema.xml
@@ -1,119 +1,75 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Widget/etc/db_schema.xml b/app/code/Magento/Widget/etc/db_schema.xml
index 49a2b0ddbcfb9..b083a3a87da45 100644
--- a/app/code/Magento/Widget/etc/db_schema.xml
+++ b/app/code/Magento/Widget/etc/db_schema.xml
@@ -1,112 +1,93 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Wishlist/etc/db_schema.xml b/app/code/Magento/Wishlist/etc/db_schema.xml
index 2977494a6bda4..827ec61d82f7b 100644
--- a/app/code/Magento/Wishlist/etc/db_schema.xml
+++ b/app/code/Magento/Wishlist/etc/db_schema.xml
@@ -1,68 +1,55 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/clean_db_schemas.php b/clean_db_schemas.php
index 081c906692c6c..2cd96079c3f16 100644
--- a/clean_db_schemas.php
+++ b/clean_db_schemas.php
@@ -45,7 +45,7 @@
$adapter->query('CREATE DATABASE ' . $resourceConnection->getSchemaName('default'));
foreach ($componentRegistrar->getPaths(\Magento\Framework\Component\ComponentRegistrar::MODULE) as $path) {
- if (strpos($path, 'magento2ee') !== false) {
+ if (strpos($path, 'magento2ce') !== false) {
@unlink($path . DIRECTORY_SEPARATOR . 'etc/db_schema.xml');
}
}
diff --git a/lib/internal/Magento/Framework/App/ResourceConnection.php b/lib/internal/Magento/Framework/App/ResourceConnection.php
index fea5c28313fc9..93e8e856d6c1d 100644
--- a/lib/internal/Magento/Framework/App/ResourceConnection.php
+++ b/lib/internal/Magento/Framework/App/ResourceConnection.php
@@ -5,10 +5,9 @@
*/
namespace Magento\Framework\App;
-use Magento\Framework\App\DeploymentConfig;
use Magento\Framework\App\ResourceConnection\ConfigInterface as ResourceConfigInterface;
-use Magento\Framework\Model\ResourceModel\Type\Db\ConnectionFactoryInterface;
use Magento\Framework\Config\ConfigOptionsListConstants;
+use Magento\Framework\Model\ResourceModel\Type\Db\ConnectionFactoryInterface;
/**
* Application provides ability to configure multiple connections to persistent storage.
@@ -92,7 +91,16 @@ public function __construct(
public function getConnection($resourceName = self::DEFAULT_CONNECTION)
{
$connectionName = $this->config->getConnectionName($resourceName);
- return $this->getConnectionByName($connectionName);
+ $connection = $this->getConnectionByName($connectionName);
+ if (preg_match('/sales/', $resourceName)) {
+ $connection->getSchemaListener()->setResource('sales');
+ }
+
+ if (preg_match('/checkout/', $resourceName) || preg_match('/quote/', $resourceName)) {
+ $connection->getSchemaListener()->setResource('quote');
+ }
+
+ return $connection;
}
/**
diff --git a/lib/internal/Magento/Framework/DB/Adapter/Pdo/Mysql.php b/lib/internal/Magento/Framework/DB/Adapter/Pdo/Mysql.php
index 9e7dbae87f97b..cfde580de5564 100644
--- a/lib/internal/Magento/Framework/DB/Adapter/Pdo/Mysql.php
+++ b/lib/internal/Magento/Framework/DB/Adapter/Pdo/Mysql.php
@@ -999,6 +999,7 @@ public function dropColumn($tableName, $columnName, $schemaName = null)
$foreignKeys = $this->getForeignKeys($tableName, $schemaName);
foreach ($foreignKeys as $fkProp) {
if ($fkProp['COLUMN_NAME'] == $columnName) {
+ $this->schemaListener->dropForeignKey($tableName, $fkProp['FK_NAME']);
$alterDrop[] = 'DROP FOREIGN KEY ' . $this->quoteIdentifier($fkProp['FK_NAME']);
}
}
@@ -1009,6 +1010,9 @@ public function dropColumn($tableName, $columnName, $schemaName = null)
$idxColumnKey = array_search($columnName, $idxColumns);
if ($idxColumnKey !== false) {
unset($idxColumns[$idxColumnKey]);
+ if (empty($idxColumns)) {
+ $this->schemaListener->dropIndex($tableName, $idxData['KEY_NAME'], 'index');
+ }
if ($idxColumns && $this->_getIndexByColumns($tableName, $idxColumns, $schemaName)) {
$this->dropIndex($tableName, $idxData['KEY_NAME'], $schemaName);
}
diff --git a/lib/internal/Magento/Framework/Module/Setup.php b/lib/internal/Magento/Framework/Module/Setup.php
index 50e881c4ae534..70c03230da7cf 100644
--- a/lib/internal/Magento/Framework/Module/Setup.php
+++ b/lib/internal/Magento/Framework/Module/Setup.php
@@ -7,9 +7,9 @@
*/
namespace Magento\Framework\Module;
+use Magento\Framework\App\ResourceConnection;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\SetupInterface;
-use Magento\Framework\App\ResourceConnection;
class Setup implements SetupInterface
{
@@ -63,14 +63,27 @@ public function __construct(
*/
public function getConnection($connectionName = null)
{
+ $resource = 'default';
+ if (preg_match('/sales/', $connectionName)) {
+ $resource = 'sales';
+ }
+
+ if (preg_match('/checkout/', $connectionName) || preg_match('/quote/', $connectionName)) {
+ $resource = 'quote';
+ }
+
if ($connectionName !== null) {
try {
- return $this->resourceModel->getConnectionByName($connectionName);
+ $connection = $this->resourceModel->getConnectionByName($connectionName);
+ $connection->getSchemaListener()->setResource($resource);
+ return $connection;
} catch (\DomainException $exception) {
//Fallback to default connection
}
}
- return $this->getDefaultConnection();
+ $connection = $this->getDefaultConnection();
+ $connection->getSchemaListener()->setResource($resource);
+ return $connection;
}
/**
diff --git a/schema_patches/MAGETWO_85326__Tool_for_generating_schema____working_on_EE_stuff.patch b/schema_patches/key_catalog_category_product.patch
similarity index 100%
rename from schema_patches/MAGETWO_85326__Tool_for_generating_schema____working_on_EE_stuff.patch
rename to schema_patches/key_catalog_category_product.patch
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Config/Converter.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Config/Converter.php
index a1781dc27ebb3..cf69afb72871b 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Config/Converter.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Config/Converter.php
@@ -80,7 +80,7 @@ private function recursiveConvert(\Traversable $source)
*/
private function hasAttributesExceptName(\DOMElement $element)
{
- return $element->hasAttribute('xsi:type') || $element->attributes->length > 2;
+ return $element->hasAttribute('xsi:type') || $element->attributes->length >= 2;
}
/**
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/SchemaBuilder.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/SchemaBuilder.php
index b37e0ba2c12e5..9c9f7cc246030 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/SchemaBuilder.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Declaration/SchemaBuilder.php
@@ -149,7 +149,7 @@ private function getStructuralElementResource(array $tableData)
* @param array $structuralElementData
* @return bool
*/
- private function isDisabled(array $structuralElementData)
+ private function isDisabled($structuralElementData)
{
return isset($structuralElementData['disabled']) &&
$this->booleanUtils->toBoolean($structuralElementData['disabled']);
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/TableDiff.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/TableDiff.php
index 6c43c7696f54e..07612bca8e305 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/TableDiff.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Diff/TableDiff.php
@@ -61,8 +61,9 @@ public function __construct(DiffManager $diffManager)
*/
private function excludeAutoIndexes(Table $table, array $indexes)
{
- foreach ($this->preprocessConstraintsAndIndexes($table->getReferenceConstraints()) as $name => $constraint) {
- $name = str_replace("fk_", 'index', $name);
+ foreach ($table->getReferenceConstraints() as $constraint) {
+ $indexNameToExclude = $constraint->getColumn()->getName();
+ $name = 'index' . $indexNameToExclude;
unset($indexes[$name]);
}
@@ -119,6 +120,7 @@ public function diff(
if ($elementType === self::INDEX_DIFF_TYPE) {
$generatedElements = $this->excludeAutoIndexes($generatedTable, $generatedElements);
+ $declaredElements = $this->excludeAutoIndexes($declaredTable, $declaredElements);
}
foreach ($declaredElements as $elementName => $element) {
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Table.php b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Table.php
index 9fac88e0ce0fe..5cd93131ddf59 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Table.php
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/Dto/Table.php
@@ -94,7 +94,7 @@ public function getConstraintByName($name)
/**
* This method lookup only for foreign keys constraints
*
- * @return Constraint[]
+ * @return Reference[]
*/
public function getReferenceConstraints()
{
diff --git a/setup/src/Magento/Setup/Model/Declaration/Schema/etc/schema.xsd b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/schema.xsd
index ef71b6350da0e..3ead78a5a8aa5 100644
--- a/setup/src/Magento/Setup/Model/Declaration/Schema/etc/schema.xsd
+++ b/setup/src/Magento/Setup/Model/Declaration/Schema/etc/schema.xsd
@@ -61,7 +61,7 @@
-
+
diff --git a/setup/src/Magento/Setup/Model/Installer.php b/setup/src/Magento/Setup/Model/Installer.php
index cf33ec85e13b0..6713a7587f6e4 100644
--- a/setup/src/Magento/Setup/Model/Installer.php
+++ b/setup/src/Magento/Setup/Model/Installer.php
@@ -11,7 +11,6 @@
use Magento\Framework\App\DeploymentConfig\Writer;
use Magento\Framework\App\Filesystem\DirectoryList;
use Magento\Framework\App\MaintenanceMode;
-use Magento\Framework\App\ResourceConnection\Config;
use Magento\Framework\App\State\CleanupFiles;
use Magento\Framework\Component\ComponentRegistrar;
use Magento\Framework\Config\ConfigOptionsListConstants;
@@ -33,10 +32,8 @@
use Magento\Setup\Console\Command\InstallCommand;
use Magento\Setup\Controller\ResponseTypeInterface;
use Magento\Setup\Model\ConfigModel as SetupConfigModel;
-use Magento\Setup\Model\Declaration\Schema\Config\SchemaLocator;
use Magento\Setup\Module\ConnectionFactory;
use Magento\Setup\Module\DataSetupFactory;
-use Magento\Setup\Module\Setup;
use Magento\Setup\Module\SetupFactory;
use Magento\Setup\Validator\DbValidator;
use Magento\Store\Model\Store;
@@ -878,6 +875,7 @@ private function handleDBSchemaData($setup, $type, array $request)
) {
foreach ($moduleNames as $moduleName) {
$this->schemaListener->setModuleName($moduleName);
+ $this->schemaListener->setResource('default');
$this->log->log("Module '{$moduleName}':");
$configVer = $this->moduleList->getOne($moduleName)['setup_version'];
$currentVersion = $moduleContextList[$moduleName]->getVersion();
@@ -927,6 +925,7 @@ private function handleDBSchemaData($setup, $type, array $request)
'Magento_Weee' => 'Magento_WeeeStaging',
'Magento_Wishlist' => 'Magento_CatalogStaging',
];
+
$this->schemaListener->toogleIgnore(SchemaListener::IGNORE_ON);
if ($type === 'schema') {
$this->log->log('Schema post-updates:');
@@ -941,6 +940,7 @@ private function handleDBSchemaData($setup, $type, array $request)
$this->schemaListener->toogleIgnore(
SchemaListener::IGNORE_OFF | SchemaListener::STAGING_FK_KEYS
);
+ $this->schemaListener->setResource('default');
$this->log->log("Module '{$moduleName}':");
$modulePostUpdater = $this->getSchemaDataHandler($moduleName, $handlerType);
diff --git a/setup/src/Magento/Setup/Model/SchemaListener.php b/setup/src/Magento/Setup/Model/SchemaListener.php
index 123e3acc226dc..49d4603f513ad 100644
--- a/setup/src/Magento/Setup/Model/SchemaListener.php
+++ b/setup/src/Magento/Setup/Model/SchemaListener.php
@@ -36,6 +36,11 @@ class SchemaListener
*/
private $tables = [];
+ /**
+ * @var string
+ */
+ private $resource;
+
/**
* This flag allows us to ignore some DDL operations
*
@@ -316,6 +321,8 @@ public function log($tableName, array $dataToLog)
} else {
$this->tables[$moduleName][strtolower($tableName)] = $dataToLog;
}
+
+ $this->tables[$moduleName][strtolower($tableName)]['resource'] = $this->resource;
}
/**
@@ -475,6 +482,14 @@ public function toogleIgnore($flag)
$this->ignore = $flag;
}
+ /**
+ * @param string $resource
+ */
+ public function setResource(string $resource)
+ {
+ $this->resource = $resource;
+ }
+
/**
* Check whether staging fk keys installer is enabled
*
diff --git a/setup/src/Magento/Setup/Model/SchemaListenerDefinition/DecimalDefinition.php b/setup/src/Magento/Setup/Model/SchemaListenerDefinition/DecimalDefinition.php
index 446942b3a720f..0d147f273a154 100644
--- a/setup/src/Magento/Setup/Model/SchemaListenerDefinition/DecimalDefinition.php
+++ b/setup/src/Magento/Setup/Model/SchemaListenerDefinition/DecimalDefinition.php
@@ -12,14 +12,20 @@
class DecimalDefinition implements DefinitionConverterInterface
{
/**
- * Default scale for all decimals
+ * Decimal and float has different default values
+ *
+ * @var array
*/
- const DEFAULT_SCALE = '0';
-
- /**
- * Default precision for all decimals
- */
- const DEFAULT_PRECISION = '10';
+ private static $shapeByType = [
+ 'float' => [
+ 'precision' => '10',
+ 'scale' => '0'
+ ],
+ 'decimal' => [
+ 'precision' => '12',
+ 'scale' => '4'
+ ]
+ ];
/**
* @inheritdoc
@@ -30,11 +36,11 @@ public function convertToDefinition(array $definition)
'xsi:type' => $definition['type'],
'name' => $definition['name'],
//In previos adapter this 2 fields were switched, so we need to switch again
- 'scale' => $definition['precision'] ?? self::DEFAULT_PRECISION,
- 'precission' => $definition['scale'] ?? self::DEFAULT_SCALE,
+ 'scale' => $definition['precision'] ?? self::$shapeByType[$definition['type']]['precision'],
+ 'precission' => $definition['scale'] ?? self::$shapeByType[$definition['type']]['scale'],
'unsigned' => $definition['unsigned'] ?? false,
'nullable' => $definition['nullable'] ?? true,
- 'default' => isset($definition['default']) ? (int) $definition['default'] : null,
+ 'default' => isset($definition['default']) && $definition['default'] !== false ? (int) $definition['default'] : null,
'primary' => $definition['primary'] ?? false
];
}
diff --git a/setup/src/Magento/Setup/Model/SchemaListenerDefinition/IntegerDefinition.php b/setup/src/Magento/Setup/Model/SchemaListenerDefinition/IntegerDefinition.php
index 4f7d9a2e62532..63d59bb2f0044 100644
--- a/setup/src/Magento/Setup/Model/SchemaListenerDefinition/IntegerDefinition.php
+++ b/setup/src/Magento/Setup/Model/SchemaListenerDefinition/IntegerDefinition.php
@@ -50,12 +50,18 @@ public function convertToDefinition(array $definition)
$definition['type'] = 'boolean';
return $this->booleanDefinition->convertToDefinition($definition);
}
+ $length = $definition['length'] ?? self::$lengthDefaults[$definition['type']];
+ $unsigned = $definition['unsigned'] ?? false;
+
+ if ((bool) $unsigned && in_array($definition['type'], ['int', 'smallint'])) {
+ $length--;
+ }
return [
'xsi:type' => $definition['type'],
'name' => $definition['name'],
- 'padding' => $definition['length'] ?? self::$lengthDefaults[$definition['type']],
- 'unsigned' => $definition['unsigned'] ?? false,
+ 'padding' => $length,
+ 'unsigned' => $unsigned,
'nullable' => $definition['nullable'] ?? true,
'identity' => $definition['identity'] ?? false,
'default' => isset($definition['default']) && $definition['default'] !== false ? (int) $definition['default'] : null,
diff --git a/setup/src/Magento/Setup/Model/SchemaPersistor.php b/setup/src/Magento/Setup/Model/SchemaPersistor.php
index ab7ee1f026bf6..6745c47e55b16 100644
--- a/setup/src/Magento/Setup/Model/SchemaPersistor.php
+++ b/setup/src/Magento/Setup/Model/SchemaPersistor.php
@@ -66,7 +66,7 @@ public function persist(SchemaListener $schemaListener)
$table = $dom->addChild('table');
$table->addAttribute('name', $tableName);
/** @TODO: handle different resources for sales and checkout tables */
- $table->addAttribute('resource', 'default');
+ $table->addAttribute('resource', $tableData['resource']);
$this->processColumns($tableData, $table);
$this->processConstraints($tableData, $table);
$this->processIndexes($tableData, $table);
@@ -222,7 +222,7 @@ private function processConstraints(array $tableData, \SimpleXMLElement $table)
*/
private function persistModule(\SimpleXMLElement $simpleXmlElementDom, $path)
{
- if (strpos($path, 'magento2ee') !== false) {
+ if (strpos($path, 'magento2ce') !== false) {
$dom = new \DOMDocument('1.0');
$dom->preserveWhiteSpace = false;
$dom->formatOutput = true;
From 88418ad4bda29dc91bffabdf4f3129dfe9e687fb Mon Sep 17 00:00:00 2001
From: Ievgen Sentiabov
Date: Thu, 11 Jan 2018 16:51:45 +0200
Subject: [PATCH 283/904] Removed "Object" usage as class name
---
.../Framework/Code/Reader/SourceArgumentsReaderTest.php | 4 ++--
.../Code/Reader/_files/SourceArgumentsReaderTest.php.sample | 6 +++---
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/dev/tests/integration/testsuite/Magento/Framework/Code/Reader/SourceArgumentsReaderTest.php b/dev/tests/integration/testsuite/Magento/Framework/Code/Reader/SourceArgumentsReaderTest.php
index 2f7f040d82c24..d1b22e853ce1d 100644
--- a/dev/tests/integration/testsuite/Magento/Framework/Code/Reader/SourceArgumentsReaderTest.php
+++ b/dev/tests/integration/testsuite/Magento/Framework/Code/Reader/SourceArgumentsReaderTest.php
@@ -41,8 +41,8 @@ public function getConstructorArgumentTypesDataProvider()
'\Imported\Name\Space\One',
'\Imported\Name\Space\AnotherTest\Extended',
'\Imported\Name\Space\Test',
- '\Imported\Name\Space\Object\Under\Test',
- '\Imported\Name\Space\Object',
+ '\Imported\Name\Space\ClassName\Under\Test',
+ '\Imported\Name\Space\ClassName',
'\Some\Testing\Name\Space\Test',
'array',
''
diff --git a/dev/tests/integration/testsuite/Magento/Framework/Code/Reader/_files/SourceArgumentsReaderTest.php.sample b/dev/tests/integration/testsuite/Magento/Framework/Code/Reader/_files/SourceArgumentsReaderTest.php.sample
index 8bf978150d003..47c059de2034b 100644
--- a/dev/tests/integration/testsuite/Magento/Framework/Code/Reader/_files/SourceArgumentsReaderTest.php.sample
+++ b/dev/tests/integration/testsuite/Magento/Framework/Code/Reader/_files/SourceArgumentsReaderTest.php.sample
@@ -6,7 +6,7 @@
namespace Some\Testing\Name\Space;
use Imported\Name\Space\One as FirstImport;
-use Imported\Name\Space\Object;
+use Imported\Name\Space\ClassName;
use Imported\Name\Space\Test as Testing, \Imported\Name\Space\AnotherTest ;
class AnotherSimpleClass
@@ -16,8 +16,8 @@ class AnotherSimpleClass
FirstImport $itemTwo,
AnotherTest\Extended $itemThree,
Testing $itemFour,
- Object\Under\Test $itemFive,
- Object $itemSix,
+ ClassName\Under\Test $itemFive,
+ ClassName $itemSix,
Test $itemSeven,
array $itemEight = [],
$itemNine = 'test'
From 76e50e36e5d896c1718695aab6d4e217ac26313f Mon Sep 17 00:00:00 2001
From: Kieu Phan
Date: Thu, 11 Jan 2018 09:35:20 -0600
Subject: [PATCH 284/904] MAGETWO-85452: QA Activities
- Move general sections out of CMS section to have access from other TESTs
---
.../Cest/AdminAddImageToWYSIWYGBlockCest.xml | 6 +--
.../Cest/AdminAddImageToWYSIWYGCMSCest.xml | 52 +++++++++---------
.../AdminAddVariableToWYSIWYGBlockCest.xml | 6 +--
.../Cest/AdminAddVariableToWYSIWYGCMSCest.xml | 8 +--
.../Cest/AdminAddWidgetToWYSIWYGBlockCest.xml | 6 +--
...WidgetToWYSIWYGWithCMSPageLinkTypeCest.xml | 6 +--
...getToWYSIWYGWithCMSStaticBlockTypeCest.xml | 6 +--
...WYSIWYGWithCatalogCategoryLinkTypeCest.xml | 6 +--
...oWYSIWYGWithCatalogProductLinkTypeCest.xml | 6 +--
...oWYSIWYGWithCatalogProductListTypeCest.xml | 6 +--
...YGWithRecentlyComparedProductsTypeCest.xml | 6 +--
...IWYGWithRecentlyViewedProductsTypeCest.xml | 6 +--
.../Cest/AdminSwitchWYSIWYGOptionsCest.xml | 8 +--
...yTinyMCEv4IsNativeWYSIWYGOnCMSPageCest.xml | 2 +-
.../Section/CmsNewPagePageContentSection.xml | 36 -------------
.../AdminAddImageToWYSIWYGNewsletterCest.xml | 54 +++++++++----------
.../AdminAddWidgetToWYSIWYGNewsletterCest.xml | 2 +-
...nyMCEv4IsNativeWYSIWYGOnNewsletterCest.xml | 2 +-
18 files changed, 94 insertions(+), 130 deletions(-)
diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddImageToWYSIWYGBlockCest.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddImageToWYSIWYGBlockCest.xml
index 0407e5421d9e3..66007231a8588 100644
--- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddImageToWYSIWYGBlockCest.xml
+++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddImageToWYSIWYGBlockCest.xml
@@ -87,9 +87,9 @@
-
-
-
+
+
+
diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddImageToWYSIWYGCMSCest.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddImageToWYSIWYGCMSCest.xml
index f3065163d778e..f0db340b6588c 100644
--- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddImageToWYSIWYGCMSCest.xml
+++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddImageToWYSIWYGCMSCest.xml
@@ -31,44 +31,44 @@
-
-
+
+
-
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
-
+
-
+
-
-
-
-
+
+
+
+
-
-
-
-
+
+
+
+
-
-
+
+
-
-
-
-
+
+
+
+
diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddVariableToWYSIWYGBlockCest.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddVariableToWYSIWYGBlockCest.xml
index b14e0bd2711f3..d543b77fc03c7 100644
--- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddVariableToWYSIWYGBlockCest.xml
+++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddVariableToWYSIWYGBlockCest.xml
@@ -92,9 +92,9 @@
-
-
-
+
+
+
diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddVariableToWYSIWYGCMSCest.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddVariableToWYSIWYGCMSCest.xml
index 387f939441fa3..7336ed648ca82 100644
--- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddVariableToWYSIWYGCMSCest.xml
+++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddVariableToWYSIWYGCMSCest.xml
@@ -41,10 +41,10 @@
-
+
-
-
+
+
@@ -61,7 +61,7 @@
-
+
diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGBlockCest.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGBlockCest.xml
index c221c9c46194d..daf91b2f53cd0 100644
--- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGBlockCest.xml
+++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGBlockCest.xml
@@ -60,9 +60,9 @@
-
-
-
+
+
+
diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGWithCMSPageLinkTypeCest.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGWithCMSPageLinkTypeCest.xml
index 1814c3f038794..3d1de1a70a7c5 100644
--- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGWithCMSPageLinkTypeCest.xml
+++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGWithCMSPageLinkTypeCest.xml
@@ -33,10 +33,10 @@
-
+
-
-
+
+
diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGWithCMSStaticBlockTypeCest.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGWithCMSStaticBlockTypeCest.xml
index f14330ce207e8..c4a31f5797334 100644
--- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGWithCMSStaticBlockTypeCest.xml
+++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGWithCMSStaticBlockTypeCest.xml
@@ -34,10 +34,10 @@
-
+
-
-
+
+
diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGWithCatalogCategoryLinkTypeCest.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGWithCatalogCategoryLinkTypeCest.xml
index 04b0b968cfc03..872d374810d82 100644
--- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGWithCatalogCategoryLinkTypeCest.xml
+++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGWithCatalogCategoryLinkTypeCest.xml
@@ -33,10 +33,10 @@
-
+
-
-
+
+
diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGWithCatalogProductLinkTypeCest.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGWithCatalogProductLinkTypeCest.xml
index 5fa3c07e53e3e..73b20b1324fbf 100644
--- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGWithCatalogProductLinkTypeCest.xml
+++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGWithCatalogProductLinkTypeCest.xml
@@ -37,10 +37,10 @@
-
+
-
-
+
+
diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGWithCatalogProductListTypeCest.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGWithCatalogProductListTypeCest.xml
index 108ee114a7ec4..f2254a4e1bc0f 100644
--- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGWithCatalogProductListTypeCest.xml
+++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGWithCatalogProductListTypeCest.xml
@@ -39,10 +39,10 @@
-
+
-
-
+
+
diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGWithRecentlyComparedProductsTypeCest.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGWithRecentlyComparedProductsTypeCest.xml
index 1e9f8f3ec128d..d344ffa725480 100644
--- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGWithRecentlyComparedProductsTypeCest.xml
+++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGWithRecentlyComparedProductsTypeCest.xml
@@ -36,10 +36,10 @@
-
+
-
-
+
+
diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGWithRecentlyViewedProductsTypeCest.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGWithRecentlyViewedProductsTypeCest.xml
index 670a0ecc35898..02dceb9ead976 100644
--- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGWithRecentlyViewedProductsTypeCest.xml
+++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminAddWidgetToWYSIWYGWithRecentlyViewedProductsTypeCest.xml
@@ -37,10 +37,10 @@
-
+
-
-
+
+
diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminSwitchWYSIWYGOptionsCest.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminSwitchWYSIWYGOptionsCest.xml
index 50504c51b6d2e..774d08b21dee6 100644
--- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminSwitchWYSIWYGOptionsCest.xml
+++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/AdminSwitchWYSIWYGOptionsCest.xml
@@ -39,8 +39,8 @@
-
-
+
+
@@ -65,8 +65,8 @@
-
-
+
+
diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/VerifyTinyMCEv4IsNativeWYSIWYGOnCMSPageCest.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/VerifyTinyMCEv4IsNativeWYSIWYGOnCMSPageCest.xml
index 143e7d5c70eb2..f643b3141181b 100644
--- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/VerifyTinyMCEv4IsNativeWYSIWYGOnCMSPageCest.xml
+++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Cest/VerifyTinyMCEv4IsNativeWYSIWYGOnCMSPageCest.xml
@@ -35,7 +35,7 @@
-
+
diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Section/CmsNewPagePageContentSection.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Section/CmsNewPagePageContentSection.xml
index 7b3b10b78ed6e..3388a0cf7c741 100644
--- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Section/CmsNewPagePageContentSection.xml
+++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Cms/Section/CmsNewPagePageContentSection.xml
@@ -15,45 +15,9 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Newsletter/Cest/AdminAddImageToWYSIWYGNewsletterCest.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Newsletter/Cest/AdminAddImageToWYSIWYGNewsletterCest.xml
index e238228ff6846..4277c16138aa0 100644
--- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Newsletter/Cest/AdminAddImageToWYSIWYGNewsletterCest.xml
+++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Newsletter/Cest/AdminAddImageToWYSIWYGNewsletterCest.xml
@@ -34,45 +34,45 @@
-
+
-
-
+
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
+
-
+
-
-
-
-
+
+
+
+
-
-
-
-
+
+
+
+
-
-
+
+
-
-
-
-
+
+
+
+
diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Newsletter/Cest/AdminAddWidgetToWYSIWYGNewsletterCest.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Newsletter/Cest/AdminAddWidgetToWYSIWYGNewsletterCest.xml
index 93bd61704fb40..3e38d4712a82c 100644
--- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Newsletter/Cest/AdminAddWidgetToWYSIWYGNewsletterCest.xml
+++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Newsletter/Cest/AdminAddWidgetToWYSIWYGNewsletterCest.xml
@@ -33,7 +33,7 @@
-
+
diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Newsletter/Cest/VerifyTinyMCEv4IsNativeWYSIWYGOnNewsletterCest.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Newsletter/Cest/VerifyTinyMCEv4IsNativeWYSIWYGOnNewsletterCest.xml
index 5f0d48d0ee2d6..2dcc47b5afc55 100644
--- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Newsletter/Cest/VerifyTinyMCEv4IsNativeWYSIWYGOnNewsletterCest.xml
+++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Newsletter/Cest/VerifyTinyMCEv4IsNativeWYSIWYGOnNewsletterCest.xml
@@ -34,7 +34,7 @@
-
+
From 5946584770ffbeca1b20435bd5856bc850297865 Mon Sep 17 00:00:00 2001
From: Sergii Kovalenko
Date: Thu, 11 Jan 2018 19:04:11 +0200
Subject: [PATCH 285/904] MAGETWO-85326: Tool for generating schema
--working on CE stuff
---
.../AdminNotification/etc/db_schema.xml | 4 +-
.../Magento/Authorization/etc/db_schema.xml | 4 +-
app/code/Magento/Bundle/etc/db_schema.xml | 98 +--
app/code/Magento/Captcha/etc/db_schema.xml | 2 +-
app/code/Magento/Catalog/etc/db_schema.xml | 280 +++----
.../CatalogInventory/etc/db_schema.xml | 36 +-
.../Magento/CatalogRule/etc/db_schema.xml | 32 +-
.../Magento/CatalogSearch/etc/db_schema.xml | 4 +-
.../CatalogUrlRewrite/etc/db_schema.xml | 2 +-
.../CheckoutAgreements/etc/db_schema.xml | 4 +-
app/code/Magento/Cms/etc/db_schema.xml | 8 +-
app/code/Magento/Config/etc/db_schema.xml | 2 +-
.../ConfigurableProduct/etc/db_schema.xml | 6 +-
app/code/Magento/Cron/etc/db_schema.xml | 2 +-
app/code/Magento/Customer/etc/db_schema.xml | 58 +-
app/code/Magento/Directory/etc/db_schema.xml | 12 +-
.../Magento/Downloadable/etc/db_schema.xml | 28 +-
app/code/Magento/Eav/etc/db_schema.xml | 44 +-
app/code/Magento/Email/etc/db_schema.xml | 2 +-
.../Magento/GiftMessage/etc/db_schema.xml | 2 +-
.../Magento/GoogleOptimizer/etc/db_schema.xml | 2 +-
.../Magento/ImportExport/etc/db_schema.xml | 4 +-
app/code/Magento/Indexer/etc/db_schema.xml | 4 +-
.../Magento/Integration/etc/db_schema.xml | 12 +-
.../NewRelicReporting/Setup/InstallSchema.php | 4 +-
.../NewRelicReporting/etc/db_schema.xml | 14 +-
app/code/Magento/Newsletter/etc/db_schema.xml | 12 +-
.../Magento/OfflineShipping/etc/db_schema.xml | 8 +-
app/code/Magento/Paypal/etc/db_schema.xml | 16 +-
app/code/Magento/Persistent/etc/db_schema.xml | 2 +-
.../Magento/ProductAlert/etc/db_schema.xml | 6 +-
.../Magento/ProductVideo/etc/db_schema.xml | 2 +-
app/code/Magento/Quote/etc/db_schema.xml | 182 ++---
app/code/Magento/Reports/etc/db_schema.xml | 20 +-
app/code/Magento/Review/etc/db_schema.xml | 26 +-
app/code/Magento/Sales/etc/db_schema.xml | 716 +++++++++---------
app/code/Magento/SalesRule/etc/db_schema.xml | 56 +-
.../Magento/SalesSequence/etc/db_schema.xml | 4 +-
app/code/Magento/Search/etc/db_schema.xml | 4 +-
app/code/Magento/Security/etc/db_schema.xml | 4 +-
app/code/Magento/SendFriend/etc/db_schema.xml | 2 +-
app/code/Magento/Sitemap/etc/db_schema.xml | 2 +-
app/code/Magento/Store/etc/db_schema.xml | 6 +-
app/code/Magento/Swatches/etc/db_schema.xml | 2 +-
app/code/Magento/Tax/etc/db_schema.xml | 24 +-
app/code/Magento/Theme/etc/db_schema.xml | 8 +-
.../Magento/Translation/etc/db_schema.xml | 2 +-
app/code/Magento/Ui/etc/db_schema.xml | 2 +-
app/code/Magento/UrlRewrite/etc/db_schema.xml | 2 +-
app/code/Magento/User/etc/db_schema.xml | 10 +-
app/code/Magento/Variable/etc/db_schema.xml | 4 +-
app/code/Magento/Vault/etc/db_schema.xml | 4 +-
app/code/Magento/Weee/etc/db_schema.xml | 68 +-
app/code/Magento/Widget/etc/db_schema.xml | 12 +-
app/code/Magento/Wishlist/etc/db_schema.xml | 8 +-
.../Schema/Db/DbSchemaReaderInterface.php | 9 +
.../Schema/Db/DbSchemaWriterInterface.php | 3 +-
.../Schema/Db/MySQL/DbSchemaReader.php | 14 +-
.../Schema/Db/MySQL/DbSchemaWriter.php | 2 +-
.../Db/MySQL/Definition/Columns/Decimal.php | 6 +-
.../Db/MySQL/Definition/Columns/Timestamp.php | 13 +-
.../Schema/Db/MySQL/Definition/Index.php | 8 -
.../Declaration/Schema/Db/SchemaBuilder.php | 4 +-
.../Schema/Declaration/SchemaBuilder.php | 1 +
.../Declaration/Schema/Diff/TableDiff.php | 2 +-
.../Schema/Dto/Columns/Timestamp.php | 16 +
.../Schema/Dto/Factories/Table.php | 10 +
.../Model/Declaration/Schema/Dto/Table.php | 36 +-
.../Schema/Operations/CreateTable.php | 7 +-
.../Model/Declaration/Schema/etc/schema.xsd | 8 +
.../Magento/Setup/Model/SchemaListener.php | 15 +-
.../DecimalDefinition.php | 11 +-
.../TimestampDefinition.php | 7 +-
.../Magento/Setup/Model/SchemaPersistor.php | 4 +
74 files changed, 1081 insertions(+), 979 deletions(-)
diff --git a/app/code/Magento/AdminNotification/etc/db_schema.xml b/app/code/Magento/AdminNotification/etc/db_schema.xml
index d9e08fdb40620..750118bb0716a 100644
--- a/app/code/Magento/AdminNotification/etc/db_schema.xml
+++ b/app/code/Magento/AdminNotification/etc/db_schema.xml
@@ -1,6 +1,6 @@
-
+
-
+
diff --git a/app/code/Magento/Authorization/etc/db_schema.xml b/app/code/Magento/Authorization/etc/db_schema.xml
index 0750e0c68dabb..ff2e3b6ceb51e 100644
--- a/app/code/Magento/Authorization/etc/db_schema.xml
+++ b/app/code/Magento/Authorization/etc/db_schema.xml
@@ -1,6 +1,6 @@
-
+
-
+
diff --git a/app/code/Magento/Bundle/etc/db_schema.xml b/app/code/Magento/Bundle/etc/db_schema.xml
index c9b873fe5fbc8..2731f31e03c28 100644
--- a/app/code/Magento/Bundle/etc/db_schema.xml
+++ b/app/code/Magento/Bundle/etc/db_schema.xml
@@ -1,6 +1,6 @@
-