1column.phtml
@@ -39,12 +40,7 @@
as="shipping_method" template="express/review/shipping/method.phtml"/>
-
-
-
+
diff --git a/app/code/Magento/Paypal/view/frontend/layout/paypal_express_review_details.xml b/app/code/Magento/Paypal/view/frontend/layout/paypal_express_review_details.xml
index f0ed14376cf6f..5407774f232e5 100644
--- a/app/code/Magento/Paypal/view/frontend/layout/paypal_express_review_details.xml
+++ b/app/code/Magento/Paypal/view/frontend/layout/paypal_express_review_details.xml
@@ -24,10 +24,9 @@
*/
-->
+
-
-
-
+
diff --git a/app/code/Magento/PaypalUk/view/frontend/layout/paypaluk_express_review.xml b/app/code/Magento/Paypal/view/frontend/layout/paypal_payflowexpress_review.xml
similarity index 75%
rename from app/code/Magento/PaypalUk/view/frontend/layout/paypaluk_express_review.xml
rename to app/code/Magento/Paypal/view/frontend/layout/paypal_payflowexpress_review.xml
index 17b595fd69733..5cdaf6ca42ce7 100644
--- a/app/code/Magento/PaypalUk/view/frontend/layout/paypaluk_express_review.xml
+++ b/app/code/Magento/Paypal/view/frontend/layout/paypal_payflowexpress_review.xml
@@ -24,6 +24,7 @@
*/
-->
+
1column.phtml
@@ -31,18 +32,13 @@
-
- paypaluk
+ template="payflowexpress/review.phtml">
+
+ paypal/payflowexpress
-
-
-
+
diff --git a/app/code/Magento/PaypalUk/view/frontend/express/review.phtml b/app/code/Magento/Paypal/view/frontend/payflowexpress/review.phtml
similarity index 100%
rename from app/code/Magento/PaypalUk/view/frontend/express/review.phtml
rename to app/code/Magento/Paypal/view/frontend/payflowexpress/review.phtml
diff --git a/app/code/Magento/PaypalUk/i18n/de_DE.csv b/app/code/Magento/PaypalUk/i18n/de_DE.csv
deleted file mode 100644
index dff193d6cb66f..0000000000000
--- a/app/code/Magento/PaypalUk/i18n/de_DE.csv
+++ /dev/null
@@ -1,2 +0,0 @@
-"PayPal Express Checkout (Payflow Edition) Shortcut Wrapper","PayPal Express Checkout (Payflow Edition) Shortcut Wrapper"
-"PayPal Express Order Review Form","PayPal Express Bestellübersichtsformular"
diff --git a/app/code/Magento/PaypalUk/i18n/en_US.csv b/app/code/Magento/PaypalUk/i18n/en_US.csv
deleted file mode 100644
index 94085b297f0a3..0000000000000
--- a/app/code/Magento/PaypalUk/i18n/en_US.csv
+++ /dev/null
@@ -1,2 +0,0 @@
-"PayPal Express Checkout (Payflow Edition) Shortcut Wrapper","PayPal Express Checkout (Payflow Edition) Shortcut Wrapper"
-"PayPal Express Order Review Form","PayPal Express Order Review Form"
diff --git a/app/code/Magento/PaypalUk/i18n/es_ES.csv b/app/code/Magento/PaypalUk/i18n/es_ES.csv
deleted file mode 100644
index d50b06868ab77..0000000000000
--- a/app/code/Magento/PaypalUk/i18n/es_ES.csv
+++ /dev/null
@@ -1,2 +0,0 @@
-"PayPal Express Checkout (Payflow Edition) Shortcut Wrapper","Contenedor de acceso directo a Pago Express de PayPal (Edición de Flujo de Pago)"
-"PayPal Express Order Review Form","Formulario para revisar el pedido express de Paypal"
diff --git a/app/code/Magento/PaypalUk/i18n/fr_FR.csv b/app/code/Magento/PaypalUk/i18n/fr_FR.csv
deleted file mode 100644
index eee5aec03eb53..0000000000000
--- a/app/code/Magento/PaypalUk/i18n/fr_FR.csv
+++ /dev/null
@@ -1,2 +0,0 @@
-"PayPal Express Checkout (Payflow Edition) Shortcut Wrapper","Paiement express Paypal (Edition Payflow) Shortcut Wrapper"
-"PayPal Express Order Review Form","Formulaire de vérification du paiement express via Paypal."
diff --git a/app/code/Magento/PaypalUk/i18n/nl_NL.csv b/app/code/Magento/PaypalUk/i18n/nl_NL.csv
deleted file mode 100644
index c260cba00ac6b..0000000000000
--- a/app/code/Magento/PaypalUk/i18n/nl_NL.csv
+++ /dev/null
@@ -1,2 +0,0 @@
-"PayPal Express Checkout (Payflow Edition) Shortcut Wrapper","PayPal Express Checkout (Payflow Edition) Shortcut Wrapper"
-"PayPal Express Order Review Form","PayPal Express Bestelling Terugzien Formulier"
diff --git a/app/code/Magento/PaypalUk/i18n/pt_BR.csv b/app/code/Magento/PaypalUk/i18n/pt_BR.csv
deleted file mode 100644
index 2b6cee81fc3f5..0000000000000
--- a/app/code/Magento/PaypalUk/i18n/pt_BR.csv
+++ /dev/null
@@ -1,2 +0,0 @@
-"PayPal Express Checkout (Payflow Edition) Shortcut Wrapper","Fechar Pedido com PayPal Express (Edição Payflow): Wrapper Simplificado"
-"PayPal Express Order Review Form","PayPal Express: Revisar Pedido"
diff --git a/app/code/Magento/PaypalUk/i18n/zh_CN.csv b/app/code/Magento/PaypalUk/i18n/zh_CN.csv
deleted file mode 100644
index e899368134f93..0000000000000
--- a/app/code/Magento/PaypalUk/i18n/zh_CN.csv
+++ /dev/null
@@ -1,2 +0,0 @@
-"PayPal Express Checkout (Payflow Edition) Shortcut Wrapper","PayPal快速结账(Payflow版)快捷方式包装"
-"PayPal Express Order Review Form","PayPal快速订单审查表单"
diff --git a/app/code/Magento/PaypalUk/view/frontend/layout/SHORTCUT_uk_popup.xml b/app/code/Magento/PaypalUk/view/frontend/layout/SHORTCUT_uk_popup.xml
deleted file mode 100644
index 5e340be4acfa9..0000000000000
--- a/app/code/Magento/PaypalUk/view/frontend/layout/SHORTCUT_uk_popup.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-
-
-
-
-
-
-
- 1
-
-
- after
-
-
-
-
-
diff --git a/app/code/Magento/PaypalUk/view/frontend/layout/catalog_product_view.xml b/app/code/Magento/PaypalUk/view/frontend/layout/catalog_product_view.xml
deleted file mode 100644
index daf2f151f4b46..0000000000000
--- a/app/code/Magento/PaypalUk/view/frontend/layout/catalog_product_view.xml
+++ /dev/null
@@ -1,40 +0,0 @@
-
-
-
-
-
-
-
- 1
-
-
-
-
-
-
diff --git a/app/code/Magento/PaypalUk/view/frontend/layout/catalogsearch_result_index.xml b/app/code/Magento/PaypalUk/view/frontend/layout/catalogsearch_result_index.xml
deleted file mode 100644
index 40668f6fc4bdb..0000000000000
--- a/app/code/Magento/PaypalUk/view/frontend/layout/catalogsearch_result_index.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-
-
-
-
-
diff --git a/app/code/Magento/PaypalUk/view/frontend/layout/checkout_cart_index.xml b/app/code/Magento/PaypalUk/view/frontend/layout/checkout_cart_index.xml
deleted file mode 100644
index 87b1ed17124fc..0000000000000
--- a/app/code/Magento/PaypalUk/view/frontend/layout/checkout_cart_index.xml
+++ /dev/null
@@ -1,44 +0,0 @@
-
-
-
-
-
-
- 1
-
-
-
-
-
-
- 1
-
-
-
-
-
diff --git a/app/code/Magento/PaypalUk/view/frontend/layout/checkout_onepage_failure.xml b/app/code/Magento/PaypalUk/view/frontend/layout/checkout_onepage_failure.xml
deleted file mode 100644
index 40668f6fc4bdb..0000000000000
--- a/app/code/Magento/PaypalUk/view/frontend/layout/checkout_onepage_failure.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-
-
-
-
-
diff --git a/app/code/Magento/PaypalUk/view/frontend/layout/checkout_onepage_success.xml b/app/code/Magento/PaypalUk/view/frontend/layout/checkout_onepage_success.xml
deleted file mode 100644
index 40668f6fc4bdb..0000000000000
--- a/app/code/Magento/PaypalUk/view/frontend/layout/checkout_onepage_success.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-
-
-
-
-
diff --git a/app/code/Magento/PaypalUk/view/frontend/layout/review_product_list.xml b/app/code/Magento/PaypalUk/view/frontend/layout/review_product_list.xml
deleted file mode 100644
index 40668f6fc4bdb..0000000000000
--- a/app/code/Magento/PaypalUk/view/frontend/layout/review_product_list.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-
-
-
-
-
diff --git a/app/code/Magento/PaypalUk/view/frontend/layout/tag_customer_view.xml b/app/code/Magento/PaypalUk/view/frontend/layout/tag_customer_view.xml
deleted file mode 100644
index 40668f6fc4bdb..0000000000000
--- a/app/code/Magento/PaypalUk/view/frontend/layout/tag_customer_view.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-
-
-
-
-
diff --git a/app/code/Magento/PaypalUk/view/frontend/layout/tag_product_list.xml b/app/code/Magento/PaypalUk/view/frontend/layout/tag_product_list.xml
deleted file mode 100644
index 40668f6fc4bdb..0000000000000
--- a/app/code/Magento/PaypalUk/view/frontend/layout/tag_product_list.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-
-
-
-
-
diff --git a/app/code/Magento/PaypalUk/view/frontend/layout/wishlist_index_index.xml b/app/code/Magento/PaypalUk/view/frontend/layout/wishlist_index_index.xml
deleted file mode 100644
index 40668f6fc4bdb..0000000000000
--- a/app/code/Magento/PaypalUk/view/frontend/layout/wishlist_index_index.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-
-
-
-
-
diff --git a/app/code/Magento/Persistent/Model/Session.php b/app/code/Magento/Persistent/Model/Session.php
index 56e94d4e26ad8..3b9900655cad3 100644
--- a/app/code/Magento/Persistent/Model/Session.php
+++ b/app/code/Magento/Persistent/Model/Session.php
@@ -70,7 +70,7 @@ class Session extends \Magento\Core\Model\AbstractModel
protected $_coreData;
/**
- * @var \Magento\Core\Model\Config
+ * @var \Magento\App\ConfigInterface
*/
protected $_coreConfig;
@@ -103,7 +103,7 @@ class Session extends \Magento\Core\Model\AbstractModel
*
* @param \Magento\Core\Model\Context $context
* @param \Magento\Core\Model\Registry $registry
- * @param \Magento\Core\Model\Config $coreConfig
+ * @param \Magento\App\ConfigInterface $coreConfig
* @param \Magento\Core\Helper\Data $coreData
* @param \Magento\Persistent\Helper\Data $persistentData
* @param \Magento\Stdlib\Cookie $cookie
@@ -117,7 +117,7 @@ class Session extends \Magento\Core\Model\AbstractModel
public function __construct(
\Magento\Core\Model\Context $context,
\Magento\Core\Model\Registry $registry,
- \Magento\Core\Model\Config $coreConfig,
+ \Magento\App\ConfigInterface $coreConfig,
\Magento\Core\Helper\Data $coreData,
\Magento\Persistent\Helper\Data $persistentData,
\Magento\Stdlib\Cookie $cookie,
diff --git a/app/code/Magento/Persistent/etc/frontend/di.xml b/app/code/Magento/Persistent/etc/frontend/di.xml
index 59fec0ddd696a..8a467c2a49cd0 100644
--- a/app/code/Magento/Persistent/etc/frontend/di.xml
+++ b/app/code/Magento/Persistent/etc/frontend/di.xml
@@ -26,9 +26,9 @@
-
- /persistent/index/saveMethod
-
+
+ - /persistent/index/saveMethod
+
diff --git a/app/code/Magento/Persistent/etc/frontend/events.xml b/app/code/Magento/Persistent/etc/frontend/events.xml
index ce099785c6afc..926499b7bc952 100644
--- a/app/code/Magento/Persistent/etc/frontend/events.xml
+++ b/app/code/Magento/Persistent/etc/frontend/events.xml
@@ -76,7 +76,7 @@
-
+
diff --git a/app/code/Magento/ProductAlert/Block/Email/AbstractEmail.php b/app/code/Magento/ProductAlert/Block/Email/AbstractEmail.php
index d8a4ae38ad81f..d698531ef0af6 100644
--- a/app/code/Magento/ProductAlert/Block/Email/AbstractEmail.php
+++ b/app/code/Magento/ProductAlert/Block/Email/AbstractEmail.php
@@ -132,8 +132,8 @@ public function getProducts()
protected function _getUrlParams()
{
return array(
- '_store' => $this->getStore(),
- '_store_to_url' => true
+ '_scope' => $this->getStore(),
+ '_scope_to_url' => true
);
}
}
diff --git a/app/code/Magento/Reports/Block/Adminhtml/Grid/AbstractGrid.php b/app/code/Magento/Reports/Block/Adminhtml/Grid/AbstractGrid.php
index 460b4bfecca9e..f4e7c602b3011 100644
--- a/app/code/Magento/Reports/Block/Adminhtml/Grid/AbstractGrid.php
+++ b/app/code/Magento/Reports/Block/Adminhtml/Grid/AbstractGrid.php
@@ -57,7 +57,6 @@ class AbstractGrid extends \Magento\Backend\Block\Widget\Grid\Extended
/**
* @param \Magento\Backend\Block\Template\Context $context
- * @param \Magento\Core\Model\Url $urlModel
* @param \Magento\Backend\Helper\Data $backendHelper
* @param \Magento\Reports\Model\Resource\Report\Collection\Factory $resourceFactory
* @param \Magento\Reports\Model\Grouped\CollectionFactory $collectionFactory
@@ -66,7 +65,6 @@ class AbstractGrid extends \Magento\Backend\Block\Widget\Grid\Extended
*/
public function __construct(
\Magento\Backend\Block\Template\Context $context,
- \Magento\Core\Model\Url $urlModel,
\Magento\Backend\Helper\Data $backendHelper,
\Magento\Reports\Model\Resource\Report\Collection\Factory $resourceFactory,
\Magento\Reports\Model\Grouped\CollectionFactory $collectionFactory,
@@ -76,7 +74,7 @@ public function __construct(
$this->_resourceFactory = $resourceFactory;
$this->_collectionFactory = $collectionFactory;
$this->_reportsData = $reportsData;
- parent::__construct($context, $urlModel, $backendHelper, $data);
+ parent::__construct($context, $backendHelper, $data);
}
protected function _construct()
diff --git a/app/code/Magento/Reports/Block/Adminhtml/Product/Downloads/Grid.php b/app/code/Magento/Reports/Block/Adminhtml/Product/Downloads/Grid.php
index d3ecb6ffc3a96..37fc636f6e7a4 100644
--- a/app/code/Magento/Reports/Block/Adminhtml/Product/Downloads/Grid.php
+++ b/app/code/Magento/Reports/Block/Adminhtml/Product/Downloads/Grid.php
@@ -42,20 +42,18 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended
/**
* @param \Magento\Backend\Block\Template\Context $context
- * @param \Magento\Core\Model\Url $urlModel
* @param \Magento\Backend\Helper\Data $backendHelper
* @param \Magento\Reports\Model\Resource\Product\Downloads\CollectionFactory $downloadsFactory
* @param array $data
*/
public function __construct(
\Magento\Backend\Block\Template\Context $context,
- \Magento\Core\Model\Url $urlModel,
\Magento\Backend\Helper\Data $backendHelper,
\Magento\Reports\Model\Resource\Product\Downloads\CollectionFactory $downloadsFactory,
array $data = array()
) {
$this->_downloadsFactory = $downloadsFactory;
- parent::__construct($context, $urlModel, $backendHelper, $data);
+ parent::__construct($context, $backendHelper, $data);
}
protected function _construct()
diff --git a/app/code/Magento/Reports/Block/Adminhtml/Product/Grid.php b/app/code/Magento/Reports/Block/Adminhtml/Product/Grid.php
index 3da2162f06834..185294d94033b 100644
--- a/app/code/Magento/Reports/Block/Adminhtml/Product/Grid.php
+++ b/app/code/Magento/Reports/Block/Adminhtml/Product/Grid.php
@@ -42,20 +42,18 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended
/**
* @param \Magento\Backend\Block\Template\Context $context
- * @param \Magento\Core\Model\Url $urlModel
* @param \Magento\Backend\Helper\Data $backendHelper
* @param \Magento\Reports\Model\Resource\Product\CollectionFactory $collectionFactory
* @param array $data
*/
public function __construct(
\Magento\Backend\Block\Template\Context $context,
- \Magento\Core\Model\Url $urlModel,
\Magento\Backend\Helper\Data $backendHelper,
\Magento\Reports\Model\Resource\Product\CollectionFactory $collectionFactory,
array $data = array()
) {
$this->_collectionFactory = $collectionFactory;
- parent::__construct($context, $urlModel, $backendHelper, $data);
+ parent::__construct($context, $backendHelper, $data);
}
protected function _construct()
diff --git a/app/code/Magento/Reports/Block/Adminhtml/Product/Lowstock/Grid.php b/app/code/Magento/Reports/Block/Adminhtml/Product/Lowstock/Grid.php
index 0975c8efc3347..2de893c3cabf7 100644
--- a/app/code/Magento/Reports/Block/Adminhtml/Product/Lowstock/Grid.php
+++ b/app/code/Magento/Reports/Block/Adminhtml/Product/Lowstock/Grid.php
@@ -42,20 +42,18 @@ class Grid extends \Magento\Backend\Block\Widget\Grid
/**
* @param \Magento\Backend\Block\Template\Context $context
- * @param \Magento\Core\Model\Url $urlModel
* @param \Magento\Backend\Helper\Data $backendHelper
* @param \Magento\Reports\Model\Resource\Product\Lowstock\CollectionFactory $lowstocksFactory
* @param array $data
*/
public function __construct(
\Magento\Backend\Block\Template\Context $context,
- \Magento\Core\Model\Url $urlModel,
\Magento\Backend\Helper\Data $backendHelper,
\Magento\Reports\Model\Resource\Product\Lowstock\CollectionFactory $lowstocksFactory,
array $data = array()
) {
$this->_lowstocksFactory = $lowstocksFactory;
- parent::__construct($context, $urlModel, $backendHelper, $data);
+ parent::__construct($context, $backendHelper, $data);
}
/**
diff --git a/app/code/Magento/Reports/Block/Adminhtml/Review/Detail/Grid.php b/app/code/Magento/Reports/Block/Adminhtml/Review/Detail/Grid.php
index bac69719883b2..d28086d5d6e72 100644
--- a/app/code/Magento/Reports/Block/Adminhtml/Review/Detail/Grid.php
+++ b/app/code/Magento/Reports/Block/Adminhtml/Review/Detail/Grid.php
@@ -42,20 +42,18 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended
/**
* @param \Magento\Backend\Block\Template\Context $context
- * @param \Magento\Core\Model\Url $urlModel
* @param \Magento\Backend\Helper\Data $backendHelper
* @param \Magento\Reports\Model\Resource\Review\CollectionFactory $reviewsFactory
* @param array $data
*/
public function __construct(
\Magento\Backend\Block\Template\Context $context,
- \Magento\Core\Model\Url $urlModel,
\Magento\Backend\Helper\Data $backendHelper,
\Magento\Reports\Model\Resource\Review\CollectionFactory $reviewsFactory,
array $data = array()
) {
$this->_reviewsFactory = $reviewsFactory;
- parent::__construct($context, $urlModel, $backendHelper, $data);
+ parent::__construct($context, $backendHelper, $data);
}
protected function _construct()
diff --git a/app/code/Magento/Reports/Block/Adminhtml/Sales/Tax/Grid.php b/app/code/Magento/Reports/Block/Adminhtml/Sales/Tax/Grid.php
index aed5ce92b1737..44adfe5e890f4 100644
--- a/app/code/Magento/Reports/Block/Adminhtml/Sales/Tax/Grid.php
+++ b/app/code/Magento/Reports/Block/Adminhtml/Sales/Tax/Grid.php
@@ -44,7 +44,6 @@ class Grid extends \Magento\Reports\Block\Adminhtml\Grid\AbstractGrid
/**
* @param \Magento\Backend\Block\Template\Context $context
- * @param \Magento\Core\Model\Url $urlModel
* @param \Magento\Backend\Helper\Data $backendHelper
* @param \Magento\Reports\Model\Resource\Report\Collection\Factory $resourceFactory
* @param \Magento\Reports\Model\Grouped\CollectionFactory $collectionFactory
@@ -54,7 +53,6 @@ class Grid extends \Magento\Reports\Block\Adminhtml\Grid\AbstractGrid
*/
public function __construct(
\Magento\Backend\Block\Template\Context $context,
- \Magento\Core\Model\Url $urlModel,
\Magento\Backend\Helper\Data $backendHelper,
\Magento\Reports\Model\Resource\Report\Collection\Factory $resourceFactory,
\Magento\Reports\Model\Grouped\CollectionFactory $collectionFactory,
@@ -65,7 +63,6 @@ public function __construct(
$this->_configFactory = $configFactory;
parent::__construct(
$context,
- $urlModel,
$backendHelper,
$resourceFactory,
$collectionFactory,
diff --git a/app/code/Magento/Reports/Block/Adminhtml/Shopcart/Abandoned/Grid.php b/app/code/Magento/Reports/Block/Adminhtml/Shopcart/Abandoned/Grid.php
index db70f4963208e..ff7f09092ab17 100644
--- a/app/code/Magento/Reports/Block/Adminhtml/Shopcart/Abandoned/Grid.php
+++ b/app/code/Magento/Reports/Block/Adminhtml/Shopcart/Abandoned/Grid.php
@@ -42,20 +42,18 @@ class Grid extends \Magento\Reports\Block\Adminhtml\Grid\Shopcart
/**
* @param \Magento\Backend\Block\Template\Context $context
- * @param \Magento\Core\Model\Url $urlModel
* @param \Magento\Backend\Helper\Data $backendHelper
* @param \Magento\Reports\Model\Resource\Quote\CollectionFactory $quotesFactory
* @param array $data
*/
public function __construct(
\Magento\Backend\Block\Template\Context $context,
- \Magento\Core\Model\Url $urlModel,
\Magento\Backend\Helper\Data $backendHelper,
\Magento\Reports\Model\Resource\Quote\CollectionFactory $quotesFactory,
array $data = array()
) {
$this->_quotesFactory = $quotesFactory;
- parent::__construct($context, $urlModel, $backendHelper, $data);
+ parent::__construct($context, $backendHelper, $data);
}
protected function _construct()
diff --git a/app/code/Magento/Reports/Block/Adminhtml/Shopcart/Customer/Grid.php b/app/code/Magento/Reports/Block/Adminhtml/Shopcart/Customer/Grid.php
index 9ea648a0be0d6..0505ca3af83c8 100644
--- a/app/code/Magento/Reports/Block/Adminhtml/Shopcart/Customer/Grid.php
+++ b/app/code/Magento/Reports/Block/Adminhtml/Shopcart/Customer/Grid.php
@@ -42,20 +42,18 @@ class Grid extends \Magento\Reports\Block\Adminhtml\Grid\Shopcart
/**
* @param \Magento\Backend\Block\Template\Context $context
- * @param \Magento\Core\Model\Url $urlModel
* @param \Magento\Backend\Helper\Data $backendHelper
* @param \Magento\Reports\Model\Resource\Customer\CollectionFactory $customersFactory
* @param array $data
*/
public function __construct(
\Magento\Backend\Block\Template\Context $context,
- \Magento\Core\Model\Url $urlModel,
\Magento\Backend\Helper\Data $backendHelper,
\Magento\Reports\Model\Resource\Customer\CollectionFactory $customersFactory,
array $data = array()
) {
$this->_customersFactory = $customersFactory;
- parent::__construct($context, $urlModel, $backendHelper, $data);
+ parent::__construct($context, $backendHelper, $data);
}
protected function _construct()
diff --git a/app/code/Magento/Reports/Block/Adminhtml/Shopcart/Product/Grid.php b/app/code/Magento/Reports/Block/Adminhtml/Shopcart/Product/Grid.php
index 6cd417d299c14..a90e69386d318 100644
--- a/app/code/Magento/Reports/Block/Adminhtml/Shopcart/Product/Grid.php
+++ b/app/code/Magento/Reports/Block/Adminhtml/Shopcart/Product/Grid.php
@@ -42,20 +42,18 @@ class Grid extends \Magento\Reports\Block\Adminhtml\Grid\Shopcart
/**
* @param \Magento\Backend\Block\Template\Context $context
- * @param \Magento\Core\Model\Url $urlModel
* @param \Magento\Backend\Helper\Data $backendHelper
* @param \Magento\Reports\Model\Resource\Quote\CollectionFactory $quotesFactory
* @param array $data
*/
public function __construct(
\Magento\Backend\Block\Template\Context $context,
- \Magento\Core\Model\Url $urlModel,
\Magento\Backend\Helper\Data $backendHelper,
\Magento\Reports\Model\Resource\Quote\CollectionFactory $quotesFactory,
array $data = array()
) {
$this->_quotesFactory = $quotesFactory;
- parent::__construct($context, $urlModel, $backendHelper, $data);
+ parent::__construct($context, $backendHelper, $data);
}
protected function _construct()
diff --git a/app/code/Magento/Reports/Block/Adminhtml/Wishlist/Grid.php b/app/code/Magento/Reports/Block/Adminhtml/Wishlist/Grid.php
index 304db730dee46..e51e4034265e9 100644
--- a/app/code/Magento/Reports/Block/Adminhtml/Wishlist/Grid.php
+++ b/app/code/Magento/Reports/Block/Adminhtml/Wishlist/Grid.php
@@ -42,20 +42,18 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended
/**
* @param \Magento\Backend\Block\Template\Context $context
- * @param \Magento\Core\Model\Url $urlModel
* @param \Magento\Backend\Helper\Data $backendHelper
* @param \Magento\Reports\Model\Resource\Wishlist\Product\CollectionFactory $productsFactory
* @param array $data
*/
public function __construct(
\Magento\Backend\Block\Template\Context $context,
- \Magento\Core\Model\Url $urlModel,
\Magento\Backend\Helper\Data $backendHelper,
\Magento\Reports\Model\Resource\Wishlist\Product\CollectionFactory $productsFactory,
array $data = array()
) {
$this->_productsFactory = $productsFactory;
- parent::__construct($context, $urlModel, $backendHelper, $data);
+ parent::__construct($context, $backendHelper, $data);
}
protected function _construct()
diff --git a/app/code/Magento/Reports/etc/di.xml b/app/code/Magento/Reports/etc/di.xml
index e0b2110c9146c..cc274db9d331e 100644
--- a/app/code/Magento/Reports/etc/di.xml
+++ b/app/code/Magento/Reports/etc/di.xml
@@ -29,9 +29,9 @@
-
- Magento\Reports\Model\Resource\Setup
-
+
+ - Magento\Reports\Model\Resource\Setup
+
diff --git a/app/code/Magento/Review/Block/Adminhtml/Add.php b/app/code/Magento/Review/Block/Adminhtml/Add.php
index 136b520c6f4a7..7bcf2e85007b7 100644
--- a/app/code/Magento/Review/Block/Adminhtml/Add.php
+++ b/app/code/Magento/Review/Block/Adminhtml/Add.php
@@ -24,6 +24,8 @@
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
+namespace Magento\Review\Block\Adminhtml;
+
/**
* Adminhtml add Review main block
*
@@ -31,9 +33,6 @@
* @package Magento_Review
* @author Magento Core Team
*/
-
-namespace Magento\Review\Block\Adminhtml;
-
class Add extends \Magento\Backend\Block\Widget\Form\Container
{
protected function _construct()
@@ -119,6 +118,9 @@ protected function _construct()
';
}
+ /**
+ * @return string
+ */
public function getHeaderText()
{
return __('Add New Review');
diff --git a/app/code/Magento/Review/Block/Adminhtml/Add/Form.php b/app/code/Magento/Review/Block/Adminhtml/Add/Form.php
index 710f4fd2a21e7..35371248f652b 100644
--- a/app/code/Magento/Review/Block/Adminhtml/Add/Form.php
+++ b/app/code/Magento/Review/Block/Adminhtml/Add/Form.php
@@ -69,6 +69,9 @@ public function __construct(
parent::__construct($context, $registry, $formFactory, $data);
}
+ /**
+ * @return void
+ */
protected function _prepareForm()
{
/** @var \Magento\Data\Form $form */
diff --git a/app/code/Magento/Review/Block/Adminhtml/Edit.php b/app/code/Magento/Review/Block/Adminhtml/Edit.php
index 52b2840b8ad64..23ff1302b99a1 100644
--- a/app/code/Magento/Review/Block/Adminhtml/Edit.php
+++ b/app/code/Magento/Review/Block/Adminhtml/Edit.php
@@ -24,11 +24,11 @@
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
+namespace Magento\Review\Block\Adminhtml;
+
/**
* Review edit form
*/
-namespace Magento\Review\Block\Adminhtml;
-
class Edit extends \Magento\Backend\Block\Widget\Form\Container
{
/**
@@ -213,6 +213,9 @@ protected function _construct()
';
}
+ /**
+ * @return string
+ */
public function getHeaderText()
{
$reviewData = $this->_coreRegistry->registry('review_data');
diff --git a/app/code/Magento/Review/Block/Adminhtml/Edit/Form.php b/app/code/Magento/Review/Block/Adminhtml/Edit/Form.php
index 0ac0acf6ebc28..e429057dabfb4 100644
--- a/app/code/Magento/Review/Block/Adminhtml/Edit/Form.php
+++ b/app/code/Magento/Review/Block/Adminhtml/Edit/Form.php
@@ -80,6 +80,9 @@ public function __construct(
parent::__construct($context, $registry, $formFactory, $data);
}
+ /**
+ * @return $this
+ */
protected function _prepareForm()
{
$review = $this->_coreRegistry->registry('review_data');
diff --git a/app/code/Magento/Review/Block/Adminhtml/Grid.php b/app/code/Magento/Review/Block/Adminhtml/Grid.php
index 671b81f9ae6e8..a954bc7dfa949 100644
--- a/app/code/Magento/Review/Block/Adminhtml/Grid.php
+++ b/app/code/Magento/Review/Block/Adminhtml/Grid.php
@@ -74,7 +74,6 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended
/**
* @param \Magento\Backend\Block\Template\Context $context
- * @param \Magento\Core\Model\Url $urlModel
* @param \Magento\Backend\Helper\Data $backendHelper
* @param \Magento\Review\Model\ReviewFactory $reviewFactory
* @param \Magento\Review\Model\Resource\Review\Product\CollectionFactory $productsFactory
@@ -85,7 +84,6 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended
*/
public function __construct(
\Magento\Backend\Block\Template\Context $context,
- \Magento\Core\Model\Url $urlModel,
\Magento\Backend\Helper\Data $backendHelper,
\Magento\Review\Model\ReviewFactory $reviewFactory,
\Magento\Review\Model\Resource\Review\Product\CollectionFactory $productsFactory,
@@ -99,7 +97,7 @@ public function __construct(
$this->_reviewData = $reviewData;
$this->_reviewActionPager = $reviewActionPager;
$this->_reviewFactory = $reviewFactory;
- parent::__construct($context, $urlModel, $backendHelper, $data);
+ parent::__construct($context, $backendHelper, $data);
}
/**
@@ -305,7 +303,7 @@ protected function _prepareColumns()
/**
* Prepare grid mass actions
*
- * @return \Magento\Backend\Block\Widget\Grid|void
+ * @return void
*/
protected function _prepareMassaction()
{
diff --git a/app/code/Magento/Review/Block/Adminhtml/Grid/Filter/Type.php b/app/code/Magento/Review/Block/Adminhtml/Grid/Filter/Type.php
index 132b4cedecedf..8d8721e2e5979 100644
--- a/app/code/Magento/Review/Block/Adminhtml/Grid/Filter/Type.php
+++ b/app/code/Magento/Review/Block/Adminhtml/Grid/Filter/Type.php
@@ -24,6 +24,8 @@
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
+namespace Magento\Review\Block\Adminhtml\Grid\Filter;
+
/**
* Adminhtml review grid filter by type
*
@@ -31,11 +33,11 @@
* @package Magento_Review
* @author Magento Core Team
*/
-
-namespace Magento\Review\Block\Adminhtml\Grid\Filter;
-
class Type extends \Magento\Backend\Block\Widget\Grid\Column\Filter\Select
{
+ /**
+ * @return array
+ */
protected function _getOptions()
{
return array(
@@ -46,6 +48,9 @@ protected function _getOptions()
);
}
+ /**
+ * @return int
+ */
public function getCondition()
{
if ($this->getValue() == 1) {
diff --git a/app/code/Magento/Review/Block/Adminhtml/Grid/Renderer/Type.php b/app/code/Magento/Review/Block/Adminhtml/Grid/Renderer/Type.php
index 8745462be1088..67ebcececcc40 100644
--- a/app/code/Magento/Review/Block/Adminhtml/Grid/Renderer/Type.php
+++ b/app/code/Magento/Review/Block/Adminhtml/Grid/Renderer/Type.php
@@ -24,6 +24,8 @@
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
+namespace Magento\Review\Block\Adminhtml\Grid\Renderer;
+
/**
* Adminhtml review grid item renderer for item type
*
@@ -31,11 +33,11 @@
* @package Magento_Review
* @author Magento Core Team
*/
-
-namespace Magento\Review\Block\Adminhtml\Grid\Renderer;
-
class Type extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer
{
+ /**
+ * @return string
+ */
public function render(\Magento\Object $row)
{
diff --git a/app/code/Magento/Review/Block/Adminhtml/Product/Grid.php b/app/code/Magento/Review/Block/Adminhtml/Product/Grid.php
index 8c29fbee23484..8cda7a1478d53 100644
--- a/app/code/Magento/Review/Block/Adminhtml/Product/Grid.php
+++ b/app/code/Magento/Review/Block/Adminhtml/Product/Grid.php
@@ -42,7 +42,6 @@ class Grid extends \Magento\Catalog\Block\Adminhtml\Product\Grid
/**
* @param \Magento\Backend\Block\Template\Context $context
- * @param \Magento\Core\Model\Url $urlModel
* @param \Magento\Backend\Helper\Data $backendHelper
* @param \Magento\Core\Model\WebsiteFactory $websiteFactory
* @param \Magento\Eav\Model\Resource\Entity\Attribute\Set\CollectionFactory $setsFactory
@@ -58,7 +57,6 @@ class Grid extends \Magento\Catalog\Block\Adminhtml\Product\Grid
*/
public function __construct(
\Magento\Backend\Block\Template\Context $context,
- \Magento\Core\Model\Url $urlModel,
\Magento\Backend\Helper\Data $backendHelper,
\Magento\Core\Model\WebsiteFactory $websiteFactory,
\Magento\Eav\Model\Resource\Entity\Attribute\Set\CollectionFactory $setsFactory,
@@ -73,7 +71,6 @@ public function __construct(
$this->_websitesFactory = $websitesFactory;
parent::__construct(
$context,
- $urlModel,
$backendHelper,
$websiteFactory,
$setsFactory,
@@ -93,6 +90,9 @@ protected function _construct()
$this->setUseAjax(true);
}
+ /**
+ * @return void
+ */
protected function _prepareColumns()
{
$this->addColumn('entity_id', array(
@@ -157,16 +157,25 @@ protected function _prepareColumns()
}
}
+ /**
+ * @return string
+ */
public function getGridUrl()
{
return $this->getUrl('catalog/*/productGrid', array('_current'=>true));
}
+ /**
+ * @return string
+ */
public function getRowUrl($row)
{
return $this->getUrl('catalog/*/jsonProductInfo', array('id' => $row->getId()));
}
+ /**
+ * @return $this
+ */
protected function _prepareMassaction()
{
return $this;
diff --git a/app/code/Magento/Review/Block/Adminhtml/Rating/Detailed.php b/app/code/Magento/Review/Block/Adminhtml/Rating/Detailed.php
index c5eda0804c5db..db12de01600d8 100644
--- a/app/code/Magento/Review/Block/Adminhtml/Rating/Detailed.php
+++ b/app/code/Magento/Review/Block/Adminhtml/Rating/Detailed.php
@@ -23,16 +23,26 @@
* @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
+namespace Magento\Review\Block\Adminhtml\Rating;
+
+use Magento\Rating\Model\Rating;
+use Magento\Rating\Model\Rating\Option;
+use Magento\Rating\Model\Resource\Rating\Collection as RatingCollection;
+use Magento\Rating\Model\Resource\Rating\Option\Vote\Collection as VoteCollection;
/**
* Adminhtml detailed rating stars
*/
-namespace Magento\Review\Block\Adminhtml\Rating;
-
class Detailed extends \Magento\Backend\Block\Template
{
+ /**
+ * @var VoteCollection
+ */
protected $_voteCollection = false;
+ /**
+ * @var string
+ */
protected $_template = 'Magento_Rating::rating/detailed.phtml';
/**
@@ -81,6 +91,9 @@ protected function _construct()
}
}
+ /**
+ * @return RatingCollection
+ */
public function getRating()
{
if (!$this->getRatingCollection()) {
@@ -131,12 +144,20 @@ public function getRating()
return $this->getRatingCollection();
}
+ /**
+ * @return $this
+ */
public function setIndependentMode()
{
$this->setIsIndependentMode(true);
return $this;
}
+ /**
+ * @param Option $option
+ * @param Rating $rating
+ * @return bool
+ */
public function isSelected($option, $rating)
{
if ($this->getIsIndependentMode()) {
diff --git a/app/code/Magento/Review/Block/Adminhtml/Rating/Summary.php b/app/code/Magento/Review/Block/Adminhtml/Rating/Summary.php
index f1b4eda9b0565..11abe14d21f44 100644
--- a/app/code/Magento/Review/Block/Adminhtml/Rating/Summary.php
+++ b/app/code/Magento/Review/Block/Adminhtml/Rating/Summary.php
@@ -24,13 +24,18 @@
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
+namespace Magento\Review\Block\Adminhtml\Rating;
+
+use Magento\Rating\Model\Resource\Rating\Collection as RatingCollection;
+
/**
* Adminhtml summary rating stars
*/
-namespace Magento\Review\Block\Adminhtml\Rating;
-
class Summary extends \Magento\Backend\Block\Template
{
+ /**
+ * @var string
+ */
protected $_template = 'Magento_Rating::rating/stars/summary.phtml';
/**
@@ -77,6 +82,9 @@ protected function _construct()
}
}
+ /**
+ * @return RatingCollection
+ */
public function getRating()
{
if (!$this->getRatingCollection()) {
@@ -89,6 +97,9 @@ public function getRating()
return $this->getRatingCollection();
}
+ /**
+ * @return string
+ */
public function getRatingSummary()
{
if (!$this->getRatingSummaryCache()) {
diff --git a/app/code/Magento/Review/Block/Customer/ListCustomer.php b/app/code/Magento/Review/Block/Customer/ListCustomer.php
index ce91b039562c5..e2a46d8c5b729 100644
--- a/app/code/Magento/Review/Block/Customer/ListCustomer.php
+++ b/app/code/Magento/Review/Block/Customer/ListCustomer.php
@@ -23,7 +23,7 @@
* @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
-
+namespace Magento\Review\Block\Customer;
/**
* Customer Reviews list block
@@ -32,8 +32,6 @@
* @package Magento_Review
* @author Magento Core Team
*/
-namespace Magento\Review\Block\Customer;
-
class ListCustomer extends \Magento\Customer\Block\Account\Dashboard
{
/**
@@ -67,6 +65,9 @@ public function __construct(
$this->_isScopePrivate = true;
}
+ /**
+ * @return $this
+ */
protected function _initCollection()
{
$this->_collection = $this->_collectionFactory->create();
@@ -157,7 +158,7 @@ public function getProductLink()
/**
* Format date in short format
*
- * @param $date
+ * @param string $date
* @return string
*/
public function dateFormat($date)
diff --git a/app/code/Magento/Review/Block/Customer/Recent.php b/app/code/Magento/Review/Block/Customer/Recent.php
index 3e2ea6e2bb482..c2d11019f5c73 100644
--- a/app/code/Magento/Review/Block/Customer/Recent.php
+++ b/app/code/Magento/Review/Block/Customer/Recent.php
@@ -26,6 +26,8 @@
namespace Magento\Review\Block\Customer;
+use Magento\Review\Model\Resource\Review\Product\Collection;
+
/**
* Recent Customer Reviews Block
*/
@@ -39,7 +41,7 @@ class Recent extends \Magento\View\Element\Template
/**
* Product reviews collection
*
- * @var \Magento\Review\Model\Resource\Review\Product\Collection
+ * @var Collection
*/
protected $_collection;
@@ -91,6 +93,9 @@ public function truncateString($value, $length = 80, $etc = '...', &$remainder =
));
}
+ /**
+ * @return $this
+ */
protected function _initCollection()
{
$this->_collection = $this->_collectionFactory->create();
@@ -104,11 +109,17 @@ protected function _initCollection()
return $this;
}
+ /**
+ * @return int
+ */
public function count()
{
return $this->_getCollection()->getSize();
}
+ /**
+ * @return Collection
+ */
protected function _getCollection()
{
if (!$this->_collection) {
@@ -117,31 +128,49 @@ protected function _getCollection()
return $this->_collection;
}
+ /**
+ * @return Collection
+ */
public function getCollection()
{
return $this->_getCollection();
}
+ /**
+ * @return string
+ */
public function getReviewLink()
{
return $this->getUrl('review/customer/view/');
}
+ /**
+ * @return string
+ */
public function getProductLink()
{
return $this->getUrl('catalog/product/view/');
}
+ /**
+ * @return string
+ */
public function dateFormat($date)
{
return $this->formatDate($date, \Magento\Core\Model\LocaleInterface::FORMAT_TYPE_SHORT);
}
+ /**
+ * @return string
+ */
public function getAllReviewsUrl()
{
return $this->getUrl('review/customer');
}
+ /**
+ * @return string
+ */
public function getReviewUrl($id)
{
return $this->getUrl('review/customer/view', array('id' => $id));
diff --git a/app/code/Magento/Review/Block/Customer/View.php b/app/code/Magento/Review/Block/Customer/View.php
index f2514ef107a53..b41a95cb47896 100644
--- a/app/code/Magento/Review/Block/Customer/View.php
+++ b/app/code/Magento/Review/Block/Customer/View.php
@@ -34,6 +34,10 @@
namespace Magento\Review\Block\Customer;
+use Magento\Catalog\Model\Product as Product;
+use Magento\Rating\Model\Rating\Option\Vote\Collection as VoteCollection;
+use Magento\Review\Model\Review as Review;
+
class View extends \Magento\Catalog\Block\Product\AbstractProduct
{
protected $_template = 'customer/view.phtml';
@@ -136,6 +140,9 @@ protected function _construct()
$this->setReviewId($this->getRequest()->getParam('id', false));
}
+ /**
+ * @return Product
+ */
public function getProductData()
{
if( $this->getReviewId() && !$this->getProductCacheData() ) {
@@ -147,6 +154,9 @@ public function getProductData()
return $this->getProductCacheData();
}
+ /**
+ * @return Review
+ */
public function getReviewData()
{
if( $this->getReviewId() && !$this->getReviewCachedData() ) {
@@ -155,11 +165,17 @@ public function getReviewData()
return $this->getReviewCachedData();
}
+ /**
+ * @return string
+ */
public function getBackUrl()
{
return $this->getUrl('review/customer');
}
+ /**
+ * @return VoteCollection
+ */
public function getRating()
{
if( !$this->getRatingCollection() ) {
@@ -176,6 +192,9 @@ public function getRating()
return $this->getRatingCollection();
}
+ /**
+ * @return array
+ */
public function getRatingSummary()
{
if( !$this->getRatingSummaryCache() ) {
@@ -184,6 +203,9 @@ public function getRatingSummary()
return $this->getRatingSummaryCache();
}
+ /**
+ * @return int
+ */
public function getTotalReviews()
{
if( !$this->getTotalReviewsCache() ) {
@@ -192,6 +214,9 @@ public function getTotalReviews()
return $this->getTotalReviewsCache();
}
+ /**
+ * @return string
+ */
public function dateFormat($date)
{
return $this->formatDate($date, \Magento\Core\Model\LocaleInterface::FORMAT_TYPE_LONG);
@@ -200,7 +225,7 @@ public function dateFormat($date)
/**
* Check whether current customer is review owner
*
- * @return boolean
+ * @return bool
*/
public function isReviewOwner()
{
diff --git a/app/code/Magento/Review/Block/Form.php b/app/code/Magento/Review/Block/Form.php
index 31361997ee1b7..10ab8e13a75dd 100644
--- a/app/code/Magento/Review/Block/Form.php
+++ b/app/code/Magento/Review/Block/Form.php
@@ -33,6 +33,9 @@
*/
namespace Magento\Review\Block;
+use Magento\Catalog\Model\Product;
+use Magento\Rating\Model\Resource\Rating\Collection as RatingCollection;
+
class Form extends \Magento\View\Element\Template
{
/**
@@ -139,18 +142,27 @@ protected function _construct()
->assign('messages', $this->messageManager->getMessages(true));
}
+ /**
+ * @return Product
+ */
public function getProductInfo()
{
$product = $this->_productFactory->create();
return $product->load($this->getRequest()->getParam('id'));
}
+ /**
+ * @return string
+ */
public function getAction()
{
$productId = $this->getRequest()->getParam('id', false);
return $this->getUrl('review/product/post', array('id' => $productId));
}
+ /**
+ * @return RatingCollection
+ */
public function getRatings()
{
return $this->_ratingFactory->create()
diff --git a/app/code/Magento/Review/Block/Helper.php b/app/code/Magento/Review/Block/Helper.php
index a92e36adddc2f..98c04a9a85a1c 100644
--- a/app/code/Magento/Review/Block/Helper.php
+++ b/app/code/Magento/Review/Block/Helper.php
@@ -24,6 +24,10 @@
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
+namespace Magento\Review\Block;
+
+use Magento\Catalog\Model\Product;
+
/**
* Review helper
*
@@ -31,10 +35,11 @@
* @package Magento_Review
* @author Magento Core Team
*/
-namespace Magento\Review\Block;
-
class Helper extends \Magento\View\Element\Template
{
+ /**
+ * @var array
+ */
protected $_availableTemplates = array(
'default' => 'helper/summary.phtml',
'short' => 'helper/summary_short.phtml'
@@ -59,6 +64,12 @@ public function __construct(
parent::__construct($context, $data);
}
+ /**
+ * @param Product $product
+ * @param string $templateType
+ * @param bool $displayIfNoReviews
+ * @return string
+ */
public function getSummaryHtml($product, $templateType, $displayIfNoReviews)
{
// pick template among available
@@ -77,16 +88,25 @@ public function getSummaryHtml($product, $templateType, $displayIfNoReviews)
return $this->toHtml();
}
+ /**
+ * @return string
+ */
public function getRatingSummary()
{
return $this->getProduct()->getRatingSummary()->getRatingSummary();
}
+ /**
+ * @return int
+ */
public function getReviewsCount()
{
return $this->getProduct()->getRatingSummary()->getReviewsCount();
}
+ /**
+ * @return string
+ */
public function getReviewsUrl()
{
return $this->getUrl('review/product/list', array(
@@ -102,6 +122,7 @@ public function getReviewsUrl()
*
* @param string $type
* @param string $template
+ * @return void
*/
public function addTemplate($type, $template)
{
diff --git a/app/code/Magento/Review/Block/Product/View.php b/app/code/Magento/Review/Block/Product/View.php
index 9ad39b65b6a26..93c8ed0d78580 100644
--- a/app/code/Magento/Review/Block/Product/View.php
+++ b/app/code/Magento/Review/Block/Product/View.php
@@ -23,6 +23,9 @@
* @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
+namespace Magento\Review\Block\Product;
+
+use Magento\Review\Model\Resource\Review\Collection as ReviewCollection;
/**
* Product Reviews Page
@@ -31,12 +34,10 @@
* @package Magento_Review
* @author Magento Core Team
*/
-namespace Magento\Review\Block\Product;
-
class View extends \Magento\Catalog\Block\Product\View
{
/**
- * @var \Magento\Review\Model\Resource\Review\Collection
+ * @var ReviewCollection
*/
protected $_reviewsCollection;
@@ -155,6 +156,9 @@ public function getReviewsSummaryHtml(
;
}
+ /**
+ * @return ReviewCollection
+ */
public function getReviewsCollection()
{
if (null === $this->_reviewsCollection) {
diff --git a/app/code/Magento/Review/Block/Product/View/ListView.php b/app/code/Magento/Review/Block/Product/View/ListView.php
index 09e1dfc70a59b..a7f419253c757 100644
--- a/app/code/Magento/Review/Block/Product/View/ListView.php
+++ b/app/code/Magento/Review/Block/Product/View/ListView.php
@@ -23,6 +23,7 @@
* @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
+namespace Magento\Review\Block\Product\View;
/**
* Detailed Product Reviews
@@ -31,17 +32,24 @@
* @package Magento_Review
* @author Magento Core Team
*/
-namespace Magento\Review\Block\Product\View;
-
class ListView extends \Magento\Review\Block\Product\View
{
+ /**
+ * @var false
+ */
protected $_forceHasOptions = false;
+ /**
+ * @return int
+ */
public function getProductId()
{
return $this->_coreRegistry->registry('product')->getId();
}
+ /**
+ * @return $this
+ */
protected function _prepareLayout()
{
parent::_prepareLayout();
@@ -54,6 +62,9 @@ protected function _prepareLayout()
return $this;
}
+ /**
+ * @return $this
+ */
protected function _beforeToHtml()
{
$this->getReviewsCollection()
@@ -62,6 +73,9 @@ protected function _beforeToHtml()
return parent::_beforeToHtml();
}
+ /**
+ * @return string
+ */
public function getReviewUrl($id)
{
return $this->getUrl('*/*/view', array('id' => $id));
diff --git a/app/code/Magento/Review/Block/Product/View/Other.php b/app/code/Magento/Review/Block/Product/View/Other.php
index 2f204470c5cda..e4e6d04c2384d 100644
--- a/app/code/Magento/Review/Block/Product/View/Other.php
+++ b/app/code/Magento/Review/Block/Product/View/Other.php
@@ -24,11 +24,11 @@
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
+namespace Magento\Review\Block\Product\View;
+
/**
* Product view other block
*/
-namespace Magento\Review\Block\Product\View;
-
class Other extends \Magento\View\Element\Template
{
/**
diff --git a/app/code/Magento/Review/Block/View.php b/app/code/Magento/Review/Block/View.php
index b66af65dd3450..080ecb97caf57 100644
--- a/app/code/Magento/Review/Block/View.php
+++ b/app/code/Magento/Review/Block/View.php
@@ -36,6 +36,9 @@
class View extends \Magento\Catalog\Block\Product\AbstractProduct
{
+ /**
+ * @var string
+ */
protected $_template = 'view.phtml';
/**
diff --git a/app/code/Magento/Review/Controller/Customer.php b/app/code/Magento/Review/Controller/Customer.php
index 791ab0b6d1848..6b557555a7d8c 100644
--- a/app/code/Magento/Review/Controller/Customer.php
+++ b/app/code/Magento/Review/Controller/Customer.php
@@ -70,6 +70,9 @@ public function dispatch(RequestInterface $request)
return parent::dispatch($request);
}
+ /**
+ * @return void
+ */
public function indexAction()
{
$this->_view->loadLayout();
@@ -87,6 +90,9 @@ public function indexAction()
$this->_view->renderLayout();
}
+ /**
+ * @return void
+ */
public function viewAction()
{
$this->_view->loadLayout();
diff --git a/app/code/Magento/Review/Controller/Product.php b/app/code/Magento/Review/Controller/Product.php
index ab4f2ff63799d..a90661fa3e9db 100644
--- a/app/code/Magento/Review/Controller/Product.php
+++ b/app/code/Magento/Review/Controller/Product.php
@@ -35,6 +35,7 @@
use Magento\App\Action\NotFoundException;
use Magento\App\RequestInterface;
+use Magento\Review\Model\Review;
class Product extends \Magento\App\Action\Action
{
@@ -241,8 +242,8 @@ protected function _loadProduct($productId)
* Load review model with data by passed id.
* Return false if review was not loaded or review is not approved.
*
- * @param $reviewId
- * @return bool|\Magento\Review\Model\Review
+ * @param int $reviewId
+ * @return bool|Review
*/
protected function _loadReview($reviewId)
{
@@ -251,7 +252,7 @@ protected function _loadReview($reviewId)
}
$review = $this->_reviewFactory->create()->load($reviewId);
- /* @var $review \Magento\Review\Model\Review */
+ /* @var $review Review */
if (!$review->getId()
|| !$review->isApproved()
|| !$review->isAvailableOnStore($this->_storeManager->getStore())
@@ -266,6 +267,8 @@ protected function _loadReview($reviewId)
/**
* Submit new review action
+ *
+ * @return void
*/
public function postAction()
{
@@ -289,14 +292,14 @@ public function postAction()
$session = $this->_session;
/* @var $session \Magento\Core\Model\Session */
$review = $this->_reviewFactory->create()->setData($data);
- /* @var $review \Magento\Review\Model\Review */
+ /* @var $review Review */
$validate = $review->validate();
if ($validate === true) {
try {
- $review->setEntityId($review->getEntityIdByCode(\Magento\Review\Model\Review::ENTITY_PRODUCT_CODE))
+ $review->setEntityId($review->getEntityIdByCode(Review::ENTITY_PRODUCT_CODE))
->setEntityPkValue($product->getId())
- ->setStatusId(\Magento\Review\Model\Review::STATUS_PENDING)
+ ->setStatusId(Review::STATUS_PENDING)
->setCustomerId($this->_customerSession->getCustomerId())
->setStoreId($this->_storeManager->getStore()->getId())
->setStores(array($this->_storeManager->getStore()->getId()))
@@ -339,6 +342,7 @@ public function postAction()
/**
* Show list of product's reviews
*
+ * @return void
*/
public function listAction()
{
@@ -373,6 +377,7 @@ public function listAction()
/**
* Show details of one review
*
+ * @return void
*/
public function viewAction()
{
@@ -396,6 +401,7 @@ public function viewAction()
/**
* Load specific layout handles by product type id
*
+ * @return void
*/
protected function _initProductLayout($product)
{
diff --git a/app/code/Magento/Review/Helper/Action/Pager.php b/app/code/Magento/Review/Helper/Action/Pager.php
index 651b24717bb1d..94321d412917b 100644
--- a/app/code/Magento/Review/Helper/Action/Pager.php
+++ b/app/code/Magento/Review/Helper/Action/Pager.php
@@ -66,6 +66,7 @@ public function __construct(
* Set storage id
*
* @param $storageId
+ * @return void
*/
public function setStorageId($storageId)
{
@@ -76,7 +77,7 @@ public function setStorageId($storageId)
* Set items to storage
*
* @param array $items
- * @return \Magento\Review\Helper\Action\Pager
+ * @return $this
*/
public function setItems(array $items)
{
@@ -88,6 +89,8 @@ public function setItems(array $items)
/**
* Load stored items
+ *
+ * @return void
*/
protected function _loadItems()
{
@@ -129,7 +132,6 @@ public function getPreviousItemId($id)
}
/**
- *
*
* @param mixed $value
* @return int|bool
diff --git a/app/code/Magento/Review/Model/Resource/Review.php b/app/code/Magento/Review/Model/Resource/Review.php
index 2010a0ac73f7a..a738d34a5134d 100644
--- a/app/code/Magento/Review/Model/Resource/Review.php
+++ b/app/code/Magento/Review/Model/Resource/Review.php
@@ -23,7 +23,9 @@
* @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
+namespace Magento\Review\Model\Resource;
+use Magento\Core\Model\AbstractModel;
/**
* Review resource model
@@ -32,8 +34,6 @@
* @package Magento_Review
* @author Magento Core Team
*/
-namespace Magento\Review\Model\Resource;
-
class Review extends \Magento\Core\Model\Resource\Db\AbstractDb
{
/**
@@ -147,7 +147,7 @@ protected function _construct()
*
* @param string $field
* @param mixed $value
- * @param unknown_type $object
+ * @param AbstractModel $object
* @return \Zend_Db_Select
*/
protected function _getLoadSelect($field, $value, $object)
@@ -163,10 +163,10 @@ protected function _getLoadSelect($field, $value, $object)
/**
* Perform actions before object save
*
- * @param \Magento\Core\Model\AbstractModel $object
- * @return $this|\Magento\Core\Model\Resource\Db\AbstractDb
+ * @param AbstractModel $object
+ * @return $this
*/
- protected function _beforeSave(\Magento\Core\Model\AbstractModel $object)
+ protected function _beforeSave(AbstractModel $object)
{
if (!$object->getId()) {
$object->setCreatedAt($this->_date->gmtDate());
@@ -184,10 +184,10 @@ protected function _beforeSave(\Magento\Core\Model\AbstractModel $object)
/**
* Perform actions after object save
*
- * @param \Magento\Object $object
- * @return \Magento\Review\Model\Resource\Review
+ * @param AbstractModel $object
+ * @return $this
*/
- protected function _afterSave(\Magento\Core\Model\AbstractModel $object)
+ protected function _afterSave(AbstractModel $object)
{
$adapter = $this->_getWriteAdapter();
/**
@@ -249,10 +249,10 @@ protected function _afterSave(\Magento\Core\Model\AbstractModel $object)
/**
* Perform actions after object load
*
- * @param \Magento\Object $object
- * @return \Magento\Review\Model\Resource\Review
+ * @param AbstractModel $object
+ * @return $this
*/
- protected function _afterLoad(\Magento\Core\Model\AbstractModel $object)
+ protected function _afterLoad(AbstractModel $object)
{
$adapter = $this->_getReadAdapter();
$select = $adapter->select()
@@ -270,10 +270,10 @@ protected function _afterLoad(\Magento\Core\Model\AbstractModel $object)
/**
* Action before delete
*
- * @param \Magento\Core\Model\AbstractModel $object
- * @return \Magento\Review\Model\Resource\Review
+ * @param AbstractModel $object
+ * @return $this
*/
- protected function _beforeDelete(\Magento\Core\Model\AbstractModel $object)
+ protected function _beforeDelete(AbstractModel $object)
{
// prepare rating ids, that depend on review
$this->_deleteCache = array(
@@ -286,10 +286,10 @@ protected function _beforeDelete(\Magento\Core\Model\AbstractModel $object)
/**
* Perform actions after object delete
*
- * @param \Magento\Core\Model\AbstractModel $object
- * @return \Magento\Review\Model\Resource\Review
+ * @param AbstractModel $object
+ * @return $this
*/
- public function afterDeleteCommit(\Magento\Core\Model\AbstractModel $object)
+ public function afterDeleteCommit(AbstractModel $object)
{
$this->aggregate($object);
@@ -337,7 +337,8 @@ public function getTotalReviews($entityPkValue, $approvedOnly = false, $storeId
/**
* Aggregate
*
- * @param \Magento\Core\Model\AbstractModel $object
+ * @param AbstractModel $object
+ * @return void
*/
public function aggregate($object)
{
@@ -420,9 +421,9 @@ protected function _loadVotedRatingIds($reviewId)
* Aggregate this review's ratings.
* Useful, when changing the review.
*
- * @param array $ratingIds
+ * @param int[] $ratingIds
* @param int $entityPkValue
- * @return \Magento\Review\Model\Resource\Review
+ * @return $this
*/
protected function _aggregateRatings($ratingIds, $entityPkValue)
{
@@ -442,6 +443,7 @@ protected function _aggregateRatings($ratingIds, $entityPkValue)
*
* @param int $reviewId
* @param int $entityPkValue
+ * @return void
*/
public function reAggregateReview($reviewId, $entityPkValue)
{
diff --git a/app/code/Magento/Review/Model/Resource/Review/Collection.php b/app/code/Magento/Review/Model/Resource/Review/Collection.php
index ba06eae13fdd0..0ccbe91e17361 100644
--- a/app/code/Magento/Review/Model/Resource/Review/Collection.php
+++ b/app/code/Magento/Review/Model/Resource/Review/Collection.php
@@ -140,7 +140,7 @@ protected function _construct()
/**
* init select
*
- * @return \Magento\Review\Model\Resource\Review\Product\Collection
+ * @return $this
*/
protected function _initSelect()
{
@@ -154,7 +154,7 @@ protected function _initSelect()
/**
* @param int|string $customerId
- * @return \Magento\Review\Model\Resource\Review\Collection
+ * @return $this
*/
public function addCustomerFilter($customerId)
{
@@ -167,8 +167,8 @@ public function addCustomerFilter($customerId)
/**
* Add store filter
*
- * @param int|array $storeId
- * @return \Magento\Review\Model\Resource\Review\Collection
+ * @param int|int[] $storeId
+ * @return $this
*/
public function addStoreFilter($storeId)
{
@@ -183,7 +183,7 @@ public function addStoreFilter($storeId)
/**
* Add stores data
*
- * @return \Magento\Review\Model\Resource\Review\Collection
+ * @return $this
*/
public function addStoreData()
{
@@ -196,7 +196,7 @@ public function addStoreData()
*
* @param int|string $entity
* @param int $pkValue
- * @return \Magento\Review\Model\Resource\Review\Collection
+ * @return $this
*/
public function addEntityFilter($entity, $pkValue)
{
@@ -225,7 +225,7 @@ public function addEntityFilter($entity, $pkValue)
* Add status filter
*
* @param int|string $status
- * @return \Magento\Review\Model\Resource\Review\Collection
+ * @return $this
*/
public function addStatusFilter($status)
{
@@ -245,7 +245,7 @@ public function addStatusFilter($status)
* Set date order
*
* @param string $dir
- * @return \Magento\Review\Model\Resource\Review\Collection
+ * @return $this
*/
public function setDateOrder($dir = 'DESC')
{
@@ -256,7 +256,7 @@ public function setDateOrder($dir = 'DESC')
/**
* Add rate votes
*
- * @return \Magento\Review\Model\Resource\Review\Collection
+ * @return $this
*/
public function addRateVotes()
{
@@ -276,7 +276,7 @@ public function addRateVotes()
/**
* Add reviews total count
*
- * @return \Magento\Review\Model\Resource\Review\Collection
+ * @return $this
*/
public function addReviewsTotalCount()
{
@@ -295,7 +295,7 @@ public function addReviewsTotalCount()
*
* @param boolean $printQuery
* @param boolean $logQuery
- * @return \Magento\Review\Model\Resource\Review\Collection
+ * @return $this
*/
public function load($printQuery = false, $logQuery = false)
{
@@ -313,6 +313,7 @@ public function load($printQuery = false, $logQuery = false)
/**
* Add store data
*
+ * @return void
*/
protected function _addStoreData()
{
diff --git a/app/code/Magento/Review/Model/Resource/Review/Product/Collection.php b/app/code/Magento/Review/Model/Resource/Review/Product/Collection.php
index c4cfe55e4d327..0ddcd16cb2a72 100644
--- a/app/code/Magento/Review/Model/Resource/Review/Product/Collection.php
+++ b/app/code/Magento/Review/Model/Resource/Review/Product/Collection.php
@@ -23,7 +23,9 @@
* @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
+namespace Magento\Review\Model\Resource\Review\Product;
+use \Magento\Eav\Model\Entity\Attribute\AbstractAttribute;
/**
* Review Product Collection
@@ -32,8 +34,6 @@
* @package Magento_Review
* @author Magento Core Team
*/
-namespace Magento\Review\Model\Resource\Review\Product;
-
class Collection extends \Magento\Catalog\Model\Resource\Product\Collection
{
/**
@@ -53,11 +53,10 @@ class Collection extends \Magento\Catalog\Model\Resource\Product\Collection
/**
* Add store data flag
*
- * @var boolean
+ * @var bool
*/
protected $_addStoreDataFlag = false;
-
/**
* Filter by stores for the collection
*
@@ -162,7 +161,7 @@ protected function _construct()
/**
* init select
*
- * @return \Magento\Review\Model\Resource\Review\Product\Collection
+ * @return $this
*/
protected function _initSelect()
{
@@ -174,8 +173,8 @@ protected function _initSelect()
/**
* Adds store filter into array
*
- * @param mixed $storeId
- * @return \Magento\Review\Model\Resource\Review\Product\Collection
+ * @param int|int[] $storeId
+ * @return $this
*/
public function addStoreFilter($storeId = null)
{
@@ -202,7 +201,7 @@ public function addStoreFilter($storeId = null)
* Adds specific store id into array
*
* @param array $storeId
- * @return \Magento\Review\Model\Resource\Review\Product\Collection
+ * @return $this
*/
public function setStoreFilter($storeId)
{
@@ -227,7 +226,7 @@ public function setStoreFilter($storeId)
* Applies all store filters in one place to prevent multiple joins in select
*
* @param null|Zend_Db_Select $select
- * @return \Magento\Review\Model\Resource\Review\Product\Collection
+ * @return $this
*/
protected function _applyStoresFilterToSelect(\Zend_Db_Select $select = null)
{
@@ -259,7 +258,7 @@ protected function _applyStoresFilterToSelect(\Zend_Db_Select $select = null)
/**
* Add stores data
*
- * @return \Magento\Review\Model\Resource\Review\Product\Collection
+ * @return $this
*/
public function addStoreData()
{
@@ -271,7 +270,7 @@ public function addStoreData()
* Add customer filter
*
* @param int $customerId
- * @return \Magento\Review\Model\Resource\Review\Product\Collection
+ * @return $this
*/
public function addCustomerFilter($customerId)
{
@@ -284,7 +283,7 @@ public function addCustomerFilter($customerId)
* Add entity filter
*
* @param int $entityId
- * @return \Magento\Review\Model\Resource\Review\Product\Collection
+ * @return $this
*/
public function addEntityFilter($entityId)
{
@@ -296,8 +295,8 @@ public function addEntityFilter($entityId)
/**
* Add status filter
*
- * @param mixed $status
- * @return \Magento\Review\Model\Resource\Review\Product\Collection
+ * @param int $status
+ * @return $this
*/
public function addStatusFilter($status)
{
@@ -310,7 +309,7 @@ public function addStatusFilter($status)
* Set date order
*
* @param string $dir
- * @return \Magento\Review\Model\Resource\Review\Product\Collection
+ * @return $this
*/
public function setDateOrder($dir = 'DESC')
{
@@ -321,7 +320,7 @@ public function setDateOrder($dir = 'DESC')
/**
* Add review summary
*
- * @return \Magento\Review\Model\Resource\Review\Product\Collection
+ * @return $this
*/
public function addReviewSummary()
{
@@ -336,7 +335,7 @@ public function addReviewSummary()
/**
* Add rote votes
*
- * @return \Magento\Review\Model\Resource\Review\Product\Collection
+ * @return $this
*/
public function addRateVotes()
{
@@ -352,9 +351,9 @@ public function addRateVotes()
}
/**
- * join fields to entity
+ * Join fields to entity
*
- * @return \Magento\Review\Model\Resource\Review\Product\Collection
+ * @return $this
*/
protected function _joinFields()
{
@@ -428,7 +427,7 @@ public function getSelectCountSql()
*
* @param string $attribute
* @param string $dir
- * @return \Magento\Review\Model\Resource\Review\Product\Collection
+ * @return $this
*/
public function setOrder($attribute, $dir = 'DESC')
{
@@ -457,10 +456,10 @@ public function setOrder($attribute, $dir = 'DESC')
/**
* Add attribute to filter
*
- * @param \Magento\Eav\Model\Entity\Attribute\AbstractAttribute|string $attribute
- * @param array $condition
+ * @param AbstractAttribute|string $attribute
+ * @param array|null $condition
* @param string $joinType
- * @return \Magento\Review\Model\Resource\Review\Product\Collection
+ * @return $this
*/
public function addAttributeToFilter($attribute, $condition = null, $joinType = 'inner')
{
@@ -527,7 +526,7 @@ public function getColumnValues($colName)
/**
* Action after load
*
- * @return \Magento\Review\Model\Resource\Review\Product\Collection
+ * @return $this
*/
protected function _afterLoad()
{
@@ -541,6 +540,7 @@ protected function _afterLoad()
/**
* Add store data
*
+ * @return void
*/
protected function _addStoreData()
{
@@ -577,7 +577,7 @@ protected function _addStoreData()
/**
* Redeclare parent method for store filters applying
*
- * @return \Magento\Review\Model\Resource\Review\Product\Collection
+ * @return $this
*/
protected function _beforeLoad()
{
diff --git a/app/code/Magento/Review/Model/Resource/Review/Summary.php b/app/code/Magento/Review/Model/Resource/Review/Summary.php
index 2f44a63753ae6..97ddf61f1eaa9 100644
--- a/app/code/Magento/Review/Model/Resource/Review/Summary.php
+++ b/app/code/Magento/Review/Model/Resource/Review/Summary.php
@@ -23,7 +23,9 @@
* @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
+namespace Magento\Review\Model\Resource\Review;
+use Magento\Core\Model\AbstractModel;
/**
* Review summary resource model
@@ -32,8 +34,6 @@
* @package Magento_Review
* @author Magento Core Team
*/
-namespace Magento\Review\Model\Resource\Review;
-
class Summary extends \Magento\Core\Model\Resource\Db\AbstractDb
{
/**
@@ -50,8 +50,8 @@ protected function _construct()
*
* @param string $field
* @param mixed $value
- * @param \Magento\Core\Model\AbstractModel $object
- * @return unknown
+ * @param AbstractModel $object
+ * @return \Zend_Db_Select
*/
protected function _getLoadSelect($field, $value, $object)
{
diff --git a/app/code/Magento/Review/Model/Review.php b/app/code/Magento/Review/Model/Review.php
index 252465010c7f5..2ce301b60d6cd 100644
--- a/app/code/Magento/Review/Model/Review.php
+++ b/app/code/Magento/Review/Model/Review.php
@@ -23,6 +23,11 @@
* @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
+namespace Magento\Review\Model;
+
+use Magento\Review\Model\Resource\Review\Product\Collection as ProductCollection;
+use Magento\Review\Model\Resource\Review\Status\Collection as StatusCollection;
+use Magento\Catalog\Model\Product;
/**
* Review model
@@ -41,8 +46,6 @@
* @package Magento_Review
* @author Magento Core Team
*/
-namespace Magento\Review\Model;
-
class Review extends \Magento\Core\Model\AbstractModel
{
/**
@@ -142,27 +145,47 @@ protected function _construct()
$this->_init('Magento\Review\Model\Resource\Review');
}
+ /**
+ * @return ProductCollection
+ */
public function getProductCollection()
{
return $this->_productFactory->create();
}
+ /**
+ * @return StatusCollection
+ */
public function getStatusCollection()
{
return $this->_statusFactory->create();
}
+ /**
+ * @param int $entityPkValue
+ * @param bool approvedOnly
+ * @param int $storeId
+ * @return int
+ */
public function getTotalReviews($entityPkValue, $approvedOnly=false, $storeId=0)
{
return $this->getResource()->getTotalReviews($entityPkValue, $approvedOnly, $storeId);
}
+ /**
+ * @return $this
+ */
public function aggregate()
{
$this->getResource()->aggregate($this);
return $this;
}
+ /**
+ * @param Product $product
+ * @param int $storeId
+ * @return void
+ */
public function getEntitySummary($product, $storeId=0)
{
$summaryData = $this->_summaryModFactory->create()
@@ -173,16 +196,25 @@ public function getEntitySummary($product, $storeId=0)
$product->setRatingSummary($summary);
}
+ /**
+ * @return int
+ */
public function getPendingStatus()
{
return self::STATUS_PENDING;
}
+ /**
+ * @return string
+ */
public function getReviewUrl()
{
return $this->_urlModel->getUrl('review/product/view', array('id' => $this->getReviewId()));
}
+ /**
+ * @return bool|string[]
+ */
public function validate()
{
$errors = array();
@@ -219,8 +251,8 @@ protected function _afterDeleteCommit()
/**
* Append review summary to product collection
*
- * @param \Magento\Catalog\Model\Resource\Product\Collection $collection
- * @return \Magento\Review\Model\Review
+ * @param ProductCollection $collection
+ * @return $this
*/
public function appendSummary($collection)
{
@@ -249,6 +281,9 @@ public function appendSummary($collection)
return $this;
}
+ /**
+ * @return $this
+ */
protected function _beforeDelete()
{
$this->_protectFromNonAdmin();
diff --git a/app/code/Magento/Review/Model/Review/Summary.php b/app/code/Magento/Review/Model/Review/Summary.php
index 4118a2a5407c0..9ce693020bfa3 100644
--- a/app/code/Magento/Review/Model/Review/Summary.php
+++ b/app/code/Magento/Review/Model/Review/Summary.php
@@ -23,13 +23,11 @@
* @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
+namespace Magento\Review\Model\Review;
/**
* Review summary
*/
-
-namespace Magento\Review\Model\Review;
-
class Summary extends \Magento\Core\Model\AbstractModel
{
/**
@@ -49,16 +47,25 @@ public function __construct(
parent::__construct($context, $registry, $resource, $resourceCollection, $data);
}
+ /**
+ * @return int
+ */
public function getEntityPkValue()
{
return $this->_getData('entity_pk_value');
}
+ /**
+ * @return string
+ */
public function getRatingSummary()
{
return $this->_getData('rating_summary');
}
+ /**
+ * @return int
+ */
public function getReviewsCount()
{
return $this->_getData('reviews_count');
diff --git a/app/code/Magento/Review/etc/frontend/di.xml b/app/code/Magento/Review/etc/frontend/di.xml
index 97900597754f7..0959fd7c574db 100644
--- a/app/code/Magento/Review/etc/frontend/di.xml
+++ b/app/code/Magento/Review/etc/frontend/di.xml
@@ -50,16 +50,16 @@
-
- /review/customer/
-
+
+ - /review/customer/
+
-
- post
-
+
+ - post
+
diff --git a/app/code/Magento/Rss/App/Action/Plugin/Authentication.php b/app/code/Magento/Rss/App/Action/Plugin/Authentication.php
index d5a579d2ed2c5..8cd80cb51b846 100644
--- a/app/code/Magento/Rss/App/Action/Plugin/Authentication.php
+++ b/app/code/Magento/Rss/App/Action/Plugin/Authentication.php
@@ -56,7 +56,7 @@ class Authentication extends \Magento\Backend\App\Action\Plugin\Authentication
/**
* @param \Magento\Backend\Model\Auth $auth
- * @param \Magento\Backend\Model\Url $url
+ * @param \Magento\Backend\Model\UrlInterface $url
* @param \Magento\App\ResponseInterface $response
* @param \Magento\App\ActionFlag $actionFlag
* @param \Magento\Message\ManagerInterface $messageManager
@@ -66,7 +66,7 @@ class Authentication extends \Magento\Backend\App\Action\Plugin\Authentication
*/
public function __construct(
\Magento\Backend\Model\Auth $auth,
- \Magento\Backend\Model\Url $url,
+ \Magento\Backend\Model\UrlInterface $url,
\Magento\App\ResponseInterface $response,
\Magento\App\ActionFlag $actionFlag,
\Magento\Message\ManagerInterface $messageManager,
diff --git a/app/code/Magento/Rss/Block/Catalog/AbstractCatalog.php b/app/code/Magento/Rss/Block/Catalog/AbstractCatalog.php
index 5244c5699c48b..cf0e59c185a7f 100644
--- a/app/code/Magento/Rss/Block/Catalog/AbstractCatalog.php
+++ b/app/code/Magento/Rss/Block/Catalog/AbstractCatalog.php
@@ -29,23 +29,15 @@
class AbstractCatalog extends \Magento\Rss\Block\AbstractBlock
{
/**
- * Stored price block instances
- * @var array
+ * Block alias fallback
*/
- protected $_priceBlock = array();
+ const DEFAULT_TYPE = 'default';
/**
- * Stored price blocks info
+ * Stored price block instances
* @var array
*/
- protected $_priceBlockTypes = array();
-
- /**
- * Default values for price block and template
- * @var string
- */
- protected $_priceBlockDefaultTemplate = 'rss/product/price.phtml';
- protected $_priceBlockDefaultType = 'Magento\Catalog\Block\Product\Price';
+ protected $_priceBlock = array();
/**
* Whether to show "As low as" as a link
@@ -87,37 +79,27 @@ public function __construct(
/**
* Return Price Block renderer for specified product type
*
- * @param string $productTypeId Catalog Product type
- * @return \Magento\View\Element\AbstractBlock
+ * @param string $type Catalog Product type
+ * @return \Magento\View\Element\Template
*/
- protected function _getPriceBlock($productTypeId)
+ protected function _getPriceBlock($type)
{
- if (!isset($this->_priceBlock[$productTypeId])) {
- $block = $this->_priceBlockDefaultType;
- if (isset($this->_priceBlockTypes[$productTypeId])) {
- if ($this->_priceBlockTypes[$productTypeId]['block'] != '') {
- $block = $this->_priceBlockTypes[$productTypeId]['block'];
- }
+ if (!isset($this->_priceBlock[$type])) {
+ /** @var \Magento\View\Element\RendererList $rendererList */
+ $rendererList = $this->getRendererListName()
+ ? $this->getLayout()->getBlock($this->getRendererListName())
+ : $this->getChildBlock('renderer.list');
+ if (!$rendererList) {
+ throw new \RuntimeException(
+ 'Renderer list for block "' . $this->getNameInLayout() . '" is not defined'
+ );
}
- $this->_priceBlock[$productTypeId] = $this->getLayout()->createBlock($block);
+ $overriddenTemplates = $this->getOverriddenTemplates() ?: array();
+ $template = isset($overriddenTemplates[$type]) ? $overriddenTemplates[$type] : $this->getRendererTemplate();
+ $renderer = $rendererList->getRenderer($type, self::DEFAULT_TYPE, $template);
+ $this->_priceBlock[$type] = $renderer;
}
- return $this->_priceBlock[$productTypeId];
- }
-
- /**
- * Return template for Price Block renderer
- *
- * @param string $productTypeId Catalog Product type
- * @return string
- */
- protected function _getPriceBlockTemplate($productTypeId)
- {
- if (isset($this->_priceBlockTypes[$productTypeId])) {
- if ($this->_priceBlockTypes[$productTypeId]['template'] != '') {
- return $this->_priceBlockTypes[$productTypeId]['template'];
- }
- }
- return $this->_priceBlockDefaultTemplate;
+ return $this->_priceBlock[$type];
}
/**
@@ -136,28 +118,10 @@ public function getPriceHtml($product, $displayMinimalPrice = false, $idSuffix='
}
return $this->_getPriceBlock($typeId)
- ->setTemplate($this->_getPriceBlockTemplate($typeId))
->setProduct($product)
->setDisplayMinimalPrice($displayMinimalPrice)
->setIdSuffix($idSuffix)
->setUseLinkForAsLowAs($this->_useLinkForAsLowAs)
->toHtml();
}
-
- /**
- * Adding customized price template for product type, used as action in layouts
- *
- * @param string $type Catalog Product Type
- * @param string $block Block Type
- * @param string $template Template
- */
- public function addPriceBlockType($type, $block = '', $template = '')
- {
- if ($type) {
- $this->_priceBlockTypes[$type] = array(
- 'block' => $block,
- 'template' => $template
- );
- }
- }
}
diff --git a/app/code/Magento/Rss/Block/Catalog/Review.php b/app/code/Magento/Rss/Block/Catalog/Review.php
index ded1c8572161c..f569004435741 100644
--- a/app/code/Magento/Rss/Block/Catalog/Review.php
+++ b/app/code/Magento/Rss/Block/Catalog/Review.php
@@ -51,18 +51,12 @@ class Review extends \Magento\Backend\Block\AbstractBlock
*/
protected $_storeManager;
- /**
- * @var \Magento\Core\Model\Url
- */
- protected $_urlModel;
-
/**
* @param \Magento\Backend\Block\Context $context
* @param \Magento\Rss\Model\RssFactory $rssFactory
* @param \Magento\Core\Model\Resource\Iterator $resourceIterator
* @param \Magento\Review\Model\ReviewFactory $reviewFactory
* @param \Magento\Core\Model\StoreManagerInterface $storeManager
- * @param \Magento\Core\Model\Url $urlModel
* @param array $data
*/
public function __construct(
@@ -71,14 +65,12 @@ public function __construct(
\Magento\Core\Model\Resource\Iterator $resourceIterator,
\Magento\Review\Model\ReviewFactory $reviewFactory,
\Magento\Core\Model\StoreManagerInterface $storeManager,
- \Magento\Core\Model\Url $urlModel,
array $data = array()
) {
$this->_rssFactory = $rssFactory;
$this->_resourceIterator = $resourceIterator;
$this->_reviewFactory = $reviewFactory;
$this->_storeManager = $storeManager;
- $this->_urlModel = $urlModel;
parent::__construct($context, $data);
}
@@ -130,8 +122,8 @@ public function addReviewItemXmlCallback($args)
$rssObj = $args['rssObj'];
$row = $args['row'];
- $productUrl = $this->_urlModel
- ->setStore($row['store_id'])
+ $productUrl = $this->_urlBuilder
+ ->setScope($row['store_id'])
->getUrl('catalog/product/view', array('id' => $row['entity_id']));
$reviewUrl = $this->getUrl(
'catalog/product_review/edit/',
diff --git a/app/code/Magento/Rss/Controller/Adminhtml/Authenticate.php b/app/code/Magento/Rss/Controller/Adminhtml/Authenticate.php
index 991f4381c059f..c025c09eccb38 100644
--- a/app/code/Magento/Rss/Controller/Adminhtml/Authenticate.php
+++ b/app/code/Magento/Rss/Controller/Adminhtml/Authenticate.php
@@ -39,6 +39,6 @@ class Authenticate extends \Magento\Backend\App\Action
public function __construct(Action\Context $context)
{
parent::__construct($context);
- $this->_objectManager->get('Magento\Backend\Model\Url')->turnOffSecretKey();
+ $this->_objectManager->get('Magento\Backend\Model\UrlInterface')->turnOffSecretKey();
}
}
diff --git a/app/code/Magento/Rss/Model/System/Config/Backend/Links.php b/app/code/Magento/Rss/Model/System/Config/Backend/Links.php
index 18b02f0d15452..84953cec8ddc3 100644
--- a/app/code/Magento/Rss/Model/System/Config/Backend/Links.php
+++ b/app/code/Magento/Rss/Model/System/Config/Backend/Links.php
@@ -41,7 +41,7 @@ class Links extends \Magento\Core\Model\Config\Value
* @param \Magento\Core\Model\Context $context
* @param \Magento\Core\Model\Registry $registry
* @param \Magento\Core\Model\StoreManagerInterface $storeManager
- * @param \Magento\Core\Model\Config $config
+ * @param \Magento\App\ConfigInterface $config
* @param \Magento\App\Cache\TypeListInterface $cacheTypeList
* @param \Magento\Core\Model\Resource\AbstractResource $resource
* @param \Magento\Data\Collection\Db $resourceCollection
@@ -51,7 +51,7 @@ public function __construct(
\Magento\Core\Model\Context $context,
\Magento\Core\Model\Registry $registry,
\Magento\Core\Model\StoreManagerInterface $storeManager,
- \Magento\Core\Model\Config $config,
+ \Magento\App\ConfigInterface $config,
\Magento\App\Cache\TypeListInterface $cacheTypeList,
\Magento\Core\Model\Resource\AbstractResource $resource = null,
\Magento\Data\Collection\Db $resourceCollection = null,
diff --git a/app/code/Magento/Rss/view/frontend/layout/rss_catalog_category.xml b/app/code/Magento/Rss/view/frontend/layout/rss_catalog_category.xml
index e5d031662dbe5..ae600eef4793f 100644
--- a/app/code/Magento/Rss/view/frontend/layout/rss_catalog_category.xml
+++ b/app/code/Magento/Rss/view/frontend/layout/rss_catalog_category.xml
@@ -24,11 +24,8 @@
*/
-->
+
diff --git a/app/code/Magento/Rss/view/frontend/layout/rss_catalog_new.xml b/app/code/Magento/Rss/view/frontend/layout/rss_catalog_new.xml
index 0961f315709e9..dfc688fd6bde0 100644
--- a/app/code/Magento/Rss/view/frontend/layout/rss_catalog_new.xml
+++ b/app/code/Magento/Rss/view/frontend/layout/rss_catalog_new.xml
@@ -24,11 +24,8 @@
*/
-->
+
diff --git a/app/code/Magento/Sales/Block/Adminhtml/Billing/Agreement/Grid.php b/app/code/Magento/Sales/Block/Adminhtml/Billing/Agreement/Grid.php
index ab034b11330ce..f21568db051d3 100644
--- a/app/code/Magento/Sales/Block/Adminhtml/Billing/Agreement/Grid.php
+++ b/app/code/Magento/Sales/Block/Adminhtml/Billing/Agreement/Grid.php
@@ -52,7 +52,6 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended
/**
* @param \Magento\Backend\Block\Template\Context $context
- * @param \Magento\Core\Model\Url $urlModel
* @param \Magento\Backend\Helper\Data $backendHelper
* @param \Magento\Payment\Helper\Data $paymentData
* @param \Magento\Sales\Model\Resource\Billing\Agreement\CollectionFactory $agreementFactory
@@ -61,7 +60,6 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended
*/
public function __construct(
\Magento\Backend\Block\Template\Context $context,
- \Magento\Core\Model\Url $urlModel,
\Magento\Backend\Helper\Data $backendHelper,
\Magento\Payment\Helper\Data $paymentData,
\Magento\Sales\Model\Resource\Billing\Agreement\CollectionFactory $agreementFactory,
@@ -71,7 +69,7 @@ public function __construct(
$this->_paymentData = $paymentData;
$this->_agreementFactory = $agreementFactory;
$this->_agreementModel = $agreementModel;
- parent::__construct($context, $urlModel, $backendHelper, $data);
+ parent::__construct($context, $backendHelper, $data);
}
/**
diff --git a/app/code/Magento/Sales/Block/Adminhtml/Billing/Agreement/View/Tab/Info.php b/app/code/Magento/Sales/Block/Adminhtml/Billing/Agreement/View/Tab/Info.php
index 002d19e665e4e..fae5615476164 100644
--- a/app/code/Magento/Sales/Block/Adminhtml/Billing/Agreement/View/Tab/Info.php
+++ b/app/code/Magento/Sales/Block/Adminhtml/Billing/Agreement/View/Tab/Info.php
@@ -43,27 +43,23 @@ class Info extends \Magento\Backend\Block\Template
*/
protected $_coreRegistry = null;
- /**
- * Core registry
- *
- * @var \Magento\Customer\Model\CustomerFactory
- */
- protected $_customerFactory;
+ /** @var \Magento\Customer\Service\V1\CustomerServiceInterface */
+ protected $_customerService;
/**
* @param \Magento\Backend\Block\Template\Context $context
* @param \Magento\Core\Model\Registry $registry
- * @param \Magento\Customer\Model\CustomerFactory $customerFactory
+ * @param \Magento\Customer\Service\V1\CustomerServiceInterface $customerService
* @param array $data
*/
public function __construct(
\Magento\Backend\Block\Template\Context $context,
\Magento\Core\Model\Registry $registry,
- \Magento\Customer\Model\CustomerFactory $customerFactory,
+ \Magento\Customer\Service\V1\CustomerServiceInterface $customerService,
array $data = array()
) {
$this->_coreRegistry = $registry;
- $this->_customerFactory = $customerFactory;
+ $this->_customerService = $customerService;
parent::__construct($context, $data);
}
@@ -126,11 +122,13 @@ protected function _toHtml()
{
$agreement = $this->_getBillingAgreement();
$this->setReferenceId($agreement->getReferenceId());
- $customer = $this->_customerFactory->create()->load($agreement->getCustomerId());
+ $customerId = $agreement->getCustomerId();
+ $customer = $this->_customerService->getCustomer($customerId);
+
+ $this->setCustomerEmail($customer->getEmail());
$this->setCustomerUrl(
- $this->getUrl('customer/index/edit', array('id' => $customer->getId()))
+ $this->getUrl('customer/index/edit', array('id' => $customerId))
);
- $this->setCustomerEmail($customer->getEmail());
$this->setStatus($agreement->getStatusLabel());
$this->setCreatedAt(
$this->formatDate($agreement->getCreatedAt(), 'short', true)
diff --git a/app/code/Magento/Sales/Block/Adminhtml/Creditmemo/Grid.php b/app/code/Magento/Sales/Block/Adminhtml/Creditmemo/Grid.php
index 59c01c8d39232..e0480bfd91cfe 100644
--- a/app/code/Magento/Sales/Block/Adminhtml/Creditmemo/Grid.php
+++ b/app/code/Magento/Sales/Block/Adminhtml/Creditmemo/Grid.php
@@ -45,7 +45,6 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended
/**
* @param \Magento\Backend\Block\Template\Context $context
- * @param \Magento\Core\Model\Url $urlModel
* @param \Magento\Backend\Helper\Data $backendHelper
* @param \Magento\Sales\Model\Order\CreditmemoFactory $creditmemoFactory
* @param \Magento\Sales\Model\Resource\Order\Creditmemo\Grid\CollectionFactory $collectionFactory
@@ -53,7 +52,6 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended
*/
public function __construct(
\Magento\Backend\Block\Template\Context $context,
- \Magento\Core\Model\Url $urlModel,
\Magento\Backend\Helper\Data $backendHelper,
\Magento\Sales\Model\Order\CreditmemoFactory $creditmemoFactory,
\Magento\Sales\Model\Resource\Order\Creditmemo\Grid\CollectionFactory $collectionFactory,
@@ -61,7 +59,7 @@ public function __construct(
) {
$this->_creditmemoFactory = $creditmemoFactory;
$this->_collectionFactory = $collectionFactory;
- parent::__construct($context, $urlModel, $backendHelper, $data);
+ parent::__construct($context, $backendHelper, $data);
}
protected function _construct()
diff --git a/app/code/Magento/Sales/Block/Adminhtml/Customer/Edit/Tab/Agreement.php b/app/code/Magento/Sales/Block/Adminhtml/Customer/Edit/Tab/Agreement.php
index 29007f631b396..26967cda12b08 100644
--- a/app/code/Magento/Sales/Block/Adminhtml/Customer/Edit/Tab/Agreement.php
+++ b/app/code/Magento/Sales/Block/Adminhtml/Customer/Edit/Tab/Agreement.php
@@ -51,7 +51,6 @@ class Agreement
/**
* @param \Magento\Backend\Block\Template\Context $context
- * @param \Magento\Core\Model\Url $urlModel
* @param \Magento\Backend\Helper\Data $backendHelper
* @param \Magento\Payment\Helper\Data $paymentData
* @param \Magento\Sales\Model\Resource\Billing\Agreement\CollectionFactory $agreementFactory
@@ -61,7 +60,6 @@ class Agreement
*/
public function __construct(
\Magento\Backend\Block\Template\Context $context,
- \Magento\Core\Model\Url $urlModel,
\Magento\Backend\Helper\Data $backendHelper,
\Magento\Payment\Helper\Data $paymentData,
\Magento\Sales\Model\Resource\Billing\Agreement\CollectionFactory $agreementFactory,
@@ -72,7 +70,6 @@ public function __construct(
$this->_coreRegistry = $coreRegistry;
parent::__construct(
$context,
- $urlModel,
$backendHelper,
$paymentData,
$agreementFactory,
@@ -119,7 +116,7 @@ public function getTabTitle()
public function canShowTab()
{
$customer = $this->_coreRegistry->registry('current_customer');
- return (bool)$customer->getId();
+ return !is_null($customer);
}
/**
@@ -154,8 +151,12 @@ public function getAfter()
*/
protected function _prepareCollection()
{
+ $customerId = $this->_coreRegistry->registry('current_customer_id');
+ if (!$customerId) {
+ $customerId = $this->_coreRegistry->registry('current_customer')->getId();
+ }
$collection = $this->_agreementFactory->create()
- ->addFieldToFilter('customer_id', $this->_coreRegistry->registry('current_customer')->getId())
+ ->addFieldToFilter('customer_id', $customerId)
->setOrder('created_at');
$this->setCollection($collection);
return \Magento\Backend\Block\Widget\Grid::_prepareCollection();
diff --git a/app/code/Magento/Sales/Block/Adminhtml/Customer/Edit/Tab/Recurring/Profile.php b/app/code/Magento/Sales/Block/Adminhtml/Customer/Edit/Tab/Recurring/Profile.php
index f20749ec7480f..d589742d0d7a6 100644
--- a/app/code/Magento/Sales/Block/Adminhtml/Customer/Edit/Tab/Recurring/Profile.php
+++ b/app/code/Magento/Sales/Block/Adminhtml/Customer/Edit/Tab/Recurring/Profile.php
@@ -18,19 +18,17 @@
* versions in the future. If you wish to customize Magento for your
* needs please refer to http://www.magentocommerce.com for more information.
*
- * @category Magento
- * @package Magento_Sales
* @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
/**
* Adminhtml customer recurring profiles tab
- *
- * @author Magento Core Team
*/
namespace Magento\Sales\Block\Adminhtml\Customer\Edit\Tab\Recurring;
+use Magento\Customer\Controller\Adminhtml\Index as CustomerController;
+
class Profile
extends \Magento\Sales\Block\Adminhtml\Recurring\Profile\Grid
implements \Magento\Backend\Block\Widget\Tab\TabInterface
@@ -42,9 +40,13 @@ class Profile
*/
protected $_coreRegistry = null;
+ /**
+ * @var int
+ */
+ protected $_currentCustomerId;
+
/**
* @param \Magento\Backend\Block\Template\Context $context
- * @param \Magento\Core\Model\Url $urlModel
* @param \Magento\Backend\Helper\Data $backendHelper
* @param \Magento\Payment\Helper\Data $paymentData
* @param \Magento\Sales\Model\Resource\Recurring\Profile\CollectionFactory $profileCollection
@@ -54,7 +56,6 @@ class Profile
*/
public function __construct(
\Magento\Backend\Block\Template\Context $context,
- \Magento\Core\Model\Url $urlModel,
\Magento\Backend\Helper\Data $backendHelper,
\Magento\Payment\Helper\Data $paymentData,
\Magento\Sales\Model\Resource\Recurring\Profile\CollectionFactory $profileCollection,
@@ -63,9 +64,19 @@ public function __construct(
array $data = array()
) {
$this->_coreRegistry = $coreRegistry;
+
+ // @todo remove usage of REGISTRY_CURRENT_CUSTOMER in advantage of REGISTRY_CURRENT_CUSTOMER_ID
+ $currentCustomer = $this->_coreRegistry->registry(CustomerController::REGISTRY_CURRENT_CUSTOMER);
+ if ($currentCustomer) {
+ $this->_currentCustomerId = $currentCustomer->getId();
+ } else {
+ $this->_currentCustomerId = $this->_coreRegistry->registry(
+ CustomerController::REGISTRY_CURRENT_CUSTOMER_ID
+ );
+ }
+
parent::__construct(
$context,
- $urlModel,
$backendHelper,
$paymentData,
$profileCollection,
@@ -111,8 +122,7 @@ public function getTabTitle()
*/
public function canShowTab()
{
- $customer = $this->_coreRegistry->registry('current_customer');
- return (bool)$customer->getId();
+ return (bool)$this->_currentCustomerId;
}
/**
@@ -132,12 +142,18 @@ public function isHidden()
*/
protected function _prepareCollection()
{
- $collection = $this->_profileCollection->create()
- ->addFieldToFilter('customer_id', $this->_coreRegistry->registry('current_customer')->getId());
+ if (!$this->_currentCustomerId) {
+ return $this;
+ }
+
+ $collection = $this->_profileCollection->create()->addFieldToFilter('customer_id', $this->_currentCustomerId);
+
if (!$this->getParam($this->getVarNameSort())) {
$collection->setOrder('profile_id', 'desc');
}
+
$this->setCollection($collection);
+
return parent::_prepareCollection();
}
diff --git a/app/code/Magento/Sales/Block/Adminhtml/Invoice/Grid.php b/app/code/Magento/Sales/Block/Adminhtml/Invoice/Grid.php
index cbe163e884030..5043c9b50e1fe 100644
--- a/app/code/Magento/Sales/Block/Adminhtml/Invoice/Grid.php
+++ b/app/code/Magento/Sales/Block/Adminhtml/Invoice/Grid.php
@@ -45,7 +45,6 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended
/**
* @param \Magento\Backend\Block\Template\Context $context
- * @param \Magento\Core\Model\Url $urlModel
* @param \Magento\Backend\Helper\Data $backendHelper
* @param \Magento\Sales\Model\Order\InvoiceFactory $invoiceFactory
* @param \Magento\Sales\Model\Resource\Order\Invoice\Grid\CollectionFactory $collectionFactory
@@ -53,7 +52,6 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended
*/
public function __construct(
\Magento\Backend\Block\Template\Context $context,
- \Magento\Core\Model\Url $urlModel,
\Magento\Backend\Helper\Data $backendHelper,
\Magento\Sales\Model\Order\InvoiceFactory $invoiceFactory,
\Magento\Sales\Model\Resource\Order\Invoice\Grid\CollectionFactory $collectionFactory,
@@ -61,7 +59,7 @@ public function __construct(
) {
$this->_invoiceFactory = $invoiceFactory;
$this->_collectionFactory = $collectionFactory;
- parent::__construct($context, $urlModel, $backendHelper, $data);
+ parent::__construct($context, $backendHelper, $data);
}
protected function _construct()
diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/Address/Form.php b/app/code/Magento/Sales/Block/Adminhtml/Order/Address/Form.php
index 15c4b2e2ad84e..348a185fc5a87 100644
--- a/app/code/Magento/Sales/Block/Adminhtml/Order/Address/Form.php
+++ b/app/code/Magento/Sales/Block/Adminhtml/Order/Address/Form.php
@@ -18,21 +18,15 @@
* versions in the future. If you wish to customize Magento for your
* needs please refer to http://www.magentocommerce.com for more information.
*
- * @category Magento
- * @package Magento_Sales
* @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
-/**
- * Adminhtml sales order edit address block
- *
- * @category Magento
- * @package Magento_Sales
- * @author Magento Core Team
- */
namespace Magento\Sales\Block\Adminhtml\Order\Address;
+/**
+ * Adminhtml sales order address block
+ */
class Form
extends \Magento\Sales\Block\Adminhtml\Order\Create\Form\Address
{
@@ -52,13 +46,12 @@ class Form
* @param \Magento\Data\FormFactory $formFactory
* @param \Magento\Core\Helper\Data $coreData
* @param \Magento\Json\EncoderInterface $jsonEncoder
- * @param \Magento\Customer\Model\AddressFactory $addressFactory
- * @param \Magento\Customer\Model\FormFactory $customerFormFactory
- * @param \Magento\Backend\Helper\Addresses $adminhtmlAddresses
+ * @param \Magento\Customer\Model\Metadata\FormFactory $customerFormFactory
* @param \Magento\Customer\Helper\Data $customerHelper
+ * @param \Magento\Customer\Service\V1\CustomerAddressServiceInterface $addressService
+ * @param \Magento\Customer\Helper\Address $addressHelper
* @param \Magento\Core\Model\Registry $registry
* @param array $data
- *
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function __construct(
@@ -68,10 +61,10 @@ public function __construct(
\Magento\Data\FormFactory $formFactory,
\Magento\Core\Helper\Data $coreData,
\Magento\Json\EncoderInterface $jsonEncoder,
- \Magento\Customer\Model\AddressFactory $addressFactory,
- \Magento\Customer\Model\FormFactory $customerFormFactory,
- \Magento\Backend\Helper\Addresses $adminhtmlAddresses,
+ \Magento\Customer\Model\Metadata\FormFactory $customerFormFactory,
\Magento\Customer\Helper\Data $customerHelper,
+ \Magento\Customer\Service\V1\CustomerAddressServiceInterface $addressService,
+ \Magento\Customer\Helper\Address $addressHelper,
\Magento\Core\Model\Registry $registry,
array $data = array()
) {
@@ -83,10 +76,10 @@ public function __construct(
$formFactory,
$coreData,
$jsonEncoder,
- $addressFactory,
$customerFormFactory,
- $adminhtmlAddresses,
$customerHelper,
+ $addressService,
+ $addressHelper,
$data
);
}
@@ -111,7 +104,9 @@ protected function _prepareForm()
parent::_prepareForm();
$this->_form->setId('edit_form');
$this->_form->setMethod('post');
- $this->_form->setAction($this->getUrl('sales/*/addressSave', array('address_id'=>$this->_getAddress()->getId())));
+ $this->_form->setAction(
+ $this->getUrl('sales/*/addressSave', array('address_id' => $this->_getAddress()->getId()))
+ );
$this->_form->setUseContainer(true);
return $this;
}
diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/AbstractCreate.php b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/AbstractCreate.php
index 942ff0f5072fb..f70617314472a 100644
--- a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/AbstractCreate.php
+++ b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/AbstractCreate.php
@@ -86,16 +86,6 @@ public function getQuote()
return $this->_getSession()->getQuote();
}
- /**
- * Retrieve customer model object
- *
- * @return \Magento\Customer\Model\Customer
- */
- public function getCustomer()
- {
- return $this->_getSession()->getCustomer();
- }
-
/**
* Retrieve customer identifier
*
diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Billing/Address.php b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Billing/Address.php
index a6900f817f540..c2fba38e16e01 100644
--- a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Billing/Address.php
+++ b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Billing/Address.php
@@ -97,7 +97,7 @@ public function getAddressId()
/**
* Return billing address object
*
- * @return \Magento\Customer\Model\Address
+ * @return \Magento\Sales\Model\Quote\Address
*/
public function getAddress()
{
diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Form.php b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Form.php
index 982d4c3bf2f53..5b9b5708f4b2a 100644
--- a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Form.php
+++ b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Form.php
@@ -18,40 +18,33 @@
* versions in the future. If you wish to customize Magento for your
* needs please refer to http://www.magentocommerce.com for more information.
*
- * @category Magento
- * @package Magento_Sales
* @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
-/**
- * Adminhtml sales order create sidebar
- *
- * @category Magento
- * @package Magento_Sales
- * @author Magento Core Team
- */
-
namespace Magento\Sales\Block\Adminhtml\Order\Create;
+/**
+ * Adminhtml sales order create form block
+ */
class Form extends \Magento\Sales\Block\Adminhtml\Order\Create\AbstractCreate
{
- /**
- * @var \Magento\Customer\Model\FormFactory
- */
+ /** @var \Magento\Customer\Model\Metadata\FormFactory */
protected $_customerFormFactory;
- /**
- * @var \Magento\Json\EncoderInterface
- */
+ /** @var \Magento\Json\EncoderInterface */
protected $_jsonEncoder;
+ /** @var \Magento\Customer\Service\V1\CustomerAddressServiceInterface */
+ protected $_addressService;
+
/**
* @param \Magento\Backend\Block\Template\Context $context
* @param \Magento\Json\EncoderInterface $jsonEncoder
* @param \Magento\Backend\Model\Session\Quote $sessionQuote
* @param \Magento\Sales\Model\AdminOrder\Create $orderCreate
- * @param \Magento\Customer\Model\FormFactory $customerFormFactory
+ * @param \Magento\Customer\Model\Metadata\FormFactory $customerFormFactory
+ * @param \Magento\Customer\Service\V1\CustomerAddressServiceInterface $addressService
* @param array $data
*/
public function __construct(
@@ -59,11 +52,13 @@ public function __construct(
\Magento\Backend\Model\Session\Quote $sessionQuote,
\Magento\Sales\Model\AdminOrder\Create $orderCreate,
\Magento\Json\EncoderInterface $jsonEncoder,
- \Magento\Customer\Model\FormFactory $customerFormFactory,
+ \Magento\Customer\Model\Metadata\FormFactory $customerFormFactory,
+ \Magento\Customer\Service\V1\CustomerAddressServiceInterface $addressService,
array $data = array()
) {
$this->_jsonEncoder = $jsonEncoder;
$this->_customerFormFactory = $customerFormFactory;
+ $this->_addressService = $addressService;
parent::__construct($context, $sessionQuote, $orderCreate, $data);
}
@@ -75,6 +70,7 @@ protected function _construct()
/**
* Retrieve url for loading blocks
+ *
* @return string
*/
public function getLoadBlockUrl()
@@ -84,6 +80,7 @@ public function getLoadBlockUrl()
/**
* Retrieve url for form submiting
+ *
* @return string
*/
public function getSaveUrl()
@@ -102,7 +99,7 @@ public function getCustomerSelectorDisplay()
public function getStoreSelectorDisplay()
{
- $storeId = $this->getStoreId();
+ $storeId = $this->getStoreId();
$customerId = $this->getCustomerId();
if (!is_null($customerId) && !$storeId) {
return 'block';
@@ -112,7 +109,7 @@ public function getStoreSelectorDisplay()
public function getDataSelectorDisplay()
{
- $storeId = $this->getStoreId();
+ $storeId = $this->getStoreId();
$customerId = $this->getCustomerId();
if (!is_null($customerId) && $storeId) {
return 'block';
@@ -123,16 +120,17 @@ public function getDataSelectorDisplay()
public function getOrderDataJson()
{
$data = array();
- if (!is_null($this->getCustomerId())) {
+ if ($this->getCustomerId()) {
$data['customer_id'] = $this->getCustomerId();
$data['addresses'] = array();
-
- /* @var $addressForm \Magento\Customer\Model\Form */
- $addressForm = $this->_customerFormFactory->create()
- ->setFormCode('adminhtml_customer_address')
- ->setStore($this->getStore());
- foreach ($this->getCustomer()->getAddresses() as $address) {
- $data['addresses'][$address->getId()] = $addressForm->setEntity($address)
+ $addresses = $this->_addressService->getAddresses($this->getCustomerId());
+ foreach ($addresses as $addressDto) {
+ $addressForm = $this->_customerFormFactory->create(
+ 'customer_address',
+ 'adminhtml_customer_address',
+ $addressDto->__toArray()
+ );
+ $data['addresses'][$addressDto->getId()] = $addressForm
->outputData(\Magento\Eav\Model\AttributeDataFactory::OUTPUT_FORMAT_JSON);
}
}
diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Form/AbstractForm.php b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Form/AbstractForm.php
index 36d1aa152fa39..8b028e58fe9ff 100644
--- a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Form/AbstractForm.php
+++ b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Form/AbstractForm.php
@@ -160,7 +160,7 @@ protected function _addAdditionalFormElementData(\Magento\Data\Form\Element\Abst
/**
* Add rendering EAV attributes to Form element
*
- * @param array|\Magento\Data\Collection $attributes
+ * @param \Magento\Customer\Service\V1\Dto\Eav\AttributeMetadata[] $attributes
* @param \Magento\Data\Form\AbstractForm $form
* @return \Magento\Sales\Block\Adminhtml\Order\Create\Form\AbstractForm
*/
@@ -174,16 +174,14 @@ protected function _addAttributesToForm($attributes, \Magento\Data\Form\Abstract
$renderers = $this->_getAdditionalFormElementRenderers();
foreach ($attributes as $attribute) {
- /** @var $attribute \Magento\Customer\Model\Attribute */
- $attribute->setStoreId($this->_sessionQuote->getStoreId());
- $inputType = $attribute->getFrontend()->getInputType();
+ $inputType = $attribute->getFrontendInput();
if ($inputType) {
$element = $form->addField($attribute->getAttributeCode(), $inputType, array(
'name' => $attribute->getAttributeCode(),
'label' => __($attribute->getStoreLabel()),
- 'class' => $attribute->getFrontend()->getClass(),
- 'required' => $attribute->getIsRequired(),
+ 'class' => $attribute->getFrontendClass(),
+ 'required' => $attribute->isRequired(),
));
if ($inputType == 'multiline') {
$element->setLineCount($attribute->getMultilineCount());
@@ -196,7 +194,11 @@ protected function _addAttributesToForm($attributes, \Magento\Data\Form\Abstract
}
if ($inputType == 'select' || $inputType == 'multiselect') {
- $element->setValues($attribute->getFrontend()->getSelectOptions());
+ $options = array();
+ foreach ($attribute->getOptions() as $optionDto) {
+ $options[] = $optionDto->__toArray();
+ }
+ $element->setValues($options);
} else if ($inputType == 'date') {
$format = $this->_locale->getDateFormat(\Magento\Core\Model\LocaleInterface::FORMAT_TYPE_SHORT);
$element->setImage($this->getViewFileUrl('images/grid-cal.gif'));
diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Form/Account.php b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Form/Account.php
index c08c18eb0a6e3..363f0cf19638c 100644
--- a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Form/Account.php
+++ b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Form/Account.php
@@ -34,22 +34,20 @@
class Account extends \Magento\Sales\Block\Adminhtml\Order\Create\Form\AbstractForm
{
/**
- * @var \Magento\Customer\Model\CustomerFactory
+ * @var \Magento\Customer\Model\Metadata\FormFactory
*/
- protected $_customerFactory;
+ protected $_metadataFormFactory;
- /**
- * @var \Magento\Customer\Model\FormFactory
- */
- protected $_customerFormFactory;
+ /** @var \Magento\Customer\Service\V1\CustomerServiceInterface */
+ protected $_customerService;
/**
* @param \Magento\Backend\Block\Template\Context $context
* @param \Magento\Backend\Model\Session\Quote $sessionQuote
* @param \Magento\Sales\Model\AdminOrder\Create $orderCreate
* @param \Magento\Data\FormFactory $formFactory
- * @param \Magento\Customer\Model\CustomerFactory $customerFactory
- * @param \Magento\Customer\Model\FormFactory $customerFormFactory
+ * @param \Magento\Customer\Model\Metadata\FormFactory $metadataFormFactory
+ * @param \Magento\Customer\Service\V1\CustomerServiceInterface $customerService
* @param array $data
*/
public function __construct(
@@ -57,12 +55,12 @@ public function __construct(
\Magento\Backend\Model\Session\Quote $sessionQuote,
\Magento\Sales\Model\AdminOrder\Create $orderCreate,
\Magento\Data\FormFactory $formFactory,
- \Magento\Customer\Model\CustomerFactory $customerFactory,
- \Magento\Customer\Model\FormFactory $customerFormFactory,
+ \Magento\Customer\Model\Metadata\FormFactory $metadataFormFactory,
+ \Magento\Customer\Service\V1\CustomerServiceInterface $customerService,
array $data = array()
) {
- $this->_customerFactory = $customerFactory;
- $this->_customerFormFactory = $customerFormFactory;
+ $this->_metadataFormFactory = $metadataFormFactory;
+ $this->_customerService = $customerService;
parent::__construct($context, $sessionQuote, $orderCreate, $formFactory, $data);
}
@@ -93,22 +91,18 @@ public function getHeaderText()
*/
protected function _prepareForm()
{
- /* @var $customerModel \Magento\Customer\Model\Customer */
- $customerModel = $this->_customerFactory->create();
-
- /* @var $customerForm \Magento\Customer\Model\Form */
- $customerForm = $this->_customerFormFactory->create();
- $customerForm->setFormCode('adminhtml_checkout')
- ->setStore($this->getStore())
- ->setEntity($customerModel);
+ /** @var \Magento\Customer\Model\Metadata\Form $customerForm */
+ $customerForm = $this->_metadataFormFactory->create(
+ 'customer',
+ 'adminhtml_checkout'
+ );
// prepare customer attributes to show
- $attributes = array();
+ $attributes = [];
// add system required attributes
foreach ($customerForm->getSystemAttributes() as $attribute) {
- /* @var $attribute \Magento\Customer\Model\Attribute */
- if ($attribute->getIsRequired()) {
+ if ($attribute->isRequired()) {
$attributes[$attribute->getAttributeCode()] = $attribute;
}
}
@@ -119,7 +113,6 @@ protected function _prepareForm()
// add user defined attributes
foreach ($customerForm->getUserAttributes() as $attribute) {
- /* @var $attribute \Magento\Customer\Model\Attribute */
$attributes[$attribute->getAttributeCode()] = $attribute;
}
@@ -157,7 +150,12 @@ protected function _addAdditionalFormElementData(\Magento\Data\Form\Element\Abst
*/
public function getFormValues()
{
- $data = $this->getCustomer()->getData();
+ try {
+ $customer = $this->_customerService->getCustomer($this->getCustomerId());
+ } catch (\Exception $e) {
+ /** If customer does not exist do nothing. */
+ }
+ $data = isset($customer) ? $customer->__toArray() : array();
foreach ($this->getQuote()->getData() as $key => $value) {
if (strpos($key, 'customer_') === 0) {
$data[substr($key, 9)] = $value;
diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Form/Address.php b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Form/Address.php
index 5c636f2791dff..84b9b7eb8a9b2 100644
--- a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Form/Address.php
+++ b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Form/Address.php
@@ -33,30 +33,10 @@
*/
namespace Magento\Sales\Block\Adminhtml\Order\Create\Form;
-class Address
- extends \Magento\Sales\Block\Adminhtml\Order\Create\Form\AbstractForm
+class Address extends \Magento\Sales\Block\Adminhtml\Order\Create\Form\AbstractForm
{
/**
- * Customer Address Form instance
- *
- * @var \Magento\Customer\Model\Form
- */
- protected $_addressForm;
-
- /**
- * Adminhtml addresses
- *
- * @var \Magento\Backend\Helper\Addresses
- */
- protected $_adminhtmlAddresses = null;
-
- /**
- * @var \Magento\Customer\Model\AddressFactory
- */
- protected $_addressFactory;
-
- /**
- * @var \Magento\Customer\Model\FormFactory
+ * @var \Magento\Customer\Model\Metadata\FormFactory
*/
protected $_customerFormFactory;
@@ -75,6 +55,16 @@ class Address
*/
protected $_customerHelper;
+ /**
+ * @var \Magento\Customer\Service\V1\CustomerAddressServiceInterface
+ */
+ protected $_addressService;
+
+ /**
+ * @var \Magento\Customer\Helper\Address
+ */
+ protected $_addressHelper;
+
/**
* @param \Magento\Backend\Block\Template\Context $context
* @param \Magento\Backend\Model\Session\Quote $sessionQuote
@@ -82,12 +72,12 @@ class Address
* @param \Magento\Data\FormFactory $formFactory
* @param \Magento\Core\Helper\Data $coreData
* @param \Magento\Json\EncoderInterface $jsonEncoder
- * @param \Magento\Customer\Model\AddressFactory $addressFactory
- * @param \Magento\Customer\Model\FormFactory $customerFormFactory
- * @param \Magento\Backend\Helper\Addresses $adminhtmlAddresses
+ * @param \Magento\Customer\Model\Metadata\FormFactory $customerFormFactory
* @param \Magento\Customer\Helper\Data $customerHelper
+ * @param \Magento\Customer\Service\V1\CustomerAddressServiceInterface $addressService
+ * @param \Magento\Customer\Helper\Address $addressHelper
* @param array $data
- *
+ *
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function __construct(
@@ -97,18 +87,18 @@ public function __construct(
\Magento\Data\FormFactory $formFactory,
\Magento\Core\Helper\Data $coreData,
\Magento\Json\EncoderInterface $jsonEncoder,
- \Magento\Customer\Model\AddressFactory $addressFactory,
- \Magento\Customer\Model\FormFactory $customerFormFactory,
- \Magento\Backend\Helper\Addresses $adminhtmlAddresses,
+ \Magento\Customer\Model\Metadata\FormFactory $customerFormFactory,
\Magento\Customer\Helper\Data $customerHelper,
+ \Magento\Customer\Service\V1\CustomerAddressServiceInterface $addressService,
+ \Magento\Customer\Helper\Address $addressHelper,
array $data = array()
) {
$this->_customerHelper = $customerHelper;
$this->_coreData = $coreData;
$this->_jsonEncoder = $jsonEncoder;
- $this->_addressFactory = $addressFactory;
$this->_customerFormFactory = $customerFormFactory;
- $this->_adminhtmlAddresses = $adminhtmlAddresses;
+ $this->_addressService = $addressService;
+ $this->_addressHelper = $addressHelper;
parent::__construct($context, $sessionQuote, $orderCreate, $formFactory, $data);
}
@@ -123,28 +113,16 @@ public function getConfig($path)
return $this->_storeConfig->getConfig($path);
}
/**
- * Return Customer Address Collection as array
+ * Retrieve current customer address DTOs collection.
*
- * @return array
+ * @return \Magento\Customer\Service\V1\Dto\Address[]
*/
public function getAddressCollection()
{
- return $this->getCustomer()->getAddresses();
- }
-
- /**
- * Return customer address form instance
- *
- * @return \Magento\Customer\Model\Form
- */
- protected function _getAddressForm()
- {
- if (is_null($this->_addressForm)) {
- $this->_addressForm = $this->_customerFormFactory->create()
- ->setFormCode('adminhtml_customer_address')
- ->setStore($this->getStore());
+ if ($this->getCustomerId()) {
+ return $this->_addressService->getAddresses($this->getCustomerId());
}
- return $this->_addressForm;
+ return [];
}
/**
@@ -154,18 +132,20 @@ protected function _getAddressForm()
*/
public function getAddressCollectionJson()
{
- $addressForm = $this->_getAddressForm();
- $data = array();
-
- $emptyAddress = $this->getCustomer()
- ->getAddressById(null)
- ->setCountryId($this->_coreData->getDefaultCountry($this->getStore()));
- $data[0] = $addressForm->setEntity($emptyAddress)
- ->outputData(\Magento\Eav\Model\AttributeDataFactory::OUTPUT_FORMAT_JSON);
-
- foreach ($this->getAddressCollection() as $address) {
- $addressForm->setEntity($address);
- $data[$address->getId()] = $addressForm->outputData(
+ $defaultCountryId = $this->_coreData->getDefaultCountry($this->getStore());
+ $emptyAddressForm = $this->_customerFormFactory->create(
+ 'customer_address',
+ 'adminhtml_customer_address',
+ [\Magento\Customer\Service\V1\Dto\Address::KEY_COUNTRY_ID => $defaultCountryId]
+ );
+ $data = [0 => $emptyAddressForm->outputData(\Magento\Eav\Model\AttributeDataFactory::OUTPUT_FORMAT_JSON)];
+ foreach ($this->getAddressCollection() as $addressDto) {
+ $addressForm = $this->_customerFormFactory->create(
+ 'customer_address',
+ 'adminhtml_customer_address',
+ $addressDto->__toArray()
+ );
+ $data[$addressDto->getId()] = $addressForm->outputData(
\Magento\Eav\Model\AttributeDataFactory::OUTPUT_FORMAT_JSON
);
}
@@ -175,6 +155,8 @@ public function getAddressCollectionJson()
/**
* Prepare Form and add elements to form
*
+ * @SuppressWarnings(PHPMD.CyclomaticComplexity)
+ * @SuppressWarnings(PHPMD.NPathComplexity)
* @return \Magento\Sales\Block\Adminhtml\Order\Create\Form\Address
*/
protected function _prepareForm()
@@ -183,17 +165,11 @@ protected function _prepareForm()
'no_container' => true
));
- /* @var $addressModel \Magento\Customer\Model\Address */
- $addressModel = $this->_addressFactory->create();
-
- $addressForm = $this->_getAddressForm()
- ->setEntity($addressModel);
-
+ $addressForm = $this->_customerFormFactory->create(
+ 'customer_address',
+ 'adminhtml_customer_address'
+ );
$attributes = $addressForm->getAttributes();
- if (isset($attributes['street'])) {
- $this->_adminhtmlAddresses
- ->processStreetAttribute($attributes['street']);
- }
$this->_addAttributesToForm($attributes, $fieldset);
$prefixElement = $this->_form->getElement('prefix');
@@ -291,13 +267,18 @@ public function getAddressId()
}
/**
- * Return customer address formated as one-line string
+ * Represent customer address in 'online' format.
*
- * @param \Magento\Customer\Model\Address $address
+ * @param \Magento\Customer\Service\V1\Dto\Address $addressData
* @return string
*/
- public function getAddressAsString($address)
+ public function getAddressAsString($addressData)
{
- return $this->escapeHtml($address->format('oneline'));
+ $formatTypeRenderer = $this->_addressHelper->getFormatTypeRenderer('oneline');
+ $result = '';
+ if ($formatTypeRenderer) {
+ $result = $formatTypeRenderer->renderArray($addressData->__toArray());
+ }
+ return $this->escapeHtml($result);
}
}
diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Header.php b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Header.php
index 1a192c33cb712..64a59582d9f9d 100644
--- a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Header.php
+++ b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Header.php
@@ -18,46 +18,97 @@
* versions in the future. If you wish to customize Magento for your
* needs please refer to http://www.magentocommerce.com for more information.
*
- * @category Magento
- * @package Magento_Sales
* @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
+namespace Magento\Sales\Block\Adminhtml\Order\Create;
+
/**
* Create order form header
- *
- * @author Magento Core Team
*/
-namespace Magento\Sales\Block\Adminhtml\Order\Create;
-
class Header extends \Magento\Sales\Block\Adminhtml\Order\Create\AbstractCreate
{
+ /** @var \Magento\Customer\Service\V1\CustomerServiceInterface */
+ protected $_customerService;
+
+ /** @var \Magento\Customer\Helper\View */
+ protected $_customerViewHelper;
+
+ /**
+ * Initialize dependencies.
+ *
+ * @param \Magento\Backend\Block\Template\Context $context
+ * @param \Magento\Backend\Model\Session\Quote $sessionQuote
+ * @param \Magento\Sales\Model\AdminOrder\Create $orderCreate
+ * @param \Magento\Customer\Service\V1\CustomerServiceInterface $customerService
+ * @param \Magento\Customer\Helper\View $customerViewHelper
+ * @param array $data
+ */
+ public function __construct(
+ \Magento\Backend\Block\Template\Context $context,
+ \Magento\Backend\Model\Session\Quote $sessionQuote,
+ \Magento\Sales\Model\AdminOrder\Create $orderCreate,
+ \Magento\Customer\Service\V1\CustomerServiceInterface $customerService,
+ \Magento\Customer\Helper\View $customerViewHelper,
+ array $data = array()
+ ) {
+ $this->_customerService = $customerService;
+ $this->_customerViewHelper = $customerViewHelper;
+ parent::__construct($context, $sessionQuote, $orderCreate, $data);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
protected function _toHtml()
{
if ($this->_getSession()->getOrder()->getId()) {
return __('Edit Order #%1', $this->_getSession()->getOrder()->getIncrementId());
}
+ $out = $this->_getCreateOrderTitle();
+ return $this->escapeHtml($out);
+ }
+ /**
+ * Generate title for new order creation page.
+ *
+ * @return string
+ */
+ protected function _getCreateOrderTitle()
+ {
$customerId = $this->getCustomerId();
- $storeId = $this->getStoreId();
+ $storeId = $this->getStoreId();
$out = '';
if ($customerId && $storeId) {
- $out.= __('Create New Order for %1 in %2', $this->getCustomer()->getName(), $this->getStore()->getName());
- }
- elseif (!is_null($customerId) && $storeId){
- $out.= __('Create New Order for New Customer in %1', $this->getStore()->getName());
- }
- elseif ($customerId) {
- $out.= __('Create New Order for %1', $this->getCustomer()->getName());
- }
- elseif (!is_null($customerId)){
- $out.= __('Create New Order for New Customer');
+ $out .= __(
+ 'Create New Order for %1 in %2',
+ $this->_getCustomerName($customerId),
+ $this->getStore()->getName()
+ );
+ return $out;
+ } elseif (!$customerId && $storeId) {
+ $out .= __('Create New Order for New Customer in %1', $this->getStore()->getName());
+ return $out;
+ } elseif ($customerId && !$storeId) {
+ $out .= __('Create New Order for %1', $this->_getCustomerName($customerId));
+ return $out;
+ } elseif (!$customerId && !$storeId) {
+ $out .= __('Create New Order for New Customer');
+ return $out;
}
- else {
- $out.= __('Create New Order');
- }
- $out = $this->escapeHtml($out);
return $out;
}
+
+ /**
+ * Get customer name by his ID.
+ *
+ * @param int $customerId
+ * @return string
+ */
+ protected function _getCustomerName($customerId)
+ {
+ $customerData = $this->_customerService->getCustomer($customerId);
+ return $this->_customerViewHelper->getCustomerName($customerData);
+ }
}
diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Search/Grid.php b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Search/Grid.php
index 2d27a4fdc2133..24c9cfe6bae84 100644
--- a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Search/Grid.php
+++ b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Search/Grid.php
@@ -57,7 +57,6 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended
/**
* @param \Magento\Backend\Block\Template\Context $context
- * @param \Magento\Core\Model\Url $urlModel
* @param \Magento\Backend\Helper\Data $backendHelper
* @param \Magento\Catalog\Model\ProductFactory $productFactory
* @param \Magento\Catalog\Model\Config $catalogConfig
@@ -67,7 +66,6 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended
*/
public function __construct(
\Magento\Backend\Block\Template\Context $context,
- \Magento\Core\Model\Url $urlModel,
\Magento\Backend\Helper\Data $backendHelper,
\Magento\Catalog\Model\ProductFactory $productFactory,
\Magento\Catalog\Model\Config $catalogConfig,
@@ -79,7 +77,7 @@ public function __construct(
$this->_catalogConfig = $catalogConfig;
$this->_sessionQuote = $sessionQuote;
$this->_salesConfig = $salesConfig;
- parent::__construct($context, $urlModel, $backendHelper, $data);
+ parent::__construct($context, $backendHelper, $data);
}
protected function _construct()
diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Search/Grid/Renderer/Qty.php b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Search/Grid/Renderer/Qty.php
index 734d7e9627670..ec9d7ab7f05dd 100644
--- a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Search/Grid/Renderer/Qty.php
+++ b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Search/Grid/Renderer/Qty.php
@@ -36,6 +36,25 @@
class Qty
extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\Input
{
+ /**
+ * @var \Magento\Catalog\Model\ProductTypes\ConfigInterface
+ */
+ protected $typeConfig;
+
+ /**
+ * @param \Magento\Backend\Block\Context $context
+ * @param \Magento\Catalog\Model\ProductTypes\ConfigInterface $typeConfig
+ * @param array $data
+ */
+ public function __construct(
+ \Magento\Backend\Block\Context $context,
+ \Magento\Catalog\Model\ProductTypes\ConfigInterface $typeConfig,
+ array $data = array()
+ ) {
+ parent::__construct($context, $data);
+ $this->typeConfig = $typeConfig;
+ }
+
/**
* Returns whether this qty field must be inactive
*
@@ -44,7 +63,7 @@ class Qty
*/
protected function _isInactive($row)
{
- return $row->getTypeId() == \Magento\GroupedProduct\Model\Product\Type\Grouped::TYPE_CODE;
+ return $this->typeConfig->isProductSet($row->getTypeId());
}
/**
@@ -56,10 +75,13 @@ protected function _isInactive($row)
public function render(\Magento\Object $row)
{
// Prepare values
- $isInactive = $this->_isInactive($row);
+ $disabled = '';
+ $addClass = '';
- if ($isInactive) {
+ if ($this->_isInactive($row)) {
$qty = '';
+ $disabled = 'disabled="disabled" ';
+ $addClass = ' input-inactive';
} else {
$qty = $row->getData($this->getColumn()->getIndex());
$qty *= 1;
@@ -71,11 +93,8 @@ public function render(\Magento\Object $row)
// Compose html
$html = 'getColumn()->getId() . '" ';
- $html .= 'value="' . $qty . '" ';
- if ($isInactive) {
- $html .= 'disabled="disabled" ';
- }
- $html .= 'class="input-text ' . $this->getColumn()->getInlineCss() . ($isInactive ? ' input-inactive' : '') . '" />';
+ $html .= 'value="' . $qty . '" ' . $disabled;
+ $html .= 'class="input-text ' . $this->getColumn()->getInlineCss() . $addClass . '" />';
return $html;
}
}
diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Shipping/Address.php b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Shipping/Address.php
index da382631565be..313aab696aca1 100644
--- a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Shipping/Address.php
+++ b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Shipping/Address.php
@@ -34,8 +34,7 @@
*/
namespace Magento\Sales\Block\Adminhtml\Order\Create\Shipping;
-class Address
- extends \Magento\Sales\Block\Adminhtml\Order\Create\Form\Address
+class Address extends \Magento\Sales\Block\Adminhtml\Order\Create\Form\Address
{
/**
* Return header text
@@ -127,7 +126,7 @@ public function getAddressId()
/**
* Return address object
*
- * @return \Magento\Customer\Model\Address
+ * @return \Magento\Sales\Model\Quote\Address
*/
public function getAddress()
{
diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Sidebar/AbstractSidebar.php b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Sidebar/AbstractSidebar.php
index 1529106211fc2..42854d006252a 100644
--- a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Sidebar/AbstractSidebar.php
+++ b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Sidebar/AbstractSidebar.php
@@ -168,7 +168,7 @@ public function getItems()
/*
* Filtering items by allowed product type
*/
- foreach($items as $key => $item) {
+ foreach ($items as $key => $item) {
if ($item instanceof \Magento\Catalog\Model\Product) {
$type = $item->getTypeId();
} else if ($item instanceof \Magento\Sales\Model\Order\Item) {
@@ -209,4 +209,25 @@ public function canDisplayPrice()
return true;
}
+ /**
+ * Get item qty
+ *
+ * @param \Magento\Object $item
+ * @return int
+ */
+ public function getItemQty(\Magento\Object $item)
+ {
+ return $item->getQty()*1 ? $item->getQty()*1 : 1;
+ }
+
+ /**
+ * Check whether product configuration is required before adding to order
+ *
+ * @param $productType
+ * @return bool
+ */
+ public function isConfigurationRequired($productType)
+ {
+ return false;
+ }
}
diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/View/Info.php b/app/code/Magento/Sales/Block/Adminhtml/Order/View/Info.php
index 3212636b73d07..e62c28153fdb1 100644
--- a/app/code/Magento/Sales/Block/Adminhtml/Order/View/Info.php
+++ b/app/code/Magento/Sales/Block/Adminhtml/Order/View/Info.php
@@ -18,67 +18,57 @@
* versions in the future. If you wish to customize Magento for your
* needs please refer to http://www.magentocommerce.com for more information.
*
- * @category Magento
- * @package Magento_Sales
* @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
+namespace Magento\Sales\Block\Adminhtml\Order\View;
+
+use Magento\Customer\Service\V1\CustomerMetadataServiceInterface;
+use Magento\Eav\Model\AttributeDataFactory;
/**
* Order history block
- *
- * @category Magento
- * @package Magento_Sales
- * @author Magento Core Team
*/
-namespace Magento\Sales\Block\Adminhtml\Order\View;
-
class Info extends \Magento\Sales\Block\Adminhtml\Order\AbstractOrder
{
/**
- * @var \Magento\Customer\Model\GroupFactory
- */
- protected $_groupFactory;
-
- /**
- * @var \Magento\Eav\Model\AttributeDataFactory
+ * Customer service
+ *
+ * @var CustomerMetadataServiceInterface
*/
- protected $_attrDataFactory;
+ protected $_customerMetadataService;
/**
- * @var \Magento\Customer\Model\CustomerFactory
+ * @var \Magento\Customer\Service\V1\CustomerGroupServiceInterface
*/
- protected $_customerFactory;
+ protected $_groupService;
/**
- * @var \Magento\Eav\Model\Config
+ * @var \Magento\Customer\Model\Metadata\ElementFactory
*/
- protected $_eavConfig;
+ protected $_metadataElementFactory;
/**
* @param \Magento\Backend\Block\Template\Context $context
* @param \Magento\Core\Model\Registry $registry
* @param \Magento\Sales\Helper\Admin $adminHelper
- * @param \Magento\Customer\Model\GroupFactory $groupFactory
- * @param \Magento\Customer\Model\CustomerFactory $customerFactory
- * @param \Magento\Eav\Model\Config $eavConfig
- * @param \Magento\Eav\Model\AttributeDataFactory $attrDataFactory
+ * @param \Magento\Customer\Service\V1\CustomerGroupServiceInterface $groupService
+ * @param CustomerMetadataServiceInterface $customerMetadataService
+ * @param \Magento\Customer\Model\Metadata\ElementFactory $elementFactory
* @param array $data
*/
public function __construct(
\Magento\Backend\Block\Template\Context $context,
\Magento\Core\Model\Registry $registry,
\Magento\Sales\Helper\Admin $adminHelper,
- \Magento\Customer\Model\GroupFactory $groupFactory,
- \Magento\Customer\Model\CustomerFactory $customerFactory,
- \Magento\Eav\Model\Config $eavConfig,
- \Magento\Eav\Model\AttributeDataFactory $attrDataFactory,
+ \Magento\Customer\Service\V1\CustomerGroupServiceInterface $groupService,
+ CustomerMetadataServiceInterface $customerMetadataService,
+ \Magento\Customer\Model\Metadata\ElementFactory $elementFactory,
array $data = array()
) {
- $this->_customerFactory = $customerFactory;
- $this->_groupFactory = $groupFactory;
- $this->_eavConfig = $eavConfig;
- $this->_attrDataFactory = $attrDataFactory;
+ $this->_groupService = $groupService;
+ $this->_customerMetadataService = $customerMetadataService;
+ $this->_metadataElementFactory = $elementFactory;
parent::__construct($context, $registry, $adminHelper, $data);
}
@@ -118,22 +108,41 @@ public function getOrderStoreName()
return null;
}
+ /**
+ * Return name of the customer group.
+ *
+ * @return string
+ */
public function getCustomerGroupName()
{
if ($this->getOrder()) {
- return $this->_groupFactory->create()->load((int)$this->getOrder()->getCustomerGroupId())->getCode();
+ $customerGroupId = $this->getOrder()->getCustomerGroupId();
+ if (!is_null($customerGroupId)) {
+ return $this->_groupService->getGroup($customerGroupId)->getCode();
+ }
}
- return null;
+ return '';
}
+ /**
+ * Get URL to edit the customer.
+ *
+ * @return string
+ */
public function getCustomerViewUrl()
{
if ($this->getOrder()->getCustomerIsGuest() || !$this->getOrder()->getCustomerId()) {
- return false;
+ return '';
}
return $this->getUrl('customer/index/edit', array('id' => $this->getOrder()->getCustomerId()));
}
+ /**
+ * Get order view URL.
+ *
+ * @param int $orderId
+ * @return string
+ */
public function getViewUrl($orderId)
{
return $this->getUrl('sales/order/view', array('order_id'=>$orderId));
@@ -163,28 +172,25 @@ protected function _prepareAccountDataSortOrder(array $data, $sortOrder)
*/
public function getCustomerAccountData()
{
- $accountData = array();
-
+ $accountData = [];
$entityType = 'customer';
- $customer = $this->_customerFactory->create();
- foreach ($this->_eavConfig->getEntityAttributeCodes($entityType) as $attributeCode) {
- /* @var $attribute \Magento\Customer\Model\Attribute */
- $attribute = $this->_eavConfig->getAttribute($entityType, $attributeCode);
- if (!$attribute->getIsVisible() || $attribute->getIsSystem()) {
+
+ foreach ($this->_customerMetadataService->getAllCustomerAttributeMetadata($entityType) as $attribute) {
+ /* @var $attribute \Magento\Customer\Service\V1\Dto\Eav\AttributeMetadata */
+ if (!$attribute->isVisible() || $attribute->isSystem()) {
continue;
}
$orderKey = sprintf('customer_%s', $attribute->getAttributeCode());
$orderValue = $this->getOrder()->getData($orderKey);
if ($orderValue != '') {
- $customer->setData($attribute->getAttributeCode(), $orderValue);
- $dataModel = $this->_attrDataFactory->create($attribute, $customer);
- $value = $dataModel->outputValue(\Magento\Eav\Model\AttributeDataFactory::OUTPUT_FORMAT_HTML);
- $sortOrder = $attribute->getSortOrder() + $attribute->getIsUserDefined() ? 200 : 0;
+ $metadataElement = $this->_metadataElementFactory->create($attribute, $orderValue, $entityType);
+ $value = $metadataElement->outputValue(AttributeDataFactory::OUTPUT_FORMAT_HTML);
+ $sortOrder = $attribute->getSortOrder() + $attribute->isUserDefined() ? 200 : 0;
$sortOrder = $this->_prepareAccountDataSortOrder($accountData, $sortOrder);
- $accountData[$sortOrder] = array(
+ $accountData[$sortOrder] = [
'label' => $attribute->getFrontendLabel(),
- 'value' => $this->escapeHtml($value, array('br'))
- );
+ 'value' => $this->escapeHtml($value, ['br'])
+ ];
}
}
diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/View/Tab/Creditmemos.php b/app/code/Magento/Sales/Block/Adminhtml/Order/View/Tab/Creditmemos.php
index d8b472d56b53d..6cfa1ee36a42a 100644
--- a/app/code/Magento/Sales/Block/Adminhtml/Order/View/Tab/Creditmemos.php
+++ b/app/code/Magento/Sales/Block/Adminhtml/Order/View/Tab/Creditmemos.php
@@ -56,7 +56,6 @@ class Creditmemos
/**
* @param \Magento\Backend\Block\Template\Context $context
- * @param \Magento\Core\Model\Url $urlModel
* @param \Magento\Backend\Helper\Data $backendHelper
* @param \Magento\Sales\Model\Resource\Order\Collection\Factory $collectionFactory
* @param \Magento\Sales\Model\Order\Creditmemo $orderCreditmemo
@@ -65,7 +64,6 @@ class Creditmemos
*/
public function __construct(
\Magento\Backend\Block\Template\Context $context,
- \Magento\Core\Model\Url $urlModel,
\Magento\Backend\Helper\Data $backendHelper,
\Magento\Sales\Model\Resource\Order\Collection\Factory $collectionFactory,
\Magento\Sales\Model\Order\Creditmemo $orderCreditmemo,
@@ -75,7 +73,7 @@ public function __construct(
$this->_coreRegistry = $coreRegistry;
$this->_orderCreditmemo = $orderCreditmemo;
$this->_collectionFactory = $collectionFactory;
- parent::__construct($context, $urlModel, $backendHelper, $data);
+ parent::__construct($context, $backendHelper, $data);
}
protected function _construct()
diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/View/Tab/Invoices.php b/app/code/Magento/Sales/Block/Adminhtml/Order/View/Tab/Invoices.php
index d1ef50e1ab266..41743203a0911 100644
--- a/app/code/Magento/Sales/Block/Adminhtml/Order/View/Tab/Invoices.php
+++ b/app/code/Magento/Sales/Block/Adminhtml/Order/View/Tab/Invoices.php
@@ -56,7 +56,6 @@ class Invoices
/**
* @param \Magento\Backend\Block\Template\Context $context
- * @param \Magento\Core\Model\Url $urlModel
* @param \Magento\Backend\Helper\Data $backendHelper
* @param \Magento\Sales\Model\Resource\Order\Collection\Factory $collectionFactory
* @param \Magento\Sales\Model\Order\Invoice $orderInvoice
@@ -65,7 +64,6 @@ class Invoices
*/
public function __construct(
\Magento\Backend\Block\Template\Context $context,
- \Magento\Core\Model\Url $urlModel,
\Magento\Backend\Helper\Data $backendHelper,
\Magento\Sales\Model\Resource\Order\Collection\Factory $collectionFactory,
\Magento\Sales\Model\Order\Invoice $orderInvoice,
@@ -75,7 +73,7 @@ public function __construct(
$this->_coreRegistry = $coreRegistry;
$this->_orderInvoice = $orderInvoice;
$this->_collectionFactory = $collectionFactory;
- parent::__construct($context, $urlModel, $backendHelper, $data);
+ parent::__construct($context, $backendHelper, $data);
}
protected function _construct()
diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/View/Tab/Shipments.php b/app/code/Magento/Sales/Block/Adminhtml/Order/View/Tab/Shipments.php
index 9d7598bc97c09..ca7726e567b66 100644
--- a/app/code/Magento/Sales/Block/Adminhtml/Order/View/Tab/Shipments.php
+++ b/app/code/Magento/Sales/Block/Adminhtml/Order/View/Tab/Shipments.php
@@ -47,7 +47,6 @@ class Shipments
/**
* @param \Magento\Backend\Block\Template\Context $context
- * @param \Magento\Core\Model\Url $urlModel
* @param \Magento\Backend\Helper\Data $backendHelper
* @param \Magento\Sales\Model\Resource\Order\Collection\Factory $collectionFactory
* @param \Magento\Core\Model\Registry $coreRegistry
@@ -55,7 +54,6 @@ class Shipments
*/
public function __construct(
\Magento\Backend\Block\Template\Context $context,
- \Magento\Core\Model\Url $urlModel,
\Magento\Backend\Helper\Data $backendHelper,
\Magento\Sales\Model\Resource\Order\Collection\Factory $collectionFactory,
\Magento\Core\Model\Registry $coreRegistry,
@@ -63,7 +61,7 @@ public function __construct(
) {
$this->_coreRegistry = $coreRegistry;
$this->_collectionFactory = $collectionFactory;
- parent::__construct($context, $urlModel, $backendHelper, $data);
+ parent::__construct($context, $backendHelper, $data);
}
protected function _construct()
diff --git a/app/code/Magento/Sales/Block/Adminhtml/Recurring/Profile/Grid.php b/app/code/Magento/Sales/Block/Adminhtml/Recurring/Profile/Grid.php
index be1e8bb9e9117..7847b9ceb92b0 100644
--- a/app/code/Magento/Sales/Block/Adminhtml/Recurring/Profile/Grid.php
+++ b/app/code/Magento/Sales/Block/Adminhtml/Recurring/Profile/Grid.php
@@ -53,7 +53,6 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended
/**
* @param \Magento\Backend\Block\Template\Context $context
- * @param \Magento\Core\Model\Url $urlModel
* @param \Magento\Backend\Helper\Data $backendHelper
* @param \Magento\Payment\Helper\Data $paymentData
* @param \Magento\Sales\Model\Resource\Recurring\Profile\CollectionFactory $profileCollection
@@ -62,7 +61,6 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended
*/
public function __construct(
\Magento\Backend\Block\Template\Context $context,
- \Magento\Core\Model\Url $urlModel,
\Magento\Backend\Helper\Data $backendHelper,
\Magento\Payment\Helper\Data $paymentData,
\Magento\Sales\Model\Resource\Recurring\Profile\CollectionFactory $profileCollection,
@@ -72,7 +70,7 @@ public function __construct(
$this->_paymentData = $paymentData;
$this->_profileCollection = $profileCollection;
$this->_recurringProfile = $recurringProfile;
- parent::__construct($context, $urlModel, $backendHelper, $data);
+ parent::__construct($context, $backendHelper, $data);
}
protected function _construct()
diff --git a/app/code/Magento/Sales/Block/Adminhtml/Recurring/Profile/View/Tab/Orders.php b/app/code/Magento/Sales/Block/Adminhtml/Recurring/Profile/View/Tab/Orders.php
index 422dcefdea863..7b41c64d2b99e 100644
--- a/app/code/Magento/Sales/Block/Adminhtml/Recurring/Profile/View/Tab/Orders.php
+++ b/app/code/Magento/Sales/Block/Adminhtml/Recurring/Profile/View/Tab/Orders.php
@@ -52,7 +52,6 @@ class Orders
/**
* @param \Magento\Backend\Block\Template\Context $context
- * @param \Magento\Core\Model\Url $urlModel
* @param \Magento\Backend\Helper\Data $backendHelper
* @param \Magento\Core\Model\Registry $coreRegistry
* @param \Magento\Sales\Model\Resource\Order\Grid\CollectionFactory $orderCollection
@@ -61,7 +60,6 @@ class Orders
*/
public function __construct(
\Magento\Backend\Block\Template\Context $context,
- \Magento\Core\Model\Url $urlModel,
\Magento\Backend\Helper\Data $backendHelper,
\Magento\Core\Model\Registry $coreRegistry,
\Magento\Sales\Model\Resource\Order\Grid\CollectionFactory $orderCollection,
@@ -71,7 +69,7 @@ public function __construct(
$this->_coreRegistry = $coreRegistry;
$this->_orderCollection = $orderCollection;
$this->_orderConfig = $orderConfig;
- parent::__construct($context, $urlModel, $backendHelper, $data);
+ parent::__construct($context, $backendHelper, $data);
}
/**
diff --git a/app/code/Magento/Sales/Block/Adminhtml/Shipment/Grid.php b/app/code/Magento/Sales/Block/Adminhtml/Shipment/Grid.php
index f69d9a75faea8..6ba615240c0e9 100644
--- a/app/code/Magento/Sales/Block/Adminhtml/Shipment/Grid.php
+++ b/app/code/Magento/Sales/Block/Adminhtml/Shipment/Grid.php
@@ -40,20 +40,18 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended
/**
* @param \Magento\Backend\Block\Template\Context $context
- * @param \Magento\Core\Model\Url $urlModel
* @param \Magento\Backend\Helper\Data $backendHelper
* @param \Magento\Sales\Model\Resource\Order\Collection\Factory $collectionFactory
* @param array $data
*/
public function __construct(
\Magento\Backend\Block\Template\Context $context,
- \Magento\Core\Model\Url $urlModel,
\Magento\Backend\Helper\Data $backendHelper,
\Magento\Sales\Model\Resource\Order\Collection\Factory $collectionFactory,
array $data = array()
) {
$this->_collectionFactory = $collectionFactory;
- parent::__construct($context, $urlModel, $backendHelper, $data);
+ parent::__construct($context, $backendHelper, $data);
}
diff --git a/app/code/Magento/Sales/Block/Adminhtml/Transactions/Detail/Grid.php b/app/code/Magento/Sales/Block/Adminhtml/Transactions/Detail/Grid.php
index 344a67cfef1e9..11c7f3a29b193 100644
--- a/app/code/Magento/Sales/Block/Adminhtml/Transactions/Detail/Grid.php
+++ b/app/code/Magento/Sales/Block/Adminhtml/Transactions/Detail/Grid.php
@@ -49,7 +49,6 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended
/**
* @param \Magento\Backend\Block\Template\Context $context
- * @param \Magento\Core\Model\Url $urlModel
* @param \Magento\Backend\Helper\Data $backendHelper
* @param \Magento\Data\CollectionFactory $collectionFactory
* @param \Magento\Core\Model\Registry $coreRegistry
@@ -57,7 +56,6 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended
*/
public function __construct(
\Magento\Backend\Block\Template\Context $context,
- \Magento\Core\Model\Url $urlModel,
\Magento\Backend\Helper\Data $backendHelper,
\Magento\Data\CollectionFactory $collectionFactory,
\Magento\Core\Model\Registry $coreRegistry,
@@ -65,7 +63,7 @@ public function __construct(
) {
$this->_collectionFactory = $collectionFactory;
$this->_coreRegistry = $coreRegistry;
- parent::__construct($context, $urlModel, $backendHelper, $data);
+ parent::__construct($context, $backendHelper, $data);
}
/**
diff --git a/app/code/Magento/Sales/Block/Adminhtml/Transactions/Grid.php b/app/code/Magento/Sales/Block/Adminhtml/Transactions/Grid.php
index a09fb1b1e8a6e..de7195575f2f7 100644
--- a/app/code/Magento/Sales/Block/Adminhtml/Transactions/Grid.php
+++ b/app/code/Magento/Sales/Block/Adminhtml/Transactions/Grid.php
@@ -61,7 +61,6 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended
/**
* @param \Magento\Backend\Block\Template\Context $context
- * @param \Magento\Core\Model\Url $urlModel
* @param \Magento\Backend\Helper\Data $backendHelper
* @param \Magento\Sales\Model\Order\Payment\Transaction $transaction
* @param \Magento\Sales\Model\Resource\Order\Payment\Transaction\CollectionFactory $collectionFactory
@@ -71,7 +70,6 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended
*/
public function __construct(
\Magento\Backend\Block\Template\Context $context,
- \Magento\Core\Model\Url $urlModel,
\Magento\Backend\Helper\Data $backendHelper,
\Magento\Sales\Model\Order\Payment\Transaction $transaction,
\Magento\Sales\Model\Resource\Order\Payment\Transaction\CollectionFactory $collectionFactory,
@@ -83,7 +81,7 @@ public function __construct(
$this->_paymentData = $paymentData;
$this->_transaction = $transaction;
$this->_collectionFactory = $collectionFactory;
- parent::__construct($context, $urlModel, $backendHelper, $data);
+ parent::__construct($context, $backendHelper, $data);
}
/**
diff --git a/app/code/Magento/Sales/Block/Billing/Agreement/View.php b/app/code/Magento/Sales/Block/Billing/Agreement/View.php
index 59a5c435e2b12..1493ade7ffc04 100644
--- a/app/code/Magento/Sales/Block/Billing/Agreement/View.php
+++ b/app/code/Magento/Sales/Block/Billing/Agreement/View.php
@@ -116,14 +116,16 @@ public function __construct(
public function getRelatedOrders()
{
if (is_null($this->_relatedOrders)) {
+ $billingAgreement = $this->_getBillingAgreementInstance();
+ $billingAgreementId = $billingAgreement ? $billingAgreement->getAgreementId() : 0;
$this->_relatedOrders = $this->_orderCollectionFactory->create()
->addFieldToSelect('*')
- ->addFieldToFilter('customer_id', $this->_customerSession->getCustomer()->getId())
+ ->addFieldToFilter('customer_id', (int)$this->_customerSession->getCustomerId())
->addFieldToFilter(
'state',
array('in' => $this->_orderConfig->getVisibleOnFrontStates())
)
- ->addBillingAgreementsFilter($this->_billingAgreementInstance->getAgreementId())
+ ->addBillingAgreementsFilter($billingAgreementId)
->setOrder('created_at', 'desc');
}
return $this->_relatedOrders;
@@ -174,9 +176,6 @@ public function getOrderItemValue(\Magento\Sales\Model\Order $order, $key)
*/
protected function _prepareLayout()
{
- if (is_null($this->_billingAgreementInstance)) {
- $this->_billingAgreementInstance = $this->_coreRegistry->registry('current_billing_agreement');
- }
parent::_prepareLayout();
$pager = $this->getLayout()->createBlock('Magento\Theme\Block\Html\Pager')
@@ -187,6 +186,19 @@ protected function _prepareLayout()
return $this;
}
+ /**
+ * Return current billing agreement.
+ *
+ * @return \Magento\Sales\Model\Billing\Agreement|null
+ */
+ protected function _getBillingAgreementInstance()
+ {
+ if (is_null($this->_billingAgreementInstance)) {
+ $this->_billingAgreementInstance = $this->_coreRegistry->registry('current_billing_agreement');
+ }
+ return $this->_billingAgreementInstance;
+ }
+
/**
* Load available billing agreement methods
*
@@ -211,21 +223,22 @@ protected function _toHtml()
{
$this->_loadPaymentMethods();
$this->setBackUrl($this->getUrl('*/billing_agreement/'));
- if ($this->_billingAgreementInstance) {
- $this->setReferenceId($this->_billingAgreementInstance->getReferenceId());
+ $billingAgreement = $this->_getBillingAgreementInstance();
+ if ($billingAgreement) {
+ $this->setReferenceId($billingAgreement->getReferenceId());
- $this->setCanCancel($this->_billingAgreementInstance->canCancel());
+ $this->setCanCancel($billingAgreement->canCancel());
$this->setCancelUrl(
$this->getUrl('*/billing_agreement/cancel', array(
'_current' => true,
- 'payment_method' => $this->_billingAgreementInstance->getMethodCode()))
+ 'payment_method' => $billingAgreement->getMethodCode()))
);
- $paymentMethodTitle = $this->_billingAgreementInstance->getAgreementLabel();
+ $paymentMethodTitle = $billingAgreement->getAgreementLabel();
$this->setPaymentMethodTitle($paymentMethodTitle);
- $createdAt = $this->_billingAgreementInstance->getCreatedAt();
- $updatedAt = $this->_billingAgreementInstance->getUpdatedAt();
+ $createdAt = $billingAgreement->getCreatedAt();
+ $updatedAt = $billingAgreement->getUpdatedAt();
$this->setAgreementCreatedAt(
($createdAt)
? $this->formatDate($createdAt, 'short', true)
@@ -236,7 +249,7 @@ protected function _toHtml()
$this->formatDate($updatedAt, 'short', true)
);
}
- $this->setAgreementStatus($this->_billingAgreementInstance->getStatusLabel());
+ $this->setAgreementStatus($billingAgreement->getStatusLabel());
}
return parent::_toHtml();
diff --git a/app/code/Magento/Sales/Block/Items/AbstractItems.php b/app/code/Magento/Sales/Block/Items/AbstractItems.php
index aa0eeaf1b4968..53bb39eedfe8d 100644
--- a/app/code/Magento/Sales/Block/Items/AbstractItems.php
+++ b/app/code/Magento/Sales/Block/Items/AbstractItems.php
@@ -40,21 +40,6 @@ class AbstractItems extends \Magento\View\Element\Template
*/
const DEFAULT_TYPE = 'default';
- /**
- * Initialize default item renderer
- */
- protected function _prepareLayout()
- {
- if (!$this->getChildBlock(self::DEFAULT_TYPE)) {
- $this->addChild(
- self::DEFAULT_TYPE,
- 'Magento\Checkout\Block\Cart\Item\Renderer',
- array('template' => 'cart/item/default.phtml')
- );
- }
- return parent::_prepareLayout();
- }
-
/**
* Retrieve item renderer block
*
@@ -64,11 +49,16 @@ protected function _prepareLayout()
*/
public function getItemRenderer($type)
{
- $renderer = $this->getChildBlock($type) ?: $this->getChildBlock(self::DEFAULT_TYPE);
- if (!$renderer instanceof \Magento\View\Element\BlockInterface) {
- throw new \RuntimeException('Renderer for type "' . $type . '" does not exist.');
+ /** @var \Magento\View\Element\RendererList $rendererList */
+ $rendererList = $this->getRendererListName()
+ ? $this->getLayout()->getBlock($this->getRendererListName())
+ : $this->getChildBlock('renderer.list');
+ if (!$rendererList) {
+ throw new \RuntimeException('Renderer list for block "' . $this->getNameInLayout() . '" is not defined');
}
- $renderer->setRenderedBlock($this);
+ $overriddenTemplates = $this->getOverriddenTemplates() ?: array();
+ $template = isset($overriddenTemplates[$type]) ? $overriddenTemplates[$type] : $this->getRendererTemplate();
+ $renderer = $rendererList->getRenderer($type, self::DEFAULT_TYPE, $template);
return $renderer;
}
diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Billing/Agreement.php b/app/code/Magento/Sales/Controller/Adminhtml/Billing/Agreement.php
index 7f246512a9857..9a8ae0c9627f2 100644
--- a/app/code/Magento/Sales/Controller/Adminhtml/Billing/Agreement.php
+++ b/app/code/Magento/Sales/Controller/Adminhtml/Billing/Agreement.php
@@ -192,14 +192,10 @@ protected function _initBillingAgreement()
*/
protected function _initCustomer()
{
- $customerId = (int) $this->getRequest()->getParam('id');
- $customer = $this->_objectManager->create('Magento\Customer\Model\Customer');
-
+ $customerId = (int)$this->getRequest()->getParam('id');
if ($customerId) {
- $customer->load($customerId);
+ $this->_coreRegistry->register('current_customer_id', $customerId);
}
-
- $this->_coreRegistry->register('current_customer', $customer);
return $this;
}
diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Recurring/Profile.php b/app/code/Magento/Sales/Controller/Adminhtml/Recurring/Profile.php
index 1b16eef117d8a..e3b936978d1c3 100644
--- a/app/code/Magento/Sales/Controller/Adminhtml/Recurring/Profile.php
+++ b/app/code/Magento/Sales/Controller/Adminhtml/Recurring/Profile.php
@@ -18,8 +18,6 @@
* versions in the future. If you wish to customize Magento for your
* needs please refer to http://www.magentocommerce.com for more information.
*
- * @category Magento
- * @package Magento_Sales
* @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
@@ -32,9 +30,27 @@
namespace Magento\Sales\Controller\Adminhtml\Recurring;
use Magento\App\Action\NotFoundException;
+use Magento\Core\Exception as CoreException;
+use Magento\Customer\Controller\Adminhtml\Index as CustomerController;
class Profile extends \Magento\Backend\App\Action
{
+ /**#@+
+ * Request parameter keys
+ */
+ const PARAM_CUSTOMER_ID = 'id';
+ const PARAM_PROFILE = 'profile';
+ const PARAM_ACTION = 'action';
+ /**#@-*/
+
+ /**#@+
+ * Values for PARAM_ACTION request parameter
+ */
+ const ACTION_CANCEL = 'cancel';
+ const ACTION_SUSPEND = 'suspend';
+ const ACTION_ACTIVATE = 'activate';
+ /**#@-*/
+
/**
* Core registry
*
@@ -42,15 +58,31 @@ class Profile extends \Magento\Backend\App\Action
*/
protected $_coreRegistry = null;
+ /**
+ * @var \Magento\Customer\Service\V1\CustomerServiceInterface
+ */
+ protected $_customerService;
+
+ /**
+ * @var \Magento\Logger
+ */
+ protected $_logger;
+
/**
* @param \Magento\Backend\App\Action\Context $context
* @param \Magento\Core\Model\Registry $coreRegistry
+ * @param \Magento\Customer\Service\V1\CustomerServiceInterface $customerService
+ * @param \Magento\Logger $logger
*/
public function __construct(
\Magento\Backend\App\Action\Context $context,
- \Magento\Core\Model\Registry $coreRegistry
+ \Magento\Core\Model\Registry $coreRegistry,
+ \Magento\Customer\Service\V1\CustomerServiceInterface $customerService,
+ \Magento\Logger $logger
) {
$this->_coreRegistry = $coreRegistry;
+ $this->_customerService = $customerService;
+ $this->_logger = $logger;
parent::__construct($context);
}
@@ -78,10 +110,10 @@ public function viewAction()
$this->_title->add(__('Profile #%1', $profile->getReferenceId()));
$this->_view->renderLayout();
return;
- } catch (\Magento\Core\Exception $e) {
+ } catch (CoreException $e) {
$this->messageManager->addError($e->getMessage());
} catch (\Exception $e) {
- $this->_objectManager->get('Magento\Logger')->logException($e);
+ $this->_logger->logException($e);
}
$this->_redirect('sales/*/');
}
@@ -94,10 +126,10 @@ public function gridAction()
try {
$this->_view->loadLayout()->renderLayout();
return;
- } catch (\Magento\Core\Exception $e) {
+ } catch (CoreException $e) {
$this->messageManager->addError($e->getMessage());
} catch (\Exception $e) {
- $this->_objectManager->get('Magento\Logger')->logException($e);
+ $this->_logger->logException($e);
}
$this->_redirect('sales/*/');
}
@@ -113,7 +145,7 @@ public function ordersAction()
$this->_initProfile();
$this->_view->loadLayout()->renderLayout();
} catch (\Exception $e) {
- $this->_objectManager->get('Magento\Logger')->logException($e);
+ $this->_logger->logException($e);
throw new NotFoundException();
}
}
@@ -126,27 +158,30 @@ public function updateStateAction()
$profile = null;
try {
$profile = $this->_initProfile();
+ $action = $this->getRequest()->getParam(self::PARAM_ACTION);
- switch ($this->getRequest()->getParam('action')) {
- case 'cancel':
+ switch ($action) {
+ case self::ACTION_CANCEL:
$profile->cancel();
break;
- case 'suspend':
+ case self::ACTION_SUSPEND:
$profile->suspend();
break;
- case 'activate':
+ case self::ACTION_ACTIVATE:
$profile->activate();
break;
+ default:
+ throw new \Exception(sprintf('Wrong action parameter: %s', $action));
}
$this->messageManager->addSuccess(__('The profile state has been updated.'));
- } catch (\Magento\Core\Exception $e) {
+ } catch (CoreException $e) {
$this->messageManager->addError($e->getMessage());
} catch (\Exception $e) {
$this->messageManager->addError(__('We could not update the profile.'));
- $this->_objectManager->get('Magento\Logger')->logException($e);
+ $this->_logger->logException($e);
}
if ($profile) {
- $this->_redirect('sales/*/view', array('profile' => $profile->getId()));
+ $this->_redirect('sales/*/view', array(self::PARAM_PROFILE => $profile->getId()));
} else {
$this->_redirect('sales/*/');
}
@@ -167,14 +202,14 @@ public function updateProfileAction()
} else {
$this->messageManager->addNotice(__('The profile has no changes.'));
}
- } catch (\Magento\Core\Exception $e) {
+ } catch (CoreException $e) {
$this->messageManager->addError($e->getMessage());
} catch (\Exception $e) {
$this->messageManager->addError(__('We could not update the profile.'));
- $this->_objectManager->get('Magento\Logger')->logException($e);
+ $this->_logger->logException($e);
}
if ($profile) {
- $this->_redirect('sales/*/view', array('profile' => $profile->getId()));
+ $this->_redirect('sales/*/view', array(self::PARAM_PROFILE => $profile->getId()));
} else {
$this->_redirect('sales/*/');
}
@@ -186,39 +221,29 @@ public function updateProfileAction()
*/
public function customerGridAction()
{
- $this->_initCustomer();
- $this->_view->loadLayout(false);
- $this->_view->renderLayout();
- }
-
- /**
- * Initialize customer by ID specified in request
- *
- * @return \Magento\Sales\Controller\Adminhtml\Billing\Agreement
- */
- protected function _initCustomer()
- {
- $customerId = (int) $this->getRequest()->getParam('id');
- $customer = $this->_objectManager->create('Magento\Customer\Model\Customer');
+ $customerId = (int)$this->getRequest()->getParam(self::PARAM_CUSTOMER_ID);
if ($customerId) {
- $customer->load($customerId);
+ $this->_coreRegistry->register(CustomerController::REGISTRY_CURRENT_CUSTOMER_ID, $customerId);
}
- $this->_coreRegistry->register('current_customer', $customer);
- return $this;
+ $this->_view->loadLayout(false);
+ $this->_view->renderLayout();
}
/**
* Load/set profile
*
* @return \Magento\Sales\Model\Recurring\Profile
+ * @throws \Magento\Core\Exception
*/
protected function _initProfile()
{
- $profile = $this->_objectManager->create('Magento\Sales\Model\Recurring\Profile')->load($this->getRequest()->getParam('profile'));
+ /** @var \Magento\Sales\Model\Recurring\Profile $profile */
+ $profile = $this->_objectManager->create('Magento\Sales\Model\Recurring\Profile')
+ ->load($this->getRequest()->getParam(self::PARAM_PROFILE));
if (!$profile->getId()) {
- throw new \Magento\Core\Exception(__('The profile you specified does not exist.'));
+ throw new CoreException(__('The profile you specified does not exist.'));
}
$this->_coreRegistry->register('current_recurring_profile', $profile);
return $profile;
diff --git a/app/code/Magento/Sales/Controller/Billing/Agreement.php b/app/code/Magento/Sales/Controller/Billing/Agreement.php
index 6299b46c1c8ab..e5e63f5cad58a 100644
--- a/app/code/Magento/Sales/Controller/Billing/Agreement.php
+++ b/app/code/Magento/Sales/Controller/Billing/Agreement.php
@@ -122,9 +122,9 @@ public function startWizardAction()
$agreement
->setStoreId($this->_objectManager->get('Magento\Core\Model\StoreManager')->getStore()->getId())
->setMethodCode($paymentCode)
- ->setReturnUrl($this->_objectManager->create('Magento\Core\Model\Url')
+ ->setReturnUrl($this->_objectManager->create('Magento\UrlInterface')
->getUrl('*/*/returnWizard', array('payment_method' => $paymentCode)))
- ->setCancelUrl($this->_objectManager->create('Magento\Core\Model\Url')
+ ->setCancelUrl($this->_objectManager->create('Magento\UrlInterface')
->getUrl('*/*/cancelWizard', array('payment_method' => $paymentCode)));
return $this->getResponse()->setRedirect($agreement->initToken());
diff --git a/app/code/Magento/Sales/Model/AdminOrder/Create.php b/app/code/Magento/Sales/Model/AdminOrder/Create.php
index 57913eee0c3c2..97246cabba103 100644
--- a/app/code/Magento/Sales/Model/AdminOrder/Create.php
+++ b/app/code/Magento/Sales/Model/AdminOrder/Create.php
@@ -159,6 +159,11 @@ class Create extends \Magento\Object implements \Magento\Checkout\Model\Cart\Car
*/
protected $messageManager;
+ /**
+ * @var Product\Quote\Initializer
+ */
+ protected $quoteInitializer;
+
/**
* @param \Magento\ObjectManager $objectManager
* @param \Magento\Event\ManagerInterface $eventManager
@@ -168,6 +173,7 @@ class Create extends \Magento\Object implements \Magento\Checkout\Model\Cart\Car
* @param \Magento\Logger $logger
* @param \Magento\Object\Copy $objectCopyService
* @param \Magento\Message\ManagerInterface $messageManager
+ * @param Product\Quote\Initializer $quoteInitializer
* @param array $data
*/
public function __construct(
@@ -179,6 +185,7 @@ public function __construct(
\Magento\Logger $logger,
\Magento\Object\Copy $objectCopyService,
\Magento\Message\ManagerInterface $messageManager,
+ Product\Quote\Initializer $quoteInitializer,
array $data = array()
) {
$this->_objectManager = $objectManager;
@@ -187,6 +194,7 @@ public function __construct(
$this->_salesConfig = $salesConfig;
$this->_logger = $logger;
$this->_objectCopyService = $objectCopyService;
+ $this->quoteInitializer = $quoteInitializer;
parent::__construct($data);
$this->_session = $sessionQuote;
$this->messageManager = $messageManager;
@@ -817,30 +825,10 @@ public function addProduct($product, $config = 1)
}
}
- $stockItem = $product->getStockItem();
- if ($stockItem && $stockItem->getIsQtyDecimal()) {
- $product->setIsQtyDecimal(1);
- } else {
- $config->setQty((int) $config->getQty());
- }
+ $item = $this->quoteInitializer->init($this->getQuote(), $product, $config);
- $product->setCartQty($config->getQty());
- $item = $this->getQuote()->addProductAdvanced(
- $product,
- $config,
- \Magento\Catalog\Model\Product\Type\AbstractType::PROCESS_MODE_FULL
- );
if (is_string($item)) {
- if ($product->getTypeId() != \Magento\GroupedProduct\Model\Product\Type\Grouped::TYPE_CODE) {
- $item = $this->getQuote()->addProductAdvanced(
- $product,
- $config,
- \Magento\Catalog\Model\Product\Type\AbstractType::PROCESS_MODE_LITE
- );
- }
- if (is_string($item)) {
- throw new \Magento\Core\Exception($item);
- }
+ throw new \Magento\Core\Exception($item);
}
$item->checkData();
diff --git a/app/code/Magento/Sales/Model/AdminOrder/Product/Quote/Initializer.php b/app/code/Magento/Sales/Model/AdminOrder/Product/Quote/Initializer.php
new file mode 100644
index 0000000000000..0e77c12ac3978
--- /dev/null
+++ b/app/code/Magento/Sales/Model/AdminOrder/Product/Quote/Initializer.php
@@ -0,0 +1,64 @@
+
+ *
+ */
+namespace Magento\Sales\Model\AdminOrder\Product\Quote;
+
+class Initializer
+{
+ /**
+ * @param \Magento\Sales\Model\Quote $quote
+ * @param \Magento\Catalog\Model\Product $product
+ * @param \Magento\Object $config
+ * @return \Magento\Sales\Model\Quote\Item|string
+ */
+ public function init(
+ \Magento\Sales\Model\Quote $quote,
+ \Magento\Catalog\Model\Product $product,
+ \Magento\Object $config
+ ) {
+ $stockItem = $product->getStockItem();
+ if ($stockItem && $stockItem->getIsQtyDecimal()) {
+ $product->setIsQtyDecimal(1);
+ } else {
+ $config->setQty((int) $config->getQty());
+ }
+
+ $product->setCartQty($config->getQty());
+
+ $item = $quote->addProductAdvanced(
+ $product,
+ $config,
+ \Magento\Catalog\Model\Product\Type\AbstractType::PROCESS_MODE_FULL
+ );
+
+ return $item;
+ }
+
+}
diff --git a/app/code/Magento/Sales/Model/Order/Grid/Row/UrlGenerator.php b/app/code/Magento/Sales/Model/Order/Grid/Row/UrlGenerator.php
index cc16eb5ea4f7d..d04a759081e56 100644
--- a/app/code/Magento/Sales/Model/Order/Grid/Row/UrlGenerator.php
+++ b/app/code/Magento/Sales/Model/Order/Grid/Row/UrlGenerator.php
@@ -37,12 +37,12 @@ class UrlGenerator extends \Magento\Backend\Model\Widget\Grid\Row\UrlGenerator
protected $_authorization;
/**
- * @param \Magento\Backend\Model\Url $backendUrl
+ * @param \Magento\Backend\Model\UrlInterface $backendUrl
* @param \Magento\AuthorizationInterface $authorization
* @param array $args
*/
public function __construct(
- \Magento\Backend\Model\Url $backendUrl,
+ \Magento\Backend\Model\UrlInterface $backendUrl,
\Magento\AuthorizationInterface $authorization,
array $args = array()
) {
diff --git a/app/code/Magento/Sales/Model/Order/Pdf/Items/AbstractItems.php b/app/code/Magento/Sales/Model/Order/Pdf/Items/AbstractItems.php
index 747da4c7137e3..52700c71af862 100644
--- a/app/code/Magento/Sales/Model/Order/Pdf/Items/AbstractItems.php
+++ b/app/code/Magento/Sales/Model/Order/Pdf/Items/AbstractItems.php
@@ -24,11 +24,11 @@
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
+namespace Magento\Sales\Model\Order\Pdf\Items;
+
/**
* Sales Order Pdf Items renderer Abstract
*/
-namespace Magento\Sales\Model\Order\Pdf\Items;
-
abstract class AbstractItems extends \Magento\Core\Model\AbstractModel
{
/**
@@ -71,18 +71,24 @@ abstract class AbstractItems extends \Magento\Core\Model\AbstractModel
*
* @var \Magento\Tax\Helper\Data
*/
- protected $_taxData = null;
+ protected $_taxData;
/**
* @var \Magento\Filesystem\Directory\ReadInterface
*/
protected $_rootDirectory;
+ /**
+ * @var \Magento\Filter\FilterManager
+ */
+ protected $filterManager;
+
/**
* @param \Magento\Core\Model\Context $context
* @param \Magento\Core\Model\Registry $registry
* @param \Magento\Tax\Helper\Data $taxData
- * @param \Magento\App\Filesystem $filesystem,
+ * @param \Magento\App\Filesystem $filesystem ,
+ * @param \Magento\Filter\FilterManager $filterManager
* @param \Magento\Core\Model\Resource\AbstractResource $resource
* @param \Magento\Data\Collection\Db $resourceCollection
* @param array $data
@@ -92,10 +98,12 @@ public function __construct(
\Magento\Core\Model\Registry $registry,
\Magento\Tax\Helper\Data $taxData,
\Magento\App\Filesystem $filesystem,
+ \Magento\Filter\FilterManager $filterManager,
\Magento\Core\Model\Resource\AbstractResource $resource = null,
\Magento\Data\Collection\Db $resourceCollection = null,
array $data = array()
) {
+ $this->filterManager = $filterManager;
$this->_taxData = $taxData;
$this->_rootDirectory = $filesystem->getDirectoryRead(\Magento\App\Filesystem::ROOT_DIR);
parent::__construct($context, $registry, $resource, $resourceCollection, $data);
@@ -169,7 +177,7 @@ public function setPage(\Zend_Pdf_Page $page)
*/
public function getOrder()
{
- if (is_null($this->_order)) {
+ if (null === $this->_order) {
throw new \Magento\Core\Exception(__('The order object is not specified.'));
}
return $this->_order;
@@ -183,7 +191,7 @@ public function getOrder()
*/
public function getSource()
{
- if (is_null($this->_source)) {
+ if (null === $this->_source) {
throw new \Magento\Core\Exception(__('The source object is not specified.'));
}
return $this->_source;
@@ -197,7 +205,7 @@ public function getSource()
*/
public function getItem()
{
- if (is_null($this->_item)) {
+ if (null === $this->_item) {
throw new \Magento\Core\Exception(__('An item object is not specified.'));
}
return $this->_item;
@@ -211,7 +219,7 @@ public function getItem()
*/
public function getPdf()
{
- if (is_null($this->_pdf)) {
+ if (null === $this->_pdf) {
throw new \Magento\Core\Exception(__('A PDF object is not specified.'));
}
return $this->_pdf;
@@ -225,7 +233,7 @@ public function getPdf()
*/
public function getPage()
{
- if (is_null($this->_pdfPage)) {
+ if (null === $this->_pdfPage) {
throw new \Magento\Core\Exception(__('A PDF page object is not specified.'));
}
return $this->_pdfPage;
@@ -250,7 +258,7 @@ protected function _formatOptionValue($value)
$resultValue = '';
if (is_array($value)) {
if (isset($value['qty'])) {
- $resultValue .= sprintf('%d', $value['qty']) . ' x ';
+ $resultValue .= $this->filterManager->sprintf($value['qty'], array('format' => '%d')) . ' x ';
}
$resultValue .= $value['title'];
@@ -313,7 +321,8 @@ public function getItemPricesForDisplay()
*
* @return array
*/
- public function getItemOptions() {
+ public function getItemOptions()
+ {
$result = array();
$options = $this->getItem()->getOrderItem()->getProductOptions();
if ($options) {
diff --git a/app/code/Magento/Sales/Model/Order/Pdf/Items/Creditmemo/DefaultCreditmemo.php b/app/code/Magento/Sales/Model/Order/Pdf/Items/Creditmemo/DefaultCreditmemo.php
index 644e446049ef0..e66e3689e6ef5 100644
--- a/app/code/Magento/Sales/Model/Order/Pdf/Items/Creditmemo/DefaultCreditmemo.php
+++ b/app/code/Magento/Sales/Model/Order/Pdf/Items/Creditmemo/DefaultCreditmemo.php
@@ -24,15 +24,11 @@
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
+namespace Magento\Sales\Model\Order\Pdf\Items\Creditmemo;
+
/**
* Sales Order Creditmemo Pdf default items renderer
- *
- * @category Magento
- * @package Magento_Sales
- * @author Magento Core Team
*/
-namespace Magento\Sales\Model\Order\Pdf\Items\Creditmemo;
-
class DefaultCreditmemo extends \Magento\Sales\Model\Order\Pdf\Items\AbstractItems
{
/**
@@ -47,6 +43,7 @@ class DefaultCreditmemo extends \Magento\Sales\Model\Order\Pdf\Items\AbstractIte
* @param \Magento\Core\Model\Registry $registry
* @param \Magento\Tax\Helper\Data $taxData
* @param \Magento\App\Filesystem $filesystem
+ * @param \Magento\Filter\FilterManager $filterManager
* @param \Magento\Stdlib\String $string
* @param \Magento\Core\Model\Resource\AbstractResource $resource
* @param \Magento\Data\Collection\Db $resourceCollection
@@ -57,13 +54,23 @@ public function __construct(
\Magento\Core\Model\Registry $registry,
\Magento\Tax\Helper\Data $taxData,
\Magento\App\Filesystem $filesystem,
+ \Magento\Filter\FilterManager $filterManager,
\Magento\Stdlib\String $string,
\Magento\Core\Model\Resource\AbstractResource $resource = null,
\Magento\Data\Collection\Db $resourceCollection = null,
array $data = array()
) {
$this->string = $string;
- parent::__construct($context, $registry, $taxData, $filesystem, $resource, $resourceCollection, $data);
+ parent::__construct(
+ $context,
+ $registry,
+ $taxData,
+ $filesystem,
+ $filterManager,
+ $resource,
+ $resourceCollection,
+ $data
+ );
}
/**
@@ -138,15 +145,17 @@ public function draw()
foreach ($options as $option) {
// draw options label
$lines[][] = array(
- 'text' => $this->string->split(strip_tags($option['label']), 40, true, true),
+ 'text' => $this->string->split($this->filterManager->stripTags($option['label']), 40, true, true),
'font' => 'italic',
'feed' => 35
);
// draw options value
- $_printValue = isset($option['print_value']) ? $option['print_value'] : strip_tags($option['value']);
+ $printValue = isset($option['print_value'])
+ ? $option['print_value']
+ : $this->filterManager->stripTags($option['value']);
$lines[][] = array(
- 'text' => $this->string->split($_printValue, 30, true, true),
+ 'text' => $this->string->split($printValue, 30, true, true),
'feed' => 40
);
}
diff --git a/app/code/Magento/Sales/Model/Order/Pdf/Items/Invoice/DefaultInvoice.php b/app/code/Magento/Sales/Model/Order/Pdf/Items/Invoice/DefaultInvoice.php
index 2fd9830570529..ea9e408dc51bc 100644
--- a/app/code/Magento/Sales/Model/Order/Pdf/Items/Invoice/DefaultInvoice.php
+++ b/app/code/Magento/Sales/Model/Order/Pdf/Items/Invoice/DefaultInvoice.php
@@ -24,11 +24,11 @@
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
+namespace Magento\Sales\Model\Order\Pdf\Items\Invoice;
+
/**
* Sales Order Invoice Pdf default items renderer
*/
-namespace Magento\Sales\Model\Order\Pdf\Items\Invoice;
-
class DefaultInvoice extends \Magento\Sales\Model\Order\Pdf\Items\AbstractItems
{
/**
@@ -43,6 +43,7 @@ class DefaultInvoice extends \Magento\Sales\Model\Order\Pdf\Items\AbstractItems
* @param \Magento\Core\Model\Registry $registry
* @param \Magento\Tax\Helper\Data $taxData
* @param \Magento\App\Filesystem $filesystem
+ * @param \Magento\Filter\FilterManager $filterManager
* @param \Magento\Stdlib\String $string
* @param \Magento\Core\Model\Resource\AbstractResource $resource
* @param \Magento\Data\Collection\Db $resourceCollection
@@ -53,13 +54,23 @@ public function __construct(
\Magento\Core\Model\Registry $registry,
\Magento\Tax\Helper\Data $taxData,
\Magento\App\Filesystem $filesystem,
+ \Magento\Filter\FilterManager $filterManager,
\Magento\Stdlib\String $string,
\Magento\Core\Model\Resource\AbstractResource $resource = null,
\Magento\Data\Collection\Db $resourceCollection = null,
array $data = array()
) {
$this->string = $string;
- parent::__construct($context, $registry, $taxData, $filesystem, $resource, $resourceCollection, $data);
+ parent::__construct(
+ $context,
+ $registry,
+ $taxData,
+ $filesystem,
+ $filterManager,
+ $resource,
+ $resourceCollection,
+ $data
+ );
}
/**
@@ -98,7 +109,7 @@ public function draw()
$prices = $this->getItemPricesForDisplay();
$feedPrice = 395;
$feedSubtotal = $feedPrice + 170;
- foreach ($prices as $priceData){
+ foreach ($prices as $priceData) {
if (isset($priceData['label'])) {
// draw Price label
$lines[$i][] = array(
@@ -145,18 +156,18 @@ public function draw()
foreach ($options as $option) {
// draw options label
$lines[][] = array(
- 'text' => $this->string->split(strip_tags($option['label']), 40, true, true),
+ 'text' => $this->string->split($this->filterManager->stripTags($option['label']), 40, true, true),
'font' => 'italic',
'feed' => 35
);
if ($option['value']) {
if (isset($option['print_value'])) {
- $_printValue = $option['print_value'];
+ $printValue = $option['print_value'];
} else {
- $_printValue = strip_tags($option['value']);
+ $printValue = $this->filterManager->stripTags($option['value']);
}
- $values = explode(', ', $_printValue);
+ $values = explode(', ', $printValue);
foreach ($values as $value) {
$lines[][] = array(
'text' => $this->string->split($value, 30, true, true),
diff --git a/app/code/Magento/Sales/Model/Order/Pdf/Items/Shipment/DefaultShipment.php b/app/code/Magento/Sales/Model/Order/Pdf/Items/Shipment/DefaultShipment.php
index 3d5427b9e57b4..b51d13f24fcb5 100644
--- a/app/code/Magento/Sales/Model/Order/Pdf/Items/Shipment/DefaultShipment.php
+++ b/app/code/Magento/Sales/Model/Order/Pdf/Items/Shipment/DefaultShipment.php
@@ -24,11 +24,11 @@
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
+namespace Magento\Sales\Model\Order\Pdf\Items\Shipment;
+
/**
* Sales Order Shipment Pdf default items renderer
*/
-namespace Magento\Sales\Model\Order\Pdf\Items\Shipment;
-
class DefaultShipment extends \Magento\Sales\Model\Order\Pdf\Items\AbstractItems
{
/**
@@ -43,6 +43,7 @@ class DefaultShipment extends \Magento\Sales\Model\Order\Pdf\Items\AbstractItems
* @param \Magento\Core\Model\Registry $registry
* @param \Magento\Tax\Helper\Data $taxData
* @param \Magento\App\Filesystem $filesystem
+ * @param \Magento\Filter\FilterManager $filterManager
* @param \Magento\Stdlib\String $string
* @param \Magento\Core\Model\Resource\AbstractResource $resource
* @param \Magento\Data\Collection\Db $resourceCollection
@@ -53,13 +54,23 @@ public function __construct(
\Magento\Core\Model\Registry $registry,
\Magento\Tax\Helper\Data $taxData,
\Magento\App\Filesystem $filesystem,
+ \Magento\Filter\FilterManager $filterManager,
\Magento\Stdlib\String $string,
\Magento\Core\Model\Resource\AbstractResource $resource = null,
\Magento\Data\Collection\Db $resourceCollection = null,
array $data = array()
) {
$this->string = $string;
- parent::__construct($context, $registry, $taxData, $filesystem, $resource, $resourceCollection, $data);
+ parent::__construct(
+ $context,
+ $registry,
+ $taxData,
+ $filesystem,
+ $filterManager,
+ $resource,
+ $resourceCollection,
+ $data
+ );
}
/**
@@ -73,7 +84,6 @@ public function draw()
$lines = array();
// draw Product name
- $stringHelper = $this->string;
$lines[0] = array(array(
'text' => $this->string->split($item->getName(), 60, true, true),
'feed' => 100,
@@ -81,7 +91,7 @@ public function draw()
// draw QTY
$lines[0][] = array(
- 'text' => $item->getQty()*1,
+ 'text' => $item->getQty() * 1,
'feed' => 35
);
@@ -98,17 +108,17 @@ public function draw()
foreach ($options as $option) {
// draw options label
$lines[][] = array(
- 'text' => $stringHelper->split(strip_tags($option['label']), 70, true, true),
+ 'text' => $this->string->split($this->filterManager->stripTags($option['label']), 70, true, true),
'font' => 'italic',
'feed' => 110
);
// draw options value
if ($option['value']) {
- $_printValue = isset($option['print_value'])
+ $printValue = isset($option['print_value'])
? $option['print_value']
- : strip_tags($option['value']);
- $values = explode(', ', $_printValue);
+ : $this->filterManager->stripTags($option['value']);
+ $values = explode(', ', $printValue);
foreach ($values as $value) {
$lines[][] = array(
'text' => $this->string->split($value, 50, true, true),
diff --git a/app/code/Magento/Sales/Model/Quote.php b/app/code/Magento/Sales/Model/Quote.php
index 61594e2c68f5b..ac36e1945ac20 100644
--- a/app/code/Magento/Sales/Model/Quote.php
+++ b/app/code/Magento/Sales/Model/Quote.php
@@ -220,7 +220,7 @@ class Quote extends \Magento\Core\Model\AbstractModel
protected $_storeManager;
/**
- * @var \Magento\Core\Model\Config
+ * @var \Magento\App\ConfigInterface
*/
protected $_config;
@@ -291,7 +291,7 @@ class Quote extends \Magento\Core\Model\AbstractModel
* @param \Magento\Catalog\Helper\Product $catalogProduct
* @param \Magento\Core\Model\Store\ConfigInterface $coreStoreConfig
* @param \Magento\Core\Model\StoreManagerInterface $storeManager
- * @param \Magento\Core\Model\Config $config
+ * @param \Magento\App\ConfigInterface $config
* @param \Magento\Sales\Model\Quote\AddressFactory $quoteAddressFactory
* @param \Magento\Customer\Model\CustomerFactory $customerFactory
* @param \Magento\Customer\Model\GroupFactory $customerGroupFactory
@@ -315,7 +315,7 @@ public function __construct(
\Magento\Catalog\Helper\Product $catalogProduct,
\Magento\Core\Model\Store\ConfigInterface $coreStoreConfig,
\Magento\Core\Model\StoreManagerInterface $storeManager,
- \Magento\Core\Model\Config $config,
+ \Magento\App\ConfigInterface $config,
\Magento\Sales\Model\Quote\AddressFactory $quoteAddressFactory,
\Magento\Customer\Model\CustomerFactory $customerFactory,
\Magento\Customer\Model\GroupFactory $customerGroupFactory,
diff --git a/app/code/Magento/Sales/Model/Quote/Item/RelatedProducts.php b/app/code/Magento/Sales/Model/Quote/Item/RelatedProducts.php
new file mode 100644
index 0000000000000..3776bf178d387
--- /dev/null
+++ b/app/code/Magento/Sales/Model/Quote/Item/RelatedProducts.php
@@ -0,0 +1,67 @@
+_relatedProductTypes = $relatedProductTypes;
+ }
+
+ /**
+ * Retrieve Array of product ids which have special relation with products in Cart
+ *
+ * @param \Magento\Sales\Model\Quote\Item[] $quoteItems
+ * @return array
+ */
+ public function getRelatedProductIds(array $quoteItems)
+ {
+ $productIds = array();
+ /** @var $quoteItems \Magento\Sales\Model\Quote\Item[] */
+ foreach ($quoteItems as $quoteItem) {
+ $productTypeOpt = $quoteItem->getOptionByCode('product_type');
+ if ($productTypeOpt instanceof \Magento\Sales\Model\Quote\Item\Option) {
+ if (in_array($productTypeOpt->getValue(), $this->_relatedProductTypes)
+ && $productTypeOpt->getProductId()
+ ) {
+ $productIds[] = $productTypeOpt->getProductId();
+ }
+ }
+ }
+ return $productIds;
+ }
+}
diff --git a/app/code/Magento/Sales/Model/Resource/Report/Bestsellers.php b/app/code/Magento/Sales/Model/Resource/Report/Bestsellers.php
index 750cb67340180..5e6f50f10039c 100644
--- a/app/code/Magento/Sales/Model/Resource/Report/Bestsellers.php
+++ b/app/code/Magento/Sales/Model/Resource/Report/Bestsellers.php
@@ -45,6 +45,17 @@ class Bestsellers extends \Magento\Sales\Model\Resource\Report\AbstractReport
*/
protected $_salesResourceHelper;
+ /**
+ * Ignored product types list
+ *
+ * @var array
+ */
+ protected $ignoredProductTypes = array(
+ \Magento\Catalog\Model\Product\Type::TYPE_CONFIGURABLE
+ => \Magento\Catalog\Model\Product\Type::TYPE_CONFIGURABLE,
+ \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE => \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE,
+ );
+
/**
* @param \Magento\App\Resource $resource
* @param \Magento\Logger $logger
@@ -54,6 +65,7 @@ class Bestsellers extends \Magento\Sales\Model\Resource\Report\AbstractReport
* @param \Magento\Stdlib\DateTime\Timezone\Validator $timezoneValidator
* @param \Magento\Catalog\Model\Resource\Product $productResource
* @param \Magento\Sales\Model\Resource\Helper $salesResourceHelper
+ * @param array $ignoredProductTypes
*/
public function __construct(
\Magento\App\Resource $resource,
@@ -63,11 +75,13 @@ public function __construct(
\Magento\Stdlib\DateTime $dateTime,
\Magento\Stdlib\DateTime\Timezone\Validator $timezoneValidator,
\Magento\Catalog\Model\Resource\Product $productResource,
- \Magento\Sales\Model\Resource\Helper $salesResourceHelper
+ \Magento\Sales\Model\Resource\Helper $salesResourceHelper,
+ array $ignoredProductTypes = array()
) {
parent::__construct($resource, $logger, $locale, $reportsFlagFactory, $dateTime, $timezoneValidator);
$this->_productResource = $productResource;
$this->_salesResourceHelper = $salesResourceHelper;
+ $this->ignoredProductTypes = array_merge($this->ignoredProductTypes, $ignoredProductTypes);
}
@@ -154,16 +168,10 @@ public function aggregate($from = null, $to = null)
)
->where('source_table.state != ?', \Magento\Sales\Model\Order::STATE_CANCELED);
- $productTypes = array(
- \Magento\GroupedProduct\Model\Product\Type\Grouped::TYPE_CODE,
- \Magento\Catalog\Model\Product\Type::TYPE_CONFIGURABLE,
- \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE,
- );
-
$joinExpr = array(
'product.entity_id = order_item.product_id',
$adapter->quoteInto('product.entity_type_id = ?', $this->_productResource->getTypeId()),
- $adapter->quoteInto('product.type_id NOT IN(?)', $productTypes)
+ $adapter->quoteInto('product.type_id NOT IN(?)', $this->ignoredProductTypes)
);
$joinExpr = implode(' AND ', $joinExpr);
diff --git a/app/code/Magento/Sales/Model/Resource/Setup.php b/app/code/Magento/Sales/Model/Resource/Setup.php
index 4d0e07fc22233..06de721bebb6d 100644
--- a/app/code/Magento/Sales/Model/Resource/Setup.php
+++ b/app/code/Magento/Sales/Model/Resource/Setup.php
@@ -32,7 +32,7 @@
class Setup extends \Magento\Eav\Model\Entity\Setup
{
/**
- * @var \Magento\Core\Model\Config
+ * @var \Magento\App\ConfigInterface
*/
protected $_config;
@@ -46,7 +46,7 @@ class Setup extends \Magento\Eav\Model\Entity\Setup
* @param string $resourceName
* @param \Magento\App\CacheInterface $cache
* @param \Magento\Eav\Model\Resource\Entity\Attribute\Group\CollectionFactory $attrGroupCollectionFactory
- * @param \Magento\Core\Model\Config $config
+ * @param \Magento\App\ConfigInterface $config
* @param string $moduleName
* @param string $connectionName
*/
@@ -55,7 +55,7 @@ public function __construct(
$resourceName,
\Magento\App\CacheInterface $cache,
\Magento\Eav\Model\Resource\Entity\Attribute\Group\CollectionFactory $attrGroupCollectionFactory,
- \Magento\Core\Model\Config $config,
+ \Magento\App\ConfigInterface $config,
$moduleName = 'Magento_Sales',
$connectionName = ''
) {
@@ -260,7 +260,7 @@ public function getDefaultEntities()
/**
* Get config model
*
- * @return \Magento\Core\Model\Config
+ * @return \Magento\App\ConfigInterface
*/
public function getConfigModel()
{
diff --git a/app/code/Magento/Sales/etc/di.xml b/app/code/Magento/Sales/etc/di.xml
index 59078dba80599..3c57eced98723 100644
--- a/app/code/Magento/Sales/etc/di.xml
+++ b/app/code/Magento/Sales/etc/di.xml
@@ -51,16 +51,16 @@
-
- sales_quote_item
-
+
+ - sales_quote_item
+
-
- Magento\Sales\Model\Resource\Setup
-
+
+ - Magento\Sales\Model\Resource\Setup
+
diff --git a/app/code/Magento/Sales/etc/frontend/di.xml b/app/code/Magento/Sales/etc/frontend/di.xml
index a80b694568a68..dc8ac95a7b91c 100644
--- a/app/code/Magento/Sales/etc/frontend/di.xml
+++ b/app/code/Magento/Sales/etc/frontend/di.xml
@@ -26,9 +26,9 @@
-
- /sales/
-
+
+ - /sales/
+
diff --git a/app/code/Magento/Sales/etc/module.xml b/app/code/Magento/Sales/etc/module.xml
index ca7f4f1ff6d8c..6f7a570a72044 100755
--- a/app/code/Magento/Sales/etc/module.xml
+++ b/app/code/Magento/Sales/etc/module.xml
@@ -28,13 +28,11 @@
-
-
diff --git a/app/code/Magento/Sales/etc/pdf.xml b/app/code/Magento/Sales/etc/pdf.xml
index d0c40dc3024d4..36342a1e9cda2 100644
--- a/app/code/Magento/Sales/etc/pdf.xml
+++ b/app/code/Magento/Sales/etc/pdf.xml
@@ -27,14 +27,12 @@
Magento\Sales\Model\Order\Pdf\Items\Invoice\DefaultInvoice
- Magento\Sales\Model\Order\Pdf\Items\Invoice\Grouped
Magento\Sales\Model\Order\Pdf\Items\Shipment\DefaultShipment
Magento\Sales\Model\Order\Pdf\Items\Creditmemo\DefaultCreditmemo
- Magento\Sales\Model\Order\Pdf\Items\Creditmemo\Grouped
diff --git a/app/code/Magento/Sales/etc/sales.xml b/app/code/Magento/Sales/etc/sales.xml
index 1d1a9e1d01086..9c9396f7723cd 100644
--- a/app/code/Magento/Sales/etc/sales.xml
+++ b/app/code/Magento/Sales/etc/sales.xml
@@ -63,6 +63,5 @@
-
diff --git a/app/code/Magento/Sales/view/adminhtml/layout/sales_order_creditmemo_new.xml b/app/code/Magento/Sales/view/adminhtml/layout/sales_order_creditmemo_new.xml
index 8ef5db3a77437..4d22558f1c87c 100644
--- a/app/code/Magento/Sales/view/adminhtml/layout/sales_order_creditmemo_new.xml
+++ b/app/code/Magento/Sales/view/adminhtml/layout/sales_order_creditmemo_new.xml
@@ -33,40 +33,11 @@
-
-
diff --git a/app/code/Magento/Sales/view/adminhtml/layout/sales_order_creditmemo_updateqty.xml b/app/code/Magento/Sales/view/adminhtml/layout/sales_order_creditmemo_updateqty.xml
index f3eaade1dc2fc..4d23e16b95544 100644
--- a/app/code/Magento/Sales/view/adminhtml/layout/sales_order_creditmemo_updateqty.xml
+++ b/app/code/Magento/Sales/view/adminhtml/layout/sales_order_creditmemo_updateqty.xml
@@ -28,39 +28,11 @@
-
-
diff --git a/app/code/Magento/Sales/view/adminhtml/layout/sales_order_creditmemo_view.xml b/app/code/Magento/Sales/view/adminhtml/layout/sales_order_creditmemo_view.xml
index 36169c4bf9dd1..f98cf91803f03 100644
--- a/app/code/Magento/Sales/view/adminhtml/layout/sales_order_creditmemo_view.xml
+++ b/app/code/Magento/Sales/view/adminhtml/layout/sales_order_creditmemo_view.xml
@@ -33,7 +33,6 @@
-
-
diff --git a/app/code/Magento/Sales/view/adminhtml/layout/sales_order_invoice_new.xml b/app/code/Magento/Sales/view/adminhtml/layout/sales_order_invoice_new.xml
index 6a00c82dd57a4..2b526cbbd1225 100644
--- a/app/code/Magento/Sales/view/adminhtml/layout/sales_order_invoice_new.xml
+++ b/app/code/Magento/Sales/view/adminhtml/layout/sales_order_invoice_new.xml
@@ -33,53 +33,10 @@
-
-
diff --git a/app/code/Magento/Sales/view/adminhtml/layout/sales_order_invoice_updateqty.xml b/app/code/Magento/Sales/view/adminhtml/layout/sales_order_invoice_updateqty.xml
index 8a658bd1e9bd9..c0f08719b17fb 100644
--- a/app/code/Magento/Sales/view/adminhtml/layout/sales_order_invoice_updateqty.xml
+++ b/app/code/Magento/Sales/view/adminhtml/layout/sales_order_invoice_updateqty.xml
@@ -28,53 +28,10 @@
-
-
diff --git a/app/code/Magento/Sales/view/adminhtml/layout/sales_order_invoice_view.xml b/app/code/Magento/Sales/view/adminhtml/layout/sales_order_invoice_view.xml
index d8081b524f28d..9d5646513aeb1 100644
--- a/app/code/Magento/Sales/view/adminhtml/layout/sales_order_invoice_view.xml
+++ b/app/code/Magento/Sales/view/adminhtml/layout/sales_order_invoice_view.xml
@@ -33,7 +33,6 @@
-
-
diff --git a/app/code/Magento/Sales/view/adminhtml/layout/sales_order_view.xml b/app/code/Magento/Sales/view/adminhtml/layout/sales_order_view.xml
index 48542594e246c..b32df85183b4b 100644
--- a/app/code/Magento/Sales/view/adminhtml/layout/sales_order_view.xml
+++ b/app/code/Magento/Sales/view/adminhtml/layout/sales_order_view.xml
@@ -48,7 +48,6 @@
-
diff --git a/app/code/Magento/Sales/view/adminhtml/order/create/form/address.phtml b/app/code/Magento/Sales/view/adminhtml/order/create/form/address.phtml
index b83784b849ec5..68a9f311f64a8 100644
--- a/app/code/Magento/Sales/view/adminhtml/order/create/form/address.phtml
+++ b/app/code/Magento/Sales/view/adminhtml/order/create/form/address.phtml
@@ -23,6 +23,10 @@
* @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
*/
+
+/**
+ * @var \Magento\Sales\Block\Adminhtml\Order\Create\Billing\Address|\Magento\Sales\Block\Adminhtml\Order\Create\Shipping\Address $this
+ */
if($this->getIsShipping()):
$_fieldsContainerId = 'order-shipping_address_fields';
$_addressChoiceContainerId = 'order-shipping_address_choice';
diff --git a/app/code/Magento/Sales/view/adminhtml/order/create/sidebar/items.phtml b/app/code/Magento/Sales/view/adminhtml/order/create/sidebar/items.phtml
index 702e9d3e2f75e..6e6d2171acf22 100644
--- a/app/code/Magento/Sales/view/adminhtml/order/create/sidebar/items.phtml
+++ b/app/code/Magento/Sales/view/adminhtml/order/create/sidebar/items.phtml
@@ -70,9 +70,7 @@
escapeHtml($_item->getName()) ?> |
canDisplayItemQty()): ?>
- getProduct()->getTypeId() != \Magento\GroupedProduct\Model\Product\Type\Grouped::TYPE_CODE): ?>
- getQty()*1 ? $_item->getQty()*1 : 1 ?>
-
+ getItemQty($_item); ?>
|
canDisplayPrice()): ?>
@@ -82,9 +80,9 @@
|
- getTypeId() == \Magento\GroupedProduct\Model\Product\Type\Grouped::TYPE_CODE && $this->getDataId() == 'wishlist'): ?>
+ isConfigurationRequired($_item->getTypeId()) && $this->getDataId() == 'wishlist'): ?>
- getTypeId() == \Magento\GroupedProduct\Model\Product\Type\Grouped::TYPE_CODE): ?>
+ isConfigurationRequired($_item->getTypeId())): ?>
diff --git a/app/code/Magento/Sales/view/frontend/layout/sales_email_order_creditmemo_items.xml b/app/code/Magento/Sales/view/frontend/layout/sales_email_order_creditmemo_items.xml
index 8606fd7ae2387..a92b603517b6b 100644
--- a/app/code/Magento/Sales/view/frontend/layout/sales_email_order_creditmemo_items.xml
+++ b/app/code/Magento/Sales/view/frontend/layout/sales_email_order_creditmemo_items.xml
@@ -24,9 +24,9 @@
*/
-->
+
-
-
+
colspan="3" align="right" style="padding:3px 9px"
diff --git a/app/code/Magento/Bundle/view/frontend/layout/sales_order_invoice.xml b/app/code/Magento/Sales/view/frontend/layout/sales_email_order_creditmemo_renderers.xml
similarity index 75%
rename from app/code/Magento/Bundle/view/frontend/layout/sales_order_invoice.xml
rename to app/code/Magento/Sales/view/frontend/layout/sales_email_order_creditmemo_renderers.xml
index 861baa1c1087f..6103c5b3f2397 100644
--- a/app/code/Magento/Bundle/view/frontend/layout/sales_order_invoice.xml
+++ b/app/code/Magento/Sales/view/frontend/layout/sales_email_order_creditmemo_renderers.xml
@@ -23,8 +23,8 @@
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
*/
-->
-
-
-
+
+
+
diff --git a/app/code/Magento/Sales/view/frontend/layout/sales_email_order_invoice_items.xml b/app/code/Magento/Sales/view/frontend/layout/sales_email_order_invoice_items.xml
index fc245231b4706..20883ecb5ca33 100644
--- a/app/code/Magento/Sales/view/frontend/layout/sales_email_order_invoice_items.xml
+++ b/app/code/Magento/Sales/view/frontend/layout/sales_email_order_invoice_items.xml
@@ -24,9 +24,9 @@
*/
-->
+
-
-
+
colspan="3" align="right" style="padding:3px 9px"
diff --git a/app/code/Magento/Sales/view/frontend/layout/sales_email_order_invoice_renderers.xml b/app/code/Magento/Sales/view/frontend/layout/sales_email_order_invoice_renderers.xml
new file mode 100644
index 0000000000000..5a95ce784ced9
--- /dev/null
+++ b/app/code/Magento/Sales/view/frontend/layout/sales_email_order_invoice_renderers.xml
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Sales/view/frontend/layout/sales_email_order_items.xml b/app/code/Magento/Sales/view/frontend/layout/sales_email_order_items.xml
index fcba97901fe21..aea3fbcde4e36 100644
--- a/app/code/Magento/Sales/view/frontend/layout/sales_email_order_items.xml
+++ b/app/code/Magento/Sales/view/frontend/layout/sales_email_order_items.xml
@@ -24,9 +24,9 @@
*/
-->
+
-
-
+
colspan="3" align="right" style="padding:3px 9px"
diff --git a/app/code/Magento/Bundle/view/frontend/layout/sales_guest_shipment.xml b/app/code/Magento/Sales/view/frontend/layout/sales_email_order_renderers.xml
similarity index 76%
rename from app/code/Magento/Bundle/view/frontend/layout/sales_guest_shipment.xml
rename to app/code/Magento/Sales/view/frontend/layout/sales_email_order_renderers.xml
index d34a37f904840..506495e63bf9c 100644
--- a/app/code/Magento/Bundle/view/frontend/layout/sales_guest_shipment.xml
+++ b/app/code/Magento/Sales/view/frontend/layout/sales_email_order_renderers.xml
@@ -23,8 +23,8 @@
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
*/
-->
-
-
-
+
+
+
diff --git a/app/code/Magento/Sales/view/frontend/layout/sales_email_order_shipment_items.xml b/app/code/Magento/Sales/view/frontend/layout/sales_email_order_shipment_items.xml
index dbf12ea55f9c1..f041570c04a1d 100644
--- a/app/code/Magento/Sales/view/frontend/layout/sales_email_order_shipment_items.xml
+++ b/app/code/Magento/Sales/view/frontend/layout/sales_email_order_shipment_items.xml
@@ -24,8 +24,9 @@
*/
-->
+
-
+
diff --git a/app/code/Magento/Sales/view/frontend/layout/sales_email_order_shipment_renderers.xml b/app/code/Magento/Sales/view/frontend/layout/sales_email_order_shipment_renderers.xml
new file mode 100644
index 0000000000000..1c435a00cc111
--- /dev/null
+++ b/app/code/Magento/Sales/view/frontend/layout/sales_email_order_shipment_renderers.xml
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Sales/view/frontend/layout/sales_guest_creditmemo.xml b/app/code/Magento/Sales/view/frontend/layout/sales_guest_creditmemo.xml
index 17b7d0cb21109..91ecf77c39532 100644
--- a/app/code/Magento/Sales/view/frontend/layout/sales_guest_creditmemo.xml
+++ b/app/code/Magento/Sales/view/frontend/layout/sales_guest_creditmemo.xml
@@ -24,6 +24,7 @@
*/
-->
+
1column.phtml
@@ -35,8 +36,7 @@
-
-
+
colspan="6" class="mark"
diff --git a/app/code/Magento/Sales/view/frontend/layout/sales_guest_invoice.xml b/app/code/Magento/Sales/view/frontend/layout/sales_guest_invoice.xml
index 54bd4a12913bc..35aab993fe85a 100644
--- a/app/code/Magento/Sales/view/frontend/layout/sales_guest_invoice.xml
+++ b/app/code/Magento/Sales/view/frontend/layout/sales_guest_invoice.xml
@@ -24,6 +24,7 @@
*/
-->
+
1column.phtml
@@ -35,8 +36,7 @@
-
-
+
colspan="4" class="mark"
diff --git a/app/code/Magento/Sales/view/frontend/layout/sales_guest_print.xml b/app/code/Magento/Sales/view/frontend/layout/sales_guest_print.xml
index 7b55c73b3b5af..947436d8b7188 100644
--- a/app/code/Magento/Sales/view/frontend/layout/sales_guest_print.xml
+++ b/app/code/Magento/Sales/view/frontend/layout/sales_guest_print.xml
@@ -24,10 +24,10 @@
*/
-->
+
-
-
+
colspan="4" class="mark"
diff --git a/app/code/Magento/Sales/view/frontend/layout/sales_guest_printcreditmemo.xml b/app/code/Magento/Sales/view/frontend/layout/sales_guest_printcreditmemo.xml
index f8d89184781e6..9fe41bf9baaac 100644
--- a/app/code/Magento/Sales/view/frontend/layout/sales_guest_printcreditmemo.xml
+++ b/app/code/Magento/Sales/view/frontend/layout/sales_guest_printcreditmemo.xml
@@ -24,10 +24,10 @@
*/
-->
+
-
-
+
colspan="6" class="mark"
diff --git a/app/code/Magento/Sales/view/frontend/layout/sales_guest_printinvoice.xml b/app/code/Magento/Sales/view/frontend/layout/sales_guest_printinvoice.xml
index 13c631f5b3f33..5eacd46c052b7 100644
--- a/app/code/Magento/Sales/view/frontend/layout/sales_guest_printinvoice.xml
+++ b/app/code/Magento/Sales/view/frontend/layout/sales_guest_printinvoice.xml
@@ -24,10 +24,10 @@
*/
-->
+
-
-
+
colspan="4" class="mark"
diff --git a/app/code/Magento/Sales/view/frontend/layout/sales_guest_printshipment.xml b/app/code/Magento/Sales/view/frontend/layout/sales_guest_printshipment.xml
index 7725c00812929..c496aad0a008a 100644
--- a/app/code/Magento/Sales/view/frontend/layout/sales_guest_printshipment.xml
+++ b/app/code/Magento/Sales/view/frontend/layout/sales_guest_printshipment.xml
@@ -24,9 +24,10 @@
*/
-->
+
-
+
diff --git a/app/code/Magento/Sales/view/frontend/layout/sales_guest_view.xml b/app/code/Magento/Sales/view/frontend/layout/sales_guest_view.xml
index eb67d146a8a4c..1474388986a21 100644
--- a/app/code/Magento/Sales/view/frontend/layout/sales_guest_view.xml
+++ b/app/code/Magento/Sales/view/frontend/layout/sales_guest_view.xml
@@ -24,6 +24,8 @@
*/
-->
+
+
1column.phtml
@@ -35,8 +37,7 @@
-
-
+
colspan="4" class="mark"
diff --git a/app/code/Magento/Sales/view/frontend/layout/sales_order_creditmemo.xml b/app/code/Magento/Sales/view/frontend/layout/sales_order_creditmemo.xml
index 15fd5b781dec4..edaffb426d100 100644
--- a/app/code/Magento/Sales/view/frontend/layout/sales_order_creditmemo.xml
+++ b/app/code/Magento/Sales/view/frontend/layout/sales_order_creditmemo.xml
@@ -24,6 +24,7 @@
*/
-->
+
@@ -31,8 +32,7 @@
-
-
+
colspan="6" class="mark"
diff --git a/app/code/Magento/Sales/view/frontend/layout/sales_order_creditmemo_renderers.xml b/app/code/Magento/Sales/view/frontend/layout/sales_order_creditmemo_renderers.xml
new file mode 100644
index 0000000000000..a963c5fa43eaf
--- /dev/null
+++ b/app/code/Magento/Sales/view/frontend/layout/sales_order_creditmemo_renderers.xml
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Sales/view/frontend/layout/sales_order_invoice.xml b/app/code/Magento/Sales/view/frontend/layout/sales_order_invoice.xml
index 856c8e534e64f..127c7ea7d22a8 100644
--- a/app/code/Magento/Sales/view/frontend/layout/sales_order_invoice.xml
+++ b/app/code/Magento/Sales/view/frontend/layout/sales_order_invoice.xml
@@ -25,14 +25,14 @@
-->
+
-
-
+
colspan="4" class="mark"
diff --git a/app/code/Magento/Sales/view/frontend/layout/sales_order_invoice_renderers.xml b/app/code/Magento/Sales/view/frontend/layout/sales_order_invoice_renderers.xml
new file mode 100644
index 0000000000000..81ebc1a621825
--- /dev/null
+++ b/app/code/Magento/Sales/view/frontend/layout/sales_order_invoice_renderers.xml
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Sales/view/frontend/layout/sales_order_item_renderers.xml b/app/code/Magento/Sales/view/frontend/layout/sales_order_item_renderers.xml
new file mode 100644
index 0000000000000..2789f977398fc
--- /dev/null
+++ b/app/code/Magento/Sales/view/frontend/layout/sales_order_item_renderers.xml
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Sales/view/frontend/layout/sales_order_print.xml b/app/code/Magento/Sales/view/frontend/layout/sales_order_print.xml
index 26b8965c4893a..67df30b8b6c40 100644
--- a/app/code/Magento/Sales/view/frontend/layout/sales_order_print.xml
+++ b/app/code/Magento/Sales/view/frontend/layout/sales_order_print.xml
@@ -24,10 +24,10 @@
*/
-->
+
-
-
+
colspan="4" class="mark"
diff --git a/app/code/Magento/Bundle/view/frontend/layout/paypal_express_review.xml b/app/code/Magento/Sales/view/frontend/layout/sales_order_print_creditmemo_renderers.xml
similarity index 82%
rename from app/code/Magento/Bundle/view/frontend/layout/paypal_express_review.xml
rename to app/code/Magento/Sales/view/frontend/layout/sales_order_print_creditmemo_renderers.xml
index 657757e4e4a6d..66eb571443331 100644
--- a/app/code/Magento/Bundle/view/frontend/layout/paypal_express_review.xml
+++ b/app/code/Magento/Sales/view/frontend/layout/sales_order_print_creditmemo_renderers.xml
@@ -24,7 +24,7 @@
*/
-->
-
-
+
+
diff --git a/app/code/Magento/Sales/view/frontend/layout/sales_order_print_invoice_renderers.xml b/app/code/Magento/Sales/view/frontend/layout/sales_order_print_invoice_renderers.xml
new file mode 100644
index 0000000000000..323263038a0a3
--- /dev/null
+++ b/app/code/Magento/Sales/view/frontend/layout/sales_order_print_invoice_renderers.xml
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Sales/view/frontend/layout/sales_order_print_renderers.xml b/app/code/Magento/Sales/view/frontend/layout/sales_order_print_renderers.xml
new file mode 100644
index 0000000000000..bc4ce6d24df16
--- /dev/null
+++ b/app/code/Magento/Sales/view/frontend/layout/sales_order_print_renderers.xml
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Bundle/view/frontend/layout/sales_order_printorder.xml b/app/code/Magento/Sales/view/frontend/layout/sales_order_print_shipment_renderers.xml
similarity index 83%
rename from app/code/Magento/Bundle/view/frontend/layout/sales_order_printorder.xml
rename to app/code/Magento/Sales/view/frontend/layout/sales_order_print_shipment_renderers.xml
index bea81de24d974..7b6bbe02442de 100644
--- a/app/code/Magento/Bundle/view/frontend/layout/sales_order_printorder.xml
+++ b/app/code/Magento/Sales/view/frontend/layout/sales_order_print_shipment_renderers.xml
@@ -24,7 +24,7 @@
*/
-->
-
-
+
+
diff --git a/app/code/Magento/Sales/view/frontend/layout/sales_order_printcreditmemo.xml b/app/code/Magento/Sales/view/frontend/layout/sales_order_printcreditmemo.xml
index 7f684f4d30603..282a266052201 100644
--- a/app/code/Magento/Sales/view/frontend/layout/sales_order_printcreditmemo.xml
+++ b/app/code/Magento/Sales/view/frontend/layout/sales_order_printcreditmemo.xml
@@ -24,10 +24,10 @@
*/
-->
+
-
-
+
colspan="6" class="mark"
diff --git a/app/code/Magento/Sales/view/frontend/layout/sales_order_printinvoice.xml b/app/code/Magento/Sales/view/frontend/layout/sales_order_printinvoice.xml
index a080901d33eaf..8c6395175efb3 100644
--- a/app/code/Magento/Sales/view/frontend/layout/sales_order_printinvoice.xml
+++ b/app/code/Magento/Sales/view/frontend/layout/sales_order_printinvoice.xml
@@ -24,10 +24,10 @@
*/
-->
+
-
-
+
colspan="4" class="mark"
diff --git a/app/code/Magento/Sales/view/frontend/layout/sales_order_printshipment.xml b/app/code/Magento/Sales/view/frontend/layout/sales_order_printshipment.xml
index 70846a8bc6dfc..0908006fc8353 100644
--- a/app/code/Magento/Sales/view/frontend/layout/sales_order_printshipment.xml
+++ b/app/code/Magento/Sales/view/frontend/layout/sales_order_printshipment.xml
@@ -24,9 +24,10 @@
*/
-->
+
-
+
diff --git a/app/code/Magento/Sales/view/frontend/layout/sales_order_shipment_renderers.xml b/app/code/Magento/Sales/view/frontend/layout/sales_order_shipment_renderers.xml
new file mode 100644
index 0000000000000..ce2ba02abff2d
--- /dev/null
+++ b/app/code/Magento/Sales/view/frontend/layout/sales_order_shipment_renderers.xml
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Sales/view/frontend/layout/sales_order_view.xml b/app/code/Magento/Sales/view/frontend/layout/sales_order_view.xml
index ac1f33f1ca9d8..8cfeed067d18f 100644
--- a/app/code/Magento/Sales/view/frontend/layout/sales_order_view.xml
+++ b/app/code/Magento/Sales/view/frontend/layout/sales_order_view.xml
@@ -25,14 +25,14 @@
-->
+
-
-
+
colspan="4" class="mark"
diff --git a/app/code/Magento/SalesRule/Block/Adminhtml/Promo/Quote/Edit/Tab/Coupons/Grid.php b/app/code/Magento/SalesRule/Block/Adminhtml/Promo/Quote/Edit/Tab/Coupons/Grid.php
index af304f06f027b..35da87ab0f25f 100644
--- a/app/code/Magento/SalesRule/Block/Adminhtml/Promo/Quote/Edit/Tab/Coupons/Grid.php
+++ b/app/code/Magento/SalesRule/Block/Adminhtml/Promo/Quote/Edit/Tab/Coupons/Grid.php
@@ -50,7 +50,6 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended
/**
* @param \Magento\Backend\Block\Template\Context $context
- * @param \Magento\Core\Model\Url $urlModel
* @param \Magento\Backend\Helper\Data $backendHelper
* @param \Magento\SalesRule\Model\Resource\Coupon\CollectionFactory $salesRuleCoupon
* @param \Magento\Core\Model\Registry $coreRegistry
@@ -58,7 +57,6 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended
*/
public function __construct(
\Magento\Backend\Block\Template\Context $context,
- \Magento\Core\Model\Url $urlModel,
\Magento\Backend\Helper\Data $backendHelper,
\Magento\SalesRule\Model\Resource\Coupon\CollectionFactory $salesRuleCoupon,
\Magento\Core\Model\Registry $coreRegistry,
@@ -66,7 +64,7 @@ public function __construct(
) {
$this->_coreRegistry = $coreRegistry;
$this->_salesRuleCoupon = $salesRuleCoupon;
- parent::__construct($context, $urlModel, $backendHelper, $data);
+ parent::__construct($context, $backendHelper, $data);
}
/**
diff --git a/app/code/Magento/SalesRule/Block/Adminhtml/Promo/Widget/Chooser.php b/app/code/Magento/SalesRule/Block/Adminhtml/Promo/Widget/Chooser.php
index d20c3b174cd6d..6bca308be0b0c 100644
--- a/app/code/Magento/SalesRule/Block/Adminhtml/Promo/Widget/Chooser.php
+++ b/app/code/Magento/SalesRule/Block/Adminhtml/Promo/Widget/Chooser.php
@@ -17,7 +17,7 @@
* Do not edit or add to this file if you wish to upgrade Magento to newer
* versions in the future. If you wish to customize Magento for your
* needs please refer to http://www.magentocommerce.com for more information.
- *
+ *
* @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
@@ -32,20 +32,18 @@ class Chooser extends \Magento\Backend\Block\Widget\Grid\Extended
/**
* @param \Magento\Backend\Block\Template\Context $context
- * @param \Magento\Core\Model\Url $urlModel
* @param \Magento\Backend\Helper\Data $backendHelper
* @param \Magento\SalesRule\Model\RuleFactory $ruleFactory
* @param array $data
*/
public function __construct(
\Magento\Backend\Block\Template\Context $context,
- \Magento\Core\Model\Url $urlModel,
\Magento\Backend\Helper\Data $backendHelper,
\Magento\SalesRule\Model\RuleFactory $ruleFactory,
array $data = array()
) {
$this->ruleFactory = $ruleFactory;
- parent::__construct($context, $urlModel, $backendHelper, $data);
+ parent::__construct($context, $backendHelper, $data);
}
/**
@@ -134,53 +132,53 @@ function (grid, event) {
protected function _prepareColumns()
{
$this->addColumn('rule_id', array(
- 'header' => __('ID'),
- 'align' => 'right',
- 'width' => '50px',
- 'index' => 'rule_id',
- ));
+ 'header' => __('ID'),
+ 'align' => 'right',
+ 'width' => '50px',
+ 'index' => 'rule_id',
+ ));
$this->addColumn('name', array(
- 'header' => __('Rule'),
- 'align' => 'left',
- 'index' => 'name',
- ));
+ 'header' => __('Rule'),
+ 'align' => 'left',
+ 'index' => 'name',
+ ));
$this->addColumn('coupon_code', array(
- 'header' => __('Coupon Code'),
- 'align' => 'left',
- 'width' => '150px',
- 'index' => 'code',
- ));
+ 'header' => __('Coupon Code'),
+ 'align' => 'left',
+ 'width' => '150px',
+ 'index' => 'code',
+ ));
$this->addColumn('from_date', array(
- 'header' => __('Start on'),
- 'align' => 'left',
- 'width' => '120px',
- 'type' => 'date',
- 'index' => 'from_date',
- ));
+ 'header' => __('Start on'),
+ 'align' => 'left',
+ 'width' => '120px',
+ 'type' => 'date',
+ 'index' => 'from_date',
+ ));
$this->addColumn('to_date', array(
- 'header' => __('End on'),
- 'align' => 'left',
- 'width' => '120px',
- 'type' => 'date',
- 'default' => '--',
- 'index' => 'to_date',
- ));
+ 'header' => __('End on'),
+ 'align' => 'left',
+ 'width' => '120px',
+ 'type' => 'date',
+ 'default' => '--',
+ 'index' => 'to_date',
+ ));
$this->addColumn('is_active', array(
- 'header' => __('Status'),
- 'align' => 'left',
- 'width' => '80px',
- 'index' => 'is_active',
- 'type' => 'options',
- 'options' => array(
- 1 => 'Active',
- 0 => 'Inactive',
- ),
- ));
+ 'header' => __('Status'),
+ 'align' => 'left',
+ 'width' => '80px',
+ 'index' => 'is_active',
+ 'type' => 'options',
+ 'options' => array(
+ 1 => 'Active',
+ 0 => 'Inactive',
+ ),
+ ));
return parent::_prepareColumns();
}
diff --git a/app/code/Magento/SalesRule/etc/adminhtml/di.xml b/app/code/Magento/SalesRule/etc/adminhtml/di.xml
index c411729e5b098..09cab679ac02e 100644
--- a/app/code/Magento/SalesRule/etc/adminhtml/di.xml
+++ b/app/code/Magento/SalesRule/etc/adminhtml/di.xml
@@ -26,14 +26,16 @@
-
- -
-
- ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789
- ABCDEFGHIJKLMNOPQRSTUVWXYZ
- 0123456789
-
-
+
+ - -
+ -
+
+
- ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789
+ - ABCDEFGHIJKLMNOPQRSTUVWXYZ
+ - 0123456789
+
+
+
diff --git a/app/code/Magento/SalesRule/etc/di.xml b/app/code/Magento/SalesRule/etc/di.xml
index 2ce784a1decdf..2f86d60345d63 100644
--- a/app/code/Magento/SalesRule/etc/di.xml
+++ b/app/code/Magento/SalesRule/etc/di.xml
@@ -30,9 +30,9 @@
-
- Magento\SalesRule\Model\Resource\Setup
-
+
+ - Magento\SalesRule\Model\Resource\Setup
+
diff --git a/app/code/Magento/Sendfriend/Controller/Product.php b/app/code/Magento/Sendfriend/Controller/Product.php
index e8cace7f2e0a0..61c2220522c2d 100644
--- a/app/code/Magento/Sendfriend/Controller/Product.php
+++ b/app/code/Magento/Sendfriend/Controller/Product.php
@@ -88,7 +88,7 @@ public function dispatch(RequestInterface $request)
$this->_actionFlag->set('', self::FLAG_NO_DISPATCH, true);
if ($this->getRequest()->getActionName() == 'sendemail') {
$session->setBeforeAuthUrl($this->_objectManager
- ->create('Magento\Core\Model\Url')
+ ->create('Magento\UrlInterface')
->getUrl('*/*/send', array(
'_current' => true
)));
@@ -246,7 +246,7 @@ public function sendmailAction()
$catalogSession->setSendfriendFormData($data);
$url = $this->_objectManager
- ->create('Magento\Core\Model\Url')
+ ->create('Magento\UrlInterface')
->getUrl('*/*/send', array('_current' => true));
$this->getResponse()->setRedirect($this->_redirect->error($url));
}
diff --git a/app/code/Magento/Shipping/Block/Adminhtml/Carrier/Tablerate/Grid.php b/app/code/Magento/Shipping/Block/Adminhtml/Carrier/Tablerate/Grid.php
index 8ab9b62ea10f9..46672da0c9205 100644
--- a/app/code/Magento/Shipping/Block/Adminhtml/Carrier/Tablerate/Grid.php
+++ b/app/code/Magento/Shipping/Block/Adminhtml/Carrier/Tablerate/Grid.php
@@ -62,7 +62,6 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended
/**
* @param \Magento\Backend\Block\Template\Context $context
- * @param \Magento\Core\Model\Url $urlModel
* @param \Magento\Backend\Helper\Data $backendHelper
* @param \Magento\Shipping\Model\Resource\Carrier\Tablerate\CollectionFactory $collectionFactory
* @param \Magento\Shipping\Model\Carrier\Tablerate $tablerate
@@ -70,7 +69,6 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended
*/
public function __construct(
\Magento\Backend\Block\Template\Context $context,
- \Magento\Core\Model\Url $urlModel,
\Magento\Backend\Helper\Data $backendHelper,
\Magento\Shipping\Model\Resource\Carrier\Tablerate\CollectionFactory $collectionFactory,
\Magento\Shipping\Model\Carrier\Tablerate $tablerate,
@@ -78,7 +76,7 @@ public function __construct(
) {
$this->_collectionFactory = $collectionFactory;
$this->_tablerate = $tablerate;
- parent::__construct($context, $urlModel, $backendHelper, $data);
+ parent::__construct($context, $backendHelper, $data);
}
/**
diff --git a/app/code/Magento/Shipping/Model/Config/Backend/Tablerate.php b/app/code/Magento/Shipping/Model/Config/Backend/Tablerate.php
index 00d0e6a579439..f486f7d75b4a7 100644
--- a/app/code/Magento/Shipping/Model/Config/Backend/Tablerate.php
+++ b/app/code/Magento/Shipping/Model/Config/Backend/Tablerate.php
@@ -45,7 +45,7 @@ class Tablerate extends \Magento\Core\Model\Config\Value
* @param \Magento\Core\Model\Context $context
* @param \Magento\Core\Model\Registry $registry
* @param \Magento\Core\Model\StoreManagerInterface $storeManager
- * @param \Magento\Core\Model\Config $config
+ * @param \Magento\App\ConfigInterface $config
* @param \Magento\Shipping\Model\Resource\Carrier\TablerateFactory $tablerateFactory
* @param \Magento\Core\Model\Resource\AbstractResource $resource
* @param \Magento\Data\Collection\Db $resourceCollection
@@ -55,7 +55,7 @@ public function __construct(
\Magento\Core\Model\Context $context,
\Magento\Core\Model\Registry $registry,
\Magento\Core\Model\StoreManagerInterface $storeManager,
- \Magento\Core\Model\Config $config,
+ \Magento\App\ConfigInterface $config,
\Magento\Shipping\Model\Resource\Carrier\TablerateFactory $tablerateFactory,
\Magento\Core\Model\Resource\AbstractResource $resource = null,
\Magento\Data\Collection\Db $resourceCollection = null,
diff --git a/app/code/Magento/Shipping/Model/Resource/Carrier/Tablerate.php b/app/code/Magento/Shipping/Model/Resource/Carrier/Tablerate.php
index 4d7365b57d38b..92c32c7d01dd5 100644
--- a/app/code/Magento/Shipping/Model/Resource/Carrier/Tablerate.php
+++ b/app/code/Magento/Shipping/Model/Resource/Carrier/Tablerate.php
@@ -100,7 +100,7 @@ class Tablerate extends \Magento\Core\Model\Resource\Db\AbstractDb
protected $_conditionFullNames = array();
/**
- * @var \Magento\Core\Model\Config
+ * @var \Magento\App\ConfigInterface
*/
protected $_coreConfig;
@@ -139,7 +139,7 @@ class Tablerate extends \Magento\Core\Model\Resource\Db\AbstractDb
/**
* @param \Magento\App\Resource $resource
* @param \Magento\Logger $logger
- * @param \Magento\Core\Model\Config $coreConfig
+ * @param \Magento\App\ConfigInterface $coreConfig
* @param \Magento\Core\Model\StoreManagerInterface $storeManager
* @param \Magento\Shipping\Model\Carrier\Tablerate $carrierTablerate
* @param \Magento\Directory\Model\Resource\Country\CollectionFactory $countryCollectionFactory
@@ -149,7 +149,7 @@ class Tablerate extends \Magento\Core\Model\Resource\Db\AbstractDb
public function __construct(
\Magento\App\Resource $resource,
\Magento\Logger $logger,
- \Magento\Core\Model\Config $coreConfig,
+ \Magento\App\ConfigInterface $coreConfig,
\Magento\Core\Model\StoreManagerInterface $storeManager,
\Magento\Shipping\Model\Carrier\Tablerate $carrierTablerate,
\Magento\Directory\Model\Resource\Country\CollectionFactory $countryCollectionFactory,
diff --git a/app/code/Magento/Shipping/view/frontend/layout/sales_guest_shipment.xml b/app/code/Magento/Shipping/view/frontend/layout/sales_guest_shipment.xml
index 514bfcc9d82e2..0d905bf0aacc2 100644
--- a/app/code/Magento/Shipping/view/frontend/layout/sales_guest_shipment.xml
+++ b/app/code/Magento/Shipping/view/frontend/layout/sales_guest_shipment.xml
@@ -24,17 +24,18 @@
*/
-->
+
+
Track All Shipments
-
-
\ No newline at end of file
+
diff --git a/app/code/Magento/Shipping/view/frontend/layout/sales_order_shipment.xml b/app/code/Magento/Shipping/view/frontend/layout/sales_order_shipment.xml
index 514bfcc9d82e2..0d905bf0aacc2 100644
--- a/app/code/Magento/Shipping/view/frontend/layout/sales_order_shipment.xml
+++ b/app/code/Magento/Shipping/view/frontend/layout/sales_order_shipment.xml
@@ -24,17 +24,18 @@
*/
-->
+
+
Track All Shipments
-
-
\ No newline at end of file
+
diff --git a/app/code/Magento/Sitemap/Model/Sitemap.php b/app/code/Magento/Sitemap/Model/Sitemap.php
index 83ac6d0b323c3..b09e67f21bf02 100644
--- a/app/code/Magento/Sitemap/Model/Sitemap.php
+++ b/app/code/Magento/Sitemap/Model/Sitemap.php
@@ -561,7 +561,7 @@ protected function _getBaseDir()
* @param string $type
* @return string
*/
- protected function _getStoreBaseUrl($type = \Magento\Core\Model\Store::URL_TYPE_LINK)
+ protected function _getStoreBaseUrl($type = \Magento\UrlInterface::URL_TYPE_LINK)
{
return rtrim($this->_storeManager->getStore($this->getStoreId())->getBaseUrl($type), '/') . '/';
}
@@ -573,7 +573,7 @@ protected function _getStoreBaseUrl($type = \Magento\Core\Model\Store::URL_TYPE_
* @param string $type
* @return string
*/
- protected function _getUrl($url, $type = \Magento\Core\Model\Store::URL_TYPE_LINK)
+ protected function _getUrl($url, $type = \Magento\UrlInterface::URL_TYPE_LINK)
{
return $this->_getStoreBaseUrl($type) . ltrim($url, '/');
}
@@ -586,7 +586,7 @@ protected function _getUrl($url, $type = \Magento\Core\Model\Store::URL_TYPE_LIN
*/
protected function _getMediaUrl($url)
{
- return $this->_getUrl($url, \Magento\Core\Model\Store::URL_TYPE_MEDIA);
+ return $this->_getUrl($url, \Magento\UrlInterface::URL_TYPE_MEDIA);
}
/**
@@ -629,7 +629,7 @@ protected function _getStoreBaseDomain()
$storeDomain = rtrim($url . '/' . $installationFolder, '/');
} else {
//case when documentRoot contains symlink to basedir
- $url = $this->_getStoreBaseUrl(\Magento\Core\Model\Store::URL_TYPE_WEB);
+ $url = $this->_getStoreBaseUrl(\Magento\UrlInterface::URL_TYPE_WEB);
$storeDomain = rtrim($url, '/');
}
diff --git a/app/code/Magento/Tax/Model/Config/Price/IncludePrice.php b/app/code/Magento/Tax/Model/Config/Price/IncludePrice.php
index 5131c2d073d4c..41ce467fa9ae6 100644
--- a/app/code/Magento/Tax/Model/Config/Price/IncludePrice.php
+++ b/app/code/Magento/Tax/Model/Config/Price/IncludePrice.php
@@ -37,7 +37,7 @@ class IncludePrice extends \Magento\Core\Model\Config\Value
* @param \Magento\Core\Model\Context $context
* @param \Magento\Core\Model\Registry $registry
* @param \Magento\Core\Model\StoreManagerInterface $storeManager
- * @param \Magento\Core\Model\Config $config
+ * @param \Magento\App\ConfigInterface $config
* @param \Magento\Core\Model\App $app
* @param \Magento\Core\Model\Resource\AbstractResource $resource
* @param \Magento\Data\Collection\Db $resourceCollection
@@ -47,7 +47,7 @@ public function __construct(
\Magento\Core\Model\Context $context,
\Magento\Core\Model\Registry $registry,
\Magento\Core\Model\StoreManagerInterface $storeManager,
- \Magento\Core\Model\Config $config,
+ \Magento\App\ConfigInterface $config,
\Magento\Core\Model\App $app,
\Magento\Core\Model\Resource\AbstractResource $resource = null,
\Magento\Data\Collection\Db $resourceCollection = null,
diff --git a/app/code/Magento/Tax/Model/Resource/Setup.php b/app/code/Magento/Tax/Model/Resource/Setup.php
index 03a4c4177976f..d3876846b83b6 100644
--- a/app/code/Magento/Tax/Model/Resource/Setup.php
+++ b/app/code/Magento/Tax/Model/Resource/Setup.php
@@ -41,7 +41,7 @@ class Setup extends \Magento\Sales\Model\Resource\Setup
* @param string $resourceName
* @param \Magento\App\CacheInterface $cache
* @param \Magento\Eav\Model\Resource\Entity\Attribute\Group\CollectionFactory $attrGroupCollectionFactory
- * @param \Magento\Core\Model\Config $config
+ * @param \Magento\App\ConfigInterface $config
* @param \Magento\Catalog\Model\Resource\SetupFactory $setupFactory
* @param string $moduleName
* @param string $connectionName
@@ -51,7 +51,7 @@ public function __construct(
$resourceName,
\Magento\App\CacheInterface $cache,
\Magento\Eav\Model\Resource\Entity\Attribute\Group\CollectionFactory $attrGroupCollectionFactory,
- \Magento\Core\Model\Config $config,
+ \Magento\App\ConfigInterface $config,
\Magento\Catalog\Model\Resource\SetupFactory $setupFactory,
$moduleName = 'Magento_Tax',
$connectionName = ''
diff --git a/app/code/Magento/Tax/etc/di.xml b/app/code/Magento/Tax/etc/di.xml
index a3a3cccb3cc73..8a88e481c3982 100644
--- a/app/code/Magento/Tax/etc/di.xml
+++ b/app/code/Magento/Tax/etc/di.xml
@@ -31,9 +31,9 @@
-
- Magento\Tax\Model\Resource\Setup
-
+
+ - Magento\Tax\Model\Resource\Setup
+
diff --git a/app/code/Magento/Theme/Block/Html.php b/app/code/Magento/Theme/Block/Html.php
index f8bb35b1b90b5..7c2ebee96a9ac 100644
--- a/app/code/Magento/Theme/Block/Html.php
+++ b/app/code/Magento/Theme/Block/Html.php
@@ -57,7 +57,7 @@ protected function _construct()
$this->addBodyClass($this->_request->getFullActionName('-'));
if ($this->_cacheState->isEnabled(self::CACHE_GROUP)) {
- $this->_app->setUseSessionVar(true);
+ $this->_sidResolver->setUseSessionVar(true);
}
}
@@ -119,7 +119,7 @@ public function getPrintLogoUrl()
// buld url
if (!empty($logo)) {
- $logo = $this->_urlBuilder->getBaseUrl(array('_type' => \Magento\Core\Model\Store::URL_TYPE_MEDIA)) . $logo;
+ $logo = $this->_urlBuilder->getBaseUrl(array('_type' => \Magento\UrlInterface::URL_TYPE_MEDIA)) . $logo;
} else {
$logo = '';
}
@@ -214,7 +214,7 @@ public function getAbsoluteFooter()
protected function _afterToHtml($html)
{
if ($this->_cacheState->isEnabled(self::CACHE_GROUP)) {
- $this->_app->setUseSessionVar(false);
+ $this->_sidResolver->setUseSessionVar(false);
\Magento\Profiler::start('CACHE_URL');
$html = $this->_urlBuilder->sessionUrlVar($html);
\Magento\Profiler::stop('CACHE_URL');
diff --git a/app/code/Magento/Theme/Block/Html/Head.php b/app/code/Magento/Theme/Block/Html/Head.php
index 09600c188ace8..4902352edb13b 100644
--- a/app/code/Magento/Theme/Block/Html/Head.php
+++ b/app/code/Magento/Theme/Block/Html/Head.php
@@ -386,7 +386,8 @@ protected function _getFaviconFile()
$folderName = \Magento\Backend\Model\Config\Backend\Image\Favicon::UPLOAD_DIR;
$storeConfig = $this->_storeConfig->getConfig('design/head/shortcut_icon');
$path = $folderName . '/' . $storeConfig;
- $faviconFile = $this->_storeManager->getStore()->getBaseUrl('media') . $path;
+ $faviconFile = $this->_storeManager->getStore()
+ ->getBaseUrl(\Magento\UrlInterface::URL_TYPE_MEDIA) . $path;
if (!is_null($storeConfig) && $this->_isFile($path)) {
$url = $faviconFile;
diff --git a/app/code/Magento/Theme/Block/Html/Header.php b/app/code/Magento/Theme/Block/Html/Header.php
index ff028e4139d3e..32f9a799ab86e 100644
--- a/app/code/Magento/Theme/Block/Html/Header.php
+++ b/app/code/Magento/Theme/Block/Html/Header.php
@@ -130,7 +130,7 @@ protected function _getLogoUrl()
$folderName = \Magento\Backend\Model\Config\Backend\Image\Logo::UPLOAD_DIR;
$storeLogoPath = $this->_storeConfig->getConfig('design/header/logo_src');
$path = $folderName . '/' . $storeLogoPath;
- $logoUrl = $this->_urlBuilder->getBaseUrl(array('_type' => \Magento\Core\Model\Store::URL_TYPE_MEDIA)) . $path;
+ $logoUrl = $this->_urlBuilder->getBaseUrl(array('_type' => \Magento\UrlInterface::URL_TYPE_MEDIA)) . $path;
if (!is_null($storeLogoPath) && $this->_isFile($path)) {
$url = $logoUrl;
diff --git a/app/code/Magento/Theme/Block/Html/Notices.php b/app/code/Magento/Theme/Block/Html/Notices.php
index f8cf1a1c2797a..64740be03ec2e 100644
--- a/app/code/Magento/Theme/Block/Html/Notices.php
+++ b/app/code/Magento/Theme/Block/Html/Notices.php
@@ -29,22 +29,14 @@
*/
class Notices extends \Magento\View\Element\Template
{
- /**
- * @var \Magento\Core\Model\Url
- */
- protected $_urlModel;
-
/**
* @param \Magento\View\Element\Template\Context $context
- * @param \Magento\Core\Model\Url $urlModel
* @param array $data
*/
public function __construct(
\Magento\View\Element\Template\Context $context,
- \Magento\Core\Model\Url $urlModel,
array $data = array()
) {
- $this->_urlModel = $urlModel;
parent::__construct($context, $data);
}
@@ -75,6 +67,6 @@ public function displayDemoNotice()
*/
public function getPrivacyPolicyLink()
{
- return $this->_urlModel->getUrl('privacy-policy-cookie-restriction-mode');
+ return $this->_urlBuilder->getUrl('privacy-policy-cookie-restriction-mode');
}
}
diff --git a/app/code/Magento/Theme/Model/Config.php b/app/code/Magento/Theme/Model/Config.php
index 3a6f43c3cf4db..f40d94b7b6a1b 100644
--- a/app/code/Magento/Theme/Model/Config.php
+++ b/app/code/Magento/Theme/Model/Config.php
@@ -37,7 +37,7 @@ class Config
protected $_configWriter;
/**
- * @var \Magento\Core\Model\Config\Value
+ * @var \Magento\App\Config\ValueInterface
*/
protected $_configData;
@@ -64,7 +64,7 @@ class Config
protected $_layoutCache;
/**
- * @param \Magento\Core\Model\Config\Value $configData
+ * @param \Magento\App\Config\ValueInterface $configData
* @param \Magento\Core\Model\Config\Storage\WriterInterface $configWriter
* @param \Magento\Core\Model\StoreManagerInterface $storeManager
* @param \Magento\Event\ManagerInterface $eventManager
@@ -72,7 +72,7 @@ class Config
* @param \Magento\Cache\FrontendInterface $layoutCache
*/
public function __construct(
- \Magento\Core\Model\Config\Value $configData,
+ \Magento\App\Config\ValueInterface $configData,
\Magento\Core\Model\Config\Storage\WriterInterface $configWriter,
\Magento\Core\Model\StoreManagerInterface $storeManager,
\Magento\Event\ManagerInterface $eventManager,
@@ -95,8 +95,11 @@ public function __construct(
* @param string $scope
* @return $this
*/
- public function assignToStore($theme, array $stores = array(), $scope = \Magento\Core\Model\Config::SCOPE_STORES)
- {
+ public function assignToStore(
+ $theme,
+ array $stores = array(),
+ $scope = \Magento\Core\Model\ScopeInterface::SCOPE_STORES
+ ) {
$isReassigned = false;
$this->_unassignThemeFromStores(
@@ -191,7 +194,7 @@ protected function _assignThemeToStores($themeId, $stores, $scope, &$isReassigne
protected function _assignThemeToDefaultScope($themeId, &$isReassigned)
{
$configPath = \Magento\View\DesignInterface::XML_PATH_THEME_ID;
- $this->_configWriter->save($configPath, $themeId, \Magento\Core\Model\Config::SCOPE_DEFAULT);
+ $this->_configWriter->save($configPath, $themeId, \Magento\Core\Model\ScopeInterface::SCOPE_DEFAULT);
$isReassigned = true;
return $this;
}
diff --git a/app/code/Magento/Theme/etc/di.xml b/app/code/Magento/Theme/etc/di.xml
index ad6d2b5d914cc..b1e7b0e503c6d 100644
--- a/app/code/Magento/Theme/etc/di.xml
+++ b/app/code/Magento/Theme/etc/di.xml
@@ -34,10 +34,10 @@
-
- 2M
- 2M
-
+
+ - 2M
+ - 2M
+
diff --git a/app/code/Magento/Theme/view/frontend/html/breadcrumbs.phtml b/app/code/Magento/Theme/view/frontend/html/breadcrumbs.phtml
index 7e7f174b21f92..e358f2e12f49f 100644
--- a/app/code/Magento/Theme/view/frontend/html/breadcrumbs.phtml
+++ b/app/code/Magento/Theme/view/frontend/html/breadcrumbs.phtml
@@ -23,17 +23,19 @@
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
*/
?>
-
+
- $_crumbInfo): ?>
- -
-
- escapeHtml($_crumbInfo['label']) ?>
-
- escapeHtml($_crumbInfo['label']) ?>
+ $crumbInfo) : ?>
+
-
+
+
+ escapeHtml($crumbInfo['label']) ?>
+
+
+ escapeHtml($crumbInfo['label']) ?>
- escapeHtml($_crumbInfo['label']) ?>
+ escapeHtml($crumbInfo['label']) ?>
diff --git a/app/code/Magento/Usa/etc/di.xml b/app/code/Magento/Usa/etc/di.xml
index fd18f534c118a..d3567f0116046 100644
--- a/app/code/Magento/Usa/etc/di.xml
+++ b/app/code/Magento/Usa/etc/di.xml
@@ -26,9 +26,9 @@
-
- Magento\Usa\Model\Resource\Setup
-
+
+ - Magento\Usa\Model\Resource\Setup
+
diff --git a/app/code/Magento/User/Block/Role/Grid/User.php b/app/code/Magento/User/Block/Role/Grid/User.php
index 57727524e09bc..da95b46590381 100644
--- a/app/code/Magento/User/Block/Role/Grid/User.php
+++ b/app/code/Magento/User/Block/Role/Grid/User.php
@@ -50,7 +50,6 @@ class User extends \Magento\Backend\Block\Widget\Grid\Extended
/**
* @param \Magento\Backend\Block\Template\Context $context
- * @param \Magento\Core\Model\Url $urlModel
* @param \Magento\Backend\Helper\Data $backendHelper
* @param \Magento\Json\EncoderInterface $jsonEncoder
* @param \Magento\Core\Model\Registry $coreRegistry
@@ -59,14 +58,13 @@ class User extends \Magento\Backend\Block\Widget\Grid\Extended
*/
public function __construct(
\Magento\Backend\Block\Template\Context $context,
- \Magento\Core\Model\Url $urlModel,
\Magento\Backend\Helper\Data $backendHelper,
\Magento\Json\EncoderInterface $jsonEncoder,
\Magento\Core\Model\Registry $coreRegistry,
\Magento\User\Model\RoleFactory $roleFactory,
array $data = array()
) {
- parent::__construct($context, $urlModel, $backendHelper, $data);
+ parent::__construct($context, $backendHelper, $data);
$this->_jsonEncoder = $jsonEncoder;
$this->_coreRegistry = $coreRegistry;
$this->_roleFactory = $roleFactory;
diff --git a/app/code/Magento/User/Block/User/Edit/Tab/Roles.php b/app/code/Magento/User/Block/User/Edit/Tab/Roles.php
index 4eba9a1d87d51..cc496d68128ec 100644
--- a/app/code/Magento/User/Block/User/Edit/Tab/Roles.php
+++ b/app/code/Magento/User/Block/User/Edit/Tab/Roles.php
@@ -48,7 +48,6 @@ class Roles extends \Magento\Backend\Block\Widget\Grid\Extended
/**
* @param \Magento\Backend\Block\Template\Context $context
- * @param \Magento\Core\Model\Url $urlModel
* @param \Magento\Backend\Helper\Data $backendHelper
* @param \Magento\Json\EncoderInterface $jsonEncoder
* @param \Magento\User\Model\Resource\Role\CollectionFactory $userRolesFactory
@@ -57,7 +56,6 @@ class Roles extends \Magento\Backend\Block\Widget\Grid\Extended
*/
public function __construct(
\Magento\Backend\Block\Template\Context $context,
- \Magento\Core\Model\Url $urlModel,
\Magento\Backend\Helper\Data $backendHelper,
\Magento\Json\EncoderInterface $jsonEncoder,
\Magento\User\Model\Resource\Role\CollectionFactory $userRolesFactory,
@@ -67,7 +65,7 @@ public function __construct(
$this->_jsonEncoder = $jsonEncoder;
$this->_userRolesFactory = $userRolesFactory;
$this->_coreRegistry = $coreRegistry;
- parent::__construct($context, $urlModel, $backendHelper, $data);
+ parent::__construct($context, $backendHelper, $data);
}
protected function _construct()
diff --git a/app/code/Magento/User/Model/User.php b/app/code/Magento/User/Model/User.php
index bd4191de29e24..4cd95ead3db1e 100644
--- a/app/code/Magento/User/Model/User.php
+++ b/app/code/Magento/User/Model/User.php
@@ -532,7 +532,7 @@ public function getAclRole()
*/
public function authenticate($username, $password)
{
- $config = $this->_config->getFlag('admin/security/use_case_sensitive_login');
+ $config = $this->_config->isSetFlag('admin/security/use_case_sensitive_login');
$result = false;
try {
diff --git a/app/code/Magento/User/etc/di.xml b/app/code/Magento/User/etc/di.xml
index 2b49a54b1e4f2..9330d554a19b1 100644
--- a/app/code/Magento/User/etc/di.xml
+++ b/app/code/Magento/User/etc/di.xml
@@ -41,9 +41,9 @@
-
- Magento\User\Model\Resource\Setup
-
+
+ - Magento\User\Model\Resource\Setup
+
diff --git a/app/code/Magento/Webapi/Controller/Rest.php b/app/code/Magento/Webapi/Controller/Rest.php
index b90d17b0344a0..98b2a14b2ae82 100644
--- a/app/code/Magento/Webapi/Controller/Rest.php
+++ b/app/code/Magento/Webapi/Controller/Rest.php
@@ -25,11 +25,14 @@
namespace Magento\Webapi\Controller;
use Magento\Authz\Service\AuthorizationV1Interface as AuthorizationService;
+use Magento\Webapi\Controller\Rest\Router\Route;
+use Magento\Service\Entity\MagentoDtoInterface;
/**
* Front controller for WebAPI REST area.
*
- * TODO: Fix coupling between objects
+ * TODO: Consider warnings suppression removal
+ *
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class Rest implements \Magento\App\FrontControllerInterface
@@ -58,7 +61,18 @@ class Rest implements \Magento\App\FrontControllerInterface
/** @var AuthorizationService */
protected $_authorizationService;
+ /** @var ServiceArgsSerializer */
+ protected $_serializer;
+
+ /** @var \Magento\Webapi\Controller\ErrorProcessor */
+ protected $_errorProcessor;
+
/**
+ * Initialize dependencies.
+ *
+ * TODO: Consider removal of warning suppression
+ *
+ * @SuppressWarnings(PHPMD.ExcessiveParameterList)
* @param Rest\Request $request
* @param Rest\Response $response
* @param Rest\Router $router
@@ -67,6 +81,8 @@ class Rest implements \Magento\App\FrontControllerInterface
* @param \Magento\Oauth\OauthInterface $oauthService
* @param \Magento\Oauth\Helper\Request $oauthHelper
* @param AuthorizationService $authorizationService
+ * @param ServiceArgsSerializer $serializer
+ * @param \Magento\Webapi\Controller\ErrorProcessor $errorProcessor
*/
public function __construct(
\Magento\Webapi\Controller\Rest\Request $request,
@@ -76,7 +92,9 @@ public function __construct(
\Magento\App\State $appState,
\Magento\Oauth\OauthInterface $oauthService,
\Magento\Oauth\Helper\Request $oauthHelper,
- AuthorizationService $authorizationService
+ AuthorizationService $authorizationService,
+ ServiceArgsSerializer $serializer,
+ \Magento\Webapi\Controller\ErrorProcessor $errorProcessor
) {
$this->_router = $router;
$this->_request = $request;
@@ -86,16 +104,8 @@ public function __construct(
$this->_oauthService = $oauthService;
$this->_oauthHelper = $oauthHelper;
$this->_authorizationService = $authorizationService;
- }
-
- /**
- * Initialize front controller
- *
- * @return \Magento\Webapi\Controller\Rest
- */
- public function init()
- {
- return $this;
+ $this->_serializer = $serializer;
+ $this->_errorProcessor = $errorProcessor;
}
/**
@@ -113,16 +123,13 @@ public function dispatch(\Magento\App\RequestInterface $request)
if (!$this->_appState->isInstalled()) {
throw new \Magento\Webapi\Exception(__('Magento is not yet installed'));
}
- // TODO: Consider changing service interface to operate with objects to avoid overhead
- $requestUrl = $this->_oauthHelper->getRequestUrl($this->_request);
- $oauthRequest = $this->_oauthHelper->prepareRequest(
- $this->_request, $requestUrl, $this->_request->getRequestData()
- );
+ $oauthRequest = $this->_oauthHelper->prepareRequest($this->_request);
$consumerId = $this->_oauthService->validateAccessTokenRequest(
- $oauthRequest, $requestUrl, $this->_request->getMethod()
+ $oauthRequest,
+ $this->_oauthHelper->getRequestUrl($this->_request),
+ $this->_request->getMethod()
);
$this->_request->setConsumerId($consumerId);
-
$route = $this->_router->match($this->_request);
if (!$this->_authorizationService->isAllowed($route->getAclResources())) {
@@ -142,19 +149,66 @@ public function dispatch(\Magento\App\RequestInterface $request)
}
/** @var array $inputData */
$inputData = $this->_request->getRequestData();
- $serviceMethod = $route->getServiceMethod();
- $service = $this->_objectManager->get($route->getServiceClass());
- $outputData = $service->$serviceMethod($inputData);
- if (!is_array($outputData)) {
- throw new \LogicException(
- sprintf('The method "%s" of service "%s" must return an array.', $serviceMethod,
- $route->getServiceClass())
- );
- }
- $this->_response->prepareResponse($outputData);
+ $serviceMethodName = $route->getServiceMethod();
+ $serviceClassName = $route->getServiceClass();
+ $inputParams = $this->_serializer->getInputData($serviceClassName, $serviceMethodName, $inputData);
+ $service = $this->_objectManager->get($serviceClassName);
+ /** @var \Magento\Service\Entity\AbstractDto $outputData */
+ $outputData = call_user_func_array([$service, $serviceMethodName], $inputParams);
+ $outputArray = $this->_processServiceOutput($outputData);
+ $this->_response->prepareResponse($outputArray);
} catch (\Exception $e) {
- $this->_response->setException($e);
+ $maskedException = $this->_errorProcessor->maskException($e);
+ $this->_response->setException($maskedException);
}
return $this->_response;
}
+
+ /**
+ * Converts the incoming data into scalar or an array of scalars format.
+ *
+ * If the data provided is null, then an empty array is returned. Otherwise, if the data is an object, it is
+ * assumed to be a DTO and converted to an associative array with keys representing the properties of the DTO.
+ * Nested DTOs are also converted. If the data provided is itself an array, then we iterate through the contents
+ * and convert each piece individually.
+ *
+ * @param mixed $data
+ * @return array|int|string|bool|float Scalar or array of scalars
+ */
+ protected function _processServiceOutput($data)
+ {
+ if (is_array($data)) {
+ $result = [];
+ foreach ($data as $datum) {
+ if (is_object($datum)) {
+ $result[] = $this->_convertDtoToArray($datum);
+ } else {
+ $result[] = $datum;
+ }
+ }
+ } else if (is_object($data)) {
+ $result = $this->_convertDtoToArray($data);
+ } else if (is_null($data)) {
+ $result = [];
+ } else {
+ /** No processing is required for scalar types */
+ $result = $data;
+ }
+ return $result;
+ }
+
+ /**
+ * Convert DTO to array.
+ *
+ * @param object $dto
+ * @return array
+ * @throws \InvalidArgumentException
+ */
+ protected function _convertDtoToArray($dto)
+ {
+ if (!is_object($dto) || !method_exists($dto, '__toArray')) {
+ throw new \InvalidArgumentException("All objects returned by service must implement __toArray().");
+ }
+ return $dto->__toArray();
+ }
}
diff --git a/app/code/Magento/Webapi/Controller/ServiceArgsSerializer.php b/app/code/Magento/Webapi/Controller/ServiceArgsSerializer.php
new file mode 100644
index 0000000000000..4a8ce5ea919dd
--- /dev/null
+++ b/app/code/Magento/Webapi/Controller/ServiceArgsSerializer.php
@@ -0,0 +1,171 @@
+_typeProcessor = $typeProcessor;
+ }
+
+ /**
+ * Converts the provided input array from key-value format to a list of parameters suitable for the specified
+ * class / method.
+ *
+ * The input array should have the field name as the key, and the value will either be a primitive or another
+ * key-value array. The top level of this array needs keys that match the names of the parameters on the
+ * service method.
+ *
+ * Mismatched types are caught by the PHP runtime, not explicitly checked for by this code.
+ *
+ * @param string $serviceClassName name of the service class that we are trying to call
+ * @param string $serviceMethodName name of the method that we are trying to call
+ * @param array $inputArray data to send to method in key-value format
+ *
+ * @return array list of parameters that can be used to call the service method
+ */
+ public function getInputData($serviceClassName, $serviceMethodName, array $inputArray)
+ {
+ /** TODO: Reflection causes performance degradation when used in runtime. Should be optimized via caching */
+ $serviceClass = new ClassReflection($serviceClassName);
+ /** @var MethodReflection $serviceMethod */
+ $serviceMethod = $serviceClass->getMethod($serviceMethodName);
+ /** @var ParameterReflection[] $params */
+ $params = $serviceMethod->getParameters();
+
+ $inputData = [];
+ foreach ($params as $param) {
+ $paramName = $param->getName();
+ if (isset($inputArray[$paramName])) {
+ if ($this->_isArrayParam($param)) {
+ $paramType = "{$param->getType()}[]";
+ /** Eliminate 'item' node if present. It is wrapping all data, declared in WSDL as array */
+ $paramValue = isset($inputArray[$paramName][ComplexTypeStrategy::ARRAY_ITEM_KEY_NAME])
+ ? $inputArray[$paramName][ComplexTypeStrategy::ARRAY_ITEM_KEY_NAME]
+ : $inputArray[$paramName];
+ } else {
+ $paramType = $param->getType();
+ $paramValue = $inputArray[$paramName];
+ }
+ $inputData[] = $this->_convertValue($paramValue, $paramType);
+ } else {
+ $inputData[] = $param->getDefaultValue(); // not set, so use default
+ }
+ }
+
+ return $inputData;
+ }
+
+ /**
+ * Check if parameter is an array.
+ *
+ * @param ParameterReflection $param
+ * @return bool
+ */
+ protected function _isArrayParam($param)
+ {
+ $isArray = $param->isArray();
+ $docBlock = $param->getDeclaringFunction()->getDocBlock();
+ /** If array type is not set explicitly in the method interface, examine annotations */
+ if (!$isArray && $docBlock) {
+ /** This pattern will help to skip parameters declarations which precede to the current one */
+ $precedingParamsPattern = str_repeat('.*\@param.*', $param->getPosition());
+ $paramType = str_replace('\\', '\\\\', $param->getType());
+ if (preg_match("/.*{$precedingParamsPattern}\@param\s+({$paramType}\[\]).*/i", $docBlock->getContents())) {
+ $isArray = true;
+ }
+ }
+ return $isArray;
+ }
+
+ /**
+ * Creates a new instance of the given class and populates it with the array of data.
+ *
+ * @param string|\ReflectionClass $class
+ * @param array $data
+ * @return object the newly created and populated object
+ */
+ protected function _createFromArray($class, $data)
+ {
+ $className = is_string($class) ? $class : $class->getName();
+ try {
+ $class = new ClassReflection($className);
+ foreach ($data as $propertyName => $value) {
+ $getterName = 'get' . str_replace(' ', '', ucwords(str_replace('_', ' ', $propertyName)));
+ $methodReflection = $class->getMethod($getterName);
+ if ($methodReflection->isPublic()) {
+ $returnType = $this->_typeProcessor->getGetterReturnType($methodReflection)['type'];
+ $data[$propertyName] = $this->_convertValue($value, $returnType);
+ }
+ }
+ } catch (\ReflectionException $e) {
+ // Case where data array contains keys with no matching setter methods
+ // TODO: do we need to do anything here or can we just ignore this and keep going?
+ }
+ $obj = new $className($data);
+ return $obj;
+ }
+
+ /**
+ * Convert data from array to DTO representation if type is DTO or array of DTOs.
+ *
+ * @param mixed $value
+ * @param string $type
+ * @return mixed
+ */
+ protected function _convertValue($value, $type)
+ {
+ if (!$this->_typeProcessor->isTypeSimple($type)) {
+ if ($this->_typeProcessor->isArrayType($type)) {
+ $itemType = $this->_typeProcessor->getArrayItemType($type);
+ foreach ($value as $key => $item) {
+ $result[$key] = $this->_createFromArray($itemType, $item);
+ }
+ } else {
+ $result = $this->_createFromArray($type, $value);
+ }
+ } else {
+ $result = $value;
+ }
+ return $result;
+ }
+}
diff --git a/app/code/Magento/Webapi/Controller/Soap.php b/app/code/Magento/Webapi/Controller/Soap.php
index 66b78a5a6b9be..b617a0324a3cc 100644
--- a/app/code/Magento/Webapi/Controller/Soap.php
+++ b/app/code/Magento/Webapi/Controller/Soap.php
@@ -25,10 +25,12 @@
*/
namespace Magento\Webapi\Controller;
-use Magento\Webapi\Exception as WebapiException;
use Magento\Service\AuthorizationException;
+use Magento\Webapi\Exception as WebapiException;
/**
+ * TODO: Consider warnings suppression removal
+ *
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class Soap implements \Magento\App\FrontControllerInterface
@@ -73,7 +75,7 @@ class Soap implements \Magento\App\FrontControllerInterface
* @param \Magento\Webapi\Model\Soap\Server $soapServer
* @param \Magento\Webapi\Controller\ErrorProcessor $errorProcessor
* @param \Magento\App\State $appState
- * @param \Magento\Core\Model\AppInterface $application
+ * @param \Magento\AppInterface $application
* @param \Magento\Oauth\OauthInterface $oauthService
*/
public function __construct(
@@ -83,7 +85,7 @@ public function __construct(
\Magento\Webapi\Model\Soap\Server $soapServer,
\Magento\Webapi\Controller\ErrorProcessor $errorProcessor,
\Magento\App\State $appState,
- \Magento\Core\Model\AppInterface $application,
+ \Magento\AppInterface $application,
\Magento\Oauth\OauthInterface $oauthService
) {
$this->_request = $request;
@@ -96,16 +98,6 @@ public function __construct(
$this->_oauthService = $oauthService;
}
- /**
- * Initialize front controller
- *
- * @return \Magento\Webapi\Controller\Soap
- */
- public function init()
- {
- return $this;
- }
-
/**
* @param \Magento\App\RequestInterface $request
* @return \Magento\App\ResponseInterface
@@ -125,13 +117,12 @@ public function dispatch(\Magento\App\RequestInterface $request)
$this->_soapServer->generateUri()
);
$this->_setResponseContentType(self::CONTENT_TYPE_WSDL_REQUEST);
+ $this->_setResponseBody($responseBody);
} else {
$consumerId = $this->_oauthService->validateAccessToken($this->_getAccessToken());
$this->_request->setConsumerId($consumerId);
- $responseBody = $this->_soapServer->handle();
- $this->_setResponseContentType(self::CONTENT_TYPE_SOAP_CALL);
+ $this->_soapServer->handle();
}
- $this->_setResponseBody($responseBody);
} catch (\Exception $e) {
$this->_prepareErrorResponse($e);
}
diff --git a/app/code/Magento/Webapi/Controller/Soap/Request.php b/app/code/Magento/Webapi/Controller/Soap/Request.php
index 8f92e11728517..b6e579e046371 100644
--- a/app/code/Magento/Webapi/Controller/Soap/Request.php
+++ b/app/code/Magento/Webapi/Controller/Soap/Request.php
@@ -29,7 +29,6 @@ class Request extends \Magento\Webapi\Controller\Request
{
/**
* Identify versions of resources that should be used for API configuration generation.
- * TODO : This is getting called twice within a single request. Need to cache.
*
* @return array
* @throws \Magento\Webapi\Exception When GET parameters are invalid
@@ -55,7 +54,7 @@ public function getRequestedServices()
/**
* Extract the resources query param value and return associative array of the form 'resource' => 'version'
*
- * @param string $param eg testModule1AllSoapAndRest:V1,testModule2AllSoapNoRest:V1
+ * @param string $param eg testModule1AllSoapAndRestV1,testModule2AllSoapNoRestV1
* @return array eg array (
* 'testModule1AllSoapAndRest' => 'V1',
* 'testModule2AllSoapNoRest' => 'V1',
@@ -65,7 +64,6 @@ public function getRequestedServices()
protected function _convertRequestParamToServiceArray($param)
{
$serviceSeparator = ',';
- //TODO: This should be a globally used pattern in Webapi module
$serviceVerPattern = "[a-zA-Z\d]*V[\d]+";
$regexp = "/^($serviceVerPattern)([$serviceSeparator]$serviceVerPattern)*$/";
//Check if the $param is of valid format
diff --git a/app/code/Magento/Webapi/Controller/Soap/Handler.php b/app/code/Magento/Webapi/Controller/Soap/Request/Handler.php
similarity index 52%
rename from app/code/Magento/Webapi/Controller/Soap/Handler.php
rename to app/code/Magento/Webapi/Controller/Soap/Request/Handler.php
index 7a731c938b964..383428ad47b62 100644
--- a/app/code/Magento/Webapi/Controller/Soap/Handler.php
+++ b/app/code/Magento/Webapi/Controller/Soap/Request/Handler.php
@@ -22,18 +22,22 @@
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
-namespace Magento\Webapi\Controller\Soap;
+namespace Magento\Webapi\Controller\Soap\Request;
use Magento\Authz\Service\AuthorizationV1Interface as AuthorizationService;
use Magento\Webapi\Model\Soap\Config as SoapConfig;
use Magento\Webapi\Controller\Soap\Request as SoapRequest;
use Magento\Webapi\Exception as WebapiException;
use Magento\Service\AuthorizationException;
+use Magento\Webapi\Controller\ServiceArgsSerializer;
/**
* Handler of requests to SOAP server.
*
* The main responsibility is to instantiate proper action controller (service) and execute requested method on it.
+ *
+ * TODO: Fix warnings suppression
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class Handler
{
@@ -51,6 +55,12 @@ class Handler
/** @var AuthorizationService */
protected $_authorizationService;
+ /** @var \Magento\Webapi\Helper\Data */
+ protected $_helper;
+
+ /** @var ServiceArgsSerializer */
+ protected $_serializer;
+
/**
* Initialize dependencies.
*
@@ -58,17 +68,23 @@ class Handler
* @param \Magento\ObjectManager $objectManager
* @param SoapConfig $apiConfig
* @param AuthorizationService $authorizationService
+ * @param \Magento\Webapi\Helper\Data $helper
+ * @param ServiceArgsSerializer $serializer
*/
public function __construct(
SoapRequest $request,
\Magento\ObjectManager $objectManager,
SoapConfig $apiConfig,
- AuthorizationService $authorizationService
+ AuthorizationService $authorizationService,
+ \Magento\Webapi\Helper\Data $helper,
+ ServiceArgsSerializer $serializer
) {
$this->_request = $request;
$this->_objectManager = $objectManager;
$this->_apiConfig = $apiConfig;
$this->_authorizationService = $authorizationService;
+ $this->_helper = $helper;
+ $this->_serializer = $serializer;
}
/**
@@ -105,64 +121,105 @@ public function __call($operation, $arguments)
implode($serviceMethodInfo[SoapConfig::KEY_ACL_RESOURCES], ', '));
}
$service = $this->_objectManager->get($serviceClass);
- $outputData = $service->$serviceMethod($this->_prepareParameters($arguments));
- if (!is_array($outputData)) {
- throw new \LogicException(
- sprintf('The method "%s" of service "%s" must return an array.', $serviceMethod, $serviceClass)
- );
- }
- return $outputData;
+ $inputData = $this->_prepareRequestData($serviceClass, $serviceMethod, $arguments);
+ $outputData = call_user_func_array(array($service, $serviceMethod), $inputData);
+ return $this->_prepareResponseData($outputData);
}
/**
- * Extract service method parameters from SOAP operation arguments.
+ * Convert SOAP operation arguments into format acceptable by service method.
*
- * @param \stdClass|array $arguments
+ * @param string $serviceClass
+ * @param string $serviceMethod
+ * @param array $arguments
* @return array
*/
- protected function _prepareParameters($arguments)
+ protected function _prepareRequestData($serviceClass, $serviceMethod, $arguments)
{
/** SoapServer wraps parameters into array. Thus this wrapping should be removed to get access to parameters. */
$arguments = reset($arguments);
- $this->_associativeObjectToArray($arguments);
- $arguments = get_object_vars($arguments);
- return $arguments;
+ $arguments = $this->_toArray($arguments);
+ return $this->_serializer->getInputData($serviceClass, $serviceMethod, $arguments);
+ }
+
+ /**
+ * Convert service response into format acceptable by SoapServer.
+ *
+ * @param object|array|string|int|double|null $data
+ * @return array
+ * @throws \InvalidArgumentException
+ */
+ protected function _prepareResponseData($data)
+ {
+ if ($this->_isDto($data)) {
+ $result = $this->_unpackDto($data);
+ } elseif (is_array($data)) {
+ foreach ($data as $key => $value) {
+ $result[$key] = $this->_isDto($value) ? $this->_unpackDto($value) : $value;
+ }
+ } elseif (is_string($data) || is_numeric($data) || is_null($data)) {
+ $result = $data;
+ } else {
+ throw new \InvalidArgumentException("Service returned result in invalid format.");
+ }
+ return array(self::RESULT_NODE_NAME => $result);
}
/**
- * Go through an object parameters and unpack associative object to array.
+ * Create new object and initialize its public fields with data retrieved from DTO.
*
- * This function uses recursion and operates by reference.
+ * This method processes all nested DTOs recursively.
+ *
+ * @param object $dto
+ * @return \stdClass
+ * @throws \InvalidArgumentException
+ */
+ protected function _unpackDto($dto)
+ {
+ if (!$this->_isDto($dto)) {
+ throw new \InvalidArgumentException("Object is expected to implement __toArray() method.");
+ }
+ $response = new \stdClass();
+ foreach ($dto->__toArray() as $fieldName => $fieldValue) {
+ if ($this->_isDto($fieldValue)) {
+ $fieldValue = $this->_unpackDto($fieldValue);
+ }
+ $response->$fieldName = $fieldValue;
+ }
+ return $response;
+ }
+
+ /**
+ * Check if provided variable is service DTO.
*
- * @param \stdClass|array $obj
+ * @param mixed $var
* @return bool
*/
- protected function _associativeObjectToArray(&$obj)
+ protected function _isDto($var)
+ {
+ return (is_object($var) && method_exists($var, '__toArray'));
+ }
+
+ /**
+ * Convert multidimensional object/array into multidimensional array of primitives.
+ *
+ * @param object|array $input
+ * @return array
+ * @throws \InvalidArgumentException
+ */
+ protected function _toArray($input)
{
- if (is_object($obj)) {
- if (property_exists($obj, 'key') && property_exists($obj, 'value')) {
- if (count(array_keys(get_object_vars($obj))) === 2) {
- $obj = array($obj->key => $obj->value);
- return true;
- }
+ if (!is_object($input) && !is_array($input)) {
+ throw new \InvalidArgumentException("Input argument must be an array or object");
+ }
+ $result = array();
+ foreach ((array)$input as $key => $value) {
+ if (is_object($value) || is_array($value)) {
+ $result[$key] = $this->_toArray($value);
} else {
- foreach (array_keys(get_object_vars($obj)) as $key) {
- $this->_associativeObjectToArray($obj->$key);
- }
- }
- } else if (is_array($obj)) {
- $arr = array();
- $object = $obj;
- foreach ($obj as &$value) {
- if ($this->_associativeObjectToArray($value)) {
- array_walk($value, function ($val, $key) use (&$arr) {
- $arr[$key] = $val;
- });
- $object = $arr;
- }
+ $result[$key] = $value;
}
- $obj = $object;
}
- return false;
+ return $result;
}
}
diff --git a/app/code/Magento/Webapi/Helper/Data.php b/app/code/Magento/Webapi/Helper/Data.php
index a10e42a2066ab..aa996df32aa3c 100644
--- a/app/code/Magento/Webapi/Helper/Data.php
+++ b/app/code/Magento/Webapi/Helper/Data.php
@@ -50,4 +50,88 @@ public function getSelectedResources()
}
return $selectedResourceIds;
}
+
+ /**
+ * Translate service interface name into service name.
+ * Example:
+ *
+ * - \Magento\Customer\Service\CustomerV1Interface => customer // $preserveVersion == false
+ * - \Magento\Customer\Service\Customer\AddressV1Interface => customerAddressV1 // $preserveVersion == true
+ * - \Magento\Catalog\Service\ProductV2Interface => catalogProductV2 // $preserveVersion == true
+ *
+ *
+ * @param string $interfaceName
+ * @param bool $preserveVersion Should version be preserved during interface name conversion into service name
+ * @return string
+ * @throws \InvalidArgumentException
+ */
+ public function getServiceName($interfaceName, $preserveVersion = true)
+ {
+ $serviceNameParts = $this->getServiceNameParts($interfaceName, $preserveVersion);
+ return lcfirst(implode('', $serviceNameParts));
+ }
+
+ /**
+ * Identify the list of service name parts including sub-services using class name.
+ *
+ * Examples of input/output pairs:
+ * - 'Magento\Customer\Service\Customer\AddressV1Interface' => array('Customer', 'Address', 'V1')
+ * - 'Vendor\Customer\Service\Customer\AddressV1Interface' => array('VendorCustomer', 'Address', 'V1)
+ * - 'Magento\Catalog\Service\ProductV2Interface' => array('CatalogProduct', 'V2')
+ *
+ * @param string $className
+ * @param bool $preserveVersion Should version be preserved during class name conversion into service name
+ * @return array
+ * @throws \InvalidArgumentException When class is not valid API service.
+ */
+ public function getServiceNameParts($className, $preserveVersion = false)
+ {
+ if (preg_match(\Magento\Webapi\Model\Config::SERVICE_CLASS_PATTERN, $className, $matches)) {
+ $moduleNamespace = $matches[1];
+ $moduleName = $matches[2];
+ $moduleNamespace = ($moduleNamespace == 'Magento') ? '' : $moduleNamespace;
+ $serviceNameParts = explode('\\', trim($matches[4], '\\'));
+ if ($moduleName == $serviceNameParts[0]) {
+ /** Avoid duplication of words in service name */
+ $moduleName = '';
+ }
+ $parentServiceName = $moduleNamespace . $moduleName . array_shift($serviceNameParts);
+ array_unshift($serviceNameParts, $parentServiceName);
+ if ($preserveVersion) {
+ $serviceVersion = $matches[3];
+ $serviceNameParts[] = $serviceVersion;
+ }
+ return $serviceNameParts;
+ }
+ throw new \InvalidArgumentException(sprintf('The service interface name "%s" is invalid.', $className));
+ }
+
+ /**
+ * Convert DTO getter name into field name.
+ *
+ * @param string $getterName
+ * @return string
+ */
+ public function dtoGetterNameToFieldName($getterName)
+ {
+ if ((strpos($getterName, 'get') === 0)) {
+ /** Remove 'get' prefix and make the first letter lower case */
+ $fieldName = substr($getterName, strlen('get'));
+ } else {
+ /** If methods are with 'is' or 'has' prefix */
+ $fieldName = $getterName;
+ }
+ return lcfirst($fieldName);
+ }
+
+ /**
+ * Convert DTO field name into setter name.
+ *
+ * @param string $fieldName
+ * @return string
+ */
+ public function dtoFieldNameToSetterName($fieldName)
+ {
+ return 'set' . ucfirst($fieldName);
+ }
}
diff --git a/app/code/Magento/Webapi/Model/Config.php b/app/code/Magento/Webapi/Model/Config.php
index 3a729bee4f2d9..404132d2eb2b5 100644
--- a/app/code/Magento/Webapi/Model/Config.php
+++ b/app/code/Magento/Webapi/Model/Config.php
@@ -36,7 +36,7 @@ class Config
/**
* Pattern for Web API interface name.
*/
- const SERVICE_CLASS_PATTERN = '/^(.+?)\\\\(.+?)\\\\Service(\\\\.+)+(V\d+)Interface$/';
+ const SERVICE_CLASS_PATTERN = '/^(.+?)\\\\(.+?)\\\\Service\\\\(V\d+)+(\\\\.+)Interface$/';
/**
* @var \Magento\App\Cache\Type\Config
diff --git a/app/code/Magento/Webapi/Model/Config/ClassReflector.php b/app/code/Magento/Webapi/Model/Config/ClassReflector.php
new file mode 100644
index 0000000000000..72cc4f8555870
--- /dev/null
+++ b/app/code/Magento/Webapi/Model/Config/ClassReflector.php
@@ -0,0 +1,132 @@
+_typeProcessor = $typeProcessor;
+ }
+
+ /**
+ * Reflect methods in given class and set retrieved data into reader.
+ *
+ * @param array $methods
+ * @param string $className
+ * @return array array(
+ * $firstMethod => array(
+ * 'documentation' => $methodDocumentation,
+ * 'interface' => array(
+ * 'in' => array(
+ * 'parameters' => array(
+ * $firstParameter => array(
+ * 'type' => $type,
+ * 'required' => $isRequired,
+ * 'documentation' => $parameterDocumentation
+ * ),
+ * ...
+ * )
+ * ),
+ * 'out' => array(
+ * 'parameters' => array(
+ * $firstParameter => array(
+ * 'type' => $type,
+ * 'required' => $isRequired,
+ * 'documentation' => $parameterDocumentation
+ * ),
+ * ...
+ * )
+ * )
+ * )
+ * ),
+ * ...
+ * )
+ */
+ public function reflectClassMethods($className, $methods)
+ {
+ $data = array();
+ $classReflection = new \Zend\Server\Reflection\ReflectionClass(new \ReflectionClass($className));
+ /** @var $methodReflection ReflectionMethod */
+ foreach ($classReflection->getMethods() as $methodReflection) {
+ $methodName = $methodReflection->getName();
+ if (array_key_exists($methodName, $methods)) {
+ $data[$methodName] = $this->extractMethodData($methodReflection);
+ }
+ }
+ return $data;
+ }
+
+ /**
+ * Retrieve method interface and documentation description.
+ *
+ * @param ReflectionMethod $method
+ * @return array
+ * @throws \InvalidArgumentException
+ */
+ public function extractMethodData(ReflectionMethod $method)
+ {
+ $methodData = array('documentation' => $method->getDescription(), 'interface' => array());
+ $prototypes = $method->getPrototypes();
+ /** Take the fullest interface that also includes optional parameters. */
+ /** @var \Zend\Server\Reflection\Prototype $prototype */
+ $prototype = end($prototypes);
+ /** @var \Zend\Server\Reflection\ReflectionParameter $parameter */
+ foreach ($prototype->getParameters() as $parameter) {
+ $parameterData = array(
+ 'type' => $this->_typeProcessor->process($parameter->getType()),
+ 'required' => !$parameter->isOptional(),
+ 'documentation' => $parameter->getDescription(),
+ );
+ if ($parameter->isOptional()) {
+ $parameterData['default'] = $parameter->getDefaultValue();
+ }
+ $methodData['interface']['in']['parameters'][$parameter->getName()] = $parameterData;
+ }
+ if ($prototype->getReturnType() != 'void') {
+ $methodData['interface']['out']['parameters']['result'] = array(
+ 'type' => $this->_typeProcessor->process($prototype->getReturnType()),
+ 'documentation' => $prototype->getReturnValue()->getDescription(),
+ 'required' => true,
+ );
+ }
+
+ return $methodData;
+ }
+}
diff --git a/app/code/Magento/Webapi/Model/Config/ClassReflector/TypeProcessor.php b/app/code/Magento/Webapi/Model/Config/ClassReflector/TypeProcessor.php
new file mode 100644
index 0000000000000..72264cf7c75c8
--- /dev/null
+++ b/app/code/Magento/Webapi/Model/Config/ClassReflector/TypeProcessor.php
@@ -0,0 +1,374 @@
+array(
+ * $complexTypeName => array(
+ * 'documentation' => $typeDocumentation
+ * 'parameters' => array(
+ * $firstParameter => array(
+ * 'type' => $type,
+ * 'required' => $isRequired,
+ * 'default' => $defaultValue,
+ * 'documentation' => $parameterDocumentation
+ * ),
+ * ...
+ * )
+ * ),
+ * ...
+ * )
+ */
+ protected $_types = array();
+
+ /**
+ * Types class map.
+ *
+ * @var array array(
+ * $complexTypeName => $interfaceName,
+ * ...
+ * )
+ */
+ protected $_typeToClassMap = array();
+
+ /**
+ * Construct type processor.
+ *
+ * @param \Magento\Webapi\Helper\Data $helper
+ */
+ public function __construct(\Magento\Webapi\Helper\Data $helper)
+ {
+ $this->_helper = $helper;
+ }
+
+ /**
+ * Retrieve processed types data.
+ *
+ * @return array
+ */
+ public function getTypesData()
+ {
+ return $this->_types;
+ }
+
+ /**
+ * Retrieve data type details for the given type name.
+ *
+ * @param string $typeName
+ * @return array
+ * @throws \InvalidArgumentException
+ */
+ public function getTypeData($typeName)
+ {
+ if (!isset($this->_types[$typeName])) {
+ throw new \InvalidArgumentException(sprintf('Data type "%s" is not declared.', $typeName));
+ }
+ return $this->_types[$typeName];
+ }
+
+ /**
+ * Add or update type data in config.
+ *
+ * @param string $typeName
+ * @param array $data
+ */
+ public function setTypeData($typeName, $data)
+ {
+ if (!isset($this->_types[$typeName])) {
+ $this->_types[$typeName] = $data;
+ } else {
+ $this->_types[$typeName] = array_merge_recursive($this->_types[$typeName], $data);
+ }
+ }
+
+ /**
+ * Process type name. In case parameter type is a complex type (class) - process its properties.
+ *
+ * @param string $type
+ * @return string
+ * @throws \LogicException
+ */
+ public function process($type)
+ {
+ $typeName = $this->normalizeType($type);
+ if (!$this->isTypeSimple($typeName)) {
+ if ((!$this->isArrayType($type) && !class_exists($type))
+ || !class_exists(str_replace('[]', '', $type))
+ ) {
+ throw new \LogicException(
+ sprintf('Class "%s" does not exist. Please note that namespace must be specified.', $type)
+ );
+ }
+ $complexTypeName = $this->translateTypeName($type);
+ if (!isset($this->_types[$complexTypeName])) {
+ $this->_processComplexType($type);
+ if (!$this->isArrayType($complexTypeName)) {
+ $this->_typeToClassMap[$complexTypeName] = $type;
+ }
+ }
+ $typeName = $complexTypeName;
+ }
+
+ return $typeName;
+ }
+
+ /**
+ * Retrieve complex type information from class public properties.
+ *
+ * @param string $class
+ * @return array
+ * @throws \InvalidArgumentException
+ */
+ protected function _processComplexType($class)
+ {
+ $typeName = $this->translateTypeName($class);
+ $this->_types[$typeName] = array();
+ if ($this->isArrayType($class)) {
+ $this->process($this->getArrayItemType($class));
+ } else {
+ if (!class_exists($class)) {
+ throw new \InvalidArgumentException(
+ sprintf('Could not load the "%s" class as parameter type.', $class)
+ );
+ }
+ $reflection = new ClassReflection($class);
+ $docBlock = $reflection->getDocBlock();
+ $this->_types[$typeName]['documentation'] = $docBlock ? $this->_getDescription($docBlock) : '';
+ /** @var \Zend\Code\Reflection\MethodReflection $methodReflection */
+ foreach ($reflection->getMethods(\ReflectionMethod::IS_PUBLIC) as $methodReflection) {
+ $this->_processMethod($methodReflection, $typeName);
+ }
+ }
+
+ return $this->_types[$typeName];
+ }
+
+ /**
+ * Collect metadata for virtual field corresponding to current method if it is a getter (used in WSDL generation).
+ *
+ * @param \Zend\Code\Reflection\MethodReflection $methodReflection
+ * @param string $typeName
+ */
+ protected function _processMethod(\Zend\Code\Reflection\MethodReflection $methodReflection, $typeName)
+ {
+ $isGetter = (strpos($methodReflection->getName(), 'get') === 0)
+ || (strpos($methodReflection->getName(), 'is') === 0)
+ || (strpos($methodReflection->getName(), 'has') === 0);
+ if ($isGetter) {
+ $returnMetadata = $this->getGetterReturnType($methodReflection);
+ $fieldName = $this->_helper->dtoGetterNameToFieldName($methodReflection->getName());
+ $this->_types[$typeName]['parameters'][$fieldName] = array(
+ 'type' => $this->process($returnMetadata['type']),
+ 'required' => $returnMetadata['isRequired'],
+ 'documentation' => $returnMetadata['description']
+ );
+ }
+ }
+
+ /**
+ * Get short and long description from docblock and concatenate.
+ *
+ * @param \Zend\Code\Reflection\DocBlockReflection $doc
+ * @return string
+ */
+ protected function _getDescription(\Zend\Code\Reflection\DocBlockReflection $doc)
+ {
+ $shortDescription = $doc->getShortDescription();
+ $longDescription = $doc->getLongDescription();
+
+ $description = rtrim($shortDescription);
+ $longDescription = str_replace(array("\n", "\r"), '', $longDescription);
+ if (!empty($longDescription) && !empty($description)) {
+ $description .= " ";
+ }
+ $description .= ltrim($longDescription);
+
+ return $description;
+ }
+
+ /**
+ * Identify getter return type by its reflection.
+ *
+ * @param \Zend\Code\Reflection\MethodReflection $methodReflection
+ * @return array array(
+ * 'type' => $type,
+ * 'isRequired' => $isRequired,
+ * 'description' => $description
+ * )
+ * @throws \InvalidArgumentException
+ */
+ public function getGetterReturnType($methodReflection)
+ {
+ $methodDocBlock = $methodReflection->getDocBlock();
+ if (!$methodDocBlock) {
+ throw new \InvalidArgumentException('Each getter must have description with @return annotation.');
+ }
+ $returnAnnotations = $methodDocBlock->getTags('return');
+ if (empty($returnAnnotations)) {
+ throw new \InvalidArgumentException('Getter return type must be specified using @return annotation.');
+ }
+ /** @var \Zend\Code\Reflection\DocBlock\Tag\ReturnTag $returnAnnotation */
+ $returnAnnotation = current($returnAnnotations);
+ $returnType = $returnAnnotation->getType();
+ /*
+ * Adding this code as a workaround since \Zend\Code\Reflection\DocBlock\Tag\ReturnTag::initialize does not
+ * detect and return correct type for array of objects in annotation.
+ * eg @return \Magento\Webapi\Service\Entity\SimpleDto[] is returned with type
+ * \Magento\Webapi\Service\Entity\SimpleDto instead of \Magento\Webapi\Service\Entity\SimpleDto[]
+ */
+ $escapedReturnType = str_replace('\\', '\\\\', $returnType);
+ if (preg_match("/.*\@return\s+({$escapedReturnType}\[\]).*/i", $methodDocBlock->getContents(), $matches)) {
+ $returnType = $matches[1];
+ }
+ $isRequired = preg_match("/.*\@return\s+\S+\|null.*/i", $methodDocBlock->getContents(), $matches)
+ ? false
+ : true;
+ return [
+ 'type' => $returnType,
+ 'isRequired' => $isRequired,
+ 'description' => $returnAnnotation->getDescription()
+ ];
+ }
+
+ /**
+ * Normalize short type names to full type names.
+ *
+ * @param string $type
+ * @return string
+ */
+ public function normalizeType($type)
+ {
+ $normalizationMap = array(
+ 'str' => 'string',
+ 'integer' => 'int',
+ 'bool' => 'boolean',
+ );
+
+ return is_string($type) && isset($normalizationMap[$type]) ? $normalizationMap[$type] : $type;
+ }
+
+ /**
+ * Check if given type is a simple type.
+ *
+ * @param string $type
+ * @return bool
+ */
+ public function isTypeSimple($type)
+ {
+ $type = $this->normalizeType($type);
+ if ($this->isArrayType($type)) {
+ $type = $this->getArrayItemType($type);
+ }
+
+ return in_array($type, array('string', 'int', 'float', 'double', 'boolean'));
+ }
+
+ /**
+ * Check if given type is an array of type items.
+ * Example:
+ *
+ * ComplexType[] -> array of ComplexType items
+ * string[] -> array of strings
+ *
+ *
+ * @param string $type
+ * @return bool
+ */
+ public function isArrayType($type)
+ {
+ return (bool)preg_match('/(\[\]$|^ArrayOf)/', $type);
+ }
+
+ /**
+ * Get item type of the array.
+ * Example:
+ *
+ * ComplexType[] => ComplexType
+ * string[] => string
+ * int[] => integer
+ *
+ *
+ * @param string $arrayType
+ * @return string
+ */
+ public function getArrayItemType($arrayType)
+ {
+ return $this->normalizeType(str_replace('[]', '', $arrayType));
+ }
+
+ /**
+ * Translate complex type class name into type name.
+ *
+ * Example:
+ *
+ * Magento_Customer_Service_CustomerData => CustomerData
+ * Magento_Catalog_Service_ProductData => CatalogProductData
+ *
+ *
+ * @param string $class
+ * @return string
+ * @throws \InvalidArgumentException
+ */
+ public function translateTypeName($class)
+ {
+ if (preg_match('/\\\\?(.*)\\\\(.*)\\\\Service\\\\\2?(.*)/', $class, $matches)) {
+ $moduleNamespace = $matches[1] == 'Magento' ? '' : $matches[1];
+ $moduleName = $matches[2];
+ $typeNameParts = explode('\\', $matches[3]);
+
+ return ucfirst($moduleNamespace . $moduleName . implode('', $typeNameParts));
+ }
+ throw new \InvalidArgumentException(sprintf('Invalid parameter type "%s".', $class));
+ }
+
+ /**
+ * Translate array complex type name.
+ *
+ * Example:
+ *
+ * ComplexTypeName[] => ArrayOfComplexTypeName
+ * string[] => ArrayOfString
+ *
+ *
+ * @param string $type
+ * @return string
+ */
+ public function translateArrayTypeName($type)
+ {
+ return 'ArrayOf' . ucfirst($this->getArrayItemType($type));
+ }
+}
diff --git a/app/code/Magento/Webapi/Model/Rest/Config.php b/app/code/Magento/Webapi/Model/Rest/Config.php
index 48284a6c402c2..7f75332c38e16 100644
--- a/app/code/Magento/Webapi/Model/Rest/Config.php
+++ b/app/code/Magento/Webapi/Model/Rest/Config.php
@@ -109,6 +109,8 @@ protected function _getServiceBaseUrl($request)
}
/**
+ * TODO: Refactor $this->_config->getServices() to return array with baseUrl as the key since its unique and
+ * needs to be used directly instead of looping each key
* Generate the list of available REST routes. Current HTTP method is taken into account.
*
* @param \Magento\Webapi\Controller\Rest\Request $request
diff --git a/app/code/Magento/Webapi/Model/Soap/Config.php b/app/code/Magento/Webapi/Model/Soap/Config.php
index 2cc8a36e6daca..76d8a4c5b3e3c 100644
--- a/app/code/Magento/Webapi/Model/Soap/Config.php
+++ b/app/code/Magento/Webapi/Model/Soap/Config.php
@@ -65,20 +65,35 @@ class Config
*/
protected $_soapOperations;
+ /** @var \Magento\Webapi\Helper\Data */
+ protected $_helper;
+
+ /** @var \Magento\Webapi\Model\Config\ClassReflector */
+ protected $_classReflector;
+
/**
+ * Initialize dependencies.
+ *
* @param \Magento\ObjectManager $objectManager
* @param \Magento\App\Filesystem $filesystem
* @param \Magento\Webapi\Model\Config $config
+ * @param \Magento\Webapi\Model\Config\ClassReflector $classReflector
+ * @param \Magento\Webapi\Helper\Data $helper
*/
public function __construct(
\Magento\ObjectManager $objectManager,
\Magento\App\Filesystem $filesystem,
- \Magento\Webapi\Model\Config $config
+ \Magento\Webapi\Model\Config $config,
+ \Magento\Webapi\Model\Config\ClassReflector $classReflector,
+ \Magento\Webapi\Helper\Data $helper
) {
// TODO: Check if Service specific XSD is already cached
$this->modulesDirectory = $filesystem->getDirectoryRead(\Magento\App\Filesystem::MODULES_DIR);
$this->_config = $config;
$this->_objectManager = $objectManager;
+ $this->_helper = $helper;
+ $this->_classReflector = $classReflector;
+ $this->_initServicesMetadata();
}
/**
@@ -118,29 +133,37 @@ protected function _getSoapOperations($requestedService)
/**
* Collect the list of services with their operations available in SOAP.
- * The list of services is taken from webapi.xml configuration files.
- * The list of methods in contrast to REST is taken from PHP Interface using reflection.
*
* @return array
*/
- protected function _getSoapServices()
+ protected function _initServicesMetadata()
{
// TODO: Implement caching if this approach is approved
if (is_null($this->_soapServices)) {
$this->_soapServices = array();
foreach ($this->_config->getServices() as $serviceData) {
$serviceClass = $serviceData[Converter::KEY_SERVICE_CLASS];
+ $serviceName = $this->_helper->getServiceName($serviceClass);
foreach ($serviceData[Converter::KEY_SERVICE_METHODS] as $methodMetadata) {
// TODO: Simplify the structure in SOAP. Currently it is unified in SOAP and REST
$methodName = $methodMetadata[Converter::KEY_SERVICE_METHOD];
- $this->_soapServices[$serviceClass]['methods'][$methodName] = array(
+ $this->_soapServices[$serviceName]['methods'][$methodName] = array(
self::KEY_METHOD => $methodName,
self::KEY_IS_REQUIRED => (bool)$methodMetadata[Converter::KEY_IS_SECURE],
self::KEY_IS_SECURE => $methodMetadata[Converter::KEY_IS_SECURE],
self::KEY_ACL_RESOURCES => $methodMetadata[Converter::KEY_ACL_RESOURCES]
);
- $this->_soapServices[$serviceClass][self::KEY_CLASS] = $serviceClass;
+ $this->_soapServices[$serviceName][self::KEY_CLASS] = $serviceClass;
};
+ $reflectedMethodsMetadata = $this->_classReflector->reflectClassMethods(
+ $serviceClass,
+ $this->_soapServices[$serviceName]['methods']
+ );
+ // TODO: Consider service documentation extraction via reflection
+ $this->_soapServices[$serviceName]['methods'] = array_merge_recursive(
+ $this->_soapServices[$serviceName]['methods'],
+ $reflectedMethodsMetadata
+ );
};
}
return $this->_soapServices;
@@ -182,49 +205,13 @@ public function getRequestedSoapServices(array $requestedServices)
{
$services = array();
foreach ($requestedServices as $serviceName) {
- foreach ($this->_getSoapServices() as $serviceData) {
- $serviceWithVersion = $this->getServiceName($serviceData[self::KEY_CLASS]);
- if ($serviceWithVersion === $serviceName) {
- $services[] = $serviceData;
- }
+ if (isset($this->_soapServices[$serviceName])) {
+ $services[] = $this->_soapServices[$serviceName];
}
}
return $services;
}
- /**
- * Load and return Service XSD for the provided Service Class
- *
- * @param $serviceClass
- * @return \DOMDocument
- */
- public function getServiceSchemaDOM($serviceClass)
- {
- // TODO: Change pattern to match interface instead of class. Think about sub-services.
- if (!preg_match(\Magento\Webapi\Model\Config::SERVICE_CLASS_PATTERN, $serviceClass, $matches)) {
- // TODO: Generate exception when error handling strategy is defined
- }
-
- $vendorName = $matches[1];
- $moduleName = $matches[2];
- /** Convert "_Catalog_Attribute" into "Catalog/Attribute" */
- $servicePath = str_replace('_', '/', ltrim($matches[3], '_'));
- $version = $matches[4];
- $schemaPath = "{$vendorName}/{$moduleName}/etc/schema/{$servicePath}{$version}.xsd";
-
- if ($this->modulesDirectory->isFile($schemaPath)) {
- $schema = $this->modulesDirectory->readFile($schemaPath);
- } else {
- $schema = '';
- }
-
- // TODO: Should happen only once the cache is in place
- $serviceSchema = $this->_objectManager->create('DOMDocument');
- $serviceSchema->loadXML($schema);
-
- return $serviceSchema;
- }
-
/**
* Generate SOAP operation name.
*
@@ -234,63 +221,23 @@ public function getServiceSchemaDOM($serviceClass)
*/
public function getSoapOperation($interfaceName, $methodName)
{
- $serviceName = $this->getServiceName($interfaceName);
+ $serviceName = $this->_helper->getServiceName($interfaceName);
$operationName = $serviceName . ucfirst($methodName);
return $operationName;
}
/**
- * Translate service interface name into service name.
- * Example:
- *
- * - \Magento\Customer\Service\CustomerV1Interface => customer // $preserveVersion == false
- * - \Magento\Customer\Service\Customer\AddressV1Interface => customerAddressV1 // $preserveVersion == true
- * - \Magento\Catalog\Service\ProductV2Interface => catalogProductV2 // $preserveVersion == true
- *
- *
- * @param string $interfaceName
- * @param bool $preserveVersion Should version be preserved during interface name conversion into service name
- * @return string
- * @throws \InvalidArgumentException
- */
- public function getServiceName($interfaceName, $preserveVersion = true)
- {
- $serviceNameParts = $this->getServiceNameParts($interfaceName, $preserveVersion);
- return lcfirst(implode('', $serviceNameParts));
- }
-
- /**
- * Identify the list of service name parts including sub-services using class name.
+ * Retrieve specific service interface data.
*
- * Examples of input/output pairs:
- * - 'Magento\Customer\Service\Customer\AddressV1Interface' => array('Customer', 'Address', 'V1')
- * - 'Vendor\Customer\Service\Customer\AddressV1Interface' => array('VendorCustomer', 'Address', 'V1)
- * - 'Magento\Catalog\Service\ProductV2Interface' => array('CatalogProduct', 'V2')
- *
- * @param string $className
- * @param bool $preserveVersion Should version be preserved during class name conversion into service name
+ * @param string $serviceName
* @return array
- * @throws \InvalidArgumentException When class is not valid API service.
+ * @throws \RuntimeException
*/
- public function getServiceNameParts($className, $preserveVersion = false)
+ public function getServiceMetadata($serviceName)
{
- if (preg_match(\Magento\Webapi\Model\Config::SERVICE_CLASS_PATTERN, $className, $matches)) {
- $moduleNamespace = $matches[1];
- $moduleName = $matches[2];
- $moduleNamespace = ($moduleNamespace == 'Magento') ? '' : $moduleNamespace;
- $serviceNameParts = explode('\\', trim($matches[3], '\\'));
- if ($moduleName == $serviceNameParts[0]) {
- /** Avoid duplication of words in service name */
- $moduleName = '';
- }
- $parentServiceName = $moduleNamespace . $moduleName . array_shift($serviceNameParts);
- array_unshift($serviceNameParts, $parentServiceName);
- if ($preserveVersion) {
- $serviceVersion = $matches[4];
- $serviceNameParts[] = $serviceVersion;
- }
- return $serviceNameParts;
+ if (!isset($this->_soapServices[$serviceName]) || !is_array($this->_soapServices[$serviceName])) {
+ throw new \RuntimeException(__('Requested service is not available: "%1"', $serviceName));
}
- throw new \InvalidArgumentException(sprintf('The service interface name "%s" is invalid.', $className));
+ return $this->_soapServices[$serviceName];
}
}
diff --git a/app/code/Magento/Webapi/Model/Soap/Fault.php b/app/code/Magento/Webapi/Model/Soap/Fault.php
index b74295bbb75ed..b748e5bf22449 100644
--- a/app/code/Magento/Webapi/Model/Soap/Fault.php
+++ b/app/code/Magento/Webapi/Model/Soap/Fault.php
@@ -40,8 +40,12 @@ class Fault extends \RuntimeException
*/
const NODE_DETAIL_CODE = 'Code';
const NODE_DETAIL_PARAMETERS = 'Parameters';
+ /** Note that parameter node must be unique in scope of all complex types declared in WSDL */
+ const NODE_DETAIL_PARAMETER = 'GenericFaultParameter';
+ const NODE_DETAIL_PARAMETER_KEY = 'key';
+ const NODE_DETAIL_PARAMETER_VALUE = 'value';
const NODE_DETAIL_TRACE = 'Trace';
- const NODE_DETAIL_WRAPPER = 'DefaultFault';
+ const NODE_DETAIL_WRAPPER = 'GenericFault';
/**#@-*/
/** @var string */
@@ -280,12 +284,47 @@ protected function _convertDetailsToXml($details)
if (is_numeric($detailNode)) {
continue;
}
- if (is_string($detailValue) || is_numeric($detailValue)) {
- $detailsXml .= "" . htmlspecialchars($detailValue) . "";
- } elseif (is_array($detailValue)) {
- $detailsXml .= "" . $this->_convertDetailsToXml($detailValue) . "";
+ switch ($detailNode) {
+ case self::NODE_DETAIL_CODE:
+ // break is intentionally omitted
+ case self::NODE_DETAIL_TRACE:
+ if (is_string($detailValue) || is_numeric($detailValue)) {
+ $detailsXml .= "" . htmlspecialchars($detailValue) . "";
+ }
+ break;
+ case self::NODE_DETAIL_PARAMETERS:
+ $detailsXml .= $this->_getParametersXml($detailValue, $detailNode, $detailsXml);
+ break;
}
}
return $detailsXml;
}
+
+ /**
+ * Generate XML for parameters.
+ *
+ * @param array $parameters
+ * @return string
+ */
+ protected function _getParametersXml($parameters)
+ {
+ $result = '';
+ if (is_array($parameters)) {
+ $paramsXml = '';
+ foreach ($parameters as $parameterName => $parameterValue) {
+ if (is_string($parameterName) && (is_string($parameterValue) || is_numeric($parameterValue))) {
+ $keyNode = self::NODE_DETAIL_PARAMETER_KEY;
+ $valueNode = self::NODE_DETAIL_PARAMETER_VALUE;
+ $parameterNode = self::NODE_DETAIL_PARAMETER;
+ $paramsXml .= "$parameterName"
+ . htmlspecialchars($parameterValue) . "";
+ }
+ }
+ if (!empty($paramsXml)) {
+ $parametersNode = self::NODE_DETAIL_PARAMETERS;
+ $result = "" . $paramsXml . "";
+ }
+ }
+ return $result;
+ }
}
diff --git a/app/code/Magento/Webapi/Model/Soap/Server.php b/app/code/Magento/Webapi/Model/Soap/Server.php
index ad8650753c155..cf9e60c9ded32 100644
--- a/app/code/Magento/Webapi/Model/Soap/Server.php
+++ b/app/code/Magento/Webapi/Model/Soap/Server.php
@@ -61,6 +61,9 @@ class Server
/** @var \Magento\Webapi\Model\Soap\Server\Factory */
protected $_soapServerFactory;
+ /** @var \Magento\Webapi\Model\Config\ClassReflector\TypeProcessor */
+ protected $_typeProcessor;
+
/**
* Initialize dependencies, initialize WSDL cache.
*
@@ -70,6 +73,7 @@ class Server
* @param \Magento\DomDocument\Factory $domDocumentFactory
* @param \Magento\Core\Model\StoreManagerInterface $storeManager
* @param \Magento\Webapi\Model\Soap\Server\Factory $soapServerFactory
+ * @param \Magento\Webapi\Model\Config\ClassReflector\TypeProcessor $typeProcessor
* @throws \Magento\Webapi\Exception
*/
public function __construct(
@@ -78,7 +82,8 @@ public function __construct(
\Magento\Webapi\Controller\Soap\Request $request,
\Magento\DomDocument\Factory $domDocumentFactory,
\Magento\Core\Model\StoreManagerInterface $storeManager,
- \Magento\Webapi\Model\Soap\Server\Factory $soapServerFactory
+ \Magento\Webapi\Model\Soap\Server\Factory $soapServerFactory,
+ \Magento\Webapi\Model\Config\ClassReflector\TypeProcessor $typeProcessor
) {
if (!extension_loaded('soap')) {
throw new \Magento\Webapi\Exception('SOAP extension is not loaded.', 0,
@@ -90,6 +95,7 @@ public function __construct(
$this->_domDocumentFactory = $domDocumentFactory;
$this->_storeManager = $storeManager;
$this->_soapServerFactory = $soapServerFactory;
+ $this->_typeProcessor = $typeProcessor;
/** Enable or disable SOAP extension WSDL cache depending on Magento configuration. */
$wsdlCacheEnabled = (bool)$storeManager->getStore()->getConfig(self::CONFIG_PATH_WSDL_CACHE_ENABLED);
if ($wsdlCacheEnabled) {
@@ -100,9 +106,7 @@ public function __construct(
}
/**
- * Handle SOAP request.
- *
- * @return string
+ * Handle SOAP request. Response is sent by SOAP server.
*/
public function handle()
{
@@ -112,8 +116,8 @@ public function handle()
'encoding' => $this->getApiCharset(),
'soap_version' => SOAP_1_2
);
- $soap = $this->_soapServerFactory->create($this->generateUri(true), $options);
- return $soap->handle($rawRequestBody);
+ $soapServer = $this->_soapServerFactory->create($this->generateUri(true), $options);
+ $soapServer->handle($rawRequestBody);
}
/**
diff --git a/app/code/Magento/Webapi/Model/Soap/Server/Factory.php b/app/code/Magento/Webapi/Model/Soap/Server/Factory.php
index 53deae10a27d7..e11f120d7700a 100644
--- a/app/code/Magento/Webapi/Model/Soap/Server/Factory.php
+++ b/app/code/Magento/Webapi/Model/Soap/Server/Factory.php
@@ -33,7 +33,7 @@ class Factory
protected $_objectManager;
/**
- * @var \Magento\Webapi\Controller\Soap\Handler
+ * @var \Magento\Webapi\Controller\Soap\Request\Handler
*/
protected $_soapHandler;
@@ -41,11 +41,11 @@ class Factory
* Initialize the class
*
* @param \Magento\ObjectManager $objectManager
- * @param \Magento\Webapi\Controller\Soap\Handler $soapHandler
+ * @param \Magento\Webapi\Controller\Soap\Request\Handler $soapHandler
*/
public function __construct(
\Magento\ObjectManager $objectManager,
- \Magento\Webapi\Controller\Soap\Handler $soapHandler
+ \Magento\Webapi\Controller\Soap\Request\Handler $soapHandler
) {
$this->_objectManager = $objectManager;
$this->_soapHandler = $soapHandler;
diff --git a/app/code/Magento/Webapi/Model/Soap/Wsdl.php b/app/code/Magento/Webapi/Model/Soap/Wsdl.php
index 776339b260a2f..026ca0330cceb 100644
--- a/app/code/Magento/Webapi/Model/Soap/Wsdl.php
+++ b/app/code/Magento/Webapi/Model/Soap/Wsdl.php
@@ -24,6 +24,7 @@
namespace Magento\Webapi\Model\Soap;
use DOMElement;
+use Magento\Webapi\Model\Soap\Wsdl\ComplexTypeStrategy;
/**
* Magento-specific WSDL builder.
@@ -36,106 +37,36 @@ class Wsdl extends \Zend\Soap\Wsdl
*
* @param string $name
* @param string|\Zend\Uri\Uri $uri
- * @param \Magento\Webapi\Model\Soap\Wsdl\ComplexTypeStrategy\AnyComplexType $strategy
+ * @param ComplexTypeStrategy $strategy
*/
- public function __construct(
- $name,
- $uri,
- \Magento\Webapi\Model\Soap\Wsdl\ComplexTypeStrategy\AnyComplexType $strategy
- ) {
- parent::__construct($name, $uri, $strategy);
- }
-
- /**
- * Add complex type definition
- *
- * @param \DOMNode $complexTypeNode XSD of service method for input/output
- * @return string|null
- */
- public function addComplexType($complexTypeNode)
+ public function __construct($name, $uri, ComplexTypeStrategy $strategy)
{
- $this->addSchemaTypeSection();
-
- $strategy = $this->getComplexTypeStrategy();
- $strategy->setContext($this);
- // delegates the detection of a complex type to the current strategy
- return $strategy->addComplexType($complexTypeNode);
+ parent::__construct($name, $uri, $strategy);
}
/**
* Add an operation to port type.
*
- * Multiple faults generation is allowed, while it is not allowed in parent.
- *
* @param DOMElement $portType
* @param string $name Operation name
* @param string|bool $input Input Message
* @param string|bool $output Output Message
- * @param array|bool $fault array of Fault messages in the format: array(array('message' => ..., 'name' => ...))
+ * @param string|bool|array $fault Message name OR array('message' => ..., 'name' => ...)
* @return object The new operation's XML_Tree_Node
*/
public function addPortOperation($portType, $name, $input = false, $output = false, $fault = false)
{
$operation = parent::addPortOperation($portType, $name, $input, $output, false);
if (is_array($fault)) {
- foreach ($fault as $faultInfo) {
- $isMessageValid = isset($faultInfo['message']) && is_string($faultInfo['message'])
- && strlen(trim($faultInfo['message']));
- $isNameValid = isset($faultInfo['name']) && is_string($faultInfo['name'])
- && strlen(trim($faultInfo['name']));
-
- if ($isNameValid && $isMessageValid) {
- $node = $this->toDomDocument()->createElement('fault');
- $node->setAttribute('name', $faultInfo['name']);
- $node->setAttribute('message', $faultInfo['message']);
- $operation->appendChild($node);
- }
- }
- }
- return $operation;
- }
-
- /**
- * Add an operation to a binding element.
- *
- * Multiple faults binding is allowed, while it is not allowed in parent.
- *
- * @param DOMElement $binding
- * @param string $name Operation name
- * @param bool|array $input An array of attributes for the input element,
- * allowed keys are: 'use', 'namespace', 'encodingStyle'.
- * @param bool|array $output An array of attributes for the output element,
- * allowed keys are: 'use', 'namespace', 'encodingStyle'.
- * @param bool|array $fault An array of arrays which contain fault names: array(array('name' => ...))).
- * @param int $soapVersion SOAP version to be used in binding operation. 1.1 used by default.
- * @return DOMElement The new Operation's XML_Tree_Node
- */
- public function addBindingOperation(
- $binding,
- $name,
- $input = false,
- $output = false,
- $fault = false,
- $soapVersion = SOAP_1_1
- ) {
- $operation = parent::addBindingOperation($binding, $name, $input, $output, false, $soapVersion);
- if (is_array($fault)) {
- foreach ($fault as $faultInfo) {
- $isNameValid = isset($faultInfo['name']) && is_string($faultInfo['name'])
- && strlen(trim($faultInfo['name']));
-
- if ($isNameValid) {
- $faultInfo['use'] = 'literal';
- $wsdlFault = $this->toDomDocument()->createElement('fault');
- $wsdlFault->setAttribute('name', $faultInfo['name']);
-
- $soapFault = $this->toDomDocument()->createElement('soap:fault');
- $soapFault->setAttribute('name', $faultInfo['name']);
- $soapFault->setAttribute('use', 'literal');
+ $isMessageValid = isset($fault['message']) && is_string($fault['message'])
+ && strlen(trim($fault['message']));
+ $isNameValid = isset($fault['name']) && is_string($fault['name']) && strlen(trim($fault['name']));
- $wsdlFault->appendChild($soapFault);
- $operation->appendChild($wsdlFault);
- }
+ if ($isNameValid && $isMessageValid) {
+ $node = $this->toDomDocument()->createElement('fault');
+ $node->setAttribute('name', $fault['name']);
+ $node->setAttribute('message', $fault['message']);
+ $operation->appendChild($node);
}
}
return $operation;
diff --git a/app/code/Magento/Webapi/Model/Soap/Wsdl/ComplexTypeStrategy.php b/app/code/Magento/Webapi/Model/Soap/Wsdl/ComplexTypeStrategy.php
new file mode 100644
index 0000000000000..cc48f70fced4d
--- /dev/null
+++ b/app/code/Magento/Webapi/Model/Soap/Wsdl/ComplexTypeStrategy.php
@@ -0,0 +1,460 @@
+_typeProcessor = $typeProcessor;
+ }
+
+ /**
+ * Return DOM Document
+ *
+ * @return \DomDocument
+ */
+ protected function _getDom()
+ {
+ return $this->getContext()->toDomDocument();
+ }
+
+ /**
+ * Add complex type.
+ *
+ * @param string $type
+ * @param array $parentCallInfo array of callInfo from parent complex type
+ * @return string
+ * @throws \InvalidArgumentException
+ */
+ public function addComplexType($type, $parentCallInfo = array())
+ {
+ if (($soapType = $this->scanRegisteredTypes($type)) !== null) {
+ return $soapType;
+ }
+ $soapType = Wsdl::TYPES_NS . ':' . $type;
+ // Register type here to avoid recursion
+ $this->getContext()->addType($type, $soapType);
+ $complexType = $this->_getDom()->createElement(Wsdl::XSD_NS . ':complexType');
+ $complexType->setAttribute('name', $type);
+ $typeData = $this->_typeProcessor->getTypeData($type);
+ if (isset($typeData['documentation'])) {
+ $this->addAnnotation($complexType, $typeData['documentation']);
+ }
+
+ if (isset($typeData['parameters']) && is_array($typeData['parameters'])) {
+ $callInfo = isset($typeData['callInfo']) ? $typeData['callInfo'] : $parentCallInfo;
+ $sequence = $this->_processParameters($typeData['parameters'], $callInfo);
+ $complexType->appendChild($sequence);
+ }
+
+ $this->getContext()->getSchema()->appendChild($complexType);
+ return $soapType;
+ }
+
+ /**
+ * Process type parameters and create complex type sequence.
+ *
+ * @param array $parameters
+ * @param array $callInfo
+ * @return \DOMElement
+ */
+ protected function _processParameters($parameters, $callInfo)
+ {
+ $sequence = $this->_getDom()->createElement(Wsdl::XSD_NS . ':sequence');
+ foreach ($parameters as $parameterName => $parameterData) {
+ $parameterType = $parameterData['type'];
+ $element = $this->_getDom()->createElement(Wsdl::XSD_NS . ':element');
+ $element->setAttribute('name', $parameterName);
+ $isRequired = isset($parameterData['required']) && $parameterData['required'];
+ $default = isset($parameterData['default']) ? $parameterData['default'] : null;
+ $this->_revertRequiredCallInfo($isRequired, $callInfo);
+
+ if ($this->_typeProcessor->isArrayType($parameterType)) {
+ $this->_processArrayParameter($parameterType, $callInfo);
+ $element->setAttribute(
+ 'type',
+ Wsdl::TYPES_NS . ':' . $this->_typeProcessor->translateArrayTypeName($parameterType)
+ );
+ } else {
+ $this->_processParameter($element, $isRequired, $parameterData, $parameterType, $callInfo);
+ }
+
+ $this->addAnnotation($element, $parameterData['documentation'], $default, $callInfo);
+ $sequence->appendChild($element);
+ }
+
+ return $sequence;
+ }
+
+ /**
+ * Process parameter and declare complex type if necessary.
+ *
+ * @param \DOMElement $element
+ * @param boolean $isRequired
+ * @param array $parameterData
+ * @param string $parameterType
+ * @param array $callInfo
+ */
+ protected function _processParameter(\DOMElement $element, $isRequired, $parameterData, $parameterType, $callInfo)
+ {
+ $element->setAttribute('minOccurs', $isRequired ? 1 : 0);
+ $maxOccurs = (isset($parameterData['isArray']) && $parameterData['isArray']) ? 'unbounded' : 1;
+ $element->setAttribute('maxOccurs', $maxOccurs);
+ if ($this->_typeProcessor->isTypeSimple($parameterType)) {
+ $typeNs = Wsdl::XSD_NS;
+ } else {
+ $typeNs = Wsdl::TYPES_NS;
+ $this->addComplexType($parameterType, $callInfo);
+ }
+ $element->setAttribute('type', $typeNs . ':' . $parameterType);
+ }
+
+ /**
+ * Process array of types.
+ *
+ * @param string $type
+ * @param array $callInfo
+ */
+ protected function _processArrayParameter($type, $callInfo = array())
+ {
+ $arrayItemType = $this->_typeProcessor->getArrayItemType($type);
+ $arrayTypeName = $this->_typeProcessor->translateArrayTypeName($type);
+ if (!$this->_typeProcessor->isTypeSimple($arrayItemType)) {
+ $this->addComplexType($arrayItemType, $callInfo);
+ }
+ $arrayTypeParameters = array(
+ self::ARRAY_ITEM_KEY_NAME => array(
+ 'type' => $arrayItemType,
+ 'required' => false,
+ 'isArray' => true,
+ 'documentation' => sprintf('An item of %s.', $arrayTypeName)
+ )
+ );
+ $arrayTypeData = array(
+ 'documentation' => sprintf('An array of %s items.', $arrayItemType),
+ 'parameters' => $arrayTypeParameters,
+ );
+ $this->_typeProcessor->setTypeData($arrayTypeName, $arrayTypeData);
+ $this->addComplexType($arrayTypeName, $callInfo);
+ }
+
+ /**
+ * Revert required call info data if needed.
+ *
+ * @param boolean $isRequired
+ * @param array $callInfo
+ */
+ protected function _revertRequiredCallInfo($isRequired, &$callInfo)
+ {
+ if (!$isRequired) {
+ if (isset($callInfo['requiredInput']['yes'])) {
+ $callInfo['requiredInput']['no']['calls'] = $callInfo['requiredInput']['yes']['calls'];
+ unset($callInfo['requiredInput']['yes']);
+ }
+ if (isset($callInfo['returned']['always'])) {
+ $callInfo['returned']['conditionally']['calls'] = $callInfo['returned']['always']['calls'];
+ unset($callInfo['returned']['always']);
+ }
+ }
+ }
+
+ /**
+ * Generate annotation data for WSDL.
+ *
+ * Convert all {key:value} from documentation into appinfo nodes.
+ * Override default callInfo values if defined in parameter documentation.
+ *
+ * @param \DOMElement $element
+ * @param string $documentation parameter documentation string
+ * @param string|null $default
+ * @param array $callInfo
+ */
+ public function addAnnotation(\DOMElement $element, $documentation, $default = null, $callInfo = array())
+ {
+ $annotationNode = $this->_getDom()->createElement(Wsdl::XSD_NS . ':annotation');
+
+ $elementType = $this->_getElementType($element);
+ $appInfoNode = $this->_getDom()->createElement(Wsdl::XSD_NS . ':appinfo');
+ $appInfoNode->setAttributeNS(
+ Wsdl::XML_NS_URI,
+ Wsdl::XML_NS . ':' . self::APP_INF_NS,
+ $this->getContext()->getTargetNamespace()
+ );
+
+ $this->_processDefaultValueAnnotation($elementType, $default, $appInfoNode);
+ $this->_processElementType($elementType, $documentation, $appInfoNode);
+
+ if (preg_match_all('/{([a-z]+):(.+)}/Ui', $documentation, $matches)) {
+ for ($i = 0; $i < count($matches[0]); $i++) {
+ $appinfoTag = $matches[0][$i];
+ $tagName = $matches[1][$i];
+ $tagValue = $matches[2][$i];
+ switch ($tagName) {
+ case 'callInfo':
+ $callInfoRegExp = '/([a-z].+):(returned|requiredInput):(yes|no|always|conditionally)/i';
+ if (preg_match($callInfoRegExp, $tagValue)) {
+ list($callName, $direction, $condition) = explode(':', $tagValue);
+ $condition = strtolower($condition);
+ if (preg_match('/allCallsExcept\(([a-zA-Z].+)\)/', $callName, $calls)) {
+ $callInfo[$direction][$condition] = array(
+ 'allCallsExcept' => $calls[1],
+ );
+ } else if (!isset($callInfo[$direction][$condition]['allCallsExcept'])) {
+ $this->_overrideCallInfoName($callInfo, $callName);
+ $callInfo[$direction][$condition]['calls'][] = $callName;
+ }
+ }
+ break;
+ case 'seeLink':
+ $this->_processSeeLink($appInfoNode, $tagValue);
+ break;
+ case 'docInstructions':
+ $this->_processDocInstructions($appInfoNode, $tagValue);
+ break;
+ default:
+ $nodeValue = trim($tagValue);
+ $simpleTextNode = $this->_getDom()->createElement(self::APP_INF_NS . ':' . $tagName);
+ $simpleTextNode->appendChild($this->_getDom()->createTextNode($nodeValue));
+ $appInfoNode->appendChild($simpleTextNode);
+ break;
+ }
+ $documentation = str_replace($appinfoTag, '', $documentation);
+ }
+ }
+ $this->_processCallInfo($appInfoNode, $callInfo);
+ $documentationNode = $this->_getDom()->createElement(Wsdl::XSD_NS . ':documentation');
+ $documentationText = trim($documentation);
+ $documentationNode->appendChild($this->_getDom()->createTextNode($documentationText));
+ $annotationNode->appendChild($documentationNode);
+ $annotationNode->appendChild($appInfoNode);
+ $element->appendChild($annotationNode);
+ }
+
+ /**
+ * Process different element types.
+ *
+ * @param string $elementType
+ * @param string $documentation
+ * @param \DOMElement $appInfoNode
+ */
+ protected function _processElementType($elementType, $documentation, \DOMElement $appInfoNode)
+ {
+ if ($elementType == 'int') {
+ $this->_processRequiredAnnotation('min', $documentation, $appInfoNode);
+ $this->_processRequiredAnnotation('max', $documentation, $appInfoNode);
+ }
+ if ($elementType == 'string') {
+ $this->_processRequiredAnnotation('maxLength', $documentation, $appInfoNode);
+ }
+
+ if ($this->_typeProcessor->isArrayType($elementType)) {
+ $natureOfTypeNode = $this->_getDom()->createElement(self::APP_INF_NS . ':natureOfType');
+ $natureOfTypeNode->appendChild($this->_getDom()->createTextNode('array'));
+ $appInfoNode->appendChild($natureOfTypeNode);
+ }
+ }
+
+ /**
+ * Process default value annotation.
+ *
+ * @param string $elementType
+ * @param string $default
+ * @param \DOMElement $appInfoNode
+ */
+ protected function _processDefaultValueAnnotation($elementType, $default, \DOMElement $appInfoNode)
+ {
+ if ($elementType == 'boolean') {
+ $default = (bool)$default ? 'true' : 'false';
+ }
+ if ($default) {
+ $defaultNode = $this->_getDom()->createElement(self::APP_INF_NS . ':default');
+ $defaultNode->appendChild($this->_getDom()->createTextNode($default));
+ $appInfoNode->appendChild($defaultNode);
+ }
+ }
+
+ /**
+ * Retrieve element type.
+ *
+ * @param \DOMElement $element
+ * @return string|null
+ * @SuppressWarnings(PHPMD.UnusedLocalVariable)
+ */
+ protected function _getElementType(\DOMElement $element)
+ {
+ $elementType = null;
+ if ($element->hasAttribute('type')) {
+ list($typeNs, $elementType) = explode(':', $element->getAttribute('type'));
+ }
+ return $elementType;
+ }
+
+ /**
+ * Check if there is given annotation in documentation, and if not - create an empty one.
+ *
+ * @param $annotation
+ * @param $documentation
+ * @param \DOMElement $appInfoNode
+ */
+ protected function _processRequiredAnnotation($annotation, $documentation, \DOMElement $appInfoNode)
+ {
+ if (!preg_match("/{{$annotation}:.+}/Ui", $documentation)) {
+ $annotationNode = $this->_getDom()->createElement(self::APP_INF_NS . ':' . $annotation);
+ $appInfoNode->appendChild($annotationNode);
+ }
+ }
+
+ /**
+ * Process 'callInfo' appinfo tag.
+ *
+ * @param \DOMElement $appInfoNode
+ * @param $callInfo
+ */
+ protected function _processCallInfo(\DOMElement $appInfoNode, $callInfo)
+ {
+ if (!empty($callInfo)) {
+ foreach ($callInfo as $direction => $conditions) {
+ foreach ($conditions as $condition => $info) {
+ $callInfoNode = $this->_getDom()->createElement(self::APP_INF_NS . ':callInfo');
+ if (isset($info['allCallsExcept'])) {
+ $allExceptNode = $this->_getDom()->createElement(self::APP_INF_NS . ':allCallsExcept');
+ $allExceptNode->appendChild($this->_getDom()->createTextNode($info['allCallsExcept']));
+ $callInfoNode->appendChild($allExceptNode);
+ } else if (isset($info['calls'])) {
+ foreach ($info['calls'] as $callName) {
+ $callNode = $this->_getDom()->createElement(self::APP_INF_NS . ':callName');
+ $callNode->appendChild($this->_getDom()->createTextNode($callName));
+ $callInfoNode->appendChild($callNode);
+ }
+ }
+ $directionNode = $this->_getDom()->createElement(self::APP_INF_NS . ':' . $direction);
+ $directionNode->appendChild($this->_getDom()->createTextNode(ucfirst($condition)));
+ $callInfoNode->appendChild($directionNode);
+ $appInfoNode->appendChild($callInfoNode);
+ }
+ }
+ }
+ }
+
+ /**
+ * Process 'docInstructions' appinfo tag.
+ *
+ * @param \DOMElement $appInfoNode
+ * @param $tagValue
+ */
+ protected function _processDocInstructions(\DOMElement $appInfoNode, $tagValue)
+ {
+ if (preg_match('/(input|output):(.+)/', $tagValue, $docMatches)) {
+ $docInstructionsNode = $this->_getDom()->createElement(self::APP_INF_NS . ':docInstructions');
+ $directionNode = $this->_getDom()->createElement(self::APP_INF_NS . ':' . $docMatches[1]);
+ $directionValueNode = $this->_getDom()->createElement(self::APP_INF_NS . ':' . $docMatches[2]);
+ $directionNode->appendChild($directionValueNode);
+ $docInstructionsNode->appendChild($directionNode);
+ $appInfoNode->appendChild($docInstructionsNode);
+ }
+ }
+
+ /**
+ * Process 'seeLink' appinfo tag.
+ *
+ * @param \DOMElement $appInfoNode
+ * @param $tagValue
+ */
+ protected function _processSeeLink(\DOMElement $appInfoNode, $tagValue)
+ {
+ if (preg_match('|([http://]?.+):(.+):(.+)|i', $tagValue, $matches)) {
+ $seeLink = array(
+ 'url' => $matches[1],
+ 'title' => $matches[2],
+ 'for' => $matches[3],
+ );
+ $seeLinkNode = $this->_getDom()->createElement(self::APP_INF_NS . ':seeLink');
+ foreach (array('url', 'title', 'for') as $subNodeName) {
+ if (isset($seeLink[$subNodeName])) {
+ $seeLinkSubNode = $this->_getDom()->createElement(self::APP_INF_NS . ':' . $subNodeName);
+ $seeLinkSubNode->appendChild($this->_getDom()->createTextNode($seeLink[$subNodeName]));
+ $seeLinkNode->appendChild($seeLinkSubNode);
+ }
+ }
+ $appInfoNode->appendChild($seeLinkNode);
+ }
+ }
+
+ /**
+ * Delete callName if it's already defined in some direction group.
+ *
+ * @param $callInfo
+ * @param $callName
+ */
+ protected function _overrideCallInfoName(&$callInfo, $callName)
+ {
+ foreach ($callInfo as $direction => &$callInfoData) {
+ foreach ($callInfoData as $condition => &$data) {
+ if (isset($data['calls'])) {
+ $foundCallNameIndex = array_search($callName, $data['calls']);
+ if ($foundCallNameIndex !== false) {
+ unset($data['calls'][$foundCallNameIndex]);
+ if (empty($data['calls'])) {
+ unset($callInfo[$direction][$condition]);
+ }
+ break;
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/app/code/Magento/Webapi/Model/Soap/Wsdl/Factory.php b/app/code/Magento/Webapi/Model/Soap/Wsdl/Factory.php
index 54891183f7a03..11e06a519ea2c 100644
--- a/app/code/Magento/Webapi/Model/Soap/Wsdl/Factory.php
+++ b/app/code/Magento/Webapi/Model/Soap/Wsdl/Factory.php
@@ -1,7 +1,5 @@
_apiConfig = $apiConfig;
$this->_wsdlFactory = $wsdlFactory;
$this->_cache = $cache;
+ $this->_typeProcessor = $typeProcessor;
}
/**
@@ -81,7 +88,7 @@ public function __construct(
* @param array $requestedServices
* @param string $endPointUrl
* @return string
- * @throws \Magento\Webapi\Exception
+ * @throws \Exception
*/
public function generate($requestedServices, $endPointUrl)
{
@@ -92,8 +99,12 @@ public function generate($requestedServices, $endPointUrl)
if ($cachedWsdlContent !== false) {
return $cachedWsdlContent;
}
+ $services = array();
+ foreach ($requestedServices as $serviceName) {
+ $services[$serviceName] = $this->_apiConfig->getServiceMetadata($serviceName);
+ }
- $wsdlContent = $this->_generate($requestedServices, $endPointUrl);
+ $wsdlContent = $this->_generate($services, $endPointUrl);
$this->_cache->save($wsdlContent, $cacheId, array(\Magento\Webapi\Model\Cache\Type::CACHE_TAG));
return $wsdlContent;
@@ -109,22 +120,11 @@ public function generate($requestedServices, $endPointUrl)
*/
protected function _generate($requestedServices, $endPointUrl)
{
- $services = array();
-
- try {
- foreach ($requestedServices as $serviceName) {
- $services[$serviceName] = $this->_prepareServiceData($serviceName);
- }
- } catch (\Magento\Webapi\Exception $e) {
- throw $e;
- } catch (\Exception $e) {
- throw new \Magento\Webapi\Exception($e->getMessage());
- }
-
+ $this->_collectCallInfo($requestedServices);
$wsdl = $this->_wsdlFactory->create(self::WSDL_NAME, $endPointUrl);
$wsdl->addSchemaTypeSection();
- $this->_addDefaultFaultComplexTypeNodes($wsdl);
- foreach ($services as $serviceClass => $serviceData) {
+ $faultMessageName = $this->_addGenericFaultComplexTypeNodes($wsdl);
+ foreach ($requestedServices as $serviceClass => $serviceData) {
$portTypeName = $this->getPortTypeName($serviceClass);
$bindingName = $this->getBindingName($serviceClass);
$portType = $wsdl->addPortType($portTypeName);
@@ -137,43 +137,31 @@ protected function _generate($requestedServices, $endPointUrl)
foreach ($serviceData['methods'] as $methodName => $methodData) {
$operationName = $this->getOperationName($serviceClass, $methodName);
- $inputBinding = array('use' => 'literal');
+ $bindingDataPrototype = array('use' => 'literal');
+ $inputBinding = $bindingDataPrototype;
$inputMessageName = $this->_createOperationInput($wsdl, $operationName, $methodData);
$outputMessageName = false;
$outputBinding = false;
- if (isset($methodData['interface']['outputComplexTypes'])) {
- $outputBinding = array('use' => 'literal');
+ if (isset($methodData['interface']['out']['parameters'])) {
+ $outputBinding = $bindingDataPrototype;
$outputMessageName = $this->_createOperationOutput($wsdl, $operationName, $methodData);
}
-
- /** Default SOAP fault should be added to each operation declaration */
- $faultsInfo = array(
- array(
- 'name' => Fault::NODE_DETAIL_WRAPPER,
- 'message' => Wsdl::TYPES_NS . ':' . $this->_getDefaultFaultMessageName()
- )
- );
- if (isset($methodData['interface']['faultComplexTypes'])) {
- $faultsInfo = array_merge(
- $faultsInfo,
- $this->_createOperationFaults($wsdl, $operationName, $methodData)
- );
- }
+ $faultBinding = array_merge($bindingDataPrototype, array('name' => Fault::NODE_DETAIL_WRAPPER));
$wsdl->addPortOperation(
$portType,
$operationName,
$inputMessageName,
$outputMessageName,
- $faultsInfo
+ array('message' => $faultMessageName, 'name' => Fault::NODE_DETAIL_WRAPPER)
);
$bindingOperation = $wsdl->addBindingOperation(
$binding,
$operationName,
$inputBinding,
$outputBinding,
- $faultsInfo,
+ $faultBinding,
SOAP_1_2
);
$wsdl->addSoapOperation($bindingOperation, $operationName, SOAP_1_2);
@@ -182,63 +170,6 @@ protected function _generate($requestedServices, $endPointUrl)
return $wsdl->toXML();
}
- /**
- * Extract complex type element from dom document by type name (include referenced types as well).
- *
- * @param string $serviceName
- * @param string $typeName Type names as defined in Service XSDs
- * @param \DOMDocument $domDocument
- * @return \DOMNode[]
- */
- public function getComplexTypeNodes($serviceName, $typeName, $domDocument)
- {
- $response = array();
- /** TODO: Use object manager to instantiate objects */
- $xpath = new \DOMXPath($domDocument);
- $typeXPath = "//xsd:complexType[@name='{$typeName}']";
- $complexTypeNodes = $xpath->query($typeXPath);
- if ($complexTypeNodes) {
- $complexTypeNode = $complexTypeNodes->item(0);
- }
- if (isset($complexTypeNode)) {
- $this->_registeredTypes[] = $serviceName . $typeName;
-
- $referencedTypes = $xpath->query("{$typeXPath}//@type");
- foreach ($referencedTypes as $referencedType) {
- $referencedTypeName = $referencedType->value;
- $prefixedRefTypeName = $serviceName . $referencedTypeName;
- if ($this->isComplexType($referencedTypeName, $domDocument)
- && !in_array($prefixedRefTypeName, $this->_registeredTypes)
- ) {
- $response += $this->getComplexTypeNodes($serviceName, $referencedTypeName, $domDocument);
- /** Add target namespace to the referenced type name */
- $referencedType->value = Wsdl::TYPES_NS . ':' . $prefixedRefTypeName;
- }
- }
- $complexTypeNode->setAttribute(
- 'name',
- $serviceName . $typeName
- );
- $response[$serviceName . $typeName]
- = $complexTypeNode->cloneNode(true);
- }
- return $response;
- }
-
- /**
- * Check if provided type is complex or simple type.
- *
- * Current implementation is based on the assumption that complex types are not prefixed with any namespace,
- * and simple types are prefixed.
- *
- * @param string $typeName
- * @return bool
- */
- public function isComplexType($typeName)
- {
- return !strpos($typeName, ':');
- }
-
/**
* Create input message and corresponding element and complex types in WSDL.
*
@@ -250,18 +181,27 @@ public function isComplexType($typeName)
protected function _createOperationInput(Wsdl $wsdl, $operationName, $methodData)
{
$inputMessageName = $this->getInputMessageName($operationName);
+ $complexTypeName = $this->getElementComplexTypeName($inputMessageName);
+ $inputParameters = array();
$elementData = array(
'name' => $inputMessageName,
- 'type' => Wsdl::TYPES_NS . ':' . $inputMessageName
+ 'type' => Wsdl::TYPES_NS . ':' . $complexTypeName
);
- if (isset($methodData['interface']['inputComplexTypes'])) {
- foreach ($methodData['interface']['inputComplexTypes'] as $complexTypeNode) {
- $wsdl->addComplexType($complexTypeNode);
- }
+ if (isset($methodData['interface']['in']['parameters'])) {
+ $inputParameters = $methodData['interface']['in']['parameters'];
} else {
$elementData['nillable'] = 'true';
}
$wsdl->addElement($elementData);
+ $callInfo = array();
+ $callInfo['requiredInput']['yes']['calls'] = array($operationName);
+ $typeData = array(
+ 'documentation' => $methodData['documentation'],
+ 'parameters' => $inputParameters,
+ 'callInfo' => $callInfo,
+ );
+ $this->_typeProcessor->setTypeData($complexTypeName, $typeData);
+ $wsdl->addComplexType($complexTypeName);
$wsdl->addMessage(
$inputMessageName,
array(
@@ -274,7 +214,7 @@ protected function _createOperationInput(Wsdl $wsdl, $operationName, $methodData
}
/**
- * Create output message, corresponding element and complex types in WSDL.
+ * Create output message and corresponding element and complex types in WSDL.
*
* @param Wsdl $wsdl
* @param string $operationName
@@ -284,17 +224,22 @@ protected function _createOperationInput(Wsdl $wsdl, $operationName, $methodData
protected function _createOperationOutput(Wsdl $wsdl, $operationName, $methodData)
{
$outputMessageName = $this->getOutputMessageName($operationName);
+ $complexTypeName = $this->getElementComplexTypeName($outputMessageName);
$wsdl->addElement(
array(
'name' => $outputMessageName,
- 'type' => Wsdl::TYPES_NS . ':' . $outputMessageName
+ 'type' => Wsdl::TYPES_NS . ':' . $complexTypeName
)
);
- if (isset($methodData['interface']['outputComplexTypes'])) {
- foreach ($methodData['interface']['outputComplexTypes'] as $complexTypeNode) {
- $wsdl->addComplexType($complexTypeNode);
- }
- }
+ $callInfo = array();
+ $callInfo['returned']['always']['calls'] = array($operationName);
+ $typeData = array(
+ 'documentation' => sprintf('Response container for the %s call.', $operationName),
+ 'parameters' => $methodData['interface']['out']['parameters'],
+ 'callInfo' => $callInfo,
+ );
+ $this->_typeProcessor->setTypeData($complexTypeName, $typeData);
+ $wsdl->addComplexType($complexTypeName);
$wsdl->addMessage(
$outputMessageName,
array(
@@ -306,46 +251,6 @@ protected function _createOperationOutput(Wsdl $wsdl, $operationName, $methodDat
return Wsdl::TYPES_NS . ':' . $outputMessageName;
}
- /**
- * Create an array of items that contain information about method faults.
- *
- * @param Wsdl $wsdl
- * @param string $operationName
- * @param array $methodData
- * @return array array(array('name' => ..., 'message' => ...))
- */
- protected function _createOperationFaults(Wsdl $wsdl, $operationName, $methodData)
- {
- $faults = array();
- if (isset($methodData['interface']['faultComplexTypes'])) {
- foreach ($methodData['interface']['faultComplexTypes'] as $faultName => $faultComplexTypes) {
- $faultMessageName = $this->getFaultMessageName($operationName, $faultName);
- $wsdl->addElement(
- array(
- 'name' => $faultMessageName,
- 'type' => Wsdl::TYPES_NS . ':' . $faultMessageName
- )
- );
- foreach ($faultComplexTypes as $complexTypeNode) {
- $wsdl->addComplexType($complexTypeNode);
- }
- $wsdl->addMessage(
- $faultMessageName,
- array(
- 'messageParameters' => array(
- 'element' => Wsdl::TYPES_NS . ':' . $faultMessageName
- )
- )
- );
- $faults[] = array(
- 'name' => $operationName . $faultName,
- 'message' => Wsdl::TYPES_NS . ':' . $faultMessageName
- );
- }
- }
- return $faults;
- }
-
/**
* Get name of complexType for message element.
*
@@ -436,245 +341,111 @@ public function getOutputMessageName($operationName)
}
/**
- * Get fault message node name for operation.
+ * Collect data about complex types call info.
*
- * @param string $operationName
- * @param string $faultName
- * @return string
- */
- public function getFaultMessageName($operationName, $faultName)
- {
- return $operationName . $faultName . 'Fault';
- }
-
- /**
- * Get complexType name defined in the XSD for requests
+ * Walks through all requested services and checks all methods 'in' and 'out' parameters.
*
- * @param $serviceMethod
- * @return string
- */
- public function getXsdRequestTypeName($serviceMethod)
- {
- return ucfirst($serviceMethod) . "Request";
- }
-
- /**
- * Get complexType name defined in the XSD for responses
- *
- * @param $serviceMethod
- * @return string
- */
- public function getXsdResponseTypeName($serviceMethod)
- {
- return ucfirst($serviceMethod) . "Response";
- }
-
- /**
- * Get info about complex types defined in the XSD for the service method faults.
- *
- * @param string $serviceMethod
- * @param \DOMDocument $domDocument
- * @return array array(array('complexTypeName' => ..., 'faultName' => ...))
+ * @param array $requestedServices
*/
- public function getXsdFaultTypeNames($serviceMethod, $domDocument)
+ protected function _collectCallInfo($requestedServices)
{
- $faultTypeNames = array();
- $xpath = new \DOMXPath($domDocument);
- $serviceMethod = ucfirst($serviceMethod);
- $typeXPath = "//xsd:complexType[starts-with(@name,'{$serviceMethod}') and contains(@name,'Fault')]";
- $complexTypeNodes = $xpath->query($typeXPath);
- /** @var \DOMElement $complexTypeNode */
- foreach ($complexTypeNodes as $complexTypeNode) {
- $complexTypeName = $complexTypeNode->getAttribute('name');
- if (preg_match("/^{$serviceMethod}(\w+)Fault$/", $complexTypeName, $matches)) {
- $faultTypeNames[] = array('complexTypeName' => $complexTypeName, 'faultName' => $matches[1]);
+ foreach ($requestedServices as $serviceName => $serviceData) {
+ foreach ($serviceData['methods'] as $methodName => $methodData) {
+ $this->_processInterfaceCallInfo($methodData['interface'], $serviceName, $methodName);
}
}
- return $faultTypeNames;
}
/**
- * Prepare data about requested service for WSDL generator.
+ * Process call info data from interface.
*
+ * @param array $interface
* @param string $serviceName
- * @return array
- * @throws \Magento\Webapi\Exception
- * @throws \LogicException
+ * @param string $methodName
*/
- protected function _prepareServiceData($serviceName)
+ protected function _processInterfaceCallInfo($interface, $serviceName, $methodName)
{
- $requestedServices = $this->_apiConfig->getRequestedSoapServices(array($serviceName));
- if (empty($requestedServices)) {
- throw new \Magento\Webapi\Exception(
- __('Service %1 is not available.', $serviceName),
- 0,
- \Magento\Webapi\Exception::HTTP_NOT_FOUND
- );
- }
- /** $requestedServices is expected to contain exactly one item */
- $serviceData = reset($requestedServices);
- $serviceDataTypes = array('methods' => array());
- $serviceClass = $serviceData[\Magento\Webapi\Model\Soap\Config::KEY_CLASS];
- foreach ($serviceData['methods'] as $operationData) {
- $methodInterface = array();
- $serviceMethod = $operationData[\Magento\Webapi\Model\Soap\Config::KEY_METHOD];
- /** @var $payloadSchemaDom \DOMDocument */
- $payloadSchemaDom = $this->_apiConfig->getServiceSchemaDOM($serviceClass);
- $operationName = $this->getOperationName($serviceName, $serviceMethod);
-
- /** Process input complex type */
- $inputParameterName = $this->getInputMessageName($operationName);
- $inputComplexTypes = $this->getComplexTypeNodes(
- $serviceName,
- $this->getXsdRequestTypeName($serviceMethod),
- $payloadSchemaDom
- );
- if (empty($inputComplexTypes)) {
- if ($operationData[\Magento\Webapi\Model\Soap\Config::KEY_IS_REQUIRED]) {
- throw new \LogicException(
- sprintf('The method "%s" of service "%s" must have "%s" complex type defined in its schema.',
- $serviceMethod, $serviceName, $inputParameterName)
- );
- } else {
- /** Generate empty input request to make WSDL compliant with WS-I basic profile */
- $inputComplexTypes[] = $this->_generateEmptyComplexType($inputParameterName, $payloadSchemaDom);
+ foreach ($interface as $direction => $interfaceData) {
+ $direction = ($direction == 'in') ? 'requiredInput' : 'returned';
+ foreach ($interfaceData['parameters'] as $parameterData) {
+ $parameterType = $parameterData['type'];
+ if (!$this->_typeProcessor->isTypeSimple($parameterType)) {
+ $operation = $this->getOperationName($serviceName, $methodName);
+ if ($parameterData['required']) {
+ $condition = ($direction == 'requiredInput') ? 'yes' : 'always';
+ } else {
+ $condition = ($direction == 'requiredInput') ? 'no' : 'conditionally';
+ }
+ $callInfo = array();
+ $callInfo[$direction][$condition]['calls'][] = $operation;
+ $this->_typeProcessor->setTypeData($parameterType, array('callInfo' => $callInfo));
}
}
- $methodInterface['inputComplexTypes'] = $inputComplexTypes;
-
- /** Process output complex type */
- $outputParameterName = $this->getOutputMessageName($operationName);
- $outputComplexTypes = $this->getComplexTypeNodes(
- $serviceName,
- $this->getXsdResponseTypeName($serviceMethod),
- $payloadSchemaDom
- );
- if (!empty($outputComplexTypes)) {
- $methodInterface['outputComplexTypes'] = $outputComplexTypes;
- } else {
- throw new \LogicException(
- sprintf('The method "%s" of service "%s" must have "%s" complex type defined in its schema.',
- $serviceMethod, $serviceName, $outputParameterName)
- );
- }
-
- /** Process fault complex types */
- foreach ($this->getXsdFaultTypeNames($serviceMethod, $payloadSchemaDom) as $faultComplexType) {
- $faultComplexTypes = $this->_getFaultComplexTypeNodes(
- $serviceName,
- $faultComplexType['complexTypeName'],
- $payloadSchemaDom
- );
- if (!empty($faultComplexTypes)) {
- $methodInterface['faultComplexTypes'][$faultComplexType['faultName']] = $faultComplexTypes;
- }
- }
- $serviceDataTypes['methods'][$serviceMethod]['interface'] = $methodInterface;
}
- return $serviceDataTypes;
}
/**
- * Add WSDL elements related to default SOAP fault, which are common for all operations: element, type and message.
+ * Add WSDL elements related to generic SOAP fault, which are common for all operations: element, type and message.
*
* @param Wsdl $wsdl
- * @return \DOMNode[]
+ * @return string Default fault message name
*/
- protected function _addDefaultFaultComplexTypeNodes($wsdl)
+ protected function _addGenericFaultComplexTypeNodes($wsdl)
{
- $domDocument = new \DOMDocument();
- $typeName = Fault::NODE_DETAIL_WRAPPER;
- $defaultFault = $this->_generateEmptyComplexType($typeName, $domDocument);
- $elementName = Fault::NODE_DETAIL_WRAPPER;
- $wsdl->addElement(array('name' => $elementName, 'type' => Wsdl::TYPES_NS . ':' . $typeName));
+ $faultMessageName = Fault::NODE_DETAIL_WRAPPER;
+ $complexTypeName = $this->getElementComplexTypeName($faultMessageName);
+ $wsdl->addElement(
+ array(
+ 'name' => $faultMessageName,
+ 'type' => Wsdl::TYPES_NS . ':' . $complexTypeName
+ )
+ );
+ $faultParamsComplexType = Fault::NODE_DETAIL_PARAMETER;
+ $faultParamsData = array(
+ 'parameters' => array(
+ Fault::NODE_DETAIL_PARAMETER_KEY => array(
+ 'type' => 'string',
+ 'required' => true,
+ 'documentation' => '',
+ ),
+ Fault::NODE_DETAIL_PARAMETER_VALUE => array(
+ 'type' => 'string',
+ 'required' => true,
+ 'documentation' => '',
+ )
+ )
+ );
+ $genericFaultTypeData = array(
+ 'parameters' => array(
+ Fault::NODE_DETAIL_CODE => array(
+ 'type' => 'int',
+ 'required' => true,
+ 'documentation' => 'SOAP fault code, unique for each type of exceptions.',
+ ),
+ Fault::NODE_DETAIL_TRACE => array(
+ 'type' => 'string',
+ 'required' => false,
+ 'documentation' => 'Exception calls stack trace.',
+ ),
+ Fault::NODE_DETAIL_PARAMETERS => array(
+ 'type' => "{$faultParamsComplexType}[]",
+ 'required' => false,
+ 'documentation' => 'Additional exception parameters.',
+ )
+ )
+ );
+ $this->_typeProcessor->setTypeData($faultParamsComplexType, $faultParamsData);
+ $this->_typeProcessor->setTypeData($complexTypeName, $genericFaultTypeData);
+ $wsdl->addComplexType($complexTypeName);
$wsdl->addMessage(
- $this->_getDefaultFaultMessageName(),
- array('messageParameters' => array('element' => Wsdl::TYPES_NS . ':' . $elementName))
+ $faultMessageName,
+ array(
+ 'messageParameters' => array(
+ 'element' => Wsdl::TYPES_NS . ':' . $faultMessageName
+ )
+ )
);
- $this->_addDefaultFaultElements($defaultFault);
- $wsdl->addComplexType($defaultFault);
- }
- /**
- * Generate all necessary complex types for the fault of specified type.
- *
- * @param string $serviceName
- * @param string $typeName
- * @param \DOMDocument $domDocument
- * @return \DOMNode[]
- */
- protected function _getFaultComplexTypeNodes($serviceName, $typeName, $domDocument)
- {
- $complexTypesNodes = $this->getComplexTypeNodes($serviceName, $typeName, $domDocument);
- $faultTypeName = $serviceName . $typeName;
- $paramsTypeName = $faultTypeName . 'Params';
- if (isset($complexTypesNodes[$faultTypeName])) {
- /** Rename fault complex type to fault param complex type */
- $faultComplexType = $complexTypesNodes[$faultTypeName];
- $faultComplexType->setAttribute('name', $paramsTypeName);
- $complexTypesNodes[$paramsTypeName] = $complexTypesNodes[$faultTypeName];
-
- /** Create new fault complex type, which will contain reference to fault param complex type */
- $newFaultComplexType = $this->_generateEmptyComplexType($faultTypeName, $domDocument);
- $this->_addDefaultFaultElements($newFaultComplexType);
- /** Create 'Parameters' element and use fault param complex type as its type */
- $parametersElement = $domDocument->createElement('xsd:element');
- $parametersElement->setAttribute('name', Fault::NODE_DETAIL_PARAMETERS);
- $parametersElement->setAttribute('type', Wsdl::TYPES_NS . ':' . $paramsTypeName);
- $newFaultComplexType->firstChild->appendChild($parametersElement);
-
- $complexTypesNodes[$faultTypeName] = $newFaultComplexType;
- }
- return $complexTypesNodes;
- }
-
- /**
- * Generate empty complex type with the specified name.
- *
- * @param string $complexTypeName
- * @param \DOMDocument $domDocument
- * @return \DOMElement
- */
- protected function _generateEmptyComplexType($complexTypeName, $domDocument)
- {
- $complexTypeNode = $domDocument->createElement('xsd:complexType');
- $complexTypeNode->setAttribute('name', $complexTypeName);
- $xsdNamespace = 'http://www.w3.org/2001/XMLSchema';
- $complexTypeNode->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:xsd', $xsdNamespace);
- $domDocument->appendChild($complexTypeNode);
- $sequenceNode = $domDocument->createElement('xsd:sequence');
- $complexTypeNode->appendChild($sequenceNode);
- return $complexTypeNode;
- }
-
- /**
- * Add 'Detail' and 'Trace' elements to the fault element.
- *
- * @param \DOMElement $faultElement
- */
- protected function _addDefaultFaultElements($faultElement)
- {
- /** Create 'Code' element */
- $codeElement = $faultElement->ownerDocument->createElement('xsd:element');
- $codeElement->setAttribute('name', Fault::NODE_DETAIL_CODE);
- $codeElement->setAttribute('type', 'xsd:int');
- $faultElement->firstChild->appendChild($codeElement);
-
- /** Create 'Trace' element */
- $traceElement = $faultElement->ownerDocument->createElement('xsd:element');
- $traceElement->setAttribute('name', Fault::NODE_DETAIL_TRACE);
- $traceElement->setAttribute('type', 'xsd:string');
- $traceElement->setAttribute('minOccurs', '0');
- $faultElement->firstChild->appendChild($traceElement);
- }
-
- /**
- * Retrieve name of default SOAP fault message name in WSDL.
- *
- * @return string
- */
- protected function _getDefaultFaultMessageName()
- {
- return Fault::NODE_DETAIL_WRAPPER;
+ return Wsdl::TYPES_NS . ':' . $faultMessageName;
}
}
diff --git a/app/code/Magento/Webapi/etc/di.xml b/app/code/Magento/Webapi/etc/di.xml
index 48f019da28b05..c981e05a523d7 100644
--- a/app/code/Magento/Webapi/etc/di.xml
+++ b/app/code/Magento/Webapi/etc/di.xml
@@ -26,14 +26,18 @@
-
-
- rest
-
-
- soap
-
-
+
+ -
+
+
- rest
+
+
+ -
+
+
- soap
+
+
+
diff --git a/app/code/Magento/Webapi/etc/webapi_rest/di.xml b/app/code/Magento/Webapi/etc/webapi_rest/di.xml
index 0ff022f4deaf2..a4b50fa47bff2 100644
--- a/app/code/Magento/Webapi/etc/webapi_rest/di.xml
+++ b/app/code/Magento/Webapi/etc/webapi_rest/di.xml
@@ -34,50 +34,68 @@
-
-
- application/json
- Magento\Webapi\Controller\Rest\Request\Deserializer\Json
-
-
- application/xml
- Magento\Webapi\Controller\Rest\Request\Deserializer\Xml
-
-
- application/xhtml+xml
- Magento\Webapi\Controller\Rest\Request\Deserializer\Xml
-
-
- text/xml
- Magento\Webapi\Controller\Rest\Request\Deserializer\Xml
-
-
+
+ -
+
+
- application/json
+ - Magento\Webapi\Controller\Rest\Request\Deserializer\Json
+
+
+ -
+
+
- application/xml
+ - Magento\Webapi\Controller\Rest\Request\Deserializer\Xml
+
+
+ -
+
+
- application/xhtml+xml
+ - Magento\Webapi\Controller\Rest\Request\Deserializer\Xml
+
+
+ -
+
+
- text/xml
+ - Magento\Webapi\Controller\Rest\Request\Deserializer\Xml
+
+
+
-
-
- */*
- Magento\Webapi\Controller\Rest\Response\Renderer\Json
-
-
- application/json
- Magento\Webapi\Controller\Rest\Response\Renderer\Json
-
-
- text/xml
- Magento\Webapi\Controller\Rest\Response\Renderer\Xml
-
-
- application/xml
- Magento\Webapi\Controller\Rest\Response\Renderer\Xml
-
-
- application/xhtml+xml
- Magento\Webapi\Controller\Rest\Response\Renderer\Xml
-
-
+
+ -
+
+
- */*
+ - Magento\Webapi\Controller\Rest\Response\Renderer\Json
+
+
+ -
+
+
- application/json
+ - Magento\Webapi\Controller\Rest\Response\Renderer\Json
+
+
+ -
+
+
- text/xml
+ - Magento\Webapi\Controller\Rest\Response\Renderer\Xml
+
+
+ -
+
+
- application/xml
+ - Magento\Webapi\Controller\Rest\Response\Renderer\Xml
+
+
+ -
+
+
- application/xhtml+xml
+ - Magento\Webapi\Controller\Rest\Response\Renderer\Xml
+
+
+
diff --git a/app/code/Magento/Webapi/etc/webapi_soap/di.xml b/app/code/Magento/Webapi/etc/webapi_soap/di.xml
index 836d05317eed0..f98dd0fc07df4 100644
--- a/app/code/Magento/Webapi/etc/webapi_soap/di.xml
+++ b/app/code/Magento/Webapi/etc/webapi_soap/di.xml
@@ -40,7 +40,7 @@
-
+
diff --git a/app/code/Magento/Weee/Model/Attribute/Backend/Weee/Tax.php b/app/code/Magento/Weee/Model/Attribute/Backend/Weee/Tax.php
index 005495c828160..4d5efa77bd4eb 100644
--- a/app/code/Magento/Weee/Model/Attribute/Backend/Weee/Tax.php
+++ b/app/code/Magento/Weee/Model/Attribute/Backend/Weee/Tax.php
@@ -48,7 +48,7 @@ class Tax extends \Magento\Catalog\Model\Product\Attribute\Backend\Price
* @param \Magento\Directory\Model\CurrencyFactory $currencyFactory
* @param \Magento\Core\Model\StoreManagerInterface $storeManager
* @param \Magento\Catalog\Helper\Data $catalogData
- * @param \Magento\Core\Model\Config $config
+ * @param \Magento\App\ConfigInterface $config
* @param \Magento\Directory\Helper\Data $directoryHelper
* @param \Magento\Weee\Model\Resource\Attribute\Backend\Weee\Tax $attributeTax
*/
@@ -57,7 +57,7 @@ public function __construct(
\Magento\Directory\Model\CurrencyFactory $currencyFactory,
\Magento\Core\Model\StoreManagerInterface $storeManager,
\Magento\Catalog\Helper\Data $catalogData,
- \Magento\Core\Model\Config $config,
+ \Magento\App\ConfigInterface $config,
\Magento\Directory\Helper\Data $directoryHelper,
\Magento\Weee\Model\Resource\Attribute\Backend\Weee\Tax $attributeTax
) {
diff --git a/app/code/Magento/Weee/Model/Observer.php b/app/code/Magento/Weee/Model/Observer.php
index 7ddee5c048ecf..babc527a64bfa 100644
--- a/app/code/Magento/Weee/Model/Observer.php
+++ b/app/code/Magento/Weee/Model/Observer.php
@@ -50,13 +50,19 @@ class Observer extends \Magento\Core\Model\AbstractModel
*/
protected $_layout;
+ /**
+ * @var \Magento\Catalog\Model\ProductTypes\ConfigInterface
+ */
+ protected $productTypeConfig;
+
/**
* @param \Magento\Core\Model\Context $context
* @param \Magento\Core\Model\Registry $registry
* @param \Magento\View\LayoutInterface $layout
- * @param \Magento\Weee\Model\Tax $weeeTax
+ * @param Tax $weeeTax
* @param \Magento\Weee\Helper\Data $weeeData
* @param \Magento\Catalog\Model\Product\Type $productType
+ * @param \Magento\Catalog\Model\ProductTypes\ConfigInterface $productTypeConfig
* @param \Magento\Core\Model\Resource\AbstractResource $resource
* @param \Magento\Data\Collection\Db $resourceCollection
* @param array $data
@@ -68,6 +74,7 @@ public function __construct(
\Magento\Weee\Model\Tax $weeeTax,
\Magento\Weee\Helper\Data $weeeData,
\Magento\Catalog\Model\Product\Type $productType,
+ \Magento\Catalog\Model\ProductTypes\ConfigInterface $productTypeConfig,
\Magento\Core\Model\Resource\AbstractResource $resource = null,
\Magento\Data\Collection\Db $resourceCollection = null,
array $data = array()
@@ -76,6 +83,7 @@ public function __construct(
$this->_weeeTax = $weeeTax;
$this->_productType = $productType;
$this->_weeeData = $weeeData;
+ $this->productTypeConfig = $productTypeConfig;
parent::__construct($context, $registry, $resource, $resourceCollection, $data);
}
@@ -158,9 +166,6 @@ public function addWeeeTaxAttributeType(\Magento\Event\Observer $observer)
'_default_value',
'_front_fieldset',
),
- 'disabled_types' => array(
- \Magento\GroupedProduct\Model\Product\Type\Grouped::TYPE_CODE,
- )
);
$response->setTypes($types);
@@ -184,7 +189,7 @@ public function assignBackendModelToAttribute(\Magento\Event\Observer $observer)
if (!$object->getApplyTo()) {
$applyTo = array();
foreach ($this->_productType->getOptions() as $option) {
- if ($option['value'] == \Magento\GroupedProduct\Model\Product\Type\Grouped::TYPE_CODE) {
+ if ($this->productTypeConfig->isProductSet($option['value'])) {
continue;
}
$applyTo[] = $option['value'];
@@ -199,7 +204,8 @@ public function assignBackendModelToAttribute(\Magento\Event\Observer $observer)
/**
* Add custom element type for attributes form
*
- * @param \Magento\Event\Observer $observer
+ * @param \Magento\Event\Observer $observer
+ * @return \Magento\Weee\Model\Observer
*/
public function updateElementTypes(\Magento\Event\Observer $observer)
{
diff --git a/app/code/Magento/Weee/etc/di.xml b/app/code/Magento/Weee/etc/di.xml
index d57ab7dc70f3e..0dda633d0ca47 100644
--- a/app/code/Magento/Weee/etc/di.xml
+++ b/app/code/Magento/Weee/etc/di.xml
@@ -42,9 +42,9 @@
-
- Magento\Sales\Model\Resource\Setup
-
+
+ - Magento\Sales\Model\Resource\Setup
+
diff --git a/app/code/Magento/Weee/etc/module.xml b/app/code/Magento/Weee/etc/module.xml
index 6d8f60b135c53..0f4adb9404d23 100644
--- a/app/code/Magento/Weee/etc/module.xml
+++ b/app/code/Magento/Weee/etc/module.xml
@@ -41,7 +41,6 @@
-
diff --git a/app/code/Magento/Widget/Model/Widget/Config.php b/app/code/Magento/Widget/Model/Widget/Config.php
index 198f32cdf4fb4..1dc177919a515 100644
--- a/app/code/Magento/Widget/Model/Widget/Config.php
+++ b/app/code/Magento/Widget/Model/Widget/Config.php
@@ -40,7 +40,7 @@ class Config
protected $_widget;
/**
- * @var \Magento\Backend\Model\Url
+ * @var \Magento\Backend\Model\UrlInterface
*/
protected $_backendUrl;
@@ -55,13 +55,13 @@ class Config
protected $_widgetFactory;
/**
- * @param \Magento\Backend\Model\Url $backendUrl
+ * @param \Magento\Backend\Model\UrlInterface $backendUrl
* @param \Magento\Core\Helper\Data $coreHelper
* @param \Magento\View\Url $viewUrl
* @param \Magento\Widget\Model\WidgetFactory $widgetFactory
*/
public function __construct(
- \Magento\Backend\Model\Url $backendUrl,
+ \Magento\Backend\Model\UrlInterface $backendUrl,
\Magento\Core\Helper\Data $coreHelper,
\Magento\View\Url $viewUrl,
\Magento\Widget\Model\WidgetFactory $widgetFactory
diff --git a/app/code/Magento/Widget/etc/adminhtml/di.xml b/app/code/Magento/Widget/etc/adminhtml/di.xml
index 74be126898b9b..df83b22764ac4 100644
--- a/app/code/Magento/Widget/etc/adminhtml/di.xml
+++ b/app/code/Magento/Widget/etc/adminhtml/di.xml
@@ -26,10 +26,10 @@
-
- block_html
- layout
-
+
+ - block_html
+ - layout
+
diff --git a/app/code/Magento/Widget/etc/di.xml b/app/code/Magento/Widget/etc/di.xml
index deb5095121387..9c37d60bbab66 100644
--- a/app/code/Magento/Widget/etc/di.xml
+++ b/app/code/Magento/Widget/etc/di.xml
@@ -53,9 +53,9 @@
-
- Magento\Core\Model\Resource\Setup\Generic
-
+
+ - Magento\Core\Model\Resource\Setup\Generic
+
diff --git a/app/code/Magento/Wishlist/Block/Share/Email/Items.php b/app/code/Magento/Wishlist/Block/Share/Email/Items.php
index 8253de85176f7..0d331f2d7908c 100644
--- a/app/code/Magento/Wishlist/Block/Share/Email/Items.php
+++ b/app/code/Magento/Wishlist/Block/Share/Email/Items.php
@@ -47,7 +47,7 @@ class Items extends \Magento\Wishlist\Block\AbstractBlock
*/
public function getProductUrl($product, $additional = array())
{
- $additional['_store_to_url'] = true;
+ $additional['_scope_to_url'] = true;
return parent::getProductUrl($product, $additional);
}
@@ -61,7 +61,7 @@ public function getProductUrl($product, $additional = array())
public function getAddToCartUrl($product, $additional = array())
{
$additional['nocookie'] = 1;
- $additional['_store_to_url'] = true;
+ $additional['_scope_to_url'] = true;
return parent::getAddToCartUrl($product, $additional);
}
diff --git a/app/code/Magento/Wishlist/Controller/AbstractController.php b/app/code/Magento/Wishlist/Controller/AbstractController.php
index 2057f16ac78d6..85a1e808b0e86 100644
--- a/app/code/Magento/Wishlist/Controller/AbstractController.php
+++ b/app/code/Magento/Wishlist/Controller/AbstractController.php
@@ -151,7 +151,7 @@ public function allcartAction()
if ($isOwner) {
$indexUrl = $this->_objectManager->get('Magento\Wishlist\Helper\Data')->getListUrl($wishlist->getId());
} else {
- $indexUrl = $this->_objectManager->create('Magento\Core\Model\Url')
+ $indexUrl = $this->_objectManager->create('Magento\UrlInterface')
->getUrl('wishlist/shared', array('code' => $wishlist->getSharingCode()));
}
if ($this->_objectManager->get('Magento\Checkout\Helper\Cart')->getShouldRedirectToCart()) {
diff --git a/app/code/Magento/Wishlist/Helper/Data.php b/app/code/Magento/Wishlist/Helper/Data.php
index e3db7e1738ce4..1038fa3166746 100644
--- a/app/code/Magento/Wishlist/Helper/Data.php
+++ b/app/code/Magento/Wishlist/Helper/Data.php
@@ -389,7 +389,7 @@ public function getAddToCartUrl($item)
$this->_getUrl('*/*/*', array(
'_current' => true,
'_use_rewrite' => true,
- '_store_to_url' => true,
+ '_scope_to_url' => true,
))
);
@@ -412,7 +412,7 @@ public function getSharedAddToCartUrl($item)
$continueUrl = $this->_coreData->urlEncode($this->_getUrl('*/*/*', array(
'_current' => true,
'_use_rewrite' => true,
- '_store_to_url' => true,
+ '_scope_to_url' => true,
)));
$urlParamName = \Magento\App\Action\Action::PARAM_NAME_URL_ENCODED;
diff --git a/app/code/Magento/Wishlist/Model/Item.php b/app/code/Magento/Wishlist/Model/Item.php
index 9725b930f0e95..dd5e0bcb807c3 100644
--- a/app/code/Magento/Wishlist/Model/Item.php
+++ b/app/code/Magento/Wishlist/Model/Item.php
@@ -131,6 +131,11 @@ class Item extends \Magento\Core\Model\AbstractModel
*/
protected $_wishlOptionCollectionFactory;
+ /**
+ * @var \Magento\Catalog\Model\ProductTypes\ConfigInterface
+ */
+ protected $productTypeConfig;
+
/**
* @param \Magento\Core\Model\Context $context
* @param \Magento\Core\Model\Registry $registry
@@ -138,8 +143,9 @@ class Item extends \Magento\Core\Model\AbstractModel
* @param \Magento\Core\Model\Date $date
* @param \Magento\Catalog\Model\ProductFactory $productFactory
* @param \Magento\Catalog\Model\Resource\Url $catalogUrl
- * @param \Magento\Wishlist\Model\Item\OptionFactory $wishlistOptFactory
- * @param \Magento\Wishlist\Model\Resource\Item\Option\CollectionFactory $wishlOptionCollectionFactory
+ * @param Item\OptionFactory $wishlistOptFactory
+ * @param Resource\Item\Option\CollectionFactory $wishlOptionCollectionFactory
+ * @param \Magento\Catalog\Model\ProductTypes\ConfigInterface $productTypeConfig
* @param \Magento\Core\Model\Resource\AbstractResource $resource
* @param \Magento\Data\Collection\Db $resourceCollection
* @param array $data
@@ -153,10 +159,12 @@ public function __construct(
\Magento\Catalog\Model\Resource\Url $catalogUrl,
\Magento\Wishlist\Model\Item\OptionFactory $wishlistOptFactory,
\Magento\Wishlist\Model\Resource\Item\Option\CollectionFactory $wishlOptionCollectionFactory,
+ \Magento\Catalog\Model\ProductTypes\ConfigInterface $productTypeConfig,
\Magento\Core\Model\Resource\AbstractResource $resource = null,
\Magento\Data\Collection\Db $resourceCollection = null,
array $data = array()
) {
+ $this->productTypeConfig = $productTypeConfig;
$this->_storeManager = $storeManager;
$this->_date = $date;
$this->_productFactory = $productFactory;
@@ -474,7 +482,6 @@ public function getBuyRequest()
$option = $this->getOptionByCode('info_buyRequest');
$initialData = $option ? unserialize($option->getValue()) : null;
- // There can be wrong data due to bug in Grouped products - it formed 'info_buyRequest' as \Magento\Object
if ($initialData instanceof \Magento\Object) {
$initialData = $initialData->getData();
}
@@ -724,7 +731,7 @@ public function getOptionByCode($code)
public function canHaveQty()
{
$product = $this->getProduct();
- return $product->getTypeId() != \Magento\GroupedProduct\Model\Product\Type\Grouped::TYPE_CODE;
+ return !$this->productTypeConfig->isProductSet($product->getTypeId());
}
/**
diff --git a/app/code/Magento/Wishlist/etc/frontend/di.xml b/app/code/Magento/Wishlist/etc/frontend/di.xml
index 6ebfe13ebf1a1..c20d0f98265cf 100644
--- a/app/code/Magento/Wishlist/etc/frontend/di.xml
+++ b/app/code/Magento/Wishlist/etc/frontend/di.xml
@@ -44,16 +44,16 @@
-
- /wishlist/
-
+
+ - /wishlist/
+
-
- add
-
+
+ - add
+
diff --git a/app/etc/di.xml b/app/etc/di.xml
index 741d3dfa0e95a..f0700b2a744a7 100644
--- a/app/etc/di.xml
+++ b/app/etc/di.xml
@@ -30,7 +30,7 @@
-
+
@@ -40,12 +40,12 @@
-
+
-
+
@@ -64,6 +64,7 @@
+
@@ -84,9 +85,9 @@
-
- Magento\Session\SaveHandler\DbTable
-
+
+ - Magento\Session\SaveHandler\DbTable
+
@@ -116,14 +117,14 @@
-
+
Magento\App\State::PARAM_MODE
-
+
- Magento\App\Config\Loader::PARAM_CUSTOM_FILE
+ Magento\App\Arguments\Loader::PARAM_CUSTOM_FILE
@@ -133,17 +134,21 @@
- Magento\Core\Model\App::PARAM_CACHE_OPTIONS
+ Magento\Core\Model\App::PARAM_CACHE_FORCED_OPTIONS
-
-
- Magento\Cache\Frontend\Decorator\TagScope
-
- MAGE
-
-
-
+
+ -
+
+
- Magento\Cache\Frontend\Decorator\TagScope
+ -
+
+
- MAGE
+
+
+
+
+
@@ -167,11 +172,6 @@
-
-
-
-
-
@@ -221,9 +221,9 @@
plugin-list
-
- global
-
+
+ - global
+
@@ -252,31 +252,39 @@
-
+
-
-
- Magento\Core\Model\Store::URL_TYPE_LIB
- Magento\App\Filesystem::PUB_LIB_DIR
-
-
- Magento\Core\Model\Store::URL_TYPE_MEDIA
- Magento\App\Filesystem::MEDIA_DIR
-
-
- Magento\Core\Model\Store::URL_TYPE_STATIC
- Magento\App\Filesystem::STATIC_VIEW_DIR
-
-
- Magento\Core\Model\Store::URL_TYPE_CACHE
- Magento\App\Filesystem::PUB_VIEW_CACHE_DIR
-
-
+
+ -
+
+
- Magento\UrlInterface::URL_TYPE_LIB
+ - Magento\App\Filesystem::PUB_LIB_DIR
+
+
+ -
+
+
- Magento\UrlInterface::URL_TYPE_MEDIA
+ - Magento\App\Filesystem::MEDIA_DIR
+
+
+ -
+
+
- Magento\UrlInterface::URL_TYPE_STATIC
+ - Magento\App\Filesystem::STATIC_VIEW_DIR
+
+
+ -
+
+
- Magento\UrlInterface::URL_TYPE_CACHE
+ - Magento\App\Filesystem::PUB_VIEW_CACHE_DIR
+
+
+
@@ -297,16 +305,24 @@
-
-
- Magento\Core\Model\Layout\Argument\Handler\Options
- Magento\Core\Model\Layout\Argument\Handler\Url
- Magento\Core\Model\Layout\Argument\Handler\ArrayHandler
- Magento\Core\Model\Layout\Argument\Handler\Boolean
- Magento\Core\Model\Layout\Argument\Handler\Helper
- Magento\Core\Model\Layout\Argument\Handler\Number
- Magento\Core\Model\Layout\Argument\Handler\String
-
+
+ - Magento\Core\Model\Layout\Argument\Handler\Object
+ - Magento\Core\Model\Layout\Argument\Handler\Options
+ - Magento\Core\Model\Layout\Argument\Handler\Url
+ - Magento\Core\Model\Layout\Argument\Handler\ArrayHandler
+ - Magento\Core\Model\Layout\Argument\Handler\Boolean
+ - Magento\Core\Model\Layout\Argument\Handler\Helper
+ - Magento\Core\Model\Layout\Argument\Handler\Number
+ - Magento\Core\Model\Layout\Argument\Handler\String
+
+
+
+
+
+
+
+
+
diff --git a/dev/shell/newindexer.php b/dev/shell/newindexer.php
new file mode 100644
index 0000000000000..224444eed58e3
--- /dev/null
+++ b/dev/shell/newindexer.php
@@ -0,0 +1,36 @@
+ 'admin',
+ \Magento\Core\Model\App::PARAM_RUN_TYPE => 'store',
+);
+
+$entryPoint = new \Magento\App\EntryPoint\EntryPoint(BP, $params);
+$entryPoint->run('Magento\Indexer\App\Shell', array(
+ 'entryFileName' => basename(__FILE__),
+));
diff --git a/dev/tests/integration/framework/Magento/TestFramework/Annotation/ConfigFixture.php b/dev/tests/integration/framework/Magento/TestFramework/Annotation/ConfigFixture.php
index 3a63194fbfd84..994f8aa334f96 100644
--- a/dev/tests/integration/framework/Magento/TestFramework/Annotation/ConfigFixture.php
+++ b/dev/tests/integration/framework/Magento/TestFramework/Annotation/ConfigFixture.php
@@ -85,7 +85,7 @@ protected function _setConfigValue($configPath, $value, $storeCode = false)
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
if (strpos($configPath, 'default/') === 0) {
$configPath = substr($configPath, 8);
- $objectManager->get('Magento\Core\Model\Config')->setValue($configPath, $value);
+ $objectManager->get('Magento\App\ConfigInterface')->setValue($configPath, $value);
}
} else {
\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Core\Model\StoreManagerInterface')
diff --git a/dev/tests/integration/framework/Magento/TestFramework/Application.php b/dev/tests/integration/framework/Magento/TestFramework/Application.php
index a8ac17b9701cf..24fc545255d18 100644
--- a/dev/tests/integration/framework/Magento/TestFramework/Application.php
+++ b/dev/tests/integration/framework/Magento/TestFramework/Application.php
@@ -285,7 +285,7 @@ public function run()
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
/** @var \Magento\App\Http $app */
$app = $objectManager->get('Magento\App\Http');
- $response = $app->execute();
+ $response = $app->launch();
$response->sendResponse();
}
diff --git a/dev/tests/integration/framework/Magento/TestFramework/ObjectManagerFactory.php b/dev/tests/integration/framework/Magento/TestFramework/ObjectManagerFactory.php
index 0b3b92cd05f0b..103b28f3693a6 100644
--- a/dev/tests/integration/framework/Magento/TestFramework/ObjectManagerFactory.php
+++ b/dev/tests/integration/framework/Magento/TestFramework/ObjectManagerFactory.php
@@ -94,12 +94,12 @@ public function restore(ObjectManager $objectManager, $rootDir, array $arguments
),
));
- $options = new \Magento\App\Config(
+ $options = new \Magento\App\Arguments(
$arguments,
- new \Magento\App\Config\Loader($directoryList)
+ new \Magento\App\Arguments\Loader($directoryList)
);
- $objectManager->addSharedInstance($options, 'Magento\App\Config');
+ $objectManager->addSharedInstance($options, 'Magento\App\Arguments');
$objectManager->getFactory()->setArguments($options->get());
$objectManager->configure(
$objectManager->get('Magento\App\ObjectManager\ConfigLoader')->load('global')
diff --git a/dev/tests/integration/framework/Magento/TestFramework/TestCase/AbstractConfigFiles.php b/dev/tests/integration/framework/Magento/TestFramework/TestCase/AbstractConfigFiles.php
index 6bc49bb751558..066eb5d8ca449 100644
--- a/dev/tests/integration/framework/Magento/TestFramework/TestCase/AbstractConfigFiles.php
+++ b/dev/tests/integration/framework/Magento/TestFramework/TestCase/AbstractConfigFiles.php
@@ -54,7 +54,7 @@ public function setUp()
$xmlFiles = $this->getXmlConfigFiles();
if (!empty($xmlFiles)) {
- $this->_fileResolverMock = $this->getMockBuilder('Magento\App\Config\FileResolver\Primary')
+ $this->_fileResolverMock = $this->getMockBuilder('Magento\App\Arguments\FileResolver\Primary')
->disableOriginalConstructor()->getMock();
/* Enable Validation regardles of MAGE_MODE */
diff --git a/dev/tests/integration/testsuite/Magento/App/Cache/Frontend/PoolTest.php b/dev/tests/integration/testsuite/Magento/App/Cache/Frontend/PoolTest.php
deleted file mode 100644
index 2f505766f2812..0000000000000
--- a/dev/tests/integration/testsuite/Magento/App/Cache/Frontend/PoolTest.php
+++ /dev/null
@@ -1,64 +0,0 @@
- $cacheBackendName);
- $this->_model = new \Magento\App\Cache\Frontend\Pool(
- \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
- ->create('Magento\App\Cache\Frontend\Factory'),
- $settings
- );
-
-
- $cache = $this->_model->get(\Magento\App\Cache\Frontend\Pool::DEFAULT_FRONTEND_ID);
- $this->assertInstanceOf('Magento\Cache\FrontendInterface', $cache);
- $this->assertInstanceOf('Zend_Cache_Backend_Interface', $cache->getBackend());
- }
-
- public function cacheBackendDataProvider()
- {
- return array(
- array('sqlite'),
- array('memcached'),
- array('apc'),
- array('xcache'),
- array('eaccelerator'),
- array('database'),
- array('File'),
- array('')
- );
- }
-}
diff --git a/dev/tests/integration/testsuite/Magento/Backend/App/AbstractActionTest.php b/dev/tests/integration/testsuite/Magento/Backend/App/AbstractActionTest.php
index d4a0abd7aa441..71541542828ce 100644
--- a/dev/tests/integration/testsuite/Magento/Backend/App/AbstractActionTest.php
+++ b/dev/tests/integration/testsuite/Magento/Backend/App/AbstractActionTest.php
@@ -39,9 +39,9 @@ public function testPreDispatchWithEmptyUrlRedirectsToStartupPage()
\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Config\ScopeInterface')
->setCurrentScope(\Magento\Backend\App\Area\FrontNameResolver::AREA_CODE);
$this->dispatch('backend');
- /** @var $backendUrlModel \Magento\Backend\Model\Url */
+ /** @var $backendUrlModel \Magento\Backend\Model\UrlInterface */
$backendUrlModel =
- \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Backend\Model\Url');
+ \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Backend\Model\UrlInterface');
$url = $backendUrlModel->getStartupPageUrl();
$expected = $backendUrlModel->getUrl($url);
$this->assertRedirect($this->stringStartsWith($expected));
diff --git a/dev/tests/integration/testsuite/Magento/Backend/Block/_files/form_key_disabled.php b/dev/tests/integration/testsuite/Magento/Backend/Block/_files/form_key_disabled.php
index a77587caaddbe..c1e11729087b8 100644
--- a/dev/tests/integration/testsuite/Magento/Backend/Block/_files/form_key_disabled.php
+++ b/dev/tests/integration/testsuite/Magento/Backend/Block/_files/form_key_disabled.php
@@ -25,4 +25,6 @@
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
-\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Backend\Model\Url')->turnOffSecretKey();
+\Magento\TestFramework\Helper\Bootstrap::getObjectManager()
+ ->get('Magento\Backend\Model\UrlInterface')
+ ->turnOffSecretKey();
diff --git a/dev/tests/integration/testsuite/Magento/Backend/Block/_files/form_key_disabled_rollback.php b/dev/tests/integration/testsuite/Magento/Backend/Block/_files/form_key_disabled_rollback.php
index c21363e308a76..6c4cba7cea101 100644
--- a/dev/tests/integration/testsuite/Magento/Backend/Block/_files/form_key_disabled_rollback.php
+++ b/dev/tests/integration/testsuite/Magento/Backend/Block/_files/form_key_disabled_rollback.php
@@ -25,4 +25,6 @@
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
-\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Backend\Model\Url')->turnOnSecretKey();
+\Magento\TestFramework\Helper\Bootstrap::getObjectManager()
+ ->get('Magento\Backend\Model\UrlInterface')
+ ->turnOnSecretKey();
diff --git a/dev/tests/integration/testsuite/Magento/Backend/Controller/Adminhtml/AuthTest.php b/dev/tests/integration/testsuite/Magento/Backend/Controller/Adminhtml/AuthTest.php
index 3eeccffb45b33..be170ad67df51 100644
--- a/dev/tests/integration/testsuite/Magento/Backend/Controller/Adminhtml/AuthTest.php
+++ b/dev/tests/integration/testsuite/Magento/Backend/Controller/Adminhtml/AuthTest.php
@@ -55,7 +55,7 @@ protected function tearDown()
*/
protected function _login()
{
- \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Backend\Model\Url')
+ \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Backend\Model\UrlInterface')
->turnOffSecretKey();
$this->_auth = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Backend\Model\Auth');
@@ -71,7 +71,7 @@ protected function _logout()
{
$this->_auth->logout();
\Magento\TestFramework\Helper\Bootstrap::getObjectManager()
- ->get('Magento\Backend\Model\Url')->turnOnSecretKey();
+ ->get('Magento\Backend\Model\UrlInterface')->turnOnSecretKey();
}
/**
@@ -98,9 +98,9 @@ public function testLoggedLoginAction()
$this->_login();
$this->dispatch('backend/admin/auth/login');
- /** @var $backendUrlModel \Magento\Backend\Model\Url */
+ /** @var $backendUrlModel \Magento\Backend\Model\UrlInterface */
$backendUrlModel = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
- ->get('Magento\Backend\Model\Url');
+ ->get('Magento\Backend\Model\UrlInterface');
$url = $backendUrlModel->getStartupPageUrl();
$expected = $backendUrlModel->getUrl($url);
$this->assertRedirect($this->stringStartsWith($expected));
diff --git a/dev/tests/integration/testsuite/Magento/Backend/Helper/DataTest.php b/dev/tests/integration/testsuite/Magento/Backend/Helper/DataTest.php
index 20363600811ce..f966f72d105d3 100644
--- a/dev/tests/integration/testsuite/Magento/Backend/Helper/DataTest.php
+++ b/dev/tests/integration/testsuite/Magento/Backend/Helper/DataTest.php
@@ -64,7 +64,7 @@ protected function tearDown()
*/
protected function _login()
{
- \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Backend\Model\Url')
+ \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Backend\Model\UrlInterface')
->turnOffSecretKey();
$this->_auth = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Backend\Model\Auth');
$this->_auth->login(
@@ -78,7 +78,7 @@ protected function _logout()
{
$this->_auth->logout();
\Magento\TestFramework\Helper\Bootstrap::getObjectManager()
- ->get('Magento\Backend\Model\Url')->turnOnSecretKey();
+ ->get('Magento\Backend\Model\UrlInterface')->turnOnSecretKey();
}
/**
@@ -112,7 +112,7 @@ public function testGetCurrentUserId()
/**
* perform login
*/
- \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Backend\Model\Url')
+ \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Backend\Model\UrlInterface')
->turnOffSecretKey();
$auth = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
@@ -125,7 +125,7 @@ public function testGetCurrentUserId()
*/
$auth->logout();
\Magento\TestFramework\Helper\Bootstrap::getObjectManager()
- ->get('Magento\Backend\Model\Url')->turnOnSecretKey();
+ ->get('Magento\Backend\Model\UrlInterface')->turnOnSecretKey();
$this->assertFalse($this->_helper->getCurrentUserId());
}
diff --git a/dev/tests/integration/testsuite/Magento/Backend/Model/Translate/InlineTest.php b/dev/tests/integration/testsuite/Magento/Backend/Model/Translate/InlineTest.php
index 59fec14dc23f9..4e449a74d0977 100644
--- a/dev/tests/integration/testsuite/Magento/Backend/Model/Translate/InlineTest.php
+++ b/dev/tests/integration/testsuite/Magento/Backend/Model/Translate/InlineTest.php
@@ -52,7 +52,7 @@ protected function setUp()
public function testAjaxUrl()
{
$body = 'some body';
- /** @var \Magento\Backend\Model\Url $url */
+ /** @var \Magento\Backend\Model\UrlInterface $url */
$url = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
->get('Magento\UrlInterface');
$url->getUrl(\Magento\Backend\App\Area\FrontNameResolver::AREA_CODE . '/ajax/translate');
diff --git a/dev/tests/integration/testsuite/Magento/Backend/Model/UrlTest.php b/dev/tests/integration/testsuite/Magento/Backend/Model/UrlTest.php
index 16b369343b128..16259d9d9fba6 100644
--- a/dev/tests/integration/testsuite/Magento/Backend/Model/UrlTest.php
+++ b/dev/tests/integration/testsuite/Magento/Backend/Model/UrlTest.php
@@ -28,14 +28,14 @@
namespace Magento\Backend\Model;
/**
- * Test class for \Magento\Backend\Model\Url.
+ * Test class for \Magento\Backend\Model\UrlInterface.
*
* @magentoAppArea adminhtml
*/
class UrlTest extends \PHPUnit_Framework_TestCase
{
/**
- * @var \Magento\Backend\Model\Url
+ * @var \Magento\Backend\Model\UrlInterface
*/
protected $_model;
@@ -43,40 +43,7 @@ protected function setUp()
{
parent::setUp();
$this->_model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
- ->create('Magento\Backend\Model\Url');
- }
-
- /**
- * @covers \Magento\Backend\Model\Url::isSecure
- */
- public function testIsSecure()
- {
- \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Backend\App\ConfigInterface')
- ->setValue('web/secure/use_in_adminhtml', true);
- $this->assertTrue($this->_model->isSecure());
-
- \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Backend\App\ConfigInterface')
- ->setValue('web/secure/use_in_adminhtml', false);
- $this->assertFalse($this->_model->isSecure());
-
- $this->_model->setData('secure_is_forced', true);
- $this->_model->setData('secure', true);
- $this->assertTrue($this->_model->isSecure());
-
- $this->_model->setData('secure', false);
- $this->assertFalse($this->_model->isSecure());
- }
-
- /**
- * @covers \Magento\Backend\Model\Url::setRouteParams
- */
- public function testSetRouteParams()
- {
- $this->_model->setRouteParams(array('_nosecret' => 'any_value'));
- $this->assertTrue($this->_model->getNoSecret());
-
- $this->_model->setRouteParams(array());
- $this->assertFalse($this->_model->getNoSecret());
+ ->create('Magento\Backend\Model\UrlInterface');
}
/**
diff --git a/dev/tests/integration/testsuite/Magento/Backend/Utility/Controller.php b/dev/tests/integration/testsuite/Magento/Backend/Utility/Controller.php
index 250e1309b59f4..f224998cae504 100644
--- a/dev/tests/integration/testsuite/Magento/Backend/Utility/Controller.php
+++ b/dev/tests/integration/testsuite/Magento/Backend/Utility/Controller.php
@@ -48,7 +48,7 @@ protected function setUp()
{
parent::setUp();
- $this->_objectManager->get('Magento\Backend\Model\Url')->turnOffSecretKey();
+ $this->_objectManager->get('Magento\Backend\Model\UrlInterface')->turnOffSecretKey();
$this->_auth = $this->_objectManager->get('Magento\Backend\Model\Auth');
$this->_session = $this->_auth->getAuthStorage();
@@ -74,7 +74,7 @@ protected function tearDown()
$this->_auth->logout();
$this->_auth = null;
$this->_session = null;
- $this->_objectManager->get('Magento\Backend\Model\Url')->turnOnSecretKey();
+ $this->_objectManager->get('Magento\Backend\Model\UrlInterface')->turnOnSecretKey();
parent::tearDown();
}
diff --git a/dev/tests/integration/testsuite/Magento/Captcha/Model/ObserverTest.php b/dev/tests/integration/testsuite/Magento/Captcha/Model/ObserverTest.php
index 9f39840800c63..4db394c4f71b1 100644
--- a/dev/tests/integration/testsuite/Magento/Captcha/Model/ObserverTest.php
+++ b/dev/tests/integration/testsuite/Magento/Captcha/Model/ObserverTest.php
@@ -41,7 +41,7 @@ class ObserverTest extends \Magento\TestFramework\TestCase\AbstractController
*/
public function testBackendLoginActionWithInvalidCaptchaReturnsError()
{
- \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Backend\Model\Url')
+ \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Backend\Model\UrlInterface')
->turnOffSecretKey();
$post = array(
@@ -114,7 +114,7 @@ public function testCheckUserForgotPasswordBackendWhenCaptchaFailed()
*/
public function testCheckUnsuccessfulMessageWhenCaptchaFailed()
{
- \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Backend\Model\Url')
+ \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Backend\Model\UrlInterface')
->turnOffSecretKey();
$this->getRequest()->setPost(array('email' => 'dummy@dummy.com', 'captcha' => '1234'));
$this->dispatch('backend/admin/auth/forgotpassword');
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Action/AttributeTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Action/AttributeTest.php
index 178ed26d782a7..de04f8cc86c15 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Action/AttributeTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Action/AttributeTest.php
@@ -49,7 +49,7 @@ public function testSaveActionRedirectsSuccessfully()
$this->dispatch('backend/catalog/product_action_attribute/save/store/0');
$this->assertEquals(302, $this->getResponse()->getHttpResponseCode());
- /** @var \Magento\Backend\Model\Url $urlBuilder */
+ /** @var \Magento\Backend\Model\UrlInterface $urlBuilder */
$urlBuilder = $objectManager->get('Magento\UrlInterface');
/** @var \Magento\Catalog\Helper\Product\Edit\Action\Attribute $attributeHelper */
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Helper/DataTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Helper/DataTest.php
index cfa52de7bfb8a..11afaaf1b4e0a 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Helper/DataTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Helper/DataTest.php
@@ -118,21 +118,6 @@ public function testGetAttributeHiddenFields()
}
}
- public function testGetAttributeDisabledTypes()
- {
- $this->assertEquals(array(), $this->_helper->getAttributeDisabledTypes());
- /** @var $objectManager \Magento\TestFramework\ObjectManager */
- $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
- $objectManager->get('Magento\Core\Model\Registry')->register('attribute_type_disabled_types', 'test');
- try {
- $this->assertEquals('test', $this->_helper->getAttributeDisabledTypes());
- $objectManager->get('Magento\Core\Model\Registry')->unregister('attribute_type_disabled_types');
- } catch (\Exception $e) {
- $objectManager->get('Magento\Core\Model\Registry')->unregister('attribute_type_disabled_types');
- throw $e;
- }
- }
-
public function testGetPriceScopeDefault()
{
// $this->assertEquals(\Magento\Core\Model\Store::PRICE_SCOPE_GLOBAL, $this->_helper->getPriceScope());
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Helper/Product/UrlTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Helper/Product/UrlTest.php
index ec11ea38f56d0..2048e65afe507 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Helper/Product/UrlTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Helper/Product/UrlTest.php
@@ -36,8 +36,8 @@ class UrlTest extends \PHPUnit_Framework_TestCase
public static function setUpBeforeClass()
{
- /** @var $configModel \Magento\Core\Model\Config */
- $configModel = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Core\Model\Config');
+ /** @var $configModel \Magento\App\ConfigInterface */
+ $configModel = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\App\ConfigInterface');
// @todo re-implement this test
$data = array(
'from' => '™',
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Category/CategoryImageTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Category/CategoryImageTest.php
index 565f59cc2aa0d..27216bf362b67 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Category/CategoryImageTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Category/CategoryImageTest.php
@@ -47,7 +47,6 @@ class CategoryImageTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
- /** @var $configModel \Magento\Core\Model\Config */
$this->_oldLogActive = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
->get('Magento\Core\Model\StoreManagerInterface')->getStore()->getConfig('dev/log/active');
$this->_oldExceptionFile = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/CategoryTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/CategoryTest.php
index 26bc170f7770c..d1882e7714162 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Model/CategoryTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/CategoryTest.php
@@ -74,8 +74,8 @@ public static function setUpBeforeClass()
}
// get list of not existing tables
- /** @var $application \Magento\Core\Model\App */
- $application = self::$_objectManager->get('Magento\Core\Model\App');
+ /** @var $storeManager \Magento\Core\Model\StoreManagerInterface */
+ $storeManager = self::$_objectManager->get('Magento\Core\Model\StoreManagerInterface');
/** @var $categoryResource \Magento\Catalog\Model\Resource\Category\Flat */
$categoryResource = self::$_objectManager->create('Magento\Catalog\Model\Resource\Category\Flat');
/** @var $setupModel \Magento\Core\Model\Resource\Setup */
@@ -85,7 +85,7 @@ public static function setUpBeforeClass()
'moduleName' => 'Magento_Core',
)
);
- $stores = $application->getStores();
+ $stores = $storeManager->getStores();
/** @var $store \Magento\Core\Model\Store */
foreach ($stores as $store) {
$tableName = $categoryResource->getMainStoreTable($store->getId());
@@ -146,16 +146,16 @@ protected static function _getCategoryIndexerProcess()
protected function setUp()
{
- /** @var $application \Magento\Core\Model\App */
- $application = self::$_objectManager->get('Magento\Core\Model\App');
- $this->_store = $application->getStore();
+ /** @var $storeManager \Magento\Core\Model\StoreManagerInterface */
+ $storeManager = self::$_objectManager->get('Magento\Core\Model\StoreManagerInterface');
+ $this->_store = $storeManager->getStore();
$this->_model = self::$_objectManager->create('Magento\Catalog\Model\Category');
}
public function testGetUrlInstance()
{
$instance = $this->_model->getUrlInstance();
- $this->assertInstanceOf('Magento\Core\Model\Url', $instance);
+ $this->assertInstanceOf('Magento\Url', $instance);
$this->assertSame($instance, $this->_model->getUrlInstance());
}
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/UrlTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/UrlTest.php
index 85c032855c14b..9af1354197856 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/UrlTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/UrlTest.php
@@ -48,7 +48,7 @@ protected function setUp()
public function testGetUrlInstance()
{
$instance = $this->_model->getUrlInstance();
- $this->assertInstanceOf('Magento\Core\Model\Url', $instance);
+ $this->assertInstanceOf('Magento\Url', $instance);
$this->assertSame($instance, $this->_model->getUrlInstance());
}
diff --git a/dev/tests/integration/testsuite/Magento/CatalogSearch/Controller/ResultTest.php b/dev/tests/integration/testsuite/Magento/CatalogSearch/Controller/ResultTest.php
index ea346db313adb..091b0952a8c86 100644
--- a/dev/tests/integration/testsuite/Magento/CatalogSearch/Controller/ResultTest.php
+++ b/dev/tests/integration/testsuite/Magento/CatalogSearch/Controller/ResultTest.php
@@ -31,11 +31,9 @@ class ResultTest extends \Magento\TestFramework\TestCase\AbstractController
{
/**
* @magentoDataFixture Magento/CatalogSearch/_files/query.php
- * @magentoConfigFixture current_store general/locale/code de_DE
*/
public function testIndexActionTranslation()
{
- $this->markTestIncomplete('endTest() called too early, config fixture reseted');
$this->getRequest()->setParam('q', 'query_text');
$this->dispatch('catalogsearch/result');
@@ -46,4 +44,15 @@ public function testIndexActionTranslation()
$this->assertNotContains('Search entire store here...', $responseBody);
$this->assertContains('Den gesamten Shop durchsuchen...', $responseBody);
}
+
+ public function testIndexActionXSSQueryVerification()
+ {
+ $this->getRequest()->setParam('q', '');
+ $this->dispatch('catalogsearch/result');
+
+ $responseBody = $this->getResponse()->getBody();
+ $data = '';
+ $this->assertNotContains($data, $responseBody);
+ $this->assertContains(htmlspecialchars($data, ENT_COMPAT, 'UTF-8', false), $responseBody);
+ }
}
diff --git a/dev/tests/integration/testsuite/Magento/CatalogSearch/_files/query.php b/dev/tests/integration/testsuite/Magento/CatalogSearch/_files/query.php
index d38233ea17ad3..483a9d426f879 100644
--- a/dev/tests/integration/testsuite/Magento/CatalogSearch/_files/query.php
+++ b/dev/tests/integration/testsuite/Magento/CatalogSearch/_files/query.php
@@ -27,6 +27,8 @@
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
+$objectManager->get('Magento\Core\Model\Locale')->setLocale('de_DE');
+
/** @var $query \Magento\CatalogSearch\Model\Query */
$query = $objectManager->create('Magento\CatalogSearch\Model\Query');
$query->setStoreId(1);
diff --git a/dev/tests/integration/testsuite/Magento/Checkout/Block/Cart/SidebarTest.php b/dev/tests/integration/testsuite/Magento/Checkout/Block/Cart/SidebarTest.php
index 587d686a5d7d4..0d77e8059b1ee 100644
--- a/dev/tests/integration/testsuite/Magento/Checkout/Block/Cart/SidebarTest.php
+++ b/dev/tests/integration/testsuite/Magento/Checkout/Block/Cart/SidebarTest.php
@@ -36,6 +36,13 @@ protected function setUp()
->setAreaCode('frontend');
$this->_block = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\View\LayoutInterface')
->createBlock('Magento\Checkout\Block\Cart\Sidebar');
+ $this->_block->addChild('renderer.list', '\Magento\View\Element\RendererList');
+ $this->_block->getChildBlock('renderer.list')
+ ->addChild(
+ 'default',
+ '\Magento\Checkout\Block\Cart\Item\Renderer',
+ array('template' => 'cart/item/default.phtml')
+ );
}
public function testGetCacheKeyInfo()
diff --git a/dev/tests/integration/testsuite/Magento/Cms/Model/Wysiwyg/Images/StorageTest.php b/dev/tests/integration/testsuite/Magento/Cms/Model/Wysiwyg/Images/StorageTest.php
index 3f79c091d33a3..93521b3a2e92f 100644
--- a/dev/tests/integration/testsuite/Magento/Cms/Model/Wysiwyg/Images/StorageTest.php
+++ b/dev/tests/integration/testsuite/Magento/Cms/Model/Wysiwyg/Images/StorageTest.php
@@ -85,7 +85,7 @@ public function testGetThumbsPath()
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
$filesystem = $objectManager->get('Magento\App\Filesystem');
$session = $objectManager->get('Magento\Backend\Model\Session');
- $backendUrl = $objectManager->get('Magento\Backend\Model\Url');
+ $backendUrl = $objectManager->get('Magento\Backend\Model\UrlInterface');
$imageFactory = $objectManager->get('Magento\Image\AdapterFactory');
$viewUrl = $objectManager->get('Magento\View\Url');
$imageHelper = $objectManager->get('Magento\Cms\Helper\Wysiwyg\Images');
diff --git a/dev/tests/integration/testsuite/Magento/Core/Model/AppTest.php b/dev/tests/integration/testsuite/Magento/Core/Model/AppTest.php
index 11be911df5dbd..5a89cae7fff2a 100644
--- a/dev/tests/integration/testsuite/Magento/Core/Model/AppTest.php
+++ b/dev/tests/integration/testsuite/Magento/Core/Model/AppTest.php
@@ -60,41 +60,6 @@ public function testGetCookie()
$this->assertInstanceOf('Magento\Stdlib\Cookie', $this->_model->getCookie());
}
- /**
- * @magentoAppIsolation enabled
- * @magentoConfigFixture current_store general/single_store_mode/enabled 1
- */
- public function testIsSingleStoreModeWhenEnabled()
- {
- $this->assertTrue($this->_mageModel->isSingleStoreMode());
- }
-
- /**
- * @magentoAppIsolation enabled
- * @magentoConfigFixture current_store general/single_store_mode/enabled 0
- */
- public function testIsSingleStoreModeWhenDisabled()
- {
- $this->assertFalse($this->_mageModel->isSingleStoreMode());;
- }
-
- public function testHasSingleStore()
- {
- $this->assertTrue($this->_model->hasSingleStore());
- $this->assertTrue($this->_mageModel->hasSingleStore());
- }
-
- /**
- * @magentoAppIsolation enabled
- */
- public function testSetCurrentStore()
- {
- $store = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
- ->create('Magento\Core\Model\Store');
- $this->_model->setCurrentStore($store);
- $this->assertSame($store, $this->_model->getStore());
- }
-
public function testSetErrorHandler()
{
$this->_model->setErrorHandler(array($this, 'errorHandler'));
@@ -122,70 +87,11 @@ public function testGetArea()
$this->assertSame($area, $this->_model->getArea('frontend'));
}
- /**
- * @expectedException \Magento\Core\Model\Store\Exception
- */
- public function testGetNotExistingStore()
- {
- $this->_mageModel->getStore(100);
- }
-
- public function testGetSafeNotExistingStore()
- {
- $this->_mageModel->getSafeStore(100);
- $request = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\App\Request\Http');
- $this->assertEquals('noroute', $request->getActionName());
- }
-
- public function testGetStores()
- {
- $this->assertNotEmpty($this->_mageModel->getStores());
- $this->assertNotContains(
- \Magento\Core\Model\Store::DEFAULT_STORE_ID,
- array_keys($this->_mageModel->getStores())
- );
- $this->assertContains(
- \Magento\Core\Model\Store::DEFAULT_STORE_ID,
- array_keys($this->_mageModel->getStores(true))
- );
- }
-
- public function testGetDefaultStoreView()
- {
- $store = $this->_mageModel->getDefaultStoreView();
- $this->assertEquals('default', $store->getCode());
- }
-
public function testGetDistroLocaleCode()
{
$this->assertEquals(\Magento\Core\Model\App::DISTRO_LOCALE_CODE, $this->_model->getDistroLocaleCode());
}
- /**
- * @expectedException \Magento\Core\Exception
- */
- public function testGetWebsiteNonExisting()
- {
- $this->assertNotEmpty($this->_mageModel->getWebsite(true)->getId());
- $this->_mageModel->getWebsite(100);
- }
-
- public function testGetWebsites()
- {
- $this->assertNotEmpty($this->_mageModel->getWebsites());
- $this->assertNotContains(0, array_keys($this->_mageModel->getWebsites()));
- $this->assertContains(0, array_keys($this->_mageModel->getWebsites(true)));
- }
-
- /**
- * @expectedException \Magento\Core\Exception
- */
- public function testGetGroupNonExisting()
- {
- $this->assertNotEmpty($this->_mageModel->getGroup(true)->getId());
- $this->_mageModel->getGroup(100);
- }
-
public function testGetLocale()
{
$locale = $this->_model->getLocale();
@@ -263,38 +169,4 @@ public function testSetGetResponse()
$this->assertSame($response, $this->_model->getResponse());
$this->assertEmpty($this->_model->getResponse()->getHeaders());
}
-
- /**
- * @expectedException \Magento\Core\Model\Store\Exception
- */
- public function testThrowStoreException()
- {
- $this->_model->throwStoreException('test');
- }
-
- public function testSetGetUseSessionVar()
- {
- $this->assertFalse($this->_model->getUseSessionVar());
- $this->_model->setUseSessionVar(true);
- $this->assertTrue($this->_model->getUseSessionVar());
- }
-
- public function testGetAnyStoreView()
- {
- $this->assertInstanceOf('Magento\Core\Model\Store', $this->_mageModel->getAnyStoreView());
- }
-
- public function testSetGetUseSessionInUrl()
- {
- $this->assertTrue($this->_model->getUseSessionInUrl());
- $this->_model->setUseSessionInUrl(false);
- $this->assertFalse($this->_model->getUseSessionInUrl());
- }
-
- public function testGetGroups()
- {
- $groups = $this->_mageModel->getGroups();
- $this->assertInternalType('array', $groups);
- $this->assertGreaterThanOrEqual(1, count($groups));
- }
}
diff --git a/dev/tests/integration/testsuite/Magento/Core/Model/Resource/Db/ProfilerTest.php b/dev/tests/integration/testsuite/Magento/Core/Model/Resource/Db/ProfilerTest.php
index 2886e5fc2957d..8ac262b63b1ee 100644
--- a/dev/tests/integration/testsuite/Magento/Core/Model/Resource/Db/ProfilerTest.php
+++ b/dev/tests/integration/testsuite/Magento/Core/Model/Resource/Db/ProfilerTest.php
@@ -61,7 +61,7 @@ protected function setUp()
protected function _getConnectionRead()
{
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
- $localConfig = $objectManager->get('Magento\App\Config');
+ $localConfig = $objectManager->get('Magento\App\Arguments');
$connectionConfig = $localConfig->getConnection('default');
$connectionConfig['profiler'] = array(
'class' => 'Magento\Core\Model\Resource\Db\Profiler',
diff --git a/dev/tests/integration/testsuite/Magento/Core/Model/Resource/Store/CollectionTest.php b/dev/tests/integration/testsuite/Magento/Core/Model/Resource/Store/CollectionTest.php
index 336cb762097ac..ee1da0f464290 100644
--- a/dev/tests/integration/testsuite/Magento/Core/Model/Resource/Store/CollectionTest.php
+++ b/dev/tests/integration/testsuite/Magento/Core/Model/Resource/Store/CollectionTest.php
@@ -147,7 +147,7 @@ public function testAddExpressionFieldToSelect()
*/
public function testGetAllIds()
{
- $this->assertContains(\Magento\Core\Model\AppInterface::DISTRO_STORE_ID, $this->_collection->getAllIds());
+ $this->assertContains(\Magento\Core\Model\Store::DISTRO_STORE_ID, $this->_collection->getAllIds());
}
/**
diff --git a/dev/tests/integration/testsuite/Magento/Core/Model/Session/AbstractSession/VarienTest.php b/dev/tests/integration/testsuite/Magento/Core/Model/Session/AbstractSession/VarienTest.php
index ffa56717443d9..d562960a71cff 100644
--- a/dev/tests/integration/testsuite/Magento/Core/Model/Session/AbstractSession/VarienTest.php
+++ b/dev/tests/integration/testsuite/Magento/Core/Model/Session/AbstractSession/VarienTest.php
@@ -49,8 +49,8 @@ public function testSessionSaveMethod($saveMethod, $iniValue)
$this->markTestSkipped("Can't set '$iniValue' as session save handler");
}
ini_set('session.save_handler', $origSessionHandler);
- /** @var $configModel \Magento\Core\Model\Config */
- $configModel = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Core\Model\Config');
+ /** @var $configModel \Magento\App\ConfigInterface */
+ $configModel = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\App\ConfigInterface');
$configModel->setNode(\Magento\Core\Model\Session\Config::PARAM_SESSION_SAVE_METHOD, $saveMethod);
/**
* @var \Magento\Session\SessionManagerInterface $model
diff --git a/dev/tests/integration/testsuite/Magento/Core/Model/Session/SidResolverTest.php b/dev/tests/integration/testsuite/Magento/Core/Model/Session/SidResolverTest.php
index 4af3964a06de5..d655fe20c98f2 100644
--- a/dev/tests/integration/testsuite/Magento/Core/Model/Session/SidResolverTest.php
+++ b/dev/tests/integration/testsuite/Magento/Core/Model/Session/SidResolverTest.php
@@ -76,7 +76,7 @@ protected function setUp()
->disableOriginalConstructor()
->getMockForAbstractClass();
- $this->urlBuilder = $this->getMockBuilder('Magento\UrlInterface')
+ $this->urlBuilder = $this->getMockBuilder('Magento\Url')
->setMethods(array('isOwnOriginUrl'))
->disableOriginalConstructor()
->getMockForAbstractClass();
@@ -156,4 +156,18 @@ public function testGetSessionIdQueryParamCustom()
);
$this->session->setName($oldSessionName);
}
+
+ public function testSetGetUseSessionVar()
+ {
+ $this->assertFalse($this->model->getUseSessionVar());
+ $this->model->setUseSessionVar(true);
+ $this->assertTrue($this->model->getUseSessionVar());
+ }
+
+ public function testSetGetUseSessionInUrl()
+ {
+ $this->assertTrue($this->model->getUseSessionInUrl());
+ $this->model->setUseSessionInUrl(false);
+ $this->assertFalse($this->model->getUseSessionInUrl());
+ }
}
diff --git a/dev/tests/integration/testsuite/Magento/Core/Model/StoreTest.php b/dev/tests/integration/testsuite/Magento/Core/Model/StoreTest.php
index f2cd9f2752e4b..7db7aef1bbe05 100644
--- a/dev/tests/integration/testsuite/Magento/Core/Model/StoreTest.php
+++ b/dev/tests/integration/testsuite/Magento/Core/Model/StoreTest.php
@@ -55,12 +55,12 @@ protected function _getStoreModel()
'registry' => $objectManager->get('Magento\Core\Model\Registry'),
'coreFileStorageDatabase' => $objectManager->get('Magento\Core\Helper\File\Storage\Database'),
'configCacheType' => $objectManager->get('Magento\App\Cache\Type\Config'),
- 'url' => $objectManager->get('Magento\Core\Model\Url'),
+ 'url' => $objectManager->get('Magento\Url'),
'request' => $objectManager->get('Magento\App\RequestInterface'),
'configDataResource' => $objectManager->get('Magento\Core\Model\Resource\Config\Data'),
'filesystem' => $objectManager->get('Magento\App\Filesystem'),
'coreStoreConfig' => $objectManager->get('Magento\Core\Model\Store\Config'),
- 'coreConfig' => $objectManager->get('Magento\Core\Model\Config'),
+ 'coreConfig' => $objectManager->get('Magento\App\ReinitableConfigInterface'),
'resource' => $objectManager->get('Magento\Core\Model\Resource\Store'),
'storeManager' => $objectManager->get('Magento\Core\Model\StoreManager'),
'sidResolver' => $objectManager->get('Magento\Session\SidResolverInterface'),
@@ -128,8 +128,8 @@ public function testSetGetWebsite()
public function testSetGetGroup()
{
$this->assertFalse($this->_model->getGroup());
- $storeGroup = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Core\Model\App')
- ->getGroup();
+ $storeGroup = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
+ ->get('Magento\Core\Model\StoreManager')->getGroup();
$this->_model->setGroup($storeGroup);
$actualResult = $this->_model->getGroup();
$this->assertSame($storeGroup, $actualResult);
@@ -162,34 +162,34 @@ public function testGetBaseUrl($type, $useRewrites, $useStoreCode, $expected)
public function getBaseUrlDataProvider()
{
return array(
- array(\Magento\Core\Model\Store::URL_TYPE_WEB, false, false, 'http://localhost/'),
- array(\Magento\Core\Model\Store::URL_TYPE_WEB, false, true, 'http://localhost/'),
- array(\Magento\Core\Model\Store::URL_TYPE_WEB, true, false, 'http://localhost/'),
- array(\Magento\Core\Model\Store::URL_TYPE_WEB, true, true, 'http://localhost/'),
- array(\Magento\Core\Model\Store::URL_TYPE_LINK, false, false, 'http://localhost/index.php/'),
- array(\Magento\Core\Model\Store::URL_TYPE_LINK, false, true, 'http://localhost/index.php/default/'),
- array(\Magento\Core\Model\Store::URL_TYPE_LINK, true, false, 'http://localhost/'),
- array(\Magento\Core\Model\Store::URL_TYPE_LINK, true, true, 'http://localhost/default/'),
- array(\Magento\Core\Model\Store::URL_TYPE_DIRECT_LINK, false, false, 'http://localhost/index.php/'),
- array(\Magento\Core\Model\Store::URL_TYPE_DIRECT_LINK, false, true, 'http://localhost/index.php/'),
- array(\Magento\Core\Model\Store::URL_TYPE_DIRECT_LINK, true, false, 'http://localhost/'),
- array(\Magento\Core\Model\Store::URL_TYPE_DIRECT_LINK, true, true, 'http://localhost/'),
- array(\Magento\Core\Model\Store::URL_TYPE_STATIC, false, false, 'http://localhost/pub/static/'),
- array(\Magento\Core\Model\Store::URL_TYPE_STATIC, false, true, 'http://localhost/pub/static/'),
- array(\Magento\Core\Model\Store::URL_TYPE_STATIC, true, false, 'http://localhost/pub/static/'),
- array(\Magento\Core\Model\Store::URL_TYPE_STATIC, true, true, 'http://localhost/pub/static/'),
- array(\Magento\Core\Model\Store::URL_TYPE_CACHE, false, false, 'http://localhost/pub/cache/'),
- array(\Magento\Core\Model\Store::URL_TYPE_CACHE, false, true, 'http://localhost/pub/cache/'),
- array(\Magento\Core\Model\Store::URL_TYPE_CACHE, true, false, 'http://localhost/pub/cache/'),
- array(\Magento\Core\Model\Store::URL_TYPE_CACHE, true, true, 'http://localhost/pub/cache/'),
- array(\Magento\Core\Model\Store::URL_TYPE_LIB, false, false, 'http://localhost/pub/lib/'),
- array(\Magento\Core\Model\Store::URL_TYPE_LIB, false, true, 'http://localhost/pub/lib/'),
- array(\Magento\Core\Model\Store::URL_TYPE_LIB, true, false, 'http://localhost/pub/lib/'),
- array(\Magento\Core\Model\Store::URL_TYPE_LIB, true, true, 'http://localhost/pub/lib/'),
- array(\Magento\Core\Model\Store::URL_TYPE_MEDIA, false, false, 'http://localhost/pub/media/'),
- array(\Magento\Core\Model\Store::URL_TYPE_MEDIA, false, true, 'http://localhost/pub/media/'),
- array(\Magento\Core\Model\Store::URL_TYPE_MEDIA, true, false, 'http://localhost/pub/media/'),
- array(\Magento\Core\Model\Store::URL_TYPE_MEDIA, true, true, 'http://localhost/pub/media/'),
+ array(\Magento\UrlInterface::URL_TYPE_WEB, false, false, 'http://localhost/'),
+ array(\Magento\UrlInterface::URL_TYPE_WEB, false, true, 'http://localhost/'),
+ array(\Magento\UrlInterface::URL_TYPE_WEB, true, false, 'http://localhost/'),
+ array(\Magento\UrlInterface::URL_TYPE_WEB, true, true, 'http://localhost/'),
+ array(\Magento\UrlInterface::URL_TYPE_LINK, false, false, 'http://localhost/index.php/'),
+ array(\Magento\UrlInterface::URL_TYPE_LINK, false, true, 'http://localhost/index.php/default/'),
+ array(\Magento\UrlInterface::URL_TYPE_LINK, true, false, 'http://localhost/'),
+ array(\Magento\UrlInterface::URL_TYPE_LINK, true, true, 'http://localhost/default/'),
+ array(\Magento\UrlInterface::URL_TYPE_DIRECT_LINK, false, false, 'http://localhost/index.php/'),
+ array(\Magento\UrlInterface::URL_TYPE_DIRECT_LINK, false, true, 'http://localhost/index.php/'),
+ array(\Magento\UrlInterface::URL_TYPE_DIRECT_LINK, true, false, 'http://localhost/'),
+ array(\Magento\UrlInterface::URL_TYPE_DIRECT_LINK, true, true, 'http://localhost/'),
+ array(\Magento\UrlInterface::URL_TYPE_STATIC, false, false, 'http://localhost/pub/static/'),
+ array(\Magento\UrlInterface::URL_TYPE_STATIC, false, true, 'http://localhost/pub/static/'),
+ array(\Magento\UrlInterface::URL_TYPE_STATIC, true, false, 'http://localhost/pub/static/'),
+ array(\Magento\UrlInterface::URL_TYPE_STATIC, true, true, 'http://localhost/pub/static/'),
+ array(\Magento\UrlInterface::URL_TYPE_CACHE, false, false, 'http://localhost/pub/cache/'),
+ array(\Magento\UrlInterface::URL_TYPE_CACHE, false, true, 'http://localhost/pub/cache/'),
+ array(\Magento\UrlInterface::URL_TYPE_CACHE, true, false, 'http://localhost/pub/cache/'),
+ array(\Magento\UrlInterface::URL_TYPE_CACHE, true, true, 'http://localhost/pub/cache/'),
+ array(\Magento\UrlInterface::URL_TYPE_LIB, false, false, 'http://localhost/pub/lib/'),
+ array(\Magento\UrlInterface::URL_TYPE_LIB, false, true, 'http://localhost/pub/lib/'),
+ array(\Magento\UrlInterface::URL_TYPE_LIB, true, false, 'http://localhost/pub/lib/'),
+ array(\Magento\UrlInterface::URL_TYPE_LIB, true, true, 'http://localhost/pub/lib/'),
+ array(\Magento\UrlInterface::URL_TYPE_MEDIA, false, false, 'http://localhost/pub/media/'),
+ array(\Magento\UrlInterface::URL_TYPE_MEDIA, false, true, 'http://localhost/pub/media/'),
+ array(\Magento\UrlInterface::URL_TYPE_MEDIA, true, false, 'http://localhost/pub/media/'),
+ array(\Magento\UrlInterface::URL_TYPE_MEDIA, true, true, 'http://localhost/pub/media/'),
);
}
@@ -206,15 +206,15 @@ public function testGetBaseUrlInPub()
$this->assertEquals(
'http://localhost/pub/static/',
- $this->_model->getBaseUrl(\Magento\Core\Model\Store::URL_TYPE_STATIC)
+ $this->_model->getBaseUrl(\Magento\UrlInterface::URL_TYPE_STATIC)
);
$this->assertEquals(
'http://localhost/pub/lib/',
- $this->_model->getBaseUrl(\Magento\Core\Model\Store::URL_TYPE_LIB)
+ $this->_model->getBaseUrl(\Magento\UrlInterface::URL_TYPE_LIB)
);
$this->assertEquals(
'http://localhost/pub/media/',
- $this->_model->getBaseUrl(\Magento\Core\Model\Store::URL_TYPE_MEDIA)
+ $this->_model->getBaseUrl(\Magento\UrlInterface::URL_TYPE_MEDIA)
);
}
@@ -252,14 +252,14 @@ public function testGetBaseUrlForCustomEntryPoint($type, $useCustomEntryPoint, $
public function getBaseUrlForCustomEntryPointDataProvider()
{
return array(
- array(\Magento\Core\Model\Store::URL_TYPE_LINK, false, false, 'http://localhost/custom_entry.php/'),
- array(\Magento\Core\Model\Store::URL_TYPE_LINK, false, true, 'http://localhost/custom_entry.php/default/'),
- array(\Magento\Core\Model\Store::URL_TYPE_LINK, true, false, 'http://localhost/index.php/'),
- array(\Magento\Core\Model\Store::URL_TYPE_LINK, true, true, 'http://localhost/index.php/default/'),
- array(\Magento\Core\Model\Store::URL_TYPE_DIRECT_LINK, false, false, 'http://localhost/custom_entry.php/'),
- array(\Magento\Core\Model\Store::URL_TYPE_DIRECT_LINK, false, true, 'http://localhost/custom_entry.php/'),
- array(\Magento\Core\Model\Store::URL_TYPE_DIRECT_LINK, true, false, 'http://localhost/index.php/'),
- array(\Magento\Core\Model\Store::URL_TYPE_DIRECT_LINK, true, true, 'http://localhost/index.php/'),
+ array(\Magento\UrlInterface::URL_TYPE_LINK, false, false, 'http://localhost/custom_entry.php/'),
+ array(\Magento\UrlInterface::URL_TYPE_LINK, false, true, 'http://localhost/custom_entry.php/default/'),
+ array(\Magento\UrlInterface::URL_TYPE_LINK, true, false, 'http://localhost/index.php/'),
+ array(\Magento\UrlInterface::URL_TYPE_LINK, true, true, 'http://localhost/index.php/default/'),
+ array(\Magento\UrlInterface::URL_TYPE_DIRECT_LINK, false, false, 'http://localhost/custom_entry.php/'),
+ array(\Magento\UrlInterface::URL_TYPE_DIRECT_LINK, false, true, 'http://localhost/custom_entry.php/'),
+ array(\Magento\UrlInterface::URL_TYPE_DIRECT_LINK, true, false, 'http://localhost/index.php/'),
+ array(\Magento\UrlInterface::URL_TYPE_DIRECT_LINK, true, true, 'http://localhost/index.php/'),
);
}
diff --git a/dev/tests/integration/testsuite/Magento/Core/Model/ThemeTest.php b/dev/tests/integration/testsuite/Magento/Core/Model/ThemeTest.php
index 56ec20cde913a..a87314e98cc18 100644
--- a/dev/tests/integration/testsuite/Magento/Core/Model/ThemeTest.php
+++ b/dev/tests/integration/testsuite/Magento/Core/Model/ThemeTest.php
@@ -70,9 +70,9 @@ protected function _getThemeValidData()
public function testChildRelation()
{
/** @var $theme \Magento\View\Design\ThemeInterface */
- /** @var $currentTheme \Magento\View\Design\ThemeInterface */
$theme = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\View\Design\ThemeInterface');
$collection = $theme->getCollection()->addTypeFilter(\Magento\View\Design\ThemeInterface::TYPE_VIRTUAL);
+ /** @var $currentTheme \Magento\View\Design\ThemeInterface */
foreach ($collection as $currentTheme) {
$parentTheme = $currentTheme->getParentTheme();
if (!empty($parentTheme)) {
@@ -80,4 +80,23 @@ public function testChildRelation()
}
}
}
+
+ /**
+ * @magentoDataFixture Magento/Core/Model/_files/design/themes.php
+ * @magentoAppIsolation enabled
+ * @magentoAppArea frontend
+ */
+ public function testGetInheritedThemes()
+ {
+ /** @var \Magento\View\Design\Theme\FlyweightFactory $themeFactory */
+ $themeFactory = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
+ ->get('Magento\View\Design\Theme\FlyweightFactory');
+ $theme = $themeFactory->create('vendor_custom_theme');
+ $this->assertCount(2, $theme->getInheritedThemes());
+ $expected = array();
+ foreach ($theme->getInheritedThemes() as $someTheme) {
+ $expected[] = $someTheme->getFullPath();
+ }
+ $this->assertEquals(array('frontend/vendor_default', 'frontend/vendor_custom_theme'), $expected);
+ }
}
diff --git a/dev/tests/integration/testsuite/Magento/Core/Model/TranslateTest.php b/dev/tests/integration/testsuite/Magento/Core/Model/TranslateTest.php
index 1cb656463fa38..877dd2c8be70b 100644
--- a/dev/tests/integration/testsuite/Magento/Core/Model/TranslateTest.php
+++ b/dev/tests/integration/testsuite/Magento/Core/Model/TranslateTest.php
@@ -91,7 +91,7 @@ protected function setUp()
array(
$objectManager->get('Magento\Core\Model\StoreManagerInterface'),
$objectManager->get('Magento\View\Design\Theme\FlyweightFactory'),
- $objectManager->get('Magento\Core\Model\Config'),
+ $objectManager->get('Magento\App\ConfigInterface'),
$objectManager->get('Magento\Core\Model\Store\Config'),
$objectManager->get('Magento\Core\Model\ThemeFactory'),
$objectManager->get('Magento\Core\Model\App'),
diff --git a/dev/tests/integration/testsuite/Magento/Core/Model/_files/design/themes.php b/dev/tests/integration/testsuite/Magento/Core/Model/_files/design/themes.php
index 94efdd6611359..ed6935bd236c1 100644
--- a/dev/tests/integration/testsuite/Magento/Core/Model/_files/design/themes.php
+++ b/dev/tests/integration/testsuite/Magento/Core/Model/_files/design/themes.php
@@ -42,6 +42,4 @@
/** @var $registration \Magento\Core\Model\Theme\Registration */
$registration = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
->create('Magento\Core\Model\Theme\Registration');
-$registration->register(
- implode('/', array('*', '*', 'theme.xml'))
-);
+$registration->register(implode('/', array('*', '*', 'theme.xml')));
diff --git a/dev/tests/integration/testsuite/Magento/Css/PreProcessor/Adapter/OyejorgeTest.php b/dev/tests/integration/testsuite/Magento/Css/PreProcessor/Adapter/OyejorgeTest.php
new file mode 100644
index 0000000000000..e0dac5c361fad
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Css/PreProcessor/Adapter/OyejorgeTest.php
@@ -0,0 +1,49 @@
+model = $objectManager->create('Magento\Css\PreProcessor\Adapter\Oyejorge');
+ }
+
+ public function testProcess()
+ {
+ $sourceFilePath = realpath(__DIR__ . '/../_files/oyejorge.less');
+ $resultCss = file_get_contents(__DIR__ . '/../_files/oyejorge.css');
+ $this->assertEquals(trim($resultCss), $this->model->process($sourceFilePath));
+ }
+}
diff --git a/dev/tests/integration/testsuite/Magento/Css/PreProcessor/_files/nested/import.less b/dev/tests/integration/testsuite/Magento/Css/PreProcessor/_files/nested/import.less
new file mode 100644
index 0000000000000..98e89e191f7e6
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Css/PreProcessor/_files/nested/import.less
@@ -0,0 +1 @@
+@body-bg-img: url(Magento_Theme::validation_advice_bg.gif);
diff --git a/dev/tests/integration/testsuite/Magento/Css/PreProcessor/_files/oyejorge.css b/dev/tests/integration/testsuite/Magento/Css/PreProcessor/_files/oyejorge.css
new file mode 100644
index 0000000000000..5cfe4bd6f2372
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Css/PreProcessor/_files/oyejorge.css
@@ -0,0 +1,45 @@
+#header {
+ color: #4d926f;
+}
+h2 {
+ color: #4d926f;
+}
+#header {
+ -webkit-border-radius: 5px;
+ -moz-border-radius: 5px;
+ -ms-border-radius: 5px;
+ -o-border-radius: 5px;
+ border-radius: 5px;
+}
+#footer {
+ -webkit-border-radius: 10px;
+ -moz-border-radius: 10px;
+ -ms-border-radius: 10px;
+ -o-border-radius: 10px;
+ border-radius: 10px;
+}
+#header h1 {
+ font-size: 26px;
+ font-weight: bold;
+}
+#header p {
+ font-size: 12px;
+}
+#header p a {
+ text-decoration: none;
+}
+#header p a:hover {
+ border-width: 1px;
+}
+#header {
+ color: #333333;
+ border-left: 1px;
+ border-right: 2px;
+}
+#footer {
+ color: #114411;
+ border-color: #7d2717;
+}
+body {
+ background-image: url(Magento_Theme::validation_advice_bg.gif);
+}
diff --git a/dev/tests/integration/testsuite/Magento/Css/PreProcessor/_files/oyejorge.less b/dev/tests/integration/testsuite/Magento/Css/PreProcessor/_files/oyejorge.less
new file mode 100644
index 0000000000000..447915d0cfaa5
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Css/PreProcessor/_files/oyejorge.less
@@ -0,0 +1,69 @@
+// Variables
+
+@color: #4D926F;
+
+#header {
+ color: @color;
+}
+
+h2 {
+ color: @color;
+}
+
+// Mixins
+
+.rounded-corners (@radius: 5px) {
+ -webkit-border-radius: @radius;
+ -moz-border-radius: @radius;
+ -ms-border-radius: @radius;
+ -o-border-radius: @radius;
+ border-radius: @radius;
+}
+
+#header {
+ .rounded-corners;
+}
+
+#footer {
+ .rounded-corners(10px);
+}
+
+// Nested Rules
+
+#header {
+ h1 {
+ font-size: 26px;
+ font-weight: bold;
+ }
+ p { font-size: 12px;
+ a {
+ text-decoration: none;
+ &:hover {
+ border-width: 1px;
+ }
+ }
+ }
+}
+
+// Functions & Operations
+
+@the-border: 1px;
+@base-color: #111;
+@red: #842210;
+
+#header {
+ color: (@base-color * 3);
+ border-left: @the-border;
+ border-right: (@the-border * 2);
+}
+
+#footer {
+ color: (@base-color + #003300);
+ border-color: desaturate(@red, 10%);
+}
+
+@import "nested/import.less";
+
+body {
+ background-image: @body-bg-img;
+}
diff --git a/dev/tests/integration/testsuite/Magento/Customer/Helper/ViewTest.php b/dev/tests/integration/testsuite/Magento/Customer/Helper/ViewTest.php
new file mode 100644
index 0000000000000..6ddbb8e40df16
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Customer/Helper/ViewTest.php
@@ -0,0 +1,141 @@
+_customerMetadataService = $this->getMock(
+ 'Magento\Customer\Service\V1\CustomerMetadataServiceInterface'
+ );
+ $this->_helper = Bootstrap::getObjectManager()->create(
+ 'Magento\Customer\Helper\View',
+ array('customerMetadataService' => $this->_customerMetadataService)
+ );
+ parent::setUp();
+ }
+
+ /**
+ * @param \Magento\Customer\Service\V1\Dto\Customer $customerDto
+ * @param string $expectedCustomerName
+ * @param bool $isPrefixAllowed
+ * @param bool $isMiddleNameAllowed
+ * @param bool $isSuffixAllowed
+ * @dataProvider getCustomerNameDataProvider
+ */
+ public function testGetCustomerName(
+ $customerDto,
+ $expectedCustomerName,
+ $isPrefixAllowed = false,
+ $isMiddleNameAllowed = false,
+ $isSuffixAllowed = false
+ ) {
+
+ $visibleAttribute = $this->getMock('Magento\Customer\Service\V1\Dto\Eav\AttributeMetadata', [], [], '', false);
+ $visibleAttribute->expects($this->any())->method('isVisible')->will($this->returnValue(true));
+
+ $invisibleAttribute = $this->getMock(
+ 'Magento\Customer\Service\V1\Dto\Eav\AttributeMetadata',
+ [],
+ [],
+ '',
+ false
+ );
+ $invisibleAttribute->expects($this->any())->method('isVisible')->will($this->returnValue(false));
+
+ $this->_customerMetadataService->expects($this->any())
+ ->method('getAttributeMetadata')
+ ->will(
+ $this->returnValueMap(
+ [
+ ['customer', 'prefix', $isPrefixAllowed ? $visibleAttribute : $invisibleAttribute],
+ ['customer', 'middlename', $isMiddleNameAllowed ? $visibleAttribute : $invisibleAttribute],
+ ['customer', 'suffix', $isSuffixAllowed ? $visibleAttribute : $invisibleAttribute],
+ ]
+ )
+ );
+
+ $this->assertEquals(
+ $expectedCustomerName,
+ $this->_helper->getCustomerName($customerDto),
+ 'Full customer name is invalid'
+ );
+ }
+
+ public function getCustomerNameDataProvider()
+ {
+ /** @var \Magento\Customer\Service\V1\Dto\CustomerBuilder $customerBuilder */
+ $customerBuilder = Bootstrap::getObjectManager()->create('Magento\Customer\Service\V1\Dto\CustomerBuilder');
+ return [
+ 'With disabled prefix, middle name, suffix' => [
+ $customerBuilder->setPrefix('prefix')
+ ->setFirstname('FirstName')
+ ->setMiddlename('MiddleName')
+ ->setLastname('LastName')
+ ->setSuffix('suffix')
+ ->create(),
+ 'FirstName LastName'
+ ],
+ 'With prefix, middle name, suffix' => [
+ $customerBuilder->setPrefix('prefix')
+ ->setFirstname('FirstName')
+ ->setMiddlename('MiddleName')
+ ->setLastname('LastName')
+ ->setSuffix('suffix')
+ ->create(),
+ 'prefix FirstName MiddleName LastName suffix',
+ true, // $isPrefixAllowed
+ true, // $isMiddleNameAllowed
+ true //$isSuffixAllowed
+ ],
+ 'Empty prefix, middle name, suffix' => [
+ $customerBuilder->setFirstname('FirstName')->setLastname('LastName')->create(),
+ 'FirstName LastName',
+ true, // $isPrefixAllowed
+ true, // $isMiddleNameAllowed
+ true //$isSuffixAllowed
+ ],
+ 'Empty prefix and suffix, not empty middle name' => [
+ $customerBuilder->setFirstname('FirstName')
+ ->setMiddlename('MiddleName')
+ ->setLastname('LastName')
+ ->create(),
+ 'FirstName MiddleName LastName',
+ true, // $isPrefixAllowed
+ true, // $isMiddleNameAllowed
+ true //$isSuffixAllowed
+ ],
+ ];
+ }
+}
diff --git a/dev/tests/integration/testsuite/Magento/Customer/Model/Metadata/FormTest.php b/dev/tests/integration/testsuite/Magento/Customer/Model/Metadata/FormTest.php
new file mode 100644
index 0000000000000..06d02c8b2a54f
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Customer/Model/Metadata/FormTest.php
@@ -0,0 +1,139 @@
+_formFactory = $objectManager
+ ->create('Magento\Customer\Model\Metadata\FormFactory');
+
+ $this->_requestData = [
+ 'id' => 14,
+ 'default_shipping' => true,
+ 'default_billing' => false,
+ 'company' => 'Company Name',
+ 'fax' => '(555) 555-5555',
+ 'middlename' => 'Mid',
+ 'prefix' => 'Mr.',
+ 'suffix' => 'Esq.',
+ 'vat_id' => 'S45',
+ 'firstname' => 'Jane',
+ 'lastname' => 'Doe',
+ 'street' => ['7700 W Parmer Ln'],
+ 'city' => 'Austin',
+ 'country_id' => 'US',
+ 'postcode' => '78620',
+ 'telephone' => '5125125125',
+ 'region_id' => 0,
+ 'region' => 'Texas',
+ ];
+
+ $this->_expected = $this->_requestData;
+ /** Unset data which is not part of the form */
+ unset($this->_expected['id']);
+ unset($this->_expected['default_shipping']);
+ unset($this->_expected['default_billing']);
+ unset($this->_expected['middlename']);
+ unset($this->_expected['prefix']);
+ unset($this->_expected['suffix']);
+
+ $this->_request = $objectManager->get('Magento\App\RequestInterface');
+ $this->_request->setParams($this->_requestData);
+ }
+
+ public function testCompactData()
+ {
+ $addressForm = $this->_formFactory->create(
+ 'customer_address',
+ 'customer_address_edit',
+ []
+ );
+ $addressData = $addressForm->extractData($this->_request);
+ $attributeValues = $addressForm->compactData($addressData);
+ $this->assertEquals($this->_expected, $attributeValues);
+ }
+
+ public function testGetAttributes()
+ {
+ $expectedAttributes = [
+ 'prefix', 'firstname', 'middlename', 'lastname', 'suffix', 'company', 'street', 'city', 'country_id',
+ 'region', 'region_id', 'postcode', 'telephone', 'fax', 'vat_id'
+ ];
+ $addressForm = $this->_formFactory->create(
+ 'customer_address',
+ 'customer_address_edit',
+ []
+ );
+ $this->assertEquals($expectedAttributes, array_keys($addressForm->getAttributes()));
+ }
+
+ public function testGetSystemAttributes()
+ {
+ $addressForm = $this->_formFactory->create(
+ 'customer_address',
+ 'customer_address_edit',
+ []
+ );
+ $this->assertCount(15, $addressForm->getSystemAttributes());
+ }
+
+ /**
+ * @magentoDataFixture Magento/Customer/_files/attribute_user_defined.php
+ */
+ public function testGetUserAttributes()
+ {
+ $expectedAttributes = ['user_attribute'];
+ $addressForm = $this->_formFactory->create(
+ 'customer_address',
+ 'customer_address_edit',
+ []
+ );
+ $this->assertEquals($expectedAttributes, array_keys($addressForm->getUserAttributes()));
+ }
+}
\ No newline at end of file
diff --git a/dev/tests/integration/testsuite/Magento/Customer/Service/CustomerTest.php b/dev/tests/integration/testsuite/Magento/Customer/Service/CustomerTest.php
deleted file mode 100644
index db32c7fcd5daa..0000000000000
--- a/dev/tests/integration/testsuite/Magento/Customer/Service/CustomerTest.php
+++ /dev/null
@@ -1,612 +0,0 @@
-_objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
- $this->_customerFactory = $this->_objectManager->get('Magento\Customer\Model\CustomerFactory');
- $this->_model = $this->_objectManager->create('Magento\Customer\Service\Customer');
- \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\App\State')->setAreaCode('frontend');
- }
-
- protected function tearDown()
- {
- $previousStoreId = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
- ->get('Magento\Core\Model\StoreManagerInterface')->getStore();
- if ($this->_createdCustomer && $this->_createdCustomer->getId() > 0) {
- \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Core\Model\App')
- ->loadArea(\Magento\Backend\App\Area\FrontNameResolver::AREA_CODE);
- $this->_createdCustomer->getAddressesCollection()->delete();
- $this->_createdCustomer->delete();
- }
- \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
- ->get('Magento\Core\Model\StoreManagerInterface')
- ->setCurrentStore($previousStoreId);
-
- $this->_model = null;
- }
-
- /**
- * @param array $customerData
- * @dataProvider createDataProvider
- * @magentoAppArea adminhtml
- */
- public function testCreate($customerData)
- {
- $this->_createdCustomer = $this->_model->create($customerData);
- $this->assertInstanceOf('Magento\Customer\Model\Customer', $this->_createdCustomer);
- $this->assertNotEmpty($this->_createdCustomer->getId());
-
- $loadedCustomer = $this->_customerFactory->create()
- ->load($this->_createdCustomer->getId());
- if (array_key_exists('sendemail', $customerData)) {
- unset($customerData['sendemail']);
- }
- $expectedData = $customerData;
- $actualData = $loadedCustomer->toArray(array_keys($customerData));
- if (isset($expectedData['password'])) {
- // TODO Add assertions for password if needed
- unset($expectedData['password'], $actualData['password']);
- }
- $this->assertEquals($expectedData, $actualData);
- }
-
- /**
- * @return array
- */
- public function createDataProvider()
- {
- return array(
- 'Valid data' => array(array(
- 'website_id' => 1,
- 'sendemail' => true,
- 'group_id' => 1,
- 'disable_auto_group_change' => 0,
- 'prefix' => 'Prefix',
- 'firstname' => 'Service',
- 'middlename' => 'Middlename',
- 'lastname' => 'CreateValid',
- 'suffix' => 'Suffix',
- 'email' => 'test' . mt_rand(1000, 9999) . '@mail.com',
- 'dob' => date('Y-m-d H:i:s'),
- 'taxvat' => null,
- 'gender' => 1,
- 'password' => '123123q',
- 'default_billing' => null,
- 'default_shipping' => null,
- 'store_id' => \Magento\Core\Model\Store::DEFAULT_STORE_ID
- )),
- 'Mandatory data' => array(array(
- 'firstname' => 'SomeName',
- 'lastname' => 'CreateMandatory',
- 'email' => 'test' . mt_rand(1000, 9999) . '@mail.com',
- )),
- );
- }
-
- /**
- * @param array $customerData
- * @param string $exceptionName
- * @param string $exceptionText
- * @dataProvider createExceptionsDataProvider
- */
- public function testCreateExceptions($customerData, $exceptionName, $exceptionText = '')
- {
- $this->setExpectedException($exceptionName, $exceptionText);
- $this->_createdCustomer = $this->_model->create($customerData);
- }
-
- /**
- * @return array
- */
- public function createExceptionsDataProvider()
- {
- return array(
- 'First name is required field' => array(array(
- 'website_id' => 0,
- 'group_id' => 1,
- 'disable_auto_group_change' => 0,
- 'prefix' => null,
- 'firstname' => null,
- 'lastname' => 'ServiceTestCreateExceptionFNR',
- 'suffix' => null,
- 'email' => 'test' . mt_rand(1000, 9999) . '@mail.com',
- 'password' => '123123q',
- 'store_id' => \Magento\Core\Model\Store::DEFAULT_STORE_ID
- ), 'Magento\Validator\ValidatorException'),
- 'Invalid email' => array(array(
- 'website_id' => 0,
- 'group_id' => 1,
- 'disable_auto_group_change' => 0,
- 'prefix' => null,
- 'firstname' => 'ServiceTestCreate',
- 'lastname' => 'ExceptionInvalidEmail',
- 'suffix' => null,
- 'email' => '111@111',
- 'password' => '123123q',
- 'store_id' => \Magento\Core\Model\Store::DEFAULT_STORE_ID
- ), 'Magento\Validator\ValidatorException'),
- 'Invalid password' => array(array(
- 'website_id' => 0,
- 'group_id' => 1,
- 'disable_auto_group_change' => 0,
- 'prefix' => null,
- 'firstname' => 'ServiceTestCreate',
- 'lastname' => 'ExceptionPassword',
- 'suffix' => null,
- 'email' => 'test' . mt_rand(1000, 9999) . '@mail.com',
- 'password' => '123',
- 'store_id' => \Magento\Core\Model\Store::DEFAULT_STORE_ID
- ), 'Magento\Eav\Model\Entity\Attribute\Exception', 'The password must have at least 6 characters.')
- );
- }
-
- /**
- * @param array $addressesData
- * @dataProvider createWithAddressesDataProvider
- */
- public function testCreateWithAddresses($addressesData)
- {
- $customerData = array(
- 'firstname' => 'ServiceTest',
- 'lastname' => 'CreateWithAddress',
- 'email' => 'test' . mt_rand(1000, 9999) . '@mail.com',
- );
-
- $this->_createdCustomer = $this->_model->create($customerData, $addressesData);
- $this->assertCount(count($addressesData), $this->_createdCustomer->getAddresses());
-
- /** @var \Magento\Customer\Model\Customer $loadedCustomer */
- $loadedCustomer = $this->_customerFactory->create()
- ->load($this->_createdCustomer->getId());
-
- $createdData = array();
- /** @var \Magento\Customer\Model\Address $address */
- foreach ($loadedCustomer->getAddresses() as $address) {
- $addressData = current($addressesData);
- $createdData[] = $address->toArray(array_keys($addressData));
- next($addressesData);
- }
-
- $this->assertEquals(
- $this->_getSortedByKey($createdData, 'firstname'),
- $this->_getSortedByKey($addressesData, 'firstname')
- );
- }
-
- /**
- * @param array $data
- * @param string $sortKey
- * @return array
- */
- protected function _getSortedByKey($data, $sortKey)
- {
- $callback = function ($elementOne, $elementTwo) use ($sortKey) {
- return strcmp($elementOne[$sortKey], $elementTwo[$sortKey]);
- };
- usort($data, $callback);
- return $data;
- }
-
- /**
- * @return array
- */
- public function createWithAddressesDataProvider()
- {
- return array(
- 'Two addresses' => array(
- array(
- array(
- 'prefix' => 'Mrs.',
- 'firstname' => 'Linda',
- 'middlename' => 'G.',
- 'lastname' => 'Jones',
- 'suffix' => 'Suffix',
- 'company' => 'Vitagee',
- 'street' => "3083 Eagles Nest Drive\nHoopa",
- 'country_id' => 'US',
- 'region_id' => '12', // California
- 'city' => 'Los Angeles',
- 'postcode' => '95546',
- 'fax' => '55512450056',
- 'telephone' => '55512450000',
- 'vat_id' => '556-70-1739',
- ),
- array(
- 'firstname' => 'John',
- 'lastname' => 'Smith',
- 'street' => 'Green str, 67',
- 'country_id' => 'AL',
- 'city' => 'CityM',
- 'postcode' => '75477',
- 'telephone' => '3468676',
- )
- )
- ),
- 'One address' => array(
- array(
- array(
- 'firstname' => 'John',
- 'lastname' => 'Smith',
- 'street' => 'Green str, 67',
- 'country_id' => 'AL',
- 'city' => 'CityM',
- 'postcode' => '75477',
- 'telephone' => '3468676',
- )
- )
- )
- );
- }
-
- /**
- * @expectedException \Magento\Core\Exception
- * @expectedExceptionMessage The address with the specified ID not found.
- */
- public function testCreateWithInvalidAddressId()
- {
- $customerData = array(
- 'firstname' => 'ServiceTest',
- 'lastname' => 'InvalidAddress',
- 'email' => 'test' . mt_rand(1000, 9999) . '@mail.com',
- );
-
- $addressData = array(
- 'entity_id' => 'fake',
- 'firstname' => 'John',
- 'lastname' => 'Smith',
- 'street' => 'Green str, 67',
- 'country_id' => 'AL',
- 'city' => 'CityM',
- 'postcode' => '75477',
- 'telephone' => '3468676',
- );
-
- $this->_createdCustomer = $this->_model->create($customerData, array($addressData));
- }
-
- /**
- * @param array $customerData
- * @magentoDataFixture Magento/Customer/_files/customer.php
- * @dataProvider updateDataProvider
- * @magentoAppArea frontend
- */
- public function testUpdate($customerData)
- {
- \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Core\Model\App')
- ->getArea(\Magento\Core\Model\App\Area::AREA_FRONTEND)->load();
- $expected = $this->_customerFactory->create()
- ->load(1);
-
- $updatedCustomer = $this->_model->update($expected->getId(), $customerData);
-
- $this->assertInstanceOf('Magento\Customer\Model\Customer', $updatedCustomer);
- $this->assertFalse($updatedCustomer->isObjectNew());
- $actualData = $this->_customerFactory->create()
- ->load($expected->getId())->getData();
- $expectedData = array_merge($updatedCustomer->toArray(array_keys($actualData)), $customerData);
- unset($expectedData['updated_at'], $actualData['updated_at']);
- if (isset($expectedData['password'])) {
- // TODO Add assertions for password if needed
- unset($expectedData['password'], $actualData['password']);
- }
- $this->assertEquals($expectedData, $actualData);
- }
-
- /**
- * @return array
- */
- public function updateDataProvider()
- {
- return array(
- 'Change name' => array(array(
- 'firstname' => 'SomeName2',
- )),
- 'Change password' => array(array(
- 'password' => '111111'
- )),
- 'Multiple properties' => array(array(
- 'disable_auto_group_change' => 0,
- 'prefix' => 'Prefix',
- 'firstname' => 'ServiceTest',
- 'middlename' => 'Middlename',
- 'lastname' => 'UpdateMultiple',
- 'suffix' => 'Suffix',
- 'email' => 'test' . mt_rand(1000, 9999) . '@mail.com',
- 'dob' => date('Y-m-d H:i:s'),
- 'gender' => 1,
- 'store_id' => \Magento\Core\Model\Store::DEFAULT_STORE_ID
- ))
- );
- }
-
- /**
- * @magentoDataFixture Magento/Customer/_files/customer.php
- */
- public function testUpdateFirstname()
- {
- $customer = $this->_customerFactory->create()->load(1);
- // This call to getAttributes will cause our test to fail if the
- // customer fixture was using attribute set 0 instead of 1
- $customer->getAttributes();
-
- $updatedCustomer = $this->_model->update(1, ['firstname' => 'new_name']);
-
- $customer = $this->_customerFactory->create()->load(1);
-
- $this->assertEquals('new_name', $customer->getFirstname());
- $this->assertEquals('new_name', $updatedCustomer->getFirstname());
- }
-
- /**
- * @param array $customerData
- * @param string $exceptionName
- * @param string $exceptionMessage
- * @magentoDataFixture Magento/Customer/_files/customer.php
- * @dataProvider updateExceptionsDataProvider
- */
- public function testUpdateExceptions($customerData, $exceptionName, $exceptionMessage = '')
- {
- \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Core\Model\App')
- ->getArea(\Magento\Core\Model\App\Area::AREA_FRONTEND)->load();
- $this->setExpectedException($exceptionName, $exceptionMessage);
- $this->_model->update(1, $customerData);
- }
-
- /**
- * @return array
- */
- public function updateExceptionsDataProvider()
- {
- return array(
- 'Invalid password' => array(
- array(
- 'password' => '111'
- ),
- 'Magento\Eav\Model\Entity\Attribute\Exception'
- ),
- 'Invalid name' => array(
- array(
- 'firstname' => null
- ),
- 'Magento\Validator\ValidatorException'
- ),
- 'Invalid email' => array(
- array(
- 'email' => '3434@23434'
- ),
- 'Magento\Validator\ValidatorException'
- )
- );
- }
-
- /**
- * @expectedException \Magento\Core\Exception
- * @expectedExceptionMessage The customer with the specified ID not found.
- */
- public function testUpdateInvalidCustomerId()
- {
- $this->_model->update(1, array('firstname' => 'Foo'));
- }
-
- /**
- * @magentoDataFixture Magento/Customer/_files/customer.php
- * @appAreaCode adminhtml
- */
- public function testAutoGeneratePassword()
- {
- $oldPasswordHash = $this->_customerFactory->create()
- ->load(1)
- ->getPasswordHash();
- $updatedCustomer = $this->_model->update(
- 1,
- array('autogenerate_password' => true,)
- );
- $this->assertNotEquals($oldPasswordHash, $updatedCustomer->getPasswordHash());
- }
-
- /**
- * @param array $addressesData
- * @dataProvider customerAddressDataProvider
- * @magentoDataFixture Magento/Customer/_files/customer.php
- * @magentoDataFixture Magento/Customer/_files/customer_two_addresses.php
- */
- public function testCustomerAddressManipulation($addressesData)
- {
- /** @var \Magento\Customer\Model\Customer $customer */
- $customer = $this->_customerFactory->create()
- ->load(1);
- $this->assertCount(2, $customer->getAddresses(), 'Not all customer addresses were created.');
- $updatedCustomer = $this->_model->update(1, array(), $addressesData);
- $this->assertCount(
- count($addressesData),
- $updatedCustomer->getAddresses(),
- 'Customer address was not deleted.'
- );
-
- /** @var \Magento\Customer\Model\Customer $actualCustomer */
- $actualCustomer = $this->_customerFactory->create()
- ->load(1);
- $actualAddresses = $actualCustomer->getAddresses();
- $this->assertCount(count($addressesData), $actualAddresses, 'Customer address was not actually deleted.');
-
- // Check that all addresses were updated correctly
- $updatedData = array();
- /** @var \Magento\Customer\Model\Address $address */
- $addressesData = $this->_getSortedByKey($addressesData, 'postcode');
- foreach ($this->_getSortedByKey($actualAddresses, 'postcode') as $address) {
- $addressData = current($addressesData);
- $updatedData[] = $address->toArray(array_keys($addressData));
- next($addressesData);
- }
- $this->assertEquals($addressesData, $updatedData, 'Customer addresses are incorrect.');
- }
-
- /**
- * @return array
- */
- public function customerAddressDataProvider()
- {
- return array(
- 'Addresses update' => array(
- array(
- array('entity_id' => 1, 'postcode' => '1000001'),
- array('entity_id' => 2, 'postcode' => '1000002')
- )
- ),
- 'First address delete' => array(
- array(
- array('entity_id' => 2)
- )
- ),
- 'First address update, second delete' => array(
- array(
- array('entity_id' => 1, 'city' => 'Updated city', 'postcode' => '1000001')
- )
- ),
- 'All addresses delete' => array(
- array()
- ),
- 'Addresses updated and one created' => array(
- array(
- array('entity_id' => 1, 'postcode' => '1000001'),
- array('entity_id' => 2, 'city' => 'Updated city', 'postcode' => '1000002')
- )
- ),
- 'Address updated, deleted and created' => array(
- array(
- array(
- 'firstname' => 'John',
- 'lastname' => 'Smith',
- 'street' => 'Green str, 67',
- 'country_id' => 'AL',
- 'city' => 'CityM',
- 'postcode' => '1000001',
- 'telephone' => '3468676'
- ),
- array('entity_id' => 2, 'city' => 'Updated city', 'postcode' => '1000002')
- )
- )
- );
- }
-
- /**
- * Test beforeSave and afterSave callback
- *
- * @magentoDataFixture Magento/Customer/_files/customer.php
- */
- public function testCallback()
- {
- $customer = $this->_customerFactory->create()
- ->load(1);
- $customerData = array('firstname' => 'Updated name');
- $customer->addData($customerData);
- $addressData = array(
- array(
- 'firstname' => 'John',
- 'lastname' => 'Smith',
- 'street' => 'Green str, 67',
- 'country_id' => 'AL',
- 'city' => 'CityM',
- 'postcode' => '75477',
- 'telephone' => '3468676',
- )
- );
-
- $callbackCount = 0;
- $callback = function ($actualCustomer, $actualData, $actualAddresses) use ($customer, $customerData,
- $addressData, &$callbackCount
- ) {
- $callbackCount++;
- // Remove updated_at as in afterSave updated_at may be changed
- $expectedCustomerData = $customer->getData();
- unset($expectedCustomerData['updated_at']);
- \PHPUnit_Framework_Assert::assertEquals(
- $expectedCustomerData,
- $actualCustomer->toArray(array_keys($expectedCustomerData))
- );
- \PHPUnit_Framework_Assert::assertEquals($customerData, $actualData);
- \PHPUnit_Framework_Assert::assertEquals($addressData, $actualAddresses);
- };
-
- $this->_model->setBeforeSaveCallback($callback);
- $this->_model->setAfterSaveCallback($callback);
- $this->_model->update(1, $customerData, $addressData);
- $this->assertEquals(2, $callbackCount, 'Not all expected callbacks were called.');
- }
-
- /**
- * @param bool $isAdminStore
- * @param boolean $isConfirmed
- * @dataProvider forceConfirmedDataProvider
- */
- public function testCustomerSetForceConfirmed($isAdminStore, $isConfirmed)
- {
- $this->_model->setIsAdminStore($isAdminStore);
- $customerData = array(
- 'firstname' => 'ServiceTest',
- 'lastname' => 'ForceConfirmed',
- 'email' => 'test' . mt_rand(1000, 9999) . '@mail.com',
- 'password' => '123123q'
- );
- $this->_createdCustomer = $this->_model->create($customerData);
- $this->assertEquals($isConfirmed, $this->_createdCustomer->getForceConfirmed());
- }
-
- /**
- * @return array
- */
- public function forceConfirmedDataProvider()
- {
- return array(
- 'admin store' => array(true, true),
- 'distro store' => array(false, false),
- );
- }
-}
diff --git a/dev/tests/integration/testsuite/Magento/Customer/Service/V1/CustomerAddressServiceTest.php b/dev/tests/integration/testsuite/Magento/Customer/Service/V1/CustomerAddressServiceTest.php
index 91fbe7dd24af9..79fe6c642b857 100644
--- a/dev/tests/integration/testsuite/Magento/Customer/Service/V1/CustomerAddressServiceTest.php
+++ b/dev/tests/integration/testsuite/Magento/Customer/Service/V1/CustomerAddressServiceTest.php
@@ -560,9 +560,9 @@ protected function _assertAddressAndRegionArrayEquals($expectedArray, $actualArr
// Either both set or both unset
$this->assertTrue(!(isset($expectedRegion) xor isset($actualRegion)));
if (isset($expectedRegion) && isset($actualRegion)) {
- $this->assertInstanceOf('Magento\Customer\Service\V1\Dto\Region', $expectedRegion);
- $this->assertInstanceOf('Magento\Customer\Service\V1\Dto\Region', $actualRegion);
- $this->assertEquals($expectedRegion->__toArray(), $actualRegion->__toArray());
+ $this->assertTrue(is_array($expectedRegion));
+ $this->assertTrue(is_array($actualRegion));
+ $this->assertEquals($expectedRegion, $actualRegion);
}
}
}
diff --git a/dev/tests/integration/testsuite/Magento/Customer/_files/attribute_user_defined.php b/dev/tests/integration/testsuite/Magento/Customer/_files/attribute_user_defined.php
new file mode 100644
index 0000000000000..2665b589a29d5
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Customer/_files/attribute_user_defined.php
@@ -0,0 +1,41 @@
+create('Magento\Customer\Model\Attribute');
+$model->setName('user_attribute')
+ ->setEntityTypeId(2)
+ ->setIsUserDefined(1);
+$model->save();
+
+/** @var \Magento\Customer\Model\Resource\Setup $setupResource */
+$setupResource = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
+ ->create('Magento\Customer\Model\Resource\Setup', ['resourceName' => 'customer_setup']);
+$data = [
+ ['form_code' => 'customer_address_edit', 'attribute_id' => $model->getAttributeId()]
+];
+$setupResource->getConnection()->insertMultiple($setupResource->getTable('customer_form_attribute'), $data);
diff --git a/dev/tests/integration/testsuite/Magento/Customer/_files/attribute_user_defined_customer.php b/dev/tests/integration/testsuite/Magento/Customer/_files/attribute_user_defined_customer.php
new file mode 100644
index 0000000000000..bd39d53312165
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Customer/_files/attribute_user_defined_customer.php
@@ -0,0 +1,39 @@
+create('Magento\Customer\Model\Attribute');
+
+$model->setName(FIXTURE_ATTRIBUTE_USER_DEFINED_CUSTOMER_NAME)
+ ->setEntityTypeId(1)
+ ->setIsUserDefined(1)
+ ->setAttributeSetId(1)
+ ->setAttributeGroupId(1)
+ ->setFrontendInput('text')
+ ->setFrontendLabel(FIXTURE_ATTRIBUTE_USER_DEFINED_CUSTOMER_FRONTEND_LABEL);
+
+$model->save();
diff --git a/dev/tests/integration/testsuite/Magento/Customer/_files/customer.php b/dev/tests/integration/testsuite/Magento/Customer/_files/customer.php
index 3f29b8530339b..2406dd079fa42 100644
--- a/dev/tests/integration/testsuite/Magento/Customer/_files/customer.php
+++ b/dev/tests/integration/testsuite/Magento/Customer/_files/customer.php
@@ -26,6 +26,7 @@
*/
$customer = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
->create('Magento\Customer\Model\Customer');
+/** @var Magento\Customer\Model\Customer $customer */
$customer
->setWebsiteId(1)
->setId(1)
diff --git a/dev/tests/integration/testsuite/Magento/Email/Model/TemplateTest.php b/dev/tests/integration/testsuite/Magento/Email/Model/TemplateTest.php
index 97dcaed5a057c..17e2c6923cb2f 100644
--- a/dev/tests/integration/testsuite/Magento/Email/Model/TemplateTest.php
+++ b/dev/tests/integration/testsuite/Magento/Email/Model/TemplateTest.php
@@ -57,7 +57,7 @@ protected function setUp()
$objectManager->create('Magento\View\Url'),
$objectManager->create('Magento\View\FileSystem'),
$objectManager->create('Magento\Core\Model\Store\Config'),
- $objectManager->create('Magento\Core\Model\Config'),
+ $objectManager->create('Magento\App\ConfigInterface'),
$objectManager->get('Magento\Email\Model\Template\FilterFactory'),
$objectManager->get('Magento\Email\Model\Template\Config'),
))
@@ -241,4 +241,15 @@ public function testSendTransactionalWrongId()
array('name' => 'Sender Name', 'email' => 'sender@example.com'), 'recipient@example.com', 'Recipient Name'
);
}
+
+ /**
+ * @magentoAppIsolation enabled
+ */
+ public function testGetDefaultEmailLogo()
+ {
+ $this->assertStringEndsWith(
+ 'static/frontend/magento_plushe/en_US/Magento_Email/logo_email.gif',
+ $this->_model->getDefaultEmailLogo()
+ );
+ }
}
diff --git a/dev/tests/integration/testsuite/Magento/ImportExport/Model/Export/AbstractStubEntity.php b/dev/tests/integration/testsuite/Magento/ImportExport/Model/Export/AbstractStubEntity.php
index a2c28a7d51d9f..aa1df9dd650ce 100644
--- a/dev/tests/integration/testsuite/Magento/ImportExport/Model/Export/AbstractStubEntity.php
+++ b/dev/tests/integration/testsuite/Magento/ImportExport/Model/Export/AbstractStubEntity.php
@@ -33,13 +33,14 @@
abstract class AbstractStubEntity
extends \Magento\ImportExport\Model\Export\AbstractEntity
{
- public function __construct()
- {
- /** @var \Magento\TestFramework\ObjectManager $objectManager */
- $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
-
- $storeConfig = $objectManager->get('Magento\Core\Model\Store\Config');
- parent::__construct($storeConfig);
+ public function __construct(
+ \Magento\Core\Model\Store\Config $coreStoreConfig,
+ \Magento\Core\Model\StoreManagerInterface $storeManager,
+ \Magento\ImportExport\Model\Export\Factory $collectionFactory,
+ \Magento\ImportExport\Model\Resource\CollectionByPagesIteratorFactory $resourceColFactory,
+ array $data = array()
+ ) {
+ parent::__construct($coreStoreConfig, $storeManager, $collectionFactory, $resourceColFactory, $data);
$this->_disabledAttrs = array('default_billing', 'default_shipping');
}
}
diff --git a/dev/tests/integration/testsuite/Magento/ImportExport/Model/Export/Entity/AbstractEavTest.php b/dev/tests/integration/testsuite/Magento/ImportExport/Model/Export/Entity/AbstractEavTest.php
index 9c33325ee8d9c..58ce685b18310 100644
--- a/dev/tests/integration/testsuite/Magento/ImportExport/Model/Export/Entity/AbstractEavTest.php
+++ b/dev/tests/integration/testsuite/Magento/ImportExport/Model/Export/Entity/AbstractEavTest.php
@@ -69,7 +69,7 @@ protected function setUp()
->will($this->returnValue($customerAttributes));
$this->_model->__construct(
$objectManager->get('Magento\Core\Model\Store\Config'),
- $objectManager->get('Magento\Core\Model\App'),
+ $objectManager->get('Magento\Core\Model\StoreManager'),
$objectManager->get('Magento\ImportExport\Model\Export\Factory'),
$objectManager->get('Magento\ImportExport\Model\Resource\CollectionByPagesIteratorFactory'),
$objectManager->get('Magento\Core\Model\LocaleInterface'),
diff --git a/dev/tests/integration/testsuite/Magento/ImportExport/Model/Export/EntityAbstractTest.php b/dev/tests/integration/testsuite/Magento/ImportExport/Model/Export/EntityAbstractTest.php
index f138f680278fd..e6c5e995a2bfb 100644
--- a/dev/tests/integration/testsuite/Magento/ImportExport/Model/Export/EntityAbstractTest.php
+++ b/dev/tests/integration/testsuite/Magento/ImportExport/Model/Export/EntityAbstractTest.php
@@ -46,7 +46,7 @@ protected function setUp()
$this->_model = $this->getMockForAbstractClass(
'Magento\ImportExport\Model\Export\AbstractEntity', array(
$objectManager->get('Magento\Core\Model\Store\Config'),
- $objectManager->get('Magento\Core\Model\App'),
+ $objectManager->get('Magento\Core\Model\StoreManager'),
$objectManager->get('Magento\ImportExport\Model\Export\Factory'),
$objectManager->get('Magento\ImportExport\Model\Resource\CollectionByPagesIteratorFactory'),
)
@@ -124,12 +124,12 @@ abstract class Stub_Magento_ImportExport_Model_Export_AbstractEntity
{
public function __construct(
\Magento\Core\Model\Store\Config $coreStoreConfig,
- \Magento\Core\Model\App $app,
+ \Magento\Core\Model\StoreManagerInterface $storeManager,
\Magento\ImportExport\Model\Export\Factory $collectionFactory,
\Magento\ImportExport\Model\Resource\CollectionByPagesIteratorFactory $resourceColFactory,
array $data = array()
) {
- parent::__construct($coreStoreConfig, $app, $collectionFactory, $resourceColFactory, $data);
+ parent::__construct($coreStoreConfig, $storeManager, $collectionFactory, $resourceColFactory, $data);
$this->_disabledAttrs = array('default_billing', 'default_shipping');
}
}
diff --git a/dev/tests/integration/testsuite/Magento/Indexer/Model/ShellTest.php b/dev/tests/integration/testsuite/Magento/Indexer/Model/ShellTest.php
new file mode 100644
index 0000000000000..026cedae4229e
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Indexer/Model/ShellTest.php
@@ -0,0 +1,111 @@
+create('Magento\Indexer\Model\Shell', array('entryPoint' => $entryPoint));
+ }
+
+ /**
+ * Returns result of running model - can be real model or mocked one
+ *
+ * @param \Magento\Indexer\Model\Shell $model Can be mock
+ * @return string
+ */
+ protected function runModel($model)
+ {
+ ob_start();
+ $model->run();
+ $result = ob_get_contents();
+ ob_end_clean();
+ return $result;
+ }
+
+ public function testGetUsageHelp()
+ {
+ $model = $this->getModel('testme.php');
+ $this->assertContains('testme.php', $model->getUsageHelp());
+ }
+
+ public function testRunWithoutParams()
+ {
+ $model = $this->getModel('testme.php');
+ $result = $this->runModel($model);
+ $this->assertContains('testme.php', $result);
+ $this->assertContains('index', $result); // Something about indexes
+ }
+
+ public function testRunIndexList()
+ {
+ $model = $this->getModel('testme.php');
+ $model->setRawArgs(array('testme.php', '--', 'status'));
+ $result = $this->runModel($model);
+
+ $this->assertNotContains('testme.php', $result);
+ $this->assertNotContains('Usage:', $result);
+
+ /** @var \Magento\Indexer\Model\Config $config */
+ $config = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Indexer\Model\Config');
+ foreach ($config->getAll() as $indexerData) {
+ $this->assertContains($indexerData['title'], $result);
+ }
+ }
+
+ /**
+ * @param string $param
+ * @param bool $expectedHasErrors
+ *
+ * @dataProvider hasErrorsDataProvider
+ */
+ public function testHasErrors($param, $expectedHasErrors)
+ {
+ $model = $this->getModel('testme.php');
+ $model->setRawArgs(array('testme.php', '--', $param));
+ $this->runModel($model);
+
+ $this->assertEquals($expectedHasErrors, $model->hasErrors());
+ }
+
+ /**
+ * @return array
+ */
+ public function hasErrorsDataProvider()
+ {
+ return array(
+ 'execution without issues' => array('info', false),
+ 'issue with wrong index' => array('--reindex=wrong_index_code', true),
+ );
+ }
+}
diff --git a/dev/tests/integration/testsuite/Magento/Less/File/Source/AggregatedTest.php b/dev/tests/integration/testsuite/Magento/Less/File/Source/AggregatedTest.php
new file mode 100644
index 0000000000000..42d0350ff8ebe
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Less/File/Source/AggregatedTest.php
@@ -0,0 +1,166 @@
+reinitialize(array(
+ \Magento\App\Filesystem::PARAM_APP_DIRS => array(
+ \Magento\App\Filesystem::PUB_LIB_DIR => array('path' => dirname(dirname(__DIR__)) . '/_files/lib'),
+ \Magento\App\Filesystem::THEMES_DIR => array('path' => dirname(dirname(__DIR__)) . '/_files/design'),
+ )
+ ));
+ $this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
+ $this->objectManager->get('Magento\App\State')->setAreaCode('frontend');
+
+ /** @var \Magento\Filesystem $filesystem */
+ $filesystem = $this->objectManager->create(
+ 'Magento\App\Filesystem',
+ array('directoryList' => $this->objectManager->create(
+ 'Magento\Filesystem\DirectoryList',
+ array(
+ 'root' => BP,
+ 'directories' => array(
+ \Magento\App\Filesystem::MODULES_DIR
+ => array('path' => dirname(dirname(__DIR__)) . '/_files/code')
+ )
+ )
+ ))
+ );
+
+ /** @var \Magento\Less\File\Source\Base $sourceBase */
+ $sourceBase = $this->objectManager->create('Magento\Less\File\Source\Base', array('filesystem' => $filesystem));
+ $this->model = $this->objectManager->create(
+ 'Magento\Less\File\Source\Aggregated',
+ array('baseFiles' => $sourceBase)
+ );
+ }
+
+ /**
+ * @magentoDataFixture Magento/Less/_files/themes.php
+ * @magentoAppIsolation enabled
+ * @magentoAppArea frontend
+ * @param string $path
+ * @param string $themeName
+ * @param string[] $expectedFiles
+ * @dataProvider getFilesDataProvider
+ */
+ public function testGetFiles($path, $themeName, $expectedFiles)
+ {
+ /** @var \Magento\View\Design\Theme\FlyweightFactory $themeFactory */
+ $themeFactory = $this->objectManager->get('Magento\View\Design\Theme\FlyweightFactory');
+ $theme = $themeFactory->create($themeName);
+ if (!count($expectedFiles)) {
+ $this->setExpectedException('LogicException', 'magento_import returns empty result by path doesNotExist');
+ }
+ $files = $this->model->getFiles($theme, $path);
+ $this->assertCount(count($expectedFiles), $files, 'Files number doesn\'t match');
+
+ /** @var $file \Magento\View\Layout\File */
+ foreach ($files as $file) {
+ if (!in_array($file->getFilename(), $expectedFiles)) {
+ $this->fail(sprintf('File "%s" is not expected but found', $file->getFilename()));
+ }
+ }
+ }
+
+ /**
+ * @return array
+ */
+ public function getFilesDataProvider()
+ {
+ return array(
+ array(
+ '1.file',
+ 'test_default',
+ array(
+ str_replace(
+ '\\',
+ '/',
+ dirname(dirname(__DIR__)) . '/_files/design/frontend/test_default/1.file'
+ ),
+ str_replace(
+ '\\',
+ '/',
+ dirname(dirname(__DIR__)) . '/_files/design/frontend/test_default/Magento_Module/1.file'
+ ),
+ str_replace(
+ '\\',
+ '/',
+ dirname(dirname(__DIR__)) . '/_files/design/frontend/test_parent/Magento_Second/1.file'
+ )
+ )
+ ),
+ array(
+ '2.file',
+ 'test_default',
+ array(
+ str_replace(
+ '\\',
+ '/',
+ dirname(dirname(__DIR__)) . '/_files/lib/2.file'
+ )
+ )
+ ),
+ array(
+ 'doesNotExist',
+ 'test_default',
+ array()
+ ),
+ array(
+ '3',
+ 'test_default',
+ array(
+ str_replace(
+ '\\',
+ '/',
+ dirname(dirname(__DIR__)) . '/_files/lib/3.less'
+ ),
+ str_replace(
+ '\\',
+ '/',
+ dirname(dirname(__DIR__)) . '/_files/code/Magento/Other/view/frontend/3.less'
+ ),
+ str_replace(
+ '\\',
+ '/',
+ dirname(dirname(__DIR__)) . '/_files/design/frontend/test_default/Magento_Third/3.less'
+ )
+ )
+ ),
+ );
+ }
+}
diff --git a/dev/tests/integration/testsuite/Magento/Less/PreProcessorTest.php b/dev/tests/integration/testsuite/Magento/Less/PreProcessorTest.php
new file mode 100644
index 0000000000000..338b380c4da36
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Less/PreProcessorTest.php
@@ -0,0 +1,67 @@
+reinitialize(array(
+ \Magento\App\Filesystem::PARAM_APP_DIRS => array(
+ \Magento\App\Filesystem::PUB_LIB_DIR => array('path' => __DIR__ . '/_files/lib'),
+ \Magento\App\Filesystem::THEMES_DIR => array('path' => __DIR__ . '/_files/design')
+ )
+ ));
+ $this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
+ $this->objectManager->get('Magento\App\State')->setAreaCode('frontend');
+ $this->model = $this->objectManager->create('Magento\Css\PreProcessor\Less');
+ }
+
+ /**
+ * @magentoDataFixture Magento/Less/_files/themes.php
+ * @magentoAppIsolation enabled
+ * @magentoAppArea frontend
+ */
+ public function testProcess()
+ {
+ /** @var $filesystem \Magento\Filesystem */
+ $filesystem = $this->objectManager->get('Magento\Filesystem');
+ $targetDirectory = $filesystem->getDirectoryWrite(\Magento\App\Filesystem::TMP_DIR);
+ $designParams = array('area' => 'frontend', 'theme' => 'test_pre_process');
+ $cssTargetFile = $this->model->process('source.css', $designParams, $targetDirectory);
+ /** @var $viewFilesystem \Magento\View\FileSystem */
+ $viewFilesystem = $this->objectManager->get('Magento\View\FileSystem');
+ $this->assertFileEquals($viewFilesystem->getViewFile('source.css', $designParams), $cssTargetFile);
+ }
+}
diff --git a/dev/tests/integration/testsuite/Magento/Less/_files/code/Magento/Other/view/frontend/3.less b/dev/tests/integration/testsuite/Magento/Less/_files/code/Magento/Other/view/frontend/3.less
new file mode 100644
index 0000000000000..8a382383c31ab
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Less/_files/code/Magento/Other/view/frontend/3.less
@@ -0,0 +1,25 @@
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Academic Free License (AFL 3.0)
+ * that is bundled with this package in the file LICENSE_AFL.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/afl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @category design
+ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
+ */
+
+// dummy less file for module
diff --git a/dev/tests/integration/testsuite/Magento/Less/_files/code/Magento/Third/view/frontend/3.less b/dev/tests/integration/testsuite/Magento/Less/_files/code/Magento/Third/view/frontend/3.less
new file mode 100644
index 0000000000000..8a382383c31ab
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Less/_files/code/Magento/Third/view/frontend/3.less
@@ -0,0 +1,25 @@
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Academic Free License (AFL 3.0)
+ * that is bundled with this package in the file LICENSE_AFL.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/afl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @category design
+ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
+ */
+
+// dummy less file for module
diff --git a/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_default/1.file b/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_default/1.file
new file mode 100644
index 0000000000000..e69de29bb2d1d
diff --git a/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_default/Magento_Module/1.file b/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_default/Magento_Module/1.file
new file mode 100644
index 0000000000000..e69de29bb2d1d
diff --git a/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_default/Magento_Third/3.less b/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_default/Magento_Third/3.less
new file mode 100644
index 0000000000000..8a382383c31ab
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_default/Magento_Third/3.less
@@ -0,0 +1,25 @@
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Academic Free License (AFL 3.0)
+ * that is bundled with this package in the file LICENSE_AFL.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/afl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @category design
+ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
+ */
+
+// dummy less file for module
diff --git a/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_default/theme.xml b/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_default/theme.xml
new file mode 100644
index 0000000000000..195d325c8a046
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_default/theme.xml
@@ -0,0 +1,30 @@
+
+
+
+ Test Default
+ 2.0.0.0
+ test_parent
+
diff --git a/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_parent/Magento_Module/1.file b/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_parent/Magento_Module/1.file
new file mode 100644
index 0000000000000..e69de29bb2d1d
diff --git a/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_parent/Magento_Second/1.file b/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_parent/Magento_Second/1.file
new file mode 100644
index 0000000000000..e69de29bb2d1d
diff --git a/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_parent/theme.xml b/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_parent/theme.xml
new file mode 100644
index 0000000000000..3c145f9932e6a
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_parent/theme.xml
@@ -0,0 +1,29 @@
+
+
+
+ Test Parent
+ 2.0.0.0
+
diff --git a/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_pre_process/Magento_Test/magento_import.less b/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_pre_process/Magento_Test/magento_import.less
new file mode 100644
index 0000000000000..c30ba74d76758
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_pre_process/Magento_Test/magento_import.less
@@ -0,0 +1,3 @@
+div.test {
+ color: white;
+}
diff --git a/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_pre_process/Magento_Test2/magento_import.less b/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_pre_process/Magento_Test2/magento_import.less
new file mode 100644
index 0000000000000..6a3e9e2b39191
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_pre_process/Magento_Test2/magento_import.less
@@ -0,0 +1,3 @@
+div.test2 {
+ color: black;
+}
diff --git a/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_pre_process/Magento_Test3/import.less b/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_pre_process/Magento_Test3/import.less
new file mode 100644
index 0000000000000..f3aa4e7b32d5d
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_pre_process/Magento_Test3/import.less
@@ -0,0 +1,3 @@
+div.module_test {
+ color: red;
+}
diff --git a/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_pre_process/less/import1.less b/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_pre_process/less/import1.less
new file mode 100644
index 0000000000000..b4478b6c352c6
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_pre_process/less/import1.less
@@ -0,0 +1,4 @@
+.class {
+ @import "less/import1/import1-1.less" screen and (max-width: 400px);
+ font-size: @importedSize; // use imported variable
+}
diff --git a/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_pre_process/less/import1/import1-1.less b/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_pre_process/less/import1/import1-1.less
new file mode 100644
index 0000000000000..f8f0233a38035
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_pre_process/less/import1/import1-1.less
@@ -0,0 +1,2 @@
+@importedSize: 12pt;
+h1 { color: green; }
diff --git a/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_pre_process/less/import2.less b/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_pre_process/less/import2.less
new file mode 100644
index 0000000000000..22c610b26f033
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_pre_process/less/import2.less
@@ -0,0 +1 @@
+// empty less file
diff --git a/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_pre_process/source.css b/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_pre_process/source.css
new file mode 100644
index 0000000000000..a7563807b03a4
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_pre_process/source.css
@@ -0,0 +1,21 @@
+.class {
+ font-size: 12pt;
+}
+.class h1 {
+ color: green;
+}
+div.module_test {
+ color: red;
+}
+div.magento_import_lib {
+ color: green;
+}
+div.test {
+ color: white;
+}
+div.test2 {
+ color: black;
+}
+.end_class {
+ color: white;
+}
\ No newline at end of file
diff --git a/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_pre_process/source.less b/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_pre_process/source.less
new file mode 100644
index 0000000000000..3a4243a100d7e
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_pre_process/source.less
@@ -0,0 +1,10 @@
+@import "less/import1.less";
+@import (less) "less/import2";
+@import "Magento_Test3::import";
+@import "less/not_existed_file.less";
+//@magento_import "magento_import.less";
+//@magento_import "not_existed_magento_import.less";
+
+.end_class {
+ color: white;
+}
diff --git a/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_pre_process/theme.xml b/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_pre_process/theme.xml
new file mode 100644
index 0000000000000..443fe26456d1c
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Less/_files/design/frontend/test_pre_process/theme.xml
@@ -0,0 +1,5 @@
+
+
+ Test Pre-Processor
+ 2.0.0.0
+
diff --git a/dev/tests/integration/testsuite/Magento/Less/_files/lib/1.file b/dev/tests/integration/testsuite/Magento/Less/_files/lib/1.file
new file mode 100644
index 0000000000000..e69de29bb2d1d
diff --git a/dev/tests/integration/testsuite/Magento/Less/_files/lib/2.file b/dev/tests/integration/testsuite/Magento/Less/_files/lib/2.file
new file mode 100644
index 0000000000000..e69de29bb2d1d
diff --git a/dev/tests/unit/testsuite/Magento/Core/Model/Layout/_files/layout/catalog_product_view_type_grouped.xml b/dev/tests/integration/testsuite/Magento/Less/_files/lib/3.less
similarity index 95%
rename from dev/tests/unit/testsuite/Magento/Core/Model/Layout/_files/layout/catalog_product_view_type_grouped.xml
rename to dev/tests/integration/testsuite/Magento/Less/_files/lib/3.less
index 72b04db7c2eb3..6be86a0cd5476 100644
--- a/dev/tests/unit/testsuite/Magento/Core/Model/Layout/_files/layout/catalog_product_view_type_grouped.xml
+++ b/dev/tests/integration/testsuite/Magento/Less/_files/lib/3.less
@@ -1,5 +1,3 @@
-
-
-
+
+// dummy less file
diff --git a/dev/tests/integration/testsuite/Magento/Less/_files/lib/magento_import.less b/dev/tests/integration/testsuite/Magento/Less/_files/lib/magento_import.less
new file mode 100644
index 0000000000000..4fb146ecbca04
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Less/_files/lib/magento_import.less
@@ -0,0 +1,3 @@
+div.magento_import_lib {
+ color: green;
+}
diff --git a/dev/tests/integration/testsuite/Magento/Less/_files/themes.php b/dev/tests/integration/testsuite/Magento/Less/_files/themes.php
new file mode 100644
index 0000000000000..4128e99dac866
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Less/_files/themes.php
@@ -0,0 +1,33 @@
+reinitialize(array(
+ \Magento\App\Filesystem::PARAM_APP_DIRS => array(
+ \Magento\App\Filesystem::THEMES_DIR => array('path' => __DIR__ . '/design')
+ )
+));
+$objectManger = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
+
+/** @var $registration \Magento\Core\Model\Theme\Registration */
+$registration = $objectManger->create('Magento\Core\Model\Theme\Registration');
+$registration->register('*/*/theme.xml');
diff --git a/dev/tests/integration/testsuite/Magento/Multishipping/Block/Checkout/OverviewTest.php b/dev/tests/integration/testsuite/Magento/Multishipping/Block/Checkout/OverviewTest.php
index 8be11c8f1876d..fe6a690fbe95d 100644
--- a/dev/tests/integration/testsuite/Magento/Multishipping/Block/Checkout/OverviewTest.php
+++ b/dev/tests/integration/testsuite/Magento/Multishipping/Block/Checkout/OverviewTest.php
@@ -45,7 +45,22 @@ protected function setUp()
$this->_objectManager->get('Magento\Core\Model\App')
->loadArea(\Magento\Core\Model\App\Area::AREA_FRONTEND);
$this->_block = $this->_objectManager->get('Magento\View\LayoutInterface')
- ->createBlock('Magento\Multishipping\Block\Checkout\Overview');
+ ->createBlock('Magento\Multishipping\Block\Checkout\Overview',
+ 'checkout_overview',
+ array('data' => array(
+ 'renderer_template' => 'Magento_Multishipping::checkout/item/default.phtml',
+ 'row_renderer_template' => 'Magento_Multishipping::checkout/overview/item.phtml'
+ ),
+ )
+ );
+
+ $this->_block->addChild('renderer.list', '\Magento\View\Element\RendererList');
+ $this->_block->getChildBlock('renderer.list')
+ ->addChild(
+ 'default',
+ '\Magento\Checkout\Block\Cart\Item\Renderer',
+ array('template' => 'cart/item/default.phtml')
+ );
}
public function testGetRowItemHtml()
diff --git a/dev/tests/integration/testsuite/Magento/Mview/View/ChangelogTest.php b/dev/tests/integration/testsuite/Magento/Mview/View/ChangelogTest.php
new file mode 100644
index 0000000000000..953b3e8fff0be
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Mview/View/ChangelogTest.php
@@ -0,0 +1,149 @@
+objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
+ $this->resource = $this->objectManager->get('Magento\App\Resource');
+ $this->connection = $this->resource->getConnection('core_write');
+
+ $this->model = $this->objectManager->create('Magento\Mview\View\Changelog', array(
+ 'resource' => $this->resource));
+ $this->model->setViewId('test_view_id_1');
+ $this->model->create();
+ }
+
+ public function tearDown()
+ {
+ $this->model->drop();
+ }
+
+ /**
+ * Test for create() and drop() methods
+ */
+ public function testCreateAndDrop()
+ {
+ $model = $this->objectManager->create('Magento\Mview\View\Changelog', array(
+ 'resource' => $this->resource));
+ $model->setViewId('test_view_id_2');
+ $changelogName = $this->connection->getTableName($model->getName());
+ $this->assertFalse($this->connection->isTableExists($changelogName));
+ $model->create();
+ $this->assertTrue($this->connection->isTableExists($changelogName));
+ $model->drop();
+ $this->assertFalse($this->connection->isTableExists($changelogName));
+ }
+
+ /**
+ * Test for getVersion() method
+ */
+ public function testGetVersion()
+ {
+ $model = $this->objectManager->create('Magento\Mview\View\Changelog', array(
+ 'resource' => $this->resource));
+ $model->setViewId('test_view_id_2');
+ $model->create();
+ $this->assertEquals(0, $model->getVersion());
+ $changelogName = $this->connection->getTableName($model->getName());
+ $this->connection->insert(
+ $changelogName,
+ array($model->getColumnName() => mt_rand(1, 200))
+ );
+ $this->assertEquals($this->connection->lastInsertId($changelogName, 'version_id'), $model->getVersion());
+ $model->drop();
+ }
+
+ /**
+ * Test for clear() method
+ */
+ public function testClear()
+ {
+ $this->assertEquals(0, $this->model->getVersion());//the same that a table is empty
+ $changelogName = $this->connection->getTableName($this->model->getName());
+ $this->connection->insert(
+ $changelogName,
+ array('version_id' => 1, 'entity_id' => 1)
+ );
+ $this->assertEquals(1, $this->model->getVersion());
+ $this->model->clear(1);
+ $this->assertEquals(0, $this->model->getVersion());//the same that a table is empty
+ }
+
+ /**
+ * Test for getList() method
+ */
+ public function testGetList()
+ {
+ $this->assertEquals(0, $this->model->getVersion());//the same that a table is empty
+ $changelogName = $this->connection->getTableName($this->model->getName());
+ $testChengelogData = array(
+ array('version_id' => 1, 'entity_id' => 1),
+ array('version_id' => 2, 'entity_id' => 1),
+ array('version_id' => 3, 'entity_id' => 2),
+ array('version_id' => 4, 'entity_id' => 3),
+ array('version_id' => 5, 'entity_id' => 1)
+ );
+ foreach ($testChengelogData as $data) {
+ $this->connection->insert(
+ $changelogName,
+ $data
+ );
+ }
+ $this->assertEquals(5, $this->model->getVersion());
+ $this->assertEquals(3, count($this->model->getList(0, 5)));//distinct entity_ids
+ $this->assertEquals(3, count($this->model->getList(2, 5)));//distinct entity_ids
+ $this->assertEquals(2, count($this->model->getList(0, 3)));//distinct entity_ids
+ $this->assertEquals(1, count($this->model->getList(0, 2)));//distinct entity_ids
+ $this->assertEquals(1, count($this->model->getList(2, 3)));//distinct entity_ids
+ $this->assertEquals(0, count($this->model->getList(4, 3)));//because fromVersionId > toVersionId
+ }
+}
diff --git a/dev/tests/integration/testsuite/Magento/Newsletter/Model/QueueTest.php b/dev/tests/integration/testsuite/Magento/Newsletter/Model/QueueTest.php
index 098a317fe9b9b..9be42c395e3d3 100644
--- a/dev/tests/integration/testsuite/Magento/Newsletter/Model/QueueTest.php
+++ b/dev/tests/integration/testsuite/Magento/Newsletter/Model/QueueTest.php
@@ -82,7 +82,7 @@ public function testSendPerSubscriber()
$objectManager->get('Magento\View\Url'),
$objectManager->get('Magento\View\FileSystem'),
$objectManager->get('Magento\Core\Model\Store\ConfigInterface'),
- $objectManager->get('Magento\Core\Model\ConfigInterface'),
+ $objectManager->get('Magento\App\ConfigInterface'),
$objectManager->get('Magento\Email\Model\Template\FilterFactory'),
$objectManager->get('Magento\Email\Model\Template\Config'),
)
@@ -128,7 +128,7 @@ public function testSendPerSubscriberProblem()
$objectManager->get('Magento\View\Url'),
$objectManager->get('Magento\View\FileSystem'),
$objectManager->get('Magento\Core\Model\Store\ConfigInterface'),
- $objectManager->get('Magento\Core\Model\ConfigInterface'),
+ $objectManager->get('Magento\App\ConfigInterface'),
$objectManager->get('Magento\Email\Model\Template\FilterFactory'),
$objectManager->get('Magento\Email\Model\Template\Config'),
)
diff --git a/dev/tests/integration/testsuite/Magento/Newsletter/Model/TemplateTest.php b/dev/tests/integration/testsuite/Magento/Newsletter/Model/TemplateTest.php
index 6a5d6d7910147..5e9b04ea05afb 100644
--- a/dev/tests/integration/testsuite/Magento/Newsletter/Model/TemplateTest.php
+++ b/dev/tests/integration/testsuite/Magento/Newsletter/Model/TemplateTest.php
@@ -56,7 +56,7 @@ public function testGetProcessedTemplateFrontend($store, $design)
{
$this->_model->setTemplateText('{{view url="Magento_Theme::favicon.ico"}}');
if ($store != 'default') {
- \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Core\Model\Config')
+ \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\App\ConfigInterface')
->setValue(\Magento\Core\Model\View\Design::XML_PATH_THEME_ID, $design, 'store', $store);
}
$this->_model->emulateDesign($store, 'frontend');
diff --git a/dev/tests/integration/testsuite/Magento/ObjectManager/Config/Reader/DomTest.php b/dev/tests/integration/testsuite/Magento/ObjectManager/Config/Reader/DomTest.php
index c4b9030ca36f4..2348135b9cb15 100644
--- a/dev/tests/integration/testsuite/Magento/ObjectManager/Config/Reader/DomTest.php
+++ b/dev/tests/integration/testsuite/Magento/ObjectManager/Config/Reader/DomTest.php
@@ -36,7 +36,7 @@ class DomTest extends \PHPUnit_Framework_TestCase
protected $_fileList;
/**
- * @var \Magento\App\Config\FileResolver\Primary
+ * @var \Magento\App\Arguments\FileResolver\Primary
*/
protected $_fileResolverMock;
@@ -46,7 +46,7 @@ class DomTest extends \PHPUnit_Framework_TestCase
protected $_mergedConfig;
/**
- * @var \Magento\App\Config\ValidationState
+ * @var \Magento\App\Arguments\ValidationState
*/
protected $_validationState;
@@ -69,12 +69,12 @@ protected function setUp()
);
$this->_fileResolverMock = $this->getMock(
- 'Magento\App\Config\FileResolver\Primary', array(), array(), '', false
+ 'Magento\App\Arguments\FileResolver\Primary', array(), array(), '', false
);
$this->_fileResolverMock->expects($this->once())->method('get')->will($this->returnValue($this->_fileList));
$this->_mapper = new \Magento\ObjectManager\Config\Mapper\Dom();
$this->_validationState =
- new \Magento\App\Config\ValidationState(\Magento\App\State::MODE_DEFAULT);
+ new \Magento\App\Arguments\ValidationState(\Magento\App\State::MODE_DEFAULT);
$this->_schemaLocator = new \Magento\ObjectManager\Config\SchemaLocator();
$this->_mergedConfig = new \DOMDocument();
diff --git a/dev/tests/integration/testsuite/Magento/ObjectManager/_files/config_merged.xml b/dev/tests/integration/testsuite/Magento/ObjectManager/_files/config_merged.xml
index 5f8aeca041936..b5df256812e82 100644
--- a/dev/tests/integration/testsuite/Magento/ObjectManager/_files/config_merged.xml
+++ b/dev/tests/integration/testsuite/Magento/ObjectManager/_files/config_merged.xml
@@ -26,22 +26,22 @@
-
+
- Magento\App\Config\Loader::PARAM_CUSTOM_FILE
+ Magento\App\Arguments\Loader::PARAM_CUSTOM_FILE
-
+
someCustomValue
-
- one
- two
- three
-
+
+ - one
+ - two
+ - three
+
@@ -50,21 +50,21 @@
-
+
- Magento\App\Config\Loader::PARAM_CUSTOM_FILE
+ Magento\App\Arguments\Loader::PARAM_CUSTOM_FILE
-
+
someValue
-
- one
- one
-
+
+ - one
+ - one
+
@@ -74,16 +74,17 @@
86400
-
- Magento\Core\Model\Website::CACHE_TAG
- 1
- 10
- 1
- 0
- 100500
-
- Az-Value
-
+
+ - Magento\Core\Model\Website::CACHE_TAG
+ - 1
+ - 10
+ - 1
+ - 0
+ - 100500
+ -
+
+ - Az-Value
+
Magento\Core\Model\Website::CACHE_TAG
diff --git a/dev/tests/integration/testsuite/Magento/ObjectManager/_files/config_one.xml b/dev/tests/integration/testsuite/Magento/ObjectManager/_files/config_one.xml
index fa6ba1d3c619c..537a259f5d98b 100644
--- a/dev/tests/integration/testsuite/Magento/ObjectManager/_files/config_one.xml
+++ b/dev/tests/integration/testsuite/Magento/ObjectManager/_files/config_one.xml
@@ -25,40 +25,40 @@
-->
-
+
- Magento\App\Config\Loader::PARAM_CUSTOM_FILE
+ Magento\App\Arguments\Loader::PARAM_CUSTOM_FILE
-
+
someValue
-
- one
- two
-
+
+ - one
+ - two
+
-
+
- Magento\App\Config\Loader::PARAM_CUSTOM_FILE
+ Magento\App\Arguments\Loader::PARAM_CUSTOM_FILE
-
+
someValue
-
- one
- one
-
+
+ - one
+ - one
+
@@ -67,16 +67,17 @@
86400
-
- Magento\Core\Model\Website::CACHE_TAG
- false
- true
- 1
- 0
- 100500
-
- az-value
-
+
+ - Magento\Core\Model\Website::CACHE_TAG
+ - false
+ - true
+ - 1
+ - 0
+ - 100500
+ -
+
+ - az-value
+
Magento\Core\Model\Website::CACHE_TAG
diff --git a/dev/tests/integration/testsuite/Magento/ObjectManager/_files/config_two.xml b/dev/tests/integration/testsuite/Magento/ObjectManager/_files/config_two.xml
index d042d171b992d..ec263ed2e08d3 100644
--- a/dev/tests/integration/testsuite/Magento/ObjectManager/_files/config_two.xml
+++ b/dev/tests/integration/testsuite/Magento/ObjectManager/_files/config_two.xml
@@ -26,43 +26,43 @@
-
+
- Magento\App\Config\Loader::PARAM_CUSTOM_FILE
+ Magento\App\Arguments\Loader::PARAM_CUSTOM_FILE
paramValue
-
+
someCustomValue
-
- three
-
+
+ - three
+
-
+
-
- Magento\Core\Model\Website::CACHE_TAG
- 1
- 10
- 1
- 0
- Az-Value
-
+
+ - Magento\Core\Model\Website::CACHE_TAG
+ - 1
+ - 10
+ - 1
+ - 0
+ - Az-Value
+
Magento\Core\Model\Website::CACHE_TAG
diff --git a/dev/tests/integration/testsuite/Magento/Payment/Model/ObserverTest.php b/dev/tests/integration/testsuite/Magento/Payment/Model/ObserverTest.php
index 44079d3929f91..c4f04d7fa79b5 100644
--- a/dev/tests/integration/testsuite/Magento/Payment/Model/ObserverTest.php
+++ b/dev/tests/integration/testsuite/Magento/Payment/Model/ObserverTest.php
@@ -147,7 +147,7 @@ protected function _createEventObserver()
*/
protected function _resetConfig()
{
- $this->_objectManager->get('Magento\Core\Model\Config')->reinit();
+ $this->_objectManager->get('Magento\App\ReinitableConfigInterface')->reinit();
$this->_objectManager->create('Magento\Core\Model\StoreManagerInterface')->reinitStores();
}
}
diff --git a/dev/tests/integration/testsuite/Magento/Paypal/Model/VoidTest.php b/dev/tests/integration/testsuite/Magento/Paypal/Model/VoidTest.php
index 04ff1b1024a63..045ff23643a33 100644
--- a/dev/tests/integration/testsuite/Magento/Paypal/Model/VoidTest.php
+++ b/dev/tests/integration/testsuite/Magento/Paypal/Model/VoidTest.php
@@ -31,7 +31,7 @@ class VoidTest extends \PHPUnit_Framework_TestCase
{
/**
* @magentoDataFixture Magento/Paypal/_files/order_payflowpro.php
- * @magentoConfigFixture current_store payment/verisign/active 1
+ * @magentoConfigFixture current_store payment/payflowpro/active 1
*/
public function testPayflowProVoid()
{
diff --git a/dev/tests/integration/testsuite/Magento/Rss/Controller/CatalogTest.php b/dev/tests/integration/testsuite/Magento/Rss/Controller/CatalogTest.php
index df036d6566db0..bcf967df8f3e2 100644
--- a/dev/tests/integration/testsuite/Magento/Rss/Controller/CatalogTest.php
+++ b/dev/tests/integration/testsuite/Magento/Rss/Controller/CatalogTest.php
@@ -89,7 +89,7 @@ public function testSalesruleAction()
*/
public function testAuthorizationFailed($action)
{
- \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Backend\Model\Url')
+ \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Backend\Model\UrlInterface')
->turnOffSecretKey();
$this->dispatch("backend/rss/catalog/{$action}");
$this->assertHeaderPcre('Http/1.1', '/^401 Unauthorized$/');
@@ -172,7 +172,7 @@ protected function _loginAdmin()
'PHP_AUTH_USER' => \Magento\TestFramework\Bootstrap::ADMIN_NAME,
'PHP_AUTH_PW' => \Magento\TestFramework\Bootstrap::ADMIN_PASSWORD
));
- \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Backend\Model\Url')
+ \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Backend\Model\UrlInterface')
->turnOffSecretKey();
}
}
diff --git a/dev/tests/integration/testsuite/Magento/Sales/Block/Adminhtml/Billing/Agreement/View/Tab/InfoTest.php b/dev/tests/integration/testsuite/Magento/Sales/Block/Adminhtml/Billing/Agreement/View/Tab/InfoTest.php
new file mode 100644
index 0000000000000..3681157a1edf7
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Sales/Block/Adminhtml/Billing/Agreement/View/Tab/InfoTest.php
@@ -0,0 +1,51 @@
+create('Magento\Sales\Model\Resource\Billing\Agreement\Collection')
+ ->load();
+ $agreementId = $billingAgreementCollection->getFirstItem()->getId();
+ $this->dispatch('backend/sales/billing_agreement/view/agreement/' . $agreementId);
+
+ $this->assertSelectCount('a[name="billing_agreement_info"]', 1, $this->getResponse()->getBody(),
+ 'Response for billing agreement info doesn\'t contain billing agreement info tab');
+
+ $this->assertSelectRegExp('a', '/customer\@example.com/', 1, $this->getResponse()->getBody(),
+ 'Response for billing agreement info doesn\'t contain Customer info');
+ }
+}
diff --git a/dev/tests/integration/testsuite/Magento/Sales/Block/Adminhtml/Order/Create/Form/AbstractTest.php b/dev/tests/integration/testsuite/Magento/Sales/Block/Adminhtml/Order/Create/Form/AbstractTest.php
index cec7372bb0db0..87ad1531c123b 100644
--- a/dev/tests/integration/testsuite/Magento/Sales/Block/Adminhtml/Order/Create/Form/AbstractTest.php
+++ b/dev/tests/integration/testsuite/Magento/Sales/Block/Adminhtml/Order/Create/Form/AbstractTest.php
@@ -68,11 +68,11 @@ public function testAddAttributesToForm()
'data' => array(
'attribute_code' => 'date',
'backend_type' => 'datetime',
- 'frontend_input' => 'date',
+ 'front_end_input' => 'date',
'frontend_label' => 'Date',
)
);
- $dateAttribute = $objectManager->create('Magento\Customer\Model\Attribute', $arguments);
+ $dateAttribute = $objectManager->create('\Magento\Customer\Service\V1\Dto\Eav\AttributeMetadata', $arguments);
$attributes = array('date' => $dateAttribute);
$method->invoke($block, $attributes, $fieldset);
diff --git a/dev/tests/integration/testsuite/Magento/Sales/Block/Adminhtml/Order/Create/Form/AccountTest.php b/dev/tests/integration/testsuite/Magento/Sales/Block/Adminhtml/Order/Create/Form/AccountTest.php
new file mode 100644
index 0000000000000..81fd50b4e49dc
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Sales/Block/Adminhtml/Order/Create/Form/AccountTest.php
@@ -0,0 +1,83 @@
+_objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
+ $quote = $this->_objectManager->create('Magento\Sales\Model\Quote')->load(1);
+ $sessionQuoteMock = $this->getMockBuilder('Magento\Backend\Model\Session\Quote')
+ ->disableOriginalConstructor()
+ ->setMethods(['getCustomerId', 'getStore', 'getStoreId', 'getQuote'])
+ ->getMock();
+ $sessionQuoteMock->expects($this->any())
+ ->method('getCustomerId')
+ ->will($this->returnValue(1));
+ $sessionQuoteMock->expects($this->any())
+ ->method('getQuote')
+ ->will($this->returnValue($quote));
+ /** @var \Magento\View\LayoutInterface $layout */
+ $layout = $this->_objectManager->get('Magento\View\LayoutInterface');
+ $this->_accountBlock = $layout->createBlock(
+ 'Magento\Sales\Block\Adminhtml\Order\Create\Form\Account',
+ 'address_block' . rand(),
+ ['sessionQuote' => $sessionQuoteMock]
+ );
+ parent::setUp();
+ }
+
+ /**
+ * @magentoDataFixture Magento/Customer/_files/customer.php
+ */
+ public function testGetForm()
+ {
+ $expectedFields = ['group_id', 'email'];
+ $form = $this->_accountBlock->getForm();
+ $this->assertEquals(1, $form->getElements()->count(), "Form has invalid number of fieldsets");
+ $fieldset = $form->getElements()[0];
+
+ $this->assertEquals(count($expectedFields), $fieldset->getElements()->count());
+
+ foreach ($fieldset->getElements() as $element) {
+ $this->assertTrue(
+ in_array($element->getId(), $expectedFields),
+ sprintf('Unexpected field "%s" in form.', $element->getId())
+ );
+ }
+ }
+}
\ No newline at end of file
diff --git a/dev/tests/integration/testsuite/Magento/Sales/Block/Adminhtml/Order/Create/Form/AddressTest.php b/dev/tests/integration/testsuite/Magento/Sales/Block/Adminhtml/Order/Create/Form/AddressTest.php
new file mode 100644
index 0000000000000..f49275b3c3828
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Sales/Block/Adminhtml/Order/Create/Form/AddressTest.php
@@ -0,0 +1,181 @@
+_objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
+ $this->_addressService = $this->getMock(
+ 'Magento\Customer\Service\V1\CustomerAddressServiceInterface'
+ );
+ /** @var \Magento\View\LayoutInterface $layout */
+ $layout = $this->_objectManager->get('Magento\View\LayoutInterface');
+ $sessionQuoteMock = $this->getMockBuilder('Magento\Backend\Model\Session\Quote')
+ ->disableOriginalConstructor()
+ ->setMethods(['getCustomerId', 'getStore', 'getStoreId', 'getQuote'])
+ ->getMock();
+ $sessionQuoteMock->expects($this->any())
+ ->method('getCustomerId')
+ ->will($this->returnValue(1));
+
+ $this->_addressBlock = $layout->createBlock(
+ 'Magento\Sales\Block\Adminhtml\Order\Create\Form\Address',
+ 'address_block' . rand(),
+ array('addressService' => $this->_addressService, 'sessionQuote' => $sessionQuoteMock)
+ );
+ parent::setUp();
+ }
+
+ public function testGetAddressCollection()
+ {
+ $addressDtos = $this->_getAddresses();
+ $this->_addressService->expects($this->any())->method('getAddresses')->will($this->returnValue($addressDtos));
+ $this->assertEquals($addressDtos, $this->_addressBlock->getAddressCollection());
+ }
+
+ public function testGetAddressCollectionJson()
+ {
+ $addressDtos = $this->_getAddresses();
+ $this->_addressService->expects($this->any())->method('getAddresses')->will($this->returnValue($addressDtos));
+ $expectedOutput = '[
+ {
+ "firstname": false,
+ "lastname": false,
+ "company": false,
+ "street": "",
+ "city": false,
+ "country_id": "US",
+ "region": false,
+ "region_id": false,
+ "postcode": false,
+ "telephone": false,
+ "fax": false,
+ "vat_id": false
+ },
+ {
+ "firstname": "FirstName1",
+ "lastname": "LastName1",
+ "company": false,
+ "street": "Street1",
+ "city": false,
+ "country_id": false,
+ "region": false,
+ "region_id": false,
+ "postcode": false,
+ "telephone": false,
+ "fax": false,
+ "vat_id": false
+ },
+ {
+ "firstname": "FirstName2",
+ "lastname": "LastName2",
+ "company": false,
+ "street": "Street2",
+ "city": false,
+ "country_id": false,
+ "region": false,
+ "region_id": false,
+ "postcode": false,
+ "telephone": false,
+ "fax": false,
+ "vat_id": false
+ }
+ ]';
+ $expectedOutput = str_replace(array(' ', "\n", "\r"), '', $expectedOutput);
+ $expectedOutput = str_replace(': ', ':', $expectedOutput);
+
+ $this->assertEquals($expectedOutput, $this->_addressBlock->getAddressCollectionJson());
+ }
+
+ public function testGetAddressAsString()
+ {
+ $address = $this->_getAddresses()[0];
+ $expectedResult = "FirstName1 LastName1, Street1, , , ";
+ $this->assertEquals($expectedResult, $this->_addressBlock->getAddressAsString($address));
+ }
+
+ /**
+ * Test \Magento\Sales\Block\Adminhtml\Order\Create\Form\Address::_prepareForm() indirectly.
+ */
+ public function testGetForm()
+ {
+ $expectedFields = ['prefix', 'firstname', 'middlename', 'lastname', 'suffix', 'company', 'street', 'city',
+ 'country_id', 'region', 'region_id', 'postcode', 'telephone', 'fax', 'vat_id'];
+ $form = $this->_addressBlock->getForm();
+ $this->assertEquals(1, $form->getElements()->count(), "Form has invalid number of fieldsets");
+ /** @var \Magento\Data\Form\Element\Fieldset $fieldset */
+ $fieldset = $form->getElements()[0];
+ $this->assertEquals(
+ count($expectedFields),
+ $fieldset->getElements()->count(),
+ "Form has invalid number of fields"
+ );
+ /** @var \Magento\Data\Form\Element\AbstractElement $element */
+ foreach ($fieldset->getElements() as $element) {
+ $this->assertTrue(
+ in_array($element->getId(), $expectedFields),
+ sprintf('Unexpected field "%s" in form.', $element->getId())
+ );
+ }
+
+ /** @var \Magento\Data\Form\Element\Select $countryIdField */
+ $countryIdField = $fieldset->getElements()->searchById('country_id');
+ $this->assertSelectCount('option', 247, $countryIdField->getElementHtml());
+ }
+
+ /**
+ * @return \Magento\Customer\Service\V1\Dto\Address[]
+ */
+ protected function _getAddresses()
+ {
+ /** @var \Magento\Customer\Service\V1\Dto\AddressBuilder $addressBuilder */
+ $addressBuilder = $this->_objectManager->create('Magento\Customer\Service\V1\Dto\AddressBuilder');
+ $addressBuilder->populateWithArray(
+ array('id' => 1, 'street' => 'Street1', 'firstname' => 'FirstName1', 'lastname' => 'LastName1')
+ );
+ $addressDtos[] = $addressBuilder->create();
+ $addressBuilder->populateWithArray(
+ array('id' => 2, 'street' => 'Street2', 'firstname' => 'FirstName2', 'lastname' => 'LastName2')
+ );
+ $addressDtos[] = $addressBuilder->create();
+ return $addressDtos;
+ }
+}
diff --git a/dev/tests/integration/testsuite/Magento/Sales/Block/Adminhtml/Order/Create/FormTest.php b/dev/tests/integration/testsuite/Magento/Sales/Block/Adminhtml/Order/Create/FormTest.php
new file mode 100644
index 0000000000000..c59abe386d0b4
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Sales/Block/Adminhtml/Order/Create/FormTest.php
@@ -0,0 +1,163 @@
+_objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
+
+ $sessionMock = $this->getMockBuilder('Magento\Backend\Model\Session\Quote')
+ ->disableOriginalConstructor()
+ ->setMethods(['getCustomerId', 'getQuote', 'getStoreId', 'getStore'])
+ ->getMock();
+ $sessionMock->expects($this->any())
+ ->method('getCustomerId')
+ ->will($this->returnValue(1));
+
+ $quote = $this->_objectManager->create('Magento\Sales\Model\Quote')->load(1);
+ $sessionMock->expects($this->any())
+ ->method('getQuote')
+ ->will($this->returnValue($quote));
+
+ $sessionMock->expects($this->any())
+ ->method('getStoreId')
+ ->will($this->returnValue(1));
+
+ $storeMock = $this->getMockBuilder('\Magento\Core\Model\Store')
+ ->disableOriginalConstructor()
+ ->setMethods(['getCurrentCurrencyCode'])
+ ->getMock();
+ $storeMock->expects($this->any())
+ ->method('getCurrentCurrencyCode')
+ ->will($this->returnValue('USD'));
+ $sessionMock->expects($this->any())
+ ->method('getStore')
+ ->will($this->returnValue($storeMock));
+
+ /** @var \Magento\View\LayoutInterface $layout */
+ $layout = $this->_objectManager->get('Magento\View\LayoutInterface');
+ $this->_orderCreateBlock = $layout->createBlock(
+ 'Magento\Sales\Block\Adminhtml\Order\Create\Form',
+ 'order_create_block' . rand(),
+ ['sessionQuote' => $sessionMock]
+ );
+ parent::setUp();
+ }
+
+ /**
+ * @magentoDataFixture Magento/Customer/_files/customer.php
+ */
+ public function testOrderDataJson()
+ {
+ /** @var array $addressIds */
+ $addressIds = $this->setUpMockAddress();
+ $orderDataJson = $this->_orderCreateBlock->getOrderDataJson();
+ $expectedOrderDataJson = <<< ORDER_DATA_JSON
+ {
+ "customer_id":1,
+ "addresses":
+ {"{$addressIds[0]}":
+ {"firstname":"John","lastname":"Smith","company":false,"street":"Green str, 67","city":"CityM",
+ "country_id":"US",
+ "region":{"region_code":"AL","region":"Alabama","region_id":1},
+ "region_id":false,"postcode":"75477","telephone":"3468676","fax":false,"vat_id":false},
+ "{$addressIds[1]}":
+ {"firstname":"John","lastname":"Smith","company":false,"street":"Black str, 48","city":"CityX",
+ "country_id":"US",
+ "region":{"region_code":"AL","region":"Alabama","region_id":1},
+ "region_id":false,"postcode":"47676","telephone":"3234676","fax":false,"vat_id":false}
+ },
+ "store_id":1,"currency_symbol":"$","shipping_method_reseted":true,"payment_method":null
+ }
+ORDER_DATA_JSON;
+
+ $this->assertEquals(json_decode($expectedOrderDataJson), json_decode($orderDataJson));
+ }
+
+ private function setUpMockAddress()
+ {
+ /** @var \Magento\Customer\Service\V1\Dto\AddressBuilder $addressBuilder */
+ $addressBuilder = $this->_objectManager->create('Magento\Customer\Service\V1\Dto\AddressBuilder');
+ /** @var \Magento\Customer\Service\V1\CustomerAddressServiceInterface $addressService */
+ $addressService = $this->_objectManager->create('Magento\Customer\Service\V1\CustomerAddressServiceInterface');
+
+ $addressDto1 = $addressBuilder->setId(1)
+ ->setCountryId('US')
+ ->setCustomerId(1)
+ ->setDefaultBilling(true)
+ ->setDefaultShipping(true)
+ ->setPostcode('75477')
+ ->setRegion(
+ new V1\Dto\Region([
+ 'region_code' => 'AL',
+ 'region' => 'Alabama',
+ 'region_id' => 1
+ ])
+ )
+ ->setStreet(['Green str, 67'])
+ ->setTelephone('3468676')
+ ->setCity('CityM')
+ ->setFirstname('John')
+ ->setLastname('Smith')
+ ->create();
+
+ $addressDto2 = $addressBuilder->setId(2)
+ ->setCountryId('US')
+ ->setCustomerId(1)
+ ->setDefaultBilling(false)
+ ->setDefaultShipping(false)
+ ->setPostcode('47676')
+ ->setRegion(
+ new V1\Dto\Region([
+ 'region_code' => 'AL',
+ 'region' => 'Alabama',
+ 'region_id' => 1
+ ])
+ )
+ ->setStreet(['Black str, 48'])
+ ->setCity('CityX')
+ ->setTelephone('3234676')
+ ->setFirstname('John')
+ ->setLastname('Smith')
+ ->create();
+
+ return $addressService->saveAddresses(1, [$addressDto1, $addressDto2]);
+ }
+}
\ No newline at end of file
diff --git a/dev/tests/integration/testsuite/Magento/Sales/Block/Adminhtml/Order/Create/HeaderTest.php b/dev/tests/integration/testsuite/Magento/Sales/Block/Adminhtml/Order/Create/HeaderTest.php
new file mode 100644
index 0000000000000..1bb447d55b06c
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Sales/Block/Adminhtml/Order/Create/HeaderTest.php
@@ -0,0 +1,74 @@
+_block = Bootstrap::getObjectManager()->create('Magento\Sales\Block\Adminhtml\Order\Create\Header');
+ parent::setUp();
+ }
+
+ /**
+ * @param int|null $customerId
+ * @param int|null $storeId
+ * @param string $expectedResult
+ * @magentoDataFixture Magento/Customer/_files/customer.php
+ * @dataProvider toHtmlDataProvider
+ */
+ public function testToHtml($customerId, $storeId, $expectedResult)
+ {
+ /** @var \Magento\Backend\Model\Session\Quote $session */
+ $session = Bootstrap::getObjectManager()->get('Magento\Backend\Model\Session\Quote');
+ $session->setCustomerId($customerId);
+ $session->setStoreId($storeId);
+ $this->assertEquals($expectedResult, $this->_block->toHtml());
+ }
+
+ public function toHtmlDataProvider()
+ {
+ $customerIdFromFixture = 1;
+ $defaultStoreView = 1;
+ return [
+ 'Customer and store' => [
+ $customerIdFromFixture,
+ $defaultStoreView,
+ 'Create New Order for Firstname Lastname in Default Store View'
+ ],
+ 'No store' => [$customerIdFromFixture, null, 'Create New Order for Firstname Lastname'],
+ 'No customer' => [null, $defaultStoreView, 'Create New Order for New Customer in Default Store View'],
+ 'No customer, no store' => [null, null, 'Create New Order for New Customer'],
+ ];
+ }
+}
diff --git a/dev/tests/integration/testsuite/Magento/Sales/Block/Adminhtml/Order/View/InfoTest.php b/dev/tests/integration/testsuite/Magento/Sales/Block/Adminhtml/Order/View/InfoTest.php
new file mode 100644
index 0000000000000..1f2280124068b
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Sales/Block/Adminhtml/Order/View/InfoTest.php
@@ -0,0 +1,116 @@
+_objectManager->get('Magento\View\LayoutInterface');
+ /** @var \Magento\Sales\Block\Adminhtml\Order\View\Info $infoBlock */
+ $infoBlock = $layout->createBlock(
+ 'Magento\Sales\Block\Adminhtml\Order\View\Info', 'info_block' . mt_rand(), []
+ );
+
+ $result = $infoBlock->getCustomerAccountData();
+ $this->assertEquals([], $result, 'Customer has additional account data.');
+ }
+
+ /**
+ * @magentoDataFixture Magento/Sales/_files/order.php
+ */
+ public function testGetCustomerGroupName()
+ {
+ $layout = $this->_objectManager->get('Magento\View\LayoutInterface');
+ /** @var \Magento\Sales\Block\Adminhtml\Order\View\Info $customerGroupBlock */
+ $customerGroupBlock = $layout->createBlock(
+ 'Magento\Sales\Block\Adminhtml\Order\View\Info',
+ 'info_block' . mt_rand(),
+ ['registry' => $this->_putOrderIntoRegistry()]
+ );
+
+ $result = $customerGroupBlock->getCustomerGroupName();
+ $this->assertEquals('NOT LOGGED IN', $result);
+ }
+
+ /**
+ * @magentoDataFixture Magento/Sales/_files/order.php
+ * @magentoDataFixture Magento/Customer/_files/attribute_user_defined_customer.php
+ */
+ public function testGetCustomerAccountData()
+ {
+ $layout = $this->_objectManager->get('Magento\View\LayoutInterface');
+
+ $orderData = [
+ 'customer_' . FIXTURE_ATTRIBUTE_USER_DEFINED_CUSTOMER_NAME => self::ORDER_USER_DEFINED_ATTRIBUTE_VALUE
+ ];
+ /** @var \Magento\Sales\Block\Adminhtml\Order\View\Info $customerGroupBlock */
+ $customerGroupBlock = $layout->createBlock(
+ 'Magento\Sales\Block\Adminhtml\Order\View\Info',
+ 'info_block' . mt_rand(),
+ ['registry' => $this->_putOrderIntoRegistry($orderData)]
+ );
+
+ $this->assertEquals(
+ [
+ 200 => [
+ 'label' => FIXTURE_ATTRIBUTE_USER_DEFINED_CUSTOMER_FRONTEND_LABEL,
+ 'value' => self::ORDER_USER_DEFINED_ATTRIBUTE_VALUE
+ ]
+ ],
+ $customerGroupBlock->getCustomerAccountData()
+ );
+ }
+
+ /**
+ * @param array $additionalOrderData
+ * @return \Magento\Core\Model\Registry|\PHPUnit_Framework_MockObject_MockObject
+ */
+ protected function _putOrderIntoRegistry(array $additionalOrderData = [])
+ {
+ $registry = $this->getMockBuilder('Magento\Core\Model\Registry')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $order = $this->_objectManager->get('Magento\Sales\Model\Order')
+ ->load('100000001')
+ ->setData(array_merge(['customer_group_id' => 0], $additionalOrderData));
+
+ $registry->expects($this->any())
+ ->method('registry')
+ ->with('current_order')
+ ->will($this->returnValue($order));
+
+ return $registry;
+ }
+}
diff --git a/dev/tests/integration/testsuite/Magento/Sales/Block/Billing/Agreement/ViewTest.php b/dev/tests/integration/testsuite/Magento/Sales/Block/Billing/Agreement/ViewTest.php
new file mode 100644
index 0000000000000..465c31d5ddb3e
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Sales/Block/Billing/Agreement/ViewTest.php
@@ -0,0 +1,96 @@
+_block = Bootstrap::getObjectManager()->create('Magento\Sales\Block\Billing\Agreement\View');
+ parent::setUp();
+ }
+
+ /**
+ * Test getting orders associated with specified billing agreement.
+ *
+ * Create two identical orders, associate one of them with billing agreement and invoke testGetRelatedOrders()
+ *
+ * @magentoDataFixture Magento/Customer/_files/customer.php
+ * @magentoDataFixture Magento/Sales/_files/billing_agreement.php
+ * @magentoDataFixture Magento/Sales/_files/order.php
+ * @magentoDbIsolation enabled
+ * @magentoAppIsolation enabled
+ */
+ public function testGetRelatedOrders()
+ {
+ /** Customer ID declared in the fixture */
+ $customerId = 1;
+ /** Assign first order to the active customer */
+ /** @var \Magento\Sales\Model\Order $orderA */
+ $orderA = Bootstrap::getObjectManager()->create('Magento\Sales\Model\Order');
+ $orderA->loadByIncrementId('100000001');
+ $orderA->setCustomerIsGuest(false)->setCustomerId($customerId)->save();
+ /** @var \Magento\Customer\Model\Session $customerSession */
+ $customerSession = Bootstrap::getObjectManager()->create('Magento\Customer\Model\Session');
+ $customerSession->setCustomerId($customerId);
+
+ /** Assign second order to the active customer */
+ $orderB = clone $orderA;
+ $orderB->setId(null)
+ ->setIncrementId('100000002')
+ ->setCustomerIsGuest(false)
+ ->setCustomerId($customerId)
+ ->save();
+
+ /** @var \Magento\Customer\Model\Session $customerSession */
+ $customerSession = Bootstrap::getObjectManager()->create('Magento\Customer\Model\Session');
+ $customerSession->setCustomerId($customerId);
+
+ /** @var \Magento\Sales\Model\Resource\Billing\Agreement\Collection $billingAgreementCollection */
+ $billingAgreementCollection = Bootstrap::getObjectManager()
+ ->create('Magento\Sales\Model\Resource\Billing\Agreement\Collection');
+ /** @var \Magento\Sales\Model\Billing\Agreement $billingAgreement */
+ $billingAgreement = $billingAgreementCollection->getFirstItem();
+ $billingAgreement->addOrderRelation($orderA->getId())->save();
+
+ $registry = Bootstrap::getObjectManager()->get('Magento\Core\Model\Registry');
+ $registry->register('current_billing_agreement', $billingAgreement);
+
+ $relatedOrders = $this->_block->getRelatedOrders();
+ $this->assertEquals(1, $relatedOrders->count(), "Only one order must be returned.");
+ $this->assertEquals(
+ $orderA->getId(),
+ $relatedOrders->getFirstItem()->getId(),
+ "Invalid order returned as associated with billing agreement."
+ );
+ }
+}
diff --git a/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Billing/AgreementTest.php b/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Billing/AgreementTest.php
new file mode 100644
index 0000000000000..624fa89180972
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Billing/AgreementTest.php
@@ -0,0 +1,86 @@
+create('Magento\Backend\Model\Session');
+
+ $this->dispatch('backend/sales/billing_agreement/grid');
+ $response = $this->getResponse();
+
+ $this->assertSelectCount('button[type="button"][title="Reset Filter"]', 1, $response->getBody(),
+ "Response for billing agreement grid doesn't contain 'Reset Filter' button");
+
+ $this->assertSelectCount('[id="billing_agreements"]', 1, $response->getBody(),
+ "Response for billing agreement grid doesn't contain grid");
+ }
+
+ /**
+ * @magentoDataFixture Magento/Customer/_files/customer.php
+ * @magentoDataFixture Magento/Sales/_files/billing_agreement.php
+ */
+ public function testCustomerInfoTabs()
+ {
+ /** @var \Magento\Sales\Model\Resource\Billing\Agreement\Collection $billingAgreementCollection */
+ $billingAgreementCollection = Bootstrap::getObjectManager()
+ ->create('Magento\Sales\Model\Resource\Billing\Agreement\Collection');
+ $agreementId = $billingAgreementCollection->getFirstItem()->getId();
+ $this->dispatch('backend/sales/billing_agreement/view/agreement/' . $agreementId);
+
+ $this->assertSelectCount('a[name="billing_agreement_info"]', 1, $this->getResponse()->getBody(),
+ "Response for billing agreement info doesn't contain billing agreement info tab");
+
+ $this->assertSelectRegExp('a', '/customer\@example.com/', 1, $this->getResponse()->getBody(),
+ "Response for billing agreement info doesn't contain Customer info");
+ }
+
+ /**
+ * @magentoDataFixture Magento/Customer/_files/customer.php
+ * @magentoDataFixture Magento/Sales/_files/billing_agreement.php
+ */
+ public function testCustomerGrid()
+ {
+ $this->dispatch('backend/sales/billing_agreement/customergrid/id/1');
+ $this->assertSelectCount('td[class="col-reference_id"]', 1, $this->getResponse()->getBody(),
+ "Response for billing agreement orders doesn't contain billing agreement customers grid");
+ $this->assertSelectRegExp('td', '/REF-ID-TEST-678/', 1, $this->getResponse()->getBody(),
+ "Response for billing agreement info doesn't contain reference ID");
+ }
+}
diff --git a/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Recurring/ProfileTest.php b/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Recurring/ProfileTest.php
new file mode 100644
index 0000000000000..068332d50b90e
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Recurring/ProfileTest.php
@@ -0,0 +1,39 @@
+getRequest()->setParam(Profile::PARAM_CUSTOMER_ID, 1);
+ $this->dispatch('backend/sales/recurring_profile/customerGrid');
+ $this->assertContains(FIXTURE_RECURRING_PROFILE_SCHEDULE_DESCRIPTION, $this->getResponse()->getBody());
+ }
+}
diff --git a/dev/tests/integration/testsuite/Magento/Sales/Model/AdminOrder/CreateTest.php b/dev/tests/integration/testsuite/Magento/Sales/Model/AdminOrder/CreateTest.php
index 3234f843c9d4f..6d85d335c6b55 100644
--- a/dev/tests/integration/testsuite/Magento/Sales/Model/AdminOrder/CreateTest.php
+++ b/dev/tests/integration/testsuite/Magento/Sales/Model/AdminOrder/CreateTest.php
@@ -112,7 +112,7 @@ public function testInitFromOrderShippingAddressSameAsBillingWhenDifferent()
}
/**
- * @magentoDataFixture Magento/Sales/_files/order_paid_with_verisign.php
+ * @magentoDataFixture Magento/Sales/_files/order_paid_with_payflowpro.php
*/
public function testInitFromOrderCcInformationDeleted()
{
diff --git a/dev/tests/integration/testsuite/Magento/Sales/_files/billing_agreement.php b/dev/tests/integration/testsuite/Magento/Sales/_files/billing_agreement.php
new file mode 100644
index 0000000000000..60a9392e4f98f
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Sales/_files/billing_agreement.php
@@ -0,0 +1,36 @@
+create('Magento\Sales\Model\Billing\Agreement')
+ ->setAgreementLabel('TEST')
+ ->setCustomerId(1)
+ ->setMethodCode('paypal_express')
+ ->setReferenceId('REF-ID-TEST-678')
+ ->setStatus(Magento\Sales\Model\Billing\Agreement::STATUS_ACTIVE)
+ ->setStoreId(1)
+ ->save();
diff --git a/dev/tests/integration/testsuite/Magento/Sales/_files/invoice_verisign.php b/dev/tests/integration/testsuite/Magento/Sales/_files/invoice_payflowpro.php
similarity index 97%
rename from dev/tests/integration/testsuite/Magento/Sales/_files/invoice_verisign.php
rename to dev/tests/integration/testsuite/Magento/Sales/_files/invoice_payflowpro.php
index a96504e26067a..8987d643251cd 100644
--- a/dev/tests/integration/testsuite/Magento/Sales/_files/invoice_verisign.php
+++ b/dev/tests/integration/testsuite/Magento/Sales/_files/invoice_payflowpro.php
@@ -24,7 +24,7 @@
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
-require 'order_paid_with_verisign.php';
+require 'order_paid_with_payflowpro.php';
/** @var \Magento\Sales\Model\Order $order */
$orderService = \Magento\TestFramework\ObjectManager::getInstance()->create('Magento\Sales\Model\Service\Order',
diff --git a/dev/tests/integration/testsuite/Magento/Sales/_files/order_paid_with_verisign.php b/dev/tests/integration/testsuite/Magento/Sales/_files/order_paid_with_payflowpro.php
similarity index 98%
rename from dev/tests/integration/testsuite/Magento/Sales/_files/order_paid_with_verisign.php
rename to dev/tests/integration/testsuite/Magento/Sales/_files/order_paid_with_payflowpro.php
index 3b8d8d8d13402..752be317e8b13 100644
--- a/dev/tests/integration/testsuite/Magento/Sales/_files/order_paid_with_verisign.php
+++ b/dev/tests/integration/testsuite/Magento/Sales/_files/order_paid_with_payflowpro.php
@@ -37,7 +37,7 @@
$payment = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
->create('Magento\Sales\Model\Order\Payment');
-$payment->setMethod('verisign')
+$payment->setMethod('payflowpro')
->setCcExpMonth('5')
->setCcLast4('0005')
->setCcType('AE')
diff --git a/dev/tests/integration/testsuite/Magento/Sales/_files/recurring_profile.php b/dev/tests/integration/testsuite/Magento/Sales/_files/recurring_profile.php
new file mode 100644
index 0000000000000..82f8242f12db5
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Sales/_files/recurring_profile.php
@@ -0,0 +1,43 @@
+create('Magento\Sales\Model\Recurring\Profile');
+$profile
+ ->setQuote(Bootstrap::getObjectManager()->create('Magento\Sales\Model\Quote')->load(1))
+ ->setPeriodUnit('year')
+ ->setPeriodFrequency(1)
+ ->setScheduleDescription(FIXTURE_RECURRING_PROFILE_SCHEDULE_DESCRIPTION)
+ ->setBillingAmount(1)
+ ->setCurrencyCode('USD')
+ ->setMethodCode('paypal_express')
+ ->setInternalReferenceId('rp-1')
+ ->setCustomerId(1)
+ ->save();
diff --git a/dev/tests/integration/testsuite/Magento/Sitemap/Helper/DataTest.php b/dev/tests/integration/testsuite/Magento/Sitemap/Helper/DataTest.php
index f545ff152881e..1df7a33c9b153 100644
--- a/dev/tests/integration/testsuite/Magento/Sitemap/Helper/DataTest.php
+++ b/dev/tests/integration/testsuite/Magento/Sitemap/Helper/DataTest.php
@@ -51,7 +51,7 @@ public function testGetMaximumLinesNumber()
);
$this->assertEquals(
10,
- $this->_helper->getMaximumLinesNumber(\Magento\Core\Model\AppInterface::DISTRO_STORE_ID)
+ $this->_helper->getMaximumLinesNumber(\Magento\Core\Model\Store::DISTRO_STORE_ID)
);
}
@@ -65,7 +65,7 @@ public function testGetMaximumFileSize()
);
$this->assertEquals(
1024,
- $this->_helper->getMaximumFileSize(\Magento\Core\Model\AppInterface::DISTRO_STORE_ID)
+ $this->_helper->getMaximumFileSize(\Magento\Core\Model\Store::DISTRO_STORE_ID)
);
}
@@ -78,7 +78,7 @@ public function testGetCategoryChangefreq()
'daily', $this->_helper->getCategoryChangefreq(\Magento\Core\Model\Store::DEFAULT_STORE_ID)
);
$this->assertEquals(
- 'montly', $this->_helper->getCategoryChangefreq(\Magento\Core\Model\AppInterface::DISTRO_STORE_ID)
+ 'montly', $this->_helper->getCategoryChangefreq(\Magento\Core\Model\Store::DISTRO_STORE_ID)
);
}
@@ -91,7 +91,7 @@ public function testGetProductChangefreq()
'daily', $this->_helper->getProductChangefreq(\Magento\Core\Model\Store::DEFAULT_STORE_ID)
);
$this->assertEquals(
- 'montly', $this->_helper->getProductChangefreq(\Magento\Core\Model\AppInterface::DISTRO_STORE_ID)
+ 'montly', $this->_helper->getProductChangefreq(\Magento\Core\Model\Store::DISTRO_STORE_ID)
);
}
@@ -106,7 +106,7 @@ public function testGetPageChangefreq()
);
$this->assertEquals(
'montly',
- $this->_helper->getPageChangefreq(\Magento\Core\Model\AppInterface::DISTRO_STORE_ID)
+ $this->_helper->getPageChangefreq(\Magento\Core\Model\Store::DISTRO_STORE_ID)
);
}
@@ -121,7 +121,7 @@ public function testGetCategoryPriority()
);
$this->assertEquals(
100,
- $this->_helper->getCategoryPriority(\Magento\Core\Model\AppInterface::DISTRO_STORE_ID)
+ $this->_helper->getCategoryPriority(\Magento\Core\Model\Store::DISTRO_STORE_ID)
);
}
@@ -134,7 +134,7 @@ public function testGetProductPriority()
1,
$this->_helper->getProductPriority(\Magento\Core\Model\Store::DEFAULT_STORE_ID)
);
- $this->assertEquals(100, $this->_helper->getProductPriority(\Magento\Core\Model\AppInterface::DISTRO_STORE_ID));
+ $this->assertEquals(100, $this->_helper->getProductPriority(\Magento\Core\Model\Store::DISTRO_STORE_ID));
}
/**
@@ -146,7 +146,7 @@ public function testGetPagePriority()
0.25,
$this->_helper->getPagePriority(\Magento\Core\Model\Store::DEFAULT_STORE_ID)
);
- $this->assertEquals(100, $this->_helper->getPagePriority(\Magento\Core\Model\AppInterface::DISTRO_STORE_ID));
+ $this->assertEquals(100, $this->_helper->getPagePriority(\Magento\Core\Model\Store::DISTRO_STORE_ID));
}
/**
@@ -159,7 +159,7 @@ public function testGetEnableSubmissionRobots()
$this->_helper->getEnableSubmissionRobots(\Magento\Core\Model\Store::DEFAULT_STORE_ID)
);
$this->assertEquals(
- 1, $this->_helper->getEnableSubmissionRobots(\Magento\Core\Model\AppInterface::DISTRO_STORE_ID)
+ 1, $this->_helper->getEnableSubmissionRobots(\Magento\Core\Model\Store::DISTRO_STORE_ID)
);
}
@@ -172,7 +172,7 @@ public function testGetProductImageIncludePolicy()
'all', $this->_helper->getProductImageIncludePolicy(\Magento\Core\Model\Store::DEFAULT_STORE_ID)
);
$this->assertEquals(
- 'base', $this->_helper->getProductImageIncludePolicy(\Magento\Core\Model\AppInterface::DISTRO_STORE_ID)
+ 'base', $this->_helper->getProductImageIncludePolicy(\Magento\Core\Model\Store::DISTRO_STORE_ID)
);
}
}
diff --git a/dev/tests/integration/testsuite/Magento/Sitemap/Model/Resource/Catalog/ProductTest.php b/dev/tests/integration/testsuite/Magento/Sitemap/Model/Resource/Catalog/ProductTest.php
index d8efc558ec40f..3f834f4f04ac9 100644
--- a/dev/tests/integration/testsuite/Magento/Sitemap/Model/Resource/Catalog/ProductTest.php
+++ b/dev/tests/integration/testsuite/Magento/Sitemap/Model/Resource/Catalog/ProductTest.php
@@ -47,7 +47,7 @@ public function testGetCollectionNone()
{
$model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
->create('Magento\Sitemap\Model\Resource\Catalog\Product');
- $products = $model->getCollection(\Magento\Core\Model\AppInterface::DISTRO_STORE_ID);
+ $products = $model->getCollection(\Magento\Core\Model\Store::DISTRO_STORE_ID);
$this->_checkProductCollection($products, 3, array(1, 4, 5));
@@ -73,7 +73,7 @@ public function testGetCollectionAll()
{
$model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
->create('Magento\Sitemap\Model\Resource\Catalog\Product');
- $products = $model->getCollection(\Magento\Core\Model\AppInterface::DISTRO_STORE_ID);
+ $products = $model->getCollection(\Magento\Core\Model\Store::DISTRO_STORE_ID);
$this->_checkProductCollection($products, 3, array(1, 4, 5));
@@ -125,7 +125,7 @@ public function testGetCollectionBase()
{
$model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
->create('Magento\Sitemap\Model\Resource\Catalog\Product');
- $products = $model->getCollection(\Magento\Core\Model\AppInterface::DISTRO_STORE_ID);
+ $products = $model->getCollection(\Magento\Core\Model\Store::DISTRO_STORE_ID);
$this->_checkProductCollection($products, 3, array(1, 4, 5));
diff --git a/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/MviewConfigFilesTest.php b/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/MviewConfigFilesTest.php
new file mode 100644
index 0000000000000..2eb1fc4b62c75
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/MviewConfigFilesTest.php
@@ -0,0 +1,84 @@
+markTestIncomplete('Will enable after first indexer will be implemented');
+ $this->_schemeFile = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Filesystem')
+ ->getPath(\Magento\App\Filesystem::LIB_DIR) . '/Magento/Mview/etc/mview.xsd';
+ }
+
+ /**
+ * Test each acl configuration file
+ * @param string $file
+ */
+ public function testIndexerConfigFile($file)
+ {
+ $this->markTestIncomplete('Will enable after first indexer will be implemented');
+ $domConfig = new \Magento\Config\Dom(file_get_contents($file));
+ $result = $domConfig->validate($this->_schemeFile, $errors);
+ $message = "Invalid XML-file: {$file}\n";
+ foreach ($errors as $error) {
+ $message .= "$error\n";
+ }
+ $this->assertTrue($result, $message);
+ }
+
+ /**
+ * @return array
+ */
+ public function indexerConfigFileDataProvider()
+ {
+ $fileList = glob(
+ \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Filesystem')
+ ->getPath(\Magento\App\Filesystem::APP_DIR) . '/*/*/*/etc/mview.xml'
+ );
+ $dataProviderResult = array();
+ foreach ($fileList as $file) {
+ $dataProviderResult[$file] = array($file);
+ }
+ return $dataProviderResult;
+ }
+}
diff --git a/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/NewIndexerConfigFilesTest.php b/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/NewIndexerConfigFilesTest.php
new file mode 100644
index 0000000000000..e674c4ec5614c
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/NewIndexerConfigFilesTest.php
@@ -0,0 +1,83 @@
+markTestIncomplete('Will enable after first indexer will be implemented');
+ $this->_schemeFile = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Filesystem')
+ ->getPath(\Magento\App\Filesystem::APP_DIR) . '/code/Magento/Indexer/etc/indexer.xsd';
+ }
+
+ /**
+ * Test each acl configuration file
+ * @param string $file
+ */
+ public function testIndexerConfigFile($file)
+ {
+ $domConfig = new \Magento\Config\Dom(file_get_contents($file));
+ $result = $domConfig->validate($this->_schemeFile, $errors);
+ $message = "Invalid XML-file: {$file}\n";
+ foreach ($errors as $error) {
+ $message .= "$error\n";
+ }
+ $this->assertTrue($result, $message);
+ }
+
+ /**
+ * @return array
+ */
+ public function indexerConfigFileDataProvider()
+ {
+ $fileList = glob(
+ \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Filesystem')
+ ->getPath(\Magento\App\Filesystem::APP_DIR) . '/*/*/*/etc/indexer.xml'
+ );
+ $dataProviderResult = array();
+ foreach ($fileList as $file) {
+ $dataProviderResult[$file] = array($file);
+ }
+ return $dataProviderResult;
+ }
+}
diff --git a/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/ResourcesConfigFilesTest.php b/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/ResourcesConfigFilesTest.php
index 3bf8f0fe9fd73..90e8b4f4e4ac7 100644
--- a/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/ResourcesConfigFilesTest.php
+++ b/dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/ResourcesConfigFilesTest.php
@@ -48,7 +48,7 @@ protected function setUp()
$validationStateMock->expects($this->any())
->method('isValidated')
->will($this->returnValue(true));
- $localConfigMock = $this->getMock('Magento\App\Config', array(), array(), '', false);
+ $localConfigMock = $this->getMock('Magento\App\Arguments', array(), array(), '', false);
$localConfigMock->expects($this->any())->method('getConfiguration')->will($this->returnValue(array()));
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
$this->_model = $objectManager->create('Magento\App\Resource\Config\Reader', array(
diff --git a/dev/tests/integration/testsuite/Magento/Theme/Block/HtmlTest.php b/dev/tests/integration/testsuite/Magento/Theme/Block/HtmlTest.php
index 68cef40f3d884..1bd1534dafd0a 100644
--- a/dev/tests/integration/testsuite/Magento/Theme/Block/HtmlTest.php
+++ b/dev/tests/integration/testsuite/Magento/Theme/Block/HtmlTest.php
@@ -42,21 +42,24 @@ public function testGetPrintLogoUrl($configData, $returnValue)
->method('getConfig')
->will($this->returnValueMap($configData));
- $securityInfoMock = $this->getMock('Magento\Core\Model\Url\SecurityInfoInterface');
+ $securityInfoMock = $this->getMock('Magento\Url\SecurityInfoInterface');
$codeData = $this->getMock('Magento\Core\Helper\Data', array(), array(), '', false);
$urlBuilder = $this->getMock(
- 'Magento\Core\Model\Url',
+ 'Magento\Url',
array('getBaseUrl'),
array(
$this->getMock('Magento\App\Route\ConfigInterface'),
$this->getMock('Magento\App\Request\Http', array(), array(), '', false),
$securityInfoMock,
- $storeConfig,
- $this->getMock('Magento\Core\Model\App', array(), array(), '', false),
- $this->getMock('Magento\Core\Model\StoreManager', array(), array(), '', false),
+ $this->getMock('Magento\Url\ScopeResolverInterface', array(), array(), '', false),
$this->getMock('Magento\Core\Model\Session', array(), array(), '', false),
$this->getMock('Magento\Session\SidResolverInterface', array(), array(), '', false),
- null,
+ $this->getMock(
+ 'Magento\Url\RouteParamsResolverFactory', array(), array(), '', false
+ ),
+ $this->getMock(
+ 'Magento\Url\QueryParamsResolver', array(), array(), '', false
+ ),
array()
)
);
diff --git a/dev/tests/integration/testsuite/Magento/Url/QueryParamsResolverTest.php b/dev/tests/integration/testsuite/Magento/Url/QueryParamsResolverTest.php
new file mode 100644
index 0000000000000..6b8fcbbf2977a
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Url/QueryParamsResolverTest.php
@@ -0,0 +1,52 @@
+_model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
+ ->create('Magento\Url\QueryParamsResolver');
+ }
+
+ public function testSetGetPurgeQueryParams()
+ {
+ $params = array('one' => 1, 'two' => 2);
+ $this->_model->setQueryParams($params);
+ $this->assertEquals($params, $this->_model->getQueryParams());
+
+ $this->_model->purgeQueryParams();
+ $this->assertEquals(array(), $this->_model->getQueryParams());
+ }
+}
diff --git a/dev/tests/integration/testsuite/Magento/Core/Model/UrlTest.php b/dev/tests/integration/testsuite/Magento/UrlTest.php
similarity index 65%
rename from dev/tests/integration/testsuite/Magento/Core/Model/UrlTest.php
rename to dev/tests/integration/testsuite/Magento/UrlTest.php
index e5c1b7bfe5cdc..6b7d72c7c3ba8 100644
--- a/dev/tests/integration/testsuite/Magento/Core/Model/UrlTest.php
+++ b/dev/tests/integration/testsuite/Magento/UrlTest.php
@@ -25,45 +25,19 @@
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
-namespace Magento\Core\Model;
+namespace Magento;
class UrlTest extends \PHPUnit_Framework_TestCase
{
/**
- * @var \Magento\Core\Model\Url
+ * @var \Magento\UrlInterface
*/
protected $_model;
protected function setUp()
{
$this->_model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
- ->create('Magento\Core\Model\Url');
- }
-
- public function testParseUrl()
- {
- $url = 'http://user:password@www.example.com:80/manual/3.5/?one=1&two=2#skeleton-generator.test';
- $this->assertInstanceOf(get_class($this->_model), $this->_model->parseUrl($url));
- $this->assertEquals('http', $this->_model->getScheme());
- $this->assertEquals('www.example.com', $this->_model->getHost());
- $this->assertEquals('80', $this->_model->getPort());
- $this->assertEquals('user', $this->_model->getUser());
- $this->assertEquals('password', $this->_model->getPassword());
- $this->assertEquals('/manual/3.5/', $this->_model->getPath());
- $this->assertEquals('one=1&two=2', $this->_model->getQuery());
- $this->assertEquals('skeleton-generator.test', $this->_model->getFragment());
- }
-
- public function testGetDefaultControllerName()
- {
- $this->assertEquals('index', $this->_model->getDefaultControllerName());
- }
-
- public function testSetUseUrlCache()
- {
- $value = '2';
- $this->_model->setUseUrlCache($value);
- $this->assertEquals($value, $this->_model->getData('use_url_cache'));
+ ->create('Magento\Url');
}
public function testSetGetUseSession()
@@ -80,53 +54,11 @@ public function testSetRouteFrontName()
$this->assertEquals($value, $this->_model->getData('route_front_name'));
}
- public function testGetDefaultActionName()
- {
- $this->assertEquals('index', $this->_model->getDefaultActionName());
- }
-
public function testGetConfigData()
{
$this->assertEquals('http://localhost/', $this->_model->getConfigData('base_url'));
}
- public function testSetGetRequest()
- {
- $this->assertInstanceOf('\Magento\App\RequestInterface', $this->_model->getRequest());
- /** @var $objectManager \Magento\TestFramework\ObjectManager */
- $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
- /** @var $request \Magento\TestFramework\Request */
- $request = $objectManager->get('Magento\TestFramework\Request');
- $this->_model->setRequest($request);
- $this->assertSame($request, $this->_model->getRequest());
- }
-
- public function testGetType()
- {
- $this->assertEquals(\Magento\Core\Model\Store::URL_TYPE_LINK, $this->_model->getType());
- }
-
- /**
- * @magentoAppIsolation enabled
- */
- public function testIsSecure()
- {
- $this->assertFalse($this->_model->isSecure());
- $this->_model->setSecureIsForced(1);
- $this->assertTrue(is_bool($this->_model->isSecure()));
- $this->assertFalse($this->_model->isSecure());
- }
-
- public function testSetGetStore()
- {
- $this->assertInstanceOf('Magento\Core\Model\Store', $this->_model->getStore());
-
- $store = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
- ->create('Magento\Core\Model\Store');
- $this->_model->setStore($store);
- $this->assertSame($store, $this->_model->getStore());
- }
-
/**
* Note: isolation should be raised to flush the URL memory cache maintained by the store model
* @magentoAppIsolation enabled
@@ -179,7 +111,7 @@ public function testGetBaseUrlWithTypeRestoring()
/**
* Set specified type
*/
- $this->_model->setType(\Magento\Core\Model\Store::URL_TYPE_WEB);
+ $this->_model->setType(\Magento\UrlInterface::URL_TYPE_WEB);
$webUrl = $this->_model->getBaseUrl();
$this->assertEquals('http://localhost/', $webUrl, 'Incorrect web url');
$this->assertEquals('http://localhost/index.php/', $this->_model->getBaseUrl(), 'Incorrect link url');
@@ -187,7 +119,7 @@ public function testGetBaseUrlWithTypeRestoring()
/**
* Get url with type specified in params
*/
- $mediaUrl = $this->_model->getBaseUrl(array('_type' => \Magento\Core\Model\Store::URL_TYPE_MEDIA));
+ $mediaUrl = $this->_model->getBaseUrl(array('_type' => \Magento\UrlInterface::URL_TYPE_MEDIA));
$this->assertEquals('http://localhost/pub/media/', $mediaUrl, 'Incorrect media url');
$this->assertEquals('http://localhost/index.php/', $this->_model->getBaseUrl(), 'Incorrect link url');
}
@@ -196,65 +128,20 @@ public function getBaseUrlConfiguredDataProvider()
{
return array(
array(
- array('_type' => \Magento\Core\Model\Store::URL_TYPE_WEB),
+ array('_type' => \Magento\UrlInterface::URL_TYPE_WEB),
'http://sample.com/base_path/'
),
array(
- array('_type' => \Magento\Core\Model\Store::URL_TYPE_LINK),
+ array('_type' => \Magento\UrlInterface::URL_TYPE_LINK),
'http://sample.com/base_link_path/index.php/'
),
array(
- array('_type' => \Magento\Core\Model\Store::URL_TYPE_LINK, '_secure' => 1),
+ array('_type' => \Magento\UrlInterface::URL_TYPE_LINK, '_secure' => 1),
'https://sample.com/base_link_path/index.php/'
),
);
}
- public function testSetRoutePath()
- {
- // *
- $this->_model->setRoutePath('catalog');
- $this->assertEquals('catalog', $this->_model->getRouteName());
-
- // */*
- $this->_model->setRoutePath('catalog/product');
- $this->assertEquals('catalog', $this->_model->getRouteName());
- $this->assertEquals('product', $this->_model->getControllerName());
-
- // */*/*
- $this->_model->setRoutePath('catalog/product/view');
- $this->assertEquals('catalog', $this->_model->getRouteName());
- $this->assertEquals('product', $this->_model->getControllerName());
- $this->assertEquals('view', $this->_model->getActionName());
-
- // */*/*/param/value
- $this->_model->setRoutePath('catalog/product/view/id/50');
- $this->assertEquals('catalog', $this->_model->getRouteName());
- $this->assertEquals('product', $this->_model->getControllerName());
- $this->assertEquals('view', $this->_model->getActionName());
- $this->assertEquals('50', $this->_model->getRouteParam('id'));
- }
-
- public function testGetActionPath()
- {
- $this->assertEquals('', $this->_model->getActionPath());
-
- $this->_model->setRoutePath('catalog/product/view/id/50');
- $this->assertEquals('catalog/product/view/', $this->_model->getActionPath());
- }
-
- public function testGetRoutePath()
- {
- $this->assertEquals('', $this->_model->getRoutePath());
-
- $this->_model->setRoutePath('catalog/product/view/id/50');
- $this->assertEquals('catalog/product/view/id/50/', $this->_model->getRoutePath());
-
- $this->_model->setRoutePath('catalog/product/view');
- $this->_model->setRouteParams(array('id' => 50));
- $this->assertEquals('catalog/product/view/id/50/', $this->_model->getRoutePath());
- }
-
public function testSetGetRouteName()
{
$this->_model->setRouteName('catalog');
@@ -263,12 +150,6 @@ public function testSetGetRouteName()
$this->markTestIncomplete('setRouteName() logic is unclear.');
}
- public function testGetRouteFrontName()
- {
- $this->_model->setRouteName('catalog');
- $this->assertEquals('catalog', $this->_model->getRouteFrontName());
- }
-
public function testSetGetControllerName()
{
$this->_model->setControllerName('product');
@@ -285,32 +166,6 @@ public function testSetGetActionName()
$this->markTestIncomplete('setActionName() logic is unclear.');
}
- public function testSetGetRouteParams()
- {
- $this->_model->setRouteParams(array(
- '_type' => 1,
- '_store' => 1,
- '_forced_secure' => 1,
- '_absolute' => 1,
- '_current' => 0,
- '_use_rewrite' => 1,
- '_store_to_url' => true,
- 'param1' => 'value1',
- ));
- $this->assertEquals(array('param1' => 'value1'), $this->_model->getRouteParams());
-
- $this->_model->setRouteParams(array('param2' => 'value2'), false);
- $this->assertEquals(array('param1' => 'value1', 'param2' => 'value2'), $this->_model->getRouteParams());
- }
-
- public function testSetGetRouteParam()
- {
- $this->_model->setRouteParam('id', 100);
- $this->assertEquals(100, $this->_model->getRouteParam('id'));
- $this->_model->setRouteParam('parent_id', 50);
- $this->assertEquals(array('id' => 100, 'parent_id' => 50), $this->_model->getRouteParams());
- }
-
/**
* Note: isolation flushes the URL memory cache
* @magentoAppIsolation enabled
@@ -326,33 +181,6 @@ public function testGetRouteUrl()
);
}
- public function testSetGetQuery()
- {
- $this->_model->setQuery('one=1&two=2');
- $this->assertEquals('one=1&two=2', $this->_model->getQuery());
-
- // here comes the funny part
- $this->_model->unsQuery();
- $this->_model->setQueryParams(array('three' => 3, 'four' => 4));
- $this->assertEquals('four=4&three=3', $this->_model->getQuery(true));
- }
-
- public function testSetGetPurgeQueryParams()
- {
- $params = array('one' => 1, 'two' => 2);
- $this->_model->setQueryParams($params);
- $this->assertEquals($params, $this->_model->getQueryParams());
-
- $this->_model->purgeQueryParams();
- $this->assertEquals(array(), $this->_model->getQueryParams());
- }
-
- public function testSetGetQueryParam()
- {
- $this->_model->setQueryParam('key', 'value');
- $this->assertEquals('value', $this->_model->getQueryParam('key'));
- }
-
public function testSetGetFragment()
{
$this->_model->setFragment('value');
@@ -395,7 +223,7 @@ public function testGetUrlDoesntAddQueryParamsOnConsequentCalls()
/**
* Note: isolation flushes the URL memory cache
* @magentoAppIsolation enabled
- * @covers \Magento\Core\Model\Url::getUrl
+ * @covers \Magento\Url::getUrl
*/
public function testGetUrlDoesntAddFragmentOnConsequentCalls()
{
@@ -422,7 +250,7 @@ public function testGetUrlDoesntAddFragmentOnConsequentCalls()
* @param array $secondRouteParams
* @param string $firstExpectedUrl
* @param string $secondExpectedUrl
- * @covers \Magento\Core\Model\Url::getUrl
+ * @covers \Magento\Url::getUrl
*/
public function testGetUrlOnConsequentCalls($firstCallUrl, $secondCallUrl, $firstRouteParams, $secondRouteParams,
$firstExpectedUrl, $secondExpectedUrl
@@ -613,24 +441,6 @@ public function testUseSessionIdForUrl()
$this->assertFalse($this->_model->useSessionIdForUrl(false));
}
- /**
- * Note: isolation flushes the URL memory cache
- * @magentoAppIsolation enabled
- */
- public function testSessionVarCallback()
- {
- $this->_model->setData('use_session_id_for_url_0', false);
- $this->_model->setData('use_session_id_for_url_1', false);
-
- // evidence of cyclomatic complexity
- $this->assertEquals('?', $this->_model->sessionVarCallback(array('', '?', '', '')));
- $this->assertEquals('', $this->_model->sessionVarCallback(array('', '?', '')));
- $this->assertEquals('', $this->_model->sessionVarCallback(array('', '&', '')));
- $this->assertEquals('', $this->_model->sessionVarCallback(array('', '&', '')));
- $this->assertEquals('', $this->_model->sessionVarCallback(array('', '&', '', '')));
- $this->assertEquals('', $this->_model->sessionVarCallback(array('', '&', '', '')));
- }
-
/**
* Note: isolation flushes the URL memory cache
* @magentoAppIsolation enabled
diff --git a/dev/tests/integration/testsuite/Magento/Webapi/Model/Config/_files/webapi.php b/dev/tests/integration/testsuite/Magento/Webapi/Model/Config/_files/webapi.php
index 3e08a3edff068..27c21c68be28c 100644
--- a/dev/tests/integration/testsuite/Magento/Webapi/Model/Config/_files/webapi.php
+++ b/dev/tests/integration/testsuite/Magento/Webapi/Model/Config/_files/webapi.php
@@ -22,8 +22,8 @@
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
return array(
- '\Magento\TestModule1\Service\AllSoapAndRestV1Interface' => array(
- 'class' => '\Magento\TestModule1\Service\AllSoapAndRestV1Interface',
+ '\Magento\TestModule1\Service\V1\AllSoapAndRestInterface' => array(
+ 'class' => '\Magento\TestModule1\Service\V1\AllSoapAndRestInterface',
'methods' => array(
'item' => array(
'httpMethod' => 'GET',
@@ -42,8 +42,8 @@
),
'baseUrl' => '/V1/testmodule1',
),
- '\Magento\TestModule1\Service\AllSoapAndRestV2Interface' => array(
- 'class' => '\Magento\TestModule1\Service\AllSoapAndRestV2Interface',
+ '\Magento\TestModule1\Service\V2\AllSoapAndRestInterface' => array(
+ 'class' => '\Magento\TestModule1\Service\V2\AllSoapAndRestInterface',
'methods' => array(
'item' => array(
'httpMethod' => 'GET',
@@ -69,8 +69,8 @@
),
'baseUrl' => '/V2/testmodule1',
),
- '\Magento\TestModule2\Service\AllSoapAndRestV2Interface' => array(
- 'class' => '\Magento\TestModule2\Service\AllSoapAndRestV2Interface',
+ '\Magento\TestModule2\Service\V2\AllSoapAndRestInterface' => array(
+ 'class' => '\Magento\TestModule2\Service\V2\AllSoapAndRestInterface',
'methods' => array(
'update' => array(
'httpMethod' => 'PUT',
diff --git a/dev/tests/integration/testsuite/Magento/Webapi/Model/Config/_files/webapiA.xml b/dev/tests/integration/testsuite/Magento/Webapi/Model/Config/_files/webapiA.xml
index 882ebb5546af2..f07d0019a9c6f 100644
--- a/dev/tests/integration/testsuite/Magento/Webapi/Model/Config/_files/webapiA.xml
+++ b/dev/tests/integration/testsuite/Magento/Webapi/Model/Config/_files/webapiA.xml
@@ -24,11 +24,11 @@
*/
-->
-
+
/:id
-
+
/:id
/:id
diff --git a/dev/tests/integration/testsuite/Magento/Webapi/Model/Config/_files/webapiB.xml b/dev/tests/integration/testsuite/Magento/Webapi/Model/Config/_files/webapiB.xml
index 2c073f8df05e5..40f51078bdcf8 100644
--- a/dev/tests/integration/testsuite/Magento/Webapi/Model/Config/_files/webapiB.xml
+++ b/dev/tests/integration/testsuite/Magento/Webapi/Model/Config/_files/webapiB.xml
@@ -24,12 +24,12 @@
*/
-->
-
+
-
+
/:id
diff --git a/dev/tests/integration/testsuite/Magento/Webapi/Model/Soap/ServerTest.php b/dev/tests/integration/testsuite/Magento/Webapi/Model/Soap/ServerTest.php
index 6cef42825dbff..129b902ccdd78 100644
--- a/dev/tests/integration/testsuite/Magento/Webapi/Model/Soap/ServerTest.php
+++ b/dev/tests/integration/testsuite/Magento/Webapi/Model/Soap/ServerTest.php
@@ -52,6 +52,9 @@ class ServerTest extends \PHPUnit_Framework_TestCase
/** @var \Magento\Webapi\Model\Soap\Server\Factory */
protected $_soapServerFactory;
+ /** @var \Magento\Webapi\Model\Config\ClassReflector\TypeProcessor */
+ protected $_typeProcessor;
+
protected function setUp()
{
$this->_storeManagerMock = $this->getMockBuilder('Magento\Core\Model\StoreManager')
@@ -69,6 +72,13 @@ protected function setUp()
->disableOriginalConstructor()->getMock();
$this->_soapServerFactory = $this->getMockBuilder('Magento\Webapi\Model\Soap\Server\Factory')
->disableOriginalConstructor()->getMock();
+ $this->_typeProcessor = $this->getMock(
+ 'Magento\Webapi\Model\Config\ClassReflector\TypeProcessor',
+ [],
+ [],
+ '',
+ false
+ );
parent::setUp();
}
@@ -88,7 +98,8 @@ public function testConstructEnableWsdlCache()
$this->_requestMock,
$this->_domDocumentFactory,
$this->_storeManagerMock,
- $this->_soapServerFactory
+ $this->_soapServerFactory,
+ $this->_typeProcessor
);
/** Assert that SOAP WSDL caching option was enabled after SOAP server initialization. */
$this->assertTrue((bool)ini_get('soap.wsdl_cache_enabled'), 'WSDL caching was not enabled.');
@@ -109,7 +120,8 @@ public function testConstructDisableWsdlCache()
$this->_requestMock,
$this->_domDocumentFactory,
$this->_storeManagerMock,
- $this->_soapServerFactory
+ $this->_soapServerFactory,
+ $this->_typeProcessor
);
/** Assert that SOAP WSDL caching option was disabled after SOAP server initialization. */
$this->assertFalse((bool)ini_get('soap.wsdl_cache_enabled'), 'WSDL caching was not disabled.');
diff --git a/dev/tests/integration/testsuite/Magento/Webapi/ServiceNameCollisionTest.php b/dev/tests/integration/testsuite/Magento/Webapi/ServiceNameCollisionTest.php
index cc17c8f8f0844..c1c676f1950aa 100644
--- a/dev/tests/integration/testsuite/Magento/Webapi/ServiceNameCollisionTest.php
+++ b/dev/tests/integration/testsuite/Magento/Webapi/ServiceNameCollisionTest.php
@@ -34,20 +34,20 @@ class ServiceNameCollisionTest extends \PHPUnit_Framework_TestCase
/**
* Test there are no collisions between service names.
*
- * @see \Magento\Webapi\Model\Soap\Config::getServiceName()
+ * @see \Magento\Webapi\Helper\Data::getServiceName()
* @SuppressWarnings(PHPMD.UnusedLocalVariable)
*/
public function testServiceNameCollisions()
{
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
- /** @var \Magento\Webapi\Model\Soap\Config $soapConfig */
- $soapConfig = $objectManager->get('Magento\Webapi\Model\Soap\Config');
+ /** @var \Magento\Webapi\Helper\Data $helper */
+ $helper = $objectManager->get('Magento\Webapi\Helper\Data');
/** @var \Magento\Webapi\Model\Config $webapiConfig */
$webapiConfig = $objectManager->get('Magento\Webapi\Model\Config');
$serviceNames = array();
foreach ($webapiConfig->getServices() as $serviceClassName => $serviceData) {
- $newServiceName = $soapConfig->getServiceName($serviceClassName);
+ $newServiceName = $helper->getServiceName($serviceClassName);
$this->assertFalse(in_array($newServiceName, $serviceNames));
$serviceNames[] = $newServiceName;
}
diff --git a/dev/tests/performance/benchmark_logs_merge.php b/dev/tests/performance/benchmark_logs_merge.php
deleted file mode 100644
index 4c6aeb020c9fe..0000000000000
--- a/dev/tests/performance/benchmark_logs_merge.php
+++ /dev/null
@@ -1,88 +0,0 @@
- 'xml',
- 'csv=s' => 'csv',
- 'logs=s' => 'logs'
-));
-
-$args = $shell->getOptions();
-if (empty($args)) {
- echo $shell->getUsageMessage();
- exit(1);
-}
-
-$xmlUrl = $shell->getOption('xml');
-$scvUrl = $shell->getOption('csv');
-$newLogsUrl = $shell->getOption('logs');
-
-if (!file_exists($xmlUrl)) {
- echo 'xml does not exist';
- exit(1);
-}
-
-if (!file_exists($scvUrl)) {
- echo 'csv does not exist';
- exit(1);
-}
-
-$xml = simplexml_load_file($xmlUrl);
-$scv = readCsv($scvUrl);
-
-foreach ($xml as $key => $value) {
- unset($value->httpSample);
- unset($value->assertionResult);
-}
-
-foreach ($scv as $key => $value) {
- $httpSample = $xml->addChild('httpSample');
-
- $httpSample->addAttribute('t', $value[1]);
- $httpSample->addAttribute('lt', $value[1]);
- $httpSample->addAttribute('ts', $value[0]);
- $httpSample->addAttribute('s', 'true');
- $httpSample->addAttribute('lb', $value[2]);
- $httpSample->addAttribute('rc', '200');
- $httpSample->addAttribute('rm', 'OK');
- $httpSample->addAttribute('tn', $value[2]);
-}
-
-$xml->asXML($newLogsUrl);
-
-function readCsv($csvFile)
-{
- $fileHandle = fopen($csvFile, 'r');
- $lineOfText = array();
- while (!feof($fileHandle) ) {
- $lineOfText[] = fgetcsv($fileHandle, 1024);
- }
- fclose($fileHandle);
- return $lineOfText;
-}
diff --git a/dev/tests/performance/testsuite/fixtures/shipping_flatrate_enabled.php b/dev/tests/performance/testsuite/fixtures/shipping_flatrate_enabled.php
index e63c2895b011c..6d44bbf086f81 100644
--- a/dev/tests/performance/testsuite/fixtures/shipping_flatrate_enabled.php
+++ b/dev/tests/performance/testsuite/fixtures/shipping_flatrate_enabled.php
@@ -25,11 +25,11 @@
/** @var \Magento\TestFramework\Application $this */
/**
- * @var \Magento\Core\Model\Config\Value $configData
+ * @var \Magento\App\Config\ValueInterface $configData
*/
-$configData = $this->getObjectManager()->create('Magento\Core\Model\Config\Value');
+$configData = $this->getObjectManager()->create('Magento\App\Config\ValueInterface');
$configData->setPath('carriers/flatrate/active')
- ->setScope(\Magento\Core\Model\Config::SCOPE_DEFAULT)
+ ->setScope(\Magento\Core\Model\ScopeInterface::SCOPE_DEFAULT)
->setScopeId(0)
->setValue(1)
->save();
diff --git a/dev/tests/static/framework/Magento/TestFramework/CodingStandard/Tool/CodeSniffer.php b/dev/tests/static/framework/Magento/TestFramework/CodingStandard/Tool/CodeSniffer.php
index 3b20d86ee64b9..7f7a1b13b40a6 100644
--- a/dev/tests/static/framework/Magento/TestFramework/CodingStandard/Tool/CodeSniffer.php
+++ b/dev/tests/static/framework/Magento/TestFramework/CodingStandard/Tool/CodeSniffer.php
@@ -95,10 +95,11 @@ public function version()
* @param array $whiteList Files/directories to be inspected
* @param array $blackList Files/directories to be excluded from the inspection
* @param array $extensions Array of alphanumeric strings, for example: 'php', 'xml', 'phtml', 'css'...
+ * @param int $warningSeverity Severity level of warnings, default is 0
*
* @return int
*/
- public function run(array $whiteList, array $blackList = array(), array $extensions = array())
+ public function run(array $whiteList, array $blackList = array(), array $extensions = array(), $warningSeverity = 0)
{
$whiteList = array_map(function ($item) {
return $item;
@@ -115,7 +116,7 @@ public function run(array $whiteList, array $blackList = array(), array $extensi
$settings['ignored'] = $blackList;
$settings['extensions'] = $extensions;
$settings['reportFile'] = $this->_reportFile;
- $settings['warningSeverity'] = 0;
+ $settings['warningSeverity'] = $warningSeverity;
$settings['reports']['checkstyle'] = null;
$this->_wrapper->setValues($settings);
diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/ConcreteImplementationTest.php b/dev/tests/static/testsuite/Magento/Test/Integrity/ConcreteImplementationTest.php
new file mode 100644
index 0000000000000..6e9dbec4f5116
--- /dev/null
+++ b/dev/tests/static/testsuite/Magento/Test/Integrity/ConcreteImplementationTest.php
@@ -0,0 +1,71 @@
+fail("Incorrect class dependency found in $file:" . trim($type[0]));
+ }
+ }
+ }
+ },
+ \Magento\TestFramework\Utility\Files::init()->getClassFiles(true, false, false, false, false, false)
+ );
+ }
+}
diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/_files/blacklist/namespace.txt b/dev/tests/static/testsuite/Magento/Test/Integrity/_files/blacklist/namespace.txt
index 274783b42c9a3..46b39e01a3820 100644
--- a/dev/tests/static/testsuite/Magento/Test/Integrity/_files/blacklist/namespace.txt
+++ b/dev/tests/static/testsuite/Magento/Test/Integrity/_files/blacklist/namespace.txt
@@ -63,4 +63,5 @@ dev/tests/unit/testsuite/Magento/Code/Validator/_files/ClassesForConstructorInte
dev/tests/unit/testsuite/Magento/Code/Validator/_files/ClassesForContextAggregation.php
dev/tests/unit/testsuite/Magento/Code/Reader/_files/ClassesForArgumentsReader.php
dev/tests/unit/testsuite/Magento/Code/Validator/_files/ClassesForArgumentSequence.php
-dev/tests/unit/testsuite/Magento/Code/Validator/_files/ClassesForTypeDuplication.php
\ No newline at end of file
+dev/tests/unit/testsuite/Magento/Code/Validator/_files/ClassesForTypeDuplication.php
+dev/tests/static/testsuite/Magento/Test/Php/_files/phpcs/Magento/Sniffs/Annotations/RequireAnnotatedMethodsSniff.php
diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/_files/classes/blacklist.txt b/dev/tests/static/testsuite/Magento/Test/Integrity/_files/classes/blacklist.txt
new file mode 100644
index 0000000000000..1f94e467559bb
--- /dev/null
+++ b/dev/tests/static/testsuite/Magento/Test/Integrity/_files/classes/blacklist.txt
@@ -0,0 +1,6 @@
+\Magento\Backend\Model\Url
+\Magento\Core\Model\Url\RouteParamsResolver
+\Magento\Core\Model\Url\SecurityInfo
+\Magento\Core\Model\Url\ScopeResolver
+\Magento\Url
+\Magento\Core\Model\Config
diff --git a/dev/tests/static/testsuite/Magento/Test/Legacy/LayoutTest.php b/dev/tests/static/testsuite/Magento/Test/Legacy/LayoutTest.php
index e3688f440cd6a..d36e5d29a613f 100644
--- a/dev/tests/static/testsuite/Magento/Test/Legacy/LayoutTest.php
+++ b/dev/tests/static/testsuite/Magento/Test/Legacy/LayoutTest.php
@@ -321,7 +321,7 @@ public function getAllowedActionNodeMethods()
'setPageLayout',
'setPageTitle',
'setParentType',
- 'setPaypalActionPrefix',
+ 'setControllerPath',
'setPosition',
'setPositioned',
'setRewardMessage',
diff --git a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_classes.php b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_classes.php
index 8e548d12698ed..d3f1f58b232ed 100644
--- a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_classes.php
+++ b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_classes.php
@@ -597,7 +597,7 @@
'Magento\Backend\Model\Config\Source\Yesnocustom'
),
array('Mage_Adminhtml_Model_System_Store', 'Magento\Core\Model\System\Store'),
- array('Mage_Adminhtml_Model_Url', 'Magento\Backend\Model\Url'),
+ array('Mage_Adminhtml_Model_Url', 'Magento\Backend\Model\UrlInterface'),
array('Mage_Adminhtml_Rss_CatalogController'),
array('Mage_Adminhtml_Rss_OrderController'),
array('Mage_Adminhtml_SystemController', 'Magento\Backend\Controller\Adminhtml\System'),
@@ -1467,6 +1467,10 @@
array('Magento\Core\Model\Theme\FlyweightFactory', 'Magento\View\Design\Theme\FlyweightFactory'),
array('Magento\Core\Model\Image\AdapterFactory', 'Magento\Image\AdapterFactory'),
array('Magento\Core\Model\EntryPoint\Cron', 'Magento\App\Cron'),
+ array(
+ 'Magento\Checkout\Block\Cart\Item\Renderer\Grouped',
+ 'Magento\GroupedProduct\Block\Cart\Item\Renderer\Grouped'
+ ),
array('Magento\Log\Model\EntryPoint\Shell', 'Magento\Log\App\Shell'),
array('Magento\Index\Model\EntryPoint\Shell', 'Magento\Index\App\Shell'),
array('Magento\Index\Model\EntryPoint\Indexer', 'Magento\Index\App\Indexer'),
@@ -1802,6 +1806,7 @@
array('Magento\Catalog\Model\Resource\Convert'),
array('Magento\Reminder\Model\Resource\HelperFactory'),
array('Magento\Reminder\Model\Resource\Helper'),
+ array('Magento\Core\Model\ConfigInterface', 'Magento\App\ConfigInterface'),
array('Magento\CatalogRule\Block\Adminhtml\Promo\Widget\Chooser'),
array(
'Magento\Catalog\Model\Product\Type\Grouped\Backend',
@@ -1842,6 +1847,26 @@
'Magento\Catalog\Block\Product\View\Type\Grouped',
'Magento\GroupedProduct\Block\Product\View\Type\Grouped'
),
+ array(
+ 'Magento\Sales\Block\Adminhtml\Items\Column\Name\Grouped',
+ 'Magento\GroupedProduct\Block\Adminhtml\Items\Column\Name\Grouped'
+ ),
+ array(
+ 'Magento\Sales\Model\Order\Pdf\Items\Invoice\Grouped',
+ 'Magento\GroupedProduct\Model\Order\Pdf\Items\Invoice\Grouped'
+ ),
+ array(
+ 'Magento\Sales\Block\Order\Item\Renderer\Grouped',
+ 'Magento\GroupedProduct\Block\Order\Item\Renderer\Grouped'
+ ),
+ array(
+ 'Magento\ImportExport\Model\Export\Entity\Product\Type\Grouped',
+ 'Magento\GroupedProduct\Model\Export\Entity\Product\Type\Grouped'
+ ),
+ array(
+ 'Magento\ImportExport\Model\Import\Entity\Product\Type\Grouped',
+ 'Magento\GroupedProduct\Model\Import\Entity\Product\Type\Grouped'
+ ),
['CollFactory', 'CollectionFactory'], // no need to shorten anymore
['Magento\Shipping\Model\Rate\Result\AbstractResult', 'Magento\Sales\Model\Quote\Address\RateResult\AbstractResult'],
['Magento\Shipping\Model\Rate\Result\Error', 'Magento\Sales\Model\Quote\Address\RateResult\Error'],
@@ -1857,5 +1882,7 @@
array('Magento\PageCache\Model\Control\Zend'),
array('Magento\PageCache\Model\System\Config\Source\Controls'),
array('Magento\PageCache\Model\CacheControlFactory'),
- array('Magento\PageCache\Model\Observer'),
+ array('Magento\Config\Dom\Converter\ArrayConverter'),
+ array('Magento\Acl\Resource\Config\Dom'),
+ array('Magento\GoogleShopping\Helper\Price', 'Magento\Catalog\Model\Product\CatalogPrice'),
);
diff --git a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_constants.php b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_constants.php
index 620f02e6d0a08..982d56711acfd 100644
--- a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_constants.php
+++ b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_constants.php
@@ -26,12 +26,12 @@
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
return array(
- array('ADMIN_STORE_ID', 'Magento\Core\Model\AppInterface'),
+ array('ADMIN_STORE_ID', 'Magento\AppInterface'),
array('BACKORDERS_BELOW'),
array('DS'),
array('BACKORDERS_YES'),
array('CACHE_TAG', 'Magento\Api\Model\Config', 'Magento_Api_Model_Cache_Type::CACHE_TAG'),
- array('CACHE_TAG', 'Magento\Core\Model\AppInterface'),
+ array('CACHE_TAG', 'Magento\AppInterface'),
array(
'CACHE_TAG',
'Magento\Core\Model\Resource\Db\Collection\AbstractCollection',
@@ -94,7 +94,7 @@
array('INIT_OPTION_RESPONSE', 'Magento\Core\Model\App'),
array('INIT_OPTION_SCOPE_CODE', 'Magento\Core\Model\App', 'Magento_Core_Model_App::PARAM_RUN_CODE'),
array('INIT_OPTION_SCOPE_TYPE', 'Magento\Core\Model\App', 'Magento_Core_Model_App::PARAM_RUN_TYPE'),
- array('INIT_OPTION_URIS', 'Magento\Core\Model\App', 'Magento_Core_Model_App::PARAM_APP_URIS'),
+ array('INIT_OPTION_URIS', 'Magento\Core\Model\App'),
array('INSTALLER_HOST_RESPONSE', 'Magento\Install\Model\Installer'),
array(
'LAYOUT_GENERAL_CACHE_TAG',
@@ -104,6 +104,7 @@
array('LOCALE_CACHE_KEY', 'Magento\Backend\Block\Page\Footer'),
array('LOCALE_CACHE_LIFETIME', 'Magento\Backend\Block\Page\Footer'),
array('LOCALE_CACHE_TAG', 'Magento\Backend\Block\Page\Footer'),
+ array('PARAM_CACHE_OPTIONS', '\Magento\Core\Model\App', '\Magento\Core\Model\App::PARAM_CACHE_FORCED_OPTIONS'),
array('PATH_PREFIX_CUSTOMIZATION', 'Magento\Core\Model\Theme'),
array('PATH_PREFIX_CUSTOMIZED', 'Magento\Core\Model\Theme\Files'),
array('PUBLIC_BASE_THEME_DIR', 'Magento\Core\Model\Design\PackageInterface'),
@@ -505,7 +506,7 @@
),
array(
'USE_PARENT_IMAGE',
- 'Magento\Checkout\Block\Cart\Item\Renderer\Grouped',
+ 'Magento\GroupedProduct\Block\Cart\Item\Renderer\Grouped',
'Magento\Catalog\Model\Config\Source\Product\Thumbnail::OPTION_USE_PARENT_IMAGE'
),
array(
@@ -515,8 +516,8 @@
),
array(
'GROUPED_PRODUCT_IMAGE',
- 'Magento\Checkout\Block\Cart\Item\Renderer\Grouped',
- 'Magento\Checkout\Block\Cart\Item\Renderer\Grouped::CONFIG_THUMBNAIL_SOURCE'
+ 'Magento\GroupedProduct\Block\Cart\Item\Renderer\Grouped',
+ 'Magento\GroupedProduct\Block\Cart\Item\Renderer\Grouped::CONFIG_THUMBNAIL_SOURCE'
),
array('TYPE_BLOCK', '\Magento\Core\Model\Layout', '\Magento\View\Layout\Element'),
array('TYPE_CONTAINER', '\Magento\Core\Model\Layout', '\Magento\View\Layout\Element'),
diff --git a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_methods.php b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_methods.php
index a1b18f18361fa..b4ac933e9ce51 100644
--- a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_methods.php
+++ b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_methods.php
@@ -147,6 +147,8 @@
array('_needToAddDummy'),
array('_needToAddDummyForShipment'),
array('_outTemplate', 'Magento\Backend\App\AbstractAction'),
+ array('getCustomer', 'Magento\Sales\Block\Adminhtml\Order\Create\AbstractCreate', 'getCustomerId'),
+ array('_getAddressForm', 'Magento\Sales\Block\Adminhtml\Order\Create\Form\Address'),
array('_parseDescription', 'Magento\Sales\Model\Order\Pdf\Items\AbstractItems'),
array('_parsePackageTheme', 'Magento\Widget\Model\Widget\Instance'),
array('_parseXmlTrackingResponse', 'Magento\Usa\Model\Shipping\Carrier\Fedex'),
@@ -287,6 +289,7 @@
array('countChildren', 'Magento\Core\Block\AbstractBlock'),
array('crear'),
array('createDirIfNotExists', '', 'mkdir()'),
+ array('createEntityTables', 'Magento\Eav\Model\Entity\Setup'),
array('createOrderItem', 'Magento\CatalogInventory\Model\Observer'),
array('debugRequest', 'Magento\Paypal\Model\Api\Standard'),
array('decorateArray', 'Magento\Core\Helper\Data', 'Magento\Stdlib\ArrayUtils::decorateArray'),
@@ -345,7 +348,7 @@
array('getConfigDataModel', 'Magento\Core\Model\Config'),
array('getConnectionTypeInstance', 'Magento\App\Resource'),
array('getContainers', 'Magento\Core\Model\Layout\Update', 'Magento\Core\Model\Layout\Merge'),
- array('getCurrentUrl', 'Magento\Core\Helper\Url', 'Magento\Core\Model\Url'),
+ array('getCurrentUrl', 'Magento\Core\Helper\Url', 'Magento\Url'),
array('getCustomerData', 'Magento\Sales\Block\Adminhtml\Order\Create\Form\Account'),
array('getDataForSave', 'Magento\Wishlist\Model\Item'),
array('getDataMaxSize'),
@@ -503,8 +506,8 @@
array('getRowId', 'Magento\Backend\Block\Widget\Grid'),
array('getSaveTemplateFlag', 'Magento\Newsletter\Model\Queue'),
array('getSectionNode', 'Magento\Core\Model\Config'),
- array('getSecure', 'Magento\Backend\Model\Url', 'isSecure'),
- array('getSecure', 'Magento\Core\Model\Url', 'isSecure'),
+ array('getSecure', 'Magento\Backend\Model\UrlInterface', 'isSecure'),
+ array('getSecure', 'Magento\Url', 'isSecure'),
array('getSelectionFinalPrice', 'Magento\Bundle\Model\Product\Price'),
array('getShipId', 'Magento\Shipping\Block\Tracking\Popup'),
array('getShippingCarrier', 'Magento\Sales\Model\Order', 'Magento\Shipping\Model\CarrierFactory::create'),
@@ -889,7 +892,7 @@
array('run', '\Magento\Core\Model\App'),
array('_initFrontController', '\Magento\Core\Model\App'),
array('_getFrontControllerByCurrentArea', '\Magento\Core\Model\App'),
- array('run', '\Magento\Core\Model\AppInterface'),
+ array('run', '\Magento\AppInterface'),
array('setModuleDir', 'Magento\Module\Dir\Reader'),
array('setModuleDir', 'Magento\Core\Model\Config'),
array('getAreaConfig', 'Magento\Core\Model\Config'),
@@ -1189,4 +1192,10 @@
array('getUpdateUrl', 'Magento\Wishlist\Helper\Data'),
array('getItemRemoveUrl', 'Magento\Wishlist\Block\AbstractBlock'),
array('_getUrlParams', 'Magento\Catalog\Helper\Product\Compare'),
+ array('getFileIdentifier', 'Magento\View\Layout\File\FileList', 'Magento\View\Layout\File'),
+ array('_getInitialXml', 'Magento\Config\Theme'),
+ array('_getIdAttributes', 'Magento\Config\Theme'),
+ array('_getSession', 'Magento\CatalogSearch\Controller\Result'),
+ array('addPriceBlockType', 'Magento\Rss\Block\Catalog\AbstractCatalog'),
+ array('getAttributeDisabledTypes', 'Magento\Catalog\Helper\Data'),
);
diff --git a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_properties.php b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_properties.php
index bbdd9b45e7692..27369667fcae2 100644
--- a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_properties.php
+++ b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_properties.php
@@ -50,6 +50,9 @@
array('_currency', 'Magento\GoogleCheckout\Model\Api\Xml\Checkout'),
array('_currencyNameTable'),
array('_customEtcDir', 'Magento\Core\Model\Config'),
+ array('_customerFactory ', '\Magento\Sales\Block\Adminhtml\Billing\Agreement\View\Tab\Info'),
+ array('_customerFactory ', '\Magento\Sales\Block\Adminhtml\Order\Create\Form\Account'),
+ array('_customerFormFactory', '\Magento\Sales\Block\Adminhtml\Order\Create\Form\Account'),
array('_defaultTemplates', 'Magento\Email\Model\Template'),
array('_designProductSettingsApplied'),
array('_directOutput', 'Magento\Core\Model\Layout'),
@@ -105,6 +108,8 @@
array('decoratedIsOdd', null, 'getDecoratedIsOdd'),
array('decoratedIsLast', null, 'getDecoratedIsLast'),
array('static', 'Magento\Email\Model\Template\Filter'),
+ array('_addressForm', 'Magento\Sales\Block\Adminhtml\Order\Create\Form\Address'),
+ array('_adminhtmlAddresses', 'Magento\Sales\Block\Adminhtml\Order\Create\Form\Address'),
array('_useAnalyticFunction'),
array('_defaultIndexer', 'Magento\CatalogInventory\Model\Resource\Indexer\Stock'),
array('_engine', 'Magento\CatalogSearch\Model\Resource\Fulltext'),
@@ -267,4 +272,5 @@
array('_messagesBlock', 'Magento\View\Element\AbstractBlock'),
array('_messagesBlock', 'Magento\Connect\Helper\Data'),
array('escapeMessageFlag', 'Magento\View\Block\Messages'),
+ array('fileIteratorFactory', 'Magento\Core\Model\Theme\Collection')
);
diff --git a/dev/tests/static/testsuite/Magento/Test/Php/LiveCodeTest.php b/dev/tests/static/testsuite/Magento/Test/Php/LiveCodeTest.php
index e72132c4f240e..7d2bb7b346e73 100644
--- a/dev/tests/static/testsuite/Magento/Test/Php/LiveCodeTest.php
+++ b/dev/tests/static/testsuite/Magento/Test/Php/LiveCodeTest.php
@@ -23,8 +23,8 @@
* @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
-
namespace Magento\Test\Php;
+
use Magento\TestFramework\Utility;
/**
@@ -119,6 +119,29 @@ public function testCodeStyle()
);
}
+ public function testAnnotationStandard()
+ {
+ $reportFile = self::$_reportDir . '/phpcs_annotations_report.xml';
+ $warningSeverity = 5;
+ $wrapper = new \Magento\TestFramework\CodingStandard\Tool\CodeSniffer\Wrapper();
+ $codeSniffer = new \Magento\TestFramework\CodingStandard\Tool\CodeSniffer(
+ realpath(__DIR__ . '/_files/phpcs/Magento'),
+ $reportFile,
+ $wrapper
+ );
+ if (!$codeSniffer->canRun()) {
+ $this->markTestSkipped('PHP Code Sniffer is not installed.');
+ }
+ self::setupFileLists();
+ $result = $codeSniffer->run(self::$_whiteList, self::$_blackList, array('php', 'phtml'), $warningSeverity);
+ $this->markTestIncomplete("PHP Code Sniffer has found $result error(s): See detailed report in $reportFile");
+ $this->assertEquals(
+ 0,
+ $result,
+ "PHP Code Sniffer has found $result error(s): See detailed report in $reportFile"
+ );
+ }
+
public function testCodeMess()
{
$reportFile = self::$_reportDir . '/phpmd_report.xml';
diff --git a/dev/tests/static/testsuite/Magento/Test/Php/_files/phpcpd/blacklist/common.txt b/dev/tests/static/testsuite/Magento/Test/Php/_files/phpcpd/blacklist/common.txt
index f7aabbe67971c..a6b13a3d4d0bc 100644
--- a/dev/tests/static/testsuite/Magento/Test/Php/_files/phpcpd/blacklist/common.txt
+++ b/dev/tests/static/testsuite/Magento/Test/Php/_files/phpcpd/blacklist/common.txt
@@ -98,6 +98,7 @@ lib/Magento/Acl
lib/PEAR
lib/phpseclib
lib/Magento/Convert
+lib/Magento/App/Config
Magento/Cron/Model
Magento/SalesRule/Model/Resource/Report/Rule
Magento/SalesRule/Model/Resource/Rule
diff --git a/dev/tests/static/testsuite/Magento/Test/Php/_files/phpcs/Magento/Sniffs/Annotations/RequireAnnotatedMethodsSniff.php b/dev/tests/static/testsuite/Magento/Test/Php/_files/phpcs/Magento/Sniffs/Annotations/RequireAnnotatedMethodsSniff.php
new file mode 100644
index 0000000000000..6bee378ab18a3
--- /dev/null
+++ b/dev/tests/static/testsuite/Magento/Test/Php/_files/phpcs/Magento/Sniffs/Annotations/RequireAnnotatedMethodsSniff.php
@@ -0,0 +1,1022 @@
+
+ * @author Marc McIntyre
+ * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600)
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
+ * @link http://pear.php.net/package/PHP_CodeSniffer
+ *
+ * @SuppressWarnings(PHPMD)
+ */
+class Magento_Sniffs_Annotations_RequireAnnotatedMethodsSniff implements PHP_CodeSniffer_Sniff
+{
+ const AMBIGUOUS_TYPE = 'AmbiguousType';
+
+ const MISSING = 'Missing';
+
+ const WRONG_STYLE = 'WrongStyle';
+
+ const WRONG_END = 'WrongEnd';
+
+ const FAILED_PARSE = 'FailedParse';
+
+ const CONTENT_AFTER_OPEN = 'ContentAfterOpen';
+
+ const MISSING_SHORT = 'MissingShort';
+
+ const NO_DOC = 'Empty';
+
+ const SPACING_BEFORE_SHORT = 'SpacingBeforeShort';
+
+ const SPACING_BEFORE_TAGS = 'SpacingBeforeTags';
+
+ const SHORT_SINGLE_LINE = 'ShortSingleLine';
+
+ const SHORT_NOT_CAPITAL = 'ShortNotCapital';
+
+ const SPACING_AFTER = 'SpacingAfter';
+
+ const SEE_ORDER = 'SeeOrder';
+
+ const EMPTY_SEE = 'EmptySee';
+
+ const DUPLICATE_RETURN = 'DuplicateReturn';
+
+ const MISSING_PARAM_TAG = 'MissingParamTag';
+
+ const SPACING_AFTER_LONG_NAME = 'SpacingAfterLongName';
+
+ const SPACING_AFTER_LONG_TYPE = 'SpacingAfterLongType';
+
+ const MISSING_PARAM_TYPE = 'MissingParamType';
+
+ const MISSING_PARAM_NAME = 'MissingParamName';
+
+ const EXTRA_PARAM_COMMENT = 'ExtraParamComment';
+
+ const PARAM_NAME_NO_MATCH = 'ParamNameNoMatch';
+
+ const PARAM_NAME_NO_CASE_MATCH = 'ParamNameNoCaseMatch';
+
+ const INVALID_TYPE_HINT = 'InvalidTypeHint';
+
+ const INCORRECT_TYPE_HINT = 'IncorrectTypeHint';
+
+ const TYPE_HINT_MISSING = 'TypeHintMissing';
+
+ const INCORRECT_PARAM_VAR_NAME = 'IncorrectParamVarName';
+
+ const RETURN_ORDER = 'ReturnOrder';
+
+ const MISSING_RETURN_TYPE = 'MissingReturnType';
+
+ const INVALID_RETURN = 'InvalidReturn';
+
+ const INVALID_RETURN_VOID = 'InvalidReturnVoid';
+
+ const INVALID_NO_RETURN = 'InvalidNoReturn';
+
+ const INVALID_RETURN_NOT_VOID = 'InvalidReturnNotVoid';
+
+ const INCORRECT_INHERIT_DOC = 'IncorrectInheritDoc';
+
+ const RETURN_INDENT = 'ReturnIndent';
+
+ const MISSING_RETURN = 'MissingReturn';
+
+ const RETURN_NOT_REQUIRED = 'ReturnNotRequired';
+
+ const INVALID_THROWS = 'InvalidThrows';
+
+ const THROWS_NOT_CAPITAL = 'ThrowsNotCapital';
+
+ const THROWS_ORDER = 'ThrowsOrder';
+
+ const SPACING_AFTER_PARAMS = 'SpacingAfterParams';
+
+ const SPACING_BEFORE_PARAMS = 'SpacingBeforeParams';
+
+ const SPACING_BEFORE_PARAM_TYPE = 'SpacingBeforeParamType';
+
+ const ERROR = 0;
+
+ // tells phpcs to use the default level
+ const WARNING = 6;
+
+ // default level of warnings is 5
+ const INFO = 1;
+
+ protected static $reportingLevel = array(
+ self::AMBIGUOUS_TYPE => self::WARNING,
+ self::MISSING => self::WARNING,
+ self::WRONG_STYLE => self::WARNING,
+ self::WRONG_END => self::WARNING,
+ self::FAILED_PARSE => self::WARNING,
+ self::NO_DOC => self::WARNING,
+ self::CONTENT_AFTER_OPEN => self::WARNING,
+ self::MISSING_SHORT => self::WARNING,
+ self::NO_DOC => self::WARNING,
+ self::SPACING_BEFORE_SHORT => self::WARNING,
+ self::SPACING_BEFORE_TAGS => self::WARNING,
+ self::SHORT_SINGLE_LINE => self::WARNING,
+ self::SHORT_NOT_CAPITAL => self::WARNING,
+ self::SPACING_AFTER => self::WARNING,
+ self::SEE_ORDER => self::WARNING,
+ self::EMPTY_SEE => self::WARNING,
+ self::DUPLICATE_RETURN => self::WARNING,
+ self::MISSING_PARAM_TAG => self::WARNING,
+ self::SPACING_AFTER_LONG_NAME => self::WARNING,
+ self::SPACING_AFTER_LONG_TYPE => self::WARNING,
+ self::MISSING_PARAM_TYPE => self::WARNING,
+ self::MISSING_PARAM_NAME => self::WARNING,
+ self::EXTRA_PARAM_COMMENT => self::WARNING,
+ self::PARAM_NAME_NO_MATCH => self::WARNING,
+ self::PARAM_NAME_NO_CASE_MATCH => self::WARNING,
+ self::INVALID_TYPE_HINT => self::WARNING,
+ self::INCORRECT_TYPE_HINT => self::WARNING,
+ self::TYPE_HINT_MISSING => self::WARNING,
+ self::INCORRECT_PARAM_VAR_NAME => self::WARNING,
+ self::RETURN_ORDER => self::WARNING,
+ self::MISSING_RETURN_TYPE => self::WARNING,
+ self::INVALID_RETURN => self::WARNING,
+ self::INVALID_RETURN_VOID => self::WARNING,
+ self::INVALID_NO_RETURN => self::WARNING,
+ self::INVALID_RETURN_NOT_VOID => self::WARNING,
+ self::INCORRECT_INHERIT_DOC => self::WARNING,
+ self::RETURN_INDENT => self::WARNING,
+ self::MISSING_RETURN => self::WARNING,
+ self::RETURN_NOT_REQUIRED => self::WARNING,
+ self::INVALID_THROWS => self::WARNING,
+ self::THROWS_NOT_CAPITAL => self::WARNING,
+ self::THROWS_ORDER => self::WARNING,
+ self::SPACING_AFTER_PARAMS => self::WARNING,
+ self::SPACING_BEFORE_PARAMS => self::WARNING,
+ self::SPACING_BEFORE_PARAM_TYPE => self::WARNING
+ );
+
+ /**
+ * List of allowed types
+ *
+ * @var string[]
+ */
+ protected static $allowedTypes = array(
+ 'array',
+ 'boolean',
+ 'bool',
+ 'float',
+ 'integer',
+ 'int',
+ 'object',
+ 'string',
+ 'resource',
+ 'callable'
+ );
+
+ /**
+ * The name of the method that we are currently processing.
+ *
+ * @var string
+ */
+ private $_methodName = '';
+
+ /**
+ * The position in the stack where the function token was found.
+ *
+ * @var int
+ */
+ private $_functionToken = null;
+
+ /**
+ * The position in the stack where the class token was found.
+ *
+ * @var int
+ */
+ private $_classToken = null;
+
+ /**
+ * The index of the current tag we are processing.
+ *
+ * @var int
+ */
+ private $_tagIndex = 0;
+
+ /**
+ * The function comment parser for the current method.
+ *
+ * @var PHP_CodeSniffer_Comment_Parser_FunctionCommentParser
+ */
+ protected $commentParser = null;
+
+ /**
+ * The current PHP_CodeSniffer_File object we are processing.
+ *
+ * @var PHP_CodeSniffer_File
+ */
+ protected $currentFile = null;
+
+ /**
+ * Returns an array of tokens this test wants to listen for.
+ *
+ * @return array
+ */
+ public function register()
+ {
+ return array(T_FUNCTION);
+ }
+
+ //end register()
+
+
+ /**
+ * Processes this test, when one of its tokens is encountered.
+ *
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
+ * @param int $stackPtr The position of the current token
+ * in the stack passed in $tokens.
+ *
+ * @return void
+ */
+ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
+ {
+ $this->currentFile = $phpcsFile;
+
+ $tokens = $phpcsFile->getTokens();
+
+ $find = array(T_COMMENT, T_DOC_COMMENT, T_CLASS, T_FUNCTION, T_OPEN_TAG);
+
+ $commentEnd = $phpcsFile->findPrevious($find, $stackPtr - 1);
+
+ if ($commentEnd === false) {
+ return;
+ }
+
+ // If the token that we found was a class or a function, then this
+ // function has no doc comment.
+ $code = $tokens[$commentEnd]['code'];
+
+ if ($code === T_COMMENT) {
+ // The function might actually be missing a comment, and this last comment
+ // found is just commenting a bit of code on a line. So if it is not the
+ // only thing on the line, assume we found nothing.
+ $prevContent = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, $commentEnd);
+ if ($tokens[$commentEnd]['line'] === $tokens[$commentEnd]['line']) {
+ $error = 'Missing function doc comment';
+ $this->addMessage($error, $stackPtr, self::MISSING);
+ } else {
+ $error = 'You must use "/**" style comments for a function comment';
+ $this->addMessage($error, $stackPtr, self::WRONG_STYLE);
+ }
+ return;
+ } else {
+ if ($code !== T_DOC_COMMENT) {
+ $error = 'Missing function doc comment';
+ $this->addMessage($error, $stackPtr, self::MISSING);
+ return;
+ } else {
+ if (trim($tokens[$commentEnd]['content']) !== '*/') {
+ $error = 'You must use "*/" to end a function comment; found "%s"';
+ $this->addMessage(
+ $error,
+ $commentEnd,
+ self::WRONG_END,
+ array(trim($tokens[$commentEnd]['content']))
+ );
+ return;
+ }
+ }
+ }
+
+ // If there is any code between the function keyword and the doc block
+ // then the doc block is not for us.
+ $ignore = PHP_CodeSniffer_Tokens::$scopeModifiers;
+ $ignore[] = T_STATIC;
+ $ignore[] = T_WHITESPACE;
+ $ignore[] = T_ABSTRACT;
+ $ignore[] = T_FINAL;
+ $prevToken = $phpcsFile->findPrevious($ignore, $stackPtr - 1, null, true);
+ if ($prevToken !== $commentEnd) {
+ $this->addMessage('Missing function doc comment', $stackPtr, self::MISSING);
+ return;
+ }
+
+ $this->_functionToken = $stackPtr;
+
+ $this->_classToken = null;
+ foreach ($tokens[$stackPtr]['conditions'] as $condPtr => $condition) {
+ if ($condition === T_CLASS || $condition === T_INTERFACE) {
+ $this->_classToken = $condPtr;
+ break;
+ }
+ }
+
+ // Find the first doc comment.
+ $commentStart = $phpcsFile->findPrevious(T_DOC_COMMENT, $commentEnd - 1, null, true) + 1;
+ $commentString = $phpcsFile->getTokensAsString($commentStart, $commentEnd - $commentStart + 1);
+ $this->_methodName = $phpcsFile->getDeclarationName($stackPtr);
+
+ try {
+ $this->commentParser = new PHP_CodeSniffer_CommentParser_FunctionCommentParser($commentString, $phpcsFile);
+ $this->commentParser->parse();
+ } catch (PHP_CodeSniffer_CommentParser_ParserException $e) {
+ $line = $e->getLineWithinComment() + $commentStart;
+ $this->addMessage($e->getMessage(), $line, self::FAILED_PARSE);
+ return;
+ }
+
+ $comment = $this->commentParser->getComment();
+ if (is_null($comment) === true) {
+ $error = 'Function doc comment is empty';
+ $this->addMessage($error, $commentStart, self::NO_DOC);
+ return;
+ }
+
+ // The first line of the comment should just be the /** code.
+ $eolPos = strpos($commentString, $phpcsFile->eolChar);
+ $firstLine = substr($commentString, 0, $eolPos);
+ if ($firstLine !== '/**') {
+ $error = 'The open comment tag must be the only content on the line';
+ $this->addMessage($error, $commentStart, self::CONTENT_AFTER_OPEN);
+ }
+
+ // If the comment has an inherit doc note just move on
+ if (preg_match('/\{\@inheritdoc\}/', $commentString)) {
+ return;
+ } else {
+ if (preg_match('/\{?\@?inherit[dD]oc\}?/', $commentString)) {
+ $error = 'The incorrect inherit doc tag usage. Should be {@inheritdoc}';
+ $this->addMessage($error, $commentStart, self::INCORRECT_INHERIT_DOC);
+ return;
+ }
+ }
+
+ $this->processParams($commentStart, $commentEnd);
+ $this->processSees($commentStart);
+ $this->processReturn($commentStart, $commentEnd);
+ $this->processThrows($commentStart);
+
+ // Check for a comment description.
+ $short = $comment->getShortComment();
+ if (trim($short) === '') {
+ $error = 'Missing short description in function doc comment';
+ $this->addMessage($error, $commentStart, self::MISSING_SHORT);
+ return;
+ }
+
+ // No extra newline before short description.
+ $newlineCount = 0;
+ $newlineSpan = strspn($short, $phpcsFile->eolChar);
+ if ($short !== '' && $newlineSpan > 0) {
+ $error = 'Extra newline(s) found before function comment short description';
+ $this->addMessage($error, $commentStart + 1, self::SPACING_BEFORE_SHORT);
+ }
+
+ $newlineCount = substr_count($short, $phpcsFile->eolChar) + 1;
+
+ // Exactly one blank line between short and long description.
+ $long = $comment->getLongComment();
+ /* Magento Standard Allows for no long description
+ if (empty($long) === false) {
+ $between = $comment->getWhiteSpaceBetween();
+ $newlineBetween = substr_count($between, $phpcsFile->eolChar);
+ if ($newlineBetween !== 2) {
+ $error = 'There must be exactly one blank line between descriptions in function comment';
+ $phpcsFile->addError($error, ($commentStart + $newlineCount + 1), 'SpacingBetween');
+ }
+ $newlineCount += $newlineBetween;
+ $testLong = trim($long);
+ if (preg_match('|\p{Lu}|u', $testLong[0]) === 0) {
+ $error = 'Function comment long description must start with a capital letter';
+ $phpcsFile->addError($error, ($commentStart + $newlineCount), 'LongNotCapital');
+ }
+ }//end if
+ */
+
+ // Exactly one blank line before tags.
+ $params = $this->commentParser->getTagOrders();
+ if (count($params) > 1) {
+ $newlineSpan = $comment->getNewlineAfter();
+ if ($newlineSpan !== 2) {
+ $error = 'There must be exactly one blank line before the tags in function comment';
+ if ($long !== '') {
+ $newlineCount += substr_count($long, $phpcsFile->eolChar) - $newlineSpan + 1;
+ }
+
+ $this->addMessage($error, $commentStart + $newlineCount, self::SPACING_BEFORE_TAGS);
+ $short = rtrim($short, $phpcsFile->eolChar . ' ');
+ }
+ }
+
+ // Short description must be single line and end with a full stop.
+ $testShort = trim($short);
+ $lastChar = $testShort[strlen($testShort) - 1];
+ if (substr_count($testShort, $phpcsFile->eolChar) !== 0) {
+ $error = 'Function comment short description must be on a single line';
+ $this->addMessage($error, $commentStart + 1, self::SHORT_SINGLE_LINE);
+ }
+
+ if (preg_match('|\p{Lu}|u', $testShort[0]) === 0) {
+ $error = 'Function comment short description must start with a capital letter';
+ $this->addMessage($error, $commentStart + 1, self::SHORT_NOT_CAPITAL);
+ }
+
+ /* Magento standard does not require this.
+ if ($lastChar !== '.') {
+ $error = 'Function comment short description must end with a full stop';
+ $phpcsFile->addError($error, ($commentStart + 1), 'ShortFullStop');
+ }
+ */
+
+ // Check for unknown/deprecated tags.
+ /* Magento is not using this at the moment
+ $this->processUnknownTags($commentStart, $commentEnd);
+ */
+
+ // The last content should be a newline and the content before
+ // that should not be blank. If there is more blank space
+ // then they have additional blank lines at the end of the comment.
+ $words = $this->commentParser->getWords();
+ $lastPos = count($words) - 1;
+ if (trim(
+ $words[$lastPos - 1]
+ ) !== '' || strpos(
+ $words[$lastPos - 1],
+ $this->currentFile->eolChar
+ ) === false || trim(
+ $words[$lastPos - 2]
+ ) === ''
+ ) {
+ $error = 'Additional blank lines found at end of function comment';
+ $this->addMessage($error, $commentEnd, self::SPACING_AFTER);
+ }
+ }
+
+ //end process()
+
+
+ /**
+ * Process the see tags.
+ *
+ * @param int $commentStart The position in the stack where the comment started.
+ *
+ * @return void
+ */
+ protected function processSees($commentStart)
+ {
+ $sees = $this->commentParser->getSees();
+ if (empty($sees) === false) {
+ $tagOrder = $this->commentParser->getTagOrders();
+ $index = array_keys($this->commentParser->getTagOrders(), 'see');
+ foreach ($sees as $i => $see) {
+ $errorPos = $commentStart + $see->getLine();
+ $since = array_keys($tagOrder, 'since');
+ if (count($since) === 1 && $this->_tagIndex !== 0) {
+ $this->_tagIndex++;
+ if ($index[$i] !== $this->_tagIndex) {
+ $error = 'The @see tag is in the wrong order; the tag precedes @return';
+ $this->addMessage($error, $errorPos, self::SEE_ORDER);
+ }
+ }
+
+ $content = $see->getContent();
+ if (empty($content) === true) {
+ $error = 'Content missing for @see tag in function comment';
+ $this->addMessage($error, $errorPos, self::EMPTY_SEE);
+ continue;
+ }
+ }
+ }
+ }
+
+ //end processSees()
+
+
+ /**
+ * Process the return comment of this function comment.
+ *
+ * @param int $commentStart The position in the stack where the comment started.
+ * @param int $commentEnd The position in the stack where the comment ended.
+ *
+ * @return void
+ */
+ protected function processReturn($commentStart, $commentEnd)
+ {
+ // Skip constructor and destructor.
+ $className = '';
+ if ($this->_classToken !== null) {
+ $className = $this->currentFile->getDeclarationName($this->_classToken);
+ $className = strtolower(ltrim($className, '_'));
+ }
+
+ $methodName = strtolower(ltrim($this->_methodName, '_'));
+ $isSpecialMethod = $this->_methodName === '__construct' || $this->_methodName === '__destruct';
+ $return = $this->commentParser->getReturn();
+
+ if ($isSpecialMethod === false && $methodName !== $className) {
+ if ($return !== null) {
+ $tagOrder = $this->commentParser->getTagOrders();
+ $index = array_keys($tagOrder, 'return');
+ $errorPos = $commentStart + $return->getLine();
+ $content = trim($return->getRawContent());
+
+ if (count($index) > 1) {
+ $error = 'Only 1 @return tag is allowed in function comment';
+ $this->addMessage($error, $errorPos, self::DUPLICATE_RETURN);
+ return;
+ }
+
+ $since = array_keys($tagOrder, 'since');
+ if (count($since) === 1 && $this->_tagIndex !== 0) {
+ $this->_tagIndex++;
+ if ($index[0] !== $this->_tagIndex) {
+ $error = 'The @return tag is in the wrong order; the tag follows @see (if used)';
+ $this->addMessage($error, $errorPos, self::RETURN_ORDER);
+ }
+ }
+
+ if (empty($content) === true) {
+ $error = 'Return type missing for @return tag in function comment';
+ $this->addMessage($error, $errorPos, self::MISSING_RETURN_TYPE);
+ } else {
+ // Check return type (can be multiple, separated by '|').
+ $typeNames = explode('|', $content);
+ $suggestedNames = array();
+ foreach ($typeNames as $i => $typeName) {
+ $suggestedName = $this->suggestType($typeName);
+ if (in_array($suggestedName, $suggestedNames) === false) {
+ $suggestedNames[] = $suggestedName;
+ }
+ }
+
+ $suggestedType = implode('|', $suggestedNames);
+ if ($content !== $suggestedType) {
+ $error = 'Function return type "%s" is invalid';
+ $data = array($content);
+ $this->addMessage($error, $errorPos, self::INVALID_RETURN, $data);
+ } elseif ($content === 'array' || $content === 'mixed') {
+ // Warn about ambiguous types ie array or mixed
+ $error = 'Ambiguous type "%s" for @return is NOT recommended';
+ $data = array($typeName);
+ $this->addMessage($error, $errorPos, self::AMBIGUOUS_TYPE, $data);
+ }
+
+ $tokens = $this->currentFile->getTokens();
+
+ // If the return type is void, make sure there is
+ // no return statement in the function.
+ if ($content === 'void') {
+ if (isset($tokens[$this->_functionToken]['scope_closer']) === true) {
+ $endToken = $tokens[$this->_functionToken]['scope_closer'];
+
+ $tokens = $this->currentFile->getTokens();
+ for ($returnToken = $this->_functionToken; $returnToken < $endToken; $returnToken++) {
+ if ($tokens[$returnToken]['code'] === T_CLOSURE) {
+ $returnToken = $tokens[$returnToken]['scope_closer'];
+ continue;
+ }
+
+ if ($tokens[$returnToken]['code'] === T_RETURN) {
+ break;
+ }
+ }
+
+ if ($returnToken !== $endToken) {
+ // If the function is not returning anything, just
+ // exiting, then there is no problem.
+ $semicolon = $this->currentFile->findNext(T_WHITESPACE, $returnToken + 1, null, true);
+ if ($tokens[$semicolon]['code'] !== T_SEMICOLON) {
+ $error = 'Function return type is void, but function contains return statement';
+ $this->addMessage($error, $errorPos, self::INVALID_RETURN_VOID);
+ }
+ }
+ }
+ } else {
+ if ($content !== 'mixed') {
+ // If return type is not void, there needs to be a
+ // returns statement somewhere in the function that
+ // returns something.
+ if (isset($tokens[$this->_functionToken]['scope_closer']) === true) {
+ $endToken = $tokens[$this->_functionToken]['scope_closer'];
+ $returnToken = $this->currentFile->findNext(
+ T_RETURN,
+ $this->_functionToken,
+ $endToken
+ );
+ if ($returnToken === false) {
+ $error = 'Function return type is not void, but function has no return statement';
+ $this->addMessage($error, $errorPos, self::INVALID_NO_RETURN);
+ } else {
+ $semicolon = $this->currentFile->findNext(
+ T_WHITESPACE,
+ $returnToken + 1,
+ null,
+ true
+ );
+ if ($tokens[$semicolon]['code'] === T_SEMICOLON) {
+ $error = 'Function return type is not void, ' .
+ 'but function is returning void here';
+ $this->addMessage($error, $returnToken, self::INVALID_RETURN_NOT_VOID);
+ }
+ }
+ }
+ }
+ }
+ //end if
+
+ $spacing = substr_count($return->getWhitespaceBeforeValue(), ' ');
+ if ($spacing !== 1) {
+ $error = '@return tag indented incorrectly; expected 1 space but found %s';
+ $data = array($spacing);
+ $this->addMessage($error, $errorPos, self::RETURN_INDENT, $data);
+ }
+ }
+ } else {
+ $error = 'Missing @return tag in function comment';
+ $this->addMessage($error, $commentEnd, self::MISSING_RETURN);
+ }
+ } else {
+ // No return tag for constructor and destructor.
+ if ($return !== null) {
+ $errorPos = $commentStart + $return->getLine();
+ $error = '@return tag is not required for constructor and destructor';
+ $this->addMessage($error, $errorPos, self::RETURN_NOT_REQUIRED);
+ }
+ }
+ }
+
+ //end processReturn()
+
+
+ /**
+ * Process any throw tags that this function comment has.
+ *
+ * @param int $commentStart The position in the stack where the comment started.
+ *
+ * @return void
+ */
+ protected function processThrows($commentStart)
+ {
+ if (count($this->commentParser->getThrows()) === 0) {
+ return;
+ }
+
+ $tagOrder = $this->commentParser->getTagOrders();
+ $index = array_keys($this->commentParser->getTagOrders(), 'throws');
+
+ foreach ($this->commentParser->getThrows() as $i => $throw) {
+ $exception = $throw->getValue();
+ $content = trim($throw->getComment());
+ $errorPos = $commentStart + $throw->getLine();
+ if (empty($exception) === true) {
+ $error = 'Exception type and comment missing for @throws tag in function comment';
+ $this->addMessage($error, $errorPos, self::INVALID_THROWS);
+ } else {
+ if (empty($content) === true) {
+ } else {
+ // Assumes that $content is not empty.
+ // Starts with a capital letter and ends with a fullstop.
+ $firstChar = $content[0];
+ if (strtoupper($firstChar) !== $firstChar) {
+ $error = '@throws tag comment must start with a capital letter';
+ $this->addMessage($error, $errorPos, self::THROWS_NOT_CAPITAL);
+ }
+ }
+ }
+
+ $since = array_keys($tagOrder, 'since');
+ if (count($since) === 1 && $this->_tagIndex !== 0) {
+ $this->_tagIndex++;
+ if ($index[$i] !== $this->_tagIndex) {
+ $error = 'The @throws tag is in the wrong order; the tag follows @return';
+ $this->addMessage($error, $errorPos, self::THROWS_ORDER);
+ }
+ }
+ }
+ }
+
+ //end processThrows()
+
+
+ /**
+ * Process the function parameter comments.
+ *
+ * @param int $commentStart The position in the stack where
+ * the comment started.
+ * @param int $commentEnd The position in the stack where
+ * the comment ended.
+ *
+ * @return void
+ */
+ protected function processParams($commentStart, $commentEnd)
+ {
+ $realParams = $this->currentFile->getMethodParameters($this->_functionToken);
+ $params = $this->commentParser->getParams();
+ $foundParams = array();
+
+ if (empty($params) === false) {
+
+ if (substr_count($params[count($params) - 1]->getWhitespaceAfter(), $this->currentFile->eolChar) !== 2) {
+ $error = 'Last parameter comment requires a blank newline after it';
+ $errorPos = $params[count($params) - 1]->getLine() + $commentStart;
+ $this->addMessage($error, $errorPos, self::SPACING_AFTER_PARAMS);
+ }
+
+ // Parameters must appear immediately after the comment.
+ if ($params[0]->getOrder() !== 2) {
+ $error = 'Parameters must appear immediately after the comment';
+ $errorPos = $params[0]->getLine() + $commentStart;
+ $this->addMessage($error, $errorPos, self::SPACING_BEFORE_PARAMS);
+ }
+
+ $previousParam = null;
+ $spaceBeforeVar = 10000;
+ $spaceBeforeComment = 10000;
+ $longestType = 0;
+ $longestVar = 0;
+
+ foreach ($params as $param) {
+
+ $paramComment = trim($param->getComment());
+ $errorPos = $param->getLine() + $commentStart;
+
+ // Make sure that there is only one space before the var type.
+ if ($param->getWhitespaceBeforeType() !== ' ') {
+ $error = 'Expected 1 space before variable type';
+ $this->addMessage($error, $errorPos, self::SPACING_BEFORE_PARAM_TYPE);
+ }
+
+ $spaceCount = substr_count($param->getWhitespaceBeforeVarName(), ' ');
+ if ($spaceCount < $spaceBeforeVar) {
+ $spaceBeforeVar = $spaceCount;
+ $longestType = $errorPos;
+ }
+
+ $spaceCount = substr_count($param->getWhitespaceBeforeComment(), ' ');
+
+ if ($spaceCount < $spaceBeforeComment && $paramComment !== '') {
+ $spaceBeforeComment = $spaceCount;
+ $longestVar = $errorPos;
+ }
+
+ // Make sure they are in the correct order, and have the correct name.
+ $pos = $param->getPosition();
+ $paramName = $param->getVarName() !== '' ? $param->getVarName() : '[ UNKNOWN ]';
+
+ if ($previousParam !== null) {
+ $previousName = $previousParam->getVarName() !== '' ? $previousParam->getVarName() : 'UNKNOWN';
+ }
+
+ // Variable must be one of the supported standard type.
+ $typeNames = explode('|', $param->getType());
+ foreach ($typeNames as $typeName) {
+ $suggestedName = $this->suggestType($typeName);
+ if ($typeName !== $suggestedName) {
+ $error = 'Expected "%s"; found "%s" for %s at position %s';
+ $data = array($suggestedName, $typeName, $paramName, $pos);
+ $this->addMessage($error, $errorPos, self::INCORRECT_PARAM_VAR_NAME, $data);
+ } elseif ($typeName === 'array' || $typeName === 'mixed') {
+ // Warn about ambiguous types ie array or mixed
+ $error = 'Ambiguous type "%s" for %s at position %s is NOT recommended';
+ $data = array($typeName, $paramName, $pos);
+ $this->addMessage($error, $commentEnd + 2, self::AMBIGUOUS_TYPE, $data);
+ } elseif (count($typeNames) === 1) {
+ // Check type hint for array and custom type.
+ $suggestedTypeHint = '';
+ if (strpos($suggestedName, 'array') !== false) {
+ $suggestedTypeHint = 'array';
+ } else {
+ if (strpos($suggestedName, 'callable') !== false) {
+ $suggestedTypeHint = 'callable';
+ } else {
+ if (in_array($typeName, self::$allowedTypes) === false) {
+ $suggestedTypeHint = $suggestedName;
+ } else {
+ $suggestedTypeHint = $this->suggestType($typeName);
+ }
+ }
+ }
+
+ if ($suggestedTypeHint !== '' && isset($realParams[$pos - 1]) === true) {
+ $typeHint = $realParams[$pos - 1]['type_hint'];
+ if ($typeHint === '') {
+ $error = 'Type hint "%s" missing for %s at position %s';
+ $data = array($suggestedTypeHint, $paramName, $pos);
+ $this->addMessage($error, $commentEnd + 2, self::TYPE_HINT_MISSING, $data);
+ } else {
+ if ($typeHint !== $suggestedTypeHint) {
+ $error = 'Expected type hint "%s"; found "%s" for %s at position %s';
+ $data = array($suggestedTypeHint, $typeHint, $paramName, $pos);
+ $this->addMessage($error, $commentEnd + 2, self::INCORRECT_TYPE_HINT, $data);
+ }
+ }
+ } else {
+ if ($suggestedTypeHint === '' && isset($realParams[$pos - 1]) === true) {
+ $typeHint = $realParams[$pos - 1]['type_hint'];
+ if ($typeHint !== '') {
+ $error = 'Unknown type hint "%s" found for %s at position %s';
+ $data = array($typeHint, $paramName, $pos);
+ $this->addMessage($error, $commentEnd + 2, self::INVALID_TYPE_HINT, $data);
+ }
+ }
+ }
+ }
+ }
+ //end foreach
+
+ // Make sure the names of the parameter comment matches the
+ // actual parameter.
+ if (isset($realParams[$pos - 1]) === true) {
+ $realName = $realParams[$pos - 1]['name'];
+ $foundParams[] = $realName;
+
+ // Append ampersand to name if passing by reference.
+ if ($realParams[$pos - 1]['pass_by_reference'] === true) {
+ $realName = '&' . $realName;
+ }
+
+ if ($realName !== $paramName) {
+ $code = self::PARAM_NAME_NO_MATCH;
+ $data = array($paramName, $realName, $pos);
+
+ $error = 'Doc comment for var %s does not match ';
+ if (strtolower($paramName) === strtolower($realName)) {
+ $error .= 'case of ';
+ $code = self::PARAM_NAME_NO_CASE_MATCH;
+ }
+
+ $error .= 'actual variable name %s at position %s';
+
+ $this->addMessage($error, $errorPos, $code, $data);
+ }
+ } else {
+ if (substr($paramName, -4) !== ',...') {
+ // We must have an extra parameter comment.
+ $error = 'Superfluous doc comment at position ' . $pos;
+ $this->addMessage($error, $errorPos, self::EXTRA_PARAM_COMMENT);
+ }
+ }
+
+ if ($param->getVarName() === '') {
+ $error = 'Missing parameter name at position ' . $pos;
+ $this->addMessage($error, $errorPos, self::MISSING_PARAM_NAME);
+ }
+
+ if ($param->getType() === '') {
+ $error = 'Missing type at position ' . $pos;
+ $this->addMessage($error, $errorPos, self::MISSING_PARAM_TYPE);
+ }
+
+ /* no param comments required.
+ if ($paramComment === '') {
+ $error = 'Missing comment for param "%s" at position %s';
+ $data = array(
+ $paramName,
+ $pos,
+ );
+ $this->currentFile->addError($error, $errorPos, 'MissingParamComment', $data);
+ } else {
+ // Param comments must start with a capital letter and
+ // end with the full stop.
+ $firstChar = $paramComment{0};
+ if (preg_match('|\p{Lu}|u', $firstChar) === 0) {
+ $error = 'Param comment must start with a capital letter';
+ $this->currentFile->addError($error, $errorPos, 'ParamCommentNotCapital');
+ }
+ $lastChar = $paramComment[(strlen($paramComment) - 1)];
+ if ($lastChar !== '.') {
+ $error = 'Param comment must end with a full stop';
+ $this->currentFile->addError($error, $errorPos, 'ParamCommentFullStop');
+ }
+ }
+ */
+
+ $previousParam = $param;
+ }
+ //end foreach
+
+ if ($spaceBeforeVar !== 1 && $spaceBeforeVar !== 10000 && $spaceBeforeComment !== 10000) {
+ $error = 'Expected 1 space after the longest type';
+ $this->addMessage($error, $longestType, self::SPACING_AFTER_LONG_TYPE);
+ }
+
+ if ($spaceBeforeComment !== 1 && $spaceBeforeComment !== 10000) {
+ $error = 'Expected 1 space after the longest variable name';
+ $this->addMessage($error, $longestVar, self::SPACING_AFTER_LONG_NAME);
+ }
+ }
+ //end if
+
+ $realNames = array();
+ foreach ($realParams as $realParam) {
+ $realNames[] = $realParam['name'];
+ }
+
+ // Report missing comments.
+ $diff = array_diff($realNames, $foundParams);
+ foreach ($diff as $neededParam) {
+ if (count($params) !== 0) {
+ $errorPos = $params[count($params) - 1]->getLine() + $commentStart;
+ } else {
+ $errorPos = $commentStart;
+ }
+
+ $error = 'Doc comment for "%s" missing';
+ $data = array($neededParam);
+ $this->addMessage($error, $errorPos, self::MISSING_PARAM_TAG, $data);
+ }
+ }
+
+ //end processParams()
+ /**
+ * This method will add the message as an error or warning depending on the configuration
+ *
+ * @param string $error The error message.
+ * @param int $stackPtr The stack position where the error occurred.
+ * @param string $code A violation code unique to the sniff message.
+ * @param array $data Replacements for the error message.
+ * @param int $severity The severity level for this error. A value of 0
+ */
+ protected function addMessage($message, $stackPtr, $code, $data = array(), $severity = 0)
+ {
+ //
+ // Does the $code key exist in the report level
+ if (array_key_exists($code, self::$reportingLevel)) {
+ $level = self::$reportingLevel[$code];
+ if ($level === self::WARNING || $level === self::INFO) {
+ $s = $level;
+ if ($severity !== 0) {
+ $s = $severity;
+ }
+ $this->currentFile->addWarning($message, $stackPtr, $code, $data, $s);
+ } else {
+ $this->currentFile->addError($message, $stackPtr, $code, $data, $severity);
+ }
+ }
+ }
+
+ /**
+ * Determine if text is a class name
+ *
+ * @param string $class
+ * @return bool
+ */
+ protected function isClassName($class)
+ {
+ $return = false;
+ if (preg_match('/^\\\\?[A-Z]\\w+(?:\\\\\\w+)*?$/', $class)) {
+ $return = true;
+ }
+ }
+
+ /**
+ * Take the type and suggest the correct one.
+ *
+ * @param string $type
+ * @return string
+ */
+ protected function suggestType($type)
+ {
+ $suggestedName = null;
+ // First check to see if this type is a list of types. If so we break it up and check each
+ if (preg_match('/^.*?(?:\|.*)+$/', $type)) {
+ // Return list of all types in this string.
+ $types = explode('|', $type);
+ if (is_array($types)) {
+ // Loop over all types and call this method on each.
+ $suggestions = array();
+ foreach ($types as $t) {
+ $suggestions[] = $this->suggestType($t);
+ }
+ // Now that we have suggestions put them back together.
+ $suggestedName = implode('|', $suggestions);
+ } else {
+ $suggestedName = 'Unknown';
+ }
+ } elseif ($this->isClassName($type)) {
+ // If this looks like a class name.
+ $suggestedName = $type;
+ } else {
+ // Only one type First check if that type is a base one.
+ $lowerVarType = strtolower($type);
+ switch ($lowerVarType) {
+ case 'boolean':
+ $suggestedName = 'bool';
+ break;
+ case 'integer':
+ $suggestedName = 'int';
+ break;
+ }
+ //end switch
+ // If no name suggested yet then call the phpcs version of this method.
+ if (empty($suggestedName)) {
+ $suggestedName = PHP_CodeSniffer::suggestType($type);
+ }
+ }
+ return $suggestedName;
+ }
+}
diff --git a/app/code/Magento/PaypalUk/view/frontend/layout/catalogsearch_advanced_result.xml b/dev/tests/static/testsuite/Magento/Test/Php/_files/phpcs/Magento/ruleset.xml
similarity index 89%
rename from app/code/Magento/PaypalUk/view/frontend/layout/catalogsearch_advanced_result.xml
rename to dev/tests/static/testsuite/Magento/Test/Php/_files/phpcs/Magento/ruleset.xml
index 40668f6fc4bdb..2bd399650eb07 100644
--- a/app/code/Magento/PaypalUk/view/frontend/layout/catalogsearch_advanced_result.xml
+++ b/dev/tests/static/testsuite/Magento/Test/Php/_files/phpcs/Magento/ruleset.xml
@@ -23,6 +23,6 @@
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
*/
-->
-
-
-
+
+ A custom coding standard.
+
diff --git a/dev/tests/static/testsuite/Magento/Test/Php/_files/whitelist/common.txt b/dev/tests/static/testsuite/Magento/Test/Php/_files/whitelist/common.txt
index a6edf3e83f09e..4ebad2069b10d 100644
--- a/dev/tests/static/testsuite/Magento/Test/Php/_files/whitelist/common.txt
+++ b/dev/tests/static/testsuite/Magento/Test/Php/_files/whitelist/common.txt
@@ -51,7 +51,6 @@ app/code/Magento/Core/Model/AbstractShell.php
app/code/Magento/Core/Model/Theme
app/code/Magento/Core/Model/Theme.php
app/code/Magento/Core/Model/Url/SecurityInfo.php
-app/code/Magento/Core/Model/Url/SecurityInfoInterface.php
app/code/Magento/Core/sql/core_setup/upgrade-1.6.0.3-1.6.0.4.php
app/code/Magento/Cron/Model/Config/Converter
app/code/Magento/Cron/Model/Config/Reader
@@ -139,4 +138,5 @@ lib/Magento/Stdlib/DateTime.php
lib/Magento/Object.php
lib/Magento/App
lib/Magento/ObjectManager
+lib/Magento/Url/SecurityInfoInterface.php
lib/Magento/View
diff --git a/dev/tests/unit/framework/tests/unit/testsuite/Magento/TestFramework/Helper/ObjectManagerTest.php b/dev/tests/unit/framework/tests/unit/testsuite/Magento/TestFramework/Helper/ObjectManagerTest.php
index 238e43291ee09..f31f70507164f 100644
--- a/dev/tests/unit/framework/tests/unit/testsuite/Magento/TestFramework/Helper/ObjectManagerTest.php
+++ b/dev/tests/unit/framework/tests/unit/testsuite/Magento/TestFramework/Helper/ObjectManagerTest.php
@@ -92,7 +92,7 @@ public function testGetBlock()
public function testGetModel()
{
$objectManager = new \Magento\TestFramework\Helper\ObjectManager($this);
- /** @var $model \Magento\Core\Model\Config\Value */
+ /** @var $model \Magento\App\Config\ValueInterface */
$model = $objectManager->getObject('Magento\Core\Model\Config\Value');
$this->assertInstanceOf('Magento\Core\Model\Config\Value', $model);
foreach ($this->_modelDependencies as $propertyName => $propertyType) {
diff --git a/dev/tests/unit/testsuite/Magento/Acl/Loader/ResourceTest.php b/dev/tests/unit/testsuite/Magento/Acl/Loader/ResourceTest.php
index c4837175aec27..86402187103a9 100644
--- a/dev/tests/unit/testsuite/Magento/Acl/Loader/ResourceTest.php
+++ b/dev/tests/unit/testsuite/Magento/Acl/Loader/ResourceTest.php
@@ -41,7 +41,6 @@ public function testPopulateAclOnValidObjects()
$acl->expects($this->at(0))->method('addResource')->with($aclResource, null)->will($this->returnSelf());
$acl->expects($this->at(1))->method('addResource')->with($aclResource, $aclResource)->will($this->returnSelf());
- /** @var $factoryObject \Magento\Core\Model\Config */
$factoryObject = $this->getMock('Magento\Acl\ResourceFactory', array('createResource'), array(), '', false);
$factoryObject->expects($this->any())->method('createResource')->will($this->returnValue($aclResource));
diff --git a/dev/tests/unit/testsuite/Magento/App/Config/FileResolver/PrimaryTest.php b/dev/tests/unit/testsuite/Magento/App/Arguments/FileResolver/PrimaryTest.php
similarity index 94%
rename from dev/tests/unit/testsuite/Magento/App/Config/FileResolver/PrimaryTest.php
rename to dev/tests/unit/testsuite/Magento/App/Arguments/FileResolver/PrimaryTest.php
index 6bc14536aefd5..cdda0a87155a1 100644
--- a/dev/tests/unit/testsuite/Magento/App/Config/FileResolver/PrimaryTest.php
+++ b/dev/tests/unit/testsuite/Magento/App/Arguments/FileResolver/PrimaryTest.php
@@ -21,7 +21,7 @@
* @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
-namespace Magento\App\Config\FileResolver;
+namespace Magento\App\Arguments\FileResolver;
class PrimaryTest extends \PHPUnit_Framework_TestCase
{
@@ -52,7 +52,7 @@ public function testGet(array $fileList, $scope, $filename)
->method('create')
->will($this->returnValue(true));
- $model = new \Magento\App\Config\FileResolver\Primary($filesystem, $iteratorFactory);
+ $model = new \Magento\App\Arguments\FileResolver\Primary($filesystem, $iteratorFactory);
$this->assertTrue($model->get($filename, $scope));
}
diff --git a/dev/tests/unit/testsuite/Magento/App/Config/FileResolver/_files/app/etc/config.xml b/dev/tests/unit/testsuite/Magento/App/Arguments/FileResolver/_files/app/etc/config.xml
similarity index 100%
rename from dev/tests/unit/testsuite/Magento/App/Config/FileResolver/_files/app/etc/config.xml
rename to dev/tests/unit/testsuite/Magento/App/Arguments/FileResolver/_files/app/etc/config.xml
diff --git a/dev/tests/unit/testsuite/Magento/App/Config/FileResolver/_files/app/etc/custom/config.xml b/dev/tests/unit/testsuite/Magento/App/Arguments/FileResolver/_files/app/etc/custom/config.xml
similarity index 100%
rename from dev/tests/unit/testsuite/Magento/App/Config/FileResolver/_files/app/etc/custom/config.xml
rename to dev/tests/unit/testsuite/Magento/App/Arguments/FileResolver/_files/app/etc/custom/config.xml
diff --git a/dev/tests/unit/testsuite/Magento/App/Config/FileResolver/_files/primary/app/etc/di.xml b/dev/tests/unit/testsuite/Magento/App/Arguments/FileResolver/_files/primary/app/etc/di.xml
similarity index 100%
rename from dev/tests/unit/testsuite/Magento/App/Config/FileResolver/_files/primary/app/etc/di.xml
rename to dev/tests/unit/testsuite/Magento/App/Arguments/FileResolver/_files/primary/app/etc/di.xml
diff --git a/dev/tests/unit/testsuite/Magento/App/Config/FileResolver/_files/primary/app/etc/some_config/di.xml b/dev/tests/unit/testsuite/Magento/App/Arguments/FileResolver/_files/primary/app/etc/some_config/di.xml
similarity index 100%
rename from dev/tests/unit/testsuite/Magento/App/Config/FileResolver/_files/primary/app/etc/some_config/di.xml
rename to dev/tests/unit/testsuite/Magento/App/Arguments/FileResolver/_files/primary/app/etc/some_config/di.xml
diff --git a/dev/tests/unit/testsuite/Magento/App/Config/LoaderTest.php b/dev/tests/unit/testsuite/Magento/App/Arguments/LoaderTest.php
similarity index 84%
rename from dev/tests/unit/testsuite/Magento/App/Config/LoaderTest.php
rename to dev/tests/unit/testsuite/Magento/App/Arguments/LoaderTest.php
index 19ca14435fe4d..403daed7dee42 100644
--- a/dev/tests/unit/testsuite/Magento/App/Config/LoaderTest.php
+++ b/dev/tests/unit/testsuite/Magento/App/Arguments/LoaderTest.php
@@ -23,7 +23,7 @@
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
-namespace Magento\App\Config;
+namespace Magento\App\Arguments;
class LoaderTest extends \PHPUnit_Framework_TestCase
{
@@ -46,11 +46,7 @@ public function testWithOneXmlFile()
{
$this->_dirs->expects($this->once())->method('getDir')->will($this->returnValue(__DIR__ . '/_files'));
$this->_model = new Loader($this->_dirs);
- $expected = array(
- 'resource' => 'resource name',
- 'connection' => 'connection name',
- 'other' => 'other value',
- );
+ $expected = require __DIR__ . '/_files/local.php';
$this->assertEquals($expected, $this->_model->load());
}
@@ -58,12 +54,7 @@ public function testWithTwoXmlFileMerging()
{
$this->_dirs->expects($this->once())->method('getDir')->will($this->returnValue(__DIR__ . '/_files'));
$this->_model = new Loader($this->_dirs, 'other/local_developer.xml');
- $expected = array(
- 'resource' => 'resource name2',
- 'connection' => 'connection name2',
- 'other' => 'new other value',
- 'new' => 'new value',
- );
+ $expected = require __DIR__ . '/_files/other/local_developer_merged.php';
$this->assertEquals($expected, $this->_model->load());
}
diff --git a/dev/tests/unit/testsuite/Magento/App/Arguments/_files/local.php b/dev/tests/unit/testsuite/Magento/App/Arguments/_files/local.php
new file mode 100644
index 0000000000000..51f56cf2b532d
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/App/Arguments/_files/local.php
@@ -0,0 +1,70 @@
+ array(
+ 'connection_one' => array(
+ 'name' => 'connection_one',
+ 'dbName' => 'db_one',
+ ),
+ 'connection_two' => array(
+ 'name' => 'connection_two',
+ 'dbName' => 'db_two',
+ ),
+ ),
+ 'resource' => array(
+ 'resource_one' => array(
+ 'name' => 'resource_one',
+ 'connection' => 'connection_one',
+ ),
+ 'resource_two' => array(
+ 'name' => 'resource_two',
+ 'connection' => 'connection_two',
+ ),
+ ),
+ 'cache' => array(
+ 'frontend' => array(
+ 'cache_frontend_one' => array(
+ 'name' => 'cache_frontend_one',
+ 'backend' => 'blackHole',
+ ),
+ 'cache_frontend_two' => array(
+ 'name' => 'cache_frontend_two',
+ 'backend' => 'file',
+ ),
+ ),
+ 'type' => array(
+ 'cache_type_one' => array(
+ 'name' => 'cache_type_one',
+ 'frontend' => 'cache_frontend_one',
+ ),
+ 'cache_type_two' => array(
+ 'name' => 'cache_type_two',
+ 'frontend' => 'cache_frontend_two',
+ ),
+ ),
+ ),
+ 'arbitrary_one' => 'Value One',
+ 'arbitrary_two' => 'Value Two',
+);
diff --git a/dev/tests/unit/testsuite/Magento/App/Config/_files/local.xml b/dev/tests/unit/testsuite/Magento/App/Arguments/_files/local.xml
similarity index 55%
rename from dev/tests/unit/testsuite/Magento/App/Config/_files/local.xml
rename to dev/tests/unit/testsuite/Magento/App/Arguments/_files/local.xml
index 8deb84e968824..d8c9e0ef4c36d 100644
--- a/dev/tests/unit/testsuite/Magento/App/Config/_files/local.xml
+++ b/dev/tests/unit/testsuite/Magento/App/Arguments/_files/local.xml
@@ -24,7 +24,24 @@
*/
-->
- resource name
- connection name
- other value
+
+ db_one
+
+
+ db_two
+
+
+
+
+
+ blackHole
+
+
+ file
+
+
+
+
+ Value One
+ Value Two
diff --git a/dev/tests/unit/testsuite/Magento/App/Arguments/_files/other/local_developer.php b/dev/tests/unit/testsuite/Magento/App/Arguments/_files/other/local_developer.php
new file mode 100644
index 0000000000000..ba13dbaa04910
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/App/Arguments/_files/other/local_developer.php
@@ -0,0 +1,70 @@
+ array(
+ 'connection_one' => array(
+ 'name' => 'connection_one',
+ 'dbName' => 'overridden_db_one',
+ ),
+ 'connection_new' => array(
+ 'name' => 'connection_new',
+ 'dbName' => 'db_new',
+ ),
+ ),
+ 'resource' => array(
+ 'resource_one' => array(
+ 'name' => 'resource_one',
+ 'connection' => 'connection_new',
+ ),
+ 'resource_new' => array(
+ 'name' => 'resource_new',
+ 'connection' => 'connection_two',
+ ),
+ ),
+ 'cache' => array(
+ 'frontend' => array(
+ 'cache_frontend_one' => array(
+ 'name' => 'cache_frontend_one',
+ 'backend' => 'memcached',
+ ),
+ 'cache_frontend_new' => array(
+ 'name' => 'cache_frontend_new',
+ 'backend' => 'apc',
+ ),
+ ),
+ 'type' => array(
+ 'cache_type_one' => array(
+ 'name' => 'cache_type_one',
+ 'frontend' => 'cache_frontend_new',
+ ),
+ 'cache_type_new' => array(
+ 'name' => 'cache_type_new',
+ 'frontend' => 'cache_frontend_two',
+ ),
+ ),
+ ),
+ 'arbitrary_one' => 'Overridden Value One',
+ 'arbitrary_new' => 'Value New',
+);
diff --git a/dev/tests/unit/testsuite/Magento/App/Config/_files/other/local_developer.xml b/dev/tests/unit/testsuite/Magento/App/Arguments/_files/other/local_developer.xml
similarity index 55%
rename from dev/tests/unit/testsuite/Magento/App/Config/_files/other/local_developer.xml
rename to dev/tests/unit/testsuite/Magento/App/Arguments/_files/other/local_developer.xml
index 0988420175272..53dc25e4d5bb0 100644
--- a/dev/tests/unit/testsuite/Magento/App/Config/_files/other/local_developer.xml
+++ b/dev/tests/unit/testsuite/Magento/App/Arguments/_files/other/local_developer.xml
@@ -24,8 +24,24 @@
*/
-->
- resource name2
- connection name2
- new other value
- new value
+
+ overridden_db_one
+
+
+ db_new
+
+
+
+
+
+ memcached
+
+
+ apc
+
+
+
+
+ Overridden Value One
+ Value New
diff --git a/dev/tests/unit/testsuite/Magento/App/Arguments/_files/other/local_developer_merged.php b/dev/tests/unit/testsuite/Magento/App/Arguments/_files/other/local_developer_merged.php
new file mode 100644
index 0000000000000..d88e6973f40c1
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/App/Arguments/_files/other/local_developer_merged.php
@@ -0,0 +1,87 @@
+ array(
+ 'connection_one' => array(
+ 'name' => 'connection_one',
+ 'dbName' => 'overridden_db_one',
+ ),
+ 'connection_two' => array(
+ 'name' => 'connection_two',
+ 'dbName' => 'db_two',
+ ),
+ 'connection_new' => array(
+ 'name' => 'connection_new',
+ 'dbName' => 'db_new',
+ ),
+ ),
+ 'resource' => array(
+ 'resource_one' => array(
+ 'name' => 'resource_one',
+ 'connection' => 'connection_new',
+ ),
+ 'resource_two' => array(
+ 'name' => 'resource_two',
+ 'connection' => 'connection_two',
+ ),
+ 'resource_new' => array(
+ 'name' => 'resource_new',
+ 'connection' => 'connection_two',
+ ),
+ ),
+ 'cache' => array(
+ 'frontend' => array(
+ 'cache_frontend_one' => array(
+ 'name' => 'cache_frontend_one',
+ 'backend' => 'memcached',
+ ),
+ 'cache_frontend_two' => array(
+ 'name' => 'cache_frontend_two',
+ 'backend' => 'file',
+ ),
+ 'cache_frontend_new' => array(
+ 'name' => 'cache_frontend_new',
+ 'backend' => 'apc',
+ ),
+ ),
+ 'type' => array(
+ 'cache_type_one' => array(
+ 'name' => 'cache_type_one',
+ 'frontend' => 'cache_frontend_new',
+ ),
+ 'cache_type_two' => array(
+ 'name' => 'cache_type_two',
+ 'frontend' => 'cache_frontend_two',
+ ),
+ 'cache_type_new' => array(
+ 'name' => 'cache_type_new',
+ 'frontend' => 'cache_frontend_two',
+ ),
+ ),
+ ),
+ 'arbitrary_one' => 'Overridden Value One',
+ 'arbitrary_two' => 'Value Two',
+ 'arbitrary_new' => 'Value New',
+);
diff --git a/dev/tests/unit/testsuite/Magento/App/ArgumentsTest.php b/dev/tests/unit/testsuite/Magento/App/ArgumentsTest.php
new file mode 100644
index 0000000000000..0c3588ed02f31
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/App/ArgumentsTest.php
@@ -0,0 +1,141 @@
+getMock('Magento\App\Arguments\Loader', array(), array(), '', false);
+ $loader->expects($this->atLeastOnce())->method('load')->will($this->returnValue(self::$fixtureConfig));
+
+ $this->_arguments = new \Magento\App\Arguments(array(), $loader);
+ $this->_argumentsMerged = new \Magento\App\Arguments(
+ require __DIR__ . '/Arguments/_files/other/local_developer.php',
+ $loader
+ );
+ }
+
+ /**
+ * @param string $connectionName
+ * @param bool $testMerged
+ * @param array|null $expectedResult
+ * @dataProvider getConnectionDataProvider
+ */
+ public function testGetConnection($connectionName, $testMerged, $expectedResult)
+ {
+ $arguments = $testMerged ? $this->_argumentsMerged : $this->_arguments;
+ $this->assertEquals($expectedResult, $arguments->getConnection($connectionName));
+ }
+
+ public function getConnectionDataProvider()
+ {
+ return array(
+ 'existing connection' => array(
+ 'connection_one', false, array('name' => 'connection_one', 'dbName' => 'db_one')
+ ),
+ 'unknown connection' => array(
+ 'connection_new', false, null
+ ),
+ 'existing connection, added' => array(
+ 'connection_new', true, array('name' => 'connection_new', 'dbName' => 'db_new')
+ ),
+ 'existing connection, overridden' => array(
+ 'connection_one', true, array('name' => 'connection_one', 'dbName' => 'overridden_db_one')
+ ),
+ );
+ }
+
+ public function testGetConnections()
+ {
+ $this->assertEquals(self::$fixtureConfig['connection'], $this->_arguments->getConnections());
+ $this->assertEquals(self::$fixtureConfigMerged['connection'], $this->_argumentsMerged->getConnections());
+ }
+
+ public function testGetResources()
+ {
+ $this->assertEquals(self::$fixtureConfig['resource'], $this->_arguments->getResources());
+ $this->assertEquals(self::$fixtureConfigMerged['resource'], $this->_argumentsMerged->getResources());
+ }
+
+ public function testGetCacheFrontendSettings()
+ {
+ $this->assertEquals(
+ self::$fixtureConfig['cache']['frontend'],
+ $this->_arguments->getCacheFrontendSettings()
+ );
+ $this->assertEquals(
+ self::$fixtureConfigMerged['cache']['frontend'],
+ $this->_argumentsMerged->getCacheFrontendSettings()
+ );
+ }
+
+ /**
+ * @param string $cacheType
+ * @param bool $testMerged
+ * @param string|null $expectedResult
+ * @dataProvider getCacheTypeFrontendIdDataProvider
+ */
+ public function testGetCacheTypeFrontendId($cacheType, $testMerged, $expectedResult)
+ {
+ $arguments = $testMerged ? $this->_argumentsMerged : $this->_arguments;
+ $this->assertEquals($expectedResult, $arguments->getCacheTypeFrontendId($cacheType));
+ }
+
+ public function getCacheTypeFrontendIdDataProvider()
+ {
+ return array(
+ 'existing cache type' => array('cache_type_one', false, 'cache_frontend_one'),
+ 'unknown cache type' => array('cache_type_new', false, null),
+ 'existing cache type, added' => array('cache_type_new', true, 'cache_frontend_two'),
+ 'existing cache type, overridden' => array('cache_type_one', true, 'cache_frontend_new'),
+ );
+ }
+}
diff --git a/dev/tests/unit/testsuite/Magento/App/Cache/Frontend/PoolTest.php b/dev/tests/unit/testsuite/Magento/App/Cache/Frontend/PoolTest.php
index e3f97b3b1e3ca..3d6a700120c11 100644
--- a/dev/tests/unit/testsuite/Magento/App/Cache/Frontend/PoolTest.php
+++ b/dev/tests/unit/testsuite/Magento/App/Cache/Frontend/PoolTest.php
@@ -32,45 +32,40 @@ class PoolTest extends \PHPUnit_Framework_TestCase
/**
* Array of frontend cache instances stubs, used to verify, what is stored inside the pool
+ *
+ * @var \PHPUnit_Framework_MockObject_MockObject[]
*/
protected $_frontendInstances = array();
protected function setUp()
{
- // Init frontend factory
- $frontendFactory = $this->getMock('Magento\App\Cache\Frontend\Factory', array(), array(), '', false);
-
$this->_frontendInstances = array(
- \Magento\App\Cache\Frontend\Pool::DEFAULT_FRONTEND_ID
- => $this->getMock('Magento\Cache\FrontendInterface'),
+ Pool::DEFAULT_FRONTEND_ID => $this->getMock('Magento\Cache\FrontendInterface'),
'resource1' => $this->getMock('Magento\Cache\FrontendInterface'),
'resource2' => $this->getMock('Magento\Cache\FrontendInterface'),
);
- $frontendFactory->expects($this->any())
- ->method('create')
- ->will(
- $this->returnValueMap(array(
- array(
- array('data1' => 'value1', 'data2' => 'value2'),
- $this->_frontendInstances[\Magento\App\Cache\Frontend\Pool::DEFAULT_FRONTEND_ID]
- ),
- array(array('r1d1' => 'value1', 'r1d2' => 'value2'), $this->_frontendInstances['resource1']),
- array(array('r2d1' => 'value1', 'r2d2' => 'value2'), $this->_frontendInstances['resource2']),
- ))
- );
-
- $advancedOptions = array(
- 'resource1' => array('r1d1' => 'value1', 'r1d2' => 'value2'),
- 'resource2' => array('r2d1' => 'value1', 'r2d2' => 'value2'),
+
+ $frontendFactoryMap = array(
+ array(
+ array('data1' => 'value1', 'data2' => 'value2'), $this->_frontendInstances[Pool::DEFAULT_FRONTEND_ID]
+ ),
+ array(array('r1d1' => 'value1', 'r1d2' => 'value2'), $this->_frontendInstances['resource1']),
+ array(array('r2d1' => 'value1', 'r2d2' => 'value2'), $this->_frontendInstances['resource2']),
);
+ $frontendFactory = $this->getMock('Magento\App\Cache\Frontend\Factory', array(), array(), '', false);
+ $frontendFactory->expects($this->any())->method('create')->will($this->returnValueMap($frontendFactoryMap));
+
+ $arguments = $this->getMock('Magento\App\Arguments', array(), array(), '', false);
+ $arguments->expects($this->any())->method('getCacheFrontendSettings')->will($this->returnValue(array(
+ 'resource2' => array('r2d1' => 'value1', 'r2d2' => 'value2'),
+ )));
- $defaultOptions = array(
- 'data1' => 'value1',
- 'data2' => 'value2',
+ $frontendSettings = array(
+ Pool::DEFAULT_FRONTEND_ID => array('data1' => 'value1', 'data2' => 'value2'),
+ 'resource1' => array('r1d1' => 'value1', 'r1d2' => 'value2'),
);
- // Create model
- $this->_model = new \Magento\App\Cache\Frontend\Pool(
- $frontendFactory, $defaultOptions, $advancedOptions);
+
+ $this->_model = new \Magento\App\Cache\Frontend\Pool($arguments, $frontendFactory, $frontendSettings);
}
/**
@@ -78,56 +73,83 @@ protected function setUp()
*/
public function testConstructorNoInitialization()
{
+ $arguments = $this->getMock('Magento\App\Arguments', array(), array(), '', false);
$frontendFactory = $this->getMock('Magento\App\Cache\Frontend\Factory', array(), array(), '', false);
$frontendFactory
->expects($this->never())
->method('create')
;
- new \Magento\App\Cache\Frontend\Pool($frontendFactory);
+ new \Magento\App\Cache\Frontend\Pool($arguments, $frontendFactory);
}
- public function testCurrent()
+ /**
+ * @param array $fixtureCacheConfig
+ * @param array $frontendSettings
+ * @param array $expectedFactoryArg
+ *
+ * @dataProvider initializationParamsDataProvider
+ */
+ public function testInitializationParams(
+ array $fixtureCacheConfig, array $frontendSettings, array $expectedFactoryArg
+ ) {
+ $arguments = $this->getMock('Magento\App\Arguments', array(), array(), '', false);
+ $arguments
+ ->expects($this->once())->method('getCacheFrontendSettings')->will($this->returnValue($fixtureCacheConfig));
+
+ $frontendFactory = $this->getMock('Magento\App\Cache\Frontend\Factory', array(), array(), '', false);
+ $frontendFactory->expects($this->at(0))->method('create')->with($expectedFactoryArg);
+
+ $model = new \Magento\App\Cache\Frontend\Pool($arguments, $frontendFactory, $frontendSettings);
+ $model->current();
+ }
+
+ public function initializationParamsDataProvider()
{
- $this->assertEquals(
- $this->_frontendInstances[\Magento\App\Cache\Frontend\Pool::DEFAULT_FRONTEND_ID],
- $this->_model->current()
+ return array(
+ 'default frontend, default settings' => array(
+ array(),
+ array(Pool::DEFAULT_FRONTEND_ID => array('default_option' => 'default_value')),
+ array('default_option' => 'default_value'),
+ ),
+ 'default frontend, overridden settings' => array(
+ array(Pool::DEFAULT_FRONTEND_ID => array('configured_option' => 'configured_value')),
+ array(Pool::DEFAULT_FRONTEND_ID => array('ignored_option' => 'ignored_value')),
+ array('configured_option' => 'configured_value'),
+ ),
+ 'custom frontend, default settings' => array(
+ array(),
+ array('custom' => array('default_option' => 'default_value')),
+ array('default_option' => 'default_value'),
+ ),
+ 'custom frontend, overridden settings' => array(
+ array('custom' => array('configured_option' => 'configured_value')),
+ array('custom' => array('ignored_option' => 'ignored_value')),
+ array('configured_option' => 'configured_value'),
+ ),
);
}
+ public function testCurrent()
+ {
+ $this->assertSame($this->_frontendInstances[Pool::DEFAULT_FRONTEND_ID], $this->_model->current());
+ }
+
public function testKey()
{
- $this->assertEquals(
- \Magento\App\Cache\Frontend\Pool::DEFAULT_FRONTEND_ID,
- $this->_model->key()
- );
+ $this->assertEquals(Pool::DEFAULT_FRONTEND_ID, $this->_model->key());
}
public function testNext()
{
- $this->assertEquals(
- \Magento\App\Cache\Frontend\Pool::DEFAULT_FRONTEND_ID,
- $this->_model->key()
- );
+ $this->assertEquals(Pool::DEFAULT_FRONTEND_ID, $this->_model->key());
$this->_model->next();
- $this->assertEquals(
- 'resource1',
- $this->_model->key()
- );
- $this->assertSame(
- $this->_frontendInstances['resource1'],
- $this->_model->current()
- );
+ $this->assertEquals('resource1', $this->_model->key());
+ $this->assertSame($this->_frontendInstances['resource1'], $this->_model->current());
$this->_model->next();
- $this->assertEquals(
- 'resource2',
- $this->_model->key()
- );
- $this->assertSame(
- $this->_frontendInstances['resource2'],
- $this->_model->current()
- );
+ $this->assertEquals('resource2', $this->_model->key());
+ $this->assertSame($this->_frontendInstances['resource2'], $this->_model->current());
$this->_model->next();
$this->assertNull($this->_model->key());
@@ -137,16 +159,10 @@ public function testNext()
public function testRewind()
{
$this->_model->next();
- $this->assertNotEquals(
- \Magento\App\Cache\Frontend\Pool::DEFAULT_FRONTEND_ID,
- $this->_model->key()
- );
+ $this->assertNotEquals(Pool::DEFAULT_FRONTEND_ID, $this->_model->key());
$this->_model->rewind();
- $this->assertEquals(
- \Magento\App\Cache\Frontend\Pool::DEFAULT_FRONTEND_ID,
- $this->_model->key()
- );
+ $this->assertEquals(Pool::DEFAULT_FRONTEND_ID, $this->_model->key());
}
public function testValid()
@@ -166,10 +182,17 @@ public function testValid()
public function testGet()
{
- $this->assertSame($this->_frontendInstances[\Magento\App\Cache\Frontend\Pool::DEFAULT_FRONTEND_ID],
- $this->_model->get(\Magento\App\Cache\Frontend\Pool::DEFAULT_FRONTEND_ID));
- $this->assertSame($this->_frontendInstances['resource1'], $this->_model->get('resource1'));
- $this->assertSame($this->_frontendInstances['resource2'], $this->_model->get('resource2'));
+ foreach ($this->_frontendInstances as $frontendId => $frontendInstance) {
+ $this->assertSame($frontendInstance, $this->_model->get($frontendId));
+ }
}
+ /**
+ * @expectedException \InvalidArgumentException
+ * @expectedExceptionMessage Cache frontend 'unknown' is not recognized
+ */
+ public function testGetUnknownFrontendId()
+ {
+ $this->_model->get('unknown');
+ }
}
diff --git a/dev/tests/unit/testsuite/Magento/App/Cache/Type/FrontendPoolTest.php b/dev/tests/unit/testsuite/Magento/App/Cache/Type/FrontendPoolTest.php
index e1f7a14337bf0..d92012ecba75a 100644
--- a/dev/tests/unit/testsuite/Magento/App/Cache/Type/FrontendPoolTest.php
+++ b/dev/tests/unit/testsuite/Magento/App/Cache/Type/FrontendPoolTest.php
@@ -31,91 +31,77 @@ class FrontendPoolTest extends \PHPUnit_Framework_TestCase
protected $_model;
/**
- * @var \Magento\ObjectManager|PHPUnit_Framework_MockObject_MockObject
+ * @var \Magento\ObjectManager|\PHPUnit_Framework_MockObject_MockObject
*/
protected $_objectManager;
/**
- * @var \Magento\App\Cache\Frontend\Pool|PHPUnit_Framework_MockObject_MockObject
+ * @var \Magento\App\Arguments|\PHPUnit_Framework_MockObject_MockObject
+ */
+ protected $_arguments;
+
+ /**
+ * @var \Magento\App\Cache\Frontend\Pool|\PHPUnit_Framework_MockObject_MockObject
*/
protected $_cachePool;
protected function setUp()
{
$this->_objectManager = $this->getMock('Magento\ObjectManager', array(), array(), '', false);
+ $this->_arguments = $this->getMock('Magento\App\Arguments', array(), array(), '', false);
$this->_cachePool = $this->getMock('Magento\App\Cache\Frontend\Pool', array(), array(), '', false);
- $this->_model = new \Magento\App\Cache\Type\FrontendPool($this->_objectManager, $this->_cachePool);
+ $this->_model = new FrontendPool($this->_objectManager, $this->_arguments, $this->_cachePool, array(
+ 'fixture_cache_type' => 'fixture_frontend_id',
+ ));
}
- public function testGet()
+ /**
+ * @param string|null $fixtureFrontendId
+ * @param string $inputCacheType
+ * @param string $expectedFrontendId
+ *
+ * @dataProvider getDataProvider
+ */
+ public function testGet($fixtureFrontendId, $inputCacheType, $expectedFrontendId)
{
- $instanceMock = $this->getMock('Magento\Cache\FrontendInterface');
+ $this->_arguments
+ ->expects($this->once())
+ ->method('getCacheTypeFrontendId')
+ ->with($inputCacheType)
+ ->will($this->returnValue($fixtureFrontendId));
+
+ $cacheFrontend = $this->getMock('Magento\Cache\FrontendInterface');
$this->_cachePool->expects($this->once())
->method('get')
- ->with('cache_type')
- ->will($this->returnValue($instanceMock));
+ ->with($expectedFrontendId)
+ ->will($this->returnValue($cacheFrontend));
- $accessMock = $this->getMock('Magento\App\Cache\Type\AccessProxy', array(), array(), '', false);
+ $accessProxy = $this->getMock('Magento\App\Cache\Type\AccessProxy', array(), array(), '', false);
$this->_objectManager->expects($this->once())
->method('create')
- ->with('Magento\App\Cache\Type\AccessProxy',
- array('frontend' => $instanceMock, 'identifier' => 'cache_type'))
- ->will($this->returnValue($accessMock));
-
- $instance = $this->_model->get('cache_type');
- $this->assertSame($accessMock, $instance);
+ ->with(
+ 'Magento\App\Cache\Type\AccessProxy',
+ $this->identicalTo(array('frontend' => $cacheFrontend, 'identifier' => $inputCacheType))
+ )
+ ->will($this->returnValue($accessProxy));
- // And must be cached
- $instance = $this->_model->get('cache_type');
- $this->assertSame($accessMock, $instance);
+ $this->assertSame($accessProxy, $this->_model->get($inputCacheType));
+ // Result has to be cached in memory
+ $this->assertSame($accessProxy, $this->_model->get($inputCacheType));
}
- public function testGetFallbackToDefaultId()
+ public function getDataProvider()
{
- /**
- * Setup cache pool to have knowledge only about default cache instance. Also check appropriate sequence
- * of calls.
- */
- $defaultInstance = $this->getMock('Magento\Cache\FrontendInterface');
- $this->_cachePool->expects($this->at(0))
- ->method('get')
- ->with('cache_type')
- ->will($this->returnValue(null));
- $this->_cachePool->expects($this->at(1))
- ->method('get')
- ->with(\Magento\App\Cache\Frontend\Pool::DEFAULT_FRONTEND_ID)
- ->will($this->returnValue($defaultInstance));
-
- $this->_cachePool->expects($this->at(2))
- ->method('get')
- ->with('another_cache_type')
- ->will($this->returnValue(null));
- $this->_cachePool->expects($this->at(3))
- ->method('get')
- ->with(\Magento\App\Cache\Frontend\Pool::DEFAULT_FRONTEND_ID)
- ->will($this->returnValue($defaultInstance));
-
- /**
- * Setup object manager to create new access proxies. We expect two calls.
- */
- $this->_objectManager->expects($this->at(0))
- ->method('create')
- ->with('Magento\App\Cache\Type\AccessProxy',
- array('frontend' => $defaultInstance, 'identifier' => 'cache_type'))
- ->will($this->returnValue(
- $this->getMock('Magento\App\Cache\Type\AccessProxy', array(), array(), '', false)
- ));
- $this->_objectManager->expects($this->at(1))
- ->method('create')
- ->with('Magento\App\Cache\Type\AccessProxy',
- array('frontend' => $defaultInstance, 'identifier' => 'another_cache_type'))
- ->will($this->returnValue(
- $this->getMock('Magento\App\Cache\Type\AccessProxy', array(), array(), '', false)
- ));
-
- $cacheInstance = $this->_model->get('cache_type');
- $anotherInstance = $this->_model->get('another_cache_type');
- $this->assertNotSame($cacheInstance, $anotherInstance,
- 'Different cache instances must be returned for different identifiers');
+ return array(
+ 'retrieval from config' => array(
+ 'configured_frontend_id', 'fixture_cache_type', 'configured_frontend_id',
+ ),
+ 'retrieval from map' => array(
+ null, 'fixture_cache_type', 'fixture_frontend_id',
+ ),
+ 'fallback to default id' => array(
+ null, 'unknown_cache_type', \Magento\App\Cache\Frontend\Pool::DEFAULT_FRONTEND_ID,
+ ),
+ );
}
}
diff --git a/dev/tests/unit/testsuite/Magento/App/ConfigTest.php b/dev/tests/unit/testsuite/Magento/App/ConfigTest.php
deleted file mode 100644
index 3dab8547ccf2a..0000000000000
--- a/dev/tests/unit/testsuite/Magento/App/ConfigTest.php
+++ /dev/null
@@ -1,79 +0,0 @@
-_loaderMock = $this->getMock('Magento\App\Config\Loader', array(), array(), '', false);
- $params = array(
- 'connection' => array('default' => array('connection_name')),
- 'resource' => array('name' => array('default_setup'))
- );
- $this->_loaderMock->expects($this->any())->method('load')->will($this->returnValue($params));
- $this->_config = new \Magento\App\Config(
- array(),
- $this->_loaderMock
- );
- }
-
- /**
- * @param string $connectionName
- * @param array|null $connectionDetail
- * @dataProvider getConnectionDataProvider
- */
- public function testGetConnection($connectionDetail, $connectionName)
- {
- $this->assertEquals($connectionDetail, $this->_config->getConnection($connectionName));
- }
-
- public function getConnectionDataProvider()
- {
- return array(
- 'connection_name_exist' => array(array('connection_name'), 'default'),
- 'connection_name_not_exist' => array(null, 'new_default')
- );
- }
-
- public function testGetConnections()
- {
- $this->assertEquals(array('default' => array('connection_name')), $this->_config->getConnections());
- }
-
- public function testGetResources()
- {
- $this->assertEquals(array('name' => array('default_setup')), $this->_config->getResources());
- }
-}
diff --git a/dev/tests/unit/testsuite/Magento/App/CronTest.php b/dev/tests/unit/testsuite/Magento/App/CronTest.php
index c08e2d4fdf7a9..e5d3aaa24e765 100644
--- a/dev/tests/unit/testsuite/Magento/App/CronTest.php
+++ b/dev/tests/unit/testsuite/Magento/App/CronTest.php
@@ -62,11 +62,11 @@ protected function setUp()
);
}
- public function testExecuteDispatchesCronEvent()
+ public function testLaunchDispatchesCronEvent()
{
$this->_stateMock->expects($this->once())->method('setAreaCode')->with('crontab');
$this->_eventManagerMock->expects($this->once())->method('dispatch')->with('default');
$this->_responseMock->expects($this->once())->method('setCode')->with(0);
- $this->assertEquals($this->_responseMock, $this->_model->execute());
+ $this->assertEquals($this->_responseMock, $this->_model->launch());
}
}
diff --git a/dev/tests/unit/testsuite/Magento/App/EntryPoint/EntryPointTest.php b/dev/tests/unit/testsuite/Magento/App/EntryPoint/EntryPointTest.php
index e0ca6964362e2..d89f129df187a 100644
--- a/dev/tests/unit/testsuite/Magento/App/EntryPoint/EntryPointTest.php
+++ b/dev/tests/unit/testsuite/Magento/App/EntryPoint/EntryPointTest.php
@@ -68,8 +68,8 @@ protected function setUp()
public function testRunExecutesApplication()
{
$applicationName = '\Magento\App\TestApplication';
- $applicationMock = $this->getMock('\Magento\AppInterface');
- $applicationMock->expects($this->once())->method('execute')->will($this->returnValue($this->_responseMock));
+ $applicationMock = $this->getMock('\Magento\LauncherInterface');
+ $applicationMock->expects($this->once())->method('launch')->will($this->returnValue($this->_responseMock));
$this->_objectManagerMock->expects($this->once())->method('create')->with($applicationName, array())
->will($this->returnValue($applicationMock));
$this->assertNull($this->_model->run($applicationName));
@@ -78,14 +78,17 @@ public function testRunExecutesApplication()
public function testRunCatchesExceptionThrownByApplication()
{
$applicationName = '\Magento\App\TestApplication';
- $applicationMock = $this->getMock('\Magento\AppInterface');
+ $applicationMock = $this->getMock('\Magento\LauncherInterface');
$applicationMock->expects($this->once())
- ->method('execute')
+ ->method('launch')
->will($this->throwException(new \Exception('Something went wrong.')));
$this->_objectManagerMock->expects($this->once())
->method('create')
->with($applicationName, array())
->will($this->returnValue($applicationMock));
+ // clean output
+ ob_start();
$this->assertNull($this->_model->run($applicationName));
+ ob_end_clean();
}
}
diff --git a/dev/tests/unit/testsuite/Magento/App/Resource/Config/ReaderTest.php b/dev/tests/unit/testsuite/Magento/App/Resource/Config/ReaderTest.php
index 955e7a4ee5131..6c3d80a492d68 100644
--- a/dev/tests/unit/testsuite/Magento/App/Resource/Config/ReaderTest.php
+++ b/dev/tests/unit/testsuite/Magento/App/Resource/Config/ReaderTest.php
@@ -74,7 +74,7 @@ protected function setUp()
);
$this->_configLocalMock = $this->getMock(
- 'Magento\App\Config', array(), array(), '', false
+ 'Magento\App\Arguments', array(), array(), '', false
);
$this->_model = new \Magento\App\Resource\Config\Reader(
diff --git a/dev/tests/unit/testsuite/Magento/Backend/App/ConfigTest.php b/dev/tests/unit/testsuite/Magento/Backend/App/ConfigTest.php
index 710ef232a97c9..97aa355f4fc73 100644
--- a/dev/tests/unit/testsuite/Magento/Backend/App/ConfigTest.php
+++ b/dev/tests/unit/testsuite/Magento/Backend/App/ConfigTest.php
@@ -91,9 +91,9 @@ public function testReinit()
/**
* @param mixed $configValue
* @param bool $expectedResult
- * @dataProvider getFlagDataProvider
+ * @dataProvider isSetFlagDataProvider
*/
- public function testGetFlag($configValue, $expectedResult)
+ public function testIsSetFlag($configValue, $expectedResult)
{
$path = 'some path';
$configData = $this->getConfigDataMock('getValue');
@@ -107,10 +107,10 @@ public function testGetFlag($configValue, $expectedResult)
->method('getSection')
->with($this->equalTo('default'), $this->isNull())
->will($this->returnValue($configData));
- $this->assertEquals($expectedResult, $this->model->getFlag($path));
+ $this->assertEquals($expectedResult, $this->model->isSetFlag($path));
}
- public function getFlagDataProvider()
+ public function isSetFlagDataProvider()
{
return array(
array(0, false),
diff --git a/dev/tests/unit/testsuite/Magento/Backend/Block/Page/System/Config/Robots/ResetTest.php b/dev/tests/unit/testsuite/Magento/Backend/Block/Page/System/Config/Robots/ResetTest.php
index 93c408a101b9a..32e19a2466ba9 100644
--- a/dev/tests/unit/testsuite/Magento/Backend/Block/Page/System/Config/Robots/ResetTest.php
+++ b/dev/tests/unit/testsuite/Magento/Backend/Block/Page/System/Config/Robots/ResetTest.php
@@ -38,14 +38,14 @@ class ResetTest extends \PHPUnit_Framework_TestCase
private $_resetRobotsBlock;
/**
- * @var \Magento\Core\Model\ConfigInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var \Magento\App\ConfigInterface|\PHPUnit_Framework_MockObject_MockObject
*/
protected $coreConfigMock;
protected function setUp()
{
$this->coreConfigMock = $this->getMock(
- 'Magento\Core\Model\Config', array('getValue'), array(), '', false
+ 'Magento\App\ConfigInterface', array(), array(), '', false
);
$this->_resetRobotsBlock = new Reset(
diff --git a/dev/tests/unit/testsuite/Magento/Backend/Block/System/Config/Form/FieldTest.php b/dev/tests/unit/testsuite/Magento/Backend/Block/System/Config/Form/FieldTest.php
index 00954fd9eac00..b845948c2cdda 100644
--- a/dev/tests/unit/testsuite/Magento/Backend/Block/System/Config/Form/FieldTest.php
+++ b/dev/tests/unit/testsuite/Magento/Backend/Block/System/Config/Form/FieldTest.php
@@ -47,7 +47,7 @@ class FieldTest extends \PHPUnit_Framework_TestCase
/**
* @var \PHPUnit_Framework_MockObject_MockObject
*/
- protected $_appModelMock;
+ protected $_storeManagerMock;
/**
* @var \PHPUnit_Framework_MockObject_MockObject
@@ -56,10 +56,16 @@ class FieldTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
- $this->_appModelMock = $this->getMock('Magento\Core\Model\App', array(), array(), '', false, false);
+ $this->_storeManagerMock = $this->getMock('Magento\Core\Model\StoreManager',
+ array(),
+ array(),
+ '',
+ false,
+ false
+ );
$data = array(
- 'app' => $this->_appModelMock,
+ 'storeManager' => $this->_storeManagerMock,
'urlBuilder' => $this->getMock('Magento\Backend\Model\Url', array(), array(), '', false)
);
$helper = new \Magento\TestFramework\Helper\ObjectManager($this);
@@ -128,7 +134,7 @@ public function testRenderHint()
public function testRenderScopeLabel()
{
- $this->_appModelMock->expects($this->once())->method('isSingleStoreMode')->will($this->returnValue(false));
+ $this->_storeManagerMock->expects($this->once())->method('isSingleStoreMode')->will($this->returnValue(false));
$testScopeLabel = 'test_scope_label';
$this->_elementMock->expects($this->any())->method('getScope')->will($this->returnValue(true));
diff --git a/dev/tests/unit/testsuite/Magento/Backend/Block/System/Config/FormTest.php b/dev/tests/unit/testsuite/Magento/Backend/Block/System/Config/FormTest.php
index e50edc902e229..1da580c2c90a0 100644
--- a/dev/tests/unit/testsuite/Magento/Backend/Block/System/Config/FormTest.php
+++ b/dev/tests/unit/testsuite/Magento/Backend/Block/System/Config/FormTest.php
@@ -106,7 +106,7 @@ protected function setUp()
$this->_fieldFactoryMock = $this->getMock('Magento\Backend\Block\System\Config\Form\Field\Factory',
array(), array(), '', false, false
);
- $this->_coreConfigMock = $this->getMock('Magento\Core\Model\Config',
+ $this->_coreConfigMock = $this->getMock('Magento\App\ConfigInterface',
array(), array(), '', false, false
);
diff --git a/dev/tests/unit/testsuite/Magento/Backend/Block/Widget/GridTest.php b/dev/tests/unit/testsuite/Magento/Backend/Block/Widget/GridTest.php
index 08169da384823..a5a21d9e0f86c 100644
--- a/dev/tests/unit/testsuite/Magento/Backend/Block/Widget/GridTest.php
+++ b/dev/tests/unit/testsuite/Magento/Backend/Block/Widget/GridTest.php
@@ -50,7 +50,7 @@ protected function setUp()
*/
public function testAddGetClearRss($isUseStoreInUrl)
{
- $urlMock = $this->getMock('Magento\Core\Model\Url', array(), array(), '', false);
+ $urlMock = $this->getMock('Magento\Url', array(), array(), '', false);
$storeMock = $this->getMock('Magento\Core\Model\Store', array(), array(), '', false);
$storeMock->expects($this->any())
diff --git a/dev/tests/unit/testsuite/Magento/Backend/Helper/DataTest.php b/dev/tests/unit/testsuite/Magento/Backend/Helper/DataTest.php
index e83305050f342..57aa5b9912437 100644
--- a/dev/tests/unit/testsuite/Magento/Backend/Helper/DataTest.php
+++ b/dev/tests/unit/testsuite/Magento/Backend/Helper/DataTest.php
@@ -34,11 +34,6 @@ class DataTest extends \PHPUnit_Framework_TestCase
*/
protected $_helper;
- /**
- * @var \PHPUnit_Framework_MockObject_MockObject
- */
- protected $_configMock;
-
/**
* @var \PHPUnit_Framework_MockObject_MockObject
*/
@@ -46,7 +41,6 @@ class DataTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
- $this->_configMock = $this->getMock('Magento\Core\Model\Config', array(), array(), '', false, false);
$this->_frontResolverMock
= $this->getMock('\Magento\Backend\App\Area\FrontNameResolver', array(), array(), '', false);
$this->_helper = new \Magento\Backend\Helper\Data(
diff --git a/dev/tests/unit/testsuite/Magento/Backend/Model/AuthTest.php b/dev/tests/unit/testsuite/Magento/Backend/Model/AuthTest.php
index a51e667c66023..87b0ed3b300fe 100644
--- a/dev/tests/unit/testsuite/Magento/Backend/Model/AuthTest.php
+++ b/dev/tests/unit/testsuite/Magento/Backend/Model/AuthTest.php
@@ -25,7 +25,7 @@
class AuthTest extends \PHPUnit_Framework_TestCase
{
/**
- * @var Magento\Backend\Model\Auth
+ * @var \Magento\Backend\Model\Auth
*/
protected $_model;
@@ -52,9 +52,9 @@ protected function setUp()
$this->_model = new \Magento\Backend\Model\Auth(
$this->_eventManagerMock,
$this->getMock('\Magento\Backend\Helper\Data', array(), array(), '', false),
- $this->_authStorageMock = $this->getMock('\Magento\Backend\Model\Auth\StorageInterface'),
+ $this->getMock('\Magento\Backend\Model\Auth\StorageInterface'),
$this->_credentialStorage,
- $this->_coreConfigMock = $this->getMock('\Magento\Core\Model\Config', array(), array(), '', false),
+ $this->getMock('\Magento\App\ConfigInterface', array(), array(), '', false),
$this->_modelFactoryMock
);
}
diff --git a/dev/tests/unit/testsuite/Magento/Backend/Model/Config/Backend/BaseurlTest.php b/dev/tests/unit/testsuite/Magento/Backend/Model/Config/Backend/BaseurlTest.php
index a9dafc523604d..396682bdd3975 100644
--- a/dev/tests/unit/testsuite/Magento/Backend/Model/Config/Backend/BaseurlTest.php
+++ b/dev/tests/unit/testsuite/Magento/Backend/Model/Config/Backend/BaseurlTest.php
@@ -47,7 +47,7 @@ public function testSaveMergedJsCssMustBeCleaned()
$resourceCollection = $this->getMock('Magento\Data\Collection\Db', array(), array(), '', false);
$mergeService = $this->getMock('Magento\View\Asset\MergeService', array(), array(), '', false);
$coreRegistry = $this->getMock('Magento\Core\Model\Registry', array(), array(), '', false);
- $coreConfig = $this->getMock('Magento\Core\Model\Config', array(), array(), '', false);
+ $coreConfig = $this->getMock('Magento\App\ConfigInterface', array(), array(), '', false);
$storeManager = $this->getMock('Magento\Core\Model\StoreManager', array(), array(), '', false);
$model = $this->getMock(
diff --git a/dev/tests/unit/testsuite/Magento/Backend/Model/Config/Backend/EncryptedTest.php b/dev/tests/unit/testsuite/Magento/Backend/Model/Config/Backend/EncryptedTest.php
index d1ef973df641d..bfef911e3465a 100644
--- a/dev/tests/unit/testsuite/Magento/Backend/Model/Config/Backend/EncryptedTest.php
+++ b/dev/tests/unit/testsuite/Magento/Backend/Model/Config/Backend/EncryptedTest.php
@@ -54,7 +54,7 @@ protected function setUp()
),
array(), '', false
);
- $this->_configMock = $this->getMock('Magento\Core\Model\Config', array(), array(), '', false);
+ $this->_configMock = $this->getMock('Magento\App\ConfigInterface', array(), array(), '', false);
$this->_helperMock = $this->getMock('Magento\Core\Helper\Data', array(), array(), '', false);
$this->_encryptorMock = $this->getMock('Magento\Encryption\EncryptorInterface', array(), array(), '', false);
$this->_model = $helper->getObject('Magento\Backend\Model\Config\Backend\Encrypted', array(
diff --git a/dev/tests/unit/testsuite/Magento/Backend/Model/Config/Backend/SecureTest.php b/dev/tests/unit/testsuite/Magento/Backend/Model/Config/Backend/SecureTest.php
index 3dd4831b9e17f..da180a917c9ef 100644
--- a/dev/tests/unit/testsuite/Magento/Backend/Model/Config/Backend/SecureTest.php
+++ b/dev/tests/unit/testsuite/Magento/Backend/Model/Config/Backend/SecureTest.php
@@ -47,7 +47,7 @@ public function testSaveMergedJsCssMustBeCleaned()
$resourceCollection = $this->getMock('Magento\Data\Collection\Db', array(), array(), '', false);
$mergeService = $this->getMock('Magento\View\Asset\MergeService', array(), array(), '', false);
$coreRegistry = $this->getMock('Magento\Core\Model\Registry', array(), array(), '', false);
- $coreConfig = $this->getMock('Magento\Core\Model\Config', array(), array(), '', false);
+ $coreConfig = $this->getMock('Magento\App\ConfigInterface', array(), array(), '', false);
$storeManager = $this->getMock('Magento\Core\Model\StoreManager', array(), array(), '', false);
$model = $this->getMock(
diff --git a/dev/tests/unit/testsuite/Magento/Backend/Model/Config/Source/Storage/Media/DatabaseTest.php b/dev/tests/unit/testsuite/Magento/Backend/Model/Config/Source/Storage/Media/DatabaseTest.php
index 2f8ae68576421..51dd190ecb187 100644
--- a/dev/tests/unit/testsuite/Magento/Backend/Model/Config/Source/Storage/Media/DatabaseTest.php
+++ b/dev/tests/unit/testsuite/Magento/Backend/Model/Config/Source/Storage/Media/DatabaseTest.php
@@ -39,13 +39,13 @@ class DatabaseTest extends \PHPUnit_Framework_TestCase
protected $mediaDatabase;
/**
- * @var \Magento\App\Config|\PHPUnit_Framework_MockObject_MockObject
+ * @var \Magento\App\Arguments|\PHPUnit_Framework_MockObject_MockObject
*/
protected $configMock;
protected function setUp()
{
- $this->configMock = $this->getMock('Magento\App\Config', array(), array(), '', false);
+ $this->configMock = $this->getMock('Magento\App\Arguments', array(), array(), '', false);
$this->configMock->expects($this->any())
->method('getResources')
->will($this->returnValue(array(
diff --git a/dev/tests/unit/testsuite/Magento/Backend/Model/Config/Structure/AbstractElementTest.php b/dev/tests/unit/testsuite/Magento/Backend/Model/Config/Structure/AbstractElementTest.php
index 2b57d514084f5..1185dfcd520dc 100644
--- a/dev/tests/unit/testsuite/Magento/Backend/Model/Config/Structure/AbstractElementTest.php
+++ b/dev/tests/unit/testsuite/Magento/Backend/Model/Config/Structure/AbstractElementTest.php
@@ -37,22 +37,22 @@ class AbstractElementTest extends \PHPUnit_Framework_TestCase
/**
* @var \PHPUnit_Framework_MockObject_MockObject
*/
- protected $_applicationMock;
+ protected $_storeManager;
protected function setUp()
{
- $this->_applicationMock = $this->getMock('Magento\Core\Model\App', array(), array(), '', false);
+ $this->_storeManager = $this->getMock('Magento\Core\Model\StoreManager', array(), array(), '', false);
$this->_model = $this->getMockForAbstractClass(
'Magento\Backend\Model\Config\Structure\AbstractElement',
- array($this->_applicationMock)
+ array($this->_storeManager)
);
}
protected function tearDown()
{
unset($this->_model);
- unset($this->_applicationMock);
+ unset($this->_storeManager);
}
public function testGetId()
@@ -98,7 +98,7 @@ public function testGetAttribute()
public function testIsVisibleReturnsTrueInSingleStoreModeForNonHiddenElements()
{
- $this->_applicationMock->expects($this->once())->method('isSingleStoreMode')->will($this->returnValue(true));
+ $this->_storeManager->expects($this->once())->method('isSingleStoreMode')->will($this->returnValue(true));
$this->_model->setData(array('showInDefault' => 1, 'showInStore' => 0, 'showInWebsite' => 0),
\Magento\Backend\Model\Config\ScopeDefiner::SCOPE_DEFAULT);
$this->assertTrue($this->_model->isVisible());
@@ -106,7 +106,7 @@ public function testIsVisibleReturnsTrueInSingleStoreModeForNonHiddenElements()
public function testIsVisibleReturnsFalseInSingleStoreModeForHiddenElements()
{
- $this->_applicationMock->expects($this->once())->method('isSingleStoreMode')->will($this->returnValue(true));
+ $this->_storeManager->expects($this->once())->method('isSingleStoreMode')->will($this->returnValue(true));
$this->_model->setData(
array('hide_in_single_store_mode' => 1, 'showInDefault' => 1, 'showInStore' => 0, 'showInWebsite' => 0),
\Magento\Backend\Model\Config\ScopeDefiner::SCOPE_DEFAULT
@@ -119,7 +119,7 @@ public function testIsVisibleReturnsFalseInSingleStoreModeForHiddenElements()
*/
public function testIsVisibleReturnsFalseInSingleStoreModeForInvisibleElements()
{
- $this->_applicationMock->expects($this->once())->method('isSingleStoreMode')->will($this->returnValue(true));
+ $this->_storeManager->expects($this->once())->method('isSingleStoreMode')->will($this->returnValue(true));
$this->_model->setData(array('showInDefault' => 0, 'showInStore' => 0, 'showInWebsite' => 0),
\Magento\Backend\Model\Config\ScopeDefiner::SCOPE_DEFAULT
);
diff --git a/dev/tests/unit/testsuite/Magento/Backend/Model/Config/Structure/Element/AbstractCompositeTest.php b/dev/tests/unit/testsuite/Magento/Backend/Model/Config/Structure/Element/AbstractCompositeTest.php
index 76bce7427118c..56bdbc5f8f00b 100644
--- a/dev/tests/unit/testsuite/Magento/Backend/Model/Config/Structure/Element/AbstractCompositeTest.php
+++ b/dev/tests/unit/testsuite/Magento/Backend/Model/Config/Structure/Element/AbstractCompositeTest.php
@@ -37,7 +37,7 @@ class AbstractCompositeTest extends \PHPUnit_Framework_TestCase
/**
* @var \PHPUnit_Framework_MockObject_MockObject
*/
- protected $_applicationMock;
+ protected $_storeManagerMock;
/**
* @var \PHPUnit_Framework_MockObject_MockObject
@@ -63,18 +63,18 @@ protected function setUp()
$this->_iteratorMock = $this->getMock(
'Magento\Backend\Model\Config\Structure\Element\Iterator', array(), array(), '', false
);
- $this->_applicationMock = $this->getMock('Magento\Core\Model\App', array(), array(), '', false);
+ $this->_storeManagerMock = $this->getMock('Magento\Core\Model\StoreManager', array(), array(), '', false);
$this->_model = $this->getMockForAbstractClass(
'Magento\Backend\Model\Config\Structure\Element\AbstractComposite',
- array($this->_applicationMock, $this->_iteratorMock)
+ array($this->_storeManagerMock, $this->_iteratorMock)
);
}
protected function tearDown()
{
unset($this->_iteratorMock);
- unset($this->_applicationMock);
+ unset($this->_storeManagerMock);
unset($this->_model);
}
@@ -106,7 +106,7 @@ public function testHasChildrenReturnsTrueIfThereAreVisibleChildren()
public function testIsVisibleReturnsTrueIfThereAreVisibleChildren()
{
- $this->_applicationMock->expects($this->once())->method('isSingleStoreMode')->will($this->returnValue(true));
+ $this->_storeManagerMock->expects($this->once())->method('isSingleStoreMode')->will($this->returnValue(true));
$this->_iteratorMock->expects($this->once())->method('current')->will($this->returnValue(true));
$this->_iteratorMock->expects($this->once())->method('valid')->will($this->returnValue(true));
$this->_model->setData(array('showInDefault' => 'true'), 'default');
@@ -115,7 +115,7 @@ public function testIsVisibleReturnsTrueIfThereAreVisibleChildren()
public function testIsVisibleReturnsTrueIfElementHasFrontEndModel()
{
- $this->_applicationMock->expects($this->once())->method('isSingleStoreMode')->will($this->returnValue(true));
+ $this->_storeManagerMock->expects($this->once())->method('isSingleStoreMode')->will($this->returnValue(true));
$this->_model->setData(array(
'showInDefault' => 'true',
'frontend_model' => 'Model_Name'
@@ -125,7 +125,7 @@ public function testIsVisibleReturnsTrueIfElementHasFrontEndModel()
public function testIsVisibleReturnsFalseIfElementHasNoChildrenAndFrontendModel()
{
- $this->_applicationMock->expects($this->once())->method('isSingleStoreMode')->will($this->returnValue(true));
+ $this->_storeManagerMock->expects($this->once())->method('isSingleStoreMode')->will($this->returnValue(true));
$this->_model->setData(array('showInDefault' => 'true'), 'default');
$this->assertFalse($this->_model->isVisible());
}
diff --git a/dev/tests/unit/testsuite/Magento/Backend/Model/Config/Structure/Element/Dependency/MapperTest.php b/dev/tests/unit/testsuite/Magento/Backend/Model/Config/Structure/Element/Dependency/MapperTest.php
index e329e0eaabdcd..ae9075c24da04 100644
--- a/dev/tests/unit/testsuite/Magento/Backend/Model/Config/Structure/Element/Dependency/MapperTest.php
+++ b/dev/tests/unit/testsuite/Magento/Backend/Model/Config/Structure/Element/Dependency/MapperTest.php
@@ -59,7 +59,7 @@ class MapperTest extends \PHPUnit_Framework_TestCase
/**
* @var \PHPUnit_Framework_MockObject_MockObject
*/
- protected $_applicationMock;
+ protected $_storeManagerMock;
/**
* @var \PHPUnit_Framework_MockObject_MockObject
@@ -91,7 +91,7 @@ protected function setUp()
),
);
- $this->_applicationMock = $this->getMockBuilder('Magento\Core\Model\App')
+ $this->_storeManagerMock = $this->getMockBuilder('Magento\Core\Model\StoreManager')
->setMethods(array('getStore'))
->disableOriginalConstructor()
->getMock();
@@ -105,14 +105,14 @@ protected function setUp()
->disableOriginalConstructor()
->getMock();
$this->_model = new \Magento\Backend\Model\Config\Structure\Element\Dependency\Mapper(
- $this->_applicationMock, $this->_configStructureMock, $this->_fieldFactoryMock);
+ $this->_storeManagerMock, $this->_configStructureMock, $this->_fieldFactoryMock);
}
protected function tearDown()
{
unset($this->_model);
unset($this->_configStructureMock);
- unset($this->_applicationMock);
+ unset($this->_storeManagerMock);
unset($this->_fieldFactoryMock);
unset($this->_testData);
}
@@ -126,7 +126,7 @@ public function testGetDependenciesWhenDependentIsInvisible($isValueSatisfy)
$storeMock = $this->getMockBuilder('Magento\Core\Model\Store')
->disableOriginalConstructor()
->getMock();
- $this->_applicationMock->expects($this->exactly(count($this->_testData)))
+ $this->_storeManagerMock->expects($this->exactly(count($this->_testData)))
->method('getStore')
->with(self::STORE_CODE)
->will($this->returnValue($storeMock));
@@ -170,7 +170,7 @@ public function getDependenciesDataProvider()
public function testGetDependenciesIsVisible()
{
- $this->_applicationMock->expects($this->never())
+ $this->_storeManagerMock->expects($this->never())
->method('getStore');
$expected = array();
diff --git a/dev/tests/unit/testsuite/Magento/Backend/Model/Config/Structure/Element/FieldTest.php b/dev/tests/unit/testsuite/Magento/Backend/Model/Config/Structure/Element/FieldTest.php
index 277fe207ab522..4532c845fe5d2 100644
--- a/dev/tests/unit/testsuite/Magento/Backend/Model/Config/Structure/Element/FieldTest.php
+++ b/dev/tests/unit/testsuite/Magento/Backend/Model/Config/Structure/Element/FieldTest.php
@@ -41,7 +41,7 @@ class FieldTest extends \PHPUnit_Framework_TestCase
/**
* @var \PHPUnit_Framework_MockObject_MockObject
*/
- protected $_applicationMock;
+ protected $_storeManagerMock;
/**
* @var \PHPUnit_Framework_MockObject_MockObject
@@ -78,7 +78,7 @@ protected function setUp()
$this->_iteratorMock = $this->getMock(
'Magento\Backend\Model\Config\Structure\Element\Iterator', array(), array(), '', false
);
- $this->_applicationMock = $this->getMock('Magento\Core\Model\App', array(), array(), '', false);
+ $this->_storeManagerMock = $this->getMock('Magento\Core\Model\StoreManager', array(), array(), '', false);
$this->_backendFactoryMock = $this->getMock(
'Magento\Backend\Model\Config\BackendFactory', array(), array(), '', false
);
@@ -96,7 +96,7 @@ protected function setUp()
);
$this->_model = new \Magento\Backend\Model\Config\Structure\Element\Field(
- $this->_applicationMock,
+ $this->_storeManagerMock,
$this->_backendFactoryMock,
$this->_sourceFactoryMock,
$this->_commentFactoryMock,
@@ -108,7 +108,7 @@ protected function setUp()
protected function tearDown()
{
unset($this->_iteratorMock);
- unset($this->_applicationMock);
+ unset($this->_storeManagerMock);
unset($this->_backendFactoryMock);
unset($this->_sourceFactoryMock);
unset($this->_commentFactoryMock);
diff --git a/dev/tests/unit/testsuite/Magento/Backend/Model/Config/Structure/Element/GroupTest.php b/dev/tests/unit/testsuite/Magento/Backend/Model/Config/Structure/Element/GroupTest.php
index d2074055aef55..b78d026ec87b4 100644
--- a/dev/tests/unit/testsuite/Magento/Backend/Model/Config/Structure/Element/GroupTest.php
+++ b/dev/tests/unit/testsuite/Magento/Backend/Model/Config/Structure/Element/GroupTest.php
@@ -37,7 +37,7 @@ class GroupTest extends \PHPUnit_Framework_TestCase
/**
* @var \PHPUnit_Framework_MockObject_MockObject
*/
- protected $_applicationMock;
+ protected $_storeManagerMock;
/**
* @var \PHPUnit_Framework_MockObject_MockObject
@@ -59,7 +59,7 @@ protected function setUp()
$this->_iteratorMock = $this->getMock(
'Magento\Backend\Model\Config\Structure\Element\Iterator\Field', array(), array(), '', false
);
- $this->_applicationMock = $this->getMock('Magento\Core\Model\App', array(), array(), '', false);
+ $this->_storeManagerMock = $this->getMock('Magento\Core\Model\StoreManager', array(), array(), '', false);
$this->_cloneFactoryMock = $this->getMock(
'Magento\Backend\Model\Config\BackendClone\Factory', array(), array(), '', false
);
@@ -68,7 +68,7 @@ protected function setUp()
);
$this->_model = new \Magento\Backend\Model\Config\Structure\Element\Group(
- $this->_applicationMock,
+ $this->_storeManagerMock,
$this->_iteratorMock, $this->_cloneFactoryMock,
$this->_depMapperMock
);
@@ -78,7 +78,7 @@ protected function tearDown()
{
unset($this->_model);
unset($this->_iteratorMock);
- unset($this->_applicationMock);
+ unset($this->_storeManagerMock);
unset($this->_cloneFactoryMock);
unset($this->_depMapperMock);
}
@@ -104,7 +104,7 @@ public function testGetCloneModelThrowsExceptionIfNoSourceModelIsSet()
public function testGetCloneModelCreatesCloneModel()
{
- $cloneModel = $this->getMock('Magento\Core\Model\Config\Value', array(), array(), '', false);
+ $cloneModel = $this->getMock('Magento\App\Config\ValueInterface', array(), array(), '', false);
$this->_depMapperMock = $this->getMock(
'Magento\Backend\Model\Config\Structure\Element\Dependency\Mapper', array(), array(), '', false
);
diff --git a/dev/tests/unit/testsuite/Magento/Backend/Model/Config/Structure/Element/SectionTest.php b/dev/tests/unit/testsuite/Magento/Backend/Model/Config/Structure/Element/SectionTest.php
index 1ff8c8e3aff47..44835f16a9422 100644
--- a/dev/tests/unit/testsuite/Magento/Backend/Model/Config/Structure/Element/SectionTest.php
+++ b/dev/tests/unit/testsuite/Magento/Backend/Model/Config/Structure/Element/SectionTest.php
@@ -37,7 +37,7 @@ class SectionTest extends \PHPUnit_Framework_TestCase
/**
* @var \PHPUnit_Framework_MockObject_MockObject
*/
- protected $_applicationMock;
+ protected $_storeManagerMock;
/**
* @var \PHPUnit_Framework_MockObject_MockObject
@@ -54,11 +54,11 @@ protected function setUp()
$this->_iteratorMock = $this->getMock(
'Magento\Backend\Model\Config\Structure\Element\Iterator\Field', array(), array(), '', false
);
- $this->_applicationMock = $this->getMock('Magento\Core\Model\App', array(), array(), '', false);
+ $this->_storeManagerMock = $this->getMock('Magento\Core\Model\StoreManager', array(), array(), '', false);
$this->_authorizationMock = $this->getMock('Magento\AuthorizationInterface');
$this->_model = new \Magento\Backend\Model\Config\Structure\Element\Section(
- $this->_applicationMock, $this->_iteratorMock, $this->_authorizationMock
+ $this->_storeManagerMock, $this->_iteratorMock, $this->_authorizationMock
);
}
@@ -66,7 +66,7 @@ protected function tearDown()
{
unset($this->_model);
unset($this->_iteratorMock);
- unset($this->_applicationMock);
+ unset($this->_storeManagerMock);
unset($this->_authorizationMock);
}
@@ -88,14 +88,14 @@ public function testIsAllowedReturnsTrueIfResourcesIsValidAndAllowed()
public function testIsVisibleFirstChecksIfSectionIsAllowed()
{
- $this->_applicationMock->expects($this->never())->method('isSingleStoreMode');
+ $this->_storeManagerMock->expects($this->never())->method('isSingleStoreMode');
$this->assertFalse($this->_model->isVisible());
}
public function testIsVisibleProceedsWithVisibilityCheckIfSectionIsAllowed()
{
$this->_authorizationMock->expects($this->any())->method('isAllowed')->will($this->returnValue(true));
- $this->_applicationMock->expects($this->once())->method('isSingleStoreMode')->will($this->returnValue(true));
+ $this->_storeManagerMock->expects($this->once())->method('isSingleStoreMode')->will($this->returnValue(true));
$this->_model->setData(array('resource' => 'Magento_Adminhtml::all'), 'scope');
$this->_model->isVisible();
}
diff --git a/dev/tests/unit/testsuite/Magento/Backend/Model/Config/Structure/Element/TabTest.php b/dev/tests/unit/testsuite/Magento/Backend/Model/Config/Structure/Element/TabTest.php
index ec69ca69f238e..83445656b5a7c 100644
--- a/dev/tests/unit/testsuite/Magento/Backend/Model/Config/Structure/Element/TabTest.php
+++ b/dev/tests/unit/testsuite/Magento/Backend/Model/Config/Structure/Element/TabTest.php
@@ -37,7 +37,7 @@ class TabTest extends \PHPUnit_Framework_TestCase
/**
* @var \PHPUnit_Framework_MockObject_MockObject
*/
- protected $_applicationMock;
+ protected $_storeManagerMock;
/**
* @var \PHPUnit_Framework_MockObject_MockObject
@@ -49,10 +49,10 @@ protected function setUp()
$this->_iteratorMock = $this->getMock(
'Magento\Backend\Model\Config\Structure\Element\Iterator\Field', array(), array(), '', false
);
- $this->_applicationMock = $this->getMock('Magento\Core\Model\App', array(), array(), '', false);
+ $this->_storeManagerMock = $this->getMock('Magento\Core\Model\StoreManager', array(), array(), '', false);
$this->_model = new \Magento\Backend\Model\Config\Structure\Element\Tab(
- $this->_applicationMock, $this->_iteratorMock
+ $this->_storeManagerMock, $this->_iteratorMock
);
}
@@ -60,7 +60,7 @@ protected function tearDown()
{
unset($this->_model);
unset($this->_iteratorMock);
- unset($this->_applicationMock);
+ unset($this->_storeManagerMock);
}
public function testIsVisibleOnlyChecksPresenceOfChildren()
diff --git a/dev/tests/unit/testsuite/Magento/Backend/Model/ConfigTest.php b/dev/tests/unit/testsuite/Magento/Backend/Model/ConfigTest.php
index 5a08f64e038ef..e51fe8dc72476 100644
--- a/dev/tests/unit/testsuite/Magento/Backend/Model/ConfigTest.php
+++ b/dev/tests/unit/testsuite/Magento/Backend/Model/ConfigTest.php
@@ -87,14 +87,12 @@ protected function setUp()
$this->_transFactoryMock = $this->getMock(
'Magento\Core\Model\Resource\TransactionFactory', array('create'), array(), '', false
);
- $this->_appConfigMock = $this->getMock('Magento\Core\Model\Config', array(), array(), '', false);
+ $this->_appConfigMock = $this->getMock('Magento\App\ConfigInterface', array(), array(), '', false);
$this->_configLoaderMock = $this->getMock('Magento\Backend\Model\Config\Loader', array(), array(), '', false);
- $this->_applicationMock = $this->getMock('Magento\Core\Model\App', array(), array(), '', false);
$this->_dataFactoryMock = $this->getMock('Magento\Core\Model\Config\ValueFactory', array(), array(), '', false);
$this->_storeManager = $this->getMockForAbstractClass('Magento\Core\Model\StoreManagerInterface');
$this->_model = new \Magento\Backend\Model\Config(
- $this->_applicationMock,
$this->_appConfigMock,
$this->_eventManagerMock,
$structureMock,
diff --git a/dev/tests/unit/testsuite/Magento/Backend/Model/Translate/Inline/ConfigTest.php b/dev/tests/unit/testsuite/Magento/Backend/Model/Translate/Inline/ConfigTest.php
index ed115468037d8..35561948fea71 100644
--- a/dev/tests/unit/testsuite/Magento/Backend/Model/Translate/Inline/ConfigTest.php
+++ b/dev/tests/unit/testsuite/Magento/Backend/Model/Translate/Inline/ConfigTest.php
@@ -31,7 +31,7 @@ public function testIsActive()
$backendConfig = $this->getMockForAbstractClass('Magento\Backend\App\ConfigInterface');
$backendConfig
->expects($this->once())
- ->method('getFlag')
+ ->method('isSetFlag')
->with($this->equalTo('dev/translate_inline/active_admin'))
->will($this->returnValue($result));
$config = new Config($backendConfig);
diff --git a/dev/tests/unit/testsuite/Magento/Backend/Model/UrlTest.php b/dev/tests/unit/testsuite/Magento/Backend/Model/UrlTest.php
index a537078f2546b..a52180d9c268f 100644
--- a/dev/tests/unit/testsuite/Magento/Backend/Model/UrlTest.php
+++ b/dev/tests/unit/testsuite/Magento/Backend/Model/UrlTest.php
@@ -80,6 +80,11 @@ class UrlTest extends \PHPUnit_Framework_TestCase
*/
protected $_authSessionMock;
+ /**
+ * @var \PHPUnit_Framework_MockObject_MockObject
+ */
+ protected $_paramsResolverMock;
+
/**
* @var \Magento\Encryption\EncryptorInterface
*/
@@ -126,14 +131,23 @@ protected function setUp()
'', false, false);
$helper = new \Magento\TestFramework\Helper\ObjectManager($this);
$this->_encryptor = $this->getMock('Magento\Encryption\Encryptor', null, array(), '', false);
+ $this->_paramsResolverMock = $this->getMock(
+ 'Magento\Url\RouteParamsResolverFactory', array(), array(), '', false
+ );
+ $this->_paramsResolverMock->expects($this->any())
+ ->method('create')
+ ->will($this->returnValue($this->getMock(
+ 'Magento\Core\Model\Url\RouteParamsResolver', array(), array(), '', false
+ )));
$this->_model = $helper->getObject('Magento\Backend\Model\Url', array(
'coreStoreConfig' => $this->_storeConfigMock,
- 'backendHelper' => $helperMock,
- 'formKey' => $this->_formKey,
- 'menuConfig' => $this->_menuConfigMock,
- 'coreData' => $this->_coreDataMock,
- 'authSession' => $this->_authSessionMock,
- 'encryptor' => $this->_encryptor
+ 'backendHelper' => $helperMock,
+ 'formKey' => $this->_formKey,
+ 'menuConfig' => $this->_menuConfigMock,
+ 'coreData' => $this->_coreDataMock,
+ 'authSession' => $this->_authSessionMock,
+ 'encryptor' => $this->_encryptor,
+ 'routeParamsResolver' => $this->_paramsResolverMock
));
$this->_requestMock = $this->getMock('Magento\App\Request\Http', array(), array(), '', false);
@@ -205,57 +219,12 @@ public function testGetAreaFrontName()
$helper = new \Magento\TestFramework\Helper\ObjectManager($this);
$urlModel = $helper->getObject('Magento\Backend\Model\Url', array(
'backendHelper' => $helperMock,
- 'authSession' => $this->_authSessionMock
+ 'authSession' => $this->_authSessionMock,
+ 'routeParamsResolver' => $this->_paramsResolverMock,
));
$urlModel->getAreaFrontName();
}
- public function testGetActionPath()
- {
- $moduleFrontName = 'moduleFrontName';
- $controllerName = 'controllerName';
- $actionName = 'actionName';
-
- $this->_model->setRouteName($moduleFrontName);
- $this->_model->setRouteFrontName($moduleFrontName);
- $this->_model->setControllerName($controllerName);
- $this->_model->setActionName($actionName);
-
- $actionPath = $this->_model->getActionPath();
-
- $this->assertNotEmpty($actionPath);
- $this->assertStringStartsWith($this->_areaFrontName . '/', $actionPath);
- $this->assertStringMatchesFormat($this->_areaFrontName . '/%s/%s/%s', $actionPath);
- }
-
- public function testGetActionPathWhenAreaFrontNameIsEmpty()
- {
- $helperMock = $this->getMock('Magento\Backend\Helper\Data', array(), array(), '', false);
- $helperMock->expects($this->once())->method('getAreaFrontName')
- ->will($this->returnValue(''));
-
- $helper = new \Magento\TestFramework\Helper\ObjectManager($this);
- $urlModel = $helper->getObject('Magento\Backend\Model\Url', array(
- 'backendHelper' => $helperMock,
- 'authSession' => $this->_authSessionMock
- ));
-
- $moduleFrontName = 'moduleFrontName';
- $controllerName = 'controllerName';
- $actionName = 'actionName';
-
- $urlModel->setRouteName($moduleFrontName);
- $urlModel->setRouteFrontName($moduleFrontName);
- $urlModel->setControllerName($controllerName);
- $urlModel->setActionName($actionName);
-
- $actionPath = $urlModel->getActionPath();
-
- $this->assertNotEmpty($actionPath);
- $this->assertStringStartsWith($moduleFrontName . '/', $actionPath);
- $this->assertStringMatchesFormat($moduleFrontName . '/%s/%s', $actionPath);
- }
-
/**
* Check that secret key generation is based on usage of routeName passed as method param
* Params are not equals
diff --git a/dev/tests/unit/testsuite/Magento/Bundle/Model/Product/CatalogPriceTest.php b/dev/tests/unit/testsuite/Magento/Bundle/Model/Product/CatalogPriceTest.php
new file mode 100644
index 0000000000000..dc10cf9be9f44
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Bundle/Model/Product/CatalogPriceTest.php
@@ -0,0 +1,123 @@
+storeManagerMock = $this->getMock('Magento\Core\Model\StoreManagerInterface');
+ $this->commonPriceMock
+ = $this->getMock('Magento\Catalog\Model\Product\CatalogPrice', array(), array(), '', false);
+ $this->coreRegistryMock = $this->getMock('Magento\Core\Model\Registry', array(), array(), '', false);
+ $methods = array('getStoreId', 'getWebsiteId', 'getCustomerGroupId', 'getPriceModel', '__wakeup');
+ $this->productMock = $this->getMock('Magento\Catalog\Model\Product', $methods, array(), '', false);
+ $this->priceModelMock
+ = $this->getMock('Magento\Catalog\Model\Product\Type\Price', array('getTotalPrices'), array(), '', false);
+ $this->catalogPrice = new \Magento\Bundle\Model\Product\CatalogPrice(
+ $this->storeManagerMock,
+ $this->commonPriceMock,
+ $this->coreRegistryMock
+ );
+ }
+
+ public function testGetCatalogPriceWithCurrentStore()
+ {
+ $this->coreRegistryMock->expects($this->once())->method('unregister')->with('rule_data');
+ $this->productMock->expects($this->once())->method('getStoreId')->will($this->returnValue('store_id'));
+ $this->productMock->expects($this->once())->method('getWebsiteId')->will($this->returnValue('website_id'));
+ $this->productMock->expects($this->once())->method('getCustomerGroupId')->will($this->returnValue('group_id'));
+ $this->coreRegistryMock->expects($this->once())->method('register');
+ $this->productMock
+ ->expects($this->once())
+ ->method('getPriceModel')
+ ->will($this->returnValue($this->priceModelMock));
+ $this->priceModelMock
+ ->expects($this->once())
+ ->method('getTotalPrices')
+ ->with($this->productMock, 'min', false)
+ ->will($this->returnValue(15));
+ $this->storeManagerMock->expects($this->never())->method('getStore');
+ $this->storeManagerMock->expects($this->never())->method('setCurrentStore');
+ $this->assertEquals(15, $this->catalogPrice->getCatalogPrice($this->productMock));
+ }
+
+ public function testGetCatalogPriceWithCustomStore()
+ {
+ $storeMock = $this->getMock('Magento\Core\Model\Store', array(), array(), '', false);
+ $this->coreRegistryMock->expects($this->once())->method('unregister')->with('rule_data');
+ $this->productMock->expects($this->once())->method('getStoreId')->will($this->returnValue('store_id'));
+ $this->productMock->expects($this->once())->method('getWebsiteId')->will($this->returnValue('website_id'));
+ $this->productMock->expects($this->once())->method('getCustomerGroupId')->will($this->returnValue('group_id'));
+ $this->coreRegistryMock->expects($this->once())->method('register');
+ $this->productMock
+ ->expects($this->once())
+ ->method('getPriceModel')
+ ->will($this->returnValue($this->priceModelMock));
+ $this->priceModelMock
+ ->expects($this->once())
+ ->method('getTotalPrices')
+ ->with($this->productMock, 'min', true)
+ ->will($this->returnValue(15));
+ $this->storeManagerMock->expects($this->exactly(2))->method('setCurrentStore');
+ $this->assertEquals(15, $this->catalogPrice->getCatalogPrice($this->productMock, $storeMock, true));
+ }
+
+ public function testGetCatalogRegularPrice()
+ {
+ $this->assertEquals(null, $this->catalogPrice->getCatalogRegularPrice($this->productMock));
+ }
+}
+
diff --git a/dev/tests/unit/testsuite/Magento/Captcha/Helper/Adminhtml/DataTest.php b/dev/tests/unit/testsuite/Magento/Captcha/Helper/Adminhtml/DataTest.php
index 7e7623a55e196..d6bbc494040cd 100644
--- a/dev/tests/unit/testsuite/Magento/Captcha/Helper/Adminhtml/DataTest.php
+++ b/dev/tests/unit/testsuite/Magento/Captcha/Helper/Adminhtml/DataTest.php
@@ -41,7 +41,7 @@ protected function setUp()
{
$backendConfig = $this->getMockBuilder('Magento\Backend\App\ConfigInterface')
->disableOriginalConstructor()
- ->setMethods(array('getValue', 'setValue', 'reinit', 'getFlag'))
+ ->setMethods(array('getValue', 'setValue', 'reinit', 'isSetFlag'))
->getMock();
$backendConfig->expects($this->any())
->method('getValue')
@@ -57,7 +57,7 @@ protected function setUp()
$this->_model = new \Magento\Captcha\Helper\Adminhtml\Data(
$this->getMock('Magento\App\Helper\Context', array(), array(), '', false),
$this->getMock('Magento\Core\Model\StoreManager', array(), array(), '', false),
- $this->getMock('Magento\Core\Model\Config', array(), array(), '', false),
+ $this->getMock('Magento\App\ConfigInterface', array(), array(), '', false),
$filesystemMock,
$this->getMock('Magento\Captcha\Model\CaptchaFactory', array(), array(), '', false),
$backendConfig
diff --git a/dev/tests/unit/testsuite/Magento/Captcha/Helper/DataTest.php b/dev/tests/unit/testsuite/Magento/Captcha/Helper/DataTest.php
index 4010ce04559bc..5ccfebf22e7d0 100644
--- a/dev/tests/unit/testsuite/Magento/Captcha/Helper/DataTest.php
+++ b/dev/tests/unit/testsuite/Magento/Captcha/Helper/DataTest.php
@@ -161,13 +161,13 @@ public function testGetImgUrl()
/**
* Create Config Stub
*
- * @return \Magento\Core\Model\Config
+ * @return \Magento\App\ConfigInterface
*/
protected function _getConfigStub()
{
$config = $this->getMock(
- 'Magento\Core\Model\Config',
- array('getValue'),
+ 'Magento\App\ConfigInterface',
+ array(),
array(), '', false
);
diff --git a/dev/tests/unit/testsuite/Magento/Captcha/Model/ObserverTest.php b/dev/tests/unit/testsuite/Magento/Captcha/Model/ObserverTest.php
index 611191c4cb491..f7f6a3f2dbf25 100644
--- a/dev/tests/unit/testsuite/Magento/Captcha/Model/ObserverTest.php
+++ b/dev/tests/unit/testsuite/Magento/Captcha/Model/ObserverTest.php
@@ -112,7 +112,7 @@ protected function setUp()
$this->_coreData = $this->getMock('Magento\Core\Helper\Data', array(), array(), '', false);
$this->_customerData = $this->getMock('Magento\Customer\Helper\Data', array(), array(), '', false);
$this->_helper = $this->getMock('Magento\Captcha\Helper\Data', array(), array(), '', false);
- $this->_urlManager = $this->getMock('Magento\Core\Model\Url', array(), array(), '', false);
+ $this->_urlManager = $this->getMock('Magento\Url', array(), array(), '', false);
$this->_actionFlag = $this->getMock('Magento\App\ActionFlag', array(), array(), '', false);
$this->_messageManager = $this->getMock('\Magento\Message\ManagerInterface', array(), array(), '', false);
$this->redirect = $this->getMock('\Magento\App\Response\RedirectInterface', array(), array(), '', false);
diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Helper/UrlTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Helper/UrlTest.php
index 688a66ee44466..e253ba82ccfa6 100644
--- a/dev/tests/unit/testsuite/Magento/Catalog/Helper/UrlTest.php
+++ b/dev/tests/unit/testsuite/Magento/Catalog/Helper/UrlTest.php
@@ -29,7 +29,7 @@
class UrlTest extends \PHPUnit_Framework_TestCase
{
- /** @var \Magento\Core\Model\Config */
+ /** @var \Magento\App\ConfigInterface */
protected $_configMock;
/** @var \Magento\Catalog\Helper\Product\Url */
@@ -38,7 +38,7 @@ class UrlTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
$contextMock = $this->getMockBuilder('Magento\App\Helper\Context')->disableOriginalConstructor()->getMock();
- $this->_configMock = $this->getMockBuilder('Magento\Core\Model\Config')
+ $this->_configMock = $this->getMockBuilder('Magento\App\ConfigInterface')
->disableOriginalConstructor()->getMock();
$storeManager = $this->getMock('Magento\Core\Model\StoreManager', array(), array(), '', false);
$this->_urlHelper = new \Magento\Catalog\Helper\Product\Url(
diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/ObserverTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/ObserverTest.php
index 949acd7763165..e1f2b361e9382 100644
--- a/dev/tests/unit/testsuite/Magento/Catalog/Model/ObserverTest.php
+++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/ObserverTest.php
@@ -67,7 +67,7 @@ protected function setUp()
$this->_catalogCategoryFlat = $this->getMock(
'Magento\Catalog\Helper\Category\Flat', array(), array(), '', false
);
- $coreConfig = $this->getMock('Magento\Core\Model\Config', array(), array(), '', false);
+ $coreConfig = $this->getMock('Magento\App\ReinitableConfigInterface', array(), array(), '', false);
$this->_model = $this->_objectHelper->getObject('Magento\Catalog\Model\Observer', array(
'catalogCategory' => $this->_catalogCategory,
'catalogData' => $this->_catalogData,
diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Product/Attribute/Backend/Groupprice/AbstractTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Product/Attribute/Backend/Groupprice/AbstractTest.php
index 05b69e6d25e18..773b9c62f8d7f 100644
--- a/dev/tests/unit/testsuite/Magento/Catalog/Model/Product/Attribute/Backend/Groupprice/AbstractTest.php
+++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/Product/Attribute/Backend/Groupprice/AbstractTest.php
@@ -52,7 +52,7 @@ protected function setUp()
$currencyFactoryMock = $this->getMock('Magento\Directory\Model\CurrencyFactory', array(), array(), '', false);
$storeManagerMock = $this->getMock('Magento\Core\Model\StoreManagerInterface', array(), array(), '', false);
$productTypeMock = $this->getMock('Magento\Catalog\Model\Product\Type', array(), array(), '', false);
- $configMock = $this->getMock('Magento\Core\Model\Config', array(), array(), '', false);
+ $configMock = $this->getMock('Magento\App\ConfigInterface', array(), array(), '', false);
$this->_model = $this->getMockForAbstractClass(
'Magento\Catalog\Model\Product\Attribute\Backend\Groupprice\AbstractGroupprice',
diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Product/CartConfigurationTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Product/CartConfigurationTest.php
new file mode 100644
index 0000000000000..c557a34b1a1c0
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/Product/CartConfigurationTest.php
@@ -0,0 +1,54 @@
+getMock('Magento\Catalog\Model\Product', array(), array(), '', false);
+ $productMock->expects($this->once())->method('getTypeId')->will($this->returnValue($productType));
+ $this->assertEquals($expected, $cartConfiguration->isProductConfigured($productMock, $config));
+ }
+
+ public function isProductConfiguredDataProvider()
+ {
+ return array(
+ 'simple' => array('simple', array(), false),
+ 'virtual' => array('virtual', array('options' => true), true),
+ 'configurable' => array('configurable',array('super_attribute' => false), true),
+ 'bundle' => array('bundle', array('bundle_option' => 'option1'), true),
+ 'some_option_type' => array('some_option_type', array(), false)
+ );
+ }
+}
+
diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Product/CatalogPriceTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Product/CatalogPriceTest.php
new file mode 100644
index 0000000000000..7af24994d94b2
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/Product/CatalogPriceTest.php
@@ -0,0 +1,104 @@
+priceFactoryMock = $this->getMock('Magento\Catalog\Model\Product\CatalogPriceFactory',
+ array(), array(), '', false);
+ $this->productMock = $this->getMock('\Magento\Catalog\Model\Product', array(), array(), '', false);
+ $this->catalogPriceInterfaceMock = $this->getMock('Magento\Catalog\Model\Product\CatalogPriceInterface');
+ $this->model = new \Magento\Catalog\Model\Product\CatalogPrice(
+ $this->priceFactoryMock,
+ array('custom_product_type' => 'CustomProduct/Model/CatalogPrice')
+ );
+ }
+
+ public function testGetCatalogPriceWhenPoolContainsPriceModelForGivenProductType()
+ {
+ $this->productMock->expects($this->any())
+ ->method('getTypeId')
+ ->will($this->returnValue('custom_product_type'));
+ $this->priceFactoryMock->expects($this->once())
+ ->method('create')
+ ->with('CustomProduct/Model/CatalogPrice')
+ ->will($this->returnValue($this->catalogPriceInterfaceMock));
+ $this->catalogPriceInterfaceMock->expects($this->once())->method('getCatalogPrice');
+ $this->productMock->expects($this->never())->method('getFinalPrice');
+ $this->model->getCatalogPrice($this->productMock);
+ }
+
+ public function testGetCatalogPriceWhenPoolDoesNotContainPriceModelForGivenProductType()
+ {
+ $this->productMock->expects($this->any())->method('getTypeId')->will($this->returnValue('test'));
+ $this->priceFactoryMock->expects($this->never())->method('create');
+ $this->productMock->expects($this->once())->method('getFinalPrice');
+ $this->catalogPriceInterfaceMock->expects($this->never())->method('getCatalogPrice');
+ $this->model->getCatalogPrice($this->productMock);
+ }
+
+ public function testGetCatalogRegularPriceWhenPoolDoesNotContainPriceModelForGivenProductType()
+ {
+ $this->productMock->expects($this->any())->method('getTypeId')->will($this->returnValue('test'));
+ $this->priceFactoryMock->expects($this->never())->method('create');
+ $this->catalogPriceInterfaceMock->expects($this->never())->method('getCatalogRegularPrice');
+ $this->productMock->expects($this->once())->method('getPrice');
+ $this->model->getCatalogRegularPrice($this->productMock);
+ }
+
+ public function testGetCatalogRegularPriceWhenPoolContainsPriceModelForGivenProductType()
+ {
+ $this->productMock->expects($this->any())
+ ->method('getTypeId')->will($this->returnValue('custom_product_type'));
+ $this->priceFactoryMock->expects($this->once())
+ ->method('create')->with('CustomProduct/Model/CatalogPrice')
+ ->will($this->returnValue($this->catalogPriceInterfaceMock));
+ $this->catalogPriceInterfaceMock->expects($this->once())->method('getCatalogRegularPrice');
+ $this->productMock->expects($this->never())->method('getPrice');
+ $this->model->getCatalogRegularPrice($this->productMock);
+ }
+}
diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/ProductTypes/Config/_files/invalidProductTypesMergedXmlArray.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/ProductTypes/Config/_files/invalidProductTypesMergedXmlArray.php
index 603ccc4f9861e..32c88ddc8cb41 100644
--- a/dev/tests/unit/testsuite/Magento/Catalog/Model/ProductTypes/Config/_files/invalidProductTypesMergedXmlArray.php
+++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/ProductTypes/Config/_files/invalidProductTypesMergedXmlArray.php
@@ -23,12 +23,13 @@
*/
return array
(
- 'without_required_type_handle' => array(
- '',
- array("Element 'config': Missing child element(s). Expected is ( type ).")),
'type_without_required_name' => array(
'',
- array("Element 'type': The attribute 'name' is required but missing.")),
+ array(
+ "Element 'type': The attribute 'name' is required but missing.",
+ "Element 'type': Not all fields of key identity-constraint 'productTypeKey' evaluate to a node."
+ )
+ ),
'type_without_required_label' => array(
'',
array("Element 'type': The attribute 'label' is required but missing.")),
diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/ProductTypes/Config/_files/invalidProductTypesXmlArray.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/ProductTypes/Config/_files/invalidProductTypesXmlArray.php
index 568c9012c1eeb..45155c4afbc30 100644
--- a/dev/tests/unit/testsuite/Magento/Catalog/Model/ProductTypes/Config/_files/invalidProductTypesXmlArray.php
+++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/ProductTypes/Config/_files/invalidProductTypesXmlArray.php
@@ -23,9 +23,6 @@
*/
return array
(
- 'without_required_type_handle' => array(
- '',
- array("Element 'config': Missing child element(s). Expected is ( type ).")),
'types_with_same_name_attribute_value' => array(
'',
array("Element 'type': Duplicate key-sequence ['some_name'] in unique identity-constraint 'uniqueTypeName'.")),
diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/ProductTypes/Config/_files/product_types.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/ProductTypes/Config/_files/product_types.php
index 282ece99d4460..7b6eadc58aec5 100644
--- a/dev/tests/unit/testsuite/Magento/Catalog/Model/ProductTypes/Config/_files/product_types.php
+++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/ProductTypes/Config/_files/product_types.php
@@ -22,46 +22,46 @@
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
return array(
- 'type_one' => array(
- 'name' => 'type_one',
- 'label' => 'Label One',
- 'model' => 'Instance_Type',
- 'composite' => true,
- 'index_priority' => 40,
- 'can_use_qty_decimals' => true,
- 'is_qty' => true,
- 'price_model' => 'Instance_Type_One',
- 'price_indexer' => 'Instance_Type_Two',
- 'stock_indexer' => 'Instance_Type_Three',
- 'allow_product_types' => array(
- 'type_one' => 'type_one'
+ 'types' => array(
+ 'type_one' => array(
+ 'name' => 'type_one',
+ 'label' => 'Label One',
+ 'model' => 'Instance_Type',
+ 'composite' => true,
+ 'index_priority' => 40,
+ 'can_use_qty_decimals' => true,
+ 'is_qty' => true,
+ 'price_model' => 'Instance_Type_One',
+ 'price_indexer' => 'Instance_Type_Two',
+ 'stock_indexer' => 'Instance_Type_Three',
),
- ),
- 'type_two' => array(
- 'name' => 'type_two',
- 'label' => false,
- 'model' => 'Instance_Type',
- 'composite' => false,
- 'index_priority' => 0,
- 'can_use_qty_decimals' => true,
- 'is_qty' => false,
- 'allowed_selection_types' => array(
- 'type_two' => 'type_two'
+ 'type_two' => array(
+ 'name' => 'type_two',
+ 'label' => false,
+ 'model' => 'Instance_Type',
+ 'composite' => false,
+ 'index_priority' => 0,
+ 'can_use_qty_decimals' => true,
+ 'is_qty' => false,
+ 'allowed_selection_types' => array(
+ 'type_two' => 'type_two'
+ ),
+ 'custom_attributes' => array(
+ 'some_name' => 'some_value'
+ ),
+ ),
+ 'type_three' => array(
+ 'name' => 'type_three',
+ 'label' => 'Label Three',
+ 'model' => 'Instance_Type',
+ 'composite' => false,
+ 'index_priority' => 20,
+ 'can_use_qty_decimals' => false,
+ 'is_qty' => false,
+ 'price_model' => 'Instance_Type_Three',
+ 'price_indexer' => 'Instance_Type_Three',
+ 'stock_indexer' => 'Instance_Type_Three',
)
),
- 'type_three' => array(
- 'name' => 'type_three',
- 'label' => 'Label Three',
- 'model' => 'Instance_Type',
- 'composite' => false,
- 'index_priority' => 20,
- 'can_use_qty_decimals' => false,
- 'is_qty' => false,
- 'price_model' => 'Instance_Type_Three',
- 'price_indexer' => 'Instance_Type_Three',
- 'stock_indexer' => 'Instance_Type_Three',
- 'allow_product_types' => array(
- 'type_three' => 'type_three'
- )
- )
+ 'composableTypes' => array('type_one' => 'type_one', 'type_three' => 'type_three'),
);
diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/ProductTypes/Config/_files/product_types.xml b/dev/tests/unit/testsuite/Magento/Catalog/Model/ProductTypes/Config/_files/product_types.xml
index b68eaa253d1a9..7437f1e69b7b4 100644
--- a/dev/tests/unit/testsuite/Magento/Catalog/Model/ProductTypes/Config/_files/product_types.xml
+++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/ProductTypes/Config/_files/product_types.xml
@@ -29,22 +29,23 @@
-
-
-
+
+
+
-
-
-
+
+
+
+
diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/ProductTypes/Config/_files/valid_product_types_merged.xml b/dev/tests/unit/testsuite/Magento/Catalog/Model/ProductTypes/Config/_files/valid_product_types_merged.xml
index 67b7da684451d..c45846bb8adae 100644
--- a/dev/tests/unit/testsuite/Magento/Catalog/Model/ProductTypes/Config/_files/valid_product_types_merged.xml
+++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/ProductTypes/Config/_files/valid_product_types_merged.xml
@@ -25,9 +25,6 @@
-->
-
-
-
@@ -36,9 +33,6 @@
-
-
-
@@ -46,4 +40,8 @@
+
+
+
+
diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/ProductTypes/ConfigTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/ProductTypes/ConfigTest.php
index 8dde9c01b1af8..51d809d42df42 100644
--- a/dev/tests/unit/testsuite/Magento/Catalog/Model/ProductTypes/ConfigTest.php
+++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/ProductTypes/ConfigTest.php
@@ -64,15 +64,17 @@ public function testGetType($value, $expected)
public function getTypeDataProvider()
{
return array(
- 'global_key_exist' => array(array('global' => 'value'), 'value'),
- 'return_default_value' => array(array('some_key' => 'value'), array())
+ 'global_key_exist' => array(array('types' => array('global' => 'value')), 'value'),
+ 'return_default_value' => array(array('types' => array('some_key' => 'value')), array())
);
}
public function testGetAll()
{
$expected = array('Expected Data');
- $this->cacheMock->expects($this->once())->method('load')->will($this->returnValue(serialize($expected)));
+ $this->cacheMock->expects($this->once())->method('load')->will($this->returnValue(
+ serialize(array('types' => $expected)))
+ );
$this->model = new \Magento\Catalog\Model\ProductTypes\Config(
$this->readerMock,
$this->cacheMock,
diff --git a/dev/tests/unit/testsuite/Magento/CatalogSearch/Block/ResultTest.php b/dev/tests/unit/testsuite/Magento/CatalogSearch/Block/ResultTest.php
new file mode 100644
index 0000000000000..2b47bfde9707a
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/CatalogSearch/Block/ResultTest.php
@@ -0,0 +1,100 @@
+contextMock = $this->getMock('Magento\View\Element\Template\Context', [], [], '', false);
+ $this->layerMock = $this->getMock('Magento\Catalog\Model\Layer', [], [], '', false);
+ $this->dataMock = $this->getMock('Magento\CatalogSearch\Helper\Data', [], [], '', false);
+ $this->model = new Result($this->contextMock, $this->layerMock, $this->dataMock);
+ }
+
+ public function testGetSearchQueryText()
+ {
+ $this->dataMock->expects($this->once())->method('getEscapedQueryText')->will($this->returnValue('query_text'));
+ $this->assertEquals('Search results for: \'query_text\'', $this->model->getSearchQueryText());
+ }
+
+ public function testGetNoteMessages()
+ {
+ $this->dataMock->expects($this->once())->method('getNoteMessages')->will($this->returnValue('SOME-MESSAGE'));
+ $this->assertEquals('SOME-MESSAGE', $this->model->getNoteMessages());
+ }
+
+ /**
+ * @param bool $isMinQueryLength
+ * @param string $expectedResult
+ * @dataProvider getNoResultTextDataProvider
+ */
+ public function testGetNoResultText($isMinQueryLength, $expectedResult)
+ {
+ $this->dataMock->expects($this->once())
+ ->method('isMinQueryLength')
+ ->will($this->returnValue($isMinQueryLength));
+ if ($isMinQueryLength) {
+ $queryMock = $this->getMock('Magento\CatalogSearch\Model\Query', [], [], '', false);
+ $queryMock->expects($this->once())->method('getMinQueryLength')->will($this->returnValue('5'));
+
+ $this->dataMock->expects($this->once())
+ ->method('getQuery')
+ ->will($this->returnValue($queryMock));
+ }
+ $this->assertEquals($expectedResult, $this->model->getNoResultText());
+ }
+
+ /**
+ * @return array
+ */
+ public function getNoResultTextDataProvider()
+ {
+ return array(
+ array(true, 'Minimum Search query length is 5'),
+ array(false, null),
+ );
+ }
+}
diff --git a/dev/tests/unit/testsuite/Magento/Centinel/Model/ServiceTest.php b/dev/tests/unit/testsuite/Magento/Centinel/Model/ServiceTest.php
index 3ba23c5ffaded..7ec135263921c 100644
--- a/dev/tests/unit/testsuite/Magento/Centinel/Model/ServiceTest.php
+++ b/dev/tests/unit/testsuite/Magento/Centinel/Model/ServiceTest.php
@@ -35,7 +35,7 @@ class ServiceTest extends \PHPUnit_Framework_TestCase
*/
public function testGetAuthenticationStartUrl()
{
- $url = $this->getMock('Magento\Core\Model\Url', ['getUrl'], [], '', false);
+ $url = $this->getMock('Magento\Url', ['getUrl'], [], '', false);
$url->expects($this->once())
->method('getUrl')
->with(
diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Block/Cart/AbstractTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Block/Cart/AbstractTest.php
index 4724125369f97..24782e9c4e438 100644
--- a/dev/tests/unit/testsuite/Magento/Checkout/Block/Cart/AbstractTest.php
+++ b/dev/tests/unit/testsuite/Magento/Checkout/Block/Cart/AbstractTest.php
@@ -25,7 +25,9 @@
class AbstractTest extends \PHPUnit_Framework_TestCase
{
- /** @var \Magento\TestFramework\Helper\ObjectManager */
+ /**
+ * @var \Magento\TestFramework\Helper\ObjectManager
+ */
protected $_objectManager;
protected function setUp()
@@ -35,92 +37,54 @@ protected function setUp()
public function testGetItemRenderer()
{
- $renderer = $this->getMock('Magento\View\Element\AbstractBlock', array('setRenderedBlock'), array(), '', false);
+ $renderer = $this->getMock('Magento\View\Element\RendererList', array(), array(), '', false);
+
+ $renderer->expects($this->once())->method('getRenderer')
+ ->with('some-type', AbstractCart::DEFAULT_TYPE)->will($this->returnValue('rendererObject'));
+
$layout = $this->getMock('Magento\Core\Model\Layout', array(
'getChildName', 'getBlock'
), array(), '', false);
- $layout->expects($this->at(0))
+
+ $layout->expects($this->once())
->method('getChildName')
- ->with(null, 'some-type')
- ->will($this->returnValue('some-block-name'));
- $layout->expects($this->at(1))
+ ->will($this->returnValue('renderer.list'));
+
+ $layout->expects($this->once())
->method('getBlock')
- ->with('some-block-name')
+ ->with('renderer.list')
->will($this->returnValue($renderer));
- /** @var $block \Magento\Checkout\Block\Cart\AbstractCart */
+ /** @var $block \Magento\Sales\Block\Items\AbstractItems */
$block = $this->_objectManager->getObject('Magento\Checkout\Block\Cart\AbstractCart', array(
'context' => $this->_objectManager->getObject('Magento\Backend\Block\Template\Context', array(
- 'layout' => $layout,
- ))
+ 'layout' => $layout,
+ ))
));
- $renderer->expects($this->once())
- ->method('setRenderedBlock')
- ->with($block);
-
- $this->assertSame($renderer, $block->getItemRenderer('some-type'));
+ $this->assertSame('rendererObject', $block->getItemRenderer('some-type'));
}
/**
* @expectedException \RuntimeException
- * @expectedExceptionMessage Renderer for type "some-type" does not exist.
+ * @expectedExceptionMessage Renderer list for block "" is not defined
*/
public function testGetItemRendererThrowsExceptionForNonexistentRenderer()
{
- $renderer = $this->getMock('StdClass');
$layout = $this->getMock('Magento\Core\Model\Layout', array(
'getChildName', 'getBlock'
), array(), '', false);
- $layout->expects($this->at(0))
- ->method('getChildName')
- ->with(null, 'some-type')
- ->will($this->returnValue('some-block-name'));
- $layout->expects($this->at(1))
- ->method('getBlock')
- ->with('some-block-name')
- ->will($this->returnValue($renderer));
-
- /** @var $block \Magento\Checkout\Block\Cart\AbstractCart */
- $block = $this->_objectManager->getObject('Magento\Checkout\Block\Cart\AbstractCart', array(
- 'context' => $this->_objectManager->getObject('Magento\Backend\Block\Template\Context', array(
- 'layout' => $layout,
- ))
- ));
-
- $block->getItemRenderer('some-type');
- }
-
- public function testPrepareLayout()
- {
- $childBlock = $this->getMock('Magento\View\Element\AbstractBlock', array(), array(), '', false);
- /** @var $layout \Magento\View\LayoutInterface */
- $layout = $this->getMock('Magento\Core\Model\Layout', array(
- 'createBlock', 'getChildName', 'setChild'
- ), array(), '', false);
$layout->expects($this->once())
- ->method('createBlock')
- ->with(
- 'Magento\Checkout\Block\Cart\Item\Renderer',
- '.default',
- array('data' => array('template' => 'cart/item/default.phtml'))
- )
- ->will($this->returnValue($childBlock));
- $layout->expects($this->any())
->method('getChildName')
- ->with(null, 'default')
- ->will($this->returnValue(false));
- $layout->expects($this->once())
- ->method('setChild')
- ->with(null, null, 'default');
+ ->will($this->returnValue(null));
/** @var $block \Magento\Checkout\Block\Cart\AbstractCart */
$block = $this->_objectManager->getObject('Magento\Checkout\Block\Cart\AbstractCart', array(
'context' => $this->_objectManager->getObject('Magento\Backend\Block\Template\Context', array(
- 'layout' => $layout,
- ))
+ 'layout' => $layout,
+ ))
));
- $block->setLayout($layout);
+ $block->getItemRenderer('some-type');
}
}
diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Block/Cart/SidebarTest.php b/dev/tests/unit/testsuite/Magento/Checkout/Block/Cart/SidebarTest.php
index f22fcc1913363..786bbfd2a2c1c 100644
--- a/dev/tests/unit/testsuite/Magento/Checkout/Block/Cart/SidebarTest.php
+++ b/dev/tests/unit/testsuite/Magento/Checkout/Block/Cart/SidebarTest.php
@@ -40,7 +40,17 @@ public function testDeserializeRenders()
$layout = $this->getMock('Magento\Core\Model\Layout', array(
'createBlock', 'getChildName', 'setChild'
), array(), '', false);
- $layout->expects($this->once())
+
+ $rendererList = $this->_objectManager->getObject('Magento\Checkout\Block\Cart\Sidebar', array(
+ 'context' => $this->_objectManager->getObject('Magento\Backend\Block\Template\Context', array(
+ 'layout' => $layout,
+ ))
+ ));;
+ $layout->expects($this->at(0))
+ ->method('createBlock')
+ ->with('Magento\View\Element\RendererList')
+ ->will($this->returnValue($rendererList));
+ $layout->expects($this->at(4))
->method('createBlock')
->with(
'some-block',
@@ -48,11 +58,11 @@ public function testDeserializeRenders()
array('data' => array('template' => 'some-type'))
)
->will($this->returnValue($childBlock));
- $layout->expects($this->any())
+ $layout->expects($this->at(5))
->method('getChildName')
->with(null, 'some-template')
->will($this->returnValue(false));
- $layout->expects($this->once())
+ $layout->expects($this->at(6))
->method('setChild')
->with(null, null, 'some-template');
diff --git a/dev/tests/unit/testsuite/Magento/Config/DomTest.php b/dev/tests/unit/testsuite/Magento/Config/DomTest.php
index 85a4b5718af6d..5183360eeb95e 100644
--- a/dev/tests/unit/testsuite/Magento/Config/DomTest.php
+++ b/dev/tests/unit/testsuite/Magento/Config/DomTest.php
@@ -40,10 +40,9 @@ public function testMerge($xmlFile, $newXmlFile, $ids, $expectedXmlFile)
{
$xml = file_get_contents(__DIR__ . "/_files/dom/{$xmlFile}");
$newXml = file_get_contents(__DIR__ . "/_files/dom/{$newXmlFile}");
- $expectedXml = file_get_contents(__DIR__ . "/_files/dom/{$expectedXmlFile}");
$config = new \Magento\Config\Dom($xml, $ids);
$config->merge($newXml);
- $this->assertXmlStringEqualsXmlString($expectedXml, $config->getDom()->saveXML());
+ $this->assertXmlStringEqualsXmlFile(__DIR__ . "/_files/dom/{$expectedXmlFile}", $config->getDom()->saveXML());
}
/**
@@ -62,41 +61,37 @@ public function mergeDataProvider()
),
array('no_ids.xml', 'no_ids_new.xml', array(), 'no_ids_merged.xml'),
array('ambiguous_one.xml', 'ambiguous_new_two.xml', array(), 'ambiguous_merged.xml'),
- array('namespaced.xml', 'namespaced_new.xml', array(
- '/root/node' => 'id',
- ),
- 'namespaced_merged.xml'
- ),
+ array('namespaced.xml', 'namespaced_new.xml', array('/root/node' => 'id'), 'namespaced_merged.xml'),
array('override_node.xml', 'override_node_new.xml', array(), 'override_node_merged.xml'),
array('override_node_new.xml', 'override_node.xml', array(), 'override_node_merged.xml'),
array('text_node.xml', 'text_node_new.xml', array(), 'text_node_merged.xml'),
+ array(
+ 'recursive.xml', 'recursive_new.xml', array(
+ '/root/(node|another_node)(/param)?' => 'name',
+ '/root/node/param(/complex/item)+' => 'key',
+ ),
+ 'recursive_merged.xml',
+ ),
+ array(
+ 'recursive_deep.xml', 'recursive_deep_new.xml',
+ array('/root(/node)+' => 'name'),
+ 'recursive_deep_merged.xml',
+ ),
);
}
/**
- * @param string $xmlFile
- * @param string $newXmlFile
- * @dataProvider mergeExceptionDataProvider
* @expectedException \Magento\Exception
+ * @expectedExceptionMessage More than one node matching the query: /root/node/subnode
*/
- public function testMergeException($xmlFile, $newXmlFile)
+ public function testMergeException()
{
- $xml = file_get_contents(__DIR__ . "/_files/dom/{$xmlFile}");
- $newXml = file_get_contents(__DIR__ . "/_files/dom/{$newXmlFile}");
- $config = new \Magento\Config\Dom($xml, array());
+ $xml = file_get_contents(__DIR__ . "/_files/dom/ambiguous_two.xml");
+ $newXml = file_get_contents(__DIR__ . "/_files/dom/ambiguous_new_one.xml");
+ $config = new \Magento\Config\Dom($xml);
$config->merge($newXml);
}
- /**
- * @return array
- */
- public function mergeExceptionDataProvider()
- {
- return array(
- array('ambiguous_two.xml', 'ambiguous_new_one.xml')
- );
- }
-
/**
* @param string $xml
* @param array $expectedErrors
diff --git a/dev/tests/unit/testsuite/Magento/Config/ThemeTest.php b/dev/tests/unit/testsuite/Magento/Config/ThemeTest.php
index 222d2563938d6..a36bcb50662b1 100644
--- a/dev/tests/unit/testsuite/Magento/Config/ThemeTest.php
+++ b/dev/tests/unit/testsuite/Magento/Config/ThemeTest.php
@@ -29,20 +29,9 @@
class ThemeTest extends \PHPUnit_Framework_TestCase
{
- /**
- * @expectedException \InvalidArgumentException
- */
- public function testConstructException()
- {
- new \Magento\Config\Theme(array());
- }
-
public function testGetSchemaFile()
{
- $config = new \Magento\Config\Theme(array(
- file_get_contents(sprintf('%s/_files/area/%s/theme.xml', __DIR__, 'default_default'))
- ));
-
+ $config = new \Magento\Config\Theme(file_get_contents(__DIR__ . '/_files/area/default_default/theme.xml'));
$this->assertFileExists($config->getSchemaFile());
}
@@ -53,9 +42,7 @@ public function testGetSchemaFile()
*/
public function testGetThemeTitle($themePath, $expected)
{
- $config = new \Magento\Config\Theme(array(
- file_get_contents(sprintf('%s/_files/area/%s/theme.xml', __DIR__, $themePath))
- ));
+ $config = new \Magento\Config\Theme(file_get_contents(__DIR__ . "/_files/area/$themePath/theme.xml"));
$this->assertSame($expected, $config->getThemeTitle());
}
@@ -77,9 +64,7 @@ public function getThemeTitleDataProvider()
*/
public function testGetParentTheme($themePath, $expected)
{
- $config = new \Magento\Config\Theme(array(
- file_get_contents(sprintf('%s/_files/area/%s/theme.xml', __DIR__, $themePath))
- ));
+ $config = new \Magento\Config\Theme(file_get_contents(__DIR__ . "/_files/area/$themePath/theme.xml"));
$this->assertSame($expected, $config->getParentTheme());
}
diff --git a/dev/tests/unit/testsuite/Magento/Config/ValidationStateTest.php b/dev/tests/unit/testsuite/Magento/Config/ValidationStateTest.php
index 5c623862626e5..7af38ade1b6fa 100644
--- a/dev/tests/unit/testsuite/Magento/Config/ValidationStateTest.php
+++ b/dev/tests/unit/testsuite/Magento/Config/ValidationStateTest.php
@@ -32,7 +32,7 @@ class ValidationStateTest extends \PHPUnit_Framework_TestCase
*/
public function testIsValidated($appMode, $expectedResult)
{
- $model = new \Magento\App\Config\ValidationState($appMode);
+ $model = new \Magento\App\Arguments\ValidationState($appMode);
$this->assertEquals($model->isValidated(), $expectedResult);
}
diff --git a/dev/tests/unit/testsuite/Magento/Config/_files/dom/recursive.xml b/dev/tests/unit/testsuite/Magento/Config/_files/dom/recursive.xml
new file mode 100644
index 0000000000000..0cb6154e25a7a
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Config/_files/dom/recursive.xml
@@ -0,0 +1,82 @@
+
+
+
+
+
+ scalar1
+
+
+
+ -
+ scalar2
+
+ -
+ scalar3
+
+
+
+
+
+
+
+ -
+
+
-
+ scalar4
+
+ -
+ scalar5
+
+
+
+ -
+
+
-
+ scalar6
+
+ -
+ scalar7
+
+
+
+ -
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+ scalar3
+
+
+
diff --git a/dev/tests/unit/testsuite/Magento/Config/_files/dom/recursive_deep.xml b/dev/tests/unit/testsuite/Magento/Config/_files/dom/recursive_deep.xml
new file mode 100644
index 0000000000000..ba6e0e9604717
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Config/_files/dom/recursive_deep.xml
@@ -0,0 +1,77 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dev/tests/unit/testsuite/Magento/Config/_files/dom/recursive_deep_merged.xml b/dev/tests/unit/testsuite/Magento/Config/_files/dom/recursive_deep_merged.xml
new file mode 100644
index 0000000000000..39500bd9d18d7
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Config/_files/dom/recursive_deep_merged.xml
@@ -0,0 +1,77 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dev/tests/unit/testsuite/Magento/Config/_files/dom/recursive_deep_new.xml b/dev/tests/unit/testsuite/Magento/Config/_files/dom/recursive_deep_new.xml
new file mode 100644
index 0000000000000..2104971cc401a
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Config/_files/dom/recursive_deep_new.xml
@@ -0,0 +1,76 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dev/tests/unit/testsuite/Magento/Config/_files/dom/recursive_merged.xml b/dev/tests/unit/testsuite/Magento/Config/_files/dom/recursive_merged.xml
new file mode 100644
index 0000000000000..82a7386edad50
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Config/_files/dom/recursive_merged.xml
@@ -0,0 +1,91 @@
+
+
+
+
+
+ scalar10
+
+
+
+ -
+ scalar20
+
+ -
+ scalar30
+
+ -
+ scalar41
+
+
+
+
+
+
+
+
+ -
+
+
-
+ scalar40
+
+ -
+ scalar50
+
+ -
+ scalar51
+
+
+
+ -
+
+
-
+ scalar60
+
+ -
+ scalar70
+
+
+
+ -
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+ scalar4
+
+
+
+
diff --git a/dev/tests/unit/testsuite/Magento/Config/_files/dom/recursive_new.xml b/dev/tests/unit/testsuite/Magento/Config/_files/dom/recursive_new.xml
new file mode 100644
index 0000000000000..cbb036e76a21a
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Config/_files/dom/recursive_new.xml
@@ -0,0 +1,96 @@
+
+
+
+
+
+
+ scalar10
+
+
+
+ -
+ scalar20
+
+ -
+ scalar30
+
+ -
+ scalar41
+
+
+
+
+
+
+
+
+ -
+
+
-
+ scalar40
+
+ -
+ scalar50
+
+ -
+ scalar51
+
+
+
+ -
+
+
-
+ scalar60
+
+ -
+ scalar70
+
+
+
+ -
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+ scalar4
+
+
+
diff --git a/dev/tests/unit/testsuite/Magento/Core/App/Action/Plugin/InstallTest.php b/dev/tests/unit/testsuite/Magento/Core/App/Action/Plugin/InstallTest.php
index 2bc25a4159ed2..13f6b3fea3483 100644
--- a/dev/tests/unit/testsuite/Magento/Core/App/Action/Plugin/InstallTest.php
+++ b/dev/tests/unit/testsuite/Magento/Core/App/Action/Plugin/InstallTest.php
@@ -54,7 +54,7 @@ protected function setUp()
{
$this->_appStateMock = $this->getMock('Magento\App\State', array(), array(), '', false);
$this->_response = $this->getMock('Magento\App\ResponseInterface', array('setRedirect', 'sendResponse'));
- $this->_urlMock = $this->getMock('Magento\Core\Model\Url', array(), array(), '', false);
+ $this->_urlMock = $this->getMock('Magento\Url', array(), array(), '', false);
$this->_invocationChainMock =
$this->getMock('Magento\Code\Plugin\InvocationChain', array(), array(), '', false);
$this->_plugin = new \Magento\Core\App\Action\Plugin\Install(
diff --git a/dev/tests/unit/testsuite/Magento/Core/App/Action/Plugin/LastUrlTest.php b/dev/tests/unit/testsuite/Magento/Core/App/Action/Plugin/LastUrlTest.php
index 46e4e6e6a0814..2fbafb2aad368 100644
--- a/dev/tests/unit/testsuite/Magento/Core/App/Action/Plugin/LastUrlTest.php
+++ b/dev/tests/unit/testsuite/Magento/Core/App/Action/Plugin/LastUrlTest.php
@@ -28,7 +28,7 @@ class LastUrlTest extends \PHPUnit_Framework_TestCase
public function testAfterDispatch()
{
$session = $this->getMock('\Magento\Core\Model\Session', array('setLastUrl'), array(), '', false);
- $url = $this->getMock('\Magento\Core\Model\Url', array(), array(), '', false);
+ $url = $this->getMock('\Magento\Url', array(), array(), '', false);
$plugin = new \Magento\Core\App\Action\Plugin\LastUrl($session, $url);
$session->expects($this->once())->method('setLastUrl')->with('http://example.com');
$invocationChainMock = $this->getMock('Magento\Code\Plugin\InvocationChain', array(), array(), '', false);
diff --git a/dev/tests/unit/testsuite/Magento/Core/App/FrontController/Plugin/RequestPreprocessorTest.php b/dev/tests/unit/testsuite/Magento/Core/App/FrontController/Plugin/RequestPreprocessorTest.php
index b41a21b2e3ce9..bc533ef0ea514 100644
--- a/dev/tests/unit/testsuite/Magento/Core/App/FrontController/Plugin/RequestPreprocessorTest.php
+++ b/dev/tests/unit/testsuite/Magento/Core/App/FrontController/Plugin/RequestPreprocessorTest.php
@@ -73,7 +73,7 @@ protected function setUp()
= $this->getMock('\Magento\Code\Plugin\InvocationChain', array(), array(), '', false);
$this->_storeManagerMock = $this->getMock('\Magento\Core\Model\StoreManager', array(), array(), '', false);
$this->_appStateMock = $this->getMock('\Magento\App\State', array(), array(), '', false);
- $this->_urlMock = $this->getMock('\Magento\Core\Model\Url', array(), array(), '', false);
+ $this->_urlMock = $this->getMock('\Magento\Url', array(), array(), '', false);
$this->_storeConfigMock = $this->getMock('\Magento\Core\Model\Store\Config', array(), array(), '', false);
$this->_model = new \Magento\Core\App\FrontController\Plugin\RequestPreprocessor(
diff --git a/dev/tests/unit/testsuite/Magento/Core/App/MediaTest.php b/dev/tests/unit/testsuite/Magento/Core/App/MediaTest.php
index 64e24261e47ba..b64408addf47c 100644
--- a/dev/tests/unit/testsuite/Magento/Core/App/MediaTest.php
+++ b/dev/tests/unit/testsuite/Magento/Core/App/MediaTest.php
@@ -140,7 +140,7 @@ public function testProcessRequestDoesNothingIfApplicationIsNotInstalled()
$this->_appState->expects($this->once())->method('isInstalled')->will($this->returnValue(false));
$this->_responseMock->expects($this->once())->method('setHttpResponseCode')->with(404);
$this->_requestMock->expects($this->never())->method('getPathInfo');
- $this->assertEquals($this->_responseMock, $this->_model->execute());
+ $this->assertEquals($this->_responseMock, $this->_model->launch());
}
public function testProcessRequestCreatesConfigFileMediaDirectoryIsNotProvided()
@@ -162,7 +162,7 @@ public function testProcessRequestCreatesConfigFileMediaDirectoryIsNotProvided()
->with('Magento\Core\Model\File\Storage\Config')
->will($this->returnValue($this->_configMock));
$this->_configMock->expects($this->once())->method('save');
- $this->assertEquals($this->_responseMock, $this->_model->execute());
+ $this->assertEquals($this->_responseMock, $this->_model->launch());
}
public function testProcessRequestReturnsNotFoundResponseIfResourceIsNotAllowed()
@@ -189,7 +189,7 @@ public function testProcessRequestReturnsNotFoundResponseIfResourceIsNotAllowed(
->with('Magento\Core\Model\File\Storage\Config')
->will($this->returnValue($this->_configMock));
$this->_configMock->expects($this->once())->method('getAllowedResources')->will($this->returnValue(false));
- $this->assertEquals($this->_responseMock, $this->_model->execute());
+ $this->assertEquals($this->_responseMock, $this->_model->launch());
}
@@ -200,7 +200,7 @@ public function testProcessRequestReturnsNotFoundIfFileIsNotAllowed()
$this->_requestMock->expects($this->once())->method('getPathInfo');
$this->_responseMock->expects($this->once())->method('setHttpResponseCode')->with(404);
$this->_requestMock->expects($this->never())->method('getFilePath');
- $this->assertEquals($this->_responseMock, $this->_model->execute());
+ $this->assertEquals($this->_responseMock, $this->_model->launch());
}
public function testProcessRequestReturnsFileIfItsProperlySynchronized()
@@ -227,7 +227,7 @@ public function testProcessRequestReturnsFileIfItsProperlySynchronized()
->expects($this->once())
->method('setFilePath')
->with($filePath);
- $this->assertEquals($this->_responseMock, $this->_model->execute());
+ $this->assertEquals($this->_responseMock, $this->_model->launch());
}
public function testProcessRequestReturnsNotFoundIfFileIsNotSynchronized()
@@ -239,6 +239,6 @@ public function testProcessRequestReturnsNotFoundIfFileIsNotSynchronized()
$this->_requestMock->expects($this->any())
->method('getFilePath')->will($this->returnValue('non_existing_file_name'));
$this->_responseMock->expects($this->once())->method('setHttpResponseCode')->with(404);
- $this->assertEquals($this->_responseMock, $this->_model->execute());
+ $this->assertEquals($this->_responseMock, $this->_model->launch());
}
}
diff --git a/dev/tests/unit/testsuite/Magento/Core/App/Request/RewriteServiceTest.php b/dev/tests/unit/testsuite/Magento/Core/App/Request/RewriteServiceTest.php
index 1513fb243af75..350c805fe03c4 100644
--- a/dev/tests/unit/testsuite/Magento/Core/App/Request/RewriteServiceTest.php
+++ b/dev/tests/unit/testsuite/Magento/Core/App/Request/RewriteServiceTest.php
@@ -52,7 +52,7 @@ class RewriteServiceTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
$this->_routerListMock = $this->getMock('\Magento\App\RouterList', array(), array(), '', false);
- $this->_configMock = $this->getMock('\Magento\Core\Model\Config', array(), array(), '', false);
+ $this->_configMock = $this->getMock('\Magento\App\ConfigInterface', array(), array(), '', false);
$this->_requestMock = $this->getMock('\Magento\App\Request\Http', array(), array(), '', false);
$this->_rewriteFactoryMock = $this->getMock(
'\Magento\Core\Model\Url\RewriteFactory', array('create'), array(), '', false
diff --git a/dev/tests/unit/testsuite/Magento/Core/Helper/ThemeTest.php b/dev/tests/unit/testsuite/Magento/Core/Helper/ThemeTest.php
index d8e03a009aa2b..7c2af83762c50 100644
--- a/dev/tests/unit/testsuite/Magento/Core/Helper/ThemeTest.php
+++ b/dev/tests/unit/testsuite/Magento/Core/Helper/ThemeTest.php
@@ -29,11 +29,11 @@
class ThemeTest extends \PHPUnit_Framework_TestCase
{
- const ROOT = '/zzz';
- const APP = '/zzz/qqq';
- const MODULES = '/zzz/qqq/code00';
- const THEMES = '/zzz/qqq/design00';
- const PUB_LIB = '/zzz/qqq/js00';
+ const ROOT_DIR = '/zzz';
+ const APP_DIR = '/zzz/qqq';
+ const MODULES_DIR = '/zzz/qqq/code00';
+ const THEMES_DIR = '/zzz/qqq/design00';
+ const PUB_LIB_DIR = '/zzz/qqq/js00';
/**
* @dataProvider getCssFilesDataProvider
@@ -492,11 +492,11 @@ protected function _getFilesystem()
$filesystem->expects($this->any())
->method('getPath')
->will($this->returnValueMap(array(
- array(\Magento\App\Filesystem::ROOT_DIR, self::ROOT),
- array(\Magento\App\Filesystem::APP_DIR, self::APP),
- array(\Magento\App\Filesystem::MODULES_DIR, self::MODULES),
- array(\Magento\App\Filesystem::THEMES_DIR, self::THEMES),
- array(\Magento\App\Filesystem::PUB_LIB_DIR, self::PUB_LIB),
+ array(\Magento\App\Filesystem::ROOT_DIR, self::ROOT_DIR),
+ array(\Magento\App\Filesystem::APP_DIR, self::APP_DIR),
+ array(\Magento\App\Filesystem::MODULES_DIR, self::MODULES_DIR),
+ array(\Magento\App\Filesystem::THEMES_DIR, self::THEMES_DIR),
+ array(\Magento\App\Filesystem::PUB_LIB_DIR, self::PUB_LIB_DIR),
)));
return $filesystem;
diff --git a/dev/tests/unit/testsuite/Magento/Core/Model/AppTest.php b/dev/tests/unit/testsuite/Magento/Core/Model/AppTest.php
deleted file mode 100644
index 7351d21af2542..0000000000000
--- a/dev/tests/unit/testsuite/Magento/Core/Model/AppTest.php
+++ /dev/null
@@ -1,260 +0,0 @@
-_configMock = $this->getMock('Magento\Core\Model\Config', array(), array(), '', false, false);
- $this->_cacheMock = $this->getMock('Magento\App\CacheInterface');
- $this->_objectManagerMock = $this->getMock('Magento\ObjectManager', array(), array(), '', false, false);
- $this->_storeManagerMock = $this->getMock('Magento\Core\Model\StoreManagerInterface');
- $this->_eventManagerMock = $this->getMock('Magento\Event\ManagerInterface');
- $this->_appStateMock = $this->getMock('Magento\App\State', array(), array(), '', false, false);
- $this->_configScopeMock = $this->getMock('Magento\Config\Scope', array(), array(), '', false);
- $this->_frontControllerMock = $this->getMock('Magento\App\FrontControllerInterface');
-
- $this->_model = new \Magento\Core\Model\App(
- $this->_configMock,
- $this->_cacheMock,
- $this->_objectManagerMock,
- $this->_storeManagerMock,
- $this->_eventManagerMock,
- $this->_appStateMock,
- $this->_configScopeMock,
- $this->_frontControllerMock
- );
- }
-
- protected function tearDown()
- {
- unset($this->_configMock);
- unset($this->_cacheMock);
- unset($this->_objectManagerMock);
- unset($this->_storeManagerMock);
- unset($this->_eventManagerMock);
- unset($this->_appStateMock);
- unset($this->_model);
- }
-
- public function testGetSafeStore()
- {
- $storeId = 'test';
- $this->_storeManagerMock->expects($this->once())
- ->method('getSafeStore')
- ->with($this->equalTo($storeId))
- ->will($this->returnValue('proxy_result'));
- $this->assertEquals('proxy_result', $this->_model->getSafeStore($storeId));
- }
-
- public function testSetIsSingleStoreModeAllowed()
- {
- $value = true;
- $this->_storeManagerMock->expects($this->once())
- ->method('setIsSingleStoreModeAllowed')
- ->with($this->equalTo($value));
- $this->_model->setIsSingleStoreModeAllowed($value);
- }
-
- public function testHasSingleStore()
- {
- $this->_storeManagerMock->expects($this->once())
- ->method('hasSingleStore')
- ->will($this->returnValue('proxy_result'));
- $this->assertEquals('proxy_result', $this->_model->hasSingleStore());
- }
-
- public function testIsSingleStoreMode()
- {
- $this->_storeManagerMock->expects($this->once())
- ->method('isSingleStoreMode')
- ->will($this->returnValue('proxy_result'));
- $this->assertEquals('proxy_result', $this->_model->isSingleStoreMode());
- }
-
- public function testThrowStoreException()
- {
- $this->_storeManagerMock->expects($this->once())
- ->method('throwStoreException');
- $this->_model->throwStoreException();
- }
-
- public function testGetStore()
- {
- $storeId = 'some_value';
- $this->_storeManagerMock->expects($this->once())
- ->method('getStore')
- ->with($this->equalTo($storeId))
- ->will($this->returnValue('proxy_result'));
- $this->assertEquals('proxy_result', $this->_model->getStore($storeId));
- }
-
- public function testGetStores()
- {
- $withDefault = true;
- $codeKey = true;
- $this->_storeManagerMock->expects($this->once())
- ->method('getStores')
- ->with($this->equalTo($withDefault),
- $this->equalTo($codeKey))
- ->will($this->returnValue('proxy_result'));
- $this->assertEquals('proxy_result', $this->_model->getStores($withDefault, $codeKey));
- }
-
- public function testGetWebsite()
- {
- $websiteId = 'some_value';
- $this->_storeManagerMock->expects($this->once())
- ->method('getWebsite')
- ->with($this->equalTo($websiteId))
- ->will($this->returnValue('proxy_result'));
- $this->assertEquals('proxy_result', $this->_model->getWebsite($websiteId));
- }
-
- public function testGetWebsites()
- {
- $withDefault = true;
- $codeKey = true;
- $this->_storeManagerMock->expects($this->once())
- ->method('getWebsites')
- ->with($this->equalTo($withDefault),
- $this->equalTo($codeKey))
- ->will($this->returnValue('proxy_result'));
- $this->assertEquals('proxy_result', $this->_model->getWebsites($withDefault, $codeKey));
- }
-
- public function testReinitStores()
- {
- $this->_storeManagerMock->expects($this->once())
- ->method('reinitStores');
- $this->_model->reinitStores();
- }
-
- public function testSetCurrentStore()
- {
- $store = 'Test';
- $this->_storeManagerMock->expects($this->once())
- ->method('setCurrentStore')
- ->with($this->equalTo($store));
- $this->_model->setCurrentStore($store);
- }
-
- public function testGetDefaultStoreView()
- {
- $this->_storeManagerMock->expects($this->once())
- ->method('getDefaultStoreView')
- ->will($this->returnValue('proxy_result'));
- $this->assertEquals('proxy_result', $this->_model->getDefaultStoreView());
- }
-
- public function testGetGroup()
- {
- $groupId = 'test';
- $this->_storeManagerMock->expects($this->once())
- ->method('getGroup')
- ->will($this->returnValue('proxy_result'))
- ->with($this->equalTo($groupId));
- $this->assertEquals('proxy_result', $this->_model->getGroup($groupId));
- }
-
- public function testGetGroups()
- {
- $withDefault = true;
- $codeKey = true;
- $this->_storeManagerMock->expects($this->once())
- ->method('getGroups')
- ->with($this->equalTo($withDefault),
- $this->equalTo($codeKey))
- ->will($this->returnValue('proxy_result'));
- $this->assertEquals('proxy_result', $this->_model->getGroups($withDefault, $codeKey));
- }
-
- public function testClearWebsiteCache()
- {
- $websiteId = 'Test';
- $this->_storeManagerMock->expects($this->once())
- ->method('clearWebsiteCache')
- ->with($this->equalTo($websiteId));
- $this->_model->clearWebsiteCache($websiteId);
- }
-
- public function testGetAnyStoreView()
- {
- $this->_storeManagerMock->expects($this->once())
- ->method('getAnyStoreView')
- ->will($this->returnValue('proxy_result'));
- $this->assertEquals('proxy_result', $this->_model->getAnyStoreView());
- }
-}
diff --git a/dev/tests/unit/testsuite/Magento/Core/Model/File/Storage/Directory/DatabaseTest.php b/dev/tests/unit/testsuite/Magento/Core/Model/File/Storage/Directory/DatabaseTest.php
index 1727a60f65c9a..04013acc91bfa 100644
--- a/dev/tests/unit/testsuite/Magento/Core/Model/File/Storage/Directory/DatabaseTest.php
+++ b/dev/tests/unit/testsuite/Magento/Core/Model/File/Storage/Directory/DatabaseTest.php
@@ -73,7 +73,7 @@ class DatabaseTest extends \PHPUnit_Framework_TestCase
protected $directoryFactoryMock;
/**
- * @var \Magento\Core\Model\Config |\PHPUnit_Framework_MockObject_MockObject
+ * @var \Magento\App\ConfigInterface |\PHPUnit_Framework_MockObject_MockObject
*/
protected $configMock;
@@ -109,7 +109,7 @@ protected function setUp()
array('setPath', 'setName', '__wakeup', 'save', 'getParentId'), array(), '', false);
$this->directoryFactoryMock = $this->getMock('Magento\Core\Model\File\Storage\Directory\DatabaseFactory',
array('create'), array(), '', false);
- $this->configMock = $this->getMock('Magento\Core\Model\Config', array(), array(), '', false);
+ $this->configMock = $this->getMock('Magento\App\ConfigInterface', array(), array(), '', false);
$this->resourceDirectoryDatabaseMock =
$this->getMock('Magento\Core\Model\Resource\File\Storage\Directory\Database', array(), array(), '', false);
$this->loggerMock = $this->getMock('Magento\Logger', array(), array(), '', false);
diff --git a/dev/tests/unit/testsuite/Magento/Core/Model/Layout/Argument/Handler/UrlTest.php b/dev/tests/unit/testsuite/Magento/Core/Model/Layout/Argument/Handler/UrlTest.php
index 64f0877322b85..6b51e227481d1 100644
--- a/dev/tests/unit/testsuite/Magento/Core/Model/Layout/Argument/Handler/UrlTest.php
+++ b/dev/tests/unit/testsuite/Magento/Core/Model/Layout/Argument/Handler/UrlTest.php
@@ -45,7 +45,7 @@ class UrlTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
$helperObjectManager = new \Magento\TestFramework\Helper\ObjectManager($this);
- $this->_urlModleMock = $this->getMock('Magento\Core\Model\Url', array(), array(), '', false);
+ $this->_urlModleMock = $this->getMock('Magento\Url', array(), array(), '', false);
$this->_model = $helperObjectManager->getObject(
'Magento\Core\Model\Layout\Argument\Handler\Url',
array('urlModel' => $this->_urlModleMock)
diff --git a/dev/tests/unit/testsuite/Magento/Core/Model/Layout/_files/merged.xml b/dev/tests/unit/testsuite/Magento/Core/Model/Layout/_files/merged.xml
index aeaa907a9faef..13b2b71bc579d 100644
--- a/dev/tests/unit/testsuite/Magento/Core/Model/Layout/_files/merged.xml
+++ b/dev/tests/unit/testsuite/Magento/Core/Model/Layout/_files/merged.xml
@@ -34,7 +34,6 @@
-
diff --git a/dev/tests/unit/testsuite/Magento/Core/Model/ObserverTest.php b/dev/tests/unit/testsuite/Magento/Core/Model/ObserverTest.php
index 3199eb3597768..e428c3f587c8d 100644
--- a/dev/tests/unit/testsuite/Magento/Core/Model/ObserverTest.php
+++ b/dev/tests/unit/testsuite/Magento/Core/Model/ObserverTest.php
@@ -108,7 +108,7 @@ protected function setUp()
$this->_assetsMock = $this->getMock('Magento\View\Asset\GroupedCollection',
array(), array(), '', false, false);
- $this->_configMock = $this->getMock('Magento\Core\Model\ConfigInterface',
+ $this->_configMock = $this->getMock('\Magento\App\ReinitableConfigInterface',
array(), array(), '', false, false);
$this->_assetFactory = $this->getMock('Magento\View\Asset\PublicFileFactory',
diff --git a/dev/tests/unit/testsuite/Magento/Core/Model/ReinitableConfigTest.php b/dev/tests/unit/testsuite/Magento/Core/Model/ReinitableConfigTest.php
new file mode 100644
index 0000000000000..d63f8857368e9
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Core/Model/ReinitableConfigTest.php
@@ -0,0 +1,42 @@
+getMock('\Magento\Core\Model\Config\SectionPool', ['clean'], array(), '', false);
+ $sectionPool->expects($this->once())
+ ->method('clean');
+ /** @var \Magento\Core\Model\ReinitableConfig $config */
+ $config = $helper->getObject('Magento\Core\Model\ReinitableConfig', ['sectionPool' => $sectionPool]);
+ $this->assertInstanceOf('\Magento\App\ReinitableConfigInterface', $config->reinit());
+ }
+}
diff --git a/dev/tests/unit/testsuite/Magento/Core/Model/Resource/Setup/MigrationTest.php b/dev/tests/unit/testsuite/Magento/Core/Model/Resource/Setup/MigrationTest.php
index 357f5f052a90b..00fa71b1345b3 100644
--- a/dev/tests/unit/testsuite/Magento/Core/Model/Resource/Setup/MigrationTest.php
+++ b/dev/tests/unit/testsuite/Magento/Core/Model/Resource/Setup/MigrationTest.php
@@ -245,7 +245,7 @@ public function testDoUpdateClassAliases($replaceRules, $tableData, $expected, $
$this->getMock('Magento\Core\Helper\Data', array(), array(), '', false),
$this->getMock('Magento\Logger', array(), array(), '', false),
$this->getMock('Magento\Event\ManagerInterface', array(), array(), '', false),
- $this->getMock('Magento\Core\Model\Config', array(), array(), '', false, false),
+ $this->getMock('Magento\App\ConfigInterface', array(), array(), '', false, false),
$this->getMock('Magento\Module\ModuleListInterface'),
$this->getMock('Magento\Module\Dir\Reader', array(), array(), '', false, false),
$this->getMock('Magento\Core\Model\Resource\Resource', array(), array(), '', false),
diff --git a/dev/tests/unit/testsuite/Magento/Core/Model/Store/StorageFactoryTest.php b/dev/tests/unit/testsuite/Magento/Core/Model/Store/StorageFactoryTest.php
index 027c8435a329b..eab9a45d7dda0 100644
--- a/dev/tests/unit/testsuite/Magento/Core/Model/Store/StorageFactoryTest.php
+++ b/dev/tests/unit/testsuite/Magento/Core/Model/Store/StorageFactoryTest.php
@@ -54,7 +54,7 @@ class StorageFactoryTest extends \PHPUnit_Framework_TestCase
/**
* @var \PHPUnit_Framework_MockObject_MockObject
*/
- protected $_appMock;
+ protected $_sidResolverMock;
/**
* @var \PHPUnit_Framework_MockObject_MockObject
@@ -87,8 +87,8 @@ protected function setUp()
$this->_objectManagerMock = $this->getMock('Magento\ObjectManager');
$this->_eventManagerMock = $this->getMock('Magento\Event\ManagerInterface', array(), array(), '', false);
$this->_logMock = $this->getMock('Magento\Logger', array(), array(), '', false);
- $this->_appMock
- = $this->getMock('\Magento\Core\Model\AppInterface');
+ $this->_sidResolverMock
+ = $this->getMock('\Magento\Session\SidResolverInterface', array(), array(), '', false);
$this->_appStateMock = $this->getMock('Magento\App\State', array(), array(), '', false);
$this->_storage = $this->getMock('Magento\Core\Model\Store\StorageInterface');
@@ -96,7 +96,7 @@ protected function setUp()
$this->_objectManagerMock,
$this->_eventManagerMock,
$this->_logMock,
- $this->_appMock,
+ $this->_sidResolverMock,
$this->_appStateMock,
$this->_defaultStorage,
$this->_dbStorage
@@ -115,7 +115,7 @@ public function testGetInNotInstalledModeWithInternalCache()
$this->_eventManagerMock->expects($this->never())->method('dispatch');
$this->_logMock->expects($this->never())->method('initForStore');
- $this->_appMock->expects($this->never())->method('setUseSessionInUrl');
+ $this->_sidResolverMock->expects($this->never())->method('setUseSessionInUrl');
/** test create instance */
$this->assertEquals($this->_storage, $this->_model->get($this->_arguments));
@@ -159,7 +159,7 @@ public function testGetInstalledModeWithInternalCache()
->expects($this->exactly(2))
->method('addStreamLog');
- $this->_appMock->expects($this->once())
+ $this->_sidResolverMock->expects($this->once())
->method('setUseSessionInUrl')->with(true);
/** test create instance */
@@ -186,7 +186,7 @@ public function testGetWithInvalidStorageClassName()
$this->_eventManagerMock->expects($this->never())->method('dispatch');
$this->_logMock->expects($this->never())->method('initForStore');
- $this->_appMock->expects($this->never())->method('setUseSessionInUrl');
+ $this->_sidResolverMock->expects($this->never())->method('setUseSessionInUrl');
/** test create instance */
$this->assertEquals($this->_storage, $this->_model->get($this->_arguments));
diff --git a/dev/tests/unit/testsuite/Magento/Core/Model/Url/ScopeResolverTest.php b/dev/tests/unit/testsuite/Magento/Core/Model/Url/ScopeResolverTest.php
new file mode 100644
index 0000000000000..13c0e4730dfc4
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Core/Model/Url/ScopeResolverTest.php
@@ -0,0 +1,90 @@
+_storeManagerMock = $this->getMockBuilder('Magento\Core\Model\StoreManagerInterface')
+ ->getMock();
+ $this->_object = $objectManager->getObject('Magento\Core\Model\Url\ScopeResolver', array(
+ 'storeManager' => $this->_storeManagerMock)
+ );
+ }
+
+ /**
+ * @dataProvider getScopeDataProvider
+ * @param int|null$scopeId
+ */
+ public function testGetScope($scopeId)
+ {
+ $scopeMock = $this->getMockBuilder('\Magento\Url\ScopeInterface')->getMock();
+ $this->_storeManagerMock->expects($this->at(0))
+ ->method('getStore')
+ ->with($scopeId)
+ ->will($this->returnValue($scopeMock));
+ $this->_object->getScope($scopeId);
+ }
+
+ /**
+ * @expectedException \Magento\Exception
+ * @expectedExceptionMessage Invalid scope object
+ */
+ public function testGetScopeException()
+ {
+ $this->_object->getScope();
+ }
+
+ /**
+ * @return array
+ */
+ public function getScopeDataProvider()
+ {
+ return array(
+ array(null),
+ array(1),
+ );
+ }
+
+ public function testGetScopes()
+ {
+ $this->_storeManagerMock->expects($this->once())
+ ->method('getStores');
+ $this->_object->getScopes();
+ }
+}
diff --git a/dev/tests/unit/testsuite/Magento/Core/Model/UrlTest.php b/dev/tests/unit/testsuite/Magento/Core/Model/UrlTest.php
deleted file mode 100644
index efa0739c608de..0000000000000
--- a/dev/tests/unit/testsuite/Magento/Core/Model/UrlTest.php
+++ /dev/null
@@ -1,153 +0,0 @@
-_objectManager = new \Magento\TestFramework\Helper\ObjectManager($this);
- $this->_model = $this->_objectManager->getObject('\Magento\Core\Model\Url');
- }
-
- public function testSetRoutePath()
- {
- $moduleFrontName = 'moduleFrontName';
- $controllerName = 'controllerName';
- $actionName = 'actionName';
-
- $this->assertNull($this->_model->getRouteName());
- $this->assertNull($this->_model->getControllerName());
- $this->assertNull($this->_model->getActionName());
-
- $this->_model->setRoutePath($moduleFrontName . '/' . $controllerName . '/' . $actionName);
-
- $this->assertNotNull($this->_model->getRouteName());
- $this->assertEquals($moduleFrontName, $this->_model->getRouteName());
-
- $this->assertNotNull($this->_model->getControllerName());
- $this->assertEquals($controllerName, $this->_model->getControllerName());
-
- $this->assertNotNull($this->_model->getActionName());
- $this->assertEquals($actionName, $this->_model->getActionName());
- }
-
- public function testSetRoutePathWhenAsteriskUses()
- {
- $moduleFrontName = 'moduleFrontName';
- $controllerName = 'controllerName';
- $actionName = 'actionName';
-
- $requestMock = $this->getMockForAbstractClass(
- 'Magento\App\Request\Http',
- array(),
- '',
- false,
- false,
- true,
- array('getRequestedRouteName', 'getRequestedControllerName', 'getRequestedActionName')
- );
-
- $requestMock->expects($this->once())->method('getRequestedRouteName')
- ->will($this->returnValue($moduleFrontName));
- $requestMock->expects($this->once())->method('getRequestedControllerName')
- ->will($this->returnValue($controllerName));
- $requestMock->expects($this->once())->method('getRequestedActionName')
- ->will($this->returnValue($actionName));
-
- $this->_model->setRequest($requestMock);
-
- $this->_model->setRoutePath('*/*/*');
-
- $this->assertEquals($moduleFrontName, $this->_model->getRouteName());
- $this->assertEquals($controllerName, $this->_model->getControllerName());
- $this->assertEquals($actionName, $this->_model->getActionName());
- }
-
- public function testSetRoutePathWhenRouteParamsExists()
- {
- $this->assertNull($this->_model->getControllerName());
- $this->assertNull($this->_model->getActionName());
-
- $this->_model->setRoutePath('m/c/a/p1/v1/p2/v2');
-
- $this->assertNotNull($this->_model->getControllerName());
- $this->assertNotNull($this->_model->getActionName());
- $this->assertNotEmpty($this->_model->getRouteParams());
-
- $this->assertArrayHasKey('p1', $this->_model->getRouteParams());
- $this->assertArrayHasKey('p2', $this->_model->getRouteParams());
-
- $this->assertEquals('v1', $this->_model->getRouteParam('p1'));
- $this->assertEquals('v2', $this->_model->getRouteParam('p2'));
- }
-
- /**
- * @param $port mixed
- * @param $url string
- * @dataProvider getCurrentUrlProvider
- */
- public function testGetCurrentUrl($port, $url)
- {
- $methods = array('getServer', 'getScheme', 'getHttpHost', 'getModuleName', 'setModuleName',
- 'getActionName', 'setActionName', 'getParam');
- $requestMock = $this->getMock('\Magento\App\RequestInterface', $methods);
- $requestMock->expects($this->at(0))->method('getServer')->with('SERVER_PORT')
- ->will($this->returnValue($port));
- $requestMock->expects($this->at(1))->method('getServer')->with('REQUEST_URI')
- ->will($this->returnValue('/fancy_uri'));
- $requestMock->expects($this->once())->method('getScheme')->will($this->returnValue('http'));
- $requestMock->expects($this->once())->method('getHttpHost')->will($this->returnValue('example.com'));
-
- /** @var \Magento\Core\Model\Url $model */
- $model = $this->_objectManager->getObject('Magento\Core\Model\Url', array('request' => $requestMock));
- $this->assertEquals($url, $model->getCurrentUrl());
- }
-
- public function getCurrentUrlProvider()
- {
- return array(
- 'without_port' => array('', 'http://example.com/fancy_uri'),
- 'default_port' => array(80, 'http://example.com/fancy_uri'),
- 'custom_port' => array(8080, 'http://example.com:8080/fancy_uri')
- );
- }
-}
diff --git a/dev/tests/unit/testsuite/Magento/Cron/App/Cron/Plugin/ApplicationInitializerTest.php b/dev/tests/unit/testsuite/Magento/Cron/App/Cron/Plugin/ApplicationInitializerTest.php
index 2a7f358afa0ae..c4c27b9600e13 100644
--- a/dev/tests/unit/testsuite/Magento/Cron/App/Cron/Plugin/ApplicationInitializerTest.php
+++ b/dev/tests/unit/testsuite/Magento/Cron/App/Cron/Plugin/ApplicationInitializerTest.php
@@ -35,18 +35,25 @@ class ApplicationInitializerTest extends \PHPUnit_Framework_TestCase
*/
protected $_applicationMock;
+ /**
+ * @var \PHPUnit_Framework_MockObject_MockObject
+ */
+ protected $_sidResolverMock;
+
protected function setUp()
{
- $this->_applicationMock = $this->getMock('Magento\Core\Model\AppInterface');
+ $this->_applicationMock = $this->getMock('Magento\AppInterface');
+ $this->_sidResolverMock = $this->getMock('\Magento\Session\SidResolverInterface', array(), array(), '', false);
$this->_model = new ApplicationInitializer(
- $this->_applicationMock
+ $this->_applicationMock,
+ $this->_sidResolverMock
);
}
public function testBeforeExecutePerformsRequiredChecks()
{
$this->_applicationMock->expects($this->once())->method('requireInstalledInstance');
- $this->_applicationMock->expects($this->once())->method('setUseSessionInUrl')->with(false);
+ $this->_sidResolverMock->expects($this->once())->method('setUseSessionInUrl')->with(false);
$this->_model->beforeExecute(array());
}
}
diff --git a/dev/tests/unit/testsuite/Magento/Customer/Controller/Adminhtml/IndexTest.php b/dev/tests/unit/testsuite/Magento/Customer/Controller/Adminhtml/IndexTest.php
index 22c702a5585a4..8e4769018e72d 100644
--- a/dev/tests/unit/testsuite/Magento/Customer/Controller/Adminhtml/IndexTest.php
+++ b/dev/tests/unit/testsuite/Magento/Customer/Controller/Adminhtml/IndexTest.php
@@ -247,7 +247,7 @@ public function testResetPasswordActionSendEmail()
->method('generateResetPasswordLinkToken')
->will($this->returnValue($token));
- $coreHelperMock = $this->getMockBuilder('Magento\Core\Model\Url')
+ $coreHelperMock = $this->getMockBuilder('Magento\Url')
->disableOriginalConstructor()
->setMethods(array('getUrl', '__wakeup'))
->getMock();
@@ -265,7 +265,7 @@ public function testResetPasswordActionSendEmail()
$this->_objectManager->expects($this->at(2))
->method('create')
- ->with($this->equalTo('Magento\Core\Model\Url'))
+ ->with($this->equalTo('Magento\UrlInterface'))
->will($this->returnValue($coreHelperMock));
$this->messageManager->expects($this->once())
diff --git a/dev/tests/unit/testsuite/Magento/Customer/Service/CustomerTest.php b/dev/tests/unit/testsuite/Magento/Customer/Service/CustomerTest.php
deleted file mode 100644
index 065658c71339e..0000000000000
--- a/dev/tests/unit/testsuite/Magento/Customer/Service/CustomerTest.php
+++ /dev/null
@@ -1,696 +0,0 @@
-_helperMock = $this->getMockBuilder('Magento\Customer\Helper\Data')
- ->disableOriginalConstructor()
- ->setMethods(array('generateResetPasswordLinkToken'))
- ->getMock();
-
- $this->_customerFactory = $this->getMockBuilder('Magento\Customer\Model\CustomerFactory')
- ->disableOriginalConstructor()
- ->setMethods(array('create'))
- ->getMock();
- $this->_addressFactory = $this->getMockBuilder('Magento\Customer\Model\AddressFactory')
- ->disableOriginalConstructor()
- ->setMethods(array('create'))
- ->getMock();
-
- $this->_customer = $this->getMockBuilder('Magento\Customer\Model\Customer')
- ->setMethods(array('save', 'generatePassword', 'getOrigData', 'sendNewAccountEmail', 'getConfirmation',
- 'getPrimaryAddress', 'getAddresses', 'getAdditionalAddresses', 'load', 'getId', 'changePassword',
- 'sendPasswordReminderEmail', 'addAddress', 'getAddressItemById', 'getAddressesCollection',
- 'hashPassword', 'changeResetPasswordLinkToken', '__wakeup')
- )
- ->disableOriginalConstructor()
- ->getMock();
-
- $this->_customerFactory->expects($this->any())
- ->method('create')
- ->will($this->returnValue($this->_customer));
-
- $this->_address = $this->_createAddress(true, null);
- $this->_addressFactory->expects($this->any())
- ->method('create')
- ->will($this->returnValue($this->_address));
-
- $this->_service = new \Magento\Customer\Service\Customer($this->_helperMock, $this->_customerFactory,
- $this->_addressFactory
- );
- }
-
- /**
- * Create mock address for use in tests
- *
- * @param bool $hasChanges
- * @param int $addressId
- * @return \PHPUnit_Framework_MockObject_MockObject
- */
- protected function _createAddress($hasChanges, $addressId)
- {
- $address = $this->getMockBuilder('Magento\Customer\Model\Address')
- ->disableOriginalConstructor()
- ->setMethods(array('hasDataChanges', 'getId', 'addData', 'setData', 'setCustomerId', 'setPostIndex',
- '__sleep', '__wakeup'))
- ->getMock();
- $address->expects($this->any())
- ->method('hasDataChanges')
- ->will($this->returnValue($hasChanges));
- if ($addressId) {
- $address->expects($this->any())
- ->method('getId')
- ->will($this->returnValue($addressId));
- }
- return $address;
- }
-
- protected function tearDown()
- {
- unset($this->_service);
- }
-
- /**
- * Test for setSendRemainderEmail
- *
- * @param bool $set
- * @param bool $expected
- * @dataProvider setSendRemainderDataProvider
- */
- public function testSetSendRemainderEmail($set, $expected)
- {
- $this->_service->setSendRemainderEmail($set);
- $this->assertAttributeEquals($expected, '_sendRemainderEmail', $this->_service);
- }
-
- /**
- * @return array
- */
- public function setSendRemainderDataProvider()
- {
- return array(
- array(true, true),
- array(false, false)
- );
- }
-
- /**
- * Test beforeSave and afterSave callback are set correctly
- */
- public function testSetBeforeSaveCallback()
- {
- $this->assertInstanceOf('Magento\Customer\Service\Customer', $this->_service->setBeforeSaveCallback('intval'));
- $this->assertAttributeEquals('intval', '_beforeSaveCallback', $this->_service);
- }
-
- /**
- * Check beforeSave and afterSave callbacks for create and update methods
- *
- * @param string $method
- * @dataProvider methodsDataProvider
- */
- public function testCallback($method)
- {
- $customerData = array('firstname' => 'test');
- $addressData = null;
- $callback = $this->getMockBuilder('stdClass')
- ->setMethods(array('beforeSave', 'afterSave'))
- ->getMock();
- $callback->expects($this->once())
- ->method('beforeSave')
- ->with($this->_customer, $customerData, $addressData);
- $callback->expects($this->once())
- ->method('afterSave')
- ->with($this->_customer, $customerData, $addressData);
-
- $this->_service->setBeforeSaveCallback(array($callback, 'beforeSave'));
- $this->_service->setAfterSaveCallback(array($callback, 'afterSave'));
- if ($method == 'create') {
- $this->assertInstanceOf('Magento\Customer\Model\Customer',
- $this->_service->create($customerData, $addressData));
- } else {
- $this->_customer->expects($this->once())
- ->method('getId')
- ->will($this->returnValue(1));
- $this->assertInstanceOf('Magento\Customer\Model\Customer',
- $this->_service->update(1, $customerData, $addressData));
- }
- }
-
- /**
- * @return array
- */
- public function methodsDataProvider()
- {
- return array(
- array('create'),
- array('update')
- );
- }
-
- public function testSetAfterSaveCallback()
- {
- $this->assertInstanceOf('Magento\Customer\Service\Customer', $this->_service->setAfterSaveCallback('intval'));
- $this->assertAttributeEquals('intval', '_afterSaveCallback', $this->_service);
- }
-
- /**
- * Test setIsAdminStore setter
- */
- public function testSetIsAdminStore()
- {
- $this->assertInstanceOf('Magento\Customer\Service\Customer', $this->_service->setIsAdminStore(true));
- $this->assertAttributeEquals(true, '_isAdminStore', $this->_service);
- }
-
- /**
- * @param bool $isAdminStore
- * @param array $customerData
- * @param array $expectedData
- * @dataProvider forceConfirmedDataProvider
- */
- public function testCreateForceConfirmed($isAdminStore, array $customerData, array $expectedData)
- {
- if (array_key_exists('autogenerate_password', $customerData)) {
- $this->_customer->expects($this->once())
- ->method('generatePassword')
- ->will($this->returnValue('generated_password'));
- }
-
- $this->_customer->expects($this->once())
- ->method('save');
-
- $this->_service->setIsAdminStore($isAdminStore);
- $this->assertInstanceOf('Magento\Customer\Model\Customer',
- $this->_service->create($customerData));
- $this->assertEquals($expectedData, $this->_customer->toArray(array_keys($expectedData)));
- }
-
- /**
- * @return array
- */
- public function forceConfirmedDataProvider()
- {
- return array(
- 'force confirmed not set #1' => array(
- 'isAdminStore' => false,
- 'customerData' => array(
- 'password' => '123123q'
- ),
- 'expectedData' => array(
- 'password' => '123123q',
- 'force_confirmed' => null
- ),
- ),
- 'force confirmed not set #2' => array(
- 'isAdminStore' => true,
- 'customerData' => array(),
- 'expectedData' => array(
- 'force_confirmed' => null
- ),
- ),
- 'force confirmed is set' => array(
- 'isAdminStore' => true,
- 'customerData' => array(
- 'password' => '123123q'
- ),
- 'expectedData' => array(
- 'password' => '123123q',
- 'force_confirmed' => true
- ),
- ),
- 'auto generated password' => array(
- 'isAdminStore' => true,
- 'customerData' => array(
- 'autogenerate_password' => true
- ),
- 'expectedData' => array(
- 'password' => 'generated_password',
- 'force_confirmed' => true
- ),
- )
- );
- }
-
- /**
- * @param array $customerData
- * @param string $type
- * @param int|null $origId
- * @dataProvider welcomeEmailDataProvider
- */
- public function testSendWelcomeEmail(array $customerData, $type, $origId)
- {
- $this->_customer->expects($this->once())
- ->method('sendNewAccountEmail')
- ->with($type, '', $customerData['sendemail_store_id']);
- $this->_customer->expects($this->once())
- ->method('save');
- $this->_customer->expects($this->once())
- ->method('getOrigData')
- ->will($this->returnValue($origId));
- $this->_customer->expects($this->any())
- ->method('getConfirmation')
- ->will($this->returnValue(false));
-
- $this->assertInstanceOf('Magento\Customer\Model\Customer', $this->_service->create($customerData));
- }
-
- /**
- * Test that email is send for registered users
- */
- public function testSendWelcomeEmailRegistered()
- {
- $storeId = 1;
- $type = 'registered';
- $customerData = array(
- 'sendemail_store_id' => $storeId,
- 'website_id' => 1,
- 'sendemail' => true,
- 'autogenerate_password' => true
- );
- $hash = 1234567890;
-
- $this->_customer->expects($this->once())
- ->method('sendNewAccountEmail')
- ->with($type, '', $storeId);
- $this->_customer->expects($this->once())
- ->method('save');
- $this->_customer->expects($this->any())
- ->method('getOrigData')
- ->with($this->equalTo('id'))
- ->will($this->returnValue(false));
-
- $this->_helperMock->expects($this->once())
- ->method('generateResetPasswordLinkToken')
- ->will($this->returnValue($hash));
-
- $this->_customer->expects($this->once())->method('changeResetPasswordLinkToken')->with($this->equalTo($hash));
- $this->_customer->expects($this->once())
- ->method('sendNewAccountEmail')
- ->with(
- $this->equalTo($type),
- $this->equalTo(''),
- $this->equalTo($storeId)
- );
-
- $this->assertInstanceOf('Magento\Customer\Model\Customer', $this->_service->create($customerData));
- }
-
- /**
- * Test that email is send in case when user is confirmed
- */
- public function testSendWelcomeEmailConfirmed()
- {
- $storeId = 1;
- $type = 'confirmed';
- $customerData = array(
- 'sendemail_store_id' => $storeId,
- 'website_id' => 1,
- 'sendemail' => true,
- 'autogenerate_password' => true
- );
-
- $this->_customer->expects($this->once())
- ->method('sendNewAccountEmail')
- ->with($type, '', $storeId);
- $this->_customer->expects($this->once())
- ->method('save');
- $this->_customer->expects($this->any())
- ->method('getOrigData')
- ->with($this->equalTo('id'))
- ->will($this->returnValue(true));
-
- $this->_customer->expects($this->once())
- ->method('sendNewAccountEmail')
- ->with(
- $this->equalTo($type),
- $this->equalTo(''),
- $this->equalTo($storeId)
- );
-
- $this->assertInstanceOf('Magento\Customer\Model\Customer', $this->_service->create($customerData));
- }
-
- /**
- * @return array
- */
- public function welcomeEmailDataProvider()
- {
- return array(
- 'new customer new password' => array(
- array(
- 'sendemail_store_id' => 1,
- 'website_id' => 1,
- 'sendemail' => true
- ),
- 'registered',
- null
- ),
- 'new customer auto generated password' => array(
- array(
- 'sendemail_store_id' => 1,
- 'website_id' => 1,
- 'autogenerate_password' => true
- ),
- 'registered',
- null
- ),
- 'existing customer new password' => array(
- array(
- 'sendemail_store_id' => 1,
- 'website_id' => 1,
- 'sendemail' => true
- ),
- 'confirmed',
- 1
- ),
- 'existing customer auto generated password' => array(
- array(
- 'sendemail_store_id' => 1,
- 'website_id' => 1,
- 'autogenerate_password' => true
- ),
- 'confirmed',
- 1
- ),
- );
- }
-
- /**
- * @param array $customerData
- * @param int|null $origId
- * @dataProvider welcomeEmailNotCalledDataProvider
- */
- public function testSendWelcomeEmailNotCalled(array $customerData, $origId)
- {
- $this->_customer->expects($this->never())
- ->method('sendNewAccountEmail');
- $this->_customer->expects($this->once())
- ->method('save');
- $this->_customer->expects($this->any())
- ->method('getOrigData')
- ->will($this->returnValue($origId));
- if (array_key_exists('confirmation', $customerData)) {
- $this->_customer->expects($this->any())
- ->method('getConfirmation')
- ->will($this->returnValue($customerData['confirmation']));
- }
-
- $this->assertInstanceOf('Magento\Customer\Model\Customer', $this->_service->create($customerData));
- }
-
- /**
- * @return array
- */
- public function welcomeEmailNotCalledDataProvider()
- {
- return array(
- 'unchanged password' => array(
- array(
- 'website_id' => 1,
- ),
- null
- ),
- 'no website new customer send email' => array(
- array(
- 'website_id' => 0,
- 'sendemail' => true
- ),
- null
- ),
- 'no website new customer auto generated password' => array(
- array(
- 'website_id' => 0,
- 'autogenerate_password' => true
- ),
- null
- ),
- 'no website existing customer new password' => array(
- array(
- 'website_id' => 0,
- 'sendemail' => true
- ),
- 1
- ),
- 'existing customer auto generated password' => array(
- array(
- 'website_id' => 0,
- 'autogenerate_password' => true
- ),
- 1
- ),
- 'not new no confirmation' => array(
- array(
- 'sendemail_store_id' => 1,
- 'website_id' => 1,
- 'sendemail' => true,
- 'confirmation' => true
- ),
- 1
- )
- );
- }
-
- /**
- * @expectedException \Magento\Core\Exception
- * @expectedExceptionMessage The customer with the specified ID not found.
- */
- public function testLoadCustomerByIdException()
- {
- $this->_customer->expects($this->never())
- ->method('save');
- $this->_customer->expects($this->once())
- ->method('load')
- ->with(1);
- $this->_customer->expects($this->once())
- ->method('getId')
- ->will($this->returnValue(false));
-
- $this->_service->update(1, array('firstname' => 'test'));
- }
-
- /**
- * @param array $customerData
- * @dataProvider changePasswordDataProvider
- */
- public function testChangePassword(array $customerData)
- {
- $password = isset($customerData['password']) ? $customerData['password'] : 'generated_password';
- $this->_customer->expects($this->once())
- ->method('save');
- $this->_customer->expects($this->once())
- ->method('getId')
- ->will($this->returnValue(1));
- $this->_customer->expects($this->once())
- ->method('changePassword')
- ->with($password)
- ->will($this->returnSelf());
- $this->_customer->expects($this->once())
- ->method('sendPasswordReminderEmail')
- ->will($this->returnSelf());
- if (array_key_exists('autogenerate_password', $customerData)) {
- $this->_customer->expects($this->once())
- ->method('generatePassword')
- ->will($this->returnValue('generated_password'));
- }
-
- $this->assertInstanceOf('Magento\Customer\Model\Customer', $this->_service->update(1, $customerData));
- }
-
- /**
- * @return array
- */
- public function changePasswordDataProvider()
- {
- return array(
- 'new password' => array(
- array('password' => '123123q')
- ),
- 'auto generated password' => array(
- array('autogenerate_password' => true)
- )
- );
- }
-
- /**
- * @param array $addressData
- * @param \Magento\Customer\Model\Address|null $newAddress
- * @param \Magento\Customer\Model\Address|null $existingAddress
- * @param array $addressCollection
- * @param bool $dataChanged
- * @param bool $expectedDataChange
- * @dataProvider addressesDataProvider
- */
- public function testPrepareCustomerAddressForSave(array $addressData, $newAddress, $existingAddress,
- array $addressCollection, $dataChanged, $expectedDataChange
- ) {
- $this->_customer->setDataChanges($dataChanged);
-
- $this->_customer->expects($this->any())
- ->method('getId')
- ->will($this->returnValue(1));
-
- $this->_customer->expects($this->once())
- ->method('getAddressesCollection')
- ->will($this->returnValue($addressCollection));
-
- if ($newAddress) {
- // Check that customer_id is set for new addresses
- $newAddress->expects($this->once())
- ->method('setCustomerId')
- ->with(1);
- // Check that new address is added to customer address collection
- $this->_customer->expects($this->once())
- ->method('addAddress');
-
- // Check that new address is not deleted
- $newAddress->expects($this->never())
- ->method('setData')
- ->with('_deleted', true);
- }
-
- // Check that address loaded from customer address collection
- if ($existingAddress && $addressData) {
- $this->_customer->expects($this->once())
- ->method('getAddressItemById')
- ->with($existingAddress->getId())
- ->will($this->returnValue($existingAddress));
- }
-
- // Check that new data is added
- $hasExistingAddress = false;
- foreach ($addressData as $data) {
- if (array_key_exists('entity_id', $addressData)) {
- unset($data['entity_id']);
- $existingAddress->expects($this->once())
- ->method('addData')
- ->with($data);
- $hasExistingAddress = true;
- } elseif ($newAddress) {
- $newAddress->expects($this->once())
- ->method('addData')
- ->with($data);
- }
- }
- // Check that addresses is deleted
- if (in_array($existingAddress, $addressCollection) && !$hasExistingAddress) {
- $existingAddress->expects($this->atLeastOnce())
- ->method('setData')
- ->with('_deleted', true);
- }
-
- $this->assertInstanceOf('Magento\Customer\Model\Customer', $this->_service->update(1, array(), $addressData),
- 'Incorrect instance returned');
-
- $this->assertEquals($expectedDataChange, $this->_customer->hasDataChanges(),
- 'Customer change data status is incorrect');
- }
-
- /**
- * @return array
- */
- public function addressesDataProvider()
- {
- $newAddress = $this->_createAddress(true, null);
- $existingAddress = $this->_createAddress(true, 2);
- return array(
- 'no addresses #1' => array(
- array(), null, null, array(), false, false
- ),
- 'no addresses #2' => array(
- array(), null, null, array(), true, true
- ),
- 'new address' => array(
- array(array('city' => 'test')),
- $newAddress, null,
- array($newAddress), false, true
- ),
- 'existing address' => array(
- array(array('entity_id' => 2, 'city' => 'test')),
- null, $existingAddress,
- array($existingAddress), false, true
- ),
- 'new added, existing deleted' => array(
- array(array('city' => 'test')),
- $newAddress, null,
- array($newAddress, $existingAddress), false, true
- ),
- 'all addresses deleted' => array(
- array(),
- null, $existingAddress,
- array($existingAddress), false, true
- )
- );
- }
-
- /**
- * @expectedException \Magento\Core\Exception
- * @expectedExceptionMessage The address with the specified ID not found.
- */
- public function testPrepareCustomerAddressForSaveException()
- {
- $this->_customer->expects($this->any())
- ->method('getId')
- ->will($this->returnValue(1));
- $address = $this->_createAddress(true, 1);
- $this->_customer->expects($this->once())
- ->method('getAddressItemById')
- ->with($address->getId())
- ->will($this->returnValue(false));
- $this->_service->update(1, array(), array(array('entity_id' => 1, 'city' => 'test')));
- }
-}
diff --git a/dev/tests/unit/testsuite/Magento/Customer/Service/V1/CustomerAddressServiceTest.php b/dev/tests/unit/testsuite/Magento/Customer/Service/V1/CustomerAddressServiceTest.php
index 4f49ff8ff4a63..84c8387aa6107 100644
--- a/dev/tests/unit/testsuite/Magento/Customer/Service/V1/CustomerAddressServiceTest.php
+++ b/dev/tests/unit/testsuite/Magento/Customer/Service/V1/CustomerAddressServiceTest.php
@@ -258,11 +258,11 @@ public function testGetAddressesDefaultBilling()
'default_billing' => true,
'default_shipping' => false,
'customer_id' => self::ID,
- 'region' => new Dto\Region([
+ 'region' => [
'region_id' => self::REGION_ID,
'region_code' => '',
'region' => self::REGION
- ]),
+ ],
'country_id' => self::COUNTRY_ID,
'street' => [self::STREET],
'telephone' => self::TELEPHONE,
@@ -304,11 +304,11 @@ public function testGetAddressesDefaultShipping()
'default_shipping' => true,
'default_billing' => false,
'customer_id' => self::ID,
- 'region' => new Dto\Region([
+ 'region' => [
'region_id' => self::REGION_ID,
'region_code' => '',
'region' => self::REGION
- ]),
+ ],
'country_id' => self::COUNTRY_ID,
'street' => [self::STREET],
'telephone' => self::TELEPHONE,
@@ -351,11 +351,11 @@ public function testGetAddressesById()
'default_shipping' => true,
'default_billing' => false,
'customer_id' => self::ID,
- 'region' => new Dto\Region([
+ 'region' => [
'region_id' => self::REGION_ID,
'region_code' => '',
'region' => self::REGION
- ]),
+ ],
'country_id' => self::COUNTRY_ID,
'street' => [self::STREET],
'telephone' => self::TELEPHONE,
@@ -401,11 +401,11 @@ public function testGetAddresses()
'default_shipping' => true,
'default_billing' => false,
'customer_id' => self::ID,
- 'region' => new Dto\Region([
+ 'region' => [
'region_id' => self::REGION_ID,
'region_code' => '',
'region' => self::REGION
- ]),
+ ],
'country_id' => self::COUNTRY_ID,
'street' => [self::STREET],
'telephone' => self::TELEPHONE,
@@ -418,11 +418,11 @@ public function testGetAddresses()
'default_billing' => true,
'default_shipping' => false,
'customer_id' => self::ID,
- 'region' => new Dto\Region([
+ 'region' => [
'region_id' => self::REGION_ID,
'region_code' => '',
'region' => self::REGION
- ]),
+ ],
'country_id' => self::COUNTRY_ID,
'street' => [self::STREET],
'telephone' => self::TELEPHONE,
diff --git a/dev/tests/unit/testsuite/Magento/Customer/Service/V1/CustomerMetadataServiceTest.php b/dev/tests/unit/testsuite/Magento/Customer/Service/V1/CustomerMetadataServiceTest.php
index ebbb52560e3a1..f0d2e40049cf8 100644
--- a/dev/tests/unit/testsuite/Magento/Customer/Service/V1/CustomerMetadataServiceTest.php
+++ b/dev/tests/unit/testsuite/Magento/Customer/Service/V1/CustomerMetadataServiceTest.php
@@ -25,18 +25,15 @@
*/
namespace Magento\Customer\Service\V1;
-use Magento\Customer\Service\V1\CustomerMetadataService;
-use Magento\Customer\Service\V1\Dto\Eav\AttributeMetadata;
-use Magento\Customer\Service\V1\Dto\Eav\Option;
-
class CustomerMetadataServiceTest extends \PHPUnit_Framework_TestCase
{
/** Sample values for testing */
const ATTRIBUTE_CODE = 1;
- const FRONTEND_INPUT = 'frontend input';
+ const FRONTEND_INPUT = 'select';
const INPUT_FILTER = 'input filter';
const STORE_LABEL = 'store label';
const VALIDATE_RULES = 'validate rules';
+ const FRONTEND_CLASS = 'frontend class';
/**
* @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Eav\Model\Config
@@ -69,6 +66,8 @@ public function setUp()
'getStoreLabel',
'getValidateRules',
'getSource',
+ 'getFrontend',
+ 'usesSource',
'__wakeup',
)
)
@@ -80,6 +79,16 @@ public function setUp()
->disableOriginalConstructor()
->getMock();
+ $frontendMock = $this->getMockBuilder('\Magento\Eav\Model\Entity\Attribute\Frontend\AbstractFrontend')
+ ->disableOriginalConstructor()
+ ->setMethods(array('getClass'))
+ ->getMock();
+
+ $frontendMock
+ ->expects($this->any())
+ ->method('getClass')
+ ->will($this->returnValue(self::FRONTEND_CLASS));
+
$this->_mockReturnValue(
$this->_attributeEntityMock,
array(
@@ -88,6 +97,7 @@ public function setUp()
'getInputFilter' => self::INPUT_FILTER,
'getStoreLabel' => self::STORE_LABEL,
'getValidateRules' => self::VALIDATE_RULES,
+ 'getFrontend' => $frontendMock,
)
);
}
@@ -98,6 +108,10 @@ public function testGetAttributeMetadata()
->method('getAttribute')
->will($this->returnValue($this->_attributeEntityMock));
+ $this->_attributeEntityMock->expects($this->any())
+ ->method('usesSource')
+ ->will($this->returnValue(true));
+
$this->_attributeEntityMock->expects($this->any())
->method('getSource')
->will($this->returnValue($this->_sourceMock));
@@ -116,10 +130,10 @@ public function testGetAttributeMetadata()
->method('getAllOptions')
->will($this->returnValue($allOptions));
- $attributeColMock = $this->getMockBuilder('\\Magento\\Customer\\Model\\Resource\\Form\\Attribute\\Collection')
+ $attributeColMock = $this->getMockBuilder('\Magento\Customer\Model\Resource\Form\Attribute\CollectionFactory')
->disableOriginalConstructor()
->getMock();
- $storeManagerMock = $this->getMockBuilder('\\Magento\\Core\\Model\\StoreManager')
+ $storeManagerMock = $this->getMockBuilder('\Magento\Core\Model\StoreManager')
->disableOriginalConstructor()
->getMock();
@@ -131,11 +145,7 @@ public function testGetAttributeMetadata()
$optionBuilder, $attributeMetadataBuilder);
$attributeMetadata = $service->getAttributeMetadata('entityCode', 'attributeId');
- $this->assertEquals(self::ATTRIBUTE_CODE, $attributeMetadata->getAttributeCode());
- $this->assertEquals(self::FRONTEND_INPUT, $attributeMetadata->getFrontendInput());
- $this->assertEquals(self::INPUT_FILTER, $attributeMetadata->getInputFilter());
- $this->assertEquals(self::STORE_LABEL, $attributeMetadata->getStoreLabel());
- $this->assertEquals(self::VALIDATE_RULES, $attributeMetadata->getValidationRules());
+ $this->assertMetadataAttributes($attributeMetadata);
$options = $attributeMetadata->getOptions();
$this->assertNotEquals(array(), $options);
@@ -159,10 +169,10 @@ public function testGetAttributeMetadataWithoutOptions()
->method('getAllOptions')
->will($this->returnValue(array()));
- $attributeColMock = $this->getMockBuilder('\\Magento\\Customer\\Model\\Resource\\Form\\Attribute\\Collection')
+ $attributeColMock = $this->getMockBuilder('\Magento\Customer\Model\Resource\Form\Attribute\CollectionFactory')
->disableOriginalConstructor()
->getMock();
- $storeManagerMock = $this->getMockBuilder('\\Magento\\Core\\Model\\StoreManager')
+ $storeManagerMock = $this->getMockBuilder('\Magento\Core\Model\StoreManager')
->disableOriginalConstructor()
->getMock();
@@ -174,11 +184,7 @@ public function testGetAttributeMetadataWithoutOptions()
$optionBuilder, $attributeMetadataBuilder);
$attributeMetadata = $service->getAttributeMetadata('entityCode', 'attributeId');
- $this->assertEquals(self::ATTRIBUTE_CODE, $attributeMetadata->getAttributeCode());
- $this->assertEquals(self::FRONTEND_INPUT, $attributeMetadata->getFrontendInput());
- $this->assertEquals(self::INPUT_FILTER, $attributeMetadata->getInputFilter());
- $this->assertEquals(self::STORE_LABEL, $attributeMetadata->getStoreLabel());
- $this->assertEquals(self::VALIDATE_RULES, $attributeMetadata->getValidationRules());
+ $this->assertMetadataAttributes($attributeMetadata);
$options = $attributeMetadata->getOptions();
$this->assertEquals(0, count($options));
@@ -191,13 +197,13 @@ public function testGetAttributeMetadataWithoutSource()
->will($this->returnValue($this->_attributeEntityMock));
$this->_attributeEntityMock->expects($this->any())
- ->method('getSource')
- ->will($this->throwException(new \Exception('exception message')));
+ ->method('usesSource')
+ ->will($this->returnValue(false));
- $attributeColMock = $this->getMockBuilder('\\Magento\\Customer\\Model\\Resource\\Form\\Attribute\\Collection')
+ $attributeColMock = $this->getMockBuilder('\Magento\Customer\Model\Resource\Form\Attribute\CollectionFactory')
->disableOriginalConstructor()
->getMock();
- $storeManagerMock = $this->getMockBuilder('\\Magento\\Core\\Model\\StoreManager')
+ $storeManagerMock = $this->getMockBuilder('\Magento\Core\Model\StoreManager')
->disableOriginalConstructor()
->getMock();
@@ -209,11 +215,7 @@ public function testGetAttributeMetadataWithoutSource()
$optionBuilder, $attributeMetadataBuilder);
$attributeMetadata = $service->getAttributeMetadata('entityCode', 'attributeId');
- $this->assertEquals(self::ATTRIBUTE_CODE, $attributeMetadata->getAttributeCode());
- $this->assertEquals(self::FRONTEND_INPUT, $attributeMetadata->getFrontendInput());
- $this->assertEquals(self::INPUT_FILTER, $attributeMetadata->getInputFilter());
- $this->assertEquals(self::STORE_LABEL, $attributeMetadata->getStoreLabel());
- $this->assertEquals(self::VALIDATE_RULES, $attributeMetadata->getValidationRules());
+ $this->assertMetadataAttributes($attributeMetadata);
$options = $attributeMetadata->getOptions();
$this->assertEquals(0, count($options));
@@ -231,4 +233,17 @@ private function _mockReturnValue($mock, $valueMap)
->will($this->returnValue($value));
}
}
+
+ /**
+ * @param $attributeMetadata
+ */
+ private function assertMetadataAttributes($attributeMetadata)
+ {
+ $this->assertEquals(self::ATTRIBUTE_CODE, $attributeMetadata->getAttributeCode());
+ $this->assertEquals(self::FRONTEND_INPUT, $attributeMetadata->getFrontendInput());
+ $this->assertEquals(self::INPUT_FILTER, $attributeMetadata->getInputFilter());
+ $this->assertEquals(self::STORE_LABEL, $attributeMetadata->getStoreLabel());
+ $this->assertEquals(self::VALIDATE_RULES, $attributeMetadata->getValidationRules());
+ $this->assertEquals(self::FRONTEND_CLASS, $attributeMetadata->getFrontendClass());
+ }
}
diff --git a/dev/tests/unit/testsuite/Magento/DB/Ddl/TriggerTest.php b/dev/tests/unit/testsuite/Magento/DB/Ddl/TriggerTest.php
new file mode 100644
index 0000000000000..ddacd25f284ef
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/DB/Ddl/TriggerTest.php
@@ -0,0 +1,239 @@
+_object = new \Magento\DB\Ddl\Trigger();
+ }
+
+ /**
+ * Test getListOfEvents() method
+ */
+ public function testGetListOfEvents()
+ {
+ $actualEventTypes = \Magento\DB\Ddl\Trigger::getListOfEvents();
+ $this->assertInternalType('array', $actualEventTypes);
+ $this->assertCount(3, $actualEventTypes);
+ $this->assertTrue(in_array(\Magento\DB\Ddl\Trigger::EVENT_INSERT, $actualEventTypes));
+ $this->assertTrue(in_array(\Magento\DB\Ddl\Trigger::EVENT_UPDATE, $actualEventTypes));
+ $this->assertTrue(in_array(\Magento\DB\Ddl\Trigger::EVENT_DELETE, $actualEventTypes));
+ }
+
+ /**
+ * Test getListOfTimes() method
+ */
+ public function testGetListOfTimes()
+ {
+ $actualTimeTypes = \Magento\DB\Ddl\Trigger::getListOfTimes();
+ $this->assertInternalType('array', $actualTimeTypes);
+ $this->assertCount(2, $actualTimeTypes);
+ $this->assertTrue(in_array(\Magento\DB\Ddl\Trigger::TIME_AFTER, $actualTimeTypes));
+ $this->assertTrue(in_array(\Magento\DB\Ddl\Trigger::TIME_BEFORE, $actualTimeTypes));
+ }
+
+ /**
+ * Test case for getName() after setName()
+ */
+ public function testGetNameWithSetName()
+ {
+ $triggerName = 'TEST_TRIGGER_NAME' . mt_rand(100, 999);
+
+ $this->_object->setName($triggerName);
+ $this->assertEquals(strtolower($triggerName), $this->_object->getName());
+ }
+
+ /**
+ * Test case for setName() with exception
+ *
+ * @expectedException \InvalidArgumentException
+ * @expectedExceptionMessage Trigger name should be a string
+ */
+ public function testSetNameWithException()
+ {
+ $triggerName = new \stdClass();//non string
+
+ $this->_object->setName($triggerName);
+ }
+
+ /**
+ * Test case for setTable() with exception
+ *
+ * @expectedException \InvalidArgumentException
+ * @expectedExceptionMessage Trigger table name should be a string
+ */
+ public function testSetTableWithException()
+ {
+ $tableName = new \stdClass();//non string
+
+ $this->_object->setTable($tableName);
+ }
+
+ /**
+ * Test case for getName()
+ *
+ * @expectedException \Zend_Db_Exception
+ * @expectedExceptionMessage Trigger name is not defined
+ */
+ public function testGetNameWithException()
+ {
+ $tableName = 'TEST_TABLE_NAME_' . mt_rand(100, 999);
+ $event = \Magento\DB\Ddl\Trigger::EVENT_INSERT;
+
+ $this->_object
+ ->setTable($tableName)
+ ->setTime(\Magento\DB\Ddl\Trigger::TIME_AFTER)
+ ->setEvent($event);
+
+ $this->_object->getName();
+ }
+
+ /**
+ * Test case for getTime() with Exception
+ *
+ * @expectedException \Zend_Db_Exception
+ * @expectedExceptionMessage Trigger time is not defined
+ */
+ public function testGetTimeWithException()
+ {
+ $tableName = 'TEST_TABLE_NAME_' . mt_rand(100, 999);
+ $event = \Magento\DB\Ddl\Trigger::EVENT_INSERT;
+
+ $this->_object
+ ->setTable($tableName)
+ ->setEvent($event);
+
+ $this->_object->getTime();
+ }
+
+ /**
+ * Test case for getTable()
+ *
+ * @expectedException \Zend_Db_Exception
+ * @expectedExceptionMessage Trigger table name is not defined
+ */
+ public function testGetTableWithException()
+ {
+ $event = \Magento\DB\Ddl\Trigger::EVENT_INSERT;
+
+ $this->_object
+ ->setTime(\Magento\DB\Ddl\Trigger::TIME_AFTER)
+ ->setEvent($event);
+
+ $this->_object->getTable();
+ }
+
+ /**
+ * Test case for getEvent() with Exception
+ *
+ * @expectedException \Zend_Db_Exception
+ * @expectedExceptionMessage Trigger event is not defined
+ */
+ public function testGetEventWithException()
+ {
+ $tableName = 'TEST_TABLE_NAME_' . mt_rand(100, 999);
+
+ $this->_object
+ ->setTable($tableName)
+ ->setTime(\Magento\DB\Ddl\Trigger::TIME_AFTER);
+
+ $this->_object->getEvent();
+ }
+
+ /**
+ * @expectedException InvalidArgumentException
+ * @expectedExceptionMessage Trigger unsupported event type
+ */
+ public function testWrongEventTypeException()
+ {
+ $this->_object->setEvent('UNSUPORT EVENT TYPE');
+ }
+
+ /**
+ * @expectedException InvalidArgumentException
+ * @expectedExceptionMessage Trigger unsupported time type
+ */
+ public function testWrongTimeTypeException()
+ {
+ $this->_object->setTime('UNSUPORT TIME TYPE');
+ }
+
+ /**
+ * Test case for setTable() with exception
+ *
+ * @expectedException \InvalidArgumentException
+ * @expectedExceptionMessage Trigger statement should be a string
+ */
+ public function testAddStatementWithException()
+ {
+ $statement = new \stdClass();//non string
+
+ $this->_object->addStatement($statement);
+ }
+
+ /**
+ * Data provider for setBody function
+ */
+ public function getStatementsDataProvider()
+ {
+ return array(
+ array(
+ 'SQL',
+ array('SQL;')
+ ),
+ array(
+ 'SQL;',
+ array('SQL;')
+ ),
+ );
+ }
+
+ /**
+ * Test addStatement and getStatements for trigger
+ *
+ * @dataProvider getStatementsDataProvider
+ */
+ public function testAddStatement($param, $expected)
+ {
+ $this->_object->addStatement($param);
+ $this->assertEquals($expected, $this->_object->getStatements());
+ }
+
+ /**
+ * Test getStatements method
+ */
+ public function testGetStatements()
+ {
+ $this->assertEquals(array(), $this->_object->getStatements());
+ }
+}
diff --git a/dev/tests/unit/testsuite/Magento/Data/CollectionTest.php b/dev/tests/unit/testsuite/Magento/Data/CollectionTest.php
index 2ff7f18c9b15e..fd990c1f0b64a 100644
--- a/dev/tests/unit/testsuite/Magento/Data/CollectionTest.php
+++ b/dev/tests/unit/testsuite/Magento/Data/CollectionTest.php
@@ -62,7 +62,7 @@ public function testSetItemObjectClass($class)
public function setItemObjectClassDataProvider()
{
return array(
- array('Magento\Core\Model\Url'),
+ array('Magento\Url'),
array('Magento\Object'),
);
}
diff --git a/dev/tests/unit/testsuite/Magento/DesignEditor/Block/Adminhtml/Editor/Toolbar/Buttons/SaveTest.php b/dev/tests/unit/testsuite/Magento/DesignEditor/Block/Adminhtml/Editor/Toolbar/Buttons/SaveTest.php
index 0b7f7f64640c0..7f7b8181c0470 100644
--- a/dev/tests/unit/testsuite/Magento/DesignEditor/Block/Adminhtml/Editor/Toolbar/Buttons/SaveTest.php
+++ b/dev/tests/unit/testsuite/Magento/DesignEditor/Block/Adminhtml/Editor/Toolbar/Buttons/SaveTest.php
@@ -53,7 +53,7 @@ protected function setUp()
->will($this->returnArgument(0));
/** @var $urlBuilder \Magento\Core\Model\Url|\PHPUnit_Framework_MockObject_MockObject */
- $urlBuilder = $this->getMock('Magento\Core\Model\Url', array('getUrl'), array(), '', false);
+ $urlBuilder = $this->getMock('Magento\Url', array('getUrl'), array(), '', false);
$urlBuilder->expects($this->any())
->method('getUrl')
->will($this->returnValue($this->_url));
diff --git a/dev/tests/unit/testsuite/Magento/DesignEditor/Block/Adminhtml/Editor/Tools/Code/CustomTest.php b/dev/tests/unit/testsuite/Magento/DesignEditor/Block/Adminhtml/Editor/Tools/Code/CustomTest.php
index ff11fb7fdb1e4..01a0107613ced 100644
--- a/dev/tests/unit/testsuite/Magento/DesignEditor/Block/Adminhtml/Editor/Tools/Code/CustomTest.php
+++ b/dev/tests/unit/testsuite/Magento/DesignEditor/Block/Adminhtml/Editor/Tools/Code/CustomTest.php
@@ -75,7 +75,7 @@ protected function setUp()
$this->_model = $objectManagerHelper->getObject(
'Magento\DesignEditor\Block\Adminhtml\Editor\Tools\Code\Custom',
array(
- 'config' => $this->getMock('Magento\Core\Model\Config', array(), array(), '', false),
+ 'config' => $this->getMock('Magento\App\ConfigInterface', array(), array(), '', false),
'formFactory' => $this->getMock('Magento\Data\FormFactory', array(), array(), '', false),
'urlBuilder' => $this->_urlBuilder,
'themeContext' => $this->_themeContext
diff --git a/dev/tests/unit/testsuite/Magento/DesignEditor/Controller/Adminhtml/System/Design/EditorTest.php b/dev/tests/unit/testsuite/Magento/DesignEditor/Controller/Adminhtml/System/Design/EditorTest.php
index 059ad34a8560e..d995b7fc02988 100644
--- a/dev/tests/unit/testsuite/Magento/DesignEditor/Controller/Adminhtml/System/Design/EditorTest.php
+++ b/dev/tests/unit/testsuite/Magento/DesignEditor/Controller/Adminhtml/System/Design/EditorTest.php
@@ -194,7 +194,7 @@ protected function _getObjectManagerMap($countCustomization)
->will($this->returnSelf());
$eventManager = $this->getMock('Magento\Event\ManagerInterface', array(), array(), '', false);
- $configMock = $this->getMock('Magento\Core\Model\Config', array(), array(), '', false);
+ $configMock = $this->getMock('Magento\App\ConfigInterface', array(), array(), '', false);
$authMock = $this->getMock('Magento\AuthorizationInterface');
$authMock->expects($this->any())->method('filterAclNodes')->will($this->returnSelf());
$backendSession = $this->getMock('Magento\Backend\Model\Session', array('getMessages', 'getEscapeMessages'),
@@ -212,7 +212,7 @@ protected function _getObjectManagerMap($countCustomization)
$this->_getThemeCollectionFactory($countCustomization)
),
array('Magento\Core\Model\Translate', $translate),
- array('Magento\Core\Model\Config', $configMock),
+ array('Magento\App\ConfigInterface', $configMock),
array('Magento\Event\ManagerInterface', $eventManager),
array('Magento\Core\Model\StoreManager', $storeManager),
array('Magento\AuthorizationInterface', $authMock),
diff --git a/dev/tests/unit/testsuite/Magento/DesignEditor/Controller/Varien/Router/StandardTest.php b/dev/tests/unit/testsuite/Magento/DesignEditor/Controller/Varien/Router/StandardTest.php
index 37d97981de1b0..fdaa041697e99 100644
--- a/dev/tests/unit/testsuite/Magento/DesignEditor/Controller/Varien/Router/StandardTest.php
+++ b/dev/tests/unit/testsuite/Magento/DesignEditor/Controller/Varien/Router/StandardTest.php
@@ -236,7 +236,7 @@ protected function _prepareMocksForTestMatch(
$this->getMock('Magento\UrlInterface'),
$this->getMock('Magento\Core\Model\StoreManagerInterface'),
$this->getMock('Magento\Core\Model\Store\Config', array(), array(), '', false),
- $this->getMock('Magento\Core\Model\Url\SecurityInfoInterface'),
+ $this->getMock('Magento\Url\SecurityInfoInterface'),
'frontend',
$routerListMock,
$objectManager,
diff --git a/dev/tests/unit/testsuite/Magento/DesignEditor/Model/StateTest.php b/dev/tests/unit/testsuite/Magento/DesignEditor/Model/StateTest.php
index 67429a88cd206..c1c745efc1ceb 100644
--- a/dev/tests/unit/testsuite/Magento/DesignEditor/Model/StateTest.php
+++ b/dev/tests/unit/testsuite/Magento/DesignEditor/Model/StateTest.php
@@ -34,7 +34,7 @@ class StateTest extends \PHPUnit_Framework_TestCase
const LAYOUT_NAVIGATION_CLASS_NAME = 'Magento\Core\Model\Layout';
/**
- * Url model classes that will be used instead of \Magento\Core\Model\Url in different vde modes
+ * Url model classes that will be used instead of \Magento\UrlInterface in different vde modes
*/
const URL_MODEL_NAVIGATION_MODE_CLASS_NAME = 'Magento\DesignEditor\Model\Url\NavigationMode';
@@ -148,11 +148,7 @@ protected function setUp()
)
->will($this->returnSelf());
- $this->_application->expects($this->any())
- ->method('getStore')
- ->will($this->returnValue($storeManager));
-
- $configMock = $this->getMock('Magento\Core\Model\Config', array('setNode'), array(), '', false);
+ $configMock = $this->getMock('Magento\App\ConfigInterface', array(), array(), '', false);
$configMock->expects($this->any())
->method('setNode')
->with(
@@ -184,7 +180,8 @@ protected function setUp()
$this->_dataHelper,
$this->_objectManager,
$this->_application,
- $this->_themeContext
+ $this->_themeContext,
+ $storeManager
);
}
diff --git a/dev/tests/unit/testsuite/Magento/DesignEditor/Model/Url/FactoryTest.php b/dev/tests/unit/testsuite/Magento/DesignEditor/Model/Url/FactoryTest.php
index 9ce761e32b251..4a85990f2f677 100644
--- a/dev/tests/unit/testsuite/Magento/DesignEditor/Model/Url/FactoryTest.php
+++ b/dev/tests/unit/testsuite/Magento/DesignEditor/Model/Url/FactoryTest.php
@@ -53,7 +53,7 @@ public function testReplaceClassName()
{
$this->_objectManager->expects($this->once())
->method('configure')
- ->with(array('preferences' => array('Magento\Core\Model\Url' => 'TestClass')));
+ ->with(array('preferences' => array('Magento\UrlInterface' => 'TestClass')));
$this->assertEquals($this->_model, $this->_model->replaceClassName('TestClass'));
}
@@ -62,7 +62,7 @@ public function testCreate()
{
$this->_objectManager->expects($this->once())
->method('create')
- ->with('Magento\Core\Model\Url', array())
+ ->with('Magento\UrlInterface', array())
->will($this->returnValue('ModelInstance'));
$this->assertEquals('ModelInstance', $this->_model->create());
diff --git a/dev/tests/unit/testsuite/Magento/DesignEditor/Model/Url/NavigationModeTest.php b/dev/tests/unit/testsuite/Magento/DesignEditor/Model/Url/NavigationModeTest.php
index c9cbd71bf55c7..c4d9a9e119e40 100644
--- a/dev/tests/unit/testsuite/Magento/DesignEditor/Model/Url/NavigationModeTest.php
+++ b/dev/tests/unit/testsuite/Magento/DesignEditor/Model/Url/NavigationModeTest.php
@@ -51,6 +51,11 @@ class NavigationModeTest extends \PHPUnit_Framework_TestCase
*/
protected $_requestMock;
+ /**
+ * @var \PHPUnit_Framework_MockObject_MockObject
+ */
+ protected $_routeParamsMock;
+
/**
* @var array
*/
@@ -68,9 +73,19 @@ protected function setUp()
array('editorMode', 'navigation'),
array('themeId', 1))));
+ $this->_routeParamsMock = $this->getMock(
+ 'Magento\Url\RouteParamsResolverFactory', array(), array(), '', false
+ );
+ $this->_routeParamsMock->expects($this->any())
+ ->method('create')
+ ->will($this->returnValue($this->getMock(
+ 'Magento\Core\Model\Url\RouteParamsResolver', array(), array(), '', false
+ )));
+
$this->_model = $objectManagerHelper->getObject('Magento\DesignEditor\Model\Url\NavigationMode', array(
'helper' => $this->_designHelperMock,
- 'data' => $this->_testData
+ 'data' => $this->_testData,
+ 'routeParamsResolver' => $this->_routeParamsMock
));
}
@@ -109,7 +124,7 @@ public function testGetRouteUrl()
->method('isFrontUrlSecure')
->will($this->returnValue(false));
- $this->_model->setData('store', $store);
+ $this->_model->setData('scope', $store);
$this->_model->setData('type', null);
$this->_model->setData('route_front_name', self::FRONT_NAME);
diff --git a/dev/tests/unit/testsuite/Magento/Directory/Helper/DataTest.php b/dev/tests/unit/testsuite/Magento/Directory/Helper/DataTest.php
index f0e8c86a87a38..a3d7aa9ebbf76 100644
--- a/dev/tests/unit/testsuite/Magento/Directory/Helper/DataTest.php
+++ b/dev/tests/unit/testsuite/Magento/Directory/Helper/DataTest.php
@@ -92,7 +92,7 @@ public function setUp()
'coreHelper' => $this->_coreHelper,
'storeManager' => $storeManager,
'currencyFactory' => $currencyFactory,
- 'config' => $this->getMock('Magento\Core\Model\Config', array(), array(), '', false),
+ 'config' => $this->getMock('Magento\App\ConfigInterface', array(), array(), '', false),
);
$this->_object = $objectManager->getObject('Magento\Directory\Helper\Data', $arguments);
}
diff --git a/dev/tests/unit/testsuite/Magento/Directory/Model/Currency/DefaultLocatorTest.php b/dev/tests/unit/testsuite/Magento/Directory/Model/Currency/DefaultLocatorTest.php
index e647fae51ccb9..c0ea3e4ddc3dd 100644
--- a/dev/tests/unit/testsuite/Magento/Directory/Model/Currency/DefaultLocatorTest.php
+++ b/dev/tests/unit/testsuite/Magento/Directory/Model/Currency/DefaultLocatorTest.php
@@ -39,6 +39,11 @@ class DefaultLocatorTest extends \PHPUnit_Framework_TestCase
*/
protected $_appMock;
+ /**
+ * @var \PHPUnit_Framework_MockObject_MockObject
+ */
+ protected $_storeManagerMock;
+
/**
* @var \PHPUnit_Framework_MockObject_MockObject
*/
@@ -50,7 +55,8 @@ protected function setUp()
$this->_requestMock = $this->getMockForAbstractClass('Magento\App\RequestInterface',
array($backendData), '', false, false, true, array('getParam'));
$this->_appMock = $this->getMock('Magento\Core\Model\App', array(), array(), '', false);
- $this->_model = new \Magento\Directory\Model\Currency\DefaultLocator($this->_appMock);
+ $this->_storeManagerMock = $this->getMock('Magento\Core\Model\StoreManager', array(), array(), '', false);
+ $this->_model = new \Magento\Directory\Model\Currency\DefaultLocator($this->_appMock, $this->_storeManagerMock);
}
public function testGetDefaultCurrencyReturnDefaultStoreDefaultCurrencyIfNoStoreIsSpecified()
@@ -66,7 +72,7 @@ public function testGetDefaultCurrencyReturnStoreDefaultCurrency()
->will($this->returnValue('someStore'));
$storeMock = $this->getMock('Magento\Core\Model\Store', array(), array(), '', false);
$storeMock->expects($this->once())->method('getBaseCurrencyCode')->will($this->returnValue('storeCurrency'));
- $this->_appMock->expects($this->once())->method('getStore')->with('someStore')
+ $this->_storeManagerMock->expects($this->once())->method('getStore')->with('someStore')
->will($this->returnValue($storeMock));
$this->assertEquals('storeCurrency', $this->_model->getDefaultCurrency($this->_requestMock));
}
@@ -80,7 +86,7 @@ public function testGetDefaultCurrencyReturnWebsiteDefaultCurrency()
$websiteMock = $this->getMock('Magento\Core\Model\Website', array(), array(), '', false);
$websiteMock->expects($this->once())->method('getBaseCurrencyCode')
->will($this->returnValue('websiteCurrency'));
- $this->_appMock->expects($this->once())->method('getWebsite')->with('someWebsite')
+ $this->_storeManagerMock->expects($this->once())->method('getWebsite')->with('someWebsite')
->will($this->returnValue($websiteMock));
$this->assertEquals('websiteCurrency', $this->_model->getDefaultCurrency($this->_requestMock));
}
@@ -100,7 +106,7 @@ public function testGetDefaultCurrencyReturnGroupDefaultCurrency()
$groupMock->expects($this->once())->method('getWebsite')
->will($this->returnValue($websiteMock));
- $this->_appMock->expects($this->once())->method('getGroup')->with('someGroup')
+ $this->_storeManagerMock->expects($this->once())->method('getGroup')->with('someGroup')
->will($this->returnValue($groupMock));
$this->assertEquals('websiteCurrency', $this->_model->getDefaultCurrency($this->_requestMock));
}
diff --git a/dev/tests/unit/testsuite/Magento/Downloadable/Model/Sales/Order/Pdf/Items/CreditmemoTest.php b/dev/tests/unit/testsuite/Magento/Downloadable/Model/Sales/Order/Pdf/Items/CreditmemoTest.php
index ffa08a36453ee..83cc325bb746b 100644
--- a/dev/tests/unit/testsuite/Magento/Downloadable/Model/Sales/Order/Pdf/Items/CreditmemoTest.php
+++ b/dev/tests/unit/testsuite/Magento/Downloadable/Model/Sales/Order/Pdf/Items/CreditmemoTest.php
@@ -84,9 +84,13 @@ protected function setUp()
'Magento\Sales\Model\Order\Pdf\AbstractPdf', array('drawLineBlocks', 'getPdf'), array(), '', false, false
);
+ $filterManager = $this->getMock('Magento\Filter\FilterManager', array('stripTags'), array(), '', false);
+ $filterManager->expects($this->any())->method('stripTags')->will($this->returnArgument(0));
+
$modelConstructorArgs = $objectManager
->getConstructArguments('Magento\Downloadable\Model\Sales\Order\Pdf\Items\Creditmemo', array(
- 'string' => new \Magento\Stdlib\String()
+ 'string' => new \Magento\Stdlib\String(),
+ 'filterManager' => $filterManager
));
$this->_model = $this->getMock(
diff --git a/dev/tests/unit/testsuite/Magento/Eav/Model/Resource/Entity/AttributeTest.php b/dev/tests/unit/testsuite/Magento/Eav/Model/Resource/Entity/AttributeTest.php
index 4bd9b12d325ba..13131375ea7a3 100644
--- a/dev/tests/unit/testsuite/Magento/Eav/Model/Resource/Entity/AttributeTest.php
+++ b/dev/tests/unit/testsuite/Magento/Eav/Model/Resource/Entity/AttributeTest.php
@@ -205,8 +205,8 @@ protected function _prepareResourceModel()
array('status', '"status"'),
)));
- $application = $this->getMock('Magento\Core\Model\App', array('getStores'), array(), '', false);
- $application->expects($this->any())
+ $storeManager = $this->getMock('Magento\Core\Model\StoreManager', array('getStores'), array(), '', false);
+ $storeManager->expects($this->any())
->method('getStores')
->with(true)
->will($this->returnValue(array(
@@ -228,12 +228,8 @@ protected function _prepareResourceModel()
$eavEntityType = $this->getMock('Magento\Eav\Model\Resource\Entity\Type', array(), array(), '', false, false);
$arguments = array(
'resource' => $resource,
- 'app' => $this->getMock('Magento\Core\Model\App', array(), array(), '', false, false),
+ 'storeManager' => $storeManager,
'eavEntityType' => $eavEntityType,
- 'arguments' => array(
- 'application' => $application,
- 'helper' => $this->getMock('Magento\Eav\Helper\Data', array(), array(), '', false, false),
- )
);
$resourceModel = $this->getMock(
'Magento\Eav\Model\Resource\Entity\Attribute',
diff --git a/dev/tests/unit/testsuite/Magento/GoogleAdwords/Helper/DataTest.php b/dev/tests/unit/testsuite/Magento/GoogleAdwords/Helper/DataTest.php
index 8fc783f767e21..37b350c2df062 100644
--- a/dev/tests/unit/testsuite/Magento/GoogleAdwords/Helper/DataTest.php
+++ b/dev/tests/unit/testsuite/Magento/GoogleAdwords/Helper/DataTest.php
@@ -52,7 +52,7 @@ class DataTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
- $this->_configMock = $this->getMock('Magento\Core\Model\Config', array(), array(), '', false);
+ $this->_configMock = $this->getMock('Magento\App\ConfigInterface', array(), array(), '', false);
$this->_storeConfigMock = $this->getMock(
'Magento\Core\Model\Store\ConfigInterface', array(), array(), '', false
);
diff --git a/dev/tests/unit/testsuite/Magento/GroupedProduct/Block/Adminhtml/Order/Create/SidebarTest.php b/dev/tests/unit/testsuite/Magento/GroupedProduct/Block/Adminhtml/Order/Create/SidebarTest.php
new file mode 100644
index 0000000000000..c282ac2044b57
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/GroupedProduct/Block/Adminhtml/Order/Create/SidebarTest.php
@@ -0,0 +1,99 @@
+invocationChainMock = $this->getMock('Magento\Code\Plugin\InvocationChain', array(), array(), '', false);
+ $this->itemMock = $this->getMock('Magento\Catalog\Model\Product\Configuration\Item\ItemInterface');
+ $this->productMock = $this->getMock('Magento\Catalog\Model\Product', array(), array(), '', false);
+ $this->sidebarMock = new \Magento\GroupedProduct\Block\Adminhtml\Order\Create\Sidebar();
+ }
+
+ public function testAroundGetItemQtyWhenProductGrouped()
+ {
+ $this->itemMock->expects($this->once())->method('getProduct')->will($this->returnValue($this->productMock));
+ $this->productMock
+ ->expects($this->once())
+ ->method('getTypeId')
+ ->will($this->returnValue(\Magento\GroupedProduct\Model\Product\Type\Grouped::TYPE_CODE));
+ $this->invocationChainMock->expects($this->never())->method('proceed');
+ $this->assertEquals('',
+ $this->sidebarMock->aroundGetItemQty(array($this->itemMock), $this->invocationChainMock));
+ }
+
+ public function testAroundGetItemQtyWhenProductNotGrouped()
+ {
+ $arguments = array($this->itemMock);
+ $this->itemMock->expects($this->once())->method('getProduct')->will($this->returnValue($this->productMock));
+ $this->productMock
+ ->expects($this->once())
+ ->method('getTypeId')
+ ->will($this->returnValue('one'));
+ $this->invocationChainMock->expects($this->once())->method('proceed')->with($arguments);
+ $this->sidebarMock->aroundGetItemQty($arguments, $this->invocationChainMock);
+ }
+
+ public function testAroundIsConfigurationRequiredWhenProductGrouped()
+ {
+ $this->invocationChainMock->expects($this->never())->method('proceed');
+ $this->assertEquals(true,
+ $this->sidebarMock->aroundIsConfigurationRequired(
+ array(\Magento\GroupedProduct\Model\Product\Type\Grouped::TYPE_CODE),
+ $this->invocationChainMock)
+ );
+ }
+
+ public function testAroundIsConfigurationRequiredWhenProductNotGrouped()
+ {
+ $arguments = array('someValue');
+ $this->invocationChainMock->expects($this->once())->method('proceed')->with($arguments);
+ $this->sidebarMock->aroundIsConfigurationRequired($arguments, $this->invocationChainMock);
+ }
+}
+
diff --git a/dev/tests/unit/testsuite/Magento/Checkout/Block/Cart/Item/Renderer/GroupedTest.php b/dev/tests/unit/testsuite/Magento/GroupedProduct/Block/Cart/Item/Renderer/GroupedTest.php
similarity index 96%
rename from dev/tests/unit/testsuite/Magento/Checkout/Block/Cart/Item/Renderer/GroupedTest.php
rename to dev/tests/unit/testsuite/Magento/GroupedProduct/Block/Cart/Item/Renderer/GroupedTest.php
index 201361a81ed84..f350ffe2a45a1 100644
--- a/dev/tests/unit/testsuite/Magento/Checkout/Block/Cart/Item/Renderer/GroupedTest.php
+++ b/dev/tests/unit/testsuite/Magento/GroupedProduct/Block/Cart/Item/Renderer/GroupedTest.php
@@ -25,9 +25,9 @@
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
-namespace Magento\Checkout\Block\Cart\Item\Renderer;
+namespace Magento\GroupedProduct\Block\Cart\Item\Renderer;
-use Magento\Checkout\Block\Cart\Item\Renderer\Grouped as Renderer;
+use Magento\GroupedProduct\Block\Cart\Item\Renderer\Grouped as Renderer;
use \Magento\Catalog\Model\Config\Source\Product\Thumbnail as ThumbnailSource;
class GroupedTest extends \PHPUnit_Framework_TestCase
@@ -44,7 +44,7 @@ protected function setUp()
$objectManagerHelper = new \Magento\TestFramework\Helper\ObjectManager($this);
$this->_storeConfig = $this->getMock('Magento\Core\Model\Store\Config', array(), array(), '', false, false);
$this->_renderer = $objectManagerHelper->getObject(
- 'Magento\Checkout\Block\Cart\Item\Renderer\Grouped',
+ 'Magento\GroupedProduct\Block\Cart\Item\Renderer\Grouped',
array(
'storeConfig' => $this->_storeConfig,
)
diff --git a/dev/tests/unit/testsuite/Magento/GroupedProduct/Model/Product/Cart/Configuration/Plugin/GroupedTest.php b/dev/tests/unit/testsuite/Magento/GroupedProduct/Model/Product/Cart/Configuration/Plugin/GroupedTest.php
new file mode 100644
index 0000000000000..e3d2bf2606d36
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/GroupedProduct/Model/Product/Cart/Configuration/Plugin/GroupedTest.php
@@ -0,0 +1,75 @@
+invocationChainMock = $this->getMock('Magento\Code\Plugin\InvocationChain', array(), array(), '', false);
+ $this->productMock = $this->getMock('Magento\Catalog\Model\Product', array(), array(), '', false);
+ $this->groupedPlugin = new \Magento\GroupedProduct\Model\Product\Cart\Configuration\Plugin\Grouped();
+ }
+
+ public function testAroundIsProductConfiguredWhenProductGrouped()
+ {
+ $config = array('super_group' => 'product');
+ $this->productMock
+ ->expects($this->once())
+ ->method('getTypeId')
+ ->will($this->returnValue(\Magento\GroupedProduct\Model\Product\Type\Grouped::TYPE_CODE));
+ $this->invocationChainMock->expects($this->never())->method('proceed');
+ $this->assertEquals(true,
+ $this->groupedPlugin->aroundIsProductConfigured(
+ array($this->productMock, $config), $this->invocationChainMock));
+ }
+
+ public function testAroundIsProductConfiguredWhenProductIsNotGrouped()
+ {
+ $config = array('super_group' => 'product');
+ $this->productMock
+ ->expects($this->once())
+ ->method('getTypeId')
+ ->will($this->returnValue('product'));
+ $this->invocationChainMock->expects($this->once())->method('proceed')->with(array($this->productMock, $config));
+ $this->groupedPlugin->aroundIsProductConfigured(array($this->productMock, $config), $this->invocationChainMock);
+ }
+}
+
diff --git a/dev/tests/unit/testsuite/Magento/GroupedProduct/Model/Product/CatalogPriceTest.php b/dev/tests/unit/testsuite/Magento/GroupedProduct/Model/Product/CatalogPriceTest.php
new file mode 100644
index 0000000000000..5969163a2c9df
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/GroupedProduct/Model/Product/CatalogPriceTest.php
@@ -0,0 +1,170 @@
+storeManagerMock = $this->getMock('Magento\Core\Model\StoreManagerInterface');
+ $this->commonPriceMock
+ = $this->getMock('Magento\Catalog\Model\Product\CatalogPrice', array(), array(), '', false);
+ $productMethods = array('getWebsiteId', 'getCustomerGroupId', '__wakeup', 'getTypeInstance', 'setTaxClassId');
+ $this->productMock = $this->getMock('Magento\Catalog\Model\Product', $productMethods, array(), '', false);
+ $methods = array('setWebsiteId', 'isSalable', '__wakeup', 'setCustomerGroupId', 'getTaxClassId');
+ $this->associatedProductMock = $this->getMock('Magento\Catalog\Model\Product', $methods, array(), '', false);
+ $this->priceModelMock
+ = $this->getMock('Magento\Catalog\Model\Product\Type\Price', array('getTotalPrices'), array(), '', false);
+ $this->productTypeMock
+ = $this->getMock('Magento\GroupedProduct\Model\Product\Type\Grouped', array(), array(), '', false);
+
+ $this->catalogPrice = new \Magento\GroupedProduct\Model\Product\CatalogPrice(
+ $this->storeManagerMock,
+ $this->commonPriceMock
+ );
+ }
+
+ public function testGetCatalogPriceWithDefaultStoreAndWhenProductDoesNotHaveAssociatedProducts()
+ {
+ $this->productMock
+ ->expects($this->once())
+ ->method('getTypeInstance')
+ ->will($this->returnValue($this->productTypeMock));
+ $this->productTypeMock
+ ->expects($this->once())
+ ->method('getAssociatedProducts')
+ ->with($this->productMock)->will($this->returnValue(array()));
+ $this->storeManagerMock->expects($this->never())->method('getStore');
+ $this->storeManagerMock->expects($this->never())->method('setCurrentStore');
+ $this->assertEquals(null, $this->catalogPrice->getCatalogPrice($this->productMock));
+ }
+
+ public function testGetCatalogPriceWithDefaultStoreAndSubProductIsNotSalable()
+ {
+ $this->productMock
+ ->expects($this->once())
+ ->method('getTypeInstance')
+ ->will($this->returnValue($this->productTypeMock));
+ $this->productTypeMock
+ ->expects($this->once())
+ ->method('getAssociatedProducts')
+ ->with($this->productMock)->will($this->returnValue(array($this->associatedProductMock)));
+ $this->productMock->expects($this->once())->method('getWebsiteId')->will($this->returnValue('website_id'));
+ $this->productMock->expects($this->once())->method('getCustomerGroupId')->will($this->returnValue('group_id'));
+ $this->associatedProductMock
+ ->expects($this->once())
+ ->method('setWebsiteId')
+ ->will($this->returnValue($this->associatedProductMock));
+ $this->associatedProductMock
+ ->expects($this->once())
+ ->method('setCustomerGroupId')
+ ->with('group_id')
+ ->will($this->returnValue($this->associatedProductMock));
+ $this->associatedProductMock->expects($this->once())->method('isSalable')->will($this->returnValue(false));
+ $this->productMock->expects($this->never())->method('setTaxClassId');
+ $this->storeManagerMock->expects($this->never())->method('getStore');
+ $this->storeManagerMock->expects($this->never())->method('setCurrentStore');
+ $this->assertEquals(null, $this->catalogPrice->getCatalogPrice($this->productMock));
+ }
+
+ public function testGetCatalogPriceWithCustomStoreAndSubProductIsSalable()
+ {
+ $storeMock = $this->getMock('Magento\Core\Model\Store', array(), array(), '', false);
+ $this->productMock
+ ->expects($this->once())
+ ->method('getTypeInstance')
+ ->will($this->returnValue($this->productTypeMock));
+ $this->productTypeMock
+ ->expects($this->once())
+ ->method('getAssociatedProducts')
+ ->with($this->productMock)->will($this->returnValue(array($this->associatedProductMock)));
+ $this->productMock->expects($this->once())->method('getWebsiteId')->will($this->returnValue('website_id'));
+ $this->productMock->expects($this->once())->method('getCustomerGroupId')->will($this->returnValue('group_id'));
+ $this->associatedProductMock
+ ->expects($this->once())
+ ->method('setWebsiteId')
+ ->will($this->returnValue($this->associatedProductMock));
+ $this->associatedProductMock
+ ->expects($this->once())
+ ->method('setCustomerGroupId')
+ ->with('group_id')
+ ->will($this->returnValue($this->associatedProductMock));
+ $this->associatedProductMock->expects($this->once())->method('isSalable')->will($this->returnValue(true));
+ $this->commonPriceMock
+ ->expects($this->exactly(2))
+ ->method('getCatalogPrice')
+ ->with($this->associatedProductMock)
+ ->will($this->returnValue(15));
+ $this->associatedProductMock
+ ->expects($this->once())
+ ->method('getTaxClassId')
+ ->will($this->returnValue('tax_class'));
+ $this->productMock->expects($this->once())->method('setTaxClassId')->with('tax_class');
+ $this->storeManagerMock->expects($this->exactly(2))->method('setCurrentStore');
+ $this->assertEquals(15, $this->catalogPrice->getCatalogPrice($this->productMock, $storeMock, true));
+ }
+
+ public function testGetCatalogRegularPrice()
+ {
+ $this->assertEquals(null, $this->catalogPrice->getCatalogRegularPrice($this->productMock));
+ }
+}
+
diff --git a/dev/tests/unit/testsuite/Magento/GroupedProduct/Model/Product/Type/PluginTest.php b/dev/tests/unit/testsuite/Magento/GroupedProduct/Model/Product/Type/PluginTest.php
new file mode 100644
index 0000000000000..212fd14d9de5f
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/GroupedProduct/Model/Product/Type/PluginTest.php
@@ -0,0 +1,51 @@
+moduleManagerMock = $this->getMock('\Magento\Module\Manager', array(), array(), '', false);
+ $this->object = new \Magento\GroupedProduct\Model\Product\Type\Plugin($this->moduleManagerMock);
+ }
+
+ public function testAfterGetOptionArray()
+ {
+ $this->moduleManagerMock->expects($this->any())->method('isOutputEnabled')->will($this->returnValue(false));
+ $this->assertEquals(array(), $this->object->afterGetOptionArray(array('grouped' => 'test')));
+ }
+}
diff --git a/dev/tests/unit/testsuite/Magento/ImportExport/Model/Export/Entity/Eav/Customer/AddressTest.php b/dev/tests/unit/testsuite/Magento/ImportExport/Model/Export/Entity/Eav/Customer/AddressTest.php
index 64c6f59c81e06..0489b8127dcba 100644
--- a/dev/tests/unit/testsuite/Magento/ImportExport/Model/Export/Entity/Eav/Customer/AddressTest.php
+++ b/dev/tests/unit/testsuite/Magento/ImportExport/Model/Export/Entity/Eav/Customer/AddressTest.php
@@ -99,10 +99,16 @@ class AddressTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
+
+ $storeManager = $this->getMock('Magento\Core\Model\StoreManager', array(), array(), '', false);
+ $storeManager->expects($this->once())
+ ->method('getWebsites')
+ ->will($this->returnCallback(array($this, 'getWebsites')));
+
$this->_objectManager = new \Magento\TestFramework\Helper\ObjectManager($this);
$this->_model = new \Magento\ImportExport\Model\Export\Entity\Eav\Customer\Address(
$this->getMock('Magento\Core\Model\Store\Config', array(), array(), '', false),
- $this->getMock('Magento\Core\Model\App', array(), array(), '', false),
+ $storeManager,
$this->getMock('Magento\ImportExport\Model\Export\Factory', array(), array(), '', false),
$this->getMock(
'Magento\ImportExport\Model\Resource\CollectionByPagesIteratorFactory', array(), array(), '', false
@@ -129,11 +135,6 @@ protected function tearDown()
*/
protected function _getModelDependencies()
{
- $websiteManager = $this->getMock('stdClass', array('getWebsites'));
- $websiteManager->expects($this->once())
- ->method('getWebsites')
- ->will($this->returnCallback(array($this, 'getWebsites')));
-
$translator = $this->getMock('stdClass');
$entityFactory = $this->getMock('Magento\Core\Model\EntityFactory', array(), array(), '', false);
@@ -176,8 +177,6 @@ protected function _getModelDependencies()
->will($this->returnSelf());
$data = array(
- 'website_manager' => $websiteManager,
- 'store_manager' => 'not_used',
'translator' => $translator,
'attribute_collection' => $attributeCollection,
'page_size' => 1,
diff --git a/dev/tests/unit/testsuite/Magento/ImportExport/Model/Export/Entity/Eav/CustomerTest.php b/dev/tests/unit/testsuite/Magento/ImportExport/Model/Export/Entity/Eav/CustomerTest.php
index f6a31794d8f38..70de1f948dcdc 100644
--- a/dev/tests/unit/testsuite/Magento/ImportExport/Model/Export/Entity/Eav/CustomerTest.php
+++ b/dev/tests/unit/testsuite/Magento/ImportExport/Model/Export/Entity/Eav/CustomerTest.php
@@ -87,9 +87,19 @@ class CustomerTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
+ $storeManager = $this->getMock('Magento\Core\Model\StoreManager', array(), array(), '', false);
+
+ $storeManager->expects($this->any())
+ ->method('getWebsites')
+ ->will($this->returnCallback(array($this, 'getWebsites')));
+
+ $storeManager->expects($this->any())
+ ->method('getStores')
+ ->will($this->returnCallback(array($this, 'getStores')));
+
$this->_model = new \Magento\ImportExport\Model\Export\Entity\Eav\Customer(
$this->getMock('Magento\Core\Model\Store\Config', array(), array(), '', false),
- $this->getMock('Magento\Core\Model\App', array(), array(), '', false),
+ $storeManager,
$this->getMock('Magento\ImportExport\Model\Export\Factory', array(), array(), '', false),
$this->getMock(
'Magento\ImportExport\Model\Resource\CollectionByPagesIteratorFactory', array(), array(), '', false
@@ -113,16 +123,6 @@ protected function tearDown()
*/
protected function _getModelDependencies()
{
- $websiteManager = $this->getMock('stdClass', array('getWebsites'));
- $websiteManager->expects($this->once())
- ->method('getWebsites')
- ->will($this->returnCallback(array($this, 'getWebsites')));
-
- $storeManager = $this->getMock('stdClass', array('getStores'));
- $storeManager->expects($this->once())
- ->method('getStores')
- ->will($this->returnCallback(array($this, 'getStores')));
-
$translator = $this->getMock('stdClass');
$objectManagerHelper = new \Magento\TestFramework\Helper\ObjectManager($this);
@@ -142,8 +142,6 @@ protected function _getModelDependencies()
}
$data = array(
- 'website_manager' => $websiteManager,
- 'store_manager' => $storeManager,
'translator' => $translator,
'attribute_collection' => $attributeCollection,
'page_size' => 1,
diff --git a/dev/tests/unit/testsuite/Magento/ImportExport/Model/Import/Entity/Eav/Customer/AddressTest.php b/dev/tests/unit/testsuite/Magento/ImportExport/Model/Import/Entity/Eav/Customer/AddressTest.php
index 49490d08281f5..da49daa955aba 100644
--- a/dev/tests/unit/testsuite/Magento/ImportExport/Model/Import/Entity/Eav/Customer/AddressTest.php
+++ b/dev/tests/unit/testsuite/Magento/ImportExport/Model/Import/Entity/Eav/Customer/AddressTest.php
@@ -217,8 +217,6 @@ protected function _getModelDependencies()
'page_size' => 1,
'max_data_size' => 1,
'bunch_size' => 1,
- 'website_manager' => $websiteManager,
- 'store_manager' => 'not_used',
'attribute_collection' => $attributeCollection,
'entity_type_id' => 1,
'customer_storage' => $customerStorage,
@@ -483,6 +481,10 @@ protected function _getModelMockForTestImportDataWithCustomBehaviour()
protected function _getModelMock()
{
$coreStoreConfig = $this->getMock('Magento\Core\Model\Store\Config', array(), array(), '', false);
+ $storeManager = $this->getMock('\Magento\Core\Model\StoreManager', array('getWebsites'), array(), '', false);
+ $storeManager->expects($this->once())
+ ->method('getWebsites')
+ ->will($this->returnCallback(array($this, 'getWebsites')));
$modelMock = new \Magento\ImportExport\Model\Import\Entity\Eav\Customer\Address(
$this->_coreDataMock,
@@ -491,7 +493,7 @@ protected function _getModelMock()
$this->getMock('Magento\ImportExport\Model\ImportFactory', array(), array(), '', false),
$this->getMock('Magento\ImportExport\Model\Resource\Helper', array(), array(), '', false),
$this->getMock('Magento\App\Resource', array(), array(), '', false),
- $this->getMock('Magento\Core\Model\App', array(), array(), '', false),
+ $storeManager,
$this->getMock('Magento\ImportExport\Model\Export\Factory', array(), array(), '', false),
$this->getMock('Magento\Eav\Model\Config', array(), array(), '', false),
$this->getMock('Magento\ImportExport\Model\Resource\Customer\StorageFactory', array(), array(), '', false),
diff --git a/dev/tests/unit/testsuite/Magento/ImportExport/Model/Import/Entity/EavAbstractTest.php b/dev/tests/unit/testsuite/Magento/ImportExport/Model/Import/Entity/EavAbstractTest.php
index 9eb29a22cf264..8f6569bd3d1d4 100644
--- a/dev/tests/unit/testsuite/Magento/ImportExport/Model/Import/Entity/EavAbstractTest.php
+++ b/dev/tests/unit/testsuite/Magento/ImportExport/Model/Import/Entity/EavAbstractTest.php
@@ -72,7 +72,7 @@ class EavAbstractTest extends \PHPUnit_Framework_TestCase
/**
* @var \Magento\Core\Model\App
*/
- protected $_app;
+ protected $_storeManager;
/**
* @var \Magento\ImportExport\Model\Export\Factory
@@ -95,7 +95,7 @@ protected function setUp()
$this->_resourceHelper = $this->getMock(
'Magento\ImportExport\Model\Resource\Helper', array(), array(), '', false
);
- $this->_app = $this->getMock('Magento\Core\Model\App', array(), array(), '', false);
+ $this->_storeManager = $this->getMock('Magento\Core\Model\StoreManager', array(), array(), '', false);
$this->_collectionFactory = $this->getMock(
'Magento\ImportExport\Model\Export\Factory', array(), array(), '', false);
$this->_eavConfig = $this->getMock(
@@ -109,7 +109,7 @@ protected function setUp()
$this->_importFactory,
$this->_resourceHelper,
$this->_resource,
- $this->_app,
+ $this->_storeManager,
$this->_collectionFactory,
$this->_eavConfig,
$this->_getModelDependencies()
diff --git a/dev/tests/unit/testsuite/Magento/Index/App/IndexerTest.php b/dev/tests/unit/testsuite/Magento/Index/App/IndexerTest.php
index 7cef4fbaca664..7dc0e46c048ca 100644
--- a/dev/tests/unit/testsuite/Magento/Index/App/IndexerTest.php
+++ b/dev/tests/unit/testsuite/Magento/Index/App/IndexerTest.php
@@ -78,7 +78,7 @@ protected function setUp()
* @param bool $value
* @dataProvider executeDataProvider
*/
- public function testExecute($value)
+ public function testLaunch($value)
{
$process = $this->getMock(
'Magento\Index\Model\Process',
@@ -101,7 +101,7 @@ public function testExecute($value)
$indexerInterface->expects($this->once())->method('isVisible')->will($this->returnValue(false));
$process->expects($this->never())->method('reindexEverything');
}
- $this->assertEquals($this->_responseMock, $this->_entryPoint->execute());
+ $this->assertEquals($this->_responseMock, $this->_entryPoint->launch());
}
/**
diff --git a/dev/tests/unit/testsuite/Magento/Index/App/ShellTest.php b/dev/tests/unit/testsuite/Magento/Index/App/ShellTest.php
index b48c46c8b7efb..fd4dfb12cfe97 100644
--- a/dev/tests/unit/testsuite/Magento/Index/App/ShellTest.php
+++ b/dev/tests/unit/testsuite/Magento/Index/App/ShellTest.php
@@ -80,7 +80,7 @@ public function testProcessRequest($shellHasErrors)
->will($this->returnValue($shell)
);
- $this->_entryPoint->execute();
+ $this->_entryPoint->launch();
}
/**
diff --git a/dev/tests/unit/testsuite/Magento/Indexer/App/IndexerTest.php b/dev/tests/unit/testsuite/Magento/Indexer/App/IndexerTest.php
new file mode 100644
index 0000000000000..ebf5fd098c188
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Indexer/App/IndexerTest.php
@@ -0,0 +1,76 @@
+responseMock = $this->getMock('Magento\App\Console\Response', array('setCode'), array(), '', false);
+ $this->filesystemMock = $this->getMock('Magento\Filesystem', array('getDirectoryWrite'), array(), '', false);
+ $directoryMock = $this->getMock('Magento\Filesystem\Directory\Write', array(), array(), '', false);
+ $directoryMock->expects($this->any())
+ ->method('getRelativePath')
+ ->will($this->returnArgument(0));
+ $this->filesystemMock->expects($this->once())
+ ->method('getDirectoryWrite')
+ ->will($this->returnValue($directoryMock));
+ $this->processorMock = $this->getMock('Magento\Indexer\Model\Processor', array(), array(), '', false);
+ $this->entryPoint = new \Magento\Indexer\App\Indexer(
+ 'reportDir',
+ $this->filesystemMock,
+ $this->processorMock,
+ $this->responseMock
+ );
+ }
+
+ public function testLaunch()
+ {
+ $this->responseMock->expects($this->once())
+ ->method('setCode')
+ ->with(0);
+ $this->processorMock->expects($this->once())->method('reindexAll');
+ $this->assertSame($this->responseMock, $this->entryPoint->launch());
+ }
+}
diff --git a/dev/tests/unit/testsuite/Magento/Indexer/App/ShellTest.php b/dev/tests/unit/testsuite/Magento/Indexer/App/ShellTest.php
new file mode 100644
index 0000000000000..c29a7f48901d7
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Indexer/App/ShellTest.php
@@ -0,0 +1,94 @@
+shellFactoryMock = $this->getMock('Magento\Indexer\Model\ShellFactory',
+ array('create'), array(), '', false);
+ $this->responseMock = $this->getMock('Magento\App\Console\Response', array(), array(), '', false);
+ $this->entryPoint = new \Magento\Indexer\App\Shell(
+ 'indexer.php',
+ $this->shellFactoryMock,
+ $this->responseMock
+ );
+ }
+
+ /**
+ * @param boolean $shellHasErrors
+ * @dataProvider processRequestDataProvider
+ */
+ public function testProcessRequest($shellHasErrors)
+ {
+ $shell = $this->getMock('Magento\Indexer\Model\Shell', array(), array(), '', false);
+ $shell->expects($this->once())
+ ->method('hasErrors')
+ ->will($this->returnValue($shellHasErrors));
+ $shell->expects($this->once())
+ ->method('run');
+ $this->responseMock->expects($this->once())
+ ->method('setCode')
+ ->with($shellHasErrors ? -1 : 0)
+ ->will($this->returnSelf());
+ $this->shellFactoryMock->expects($this->any())
+ ->method('create')
+ ->will($this->returnValue($shell)
+ );
+
+ $this->entryPoint->launch();
+ }
+
+ /**
+ * @return array
+ */
+ public function processRequestDataProvider()
+ {
+ return array(
+ array(true),
+ array(false)
+ );
+ }
+}
diff --git a/dev/tests/unit/testsuite/Magento/Indexer/Model/ActionFactoryTest.php b/dev/tests/unit/testsuite/Magento/Indexer/Model/ActionFactoryTest.php
new file mode 100644
index 0000000000000..b71c77da2dc6d
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Indexer/Model/ActionFactoryTest.php
@@ -0,0 +1,70 @@
+objectManagerMock = $this->getMock('Magento\ObjectManager', array(), array(), '', false);
+ $this->model = new \Magento\Indexer\Model\ActionFactory($this->objectManagerMock);
+ }
+
+ /**
+ * @expectedException \InvalidArgumentException
+ * @expectedExceptionMessage NotAction doesn't implement \Magento\Indexer\Model\ActionInterface
+ */
+ public function testGetWithException()
+ {
+ $notActionInterfaceMock = $this->getMock('NotAction', array(), array(), '', false);
+ $this->objectManagerMock->expects($this->once())
+ ->method('get')
+ ->with('NotAction')
+ ->will($this->returnValue($notActionInterfaceMock));
+ $this->model->get('NotAction');
+ }
+
+ public function testGet()
+ {
+ $actionInterfaceMock = $this->getMockForAbstractClass(
+ 'Magento\Indexer\Model\ActionInterface', array(), '', false
+ );
+ $this->objectManagerMock->expects($this->once())
+ ->method('get')
+ ->with('Magento\Indexer\Model\ActionInterface')
+ ->will($this->returnValue($actionInterfaceMock));
+ $this->model->get('Magento\Indexer\Model\ActionInterface');
+ $this->assertInstanceOf('Magento\Indexer\Model\ActionInterface', $actionInterfaceMock);
+ }
+}
diff --git a/dev/tests/unit/testsuite/Magento/Indexer/Model/Config/ConverterTest.php b/dev/tests/unit/testsuite/Magento/Indexer/Model/Config/ConverterTest.php
new file mode 100644
index 0000000000000..99a838559cb80
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Indexer/Model/Config/ConverterTest.php
@@ -0,0 +1,70 @@
+_model = new \Magento\Indexer\Model\Config\Converter;
+ }
+
+ public function testConvert()
+ {
+ $data = include __DIR__ . '/../../_files/indexer_config.php';
+ $dom = new \DOMDocument();
+ $dom->loadXML($data['inputXML']);
+
+ $this->assertEquals($data['expected'], $this->_model->convert($dom));
+ }
+
+ /**
+ * @param string $xmlData
+ * @dataProvider wrongXmlDataProvider
+ * @expectedException \Exception
+ */
+ public function testMapThrowsExceptionWhenXmlHasWrongFormat($xmlData)
+ {
+ $dom = new \DOMDocument();
+ $dom->loadXML($xmlData);
+ $this->_model->convert($dom);
+ }
+
+ /**
+ * @return array
+ */
+ public function wrongXmlDataProvider()
+ {
+ return array(
+ array(
+ '',
+ )
+ );
+ }
+}
diff --git a/dev/tests/unit/testsuite/Magento/Indexer/Model/Config/ReaderTest.php b/dev/tests/unit/testsuite/Magento/Indexer/Model/Config/ReaderTest.php
new file mode 100644
index 0000000000000..3911050f1fac8
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Indexer/Model/Config/ReaderTest.php
@@ -0,0 +1,126 @@
+_fileResolverMock = $this->getMock(
+ 'Magento\Core\Model\Config\FileResolver', array('get'), array(), '', false
+ );
+
+ $this->_converter = $this->getMock(
+ 'Magento\Indexer\Model\Config\Converter', array('convert')
+ );
+
+ $moduleReader = $this->getMock(
+ 'Magento\Module\Dir\Reader', array('getModuleDir'), array(), '', false
+ );
+ $moduleReader->expects($this->once())
+ ->method('getModuleDir')
+ ->with('etc', 'Magento_Indexer')
+ ->will($this->returnValue('stub'))
+ ;
+ $schemaLocator = new \Magento\Indexer\Model\Config\SchemaLocator($moduleReader);
+
+ $validationState = $this->getMock('Magento\Config\ValidationStateInterface');
+ $validationState->expects($this->once())->method('isValidated')->will($this->returnValue(false));
+
+ $this->_model = new \Magento\Indexer\Model\Config\Reader(
+ $this->_fileResolverMock,
+ $this->_converter,
+ $schemaLocator,
+ $validationState
+ );
+ }
+
+ /**
+ * @dataProvider readerDataProvider
+ */
+ public function testReadValidConfig($files, $expectedFile)
+ {
+ $this->_fileResolverMock->expects($this->once())
+ ->method('get')
+ ->with('indexer.xml', 'scope')
+ ->will($this->returnValue($files));
+
+ $constraint = function (\DOMDocument $actual) use ($expectedFile) {
+ try {
+ $expected = file_get_contents(__DIR__ . '/../../_files/' . $expectedFile);
+ \PHPUnit_Framework_Assert::assertXmlStringEqualsXmlString($expected, $actual->saveXML());
+ return true;
+ } catch (\PHPUnit_Framework_AssertionFailedError $e) {
+ return false;
+ }
+ };
+ $expectedResult = new \stdClass();
+ $this->_converter
+ ->expects($this->once())
+ ->method('convert')
+ ->with($this->callback($constraint))
+ ->will($this->returnValue($expectedResult))
+ ;
+
+ $this->assertSame($expectedResult, $this->_model->read('scope'));
+ }
+
+ /**
+ * @return array
+ */
+ public function readerDataProvider()
+ {
+ return array(
+ array(
+ array(
+ 'indexer_one.xml' => file_get_contents(__DIR__ . '/../../_files/indexer_one.xml'),
+ 'indexer_two.xml' => file_get_contents(__DIR__ . '/../../_files/indexer_two.xml'),
+ ),
+ 'indexer_merged_one.xml',
+ ),
+ array(
+ array(
+ 'indexer_one.xml' => file_get_contents(__DIR__ . '/../../_files/indexer_one.xml'),
+ 'indexer_three.xml' => file_get_contents(__DIR__ . '/../../_files/indexer_three.xml'),
+ ),
+ 'indexer_merged_two.xml',
+ ),
+ );
+ }
+}
diff --git a/dev/tests/unit/testsuite/Magento/Indexer/Model/Indexer/CollectionTest.php b/dev/tests/unit/testsuite/Magento/Indexer/Model/Indexer/CollectionTest.php
new file mode 100644
index 0000000000000..7652c3259ea00
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Indexer/Model/Indexer/CollectionTest.php
@@ -0,0 +1,92 @@
+getMockBuilder('Magento\Data\Collection\EntityFactoryInterface')
+ ->disableOriginalConstructor()
+ ->setMethods(array('create'))
+ ->getMock();
+
+ $config = $this->getMockBuilder('Magento\Indexer\Model\ConfigInterface')
+ ->getMock();
+
+ $statesFactory = $this->getMockBuilder('Magento\Indexer\Model\Resource\Indexer\State\CollectionFactory')
+ ->disableOriginalConstructor()
+ ->setMethods(array('create'))
+ ->getMock();
+
+ $states = $this->getMockBuilder('Magento\Indexer\Model\Resource\Indexer\State\Collection')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $state = $this->getMockBuilder('Magento\Indexer\Model\Indexer\State')
+ ->setMethods(array('getIndexerId', '__wakeup'))
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $state->expects($this->any())
+ ->method('getIndexerId')
+ ->will($this->returnValue('second_indexer_id'));
+
+ $indexer = $this->getMockBuilder('Magento\Indexer\Model\Indexer\Collection')
+ ->setMethods(array('load', 'setState'))
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $indexer->expects($this->once())
+ ->method('setState')
+ ->with($state);
+
+ $indexer->expects($this->any())
+ ->method('load')
+ ->with($this->logicalOr($indexerIdOne, $indexerIdSecond));
+
+ $entityFactory->expects($this->any())
+ ->method('create')
+ ->with('Magento\Indexer\Model\Indexer')
+ ->will($this->returnValue($indexer));
+
+ $statesFactory->expects($this->once())
+ ->method('create')
+ ->will($this->returnValue($states));
+
+ $config->expects($this->once())
+ ->method('getIndexerIds')
+ ->will($this->returnValue(array($indexerIdOne, $indexerIdSecond)));
+
+ $states->expects($this->any())
+ ->method('getItems')
+ ->will($this->returnValue(array($state)));
+
+ $collection = new \Magento\Indexer\Model\Indexer\Collection($entityFactory, $config, $statesFactory);
+ $this->assertInstanceOf('Magento\Indexer\Model\Indexer\Collection', $collection->loadData());
+ }
+}
diff --git a/dev/tests/unit/testsuite/Magento/Indexer/Model/IndexerTest.php b/dev/tests/unit/testsuite/Magento/Indexer/Model/IndexerTest.php
new file mode 100644
index 0000000000000..1c7927e5eb7b2
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Indexer/Model/IndexerTest.php
@@ -0,0 +1,366 @@
+configMock = $this->getMock('Magento\Indexer\Model\Config', array('get'), array(), '', false);
+ $this->actionFactoryMock = $this->getMock(
+ 'Magento\Indexer\Model\ActionFactory', array('get'), array(), '', false
+ );
+ $this->viewMock = $this->getMock(
+ 'Magento\Mview\View',
+ array('load', 'getMode', 'getUpdated', 'getStatus', '__wakeup', 'getId'),
+ array(),
+ '',
+ false
+ );
+ $this->stateFactoryMock = $this->getMock(
+ 'Magento\Indexer\Model\Indexer\StateFactory', array('create'), array(), '', false
+ );
+ $this->indexFactoryMock = $this->getMock(
+ 'Magento\Indexer\Model\Indexer\CollectionFactory', array('create'), array(), '', false
+ );
+ $this->model = new Indexer(
+ $this->configMock,
+ $this->actionFactoryMock,
+ $this->viewMock,
+ $this->stateFactoryMock,
+ $this->indexFactoryMock
+ );
+ }
+
+ /**
+ * @expectedException \InvalidArgumentException
+ * @expectedExceptionMessage indexer_id indexer does not exist.
+ */
+ public function testLoadWithException()
+ {
+ $indexId = 'indexer_id';
+ $this->configMock->expects($this->once())
+ ->method('get')
+ ->with($indexId)
+ ->will($this->returnValue($this->getIndexerData()));
+ $this->model->load($indexId);
+ }
+
+ public function testGetView()
+ {
+ $indexId = 'indexer_internal_name';
+ $this->viewMock->expects($this->once())
+ ->method('load')
+ ->with('view_test')
+ ->will($this->returnSelf());
+ $this->loadIndexer($indexId);
+
+ $this->assertEquals($this->viewMock, $this->model->getView());
+ }
+
+ public function testGetState()
+ {
+ $indexId = 'indexer_internal_name';
+ $stateMock = $this->getMock(
+ '\Magento\Indexer\Model\Indexer\State',
+ array('load', 'getId', 'setIndexerId', '__wakeup'),
+ array(),
+ '',
+ false
+ );
+ $stateMock->expects($this->once())
+ ->method('load')
+ ->with($indexId, 'indexer_id')
+ ->will($this->returnSelf());
+ $stateMock->expects($this->never())
+ ->method('setIndexerId');
+ $stateMock->expects($this->once())
+ ->method('getId')
+ ->will($this->returnValue(1));
+ $this->stateFactoryMock->expects($this->once())
+ ->method('create')
+ ->will($this->returnValue($stateMock));
+
+ $this->loadIndexer($indexId);
+
+ $this->assertInstanceOf('\Magento\Indexer\Model\Indexer\State', $this->model->getState());
+ }
+
+ /**
+ * @param string $mode
+ * @param string $status
+ * @param bool $statusCall
+ * @param bool $stateCall
+ * @param string $result
+ * @dataProvider indexerStatusProvider
+ */
+ public function testGetStatus($mode, $status, $statusCall, $stateCall, $result)
+ {
+ $indexId = 'indexer_internal_name';
+ $this->viewMock->expects($statusCall ? $this->exactly(2) : $this->once())
+ ->method('getId')
+ ->will($this->returnValue(1));
+ $this->viewMock->expects($this->once())
+ ->method('getMode')
+ ->will($this->returnValue($mode));
+ $this->viewMock->expects($statusCall ? $this->once() : $this->never())
+ ->method('getStatus')
+ ->will($this->returnValue($status));
+
+ if ($stateCall) {
+ $stateMock = $this->getMock(
+ '\Magento\Indexer\Model\Indexer\State',
+ array('load', 'getId', 'setIndexerId', '__wakeup', 'getStatus'),
+ array(),
+ '',
+ false
+ );
+ $stateMock->expects($this->once())
+ ->method('load')
+ ->with($indexId, 'indexer_id')
+ ->will($this->returnSelf());
+ $stateMock->expects($this->never())
+ ->method('setIndexerId');
+ $stateMock->expects($this->once())
+ ->method('getId')
+ ->will($this->returnValue(1));
+ $stateMock->expects($this->once())
+ ->method('getStatus')
+ ->will($this->returnValue($status));
+ $this->stateFactoryMock->expects($this->once())
+ ->method('create')
+ ->will($this->returnValue($stateMock));
+ }
+
+ $this->loadIndexer($indexId);
+
+ $this->assertEquals($result, $this->model->getStatus());
+ }
+
+ /**
+ * @return array
+ */
+ public function indexerStatusProvider()
+ {
+ return array(
+ 'enabled_working' => array('enabled', 'working', true, false, 'working'),
+ 'enabled_idle' => array('enabled', 'idle', true, true, 'idle'),
+ 'disabled_working' => array('disabled', 'working', false, true, 'working'),
+ 'disabled_idle' => array('disabled', 'idle', false, true, 'idle'),
+ );
+ }
+
+ public function testGetUpdated()
+ {
+ $checkValue = 1;
+ $indexId = 'indexer_internal_name';
+ $this->loadIndexer($indexId);
+
+ $this->viewMock->expects($this->any())
+ ->method('getId')
+ ->will($this->returnValue(1));
+ $this->viewMock->expects($this->once())
+ ->method('getMode')
+ ->will($this->returnValue('enabled'));
+ $this->viewMock->expects($this->any())
+ ->method('getUpdated')
+ ->will($this->returnValue($checkValue));
+
+ $stateMock = $this->getMock(
+ '\Magento\Indexer\Model\Indexer\State',
+ array('load', 'getId', 'setIndexerId', '__wakeup', 'getUpdated'),
+ array(),
+ '',
+ false
+ );
+ $stateMock->expects($this->once())
+ ->method('getUpdated')
+ ->will($this->returnValue(0));
+ $this->stateFactoryMock->expects($this->once())
+ ->method('create')
+ ->will($this->returnValue($stateMock));
+
+ $this->assertEquals($checkValue, $this->model->getUpdated());
+ }
+
+ public function testReindexAll()
+ {
+ $indexId = 'indexer_internal_name';
+ $this->loadIndexer($indexId);
+
+ $stateMock = $this->getMock(
+ '\Magento\Indexer\Model\Indexer\State',
+ array('load', 'getId', 'setIndexerId', '__wakeup', 'getStatus', 'setStatus', 'save'),
+ array(),
+ '',
+ false
+ );
+ $stateMock->expects($this->once())
+ ->method('load')
+ ->with($indexId, 'indexer_id')
+ ->will($this->returnSelf());
+ $stateMock->expects($this->never())
+ ->method('setIndexerId');
+ $stateMock->expects($this->once())
+ ->method('getId')
+ ->will($this->returnValue(1));
+ $stateMock->expects($this->exactly(2))
+ ->method('setStatus')
+ ->will($this->returnSelf());
+ $stateMock->expects($this->once())
+ ->method('getStatus')
+ ->will($this->returnValue('idle'));
+ $stateMock->expects($this->exactly(2))
+ ->method('save')
+ ->will($this->returnSelf());
+ $this->stateFactoryMock->expects($this->once())
+ ->method('create')
+ ->will($this->returnValue($stateMock));
+
+ $actionMock = $this->getMock(
+ 'Magento\Indexer\Model\ActionInterface',
+ array('executeFull', 'executeList', 'executeRow'),
+ array(),
+ '',
+ false
+ );
+ $this->actionFactoryMock->expects($this->once())
+ ->method('get')
+ ->with('Some\Class\Name')
+ ->will($this->returnValue($actionMock));
+
+ $this->model->reindexAll();
+ }
+
+ /**
+ * @expectedException \Exception
+ * @expectedExceptionMessage Test exception
+ */
+ public function testReindexAllWithException()
+ {
+ $indexId = 'indexer_internal_name';
+ $this->loadIndexer($indexId);
+
+ $stateMock = $this->getMock(
+ '\Magento\Indexer\Model\Indexer\State',
+ array('load', 'getId', 'setIndexerId', '__wakeup', 'getStatus', 'setStatus', 'save'),
+ array(),
+ '',
+ false
+ );
+ $stateMock->expects($this->once())
+ ->method('load')
+ ->with($indexId, 'indexer_id')
+ ->will($this->returnSelf());
+ $stateMock->expects($this->never())
+ ->method('setIndexerId');
+ $stateMock->expects($this->once())
+ ->method('getId')
+ ->will($this->returnValue(1));
+ $stateMock->expects($this->exactly(2))
+ ->method('setStatus')
+ ->will($this->returnSelf());
+ $stateMock->expects($this->once())
+ ->method('getStatus')
+ ->will($this->returnValue('idle'));
+ $stateMock->expects($this->exactly(2))
+ ->method('save')
+ ->will($this->returnSelf());
+ $this->stateFactoryMock->expects($this->once())
+ ->method('create')
+ ->will($this->returnValue($stateMock));
+
+ $actionMock = $this->getMock(
+ 'Magento\Indexer\Model\ActionInterface',
+ array('executeFull', 'executeList', 'executeRow'),
+ array(),
+ '',
+ false
+ );
+ $actionMock->expects($this->once())
+ ->method('executeFull')
+ ->will($this->returnCallback(function () {
+ throw new \Exception('Test exception');
+ }));
+ $this->actionFactoryMock->expects($this->once())
+ ->method('get')
+ ->with('Some\Class\Name')
+ ->will($this->returnValue($actionMock));
+
+ $this->model->reindexAll();
+ }
+
+ protected function getIndexerData()
+ {
+ return array(
+ 'indexer_id' => 'indexer_internal_name',
+ 'view_id' => 'view_test',
+ 'action_class' => 'Some\Class\Name',
+ 'title' => 'Indexer public name',
+ 'description' => 'Indexer public description',
+ );
+ }
+
+ /**
+ * @param $indexId
+ */
+ protected function loadIndexer($indexId)
+ {
+ $this->configMock->expects($this->once())
+ ->method('get')
+ ->with($indexId)
+ ->will($this->returnValue($this->getIndexerData()));
+ $this->model->load($indexId);
+ }
+}
diff --git a/dev/tests/unit/testsuite/Magento/Indexer/Model/ProcessorTest.php b/dev/tests/unit/testsuite/Magento/Indexer/Model/ProcessorTest.php
new file mode 100644
index 0000000000000..5a2025245e45d
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Indexer/Model/ProcessorTest.php
@@ -0,0 +1,140 @@
+configMock = $this->getMock('Magento\Indexer\Model\Config', array('getIndexerIds'), array(), '', false);
+ $this->indexerFactoryMock = $this->getMock(
+ 'Magento\Indexer\Model\IndexerFactory', array('create'), array(), '', false
+ );
+ $this->indexersFactoryMock = $this->getMock(
+ 'Magento\Indexer\Model\Indexer\CollectionFactory', array('create'), array(), '', false
+ );
+ $this->viewProcessorMock = $this->getMockForAbstractClass(
+ 'Magento\Mview\ProcessorInterface', array(), '', false
+ );
+ $this->model = new \Magento\Indexer\Model\Processor(
+ $this->configMock,
+ $this->indexerFactoryMock,
+ $this->indexersFactoryMock,
+ $this->viewProcessorMock
+ );
+ }
+
+ public function testReindexAllInvalid()
+ {
+ $indexers = array(
+ 'indexer1',
+ 'indexer2',
+ );
+
+ $this->configMock->expects($this->once())
+ ->method('getIndexerIds')
+ ->will($this->returnValue($indexers));
+
+ $state1Mock = $this->getMock('Magento\Indexer\Model\Indexer\State',
+ array('getStatus', '__wakeup'), array(), '', false);
+ $state1Mock->expects($this->once())
+ ->method('getStatus')
+ ->will($this->returnValue(Indexer\State::STATUS_INVALID));
+ $indexer1Mock = $this->getMock('Magento\Indexer\Model\Indexer',
+ array('load', 'getState', 'reindexAll'), array(), '', false);
+ $indexer1Mock->expects($this->once())
+ ->method('getState')
+ ->will($this->returnValue($state1Mock));
+ $indexer1Mock->expects($this->once())
+ ->method('reindexAll');
+
+ $state2Mock = $this->getMock('Magento\Indexer\Model\Indexer\State',
+ array('getStatus', '__wakeup'), array(), '', false);
+ $state2Mock->expects($this->once())
+ ->method('getStatus')
+ ->will($this->returnValue(Indexer\State::STATUS_VALID));
+ $indexer2Mock = $this->getMock('Magento\Indexer\Model\Indexer',
+ array('load', 'getState', 'reindexAll'), array(), '', false);
+ $indexer2Mock->expects($this->never())
+ ->method('reindexAll');
+ $indexer2Mock->expects($this->once())
+ ->method('getState')
+ ->will($this->returnValue($state2Mock));
+
+ $this->indexerFactoryMock->expects($this->at(0))
+ ->method('create')
+ ->will($this->returnValue($indexer1Mock));
+ $this->indexerFactoryMock->expects($this->at(1))
+ ->method('create')
+ ->will($this->returnValue($indexer2Mock));
+
+ $this->model->reindexAllInvalid();
+ }
+
+ public function testReindexAll()
+ {
+ $indexerMock = $this->getMock('Magento\Indexer\Model\Indexer', array(), array(), '', false);
+ $indexerMock->expects($this->exactly(2))
+ ->method('reindexAll');
+ $indexers = array(
+ $indexerMock,
+ $indexerMock,
+ );
+
+ $indexersMock = $this->getMock('Magento\Indexer\Model\Indexer\Collection', array(), array(), '', false);
+ $this->indexersFactoryMock->expects($this->once())
+ ->method('create')
+ ->will($this->returnValue($indexersMock));
+ $indexersMock->expects($this->once())
+ ->method('getItems')
+ ->will($this->returnValue($indexers));
+
+ $this->model->reindexAll();
+ }
+}
diff --git a/dev/tests/unit/testsuite/Magento/Indexer/XsdTest.php b/dev/tests/unit/testsuite/Magento/Indexer/XsdTest.php
new file mode 100644
index 0000000000000..373e349696563
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Indexer/XsdTest.php
@@ -0,0 +1,71 @@
+_xsdSchema = BP . '/app/code/Magento/Indexer/etc/indexer.xsd';
+ $this->_xsdValidator = new \Magento\TestFramework\Utility\XsdValidator();
+ }
+
+ /**
+ * @param string $xmlString
+ * @param array $expectedError
+ * @dataProvider schemaCorrectlyIdentifiesInvalidXmlDataProvider
+ */
+ public function testSchemaCorrectlyIdentifiesInvalidXml($xmlString, $expectedError)
+ {
+ $actualError = $this->_xsdValidator->validate($this->_xsdSchema, $xmlString);
+ $this->assertEquals($expectedError, $actualError);
+ }
+
+ public function testSchemaCorrectlyIdentifiesValidXml()
+ {
+ $xmlString = file_get_contents(__DIR__ . '/_files/valid_indexer.xml');
+ $actualResult = $this->_xsdValidator->validate($this->_xsdSchema, $xmlString);
+
+ $this->assertEmpty($actualResult);
+ }
+
+ /**
+ * Data provider with invalid xml array according to events.xsd
+ */
+ public function schemaCorrectlyIdentifiesInvalidXmlDataProvider()
+ {
+ return include(__DIR__ . '/_files/invalidIndexerXmlArray.php');
+ }
+}
diff --git a/dev/tests/unit/testsuite/Magento/Indexer/_files/indexer_config.php b/dev/tests/unit/testsuite/Magento/Indexer/_files/indexer_config.php
new file mode 100644
index 0000000000000..a2b431d93ab64
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Indexer/_files/indexer_config.php
@@ -0,0 +1,39 @@
+ ''
+ . ''
+ . ''
+ . 'Indexer public nameIndexer public description'
+ . '',
+ 'expected' => array(
+ 'indexer_internal_name' => array(
+ 'indexer_id' => 'indexer_internal_name',
+ 'view_id' => 'view01',
+ 'action_class' => 'Index\Class\Name',
+ 'title' => 'Indexer public name',
+ 'description' => 'Indexer public description',
+ ),
+ ),
+);
diff --git a/app/code/Magento/PaypalUk/etc/frontend/di.xml b/dev/tests/unit/testsuite/Magento/Indexer/_files/indexer_merged_one.xml
similarity index 53%
rename from app/code/Magento/PaypalUk/etc/frontend/di.xml
rename to dev/tests/unit/testsuite/Magento/Indexer/_files/indexer_merged_one.xml
index 603125bde6606..cf21bbe45d2da 100644
--- a/app/code/Magento/PaypalUk/etc/frontend/di.xml
+++ b/dev/tests/unit/testsuite/Magento/Indexer/_files/indexer_merged_one.xml
@@ -1,4 +1,4 @@
-
+
-
-
- paypaluk
-
-
-
-
-
-
-
- frontend
-
-
-
-
-
- /paypaluk/express
-
-
-
-
+
+ Indexer public name one
+ Indexer public description one
+
+
+ Indexer public name two
+ Indexer public description two
+
+
+ Indexer public name three
+ Indexer public description three
+
+
\ No newline at end of file
diff --git a/dev/tests/unit/testsuite/Magento/Indexer/_files/indexer_merged_two.xml b/dev/tests/unit/testsuite/Magento/Indexer/_files/indexer_merged_two.xml
new file mode 100644
index 0000000000000..5d24698a167ba
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Indexer/_files/indexer_merged_two.xml
@@ -0,0 +1,35 @@
+
+
+
+
+ Indexer public name two
+ Indexer public description two
+
+
+ Indexer public name three
+ Indexer public description three
+
+
\ No newline at end of file
diff --git a/dev/tests/unit/testsuite/Magento/Indexer/_files/indexer_one.xml b/dev/tests/unit/testsuite/Magento/Indexer/_files/indexer_one.xml
new file mode 100644
index 0000000000000..46c30a8b5d0a6
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Indexer/_files/indexer_one.xml
@@ -0,0 +1,31 @@
+
+
+
+
+ Indexer public name one
+ Indexer public description one
+
+
\ No newline at end of file
diff --git a/dev/tests/unit/testsuite/Magento/Indexer/_files/indexer_three.xml b/dev/tests/unit/testsuite/Magento/Indexer/_files/indexer_three.xml
new file mode 100644
index 0000000000000..5d24698a167ba
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Indexer/_files/indexer_three.xml
@@ -0,0 +1,35 @@
+
+
+
+
+ Indexer public name two
+ Indexer public description two
+
+
+ Indexer public name three
+ Indexer public description three
+
+
\ No newline at end of file
diff --git a/dev/tests/unit/testsuite/Magento/Indexer/_files/indexer_two.xml b/dev/tests/unit/testsuite/Magento/Indexer/_files/indexer_two.xml
new file mode 100644
index 0000000000000..6b9e2d68f1e91
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Indexer/_files/indexer_two.xml
@@ -0,0 +1,35 @@
+
+
+
+
+ Indexer public name two
+ Indexer public description two
+
+
+ Indexer public name three
+ Indexer public description three
+
+
\ No newline at end of file
diff --git a/dev/tests/unit/testsuite/Magento/Indexer/_files/invalidIndexerXmlArray.php b/dev/tests/unit/testsuite/Magento/Indexer/_files/invalidIndexerXmlArray.php
new file mode 100644
index 0000000000000..84151f7d9b7f0
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Indexer/_files/invalidIndexerXmlArray.php
@@ -0,0 +1,56 @@
+ array(
+ '',
+ array("Element 'config': Missing child element(s). Expected is ( indexer ).")),
+
+ 'indexer_with_notallowed_attribute' => array(
+ ''
+ . ''
+ .'TestTest',
+ array("Element 'indexer', attribute 'notallowed': The attribute 'notallowed' is not allowed.")),
+
+ 'indexer_without_view_attribute' => array(
+ ''
+ .'TestTest',
+ array("Element 'indexer': The attribute 'view_id' is required but missing.")),
+
+ 'indexer_duplicate_view_attribute' => array(
+ ''
+ .'TestTest'
+ .''
+ .'TestTest',
+ array("Element 'indexer': Duplicate key-sequence ['view_01'] in unique identity-constraint 'uniqueViewId'.")),
+
+ 'indexer_without_title' => array(
+ ''
+ .'Test',
+ array("Element 'description': This element is not expected. Expected is ( title ).")),
+
+ 'indexer_without_description' => array(
+ ''
+ .'Test',
+ array("Element 'indexer': Missing child element(s). Expected is ( description ).")),
+);
diff --git a/dev/tests/unit/testsuite/Magento/Indexer/_files/valid_indexer.xml b/dev/tests/unit/testsuite/Magento/Indexer/_files/valid_indexer.xml
new file mode 100644
index 0000000000000..28b00625e0fc6
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Indexer/_files/valid_indexer.xml
@@ -0,0 +1,35 @@
+
+
+
+
+ Indexer public name
+ Indexer public description
+
+
+ Indexer public name
+ Indexer public description
+
+
\ No newline at end of file
diff --git a/dev/tests/unit/testsuite/Magento/Install/App/ConsoleTest.php b/dev/tests/unit/testsuite/Magento/Install/App/ConsoleTest.php
index 277336bae3ec7..cbf3c411b2c07 100644
--- a/dev/tests/unit/testsuite/Magento/Install/App/ConsoleTest.php
+++ b/dev/tests/unit/testsuite/Magento/Install/App/ConsoleTest.php
@@ -145,7 +145,7 @@ protected function _createModel($params = array())
* @param string $testValue
* @dataProvider executeShowsRequestedDataProvider
*/
- public function testExecuteShowsRequestedData($param, $method, $testValue)
+ public function testLaunchShowsRequestedData($param, $method, $testValue)
{
$model = $this->_createModel(array($param => true));
$this->_installerMock
@@ -153,7 +153,7 @@ public function testExecuteShowsRequestedData($param, $method, $testValue)
->method($method)
->will($this->returnValue($testValue));
$this->_outputMock->expects($this->once())->method('export')->with($testValue);
- $this->assertEquals($this->_responseMock, $model->execute());
+ $this->assertEquals($this->_responseMock, $model->launch());
}
public function executeShowsRequestedDataProvider()
@@ -170,7 +170,7 @@ public function testInstallReportsSuccessMessage()
{
$model = $this->_createModel(array());
$this->_outputMock->expects($this->once())->method('success')->with($this->stringContains('successfully'));
- $this->assertEquals($this->_responseMock, $model->execute());
+ $this->assertEquals($this->_responseMock, $model->launch());
}
public function testInstallReportsEncryptionKey()
@@ -178,7 +178,7 @@ public function testInstallReportsEncryptionKey()
$model = $this->_createModel(array());
$this->_installerMock->expects($this->once())->method('install')->will($this->returnValue('enc_key'));
$this->_outputMock->expects($this->once())->method('success')->with($this->stringContains('enc_key'));
- $this->assertEquals($this->_responseMock, $model->execute());
+ $this->assertEquals($this->_responseMock, $model->launch());
}
public function testUninstallReportsSuccess()
@@ -186,7 +186,7 @@ public function testUninstallReportsSuccess()
$model = $this->_createModel(array('uninstall' => true));
$this->_installerMock->expects($this->once())->method('uninstall')->will($this->returnValue(true));
$this->_outputMock->expects($this->once())->method('success')->with($this->stringContains('Uninstalled'));
- $this->assertEquals($this->_responseMock, $model->execute());
+ $this->assertEquals($this->_responseMock, $model->launch());
}
public function testUninstallReportsIgnoreIfApplicationIsNotInstalled()
@@ -194,7 +194,7 @@ public function testUninstallReportsIgnoreIfApplicationIsNotInstalled()
$model = $this->_createModel(array('uninstall' => true));
$this->_installerMock->expects($this->once())->method('uninstall')->will($this->returnValue(false));
$this->_outputMock->expects($this->once())->method('success')->with($this->stringContains('non-installed'));
- $this->assertEquals($this->_responseMock, $model->execute());
+ $this->assertEquals($this->_responseMock, $model->launch());
}
public function testExecuteReportsErrors()
@@ -203,13 +203,13 @@ public function testExecuteReportsErrors()
$this->_installerMock->expects($this->once())->method('hasErrors')->will($this->returnValue(true));
$this->_installerMock->expects($this->once())->method('getErrors')->will($this->returnValue(array('error1')));
$this->_outputMock->expects($this->once())->method('error')->with($this->stringContains('error1'));
- $this->assertEquals($this->_responseMock, $model->execute());
+ $this->assertEquals($this->_responseMock, $model->launch());
}
public function testExecuteLoadsExtraConfig()
{
$model = $this->_createModel(array('config' => realpath(__DIR__ . '/_files/config.php')));
$this->_installerMock->expects($this->once())->method('uninstall')->will($this->returnValue(true));
- $this->assertEquals($this->_responseMock, $model->execute());
+ $this->assertEquals($this->_responseMock, $model->launch());
}
}
diff --git a/dev/tests/unit/testsuite/Magento/Install/Model/Installer/Db/Mysql4Test.php b/dev/tests/unit/testsuite/Magento/Install/Model/Installer/Db/Mysql4Test.php
index ce43f8664d24d..637d7d881bd93 100644
--- a/dev/tests/unit/testsuite/Magento/Install/Model/Installer/Db/Mysql4Test.php
+++ b/dev/tests/unit/testsuite/Magento/Install/Model/Installer/Db/Mysql4Test.php
@@ -51,7 +51,7 @@ public function testSupportEngine(array $supportedEngines, $expectedResult)
$adapterMock->expects($this->once())->method('getConnection')->will($this->returnValue($connectionMock));
$adapterFactory->expects($this->once())->method('create')->will($this->returnValue($adapterMock));
- $localConfig = $this->getMockBuilder('\Magento\App\Config')
+ $localConfig = $this->getMockBuilder('\Magento\App\Arguments')
->disableOriginalConstructor()
->getMock();
@@ -85,7 +85,7 @@ public function testGetRequiredExtensions($config, $dbExtensions, $expectedResul
'Magento\Core\Model\Resource\Type\Db\Pdo\MysqlFactory', array('create'), array(), '', false
);
$localConfig =
- $this->getMockBuilder('\Magento\App\Config')->disableOriginalConstructor()->getMock();
+ $this->getMockBuilder('\Magento\App\Arguments')->disableOriginalConstructor()->getMock();
$installer = new \Magento\Install\Model\Installer\Db\Mysql4(
$adapterFactory, $localConfig, $dbExtensions
);
diff --git a/dev/tests/unit/testsuite/Magento/Install/Model/InstallerTest.php b/dev/tests/unit/testsuite/Magento/Install/Model/InstallerTest.php
index 486fbe0b1efad..4b583942f8a75 100644
--- a/dev/tests/unit/testsuite/Magento/Install/Model/InstallerTest.php
+++ b/dev/tests/unit/testsuite/Magento/Install/Model/InstallerTest.php
@@ -46,7 +46,7 @@ class InstallerTest extends \PHPUnit_Framework_TestCase
/**
* Application config model
*
- * @var \Magento\Core\Model\ConfigInterface
+ * @var \Magento\App\ConfigInterface
*/
protected $_config;
@@ -77,7 +77,7 @@ public function setUp()
{
$this->_objectManager = new \Magento\TestFramework\Helper\ObjectManager($this);
$this->_cache = $this->getMock('\Magento\App\CacheInterface', array(), array(), '', false);
- $this->_config = $this->getMock('\Magento\Core\Model\ConfigInterface', array(), array(), '', false);
+ $this->_config = $this->getMock('\Magento\App\ReinitableConfigInterface', array(), array(), '', false);
$this->_cacheState = $this->getMock('\Magento\App\Cache\StateInterface', array(), array(), '', false);
$this->_cacheTypeList = $this->getMock('\Magento\App\Cache\TypeListInterface', array(), array(), '', false);
$this->_appState = $this->getMock('\Magento\App\State', array(), array(), '', false);
diff --git a/dev/tests/unit/testsuite/Magento/Integration/Controller/Adminhtml/IntegrationTest.php b/dev/tests/unit/testsuite/Magento/Integration/Controller/Adminhtml/IntegrationTest.php
index 7c40ff0da9373..5df13c474f980 100644
--- a/dev/tests/unit/testsuite/Magento/Integration/Controller/Adminhtml/IntegrationTest.php
+++ b/dev/tests/unit/testsuite/Magento/Integration/Controller/Adminhtml/IntegrationTest.php
@@ -51,7 +51,7 @@ class IntegrationTest extends \PHPUnit_Framework_TestCase
/** @var \Magento\Core\Model\Layout\Filter\Acl|\PHPUnit_Framework_MockObject_MockObject */
protected $_layoutFilterMock;
- /** @var \Magento\Core\Model\Config|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var \Magento\App\ConfigInterface|\PHPUnit_Framework_MockObject_MockObject */
protected $_configMock;
/** @var \Magento\Event\ManagerInterface|\PHPUnit_Framework_MockObject_MockObject */
@@ -122,7 +122,7 @@ protected function setUp()
->setMethods(array('getConfig'))
->disableOriginalConstructor()
->getMock();
- $this->_configMock = $this->getMockBuilder('Magento\Core\Model\Config')->disableOriginalConstructor()
+ $this->_configMock = $this->getMockBuilder('Magento\App\ConfigInterface')->disableOriginalConstructor()
->getMock();
$this->_appMock->expects($this->any())->method('getConfig')->will($this->returnValue($this->_configMock));
$this->_eventManagerMock = $this->getMockBuilder('Magento\Event\ManagerInterface')
@@ -647,7 +647,7 @@ protected function _createIntegrationController()
protected function _verifyLoadAndRenderLayout()
{
$map = array(
- array('Magento\Core\Model\Config', $this->_configMock),
+ array('Magento\App\ConfigInterface', $this->_configMock),
array('Magento\Core\Model\Layout\Filter\Acl', $this->_layoutFilterMock),
array('Magento\Backend\Model\Session', $this->_backendSessionMock),
array('Magento\Core\Model\Translate', $this->_translateModelMock),
diff --git a/dev/tests/unit/testsuite/Magento/Less/File/FileList/CollatorTest.php b/dev/tests/unit/testsuite/Magento/Less/File/FileList/CollatorTest.php
new file mode 100644
index 0000000000000..6f1492bfaefb2
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Less/File/FileList/CollatorTest.php
@@ -0,0 +1,88 @@
+baseFile = $this->createLayoutFile('fixture_1.less', 'Fixture_TestModule');
+ $this->themeFile = $this->createLayoutFile('fixture.less', 'Fixture_TestModule', 'area/theme/path');
+ $this->originFiles = array(
+ $this->baseFile->getFileIdentifier() => $this->baseFile,
+ $this->themeFile->getFileIdentifier() => $this->themeFile
+ );
+ $this->model = new Collator();
+ }
+
+ /**
+ * Return newly created theme layout file with a mocked theme
+ *
+ * @param string $filename
+ * @param string $module
+ * @param string|null $themeFullPath
+ * @return \PHPUnit_Framework_MockObject_MockObject|\Magento\View\Layout\File
+ */
+ protected function createLayoutFile($filename, $module, $themeFullPath = null)
+ {
+ $theme = null;
+ if ($themeFullPath !== null) {
+ $theme = $this->getMockForAbstractClass('Magento\View\Design\ThemeInterface');
+ $theme->expects($this->any())->method('getFullPath')->will($this->returnValue($themeFullPath));
+ }
+ return new \Magento\View\Layout\File($filename, $module, $theme);
+ }
+
+ public function testCollate()
+ {
+ $file = $this->createLayoutFile('test/fixture.less', 'Fixture_TestModule');
+ $expected = array(
+ $this->baseFile->getFileIdentifier() => $this->baseFile,
+ $file->getFileIdentifier() => $file
+ );
+ $result = $this->model->collate(array($file), $this->originFiles);
+ $this->assertSame($expected, $result);
+ }
+}
diff --git a/dev/tests/unit/testsuite/Magento/Less/_files/invalid.less b/dev/tests/unit/testsuite/Magento/Less/_files/invalid.less
new file mode 100644
index 0000000000000..2b0831f550613
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Less/_files/invalid.less
@@ -0,0 +1,38 @@
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Academic Free License (AFL 3.0)
+ * that is bundled with this package in the file LICENSE_AFL.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/afl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
+ */
+
+/** magento_import wrong declaration*/
+//@magento_impor "magento_import.less"; //@magento_import "magento_import.less";
+//magento_import "magento_import.less";
+//@magento_import magento_import.less";
+//@magento_import "magento_import.less;
+//@magento_import "magento_import.less"
+// @magento_import "magento_import.less";
+
+/** import wrong declaration*/
+@impor "dir/import.less"; @import "dir/import.less";
+import "dir/import.less";
+@import dir/import.less";
+@import "dir/import.less;
+@import "dir/import.less"
+@ import "dir/import.less";
diff --git a/dev/tests/unit/testsuite/Magento/Less/_files/valid.less b/dev/tests/unit/testsuite/Magento/Less/_files/valid.less
new file mode 100644
index 0000000000000..06890b797070f
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Less/_files/valid.less
@@ -0,0 +1,25 @@
+/**
+ * Magento
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Academic Free License (AFL 3.0)
+ * that is bundled with this package in the file LICENSE_AFL.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/afl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@magentocommerce.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
+ * versions in the future. If you wish to customize Magento for your
+ * needs please refer to http://www.magentocommerce.com for more information.
+ *
+ * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
+ */
+
+//@magento_import "magento_import.less";
+@import "dir/import.less";
diff --git a/dev/tests/unit/testsuite/Magento/Log/App/ShellTest.php b/dev/tests/unit/testsuite/Magento/Log/App/ShellTest.php
index 1c1d2f3239305..5cf2aae6452e8 100644
--- a/dev/tests/unit/testsuite/Magento/Log/App/ShellTest.php
+++ b/dev/tests/unit/testsuite/Magento/Log/App/ShellTest.php
@@ -61,6 +61,6 @@ public function testProcessRequest()
->with(array('entryPoint' => 'shell.php'))
->will($this->returnValue($shellMock));
$shellMock->expects($this->once())->method('run');
- $this->assertEquals($this->_responseMock, $this->_model->execute());
+ $this->assertEquals($this->_responseMock, $this->_model->launch());
}
}
diff --git a/dev/tests/unit/testsuite/Magento/Module/ManagerTest.php b/dev/tests/unit/testsuite/Magento/Module/ManagerTest.php
index 9638de7ead70f..7805d61f40662 100644
--- a/dev/tests/unit/testsuite/Magento/Module/ManagerTest.php
+++ b/dev/tests/unit/testsuite/Magento/Module/ManagerTest.php
@@ -73,7 +73,7 @@ public function testIsOutputEnabledReturnsFalseForDisabledModule()
{
$this->_outputConfig
->expects($this->any())
- ->method('getFlag')
+ ->method('isSetFlag')
->will($this->returnValue(true));
$this->assertFalse($this->_model->isOutputEnabled('Nonexisting_Module'));
}
@@ -118,7 +118,7 @@ public function testIsOutputEnabledCustomConfigPath($configValue, $moduleName, $
);
$this->_outputConfig
->expects($this->at(0))
- ->method('getFlag')
+ ->method('isSetFlag')
->with(self::XML_PATH_OUTPUT_ENABLED)
->will($this->returnValue($configValue))
;
diff --git a/dev/tests/unit/testsuite/Magento/Mview/ActionFactoryTest.php b/dev/tests/unit/testsuite/Magento/Mview/ActionFactoryTest.php
new file mode 100644
index 0000000000000..7ff1b48fa87c4
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Mview/ActionFactoryTest.php
@@ -0,0 +1,70 @@
+objectManagerMock = $this->getMock('Magento\ObjectManager', array(), array(), '', false);
+ $this->model = new \Magento\Mview\ActionFactory($this->objectManagerMock);
+ }
+
+ /**
+ * @expectedException \InvalidArgumentException
+ * @expectedExceptionMessage NotAction doesn't implement \Magento\Mview\ActionInterface
+ */
+ public function testGetWithException()
+ {
+ $notActionInterfaceMock = $this->getMock('NotAction', array(), array(), '', false);
+ $this->objectManagerMock->expects($this->once())
+ ->method('get')
+ ->with('NotAction')
+ ->will($this->returnValue($notActionInterfaceMock));
+ $this->model->get('NotAction');
+ }
+
+ public function testGet()
+ {
+ $actionInterfaceMock = $this->getMockForAbstractClass(
+ 'Magento\Mview\ActionInterface', array(), '', false
+ );
+ $this->objectManagerMock->expects($this->once())
+ ->method('get')
+ ->with('Magento\Mview\ActionInterface')
+ ->will($this->returnValue($actionInterfaceMock));
+ $this->model->get('Magento\Mview\ActionInterface');
+ $this->assertInstanceOf('Magento\Mview\ActionInterface', $actionInterfaceMock);
+ }
+}
diff --git a/dev/tests/unit/testsuite/Magento/Config/Dom/Converter/ArrayConverterTest.php b/dev/tests/unit/testsuite/Magento/Mview/Config/ConverterTest.php
similarity index 51%
rename from dev/tests/unit/testsuite/Magento/Config/Dom/Converter/ArrayConverterTest.php
rename to dev/tests/unit/testsuite/Magento/Mview/Config/ConverterTest.php
index a200da37755e5..01840079ee115 100644
--- a/dev/tests/unit/testsuite/Magento/Config/Dom/Converter/ArrayConverterTest.php
+++ b/dev/tests/unit/testsuite/Magento/Mview/Config/ConverterTest.php
@@ -17,57 +17,54 @@
* Do not edit or add to this file if you wish to upgrade Magento to newer
* versions in the future. If you wish to customize Magento for your
* needs please refer to http://www.magentocommerce.com for more information.
- *
+ *
* @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
-namespace Magento\Config\Dom\Converter;
+namespace Magento\Mview\Config;
-class ArrayConverterTest extends \PHPUnit_Framework_TestCase
+class ConverterTest extends \PHPUnit_Framework_TestCase
{
/**
- * @var \Magento\Config\Dom\Converter\ArrayConverter
+ * @var \Magento\Mview\Config\Converter|\PHPUnit_Framework_MockObject_MockObject
*/
protected $_model;
- /**
- * Path to fixtures
- *
- * @var string
- */
- protected $_fixturePath;
-
protected function setUp()
{
- $this->_model = new \Magento\Config\Dom\Converter\ArrayConverter();
- $this->_fixturePath = realpath(__DIR__ . '/../../')
- . '/_files/dom/converter/';
+ $this->_model = new \Magento\Mview\Config\Converter;
+ }
+
+ public function testConvert()
+ {
+ $data = include __DIR__ . '/../_files/mview_config.php';
+ $dom = new \DOMDocument();
+ $dom->loadXML($data['inputXML']);
+
+ $this->assertEquals($data['expected'], $this->_model->convert($dom));
}
/**
- * @param string $xml
- * @param string $array
- *
- * @dataProvider convertDataProvider
+ * @param string $xmlData
+ * @dataProvider wrongXmlDataProvider
+ * @expectedException \Exception
*/
- public function testConvert($xml, $array)
+ public function testMapThrowsExceptionWhenXmlHasWrongFormat($xmlData)
{
- $xmlPath = $this->_fixturePath . $xml;
- $expected = require ($this->_fixturePath . $array);
-
$dom = new \DOMDocument();
- $dom->load($xmlPath);
-
- $actual = $this->_model->convert($dom->childNodes);
- $this->assertEquals($expected, $actual);
+ $dom->loadXML($xmlData);
+ $this->_model->convert($dom);
}
- public function convertDataProvider()
+ /**
+ * @return array
+ */
+ public function wrongXmlDataProvider()
{
return array(
- 'no attributes' => array('no_attributes.xml', 'no_attributes.php'),
- 'with attributes' => array('with_attributes.xml', 'with_attributes.php'),
- 'cdata' => array('cdata.xml', 'cdata.php'),
+ array(
+ '',
+ )
);
}
}
diff --git a/dev/tests/unit/testsuite/Magento/Mview/Config/ReaderTest.php b/dev/tests/unit/testsuite/Magento/Mview/Config/ReaderTest.php
new file mode 100644
index 0000000000000..eb90a94ec4d9f
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Mview/Config/ReaderTest.php
@@ -0,0 +1,126 @@
+_fileResolverMock = $this->getMock(
+ 'Magento\Core\Model\Config\FileResolver', array('get'), array(), '', false
+ );
+
+ $this->_converter = $this->getMock(
+ 'Magento\Mview\Config\Converter', array('convert')
+ );
+
+ $fsDirList = $this->getMock(
+ '\Magento\Filesystem\DirectoryList', array('getDir'), array(), '', false
+ );
+ $fsDirList->expects($this->once())
+ ->method('getDir')
+ ->with(\Magento\App\Filesystem::LIB_DIR)
+ ->will($this->returnValue('stub'))
+ ;
+ $schemaLocator = new \Magento\Mview\Config\SchemaLocator($fsDirList);
+
+ $validationState = $this->getMock('Magento\Config\ValidationStateInterface');
+ $validationState->expects($this->once())->method('isValidated')->will($this->returnValue(false));
+
+ $this->_model = new \Magento\Mview\Config\Reader(
+ $this->_fileResolverMock,
+ $this->_converter,
+ $schemaLocator,
+ $validationState
+ );
+ }
+
+ /**
+ * @dataProvider readerDataProvider
+ */
+ public function testReadValidConfig($files, $expectedFile)
+ {
+ $this->_fileResolverMock->expects($this->once())
+ ->method('get')
+ ->with('mview.xml', 'scope')
+ ->will($this->returnValue($files));
+
+ $constraint = function (\DOMDocument $actual) use ($expectedFile) {
+ try {
+ $expected = file_get_contents(__DIR__ . '/../_files/' . $expectedFile);
+ \PHPUnit_Framework_Assert::assertXmlStringEqualsXmlString($expected, $actual->saveXML());
+ return true;
+ } catch (\PHPUnit_Framework_AssertionFailedError $e) {
+ return false;
+ }
+ };
+ $expectedResult = new \stdClass();
+ $this->_converter
+ ->expects($this->once())
+ ->method('convert')
+ ->with($this->callback($constraint))
+ ->will($this->returnValue($expectedResult))
+ ;
+
+ $this->assertSame($expectedResult, $this->_model->read('scope'));
+ }
+
+ /**
+ * @return array
+ */
+ public function readerDataProvider()
+ {
+ return array(
+ 'mview_merged_one' => array(
+ array(
+ 'mview_one.xml' => file_get_contents(__DIR__ . '/../_files/mview_one.xml'),
+ 'mview_two.xml' => file_get_contents(__DIR__ . '/../_files/mview_two.xml'),
+ ),
+ 'mview_merged_one.xml',
+ ),
+ 'mview_merged_two' => array(
+ array(
+ 'mview_one.xml' => file_get_contents(__DIR__ . '/../_files/mview_one.xml'),
+ 'mview_three.xml' => file_get_contents(__DIR__ . '/../_files/mview_three.xml'),
+ ),
+ 'mview_merged_two.xml',
+ ),
+ );
+ }
+}
diff --git a/dev/tests/unit/testsuite/Magento/Mview/ProcessorTest.php b/dev/tests/unit/testsuite/Magento/Mview/ProcessorTest.php
new file mode 100644
index 0000000000000..d92dffc8c669c
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Mview/ProcessorTest.php
@@ -0,0 +1,128 @@
+viewsFactoryMock = $this->getMock(
+ 'Magento\Mview\View\CollectionFactory', array('create'), array(), '', false
+ );
+ $this->model = new \Magento\Mview\Processor($this->viewsFactoryMock);
+ }
+
+ /**
+ * Return array of mocked views
+ *
+ * @param string $method
+ * @return \Magento\Mview\View[]|\PHPUnit_Framework_MockObject_MockObject[]
+ */
+ protected function getViews($method)
+ {
+ $viewMock = $this->getMock('Magento\Mview\View', array(), array(), '', false);
+ $viewMock->expects($this->exactly(2))
+ ->method($method);
+ return array(
+ $viewMock,
+ $viewMock,
+ );
+ }
+
+ /**
+ * Return view collection mock
+ *
+ * @return \Magento\Mview\View\Collection|\PHPUnit_Framework_MockObject_MockObject
+ */
+ protected function getViewsMock()
+ {
+ $viewsMock = $this->getMock('Magento\Mview\View\Collection', array(), array(), '', false);
+ $this->viewsFactoryMock->expects($this->once())
+ ->method('create')
+ ->will($this->returnValue($viewsMock));
+ return $viewsMock;
+ }
+
+ public function testUpdate()
+ {
+ $viewsMock = $this->getViewsMock();
+ $viewsMock->expects($this->once())
+ ->method('getItems')
+ ->will($this->returnValue($this->getViews('update')));
+ $viewsMock->expects($this->never())
+ ->method('getItemsByColumnValue');
+
+ $this->model->update();
+ }
+
+ public function testUpdateWithGroup()
+ {
+ $group = 'group';
+ $viewsMock = $this->getViewsMock();
+ $viewsMock->expects($this->never())
+ ->method('getItems');
+ $viewsMock->expects($this->once())
+ ->method('getItemsByColumnValue')
+ ->with($group)
+ ->will($this->returnValue($this->getViews('update')));
+
+ $this->model->update($group);
+ }
+
+ public function testClearChangelog()
+ {
+ $viewsMock = $this->getViewsMock();
+ $viewsMock->expects($this->once())
+ ->method('getItems')
+ ->will($this->returnValue($this->getViews('clearChangelog')));
+ $viewsMock->expects($this->never())
+ ->method('getItemsByColumnValue');
+
+ $this->model->clearChangelog();
+ }
+
+ public function testClearChangelogWithGroup()
+ {
+ $group = 'group';
+ $viewsMock = $this->getViewsMock();
+ $viewsMock->expects($this->never())
+ ->method('getItems');
+ $viewsMock->expects($this->once())
+ ->method('getItemsByColumnValue')
+ ->with($group)
+ ->will($this->returnValue($this->getViews('clearChangelog')));
+
+ $this->model->clearChangelog($group);
+ }
+}
diff --git a/dev/tests/unit/testsuite/Magento/Mview/View/ChangelogTest.php b/dev/tests/unit/testsuite/Magento/Mview/View/ChangelogTest.php
new file mode 100644
index 0000000000000..2d5870c89c498
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Mview/View/ChangelogTest.php
@@ -0,0 +1,177 @@
+connectionMock = $this->getMock('Magento\DB\Adapter\Pdo\Mysql', array(), array(), '', false);
+
+ $this->resourceMock = $this->getMock('Magento\App\Resource', array('getConnection'), array(), '', false, false);
+ $this->resourceMock->expects($this->once())
+ ->method('getConnection')
+ ->will($this->returnValue($this->connectionMock));
+
+ $this->model = new \Magento\Mview\View\Changelog($this->resourceMock);
+ $this->model->setViewId('ViewIdTest');
+ }
+
+ public function testInstanceOf()
+ {
+ $this->assertInstanceOf('\Magento\Mview\View\ChangelogInterface', $this->model);
+ }
+
+ /**
+ * @expectedException \Exception
+ * @expectedExceptionMessage Write DB connection is not available
+ */
+ public function testCheckConnectionException()
+ {
+ $resourceMock = $this->getMock('Magento\App\Resource', array('getConnection'), array(), '', false, false);
+ $resourceMock->expects($this->once())
+ ->method('getConnection')
+ ->will($this->returnValue(null));
+ $model = new \Magento\Mview\View\Changelog($resourceMock);
+ $model->setViewId('ViewIdTest');
+ $this->assertNull($model);
+ }
+
+ public function testGetName()
+ {
+ $this->assertEquals('ViewIdTest' . '_' . \Magento\Mview\View\Changelog::NAME_SUFFIX, $this->model->getName());
+ }
+
+ public function testGetColumnName()
+ {
+ $this->assertEquals(\Magento\Mview\View\Changelog::COLUMN_NAME, $this->model->getColumnName());
+ }
+
+ public function testGetVersionWithException()
+ {
+ $changelogTableName = 'viewIdtest_cl';
+ $connection = $this->getMock('Magento\DB\Adapter\Pdo\Mysql', array('isTableExists'), array(), '', false);
+ $connection->expects($this->once())->method('isTableExists')
+ ->with($this->equalTo($changelogTableName))
+ ->will($this->returnValue(false));
+
+ $resource = $this->getMock('Magento\App\Resource', array('getConnection'), array(), '', false, false);
+ $resource->expects($this->once())
+ ->method('getConnection')
+ ->will($this->returnValue($connection));
+ $model = new \Magento\Mview\View\Changelog($resource);
+ $model->setViewId('viewIdtest');
+ $this->setExpectedException('Exception', "Table {$changelogTableName} does not exist");
+ $model->getVersion();
+ }
+
+ public function testDropWithException()
+ {
+ $changelogTableName = 'viewIdtest_cl';
+ $connection = $this->getMock('Magento\DB\Adapter\Pdo\Mysql', array('isTableExists'), array(), '', false);
+ $connection->expects($this->once())->method('isTableExists')
+ ->with($this->equalTo($changelogTableName))
+ ->will($this->returnValue(false));
+
+ $resource = $this->getMock('Magento\App\Resource', array('getConnection'), array(), '', false, false);
+ $resource->expects($this->once())
+ ->method('getConnection')
+ ->will($this->returnValue($connection));
+ $model = new \Magento\Mview\View\Changelog($resource);
+ $model->setViewId('viewIdtest');
+ $this->setExpectedException('Exception', "Table {$changelogTableName} does not exist");
+ $model->drop();
+ }
+
+ public function testCreateWithException()
+ {
+ $changelogTableName = 'viewIdtest_cl';
+ $connection = $this->getMock('Magento\DB\Adapter\Pdo\Mysql', array('isTableExists'), array(), '', false);
+ $connection->expects($this->once())->method('isTableExists')
+ ->with($this->equalTo($changelogTableName))
+ ->will($this->returnValue(true));
+
+ $resource = $this->getMock('Magento\App\Resource', array('getConnection'), array(), '', false, false);
+ $resource->expects($this->once())
+ ->method('getConnection')
+ ->will($this->returnValue($connection));
+ $model = new \Magento\Mview\View\Changelog($resource);
+ $model->setViewId('viewIdtest');
+ $this->setExpectedException('Exception', "Table {$changelogTableName} already exist");
+ $model->create();
+ }
+
+ public function testGetListWithException()
+ {
+ $changelogTableName = 'viewIdtest_cl';
+ $connection = $this->getMock('Magento\DB\Adapter\Pdo\Mysql', array('isTableExists'), array(), '', false);
+ $connection->expects($this->once())->method('isTableExists')
+ ->with($this->equalTo($changelogTableName))
+ ->will($this->returnValue(false));
+
+ $resource = $this->getMock('Magento\App\Resource', array('getConnection'), array(), '', false, false);
+ $resource->expects($this->once())
+ ->method('getConnection')
+ ->will($this->returnValue($connection));
+ $model = new \Magento\Mview\View\Changelog($resource);
+ $model->setViewId('viewIdtest');
+ $this->setExpectedException('Exception', "Table {$changelogTableName} does not exist");
+ $model->getList(mt_rand(1, 200), mt_rand(201, 400));
+ }
+
+ public function testClearWithException()
+ {
+ $changelogTableName = 'viewIdtest_cl';
+ $connection = $this->getMock('Magento\DB\Adapter\Pdo\Mysql', array('isTableExists'), array(), '', false);
+ $connection->expects($this->once())->method('isTableExists')
+ ->with($this->equalTo($changelogTableName))
+ ->will($this->returnValue(false));
+
+ $resource = $this->getMock('Magento\App\Resource', array('getConnection'), array(), '', false, false);
+ $resource->expects($this->once())
+ ->method('getConnection')
+ ->will($this->returnValue($connection));
+ $model = new \Magento\Mview\View\Changelog($resource);
+ $model->setViewId('viewIdtest');
+ $this->setExpectedException('Exception', "Table {$changelogTableName} does not exist");
+ $model->clear(mt_rand(1, 200));
+ }
+}
diff --git a/dev/tests/unit/testsuite/Magento/Mview/View/CollectionTest.php b/dev/tests/unit/testsuite/Magento/Mview/View/CollectionTest.php
new file mode 100644
index 0000000000000..517d618a4a25f
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Mview/View/CollectionTest.php
@@ -0,0 +1,92 @@
+getMockBuilder('Magento\Data\Collection\EntityFactoryInterface')
+ ->disableOriginalConstructor()
+ ->setMethods(array('create'))
+ ->getMock();
+
+ $config = $this->getMockBuilder('Magento\Mview\ConfigInterface')
+ ->getMock();
+
+ $statesFactory = $this->getMockBuilder('Magento\Mview\View\State\CollectionFactory')
+ ->disableOriginalConstructor()
+ ->setMethods(array('create'))
+ ->getMock();
+
+ $states = $this->getMockBuilder('Magento\Mview\View\State\Collection')
+ ->setMethods(array('getItems'))
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $state = $this->getMockBuilder('Magento\Mview\View\State')
+ ->setMethods(array('getViewId', '__wakeup'))
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $state->expects($this->any())
+ ->method('getViewId')
+ ->will($this->returnValue('second_indexer_id'));
+
+ $indexer = $this->getMockBuilder('Magento\Object')
+ ->setMethods(array('load', 'setState'))
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $indexer->expects($this->once())
+ ->method('setState')
+ ->with($state);
+ $indexer->expects($this->any())
+ ->method('load')
+ ->with($this->logicalOr($indexerIdOne, $indexerIdSecond));
+
+ $entityFactory->expects($this->any())
+ ->method('create')
+ ->with('Magento\Mview\ViewInterface')
+ ->will($this->returnValue($indexer));
+
+ $statesFactory->expects($this->once())
+ ->method('create')
+ ->will($this->returnValue($states));
+
+ $config->expects($this->once())
+ ->method('getAll')
+ ->will($this->returnValue(array($indexerIdOne => 1, $indexerIdSecond => 2)));
+
+ $states->expects($this->any())
+ ->method('getItems')
+ ->will($this->returnValue(array($state)));
+
+ $collection = new \Magento\Mview\View\Collection($entityFactory, $config, $statesFactory);
+ $this->assertInstanceOf('Magento\Mview\View\Collection', $collection->loadData());
+ }
+}
diff --git a/dev/tests/unit/testsuite/Magento/Mview/ViewTest.php b/dev/tests/unit/testsuite/Magento/Mview/ViewTest.php
new file mode 100644
index 0000000000000..811394055823d
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Mview/ViewTest.php
@@ -0,0 +1,286 @@
+configMock = $this->getMock(
+ '\Magento\Mview\Config', array('get'), array(), '', false
+ );
+ $this->actionFactoryMock = $this->getMock(
+ '\Magento\Mview\ActionFactory', array('get'), array(), '', false
+ );
+ $this->stateMock = $this->getMock(
+ '\Magento\Core\Model\Mview\View\State',
+ array('getViewId', 'loadByView', 'getVersionId', 'setVersionId',
+ 'getStatus', 'setStatus', 'getMode', 'setMode', 'save', '__wakeup'),
+ array(),
+ '',
+ false
+ );
+ $this->changelogMock = $this->getMock(
+ '\Magento\Mview\View\Changelog',
+ array('getViewId', 'setViewId', 'create', 'drop', 'getVersion', 'getList'),
+ array(),
+ '',
+ false
+ );
+ $this->subscriptionFactoryMock = $this->getMock(
+ '\Magento\Mview\View\SubscriptionFactory', array('create'), array(), '', false
+ );
+ $this->model = new View(
+ $this->configMock,
+ $this->actionFactoryMock,
+ $this->stateMock,
+ $this->changelogMock,
+ $this->subscriptionFactoryMock
+ );
+ }
+
+ public function testLoad()
+ {
+ $viewId = 'view_test';
+ $this->configMock->expects($this->once())
+ ->method('get')
+ ->with($viewId)
+ ->will($this->returnValue($this->getViewData()));
+ $this->assertInstanceOf('Magento\Mview\View', $this->model->load($viewId));
+ }
+
+ /**
+ * @expectedException \InvalidArgumentException
+ * @expectedExceptionMessage view_id view does not exist.
+ */
+ public function testLoadWithException()
+ {
+ $viewId = 'view_id';
+ $this->configMock->expects($this->once())
+ ->method('get')
+ ->with($viewId)
+ ->will($this->returnValue($this->getViewData()));
+ $this->model->load($viewId);
+ }
+
+ public function testSubscribe()
+ {
+ $this->stateMock->expects($this->once())
+ ->method('getMode')
+ ->will($this->returnValue('disabled'));
+ $this->stateMock->expects($this->once())
+ ->method('setMode')
+ ->with('enabled')
+ ->will($this->returnSelf());
+ $this->changelogMock->expects($this->once())
+ ->method('create');
+ $subscriptionMock = $this->getMock('Magento\Mview\View\Subscription', array('create'), array(), '', false);
+ $subscriptionMock->expects($this->exactly(1))
+ ->method('create');
+ $this->subscriptionFactoryMock->expects($this->exactly(1))
+ ->method('create')
+ ->will($this->returnValue($subscriptionMock));
+ $this->loadView();
+ $this->model->subscribe();
+ }
+
+ public function testUnsubscribe()
+ {
+ $this->stateMock->expects($this->once())
+ ->method('getMode')
+ ->will($this->returnValue('enabled'));
+ $this->stateMock->expects($this->once())
+ ->method('setMode')
+ ->with('disabled')
+ ->will($this->returnSelf());
+ $this->changelogMock->expects($this->once())
+ ->method('drop');
+ $subscriptionMock = $this->getMock('Magento\Mview\View\Subscription', array('remove'), array(), '', false);
+ $subscriptionMock->expects($this->exactly(1))
+ ->method('remove');
+ $this->subscriptionFactoryMock->expects($this->exactly(1))
+ ->method('create')
+ ->will($this->returnValue($subscriptionMock));
+ $this->loadView();
+ $this->model->unsubscribe();
+ }
+
+ public function testUpdate()
+ {
+ $currentVersionId = 3;
+ $lastVersionId = 1;
+ $listId = array(2, 3);
+ $this->stateMock->expects($this->any())
+ ->method('getViewId')
+ ->will($this->returnValue(1));
+ $this->stateMock->expects($this->once())
+ ->method('getVersionId')
+ ->will($this->returnValue($lastVersionId));
+ $this->stateMock->expects($this->once())
+ ->method('setVersionId')
+ ->will($this->returnSelf());
+ $this->stateMock->expects($this->once())
+ ->method('getMode')
+ ->will($this->returnValue('enabled'));
+ $this->stateMock->expects($this->once())
+ ->method('getStatus')
+ ->will($this->returnValue('idle'));
+ $this->stateMock->expects($this->exactly(2))
+ ->method('setStatus')
+ ->will($this->returnSelf());
+ $this->stateMock->expects($this->exactly(2))
+ ->method('save')
+ ->will($this->returnSelf());
+
+ $this->changelogMock->expects($this->once())
+ ->method('getVersion')
+ ->will($this->returnValue($currentVersionId));
+ $this->changelogMock->expects($this->once())
+ ->method('getList')
+ ->with($lastVersionId, $currentVersionId)
+ ->will($this->returnValue($listId));
+
+ $actionMock = $this->getMock('Magento\Mview\Action', array('execute'), array(), '', false);
+ $actionMock->expects($this->once())
+ ->method('execute')
+ ->with($listId)
+ ->will($this->returnSelf());
+ $this->actionFactoryMock->expects($this->once())
+ ->method('get')
+ ->with('Some\Class\Name')
+ ->will($this->returnValue($actionMock));
+
+ $this->loadView();
+ $this->model->update();
+ }
+
+ /**
+ * @expectedException \Exception
+ * @expectedExceptionMessage Test exception
+ */
+ public function testUpdateWithException()
+ {
+ $currentVersionId = 3;
+ $lastVersionId = 1;
+ $listId = array(2, 3);
+ $this->stateMock->expects($this->any())
+ ->method('getViewId')
+ ->will($this->returnValue(1));
+ $this->stateMock->expects($this->once())
+ ->method('getVersionId')
+ ->will($this->returnValue($lastVersionId));
+ $this->stateMock->expects($this->never())
+ ->method('setVersionId');
+ $this->stateMock->expects($this->once())
+ ->method('getMode')
+ ->will($this->returnValue('enabled'));
+ $this->stateMock->expects($this->once())
+ ->method('getStatus')
+ ->will($this->returnValue('idle'));
+ $this->stateMock->expects($this->exactly(2))
+ ->method('setStatus')
+ ->will($this->returnSelf());
+ $this->stateMock->expects($this->exactly(2))
+ ->method('save')
+ ->will($this->returnSelf());
+
+ $this->changelogMock->expects($this->once())
+ ->method('getVersion')
+ ->will($this->returnValue($currentVersionId));
+ $this->changelogMock->expects($this->once())
+ ->method('getList')
+ ->with($lastVersionId, $currentVersionId)
+ ->will($this->returnValue($listId));
+
+ $actionMock = $this->getMock('Magento\Mview\Action', array('execute'), array(), '', false);
+ $actionMock->expects($this->once())
+ ->method('execute')
+ ->with($listId)
+ ->will($this->returnCallback(function () {
+ throw new \Exception('Test exception');
+ }));
+ $this->actionFactoryMock->expects($this->once())
+ ->method('get')
+ ->with('Some\Class\Name')
+ ->will($this->returnValue($actionMock));
+
+ $this->loadView();
+ $this->model->update();
+ }
+
+ protected function loadView()
+ {
+ $viewId = 'view_test';
+ $this->configMock->expects($this->once())
+ ->method('get')
+ ->with($viewId)
+ ->will($this->returnValue($this->getViewData()));
+ $this->model->load($viewId);
+ }
+
+ protected function getViewData()
+ {
+ return array(
+ 'view_id' => 'view_test',
+ 'action_class' => 'Some\Class\Name',
+ 'group' => 'some_group',
+ 'subscriptions' => array(
+ 'some_entity' => array(
+ 'name' => 'some_entity',
+ 'column' => 'entity_id',
+ ),
+ ),
+ );
+ }
+}
diff --git a/dev/tests/unit/testsuite/Magento/Mview/XsdTest.php b/dev/tests/unit/testsuite/Magento/Mview/XsdTest.php
new file mode 100644
index 0000000000000..43978a263f1ca
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Mview/XsdTest.php
@@ -0,0 +1,71 @@
+_xsdSchema = BP . '/lib/Magento/Mview/etc/mview.xsd';
+ $this->_xsdValidator = new \Magento\TestFramework\Utility\XsdValidator();
+ }
+
+ /**
+ * @param string $xmlString
+ * @param array $expectedError
+ * @dataProvider schemaCorrectlyIdentifiesInvalidXmlDataProvider
+ */
+ public function testSchemaCorrectlyIdentifiesInvalidXml($xmlString, $expectedError)
+ {
+ $actualError = $this->_xsdValidator->validate($this->_xsdSchema, $xmlString);
+ $this->assertEquals($expectedError, $actualError);
+ }
+
+ public function testSchemaCorrectlyIdentifiesValidXml()
+ {
+ $xmlString = file_get_contents(__DIR__ . '/_files/valid_mview.xml');
+ $actualResult = $this->_xsdValidator->validate($this->_xsdSchema, $xmlString);
+
+ $this->assertEmpty($actualResult);
+ }
+
+ /**
+ * Data provider with invalid xml array according to events.xsd
+ */
+ public function schemaCorrectlyIdentifiesInvalidXmlDataProvider()
+ {
+ return include(__DIR__ . '/_files/invalidMviewXmlArray.php');
+ }
+}
diff --git a/dev/tests/unit/testsuite/Magento/Mview/_files/invalidMviewXmlArray.php b/dev/tests/unit/testsuite/Magento/Mview/_files/invalidMviewXmlArray.php
new file mode 100644
index 0000000000000..377789212addc
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Mview/_files/invalidMviewXmlArray.php
@@ -0,0 +1,78 @@
+ array(
+ '',
+ array("Element 'config': Missing child element(s). Expected is ( view )."),
+ ),
+
+ 'mview_with_notallowed_attribute' => array(
+ ''
+ . ''
+ . '',
+ array("Element 'view', attribute 'notallow': The attribute 'notallow' is not allowed."),
+ ),
+
+ 'mview_without_class_attribute' => array(
+ ''
+ . '',
+ array("Element 'view': The attribute 'class' is required but missing."),
+ ),
+
+ 'mview_without_group_attribute' => array(
+ ''
+ . '',
+ array("Element 'view': The attribute 'group' is required but missing."),
+ ),
+
+ 'mview_with_empty_subscriptions' => array(
+ ''
+ . ''
+ . '',
+ array("Element 'subscriptions': Missing child element(s). Expected is ( table )."),
+ ),
+
+ 'subscriptions_without_table' => array(
+ ''
+ . ''
+ . '',
+ array("Element 'subscriptions': Missing child element(s). Expected is ( table )."),
+ ),
+
+ 'table_without_column_attribute' => array(
+ ''
+ . ''
+ . '',
+ array("Element 'table': The attribute 'entity_column' is required but missing."),
+ ),
+
+ 'subscriptions_duplicate_table' => array(
+ ''
+ . ''
+ . ''
+ . '',
+ array("Element 'table': Duplicate key-sequence ['some_entity', 'entity_id'] in unique identity-constraint "
+ . "'uniqueSubscriptionsTable'."),
+ ),
+);
diff --git a/dev/tests/unit/testsuite/Magento/Mview/_files/mview_config.php b/dev/tests/unit/testsuite/Magento/Mview/_files/mview_config.php
new file mode 100644
index 0000000000000..652b3476d2810
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Mview/_files/mview_config.php
@@ -0,0 +1,46 @@
+ ''
+ . ''
+ . ''
+ . '',
+ 'expected' => array(
+ 'view_one' => array(
+ 'view_id' => 'view_one',
+ 'action_class' => 'Ogogo\Class\One',
+ 'group' => 'some_view_group',
+ 'subscriptions' => array(
+ 'some_entity' => array(
+ 'name' => 'some_entity',
+ 'column' => 'entity_id',
+ ),
+ 'some_product_relation' => array(
+ 'name' => 'some_product_relation',
+ 'column' => 'product_id',
+ ),
+ ),
+ ),
+ ),
+);
diff --git a/dev/tests/unit/testsuite/Magento/Mview/_files/mview_merged_one.xml b/dev/tests/unit/testsuite/Magento/Mview/_files/mview_merged_one.xml
new file mode 100644
index 0000000000000..bde8447bbc0c5
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Mview/_files/mview_merged_one.xml
@@ -0,0 +1,45 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/code/Magento/Bundle/view/frontend/layout/multishipping_checkout_shipping.xml b/dev/tests/unit/testsuite/Magento/Mview/_files/mview_merged_two.xml
similarity index 61%
rename from app/code/Magento/Bundle/view/frontend/layout/multishipping_checkout_shipping.xml
rename to dev/tests/unit/testsuite/Magento/Mview/_files/mview_merged_two.xml
index 91de6ad093134..744d3c2ec505c 100644
--- a/app/code/Magento/Bundle/view/frontend/layout/multishipping_checkout_shipping.xml
+++ b/dev/tests/unit/testsuite/Magento/Mview/_files/mview_merged_two.xml
@@ -1,4 +1,4 @@
-
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/dev/tests/unit/testsuite/Magento/Mview/_files/mview_one.xml b/dev/tests/unit/testsuite/Magento/Mview/_files/mview_one.xml
new file mode 100644
index 0000000000000..fb2e5b221252c
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Mview/_files/mview_one.xml
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/dev/tests/unit/testsuite/Magento/Mview/_files/mview_three.xml b/dev/tests/unit/testsuite/Magento/Mview/_files/mview_three.xml
new file mode 100644
index 0000000000000..d495d661cdc91
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Mview/_files/mview_three.xml
@@ -0,0 +1,38 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/dev/tests/unit/testsuite/Magento/Mview/_files/mview_two.xml b/dev/tests/unit/testsuite/Magento/Mview/_files/mview_two.xml
new file mode 100644
index 0000000000000..02b3c480d9052
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Mview/_files/mview_two.xml
@@ -0,0 +1,39 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/code/Magento/PaypalUk/etc/module.xml b/dev/tests/unit/testsuite/Magento/Mview/_files/valid_mview.xml
old mode 100755
new mode 100644
similarity index 61%
rename from app/code/Magento/PaypalUk/etc/module.xml
rename to dev/tests/unit/testsuite/Magento/Mview/_files/valid_mview.xml
index 89ca2937a36d1..c4ba2a84b9835
--- a/app/code/Magento/PaypalUk/etc/module.xml
+++ b/dev/tests/unit/testsuite/Magento/Mview/_files/valid_mview.xml
@@ -1,4 +1,4 @@
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/dev/tests/unit/testsuite/Magento/ObjectManager/Config/Mapper/_files/mapped_simple_di_config.php b/dev/tests/unit/testsuite/Magento/ObjectManager/Config/Mapper/_files/mapped_simple_di_config.php
index 940b985e3f689..9c5c4c92dda60 100644
--- a/dev/tests/unit/testsuite/Magento/ObjectManager/Config/Mapper/_files/mapped_simple_di_config.php
+++ b/dev/tests/unit/testsuite/Magento/ObjectManager/Config/Mapper/_files/mapped_simple_di_config.php
@@ -24,7 +24,7 @@
return array(
'preferences' => array(
'Magento\Module\UpdaterInterface' => 'Magento\Module\Updaterter',
- 'Magento\Core\Model\AppInterface' => 'Magento\Core\Model\App\Proxy',
+ 'Magento\AppInterface' => 'Magento\Core\Model\App\Proxy',
),
'Magento\App\State' => array(
@@ -35,10 +35,10 @@
),
),
- 'Magento\Core\Model\Config_Modules' => array(
+ 'Magento\Core\Model\Config\Modules' => array(
'parameters' => array(
'storage' => array(
- 'instance' => 'Magento\Core\Model\Config\Storage_Modules',
+ 'instance' => 'Magento\Core\Model\Config\Storage\Modules',
'shared' => false
),
),
@@ -46,11 +46,11 @@
'simple_modules_plugin' => array(
'sortOrder' => 10,
'disabled' => true,
- 'instance' => 'Magento\Core\Model\Config_Modules_Plugin',
+ 'instance' => 'Magento\Core\Model\Config\Modules\Plugin',
),
'simple_modules_plugin_advanced' => array(
'sortOrder' => 0,
- 'instance' => 'Magento\Core\Model\Config_Modules_PluginAdvanced',
+ 'instance' => 'Magento\Core\Model\Config\Modules\PluginAdvanced',
),
'overridden_plugin' => array(
'sortOrder' => 30,
diff --git a/dev/tests/unit/testsuite/Magento/ObjectManager/Config/Mapper/_files/simple_di_config.xml b/dev/tests/unit/testsuite/Magento/ObjectManager/Config/Mapper/_files/simple_di_config.xml
index eb0a63b512b25..bc4af2b1efc07 100644
--- a/dev/tests/unit/testsuite/Magento/ObjectManager/Config/Mapper/_files/simple_di_config.xml
+++ b/dev/tests/unit/testsuite/Magento/ObjectManager/Config/Mapper/_files/simple_di_config.xml
@@ -26,20 +26,20 @@
-
+
Magento\App\State::PARAM_MODE
-
+
-
+
-
-
+
+
@@ -47,34 +47,39 @@
-
+
-
- 25
- Custom_Cache_Model_Http_Handler
-
-
-
- 10
-
-
-
+ -
+
+
- 25
+ - Custom_Cache_Model_Http_Handler
+
+
+ -
+
+
+
- 10
+
+
+
+
86400
-
- Magento\Core\Model\Website::CACHE_TAG
- false
- true
- 1
- 0
- 100500
-
- az-value
-
+
+ - Magento\Core\Model\Website::CACHE_TAG
+ - false
+ - true
+ - 1
+ - 0
+ - 100500
+ -
+
+ - az-value
+
Magento\Core\Model\Website::CACHE_TAG
diff --git a/dev/tests/unit/testsuite/Magento/ObjectManager/Config/XsdTest.php b/dev/tests/unit/testsuite/Magento/ObjectManager/Config/XsdTest.php
index 1d83bd2c54c18..55ed9a00aef8a 100644
--- a/dev/tests/unit/testsuite/Magento/ObjectManager/Config/XsdTest.php
+++ b/dev/tests/unit/testsuite/Magento/ObjectManager/Config/XsdTest.php
@@ -59,14 +59,6 @@ public function testSchemaCorrectlyIdentifiesInvalidXml($xmlString, $expectedErr
$this->assertEquals($expectedError, $actualError);
}
- public function testSchemaCorrectlyIdentifiesValidXml()
- {
- $xmlString = file_get_contents(__DIR__ . '/_files/valid_config.xml');
- $actualResult = $this->_xsdValidator->validate($this->_xsdSchema, $xmlString);
-
- $this->assertEmpty($actualResult);
- }
-
/**
* Data provider with invalid xml array according to events.xsd
*/
@@ -74,4 +66,12 @@ public function schemaCorrectlyIdentifiesInvalidXmlDataProvider()
{
return include(__DIR__ . '/_files/invalidConfigXmlArray.php');
}
+
+ public function testSchemaCorrectlyIdentifiesValidXml()
+ {
+ $xmlString = file_get_contents(__DIR__ . '/_files/valid_config.xml');
+ $actualResult = $this->_xsdValidator->validate($this->_xsdSchema, $xmlString);
+
+ $this->assertEmpty($actualResult, join("\n", $actualResult));
+ }
}
diff --git a/dev/tests/unit/testsuite/Magento/ObjectManager/Config/_files/invalidConfigXmlArray.php b/dev/tests/unit/testsuite/Magento/ObjectManager/Config/_files/invalidConfigXmlArray.php
index d8b670952118c..ea7a1b3f24dad 100644
--- a/dev/tests/unit/testsuite/Magento/ObjectManager/Config/_files/invalidConfigXmlArray.php
+++ b/dev/tests/unit/testsuite/Magento/ObjectManager/Config/_files/invalidConfigXmlArray.php
@@ -30,65 +30,273 @@
'',
array("Element 'preference': The attribute 'type' is required but missing.")),
'preferences_with_same_for_attribute_value' => array(
- ''
- . '',
+ '
+
+
+
+ ',
array("Element 'preference': Duplicate key-sequence ['Some_For_Name'] in unique "
. "identity-constraint 'uniquePreference'.")),
- 'preferences_with_notallowed_attribute' => array(
- ''
- . '',
- array("Element 'preference', attribute 'notallowed': The attribute 'notallowed' is not allowed.")),
+ 'preferences_with_forbidden_attribute' => array(
+ '
+ ',
+ array("Element 'preference', attribute 'forbidden': The attribute 'forbidden' is not allowed.")),
'type_without_required_name_attribute' => array(
'',
array("Element 'type': The attribute 'name' is required but missing.")),
'type_with_same_name_attribute_value' => array(
- '',
+ '
+
+
+
+ ',
array("Element 'type': Duplicate key-sequence ['Some_Type_name'] in unique identity-constraint 'uniqueType'.")),
- 'type_with_notallowed_attribute' => array(
- '',
- array("Element 'type', attribute 'notallowed': The attribute 'notallowed' is not allowed.")),
+ 'type_with_forbidden_attribute' => array(
+ '',
+ array("Element 'type', attribute 'forbidden': The attribute 'forbidden' is not allowed.")),
'type_shared_attribute_with_invalid_value' => array(
'',
array("Element 'type', attribute 'shared': 'test' is not a valid value of the atomic type 'xs:boolean'.")),
- 'type_param_value_with_notallowed_attribute' => array(
- ''
- . '',
- array("Element 'value', attribute 'notallowed': The attribute 'notallowed' is not allowed.")),
+ 'type_param_value_with_forbidden_attribute' => array(
+ '
+
+
+
+
+ ',
+ array("Element 'value', attribute 'forbidden': The attribute 'forbidden' is not allowed.")),
+ 'type_param_empty' => array(
+ '',
+ array("Element 'param': Missing child element(s). Expected is one of ( instance, value, array ).")),
'type_param_without_required_name_attribute' => array(
- '',
+ '
+
+
+ ',
array("Element 'param': The attribute 'name' is required but missing.")),
'type_param_instance_without_required_type_attribute' => array(
- ''
- . '',
+ '
+ ',
array("Element 'instance': The attribute 'type' is required but missing.")),
'type_param_instance_with_invalid_shared_value' => array(
- ''
- . '',
+ '
+
+
+
+
+
+
+ ',
array("Element 'instance', attribute 'shared': 'string' is not a valid value of the atomic "
. "type 'xs:boolean'.")),
- 'type_instance_with_notallowed_attribute' => array(
- ''
- . '',
- array("Element 'instance', attribute 'notallowed': The attribute 'notallowed' is not allowed.")),
+ 'type_instance_with_forbidden_attribute' => array(
+ '
+
+
+
+
+
+
+ ',
+ array("Element 'instance', attribute 'forbidden': The attribute 'forbidden' is not allowed.")),
'type_plugin_without_required_name_attribute' => array(
'',
array("Element 'plugin': The attribute 'name' is required but missing.")),
- 'type_plugin_with_notallowed_attribute' => array(
- ''
- . '',
- array("Element 'plugin', attribute 'notallowed': The attribute 'notallowed' is not allowed.")),
+ 'type_plugin_with_forbidden_attribute' => array(
+ '
+ ',
+ array("Element 'plugin', attribute 'forbidden': The attribute 'forbidden' is not allowed.")),
'type_plugin_disabled_attribute_invalid_value' => array(
- ''
- . '',
+ '
+ ',
array("Element 'plugin', attribute 'disabled': 'string' is not a valid value of the atomic "
. "type 'xs:boolean'.")),
'type_plugin_sortorder_attribute_invalid_value' => array(
- ''
- . '',
+ '
+ ',
array("Element 'plugin', attribute 'sortOrder': 'string' is not a valid value of the atomic type 'xs:int'.")),
'type_same_name_attribute_value' => array(
- '',
+ '
+
+
+
+ ',
array("Element 'type': Duplicate key-sequence ['Some_Name'] in unique identity-constraint 'uniqueType'.")),
+ 'type_value_forbidden_element' => array(
+ '
+
+
+
+
+
+
+
+
+ ',
+ array("Element 'value': Element content is not allowed, because the content type is a simple type definition.")
+ ),
+ 'type_param_several_allowed_elements' => array(
+ '
+
+
+
+ value
+
+ - value
+
+
+
+ ',
+ array("Element 'array': This element is not expected.")
+ ),
+ 'type_array_empty' => array(
+ '
+
+
+
+
+
+
+ ',
+ array("Element 'array': Missing child element(s). Expected is ( item ).")
+ ),
+ 'type_array_forbidden_argument' => array(
+ '
+
+
+
+
+ - value
+
+
+
+ ',
+ array("Element 'array', attribute 'forbidden': The attribute 'forbidden' is not allowed.")
+ ),
+ 'type_array_forbidden_element' => array(
+ '
+
+
+
+
+
+ - value
+
+
+
+ ',
+ array("Element 'forbidden': This element is not expected. Expected is ( item ).")
+ ),
+ 'type_array_item_missed_argument' => array(
+ '
+
+
+
+
+ - value
+
+
+
+ ',
+ array("Element 'item': The attribute 'key' is required but missing.")
+ ),
+ 'type_array_item_name_argument (difference between item and param)' => array(
+ '
+
+
+
+
+ - value
+
+
+
+ ',
+ array("Element 'item', attribute 'name': The attribute 'name' is not allowed.")
+ ),
+ 'type_array_item_empty_argument' => array(
+ '
+
+
+
+
+
+
+
+
+ ',
+ array("Element 'item': Missing child element(s). Expected is one of ( instance, value, array ).")
+ ),
+ 'type_array_item_forbidden_element' => array(
+ '
+
+
+
+
+ - value
+
+
+
+ ',
+ array("Element 'forbidden': This element is not expected. Expected is one of ( instance, value, array ).")
+ ),
+ 'type_array_item_same_keys' => array(
+ '
+
+
+
+
+ - value
+ - value
+
+
+
+ ',
+ array("Element 'item': Duplicate key-sequence ['key'] in unique identity-constraint 'uniqueArrayIndex'.")
+ ),
+ 'type_array_item_same_keys_in_nested_array' => array(
+ '
+
+
+
+
+ -
+
+
- value
+ - value
+
+
+
+
+
+ ',
+ array("Element 'item': Duplicate key-sequence ['key'] in unique identity-constraint 'uniqueArrayIndex'.")
+ ),
+ 'type_array_item_value_forbidden_argument' => array(
+ '
+
+
+
+
+ - value
+
+
+
+ ',
+ array("Element 'value', attribute 'forbidden': The attribute 'forbidden' is not allowed.")
+ ),
+ 'type_array_item_value_forbidden_element' => array(
+ '
+
+
+
+
+
+
+
+
+ ',
+ array("Element 'value': Element content is not allowed, because the content type is a simple type definition.")
+ ),
'virtualtype_without_required_name_attribute' => array(
'',
array("Element 'virtualType': The attribute 'name' is required but missing.")),
@@ -96,16 +304,21 @@
'',
array("Element 'virtualType', attribute 'shared': 'string' is not a valid value of the atomic "
. "type 'xs:boolean'.")),
- 'virtualtype_with_notallowed_attribute' => array(
- '',
- array("Element 'virtualType', attribute 'notallowed': The attribute 'notallowed' is not allowed.")),
+ 'virtualtype_with_forbidden_attribute' => array(
+ '',
+ array("Element 'virtualType', attribute 'forbidden': The attribute 'forbidden' is not allowed.")),
'virtualtype_with_same_name_attribute_value' => array(
'',
array("Element 'virtualType': Duplicate key-sequence ['test_name'] in unique"
. " identity-constraint 'uniqueVirtualType'.")),
'virtualtype_with_same_param_name_attribute' => array(
- ''
- . '',
+ '
+
+
+ value
+ value
+
+ ',
array("Element 'param': Duplicate key-sequence ['same_param_name'] in unique "
. "identity-constraint 'uniqueVirtualTypeParam'.")),
);
diff --git a/dev/tests/unit/testsuite/Magento/ObjectManager/Config/_files/valid_config.xml b/dev/tests/unit/testsuite/Magento/ObjectManager/Config/_files/valid_config.xml
index 5db3b39f59d83..110dbfb89d240 100644
--- a/dev/tests/unit/testsuite/Magento/ObjectManager/Config/_files/valid_config.xml
+++ b/dev/tests/unit/testsuite/Magento/ObjectManager/Config/_files/valid_config.xml
@@ -26,13 +26,32 @@
-
-
-
- value
- 2
-
-
+
+
+ - value
+ - 2
+
+
+
+
+ -
+
+
- value
+ - 2
+
+
+ -
+
+
- value
+ -
+
+
- value
+ - 2
+
+
+
+
+
@@ -40,13 +59,32 @@
-
-
-
- value
- 2
-
-
+
+
+ - value
+
+
+
+
+
+ -
+
+
- value
+
+
+
+ -
+
+
- value
+ -
+
+
- value
+
+
+
+
+
+
some_value
diff --git a/dev/tests/unit/testsuite/Magento/PageCache/Controller/BlockTest.php b/dev/tests/unit/testsuite/Magento/PageCache/Controller/BlockTest.php
new file mode 100644
index 0000000000000..6f59c3ccdabde
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/PageCache/Controller/BlockTest.php
@@ -0,0 +1,180 @@
+layoutMock = $this->getMockBuilder('Magento\Core\Model\Layout')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $contextMock = $this->getMockBuilder('Magento\App\Action\Context')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->requestMock = $this->getMockBuilder('Magento\App\Request\Http')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->responseMock = $this->getMockBuilder('Magento\App\Response\Http')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->viewMock = $this->getMockBuilder('Magento\App\View')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $contextMock->expects($this->any())->method('getRequest')->will($this->returnValue($this->requestMock));
+ $contextMock->expects($this->any())->method('getResponse')->will($this->returnValue($this->responseMock));
+ $contextMock->expects($this->any())->method('getView')->will($this->returnValue($this->viewMock));
+
+ $this->controller = new \Magento\PageCache\Controller\Block($contextMock);
+ }
+
+ public function testRenderActionNotAjax()
+ {
+ $this->requestMock->expects($this->once())->method('isAjax')->will($this->returnValue(false));
+ $this->requestMock->expects($this->once())->method('setActionName')->will($this->returnValue('noroute'));
+ $this->requestMock->expects($this->once())->method('setDispatched')->will($this->returnValue(false));
+ $result = $this->controller->renderAction();
+ $this->assertNull($result);
+ }
+
+ /**
+ * Test no params: blocks, handles
+ */
+ public function testRenderActionNoParams()
+ {
+ $this->requestMock->expects($this->once())->method('isAjax')->will($this->returnValue(true));
+ $this->requestMock->expects($this->at(1))
+ ->method('getParam')
+ ->with($this->equalTo('blocks'), $this->equalTo([]))
+ ->will($this->returnValue([]));
+ $this->requestMock->expects($this->at(2))
+ ->method('getParam')
+ ->with($this->equalTo('handles'), $this->equalTo([]))
+ ->will($this->returnValue([]));
+ $result = $this->controller->renderAction();
+ $this->assertNull($result);
+ }
+
+ public function testRenderAction()
+ {
+ $blocks = array('block1', 'block2');
+ $handles = array('handle1', 'handle2');
+ $expectedData = array('block1' => 'data1', 'block2' => 'data2');
+ // one year
+ $maxAge = 365 * 24 * 60 * 60;
+
+ $blockInstance1 = $this->getMockForAbstractClass(
+ 'Magento\View\Element\AbstractBlock', array(), '', false, true, true, array('toHtml')
+ );
+ $blockInstance1->expects($this->once())->method('toHtml')->will($this->returnValue($expectedData['block1']));
+
+ $blockInstance2 = $this->getMockForAbstractClass(
+ 'Magento\View\Element\AbstractBlock', array(), '', false, true, true, array('toHtml')
+ );
+ $blockInstance2->expects($this->once())->method('toHtml')->will($this->returnValue($expectedData['block2']));
+
+ $this->requestMock->expects($this->once())->method('isAjax')->will($this->returnValue(true));
+ $this->requestMock->expects($this->at(1))
+ ->method('getParam')
+ ->with($this->equalTo('blocks'), $this->equalTo([]))
+ ->will($this->returnValue($blocks));
+ $this->requestMock->expects($this->at(2))
+ ->method('getParam')
+ ->with($this->equalTo('handles'), $this->equalTo([]))
+ ->will($this->returnValue($handles));
+ $this->viewMock->expects($this->once())
+ ->method('loadLayout')
+ ->with($this->equalTo($handles));
+ $this->viewMock->expects($this->any())
+ ->method('getLayout')
+ ->will($this->returnValue($this->layoutMock));
+ $this->layoutMock->expects($this->at(0))
+ ->method('getBlock')
+ ->with($this->equalTo($blocks[0]))
+ ->will($this->returnValue($blockInstance1));
+ $this->layoutMock->expects($this->at(1))
+ ->method('getBlock')
+ ->with($this->equalTo($blocks[1]))
+ ->will($this->returnValue($blockInstance2));
+
+ $this->responseMock->expects($this->at(0))
+ ->method('setHeader')
+ ->with(
+ $this->equalTo('cache-control'),
+ $this->equalTo('private, max-age=' . $maxAge),
+ $this->equalTo(true)
+ );
+ $this->responseMock->expects($this->at(1))
+ ->method('setHeader')
+ ->with($this->equalTo('expires'));
+ $this->responseMock->expects($this->at(2))
+ ->method('appendBody')
+ ->with($this->equalTo(json_encode($expectedData)));
+
+ $this->controller->renderAction();
+ }
+}
diff --git a/dev/tests/unit/testsuite/Magento/PageCache/Helper/DataTest.php b/dev/tests/unit/testsuite/Magento/PageCache/Helper/DataTest.php
new file mode 100644
index 0000000000000..ca95859ee108e
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/PageCache/Helper/DataTest.php
@@ -0,0 +1,83 @@
+getMockBuilder('\Magento\App\Helper\Context')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->configMock = $this->getMockBuilder('\Magento\App\Config')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->helper = new \Magento\PageCache\Helper\Data($context, $this->configMock);
+ }
+
+ public function testGetPublicMaxAgeCache()
+ {
+ $age = 0;
+ $this->configMock->expects($this->once())
+ ->method('getValue')
+ ->with($this->equalTo(\Magento\PageCache\Helper\Data::PUBLIC_MAX_AGE_PATH))
+ ->will($this->returnValue($age));
+ $data = $this->helper->getPublicMaxAgeCache();
+ $this->assertEquals($age, $data);
+ }
+
+ public function testMaxAgeCache()
+ {
+ // one year
+ $age = 365 * 24 * 60 * 60;
+ $this->assertEquals($age, \Magento\PageCache\Helper\Data::PRIVATE_MAX_AGE_CACHE);
+ }
+}
diff --git a/dev/tests/unit/testsuite/Magento/PageCache/Model/App/FrontController/HeaderPluginTest.php b/dev/tests/unit/testsuite/Magento/PageCache/Model/App/FrontController/HeaderPluginTest.php
index 75075328a468f..2dea378966809 100644
--- a/dev/tests/unit/testsuite/Magento/PageCache/Model/App/FrontController/HeaderPluginTest.php
+++ b/dev/tests/unit/testsuite/Magento/PageCache/Model/App/FrontController/HeaderPluginTest.php
@@ -40,63 +40,121 @@ class HeaderPluginTest extends \PHPUnit_Framework_TestCase
protected $layoutMock;
/**
- * @var \Magento\Core\Model\ConfigInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var \Magento\App\ConfigInterface|\PHPUnit_Framework_MockObject_MockObject
*/
protected $configMock;
-
+
/**
* @var \Magento\App\Response\Http|\PHPUnit_Framework_MockObject_MockObject
*/
protected $responseMock;
+ /**
+ * @var \Magento\PageCache\Model\Version|\PHPUnit_Framework_MockObject_MockObject
+ */
+ protected $versionMock;
+
+ /**
+ * @var \Magento\PageCache\Helper\Data|\PHPUnit_Framework_MockObject_MockObject
+ */
+ protected $helperMock;
+
/**
* SetUp
*/
protected function setUp()
{
$this->layoutMock = $this->getMock('Magento\Core\Model\Layout', array(), array(), '', false);
- $this->configMock = $this->getMock('Magento\Core\Model\ConfigInterface', array(), array(), '', false);
+ $this->configMock = $this->getMock('Magento\App\ConfigInterface', array(), array(), '', false);
$this->responseMock = $this->getMock('Magento\App\Response\Http', array(), array(), '', false);
- $this->plugin = new HeaderPlugin($this->layoutMock, $this->configMock);
+ $this->helperMock = $this->getMock('Magento\PageCache\Helper\Data', array(), array(), '', false);
+ $this->versionMock = $this->getMockBuilder('Magento\PageCache\Model\Version')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->plugin = new HeaderPlugin($this->layoutMock, $this->configMock, $this->helperMock, $this->versionMock);
}
/**
- * data providers for response headers
+ * Test if layout is not cacheable
*/
- public function headersCachableDataProvider()
+ public function testAfterDispatchNotCacheable()
{
- return array(
- array(false, false, '10', 'no-store, no-cache, must-revalidate, max-age=0', 'no-cache'),
- array(true, false, '20', 'public, max-age=20', 'cache'),
- array(true, true, '30', 'private, max-age=30', 'cache'),
- );
+ $pragma = 'no-cache';
+ $cacheControl = 'no-store, no-cache, must-revalidate, max-age=0';
+
+ $this->layoutMock->expects($this->once())
+ ->method('isCacheable')
+ ->will($this->returnValue(false));
+
+ $this->responseMock->expects($this->at(0))
+ ->method('setHeader')
+ ->with($this->equalTo('pragma'), $this->equalTo($pragma), $this->equalTo(true));
+ $this->responseMock->expects($this->at(1))
+ ->method('setHeader')
+ ->with($this->equalTo('cache-control'), $this->equalTo($cacheControl), $this->equalTo(true));
+ $this->responseMock->expects($this->at(2))
+ ->method('setHeader')
+ ->with($this->equalTo('expires'));
+
+ $this->versionMock->expects($this->once())->method('process');
+
+ $this->plugin->afterDispatch($this->responseMock);
}
/**
- * test response headers after dispatch, without cache
- *
- * @dataProvider headersCachableDataProvider
+ * Testing that `cache-control` already exists
*/
- public function testAfterDispatchCacheable($isCacheable, $isPrivate, $maxAge, $cacheControl, $pragma)
+ public function testAfterDispatchPrivateCache()
{
+ $pragma = 'cache';
+
$this->layoutMock->expects($this->once())
->method('isCacheable')
- ->will($this->returnValue($isCacheable));
- $this->layoutMock->expects($this->any())
- ->method('isPrivate')
- ->will($this->returnValue($isPrivate));
- $this->configMock->expects($this->any())
- ->method('getValue')
- ->with('system/headers/max-age')
- ->will($this->returnValue($maxAge));
+ ->will($this->returnValue(true));
$this->responseMock->expects($this->at(0))
->method('setHeader')
- ->with('pragma', $pragma);
+ ->with($this->equalTo('pragma'), $this->equalTo($pragma), $this->equalTo(true));
+ $this->responseMock->expects($this->at(1))
+ ->method('getHeader')
+ ->with($this->equalTo('cache-control'))
+ ->will($this->returnValue(true));
+
+ $this->versionMock->expects($this->once())->method('process');
+
+ $this->plugin->afterDispatch($this->responseMock);
+ }
+
+ /**
+ * Test setting public headers
+ */
+ public function testAfterDispatchPublicCache()
+ {
+ $maxAge = 0;
+ $pragma = 'cache';
+ $cacheControl = 'public, max-age=' . $maxAge;
+
+ $this->layoutMock->expects($this->once())
+ ->method('isCacheable')
+ ->will($this->returnValue(true));
+
+ $this->helperMock->expects($this->once())->method('getPublicMaxAgeCache')->will($this->returnValue(0));
+ $this->responseMock->expects($this->at(0))
+ ->method('setHeader')
+ ->with($this->equalTo('pragma'), $this->equalTo($pragma), $this->equalTo(true));
$this->responseMock->expects($this->at(1))
+ ->method('getHeader')
+ ->with($this->equalTo('cache-control'))
+ ->will($this->returnValue(false));
+ $this->responseMock->expects($this->at(2))
->method('setHeader')
- ->with('cache-control', $cacheControl);
+ ->with($this->equalTo('cache-control'), $this->equalTo($cacheControl), $this->equalTo(true));
+ $this->responseMock->expects($this->at(3))
+ ->method('setHeader')
+ ->with($this->equalTo('expires'));
+
+ $this->versionMock->expects($this->once())->method('process');
$this->plugin->afterDispatch($this->responseMock);
}
diff --git a/dev/tests/unit/testsuite/Magento/PageCache/Model/VersionTest.php b/dev/tests/unit/testsuite/Magento/PageCache/Model/VersionTest.php
new file mode 100644
index 0000000000000..655979f1c7fed
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/PageCache/Model/VersionTest.php
@@ -0,0 +1,98 @@
+cookieMock = $this->getMock('Magento\Stdlib\Cookie', array('set'), array(), '', false);
+ $this->requestMock = $this->getMock('Magento\App\Request\Http', array('isPost'), array(), '', false);
+ $this->versionInstance = new Version($this->cookieMock, $this->requestMock);
+ }
+
+ /**
+ * Handle private content version cookie
+ * Set cookie if it is not set.
+ * Increment version on post requests.
+ * In all other cases do nothing.
+ */
+ /**
+ * @dataProvider processProvider
+ * @param bool $isPost
+ */
+ public function testProcess($isPost)
+ {
+ $this->requestMock->expects($this->once())
+ ->method('isPost')
+ ->will($this->returnValue($isPost));
+ if ($isPost) {
+ $this->cookieMock->expects($this->once())->method('set');
+ }
+ $this->versionInstance->process();
+ }
+
+ /**
+ * Data provider for testProcess
+ * @return array
+ */
+ public function processProvider()
+ {
+ return array(
+ array(true),
+ array(false)
+ );
+ }
+}
diff --git a/dev/tests/unit/testsuite/Magento/Persistent/Helper/DataTest.php b/dev/tests/unit/testsuite/Magento/Persistent/Helper/DataTest.php
index ca2dd5de61c28..fc37cc190e6f2 100644
--- a/dev/tests/unit/testsuite/Magento/Persistent/Helper/DataTest.php
+++ b/dev/tests/unit/testsuite/Magento/Persistent/Helper/DataTest.php
@@ -27,7 +27,7 @@
class DataTest extends \PHPUnit_Framework_TestCase
{
/**
- * @var \Magento\Core\Model\Config|PHPUnit_Framework_MockObject_MockObject
+ * @var \Magento\Module\Dir\Reader|\PHPUnit_Framework_MockObject_MockObject
*/
protected $_modulesReader;
diff --git a/dev/tests/unit/testsuite/Magento/Sales/Block/Adminhtml/Order/Create/Search/Grid/Renderer/QtyTest.php b/dev/tests/unit/testsuite/Magento/Sales/Block/Adminhtml/Order/Create/Search/Grid/Renderer/QtyTest.php
new file mode 100644
index 0000000000000..88bd2736cb434
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Sales/Block/Adminhtml/Order/Create/Search/Grid/Renderer/QtyTest.php
@@ -0,0 +1,82 @@
+rowMock =
+ $this->getMock('Magento\Object', array('getTypeId', 'getIndex'),
+ array(), '', false);
+ $this->typeConfigMock = $this->getMock('Magento\Catalog\Model\ProductTypes\ConfigInterface');
+ $this->renderer = $helper->getObject(
+ 'Magento\Sales\Block\Adminhtml\Order\Create\Search\Grid\Renderer\Qty',
+ array(
+ 'typeConfig' => $this->typeConfigMock
+ )
+ );
+ }
+
+ public function testRender()
+ {
+ $expected = '';
+ $this->typeConfigMock
+ ->expects($this->any())
+ ->method('isProductSet')
+ ->with('id')
+ ->will($this->returnValue(true));
+ $this->rowMock->expects($this->once())->method('getTypeId')->will($this->returnValue('id'));
+ $columnMock =
+ $this->getMock('Magento\Backend\Block\Widget\Grid\Column',
+ array('getInlineCss', 'getId'), array(), '', false);
+ $this->renderer->setColumn($columnMock);
+
+ $columnMock->expects($this->once())->method('getId')->will($this->returnValue('id_name'));
+ $columnMock->expects($this->once())->method('getInlineCss')->will($this->returnValue('inline_css'));
+
+ $this->assertEquals($expected, $this->renderer->render($this->rowMock));
+ }
+}
+
diff --git a/dev/tests/unit/testsuite/Magento/Sales/Block/Adminhtml/Order/Create/Sidebar/AbstractSidebarTest.php b/dev/tests/unit/testsuite/Magento/Sales/Block/Adminhtml/Order/Create/Sidebar/AbstractSidebarTest.php
new file mode 100644
index 0000000000000..c79744a6c8a0f
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Sales/Block/Adminhtml/Order/Create/Sidebar/AbstractSidebarTest.php
@@ -0,0 +1,75 @@
+itemMock = $this->getMock('Magento\Object', array('getQty'), array(), '', false);
+ $this->abstractSidebar =
+ $helper->getObject('Magento\Sales\Block\Adminhtml\Order\Create\Sidebar\AbstractSidebar', array());
+ }
+
+
+ /**
+ * @param int $itemQty
+ * @param int|bool $qty
+ * @param int $expectedValue
+ * @dataProvider getItemQtyDataProvider
+ */
+ public function testGetItemQty($itemQty, $qty, $expectedValue)
+ {
+ $this->itemMock->expects($this->exactly($itemQty))->method('getQty')->will($this->returnValue($qty));
+ $this->assertEquals($expectedValue, $this->abstractSidebar->getItemQty($this->itemMock));
+ }
+
+ public function getItemQtyDataProvider()
+ {
+ return array(
+ 'whenQtyIsset' => array(2, 10, 10),
+ 'whenQtyNotIsset' => array(1, false, 1)
+ );
+ }
+
+ public function testIsConfigurationRequired()
+ {
+ $productTypeMock = $this->getMock('Magento\Catalog\Model\Product\Type', array(), array(), '', false);
+ $this->assertEquals(false, $this->abstractSidebar->isConfigurationRequired($productTypeMock));
+ }
+}
+
diff --git a/dev/tests/unit/testsuite/Magento/Sales/Block/Items/AbstractTest.php b/dev/tests/unit/testsuite/Magento/Sales/Block/Items/AbstractTest.php
index b9c9917742708..1736965db12a5 100644
--- a/dev/tests/unit/testsuite/Magento/Sales/Block/Items/AbstractTest.php
+++ b/dev/tests/unit/testsuite/Magento/Sales/Block/Items/AbstractTest.php
@@ -35,17 +35,22 @@ protected function setUp()
public function testGetItemRenderer()
{
- $renderer = $this->getMock('Magento\View\Element\AbstractBlock', array('setRenderedBlock'), array(), '', false);
+ $renderer = $this->getMock('Magento\View\Element\RendererList', array(), array(), '', false);
+
+ $renderer->expects($this->once())->method('getRenderer')
+ ->with('some-type', AbstractItems::DEFAULT_TYPE)->will($this->returnValue('rendererObject'));
+
$layout = $this->getMock('Magento\Core\Model\Layout', array(
'getChildName', 'getBlock'
), array(), '', false);
- $layout->expects($this->at(0))
+
+ $layout->expects($this->once())
->method('getChildName')
- ->with(null, 'some-type')
- ->will($this->returnValue('some-block-name'));
- $layout->expects($this->at(1))
+ ->will($this->returnValue('renderer.list'));
+
+ $layout->expects($this->once())
->method('getBlock')
- ->with('some-block-name')
+ ->with('renderer.list')
->will($this->returnValue($renderer));
/** @var $block \Magento\Sales\Block\Items\AbstractItems */
@@ -55,31 +60,21 @@ public function testGetItemRenderer()
))
));
- $renderer->expects($this->once())
- ->method('setRenderedBlock')
- ->with($block);
-
- $this->assertSame($renderer, $block->getItemRenderer('some-type'));
+ $this->assertSame('rendererObject', $block->getItemRenderer('some-type'));
}
/**
* @expectedException \RuntimeException
- * @expectedExceptionMessage Renderer for type "some-type" does not exist.
+ * @expectedExceptionMessage Renderer list for block "" is not defined
*/
public function testGetItemRendererThrowsExceptionForNonexistentRenderer()
{
- $renderer = $this->getMock('StdClass');
$layout = $this->getMock('Magento\Core\Model\Layout', array(
'getChildName', 'getBlock'
), array(), '', false);
- $layout->expects($this->at(0))
+ $layout->expects($this->once())
->method('getChildName')
- ->with(null, 'some-type')
- ->will($this->returnValue('some-block-name'));
- $layout->expects($this->at(1))
- ->method('getBlock')
- ->with('some-block-name')
- ->will($this->returnValue($renderer));
+ ->will($this->returnValue(null));
/** @var $block \Magento\Sales\Block\Items\AbstractItems */
$block = $this->_objectManager->getObject('Magento\Sales\Block\Items\AbstractItems', array(
diff --git a/dev/tests/unit/testsuite/Magento/Sales/Model/Quote/Item/RelatedProductsTest.php b/dev/tests/unit/testsuite/Magento/Sales/Model/Quote/Item/RelatedProductsTest.php
new file mode 100644
index 0000000000000..7e37af1f31d9e
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Sales/Model/Quote/Item/RelatedProductsTest.php
@@ -0,0 +1,120 @@
+relatedProductTypes = array('type1', 'type2', 'type3');
+ $this->model = new \Magento\Sales\Model\Quote\Item\RelatedProducts($this->relatedProductTypes);
+ }
+
+ /**
+ * @param string $optionValue
+ * @param int|bool $productId
+ * @param array $expectedResult
+ *
+ * @covers \Magento\Sales\Model\Quote\Item\RelatedProducts::getRelatedProductIds
+ * @dataProvider getRelatedProductIdsDataProvider
+ */
+ public function testGetRelatedProductIds($optionValue, $productId, $expectedResult)
+ {
+ $quoteItemMock = $this->getMock('\Magento\Sales\Model\Quote\Item', array(), array(), '', false);
+ $itemOptionMock = $this->getMock(
+ '\Magento\Sales\Model\Quote\Item\Option', array('getValue', 'getProductId', '__wakeup'), array(), '', false
+ );
+
+ $quoteItemMock->expects($this->once())
+ ->method('getOptionByCode')
+ ->with('product_type')
+ ->will($this->returnValue($itemOptionMock));
+
+ $itemOptionMock->expects($this->once())
+ ->method('getValue')
+ ->will($this->returnValue($optionValue));
+
+ $itemOptionMock->expects($this->any())
+ ->method('getProductId')
+ ->will($this->returnValue($productId));
+
+ $this->assertEquals($expectedResult, $this->model->getRelatedProductIds(array($quoteItemMock)));
+ }
+
+ /*
+ * Data provider for testGetRelatedProductIds
+ *
+ * @return array
+ */
+ public function getRelatedProductIdsDataProvider()
+ {
+ return array(
+ array(
+ 'optionValue' => 'type1',
+ 'productId' => 123,
+ 'expectedResult' => array(123)
+ ),
+ array(
+ 'optionValue' => 'other_type',
+ 'productId' => 123,
+ 'expectedResult' => array()
+ ),
+ array(
+ 'optionValue' => 'type1',
+ 'productId' => null,
+ 'expectedResult' => array()
+ ),
+ array(
+ 'optionValue' => 'other_type',
+ 'productId' => false,
+ 'expectedResult' => array()
+ )
+ );
+ }
+
+ /**
+ * @covers \Magento\Sales\Model\Quote\Item\RelatedProducts::getRelatedProductIds
+ */
+ public function testGetRelatedProductIdsNoOptions()
+ {
+ $quoteItemMock = $this->getMock('\Magento\Sales\Model\Quote\Item', array(), array(), '', false);
+
+ $quoteItemMock->expects($this->once())
+ ->method('getOptionByCode')
+ ->with('product_type')
+ ->will($this->returnValue(new \stdClass()));
+
+ $this->assertEquals(array(), $this->model->getRelatedProductIds(array($quoteItemMock)));
+ }
+}
diff --git a/dev/tests/unit/testsuite/Magento/Test/Tools/Di/_files/app/code/Magento/SomeModule/etc/di.xml b/dev/tests/unit/testsuite/Magento/Test/Tools/Di/_files/app/code/Magento/SomeModule/etc/di.xml
index 63d92c6802586..bdc328046b3de 100644
--- a/dev/tests/unit/testsuite/Magento/Test/Tools/Di/_files/app/code/Magento/SomeModule/etc/di.xml
+++ b/dev/tests/unit/testsuite/Magento/Test/Tools/Di/_files/app/code/Magento/SomeModule/etc/di.xml
@@ -24,7 +24,7 @@
*/
-->
-
+
diff --git a/dev/tests/unit/testsuite/Magento/Theme/Block/Adminhtml/System/Design/Theme/Tab/CssTest.php b/dev/tests/unit/testsuite/Magento/Theme/Block/Adminhtml/System/Design/Theme/Tab/CssTest.php
index ce42e4a1e8418..77d29bf234526 100644
--- a/dev/tests/unit/testsuite/Magento/Theme/Block/Adminhtml/System/Design/Theme/Tab/CssTest.php
+++ b/dev/tests/unit/testsuite/Magento/Theme/Block/Adminhtml/System/Design/Theme/Tab/CssTest.php
@@ -102,12 +102,12 @@ public function testGetAdditionalElementTypes()
{
$method = self::getMethod('_getAdditionalElementTypes');
- /** @var $configModel \Magento\Core\Model\Config */
- $configModel = $this->getMock('Magento\Core\Model\Config', null, array(), '', false);
+ /** @var $configModel \Magento\App\ConfigInterface */
+ $configModel = $this->getMock('Magento\App\ConfigInterface', array(), array(), '', false);
$this->_objectManager->expects($this->any())
->method('get')
- ->with('Magento\Core\Model\Config')
+ ->with('Magento\App\ConfigInterface')
->will($this->returnValue($configModel));
$result = $method->invokeArgs($this->_model, array());
diff --git a/dev/tests/unit/testsuite/Magento/Theme/Model/ConfigTest.php b/dev/tests/unit/testsuite/Magento/Theme/Model/ConfigTest.php
index 62086b35d5233..18b003150253b 100644
--- a/dev/tests/unit/testsuite/Magento/Theme/Model/ConfigTest.php
+++ b/dev/tests/unit/testsuite/Magento/Theme/Model/ConfigTest.php
@@ -128,7 +128,7 @@ public function testAssignToStoreInSingleStoreMode()
$this->_configData->expects($this->at(1))
->method('addFieldToFilter')
- ->with('scope', \Magento\Core\Model\Config::SCOPE_STORES)
+ ->with('scope', \Magento\Core\Model\ScopeInterface::SCOPE_STORES)
->will($this->returnValue($this->_configData));
$this->_configData->expects($this->at(2))
@@ -171,7 +171,7 @@ public function testAssignToStoreNonSingleStoreMode()
$this->_configData->expects($this->at(1))
->method('addFieldToFilter')
- ->with('scope', \Magento\Core\Model\Config::SCOPE_STORES)
+ ->with('scope', \Magento\Core\Model\ScopeInterface::SCOPE_STORES)
->will($this->returnValue($this->_configData));
$this->_configData->expects($this->at(2))
diff --git a/dev/tests/unit/testsuite/Magento/UrlTest.php b/dev/tests/unit/testsuite/Magento/UrlTest.php
new file mode 100644
index 0000000000000..78fefdb526cfe
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/UrlTest.php
@@ -0,0 +1,89 @@
+_objectManager = new \Magento\TestFramework\Helper\ObjectManager($this);
+ $paramsResolverMock = $this->getMock(
+ 'Magento\Url\RouteParamsResolverFactory', array(), array(), '', false
+ );
+ $paramsResolver = $this->_objectManager->getObject('\Magento\Core\Model\Url\RouteParamsResolver');
+ $paramsResolverMock->expects($this->any())
+ ->method('create')
+ ->will($this->returnValue($paramsResolver));
+ $this->_model = $this->_objectManager->getObject(
+ '\Magento\Url', array('routeParamsResolver' => $paramsResolverMock)
+ );
+ }
+ /**
+ * @param $port mixed
+ * @param $url string
+ * @dataProvider getCurrentUrlProvider
+ */
+ public function testGetCurrentUrl($port, $url)
+ {
+ $methods = array('getServer', 'getScheme', 'getHttpHost', 'getModuleName', 'setModuleName',
+ 'getActionName', 'setActionName', 'getParam');
+ $requestMock = $this->getMock('\Magento\App\RequestInterface', $methods);
+ $requestMock->expects($this->at(0))->method('getServer')->with('SERVER_PORT')
+ ->will($this->returnValue($port));
+ $requestMock->expects($this->at(1))->method('getServer')->with('REQUEST_URI')
+ ->will($this->returnValue('/fancy_uri'));
+ $requestMock->expects($this->once())->method('getScheme')->will($this->returnValue('http'));
+ $requestMock->expects($this->once())->method('getHttpHost')->will($this->returnValue('example.com'));
+
+ /** @var \Magento\UrlInterface $model */
+ $model = $this->_objectManager->getObject('Magento\Url', array('request' => $requestMock));
+ $this->assertEquals($url, $model->getCurrentUrl());
+ }
+
+ public function getCurrentUrlProvider()
+ {
+ return array(
+ 'without_port' => array('', 'http://example.com/fancy_uri'),
+ 'default_port' => array(80, 'http://example.com/fancy_uri'),
+ 'custom_port' => array(8080, 'http://example.com:8080/fancy_uri')
+ );
+ }
+}
diff --git a/dev/tests/unit/testsuite/Magento/View/Asset/GroupedCollectionTest.php b/dev/tests/unit/testsuite/Magento/View/Asset/GroupedCollectionTest.php
index d65da377ee924..e5c9765d4bd8c 100644
--- a/dev/tests/unit/testsuite/Magento/View/Asset/GroupedCollectionTest.php
+++ b/dev/tests/unit/testsuite/Magento/View/Asset/GroupedCollectionTest.php
@@ -112,6 +112,10 @@ public function testGetGroups()
$this->_object->add('css_asset_one', $cssAsset, array('property' => 'test_value'));
$this->_object->add('css_asset_two', $cssAsset, array('property' => 'test_value'));
+ // assets with identical properties but empty properties should be grouped together
+ $this->_object->add('css_asset_four', $cssAsset, array('property' => 'test_value2', 'junk1' => null));
+ $this->_object->add('css_asset_five', $cssAsset, array('property' => 'test_value2', 'junk2' => ''));
+
// assets with different properties should go to different groups
$this->_object->add('css_asset_three', $cssAsset, array('property' => 'different_value'));
$this->_object->add('js_asset_one', $jsAsset, array('property' => 'test_value'));
@@ -132,6 +136,10 @@ public function testGetGroups()
'properties' => array('property' => 'test_value', 'content_type' => 'css', 'can_merge' => false),
'assets' => array('css_asset_one' => $cssAsset, 'css_asset_two' => $cssAsset),
),
+ array(
+ 'properties' => array('property' => 'test_value2', 'content_type' => 'css', 'can_merge' => false),
+ 'assets' => array('css_asset_four' => $cssAsset, 'css_asset_five' => $cssAsset),
+ ),
array(
'properties' => array('property' => 'different_value', 'content_type' => 'css', 'can_merge' => false),
'assets' => array('css_asset_three' => $cssAsset),
diff --git a/dev/tests/unit/testsuite/Magento/View/Asset/MergeStrategy/ChecksumTest.php b/dev/tests/unit/testsuite/Magento/View/Asset/MergeStrategy/ChecksumTest.php
index 5d7a3c875681d..50e5963759881 100644
--- a/dev/tests/unit/testsuite/Magento/View/Asset/MergeStrategy/ChecksumTest.php
+++ b/dev/tests/unit/testsuite/Magento/View/Asset/MergeStrategy/ChecksumTest.php
@@ -46,11 +46,21 @@ class ChecksumTest extends \PHPUnit_Framework_TestCase
*/
protected $_strategy;
+ /**
+ * @var string
+ */
+ protected $_mergedFileAbs = 'absolutePath/destination_file.js';
+
/**
* @var string
*/
protected $_mergedFile = 'destination_file.js';
+ /**
+ * @var string
+ */
+ protected $_mergedMetaFileAbs = 'absolutePath/destination_file.js.dat';
+
/**
* @var string
*/
@@ -59,7 +69,7 @@ class ChecksumTest extends \PHPUnit_Framework_TestCase
/**
* @var array
*/
- protected $_filesArray = array('file1.js', 'file2.js');
+ protected $_filesArray = array('absolutePath/file1.js', 'absolutePath/file2.js');
protected function setUp()
{
@@ -78,7 +88,14 @@ protected function setUp()
));
$this->_directory->expects($this->any())
->method('getRelativePath')
- ->will($this->returnArgument(0));
+ ->will(
+ $this->returnCallback(
+ function ($path) {
+ $parts = explode('/', $path);
+ return end($parts);
+ }
+ )
+ );
$this->_strategy = $this->getMock('Magento\View\Asset\MergeStrategyInterface');
@@ -110,7 +127,7 @@ public function testMergeFilesNoMergeRequired()
->expects($this->never())
->method('mergeFiles');
- $this->_object->mergeFiles($this->_filesArray, $this->_mergedFile, 'contentType');
+ $this->_object->mergeFiles($this->_filesArray, $this->_mergedFileAbs, 'contentType');
}
/**
@@ -130,14 +147,14 @@ public function testMergeFilesFilesDoNotExist($isFileExists, $isMetaFileExists)
$this->_strategy
->expects($this->once())
->method('mergeFiles')
- ->with($this->_filesArray, $this->_mergedFile, 'contentType');
+ ->with($this->_filesArray, $this->_mergedFileAbs, 'contentType');
$this->_directory
->expects($this->once())
->method('writeFile')
->with($this->_mergedMetaFile, '123456');
- $this->_object->mergeFiles($this->_filesArray, $this->_mergedFile, 'contentType');
+ $this->_object->mergeFiles($this->_filesArray, $this->_mergedFileAbs, 'contentType');
}
/**
diff --git a/dev/tests/unit/testsuite/Magento/View/Asset/MergeStrategy/FileExistsTest.php b/dev/tests/unit/testsuite/Magento/View/Asset/MergeStrategy/FileExistsTest.php
index aa493c862fd2c..f86c306fc69bb 100644
--- a/dev/tests/unit/testsuite/Magento/View/Asset/MergeStrategy/FileExistsTest.php
+++ b/dev/tests/unit/testsuite/Magento/View/Asset/MergeStrategy/FileExistsTest.php
@@ -46,6 +46,11 @@ class FileExistsTest extends \PHPUnit_Framework_TestCase
*/
protected $_strategy;
+ /**
+ * @var string
+ */
+ protected $_mergedFileAbs = 'absolutePath/destination_file.js';
+
/**
* @var string
*/
@@ -71,6 +76,17 @@ protected function setUp()
->will($this->returnValue($this->_directory));
$this->_strategy = $this->getMock('Magento\View\Asset\MergeStrategyInterface');
+ $this->_directory->expects($this->any())
+ ->method('getRelativePath')
+ ->will(
+ $this->returnCallback(
+ function ($path) {
+ $parts = explode('/', $path);
+ return end($parts);
+ }
+ )
+ );
+
$this->_object = new \Magento\View\Asset\MergeStrategy\FileExists(
$this->_strategy,
$this->_filesystem
@@ -85,9 +101,10 @@ public function testMergeFilesFileExists()
$this->_directory->expects($this->once())
->method('isExist')
+ ->with($this->equalTo($this->_mergedFile))
->will($this->returnValue(true));
- $this->_object->mergeFiles($this->_filesArray, $this->_mergedFile, 'contentType');
+ $this->_object->mergeFiles($this->_filesArray, $this->_mergedFileAbs, 'contentType');
}
public function testMergeFilesFileDoesNotExist()
@@ -95,12 +112,13 @@ public function testMergeFilesFileDoesNotExist()
$this->_strategy
->expects($this->once())
->method('mergeFiles')
- ->with($this->_filesArray, $this->_mergedFile, 'contentType');
+ ->with($this->_filesArray, $this->_mergedFileAbs, 'contentType');
$this->_directory->expects($this->once())
->method('isExist')
+ ->with($this->equalTo($this->_mergedFile))
->will($this->returnValue(false));
- $this->_object->mergeFiles($this->_filesArray, $this->_mergedFile, 'contentType');
+ $this->_object->mergeFiles($this->_filesArray, $this->_mergedFileAbs, 'contentType');
}
}
diff --git a/dev/tests/unit/testsuite/Magento/View/Layout/File/FileList/CollatorTest.php b/dev/tests/unit/testsuite/Magento/View/Layout/File/FileList/CollatorTest.php
new file mode 100644
index 0000000000000..ab876f0c646c8
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/View/Layout/File/FileList/CollatorTest.php
@@ -0,0 +1,125 @@
+_baseFile = $this->_createLayoutFile('fixture.xml', 'Fixture_TestModule');
+ $this->_themeFile = $this->_createLayoutFile('fixture.xml', 'Fixture_TestModule', 'area/theme/path');
+ $this->_originFiles = array(
+ $this->_baseFile->getFileIdentifier() => $this->_baseFile,
+ $this->_themeFile->getFileIdentifier() => $this->_themeFile
+ );
+ $this->_model = new Collator();
+ }
+
+ /**
+ * Return newly created theme layout file with a mocked theme
+ *
+ * @param string $filename
+ * @param string $module
+ * @param string|null $themeFullPath
+ * @return \PHPUnit_Framework_MockObject_MockObject|\Magento\View\Layout\File
+ */
+ protected function _createLayoutFile($filename, $module, $themeFullPath = null)
+ {
+ $theme = null;
+ if ($themeFullPath !== null) {
+ $theme = $this->getMockForAbstractClass('Magento\View\Design\ThemeInterface');
+ $theme->expects($this->any())->method('getFullPath')->will($this->returnValue($themeFullPath));
+ }
+ return new \Magento\View\Layout\File($filename, $module, $theme);
+ }
+
+ public function testCollateBaseFile()
+ {
+ $file = $this->_createLayoutFile('test/fixture.xml', 'Fixture_TestModule');
+ $this->assertSame(
+ array($file->getFileIdentifier() => $file, $this->_themeFile->getFileIdentifier() => $this->_themeFile),
+ $this->_model->collate(array($file), $this->_originFiles)
+ );
+ }
+
+ public function testReplaceThemeFile()
+ {
+ $file = $this->_createLayoutFile('test/fixture.xml', 'Fixture_TestModule', 'area/theme/path');
+ $this->assertSame(
+ array($this->_baseFile->getFileIdentifier() => $this->_baseFile, $file->getFileIdentifier() => $file),
+ $this->_model->collate(array($file), $this->_originFiles)
+ );
+ }
+
+ /**
+ * @expectedException \LogicException
+ * @expectedExceptionMessage Overriding layout file 'new.xml' does not match to any of the files
+ */
+ public function testReplaceBaseFileException()
+ {
+ $file = $this->_createLayoutFile('new.xml', 'Fixture_TestModule');
+ $this->_model->collate(array($file), $this->_originFiles);
+ }
+
+ /**
+ * @expectedException \LogicException
+ * @expectedExceptionMessage Overriding layout file 'test/fixture.xml' does not match to any of the files
+ */
+ public function testReplaceBaseFileEmptyThemePathException()
+ {
+ $file = $this->_createLayoutFile('test/fixture.xml', 'Fixture_TestModule', '');
+ $this->_model->collate(array($file), $this->_originFiles);
+ }
+
+ /**
+ * @expectedException \LogicException
+ * @expectedExceptionMessage Overriding layout file 'new.xml' does not match to any of the files
+ */
+ public function testReplaceThemeFileException()
+ {
+ $file = $this->_createLayoutFile('new.xml', 'Fixture_TestModule', 'area/theme/path');
+ $this->_model->collate(array($file), $this->_originFiles);
+ }
+}
diff --git a/dev/tests/unit/testsuite/Magento/View/Layout/File/FileList/FactoryTest.php b/dev/tests/unit/testsuite/Magento/View/Layout/File/FileList/FactoryTest.php
index ca78fb13c2619..c6042c0391e45 100644
--- a/dev/tests/unit/testsuite/Magento/View/Layout/File/FileList/FactoryTest.php
+++ b/dev/tests/unit/testsuite/Magento/View/Layout/File/FileList/FactoryTest.php
@@ -44,7 +44,9 @@ protected function setUp()
public function testCreate()
{
- $list = new \Magento\View\Layout\File\FileList();
+ $helperObjectManager = new \Magento\TestFramework\Helper\ObjectManager($this);
+ $list = $helperObjectManager->getObject('Magento\View\Layout\File\FileList');
+
$this->_objectManager
->expects($this->once())
->method('create')
diff --git a/dev/tests/unit/testsuite/Magento/View/Layout/File/FileListTest.php b/dev/tests/unit/testsuite/Magento/View/Layout/File/FileListTest.php
index 93bea0df70245..251a48545c167 100644
--- a/dev/tests/unit/testsuite/Magento/View/Layout/File/FileListTest.php
+++ b/dev/tests/unit/testsuite/Magento/View/Layout/File/FileListTest.php
@@ -41,11 +41,17 @@ class FileListTest extends \PHPUnit_Framework_TestCase
*/
private $_themeFile;
+ /**
+ * @var \Magento\View\Layout\File\FileList\Collator|\PHPUnit_Framework_MockObject_MockObject
+ */
+ protected $collator;
+
protected function setUp()
{
$this->_baseFile = $this->_createLayoutFile('fixture.xml', 'Fixture_TestModule');
$this->_themeFile = $this->_createLayoutFile('fixture.xml', 'Fixture_TestModule', 'area/theme/path');
- $this->_model = new \Magento\View\Layout\File\FileList();
+ $this->collator = $this->getMock('Magento\View\Layout\File\FileList\Collator', array('collate'));
+ $this->_model = new \Magento\View\Layout\File\FileList($this->collator);
$this->_model->add(array($this->_baseFile, $this->_themeFile));
}
@@ -106,47 +112,21 @@ public function testAddThemeFileException()
$this->_model->add(array($file));
}
- public function testReplaceBaseFile()
- {
- $file = $this->_createLayoutFile('test/fixture.xml', 'Fixture_TestModule');
- $this->_model->replace(array($file));
- $this->assertSame(array($file, $this->_themeFile), $this->_model->getAll());
- }
-
- public function testReplaceThemeFile()
- {
- $file = $this->_createLayoutFile('test/fixture.xml', 'Fixture_TestModule', 'area/theme/path');
- $this->_model->replace(array($file));
- $this->assertSame(array($this->_baseFile, $file), $this->_model->getAll());
- }
-
- /**
- * @expectedException \LogicException
- * @expectedExceptionMessage Overriding layout file 'new.xml' does not match to any of the files
- */
- public function testReplaceBaseFileException()
- {
- $file = $this->_createLayoutFile('new.xml', 'Fixture_TestModule');
- $this->_model->replace(array($file));
- }
-
- /**
- * @expectedException \LogicException
- * @expectedExceptionMessage Overriding layout file 'test/fixture.xml' does not match to any of the files
- */
- public function testReplaceBaseFileEmptyThemePathException()
- {
- $file = $this->_createLayoutFile('test/fixture.xml', 'Fixture_TestModule', '');
- $this->_model->replace(array($file));
- }
-
- /**
- * @expectedException \LogicException
- * @expectedExceptionMessage Overriding layout file 'new.xml' does not match to any of the files
- */
- public function testReplaceThemeFileException()
+ public function testReplace()
{
- $file = $this->_createLayoutFile('new.xml', 'Fixture_TestModule', 'area/theme/path');
- $this->_model->replace(array($file));
+ $files = array('1');
+ $result = array('3');
+ $this->collator
+ ->expects($this->once())
+ ->method('collate')
+ ->with(
+ $this->equalTo($files),
+ $this->equalTo(array(
+ $this->_baseFile->getFileIdentifier() => $this->_baseFile,
+ $this->_themeFile->getFileIdentifier() => $this->_themeFile)
+ ))
+ ->will($this->returnValue($result));
+ $this->assertNull($this->_model->replace($files));
+ $this->assertSame($result, $this->_model->getAll());
}
}
diff --git a/dev/tests/unit/testsuite/Magento/View/Layout/File/Source/AggregateTest.php b/dev/tests/unit/testsuite/Magento/View/Layout/File/Source/AggregateTest.php
index b5fbdf41cc446..a5689d435d9a0 100644
--- a/dev/tests/unit/testsuite/Magento/View/Layout/File/Source/AggregateTest.php
+++ b/dev/tests/unit/testsuite/Magento/View/Layout/File/Source/AggregateTest.php
@@ -79,7 +79,9 @@ public function testGetFiles()
{
$parentTheme = $this->getMockForAbstractClass('Magento\View\Design\ThemeInterface');
$theme = $this->getMockForAbstractClass('Magento\View\Design\ThemeInterface');
- $theme->expects($this->once())->method('getParentTheme')->will($this->returnValue($parentTheme));
+ $theme->expects($this->once())->method('getInheritedThemes')->will(
+ $this->returnValue(array($parentTheme, $parentTheme))
+ );
$files = array(
new \Magento\View\Layout\File('0.xml', 'Module_One'),
diff --git a/dev/tests/unit/testsuite/Magento/View/Layout/FileTest.php b/dev/tests/unit/testsuite/Magento/View/Layout/FileTest.php
index 568db9de5d191..a24fe8f3ebad2 100644
--- a/dev/tests/unit/testsuite/Magento/View/Layout/FileTest.php
+++ b/dev/tests/unit/testsuite/Magento/View/Layout/FileTest.php
@@ -61,4 +61,13 @@ public function testGetTheme()
{
$this->assertSame($this->_theme, $this->_model->getTheme());
}
+
+ public function testGetFileIdentifier()
+ {
+ $this->_theme->expects($this->once())->method('getFullPath')->will($this->returnValue('theme_name'));
+ $this->assertSame(
+ 'theme:theme_name|module:Fixture_TestModule|file:FileTest.php',
+ $this->_model->getFileIdentifier()
+ );
+ }
}
diff --git a/dev/tests/unit/testsuite/Magento/Webapi/Controller/RestTest.php b/dev/tests/unit/testsuite/Magento/Webapi/Controller/RestTest.php
index 23d35541a7de5..fb939aee8f657 100644
--- a/dev/tests/unit/testsuite/Magento/Webapi/Controller/RestTest.php
+++ b/dev/tests/unit/testsuite/Magento/Webapi/Controller/RestTest.php
@@ -60,8 +60,8 @@ class RestTest extends \PHPUnit_Framework_TestCase
/** @var \Magento\Authz\Service\AuthorizationV1Interface */
protected $_authzServiceMock;
- const SERVICE_METHOD = \Magento\Webapi\Model\Rest\Config::KEY_METHOD;
- const SERVICE_ID = \Magento\Webapi\Model\Rest\Config::KEY_CLASS;
+ const SERVICE_METHOD = 'testMethod';
+ const SERVICE_ID = 'Magento\Webapi\Controller\TestService';
protected function setUp()
{
@@ -89,7 +89,7 @@ protected function setUp()
->disableOriginalConstructor()
->getMock();
- $this->_serviceMock = $this->getMockBuilder('stdClass')
+ $this->_serviceMock = $this->getMockBuilder(self::SERVICE_ID)
->setMethods(array(self::SERVICE_METHOD))
->disableOriginalConstructor()
->getMock();
@@ -110,6 +110,12 @@ protected function setUp()
->disableOriginalConstructor()
->getMock();
+ $errorProcessorMock = $this->getMock('Magento\Webapi\Controller\ErrorProcessor', [], [], '', false);
+ $errorProcessorMock->expects($this->any())->method('maskException')->will($this->returnArgument(0));
+
+ $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this);
+ $serializer = $objectManager->getObject('Magento\Webapi\Controller\ServiceArgsSerializer');
+
/** Init SUT. */
$this->_restController = new \Magento\Webapi\Controller\Rest(
$this->_requestMock,
@@ -119,7 +125,9 @@ protected function setUp()
$this->_appStateMock,
$this->_oauthServiceMock,
$this->_oauthHelperMock,
- $this->_authzServiceMock
+ $this->_authzServiceMock,
+ $serializer,
+ $errorProcessorMock
);
// Set default expectations used by all tests
@@ -133,6 +141,7 @@ protected function setUp()
$this->_objectManagerMock->expects($this->any())->method('get')->will($this->returnValue($this->_serviceMock));
$this->_responseMock->expects($this->any())->method('prepareResponse')->will($this->returnValue(array()));
$this->_requestMock->expects($this->any())->method('getRequestData')->will($this->returnValue(array()));
+ $this->_serviceMock->expects($this->any())->method(self::SERVICE_METHOD)->will($this->returnValue(null));
parent::setUp();
}
@@ -227,29 +236,6 @@ public function testInSecureRequestOverSecureRoute()
$this->assertEquals(\Magento\Webapi\Exception::HTTP_BAD_REQUEST, $exceptionArray[0]->getHttpCode());
}
- /**
- * Test incorrect format type response from service methods
- */
- public function testInvalidReturnTypeFromService()
- {
- $this->_appStateMock->expects($this->any())->method('isInstalled')->will($this->returnValue(true));
- $this->_serviceMock->expects($this->any())->method(self::SERVICE_METHOD)->will($this->returnValue("invalid"));
- $this->_routeMock->expects($this->any())->method('isSecure')->will($this->returnValue(false));
- $this->_requestMock->expects($this->any())->method('isSecure')->will($this->returnValue(false));
- $this->_authzServiceMock->expects($this->once())->method('isAllowed')->will($this->returnValue(true));
-
- // Override default prepareResponse. It should never be called in this case
- $this->_responseMock->expects($this->never())->method('prepareResponse');
-
- $expectedMsg = 'The method "' . self::SERVICE_METHOD . '" of service "'
- . self::SERVICE_ID . '" must return an array.';
-
- $this->_restController->dispatch($this->_requestMock);
- $this->assertTrue($this->_responseMock->isException());
- $exceptionArray = $this->_responseMock->getException();
- $this->assertEquals($expectedMsg, $exceptionArray[0]->getMessage());
- }
-
public function testAuthorizationFailed()
{
$this->_appStateMock->expects($this->any())->method('isInstalled')->will($this->returnValue(true));
@@ -263,3 +249,11 @@ public function testAuthorizationFailed()
$this->assertEquals($expectedMsg, $exceptionArray[0]->getMessage());
}
}
+
+class TestService
+{
+ public function testMethod()
+ {
+ return null;
+ }
+}
diff --git a/dev/tests/unit/testsuite/Magento/Webapi/Controller/Soap/HandlerTest.php b/dev/tests/unit/testsuite/Magento/Webapi/Controller/Soap/Request/HandlerTest.php
similarity index 70%
rename from dev/tests/unit/testsuite/Magento/Webapi/Controller/Soap/HandlerTest.php
rename to dev/tests/unit/testsuite/Magento/Webapi/Controller/Soap/Request/HandlerTest.php
index 2f83a4fd6ee0d..492134ce8a1f2 100644
--- a/dev/tests/unit/testsuite/Magento/Webapi/Controller/Soap/HandlerTest.php
+++ b/dev/tests/unit/testsuite/Magento/Webapi/Controller/Soap/Request/HandlerTest.php
@@ -22,14 +22,14 @@
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
-namespace Magento\Webapi\Controller\Soap;
+namespace Magento\Webapi\Controller\Soap\Request;
/**
- * Test for \Magento\Webapi\Controller\Soap\Handler.
+ * Test for \Magento\Webapi\Controller\Soap\Request\Handler.
*/
class HandlerTest extends \PHPUnit_Framework_TestCase
{
- /** @var \Magento\Webapi\Controller\Soap\Handler */
+ /** @var \Magento\Webapi\Controller\Soap\Request\Handler */
protected $_handler;
/** @var \Magento\ObjectManager */
@@ -44,6 +44,12 @@ class HandlerTest extends \PHPUnit_Framework_TestCase
/** @var \PHPUnit_Framework_MockObject_MockObject */
protected $_authzServiceMock;
+ /** @var \Magento\Webapi\Helper\Data|\PHPUnit_Framework_MockObject_MockObject */
+ protected $_helperMock;
+
+ /** @var \Magento\Webapi\Helper\Data|\PHPUnit_Framework_MockObject_MockObject */
+ protected $_serializerMock;
+
/** @var array */
protected $_arguments;
@@ -51,45 +57,24 @@ protected function setUp()
{
/** Prepare mocks for SUT constructor. */
$this->_apiConfigMock = $this->getMockBuilder('Magento\Webapi\Model\Soap\Config')
- ->setMethods(
- array('getServiceMethodInfo')
- )->disableOriginalConstructor()
- ->getMock();
-
- $this->_requestMock = $this->getMockBuilder('Magento\Webapi\Controller\Soap\Request')
- ->setMethods(array('getRequestedServices'))
- ->disableOriginalConstructor()
- ->getMock();
-
- $this->_objectManagerMock = $this->getMockBuilder('Magento\ObjectManager')
- ->disableOriginalConstructor()
- ->getMock();
-
- $this->_authzServiceMock = $this->getMockBuilder('Magento\Authz\Service\AuthorizationV1Interface')
- ->disableOriginalConstructor()
- ->getMock();
-
+ ->setMethods(array('getServiceMethodInfo'))->disableOriginalConstructor()->getMock();
+ $this->_requestMock = $this->getMock('Magento\Webapi\Controller\Soap\Request', [], [], '', false);
+ $this->_objectManagerMock = $this->getMock('Magento\ObjectManager', [], [], '', false);
+ $this->_authzServiceMock = $this->getMock('Magento\Authz\Service\AuthorizationV1Interface', [], [], '', false);
+ $this->_helperMock = $this->getMock('Magento\Webapi\Helper\Data', [], [], '', false);
+ $this->_serializerMock = $this->getMock('Magento\Webapi\Controller\ServiceArgsSerializer', [], [], '', false);
/** Initialize SUT. */
- $this->_handler = new \Magento\Webapi\Controller\Soap\Handler(
+ $this->_handler = new \Magento\Webapi\Controller\Soap\Request\Handler(
$this->_requestMock,
$this->_objectManagerMock,
$this->_apiConfigMock,
- $this->_authzServiceMock
+ $this->_authzServiceMock,
+ $this->_helperMock,
+ $this->_serializerMock
);
-
parent::setUp();
}
- protected function tearDown()
- {
- unset($this->_handler);
- unset($this->_objectManagerMock);
- unset($this->_apiConfigMock);
- unset($this->_requestMock);
- unset($this->_authzServiceMock);
- parent::tearDown();
- }
-
public function testCall()
{
$requestedServices = array('requestedServices');
@@ -121,14 +106,15 @@ public function testCall()
->setMethods(array($methodName))
->getMock();
- $expectedResult = array('foo' => 'bar');
- $serviceMock->expects($this->once())->method($methodName)->will($this->returnValue($expectedResult));
+ $serviceResponse = array('foo' => 'bar');
+ $serviceMock->expects($this->once())->method($methodName)->will($this->returnValue($serviceResponse));
$this->_objectManagerMock->expects($this->once())->method('get')->with($className)
->will($this->returnValue($serviceMock));
+ $this->_serializerMock->expects($this->once())->method('getInputData')->will($this->returnArgument(2));
/** Execute SUT. */
$this->assertEquals(
- $expectedResult,
+ array('result' => $serviceResponse),
$this->_handler->__call($operationName, array((object)array('field' => 1)))
);
}
diff --git a/dev/tests/unit/testsuite/Magento/Webapi/Controller/SoapTest.php b/dev/tests/unit/testsuite/Magento/Webapi/Controller/SoapTest.php
index 84d648e4fb1e7..a158c286ae47c 100644
--- a/dev/tests/unit/testsuite/Magento/Webapi/Controller/SoapTest.php
+++ b/dev/tests/unit/testsuite/Magento/Webapi/Controller/SoapTest.php
@@ -198,18 +198,15 @@ public function testDispatchSoapRequest()
$this->_appStateMock->expects($this->any())
->method('isInstalled')
->will($this->returnValue(true));
- $soapResponse = 'Some some response';
- $this->_soapServerMock->expects($this->any())
- ->method('handle')
- ->will($this->returnValue($soapResponse));
+ $this->_soapServerMock->expects($this->once())
+ ->method('handle');
$_SERVER['HTTP_AUTHORIZATION'] = 'OAuth access_token';
$this->_oauthServiceMock->expects($this->once())
->method('validateAccessToken')
->will($this->returnValue(true));
-
- $this->_soapController->dispatch($this->_requestMock);
+ $response = $this->_soapController->dispatch($this->_requestMock);
+ $this->assertEquals(200, $response->getHttpResponseCode());
unset($_SERVER['HTTP_AUTHORIZATION']);
- $this->assertEquals($soapResponse, $this->_responseMock->getBody());
}
/**
diff --git a/dev/tests/unit/testsuite/Magento/Webapi/Helper/DataTest.php b/dev/tests/unit/testsuite/Magento/Webapi/Helper/DataTest.php
new file mode 100644
index 0000000000000..32199a346cd59
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Webapi/Helper/DataTest.php
@@ -0,0 +1,111 @@
+_helper = $objectManager->getObject('Magento\Webapi\Helper\Data');
+ parent::setUp();
+ }
+
+ /**
+ * Test identifying service name parts including subservices using class name.
+ *
+ * @dataProvider serviceNamePartsDataProvider
+ */
+ public function testGetServiceNameParts($className, $preserveVersion, $expected)
+ {
+ $actual = $this->_helper->getServiceNameParts(
+ $className,
+ $preserveVersion
+ );
+ $this->assertEquals($expected, $actual);
+ }
+
+ /**
+ * Dataprovider for serviceNameParts
+ *
+ * @return array
+ */
+ public function serviceNamePartsDataProvider()
+ {
+ return array(
+ array('Magento\Customer\Service\V1\Customer\AddressInterface', false, array('Customer', 'Address')),
+ array(
+ 'Vendor\Customer\Service\V1\Customer\AddressInterface',
+ true,
+ array('VendorCustomer', 'Address', 'V1')
+ ),
+ array('Magento\Catalog\Service\V2\ProductInterface', true, array('CatalogProduct', 'V2'))
+ );
+ }
+
+ /**
+ * @expectedException \InvalidArgumentException
+ * @dataProvider dataProviderForTestGetServiceNamePartsInvalidName
+ */
+ public function testGetServiceNamePartsInvalidName($interfaceClassName)
+ {
+ $this->_helper->getServiceNameParts($interfaceClassName);
+ }
+
+ public function dataProviderForTestGetServiceNamePartsInvalidName()
+ {
+ return array(
+ array('BarV1Interface'), // Missed vendor, module, 'Service'
+ array('Service\\V1Interface'), // Missed vendor and module
+ array('Magento\\Foo\\Service\\BarVxInterface'), // Version number should be a number
+ array('Magento\\Foo\\Service\\BarInterface'), // Version missed
+ array('Magento\\Foo\\Service\\BarV1'), // 'Interface' missed
+ array('Foo\\Service\\BarV1Interface'), // Module missed
+ array('Foo\\BarV1Interface'), // Module and 'Service' missed
+ );
+ }
+
+ public function testDtoGetterNameToFieldName()
+ {
+ $this->assertEquals('id', $this->_helper->dtoGetterNameToFieldName('getId'));
+ }
+
+ public function testDtoFieldNameToSetterName()
+ {
+ $this->assertEquals('setId', $this->_helper->dtoFieldNameToSetterName('id'));
+ }
+}
+
+require_once realpath(__DIR__ . '/../_files/test_interfaces.php');
+
diff --git a/dev/tests/unit/testsuite/Magento/Webapi/Model/Config/ClassReflector/TypeProcessorTest.php b/dev/tests/unit/testsuite/Magento/Webapi/Model/Config/ClassReflector/TypeProcessorTest.php
new file mode 100644
index 0000000000000..a49ef795ff539
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Webapi/Model/Config/ClassReflector/TypeProcessorTest.php
@@ -0,0 +1,144 @@
+_helperMock = $this->getMock('Magento\Webapi\Helper\Data', [], [], '', false);
+ $this->_typeProcessor = new \Magento\Webapi\Model\Config\ClassReflector\TypeProcessor($this->_helperMock);
+ }
+
+ /**
+ * Test Retrieving of processed types data.
+ */
+ public function testGetTypesData()
+ {
+ $this->_typeProcessor->setTypeData('typeA', ['dataA']);
+ $this->_typeProcessor->setTypeData('typeB', ['dataB']);
+ $this->assertEquals(['typeA' => ['dataA'], 'typeB' => ['dataB']], $this->_typeProcessor->getTypesData());
+ }
+
+ /**
+ * @expectedException \InvalidArgumentException
+ * @expectedExceptionMessage Data type "NonExistentType" is not declared.
+ */
+ public function testGetTypeDataInvalidArgumentException()
+ {
+ $this->_typeProcessor->getTypeData('NonExistentType');
+ }
+
+ /**
+ * Test retrieval of data type details for the given type name.
+ */
+ public function testGetTypeData()
+ {
+ $this->_typeProcessor->setTypeData('typeA', ['dataA']);
+ $this->assertEquals(['dataA'], $this->_typeProcessor->getTypeData('typeA'));
+ }
+
+ /**
+ * Test data type details for the same type name set multiple times.
+ */
+ public function testSetTypeDataArrayMerge()
+ {
+ $this->_typeProcessor->setTypeData('typeA', ['dataA1']);
+ $this->_typeProcessor->setTypeData('typeA', ['dataA2']);
+ $this->_typeProcessor->setTypeData('typeA', ['dataA3']);
+ $this->assertEquals(['dataA1', 'dataA2', 'dataA3'], $this->_typeProcessor->getTypeData('typeA'));
+ }
+
+ public function testNormalizeType()
+ {
+ $this->assertEquals('blah', $this->_typeProcessor->normalizeType('blah'));
+ $this->assertEquals('string', $this->_typeProcessor->normalizeType('str'));
+ //$this->assertEquals('integer', $this->_typeProcessor->normalizeType('int'));
+ $this->assertEquals('boolean', $this->_typeProcessor->normalizeType('bool'));
+ }
+
+ public function testIsTypeSimple()
+ {
+ $this->assertTrue($this->_typeProcessor->isTypeSimple('string'));
+ $this->assertTrue($this->_typeProcessor->isTypeSimple('string[]'));
+ $this->assertTrue($this->_typeProcessor->isTypeSimple('int'));
+ $this->assertTrue($this->_typeProcessor->isTypeSimple('float'));
+ $this->assertTrue($this->_typeProcessor->isTypeSimple('double'));
+ $this->assertTrue($this->_typeProcessor->isTypeSimple('boolean'));
+ $this->assertFalse($this->_typeProcessor->isTypeSimple('blah'));
+ }
+
+ public function testIsArrayType()
+ {
+ $this->assertFalse($this->_typeProcessor->isArrayType('string'));
+ $this->assertTrue($this->_typeProcessor->isArrayType('string[]'));
+ }
+
+ public function getArrayItemType()
+ {
+ $this->assertEquals('string', $this->_typeProcessor->getArrayItemType('str[]'));
+ $this->assertEquals('string', $this->_typeProcessor->getArrayItemType('string[]'));
+ $this->assertEquals('integer', $this->_typeProcessor->getArrayItemType('int[]'));
+ $this->assertEquals('boolean', $this->_typeProcessor->getArrayItemType('bool[]'));
+ }
+
+ public function testTranslateTypeName()
+ {
+ $this->assertEquals(
+ 'TestModule1V1EntityItem',
+ $this->_typeProcessor->translateTypeName('\Magento\TestModule1\Service\V1\Entity\Item')
+ );
+ $this->assertEquals(
+ 'TestModule3V1EntityParameter[]',
+ $this->_typeProcessor->translateTypeName('\Magento\TestModule3\Service\V1\Entity\Parameter[]')
+ );
+ }
+
+ /**
+ * @expectedException \InvalidArgumentException
+ * @expectedExceptionMessage Invalid parameter type "\Magento\TestModule3\V1\Parameter[]".
+ */
+ public function testTranslateTypeNameInvalidArgumentException()
+ {
+ $this->_typeProcessor->translateTypeName('\Magento\TestModule3\V1\Parameter[]');
+ }
+
+ public function testTranslateArrayTypeName()
+ {
+ $this->assertEquals('ArrayOfComplexType', $this->_typeProcessor->translateArrayTypeName('complexType'));
+ }
+}
diff --git a/dev/tests/unit/testsuite/Magento/Webapi/Model/Config/ClassReflectorTest.php b/dev/tests/unit/testsuite/Magento/Webapi/Model/Config/ClassReflectorTest.php
new file mode 100644
index 0000000000000..243180db8cd52
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Webapi/Model/Config/ClassReflectorTest.php
@@ -0,0 +1,119 @@
+_typeProcessor = $this->getMock(
+ '\Magento\Webapi\Model\Config\ClassReflector\TypeProcessor',
+ ['process'],
+ [],
+ '',
+ false
+ );
+ $this->_typeProcessor->expects($this->any())->method('process')->will(
+ $this->returnValueMap(
+ array(
+ array('string', 'str'),
+ array('int', 'int')
+ )
+ )
+ );
+ $this->_classReflector = new \Magento\Webapi\Model\Config\ClassReflector($this->_typeProcessor);
+ }
+
+ public function testReflectClassMethods()
+ {
+ $data = $this->_classReflector->reflectClassMethods(
+ '\\Magento\\Webapi\\Model\\Config\\TestServiceForClassReflector',
+ ['generateRandomString' => ['method' => 'generateRandomString']]
+ );
+ $this->assertEquals(['generateRandomString' => $this->_getSampleReflectionData()], $data);
+ }
+
+ public function testExtractMethodData()
+ {
+ $classReflection = new \Zend\Server\Reflection\ReflectionClass
+ (new \ReflectionClass('\\Magento\\Webapi\\Model\\Config\\TestServiceForClassReflector'));
+ /** @var $methodReflection ReflectionMethod */
+ $methodReflection = $classReflection->getMethods()[0];
+ $methodData = $this->_classReflector->extractMethodData($methodReflection);
+ $expectedResponse = $this->_getSampleReflectionData();
+ $this->assertEquals($expectedResponse, $methodData);
+ }
+
+ /**
+ * Expected reflection data for TestServiceForClassReflector generateRandomString method
+ *
+ * @return array
+ */
+ protected function _getSampleReflectionData()
+ {
+ return [
+ 'documentation' => 'Basic random string generator',
+ 'interface' =>
+ [
+ 'in' =>
+ [
+ 'parameters' =>
+ [
+ 'length' =>
+ [
+ 'type' => 'int',
+ 'required' => true,
+ 'documentation' => 'length of the random string',
+ ],
+ ],
+ ],
+ 'out' =>
+ [
+ 'parameters' =>
+ [
+ 'result' =>
+ [
+ 'type' => 'str',
+ 'documentation' => 'random string',
+ 'required' => true,
+ ],
+ ],
+ ],
+ ],
+ ];
+ }
+}
diff --git a/dev/tests/unit/testsuite/Magento/Webapi/Model/Config/TestServiceForClassReflector.php b/dev/tests/unit/testsuite/Magento/Webapi/Model/Config/TestServiceForClassReflector.php
new file mode 100644
index 0000000000000..91b4e15cb8fc2
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Webapi/Model/Config/TestServiceForClassReflector.php
@@ -0,0 +1,39 @@
+ array(
// @codingStandardsIgnoreStart
'
-
+
/:id
@@ -72,14 +72,14 @@ public function exemplarXmlDataProvider()
),
'valid with several entities' => array(
'
-
+
/:id
/:id
-
+
/:id
@@ -87,7 +87,7 @@ public function exemplarXmlDataProvider()
/:id
-
+
/:id
@@ -111,7 +111,7 @@ public function exemplarXmlDataProvider()
),
'invalid rest-routes' => array(
'
-
+
@@ -127,7 +127,7 @@ public function exemplarXmlDataProvider()
/** Excessive nodes */
'irrelevant node in root' => array(
'
-
+
@@ -137,7 +137,7 @@ public function exemplarXmlDataProvider()
),
'irrelevant node in service' => array(
'
-
+
@@ -147,7 +147,7 @@ public function exemplarXmlDataProvider()
),
'irrelevant node in rest-routes' => array(
'
-
+
@@ -159,7 +159,7 @@ public function exemplarXmlDataProvider()
/** Excessive attributes */
'invalid attribute in root' => array(
'
-
+
/:id
',
@@ -167,7 +167,7 @@ public function exemplarXmlDataProvider()
),
'invalid attribute in service' => array(
'
-
+
/:id
',
@@ -175,7 +175,7 @@ public function exemplarXmlDataProvider()
),
'invalid attribute in rest-routes' => array(
'
-
+
/:id
',
@@ -185,7 +185,7 @@ public function exemplarXmlDataProvider()
/** Invalid values */
'rest-route with invalid httpMethod' => array(
'
-
+
/:id
',
@@ -196,7 +196,7 @@ public function exemplarXmlDataProvider()
),
'rest-route with invalid isSecure key type' => array(
'
-
+
',
@@ -206,7 +206,7 @@ public function exemplarXmlDataProvider()
),
'rest-route with invalid resources type' => array(
'
-
+
',
diff --git a/dev/tests/unit/testsuite/Magento/Webapi/Model/Config/_files/webapi.php b/dev/tests/unit/testsuite/Magento/Webapi/Model/Config/_files/webapi.php
index ec68b8304e9fc..84d4a2c803863 100644
--- a/dev/tests/unit/testsuite/Magento/Webapi/Model/Config/_files/webapi.php
+++ b/dev/tests/unit/testsuite/Magento/Webapi/Model/Config/_files/webapi.php
@@ -22,8 +22,8 @@
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
return array(
- '\Magento\TestModule1\Service\AllSoapAndRestV1Interface' => array(
- 'class' => '\Magento\TestModule1\Service\AllSoapAndRestV1Interface',
+ '\Magento\TestModule1\Service\V1\AllSoapAndRestInterface' => array(
+ 'class' => '\Magento\TestModule1\Service\V1\AllSoapAndRestInterface',
'baseUrl' => '/V1/testmodule1',
'methods' => array(
'item' => array(
@@ -35,8 +35,8 @@
)
)
),
- '\Magento\TestModule1\Service\AllSoapAndRestV2Interface' => array(
- 'class' => '\Magento\TestModule1\Service\AllSoapAndRestV2Interface',
+ '\Magento\TestModule1\Service\V2\AllSoapAndRestInterface' => array(
+ 'class' => '\Magento\TestModule1\Service\V2\AllSoapAndRestInterface',
'baseUrl' => '/V2/testmodule1',
'methods' => array(
'item' => array(
@@ -62,8 +62,8 @@
),
)
),
- '\Magento\TestModule1\Service\AllSoapAndRestV3Interface' => array(
- 'class' => '\Magento\TestModule1\Service\AllSoapAndRestV3Interface',
+ '\Magento\TestModule1\Service\V3\AllSoapAndRestInterface' => array(
+ 'class' => '\Magento\TestModule1\Service\V3\AllSoapAndRestInterface',
'methods' => array()
),
);
diff --git a/dev/tests/unit/testsuite/Magento/Webapi/Model/Config/_files/webapi.xml b/dev/tests/unit/testsuite/Magento/Webapi/Model/Config/_files/webapi.xml
index 72ad8f55363b5..649e1ffedc2c3 100644
--- a/dev/tests/unit/testsuite/Magento/Webapi/Model/Config/_files/webapi.xml
+++ b/dev/tests/unit/testsuite/Magento/Webapi/Model/Config/_files/webapi.xml
@@ -24,16 +24,16 @@
*/
-->
-
+
/:id
-
+
/:id
/:id
-
+
diff --git a/dev/tests/unit/testsuite/Magento/Webapi/Model/Soap/ConfigTest.php b/dev/tests/unit/testsuite/Magento/Webapi/Model/Soap/ConfigTest.php
index 82632a7763b7e..07362790f43dc 100644
--- a/dev/tests/unit/testsuite/Magento/Webapi/Model/Soap/ConfigTest.php
+++ b/dev/tests/unit/testsuite/Magento/Webapi/Model/Soap/ConfigTest.php
@@ -38,6 +38,9 @@ class ConfigTest extends \PHPUnit_Framework_TestCase
/** @var \Magento\Webapi\Model\Config|\PHPUnit_Framework_MockObject_MockObject */
protected $_configMock;
+ /** @var \Magento\Webapi\Helper\Data|\PHPUnit_Framework_MockObject_MockObject */
+ protected $_helperMock;
+
/**
* Set up helper.
*/
@@ -47,74 +50,18 @@ protected function setUp()
->disableOriginalConstructor()
->getMock();
$fileSystemMock = $this->getMockBuilder('Magento\App\Filesystem')->disableOriginalConstructor()->getMock();
- $this->_configMock = $this->getMockBuilder('Magento\Webapi\Model\Config')
- ->disableOriginalConstructor()->getMock();
- $this->_soapConfig = new \Magento\Webapi\Model\Soap\Config(
- $objectManagerMock,
- $fileSystemMock,
- $this->_configMock
- );
- parent::setUp();
- }
-
- /**
- * Test identifying service name parts including subservices using class name.
- *
- * @dataProvider serviceNamePartsDataProvider
- */
- public function testGetServiceNameParts($className, $preserveVersion, $expected)
- {
- $actual = $this->_soapConfig->getServiceNameParts(
- $className,
- $preserveVersion
- );
- $this->assertEquals($expected, $actual);
- }
-
- /**
- * Dataprovider for serviceNameParts
- *
- * @return array
- */
- public function serviceNamePartsDataProvider()
- {
- return array(
- array('Magento\Customer\Service\Customer\AddressV1Interface', false, array('Customer', 'Address')),
- array(
- 'Vendor\Customer\Service\Customer\AddressV1Interface',
- true,
- array('VendorCustomer', 'Address', 'V1')
- ),
- array('Magento\Catalog\Service\ProductV2Interface', true, array('CatalogProduct', 'V2'))
- );
- }
-
- /**
- * @expectedException \InvalidArgumentException
- * @dataProvider dataProviderForTestGetServiceNamePartsInvalidName
- */
- public function testGetServiceNamePartsInvalidName($interfaceClassName)
- {
- $this->_soapConfig->getServiceNameParts($interfaceClassName);
- }
-
- public function dataProviderForTestGetServiceNamePartsInvalidName()
- {
- return array(
- array('BarV1Interface'), // Missed vendor, module, 'Service'
- array('Service\\V1Interface'), // Missed vendor and module
- array('Magento\\Foo\\Service\\BarVxInterface'), // Version number should be a number
- array('Magento\\Foo\\Service\\BarInterface'), // Version missed
- array('Magento\\Foo\\Service\\BarV1'), // 'Interface' missed
- array('Foo\\Service\\BarV1Interface'), // Module missed
- array('Foo\\BarV1Interface'), // Module and 'Service' missed
+ $classReflection = $this->getMock(
+ 'Magento\Webapi\Model\Config\ClassReflector',
+ ['reflectClassMethods'],
+ [],
+ '',
+ false
);
- }
-
- public function testGetRequestedSoapServices()
- {
+ $classReflection->expects($this->any())->method('reflectClassMethods')->will($this->returnValue(array()));
+ $this->_helperMock = $this->getMock('Magento\Webapi\Helper\Data', [], [], '', false);
+ $this->_configMock = $this->getMock('Magento\Webapi\Model\Config', [], [], '', false);
$servicesConfig = array(
- 'Magento\Module\Service\FooV1Interface' => array(
+ 'ModuleFooV1' => array(
'class' => 'Magento\Module\Service\FooV1Interface',
'baseUrl' => '/V1/foo',
'methods' => array(
@@ -127,7 +74,7 @@ public function testGetRequestedSoapServices()
)
)
),
- 'Magento\Module\Service\BarV1Interface' => array(
+ 'ModuleBarV1' => array(
'class' => 'Magento\Module\Service\BarV1Interface',
'baseUrl' => '/V1/bar',
'methods' => array(
@@ -141,7 +88,29 @@ public function testGetRequestedSoapServices()
)
)
);
+ $this->_configMock->expects($this->once())->method('getServices')->will($this->returnValue($servicesConfig));
+ $this->_helperMock->expects($this->any())
+ ->method('getServiceName')
+ ->will(
+ $this->returnValueMap(
+ array(
+ array('Magento\Module\Service\FooV1Interface', true, 'moduleFooV1'),
+ array('Magento\Module\Service\BarV1Interface', true, 'moduleBarV1')
+ )
+ )
+ );
+ $this->_soapConfig = new \Magento\Webapi\Model\Soap\Config(
+ $objectManagerMock,
+ $fileSystemMock,
+ $this->_configMock,
+ $classReflection,
+ $this->_helperMock
+ );
+ parent::setUp();
+ }
+ public function testGetRequestedSoapServices()
+ {
$expectedResult = array(
array(
'methods' => array(
@@ -155,33 +124,31 @@ public function testGetRequestedSoapServices()
'class' => 'Magento\Module\Service\FooV1Interface'
)
);
-
- $this->_configMock->expects($this->once())->method('getServices')->will($this->returnValue($servicesConfig));
$result = $this->_soapConfig->getRequestedSoapServices(array('moduleFooV1', 'moduleBarV2', 'moduleBazV1'));
$this->assertEquals($expectedResult, $result);
}
-}
-namespace Magento\Module\Service;
-
-interface FooV1Interface
-{
- public function someMethod();
-}
-
-interface BarV1Interface
-{
- public function someMethod();
-}
+ public function testGetServiceMethodInfo()
+ {
+ $expectedResult = array(
+ 'class' => 'Magento\Module\Service\BarV1Interface',
+ 'method' => 'someMethod',
+ 'isSecure' => false,
+ 'resources' => array('Magento_TestModule1::resource2')
+ );
+ $methodInfo = $this->_soapConfig->getServiceMethodInfo(
+ 'moduleBarV1SomeMethod',
+ array('moduleBarV1', 'moduleBazV1')
+ );
+ $this->assertEquals($expectedResult, $methodInfo);
+ }
-interface FooBarV1Interface
-{
- public function someMethod();
+ public function testGetSoapOperation()
+ {
+ $expectedResult = 'moduleFooV1SomeMethod';
+ $soapOperation = $this->_soapConfig->getSoapOperation('Magento\Module\Service\FooV1Interface', 'someMethod');
+ $this->assertEquals($expectedResult, $soapOperation);
+ }
}
-namespace Magento\Module\Service\Foo;
-
-interface BarV1Interface
-{
- public function someMethod();
-}
+require_once realpath(__DIR__ . '/../../_files/test_interfaces.php');
diff --git a/dev/tests/unit/testsuite/Magento/Webapi/Model/Soap/FaultTest.php b/dev/tests/unit/testsuite/Magento/Webapi/Model/Soap/FaultTest.php
index 786e92a6cc159..05ec5655e4077 100644
--- a/dev/tests/unit/testsuite/Magento/Webapi/Model/Soap/FaultTest.php
+++ b/dev/tests/unit/testsuite/Magento/Webapi/Model/Soap/FaultTest.php
@@ -1,7 +1,5 @@
Soap fault reason.
-
+
- value1
- 2
+
+ param1
+ value1
+
+
+ param2
+ 2
+
111
-
+
@@ -155,38 +165,43 @@ public function dataProviderForGetSoapFaultMessageTest()
$expectedXmls = include __DIR__ . '/../../_files/soap_fault/soap_fault_expected_xmls.php';
return array(
//Each array contains data for SOAP Fault Message, Expected XML, and Assert Message.
- array(
+ 'ArrayDataDetails' => array(
'Fault reason',
'Sender',
- array('key1' => 'value1', 'key2' => 'value2'),
+ array(
+ Fault::NODE_DETAIL_PARAMETERS => array('key1' => 'value1', 'key2' => 'value2', 'value3'),
+ Fault::NODE_DETAIL_CODE => 333,
+ Fault::NODE_DETAIL_TRACE => 'Trace',
+ 'Invalid' => 'This node should be skipped'
+ ),
$expectedXmls['expectedResultArrayDataDetails'],
'SOAP fault message with associated array data details is invalid.'
),
- array(
+ 'IndexArrayDetails' => array(
'Fault reason',
'Sender',
array('value1', 'value2'),
$expectedXmls['expectedResultIndexArrayDetails'],
'SOAP fault message with index array data details is invalid.'
),
- array(
+ 'EmptyArrayDetails' => array(
'Fault reason',
'Sender',
array(),
$expectedXmls['expectedResultEmptyArrayDetails'],
'SOAP fault message with empty array data details is invalid.'
),
- array(
+ 'ObjectDetails' => array(
'Fault reason',
'Sender',
(object)array('key' => 'value'),
$expectedXmls['expectedResultObjectDetails'],
'SOAP fault message with object data details is invalid.'
),
- array(
+ 'ComplexDataDetails' => array(
'Fault reason',
'Sender',
- array('key' => array('sub_key' => 'value')),
+ array(Fault::NODE_DETAIL_PARAMETERS => array('key' => array('sub_key' => 'value'))),
$expectedXmls['expectedResultComplexDataDetails'],
'SOAP fault message with complex data details is invalid.'
),
@@ -223,13 +238,19 @@ public function testConstructor()
{$message}
-
+
- value1
- 2
+
+ param1
+ value1
+
+
+ param2
+ 2
+
{$code}
-
+
diff --git a/dev/tests/unit/testsuite/Magento/Webapi/Model/Soap/ServerTest.php b/dev/tests/unit/testsuite/Magento/Webapi/Model/Soap/ServerTest.php
index 90fec0fa37d4e..b3d20236b2fae 100644
--- a/dev/tests/unit/testsuite/Magento/Webapi/Model/Soap/ServerTest.php
+++ b/dev/tests/unit/testsuite/Magento/Webapi/Model/Soap/ServerTest.php
@@ -48,6 +48,9 @@ class ServerTest extends \PHPUnit_Framework_TestCase
/** @var \Magento\Webapi\Model\Soap\Server\Factory */
protected $_soapServerFactory;
+ /** @var \Magento\Webapi\Model\Config\ClassReflector\TypeProcessor|\PHPUnit_Framework_MockObject_MockObject */
+ protected $_typeProcessor;
+
protected function setUp()
{
$this->_storeManagerMock = $this->getMockBuilder('Magento\Core\Model\StoreManager')
@@ -75,6 +78,14 @@ protected function setUp()
$this->_soapServerFactory = $this->getMockBuilder('Magento\Webapi\Model\Soap\Server\Factory')
->disableOriginalConstructor()->getMock();
+ $this->_typeProcessor = $this->getMock(
+ 'Magento\Webapi\Model\Config\ClassReflector\TypeProcessor',
+ [],
+ [],
+ '',
+ false
+ );
+
/** Init SUT. */
$this->_soapServer = new \Magento\Webapi\Model\Soap\Server(
$areaListMock,
@@ -82,7 +93,8 @@ protected function setUp()
$this->_requestMock,
$this->_domDocumentFactory,
$this->_storeManagerMock,
- $this->_soapServerFactory
+ $this->_soapServerFactory,
+ $this->_typeProcessor
);
parent::setUp();
diff --git a/dev/tests/unit/testsuite/Magento/Webapi/Model/Soap/Wsdl/ComplexTypeStrategyTest.php b/dev/tests/unit/testsuite/Magento/Webapi/Model/Soap/Wsdl/ComplexTypeStrategyTest.php
new file mode 100644
index 0000000000000..2dccec6dec5a3
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Webapi/Model/Soap/Wsdl/ComplexTypeStrategyTest.php
@@ -0,0 +1,308 @@
+_typeProcessor = $this->getMockBuilder('Magento\Webapi\Model\Config\ClassReflector\TypeProcessor')
+ ->setMethods(array('getTypeData'))
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->_wsdl = $this->getMockBuilder('Magento\Webapi\Model\Soap\Wsdl')
+ ->setMethods(array('toDomDocument', 'getTypes', 'getSchema'))
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->_strategy = new ComplexTypeStrategy($this->_typeProcessor);
+ $this->_strategy->setContext($this->_wsdl);
+ parent::setUp();
+ }
+
+ /**
+ * Clean up.
+ */
+ protected function tearDown()
+ {
+ unset($this->_typeProcessor);
+ unset($this->_strategy);
+ unset($this->_wsdl);
+
+ parent::tearDown();
+ }
+
+ /**
+ * Test that addComplexType returns type WSDL name
+ * if it has already been processed (registered at includedTypes in WSDL)
+ */
+ public function testCheckTypeName()
+ {
+ $testType = 'testComplexTypeName';
+ $testTypeWsdlName = 'tns:' . $testType;
+ $includedTypes = array(
+ $testType => $testTypeWsdlName,
+ );
+ $this->_wsdl->expects($this->exactly(2))
+ ->method('getTypes')
+ ->will($this->returnValue($includedTypes));
+
+ $this->assertEquals($testTypeWsdlName, $this->_strategy->addComplexType($testType));
+ }
+
+ /**
+ * Test adding complex type with simple parameters.
+ *
+ * @param string $type
+ * @param array $data
+ * @dataProvider addComplexTypeDataProvider
+ */
+ public function testAddComplexTypeSimpleParameters($type, $data)
+ {
+ $this->_wsdl->expects($this->any())
+ ->method('getTypes')
+ ->will($this->returnValue(array()));
+
+ $this->_wsdl->expects($this->any())
+ ->method('toDomDocument')
+ ->will($this->returnValue(new \DOMDocument()));
+
+ $schemaMock = $this->_getDomElementMock();
+ $schemaMock->expects($this->any())
+ ->method('appendChild');
+ $this->_wsdl->expects($this->any())
+ ->method('getSchema')
+ ->will($this->returnValue($schemaMock));
+
+ $this->_typeProcessor->expects($this->at(0))
+ ->method('getTypeData')
+ ->with($type)
+ ->will($this->returnValue($data));
+
+ $this->assertEquals(Wsdl::TYPES_NS . ':' . $type, $this->_strategy->addComplexType($type));
+ }
+
+ /**
+ * Data provider for testAddComplexTypeSimpleParameters().
+ *
+ * @return array
+ */
+ public static function addComplexTypeDataProvider()
+ {
+ return array(
+ 'simple parameters' => array(
+ 'VendorModuleADataStructure',
+ array(
+ 'documentation' => 'test',
+ 'parameters' => array(
+ 'string_param' => array(
+ 'type' => 'string',
+ 'required' => true,
+ 'documentation' => 'Required string param.'
+ ),
+ 'int_param' => array(
+ 'type' => 'int',
+ 'required' => true,
+ 'documentation' => 'Required int param.'
+ ),
+ 'bool_param' => array(
+ 'type' => 'boolean',
+ 'required' => false,
+ 'documentation' => 'Optional complex type param.{annotation:test}'
+ ),
+ ),
+ ),
+ ),
+ 'type with call info' => array(
+ 'VendorModuleADataStructure',
+ array(
+ 'documentation' => 'test',
+ 'parameters' => array(
+ 'string_param' => array(
+ 'type' => 'string',
+ 'required' => false,
+ 'documentation' => '{callInfo:VendorModuleACreate:requiredInput:conditionally}',
+ ),
+ ),
+ 'callInfo' => array(
+ 'requiredInput' => array(
+ 'yes' => array(
+ 'calls' => array('VendorModuleACreate')
+ )
+ ),
+ 'returned' => array(
+ 'always' => array(
+ 'calls' => array('VendorModuleAGet')
+ )
+ )
+ ),
+ ),
+ ),
+ 'parameter with call info' => array(
+ 'VendorModuleADataStructure',
+ array(
+ 'documentation' => 'test',
+ 'parameters' => array(
+ 'string_param' => array(
+ 'type' => 'string',
+ 'required' => false,
+ 'documentation' => '{callInfo:VendorModuleACreate:requiredInput:conditionally}'
+ . '{callInfo:allCallsExcept(VendorModuleAGet):returned:always}',
+ ),
+ ),
+ ),
+ ),
+ 'parameter with see link' => array(
+ 'VendorModuleADataStructure',
+ array(
+ 'documentation' => 'test',
+ 'parameters' => array(
+ 'string_param' => array(
+ 'type' => 'string',
+ 'required' => false,
+ 'documentation' => '{seeLink:http://google.com/:title:for}',
+ ),
+ ),
+ ),
+ ),
+ 'parameter with doc instructions' => array(
+ 'VendorModuleADataStructure',
+ array(
+ 'documentation' => 'test',
+ 'parameters' => array(
+ 'string_param' => array(
+ 'type' => 'string',
+ 'required' => false,
+ 'documentation' => '{docInstructions:output:noDoc}',
+ ),
+ ),
+ ),
+ ),
+ );
+ }
+
+ /**
+ * Test adding complex type with complex parameters and arrays.
+ */
+ public function testAddComplexTypeComplexParameters()
+ {
+ $type = 'VendorModuleADataStructure';
+ $parameterType = 'ComplexType';
+ $typeData = array(
+ 'documentation' => 'test',
+ 'parameters' => array(
+ 'complex_param' => array(
+ 'type' => $parameterType,
+ 'required' => true,
+ 'documentation' => 'complex type param.'
+ ),
+ ),
+ );
+ $parameterData = array(
+ 'documentation' => 'test',
+ 'parameters' => array(
+ 'string_param' => array(
+ 'type' => 'ComplexTypeB[]',
+ 'required' => true,
+ 'documentation' => 'string param.'
+ ),
+ ),
+ );
+
+ $this->_wsdl->expects($this->at(0))
+ ->method('getTypes')
+ ->will($this->returnValue(array()));
+ $this->_wsdl->expects($this->any())
+ ->method('getTypes')
+ ->will($this->returnValue(array($type => Wsdl::TYPES_NS . ':' . $type)));
+
+ $this->_wsdl->expects($this->any())
+ ->method('toDomDocument')
+ ->will($this->returnValue(new \DOMDocument()));
+ $schemaMock = $this->_getDomElementMock();
+ $schemaMock->expects($this->any())
+ ->method('appendChild');
+ $this->_wsdl->expects($this->any())
+ ->method('getSchema')
+ ->will($this->returnValue($schemaMock));
+ $this->_typeProcessor->expects($this->at(0))
+ ->method('getTypeData')
+ ->with($type)
+ ->will($this->returnValue($typeData));
+ $this->_typeProcessor->expects($this->at(1))
+ ->method('getTypeData')
+ ->with($parameterType)
+ ->will($this->returnValue($parameterData));
+
+ $this->assertEquals(Wsdl::TYPES_NS . ':' . $type, $this->_strategy->addComplexType($type));
+ }
+
+ /**
+ * Test to verify if annotations are added correctly
+ */
+ public function testAddAnnotationToComplexType()
+ {
+ $dom = new \DOMDocument();
+ $this->_wsdl->expects($this->any())
+ ->method('toDomDocument')
+ ->will($this->returnValue($dom));
+ $annotationDoc = "test doc";
+ $complexType = $dom->createElement(Wsdl::XSD_NS . ':complexType');
+ $complexType->setAttribute('name', 'testRequest');
+ $this->_strategy->addAnnotation($complexType, $annotationDoc);
+ $this->assertEquals(
+ $annotationDoc,
+ $complexType->getElementsByTagName("xsd:documentation")->item(0)->nodeValue
+ );
+ }
+
+ /**
+ * Create mock for DOMElement.
+ *
+ * @return \PHPUnit_Framework_MockObject_MockObject
+ */
+ protected function _getDomElementMock()
+ {
+ return $this->getMockBuilder('DOMElement')
+ ->disableOriginalConstructor()
+ ->getMock();
+ }
+}
diff --git a/dev/tests/unit/testsuite/Magento/Webapi/Model/Soap/Wsdl/GeneratorTest.php b/dev/tests/unit/testsuite/Magento/Webapi/Model/Soap/Wsdl/GeneratorTest.php
index a7a73b99f70d5..ebab2bd3bfd80 100644
--- a/dev/tests/unit/testsuite/Magento/Webapi/Model/Soap/Wsdl/GeneratorTest.php
+++ b/dev/tests/unit/testsuite/Magento/Webapi/Model/Soap/Wsdl/GeneratorTest.php
@@ -30,17 +30,17 @@ class GeneratorTest extends \PHPUnit_Framework_TestCase
/** @var \Magento\Webapi\Model\Soap\Wsdl\Generator */
protected $_wsdlGenerator;
- /** @var \Magento\Webapi\Model\Soap\Config */
+ /** @var \Magento\Webapi\Model\Soap\Config|\PHPUnit_Framework_MockObject_MockObject */
protected $_soapConfigMock;
- /** @var \Magento\Webapi\Model\Soap\Wsdl\Factory */
+ /** @var \Magento\Webapi\Model\Soap\Wsdl\Factory|\PHPUnit_Framework_MockObject_MockObject */
protected $_wsdlFactoryMock;
- /** @var \Magento\Webapi\Model\Cache\Type */
+ /** @var \Magento\Webapi\Model\Cache\Type|\PHPUnit_Framework_MockObject_MockObject */
protected $_cacheMock;
- /** @var \Magento\DomDocument\Factory */
- protected $_domDocumentFactory;
+ /** @var \Magento\Webapi\Model\Config\ClassReflector\TypeProcessor|\PHPUnit_Framework_MockObject_MockObject */
+ protected $_typeProcessor;
protected function setUp()
{
@@ -79,132 +79,24 @@ protected function setUp()
$this->_cacheMock->expects($this->any())->method('load')->will($this->returnValue(false));
$this->_cacheMock->expects($this->any())->method('save')->will($this->returnValue(true));
- $this->_domDocumentFactory = $this->getMockBuilder('Magento\DomDocument\Factory')
- ->disableOriginalConstructor()->getMock();
+ $this->_typeProcessor = $this->getMock(
+ 'Magento\Webapi\Model\Config\ClassReflector\TypeProcessor',
+ [],
+ [],
+ '',
+ false
+ );
$this->_wsdlGenerator = new \Magento\Webapi\Model\Soap\Wsdl\Generator(
$this->_soapConfigMock,
$this->_wsdlFactoryMock,
$this->_cacheMock,
- $this->_domDocumentFactory
+ $this->_typeProcessor
);
parent::setUp();
}
- protected function tearDown()
- {
- unset($this->_wsdlGenerator);
- unset($this->_soapConfigMock);
- unset($this->_wsdlFactoryMock);
- unset($this->_cacheMock);
- parent::tearDown();
- }
-
- public function testGetComplexTypeNodes()
- {
- $serviceName = "serviceName";
- $nodesList = $this->_wsdlGenerator->getComplexTypeNodes($serviceName,
- 'ItemsResponse',
- $this->_getXsdDocumentWithReferencedTypes()
- );
- $expectedCount = 2;
- $this->assertCount($expectedCount, $nodesList, "Defined complex types count does not match.");
- $actualTypes = array();
- foreach ($nodesList as $node) {
- $actualTypes[] = $node->getAttribute('name');
- }
- $expectedTypes = array($serviceName . 'ItemsResponse', $serviceName . 'ArrayItem');
- $this->assertEquals(
- $expectedCount,
- count(array_intersect($expectedTypes, $actualTypes)),
- "Complex types does not match."
- );
- }
-
- /**
- * @return \DOMDocument
- */
- protected function _getXsdDocumentWithReferencedTypes()
- {
- $xsd =
- '
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ';
- $xsdDom = new \DOMDocument();
- $xsdDom->loadXML($xsd);
- return $xsdDom;
- }
-
- /**
- * @return \DOMDocument
- */
- protected function _getXsdDocumentMissingTargetNamespace()
- {
- $xsd =
- '
-
-
-
-
-
-
-
-
-
-
-
- ';
- $xsdDom = new \DOMDocument();
- $xsdDom->loadXML($xsd);
- return $xsdDom;
- }
-
- /**
- * @dataProvider providerIsComplexType
- */
- public function testIsComplexType($type, $isComplex)
- {
- $this->assertEquals(
- $isComplex,
- $this->_wsdlGenerator->isComplexType($type),
- "Complex type is defined incorrectly"
- );
- }
-
- public static function providerIsComplexType()
- {
- return array(
- array('xs:int', false),
- array('xsd:string', false),
- array('itemRequest', true),
- );
- }
-
/**
* Test getElementComplexTypeName
*/
@@ -280,25 +172,25 @@ public function testHandleWithException()
$genWSDL = 'generatedWSDL';
$exceptionMsg = 'exception message';
$requestedService = array(
- 'catalogProduct' => 'V1',
+ 'catalogProduct',
);
$wsdlGeneratorMock = $this->getMockBuilder(
'Magento\Webapi\Model\Soap\Wsdl\Generator'
)
- ->setMethods(array('_prepareServiceData'))
+ ->setMethods(array('_collectCallInfo'))
->setConstructorArgs(
array(
$this->_soapConfigMock,
$this->_wsdlFactoryMock,
$this->_cacheMock,
- $this->_domDocumentFactory
+ $this->_typeProcessor
)
)
->getMock();
- $wsdlGeneratorMock->expects($this->once())->method('_prepareServiceData')->will(
- $this->throwException(new \Exception($exceptionMsg))
+ $wsdlGeneratorMock->expects($this->once())->method('_collectCallInfo')->will(
+ $this->throwException(new \Magento\Webapi\Exception($exceptionMsg))
);
$this->assertEquals($genWSDL, $wsdlGeneratorMock->generate($requestedService, 'http://magento.host'));
diff --git a/dev/tests/unit/testsuite/Magento/Webapi/Service/Entity/AssociativeArrayDto.php b/dev/tests/unit/testsuite/Magento/Webapi/Service/Entity/AssociativeArrayDto.php
new file mode 100644
index 0000000000000..64ce79a41b092
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Webapi/Service/Entity/AssociativeArrayDto.php
@@ -0,0 +1,37 @@
+_get('associativeArray');
+ }
+}
diff --git a/dev/tests/unit/testsuite/Magento/Webapi/Service/Entity/DtoArrayDto.php b/dev/tests/unit/testsuite/Magento/Webapi/Service/Entity/DtoArrayDto.php
new file mode 100644
index 0000000000000..91245024ab6e9
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Webapi/Service/Entity/DtoArrayDto.php
@@ -0,0 +1,37 @@
+_get('items');
+ }
+}
diff --git a/dev/tests/unit/testsuite/Magento/Webapi/Service/Entity/DtoFromArrayTest.php b/dev/tests/unit/testsuite/Magento/Webapi/Service/Entity/DtoFromArrayTest.php
new file mode 100644
index 0000000000000..1f953121ed926
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Webapi/Service/Entity/DtoFromArrayTest.php
@@ -0,0 +1,199 @@
+getObject('Magento\Webapi\Model\Config\ClassReflector\TypeProcessor');
+ $this->serializer = new ServiceArgsSerializer($typeProcessor);
+ }
+
+ public function testSimpleProperties()
+ {
+ $data = ['entityId' => 15, 'name' => 'Test'];
+ $result = $this->serializer
+ ->getInputData('\\Magento\\Webapi\\Service\\Entity\\TestService', 'simple', $data);
+ $this->assertNotNull($result);
+ $this->assertEquals(15, $result[0]);
+ $this->assertEquals('Test', $result[1]);
+ }
+
+ public function testNestedDtoProperties()
+ {
+ $data = ['nested' => ['details' => ['entityId' => 15, 'name' => 'Test']]];
+ $result = $this->serializer
+ ->getInputData('\\Magento\\Webapi\\Service\\Entity\\TestService', 'nestedDto', $data);
+ $this->assertNotNull($result);
+ $this->assertTrue( $result[0] instanceof NestedDto);
+ /** @var array $result */
+ $this->assertEquals(1, count($result));
+ $this->assertNotEmpty($result[0]);
+ /** @var NestedDto $arg */
+ $arg = $result[0];
+ $this->assertTrue($arg instanceof NestedDto);
+ /** @var SimpleDto $details */
+ $details = $arg->getDetails();
+ $this->assertNotNull($details);
+ $this->assertTrue($details instanceof SimpleDto);
+ $this->assertEquals(15, $details->getEntityId());
+ $this->assertEquals('Test', $details->getName());
+ }
+
+ public function testSimpleArrayProperties()
+ {
+ $data = ['ids'=>[1,2,3,4]];
+ $result = $this->serializer->getInputData(
+ '\\Magento\\Webapi\\Service\\Entity\\TestService',
+ 'simpleArray',
+ $data
+ );
+ $this->assertNotNull($result);
+ /** @var array $result */
+ $this->assertEquals(1, count($result));
+ /** @var array $ids */
+ $ids = $result[0];
+ $this->assertNotNull($ids);
+ $this->assertEquals(4, count($ids));
+ $this->assertEquals($data['ids'], $ids);
+ }
+
+ public function testAssociativeArrayProperties()
+ {
+ $data = ['associativeArray' => ['key' => 'value', 'key_two' => 'value_two']];
+ $result = $this->serializer->getInputData(
+ '\\Magento\\Webapi\\Service\\Entity\\TestService',
+ 'associativeArray',
+ $data
+ );
+ $this->assertNotNull($result);
+ /** @var array $result */
+ $this->assertEquals(1, count($result));
+ /** @var array $associativeArray */
+ $associativeArray = $result[0];
+ $this->assertNotNull($associativeArray);
+ $this->assertEquals('value', $associativeArray['key']);
+ $this->assertEquals('value_two', $associativeArray['key_two']);
+ }
+
+ public function testArrayOfDtoProperties()
+ {
+ $data = ['dtos' => [ ['entityId' => 14, 'name' => 'First'], [ 'entityId' => 15, 'name' => 'Second' ] ]];
+ $result = $this->serializer->getInputData('\\Magento\\Webapi\\Service\\Entity\\TestService', 'dtoArray', $data);
+ $this->assertNotNull($result);
+ /** @var array $result */
+ $this->assertEquals(1, count($result));
+ /** @var array $dtos */
+ $dtos = $result[0];
+ $this->assertEquals(2, count($dtos));
+ /** @var SimpleDto $first */
+ $first = $dtos[0];
+ /** @var SimpleDto $second */
+ $second = $dtos[1];
+ $this->assertTrue($first instanceof SimpleDto);
+ $this->assertEquals(14, $first->getEntityId());
+ $this->assertEquals('First', $first->getName());
+ $this->assertTrue($second instanceof SimpleDto);
+ $this->assertEquals(15, $second->getEntityId());
+ $this->assertEquals('Second', $second->getName());
+ }
+
+ public function testNestedSimpleArrayProperties()
+ {
+ $data = ['arrayDto' => ['ids' => [1, 2, 3, 4]]];
+ $result = $this->serializer
+ ->getInputData('\\Magento\\Webapi\\Service\\Entity\\TestService', 'nestedSimpleArray', $data);
+ $this->assertNotNull($result);
+ /** @var array $result */
+ $this->assertEquals(1, count($result));
+ /** @var SimpleArrayDto $dto */
+ $dto = $result[0];
+ $this->assertTrue($dto instanceof SimpleArrayDto);
+ /** @var array $ids */
+ $ids = $dto->getIds();
+ $this->assertNotNull($ids);
+ $this->assertEquals(4, count($ids));
+ $this->assertEquals($data['arrayDto']['ids'], $ids);
+ }
+
+ public function testNestedAssociativeArrayProperties()
+ {
+ $data = ['associativeArrayDto' => ['associativeArray' => ['key' => 'value', 'key2' => 'value2']]];
+ $result = $this->serializer->getInputData(
+ '\\Magento\\Webapi\\Service\\Entity\\TestService',
+ 'nestedAssociativeArray',
+ $data
+ );
+ $this->assertNotNull($result);
+ /** @var array $result */
+ $this->assertEquals(1, count($result));
+ /** @var AssociativeArrayDto $dto */
+ $dto = $result[0];
+ $this->assertTrue($dto instanceof AssociativeArrayDto);
+ /** @var array $associativeArray */
+ $associativeArray = $dto->getAssociativeArray();
+ $this->assertNotNull($associativeArray);
+ $this->assertEquals('value', $associativeArray['key']);
+ $this->assertEquals('value2', $associativeArray['key2']);
+ }
+
+ public function testNestedArrayOfDtoProperties()
+ {
+ $data = ['dtos' => ['items' => [['entityId' => 1, 'name' => 'First'], ['entityId' => 2, 'name' => 'Second']]]];
+ $result = $this->serializer->getInputData(
+ '\\Magento\\Webapi\\Service\\Entity\\TestService',
+ 'nestedDtoArray',
+ $data
+ );
+ $this->assertNotNull($result);
+ /** @var array $result */
+ $this->assertEquals(1, count($result));
+ /** @var DtoArrayDto $dtos */
+ $dtos = $result[0];
+ $this->assertTrue($dtos instanceof DtoArrayDto);
+ /** @var array $items */
+ $items = $dtos->getItems();
+ $this->assertEquals(2, count($items));
+ /** @var SimpleDto $first */
+ $first = $items[0];
+ /** @var SimpleDto $second */
+ $second = $items[1];
+ $this->assertTrue($first instanceof SimpleDto);
+ $this->assertEquals(1, $first->getEntityId());
+ $this->assertEquals('First', $first->getName());
+ $this->assertTrue($second instanceof SimpleDto);
+ $this->assertEquals(2, $second->getEntityId());
+ $this->assertEquals('Second', $second->getName());
+ }
+}
diff --git a/dev/tests/unit/testsuite/Magento/Webapi/Service/Entity/NestedDto.php b/dev/tests/unit/testsuite/Magento/Webapi/Service/Entity/NestedDto.php
new file mode 100644
index 0000000000000..8766f45b557dd
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Webapi/Service/Entity/NestedDto.php
@@ -0,0 +1,37 @@
+_get('details');
+ }
+}
diff --git a/dev/tests/unit/testsuite/Magento/Webapi/Service/Entity/SimpleArrayDto.php b/dev/tests/unit/testsuite/Magento/Webapi/Service/Entity/SimpleArrayDto.php
new file mode 100644
index 0000000000000..24fa2be7bcab0
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Webapi/Service/Entity/SimpleArrayDto.php
@@ -0,0 +1,38 @@
+_get('ids');
+ }
+}
diff --git a/dev/tests/unit/testsuite/Magento/Webapi/Service/Entity/SimpleDto.php b/dev/tests/unit/testsuite/Magento/Webapi/Service/Entity/SimpleDto.php
new file mode 100644
index 0000000000000..2b11cfb18822e
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Webapi/Service/Entity/SimpleDto.php
@@ -0,0 +1,46 @@
+_get('entityId');
+ }
+
+ /**
+ * @return string|null
+ */
+ public function getName()
+ {
+ return $this->_get('name');
+ }
+}
diff --git a/dev/tests/unit/testsuite/Magento/Webapi/Service/Entity/TestService.php b/dev/tests/unit/testsuite/Magento/Webapi/Service/Entity/TestService.php
new file mode 100644
index 0000000000000..c05deda979aab
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Webapi/Service/Entity/TestService.php
@@ -0,0 +1,101 @@
+Fault reason
-
- value1
- value2
-
+
+
+
+ key1
+ value1
+
+
+ key2
+ value2
+
+
+ 333
+ Trace
+
@@ -88,7 +98,7 @@
',
'expectedResultComplexDataDetails' =>
'
-
+
@@ -97,13 +107,6 @@
Fault reason
-
-
-
- value
-
-
-
'
diff --git a/dev/tests/unit/testsuite/Magento/Webapi/_files/test_interfaces.php b/dev/tests/unit/testsuite/Magento/Webapi/_files/test_interfaces.php
new file mode 100644
index 0000000000000..9aee13f65fb86
--- /dev/null
+++ b/dev/tests/unit/testsuite/Magento/Webapi/_files/test_interfaces.php
@@ -0,0 +1,50 @@
+ 'paybox_api_debug',
'paybox/question_number' => 'paybox_question_number',
'paygate/authorizenet_debug' => 'authorizenet_debug',
- 'paypal/api_debug' => 'paypal_api_debug',
'paypal/cert' => 'paypal_cert',
'paypal/payment_transaction' => 'paypal_payment_transaction',
'paypal/settlement_report' => 'paypal_settlement_report',
'paypal/settlement_report_row' => 'paypal_settlement_report_row',
- 'paypaluk/api_debug' => 'paypaluk_api_debug',
'persistent/session' => 'persistent_session',
'poll/poll' => 'poll',
'poll/poll_answer' => 'poll_answer',
diff --git a/dev/tools/Magento/Tools/Migration/themes_view.php b/dev/tools/Magento/Tools/Migration/themes_view.php
index 1f6c2e9972211..3ea1882ab265f 100644
--- a/dev/tools/Magento/Tools/Migration/themes_view.php
+++ b/dev/tools/Magento/Tools/Migration/themes_view.php
@@ -28,9 +28,9 @@
try {
$entryPoint = new \Magento\App\EntryPoint\EntryPoint($rootDir, array());
- $objectManager = new \Magento\App\ObjectManager($config);
- /** @var $configModel \Magento\Core\Model\Config */
- $configModel = $objectManager->get('Magento\Core\Model\Config');
+ $objectManager = new \Magento\App\ObjectManager();
+ /** @var $configModel \Magento\App\ReinitableConfigInterface */
+ $configModel = $objectManager->get('Magento\App\ReinitableConfigInterface');
$configModel->reinit();
$config = array();
diff --git a/dev/tools/Magento/Tools/View/Generator/ThemeLight.php b/dev/tools/Magento/Tools/View/Generator/ThemeLight.php
index ef8198079b3c8..08a45d0cf9f52 100644
--- a/dev/tools/Magento/Tools/View/Generator/ThemeLight.php
+++ b/dev/tools/Magento/Tools/View/Generator/ThemeLight.php
@@ -24,12 +24,14 @@
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
+namespace Magento\Tools\View\Generator;
+
+use Magento\View\Design\ThemeInterface;
+
/**
* Lightweight theme that implements minimal required interface
*/
-namespace Magento\Tools\View\Generator;
-
-class ThemeLight extends \Magento\Object implements \Magento\View\Design\ThemeInterface
+class ThemeLight extends \Magento\Object implements ThemeInterface
{
/**
* {@inheritdoc}
@@ -52,7 +54,7 @@ public function getThemePath()
*/
public function getFullPath()
{
- return $this->getArea() . \Magento\View\Design\ThemeInterface::PATH_SEPARATOR . $this->getThemePath();
+ return $this->getArea() . ThemeInterface::PATH_SEPARATOR . $this->getThemePath();
}
/**
@@ -78,4 +80,12 @@ public function isPhysical()
{
return false;
}
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getInheritedThemes()
+ {
+ return array();
+ }
}
diff --git a/downloader/app/Magento/Downloader/Controller.php b/downloader/app/Magento/Downloader/Controller.php
index 305520d2cfe74..f40a5e929e6e4 100755
--- a/downloader/app/Magento/Downloader/Controller.php
+++ b/downloader/app/Magento/Downloader/Controller.php
@@ -518,7 +518,7 @@ public static function singleton()
}
\Magento\App\ObjectManager::getInstance()->get('Magento\Core\Model\App');
if (self::isInstalled()) {
- \Mage::getSingleton('Magento\Backend\Model\Url')->turnOffSecretKey();
+ \Mage::getSingleton('Magento\Backend\Model\UrlInterface')->turnOffSecretKey();
}
}
}
diff --git a/lib/Less/Autoloader.php b/lib/Less/Autoloader.php
new file mode 100644
index 0000000000000..09a884b700c7e
--- /dev/null
+++ b/lib/Less/Autoloader.php
@@ -0,0 +1,79 @@
+SetCacheDir( self::$cache_dir );
+ $parser->SetImportDirs( self::$import_dirs );
+
+
+ // combine files
+ foreach($less_files as $file_path => $uri_or_less ){
+
+ //treat as less markup if there are newline characters
+ if( strpos($uri_or_less,"\n") !== false ){
+ $parser->Parse( $uri_or_less );
+ continue;
+ }
+
+ $parser->ParseFile( $file_path, $uri_or_less );
+ }
+
+ $compiled = $parser->getCss();
+
+
+ $less_files = $parser->allParsedFiles();
+
+ return $compiled;
+ }
+
+
+ private static function CompiledName( $files ){
+
+ //save the file list
+ $temp = array(self::cache_version);
+ foreach($files as $file){
+ $temp[] = filemtime($file)."\t".filesize($file)."\t".$file;
+ }
+
+ return 'lessphp_'.sha1(json_encode($temp)).'.css';
+ }
+
+
+ public static function CleanCache(){
+ static $clean = false;
+
+ if( $clean ){
+ return;
+ }
+
+ $files = scandir(self::$cache_dir);
+ if( $files ){
+ $check_time = time() - 604800;
+ foreach($files as $file){
+ if( strpos($file,'lessphp_') !== 0 ){
+ continue;
+ }
+ $full_path = self::$cache_dir.'/'.$file;
+ if( filemtime($full_path) > $check_time ){
+ continue;
+ }
+ unlink($full_path);
+ }
+ }
+
+ $clean = true;
+ }
+
+}
\ No newline at end of file
diff --git a/lib/Less/Colors.php b/lib/Less/Colors.php
new file mode 100644
index 0000000000000..4bb2f137d8512
--- /dev/null
+++ b/lib/Less/Colors.php
@@ -0,0 +1,176 @@
+'#f0f8ff',
+ 'antiquewhite'=>'#faebd7',
+ 'aqua'=>'#00ffff',
+ 'aquamarine'=>'#7fffd4',
+ 'azure'=>'#f0ffff',
+ 'beige'=>'#f5f5dc',
+ 'bisque'=>'#ffe4c4',
+ 'black'=>'#000000',
+ 'blanchedalmond'=>'#ffebcd',
+ 'blue'=>'#0000ff',
+ 'blueviolet'=>'#8a2be2',
+ 'brown'=>'#a52a2a',
+ 'burlywood'=>'#deb887',
+ 'cadetblue'=>'#5f9ea0',
+ 'chartreuse'=>'#7fff00',
+ 'chocolate'=>'#d2691e',
+ 'coral'=>'#ff7f50',
+ 'cornflowerblue'=>'#6495ed',
+ 'cornsilk'=>'#fff8dc',
+ 'crimson'=>'#dc143c',
+ 'cyan'=>'#00ffff',
+ 'darkblue'=>'#00008b',
+ 'darkcyan'=>'#008b8b',
+ 'darkgoldenrod'=>'#b8860b',
+ 'darkgray'=>'#a9a9a9',
+ 'darkgrey'=>'#a9a9a9',
+ 'darkgreen'=>'#006400',
+ 'darkkhaki'=>'#bdb76b',
+ 'darkmagenta'=>'#8b008b',
+ 'darkolivegreen'=>'#556b2f',
+ 'darkorange'=>'#ff8c00',
+ 'darkorchid'=>'#9932cc',
+ 'darkred'=>'#8b0000',
+ 'darksalmon'=>'#e9967a',
+ 'darkseagreen'=>'#8fbc8f',
+ 'darkslateblue'=>'#483d8b',
+ 'darkslategray'=>'#2f4f4f',
+ 'darkslategrey'=>'#2f4f4f',
+ 'darkturquoise'=>'#00ced1',
+ 'darkviolet'=>'#9400d3',
+ 'deeppink'=>'#ff1493',
+ 'deepskyblue'=>'#00bfff',
+ 'dimgray'=>'#696969',
+ 'dimgrey'=>'#696969',
+ 'dodgerblue'=>'#1e90ff',
+ 'firebrick'=>'#b22222',
+ 'floralwhite'=>'#fffaf0',
+ 'forestgreen'=>'#228b22',
+ 'fuchsia'=>'#ff00ff',
+ 'gainsboro'=>'#dcdcdc',
+ 'ghostwhite'=>'#f8f8ff',
+ 'gold'=>'#ffd700',
+ 'goldenrod'=>'#daa520',
+ 'gray'=>'#808080',
+ 'grey'=>'#808080',
+ 'green'=>'#008000',
+ 'greenyellow'=>'#adff2f',
+ 'honeydew'=>'#f0fff0',
+ 'hotpink'=>'#ff69b4',
+ 'indianred'=>'#cd5c5c',
+ 'indigo'=>'#4b0082',
+ 'ivory'=>'#fffff0',
+ 'khaki'=>'#f0e68c',
+ 'lavender'=>'#e6e6fa',
+ 'lavenderblush'=>'#fff0f5',
+ 'lawngreen'=>'#7cfc00',
+ 'lemonchiffon'=>'#fffacd',
+ 'lightblue'=>'#add8e6',
+ 'lightcoral'=>'#f08080',
+ 'lightcyan'=>'#e0ffff',
+ 'lightgoldenrodyellow'=>'#fafad2',
+ 'lightgray'=>'#d3d3d3',
+ 'lightgrey'=>'#d3d3d3',
+ 'lightgreen'=>'#90ee90',
+ 'lightpink'=>'#ffb6c1',
+ 'lightsalmon'=>'#ffa07a',
+ 'lightseagreen'=>'#20b2aa',
+ 'lightskyblue'=>'#87cefa',
+ 'lightslategray'=>'#778899',
+ 'lightslategrey'=>'#778899',
+ 'lightsteelblue'=>'#b0c4de',
+ 'lightyellow'=>'#ffffe0',
+ 'lime'=>'#00ff00',
+ 'limegreen'=>'#32cd32',
+ 'linen'=>'#faf0e6',
+ 'magenta'=>'#ff00ff',
+ 'maroon'=>'#800000',
+ 'mediumaquamarine'=>'#66cdaa',
+ 'mediumblue'=>'#0000cd',
+ 'mediumorchid'=>'#ba55d3',
+ 'mediumpurple'=>'#9370d8',
+ 'mediumseagreen'=>'#3cb371',
+ 'mediumslateblue'=>'#7b68ee',
+ 'mediumspringgreen'=>'#00fa9a',
+ 'mediumturquoise'=>'#48d1cc',
+ 'mediumvioletred'=>'#c71585',
+ 'midnightblue'=>'#191970',
+ 'mintcream'=>'#f5fffa',
+ 'mistyrose'=>'#ffe4e1',
+ 'moccasin'=>'#ffe4b5',
+ 'navajowhite'=>'#ffdead',
+ 'navy'=>'#000080',
+ 'oldlace'=>'#fdf5e6',
+ 'olive'=>'#808000',
+ 'olivedrab'=>'#6b8e23',
+ 'orange'=>'#ffa500',
+ 'orangered'=>'#ff4500',
+ 'orchid'=>'#da70d6',
+ 'palegoldenrod'=>'#eee8aa',
+ 'palegreen'=>'#98fb98',
+ 'paleturquoise'=>'#afeeee',
+ 'palevioletred'=>'#d87093',
+ 'papayawhip'=>'#ffefd5',
+ 'peachpuff'=>'#ffdab9',
+ 'peru'=>'#cd853f',
+ 'pink'=>'#ffc0cb',
+ 'plum'=>'#dda0dd',
+ 'powderblue'=>'#b0e0e6',
+ 'purple'=>'#800080',
+ 'red'=>'#ff0000',
+ 'rosybrown'=>'#bc8f8f',
+ 'royalblue'=>'#4169e1',
+ 'saddlebrown'=>'#8b4513',
+ 'salmon'=>'#fa8072',
+ 'sandybrown'=>'#f4a460',
+ 'seagreen'=>'#2e8b57',
+ 'seashell'=>'#fff5ee',
+ 'sienna'=>'#a0522d',
+ 'silver'=>'#c0c0c0',
+ 'skyblue'=>'#87ceeb',
+ 'slateblue'=>'#6a5acd',
+ 'slategray'=>'#708090',
+ 'slategrey'=>'#708090',
+ 'snow'=>'#fffafa',
+ 'springgreen'=>'#00ff7f',
+ 'steelblue'=>'#4682b4',
+ 'tan'=>'#d2b48c',
+ 'teal'=>'#008080',
+ 'thistle'=>'#d8bfd8',
+ 'tomato'=>'#ff6347',
+ 'turquoise'=>'#40e0d0',
+ 'violet'=>'#ee82ee',
+ 'wheat'=>'#f5deb3',
+ 'white'=>'#ffffff',
+ 'whitesmoke'=>'#f5f5f5',
+ 'yellow'=>'#ffff00',
+ 'yellowgreen'=>'#9acd32'
+ );
+ return self::$colors;
+ }
+
+ public static function hasOwnProperty($color) {
+ $colors = self::all();
+ return isset($colors[$color]);
+ }
+
+
+ public static function color($color) {
+ $colors = self::all();
+ return $colors[$color];
+ }
+
+}
diff --git a/lib/Less/Environment.php b/lib/Less/Environment.php
new file mode 100644
index 0000000000000..57ece2148fdac
--- /dev/null
+++ b/lib/Less/Environment.php
@@ -0,0 +1,208 @@
+frames = array();
+
+
+ if( isset($options['compress']) ){
+ self::$compress = (bool)$options['compress'];
+ }
+ if( isset($options['strictUnits']) ){
+ $this->strictUnits = (bool)$options['strictUnits'];
+ }
+
+
+ if( self::$compress ){
+ self::$comma_space = ',';
+ self::$colon_space = ':';
+ }else{
+ self::$comma_space = ', ';
+ self::$colon_space = ': ';
+ }
+
+
+ }
+
+
+ //may want to just use the __clone()?
+ public function copyEvalEnv($frames = array() ){
+
+ $evalCopyProperties = array(
+ //'silent', // whether to swallow errors and warnings
+ //'verbose', // whether to log more activity
+ //'yuicompress', // whether to compress with the outside tool yui compressor
+ //'ieCompat', // whether to enforce IE compatibility (IE8 data-uri)
+ 'strictMath', // whether math has to be within parenthesis
+ 'strictUnits', // whether units need to evaluate correctly
+ //'cleancss', // whether to compress with clean-css
+ //'sourceMap', // whether to output a source map
+ //'importMultiple'// whether we are currently importing multiple copies
+ );
+
+ $new_env = new Less_Environment();
+ foreach($evalCopyProperties as $property){
+ $new_env->$property = $this->$property;
+ }
+ $new_env->frames = $frames;
+ return $new_env;
+ }
+
+ public function inParenthesis(){
+ $this->parensStack[] = true;
+ }
+
+ public function outOfParenthesis() {
+ array_pop($this->parensStack);
+ }
+
+ public function isMathOn() {
+ return $this->strictMath ? !!$this->parensStack : true;
+ }
+
+ public static function isPathRelative($path){
+ /**
+ * - return !preg_match('/^(?:[a-z-]+:|\/)/',$path);
+ * + return !preg_match('/^(?:[A-Za-z-_]+:|\/)/',$path);
+ *
+ * For identification paths such as Magento_Theme::validation_advice_bg.gif as an absolute paths.
+ */
+ return !preg_match('/^(?:[A-Za-z-_]+:|\/)/',$path);
+ }
+
+
+ /**
+ * Canonicalize a path by resolving references to '/./', '/../'
+ * Does not remove leading "../"
+ * @param string path or url
+ * @return string Canonicalized path
+ *
+ */
+ static function normalizePath($path){
+
+ $segments = explode('/',$path);
+ $segments = array_reverse($segments);
+
+ $path = array();
+ $path_len = 0;
+
+ while( $segments ){
+ $segment = array_pop($segments);
+ switch( $segment ) {
+
+ case '.':
+ break;
+
+ case '..':
+ if( !$path_len || ( $path[$path_len-1] === '..') ){
+ $path[] = $segment;
+ $path_len++;
+ }else{
+ array_pop($path);
+ $path_len--;
+ }
+ break;
+
+ default:
+ $path[] = $segment;
+ $path_len++;
+ break;
+ }
+ }
+
+ return implode('/',$path);
+ }
+
+
+ /**
+ * @return bool
+ */
+ public function getDebug(){
+ return $this->debug;
+ }
+
+ /**
+ * @param $debug
+ * @return void
+ */
+ public function setDebug($debug){
+ $this->debug = $debug;
+ }
+
+ public function unshiftFrame($frame){
+ array_unshift($this->frames, $frame);
+ }
+
+ public function shiftFrame(){
+ return array_shift($this->frames);
+ }
+
+ public function addFrame($frame){
+ $this->frames[] = $frame;
+ }
+
+ public function addFrames(array $frames){
+ $this->frames = array_merge($this->frames, $frames);
+ }
+}
diff --git a/lib/Less/Environment.php.origin b/lib/Less/Environment.php.origin
new file mode 100644
index 0000000000000..d8843597ec7fd
--- /dev/null
+++ b/lib/Less/Environment.php.origin
@@ -0,0 +1,202 @@
+frames = array();
+
+
+ if( isset($options['compress']) ){
+ self::$compress = (bool)$options['compress'];
+ }
+ if( isset($options['strictUnits']) ){
+ $this->strictUnits = (bool)$options['strictUnits'];
+ }
+
+
+ if( self::$compress ){
+ self::$comma_space = ',';
+ self::$colon_space = ':';
+ }else{
+ self::$comma_space = ', ';
+ self::$colon_space = ': ';
+ }
+
+
+ }
+
+
+ //may want to just use the __clone()?
+ public function copyEvalEnv($frames = array() ){
+
+ $evalCopyProperties = array(
+ //'silent', // whether to swallow errors and warnings
+ //'verbose', // whether to log more activity
+ //'yuicompress', // whether to compress with the outside tool yui compressor
+ //'ieCompat', // whether to enforce IE compatibility (IE8 data-uri)
+ 'strictMath', // whether math has to be within parenthesis
+ 'strictUnits', // whether units need to evaluate correctly
+ //'cleancss', // whether to compress with clean-css
+ //'sourceMap', // whether to output a source map
+ //'importMultiple'// whether we are currently importing multiple copies
+ );
+
+ $new_env = new Less_Environment();
+ foreach($evalCopyProperties as $property){
+ $new_env->$property = $this->$property;
+ }
+ $new_env->frames = $frames;
+ return $new_env;
+ }
+
+ public function inParenthesis(){
+ $this->parensStack[] = true;
+ }
+
+ public function outOfParenthesis() {
+ array_pop($this->parensStack);
+ }
+
+ public function isMathOn() {
+ return $this->strictMath ? !!$this->parensStack : true;
+ }
+
+ public static function isPathRelative($path){
+ return !preg_match('/^(?:[a-z-]+:|\/)/',$path);
+ }
+
+
+ /**
+ * Canonicalize a path by resolving references to '/./', '/../'
+ * Does not remove leading "../"
+ * @param string path or url
+ * @return string Canonicalized path
+ *
+ */
+ static function normalizePath($path){
+
+ $segments = explode('/',$path);
+ $segments = array_reverse($segments);
+
+ $path = array();
+ $path_len = 0;
+
+ while( $segments ){
+ $segment = array_pop($segments);
+ switch( $segment ) {
+
+ case '.':
+ break;
+
+ case '..':
+ if( !$path_len || ( $path[$path_len-1] === '..') ){
+ $path[] = $segment;
+ $path_len++;
+ }else{
+ array_pop($path);
+ $path_len--;
+ }
+ break;
+
+ default:
+ $path[] = $segment;
+ $path_len++;
+ break;
+ }
+ }
+
+ return implode('/',$path);
+ }
+
+
+ /**
+ * @return bool
+ */
+ public function getDebug(){
+ return $this->debug;
+ }
+
+ /**
+ * @param $debug
+ * @return void
+ */
+ public function setDebug($debug){
+ $this->debug = $debug;
+ }
+
+ public function unshiftFrame($frame){
+ array_unshift($this->frames, $frame);
+ }
+
+ public function shiftFrame(){
+ return array_shift($this->frames);
+ }
+
+ public function addFrame($frame){
+ $this->frames[] = $frame;
+ }
+
+ public function addFrames(array $frames){
+ $this->frames = array_merge($this->frames, $frames);
+ }
+}
diff --git a/lib/Less/Exception/Compiler.php b/lib/Less/Exception/Compiler.php
new file mode 100644
index 0000000000000..84c1fda2b5e3b
--- /dev/null
+++ b/lib/Less/Exception/Compiler.php
@@ -0,0 +1,20 @@
+filename = $filename;
+ }
+
+ public function getFilename() {
+ return $this->filename;
+ }
+
+ public function __toString() {
+ return $this->message . " (" . $this->filename . ")";
+ }
+}
diff --git a/lib/Less/Exception/Parser.php b/lib/Less/Exception/Parser.php
new file mode 100644
index 0000000000000..013d6d330dddf
--- /dev/null
+++ b/lib/Less/Exception/Parser.php
@@ -0,0 +1,6 @@
+env = $env;
+ $this->currentFileInfo = $currentFileInfo;
+ }
+
+
+ //tree.operate()
+ static public function operate ($env, $op, $a, $b){
+ switch ($op) {
+ case '+': return $a + $b;
+ case '-': return $a - $b;
+ case '*': return $a * $b;
+ case '/': return $a / $b;
+ }
+ }
+
+ static public function clamp($val){
+ return min(1, max(0, $val));
+ }
+
+ static public function number($n){
+
+ if ($n instanceof Less_Tree_Dimension) {
+ return floatval( $n->unit->is('%') ? $n->value / 100 : $n->value);
+ } else if (is_numeric($n)) {
+ return $n;
+ } else {
+ throw new Less_Exception_Compiler("color functions take numbers as parameters");
+ }
+ }
+
+ static public function scaled($n, $size = 256 ){
+ if( $n instanceof Less_Tree_Dimension && $n->unit->is('%') ){
+ return (float)$n->value * $size / 100;
+ } else {
+ return Less_Functions::number($n);
+ }
+ }
+
+ public function rgb ($r, $g, $b){
+ return $this->rgba($r, $g, $b, 1.0);
+ }
+
+ public function rgba($r, $g, $b, $a){
+ $rgb = array($r, $g, $b);
+ $rgb = array_map(array('Less_Functions','scaled'),$rgb);
+
+ $a = self::number($a);
+ return new Less_Tree_Color($rgb, $a);
+ }
+
+ public function hsl($h, $s, $l){
+ return $this->hsla($h, $s, $l, 1.0);
+ }
+
+ public function hsla($h, $s, $l, $a){
+
+ $h = fmod(self::number($h), 360) / 360; // Classic % operator will change float to int
+ $s = self::clamp(self::number($s));
+ $l = self::clamp(self::number($l));
+ $a = self::clamp(self::number($a));
+
+ $m2 = $l <= 0.5 ? $l * ($s + 1) : $l + $s - $l * $s;
+
+ $m1 = $l * 2 - $m2;
+
+ return $this->rgba( self::hsla_hue($h + 1/3, $m1, $m2) * 255,
+ self::hsla_hue($h, $m1, $m2) * 255,
+ self::hsla_hue($h - 1/3, $m1, $m2) * 255,
+ $a);
+ }
+
+ function hsla_hue($h, $m1, $m2){
+ $h = $h < 0 ? $h + 1 : ($h > 1 ? $h - 1 : $h);
+ if ($h * 6 < 1) return $m1 + ($m2 - $m1) * $h * 6;
+ else if ($h * 2 < 1) return $m2;
+ else if ($h * 3 < 2) return $m1 + ($m2 - $m1) * (2/3 - $h) * 6;
+ else return $m1;
+ }
+
+ public function hsv($h, $s, $v) {
+ return $this->hsva($h, $s, $v, 1.0);
+ }
+
+ public function hsva($h, $s, $v, $a) {
+ $h = ((Less_Functions::number($h) % 360) / 360 ) * 360;
+ $s = Less_Functions::number($s);
+ $v = Less_Functions::number($v);
+ $a = Less_Functions::number($a);
+
+ $i = floor(($h / 60) % 6);
+ $f = ($h / 60) - $i;
+
+ $vs = array( $v,
+ $v * (1 - $s),
+ $v * (1 - $f * $s),
+ $v * (1 - (1 - $f) * $s));
+
+ $perm = array(array(0, 3, 1),
+ array(2, 0, 1),
+ array(1, 0, 3),
+ array(1, 2, 0),
+ array(3, 1, 0),
+ array(0, 1, 2));
+
+ return $this->rgba($vs[$perm[$i][0]] * 255,
+ $vs[$perm[$i][1]] * 255,
+ $vs[$perm[$i][2]] * 255,
+ $a);
+ }
+
+ public function hue($color){
+ $c = $color->toHSL();
+ return new Less_Tree_Dimension(Less_Parser::round($c['h']));
+ }
+
+ public function saturation($color){
+ $c = $color->toHSL();
+ return new Less_Tree_Dimension(Less_Parser::round($c['s'] * 100), '%');
+ }
+
+ public function lightness($color){
+ $c = $color->toHSL();
+ return new Less_Tree_Dimension(Less_Parser::round($c['l'] * 100), '%');
+ }
+
+ public function hsvhue( $color ){
+ $hsv = $color->toHSV();
+ return new Less_Tree_Dimension( Less_Parser::round($hsv['h']) );
+ }
+
+
+ public function hsvsaturation( $color ){
+ $hsv = $color->toHSV();
+ return new Less_Tree_Dimension( Less_Parser::round($hsv['s'] * 100), '%' );
+ }
+
+ public function hsvvalue( $color ){
+ $hsv = $color->toHSV();
+ return new Less_Tree_Dimension( Less_Parser::round($hsv['v'] * 100), '%' );
+ }
+
+ public function red($color) {
+ return new Less_Tree_Dimension( $color->rgb[0] );
+ }
+
+ public function green($color) {
+ return new Less_Tree_Dimension( $color->rgb[1] );
+ }
+
+ public function blue($color) {
+ return new Less_Tree_Dimension( $color->rgb[2] );
+ }
+
+ public function alpha($color){
+ $c = $color->toHSL();
+ return new Less_Tree_Dimension($c['a']);
+ }
+
+ public function luma ($color) {
+ return new Less_Tree_Dimension(Less_Parser::round( $color->luma() * $color->alpha * 100), '%');
+ }
+
+ public function saturate($color, $amount = null){
+ // filter: saturate(3.2);
+ // should be kept as is, so check for color
+ if( !property_exists($color,'rgb') ){
+ return null;
+ }
+ $hsl = $color->toHSL();
+
+ $hsl['s'] += $amount->value / 100;
+ $hsl['s'] = self::clamp($hsl['s']);
+
+ return $this->hsla($hsl['h'], $hsl['s'], $hsl['l'], $hsl['a']);
+ }
+
+ public function desaturate($color, $amount){
+ $hsl = $color->toHSL();
+
+ $hsl['s'] -= $amount->value / 100;
+ $hsl['s'] = self::clamp($hsl['s']);
+
+ return $this->hsla($hsl['h'], $hsl['s'], $hsl['l'], $hsl['a']);
+ }
+
+
+
+ public function lighten($color, $amount){
+ $hsl = $color->toHSL();
+
+ $hsl['l'] += $amount->value / 100;
+ $hsl['l'] = self::clamp($hsl['l']);
+
+ return $this->hsla($hsl['h'], $hsl['s'], $hsl['l'], $hsl['a']);
+ }
+
+ public function darken($color, $amount){
+
+ if( $color instanceof Less_Tree_Color ){
+ $hsl = $color->toHSL();
+ $hsl['l'] -= $amount->value / 100;
+ $hsl['l'] = self::clamp($hsl['l']);
+
+ return $this->hsla($hsl['h'], $hsl['s'], $hsl['l'], $hsl['a']);
+ }
+
+ Less_Functions::Expected('color',$color);
+ }
+
+ public function fadein($color, $amount){
+ $hsl = $color->toHSL();
+ $hsl['a'] += $amount->value / 100;
+ $hsl['a'] = self::clamp($hsl['a']);
+ return $this->hsla($hsl['h'], $hsl['s'], $hsl['l'], $hsl['a']);
+ }
+
+ public function fadeout($color, $amount){
+ $hsl = $color->toHSL();
+ $hsl['a'] -= $amount->value / 100;
+ $hsl['a'] = self::clamp($hsl['a']);
+ return $this->hsla($hsl['h'], $hsl['s'], $hsl['l'], $hsl['a']);
+ }
+
+ public function fade($color, $amount){
+ $hsl = $color->toHSL();
+
+ $hsl['a'] = $amount->value / 100;
+ $hsl['a'] = self::clamp($hsl['a']);
+ return $this->hsla($hsl['h'], $hsl['s'], $hsl['l'], $hsl['a']);
+ }
+
+
+
+ public function spin($color, $amount){
+ $hsl = $color->toHSL();
+ $hue = fmod($hsl['h'] + $amount->value, 360);
+
+ $hsl['h'] = $hue < 0 ? 360 + $hue : $hue;
+
+ return $this->hsla($hsl['h'], $hsl['s'], $hsl['l'], $hsl['a']);
+ }
+
+ //
+ // Copyright (c) 2006-2009 Hampton Catlin, Nathan Weizenbaum, and Chris Eppstein
+ // http://sass-lang.com
+ //
+ public function mix($color1, $color2, $weight = null){
+ if (!$weight) {
+ $weight = new Less_Tree_Dimension('50', '%');
+ }
+
+ $p = $weight->value / 100.0;
+ $w = $p * 2 - 1;
+ $hsl1 = $color1->toHSL();
+ $hsl2 = $color2->toHSL();
+ $a = $hsl1['a'] - $hsl2['a'];
+
+ $w1 = (((($w * $a) == -1) ? $w : ($w + $a) / (1 + $w * $a)) + 1) / 2;
+ $w2 = 1 - $w1;
+
+ $rgb = array($color1->rgb[0] * $w1 + $color2->rgb[0] * $w2,
+ $color1->rgb[1] * $w1 + $color2->rgb[1] * $w2,
+ $color1->rgb[2] * $w1 + $color2->rgb[2] * $w2);
+
+ $alpha = $color1->alpha * $p + $color2->alpha * (1 - $p);
+
+ return new Less_Tree_Color($rgb, $alpha);
+ }
+
+ public function greyscale($color){
+ return $this->desaturate($color, new Less_Tree_Dimension(100));
+ }
+
+
+ public function contrast( $color, $dark = false, $light = false, $threshold = false) {
+ // filter: contrast(3.2);
+ // should be kept as is, so check for color
+ if( !property_exists($color,'rgb') ){
+ return null;
+ }
+ if( $light === false ){
+ $light = $this->rgba(255, 255, 255, 1.0);
+ }
+ if( $dark === false ){
+ $dark = $this->rgba(0, 0, 0, 1.0);
+ }
+ //Figure out which is actually light and dark!
+ if( $dark->luma() > $light->luma() ){
+ $t = $light;
+ $light = $dark;
+ $dark = $t;
+ }
+ if( $threshold === false ){
+ $threshold = 0.43;
+ } else {
+ $threshold = Less_Functions::number($threshold);
+ }
+
+ if( ($color->luma() * $color->alpha) < $threshold ){
+ return $light;
+ } else {
+ return $dark;
+ }
+ }
+
+ public function e ($str){
+ return new Less_Tree_Anonymous($str instanceof Less_Tree_JavaScript ? $str->evaluated : $str);
+ }
+
+ public function escape ($str){
+
+ $revert = array('%21'=>'!', '%2A'=>'*', '%27'=>"'",'%3F'=>'?','%26'=>'&','%2C'=>',','%2F'=>'/','%40'=>'@','%2B'=>'+','%24'=>'$');
+
+ return new Less_Tree_Anonymous(strtr(rawurlencode($str->value), $revert));
+ }
+
+
+ public function _percent(){
+ $quoted = func_get_arg(0);
+
+ $args = func_get_args();
+ array_shift($args);
+ $str = $quoted->value;
+
+ foreach($args as $arg){
+ if( preg_match('/%[sda]/i',$str, $token) ){
+ $token = $token[0];
+ $value = stristr($token, 's') ? $arg->value : $arg->toCSS();
+ $value = preg_match('/[A-Z]$/', $token) ? urlencode($value) : $value;
+ $str = preg_replace('/%[sda]/i',$value, $str, 1);
+ }
+ }
+ $str = str_replace('%%', '%', $str);
+
+ return new Less_Tree_Quoted('"' . $str . '"', $str);
+ }
+
+ public function unit($val, $unit = null ){
+ if( !($val instanceof Less_Tree_Dimension) ){
+ throw new Less_Exception_Compiler('The first argument to unit must be a number' . ($val instanceof Less_Tree_Operation ? '. Have you forgotten parenthesis?' : '.') );
+ }
+ return new Less_Tree_Dimension($val->value, $unit ? $unit->toCSS() : "");
+ }
+
+ public function convert($val, $unit){
+ return $val->convertTo($unit->value);
+ }
+
+ public function round($n, $f = false) {
+
+ $fraction = 0;
+ if( $f !== false ){
+ $fraction = $f->value;
+ }
+
+ return $this->_math('Less_Parser::round',null, $n, $fraction);
+ }
+
+ public function pi(){
+ return new Less_Tree_Dimension(M_PI);
+ }
+
+ public function mod($a, $b) {
+ return new Less_Tree_Dimension( $a->value % $b->value, $a->unit);
+ }
+
+
+
+ public function pow($x, $y) {
+ if( is_numeric($x) && is_numeric($y) ){
+ $x = new Less_Tree_Dimension($x);
+ $y = new Less_Tree_Dimension($y);
+ }elseif( !($x instanceof Less_Tree_Dimension) || !($y instanceof Less_Tree_Dimension) ){
+ throw new Less_Exception_Compiler('Arguments must be numbers');
+ }
+
+ return new Less_Tree_Dimension( pow($x->value, $y->value), $x->unit );
+ }
+
+ // var mathFunctions = [{name:"ce ...
+ public function ceil( $n ){ return $this->_math('ceil', null, $n); }
+ public function floor( $n ){ return $this->_math('floor', null, $n); }
+ public function sqrt( $n ){ return $this->_math('sqrt', null, $n); }
+ public function abs( $n ){ return $this->_math('abs', null, $n); }
+
+ public function tan( $n ){ return $this->_math('tan', '', $n); }
+ public function sin( $n ){ return $this->_math('sin', '', $n); }
+ public function cos( $n ){ return $this->_math('cos', '', $n); }
+
+ public function atan( $n ){ return $this->_math('atan', 'rad', $n); }
+ public function asin( $n ){ return $this->_math('asin', 'rad', $n); }
+ public function acos( $n ){ return $this->_math('acos', 'rad', $n); }
+
+ private function _math() {
+ $args = func_get_args();
+ $fn = array_shift($args);
+ $unit = array_shift($args);
+
+ if ($args[0] instanceof Less_Tree_Dimension) {
+
+ if( $unit === null ){
+ $unit = $args[0]->unit;
+ }else{
+ $args[0] = $args[0]->unify();
+ }
+ $args[0] = (float)$args[0]->value;
+ return new Less_Tree_Dimension( call_user_func_array($fn, $args), $unit);
+ } else if (is_numeric($args[0])) {
+ return call_user_func_array($fn,$args);
+ } else {
+ throw new Less_Exception_Compiler("math functions take numbers as parameters");
+ }
+ }
+
+ function _minmax( $isMin, $args ){
+
+ switch( count($args) ){
+ case 0: throw new Less_Exception_Compiler( 'one or more arguments required');
+ case 1: return $args[0];
+ }
+
+ $order = array(); // elems only contains original argument values.
+ $values = array(); // key is the unit.toString() for unified tree.Dimension values,
+ // value is the index into the order array.
+
+ for( $i = 0; $i < count($args); $i++ ){
+ $current = $args[$i];
+ if( !($current instanceof Less_Tree_Dimension) ){
+ $order[] = $current;
+ continue;
+ }
+ $currentUnified = $current->unify();
+ $unit = $currentUnified->unit->toString();
+
+ if( !isset($values[$unit]) ){
+ $values[$unit] = count($order);
+ $order[] = $current;
+ continue;
+ }
+
+ $j = $values[$unit];
+ $referenceUnified = $order[$j]->unify();
+ if( ($isMin && $currentUnified->value < $referenceUnified->value) || (!$isMin && $currentUnified->value > $referenceUnified->value) ){
+ $order[$j] = $current;
+ }
+ }
+ if( count($order) == 1 ){
+ return $order[0];
+ }
+
+ foreach($order as $k => $a){
+ $order[$k] = $a->toCSS( $this->env );
+ }
+
+ $args = implode( Less_Environment::$comma_space, $order);
+
+ return new Less_Tree_Anonymous( ($isMin ? 'min' : 'max') . '(' . $args . ')');
+ }
+
+ public function min(){
+ return $this->_minmax(true, func_get_args() );
+ }
+
+ public function max(){
+ return $this->_minmax(false, func_get_args() );
+ }
+
+ public function argb($color) {
+ return new Less_Tree_Anonymous($color->toARGB());
+ }
+
+ public function percentage($n) {
+ return new Less_Tree_Dimension($n->value * 100, '%');
+ }
+
+ public function color($n) {
+
+ if( $n instanceof Less_Tree_Quoted ){
+ $colorCandidate = $n->value;
+ $returnColor = Less_Tree_Color::fromKeyword($colorCandidate);
+ if( $returnColor ){
+ return $returnColor;
+ }
+ if( preg_match('/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})/',$colorCandidate) ){
+ return new Less_Tree_Color(substr($colorCandidate, 1));
+ }
+ throw new Less_Exception_Compiler("argument must be a color keyword or 3/6 digit hex e.g. #FFF");
+ } else {
+ throw new Less_Exception_Compiler("argument must be a string");
+ }
+ }
+
+
+ public function iscolor($n) {
+ return $this->_isa($n, 'Less_Tree_Color');
+ }
+
+ public function isnumber($n) {
+ return $this->_isa($n, 'Less_Tree_Dimension');
+ }
+
+ public function isstring($n) {
+ return $this->_isa($n, 'Less_Tree_Quoted');
+ }
+
+ public function iskeyword($n) {
+ return $this->_isa($n, 'Less_Tree_Keyword');
+ }
+
+ public function isurl($n) {
+ return $this->_isa($n, 'Less_Tree_Url');
+ }
+
+ public function ispixel($n) {
+ return $this->isunit($n, 'px');
+ }
+
+ public function ispercentage($n) {
+ return $this->isunit($n, '%');
+ }
+
+ public function isem($n) {
+ return $this->isunit($n, 'em');
+ }
+
+ public function isunit( $n, $unit ){
+ return ($n instanceof Less_Tree_Dimension) && $n->unit->is( ( property_exists($unit,'value') ? $unit->value : $unit) ) ? new Less_Tree_Keyword('true') : new Less_Tree_Keyword('false');
+ }
+
+ private function _isa($n, $type) {
+ return is_a($n, $type) ? new Less_Tree_Keyword('true') : new Less_Tree_Keyword('false');
+ }
+
+ /* Blending modes */
+
+ public function multiply($color1, $color2) {
+ $r = $color1->rgb[0] * $color2->rgb[0] / 255;
+ $g = $color1->rgb[1] * $color2->rgb[1] / 255;
+ $b = $color1->rgb[2] * $color2->rgb[2] / 255;
+ return $this->rgb($r, $g, $b);
+ }
+
+ public function screen($color1, $color2) {
+ $r = 255 - (255 - $color1->rgb[0]) * (255 - $color2->rgb[0]) / 255;
+ $g = 255 - (255 - $color1->rgb[1]) * (255 - $color2->rgb[1]) / 255;
+ $b = 255 - (255 - $color1->rgb[2]) * (255 - $color2->rgb[2]) / 255;
+ return $this->rgb($r, $g, $b);
+ }
+
+ public function overlay($color1, $color2) {
+ $r = $color1->rgb[0] < 128 ? 2 * $color1->rgb[0] * $color2->rgb[0] / 255 : 255 - 2 * (255 - $color1->rgb[0]) * (255 - $color2->rgb[0]) / 255;
+ $g = $color1->rgb[1] < 128 ? 2 * $color1->rgb[1] * $color2->rgb[1] / 255 : 255 - 2 * (255 - $color1->rgb[1]) * (255 - $color2->rgb[1]) / 255;
+ $b = $color1->rgb[2] < 128 ? 2 * $color1->rgb[2] * $color2->rgb[2] / 255 : 255 - 2 * (255 - $color1->rgb[2]) * (255 - $color2->rgb[2]) / 255;
+ return $this->rgb($r, $g, $b);
+ }
+
+ public function softlight($color1, $color2) {
+ $t = $color2->rgb[0] * $color1->rgb[0] / 255;
+ $r = $t + $color1->rgb[0] * (255 - (255 - $color1->rgb[0]) * (255 - $color2->rgb[0]) / 255 - $t) / 255;
+ $t = $color2->rgb[1] * $color1->rgb[1] / 255;
+ $g = $t + $color1->rgb[1] * (255 - (255 - $color1->rgb[1]) * (255 - $color2->rgb[1]) / 255 - $t) / 255;
+ $t = $color2->rgb[2] * $color1->rgb[2] / 255;
+ $b = $t + $color1->rgb[2] * (255 - (255 - $color1->rgb[2]) * (255 - $color2->rgb[2]) / 255 - $t) / 255;
+ return $this->rgb($r, $g, $b);
+ }
+
+ public function hardlight($color1, $color2) {
+ $r = $color2->rgb[0] < 128 ? 2 * $color2->rgb[0] * $color1->rgb[0] / 255 : 255 - 2 * (255 - $color2->rgb[0]) * (255 - $color1->rgb[0]) / 255;
+ $g = $color2->rgb[1] < 128 ? 2 * $color2->rgb[1] * $color1->rgb[1] / 255 : 255 - 2 * (255 - $color2->rgb[1]) * (255 - $color1->rgb[1]) / 255;
+ $b = $color2->rgb[2] < 128 ? 2 * $color2->rgb[2] * $color1->rgb[2] / 255 : 255 - 2 * (255 - $color2->rgb[2]) * (255 - $color1->rgb[2]) / 255;
+ return $this->rgb($r, $g, $b);
+ }
+
+ public function difference($color1, $color2) {
+ $r = abs($color1->rgb[0] - $color2->rgb[0]);
+ $g = abs($color1->rgb[1] - $color2->rgb[1]);
+ $b = abs($color1->rgb[2] - $color2->rgb[2]);
+ return $this->rgb($r, $g, $b);
+ }
+
+ public function exclusion($color1, $color2) {
+ $r = $color1->rgb[0] + $color2->rgb[0] * (255 - $color1->rgb[0] - $color1->rgb[0]) / 255;
+ $g = $color1->rgb[1] + $color2->rgb[1] * (255 - $color1->rgb[1] - $color1->rgb[1]) / 255;
+ $b = $color1->rgb[2] + $color2->rgb[2] * (255 - $color1->rgb[2] - $color1->rgb[2]) / 255;
+ return $this->rgb($r, $g, $b);
+ }
+
+ public function average($color1, $color2) {
+ $r = ($color1->rgb[0] + $color2->rgb[0]) / 2;
+ $g = ($color1->rgb[1] + $color2->rgb[1]) / 2;
+ $b = ($color1->rgb[2] + $color2->rgb[2]) / 2;
+ return $this->rgb($r, $g, $b);
+ }
+
+ public function negation($color1, $color2) {
+ $r = 255 - abs(255 - $color2->rgb[0] - $color1->rgb[0]);
+ $g = 255 - abs(255 - $color2->rgb[1] - $color1->rgb[1]);
+ $b = 255 - abs(255 - $color2->rgb[2] - $color1->rgb[2]);
+ return $this->rgb($r, $g, $b);
+ }
+
+ public function tint($color, $amount) {
+ return $this->mix( $this->rgb(255,255,255), $color, $amount);
+ }
+
+ public function shade($color, $amount) {
+ return $this->mix($this->rgb(0, 0, 0), $color, $amount);
+ }
+
+ public function extract($values, $index ){
+ $index = (int)$index->value - 1; // (1-based index)
+ // handle non-array values as an array of length 1
+ // return 'undefined' if index is invalid
+ if( property_exists($values,'value') && is_array($values->value) ){
+ if( isset($values->value[$index]) ){
+ return $values->value[$index];
+ }
+ return null;
+
+ }elseif( (int)$index === 0 ){
+ return $values;
+ }
+
+ return null;
+ }
+
+ function length($values){
+ $n = (property_exists($values,'value') && is_array($values->value)) ? count($values->value) : 1;
+ return new Less_Tree_Dimension($n);
+ }
+
+ function datauri($mimetypeNode, $filePathNode = null ) {
+
+ $filePath = ( $filePathNode ? $filePathNode->value : null );
+ $mimetype = $mimetypeNode->value;
+ $useBase64 = false;
+
+ $args = 2;
+ if( !$filePath ){
+ $filePath = $mimetype;
+ $args = 1;
+ }
+
+ $filePath = str_replace('\\','/',$filePath);
+ if( Less_Environment::isPathRelative($filePath) ){
+
+ if( $this->env->relativeUrls ){
+ $temp = $this->env->currentFileInfo['currentDirectory'];
+ } else {
+ $temp = $this->env->currentFileInfo['entryPath'];
+ }
+
+ if( !empty($temp) ){
+ $filePath = Less_Environment::normalizePath(rtrim($temp,'/').'/'.$filePath);
+ }
+
+ }
+
+
+ // detect the mimetype if not given
+ if( $args < 2 ){
+
+ /* incomplete
+ $mime = require('mime');
+ mimetype = mime.lookup(path);
+
+ // use base 64 unless it's an ASCII or UTF-8 format
+ var charset = mime.charsets.lookup(mimetype);
+ useBase64 = ['US-ASCII', 'UTF-8'].indexOf(charset) < 0;
+ if (useBase64) mimetype += ';base64';
+ */
+
+ $mimetype = Less_Mime::lookup($filePath);
+
+ $charset = Less_Mime::charsets_lookup($mimetype);
+ $useBase64 = !in_array($charset,array('US-ASCII', 'UTF-8'));
+ if( $useBase64 ){ $mimetype .= ';base64'; }
+
+ }else{
+ $useBase64 = preg_match('/;base64$/',$mimetype);
+ }
+
+
+ if( file_exists($filePath) ){
+ $buf = @file_get_contents($filePath);
+ }else{
+ $buf = false;
+ }
+
+
+ // IE8 cannot handle a data-uri larger than 32KB. If this is exceeded
+ // and the --ieCompat flag is enabled, return a normal url() instead.
+ $DATA_URI_MAX_KB = 32;
+ $fileSizeInKB = round( strlen($buf) / 1024 );
+ if( $fileSizeInKB >= $DATA_URI_MAX_KB ){
+ $url = new Less_Tree_Url( ($filePathNode ? $filePathNode : $mimetypeNode), $this->currentFileInfo);
+ return $url->compile($this);
+ }
+
+ if( $buf ){
+ $buf = $useBase64 ? base64_encode($buf) : rawurlencode($buf);
+ $filePath = "'data:" . $mimetype . ',' . $buf . "'";
+ }
+
+ return new Less_Tree_Url( new Less_Tree_Anonymous($filePath) );
+ }
+
+ //svg-gradient
+ function svggradient( $direction ){
+
+ $throw_message = 'svg-gradient expects direction, start_color [start_position], [color position,]..., end_color [end_position]';
+ $arguments = func_get_args();
+
+ if( count($arguments) < 3 ){
+ throw new Less_Exception_Compiler( $throw_message );
+ }
+
+ $stops = array_slice($arguments,1);
+ $gradientType = 'linear';
+ $rectangleDimension = 'x="0" y="0" width="1" height="1"';
+ $useBase64 = true;
+ $renderEnv = new Less_Environment();
+ $directionValue = $direction->toCSS($renderEnv);
+
+
+ switch( $directionValue ){
+ case "to bottom":
+ $gradientDirectionSvg = 'x1="0%" y1="0%" x2="0%" y2="100%"';
+ break;
+ case "to right":
+ $gradientDirectionSvg = 'x1="0%" y1="0%" x2="100%" y2="0%"';
+ break;
+ case "to bottom right":
+ $gradientDirectionSvg = 'x1="0%" y1="0%" x2="100%" y2="100%"';
+ break;
+ case "to top right":
+ $gradientDirectionSvg = 'x1="0%" y1="100%" x2="100%" y2="0%"';
+ break;
+ case "ellipse":
+ case "ellipse at center":
+ $gradientType = "radial";
+ $gradientDirectionSvg = 'cx="50%" cy="50%" r="75%"';
+ $rectangleDimension = 'x="-50" y="-50" width="101" height="101"';
+ break;
+ default:
+ throw new Less_Exception_Compiler( "svg-gradient direction must be 'to bottom', 'to right', 'to bottom right', 'to top right' or 'ellipse at center'" );
+ }
+
+ $returner = '' .
+ '';
+
+
+ if( $useBase64 ){
+ // only works in node, needs interface to what is supported in environment
+ try{
+ $returner = base64_encode($returner);
+ }catch(Exception $e){
+ $useBase64 = false;
+ }
+ }
+
+ $returner = "'data:image/svg+xml" . ($useBase64 ? ";base64" : "") . "," . $returner . "'";
+ return new Less_Tree_URL( new Less_Tree_Anonymous( $returner ) );
+ }
+
+
+ private static function Expected( $type, $arg ){
+
+ $debug = debug_backtrace();
+ array_shift($debug);
+ $last = array_shift($debug);
+ $last = array_intersect_key($last,array('function'=>'','class'=>'','line'=>''));
+
+ $message = 'Object of type '.get_class($arg).' passed to darken function. Expecting `Color`. '.$arg->toCSS().'. '.print_r($last,true);
+ throw new Less_Exception_Compiler($message);
+
+ }
+
+}
diff --git a/lib/Less/LICENSE b/lib/Less/LICENSE
new file mode 100644
index 0000000000000..82216a5da4551
--- /dev/null
+++ b/lib/Less/LICENSE
@@ -0,0 +1,178 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the 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.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+END OF TERMS AND CONDITIONS
+
diff --git a/lib/Less/Less.php.combine b/lib/Less/Less.php.combine
new file mode 100644
index 0000000000000..af1c4cfac489a
--- /dev/null
+++ b/lib/Less/Less.php.combine
@@ -0,0 +1,12 @@
+
+./Parser.php
+./Colors.php
+./Environment.php
+./Functions.php
+./Mime.php
+./Tree.php
+./Visitor.php
+./VisitorReplacing.php
+./Tree
+./Visitor
+./Exception
diff --git a/lib/Less/Less_Cache.php b/lib/Less/Less_Cache.php
new file mode 100644
index 0000000000000..94c90e0fa6cf5
--- /dev/null
+++ b/lib/Less/Less_Cache.php
@@ -0,0 +1,3 @@
+ 'text/html',
+ '.html'=> 'text/html',
+ '.gif' => 'image/gif',
+ '.jpg' => 'image/jpeg',
+ '.jpeg'=> 'image/jpeg',
+ '.png' => 'image/png'
+ );
+
+ static function lookup( $filepath ){
+ $parts = explode('.',$filepath);
+ $ext = '.'.strtolower(array_pop($parts));
+
+ if( !isset(self::$_types[$ext]) ){
+ return null;
+ }
+ return self::$_types[$ext];
+ }
+
+ static function charsets_lookup( $type = false ){
+ // assumes all text types are UTF-8
+ return $type && preg_match('/^text\//',$type) ? 'UTF-8' : '';
+ }
+}
\ No newline at end of file
diff --git a/lib/Less/Parser.php b/lib/Less/Parser.php
new file mode 100644
index 0000000000000..fdd4ed30090da
--- /dev/null
+++ b/lib/Less/Parser.php
@@ -0,0 +1,2014 @@
+env = $env;
+ }else{
+ $this->env = new Less_Environment( $env );
+ self::$imports = array();
+ self::$import_dirs = array();
+ if( is_array($env) ){
+ $this->SetOptions($env);
+ }
+ }
+
+ $this->pos = 0;
+ }
+
+ // options: import_dirs, compress, cache_dir, cache_method, strictUnits
+ public function SetOptions( $options ){
+ foreach($options as $option => $value){
+ $this->SetOption($option,$value);
+ }
+ }
+
+ public function SetOption($option,$value){
+
+ switch($option){
+
+ case 'import_dirs':
+ $this->SetImportDirs($value);
+ break;
+
+ case 'cache_dir':
+ $this->SetCacheDir($value);
+ break;
+
+ case 'cache_method':
+ if( in_array($value, array('php','serialize','var_export')) ){
+ $this->cache_method = $value;
+ }
+ break;
+ }
+ }
+
+
+
+
+ /**
+ * Get the current css buffer
+ *
+ * @return string
+ */
+ public function getCss(){
+
+ $precision = ini_get('precision');
+ @ini_set('precision',16);
+ $locale = setlocale(LC_NUMERIC, 0);
+ setlocale(LC_NUMERIC, "C");
+
+
+ $root = new Less_Tree_Ruleset(array(), $this->rules );
+ $root->root = true;
+ $root->firstRoot = true;
+
+
+ //$importVisitor = new Less_importVisitor();
+ //$importVisitor->run($root);
+
+ //obj($root);
+
+ self::$has_extends = false;
+
+ $evaldRoot = $root->compile($this->env);
+
+
+ $joinSelector = new Less_Visitor_joinSelector();
+ $joinSelector->run($evaldRoot);
+
+
+ if( self::$has_extends ){
+ $extendsVisitor = new Less_Visitor_processExtends();
+ $extendsVisitor->run($evaldRoot);
+ }
+
+ $toCSSVisitor = new Less_Visitor_toCSS( $this->env );
+ $toCSSVisitor->run($evaldRoot);
+
+ $css = $evaldRoot->toCSS($this->env);
+
+ if( Less_Environment::$compress ){
+ $css = preg_replace('/(^(\s)+)|((\s)+$)/', '', $css);
+ }
+
+ //reset php settings
+ @ini_set('precision',$precision);
+ setlocale(LC_NUMERIC, $locale);
+
+ return $css;
+ }
+
+
+ /**
+ * Parse a Less string into css
+ *
+ * @param string $str The string to convert
+ * @param bool $returnRoot Indicates whether the return value should be a css string a root node
+ * @return Less_Tree_Ruleset|Less_Parser
+ */
+ public function parse($str){
+ $this->input = $str;
+ $this->_parse();
+ }
+
+
+ /**
+ * Parse a Less string from a given file
+ *
+ * @throws Less_Exception_Parser
+ * @param $filename The file to parse
+ * @param $uri_root The url of the file
+ * @param bool $returnRoot Indicates whether the return value should be a css string a root node
+ * @return Less_Tree_Ruleset|Less_Parser
+ */
+ public function parseFile( $filename, $uri_root = '', $returnRoot = false){
+
+ if( !file_exists($filename) ){
+ throw new Less_Exception_Parser(sprintf('File `%s` not found.', $filename));
+ }
+
+ $previousFileInfo = $this->env->currentFileInfo;
+ $this->SetFileInfo($filename, $uri_root);
+
+ $previousImportDirs = self::$import_dirs;
+ self::AddParsedFile($filename);
+
+ $return = null;
+ if( $returnRoot ){
+ $rules = $this->GetRules( $filename );
+ $return = new Less_Tree_Ruleset(array(), $rules );
+ }else{
+ $this->_parse( $filename );
+ }
+
+ if( $previousFileInfo ){
+ $this->env->currentFileInfo = $previousFileInfo;
+ }
+ self::$import_dirs = $previousImportDirs;
+
+ return $return;
+ }
+
+
+ public function SetFileInfo( $filename, $uri_root = ''){
+
+ $this->path = pathinfo($filename, PATHINFO_DIRNAME);
+ $this->filename = Less_Environment::normalizePath($filename);
+
+ $dirname = preg_replace('/[^\/\\\\]*$/','',$this->filename);
+
+ $currentFileInfo = array();
+ $currentFileInfo['currentDirectory'] = $dirname;
+ $currentFileInfo['filename'] = $filename;
+ $currentFileInfo['rootpath'] = $dirname;
+ $currentFileInfo['entryPath'] = $dirname;
+
+ if( empty($uri_root) ){
+ $currentFileInfo['uri_root'] = $uri_root;
+ }else{
+ $currentFileInfo['uri_root'] = rtrim($uri_root,'/').'/';
+ }
+
+
+ //inherit reference
+ if( isset($this->env->currentFileInfo['reference']) && $this->env->currentFileInfo['reference'] ){
+ $currentFileInfo['reference'] = true;
+ }
+
+ $this->env->currentFileInfo = $currentFileInfo;
+
+ self::$import_dirs = array_merge( array( $dirname => $currentFileInfo['uri_root'] ), self::$import_dirs );
+ }
+
+ public function SetCacheDir( $dir ){
+
+ if( !file_exists($dir) ){
+ if( mkdir($dir) ){
+ return true;
+ }
+ throw new Less_Exception_Parser('Less.php cache directory couldn\'t be created: '.$dir);
+
+ }elseif( !is_dir($dir) ){
+ throw new Less_Exception_Parser('Less.php cache directory doesn\'t exist: '.$dir);
+
+ }elseif( !is_writable($dir) ){
+ throw new Less_Exception_Parser('Less.php cache directory isn\'t writable: '.$dir);
+
+ }else{
+ $dir = str_replace('\\','/',$dir);
+ self::$cache_dir = rtrim($dir,'/').'/';
+ return true;
+ }
+ }
+
+ public function SetImportDirs( $dirs ){
+
+ foreach($dirs as $path => $uri_root){
+
+ $path = str_replace('\\','/',$path);
+ if( !empty($path) ){
+ $path = rtrim($path,'/').'/';
+ }
+
+ if ( !is_callable($uri_root) ){
+ $uri_root = str_replace('\\','/',$uri_root);
+ if( !empty($uri_root) ){
+ $uri_root = rtrim($uri_root,'/').'/';
+ }
+ }
+
+ self::$import_dirs[$path] = $uri_root;
+ }
+ }
+
+ private function _parse( $file_path = false ){
+ $this->rules = array_merge($this->rules, $this->GetRules( $file_path ));
+ }
+
+
+ /**
+ * Return the results of parsePrimary for $file_path
+ * Use cache and save cached results if possible
+ *
+ */
+ private function GetRules( $file_path ){
+
+ $cache_file = false;
+ if( $file_path ){
+ if( $this->cache_method ){
+ $cache_file = $this->CacheFile( $file_path );
+
+ if( $cache_file && file_exists($cache_file) ){
+ switch($this->cache_method){
+
+ // Using serialize
+ // Faster but uses more memory
+ case 'serialize':
+ $cache = unserialize(file_get_contents($cache_file));
+ if( $cache ){
+ touch($cache_file);
+ return $cache;
+ }
+ break;
+
+
+ // Using generated php code
+ case 'var_export':
+ case 'php':
+ return include($cache_file);
+ }
+ }
+ }
+
+ $this->input = file_get_contents( $file_path );
+ }
+
+ $this->pos = 0;
+
+ // Remove potential UTF Byte Order Mark
+ $this->input = preg_replace('/\\G\xEF\xBB\xBF/', '', $this->input);
+ $this->input_len = strlen($this->input);
+
+ $rules = $this->parsePrimary();
+
+
+ // free up a little memory
+ unset($this->input, $this->pos);
+
+
+ //save the cache
+ if( $cache_file && $this->cache_method ){
+
+ switch($this->cache_method){
+ case 'serialize':
+ file_put_contents( $cache_file, serialize($rules) );
+ break;
+ case 'php':
+ file_put_contents( $cache_file, '' );
+ break;
+ case 'var_export':
+ /**
+ * Requires __set_state()
+ */
+ file_put_contents( $cache_file, '' );
+ break;
+ }
+
+ if( self::$clean_cache ){
+ self::CleanCache();
+ }
+
+ }
+
+ return $rules;
+ }
+
+
+ public function CacheFile( $file_path ){
+
+ if( $file_path && self::$cache_dir ){
+
+ $env = get_object_vars($this->env);
+ unset($env['frames']);
+
+ $parts = array();
+ $parts[] = $file_path;
+ $parts[] = filesize( $file_path );
+ $parts[] = filemtime( $file_path );
+ $parts[] = $env;
+ $parts[] = self::cache_version;
+ $parts[] = $this->cache_method;
+ return self::$cache_dir.'lessphp_'.base_convert( sha1(json_encode($parts) ), 16, 36).'.lesscache';
+ }
+ }
+
+
+ static function AddParsedFile($file){
+ self::$imports[] = $file;
+ }
+
+ static function AllParsedFiles(){
+ return self::$imports;
+ }
+
+ static function FileParsed($file){
+ return in_array($file,self::$imports);
+ }
+
+
+ function save() {
+ $this->memo = $this->pos;
+ }
+
+ private function restore() {
+ $this->pos = $this->memo;
+ }
+
+
+ private function isWhitespace($offset = 0) {
+ return preg_match('/\s/',$this->input[ $this->pos + $offset]);
+ }
+
+ /**
+ * Parse from a token, regexp or string, and move forward if match
+ *
+ * @param string $tok
+ * @return null|bool|object
+ */
+ private function match($toks){
+
+ // The match is confirmed, add the match length to `this::pos`,
+ // and consume any extra white-space characters (' ' || '\n')
+ // which come after that. The reason for this is that LeSS's
+ // grammar is mostly white-space insensitive.
+ //
+
+ foreach($toks as $tok){
+
+ $char = $tok[0];
+
+ if( $char === '/' ){
+ $match = $this->MatchReg($tok);
+
+ if( $match ){
+ return count($match) === 1 ? $match[0] : $match;
+ }
+
+ }elseif( $char === '#' ){
+ $match = $this->MatchChar($tok[1]);
+
+ }else{
+ // Non-terminal, match using a function call
+ $match = $this->$tok();
+
+ }
+
+ if( $match ){
+ return $match;
+ }
+ }
+ }
+
+ private function MatchFuncs($toks){
+
+ foreach($toks as $tok){
+ $match = $this->$tok();
+ if( $match ){
+ return $match;
+ }
+ }
+
+ }
+
+ // Match a single character in the input,
+ private function MatchChar($tok){
+ if( ($this->pos < $this->input_len) && ($this->input[$this->pos] === $tok) ){
+ $this->skipWhitespace(1);
+ return $tok;
+ }
+ }
+
+ // Match a regexp from the current start point
+ private function MatchReg($tok){
+
+ if( preg_match($tok, $this->input, $match, 0, $this->pos) ){
+ $this->skipWhitespace(strlen($match[0]));
+ return $match;
+ }
+ }
+
+
+ /**
+ * Same as match(), but don't change the state of the parser,
+ * just return the match.
+ *
+ * @param $tok
+ * @param int $offset
+ * @return bool
+ */
+ public function PeekReg($tok){
+ return preg_match($tok, $this->input, $match, 0, $this->pos);
+ }
+
+ public function PeekChar($tok){
+ return ($this->input[$this->pos] === $tok );
+ //return ($this->pos < $this->input_len) && ($this->input[$this->pos] === $tok );
+ }
+
+
+ public function skipWhitespace($length){
+
+ $this->pos += $length;
+
+ for(; $this->pos < $this->input_len; $this->pos++ ){
+ $c = $this->input[$this->pos];
+
+ if( ($c !== "\n") && ($c !== "\r") && ($c !== "\t") && ($c !== ' ') ){
+ break;
+ }
+ }
+ }
+
+
+ public function expect($tok, $msg = NULL) {
+ $result = $this->match( array($tok) );
+ if (!$result) {
+ throw new Less_Exception_Parser( $msg ? "Expected '" . $tok . "' got '" . $this->input[$this->pos] . "'" : $msg );
+ } else {
+ return $result;
+ }
+ }
+
+ public function expectChar($tok, $msg = null ){
+ $result = $this->MatchChar($tok);
+ if( !$result ){
+ throw new Less_Exception_Parser( $msg ? "Expected '" . $tok . "' got '" . $this->input[$this->pos] . "'" : $msg );
+ }else{
+ return $result;
+ }
+ }
+
+ //
+ // Here in, the parsing rules/functions
+ //
+ // The basic structure of the syntax tree generated is as follows:
+ //
+ // Ruleset -> Rule -> Value -> Expression -> Entity
+ //
+ // Here's some LESS code:
+ //
+ // .class {
+ // color: #fff;
+ // border: 1px solid #000;
+ // width: @w + 4px;
+ // > .child {...}
+ // }
+ //
+ // And here's what the parse tree might look like:
+ //
+ // Ruleset (Selector '.class', [
+ // Rule ("color", Value ([Expression [Color #fff]]))
+ // Rule ("border", Value ([Expression [Dimension 1px][Keyword "solid"][Color #000]]))
+ // Rule ("width", Value ([Expression [Operation "+" [Variable "@w"][Dimension 4px]]]))
+ // Ruleset (Selector [Element '>', '.child'], [...])
+ // ])
+ //
+ // In general, most rules will try to parse a token with the `$()` function, and if the return
+ // value is truly, will return a new node, of the relevant type. Sometimes, we need to check
+ // first, before parsing, that's when we use `peek()`.
+ //
+
+ //
+ // The `primary` rule is the *entry* and *exit* point of the parser.
+ // The rules here can appear at any level of the parse tree.
+ //
+ // The recursive nature of the grammar is an interplay between the `block`
+ // rule, which represents `{ ... }`, the `ruleset` rule, and this `primary` rule,
+ // as represented by this simplified grammar:
+ //
+ // primary → (ruleset | rule)+
+ // ruleset → selector+ block
+ // block → '{' primary '}'
+ //
+ // Only at one point is the primary rule not called from the
+ // block rule: at the root level.
+ //
+ private function parsePrimary(){
+ $root = array();
+
+ while( true ){
+
+ if( $this->pos >= $this->input_len ){
+ break;
+ }
+
+ $node = $this->parseExtend(true);
+ if( $node ){
+ $root = array_merge($root,$node);
+ continue;
+ }
+
+ $node = $this->MatchFuncs( array( 'parseMixinDefinition', 'parseRule', 'parseRuleset', 'parseMixinCall', 'parseComment', 'parseDirective'));
+
+ if( $node ){
+ $root[] = $node;
+ }elseif( !$this->MatchReg('/\\G[\s\n;]+/') ){
+ break;
+ }
+
+ }
+
+ return $root;
+ }
+
+
+
+ // We create a Comment node for CSS comments `/* */`,
+ // but keep the LeSS comments `//` silent, by just skipping
+ // over them.
+ private function parseComment(){
+
+ if( $this->input[$this->pos] !== '/' ){
+ return;
+ }
+
+ if( $this->input[$this->pos+1] === '/' ){
+ $match = $this->MatchReg('/\\G\/\/.*/');
+ return $this->Less_Tree_Comment($match[0], true, $this->pos, $this->env->currentFileInfo);
+ }
+
+ //$comment = $this->MatchReg('/\\G\/\*(?:[^*]|\*+[^\/*])*\*+\/\n?/');
+ $comment = $this->MatchReg('/\\G\/\*(?s).*?\*+\/\n?/');//not the same as less.js to prevent fatal errors
+ if( $comment ){
+ return $this->Less_Tree_Comment($comment[0], false, $this->pos, $this->env->currentFileInfo);
+ }
+ }
+
+ private function parseComments(){
+ $comments = array();
+
+ while( true ){
+ $comment = $this->parseComment();
+ if( !$comment ){
+ break;
+ }
+
+ $comments[] = $comment;
+ }
+
+ return $comments;
+ }
+
+
+
+ //
+ // A string, which supports escaping " and '
+ //
+ // "milky way" 'he\'s the one!'
+ //
+ private function parseEntitiesQuoted() {
+ $j = 0;
+ $e = false;
+ $index = $this->pos;
+
+ if ($this->PeekChar('~')) {
+ $j++;
+ $e = true; // Escaped strings
+ }
+
+ $char = $this->input[$this->pos+$j];
+ if( $char != '"' && $char !== "'" ){
+ return;
+ }
+
+ if ($e) {
+ $this->MatchChar('~');
+ }
+ $str = $this->MatchReg('/\\G"((?:[^"\\\\\r\n]|\\\\.)*)"|\'((?:[^\'\\\\\r\n]|\\\\.)*)\'/');
+ if( $str ){
+ $result = $str[0][0] == '"' ? $str[1] : $str[2];
+ return $this->Less_Tree_Quoted($str[0], $result, $e, $index, $this->env->currentFileInfo );
+ }
+ return;
+ }
+
+ //
+ // A catch-all word, such as:
+ //
+ // black border-collapse
+ //
+ private function parseEntitiesKeyword(){
+
+ $k = $this->MatchReg('/\\G[_A-Za-z-][_A-Za-z0-9-]*/');
+ if( $k ){
+ $k = $k[0];
+ $color = $this->fromKeyword($k);
+ if( $color ){
+ return $color;
+ }
+ return $this->Less_Tree_Keyword($k);
+ }
+ }
+
+ // duplicate of Less_Tree_Color::FromKeyword
+ private function FromKeyword( $keyword ){
+ if( Less_Colors::hasOwnProperty($keyword) ){
+ // detect named color
+ return $this->Less_Tree_Color(substr(Less_Colors::color($keyword), 1));
+ }
+
+ if( $keyword === 'transparent' ){
+ $transparent = $this->Less_Tree_Color( array(0, 0, 0), 0);
+ $transparent->isTransparentKeyword = true;
+ return $transparent;
+ }
+ }
+
+ //
+ // A function call
+ //
+ // rgb(255, 0, 255)
+ //
+ // We also try to catch IE's `alpha()`, but let the `alpha` parser
+ // deal with the details.
+ //
+ // The arguments are parsed with the `entities.arguments` parser.
+ //
+ private function parseEntitiesCall(){
+ $index = $this->pos;
+
+ if( !preg_match('/\\G([\w-]+|%|progid:[\w\.]+)\(/', $this->input, $name,0,$this->pos) ){
+ return;
+ }
+ $name = $name[1];
+ $nameLC = strtolower($name);
+
+ if ($nameLC === 'url') {
+ return null;
+ }
+
+ $this->pos += strlen($name);
+
+ if( $nameLC === 'alpha' ){
+ $alpha_ret = $this->parseAlpha();
+ if( $alpha_ret ){
+ return $alpha_ret;
+ }
+ }
+
+ $this->MatchChar('('); // Parse the '(' and consume whitespace.
+
+ $args = $this->parseEntitiesArguments();
+
+ if( !$this->MatchChar(')') ){
+ return;
+ }
+
+ if ($name) {
+ return $this->Less_Tree_Call($name, $args, $index, $this->env->currentFileInfo );
+ }
+ }
+
+ /**
+ * Parse a list of arguments
+ *
+ * @return array
+ */
+ private function parseEntitiesArguments(){
+
+ $args = array();
+ while( true ){
+ $arg = $this->MatchFuncs( array('parseEntitiesAssignment','parseExpression') );
+ if( !$arg ){
+ break;
+ }
+
+ $args[] = $arg;
+ if( !$this->MatchChar(',') ){
+ break;
+ }
+ }
+ return $args;
+ }
+
+ private function parseEntitiesLiteral(){
+ return $this->MatchFuncs( array('parseEntitiesDimension','parseEntitiesColor','parseEntitiesQuoted','parseUnicodeDescriptor') );
+ }
+
+ // Assignments are argument entities for calls.
+ // They are present in ie filter properties as shown below.
+ //
+ // filter: progid:DXImageTransform.Microsoft.Alpha( *opacity=50* )
+ //
+ private function parseEntitiesAssignment() {
+
+ $key = $this->MatchReg('/\\G\w+(?=\s?=)/');
+ if( !$key ){
+ return;
+ }
+
+ if( !$this->MatchChar('=') ){
+ return;
+ }
+
+ $value = $this->parseEntity();
+ if( $value ){
+ return $this->Less_Tree_Assignment($key[0], $value);
+ }
+ }
+
+ //
+ // Parse url() tokens
+ //
+ // We use a specific rule for urls, because they don't really behave like
+ // standard function calls. The difference is that the argument doesn't have
+ // to be enclosed within a string, so it can't be parsed as an Expression.
+ //
+ private function parseEntitiesUrl(){
+
+
+ if( $this->input[$this->pos] !== 'u' || !$this->matchReg('/\\Gurl\(/') ){
+ return;
+ }
+
+ $value = $this->match( array('parseEntitiesQuoted','parseEntitiesVariable','/\\G(?:(?:\\\\[\(\)\'"])|[^\(\)\'"])+/') );
+ if( !$value ){
+ $value = '';
+ }
+
+
+ $this->expectChar(')');
+
+
+ return $this->Less_Tree_Url((isset($value->value) || $value instanceof Less_Tree_Variable)
+ ? $value : $this->Less_Tree_Anonymous($value), $this->env->currentFileInfo );
+ }
+
+
+ //
+ // A Variable entity, such as `@fink`, in
+ //
+ // width: @fink + 2px
+ //
+ // We use a different parser for variable definitions,
+ // see `parsers.variable`.
+ //
+ private function parseEntitiesVariable(){
+ $index = $this->pos;
+ if ($this->PeekChar('@') && ($name = $this->MatchReg('/\\G@@?[\w-]+/'))) {
+ return $this->Less_Tree_Variable( $name[0], $index, $this->env->currentFileInfo);
+ }
+ }
+
+
+ // A variable entity useing the protective {} e.g. @{var}
+ private function parseEntitiesVariableCurly() {
+ $index = $this->pos;
+
+ if( $this->input_len > ($this->pos+1) && $this->input[$this->pos] === '@' && ($curly = $this->MatchReg('/\\G@\{([\w-]+)\}/')) ){
+ return $this->Less_Tree_Variable('@'.$curly[1], $index, $this->env->currentFileInfo);
+ }
+ }
+
+ //
+ // A Hexadecimal color
+ //
+ // #4F3C2F
+ //
+ // `rgb` and `hsl` colors are parsed through the `entities.call` parser.
+ //
+ private function parseEntitiesColor(){
+ if ($this->PeekChar('#') && ($rgb = $this->MatchReg('/\\G#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})/'))) {
+ return $this->Less_Tree_Color($rgb[1]);
+ }
+ }
+
+ //
+ // A Dimension, that is, a number and a unit
+ //
+ // 0.5em 95%
+ //
+ private function parseEntitiesDimension(){
+
+ $c = @ord($this->input[$this->pos]);
+
+ //Is the first char of the dimension 0-9, '.', '+' or '-'
+ if (($c > 57 || $c < 43) || $c === 47 || $c == 44){
+ return;
+ }
+
+ $value = $this->MatchReg('/\\G([+-]?\d*\.?\d+)(%|[a-z]+)?/');
+ if( $value ){
+ return $this->Less_Tree_Dimension( $value[1], isset($value[2]) ? $value[2] : null);
+ }
+ }
+
+
+ //
+ // A unicode descriptor, as is used in unicode-range
+ //
+ // U+0?? or U+00A1-00A9
+ //
+ function parseUnicodeDescriptor() {
+ $ud = $this->MatchReg('/\\G(U\+[0-9a-fA-F?]+)(\-[0-9a-fA-F?]+)?/');
+ if( $ud ){
+ return $this->Less_Tree_UnicodeDescriptor( $ud[0]);
+ }
+ }
+
+
+ //
+ // JavaScript code to be evaluated
+ //
+ // `window.location.href`
+ //
+ private function parseEntitiesJavascript(){
+ $e = false;
+ $j = $this->pos;
+ if( $this->input[$j] === '~' ){
+ $j++;
+ $e = true;
+ }
+ if( $this->input[$j] !== '`' ){
+ return;
+ }
+ if( $e ){
+ $this->MatchChar('~');
+ }
+ $str = $this->MatchReg('/\\G`([^`]*)`/');
+ if( $str ){
+ return $this->Less_Tree_Javascript( $str[1], $this->pos, $e);
+ }
+ }
+
+
+ //
+ // The variable part of a variable definition. Used in the `rule` parser
+ //
+ // @fink:
+ //
+ private function parseVariable(){
+ if ($this->PeekChar('@') && ($name = $this->MatchReg('/\\G(@[\w-]+)\s*:/'))) {
+ return $name[1];
+ }
+ }
+
+ //
+ // extend syntax - used to extend selectors
+ //
+ function parseExtend($isRule = false){
+
+ $index = $this->pos;
+ $extendList = array();
+
+
+ if( !$this->MatchReg( $isRule ? '/\\G&:extend\(/' : '/\\G:extend\(/' ) ){ return; }
+
+ do{
+ $option = null;
+ $elements = array();
+ while( true ){
+ $option = $this->MatchReg('/\\G(all)(?=\s*(\)|,))/');
+ if( $option ){ break; }
+ $e = $this->parseElement();
+ if( !$e ){ break; }
+ $elements[] = $e;
+ }
+
+ if( $option ){
+ $option = $option[1];
+ }
+
+ $extendList[] = $this->Less_Tree_Extend( $this->Less_Tree_Selector($elements), $option, $index );
+
+ }while( $this->MatchChar(",") );
+
+ $this->expect('/\\G\)/');
+
+ if( $isRule ){
+ $this->expect('/\\G;/');
+ }
+
+ return $extendList;
+ }
+
+
+ //
+ // A Mixin call, with an optional argument list
+ //
+ // #mixins > .square(#fff);
+ // .rounded(4px, black);
+ // .button;
+ //
+ // The `while` loop is there because mixins can be
+ // namespaced, but we only support the child and descendant
+ // selector for now.
+ //
+ private function parseMixinCall(){
+ $elements = array();
+ $index = $this->pos;
+ $important = false;
+ $args = null;
+ $c = null;
+
+ $char = $this->input[$this->pos];
+ if( $char !== '.' && $char !== '#' ){
+ return;
+ }
+
+ $this->save(); // stop us absorbing part of an invalid selector
+
+ while( true ){
+ $e = $this->MatchReg('/\\G[#.](?:[\w-]|\\\\(?:[A-Fa-f0-9]{1,6} ?|[^A-Fa-f0-9]))+/');
+ if( !$e ){
+ break;
+ }
+ $elements[] = $this->Less_Tree_Element($c, $e[0], $this->pos, $this->env->currentFileInfo);
+ $c = $this->MatchChar('>');
+ }
+
+ if( $this->MatchChar('(') ){
+ $returned = $this->parseMixinArgs(true);
+ $args = $returned['args'];
+ $this->expectChar(')');
+ }
+
+ if( !$args ){
+ $args = array();
+ }
+
+ if( $this->parseImportant() ){
+ $important = true;
+ }
+
+ if( $elements && ($this->MatchChar(';') || $this->PeekChar('}')) ){
+ return Less_Parser::Less_Tree_Mixin_Call( $elements, $args, $index, $this->env->currentFileInfo, $important);
+ }
+
+ $this->restore();
+ }
+
+
+ private function parseMixinArgs( $isCall ){
+ $expressions = array();
+ $argsSemiColon = array();
+ $isSemiColonSeperated = null;
+ $argsComma = array();
+ $expressionContainsNamed = null;
+ $name = null;
+ $nameLoop = null;
+ $returner = array('args'=>null, 'variadic'=> false);
+
+ while( true ){
+ if( $isCall ){
+ $arg = $this->parseExpression();
+ } else {
+ $this->parseComments();
+ if( $this->input[ $this->pos ] === '.' && $this->MatchReg('/\\G\.{3}/') ){
+ $returner['variadic'] = true;
+ if( $this->MatchChar(";") && !$isSemiColonSeperated ){
+ $isSemiColonSeperated = true;
+ }
+
+ if( $isSemiColonSeperated ){
+ $argsSemiColon[] = array('variadic'=>true);
+ }else{
+ $argsComma[] = array('variadic'=>true);
+ }
+ break;
+ }
+ $arg = $this->MatchFuncs( array('parseEntitiesVariable','parseEntitiesLiteral','parseEntitiesKeyword') );
+ }
+
+
+ if( !$arg ){
+ break;
+ }
+
+
+ $nameLoop = null;
+ if( $arg instanceof Less_Tree_Expression ){
+ $arg->throwAwayComments();
+ }
+ $value = $arg;
+ $val = null;
+
+ if( $isCall ){
+ // Variable
+ if( count($arg->value) == 1 ){
+ $val = $arg->value[0];
+ }
+ } else {
+ $val = $arg;
+ }
+
+
+ if( $val && $val instanceof Less_Tree_Variable ){
+
+ if( $this->MatchChar(':') ){
+ if( $expressions ){
+ if( $isSemiColonSeperated ){
+ throw new Less_Exception_Parser('Cannot mix ; and , as delimiter types');
+ }
+ $expressionContainsNamed = true;
+ }
+ $value = $this->expect('parseExpression');
+ $nameLoop = ($name = $val->name);
+ }elseif( !$isCall && $this->MatchReg('/\\G\.{3}/') ){
+ $returner['variadic'] = true;
+ if( $this->MatchChar(";") && !$isSemiColonSeperated ){
+ $isSemiColonSeperated = true;
+ }
+ if( $isSemiColonSeperated ){
+ $argsSemiColon[] = array('name'=> $arg->name, 'variadic' => true);
+ }else{
+ $argsComma[] = array('name'=> $arg->name, 'variadic' => true);
+ }
+ break;
+ }elseif( !$isCall ){
+ $name = $nameLoop = $val->name;
+ $value = null;
+ }
+ }
+
+ if( $value ){
+ $expressions[] = $value;
+ }
+
+ $argsComma[] = array('name'=>$nameLoop, 'value'=>$value );
+
+ if( $this->MatchChar(',') ){
+ continue;
+ }
+
+ if( $this->MatchChar(';') || $isSemiColonSeperated ){
+
+ if( $expressionContainsNamed ){
+ throw new Less_Exception_Parser('Cannot mix ; and , as delimiter types');
+ }
+
+ $isSemiColonSeperated = true;
+
+ if( count($expressions) > 1 ){
+ $value = $this->Less_Tree_Value( $expressions);
+ }
+ $argsSemiColon[] = array('name'=>$name, 'value'=>$value );
+
+ $name = null;
+ $expressions = array();
+ $expressionContainsNamed = false;
+ }
+ }
+
+ $returner['args'] = ($isSemiColonSeperated ? $argsSemiColon : $argsComma);
+ return $returner;
+ }
+
+
+ //
+ // A Mixin definition, with a list of parameters
+ //
+ // .rounded (@radius: 2px, @color) {
+ // ...
+ // }
+ //
+ // Until we have a finer grained state-machine, we have to
+ // do a look-ahead, to make sure we don't have a mixin call.
+ // See the `rule` function for more information.
+ //
+ // We start by matching `.rounded (`, and then proceed on to
+ // the argument list, which has optional default values.
+ // We store the parameters in `params`, with a `value` key,
+ // if there is a value, such as in the case of `@radius`.
+ //
+ // Once we've got our params list, and a closing `)`, we parse
+ // the `{...}` block.
+ //
+ private function parseMixinDefinition(){
+ $params = array();
+ $variadic = false;
+ $cond = null;
+
+ $char = $this->input[$this->pos];
+ if( ($char !== '.' && $char !== '#') || ($char === '{' && $this->Peek('/\\G[^{]*\}/')) ){
+ return;
+ }
+
+ $this->save();
+
+ $match = $this->MatchReg('/\\G([#.](?:[\w-]|\\\(?:[A-Fa-f0-9]{1,6} ?|[^A-Fa-f0-9]))+)\s*\(/');
+ if( $match ){
+ $name = $match[1];
+
+ $argInfo = $this->parseMixinArgs( false );
+ $params = $argInfo['args'];
+ $variadic = $argInfo['variadic'];
+
+
+ // .mixincall("@{a}");
+ // looks a bit like a mixin definition.. so we have to be nice and restore
+ if( !$this->MatchChar(')') ){
+ //furthest = i;
+ $this->restore();
+ }
+
+ $this->parseComments();
+
+ if ($this->MatchReg('/\\Gwhen/')) { // Guard
+ $cond = $this->expect('parseConditions', 'Expected conditions');
+ }
+
+ $ruleset = $this->parseBlock();
+
+ if( is_array($ruleset) ){
+ return Less_Parser::Less_Tree_Mixin_Definition( $name, $params, $ruleset, $cond, $variadic);
+ } else {
+ $this->restore();
+ }
+ }
+ }
+
+ //
+ // Entities are the smallest recognized token,
+ // and can be found inside a rule's value.
+ //
+ private function parseEntity(){
+
+ return $this->MatchFuncs( array('parseEntitiesLiteral','parseEntitiesVariable','parseEntitiesUrl','parseEntitiesCall','parseEntitiesKeyword','parseEntitiesJavascript','parseComment') );
+ }
+
+ //
+ // A Rule terminator. Note that we use `peek()` to check for '}',
+ // because the `block` rule will be expecting it, but we still need to make sure
+ // it's there, if ';' was ommitted.
+ //
+ private function parseEnd(){
+ return $this->MatchChar(';') || $this->PeekChar('}');
+ }
+
+ //
+ // IE's alpha function
+ //
+ // alpha(opacity=88)
+ //
+ private function parseAlpha(){
+
+ if ( ! $this->MatchReg('/\\G\(opacity=/i')) {
+ return;
+ }
+
+ $value = $this->MatchReg('/\\G[0-9]+/');
+ if( $value ){
+ $value = $value[0];
+ }else{
+ $value = $this->parseEntitiesVariable();
+ if( !$value ){
+ return;
+ }
+ }
+
+ $this->expectChar(')');
+ return $this->Less_Tree_Alpha( $value);
+ }
+
+
+ //
+ // A Selector Element
+ //
+ // div
+ // + h1
+ // #socks
+ // input[type="text"]
+ //
+ // Elements are the building blocks for Selectors,
+ // they are made out of a `Combinator` (see combinator rule),
+ // and an element name, such as a tag a class, or `*`.
+ //
+ private function parseElement(){
+ $c = $this->parseCombinator();
+
+ $e = $this->match( array('/\\G(?:\d+\.\d+|\d+)%/', '/\\G(?:[.#]?|:*)(?:[\w-]|[^\x00-\x9f]|\\\\(?:[A-Fa-f0-9]{1,6} ?|[^A-Fa-f0-9]))+/',
+ '#*', '#&', 'parseAttribute', '/\\G\([^()@]+\)/', '/\\G[\.#](?=@)/', 'parseEntitiesVariableCurly') );
+
+ if( is_null($e) ){
+ if( $this->MatchChar('(') ){
+ if( ($v = $this->parseSelector()) && $this->MatchChar(')') ){
+ $e = $this->Less_Tree_Paren( $v);
+ }
+ }
+ }
+
+ if( !is_null($e) ){
+ return $this->Less_Tree_Element( $c, $e, $this->pos, $this->env->currentFileInfo);
+ }
+ }
+
+ //
+ // Combinators combine elements together, in a Selector.
+ //
+ // Because our parser isn't white-space sensitive, special care
+ // has to be taken, when parsing the descendant combinator, ` `,
+ // as it's an empty space. We have to check the previous character
+ // in the input, to see if it's a ` ` character.
+ //
+ private function parseCombinator(){
+ $c = $this->input[$this->pos];
+ if ($c === '>' || $c === '+' || $c === '~' || $c === '|') {
+
+ $this->skipWhitespace(1);
+
+ return $this->Less_Tree_Combinator( $c);
+ }elseif( $this->pos > 0 && $this->isWhitespace(-1) ){
+ return $this->Less_Tree_Combinator(' ');
+ } else {
+ return $this->Less_Tree_Combinator();
+ }
+ }
+
+ //
+ // A CSS selector (see selector below)
+ // with less extensions e.g. the ability to extend and guard
+ //
+ private function parseLessSelector(){
+ return $this->parseSelector(true);
+ }
+
+ //
+ // A CSS Selector
+ //
+ // .class > div + h1
+ // li a:hover
+ //
+ // Selectors are made out of one or more Elements, see above.
+ //
+ private function parseSelector( $isLess = false ){
+ $elements = array();
+ $extendList = array();
+ $condition = null;
+ $when = false;
+ $extend = false;
+
+ while( ($isLess && ($extend = $this->parseExtend())) || ($isLess && ($when = $this->MatchReg('/\\Gwhen/') )) || ($e = $this->parseElement()) ){
+ if( $when ){
+ $condition = $this->expect('parseConditions', 'expected condition');
+ }elseif( $condition ){
+ //error("CSS guard can only be used at the end of selector");
+ }elseif( $extend ){
+ $extendList = array_merge($extendList,$extend);
+ }else{
+ //if( count($extendList) ){
+ //error("Extend can only be used at the end of selector");
+ //}
+ $c = $this->input[ $this->pos ];
+ $elements[] = $e;
+ $e = null;
+ }
+
+ if( $c === '{' || $c === '}' || $c === ';' || $c === ',' || $c === ')') { break; }
+ }
+
+ if( $elements ){
+ return $this->Less_Tree_Selector( $elements, $extendList, $condition, $this->pos, $this->env->currentFileInfo);
+ }
+ if( $extendList ) { throw new Less_Exception_Parser('Extend must be used to extend a selector, it cannot be used on its own'); }
+ }
+
+ private function parseTag(){
+ return ( $tag = $this->MatchReg('/\\G[A-Za-z][A-Za-z-]*[0-9]?/') ) ? $tag : $this->MatchChar('*');
+ }
+
+ private function parseAttribute(){
+
+ $val = null;
+ $op = null;
+
+ if( !$this->MatchChar('[') ){
+ return;
+ }
+
+ $key = $this->parseEntitiesVariableCurly();
+ if( !$key ){
+ $key = $this->expect('/\\G(?:[_A-Za-z0-9-\*]*\|)?(?:[_A-Za-z0-9-]|\\\\.)+/');
+ }
+
+ $op = $this->MatchReg('/\\G[|~*$^]?=/');
+ if( $op ){
+ $val = $this->match( array('parseEntitiesQuoted','/\\G[0-9]+%/','/\\G[\w-]+/','parseEntitiesVariableCurly') );
+ }
+
+ $this->expectChar(']');
+
+ return $this->Less_Tree_Attribute( $key, $op[0], $val);
+ }
+
+ //
+ // The `block` rule is used by `ruleset` and `mixin.definition`.
+ // It's a wrapper around the `primary` rule, with added `{}`.
+ //
+ private function parseBlock(){
+ if ($this->MatchChar('{') && (is_array($content = $this->parsePrimary())) && $this->MatchChar('}')) {
+ return $content;
+ }
+ }
+
+ //
+ // div, .class, body > p {...}
+ //
+ private function parseRuleset(){
+ $selectors = array();
+ $start = $this->pos;
+
+ while( true ){
+ $s = $this->parseLessSelector();
+ if( !$s ){
+ break;
+ }
+ $selectors[] = $s;
+ $this->parseComments();
+ if( !$this->MatchChar(',') ){
+ break;
+ }
+ if( $s->condition ){
+ //error("Guards are only currently allowed on a single selector.");
+ }
+ $this->parseComments();
+ }
+
+
+ if( $selectors && (is_array($rules = $this->parseBlock())) ){
+ return $this->Less_Tree_Ruleset( $selectors, $rules, $this->env->strictImports);
+ } else {
+ // Backtrack
+ $this->pos = $start;
+ }
+ }
+
+
+ private function parseRule( $tryAnonymous = null ){
+ $merge = false;
+ $start = $this->pos;
+ $this->save();
+
+ $c = $this->input[$this->pos];
+ if( $c === '.' || $c === '#' || $c === '&' ){
+ return;
+ }
+
+ if( $name = $this->MatchFuncs( array('parseVariable','parseRuleProperty')) ){
+
+
+ // prefer to try to parse first if its a variable or we are compressing
+ // but always fallback on the other one
+ if( !$tryAnonymous && $name[0] === '@' ){
+ $value = $this->MatchFuncs( array('parseValue','parseAnonymousValue'));
+ }else{
+ $value = $this->MatchFuncs( array('parseAnonymousValue','parseValue'));
+ }
+
+ $important = $this->parseImportant();
+
+ if( substr($name,-1) === '+' ){
+ $merge = true;
+ $name = substr($name, 0, -1 );
+ }
+
+ if( $value && $this->parseEnd() ){
+ return $this->Less_Tree_Rule( $name, $value, $important[0], $merge, $start, $this->env->currentFileInfo);
+ }else{
+ $this->restore();
+ if( $value && !$tryAnonymous ){
+ return $this->parseRule(true);
+ }
+ }
+ }
+ }
+
+ function parseAnonymousValue(){
+
+ if( preg_match('/\\G([^@+\/\'"*`(;{}-]*);/',$this->input, $match, 0, $this->pos) ){
+ $this->pos += strlen($match[1]);
+ return $this->Less_Tree_Anonymous( $match[1]);
+ }
+ }
+
+ //
+ // An @import directive
+ //
+ // @import "lib";
+ //
+ // Depending on our environment, importing is done differently:
+ // In the browser, it's an XHR request, in Node, it would be a
+ // file-system operation. The function used for importing is
+ // stored in `import`, which we pass to the Import constructor.
+ //
+ private function parseImport(){
+ $index = $this->pos;
+
+ $this->save();
+
+ $dir = $this->MatchReg('/\\G@import?\s+/');
+
+ $options = array();
+ if( $dir ){
+ $options = $this->parseImportOptions();
+ if( !$options ){
+ $options = array();
+ }
+ }
+
+ if( $dir && ($path = $this->MatchFuncs( array('parseEntitiesQuoted','parseEntitiesUrl'))) ){
+ $features = $this->parseMediaFeatures();
+ if( $this->MatchChar(';') ){
+ if( $features ){
+ $features = $this->Less_Tree_Value( $features);
+ }
+
+ return $this->Less_Tree_Import( $path, $features, $options, $this->pos, $this->env->currentFileInfo );
+ }
+ }
+
+ $this->restore();
+ }
+
+ private function parseImportOptions(){
+
+ $options = array();
+
+ // list of options, surrounded by parens
+ if( !$this->MatchChar('(') ){ return null; }
+ do{
+ $optionName = $this->parseImportOption();
+ if( $optionName ){
+ $value = true;
+ switch( $optionName ){
+ case "css":
+ $optionName = "less";
+ $value = false;
+ break;
+ case "once":
+ $optionName = "multiple";
+ $value = false;
+ break;
+ }
+ $options[$optionName] = $value;
+ if( !$this->MatchChar(',') ){ break; }
+ }
+ }while( $optionName );
+ $this->expectChar(')');
+ return $options;
+ }
+
+ private function parseImportOption(){
+ $opt = $this->MatchReg('/\\G(less|css|multiple|once|inline|reference)/');
+ if( $opt ){
+ return $opt[1];
+ }
+ }
+
+ private function parseMediaFeature() {
+ $nodes = array();
+
+ do{
+ $e = $this->MatchFuncs(array('parseEntitiesKeyword','parseEntitiesVariable'));
+ if( $e ){
+ $nodes[] = $e;
+ } elseif ($this->MatchChar('(')) {
+ $p = $this->parseProperty();
+ $e = $this->parseValue();
+ if ($this->MatchChar(')')) {
+ if ($p && $e) {
+ $nodes[] = $this->Less_Tree_Paren($this->Less_Tree_Rule( $p, $e, null, null, $this->pos, $this->env->currentFileInfo, true));
+ } elseif ($e) {
+ $nodes[] = $this->Less_Tree_Paren( $e);
+ } else {
+ return null;
+ }
+ } else
+ return null;
+ }
+ } while ($e);
+
+ if ($nodes) {
+ return $this->Less_Tree_Expression( $nodes);
+ }
+ }
+
+ private function parseMediaFeatures() {
+ $features = array();
+
+ do{
+ $e = $this->parseMediaFeature();
+ if( $e ){
+ $features[] = $e;
+ if (!$this->MatchChar(',')) break;
+ }else{
+ $e = $this->parseEntitiesVariable();
+ if( $e ){
+ $features[] = $e;
+ if (!$this->MatchChar(',')) break;
+ }
+ }
+ } while ($e);
+
+ return $features ? $features : null;
+ }
+
+ private function parseMedia() {
+ if ($this->MatchReg('/\\G@media/')) {
+ $features = $this->parseMediaFeatures();
+
+ if ($rules = $this->parseBlock()) {
+ return $this->Less_Tree_Media( $rules, $features, $this->pos, $this->env->currentFileInfo);
+ }
+ }
+ }
+
+ //
+ // A CSS Directive
+ //
+ // @charset "utf-8";
+ //
+ private function parseDirective(){
+ $hasBlock = false;
+ $hasIdentifier = false;
+ $hasExpression = false;
+
+ if (! $this->PeekChar('@')) {
+ return;
+ }
+
+ $value = $this->MatchFuncs(array('parseImport','parseMedia'));
+ if( $value ){
+ return $value;
+ }
+
+ $this->save();
+
+ $name = $this->MatchReg('/\\G@[a-z-]+/');
+
+ if( !$name ) return;
+ $name = $name[0];
+
+ $nonVendorSpecificName = $name;
+ $pos = strpos($name,'-', 2);
+ if( $name[1] == '-' && $pos > 0 ){
+ $nonVendorSpecificName = "@" . substr($name, $pos + 1);
+ }
+
+ switch($nonVendorSpecificName) {
+ case "@font-face":
+ $hasBlock = true;
+ break;
+ case "@viewport":
+ case "@top-left":
+ case "@top-left-corner":
+ case "@top-center":
+ case "@top-right":
+ case "@top-right-corner":
+ case "@bottom-left":
+ case "@bottom-left-corner":
+ case "@bottom-center":
+ case "@bottom-right":
+ case "@bottom-right-corner":
+ case "@left-top":
+ case "@left-middle":
+ case "@left-bottom":
+ case "@right-top":
+ case "@right-middle":
+ case "@right-bottom":
+ $hasBlock = true;
+ break;
+ case "@host":
+ case "@page":
+ case "@document":
+ case "@supports":
+ case "@keyframes":
+ $hasBlock = true;
+ $hasIdentifier = true;
+ break;
+ case "@namespace":
+ $hasExpression = true;
+ break;
+ }
+
+ if( $hasIdentifier ){
+ $identifier = $this->MatchReg('/\\G[^{]+/');
+ if( $identifier ){
+ $name .= " " .trim($identifier[0]);
+ }
+ }
+
+
+ if( $hasBlock ){
+
+ if ($rules = $this->parseBlock()) {
+ return $this->Less_Tree_Directive($name, $rules, $this->pos, $this->env->currentFileInfo);
+ }
+ }else{
+ $value = $hasExpression ? $this->parseExpression() : $this->parseEntity();
+ if( $value && $this->MatchChar(';') ){
+ return $this->Less_Tree_Directive($name, $value, $this->pos, $this->env->currentFileInfo);
+ }
+ }
+
+ $this->restore();
+ }
+
+
+ //
+ // A Value is a comma-delimited list of Expressions
+ //
+ // font-family: Baskerville, Georgia, serif;
+ //
+ // In a Rule, a Value represents everything after the `:`,
+ // and before the `;`.
+ //
+ private function parseValue(){
+ $expressions = array();
+
+ do{
+ $e = $this->parseExpression();
+ if( $e ){
+ $expressions[] = $e;
+ if (! $this->MatchChar(',')) {
+ break;
+ }
+ }
+ }while($e);
+
+ if( $expressions ){
+ return $this->Less_Tree_Value($expressions);
+ }
+ }
+
+ private function parseImportant (){
+ if ($this->PeekChar('!')) {
+ return $this->MatchReg('/\\G! *important/');
+ }
+ }
+
+ private function parseSub (){
+
+ if( $this->MatchChar('(') ){
+ if( $a = $this->parseAddition() ){
+ $e = $this->Less_Tree_Expression( array($a) );
+ $this->expectChar(')');
+ $e->parens = true;
+ return $e;
+ }
+ }
+ }
+
+ function parseMultiplication(){
+ $operation = false;
+ $m = $this->parseOperand();
+ if( $m ){
+ $isSpaced = $this->isWhitespace( -1 );
+ while( true ){
+
+ if( $this->PeekReg('/\\G\/[*\/]/') ){
+ break;
+ }
+
+ $op = $this->MatchChar('/');
+ if( !$op ){
+ $op = $this->MatchChar('*');
+ if( !$op ){
+ break;
+ }
+ }
+
+ $a = $this->parseOperand();
+
+ if(!$a) { break; }
+
+ $m->parensInOp = true;
+ $a->parensInOp = true;
+ $operation = $this->Less_Tree_Operation( $op, array( $operation ? $operation : $m, $a ), $isSpaced );
+ $isSpaced = $this->isWhitespace( -1 );
+ }
+ return ($operation ? $operation : $m);
+ }
+ }
+
+ private function parseAddition (){
+ $operation = false;
+ $m = $this->parseMultiplication();
+ if( $m ){
+ $isSpaced = $this->isWhitespace( -1 );
+
+ while( true ){
+ $op = $this->MatchReg('/\\G[-+]\s+/');
+ if( $op ){
+ $op = $op[0];
+ }elseif( !$isSpaced ){
+ $op = $this->match(array('#+','#-'));
+ }
+ if( !$op ){
+ break;
+ }
+
+ $a = $this->parseMultiplication();
+ if( !$a ){
+ break;
+ }
+
+ $m->parensInOp = true;
+ $a->parensInOp = true;
+ $operation = $this->Less_Tree_Operation($op, array($operation ? $operation : $m, $a), $isSpaced);
+ $isSpaced = $this->isWhitespace( -1 );
+ }
+ return $operation ? $operation : $m;
+ }
+ }
+
+ private function parseConditions() {
+ $index = $this->pos;
+ $condition = null;
+ $a = $this->parseCondition();
+ if( $a ){
+ while( $this->PeekReg('/\\G,\s*(not\s*)?\(/') && $this->MatchChar(',') ){
+ $b = $this->parseCondition();
+ if( !$b ){
+ break;
+ }
+
+ $condition = $this->Less_Tree_Condition('or', $condition ? $condition : $a, $b, $index);
+ }
+ return $condition ? $condition : $a;
+ }
+ }
+
+ private function parseCondition() {
+ $index = $this->pos;
+ $negate = false;
+
+
+ if ($this->MatchReg('/\\Gnot/')) $negate = true;
+ $this->expectChar('(');
+ $a = $this->MatchFuncs(array('parseAddition','parseEntitiesKeyword','parseEntitiesQuoted'));
+
+ if( $a ){
+ $op = $this->MatchReg('/\\G(?:>=|<=|=<|[<=>])/');
+ if( $op ){
+ $b = $this->MatchFuncs(array('parseAddition','parseEntitiesKeyword','parseEntitiesQuoted'));
+ if( $b ){
+ $c = $this->Less_Tree_Condition($op[0], $a, $b, $index, $negate);
+ } else {
+ throw new Less_Exception_Parser('Unexpected expression');
+ }
+ } else {
+ $c = $this->Less_Tree_Condition('=', $a, $this->Less_Tree_Keyword('true'), $index, $negate);
+ }
+ $this->expectChar(')');
+ return $this->MatchReg('/\\Gand/') ? $this->Less_Tree_Condition('and', $c, $this->parseCondition()) : $c;
+ }
+ }
+
+ //
+ // An operand is anything that can be part of an operation,
+ // such as a Color, or a Variable
+ //
+ private function parseOperand (){
+
+ $negate = false;
+ $offset = $this->pos+1;
+ if( $offset >= $this->input_len ){
+ return;
+ }
+ $char = $this->input[$offset];
+ if( $char === '@' || $char === '(' ){
+ $negate = $this->MatchChar('-');
+ }
+
+ $o = $this->MatchFuncs(array('parseSub','parseEntitiesDimension','parseEntitiesColor','parseEntitiesVariable','parseEntitiesCall'));
+
+ if( $negate ){
+ $o->parensInOp = true;
+ $o = $this->Less_Tree_Negative($o);
+ }
+
+ return $o;
+ }
+
+ //
+ // Expressions either represent mathematical operations,
+ // or white-space delimited Entities.
+ //
+ // 1px solid black
+ // @var * 2
+ //
+ private function parseExpression (){
+ $entities = array();
+
+ do{
+ $e = $this->MatchFuncs(array('parseAddition','parseEntity'));
+ if( $e ){
+ $entities[] = $e;
+ // operations do not allow keyword "/" dimension (e.g. small/20px) so we support that here
+ if( !$this->PeekReg('/\\G\/[\/*]/') ){
+ $delim = $this->MatchChar('/');
+ if( $delim ){
+ $entities[] = $this->Less_Tree_Anonymous($delim);
+ }
+ }
+ }
+ }while($e);
+
+ if( $entities ){
+ return $this->Less_Tree_Expression($entities);
+ }
+ }
+
+ private function parseProperty (){
+ $name = $this->MatchReg('/\\G(\*?-?[_a-zA-Z0-9-]+)\s*:/');
+ if( $name ){
+ return $name[1];
+ }
+ }
+
+ private function parseRuleProperty(){
+ $name = $this->MatchReg('/\\G(\*?-?[_a-zA-Z0-9-]+)\s*(\+?)\s*:/');
+ if( $name ){
+ return $name[1] . (isset($name[2]) ? $name[2] : '');
+ }
+ }
+
+ /**
+ * Some versions of php have trouble with method_exists($a,$b) if $a is not an object
+ *
+ */
+ public static function is_method($a,$b){
+ return is_object($a) && method_exists($a,$b);
+ }
+
+ /**
+ *
+ * Round 1.499999 to 1 instead of 2
+ *
+ */
+ public static function round($i, $precision = 0){
+
+ $precision = pow(10,$precision);
+ $i = $i*$precision;
+
+ $ceil = ceil($i);
+ $floor = floor($i);
+ if( ($ceil - $i) <= ($i - $floor) ){
+ return $ceil/$precision;
+ }else{
+ return $floor/$precision;
+ }
+ }
+
+ public function __call($class,$args){
+
+ //$pre_args = $args;
+ //$args += array(null,null,null,null,null,null,null);
+ //$obj = new $class( $args[0], $args[1], $args[2], $args[3], $args[4], $args[5], $args[6] );
+
+ $count = count($args);
+ switch($count){
+ case 0:
+ $obj = new $class();
+ break;
+
+ case 1:
+ $obj = new $class( $args[0]);
+ break;
+
+ case 2:
+ $obj = new $class( $args[0], $args[1]);
+ break;
+
+ case 3:
+ $obj = new $class( $args[0], $args[1], $args[2]);
+ break;
+
+ case 4:
+ $obj = new $class( $args[0], $args[1], $args[2], $args[3]);
+ break;
+
+ case 5:
+ $obj = new $class( $args[0], $args[1], $args[2], $args[3], $args[4] );
+ break;
+
+ case 6:
+ $obj = new $class( $args[0], $args[1], $args[2], $args[3], $args[4], $args[5] );
+ break;
+
+ case 7:
+ $obj = new $class( $args[0], $args[1], $args[2], $args[3], $args[4], $args[5], $args[6] );
+ break;
+ }
+
+
+ //caching
+ if( self::$cache_dir ){
+ $obj->cache_string = ' new '.$class.'(';
+ $comma = '';
+ foreach($args as $arg){
+ $obj->cache_string .= $comma.self::ArgString($arg);
+ $comma = ', ';
+ }
+ $obj->cache_string .= ')';
+ }
+
+ return $obj;
+ }
+
+ public static function ArgString($arg){
+
+ $type = gettype($arg);
+ switch( $type ){
+
+ case 'object':
+ $string = $arg->cache_string;
+ unset($arg->cache_string);
+ return $string;
+
+ case 'array':
+ $string = ' Array(';
+ foreach($arg as $k => $a){
+ $string .= var_export($k,true).' => '.self::ArgString($a).',';
+ }
+ return $string . ')';
+
+ default:
+ return var_export($arg,true);
+ }
+
+ }
+}
+
+
diff --git a/lib/Less/Tree.php b/lib/Less/Tree.php
new file mode 100644
index 0000000000000..fbd94a3d889e4
--- /dev/null
+++ b/lib/Less/Tree.php
@@ -0,0 +1,63 @@
+genCSS($env, $strs );
+ return implode('',$strs);
+ }
+
+ public static function OutputAdd( &$strs, $chunk, $fileInfo = null, $index = null ){
+ $strs[] = $chunk;
+ }
+
+
+ public static function outputRuleset($env, &$strs, $rules ){
+
+ $ruleCnt = count($rules);
+ $env->tabLevel++;
+
+
+ // Compressed
+ if( Less_Environment::$compress ){
+ self::OutputAdd( $strs, '{' );
+ for( $i = 0; $i < $ruleCnt; $i++ ){
+ $rules[$i]->genCSS( $env, $strs );
+ }
+ self::OutputAdd( $strs, '}' );
+ $env->tabLevel--;
+ return;
+ }
+
+
+ // Non-compressed
+ $tabSetStr = "\n".str_repeat( ' ' , $env->tabLevel-1 );
+ $tabRuleStr = $tabSetStr.' ';
+
+ self::OutputAdd( $strs, " {" );
+ for($i = 0; $i < $ruleCnt; $i++ ){
+ self::OutputAdd( $strs, $tabRuleStr );
+ $rules[$i]->genCSS( $env, $strs );
+ }
+ $env->tabLevel--;
+ self::OutputAdd( $strs, $tabSetStr.'}' );
+
+ }
+
+ public function accept($visitor){}
+
+ /**
+ * Requires php 5.3+
+ */
+ public static function __set_state($args){
+
+ $class = get_called_class();
+ $obj = new $class(null,null,null,null);
+ foreach($args as $key => $val){
+ $obj->$key = $val;
+ }
+ return $obj;
+ }
+
+}
\ No newline at end of file
diff --git a/lib/Less/Tree/Alpha.php b/lib/Less/Tree/Alpha.php
new file mode 100644
index 0000000000000..524a39dce40f1
--- /dev/null
+++ b/lib/Less/Tree/Alpha.php
@@ -0,0 +1,41 @@
+value = $val;
+ }
+
+ //function accept( $visitor ){
+ // $this->value = $visitor->visit( $this->value );
+ //}
+
+ public function compile($env){
+
+ if( !is_string($this->value) ){ return new Less_Tree_Alpha( $this->value->compile($env) ); }
+
+ return $this;
+ }
+
+ public function genCSS( $env, &$strs ){
+
+ self::OutputAdd( $strs, "alpha(opacity=" );
+
+ if( is_string($this->value) ){
+ self::OutputAdd( $strs, $this->value );
+ }else{
+ $this->value->genCSS($env, $strs);
+ }
+
+ self::OutputAdd( $strs, ')' );
+ }
+
+ public function toCSS($env = null){
+ return "alpha(opacity=" . (is_string($this->value) ? $this->value : $this->value->toCSS()) . ")";
+ }
+
+
+}
\ No newline at end of file
diff --git a/lib/Less/Tree/Anonymous.php b/lib/Less/Tree/Anonymous.php
new file mode 100644
index 0000000000000..d089c231e4fe2
--- /dev/null
+++ b/lib/Less/Tree/Anonymous.php
@@ -0,0 +1,43 @@
+value = is_object($value) ? $value->value : $value;
+ $this->index = $index;
+ $this->mapLines = $mapLines;
+ $this->currentFileInfo = $currentFileInfo;
+ }
+
+ public function compile($env){
+ return $this;
+ }
+
+ function compare($x){
+ if( !is_object($x) ){
+ return -1;
+ }
+
+ $left = $this->toCSS();
+ $right = $x->toCSS();
+
+ if( $left === $right ){
+ return 0;
+ }
+
+ return $left < $right ? -1 : 1;
+ }
+
+ public function genCSS( $env, &$strs ){
+ self::OutputAdd( $strs, $this->value, $this->currentFileInfo, $this->index, $this->mapLines );
+ }
+
+ public function toCSS($env = null){
+ return $this->value;
+ }
+
+}
diff --git a/lib/Less/Tree/Assignment.php b/lib/Less/Tree/Assignment.php
new file mode 100644
index 0000000000000..14af3e63071d2
--- /dev/null
+++ b/lib/Less/Tree/Assignment.php
@@ -0,0 +1,39 @@
+key = $key;
+ $this->value = $val;
+ }
+
+ function accept( $visitor ){
+ $this->value = $visitor->visitObj( $this->value );
+ }
+
+
+ public function compile($env) {
+ if( Less_Parser::is_method($this->value,'compile') ){
+ return new Less_Tree_Assignment( $this->key, $this->value->compile($env));
+ }
+ return $this;
+ }
+
+ public function genCSS( $env, &$strs ){
+ self::OutputAdd( $strs, $this->key . '=' );
+ if( is_string($this->value) ){
+ self::OutputAdd( $strs, $this->value );
+ }else{
+ $this->value->genCSS( $env, $strs );
+ }
+ }
+
+ public function toCss($env = null){
+ return $this->key . '=' . (is_string($this->value) ? $this->value : $this->value->toCSS());
+ }
+}
diff --git a/lib/Less/Tree/Attribute.php b/lib/Less/Tree/Attribute.php
new file mode 100644
index 0000000000000..8eb7fd175aad5
--- /dev/null
+++ b/lib/Less/Tree/Attribute.php
@@ -0,0 +1,39 @@
+key = $key;
+ $this->op = $op;
+ $this->value = $value;
+ }
+
+ function compile($env){
+
+ return new Less_Tree_Attribute(
+ is_object($this->key) ? $this->key->compile($env) : $this->key ,
+ $this->op,
+ is_object($this->value) ? $this->value->compile($env) : $this->value);
+ }
+
+ function genCSS( $env, &$strs ){
+ self::OutputAdd( $strs, $this->toCSS($env) );
+ }
+
+ function toCSS($env = null){
+ $value = $this->key;
+
+ if( $this->op ){
+ $value .= $this->op;
+ $value .= (is_object($this->value) ? $this->value->toCSS($env) : $this->value);
+ }
+
+ return '[' . $value . ']';
+ }
+}
\ No newline at end of file
diff --git a/lib/Less/Tree/Call.php b/lib/Less/Tree/Call.php
new file mode 100644
index 0000000000000..c61cca112c5ee
--- /dev/null
+++ b/lib/Less/Tree/Call.php
@@ -0,0 +1,97 @@
+name = $name;
+ $this->args = $args;
+ $this->index = $index;
+ $this->currentFileInfo = $currentFileInfo;
+ }
+
+ function accept( $visitor ){
+ $this->args = $visitor->visitArray( $this->args );
+ }
+
+ //
+ // When evaluating a function call,
+ // we either find the function in `tree.functions` [1],
+ // in which case we call it, passing the evaluated arguments,
+ // or we simply print it out as it appeared originally [2].
+ //
+ // The *functions.js* file contains the built-in functions.
+ //
+ // The reason why we evaluate the arguments, is in the case where
+ // we try to pass a variable to a function, like: `saturate(@color)`.
+ // The function should receive the value, not the variable.
+ //
+ public function compile($env){
+ $args = array();
+ foreach($this->args as $a){
+ $args[] = $a->compile($env);
+ }
+
+ $name = $this->name;
+ switch($name){
+ case '%':
+ $name = '_percent';
+ break;
+
+ case 'data-uri':
+ $name = 'datauri';
+ break;
+
+ case 'svg-gradient':
+ $name = 'svggradient';
+ break;
+ }
+
+
+ if( is_callable( array('Less_Functions',$name) ) ){ // 1.
+ try {
+ $func = new Less_Functions($env, $this->currentFileInfo);
+ $result = call_user_func_array( array($func,$name),$args);
+ if( $result != null ){
+ return $result;
+ }
+
+ } catch (Exception $e) {
+ throw new Less_Exception_Compiler('error evaluating function `' . $this->name . '` '.$e->getMessage().' index: '. $this->index);
+ }
+
+ }
+
+ return new Less_Tree_Call( $this->name, $args, $this->index, $this->currentFileInfo );
+ }
+
+ public function genCSS( $env, &$strs ){
+
+ self::OutputAdd( $strs, $this->name . '(', $this->currentFileInfo, $this->index );
+ $args_len = count($this->args);
+ for($i = 0; $i < $args_len; $i++ ){
+ $this->args[$i]->genCSS($env, $strs );
+ if( $i + 1 < $args_len ){
+ self::OutputAdd( $strs, ', ' );
+ }
+ }
+
+ self::OutputAdd( $strs, ')' );
+ }
+
+ public function toCSS($env = null){
+ return $this->compile($env)->toCSS();
+ }
+
+}
diff --git a/lib/Less/Tree/Color.php b/lib/Less/Tree/Color.php
new file mode 100644
index 0000000000000..9990e954c8ef5
--- /dev/null
+++ b/lib/Less/Tree/Color.php
@@ -0,0 +1,202 @@
+rgb = array();
+ if( is_array($rgb) ){
+ $this->rgb = $rgb;
+ }else if( strlen($rgb) == 6 ){
+ foreach(str_split($rgb, 2) as $c){
+ $this->rgb[] = hexdec($c);
+ }
+ }else{
+ foreach(str_split($rgb, 1) as $c){
+ $this->rgb[] = hexdec($c.$c);
+ }
+ }
+ $this->alpha = is_numeric($a) ? $a : 1;
+ }
+
+ public function compile($env = null){
+ return $this;
+ }
+
+ public function luma(){
+ return (0.2126 * $this->rgb[0] / 255) + (0.7152 * $this->rgb[1] / 255) + (0.0722 * $this->rgb[2] / 255);
+ }
+
+ public function genCSS( $env, &$strs ){
+ self::OutputAdd( $strs, $this->toCSS($env) );
+ }
+
+ public function toCSS($env = null, $doNotCompress = false ){
+ $compress = Less_Environment::$compress && !$doNotCompress;
+
+
+ //
+ // If we have some transparency, the only way to represent it
+ // is via `rgba`. Otherwise, we use the hex representation,
+ // which has better compatibility with older browsers.
+ // Values are capped between `0` and `255`, rounded and zero-padded.
+ //
+ if( $this->alpha < 1.0 ){
+ if( $this->alpha === 0 && isset($this->isTransparentKeyword) && $this->isTransparentKeyword ){
+ return 'transparent';
+ }
+
+
+ $values = array_map('round', $this->rgb);
+ $values[] = $this->alpha;
+
+ $glue = ($compress ? ',' : ', ');
+ return "rgba(" . implode($glue, $values) . ")";
+ }else{
+
+ $color = $this->toRGB();
+
+ if( $compress ){
+
+ // Convert color to short format
+ if( $color[1] === $color[2] && $color[3] === $color[4] && $color[5] === $color[6]) {
+ $color = '#'.$color[1] . $color[3] . $color[5];
+ }
+ }
+
+ return $color;
+ }
+ }
+
+ //
+ // Operations have to be done per-channel, if not,
+ // channels will spill onto each other. Once we have
+ // our result, in the form of an integer triplet,
+ // we create a new Color node to hold the result.
+ //
+ public function operate($env, $op, $other) {
+ $result = array();
+
+ if (! ($other instanceof Less_Tree_Color)) {
+ $other = $other->toColor();
+ }
+
+ for ($c = 0; $c < 3; $c++) {
+ $result[$c] = Less_Functions::operate($env, $op, $this->rgb[$c], $other->rgb[$c]);
+ }
+ return new Less_Tree_Color($result, $this->alpha + $other->alpha);
+ }
+
+ public function toRGB(){
+ $color = '';
+ foreach($this->rgb as $i){
+ $i = Less_Parser::round($i);
+ $i = ($i > 255 ? 255 : ($i < 0 ? 0 : $i));
+ $i = dechex($i);
+ $color .= str_pad($i, 2, '0', STR_PAD_LEFT);
+ }
+ return '#'.$color;
+ }
+
+ public function toHSL(){
+ $r = $this->rgb[0] / 255;
+ $g = $this->rgb[1] / 255;
+ $b = $this->rgb[2] / 255;
+ $a = $this->alpha;
+
+ $max = max($r, $g, $b);
+ $min = min($r, $g, $b);
+ $l = ($max + $min) / 2;
+ $d = $max - $min;
+
+ if( $max === $min ){
+ $h = $s = 0;
+ } else {
+ $s = $l > 0.5 ? $d / (2 - $max - $min) : $d / ($max + $min);
+
+ switch ($max) {
+ case $r: $h = ($g - $b) / $d + ($g < $b ? 6 : 0); break;
+ case $g: $h = ($b - $r) / $d + 2; break;
+ case $b: $h = ($r - $g) / $d + 4; break;
+ }
+ $h /= 6;
+ }
+ return array('h' => $h * 360, 's' => $s, 'l' => $l, 'a' => $a );
+ }
+
+ //Adapted from http://mjijackson.com/2008/02/rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript
+ function toHSV() {
+ $r = $this->rgb[0] / 255;
+ $g = $this->rgb[1] / 255;
+ $b = $this->rgb[2] / 255;
+ $a = $this->alpha;
+
+ $max = max($r, $g, $b);
+ $min = min($r, $g, $b);
+
+ $v = $max;
+
+ $d = $max - $min;
+ if ($max === 0) {
+ $s = 0;
+ } else {
+ $s = $d / $max;
+ }
+
+ if ($max === $min) {
+ $h = 0;
+ } else {
+ switch($max){
+ case $r: $h = ($g - $b) / $d + ($g < $b ? 6 : 0); break;
+ case $g: $h = ($b - $r) / $d + 2; break;
+ case $b: $h = ($r - $g) / $d + 4; break;
+ }
+ $h /= 6;
+ }
+ return array('h'=> $h * 360, 's'=> $s, 'v'=> $v, 'a' => $a );
+ }
+
+ public function toARGB(){
+ $argb = array_merge( (array) Less_Parser::round($this->alpha * 255), $this->rgb);
+
+ $temp = '';
+ foreach($argb as $i){
+ $i = Less_Parser::round($i);
+ $i = dechex($i > 255 ? 255 : ($i < 0 ? 0 : $i));
+ $temp .= str_pad($i, 2, '0', STR_PAD_LEFT);
+ }
+ return '#' . $temp;
+ }
+
+ public function compare($x){
+
+ if( !property_exists( $x, 'rgb' ) ){
+ return -1;
+ }
+
+
+ return ($x->rgb[0] === $this->rgb[0] &&
+ $x->rgb[1] === $this->rgb[1] &&
+ $x->rgb[2] === $this->rgb[2] &&
+ $x->alpha === $this->alpha) ? 0 : -1;
+ }
+
+
+ public static function fromKeyword( $keyword ){
+
+ if( Less_Colors::hasOwnProperty($keyword) ){
+ // detect named color
+ return new Less_Tree_Color(substr(Less_Colors::color($keyword), 1));
+ }
+
+ if( $keyword === 'transparent' ){
+ $transparent = new Less_Tree_Color( array(0, 0, 0), 0);
+ $transparent->isTransparentKeyword = true;
+ return $transparent;
+ }
+ }
+
+}
diff --git a/lib/Less/Tree/Combinator.php b/lib/Less/Tree/Combinator.php
new file mode 100644
index 0000000000000..4adb8962bc62d
--- /dev/null
+++ b/lib/Less/Tree/Combinator.php
@@ -0,0 +1,45 @@
+value = ' ';
+ }else {
+ $this->value = trim($value);
+ }
+ }
+
+ static $_outputMap = array(
+ '' => '',
+ ' ' => ' ',
+ ':' => ' :',
+ '+' => ' + ',
+ '~' => ' ~ ',
+ '>' => ' > ',
+ '|' => '|'
+ );
+
+ static $_outputMapCompressed = array(
+ '' => '',
+ ' ' => ' ',
+ ':' => ' :',
+ '+' => '+',
+ '~' => '~',
+ '>' => '>',
+ '|' => '|'
+ );
+
+ function genCSS($env, &$strs ){
+ if( Less_Environment::$compress ){
+ self::OutputAdd( $strs, self::$_outputMapCompressed[$this->value] );
+ }else{
+ self::OutputAdd( $strs, self::$_outputMap[$this->value] );
+ }
+ }
+
+}
diff --git a/lib/Less/Tree/Comment.php b/lib/Less/Tree/Comment.php
new file mode 100644
index 0000000000000..94045001208a1
--- /dev/null
+++ b/lib/Less/Tree/Comment.php
@@ -0,0 +1,38 @@
+value = $value;
+ $this->silent = !! $silent;
+ $this->currentFileInfo = $currentFileInfo;
+ }
+
+ public function genCSS( $env, &$strs ){
+ //if( $this->debugInfo ){
+ //self::OutputAdd( $strs, tree.debugInfo($env, $this), $this->currentFileInfo, $this->index);
+ //}
+ self::OutputAdd( $strs, trim($this->value) );//TODO shouldn't need to trim, we shouldn't grab the \n
+ }
+
+ public function toCSS($env = null){
+ return Less_Environment::$compress ? '' : $this->value;
+ }
+
+ public function isSilent( $env ){
+ $isReference = ($this->currentFileInfo && isset($this->currentFileInfo['reference']) && (!isset($this->isReferenced) || !$this->isReferenced) );
+ $isCompressed = Less_Environment::$compress && !preg_match('/^\/\*!/', $this->value);
+ return $this->silent || $isReference || $isCompressed;
+ }
+
+ public function compile(){
+ return $this;
+ }
+
+ public function markReferenced(){
+ $this->isReferenced = true;
+ }
+
+}
diff --git a/lib/Less/Tree/Condition.php b/lib/Less/Tree/Condition.php
new file mode 100644
index 0000000000000..7c7a0c785f766
--- /dev/null
+++ b/lib/Less/Tree/Condition.php
@@ -0,0 +1,68 @@
+op = trim($op);
+ $this->lvalue = $l;
+ $this->rvalue = $r;
+ $this->index = $i;
+ $this->negate = $negate;
+ }
+
+ public function accept($visitor){
+ $this->lvalue = $visitor->visitObj( $this->lvalue );
+ $this->rvalue = $visitor->visitObj( $this->rvalue );
+ }
+
+ public function compile($env) {
+ $a = $this->lvalue->compile($env);
+ $b = $this->rvalue->compile($env);
+
+ $i = $this->index;
+
+ switch( $this->op ){
+ case 'and':
+ $result = $a && $b;
+ break;
+
+ case 'or':
+ $result = $a || $b;
+ break;
+
+ default:
+ if( Less_Parser::is_method($a, 'compare') ){
+ $result = $a->compare($b);
+ }elseif( Less_Parser::is_method($b, 'compare') ){
+ $result = $b->compare($a);
+ }else{
+ throw new Less_Exception_Compiler('Unable to perform comparison', $this->index);
+ }
+
+ switch ($result) {
+ case -1:
+ $result = $this->op === '<' || $this->op === '=<' || $this->op === '<=';
+ break;
+
+ case 0:
+ $result = $this->op === '=' || $this->op === '>=' || $this->op === '=<' || $this->op === '<=';
+ break;
+
+ case 1:
+ $result = $this->op === '>' || $this->op === '>=';
+ break;
+ }
+ break;
+ }
+
+ return $this->negate ? !$result : $result;
+ }
+
+}
diff --git a/lib/Less/Tree/Dimension.php b/lib/Less/Tree/Dimension.php
new file mode 100644
index 0000000000000..a8729a1ac1c9d
--- /dev/null
+++ b/lib/Less/Tree/Dimension.php
@@ -0,0 +1,184 @@
+value = floatval($value);
+
+ if( $unit && ($unit instanceof Less_Tree_Unit) ){
+ $this->unit = $unit;
+ }elseif( $unit ){
+ $this->unit = new Less_Tree_Unit( array($unit) );
+ }else{
+ $this->unit = new Less_Tree_Unit( );
+ }
+ }
+
+ function accept( $visitor ){
+ $this->unit = $visitor->visitObj( $this->unit );
+ }
+
+ public function compile($env = null) {
+ return $this;
+ }
+
+ public function toColor() {
+ return new Less_Tree_Color(array($this->value, $this->value, $this->value));
+ }
+
+ public function genCSS( $env, &$strs ){
+
+ if( ($env && $env->strictUnits) && !$this->unit->isSingular() ){
+ throw new Less_Exception_Compiler("Multiple units in dimension. Correct the units or use the unit function. Bad unit: ".$this->unit->toString());
+ }
+
+ $value = $this->value;
+ $strValue = (string)$value;
+
+ if( $value !== 0 && $value < 0.000001 && $value > -0.000001 ){
+ // would be output 1e-6 etc.
+ $strValue = number_format($strValue,10);
+ $strValue = preg_replace('/\.?0+$/','', $strValue);
+ }
+
+ if( Less_Environment::$compress ){
+ // Zero values doesn't need a unit
+ if( $value === 0 && $this->unit->isLength() ){
+ self::OutputAdd( $strs, $strValue );
+ return $strValue;
+ }
+
+ // Float values doesn't need a leading zero
+ if( $value > 0 && $value < 1 && $strValue[0] === '0' ){
+ $strValue = substr($strValue,1);
+ }
+ }
+
+ self::OutputAdd( $strs, $strValue );
+ $this->unit->genCSS($env, $strs);
+ }
+
+ public function __toString(){
+ return $this->toCSS();
+ }
+
+ // In an operation between two Dimensions,
+ // we default to the first Dimension's unit,
+ // so `1px + 2em` will yield `3px`.
+ public function operate($env, $op, $other){
+
+ $value = Less_Functions::operate($env, $op, $this->value, $other->value);
+ $unit = clone $this->unit;
+
+ if( $op === '+' || $op === '-' ){
+
+ if( !$unit->numerator && !$unit->denominator ){
+ $unit->numerator = $other->unit->numerator;
+ $unit->denominator = $other->unit->denominator;
+ }elseif( !$other->unit->numerator && !$other->unit->denominator ){
+ // do nothing
+ }else{
+ $other = $other->convertTo( $this->unit->usedUnits());
+
+ if( $env->strictUnits && $other->unit->toString() !== $unit->toCSS() ){
+ throw new Less_Exception_Compiler("Incompatible units. Change the units or use the unit function. Bad units: '".$unit->toString() . "' and ".$other->unit->toString()+"'.");
+ }
+
+ $value = Less_Functions::operate($env, $op, $this->value, $other->value);
+ }
+ }elseif( $op === '*' ){
+ $unit->numerator = array_merge($unit->numerator, $other->unit->numerator);
+ $unit->denominator = array_merge($unit->denominator, $other->unit->denominator);
+ sort($unit->numerator);
+ sort($unit->denominator);
+ $unit->cancel();
+ }elseif( $op === '/' ){
+ $unit->numerator = array_merge($unit->numerator, $other->unit->denominator);
+ $unit->denominator = array_merge($unit->denominator, $other->unit->numerator);
+ sort($unit->numerator);
+ sort($unit->denominator);
+ $unit->cancel();
+ }
+ return new Less_Tree_Dimension( $value, $unit);
+ }
+
+ public function compare($other) {
+ if ($other instanceof Less_Tree_Dimension) {
+
+ $a = $this->unify();
+ $b = $other->unify();
+ $aValue = $a->value;
+ $bValue = $b->value;
+
+ if ($bValue > $aValue) {
+ return -1;
+ } elseif ($bValue < $aValue) {
+ return 1;
+ } else {
+ if( !$b->unit->isEmpty() && $a->unit->compare($b->unit) !== 0) {
+ return -1;
+ }
+ return 0;
+ }
+ } else {
+ return -1;
+ }
+ }
+
+ function unify() {
+ return $this->convertTo(array('length'=> 'm', 'duration'=> 's', 'angle' => 'rad' ));
+ }
+
+ function convertTo($conversions) {
+ $value = $this->value;
+ $unit = clone $this->unit;
+
+ if( is_string($conversions) ){
+ $derivedConversions = array();
+ foreach( Less_Tree_UnitConversions::$groups as $i ){
+ if( isset(Less_Tree_UnitConversions::${$i}[$conversions]) ){
+ $derivedConversions = array( $i => $conversions);
+ }
+ }
+ $conversions = $derivedConversions;
+ }
+
+
+ foreach($conversions as $groupName => $targetUnit){
+ $group = Less_Tree_UnitConversions::${$groupName};
+
+ //numerator
+ $len = count($unit->numerator);
+ for($i=0; $i < $len; $i++ ){
+ $atomicUnit = $unit->numerator[$i];
+ if( !isset($group[$atomicUnit]) ){
+ continue;
+ }
+
+ $value = $value * ($group[$atomicUnit] / $group[$targetUnit]);
+
+ $unit->numerator[$i] = $targetUnit;
+ }
+
+ //denominator
+ $len = count($unit->denominator);
+ for($i=0; $i < $len; $i++ ){
+ $atomicUnit = $unit->denominator[$i];
+ if( !isset($group[$atomicUnit]) ){
+ continue;
+ }
+
+ $value = $value / ($group[$atomicUnit] / $group[$targetUnit]);
+
+ $unit->denominator[$i] = $targetUnit;
+ }
+ }
+
+ $unit->cancel();
+
+ return new Less_Tree_Dimension( $value, $unit);
+ }
+}
diff --git a/lib/Less/Tree/Directive.php b/lib/Less/Tree/Directive.php
new file mode 100644
index 0000000000000..528a63b2a96d4
--- /dev/null
+++ b/lib/Less/Tree/Directive.php
@@ -0,0 +1,81 @@
+name = $name;
+ if (is_array($value)) {
+ $rule = new Less_Tree_Ruleset(array(), $value);
+ $rule->allowImports = true;
+ $this->rules = array($rule);
+ } else {
+ $this->value = $value;
+ }
+ $this->currentFileInfo = $currentFileInfo;
+ }
+
+
+ function accept( $visitor ){
+ if( $this->rules ){
+ $this->rules = $visitor->visitArray( $this->rules );
+ }
+ if( $this->value ){
+ $this->value = $visitor->visitObj( $this->value );
+ }
+ }
+
+ function genCSS( $env, &$strs ){
+
+ self::OutputAdd( $strs, $this->name, $this->currentFileInfo, $this->index );
+
+ if( $this->rules ){
+ Less_Tree::outputRuleset( $env, $strs, $this->rules);
+ }else{
+ self::OutputAdd( $strs, ' ' );
+ $this->value->genCSS( $env, $strs );
+ self::OutputAdd( $strs, ';' );
+ }
+ }
+
+ public function compile($env){
+ $evaldDirective = $this;
+ if( $this->rules ){
+ $env->unshiftFrame($this);
+ $evaldDirective = new Less_Tree_Directive( $this->name, null, $this->index, $this->currentFileInfo );
+ $evaldDirective->rules = array( $this->rules[0]->compile($env) );
+ $evaldDirective->rules[0]->root = true;
+ $env->shiftFrame();
+ }
+ return $evaldDirective;
+ }
+
+ // TODO: Not sure if this is right...
+ public function variable($name){
+ return $this->rules[0]->variable($name);
+ }
+
+ public function find($selector){
+ return $this->rules[0]->find($selector, $this);
+ }
+
+ //rulesets: function () { return tree.Ruleset.prototype.rulesets.apply(this.rules[0]); },
+
+ public function markReferenced(){
+ $this->isReferenced = true;
+ if( $this->rules ){
+ $rules = $this->rules[0]->rules;
+ for( $i = 0; $i < count($rules); $i++ ){
+ if( Less_Parser::is_method( $rules[$i], 'markReferenced') ){
+ $rules[$i]->markReferenced();
+ }
+ }
+ }
+ }
+
+}
diff --git a/lib/Less/Tree/Element.php b/lib/Less/Tree/Element.php
new file mode 100644
index 0000000000000..aafae04e488a8
--- /dev/null
+++ b/lib/Less/Tree/Element.php
@@ -0,0 +1,58 @@
+value = $value;
+ }
+
+ $this->combinator = $combinator;
+ $this->index = $index;
+ $this->currentFileInfo = $currentFileInfo;
+ }
+
+ function accept( $visitor ){
+ $this->combinator = $visitor->visitObj( $this->combinator );
+ if( is_object($this->value) ){ //object or string
+ $this->value = $visitor->visitObj( $this->value );
+ }
+ }
+
+ public function compile($env) {
+ return new Less_Tree_Element($this->combinator,
+ is_string($this->value) ? $this->value : $this->value->compile($env),
+ $this->index,
+ $this->currentFileInfo
+ );
+ }
+
+ public function genCSS( $env, &$strs ){
+ self::OutputAdd( $strs, $this->toCSS($env), $this->currentFileInfo, $this->index );
+ }
+
+ public function toCSS( $env = null ){
+
+ $value = $this->value;
+ if( !is_string($value) ){
+ $value = $value->toCSS($env);
+ }
+
+ if( $value === '' && $this->combinator->value[0] === '&' ){
+ return '';
+ }
+ return $this->combinator->toCSS($env) . $value;
+ }
+
+}
diff --git a/lib/Less/Tree/Expression.php b/lib/Less/Tree/Expression.php
new file mode 100644
index 0000000000000..0b83b538465f1
--- /dev/null
+++ b/lib/Less/Tree/Expression.php
@@ -0,0 +1,86 @@
+value = $value;
+ }
+
+ function accept( $visitor ){
+ $this->value = $visitor->visitArray( $this->value );
+ }
+
+ public function compile($env) {
+
+ $inParenthesis = $this->parens && !$this->parensInOp;
+ $doubleParen = false;
+ if( $inParenthesis ) {
+ $env->inParenthesis();
+ }
+
+ if( $this->value ){
+
+ $count = count($this->value);
+
+ if( $count > 1 ){
+
+ $ret = array();
+ foreach($this->value as $e){
+ $ret[] = $e->compile($env);
+ }
+ $returnValue = new Less_Tree_Expression($ret);
+
+ }elseif( $count === 1 ){
+
+ if( !isset($this->value[0]) ){
+ $this->value = array_slice($this->value,0);
+ }
+
+ if( ($this->value[0] instanceof Less_Tree_Expression) && $this->value[0]->parens && !$this->value[0]->parensInOp ){
+ $doubleParen = true;
+ }
+
+ $returnValue = $this->value[0]->compile($env);
+ }
+
+ } else {
+ $returnValue = $this;
+ }
+ if( $inParenthesis ){
+ $env->outOfParenthesis();
+ }
+ if( $this->parens && $this->parensInOp && !$env->isMathOn() && !$doubleParen ){
+ $returnValue = new Less_Tree_Paren($returnValue);
+ }
+ return $returnValue;
+ }
+
+ function genCSS( $env, &$strs ){
+ $val_len = count($this->value);
+ for( $i = 0; $i < $val_len; $i++ ){
+ $this->value[$i]->genCSS( $env, $strs );
+ if( $i + 1 < $val_len ){
+ self::OutputAdd( $strs, ' ' );
+ }
+ }
+ }
+
+ function throwAwayComments() {
+
+ if( is_array($this->value) ){
+ $new_value = array();
+ foreach($this->value as $v){
+ if( $v instanceof Less_Tree_Comment ){
+ continue;
+ }
+ $new_value[] = $v;
+ }
+ $this->value = $new_value;
+ }
+ }
+}
diff --git a/lib/Less/Tree/Extend.php b/lib/Less/Tree/Extend.php
new file mode 100644
index 0000000000000..203d1156556c5
--- /dev/null
+++ b/lib/Less/Tree/Extend.php
@@ -0,0 +1,66 @@
+selector = $selector;
+ $this->option = $option;
+ $this->index = $index;
+
+ switch($option){
+ case "all":
+ $this->allowBefore = true;
+ $this->allowAfter = true;
+ break;
+ default:
+ $this->allowBefore = false;
+ $this->allowAfter = false;
+ break;
+ }
+
+ $this->object_id = $i++;
+ $this->parent_ids = array($this->object_id);
+ }
+
+ function accept( $visitor ){
+ $this->selector = $visitor->visitObj( $this->selector );
+ }
+
+ function compile( $env ){
+ Less_Parser::$has_extends = true;
+ return new Less_Tree_Extend( $this->selector->compile($env), $this->option, $this->index);
+ }
+
+ function findSelfSelectors( $selectors ){
+ $selfElements = array();
+
+
+ for( $i = 0, $selectors_len = count($selectors); $i < $selectors_len; $i++ ){
+ $selectorElements = $selectors[$i]->elements;
+ // duplicate the logic in genCSS function inside the selector node.
+ // future TODO - move both logics into the selector joiner visitor
+ if( $i && $selectorElements && $selectorElements[0]->combinator->value === "") {
+ $selectorElements[0]->combinator->value = ' ';
+ }
+ $selfElements = array_merge( $selfElements, $selectors[$i]->elements );
+ }
+
+ $this->selfSelectors = array(new Less_Tree_Selector($selfElements));
+ }
+
+}
\ No newline at end of file
diff --git a/lib/Less/Tree/Import.php b/lib/Less/Tree/Import.php
new file mode 100644
index 0000000000000..528238082bf5d
--- /dev/null
+++ b/lib/Less/Tree/Import.php
@@ -0,0 +1,221 @@
+options = $options;
+ $this->index = $index;
+ $this->path = $path;
+ $this->features = $features;
+ $this->currentFileInfo = $currentFileInfo;
+
+ if( is_array($options) ){
+ $this->options += array('inline'=>false);
+
+ if( isset($this->options['less']) || $this->options['inline'] ){
+ $this->css = !isset($this->options['less']) || !$this->options['less'] || $this->options['inline'];
+ } else {
+ $pathValue = $this->getPath();
+ if( $pathValue && preg_match('/css([\?;].*)?$/',$pathValue) ){
+ $this->css = true;
+ }
+ }
+ }
+ }
+
+//
+// The actual import node doesn't return anything, when converted to CSS.
+// The reason is that it's used at the evaluation stage, so that the rules
+// it imports can be treated like any other rules.
+//
+// In `eval`, we make sure all Import nodes get evaluated, recursively, so
+// we end up with a flat structure, which can easily be imported in the parent
+// ruleset.
+//
+
+ function accept($visitor){
+
+ if( $this->features ){
+ $this->features = $visitor->visitObj($this->features);
+ }
+ $this->path = $visitor->visitObj($this->path);
+
+ if( !$this->options['inline'] && $this->root ){
+ $this->root = $visitor->visit($this->root);
+ }
+ }
+
+ function genCSS( $env, &$strs ){
+ if( $this->css ){
+
+ self::OutputAdd( $strs, '@import ', $this->currentFileInfo, $this->index );
+
+ $this->path->genCSS( $env, $strs );
+ if( $this->features ){
+ self::OutputAdd( $strs, ' ' );
+ $this->features->genCSS( $env, $strs );
+ }
+ self::OutputAdd( $strs, ';' );
+ }
+ }
+
+ function toCSS($env = null){
+ $features = $this->features ? ' ' . $this->features->toCSS($env) : '';
+
+ if ($this->css) {
+ return "@import " . $this->path->toCSS() . $features . ";\n";
+ } else {
+ return "";
+ }
+ }
+
+ function getPath(){
+ if ($this->path instanceof Less_Tree_Quoted) {
+ $path = $this->path->value;
+ return ( isset($this->css) || preg_match('/(\.[a-z]*$)|([\?;].*)$/',$path)) ? $path : $path . '.less';
+ } else if ($this->path instanceof Less_Tree_URL) {
+ return $this->path->value->value;
+ }
+ return null;
+ }
+
+ function compileForImport( $env ){
+ return new Less_Tree_Import( $this->path->compile($env), $this->features, $this->options, $this->index, $this->currentFileInfo);
+ }
+
+ function compilePath($env) {
+ $path = $this->path->compile($env);
+ $rootpath = '';
+ if( $this->currentFileInfo && $this->currentFileInfo['rootpath'] ){
+ $rootpath = $this->currentFileInfo['rootpath'];
+ }
+
+
+ if( !($path instanceof Less_Tree_URL) ){
+ if( $rootpath ){
+ $pathValue = $path->value;
+ // Add the base path if the import is relative
+ if( $pathValue && Less_Environment::isPathRelative($pathValue) ){
+ $path->value = $this->currentFileInfo['uri_root'].$pathValue;
+ }
+ }
+ $path->value = Less_Environment::normalizePath($path->value);
+ }
+
+ return $path;
+ }
+
+ function compile($env) {
+
+ $evald = $this->compileForImport($env);
+ $uri = $full_path = false;
+
+ //get path & uri
+ $evald_path = $evald->getPath();
+ if( $evald_path ){
+ foreach(Less_Parser::$import_dirs as $rootpath => $rooturi){
+ if( is_callable($rooturi) ){
+ list($path, $uri) = call_user_func($rooturi, $evald_path);
+ if( null !== $path ){
+ $full_path = $path;
+ break;
+ }
+ }else{
+ $path = $rootpath.$evald_path;
+ if( file_exists($path) ){
+ $full_path = Less_Environment::normalizePath($path);
+ $uri = Less_Environment::normalizePath(dirname($rooturi.$evald_path));
+ break;
+ }
+ }
+ }
+ }
+
+ if( !$full_path ){
+ $uri = $evald_path;
+ $full_path = $evald_path;
+ }
+
+ //import once
+ $realpath = realpath($full_path);
+
+
+ if( $realpath && Less_Parser::FileParsed($realpath) ){
+ if( isset($this->currentFileInfo['reference']) ){
+ $evald->skip = true;
+ }elseif( !isset($evald->options['multiple']) && !$env->importMultiple ){
+ $evald->skip = true;
+ }
+ }
+
+ $features = ( $evald->features ? $evald->features->compile($env) : null );
+
+ if( $evald->skip ){
+ return array();
+ }
+
+
+ if( $this->options['inline'] ){
+ //todo needs to reference css file not import
+ //$contents = new Less_Tree_Anonymous($this->root, 0, array('filename'=>$this->importedFilename), true );
+
+ Less_Parser::AddParsedFile($full_path);
+ $contents = new Less_Tree_Anonymous( file_get_contents($full_path), 0, array(), true );
+
+ if( $this->features ){
+ return new Less_Tree_Media( array($contents), $this->features->value );
+ }
+
+ return array( $contents );
+
+ }elseif( $evald->css ){
+ $temp = $this->compilePath( $env);
+ return new Less_Tree_Import( $this->compilePath( $env), $features, $this->options, $this->index);
+ }
+
+
+ // options
+ $import_env = clone $env;
+ if( (isset($this->options['reference']) && $this->options['reference']) || isset($this->currentFileInfo['reference']) ){
+ $import_env->currentFileInfo['reference'] = true;
+ }
+
+ if( (isset($this->options['multiple']) && $this->options['multiple']) ){
+ $import_env->importMultiple = true;
+ }
+
+ $parser = new Less_Parser($import_env);
+ $evald->root = $parser->parseFile($full_path, $uri, true);
+
+
+ $ruleset = new Less_Tree_Ruleset(array(), $evald->root->rules );
+ $ruleset->evalImports($import_env);
+
+ return $this->features ? new Less_Tree_Media($ruleset->rules, $this->features->value) : $ruleset->rules;
+ }
+}
+
diff --git a/lib/Less/Tree/Javascript.php b/lib/Less/Tree/Javascript.php
new file mode 100644
index 0000000000000..a32f15477fa44
--- /dev/null
+++ b/lib/Less/Tree/Javascript.php
@@ -0,0 +1,24 @@
+escaped = $escaped;
+ $this->expression = $string;
+ $this->index = $index;
+ }
+
+ public function compile($env){
+ return $this;
+ }
+
+ function genCSS( $env, &$strs ){
+ self::OutputAdd( $strs, '/* Sorry, can not do JavaScript evaluation in PHP... :( */' );
+ }
+
+ public function toCSS($env = null){
+ return Less_Environment::$compress ? '' : '/* Sorry, can not do JavaScript evaluation in PHP... :( */';
+ }
+}
diff --git a/lib/Less/Tree/Keyword.php b/lib/Less/Tree/Keyword.php
new file mode 100644
index 0000000000000..1749e7ea4a818
--- /dev/null
+++ b/lib/Less/Tree/Keyword.php
@@ -0,0 +1,27 @@
+value = $value;
+ }
+
+ public function compile($env){
+ return $this;
+ }
+
+ public function genCSS( $env, &$strs ){
+ self::OutputAdd( $strs, $this->value );
+ }
+
+ public function compare($other) {
+ if ($other instanceof Less_Tree_Keyword) {
+ return $other->value === $this->value ? 0 : 1;
+ } else {
+ return -1;
+ }
+ }
+}
diff --git a/lib/Less/Tree/Media.php b/lib/Less/Tree/Media.php
new file mode 100644
index 0000000000000..259b0dfee245b
--- /dev/null
+++ b/lib/Less/Tree/Media.php
@@ -0,0 +1,166 @@
+index = $index;
+ $this->currentFileInfo = $currentFileInfo;
+
+ $selectors = $this->emptySelectors();
+
+ $this->features = new Less_Tree_Value($features);
+
+ $this->rules = array(new Less_Tree_Ruleset($selectors, $value));
+ $this->rules[0]->allowImports = true;
+ }
+
+ function accept( $visitor ){
+ $this->features = $visitor->visitObj($this->features);
+ $this->rules = $visitor->visitArray($this->rules);
+ }
+
+ function genCSS( $env, &$strs ){
+
+ self::OutputAdd( $strs, '@media ', $this->currentFileInfo, $this->index );
+ $this->features->genCSS( $env, $strs );
+ Less_Tree::outputRuleset( $env, $strs, $this->rules);
+
+ }
+
+ public function compile($env) {
+
+ $media = new Less_Tree_Media(array(), array(), $this->index, $this->currentFileInfo );
+
+ $strictMathBypass = false;
+ if( $env->strictMath === false) {
+ $strictMathBypass = true;
+ $env->strictMath = true;
+ }
+ try {
+ $media->features = $this->features->compile($env);
+ }catch(Exception $e){}
+
+ if( $strictMathBypass ){
+ $env->strictMath = false;
+ }
+
+ $env->mediaPath[] = $media;
+ $env->mediaBlocks[] = $media;
+
+ array_unshift($env->frames, $this->rules[0]);
+ $media->rules = array($this->rules[0]->compile($env));
+ array_shift($env->frames);
+
+ array_pop($env->mediaPath);
+
+ return !$env->mediaPath ? $media->compileTop($env) : $media->compileNested($env);
+ }
+
+ public function variable($name) {
+ return $this->rules[0]->variable($name);
+ }
+
+ public function find($selector) {
+ return $this->rules[0]->find($selector, $this);
+ }
+
+ public function emptySelectors(){
+ $el = new Less_Tree_Element('','&', $this->index, $this->currentFileInfo );
+ return array( new Less_Tree_Selector(array($el), array(), null, $this->index, $this->currentFileInfo) );
+ }
+
+ public function markReferenced(){
+ $this->isReferenced = true;
+ foreach($this->rules[0]->rules as $rule){
+ if( Less_Parser::is_method($rule,'markReferenced') ){
+ $rule->markReferenced();
+ }
+ }
+ }
+
+ // evaltop
+ public function compileTop($env) {
+ $result = $this;
+
+ if (count($env->mediaBlocks) > 1) {
+ $selectors = $this->emptySelectors();
+ $result = new Less_Tree_Ruleset($selectors, $env->mediaBlocks);
+ $result->multiMedia = true;
+ }
+
+ $env->mediaBlocks = array();
+ $env->mediaPath = array();
+
+ return $result;
+ }
+
+ public function compileNested($env) {
+ $path = array_merge($env->mediaPath, array($this));
+
+ // Extract the media-query conditions separated with `,` (OR).
+ foreach ($path as $key => $p) {
+ $value = $p->features instanceof Less_Tree_Value ? $p->features->value : $p->features;
+ $path[$key] = is_array($value) ? $value : array($value);
+ }
+
+ // Trace all permutations to generate the resulting media-query.
+ //
+ // (a, b and c) with nested (d, e) ->
+ // a and d
+ // a and e
+ // b and c and d
+ // b and c and e
+
+ $permuted = $this->permute($path);
+ $expressions = array();
+ foreach($permuted as $path){
+
+ for( $i=0, $len=count($path); $i < $len; $i++){
+ $path[$i] = Less_Parser::is_method($path[$i], 'toCSS') ? $path[$i] : new Less_Tree_Anonymous($path[$i]);
+ }
+
+ for( $i = count($path) - 1; $i > 0; $i-- ){
+ array_splice($path, $i, 0, array(new Less_Tree_Anonymous('and')));
+ }
+
+ $expressions[] = new Less_Tree_Expression($path);
+ }
+ $this->features = new Less_Tree_Value($expressions);
+
+
+
+ // Fake a tree-node that doesn't output anything.
+ return new Less_Tree_Ruleset(array(), array());
+ }
+
+ public function permute($arr) {
+ if (!$arr)
+ return array();
+
+ if (count($arr) == 1)
+ return $arr[0];
+
+ $result = array();
+ $rest = $this->permute(array_slice($arr, 1));
+ foreach ($rest as $r) {
+ foreach ($arr[0] as $a) {
+ $result[] = array_merge(
+ is_array($a) ? $a : array($a),
+ is_array($r) ? $r : array($r)
+ );
+ }
+ }
+
+ return $result;
+ }
+
+ function bubbleSelectors($selectors) {
+ $this->rules = array(new Less_Tree_Ruleset( $selectors, array($this->rules[0])));
+ }
+
+}
diff --git a/lib/Less/Tree/Mixin/Call.php b/lib/Less/Tree/Mixin/Call.php
new file mode 100644
index 0000000000000..c8475b3c71d4a
--- /dev/null
+++ b/lib/Less/Tree/Mixin/Call.php
@@ -0,0 +1,145 @@
+selector = new Less_Tree_Selector($elements);
+ $this->arguments = $args;
+ $this->index = $index;
+ $this->currentFileInfo = $currentFileInfo;
+ $this->important = $important;
+ }
+
+ //function accept($visitor){
+ // $this->selector = $visitor->visit($this->selector);
+ // $this->arguments = $visitor->visit($this->arguments);
+ //}
+
+
+ /**
+ * less.js: tree.mixin.Call.prototype()
+ *
+ */
+ public function compile($env){
+
+ $rules = array();
+ $match = false;
+ $isOneFound = false;
+
+ $args = array();
+ foreach($this->arguments as $a){
+ $args[] = array('name'=> $a['name'], 'value' => $a['value']->compile($env) );
+ }
+
+ foreach($env->frames as $frame){
+ $mixins = $frame->find($this->selector, null, $env);
+
+ if( !$mixins ){
+ continue;
+ }
+
+ $isOneFound = true;
+ $mixins_len = count($mixins);
+ for( $m = 0; $m < $mixins_len; $m++ ){
+ $mixin = $mixins[$m];
+
+ $isRecursive = false;
+ foreach($env->frames as $recur_frame){
+ if( !($mixin instanceof Less_Tree_Mixin_Definition) ){
+ if( (isset($recur_frame->originalRuleset) && $mixin->ruleset_id === $recur_frame->originalRuleset)
+ || ($mixin === $recur_frame) ){
+ $isRecursive = true;
+ break;
+ }
+ }
+ }
+ if( $isRecursive ){
+ continue;
+ }
+
+ if ($mixin->matchArgs($args, $env)) {
+
+ //if( !($mixin instanceof Less_Tree_Ruleset || $mixin instanceof Less_Tree_Mixin_Definition) || $mixin->matchCondition($args, $env) ){
+ if( !Less_Parser::is_method($mixin,'matchCondition') || $mixin->matchCondition($args, $env) ){
+ try{
+
+ if( !($mixin instanceof Less_Tree_Mixin_Definition) ){
+ $mixin = new Less_Tree_Mixin_Definition('', array(), $mixin->rules, null, false);
+ $mixin->originalRuleset = $mixins[$m]->originalRuleset;
+ }
+ //if (this.important) {
+ // isImportant = env.isImportant;
+ // env.isImportant = true;
+ //}
+
+ $rules = array_merge($rules, $mixin->compile($env, $args, $this->important)->rules);
+ //if (this.important) {
+ // env.isImportant = isImportant;
+ //}
+ } catch (Exception $e) {
+ //throw new Less_Exception_Compiler($e->getMessage(), $e->index, null, $this->currentFileInfo['filename']);
+ throw new Less_Exception_Compiler($e->getMessage(), null, null, $this->currentFileInfo['filename']);
+ }
+ }
+ $match = true;
+ }
+
+ }
+
+ if( $match ){
+ if( !$this->currentFileInfo || !isset($this->currentFileInfo['reference']) || !$this->currentFileInfo['reference'] ){
+ foreach($rules as $rule){
+ if( Less_Parser::is_method($rule,'markReferenced') ){
+ $rule->markReferenced();
+ }
+ }
+ }
+ return $rules;
+ }
+ }
+
+
+ if( $isOneFound ){
+
+ $message = array();
+ if( $args ){
+ foreach($args as $a){
+ $argValue = '';
+ if( $a['name'] ){
+ $argValue += $a['name']+':';
+ }
+ if( is_object($a['value']) ){
+ $argValue += $a['value']->toCSS();
+ }else{
+ $argValue += '???';
+ }
+ $message[] = $argValue;
+ }
+ }
+ $message = implode(', ',$message);
+
+
+ throw new Less_Exception_Compiler('No matching definition was found for `'.
+ trim($this->selector->toCSS($env)) . '(' .$message.')',
+ $this->index, null, $this->currentFileInfo['filename']);
+
+ }else{
+ throw new Less_Exception_Compiler(trim($this->selector->toCSS($env)) . " is undefined", $this->index);
+ }
+ }
+}
+
+
diff --git a/lib/Less/Tree/Mixin/Definition.php b/lib/Less/Tree/Mixin/Definition.php
new file mode 100644
index 0000000000000..8476815c92df2
--- /dev/null
+++ b/lib/Less/Tree/Mixin/Definition.php
@@ -0,0 +1,231 @@
+name = $name;
+ $this->selectors = array(new Less_Tree_Selector(array( new Less_Tree_Element(null, $name))));
+
+ $this->params = $params;
+ $this->condition = $condition;
+ $this->variadic = $variadic;
+ $this->arity = count($params);
+ $this->rules = $rules;
+ $this->lookups = array();
+
+ $this->required = 0;
+ if( is_array($params) ){
+ foreach( $params as $p ){
+ if (! isset($p['name']) || ($p['name'] && !isset($p['value']))) {
+ $this->required++;
+ }
+ }
+ }
+
+ $this->frames = array();
+ $this->SetRulesetIndex();
+ }
+
+
+
+ //function accept( $visitor ){
+ // $this->params = $visitor->visit($this->params);
+ // $this->rules = $visitor->visit($this->rules);
+ // $this->condition = $visitor->visit($this->condition);
+ //}
+
+
+ public function toCSS($env = null){
+ return '';
+ }
+
+ // less.js : /lib/less/tree/mixin.js : tree.mixin.Definition.evalParams
+ public function compileParams($env, $mixinEnv, $args = array() , &$evaldArguments = array() ){
+ $frame = new Less_Tree_Ruleset(null, array());
+ $varargs;
+ $params = $this->params;
+ $val;
+ $name;
+ $isNamedFound;
+
+
+ $mixinEnv = clone $mixinEnv;
+ $mixinEnv->frames = array_merge( array($frame), $mixinEnv->frames);
+ //$mixinEnv = $mixinEnv->copyEvalEnv( array_merge( array($frame), $mixinEnv->frames) );
+
+ $args_len = count($args);
+ for($i = 0; $i < $args_len; $i++ ){
+ $arg = $args[$i];
+
+ if( $arg && $arg['name'] ){
+ $name = $arg['name'];
+ $isNamedFound = false;
+
+ foreach($params as $j => $param){
+ if( !isset($evaldArguments[$j]) && $name === $params[$j]['name']) {
+ $evaldArguments[$j] = $arg['value']->compile($env);
+ array_unshift($frame->rules, new Less_Tree_Rule( $name, $arg['value']->compile($env) ) );
+ $isNamedFound = true;
+ break;
+ }
+ }
+ if ($isNamedFound) {
+ array_splice($args, $i, 1);
+ $i--;
+ $args_len--;
+ continue;
+ } else {
+ throw new Less_Exception_Compiler("Named argument for " . $this->name .' '.$args[$i]['name'] . ' not found');
+ }
+ }
+ }
+
+ $argIndex = 0;
+ foreach($params as $i => $param){
+
+ if ( isset($evaldArguments[$i]) ){ continue; }
+
+ $arg = null;
+ if( array_key_exists($argIndex,$args) && $args[$argIndex] ){
+ $arg = $args[$argIndex];
+ }
+
+ if (isset($param['name']) && $param['name']) {
+ $name = $param['name'];
+
+ if( isset($param['variadic']) && $args ){
+ $varargs = array();
+ for ($j = $argIndex; $j < $args_len; $j++) {
+ $varargs[] = $args[$j]['value']->compile($env);
+ }
+ $expression = new Less_Tree_Expression($varargs);
+ array_unshift($frame->rules, new Less_Tree_Rule($param['name'], $expression->compile($env)));
+ }else{
+ $val = ($arg && $arg['value']) ? $arg['value'] : false;
+
+ if ($val) {
+ $val = $val->compile($env);
+ } else if ( isset($param['value']) ) {
+ $val = $param['value']->compile($mixinEnv);
+ $frame->resetCache();
+ } else {
+ throw new Less_Exception_Compiler("Wrong number of arguments for " . $this->name . " (" . count($args) . ' for ' . $this->arity . ")");
+ }
+
+ array_unshift($frame->rules, new Less_Tree_Rule($param['name'], $val));
+ $evaldArguments[$i] = $val;
+ }
+ }
+
+ if ( isset($param['variadic']) && $args) {
+ for ($j = $argIndex; $j < $args_len; $j++) {
+ $evaldArguments[$j] = $args[$j]['value']->compile($env);
+ }
+ }
+ $argIndex++;
+ }
+
+ asort($evaldArguments);
+
+ return $frame;
+ }
+
+ // less.js : /lib/less/tree/mixin.js : tree.mixin.Definition.eval
+ public function compile($env, $args = NULL, $important = NULL) {
+ $_arguments = array();
+
+ $mixinFrames = array_merge($this->frames, $env->frames);
+
+ $mixinEnv = new Less_Environment();
+ $mixinEnv->addFrames($mixinFrames);
+
+ $frame = $this->compileParams($env, $mixinEnv, $args, $_arguments);
+
+
+
+ $ex = new Less_Tree_Expression($_arguments);
+ array_unshift($frame->rules, new Less_Tree_Rule('@arguments', $ex->compile($env)));
+
+
+ $rules = array_slice($this->rules,0);
+
+ $ruleset = new Less_Tree_Ruleset(null, $rules);
+ $ruleset->originalRuleset = $this->ruleset_id;
+
+
+ $ruleSetEnv = $env->copyEvalEnv( array_merge( array($this, $frame), $mixinFrames ) );
+ $ruleset = $ruleset->compile( $ruleSetEnv );
+
+ if( $important ){
+ $ruleset = $ruleset->makeImportant();
+ }
+ return $ruleset;
+ }
+
+
+ public function matchCondition($args, $env) {
+
+ if( !$this->condition ){
+ return true;
+ }
+
+ $frame = $this->compileParams($env, $env->copyEvalEnv(array_merge($this->frames,$env->frames)), $args );
+
+ $compile_env = $env->copyEvalEnv(
+ array_merge(
+ array($frame) // the parameter variables
+ , $this->frames // the parent namespace/mixin frames
+ , $env->frames // the current environment frames
+ )
+ );
+
+ if( !$this->condition->compile($compile_env) ){
+ return false;
+ }
+
+ return true;
+ }
+
+ public function matchArgs($args, $env = NULL){
+ $argsLength = count($args);
+
+ if( !$this->variadic ){
+ if( $argsLength < $this->required ){
+ return false;
+ }
+ if( $argsLength > count($this->params) ){
+ return false;
+ }
+ }else{
+ if( $argsLength < ($this->required - 1)){
+ return false;
+ }
+ }
+
+ $len = min($argsLength, $this->arity);
+
+ for( $i = 0; $i < $len; $i++ ){
+ if( !isset($this->params[$i]['name']) && !isset($this->params[$i]['variadic']) ){
+ if( $args[$i]['value']->compile($env)->toCSS() != $this->params[$i]['value']->compile($env)->toCSS() ){
+ return false;
+ }
+ }
+ }
+
+ return true;
+ }
+
+}
diff --git a/lib/Less/Tree/Negative.php b/lib/Less/Tree/Negative.php
new file mode 100644
index 0000000000000..42d4c626aef6c
--- /dev/null
+++ b/lib/Less/Tree/Negative.php
@@ -0,0 +1,29 @@
+value = $node;
+ }
+
+ //function accept($visitor) {
+ // $this->value = $visitor->visit($this->value);
+ //}
+
+ function genCSS( $env, &$strs ){
+ self::OutputAdd( $strs, '-' );
+ $this->value->genCSS( $env, $strs );
+ }
+
+ function compile($env) {
+ if( $env->isMathOn() ){
+ $ret = new Less_Tree_Operation('*', array( new Less_Tree_Dimension(-1), $this->value ) );
+ return $ret->compile($env);
+ }
+ return new Less_Tree_Negative( $this->value->compile($env) );
+ }
+}
\ No newline at end of file
diff --git a/lib/Less/Tree/Operation.php b/lib/Less/Tree/Operation.php
new file mode 100644
index 0000000000000..5d67e7967ec6d
--- /dev/null
+++ b/lib/Less/Tree/Operation.php
@@ -0,0 +1,58 @@
+op = trim($op);
+ $this->operands = $operands;
+ $this->isSpaced = $isSpaced;
+ }
+
+ function accept($visitor) {
+ $this->operands = $visitor->visitArray($this->operands);
+ }
+
+ public function compile($env){
+ $a = $this->operands[0]->compile($env);
+ $b = $this->operands[1]->compile($env);
+
+
+ if( $env->isMathOn() ){
+
+ if( $a instanceof Less_Tree_Dimension ){
+
+ if( $b instanceof Less_Tree_Color ){
+ if ($this->op === '*' || $this->op === '+') {
+ $temp = $b;
+ $b = $a;
+ $a = $temp;
+ } else {
+ throw new Less_Exception_Compiler("Operation on an invalid type");
+ }
+ }
+ }elseif( !($a instanceof Less_Tree_Color) ){
+ throw new Less_Exception_Compiler("Operation on an invalid type");
+ }
+
+ return $a->operate($env,$this->op, $b);
+ } else {
+ return new Less_Tree_Operation($this->op, array($a, $b), $this->isSpaced );
+ }
+ }
+
+ function genCSS( $env, &$strs ){
+ $this->operands[0]->genCSS( $env, $strs );
+ if( $this->isSpaced ){
+ self::OutputAdd( $strs, " " );
+ }
+ self::OutputAdd( $strs, $this->op );
+ if( $this->isSpaced ){
+ self::OutputAdd( $strs, ' ' );
+ }
+ $this->operands[1]->genCSS( $env, $strs );
+ }
+
+}
diff --git a/lib/Less/Tree/Paren.php b/lib/Less/Tree/Paren.php
new file mode 100644
index 0000000000000..aab1337b6049b
--- /dev/null
+++ b/lib/Less/Tree/Paren.php
@@ -0,0 +1,26 @@
+value = $value;
+ }
+
+ function accept($visitor){
+ $this->value = $visitor->visitObj($this->value);
+ }
+
+ function genCSS( $env, &$strs ){
+ self::OutputAdd( $strs, '(' );
+ $this->value->genCSS( $env, $strs );
+ self::OutputAdd( $strs, ')' );
+ }
+
+ public function compile($env) {
+ return new Less_Tree_Paren($this->value->compile($env));
+ }
+
+}
diff --git a/lib/Less/Tree/Quoted.php b/lib/Less/Tree/Quoted.php
new file mode 100644
index 0000000000000..26a67d9c8908b
--- /dev/null
+++ b/lib/Less/Tree/Quoted.php
@@ -0,0 +1,67 @@
+escaped = $escaped;
+ $this->value = $content;
+ $this->quote = $str[0];
+ $this->index = $index;
+ $this->currentFileInfo = $currentFileInfo;
+ }
+
+ public function genCSS( $env, &$strs ){
+ if( !$this->escaped ){
+ self::OutputAdd( $strs, $this->quote, $this->currentFileInfo, $this->index );
+ }
+ self::OutputAdd( $strs, $this->value );
+ if( !$this->escaped ){
+ self::OutputAdd( $strs, $this->quote );
+ }
+ }
+
+ public function compile($env){
+
+ $value = $this->value;
+ if( preg_match_all('/`([^`]+)`/', $this->value, $matches) ){
+ foreach($matches as $i => $match){
+ $js = new Less_Tree_JavaScript($matches[1], $this->index, true);
+ $js = $js->compile($env)->value;
+ $value = str_replace($matches[0][$i], $js, $value);
+ }
+ }
+
+ if( preg_match_all('/@\{([\w-]+)\}/',$value,$matches) ){
+ foreach($matches[1] as $i => $match){
+ $v = new Less_Tree_Variable('@' . $match, $this->index, $this->currentFileInfo );
+ $v = $v->compile($env,true);
+ $v = ($v instanceof Less_Tree_Quoted) ? $v->value : $v->toCSS($env);
+ $value = str_replace($matches[0][$i], $v, $value);
+ }
+ }
+
+ return new Less_Tree_Quoted($this->quote . $value . $this->quote, $value, $this->escaped, $this->index);
+ }
+
+ function compare($x) {
+
+ if( !Less_Parser::is_method($x, 'toCSS') ){
+ return -1;
+ }
+
+ $left = $this->toCSS();
+ $right = $x->toCSS();
+
+ if ($left === $right) {
+ return 0;
+ }
+
+ return $left < $right ? -1 : 1;
+ }
+}
diff --git a/lib/Less/Tree/Rule.php b/lib/Less/Tree/Rule.php
new file mode 100644
index 0000000000000..4d3748fe6734d
--- /dev/null
+++ b/lib/Less/Tree/Rule.php
@@ -0,0 +1,73 @@
+name = $name;
+ $this->value = ($value instanceof Less_Tree_Value) ? $value : new Less_Tree_Value(array($value));
+ $this->important = $important ? ' ' . trim($important) : '';
+ $this->merge = $merge;
+ $this->index = $index;
+ $this->currentFileInfo = $currentFileInfo;
+ $this->inline = $inline;
+ $this->variable = ($name[0] === '@');
+ }
+
+ function accept($visitor) {
+ $this->value = $visitor->visitObj( $this->value );
+ }
+
+ function genCSS( $env, &$strs ){
+
+ self::OutputAdd( $strs, $this->name . Less_Environment::$colon_space, $this->currentFileInfo, $this->index);
+ try{
+ $this->value->genCSS($env, $strs);
+
+ }catch( Exception $e ){
+ $e->index = $this->index;
+ $e->filename = $this->currentFileInfo['filename'];
+ throw $e;
+ }
+ self::OutputAdd( $strs, $this->important . (($this->inline || ($env->lastRule && Less_Environment::$compress)) ? "" : ";"), $this->currentFileInfo, $this->index);
+ }
+
+ public function compile ($env){
+
+ $return = null;
+ $strictMathBypass = false;
+ if( $this->name === "font" && !$env->strictMath ){
+ $strictMathBypass = true;
+ $env->strictMath = true;
+ }
+
+ $return = new Less_Tree_Rule($this->name,
+ $this->value->compile($env),
+ $this->important,
+ $this->merge,
+ $this->index,
+ $this->currentFileInfo,
+ $this->inline);
+
+ if( $strictMathBypass ){
+ $env->strictMath = false;
+ }
+
+ return $return;
+ }
+
+ function makeImportant(){
+ return new Less_Tree_Rule($this->name, $this->value, '!important', $this->merge, $this->index, $this->currentFileInfo, $this->inline);
+ }
+
+}
diff --git a/lib/Less/Tree/Ruleset.php b/lib/Less/Tree/Ruleset.php
new file mode 100644
index 0000000000000..4bc875bd04681
--- /dev/null
+++ b/lib/Less/Tree/Ruleset.php
@@ -0,0 +1,535 @@
+ruleset_id = Less_Parser::$next_id++;
+ $this->originalRuleset = $this->ruleset_id;
+ }
+
+ public function __construct($selectors, $rules, $strictImports = null){
+ $this->selectors = $selectors;
+ $this->rules = $rules;
+ $this->lookups = array();
+ $this->strictImports = $strictImports;
+ $this->SetRulesetIndex();
+ }
+
+ function accept( $visitor ){
+ if( $this->paths ){
+ $paths_len = count($this->paths);
+ for($i = 0,$paths_len; $i < $paths_len; $i++ ){
+ $this->paths[$i] = $visitor->visitArray($this->paths[$i]);
+ }
+ }elseif( $this->selectors ){
+ $this->selectors = $visitor->visitArray($this->selectors);
+ }
+
+ if( $this->rules ){
+ $this->rules = $visitor->visitArray($this->rules);
+ }
+ }
+
+ public function compile($env){
+
+ $selectors = array();
+ if( $this->selectors ){
+ foreach($this->selectors as $s){
+ $selectors[] = $s->compile($env);
+ }
+ }
+ $ruleset = new Less_Tree_Ruleset($selectors, $this->rules, $this->strictImports);
+ $rules = array();
+
+ $ruleset->originalRuleset = $this->ruleset_id;
+
+ $ruleset->root = $this->root;
+ $ruleset->firstRoot = $this->firstRoot;
+ $ruleset->allowImports = $this->allowImports;
+
+ // push the current ruleset to the frames stack
+ $env->unshiftFrame($ruleset);
+
+ // currrent selectors
+ array_unshift($env->selectors,$this->selectors);
+
+
+ // Evaluate imports
+ if ($ruleset->root || $ruleset->allowImports || !$ruleset->strictImports) {
+ $ruleset->evalImports($env);
+ }
+
+
+ // Store the frames around mixin definitions,
+ // so they can be evaluated like closures when the time comes.
+ $ruleset_len = count($ruleset->rules);
+ for( $i = 0; $i < $ruleset_len; $i++ ){
+ if( $ruleset->rules[$i] instanceof Less_Tree_Mixin_Definition ){
+ $ruleset->rules[$i]->frames = array_slice($env->frames,0);
+ }
+ }
+
+ $mediaBlockCount = 0;
+ if( $env instanceof Less_Environment ){
+ $mediaBlockCount = count($env->mediaBlocks);
+ }
+
+ // Evaluate mixin calls.
+ for($i=0; $i < $ruleset_len; $i++){
+ $rule = $ruleset->rules[$i];
+ if( $rule instanceof Less_Tree_Mixin_Call ){
+ $rules = $rule->compile($env);
+
+ $temp = array();
+ foreach($rules as $r){
+ if( ($r instanceof Less_Tree_Rule) && $r->variable ){
+ // do not pollute the scope if the variable is
+ // already there. consider returning false here
+ // but we need a way to "return" variable from mixins
+ if( !$ruleset->variable($r->name) ){
+ $temp[] = $r;
+ }
+ }else{
+ $temp[] = $r;
+ }
+ }
+ $temp_count = count($temp)-1;
+ array_splice($ruleset->rules, $i, 1, $temp);
+ $ruleset_len += $temp_count;
+ $i += $temp_count;
+ $ruleset->resetCache();
+ }
+ }
+
+
+ for( $i=0; $i<$ruleset_len; $i++ ){
+ if(! ($ruleset->rules[$i] instanceof Less_Tree_Mixin_Definition) ){
+ $ruleset->rules[$i] = $ruleset->rules[$i]->compile($env);
+ }
+ }
+
+
+ // Pop the stack
+ $env->shiftFrame();
+ array_shift($env->selectors);
+
+ if ($mediaBlockCount) {
+ $len = count($env->mediaBlocks);
+ for($i = $mediaBlockCount; $i < $len; $i++ ){
+ $env->mediaBlocks[$i]->bubbleSelectors($selectors);
+ }
+ }
+
+ return $ruleset;
+ }
+
+ function evalImports($env) {
+
+ $rules_len = count($this->rules);
+ for($i=0; $i < $rules_len; $i++){
+ $rule = $this->rules[$i];
+
+ if( $rule instanceof Less_Tree_Import ){
+ $rules = $rule->compile($env);
+ if( is_array($rules) ){
+ array_splice($this->rules, $i, 1, $rules);
+ $temp_count = count($rules)-1;
+ $i += $temp_count;
+ $rules_len += $temp_count;
+ }else{
+ array_splice($this->rules, $i, 1, array($rules));
+ }
+
+ $this->resetCache();
+ }
+ }
+ }
+
+ function makeImportant(){
+
+ $important_rules = array();
+ foreach($this->rules as $rule){
+ if( $rule instanceof Less_Tree_Rule || $rule instanceof Less_Tree_Ruleset ){
+ $important_rules[] = $rule->makeImportant();
+ }else{
+ $important_rules[] = $rule;
+ }
+ }
+
+ return new Less_Tree_Ruleset($this->selectors, $important_rules, $this->strictImports );
+ }
+
+ public function matchArgs($args){
+ return !is_array($args) || !$args;
+ }
+
+ public function matchCondition( $args, $env ){
+ $lastSelector = end($this->selectors);
+ if( $lastSelector->condition && !$lastSelector->condition->compile( $env->copyEvalEnv( $env->frames ) ) ){
+ return false;
+ }
+ return true;
+ }
+
+ function resetCache() {
+ $this->_rulesets = null;
+ $this->_variables = null;
+ $this->lookups = array();
+ }
+
+ public function variables(){
+
+ if( !$this->_variables ){
+ $this->_variables = array();
+ foreach( $this->rules as $r){
+ if ($r instanceof Less_Tree_Rule && $r->variable === true) {
+ $this->_variables[$r->name] = $r;
+ }
+ }
+ }
+
+ return $this->_variables;
+ }
+
+ public function variable($name){
+ $vars = $this->variables();
+ return isset($vars[$name]) ? $vars[$name] : null;
+ }
+
+ public function find( $selector, $self = null, $env = null){
+
+ if( !$self ){
+ $self = $this->ruleset_id;
+ }
+
+ $key = $selector->toCSS($env);
+
+ if( !array_key_exists($key, $this->lookups) ){
+ $this->lookups[$key] = array();
+
+
+ foreach($this->rules as $rule){
+
+ if( ($rule instanceof Less_Tree_Ruleset) || ($rule instanceof Less_Tree_Mixin_Definition) ){
+
+ if( $rule->ruleset_id == $self ){
+ continue;
+ }
+
+ foreach( $rule->selectors as $ruleSelector ){
+ $match = $selector->match($ruleSelector);
+ if( $match ){
+ if( $selector->elements_len > $match ){
+ $this->lookups[$key] = array_merge($this->lookups[$key], $rule->find( new Less_Tree_Selector(array_slice($selector->elements, $match)), $self, $env));
+ } else {
+ $this->lookups[$key][] = $rule;
+ }
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ return $this->lookups[$key];
+ }
+
+ public function genCSS( $env, &$strs ){
+ $ruleNodes = array();
+ $rulesetNodes = array();
+ $firstRuleset = true;
+
+ if( !$this->root ){
+ $env->tabLevel++;
+ }
+
+ $tabRuleStr = $tabSetStr = '';
+ if( !Less_Environment::$compress && $env->tabLevel ){
+ $tabRuleStr = str_repeat( ' ' , $env->tabLevel );
+ $tabSetStr = str_repeat( ' ' , $env->tabLevel-1 );
+ }
+
+ foreach($this->rules as $rule){
+
+ $class = get_class($rule);
+ if( ($class === 'Less_Tree_Media') || ($class === 'Less_Tree_Directive') || ($this->root && $class === 'Less_Tree_Comment') || ($class === 'Less_Tree_Ruleset' && $rule->rules) ){
+ $rulesetNodes[] = $rule;
+ }else{
+ $ruleNodes[] = $rule;
+ }
+ }
+
+ // If this is the root node, we don't render
+ // a selector, or {}.
+ if( !$this->root ){
+
+ /*
+ debugInfo = tree.debugInfo(env, this, tabSetStr);
+
+ if (debugInfo) {
+ output.add(debugInfo);
+ output.add(tabSetStr);
+ }
+ */
+
+ for( $i = 0,$paths_len = count($this->paths); $i < $paths_len; $i++ ){
+ $path = $this->paths[$i];
+ Less_Environment::$firstSelector = true;
+ foreach($path as $p){
+ $p->genCSS($env, $strs );
+ Less_Environment::$firstSelector = false;
+ }
+ if( $i + 1 < $paths_len ){
+ self::OutputAdd( $strs, Less_Environment::$compress ? ',' : (",\n" . $tabSetStr) );
+ }
+ }
+
+ self::OutputAdd( $strs, (Less_Environment::$compress ? '{' : " {\n") . $tabRuleStr );
+ }
+
+ // Compile rules and rulesets
+ $ruleNodes_len = count($ruleNodes);
+ $rulesetNodes_len = count($rulesetNodes);
+ for( $i = 0; $i < $ruleNodes_len; $i++ ){
+ $rule = $ruleNodes[$i];
+
+ // @page{ directive ends up with root elements inside it, a mix of rules and rulesets
+ // In this instance we do not know whether it is the last property
+ if( $i + 1 === $ruleNodes_len && (!$this->root || $rulesetNodes_len === 0 || $this->firstRoot ) ){
+ $env->lastRule = true;
+ }
+
+ if( is_object($rule) ){
+ if( method_exists($rule,'genCSS') ){
+ $rule->genCSS( $env, $strs );
+ }elseif( property_exists($rule,'value') && $rule->value ){
+ self::OutputAdd( $strs, (string)$rule->value );
+ }
+ }
+
+ if( !$env->lastRule ){
+ self::OutputAdd( $strs, Less_Environment::$compress ? '' : ("\n" . $tabRuleStr) );
+ }else{
+ $env->lastRule = false;
+ }
+ }
+
+ if( !$this->root ){
+ self::OutputAdd( $strs, (Less_Environment::$compress ? '}' : "\n" . $tabSetStr . '}'));
+ $env->tabLevel--;
+ }
+
+ for( $i = 0; $i < $rulesetNodes_len; $i++ ){
+ if( $ruleNodes_len && $firstRuleset ){
+ self::OutputAdd( $strs, (Less_Environment::$compress ? "" : "\n") . ($this->root ? $tabRuleStr : $tabSetStr) );
+ }
+ if( !$firstRuleset ){
+ self::OutputAdd( $strs, (Less_Environment::$compress ? "" : "\n") . ($this->root ? $tabRuleStr : $tabSetStr));
+ }
+ $firstRuleset = false;
+ $rulesetNodes[$i]->genCSS($env, $strs);
+ }
+
+ if( !$strs && !Less_Environment::$compress && $this->firstRoot ){
+ self::OutputAdd( $strs, "\n" );
+ }
+
+ }
+
+ function markReferenced(){
+
+ foreach($this->selectors as $selector){
+ $selector->markReferenced();
+ }
+ }
+
+ public function joinSelectors( $context, $selectors ){
+ $paths = array();
+ if( is_array($selectors) ){
+ foreach($selectors as $selector) {
+ $this->joinSelector( $paths, $context, $selector);
+ }
+ }
+ return $paths;
+ }
+
+ public function joinSelector( &$paths, $context, $selector){
+
+ $hasParentSelector = false;
+
+ foreach($selector->elements as $el) {
+ if( $el->value === '&') {
+ $hasParentSelector = true;
+ }
+ }
+
+ if( !$hasParentSelector ){
+ if( $context ){
+ foreach($context as $context_el){
+ $paths[] = array_merge($context_el, array($selector) );
+ }
+ }else {
+ $paths[] = array($selector);
+ }
+ return;
+ }
+
+
+ // The paths are [[Selector]]
+ // The first list is a list of comma seperated selectors
+ // The inner list is a list of inheritance seperated selectors
+ // e.g.
+ // .a, .b {
+ // .c {
+ // }
+ // }
+ // == [[.a] [.c]] [[.b] [.c]]
+ //
+
+ // the elements from the current selector so far
+ $currentElements = array();
+ // the current list of new selectors to add to the path.
+ // We will build it up. We initiate it with one empty selector as we "multiply" the new selectors
+ // by the parents
+ $newSelectors = array(array());
+
+
+ foreach( $selector->elements as $el){
+
+ // non parent reference elements just get added
+ if( $el->value !== '&' ){
+ $currentElements[] = $el;
+ } else {
+ // the new list of selectors to add
+ $selectorsMultiplied = array();
+
+ // merge the current list of non parent selector elements
+ // on to the current list of selectors to add
+ if( $currentElements ){
+ $this->mergeElementsOnToSelectors( $currentElements, $newSelectors);
+ }
+
+ // loop through our current selectors
+ foreach($newSelectors as $sel){
+
+ // if we don't have any parent paths, the & might be in a mixin so that it can be used
+ // whether there are parents or not
+ if( !$context ){
+ // the combinator used on el should now be applied to the next element instead so that
+ // it is not lost
+ if( $sel ){
+ $sel[0]->elements = array_slice($sel[0]->elements,0);
+ $sel[0]->elements[] = new Less_Tree_Element($el->combinator, '', 0, $el->index, $el->currentFileInfo );
+ }
+ $selectorsMultiplied[] = $sel;
+ }else {
+
+ // and the parent selectors
+ foreach($context as $parentSel){
+ // We need to put the current selectors
+ // then join the last selector's elements on to the parents selectors
+
+ // our new selector path
+ $newSelectorPath = array();
+ // selectors from the parent after the join
+ $afterParentJoin = array();
+ $newJoinedSelectorEmpty = true;
+
+ //construct the joined selector - if & is the first thing this will be empty,
+ // if not newJoinedSelector will be the last set of elements in the selector
+ if( $sel ){
+ $newSelectorPath = $sel;
+ $lastSelector = array_pop($newSelectorPath);
+ $newJoinedSelector = $selector->createDerived( array_slice($lastSelector->elements,0) );
+ $newJoinedSelectorEmpty = false;
+ }
+ else {
+ $newJoinedSelector = $selector->createDerived(array());
+ }
+
+ //put together the parent selectors after the join
+ if ( count($parentSel) > 1) {
+ $afterParentJoin = array_merge($afterParentJoin, array_slice($parentSel,1) );
+ }
+
+ if ( $parentSel ){
+ $newJoinedSelectorEmpty = false;
+
+ // join the elements so far with the first part of the parent
+ $newJoinedSelector->elements[] = new Less_Tree_Element( $el->combinator, $parentSel[0]->elements[0]->value, 0, $el->index, $el->currentFileInfo);
+
+ $newJoinedSelector->elements = array_merge( $newJoinedSelector->elements, array_slice($parentSel[0]->elements, 1) );
+ }
+
+ if (!$newJoinedSelectorEmpty) {
+ // now add the joined selector
+ $newSelectorPath[] = $newJoinedSelector;
+ }
+
+ // and the rest of the parent
+ $newSelectorPath = array_merge($newSelectorPath, $afterParentJoin);
+
+ // add that to our new set of selectors
+ $selectorsMultiplied[] = $newSelectorPath;
+ }
+ }
+ }
+
+ // our new selectors has been multiplied, so reset the state
+ $newSelectors = $selectorsMultiplied;
+ $currentElements = array();
+ }
+ }
+
+ // if we have any elements left over (e.g. .a& .b == .b)
+ // add them on to all the current selectors
+ if( $currentElements ){
+ $this->mergeElementsOnToSelectors($currentElements, $newSelectors);
+ }
+ foreach( $newSelectors as $new_sel){
+ if( $new_sel ){
+ $paths[] = $new_sel;
+ }
+ }
+ }
+
+ function mergeElementsOnToSelectors( $elements, &$selectors){
+
+ if( !$selectors ){
+ $selectors[] = array( new Less_Tree_Selector($elements) );
+ return;
+ }
+
+
+ foreach( $selectors as &$sel){
+
+ // if the previous thing in sel is a parent this needs to join on to it
+ if( $sel ){
+ $last = count($sel)-1;
+ $sel[$last] = $sel[$last]->createDerived( array_merge($sel[$last]->elements, $elements) );
+ }else{
+ $sel[] = new Less_Tree_Selector( $elements );
+ }
+ }
+ }
+}
diff --git a/lib/Less/Tree/Selector.php b/lib/Less/Tree/Selector.php
new file mode 100644
index 0000000000000..2d2a8487c6273
--- /dev/null
+++ b/lib/Less/Tree/Selector.php
@@ -0,0 +1,128 @@
+elements = $elements;
+ $this->elements_len = count($elements);
+ if( $extendList ){
+ $this->extendList = $extendList;
+ }
+ $this->condition = $condition;
+ if( $currentFileInfo ){
+ $this->currentFileInfo = $currentFileInfo;
+ }
+ $this->isReferenced = $isReferenced;
+ if( !$condition ){
+ $this->evaldCondition = true;
+ }
+ }
+
+ function accept($visitor) {
+ $this->elements = $visitor->visitArray($this->elements);
+ $this->extendList = $visitor->visitArray($this->extendList);
+ if( $this->condition ){
+ $this->condition = $visitor->visitObj($this->condition);
+ }
+ }
+
+ function createDerived( $elements, $extendList = null, $evaldCondition = null ){
+ $evaldCondition = $evaldCondition != null ? $evaldCondition : $this->evaldCondition;
+ $newSelector = new Less_Tree_Selector( $elements, ($extendList ? $extendList : $this->extendList), $this->condition, $this->index, $this->currentFileInfo, $this->isReferenced);
+ $newSelector->evaldCondition = $evaldCondition;
+ return $newSelector;
+ }
+
+ public function match($other) {
+ global $debug;
+
+ if( !$other ){
+ return 0;
+ }
+
+ $offset = 0;
+ $olen = $other->elements_len;
+ if( $olen ){
+ if( $other->elements[0]->value === "&" ){
+ $offset = 1;
+ }
+ $olen -= $offset;
+ }
+
+ if( $olen === 0 ){
+ return 0;
+ }
+
+ if( $this->elements_len < $olen ){
+ return 0;
+ }
+
+ for ($i = 0; $i < $olen; $i ++) {
+ if ($this->elements[$i]->value !== $other->elements[$i + $offset]->value) {
+ return 0;
+ }
+ }
+
+ return $olen; // return number of matched selectors
+ }
+
+ public function compile($env) {
+
+ $elements = array();
+ foreach($this->elements as $el){
+ $elements[] = $el->compile($env);
+ }
+
+ $extendList = array();
+ foreach($this->extendList as $el){
+ $extendList[] = $el->compile($el);
+ }
+
+ $evaldCondition = false;
+ if( $this->condition ){
+ $evaldCondition = $this->condition->compile($env);
+ }
+
+ return $this->createDerived( $elements, $extendList, $evaldCondition );
+ }
+
+ function genCSS( $env, &$strs ){
+
+ if( !Less_Environment::$firstSelector && $this->elements[0]->combinator->value === "" ){
+ self::OutputAdd( $strs, ' ', $this->currentFileInfo, $this->index );
+ }
+ if( !$this->_css ){
+ //TODO caching? speed comparison?
+ foreach($this->elements as $element){
+ $element->genCSS( $env, $strs );
+ }
+ }
+ }
+
+ function markReferenced(){
+ $this->isReferenced = true;
+ }
+
+ function getIsReferenced(){
+ return !isset($this->currentFileInfo['reference']) || !$this->currentFileInfo['reference'] || $this->isReferenced;
+ }
+
+ function getIsOutput(){
+ return $this->evaldCondition;
+ }
+
+}
diff --git a/lib/Less/Tree/UnicodeDescriptor.php b/lib/Less/Tree/UnicodeDescriptor.php
new file mode 100644
index 0000000000000..52ff142c50250
--- /dev/null
+++ b/lib/Less/Tree/UnicodeDescriptor.php
@@ -0,0 +1,20 @@
+value = $value;
+ }
+
+ public function genCSS( $env, &$strs ){
+ self::OutputAdd( $strs, $this->value );
+ }
+
+ public function compile($env){
+ return $this;
+ }
+}
+
diff --git a/lib/Less/Tree/Unit.php b/lib/Less/Tree/Unit.php
new file mode 100644
index 0000000000000..fdb25d3e15724
--- /dev/null
+++ b/lib/Less/Tree/Unit.php
@@ -0,0 +1,130 @@
+numerator = $numerator;
+ $this->denominator = $denominator;
+ $this->backupUnit = $backupUnit;
+ }
+
+ function __clone(){
+ }
+
+ function genCSS( $env, &$strs ){
+
+ if( $this->numerator ){
+ self::OutputAdd( $strs, $this->numerator[0] );
+ }elseif( $this->denominator ){
+ self::OutputAdd( $strs, $this->denominator[0] );
+ }elseif( (!$env || !$env->strictUnits) && $this->backupUnit ){
+ self::OutputAdd( $strs, $this->backupUnit );
+ return ;
+ }
+ }
+
+ function toString(){
+ $returnStr = implode('*',$this->numerator);
+ foreach($this->denominator as $d){
+ $returnStr .= '/'.$d;
+ }
+ return $returnStr;
+ }
+
+ function compare($other) {
+ return $this->is( $other->toString() ) ? 0 : -1;
+ }
+
+ function is($unitString){
+ return $this->toString() === $unitString;
+ }
+
+ function isLength(){
+ $css = $this->toCSS();
+ return !!preg_match('/px|em|%|in|cm|mm|pc|pt|ex/',$css);
+ }
+
+ function isAngle() {
+ return isset( Less_Tree_UnitConversions::$angle[$this->toCSS()] );
+ }
+
+ function isEmpty(){
+ return !$this->numerator && !$this->denominator;
+ }
+
+ function isSingular() {
+ return count($this->numerator) <= 1 && !$this->denominator;
+ }
+
+
+ function usedUnits(){
+ $result = array();
+
+ foreach(Less_Tree_UnitConversions::$groups as $groupName){
+ $group = Less_Tree_UnitConversions::${$groupName};
+
+ foreach($this->numerator as $atomicUnit){
+ if( isset($group[$atomicUnit]) && !isset($result[$groupName]) ){
+ $result[$groupName] = $atomicUnit;
+ }
+ }
+
+ foreach($this->denominator as $atomicUnit){
+ if( isset($group[$atomicUnit]) && !isset($result[$groupName]) ){
+ $result[$groupName] = $atomicUnit;
+ }
+ }
+ }
+
+ return $result;
+ }
+
+ function cancel(){
+ $counter = array();
+ $backup = null;
+
+ foreach($this->numerator as $atomicUnit){
+ if( !$backup ){
+ $backup = $atomicUnit;
+ }
+ $counter[$atomicUnit] = ( isset($counter[$atomicUnit]) ? $counter[$atomicUnit] : 0) + 1;
+ }
+
+ foreach($this->denominator as $atomicUnit){
+ if( !$backup ){
+ $backup = $atomicUnit;
+ }
+ $counter[$atomicUnit] = ( isset($counter[$atomicUnit]) ? $counter[$atomicUnit] : 0) - 1;
+ }
+
+ $this->numerator = array();
+ $this->denominator = array();
+
+ foreach($counter as $atomicUnit => $count){
+ if( $count > 0 ){
+ for( $i = 0; $i < $count; $i++ ){
+ $this->numerator[] = $atomicUnit;
+ }
+ }elseif( $count < 0 ){
+ for( $i = 0; $i < -$count; $i++ ){
+ $this->denominator[] = $atomicUnit;
+ }
+ }
+ }
+
+ if( !$this->numerator && !$this->denominator && $backup ){
+ $this->backupUnit = $backup;
+ }
+
+ sort($this->numerator);
+ sort($this->denominator);
+ }
+
+
+}
+
diff --git a/lib/Less/Tree/UnitConversions.php b/lib/Less/Tree/UnitConversions.php
new file mode 100644
index 0000000000000..82aa93b2e62e0
--- /dev/null
+++ b/lib/Less/Tree/UnitConversions.php
@@ -0,0 +1,29 @@
+ 1,
+ 'cm'=> 0.01,
+ 'mm'=> 0.001,
+ 'in'=> 0.0254,
+ 'pt'=> 0.000352778, // 0.0254 / 72,
+ 'pc'=> 0.004233333, //0.0254 / 72 * 12
+ );
+
+ static $duration = array(
+ 's'=> 1,
+ 'ms'=> 0.001
+ );
+
+ static $angle = array(
+ 'rad' => 0.1591549430919, // 1/(2*M_PI),
+ 'deg' => 0.002777778, // 1/360,
+ 'grad'=> 0.0025, // 1/400,
+ 'turn'=> 1
+ );
+
+}
\ No newline at end of file
diff --git a/lib/Less/Tree/Url.php b/lib/Less/Tree/Url.php
new file mode 100644
index 0000000000000..999ca33f7c262
--- /dev/null
+++ b/lib/Less/Tree/Url.php
@@ -0,0 +1,43 @@
+value = $value;
+ $this->currentFileInfo = $currentFileInfo;
+ }
+
+ function accept( $visitor ){
+ $this->value = $visitor->visitObj($this->value);
+ }
+
+ function genCSS( $env, &$strs ){
+ self::OutputAdd( $strs, 'url(' );
+ $this->value->genCSS( $env, $strs );
+ self::OutputAdd( $strs, ')' );
+ }
+
+ public function compile($ctx){
+ $val = $this->value->compile($ctx);
+
+ // Add the base path if the URL is relative
+ if( $this->currentFileInfo && is_string($val->value) && Less_Environment::isPathRelative($val->value) ){
+ $rootpath = $this->currentFileInfo['uri_root'];
+ if ( !$val->quote ){
+ $rootpath = preg_replace('/[\(\)\'"\s]/', '\\$1', $rootpath );
+ }
+ $val->value = $rootpath . $val->value;
+ }
+
+ $val->value = Less_Environment::normalizePath( $val->value);
+
+ return new Less_Tree_URL($val, null);
+ }
+
+}
diff --git a/lib/Less/Tree/Value.php b/lib/Less/Tree/Value.php
new file mode 100644
index 0000000000000..86bd1759307b3
--- /dev/null
+++ b/lib/Less/Tree/Value.php
@@ -0,0 +1,38 @@
+value = $value;
+ }
+
+ function accept($visitor) {
+ $this->value = $visitor->visitArray($this->value);
+ }
+
+ public function compile($env){
+
+ $ret = array();
+ foreach($this->value as $i => $v){
+ $ret[] = $v->compile($env);
+ }
+ if( $i > 0 ){
+ return new Less_Tree_Value($ret);
+ }
+ return $ret[0];
+ }
+
+ function genCSS( $env, &$strs ){
+ $len = count($this->value);
+ for($i = 0; $i < $len; $i++ ){
+ $this->value[$i]->genCSS( $env, $strs);
+ if( $i+1 < $len ){
+ self::OutputAdd( $strs, Less_Environment::$comma_space );
+ }
+ }
+ }
+
+}
diff --git a/lib/Less/Tree/Variable.php b/lib/Less/Tree/Variable.php
new file mode 100644
index 0000000000000..74ac333a81cf7
--- /dev/null
+++ b/lib/Less/Tree/Variable.php
@@ -0,0 +1,42 @@
+name = $name;
+ $this->index = $index;
+ $this->currentFileInfo = $currentFileInfo;
+ }
+
+ public function compile($env) {
+ $name = $this->name;
+ if (strpos($name, '@@') === 0) {
+ $v = new Less_Tree_Variable(substr($name, 1), $this->index + 1);
+ $name = '@' . $v->compile($env)->value;
+ }
+
+ if ($this->evaluating) {
+ throw new Less_Exception_Compiler("Recursive variable definition for " . $name, $this->index, null, $this->currentFileInfo['filename']);
+ }
+
+ $this->evaluating = true;
+
+
+ foreach($env->frames as $frame){
+ if( $v = $frame->variable($name) ){
+ $this->evaluating = false;
+ return $v->value->compile($env);
+ }
+ }
+
+ throw new Less_Exception_Compiler("variable " . $name . " is undefined", $this->index, null);
+ }
+
+}
diff --git a/lib/Less/Visitor.php b/lib/Less/Visitor.php
new file mode 100644
index 0000000000000..760fa98304f78
--- /dev/null
+++ b/lib/Less/Visitor.php
@@ -0,0 +1,43 @@
+_visitFnCache = get_class_methods(get_class($this));
+ $this->_visitFnCache = array_flip($this->_visitFnCache);
+ }
+
+ function visitObj( $node ){
+
+ $funcName = 'visit'.$node->type;
+ if( isset($this->_visitFnCache[$funcName]) ){
+
+ $visitDeeper = true;
+ $this->$funcName( $node, $visitDeeper );
+
+ if( $visitDeeper ){
+ $node->accept($this);
+ }
+
+ $funcName = $funcName . "Out";
+ if( isset($this->_visitFnCache[$funcName]) ){
+ $this->$funcName( $node );
+ }
+
+ }else{
+ $node->accept($this);
+ }
+
+ return $node;
+ }
+
+ function visitArray( $nodes ){
+
+ array_map( array($this,'visitObj'), $nodes);
+ return $nodes;
+ }
+}
+
diff --git a/lib/Less/Visitor/extendFinder.php b/lib/Less/Visitor/extendFinder.php
new file mode 100644
index 0000000000000..c31de938b2fd4
--- /dev/null
+++ b/lib/Less/Visitor/extendFinder.php
@@ -0,0 +1,108 @@
+contexts = array();
+ $this->allExtendsStack = array(array());
+ parent::__construct();
+ }
+
+ function run($root){
+ $root = $this->visitObj($root);
+ $root->allExtends =& $this->allExtendsStack[0];
+ return $root;
+ }
+
+ function visitRule($ruleNode, &$visitDeeper ){
+ $visitDeeper = false;
+ }
+
+ function visitMixinDefinition( $mixinDefinitionNode, &$visitDeeper ){
+ $visitDeeper = false;
+ }
+
+ function visitRuleset($rulesetNode){
+
+ if( $rulesetNode->root ){
+ return;
+ }
+
+ $allSelectorsExtendList = array();
+
+ // get &:extend(.a); rules which apply to all selectors in this ruleset
+ $rules = $rulesetNode->rules;
+ $ruleCnt = count($rules);
+ for($i = 0; $i < $ruleCnt; $i++ ){
+ if( $rules[$i] instanceof Less_Tree_Extend ){
+ $allSelectorsExtendList[] = $rules[$i];
+ $rulesetNode->extendOnEveryPath = true;
+ }
+ }
+
+
+
+ // now find every selector and apply the extends that apply to all extends
+ // and the ones which apply to an individual extend
+ $paths = $rulesetNode->paths;
+ $paths_len = count($paths);
+ for($i = 0; $i < $paths_len; $i++ ){
+
+ $selectorPath = $paths[$i];
+ $selector = end($selectorPath); //$selectorPath[ count($selectorPath)-1];
+
+
+ $list = array_merge($selector->extendList, $allSelectorsExtendList);
+
+ $extendList = array();
+ foreach($list as $allSelectorsExtend){
+ $extendList[] = clone $allSelectorsExtend;
+ }
+
+ $extendList_len = count($extendList);
+ for($j = 0; $j < $extendList_len; $j++ ){
+ $this->foundExtends = true;
+ $extend = $extendList[$j];
+ $extend->findSelfSelectors( $selectorPath );
+ $extend->ruleset = $rulesetNode;
+ if( $j === 0 ){ $extend->firstExtendOnThisSelectorPath = true; }
+
+ $temp = count($this->allExtendsStack)-1;
+ $this->allExtendsStack[ $temp ][] = $extend;
+ }
+ }
+
+ $this->contexts[] = $rulesetNode->selectors;
+ }
+
+ function visitRulesetOut( $rulesetNode ){
+ if( !is_object($rulesetNode) || !$rulesetNode->root ){
+ array_pop($this->contexts);
+ }
+ }
+
+ function visitMedia( $mediaNode ){
+ $mediaNode->allExtends = array();
+ $this->allExtendsStack[] =& $mediaNode->allExtends;
+ }
+
+ function visitMediaOut( $mediaNode ){
+ array_pop($this->allExtendsStack);
+ }
+
+ function visitDirective( $directiveNode ){
+ $directiveNode->allExtends = array();
+ $this->allExtendsStack[] =& $directiveNode->allExtends;
+ }
+
+ function visitDirectiveOut( $directiveNode ){
+ array_pop($this->allExtendsStack);
+ }
+}
+
+
diff --git a/lib/Less/Visitor/import.php b/lib/Less/Visitor/import.php
new file mode 100644
index 0000000000000..6b1a7b43c3ca7
--- /dev/null
+++ b/lib/Less/Visitor/import.php
@@ -0,0 +1,95 @@
+_visitor = new Less_Visitor($this);
+ $this->_importer = $importer;
+ if( $evalEnv ){
+ $this->env = $evalEnv;
+ }else{
+ $this->env = new Less_Environment();
+ }
+ $this->importCount = 0;
+ }
+
+
+ function run( $root ){
+ // process the contents
+ $this->_visitor->visitObj($root);
+
+ $this->isFinished = true;
+
+ //if( $this->importCount === 0) {
+ // $this->_finish();
+ //}
+ }
+
+ function visitImport($importNode, &$visitArgs ){
+ $importVisitor = $this;
+
+ $visitArgs['visitDeeper'] = false;
+
+ if( $importNode->css ){
+ return $importNode;
+ }
+
+ $evaldImportNode = $importNode->compileForImport($this->env);
+
+ if( $evaldImportNode && !$evaldImportNode->css ){
+ $importNode = $evaldImportNode;
+ $this->importCount++;
+ }
+
+ return $importNode;
+ }
+
+
+ function visitRule( $ruleNode, &$visitArgs ){
+ $visitArgs['visitDeeper'] = false;
+ return $ruleNode;
+ }
+
+ function visitDirective($directiveNode, $visitArgs){
+ array_unshift($this->env->frames,$directiveNode);
+ return $directiveNode;
+ }
+
+ function visitDirectiveOut($directiveNode) {
+ array_shift($this->env->frames);
+ }
+
+ function visitMixinDefinition($mixinDefinitionNode, $visitArgs) {
+ array_unshift($this->env->frames,$mixinDefinitionNode);
+ return $mixinDefinitionNode;
+ }
+
+ function visitMixinDefinitionOut($mixinDefinitionNode) {
+ array_shift($this->env->frames);
+ }
+
+ function visitRuleset($rulesetNode, $visitArgs) {
+ array_unshift($this->env->frames,$rulesetNode);
+ return $rulesetNode;
+ }
+
+ function visitRulesetOut($rulesetNode) {
+ array_shift($this->env->frames);
+ }
+
+ function visitMedia($mediaNode, $visitArgs) {
+ array_unshift($this->env->frames, $mediaNode->ruleset);
+ return $mediaNode;
+ }
+
+ function visitMediaOut($mediaNode) {
+ array_shift($this->env->frames);
+ }
+
+}
+*/
\ No newline at end of file
diff --git a/lib/Less/Visitor/joinSelector.php b/lib/Less/Visitor/joinSelector.php
new file mode 100644
index 0000000000000..9f3ab9c95fa2e
--- /dev/null
+++ b/lib/Less/Visitor/joinSelector.php
@@ -0,0 +1,61 @@
+visitObj($root);
+ }
+
+ function visitRule( $ruleNode, &$visitDeeper ){
+ $visitDeeper = false;
+ }
+
+ function visitMixinDefinition( $mixinDefinitionNode, &$visitDeeper ){
+ $visitDeeper = false;
+ }
+
+ function visitRuleset( $rulesetNode ){
+
+ $paths = array();
+
+ if( !$rulesetNode->root ){
+ $selectors = array();
+
+ if( $rulesetNode->selectors && count($rulesetNode->selectors) ){
+ foreach($rulesetNode->selectors as $selector){
+ if( $selector->getIsOutput() ){
+ $selectors[] = $selector;
+ }
+ }
+ }
+
+ if( !count($selectors) ){
+ $rulesetNode->selectors = $selectors = null;
+ $rulesetNode->rules = null;
+ }else{
+ $context = end($this->contexts); //$context = $this->contexts[ count($this->contexts) - 1];
+ $paths = $rulesetNode->joinSelectors( $context, $selectors);
+ }
+
+ $rulesetNode->paths = $paths;
+ }
+
+ $this->contexts[] = $paths; //different from less.js. Placed after joinSelectors() so that $this->contexts will get correct $paths
+ }
+
+ function visitRulesetOut( $rulesetNode ){
+ array_pop($this->contexts);
+ }
+
+ function visitMedia($mediaNode) {
+ $context = end($this->contexts); //$context = $this->contexts[ count($this->contexts) - 1];
+
+ if( !count($context) || (is_object($context[0]) && @$context[0]->multiMedia) ){
+ $mediaNode->rules[0]->root = true;
+ }
+ }
+
+}
+
diff --git a/lib/Less/Visitor/processExtends.php b/lib/Less/Visitor/processExtends.php
new file mode 100644
index 0000000000000..ee2931a283a1e
--- /dev/null
+++ b/lib/Less/Visitor/processExtends.php
@@ -0,0 +1,361 @@
+run( $root );
+ if( !$extendFinder->foundExtends) { return $root; }
+
+ $root->allExtends = $this->doExtendChaining( $root->allExtends, $root->allExtends);
+
+ $this->allExtendsStack = array();
+ $this->allExtendsStack[] = &$root->allExtends;
+
+ return $this->visitObj( $root );
+ }
+
+ function doExtendChaining( $extendsList, $extendsListTarget, $iterationCount = 0){
+ //
+ // chaining is different from normal extension.. if we extend an extend then we are not just copying, altering and pasting
+ // the selector we would do normally, but we are also adding an extend with the same target selector
+ // this means this new extend can then go and alter other extends
+ //
+ // this method deals with all the chaining work - without it, extend is flat and doesn't work on other extend selectors
+ // this is also the most expensive.. and a match on one selector can cause an extension of a selector we had already processed if
+ // we look at each selector at a time, as is done in visitRuleset
+
+ $extendsToAdd = array();
+
+
+ //loop through comparing every extend with every target extend.
+ // a target extend is the one on the ruleset we are looking at copy/edit/pasting in place
+ // e.g. .a:extend(.b) {} and .b:extend(.c) {} then the first extend extends the second one
+ // and the second is the target.
+ // the seperation into two lists allows us to process a subset of chains with a bigger set, as is the
+ // case when processing media queries
+ for( $extendIndex = 0, $extendsList_len = count($extendsList); $extendIndex < $extendsList_len; $extendIndex++ ){
+ for( $targetExtendIndex = 0; $targetExtendIndex < count($extendsListTarget); $targetExtendIndex++ ){
+
+ $extend = $extendsList[$extendIndex];
+ $targetExtend = $extendsListTarget[$targetExtendIndex];
+
+ // look for circular references
+ if( in_array($targetExtend->object_id, $extend->parent_ids,true) ){
+ continue;
+ }
+
+ // find a match in the target extends self selector (the bit before :extend)
+ $selectorPath = array( $targetExtend->selfSelectors[0] );
+ $matches = $this->findMatch( $extend, $selectorPath);
+
+
+ if( $matches ){
+
+ // we found a match, so for each self selector..
+ foreach($extend->selfSelectors as $selfSelector ){
+
+
+ // process the extend as usual
+ $newSelector = $this->extendSelector( $matches, $selectorPath, $selfSelector);
+
+ // but now we create a new extend from it
+ $newExtend = new Less_Tree_Extend( $targetExtend->selector, $targetExtend->option, 0);
+ $newExtend->selfSelectors = $newSelector;
+
+ // add the extend onto the list of extends for that selector
+ end($newSelector)->extendList = array($newExtend);
+ //$newSelector[ count($newSelector)-1]->extendList = array($newExtend);
+
+ // record that we need to add it.
+ $extendsToAdd[] = $newExtend;
+ $newExtend->ruleset = $targetExtend->ruleset;
+
+ //remember its parents for circular references
+ $newExtend->parent_ids = array_merge($newExtend->parent_ids,$targetExtend->parent_ids,$extend->parent_ids);
+
+ // only process the selector once.. if we have :extend(.a,.b) then multiple
+ // extends will look at the same selector path, so when extending
+ // we know that any others will be duplicates in terms of what is added to the css
+ if( $targetExtend->firstExtendOnThisSelectorPath ){
+ $newExtend->firstExtendOnThisSelectorPath = true;
+ $targetExtend->ruleset->paths[] = $newSelector;
+ }
+ }
+ }
+ }
+ }
+
+ if( $extendsToAdd ){
+ // try to detect circular references to stop a stack overflow.
+ // may no longer be needed. $this->extendChainCount++;
+ if( $iterationCount > 100) {
+ $selectorOne = "{unable to calculate}";
+ $selectorTwo = "{unable to calculate}";
+ try{
+ $selectorOne = $extendsToAdd[0]->selfSelectors[0]->toCSS();
+ $selectorTwo = $extendsToAdd[0]->selector->toCSS();
+ }catch(Exception $e){}
+ throw new Less_Exception_Parser("extend circular reference detected. One of the circular extends is currently:"+$selectorOne+":extend(" + $selectorTwo+")");
+ }
+
+ // now process the new extends on the existing rules so that we can handle a extending b extending c ectending d extending e...
+ $extendsToAdd = $this->doExtendChaining( $extendsToAdd, $extendsListTarget, $iterationCount+1);
+ }
+
+ return array_merge($extendsList, $extendsToAdd);
+ }
+
+
+ function visitRule( $ruleNode, &$visitDeeper ){
+ $visitDeeper = false;
+ }
+
+ function visitMixinDefinition( $mixinDefinitionNode, &$visitDeeper ){
+ $visitDeeper = false;
+ }
+
+ function visitSelector( $selectorNode, &$visitDeeper ){
+ $visitDeeper = false;
+ }
+
+ function visitRuleset($rulesetNode){
+
+
+ if( $rulesetNode->root ){
+ return;
+ }
+
+ $allExtends = end($this->allExtendsStack);
+ $paths_len = count($rulesetNode->paths);
+
+ // look at each selector path in the ruleset, find any extend matches and then copy, find and replace
+ for( $extendIndex = 0, $all_extend_len = count($allExtends); $extendIndex < $all_extend_len; $extendIndex++ ){
+ for($pathIndex = 0; $pathIndex < $paths_len; $pathIndex++ ){
+
+ $selectorPath = $rulesetNode->paths[$pathIndex];
+
+ // extending extends happens initially, before the main pass
+ if( isset($rulesetNode->extendOnEveryPath) && $rulesetNode->extendOnEveryPath ){ continue; }
+ if( end($selectorPath)->extendList ){ continue; }
+
+ $matches = $this->findMatch($allExtends[$extendIndex], $selectorPath);
+
+ if( $matches ){
+ foreach($allExtends[$extendIndex]->selfSelectors as $selfSelector ){
+ $rulesetNode->paths[] = $this->extendSelector($matches, $selectorPath, $selfSelector);
+ }
+ }
+ }
+ }
+ }
+
+ function findMatch($extend, $haystackSelectorPath ){
+
+ //
+ // look through the haystack selector path to try and find the needle - extend.selector
+ // returns an array of selector matches that can then be replaced
+ //
+ $needleElements = $extend->selector->elements;
+ $potentialMatches = array();
+ $potentialMatches_len = 0;
+ $potentialMatch = null;
+ $matches = array();
+
+ // loop through the haystack elements
+ for($haystackSelectorIndex = 0, $haystack_path_len = count($haystackSelectorPath); $haystackSelectorIndex < $haystack_path_len; $haystackSelectorIndex++ ){
+ $hackstackSelector = $haystackSelectorPath[$haystackSelectorIndex];
+
+ for($hackstackElementIndex = 0, $haystack_elements_len = count($hackstackSelector->elements); $hackstackElementIndex < $haystack_elements_len; $hackstackElementIndex++ ){
+
+ $haystackElement = $hackstackSelector->elements[$hackstackElementIndex];
+
+ // if we allow elements before our match we can add a potential match every time. otherwise only at the first element.
+ if( $extend->allowBefore || ($haystackSelectorIndex === 0 && $hackstackElementIndex === 0) ){
+ $potentialMatches[] = array('pathIndex'=> $haystackSelectorIndex, 'index'=> $hackstackElementIndex, 'matched'=> 0, 'initialCombinator'=> $haystackElement->combinator);
+ $potentialMatches_len++;
+ }
+
+ for($i = 0; $i < $potentialMatches_len; $i++ ){
+ $potentialMatch = &$potentialMatches[$i];
+
+ // selectors add " " onto the first element. When we use & it joins the selectors together, but if we don't
+ // then each selector in haystackSelectorPath has a space before it added in the toCSS phase. so we need to work out
+ // what the resulting combinator will be
+ $targetCombinator = $haystackElement->combinator->value;
+ if( $targetCombinator === '' && $hackstackElementIndex === 0 ){
+ $targetCombinator = ' ';
+ }
+
+ // if we don't match, null our match to indicate failure
+ if( !$this->isElementValuesEqual( $needleElements[$potentialMatch['matched'] ]->value, $haystackElement->value) ||
+ ($potentialMatch['matched'] > 0 && $needleElements[ $potentialMatch['matched'] ]->combinator->value !== $targetCombinator) ){
+ $potentialMatch = null;
+ } else {
+ $potentialMatch['matched']++;
+ }
+
+ // if we are still valid and have finished, test whether we have elements after and whether these are allowed
+ if( $potentialMatch ){
+
+ $potentialMatch['finished'] = ($potentialMatch['matched'] === $extend->selector->elements_len );
+
+ if( $potentialMatch['finished'] &&
+ (!$extend->allowAfter && ($hackstackElementIndex+1 < $haystack_elements_len || $haystackSelectorIndex+1 < $haystack_path_len)) ){
+ $potentialMatch = null;
+ }
+ }
+ // if null we remove, if not, we are still valid, so either push as a valid match or continue
+ if( $potentialMatch ){
+ if( $potentialMatch['finished'] ){
+ $potentialMatch['length'] = $extend->selector->elements_len;
+ $potentialMatch['endPathIndex'] = $haystackSelectorIndex;
+ $potentialMatch['endPathElementIndex'] = $hackstackElementIndex + 1; // index after end of match
+ $potentialMatches = array(); // we don't allow matches to overlap, so start matching again
+ $potentialMatches_len = 0;
+ $matches[] = $potentialMatch;
+ }
+ } else {
+ array_splice($potentialMatches, $i, 1);
+ $potentialMatches_len--;
+ $i--;
+ }
+ }
+ }
+ }
+ return $matches;
+ }
+
+ function isElementValuesEqual( $elementValue1, $elementValue2 ){
+
+ if( $elementValue1 === $elementValue2 ){
+ return true;
+ }
+ if( is_string($elementValue1) || is_string($elementValue2) ) {
+ return false;
+ }
+
+ if( $elementValue1 instanceof Less_Tree_Attribute ){
+
+ if( $elementValue1->op !== $elementValue2->op || $elementValue1->key !== $elementValue2->key ){
+ return false;
+ }
+
+ if( !$elementValue1->value || !$elementValue2->value ){
+ if( $elementValue1->value || $elementValue2->value ) {
+ return false;
+ }
+ return true;
+ }
+ $elementValue1 = ($elementValue1->value->value ? $elementValue1->value->value : $elementValue1->value );
+ $elementValue2 = ($elementValue2->value->value ? $elementValue2->value->value : $elementValue2->value );
+ return $elementValue1 === $elementValue2;
+ }
+
+ $elementValue1 = $elementValue1->value;
+ if( $elementValue1 instanceof Less_Tree_Selector ){
+ $elementValue2 = $elementValue2->value;
+ if( !($elementValue2 instanceof Less_Tree_Selector) || $elementValue1->elements_len !== $elementValue2->elements_len ){
+ return false;
+ }
+ for( $i = 0; $i < $elementValue1->elements_len; $i++ ){
+ if( $elementValue1->elements[$i]->combinator->value !== $elementValue2->elements[$i]->combinator->value ){
+ if( $i !== 0 || ($elementValue1->elements[$i]->combinator->value || ' ') !== ($elementValue2->elements[$i]->combinator->value || ' ') ){
+ return false;
+ }
+ }
+ if( !$this->isElementValuesEqual($elementValue1->elements[$i]->value, $elementValue2->elements[$i]->value) ){
+ return false;
+ }
+ }
+ return true;
+ }
+
+ return false;
+ }
+
+ function extendSelector($matches, $selectorPath, $replacementSelector){
+
+ //for a set of matches, replace each match with the replacement selector
+
+ $currentSelectorPathIndex = 0;
+ $currentSelectorPathElementIndex = 0;
+ $path = array();
+ $selectorPath_len = count($selectorPath);
+
+ for($matchIndex = 0, $matches_len = count($matches); $matchIndex < $matches_len; $matchIndex++ ){
+
+
+ $match = $matches[$matchIndex];
+ $selector = $selectorPath[ $match['pathIndex'] ];
+ $firstElement = new Less_Tree_Element(
+ $match['initialCombinator'],
+ $replacementSelector->elements[0]->value,
+ $replacementSelector->elements[0]->index,
+ $replacementSelector->elements[0]->currentFileInfo
+ );
+
+ if( $match['pathIndex'] > $currentSelectorPathIndex && $currentSelectorPathElementIndex > 0 ){
+ $last_path = end($path);
+ $last_path->elements = array_merge( $last_path->elements, array_slice( $selectorPath[$currentSelectorPathIndex]->elements, $currentSelectorPathElementIndex));
+ $currentSelectorPathElementIndex = 0;
+ $currentSelectorPathIndex++;
+ }
+
+ $newElements = array_merge(
+ array_slice($selector->elements, $currentSelectorPathElementIndex, ($match['index'] - $currentSelectorPathElementIndex) ) // last parameter of array_slice is different than the last parameter of javascript's slice
+ , array($firstElement)
+ , array_slice($replacementSelector->elements,1)
+ );
+
+ if( $currentSelectorPathIndex === $match['pathIndex'] && $matchIndex > 0 ){
+ $last_key = count($path)-1;
+ $path[$last_key]->elements = array_merge($path[$last_key]->elements,$newElements);
+ }else{
+ $path = array_merge( $path, array_slice( $selectorPath, $currentSelectorPathIndex, $match['pathIndex'] ));
+ $path[] = new Less_Tree_Selector( $newElements );
+ }
+
+ $currentSelectorPathIndex = $match['endPathIndex'];
+ $currentSelectorPathElementIndex = $match['endPathElementIndex'];
+ if( $currentSelectorPathElementIndex >= count($selectorPath[$currentSelectorPathIndex]->elements) ){
+ $currentSelectorPathElementIndex = 0;
+ $currentSelectorPathIndex++;
+ }
+ }
+
+ if( $currentSelectorPathIndex < $selectorPath_len && $currentSelectorPathElementIndex > 0 ){
+ $last_path = end($path);
+ $last_path->elements = array_merge( $last_path->elements, array_slice($selectorPath[$currentSelectorPathIndex]->elements, $currentSelectorPathElementIndex));
+ $currentSelectorPathIndex++;
+ }
+
+ $slice_len = $selectorPath_len - $currentSelectorPathIndex;
+ $path = array_merge($path, array_slice($selectorPath, $currentSelectorPathIndex, $slice_len));
+
+ return $path;
+ }
+
+
+ function visitMedia( $mediaNode ){
+ $newAllExtends = array_merge( $mediaNode->allExtends, end($this->allExtendsStack) );
+ $this->allExtendsStack[] = $this->doExtendChaining($newAllExtends, $mediaNode->allExtends);
+ }
+
+ function visitMediaOut( $mediaNode ){
+ array_pop( $this->allExtendsStack );
+ }
+
+ function visitDirective( $directiveNode ){
+ $newAllExtends = array_merge( $directiveNode->allExtends, end($this->allExtendsStack) );
+ $this->allExtendsStack[] = $this->doExtendChaining($newAllExtends, $directiveNode->allExtends);
+ }
+
+ function visitDirectiveOut( $directiveNode ){
+ array_pop($this->allExtendsStack);
+ }
+
+}
\ No newline at end of file
diff --git a/lib/Less/Visitor/toCSS.php b/lib/Less/Visitor/toCSS.php
new file mode 100644
index 0000000000000..80da0b5b0c3cd
--- /dev/null
+++ b/lib/Less/Visitor/toCSS.php
@@ -0,0 +1,221 @@
+_env = $env;
+ parent::__construct();
+ }
+
+ function run( $root ){
+ return $this->visitObj($root);
+ }
+
+ function visitRule( $ruleNode ){
+ if( $ruleNode->variable ){
+ return array();
+ }
+ return $ruleNode;
+ }
+
+ function visitMixinDefinition( $mixinNode ){
+ return array();
+ }
+
+ function visitExtend( $extendNode ){
+ return array();
+ }
+
+ function visitComment( $commentNode ){
+ if( $commentNode->isSilent( $this->_env) ){
+ return array();
+ }
+ return $commentNode;
+ }
+
+ function visitMedia( $mediaNode, &$visitDeeper ){
+ $mediaNode->accept($this);
+ $visitDeeper = false;
+
+ if( !$mediaNode->rules ){
+ return array();
+ }
+ return $mediaNode;
+ }
+
+ function visitDirective( $directiveNode ){
+ if( isset($directiveNode->currentFileInfo['reference']) && (!property_exists($directiveNode,'isReferenced') || !$directiveNode->isReferenced) ){
+ return array();
+ }
+ if( $directiveNode->name === '@charset' ){
+ // Only output the debug info together with subsequent @charset definitions
+ // a comment (or @media statement) before the actual @charset directive would
+ // be considered illegal css as it has to be on the first line
+ if( isset($this->charset) && $this->charset ){
+
+ //if( $directiveNode->debugInfo ){
+ // $comment = new Less_Tree_Comment('/* ' . str_replace("\n",'',$directiveNode->toCSS($this->_env))." */\n");
+ // $comment->debugInfo = $directiveNode->debugInfo;
+ // return $this->visit($comment);
+ //}
+
+
+ return array();
+ }
+ $this->charset = true;
+ }
+ return $directiveNode;
+ }
+
+ function checkPropertiesInRoot( $rules ){
+ foreach($rules as $ruleNode){
+ if( $ruleNode instanceof Less_Tree_Rule && !$ruleNode->variable ){
+ $msg = "properties must be inside selector blocks, they cannot be in the root. Index ".$ruleNode->index.($ruleNode->currentFileInfo ? (' Filename: '.$ruleNode->currentFileInfo['filename']) : null);
+ throw new Less_Exception_Compiler($msg);
+ }
+ }
+ }
+
+ function visitRuleset( $rulesetNode, &$visitDeeper ){
+
+ $visitDeeper = false;
+ $rulesets = array();
+ if( $rulesetNode->firstRoot ){
+ $this->checkPropertiesInRoot( $rulesetNode->rules );
+ }
+ if( !$rulesetNode->root ){
+
+ $paths = array();
+ foreach($rulesetNode->paths as $p){
+ if( $p[0]->elements[0]->combinator->value === ' ' ){
+ $p[0]->elements[0]->combinator = new Less_Tree_Combinator('');
+ }
+
+ foreach($p as $pi){
+ if( $pi->getIsReferenced() && $pi->getIsOutput() ){
+ $paths[] = $p;
+ break;
+ }
+ }
+ }
+
+ $rulesetNode->paths = $paths;
+
+ // Compile rules and rulesets
+ $nodeRuleCnt = count($rulesetNode->rules);
+ for( $i = 0; $i < $nodeRuleCnt; ){
+ $rule = $rulesetNode->rules[$i];
+
+ if( property_exists($rule,'rules') ){
+ // visit because we are moving them out from being a child
+ $rulesets[] = $this->visitObj($rule);
+ array_splice($rulesetNode->rules,$i,1);
+ $nodeRuleCnt--;
+ continue;
+ }
+ $i++;
+ }
+
+
+ // accept the visitor to remove rules and refactor itself
+ // then we can decide now whether we want it or not
+ if( $nodeRuleCnt > 0 ){
+ $rulesetNode->accept($this);
+
+ if( $rulesetNode->rules ){
+
+ if( count($rulesetNode->rules) > 1 ){
+ $this->_mergeRules( $rulesetNode->rules );
+ $this->_removeDuplicateRules( $rulesetNode->rules );
+ }
+
+ // now decide whether we keep the ruleset
+ if( $rulesetNode->paths ){
+ //array_unshift($rulesets, $rulesetNode);
+ array_splice($rulesets,0,0,array($rulesetNode));
+ }
+ }
+
+ }
+
+ }else{
+ $rulesetNode->accept( $this );
+ if( $rulesetNode->firstRoot || $rulesetNode->rules ){
+ return $rulesetNode;
+ //array_unshift($rulesets, $rulesetNode);
+ }
+ return $rulesets;
+ }
+
+ if( count($rulesets) === 1 ){
+ return $rulesets[0];
+ }
+ return $rulesets;
+ }
+
+ function _removeDuplicateRules( &$rules ){
+ // remove duplicates
+ $ruleCache = array();
+ for( $i = count($rules)-1; $i >= 0 ; $i-- ){
+ $rule = $rules[$i];
+ if( $rule instanceof Less_Tree_Rule ){
+ if( !isset($ruleCache[$rule->name]) ){
+ $ruleCache[$rule->name] = $rule;
+ }else{
+ $ruleList =& $ruleCache[$rule->name];
+ if( $ruleList instanceof Less_Tree_Rule ){
+ $ruleList = $ruleCache[$rule->name] = array( $ruleCache[$rule->name]->toCSS($this->_env) );
+ }
+ $ruleCSS = $rule->toCSS($this->_env);
+ if( array_search($ruleCSS,$ruleList) !== false ){
+ array_splice($rules,$i,1);
+ }else{
+ $ruleList[] = $ruleCSS;
+ }
+ }
+ }
+ }
+ }
+
+ function _mergeRules( &$rules ){
+ $groups = array();
+
+ $rules_len = count($rules);
+ for( $i = 0; $i < $rules_len; $i++ ){
+ $rule = $rules[$i];
+
+ if( ($rule instanceof Less_Tree_Rule) && $rule->merge ){
+
+ $key = $rule->name;
+ if( $rule->important ){
+ $key .= ',!';
+ }
+
+ if( !isset($groups[$key]) ){
+ $groups[$key] = array();
+ $parts =& $groups[$key];
+ }else{
+ array_splice($rules, $i--, 1);
+ $rules_len--;
+ }
+
+ $parts[] = $rule;
+ }
+ }
+
+ foreach($groups as $parts){
+
+ if( count($parts) > 1 ){
+ $rule = $parts[0];
+
+ $values = array();
+ foreach($parts as $p){
+ $values[] = $p->value;
+ }
+
+ $rule->value = new Less_Tree_Value( $values );
+ }
+ }
+ }
+}
+
diff --git a/lib/Less/VisitorReplacing.php b/lib/Less/VisitorReplacing.php
new file mode 100644
index 0000000000000..a8a245eb86512
--- /dev/null
+++ b/lib/Less/VisitorReplacing.php
@@ -0,0 +1,70 @@
+type;
+ if( isset($this->_visitFnCache[$funcName]) ){
+
+ $visitDeeper = true;
+ $node = $this->$funcName( $node, $visitDeeper );
+
+ if( $node ){
+ if( $visitDeeper && is_object($node) ){
+ $node->accept($this);
+ }
+
+ $funcName = $funcName . "Out";
+ if( isset($this->_visitFnCache[$funcName]) ){
+ $this->$funcName( $node );
+ }
+ }
+
+ }else{
+ $node->accept($this);
+ }
+
+ return $node;
+ }
+
+ function visitArray( $nodes ){
+
+ $newNodes = array();
+ foreach($nodes as $node){
+ $evald = $this->visitObj($node);
+ if( $evald ){
+ if( is_array($evald) ){
+ self::flatten($evald,$newNodes);
+ }else{
+ $newNodes[] = $evald;
+ }
+ }
+ }
+ return $newNodes;
+ }
+
+ function flatten( $arr, &$out ){
+
+ foreach($arr as $item){
+ if( !is_array($item) ){
+ $out[] = $item;
+ continue;
+ }
+
+ foreach($item as $nestedItem){
+ if( is_array($nestedItem) ){
+ self::flatten( $nestedItem, $out);
+ }else{
+ $out[] = $nestedItem;
+ }
+ }
+ }
+
+ return $out;
+ }
+
+}
+
+
diff --git a/lib/Magento/Acl/Loader/DefaultLoader.php b/lib/Magento/Acl/Loader/DefaultLoader.php
index 4a04cdc00ecf5..850421381d1a0 100644
--- a/lib/Magento/Acl/Loader/DefaultLoader.php
+++ b/lib/Magento/Acl/Loader/DefaultLoader.php
@@ -31,7 +31,7 @@ class DefaultLoader implements \Magento\Acl\LoaderInterface
* Don't do anything to acl object.
*
* @param \Magento\Acl $acl
- * @return mixed
+ * @return void
*/
public function populateAcl(\Magento\Acl $acl)
{
diff --git a/lib/Magento/Acl/Loader/Resource.php b/lib/Magento/Acl/Loader/Resource.php
index ca57659de8c3d..4c0e6843d8398 100644
--- a/lib/Magento/Acl/Loader/Resource.php
+++ b/lib/Magento/Acl/Loader/Resource.php
@@ -25,29 +25,34 @@
*/
namespace Magento\Acl\Loader;
+use Magento\Acl;
+use Magento\Acl\Resource as AclResource;
+use Magento\Acl\Resource\ProviderInterface;
+use Magento\Acl\ResourceFactory;
+
class Resource implements \Magento\Acl\LoaderInterface
{
/**
* Acl resource config
*
- * @var \Magento\Acl\Resource\ProviderInterface $resourceProvider
+ * @var ProviderInterface $resourceProvider
*/
protected $_resourceProvider;
/**
* Resource factory
*
- * @var \Magento\Acl\ResourceFactory
+ * @var ResourceFactory
*/
protected $_resourceFactory;
/**
- * @param \Magento\Acl\Resource\ProviderInterface $resourceProvider
- * @param \Magento\Acl\ResourceFactory $resourceFactory
+ * @param ProviderInterface $resourceProvider
+ * @param ResourceFactory $resourceFactory
*/
public function __construct(
- \Magento\Acl\Resource\ProviderInterface $resourceProvider,
- \Magento\Acl\ResourceFactory $resourceFactory
+ ProviderInterface $resourceProvider,
+ ResourceFactory $resourceFactory
) {
$this->_resourceProvider = $resourceProvider;
$this->_resourceFactory = $resourceFactory;
@@ -56,9 +61,10 @@ public function __construct(
/**
* Populate ACL with resources from external storage
*
- * @param \Magento\Acl $acl
+ * @param Acl $acl
+ * @return void
*/
- public function populateAcl(\Magento\Acl $acl)
+ public function populateAcl(Acl $acl)
{
$this->_addResourceTree($acl, $this->_resourceProvider->getAclResources(), null);
}
@@ -66,18 +72,19 @@ public function populateAcl(\Magento\Acl $acl)
/**
* Add list of nodes and their children to acl
*
- * @param \Magento\Acl $acl
+ * @param Acl $acl
* @param array $resources
- * @param \Magento\Acl\Resource $parent
+ * @param AclResource $parent
+ * @return void
* @throws \InvalidArgumentException
*/
- protected function _addResourceTree(\Magento\Acl $acl, array $resources, \Magento\Acl\Resource $parent = null)
+ protected function _addResourceTree(Acl $acl, array $resources, AclResource $parent = null)
{
foreach ($resources as $resourceConfig) {
if (!isset($resourceConfig['id'])) {
throw new \InvalidArgumentException('Missing ACL resource identifier');
}
- /** @var $resource \Magento\Acl\Resource */
+ /** @var $resource AclResource */
$resource = $this->_resourceFactory->createResource(array('resourceId' => $resourceConfig['id']));
$acl->addResource($resource, $parent);
if (isset($resourceConfig['children'])) {
diff --git a/lib/Magento/Acl/Resource/Config/Converter/Dom.php b/lib/Magento/Acl/Resource/Config/Converter/Dom.php
index 365ecf81a0d8c..62412efb8a537 100644
--- a/lib/Magento/Acl/Resource/Config/Converter/Dom.php
+++ b/lib/Magento/Acl/Resource/Config/Converter/Dom.php
@@ -27,6 +27,9 @@ class Dom implements \Magento\Config\ConverterInterface
{
/**
* {@inheritdoc}
+ *
+ * @param \DOMDocument $source
+ * @return array
*/
public function convert($source)
{
diff --git a/lib/Magento/Acl/Resource/Config/Reader/Filesystem.php b/lib/Magento/Acl/Resource/Config/Reader/Filesystem.php
index bb2fd6fc04264..6cf7dbd9f9810 100644
--- a/lib/Magento/Acl/Resource/Config/Reader/Filesystem.php
+++ b/lib/Magento/Acl/Resource/Config/Reader/Filesystem.php
@@ -25,6 +25,15 @@
class Filesystem extends \Magento\Config\Reader\Filesystem
{
+ /**
+ * List of id attributes for merge
+ *
+ * @var array
+ */
+ protected $_idAttributes = array(
+ '/config/acl/resources(/resource)+' => 'id',
+ );
+
/**
* @param \Magento\Config\FileResolverInterface $fileResolver
* @param \Magento\Config\ConverterInterface $converter
@@ -42,7 +51,7 @@ public function __construct(
\Magento\Config\ValidationStateInterface $validationState,
$fileName = 'acl.xml',
$idAttributes = array(),
- $domDocumentClass = 'Magento\Acl\Resource\Config\Dom',
+ $domDocumentClass = 'Magento\Config\Dom',
$defaultScope = 'global'
) {
parent::__construct(
diff --git a/lib/Magento/Acl/ResourceFactory.php b/lib/Magento/Acl/ResourceFactory.php
index e969eba23a7e3..aff0c8fcec345 100644
--- a/lib/Magento/Acl/ResourceFactory.php
+++ b/lib/Magento/Acl/ResourceFactory.php
@@ -25,19 +25,21 @@
*/
namespace Magento\Acl;
+use Magento\ObjectManager;
+
class ResourceFactory
{
const RESOURCE_CLASS_NAME = 'Magento\Acl\Resource';
/**
- * @var \Magento\ObjectManager
+ * @var ObjectManager
*/
protected $_objectManager;
/**
- * @param \Magento\ObjectManager $objectManager
+ * @param ObjectManager $objectManager
*/
- public function __construct(\Magento\ObjectManager $objectManager)
+ public function __construct(ObjectManager $objectManager)
{
$this->_objectManager = $objectManager;
}
@@ -46,7 +48,7 @@ public function __construct(\Magento\ObjectManager $objectManager)
* Return new ACL resource model
*
* @param array $arguments
- * @return \Magento\Acl\Resource
+ * @return Resource
*/
public function createResource(array $arguments = array())
{
diff --git a/lib/Magento/Acl/Role/Registry.php b/lib/Magento/Acl/Role/Registry.php
index ba2b456d3da65..1beab39293200 100644
--- a/lib/Magento/Acl/Role/Registry.php
+++ b/lib/Magento/Acl/Role/Registry.php
@@ -37,7 +37,7 @@ class Registry extends \Zend_Acl_Role_Registry
*
* @param \Zend_Acl_Role_Interface|string $role
* @param array|Zend_Acl_Role_Interface|string $parents
- * @return \Magento\Acl\Role\Registry
+ * @return $this
* @throws \Zend_Acl_Role_Registry_Exception
*/
public function addParent($role, $parents)
diff --git a/lib/Magento/App/Action/Action.php b/lib/Magento/App/Action/Action.php
index e8642b63825fe..5a830c48d9259 100644
--- a/lib/Magento/App/Action/Action.php
+++ b/lib/Magento/App/Action/Action.php
@@ -144,6 +144,7 @@ public function dispatch(RequestInterface $request)
* @param string|null $controller
* @param string|null $module
* @param array|null $params
+ * @return void
*/
protected function _forward($action, $controller = null, $module = null, array $params = null)
{
@@ -173,7 +174,7 @@ protected function _forward($action, $controller = null, $module = null, array $
*
* @param string $path
* @param array $arguments
- * @return \Magento\App\ResponseInterface
+ * @return ResponseInterface
*/
protected function _redirect($path, $arguments = array())
{
diff --git a/lib/Magento/App/Action/Forward.php b/lib/Magento/App/Action/Forward.php
index 547d14f7f1fc0..fd268983b9cb4 100644
--- a/lib/Magento/App/Action/Forward.php
+++ b/lib/Magento/App/Action/Forward.php
@@ -26,12 +26,13 @@
namespace Magento\App\Action;
use Magento\App\RequestInterface;
+use Magento\App\ResponseInterface;
class Forward extends AbstractAction
{
/**
* @param RequestInterface $request
- * @return \Magento\App\ResponseInterface|mixed
+ * @return ResponseInterface
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function dispatch(RequestInterface $request)
diff --git a/lib/Magento/App/Action/Redirect.php b/lib/Magento/App/Action/Redirect.php
index 0ea3714dbd5cf..5875f1d163789 100644
--- a/lib/Magento/App/Action/Redirect.php
+++ b/lib/Magento/App/Action/Redirect.php
@@ -26,6 +26,7 @@
namespace Magento\App\Action;
use \Magento\App\RequestInterface;
+use \Magento\App\ResponseInterface;
class Redirect extends AbstractAction
{
@@ -33,7 +34,7 @@ class Redirect extends AbstractAction
* Redirect response
*
* @param RequestInterface $request
- * @return \Magento\App\ResponseInterface|mixed
+ * @return ResponseInterface
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function dispatch(RequestInterface $request)
diff --git a/lib/Magento/App/Action/Title.php b/lib/Magento/App/Action/Title.php
index 2852f5d8c1d01..1fdde88b9c39f 100644
--- a/lib/Magento/App/Action/Title.php
+++ b/lib/Magento/App/Action/Title.php
@@ -29,14 +29,14 @@ class Title
/**
* Title parts to be rendered in the page head title
*
- * @var array
+ * @var string[]
*/
protected $_titles = array();
/**
* @param string $text
* @param bool $prepend
- * @return Title
+ * @return $this
*/
public function add($text, $prepend = false)
{
@@ -51,7 +51,7 @@ public function add($text, $prepend = false)
/**
* Get titles
*
- * @return array
+ * @return string[]
*/
public function get()
{
diff --git a/lib/Magento/App/ActionFactory.php b/lib/Magento/App/ActionFactory.php
index a84f5de6e1a0b..bf223a9c248c9 100644
--- a/lib/Magento/App/ActionFactory.php
+++ b/lib/Magento/App/ActionFactory.php
@@ -25,6 +25,8 @@
*/
namespace Magento\App;
+use Magento\App\Action\AbstractAction;
+
class ActionFactory
{
/**
@@ -43,7 +45,7 @@ public function __construct(\Magento\ObjectManager $objectManager)
/**
* @param string $controllerName
* @param array $arguments
- * @return mixed
+ * @return AbstractAction
*/
public function createController($controllerName, array $arguments = array())
{
diff --git a/lib/Magento/App/ActionFlag.php b/lib/Magento/App/ActionFlag.php
index 79b4cb888d5c4..1d915cfedf25b 100644
--- a/lib/Magento/App/ActionFlag.php
+++ b/lib/Magento/App/ActionFlag.php
@@ -50,6 +50,7 @@ public function __construct(\Magento\App\RequestInterface $request)
* @param string $action
* @param string $flag
* @param string $value
+ * @return void
*/
public function set($action, $flag, $value)
{
diff --git a/lib/Magento/App/AreaList.php b/lib/Magento/App/AreaList.php
index d07dee412c2e7..83f1c6dfc5000 100644
--- a/lib/Magento/App/AreaList.php
+++ b/lib/Magento/App/AreaList.php
@@ -90,7 +90,7 @@ public function getFrontName($areaCode)
/**
* Retrieve area codes
*
- * @return array
+ * @return string[]
*/
public function getCodes()
{
diff --git a/lib/Magento/App/Arguments.php b/lib/Magento/App/Arguments.php
new file mode 100644
index 0000000000000..2fcbe005d5247
--- /dev/null
+++ b/lib/Magento/App/Arguments.php
@@ -0,0 +1,187 @@
+_loader = $loader;
+ $this->_parameters = $parameters;
+ $this->_data = array_replace_recursive($this->_parseParams($loader->load()), $parameters);
+ }
+
+ /**
+ * @param array $input
+ * @return array
+ */
+ protected function _parseParams(array $input)
+ {
+ $stack = $input;
+ unset($stack['resource']);
+ unset($stack['connection']);
+ unset($stack['cache']);
+ $output = $this->_flattenParams($stack);
+ $output['connection'] = isset($input['connection']) ? $input['connection'] : array();
+ $output['resource'] = isset($input['resource']) ? $input['resource'] : array();
+ $output['cache'] = isset($input['cache']) ? $input['cache'] : array();
+ return $output;
+ }
+
+ /**
+ * Convert associative array of arbitrary depth to a flat associative array with concatenated key path as keys
+ *
+ * @param array $params
+ * @param string $separator
+ * @return array
+ */
+ protected function _flattenParams(array $params, $separator = '.')
+ {
+ $result = array();
+ $stack = $params;
+ while ($stack) {
+ list($key, $value) = each($stack);
+ unset($stack[$key]);
+ if (is_array($value)) {
+ if (count($value)) {
+ foreach ($value as $subKey => $node) {
+ $build[$key . $separator . $subKey] = $node;
+ }
+ } else {
+ $build[$key] = null;
+ }
+ $stack = $build + $stack;
+ continue;
+ }
+ $result[$key] = $value;
+ }
+ return $result;
+ }
+
+ /**
+ * Retrieve connection configuration by connection name
+ *
+ * @param string $connectionName
+ * @return array
+ */
+ public function getConnection($connectionName)
+ {
+ return isset($this->_data['connection'][$connectionName])
+ ? $this->_data['connection'][$connectionName]
+ : null;
+ }
+
+ /**
+ * Retrieve list of connections
+ *
+ * @return array
+ */
+ public function getConnections()
+ {
+ return isset($this->_data['connection']) ? $this->_data['connection'] : array();
+ }
+
+ /**
+ * Retrieve list of resources
+ *
+ * @return array
+ */
+ public function getResources()
+ {
+ return $this->_data['resource'];
+ }
+
+ /**
+ * Retrieve settings for all cache front-ends configured in the system
+ *
+ * @return array Format: array('' => array(), ...)
+ */
+ public function getCacheFrontendSettings()
+ {
+ return isset($this->_data['cache']['frontend']) ? $this->_data['cache']['frontend'] : array();
+ }
+
+ /**
+ * Retrieve identifier of a cache frontend, configured to be used for a cache type
+ *
+ * @param string $cacheType Cache type identifier
+ * @return string|null
+ */
+ public function getCacheTypeFrontendId($cacheType)
+ {
+ return isset($this->_data['cache']['type'][$cacheType]['frontend'])
+ ? $this->_data['cache']['type'][$cacheType]['frontend']
+ : null;
+ }
+
+ /**
+ * Retrieve key
+ *
+ * @param string $key
+ * @param mixed $defaultValue
+ * @return array|null
+ */
+ public function get($key = null, $defaultValue = null)
+ {
+ if ($key === null) {
+ return $this->_data;
+ }
+ return isset($this->_data[$key]) ? $this->_data[$key] : $defaultValue;
+ }
+
+ /**
+ * Reload local.xml
+ */
+ public function reload()
+ {
+ $this->_data = array_replace_recursive($this->_parseParams($this->_loader->load()), $this->_parameters);
+ }
+}
diff --git a/lib/Magento/App/Config/FileResolver/Primary.php b/lib/Magento/App/Arguments/FileResolver/Primary.php
similarity index 95%
rename from lib/Magento/App/Config/FileResolver/Primary.php
rename to lib/Magento/App/Arguments/FileResolver/Primary.php
index 5988597077929..034eb6c67086d 100644
--- a/lib/Magento/App/Config/FileResolver/Primary.php
+++ b/lib/Magento/App/Arguments/FileResolver/Primary.php
@@ -23,11 +23,7 @@
* @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
-namespace Magento\App\Config\FileResolver;
-
-/***
- * @SuppressWarnings(PHPMD.UnusedFormalParameter)
- */
+namespace Magento\App\Arguments\FileResolver;
class Primary implements \Magento\Config\FileResolverInterface
{
@@ -59,8 +55,10 @@ public function __construct(
$this->configDirectory = $filesystem->getDirectoryRead(\Magento\App\Filesystem::CONFIG_DIR);
$this->iteratorFactory = $iteratorFactory;
}
+
/**
* @inheritdoc
+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function get($filename, $scope)
{
diff --git a/lib/Magento/App/Arguments/Loader.php b/lib/Magento/App/Arguments/Loader.php
new file mode 100644
index 0000000000000..b285790a33254
--- /dev/null
+++ b/lib/Magento/App/Arguments/Loader.php
@@ -0,0 +1,102 @@
+ 'name',
+ '/config/connection' => 'name',
+ '/config/cache/frontend' => 'name',
+ '/config/cache/type' => 'name',
+ );
+
+ /**
+ * @param \Magento\App\Filesystem\DirectoryList $dirList
+ * @param string $customFile
+ */
+ public function __construct(\Magento\App\Filesystem\DirectoryList $dirList, $customFile = null)
+ {
+ $this->_dir = $dirList->getDir(\Magento\App\Filesystem::CONFIG_DIR);
+ $this->_customFile = $customFile;
+ }
+
+ /**
+ * Load configuration
+ *
+ * @return array
+ */
+ public function load()
+ {
+ $localConfig = new \Magento\Config\Dom('', $this->_idAttributes);
+
+ $localConfigFile = $this->_dir . '/' . self::LOCAL_CONFIG_FILE;
+ if (file_exists($localConfigFile)) {
+ // 1. app/etc/local.xml
+ $localConfig->merge(file_get_contents($localConfigFile));
+
+ // 2. app/etc//.xml
+ if (preg_match('/^[a-z\d_-]+(\/|\\\)+[a-z\d_-]+\.xml$/', $this->_customFile)) {
+ $localConfigExtraFile = $this->_dir . '/' . $this->_customFile;
+ $localConfig->merge(file_get_contents($localConfigExtraFile));
+ }
+ }
+
+ $converter = new \Magento\Config\Converter\Dom\Flat($this->_idAttributes);
+
+ $result = $converter->convert($localConfig->getDom());
+ return !empty($result['config']) ? $result['config'] : array();
+ }
+}
diff --git a/lib/Magento/App/Config/ValidationState.php b/lib/Magento/App/Arguments/ValidationState.php
similarity index 97%
rename from lib/Magento/App/Config/ValidationState.php
rename to lib/Magento/App/Arguments/ValidationState.php
index 63b074dc4e998..380cd51b03e07 100644
--- a/lib/Magento/App/Config/ValidationState.php
+++ b/lib/Magento/App/Arguments/ValidationState.php
@@ -23,7 +23,7 @@
* @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
-namespace Magento\App\Config;
+namespace Magento\App\Arguments;
class ValidationState implements \Magento\Config\ValidationStateInterface
{
diff --git a/lib/Magento/App/Cache/Frontend/Pool.php b/lib/Magento/App/Cache/Frontend/Pool.php
index 8ad9493e708a8..b489041f74237 100644
--- a/lib/Magento/App/Cache/Frontend/Pool.php
+++ b/lib/Magento/App/Cache/Frontend/Pool.php
@@ -18,23 +18,26 @@
* versions in the future. If you wish to customize Magento for your
* needs please refer to http://www.magentocommerce.com for more information.
*
- * @category Magento
- * @package Magento_Core
* @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
-/**
- * In-memory readonly pool of cache front-end instances, specified in the configuration
- */
namespace Magento\App\Cache\Frontend;
+/**
+ * In-memory readonly pool of all cache front-end instances known to the system
+ */
class Pool implements \Iterator
{
/**
* Frontend identifier associated with the default settings
*/
- const DEFAULT_FRONTEND_ID = 'generic';
+ const DEFAULT_FRONTEND_ID = 'default';
+
+ /**
+ * @var \Magento\App\Arguments
+ */
+ private $_arguments;
/**
* @var \Magento\App\Cache\Frontend\Factory
@@ -47,54 +50,55 @@ class Pool implements \Iterator
private $_instances;
/**
- * Advanced config settings
- *
* @var array
*/
- private $_advancedSettings;
-
- /**
- * Default cache settings
- *
- * @var array
- */
- private $_defaultSettings;
+ private $_frontendSettings;
/**
+ * @param \Magento\App\Arguments $arguments
* @param \Magento\App\Cache\Frontend\Factory $frontendFactory
- * @param array $defaultSettings
- * @param array $advancedSettings
+ * @param array $frontendSettings Format: array('' => array(), ...)
*/
public function __construct(
+ \Magento\App\Arguments $arguments,
\Magento\App\Cache\Frontend\Factory $frontendFactory,
- array $defaultSettings = array(),
- array $advancedSettings = array()
+ array $frontendSettings = array()
) {
+ $this->_arguments = $arguments;
$this->_factory = $frontendFactory;
- $this->_advancedSettings = $advancedSettings;
- $this->_defaultSettings = empty($defaultSettings) == false ? $defaultSettings : array();
+ $this->_frontendSettings = $frontendSettings + array(self::DEFAULT_FRONTEND_ID => array());
}
/**
- * Load frontend instances from the configuration, to be used for delayed initialization
+ * Create instances of every cache frontend known to the system.
+ * Method is to be used for delayed initialization of the iterator.
+ *
+ * @return void
*/
protected function _initialize()
{
if ($this->_instances === null) {
$this->_instances = array();
- // default front-end
- $this->_instances[self::DEFAULT_FRONTEND_ID] = $this->_factory->create($this->_defaultSettings);
- // additional front-ends
-
- if ($this->_advancedSettings) {
- /** @var $frontendNode \Magento\Simplexml\Element */
- foreach ($this->_advancedSettings as $frontendId => $frontendOptions) {
- $this->_instances[$frontendId] = $this->_factory->create($frontendOptions);
- }
+ foreach ($this->_getCacheSettings() as $frontendId => $frontendOptions) {
+ $this->_instances[$frontendId] = $this->_factory->create($frontendOptions);
}
}
}
+ /**
+ * Retrieve settings for all cache front-ends known to the system
+ *
+ * @return array Format: array('' => array(), ...)
+ */
+ protected function _getCacheSettings()
+ {
+ /*
+ * Merging is intentionally implemented through array_merge() instead of array_replace_recursive()
+ * to avoid "inheritance" of the default settings that become irrelevant as soon as cache storage type changes
+ */
+ return array_merge($this->_frontendSettings, $this->_arguments->getCacheFrontendSettings());
+ }
+
/**
* {@inheritdoc}
*
@@ -143,10 +147,11 @@ public function valid()
}
/**
- * Retrieve frontend instance by its unique identifier, or return NULL, if identifier is not recognized
+ * Retrieve frontend instance by its unique identifier
*
* @param string $identifier Cache frontend identifier
* @return \Magento\Cache\FrontendInterface Cache frontend instance
+ * @throws \InvalidArgumentException
*/
public function get($identifier)
{
@@ -154,6 +159,6 @@ public function get($identifier)
if (isset($this->_instances[$identifier])) {
return $this->_instances[$identifier];
}
- return null;
+ throw new \InvalidArgumentException("Cache frontend '$identifier' is not recognized.");
}
}
diff --git a/lib/Magento/App/Cache/Proxy.php b/lib/Magento/App/Cache/Proxy.php
index 0d5fec7f468cb..15d6d55da21b1 100644
--- a/lib/Magento/App/Cache/Proxy.php
+++ b/lib/Magento/App/Cache/Proxy.php
@@ -29,7 +29,9 @@
*/
namespace Magento\App\Cache;
-class Proxy implements \Magento\App\CacheInterface
+use Magento\App\CacheInterface;
+
+class Proxy implements CacheInterface
{
/**
* @var \Magento\ObjectManager
@@ -37,7 +39,7 @@ class Proxy implements \Magento\App\CacheInterface
protected $_objectManager;
/**
- * @var \Magento\App\CacheInterface
+ * @var CacheInterface
*/
protected $_cache;
@@ -52,7 +54,7 @@ public function __construct(\Magento\ObjectManager $objectManager)
/**
* Create cache model
*
- * @return \Magento\App\CacheInterface|mixed
+ * @return CacheInterface
*/
protected function _getCache()
{
diff --git a/lib/Magento/App/Cache/State.php b/lib/Magento/App/Cache/State.php
index 2dcdee3dd085a..89948901d8b84 100644
--- a/lib/Magento/App/Cache/State.php
+++ b/lib/Magento/App/Cache/State.php
@@ -76,6 +76,7 @@ public function __construct(
* Load statuses (enabled/disabled) of cache types
*
* @param bool $forceDisableAll
+ * @return void
*/
private function _loadTypeStatuses($forceDisableAll = false)
{
@@ -111,6 +112,7 @@ public function isEnabled($cacheType)
*
* @param string $cacheType
* @param bool $isEnabled
+ * @return void
*/
public function setEnabled($cacheType, $isEnabled)
{
@@ -119,6 +121,8 @@ public function setEnabled($cacheType, $isEnabled)
/**
* Save the current statuses (enabled/disabled) of cache types to the persistent storage
+ *
+ * @return void
*/
public function persist()
{
diff --git a/lib/Magento/App/Cache/StateInterface.php b/lib/Magento/App/Cache/StateInterface.php
index e5b2672716704..814fcc14d298d 100644
--- a/lib/Magento/App/Cache/StateInterface.php
+++ b/lib/Magento/App/Cache/StateInterface.php
@@ -26,12 +26,12 @@
interface StateInterface
{
/**
- * Check if cache can be used for specific data type
+ * Whether a cache type is enabled at the moment or not
*
- * @param string $typeCode
+ * @param string $cacheType
* @return bool
*/
- public function isEnabled($typeCode);
+ public function isEnabled($cacheType);
/**
* Enable/disable a cache type in run-time
diff --git a/lib/Magento/App/Cache/Type/FrontendPool.php b/lib/Magento/App/Cache/Type/FrontendPool.php
index 456fd4258a9d8..cb1605414ef1d 100644
--- a/lib/Magento/App/Cache/Type/FrontendPool.php
+++ b/lib/Magento/App/Cache/Type/FrontendPool.php
@@ -18,17 +18,15 @@
* versions in the future. If you wish to customize Magento for your
* needs please refer to http://www.magentocommerce.com for more information.
*
- * @category Magento
- * @package Magento_Core
* @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
+namespace Magento\App\Cache\Type;
+
/**
* In-memory readonly pool of cache front-ends with enforced access control, specific to cache types
*/
-namespace Magento\App\Cache\Type;
-
class FrontendPool
{
/**
@@ -36,11 +34,21 @@ class FrontendPool
*/
private $_objectManager;
+ /**
+ * @var \Magento\App\Arguments
+ */
+ private $_arguments;
+
/**
* @var \Magento\App\Cache\Frontend\Pool
*/
private $_frontendPool;
+ /**
+ * @var array
+ */
+ private $_typeFrontendMap;
+
/**
* @var \Magento\Cache\FrontendInterface[]
*/
@@ -48,40 +56,61 @@ class FrontendPool
/**
* @param \Magento\ObjectManager $objectManager
+ * @param \Magento\App\Arguments $arguments
* @param \Magento\App\Cache\Frontend\Pool $frontendPool
+ * @param array $typeFrontendMap Format: array('' => '', ...)
*/
public function __construct(
\Magento\ObjectManager $objectManager,
- \Magento\App\Cache\Frontend\Pool $frontendPool
+ \Magento\App\Arguments $arguments,
+ \Magento\App\Cache\Frontend\Pool $frontendPool,
+ array $typeFrontendMap = array()
) {
$this->_objectManager = $objectManager;
+ $this->_arguments = $arguments;
$this->_frontendPool = $frontendPool;
+ $this->_typeFrontendMap = $typeFrontendMap;
}
/**
- * Retrieve cache frontend instance by its unique identifier, enforcing identifier-scoped access control
+ * Retrieve cache frontend instance by a cache type identifier, enforcing identifier-scoped access control
*
- * @param string $identifier Cache frontend identifier
+ * @param string $cacheType Cache type identifier
* @return \Magento\Cache\FrontendInterface Cache frontend instance
*/
- public function get($identifier)
+ public function get($cacheType)
{
- if (!isset($this->_instances[$identifier])) {
- $frontendInstance = $this->_frontendPool->get($identifier);
- if (!$frontendInstance) {
- $frontendInstance = $this->_frontendPool->get(
- \Magento\App\Cache\Frontend\Pool::DEFAULT_FRONTEND_ID
- );
- }
+ if (!isset($this->_instances[$cacheType])) {
+ $frontendId = $this->_getCacheFrontendId($cacheType);
+ $frontendInstance = $this->_frontendPool->get($frontendId);
/** @var $frontendInstance \Magento\App\Cache\Type\AccessProxy */
$frontendInstance = $this->_objectManager->create(
'Magento\App\Cache\Type\AccessProxy', array(
'frontend' => $frontendInstance,
- 'identifier' => $identifier,
+ 'identifier' => $cacheType,
)
);
- $this->_instances[$identifier] = $frontendInstance;
+ $this->_instances[$cacheType] = $frontendInstance;
+ }
+ return $this->_instances[$cacheType];
+ }
+
+ /**
+ * Retrieve cache frontend identifier, associated with a cache type
+ *
+ * @param string $cacheType
+ * @return string
+ */
+ protected function _getCacheFrontendId($cacheType)
+ {
+ $result = $this->_arguments->getCacheTypeFrontendId($cacheType);
+ if (!$result) {
+ if (isset($this->_typeFrontendMap[$cacheType])) {
+ $result = $this->_typeFrontendMap[$cacheType];
+ } else {
+ $result = \Magento\App\Cache\Frontend\Pool::DEFAULT_FRONTEND_ID;
+ }
}
- return $this->_instances[$identifier];
+ return $result;
}
}
diff --git a/lib/Magento/App/Cache/TypeList.php b/lib/Magento/App/Cache/TypeList.php
index 28f58aeb30431..b5d512e9c183e 100644
--- a/lib/Magento/App/Cache/TypeList.php
+++ b/lib/Magento/App/Cache/TypeList.php
@@ -101,6 +101,7 @@ protected function _getInvalidatedTypes()
* Save invalidated cache types
*
* @param array $types
+ * @return void
*/
protected function _saveInvalidatedTypes($types)
{
@@ -159,6 +160,7 @@ public function getInvalidated()
* Mark specific cache type(s) as invalidated
*
* @param string|array $typeCode
+ * @return void
*/
public function invalidate($typeCode)
{
@@ -176,6 +178,7 @@ public function invalidate($typeCode)
* Clean cached data for specific cache type
*
* @param string $typeCode
+ * @return void
*/
public function cleanType($typeCode)
{
diff --git a/lib/Magento/App/Config.php b/lib/Magento/App/Config.php
index 0cfc5010902f1..b6ba5c582157f 100644
--- a/lib/Magento/App/Config.php
+++ b/lib/Magento/App/Config.php
@@ -1,6 +1,6 @@
_loader = $loader;
- $this->_parameters = $parameters;
- $this->_data = array_replace_recursive($this->_parseParams($loader->load()), $parameters);
- }
-
- /**
- * @param array $input
- * @return array
- */
- protected function _parseParams(array $input)
- {
- $stack = $input;
- unset($stack['resource']);
- unset($stack['connection']);
- $separator = '.';
- $output = array();
-
- while ($stack) {
- list($key, $value) = each($stack);
- unset($stack[$key]);
- if (is_array($value)) {
- if (count($value)) {
- foreach ($value as $subKey => $node) {
- $build[$key . $separator . $subKey] = $node;
- }
- } else {
- $build[$key] = null;
- }
- $stack = $build + $stack;
- continue;
- }
- $output[$key] = $value;
- }
- $output['connection'] = isset($input['connection']) ? $input['connection'] : array();
- $output['resource'] = isset($input['resource']) ? $input['resource'] : array();
- return $output;
+ $this->_data = $loader->load();
}
/**
- * Retrieve connection configuration by connection name
+ * Retrieve config value by path
*
- * @param string $connectionName
- * @return array
+ * @param string $path
+ * @return mixed
*/
- public function getConnection($connectionName)
+ public function getValue($path = null)
{
- return isset($this->_data['connection'][$connectionName])
- ? $this->_data['connection'][$connectionName]
- : null;
+ return $this->_data->getValue($path);
}
/**
- * Retrieve list of connections
+ * Set config value
*
- * @return array
+ * @param string $path
+ * @param mixed $value
+ * @return void
*/
- public function getConnections()
+ public function setValue($path, $value)
{
- return isset($this->_data['connection']) ? $this->_data['connection'] : array();
+ $this->_data->setValue($path, $value);
}
/**
- * Retrieve list of resources
+ * Retrieve config flag
*
- * @return array
- */
- public function getResources()
- {
- return $this->_data['resource'];
- }
-
- /**
- * Retrieve key
- *
- * @param string $key
- * @param mixed $defaultValue
- * @return array|null
- */
- public function get($key = null, $defaultValue = null)
- {
- if ($key === null) {
- return $this->_data;
- }
- return isset($this->_data[$key]) ? $this->_data[$key] : $defaultValue;
- }
-
- /**
- * Reload local.xml
+ * @param string $path
+ * @return bool
*/
- public function reload()
+ public function isSetFlag($path)
{
- $this->_data = array_replace_recursive($this->_parseParams($this->_loader->load()), $this->_parameters);
+ return (bool)$this->_data->getValue($path);
}
}
diff --git a/lib/Magento/App/Config/Data.php b/lib/Magento/App/Config/Data.php
new file mode 100644
index 0000000000000..ec1b0e2571ac0
--- /dev/null
+++ b/lib/Magento/App/Config/Data.php
@@ -0,0 +1,88 @@
+_data = $processor->process($data);
+ }
+
+ /**
+ * Retrieve configuration value by path
+ *
+ * @param null|string $path
+ * @return array|string
+ */
+ public function getValue($path = null)
+ {
+ if ($path === null) {
+ return $this->_data;
+ }
+ $keys = explode('/', $path);
+ $data = $this->_data;
+ foreach ($keys as $key) {
+ if (is_array($data) && array_key_exists($key, $data)) {
+ $data = $data[$key];
+ } else {
+ return false;
+ }
+ }
+ return $data;
+ }
+
+ /**
+ * Set configuration value
+ *
+ * @param string $path
+ * @param mixed $value
+ */
+ public function setValue($path, $value)
+ {
+ $keys = explode('/', $path);
+ $lastKey = array_pop($keys);
+ $currentElement = &$this->_data;
+ foreach ($keys as $key) {
+ if (!isset($currentElement[$key])) {
+ $currentElement[$key] = array();
+ }
+ $currentElement = &$currentElement[$key];
+ }
+ $currentElement[$lastKey] = $value;
+ }
+}
diff --git a/lib/Magento/App/Config/Data/ProcessorFactory.php b/lib/Magento/App/Config/Data/ProcessorFactory.php
new file mode 100644
index 0000000000000..34231c3338ee4
--- /dev/null
+++ b/lib/Magento/App/Config/Data/ProcessorFactory.php
@@ -0,0 +1,68 @@
+_objectManager = $objectManager;
+ }
+
+ /**
+ * Get concrete Processor Interface instance
+ *
+ * @param string $model
+ * @return \Magento\App\Config\Data\ProcessorInterface
+ * @throws \InvalidArgumentException
+ */
+ public function get($model)
+ {
+ if (!isset($this->_pool[$model])) {
+ $instance = $this->_objectManager->create($model);
+ if (!($instance instanceof \Magento\App\Config\Data\ProcessorInterface)) {
+ throw new \InvalidArgumentException(
+ $model . ' does not instance of \Magento\App\Config\Data\ProcessorInterface'
+ );
+ }
+ $this->_pool[$model] = $instance;
+ }
+ return $this->_pool[$model];
+ }
+}
diff --git a/lib/Magento/App/Config/Data/ProcessorInterface.php b/lib/Magento/App/Config/Data/ProcessorInterface.php
new file mode 100644
index 0000000000000..7e5bfd3b6cf46
--- /dev/null
+++ b/lib/Magento/App/Config/Data/ProcessorInterface.php
@@ -0,0 +1,37 @@
+_objectManager = $objectManager;
+ $this->_instanceName = $instanceName;
+ }
+
+ /**
+ * Create class instance with specified parameters
+ *
+ * @param array $data
+ * @return \Magento\Core\Model\Config\Data
+ */
+ public function create(array $data = array())
+ {
+ return $this->_objectManager->create($this->_instanceName, $data);
+ }
+}
diff --git a/lib/Magento/App/Config/DataInterface.php b/lib/Magento/App/Config/DataInterface.php
new file mode 100644
index 0000000000000..b5bd72eca6d61
--- /dev/null
+++ b/lib/Magento/App/Config/DataInterface.php
@@ -0,0 +1,33 @@
+load(self::CACHE_ID);
+ if (!$data) {
+ $data = $reader->read();
+ $cache->save(serialize($data), self::CACHE_ID);
+ } else {
+ $data = unserialize($data);
+ }
+ $this->_data = $data['data'];
+ $this->_metadata = $data['metadata'];
+ }
+
+ /**
+ * Get initial data by given scope
+ *
+ * @return mixed
+ */
+ public function getData($scope)
+ {
+ list($scopeType, $scopeCode) = array_pad(explode('|', $scope), 2, null);
+
+ if ('default' == $scopeType) {
+ return isset($this->_data[$scopeType]) ? $this->_data[$scopeType] : array();
+ } elseif ($scopeCode) {
+ return isset($this->_data[$scopeType][$scopeCode]) ? $this->_data[$scopeType][$scopeCode] : array();
+ }
+ return array();
+ }
+
+ /**
+ * Get configuration metadata
+ *
+ * @return array
+ */
+ public function getMetadata()
+ {
+ return $this->_metadata;
+ }
+}
diff --git a/lib/Magento/App/Config/Initial/Reader.php b/lib/Magento/App/Config/Initial/Reader.php
new file mode 100644
index 0000000000000..acea58d6b3952
--- /dev/null
+++ b/lib/Magento/App/Config/Initial/Reader.php
@@ -0,0 +1,138 @@
+_schemaFile = $validationState->isValidated() ? $schemaLocator->getSchema() : null;
+ $this->_fileResolver = $fileResolver;
+ $this->_converter = $converter;
+ $this->_domDocumentClass = $domDocumentClass;
+ $this->_fileName = $fileName;
+ }
+
+ /**
+ * Read configuration scope
+ *
+ * @return array
+ *
+ * @throws \Magento\Exception
+ */
+ public function read()
+ {
+ $fileList = array();
+ foreach ($this->_scopePriorityScheme as $scope) {
+ $fileList = array_merge($fileList, $this->_fileResolver->get($this->_fileName, $scope));
+ }
+
+ if (!count($fileList)) {
+ return array();
+ }
+
+ /** @var \Magento\Config\Dom $domDocument */
+ $domDocument = null;
+ foreach ($fileList as $file) {
+ try {
+ if (is_null($domDocument)) {
+ $class = $this->_domDocumentClass;
+ $domDocument = new $class(
+ file_get_contents($file),
+ array(),
+ $this->_schemaFile
+ );
+ } else {
+ $domDocument->merge(file_get_contents($file));
+ }
+ } catch (\Magento\Config\Dom\ValidationException $e) {
+ throw new \Magento\Exception("Invalid XML in file " . $file . ":\n" . $e->getMessage());
+ }
+ }
+
+ $output = array();
+ if ($domDocument) {
+ $output = $this->_converter->convert($domDocument->getDom());
+ }
+ return $output;
+ }
+}
diff --git a/lib/Magento/App/Config/Initial/SchemaLocator.php b/lib/Magento/App/Config/Initial/SchemaLocator.php
new file mode 100644
index 0000000000000..aa44979186b9e
--- /dev/null
+++ b/lib/Magento/App/Config/Initial/SchemaLocator.php
@@ -0,0 +1,65 @@
+_schema = $moduleReader->getModuleDir('etc', $moduleName) . '/config.xsd';
+ }
+
+ /**
+ * 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->_schema;
+ }
+}
diff --git a/lib/Magento/App/Config/Loader.php b/lib/Magento/App/Config/Loader.php
index cc9b53bd766a4..d45fb0c7ed938 100644
--- a/lib/Magento/App/Config/Loader.php
+++ b/lib/Magento/App/Config/Loader.php
@@ -1,6 +1,6 @@
'name', '/config/connection' => 'name');
+ protected $_scopePool;
/**
- * @param \Magento\App\Filesystem\DirectoryList $dirList
- * @param string $customFile
+ * @param \Magento\App\Config\Scope\Resolver $scopeResolver
+ * @param \Magento\App\Config\ScopePool $scopePool
*/
- public function __construct(\Magento\App\Filesystem\DirectoryList $dirList, $customFile = null)
- {
- $this->_dir = $dirList->getDir(\Magento\App\Filesystem::CONFIG_DIR);
- $this->_customFile = $customFile;
+ public function __construct(
+ \Magento\App\Config\Scope\Resolver $scopeResolver,
+ \Magento\App\Config\ScopePool $scopePool
+ ) {
+ $this->_scopeResolver = $scopeResolver;
+ $this->_scopePool = $scopePool;
}
/**
- * Load configuration
+ * Process of config loading
*
- * @return array
+ * @return \Magento\App\Config\DataInterface
*/
public function load()
{
- $localConfig = new \Magento\Config\Dom('', $this->_idAttributes);
-
- $localConfigFile = $this->_dir . '/' . self::LOCAL_CONFIG_FILE;
- if (file_exists($localConfigFile)) {
- // 1. app/etc/local.xml
- $localConfig->merge(file_get_contents($localConfigFile));
-
- // 2. app/etc//.xml
- if (preg_match('/^[a-z\d_-]+(\/|\\\)+[a-z\d_-]+\.xml$/', $this->_customFile)) {
- $localConfigExtraFile = $this->_dir . '/' . $this->_customFile;
- $localConfig->merge(file_get_contents($localConfigExtraFile));
- }
- }
-
- $converter = new \Magento\Config\Converter\Dom\Flat($this->_idAttributes);
-
- $result = $converter->convert($localConfig->getDom());
- return !empty($result['config']) ? $result['config'] : array();
+ return $this->_scopePool->getScope($this->_scopeResolver->getScope());
}
}
diff --git a/lib/Magento/App/Config/LoaderInterface.php b/lib/Magento/App/Config/LoaderInterface.php
new file mode 100644
index 0000000000000..80c9c79a92900
--- /dev/null
+++ b/lib/Magento/App/Config/LoaderInterface.php
@@ -0,0 +1,35 @@
+_processorFactory = $processorFactory;
+ $this->_metadata = $initialConfig->getMetadata();
+ }
+
+ /**
+ * Retrieve array value by path
+ *
+ * @param array $data
+ * @param string $path
+ * @return string|null
+ */
+ protected function _getValue(array $data, $path)
+ {
+ $keys = explode('/', $path);
+ foreach ($keys as $key) {
+ if (is_array($data) && array_key_exists($key, $data)) {
+ $data = $data[$key];
+ } else {
+ return null;
+ }
+ }
+ return $data;
+ }
+
+ /**
+ * Set array value by path
+ *
+ * @param array $container
+ * @param string $path
+ * @param string $value
+ */
+ protected function _setValue(array &$container, $path, $value)
+ {
+ $segments = explode('/', $path);
+ $currentPointer = &$container;
+ foreach ($segments as $segment) {
+ if (!isset($currentPointer[$segment])) {
+ $currentPointer[$segment] = array();
+ }
+ $currentPointer = &$currentPointer[$segment];
+ }
+ $currentPointer = $value;
+ }
+
+ /**
+ * Process config data
+ *
+ * @param array $data
+ * @return array
+ */
+ public function process(array $data)
+ {
+ foreach ($this->_metadata as $path => $metadata) {
+ /** @var \Magento\App\Config\Data\ProcessorInterface $processor */
+ $processor = $this->_processorFactory->get($metadata['backendModel']);
+ $value = $processor->processValue($this->_getValue($data, $path));
+ $this->_setValue($data, $path, $value);
+ }
+ return $data;
+ }
+}
diff --git a/lib/Magento/App/Config/Scope/FactoryInterface.php b/lib/Magento/App/Config/Scope/FactoryInterface.php
new file mode 100644
index 0000000000000..2d9e7e9140b6e
--- /dev/null
+++ b/lib/Magento/App/Config/Scope/FactoryInterface.php
@@ -0,0 +1,37 @@
+_initialConfig = $initialConfig;
+ $this->_converter = $converter;
+ $this->_processor = $processor;
+ $this->_scopeFactory = $scopeFactory;
+ $this->_scopeHierarchy = $scopeHierarchy;
+ }
+
+ public function read($scope)
+ {
+ $config = array();
+ $scopes = $this->_scopeHierarchy->getHierarchy($scope);
+ foreach ($scopes as $scope) {
+ $config = array_replace_recursive($config, $this->_getInitialConfigData($scope));
+ $config = array_replace_recursive($config, $this->_getExtendedConfigData($scope));
+ }
+ return $this->_processor->processValue($config);
+ }
+
+ /**
+ * Retrieve initial scope config from xml files
+ *
+ * @param string $scope
+ * @return array
+ */
+ protected function _getInitialConfigData($scope)
+ {
+ return $this->_initialConfig->getData($scope);
+ }
+
+ /**
+ * Retrieve scope config from database
+ *
+ * @param string $scope
+ * @return array
+ */
+ protected function _getExtendedConfigData($scope)
+ {
+ list($scopeType, $scopeCode) = array_pad(explode('|', $scope), 2, null);
+ if (null === $scopeCode) {
+ $collection = $this->_scopeFactory->create(array('scope' => $scopeType));
+ } else {
+ $collection = $this->_scopeFactory->create(array('scope' => $scopeType, 'scopeId' => $scopeCode));
+ }
+
+ $config = array();
+ foreach ($collection as $item) {
+ $config[$item->getPath()] = $item->getValue();
+ }
+ return $this->_converter->convert($config);
+ }
+}
diff --git a/lib/Magento/App/Config/Scope/Resolver.php b/lib/Magento/App/Config/Scope/Resolver.php
new file mode 100644
index 0000000000000..e4ddd586d0a7e
--- /dev/null
+++ b/lib/Magento/App/Config/Scope/Resolver.php
@@ -0,0 +1,38 @@
+_reader = $reader;
+ $this->_dataFactory = $dataFactory;
+ $this->_cache = $cache;
+ $this->_cacheId = $cacheId;
+ }
+
+ /**
+ * Retrieve config section
+ *
+ * @param string $scope
+ * @return \Magento\App\Config\Data
+ */
+ public function getScope($scope)
+ {
+ if (!isset($this->_scopes[$scope])) {
+ $cacheKey = $this->_cacheId . '|' . $scope;
+ $data = $this->_cache->load($cacheKey);
+ if ($data) {
+ $data = unserialize($data);
+ } else {
+ $data = $this->_reader->read($scope);
+ $this->_cache->save(serialize($data), $cacheKey, array(self::CACHE_TAG));
+ }
+ $this->_scopes[$scope] = $this->_dataFactory->create(array('data' => $data));
+ }
+ return $this->_scopes[$scope];
+ }
+
+ /**
+ * Clear all stired sections
+ */
+ public function clean()
+ {
+ $this->_scopes = array();
+ $this->_cache->clean(\Zend_Cache::CLEANING_MODE_MATCHING_TAG, array(self::CACHE_TAG));
+ }
+}
diff --git a/lib/Magento/App/Config/ValueInterface.php b/lib/Magento/App/Config/ValueInterface.php
new file mode 100644
index 0000000000000..a245a7827c8a9
--- /dev/null
+++ b/lib/Magento/App/Config/ValueInterface.php
@@ -0,0 +1,57 @@
+/groups//fields/
+ *
+ * @param string $key
+ * @return string
+ */
+ public function getFieldsetDataValue($key);
+}
diff --git a/app/code/Magento/Core/Model/ConfigInterface.php b/lib/Magento/App/ConfigInterface.php
similarity index 68%
rename from app/code/Magento/Core/Model/ConfigInterface.php
rename to lib/Magento/App/ConfigInterface.php
index fd3f83e7e7aea..b162c13685c10 100644
--- a/app/code/Magento/Core/Model/ConfigInterface.php
+++ b/lib/Magento/App/ConfigInterface.php
@@ -1,6 +1,6 @@
_state->setAreaCode('crontab');
$this->_eventManager->dispatch('default');
diff --git a/lib/Magento/App/EntryPoint/EntryPoint.php b/lib/Magento/App/EntryPoint/EntryPoint.php
index 7b06d10e4f8ee..15b73061158bb 100644
--- a/lib/Magento/App/EntryPoint/EntryPoint.php
+++ b/lib/Magento/App/EntryPoint/EntryPoint.php
@@ -79,7 +79,7 @@ public function run($applicationName, array $arguments = array())
$this->_locator = $locatorFactory->create($this->_rootDir, $this->_parameters);
}
$application = $this->_locator->create($applicationName, $arguments);
- $response = $application->execute();
+ $response = $application->launch();
\Magento\Profiler::stop('magento');
$response->sendResponse();
} catch (\Exception $exception) {
diff --git a/lib/Magento/App/Error/Handler.php b/lib/Magento/App/Error/Handler.php
index fe9ec9bf17796..48e60585a95b8 100644
--- a/lib/Magento/App/Error/Handler.php
+++ b/lib/Magento/App/Error/Handler.php
@@ -64,6 +64,7 @@ public function __construct(
*
* @param \Exception $exception
* @param array $params
+ * @return void
*/
public function processException(\Exception $exception, array $params = array())
{
@@ -87,7 +88,9 @@ public function processException(\Exception $exception, array $params = array())
/**
* Show error as exception or log it
*
+ * @param string $errorMessage
* @throws \Exception
+ * @return void
*/
protected function _processError($errorMessage)
{
diff --git a/lib/Magento/App/Filesystem/DirectoryList/Configuration.php b/lib/Magento/App/Filesystem/DirectoryList/Configuration.php
index 10ab31caaa7d8..120338b7d27ab 100644
--- a/lib/Magento/App/Filesystem/DirectoryList/Configuration.php
+++ b/lib/Magento/App/Filesystem/DirectoryList/Configuration.php
@@ -62,9 +62,9 @@ class Configuration
/**
* Store directory configuration
*
- * @param \Magento\Core\Model\ConfigInterface $config
+ * @param \Magento\App\ConfigInterface $config
*/
- public function __construct(\Magento\Core\Model\ConfigInterface $config)
+ public function __construct(\Magento\App\ConfigInterface $config)
{
$this->directories = $config->getValue(self::XML_FILESYSTEM_DIRECTORY_PATH) ?: array();
$this->protocols = $config->getValue(self::XML_FILESYSTEM_WRAPPER_PATH) ?: array();
@@ -74,6 +74,7 @@ public function __construct(\Magento\Core\Model\ConfigInterface $config)
* Add directories from configuration to Filesystem
*
* @param DirectoryList $directoryList
+ * @return void
*/
public function configure(DirectoryList $directoryList)
{
diff --git a/lib/Magento/App/Filesystem/DirectoryList/Verification.php b/lib/Magento/App/Filesystem/DirectoryList/Verification.php
index 4ceae682f96cc..7d0e29933946b 100644
--- a/lib/Magento/App/Filesystem/DirectoryList/Verification.php
+++ b/lib/Magento/App/Filesystem/DirectoryList/Verification.php
@@ -25,16 +25,17 @@
*/
namespace Magento\App\Filesystem\DirectoryList;
-use Magento\App\State,
- Magento\Filesystem\FilesystemException,
- Magento\App\Filesystem;
+use Magento\App\State;
+use Magento\BootstrapException;
+use Magento\App\Filesystem;
+use Magento\Filesystem\FilesystemException;
class Verification
{
/**
* Codes of directories to create and verify in production mode
*
- * @var array
+ * @var string[]
*/
protected static $productionDirs = array(
Filesystem::SESSION_DIR,
@@ -45,7 +46,7 @@ class Verification
/**
* Codes of directories to create and verify in non-production mode
*
- * @var array
+ * @var string[]
*/
protected static $nonProductionDirs = array(
Filesystem::SESSION_DIR,
@@ -61,7 +62,7 @@ class Verification
/**
* Cached list of directories to create and verify write access
*
- * @var array
+ * @var string[]
*/
protected $dirsToVerify = array();
@@ -81,7 +82,7 @@ public function __construct(Filesystem $filesystem, State $appState)
* Return list of directories, that must be verified according to the application mode
*
* @param State $appState
- * @return array
+ * @return string[]
*/
protected function _getDirsToVerify(State $appState)
{
@@ -93,6 +94,10 @@ protected function _getDirsToVerify(State $appState)
/**
* Create the required directories, if they don't exist, and verify write access for existing directories
+ *
+ * @return void
+ * @throws BootstrapException
+ *
*/
public function createAndVerifyDirectories()
{
@@ -114,7 +119,7 @@ public function createAndVerifyDirectories()
if ($fails) {
$dirList = implode(', ', $fails);
- throw new \Magento\BootstrapException(
+ throw new BootstrapException(
"Cannot create or verify write access: {$dirList}"
);
}
diff --git a/lib/Magento/App/Http.php b/lib/Magento/App/Http.php
index e1be703a08d8c..a396fed765d94 100644
--- a/lib/Magento/App/Http.php
+++ b/lib/Magento/App/Http.php
@@ -31,7 +31,7 @@
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class Http implements \Magento\AppInterface
+class Http implements \Magento\LauncherInterface
{
/**
* @var \Magento\ObjectManager
@@ -108,7 +108,7 @@ public function __construct(
*
* @return ResponseInterface
*/
- public function execute()
+ public function launch()
{
try {
$areaCode = $this->_areaList->getCodeByFrontName($this->_request->getFrontName());
diff --git a/lib/Magento/App/ObjectManager.php b/lib/Magento/App/ObjectManager.php
index b2a89e1431ab6..cb739abc5d6d2 100644
--- a/lib/Magento/App/ObjectManager.php
+++ b/lib/Magento/App/ObjectManager.php
@@ -47,7 +47,7 @@ class ObjectManager extends \Magento\ObjectManager\ObjectManager
* TODO: Temporary solution for serialization, should be removed when Serialization problem is resolved
*
* @deprecated
- * @return \Magento\ObjectManager
+ * @return \Magento\App\ObjectManager
* @throws \RuntimeException
*/
public static function getInstance()
@@ -63,6 +63,7 @@ public static function getInstance()
*
* @param \Magento\ObjectManager $objectManager
* @throws \LogicException
+ * @return void
*/
public static function setInstance(\Magento\ObjectManager $objectManager)
{
diff --git a/lib/Magento/App/ObjectManager/ConfigCache.php b/lib/Magento/App/ObjectManager/ConfigCache.php
index f929141ee8e27..26640327d3c9e 100644
--- a/lib/Magento/App/ObjectManager/ConfigCache.php
+++ b/lib/Magento/App/ObjectManager/ConfigCache.php
@@ -64,6 +64,7 @@ public function get($key)
*
* @param array $config
* @param string $key
+ * @return void
*/
public function save(array $config, $key)
{
diff --git a/lib/Magento/App/ObjectManager/ConfigLoader/Primary.php b/lib/Magento/App/ObjectManager/ConfigLoader/Primary.php
index e3f7c36b74ab4..951fd0c29c87a 100644
--- a/lib/Magento/App/ObjectManager/ConfigLoader/Primary.php
+++ b/lib/Magento/App/ObjectManager/ConfigLoader/Primary.php
@@ -59,7 +59,7 @@ public function __construct(
public function load()
{
$reader = new \Magento\ObjectManager\Config\Reader\Dom(
- new \Magento\App\Config\FileResolver\Primary(
+ new \Magento\App\Arguments\FileResolver\Primary(
new \Magento\App\Filesystem(
$this->_directoryList,
new \Magento\Filesystem\Directory\ReadFactory(),
@@ -69,7 +69,7 @@ public function load()
),
new \Magento\ObjectManager\Config\Mapper\Dom(),
new \Magento\ObjectManager\Config\SchemaLocator(),
- new \Magento\App\Config\ValidationState($this->_appMode)
+ new \Magento\App\Arguments\ValidationState($this->_appMode)
);
return $reader->read('primary');
diff --git a/lib/Magento/App/ObjectManagerFactory.php b/lib/Magento/App/ObjectManagerFactory.php
index 336e9d9981a51..f86e841841cd3 100644
--- a/lib/Magento/App/ObjectManagerFactory.php
+++ b/lib/Magento/App/ObjectManagerFactory.php
@@ -26,7 +26,7 @@
namespace Magento\App;
-use Magento\App\Config,
+use Magento\App\Arguments,
Magento\Profiler,
Magento\App\Filesystem;
@@ -73,12 +73,12 @@ public function create($rootDir, array $arguments)
array($directoryList->getDir(\Magento\App\Filesystem::GENERATION_DIR))
);
- $options = new Config(
+ $options = new \Magento\App\Arguments(
$arguments,
- new Config\Loader(
+ new \Magento\App\Arguments\Loader(
$directoryList,
- isset($arguments[Config\Loader::PARAM_CUSTOM_FILE])
- ? $arguments[Config\Loader::PARAM_CUSTOM_FILE]
+ isset($arguments[\Magento\App\Arguments\Loader::PARAM_CUSTOM_FILE])
+ ? $arguments[\Magento\App\Arguments\Loader::PARAM_CUSTOM_FILE]
: null
)
);
@@ -108,7 +108,7 @@ public function create($rootDir, array $arguments)
$className = $this->_locatorClassName;
/** @var \Magento\ObjectManager $objectManager */
$objectManager = new $className($factory, $diConfig, array(
- 'Magento\App\Config' => $options,
+ 'Magento\App\Arguments' => $options,
'Magento\App\Filesystem\DirectoryList' => $directoryList,
'Magento\Filesystem\DirectoryList' => $directoryList
));
diff --git a/lib/Magento/App/ReinitableConfigInterface.php b/lib/Magento/App/ReinitableConfigInterface.php
new file mode 100644
index 0000000000000..b202e5e9ac673
--- /dev/null
+++ b/lib/Magento/App/ReinitableConfigInterface.php
@@ -0,0 +1,37 @@
+_route;
@@ -273,7 +300,7 @@ public function getHttpHost($trimPort = true)
* @param string|array $key
* @param mixed $value
*
- * @return \Magento\App\RequestInterface
+ * @return $this
*/
public function setPost($key, $value = null)
{
@@ -288,8 +315,8 @@ public function setPost($key, $value = null)
/**
* Specify module name where was found currently used controller
*
- * @param string $module
- * @return \Magento\App\RequestInterface
+ * @param string $module
+ * @return $this
*/
public function setControllerModule($module)
{
@@ -357,7 +384,7 @@ public function getAlias($name)
/**
* Retrieve the list of all aliases
*
- * @return array
+ * @return array|string
*/
public function getAliases()
{
@@ -425,7 +452,7 @@ public function getRequestedActionName()
* Set routing info data
*
* @param array $data
- * @return \Magento\App\RequestInterface
+ * @return $this
*/
public function setRoutingInfo($data)
{
@@ -439,7 +466,7 @@ public function setRoutingInfo($data)
* Collect properties changed by _forward in protected storage
* before _forward was called first time.
*
- * @return \Magento\App\ActionInterface
+ * @return $this
*/
public function initForward()
{
@@ -511,8 +538,8 @@ public function isAjax()
* If no $key is passed, returns the entire $_FILES array.
*
* @param string $key
- * @param mixed $default Default value to use if key not found
- * @return mixed
+ * @param array $default Default value to use if key not found
+ * @return array
*/
public function getFiles($key = null, $default = null)
{
@@ -553,7 +580,7 @@ public function getDistroBaseUrl()
* Retrieve full action name
*
* @param string $delimiter
- * @return mixed|string
+ * @return string
*/
public function getFullActionName($delimiter = '_')
{
diff --git a/lib/Magento/App/Resource.php b/lib/Magento/App/Resource.php
index b27a23b064291..cb2f344bde516 100644
--- a/lib/Magento/App/Resource.php
+++ b/lib/Magento/App/Resource.php
@@ -96,6 +96,7 @@ public function __construct(
* Set cache instance
*
* @param \Magento\App\CacheInterface $cache
+ * @return void
*/
public function setCache(\Magento\App\CacheInterface $cache)
{
@@ -107,6 +108,7 @@ public function setCache(\Magento\App\CacheInterface $cache)
* Added for console installation
*
* @param string $tablePrefix
+ * @return void
*/
public function setTablePrefix($tablePrefix)
{
@@ -139,7 +141,7 @@ public function getConnection($resourceName)
/**
* Get resource table name, validated by db adapter
*
- * @param string|array $modelEntity
+ * @param string|string[] $modelEntity
* @return string
*/
public function getTableName($modelEntity)
@@ -172,7 +174,7 @@ public function getTableName($modelEntity)
*
* @param string $tableName
* @param string $mappedName
- * @return \Magento\App\Resource
+ * @return $this
*/
public function setMappedTableName($tableName, $mappedName)
{
@@ -199,7 +201,7 @@ public function getMappedTableName($tableName)
* Retrieve 32bit UNIQUE HASH for a Table index
*
* @param string $tableName
- * @param array|string $fields
+ * @param string|string[] $fields
* @param string $indexType
* @return string
*/
diff --git a/lib/Magento/App/Resource/ConnectionFactory.php b/lib/Magento/App/Resource/ConnectionFactory.php
index 36739bc81090e..b19bba5f040a9 100644
--- a/lib/Magento/App/Resource/ConnectionFactory.php
+++ b/lib/Magento/App/Resource/ConnectionFactory.php
@@ -33,15 +33,15 @@ class ConnectionFactory
protected $_objectManager;
/**
- * @var \Magento\App\Config
+ * @var \Magento\App\Arguments
*/
protected $_localConfig;
/**
* @param \Magento\ObjectManager $objectManager
- * @param \Magento\App\Config $localConfig
+ * @param \Magento\App\Arguments $localConfig
*/
- public function __construct(\Magento\ObjectManager $objectManager, \Magento\App\Config $localConfig)
+ public function __construct(\Magento\ObjectManager $objectManager, \Magento\App\Arguments $localConfig)
{
$this->_objectManager = $objectManager;
$this->_localConfig = $localConfig;
diff --git a/lib/Magento/App/Route/Config.php b/lib/Magento/App/Route/Config.php
index a2eb55dc5ba68..3edddf058890d 100644
--- a/lib/Magento/App/Route/Config.php
+++ b/lib/Magento/App/Route/Config.php
@@ -136,7 +136,7 @@ public function getRouteByFrontName($frontName, $scope = null)
/**
* @param string $frontName
* @param string $scope
- * @return array
+ * @return string[]
*/
public function getModulesByFrontName($frontName, $scope = null)
{
diff --git a/lib/Magento/App/Route/Config/Converter.php b/lib/Magento/App/Route/Config/Converter.php
index 23bea70fc0007..769c01e92970b 100644
--- a/lib/Magento/App/Route/Config/Converter.php
+++ b/lib/Magento/App/Route/Config/Converter.php
@@ -30,7 +30,7 @@ class Converter implements \Magento\Config\ConverterInterface
/**
* Convert config
*
- * @param mixed $source
+ * @param \DOMDocument $source
* @return array
*/
public function convert($source)
diff --git a/lib/Magento/App/Router/NoRouteHandlerList.php b/lib/Magento/App/Router/NoRouteHandlerList.php
index 319dbf878248a..3e37010e5da19 100644
--- a/lib/Magento/App/Router/NoRouteHandlerList.php
+++ b/lib/Magento/App/Router/NoRouteHandlerList.php
@@ -30,7 +30,7 @@ class NoRouteHandlerList
/**
* No route handlers instances
*
- * @var array
+ * @var NoRouteHandlerInterface[]
*/
protected $_handlers;
@@ -59,7 +59,7 @@ public function __construct(
/**
* Get noRoute handlers
*
- * @return array
+ * @return NoRouteHandlerInterface[]
*/
public function getHandlers()
{
diff --git a/lib/Magento/App/RouterList.php b/lib/Magento/App/RouterList.php
index 57c0f73ce3f36..a3a2a4a84c758 100644
--- a/lib/Magento/App/RouterList.php
+++ b/lib/Magento/App/RouterList.php
@@ -96,7 +96,7 @@ public function next()
* (PHP 5 >= 5.0.0)
* Return the key of the current element
* @link http://php.net/manual/en/iterator.key.php
- * @return mixed scalar on success, or null on failure.
+ * @return void
*/
public function key()
{
diff --git a/lib/Magento/App/State.php b/lib/Magento/App/State.php
index e0738c53d1995..6841394294d1e 100644
--- a/lib/Magento/App/State.php
+++ b/lib/Magento/App/State.php
@@ -129,6 +129,7 @@ public function getMode()
* Set update mode flag
*
* @param bool $value
+ * @return void
*/
public function setUpdateMode($value)
{
@@ -150,6 +151,7 @@ public function getUpdateMode()
* Set is downloader flag
*
* @param bool $flag
+ * @return void
*/
public function setIsDownloader($flag = true)
{
@@ -160,6 +162,7 @@ public function setIsDownloader($flag = true)
* Set install date
*
* @param string $date
+ * @return void
*/
public function setInstallDate($date)
{
@@ -170,6 +173,7 @@ public function setInstallDate($date)
* Set area code
*
* @param string $code
+ * @return void
* @throws \Magento\Exception
*/
public function setAreaCode($code)
diff --git a/lib/Magento/App/View.php b/lib/Magento/App/View.php
index 1c40719bf415a..461b274acaa5e 100644
--- a/lib/Magento/App/View.php
+++ b/lib/Magento/App/View.php
@@ -155,7 +155,7 @@ public function getDefaultLayoutHandle()
/**
* Add layout handle by full controller action name
*
- * @return \Magento\App\ActionInterface
+ * @return $this
*/
public function addActionLayoutHandles()
{
@@ -168,12 +168,13 @@ public function addActionLayoutHandles()
/**
* Add layout updates handles associated with the action page
*
- * @param array $parameters page parameters
+ * @param array|null $parameters page parameters
+ * @param string|null $defaultHandle
* @return bool
*/
- public function addPageLayoutHandles(array $parameters = array())
+ public function addPageLayoutHandles(array $parameters = array(), $defaultHandle = null)
{
- $handle = $this->getDefaultLayoutHandle();
+ $handle = $defaultHandle ? $defaultHandle : $this->getDefaultLayoutHandle();
$pageHandles = array($handle);
foreach ($parameters as $key => $value) {
$pageHandles[] = $handle . '_' . $key . '_' . $value;
@@ -185,7 +186,7 @@ public function addPageLayoutHandles(array $parameters = array())
/**
* Load layout updates
*
- * @return \Magento\App\View
+ * @return $this
*/
public function loadLayoutUpdates()
{
@@ -209,7 +210,7 @@ public function loadLayoutUpdates()
/**
* Generate layout xml
*
- * @return \Magento\App\View
+ * @return $this
*/
public function generateLayoutXml()
{
@@ -226,7 +227,7 @@ public function generateLayoutXml()
/**
* Generate layout blocks
*
- * @return \Magento\App\View
+ * @return $this
*/
public function generateLayoutBlocks()
{
@@ -260,7 +261,7 @@ public function generateLayoutBlocks()
* Rendering layout
*
* @param string $output
- * @return \Magento\App\View
+ * @return $this
*/
public function renderLayout($output = '')
{
@@ -294,6 +295,7 @@ public function renderLayout($output = '')
* Set isLayoutLoaded flag
*
* @param bool $value
+ * @return void
*/
public function setIsLayoutLoaded($value)
{
diff --git a/lib/Magento/App/ViewInterface.php b/lib/Magento/App/ViewInterface.php
index 426ff234583f7..80c87c5da8bf8 100644
--- a/lib/Magento/App/ViewInterface.php
+++ b/lib/Magento/App/ViewInterface.php
@@ -69,9 +69,10 @@ public function generateLayoutXml();
* Add layout updates handles associated with the action page
*
* @param array $parameters page parameters
+ * @param string $defaultHandle
* @return bool
*/
- public function addPageLayoutHandles(array $parameters = array());
+ public function addPageLayoutHandles(array $parameters = array(), $defaultHandle = null);
/**
* Generate layout blocks
@@ -101,4 +102,4 @@ public function addActionLayoutHandles();
*/
public function setIsLayoutLoaded($value);
-}
\ No newline at end of file
+}
diff --git a/lib/Magento/AppInterface.php b/lib/Magento/AppInterface.php
index 4917d90d3bf56..f97208563466e 100644
--- a/lib/Magento/AppInterface.php
+++ b/lib/Magento/AppInterface.php
@@ -1,6 +1,6 @@
_isWritableMode($mode);
@@ -261,6 +274,7 @@ protected function _isReadableMode($mode) {
/**
* Check whether file is opened
*
+ * @return void
* @throws \Magento\Exception
*/
protected function _checkFileOpened()
diff --git a/lib/Magento/Archive/Helper/File/Bz.php b/lib/Magento/Archive/Helper/File/Bz.php
index 93318c1110c0e..6da426c5b380f 100644
--- a/lib/Magento/Archive/Helper/File/Bz.php
+++ b/lib/Magento/Archive/Helper/File/Bz.php
@@ -30,10 +30,7 @@
class Bz extends \Magento\Archive\Helper\File
{
/**
- * Open bz archive file
- *
- * @throws \Magento\Exception
- * @param string $mode
+ * {@inheritdoc}
*/
protected function _open($mode)
{
@@ -45,10 +42,7 @@ protected function _open($mode)
}
/**
- * Write data to bz archive
- *
- * @throws \Magento\Exception
- * @param $data
+ * {@inheritdoc}
*/
protected function _write($data)
{
@@ -60,11 +54,7 @@ protected function _write($data)
}
/**
- * Read data from bz archive
- *
- * @throws \Magento\Exception
- * @param int $length
- * @return string
+ * {@inheritdoc}
*/
protected function _read($length)
{
@@ -78,7 +68,7 @@ protected function _read($length)
}
/**
- * Close bz archive
+ * {@inheritdoc}
*/
protected function _close()
{
diff --git a/lib/Magento/Archive/Helper/File/Gz.php b/lib/Magento/Archive/Helper/File/Gz.php
index 01ce30bf5cdee..4cc8bad5d3814 100644
--- a/lib/Magento/Archive/Helper/File/Gz.php
+++ b/lib/Magento/Archive/Helper/File/Gz.php
@@ -30,7 +30,7 @@
class Gz extends \Magento\Archive\Helper\File
{
/**
- * @see \Magento\Archive\Helper\File::_open()
+ * {@inheritdoc}
*/
protected function _open($mode)
{
@@ -42,7 +42,7 @@ protected function _open($mode)
}
/**
- * @see \Magento\Archive\Helper\File::_write()
+ * {@inheritdoc}
*/
protected function _write($data)
{
@@ -54,7 +54,7 @@ protected function _write($data)
}
/**
- * @see \Magento\Archive\Helper\File::_read()
+ * {@inheritdoc}
*/
protected function _read($length)
{
@@ -62,7 +62,7 @@ protected function _read($length)
}
/**
- * @see \Magento\Archive\Helper\File::_eof()
+ * {@inheritdoc}
*/
protected function _eof()
{
@@ -70,7 +70,7 @@ protected function _eof()
}
/**
- * @see \Magento\Archive\Helper\File::_close()
+ * {@inheritdoc}
*/
protected function _close()
{
diff --git a/lib/Magento/Archive/Tar.php b/lib/Magento/Archive/Tar.php
index 893b0117a2b50..456d901ec0a4f 100644
--- a/lib/Magento/Archive/Tar.php
+++ b/lib/Magento/Archive/Tar.php
@@ -33,6 +33,8 @@
*/
namespace Magento\Archive;
+use \Magento\Archive\Helper\File;
+
class Tar extends \Magento\Archive\AbstractArchive implements \Magento\Archive\ArchiveInterface
{
/**
@@ -52,7 +54,7 @@ class Tar extends \Magento\Archive\AbstractArchive implements \Magento\Archive\A
/**
* Keep path to file or directory for packing.
*
- * @var mixed
+ * @var string
*/
protected $_currentPath;
@@ -60,21 +62,21 @@ class Tar extends \Magento\Archive\AbstractArchive implements \Magento\Archive\A
* Skip first level parent directory. Example:
* use test/fip.php instead test/test/fip.php;
*
- * @var mixed
+ * @var bool
*/
protected $_skipRoot;
/**
* Tarball data writer
*
- * @var \Magento\Archive\Helper\File
+ * @var File
*/
protected $_writer;
/**
* Tarball data reader
*
- * @var \Magento\Archive\Helper\File
+ * @var File
*/
protected $_reader;
@@ -88,11 +90,11 @@ class Tar extends \Magento\Archive\AbstractArchive implements \Magento\Archive\A
/**
* Initialize tarball writer
*
- * @return \Magento\Archive\Tar
+ * @return $this
*/
protected function _initWriter()
{
- $this->_writer = new \Magento\Archive\Helper\File($this->_destinationFilePath);
+ $this->_writer = new File($this->_destinationFilePath);
$this->_writer->open('w');
return $this;
@@ -112,11 +114,11 @@ protected static final function _getFormatParseHeader()
/**
* Destroy tarball writer
*
- * @return \Magento\Archive\Tar
+ * @return $this
*/
protected function _destroyWriter()
{
- if ($this->_writer instanceof \Magento\Archive\Helper\File) {
+ if ($this->_writer instanceof File) {
$this->_writer->close();
$this->_writer = null;
}
@@ -127,7 +129,7 @@ protected function _destroyWriter()
/**
* Get tarball writer
*
- * @return \Magento\Archive\Helper\File
+ * @return File
*/
protected function _getWriter()
{
@@ -141,11 +143,11 @@ protected function _getWriter()
/**
* Initialize tarball reader
*
- * @return \Magento\Archive\Tar
+ * @return $this
*/
protected function _initReader()
{
- $this->_reader = new \Magento\Archive\Helper\File($this->_getCurrentFile());
+ $this->_reader = new File($this->_getCurrentFile());
$this->_reader->open('r');
return $this;
@@ -154,11 +156,11 @@ protected function _initReader()
/**
* Destroy tarball reader
*
- * @return \Magento\Archive\Tar
+ * @return $this
*/
protected function _destroyReader()
{
- if ($this->_reader instanceof \Magento\Archive\Helper\File) {
+ if ($this->_reader instanceof File) {
$this->_reader->close();
$this->_reader = null;
}
@@ -169,7 +171,7 @@ protected function _destroyReader()
/**
* Get tarball reader
*
- * @return \Magento\Archive\Helper\File
+ * @return File
*/
protected function _getReader()
{
@@ -183,8 +185,8 @@ protected function _getReader()
/**
* Set option that define ability skip first catalog level.
*
- * @param mixed $skipRoot
- * @return \Magento\Archive\Tar
+ * @param bool $skipRoot
+ * @return $this
*/
protected function _setSkipRoot($skipRoot)
{
@@ -196,7 +198,7 @@ protected function _setSkipRoot($skipRoot)
* Set file which is packing.
*
* @param string $file
- * @return \Magento\Archive\Tar
+ * @return $this
*/
protected function _setCurrentFile($file)
{
@@ -209,7 +211,7 @@ protected function _setCurrentFile($file)
* Set path to file where tarball should be placed
*
* @param string $destinationFilePath
- * @return \Magento\Archive\Tar
+ * @return $this
*/
protected function _setDestinationFilePath($destinationFilePath)
{
@@ -231,7 +233,7 @@ protected function _getCurrentFile()
* Set path to file which is packing.
*
* @param string $path
- * @return \Magento\Archive\Tar
+ * @return $this
*/
protected function _setCurrentPath($path)
{
@@ -261,6 +263,7 @@ protected function _getCurrentPath()
* @deprecated after 1.7.0.0
* @param boolean $skipRoot
* @return string
+ * @throws \Magento\Exception
*/
protected function _packToTar($skipRoot=false)
{
@@ -294,6 +297,7 @@ protected function _packToTar($skipRoot=false)
*
* @param boolean $skipRoot
* @param boolean $finalize
+ * @return void
* @throws \Magento\Exception
*/
protected function _createTar($skipRoot = false, $finalize = false)
@@ -326,6 +330,8 @@ protected function _createTar($skipRoot = false, $finalize = false)
/**
* Write current file to tarball
+ *
+ * @return void
*/
protected function _packAndWriteCurrentFile()
{
@@ -337,7 +343,7 @@ protected function _packAndWriteCurrentFile()
$fileSize = 0;
if (is_file($currentFile) && !is_link($currentFile)) {
- $fileReader = new \Magento\Archive\Helper\File($currentFile);
+ $fileReader = new File($currentFile);
$fileReader->open('r');
while (!$fileReader->eof()) {
@@ -419,7 +425,7 @@ protected function _composeHeader($long = false)
* in the string.
*
* @param string $destination path to file is unpacked
- * @return array list of files
+ * @return string[] list of files
* @throws \Magento\Exception
*/
protected function _unpackCurrentTar($destination)
@@ -466,7 +472,6 @@ protected function _unpackCurrentTar($destination)
@symlink($header['symlink'], $currentFile);
}
}
-
return $list;
}
@@ -587,10 +592,11 @@ protected function _extractFileHeader()
*
* @param array $fileHeader
* @param string $destination
+ * @return void
*/
protected function _extractAndWriteFile($fileHeader, $destination)
{
- $fileWriter = new \Magento\Archive\Helper\File($destination);
+ $fileWriter = new File($destination);
$fileWriter->open('w', $fileHeader['mode']);
$archiveReader = $this->_getReader();
diff --git a/lib/Magento/Authorization/Factory.php b/lib/Magento/Authorization/Factory.php
index 3451f1514a2bb..3e0a1291a15b2 100644
--- a/lib/Magento/Authorization/Factory.php
+++ b/lib/Magento/Authorization/Factory.php
@@ -25,6 +25,9 @@
*/
namespace Magento\Authorization;
+use Magento\Authorization;
+use Magento\ObjectManager;
+
class Factory
{
/**
@@ -35,16 +38,16 @@ class Factory
/**
* Object Manager instance
*
- * @var \Magento\ObjectManager
+ * @var ObjectManager
*/
protected $_objectManager = null;
/**
* Factory constructor
*
- * @param \Magento\ObjectManager $objectManager
+ * @param ObjectManager $objectManager
*/
- public function __construct(\Magento\ObjectManager $objectManager)
+ public function __construct(ObjectManager $objectManager)
{
$this->_objectManager = $objectManager;
}
@@ -53,7 +56,7 @@ public function __construct(\Magento\ObjectManager $objectManager)
* Create class instance with specified parameters
*
* @param array $data
- * @return \Magento\Authorization
+ * @return Authorization
*/
public function create(array $data = array())
{
diff --git a/lib/Magento/Authorization/Policy.php b/lib/Magento/Authorization/Policy.php
index 564d58f3c6b7d..db74a2d76afe3 100644
--- a/lib/Magento/Authorization/Policy.php
+++ b/lib/Magento/Authorization/Policy.php
@@ -33,7 +33,7 @@ interface Policy
* @abstract
* @param string $roleId
* @param string $resourceId
- * @param mixed $privilege
+ * @param string|null $privilege
* @return bool
*/
public function isAllowed($roleId, $resourceId, $privilege = null);
diff --git a/lib/Magento/Authorization/Policy/Acl.php b/lib/Magento/Authorization/Policy/Acl.php
index 608ae194c804c..f2bb0001df3a9 100644
--- a/lib/Magento/Authorization/Policy/Acl.php
+++ b/lib/Magento/Authorization/Policy/Acl.php
@@ -26,7 +26,10 @@
*/
namespace Magento\Authorization\Policy;
-class Acl implements \Magento\Authorization\Policy
+use Magento\Acl\Builder;
+use Magento\Authorization\Policy;
+
+class Acl implements Policy
{
/**
* @var \Magento\Acl\Builder
@@ -34,9 +37,9 @@ class Acl implements \Magento\Authorization\Policy
protected $_aclBuilder;
/**
- * @param \Magento\Acl\Builder $aclBuilder
+ * @param Builder $aclBuilder
*/
- public function __construct(\Magento\Acl\Builder $aclBuilder)
+ public function __construct(Builder $aclBuilder)
{
$this->_aclBuilder = $aclBuilder;
}
@@ -46,7 +49,7 @@ public function __construct(\Magento\Acl\Builder $aclBuilder)
*
* @param string $roleId
* @param string $resourceId
- * @param mixed $privilege
+ * @param string $privilege
* @return bool
*/
public function isAllowed($roleId, $resourceId, $privilege = null)
diff --git a/lib/Magento/Authorization/Policy/DefaultPolicy.php b/lib/Magento/Authorization/Policy/DefaultPolicy.php
index 61d2714403a5b..3e92c9b142d65 100644
--- a/lib/Magento/Authorization/Policy/DefaultPolicy.php
+++ b/lib/Magento/Authorization/Policy/DefaultPolicy.php
@@ -37,8 +37,8 @@ class DefaultPolicy implements \Magento\Authorization\Policy
*
* @param string $roleId
* @param string $resourceId
- * @param mixed $privilege
- * @return bool
+ * @param string $privilege
+ * @return true
*/
public function isAllowed($roleId, $resourceId, $privilege = null)
{
diff --git a/lib/Magento/Autoload/ClassMap.php b/lib/Magento/Autoload/ClassMap.php
index d49cf30552ca7..ccf484b83da34 100644
--- a/lib/Magento/Autoload/ClassMap.php
+++ b/lib/Magento/Autoload/ClassMap.php
@@ -77,7 +77,7 @@ public function getFile($class)
* Add classes files declaration to the map. New map will override existing values if such was defined before.
*
* @param array $map
- * @return \Magento\Autoload\ClassMap
+ * @return $this
*/
public function addMap(array $map)
{
@@ -89,6 +89,7 @@ public function addMap(array $map)
* Resolve a class file and include it
*
* @param string $class
+ * @return void
*/
public function load($class)
{
diff --git a/lib/Magento/Autoload/IncludePath.php b/lib/Magento/Autoload/IncludePath.php
index 4af6c01c9beac..3312e9a3c941e 100644
--- a/lib/Magento/Autoload/IncludePath.php
+++ b/lib/Magento/Autoload/IncludePath.php
@@ -64,6 +64,7 @@ public static function getFilePath($class)
*
* @param string|array $path
* @param bool $prepend Whether to prepend paths or to append them
+ * @return void
*/
public static function addIncludePath($path, $prepend = true)
{
@@ -81,7 +82,8 @@ public static function addIncludePath($path, $prepend = true)
/**
* Resolve a class file and include it
*
- * @param $class
+ * @param string $class
+ * @return void
*/
public static function load($class)
{
diff --git a/lib/Magento/Autoload/Simple.php b/lib/Magento/Autoload/Simple.php
index a4893e5b6243d..b1910aedb7fec 100644
--- a/lib/Magento/Autoload/Simple.php
+++ b/lib/Magento/Autoload/Simple.php
@@ -28,9 +28,15 @@
class Simple
{
- private static $_instance;
-
- public static function instance()
+ /**
+ * @var object
+ */
+ private static $_instance;
+
+ /**
+ * @return object
+ */
+ public static function instance()
{
if (!self::$_instance) {
$class = __CLASS__;
@@ -38,13 +44,20 @@ public static function instance()
}
return self::$_instance;
}
-
- public static function register()
+
+ /**
+ * @return void
+ */
+ public static function register()
{
spl_autoload_register(array(self::instance(), 'autoload'));
}
-
- public function autoload($class)
+
+ /**
+ * @param string $class
+ * @return void
+ */
+ public function autoload($class)
{
$classFile = str_replace(' ', '/', ucwords(str_replace('_', ' ', $class)));
$classFile.= '.php';
diff --git a/lib/Magento/Cache/Backend/Database.php b/lib/Magento/Cache/Backend/Database.php
index 38a58709b41c1..e6b4a2cf3ccf9 100644
--- a/lib/Magento/Cache/Backend/Database.php
+++ b/lib/Magento/Cache/Backend/Database.php
@@ -68,6 +68,9 @@ class Database extends \Zend_Cache_Backend implements \Zend_Cache_Backend_Extend
'store_data' => true,
);
+ /**
+ * @var \Zend_Db_Adapter_Abstract
+ */
protected $_adapter = null;
/**
@@ -195,11 +198,11 @@ public function test($id)
* Note : $data is always "string" (serialization is done by the
* core not by the backend)
*
- * @param string $data Datas to cache
- * @param string $id Cache id
- * @param array $tags Array of strings, the cache record will be tagged by each string entry
- * @param int $specificLifetime If != false, set a specific lifetime for this cache record (null => infinite lifetime)
- * @return boolean true if no problem
+ * @param string $data Datas to cache
+ * @param string $id Cache id
+ * @param string[] $tags Array of strings, the cache record will be tagged by each string entry
+ * @param int|bool $specificLifetime If != false, set a specific lifetime for this cache record (null => infinite lifetime)
+ * @return bool true if no problem
*/
public function save($data, $id, $tags = array(), $specificLifetime = false)
{
@@ -263,7 +266,7 @@ public function remove($id)
* ($tags can be an array of strings or a single string)
*
* @param string $mode Clean mode
- * @param array $tags Array of tags
+ * @param string[] $tags Array of tags
* @return boolean true if no problem
*/
public function clean($mode = \Zend_Cache::CLEANING_MODE_ALL, $tags = array())
@@ -304,7 +307,7 @@ public function clean($mode = \Zend_Cache::CLEANING_MODE_ALL, $tags = array())
/**
* Return an array of stored cache ids
*
- * @return array array of stored cache ids (string)
+ * @return string[] array of stored cache ids (string)
*/
public function getIds()
{
@@ -320,7 +323,7 @@ public function getIds()
/**
* Return an array of stored tags
*
- * @return array array of stored tags (string)
+ * @return string[] array of stored tags (string)
*/
public function getTags()
{
@@ -335,8 +338,8 @@ public function getTags()
*
* In case of multiple tags, a logical AND is made between tags
*
- * @param array $tags array of tags
- * @return array array of matching cache ids (string)
+ * @param string[] $tags array of tags
+ * @return string[] array of matching cache ids (string)
*/
public function getIdsMatchingTags($tags = array())
{
@@ -354,8 +357,8 @@ public function getIdsMatchingTags($tags = array())
*
* In case of multiple tags, a logical OR is made between tags
*
- * @param array $tags array of tags
- * @return array array of not matching cache ids (string)
+ * @param string[] $tags array of tags
+ * @return string[] array of not matching cache ids (string)
*/
public function getIdsNotMatchingTags($tags = array())
{
@@ -367,8 +370,8 @@ public function getIdsNotMatchingTags($tags = array())
*
* In case of multiple tags, a logical AND is made between tags
*
- * @param array $tags array of tags
- * @return array array of any matching cache ids (string)
+ * @param string[] $tags array of tags
+ * @return string[] array of any matching cache ids (string)
*/
public function getIdsMatchingAnyTags($tags = array())
{
@@ -398,7 +401,7 @@ public function getFillingPercentage()
* - mtime : timestamp of last modification time
*
* @param string $id cache id
- * @return array array of metadatas (false if the cache id is not found)
+ * @return array|false array of metadatas (false if the cache id is not found)
*/
public function getMetadatas($id)
{
@@ -472,7 +475,7 @@ public function getCapabilities()
* Save tags related to specific id
*
* @param string $id
- * @param array $tags
+ * @param string[] $tags
* @return bool
*/
protected function _saveTags($id, $tags)
@@ -513,7 +516,7 @@ protected function _saveTags($id, $tags)
* Remove cache data by tags with specified mode
*
* @param string $mode
- * @param array $tags
+ * @param string[] $tags
* @return bool
*/
protected function _cleanByTags($mode, $tags)
diff --git a/lib/Magento/Cache/Backend/Decorator/AbstractDecorator.php b/lib/Magento/Cache/Backend/Decorator/AbstractDecorator.php
index 1221995f2ee21..9dfd0dfbc07f5 100644
--- a/lib/Magento/Cache/Backend/Decorator/AbstractDecorator.php
+++ b/lib/Magento/Cache/Backend/Decorator/AbstractDecorator.php
@@ -108,12 +108,12 @@ public function test($cacheId)
*
* @param string $data Datas to cache
* @param string $cacheId Cache id
- * @param array $tags Array of strings, the cache record will be tagged by each string entry
- * @param bool $specificLifetime If != false, set a specific lifetime for this cache record
+ * @param string[] $tags Array of strings, the cache record will be tagged by each string entry
+ * @param bool $specificLifetime If != false, set a specific lifetime for this cache record
* (null => infinite lifetime)
- * @param int $priority integer between 0 (very low priority) and 10 (maximum priority) used by
+ * @param int $priority integer between 0 (very low priority) and 10 (maximum priority) used by
* some particular backends
- * @return boolean true if no problem
+ * @return bool true if no problem
*/
public function save($data, $cacheId, $tags = array(), $specificLifetime = false, $priority = 8)
{
@@ -123,8 +123,8 @@ public function save($data, $cacheId, $tags = array(), $specificLifetime = false
/**
* Remove a cache record
*
- * @param string $cacheId Cache id
- * @return boolean True if no problem
+ * @param string $cacheId Cache id
+ * @return bool true if no problem
*/
public function remove($cacheId)
{
@@ -145,8 +145,8 @@ public function remove($cacheId)
* ($tags can be an array of strings or a single string)
*
* @param string $mode Clean mode
- * @param array $tags Array of tags
- * @return boolean true if no problem
+ * @param string[] $tags Array of tags
+ * @return bool true if no problem
*/
public function clean($mode = \Zend_Cache::CLEANING_MODE_ALL, $tags = array())
{
@@ -156,7 +156,7 @@ public function clean($mode = \Zend_Cache::CLEANING_MODE_ALL, $tags = array())
/**
* Return an array of stored cache ids
*
- * @return array array of stored cache ids (string)
+ * @return string[] array of stored cache ids (string)
*/
public function getIds()
{
@@ -166,7 +166,7 @@ public function getIds()
/**
* Return an array of stored tags
*
- * @return array array of stored tags (string)
+ * @return string[] array of stored tags (string)
*/
public function getTags()
{
@@ -178,8 +178,8 @@ public function getTags()
*
* In case of multiple tags, a logical AND is made between tags
*
- * @param array $tags array of tags
- * @return array array of matching cache ids (string)
+ * @param string[] $tags array of tags
+ * @return string[] array of matching cache ids (string)
*/
public function getIdsMatchingTags($tags = array())
{
@@ -191,8 +191,8 @@ public function getIdsMatchingTags($tags = array())
*
* In case of multiple tags, a logical OR is made between tags
*
- * @param array $tags array of tags
- * @return array array of not matching cache ids (string)
+ * @param string[] $tags array of tags
+ * @return string[] array of not matching cache ids (string)
*/
public function getIdsNotMatchingTags($tags = array())
{
@@ -204,8 +204,8 @@ public function getIdsNotMatchingTags($tags = array())
*
* In case of multiple tags, a logical AND is made between tags
*
- * @param array $tags array of tags
- * @return array array of any matching cache ids (string)
+ * @param string[] $tags array of tags
+ * @return string[] array of any matching cache ids (string)
*/
public function getIdsMatchingAnyTags($tags = array())
{
@@ -231,7 +231,7 @@ public function getFillingPercentage()
* - mtime : timestamp of last modification time
*
* @param string $cacheId cache id
- * @return array array of metadatas (false if the cache id is not found)
+ * @return array|bool array of metadatas (false if the cache id is not found)
*/
public function getMetadatas($cacheId)
{
diff --git a/lib/Magento/Cache/Backend/Decorator/Compression.php b/lib/Magento/Cache/Backend/Decorator/Compression.php
index 4af86344cb3a7..31583ae666a25 100644
--- a/lib/Magento/Cache/Backend/Decorator/Compression.php
+++ b/lib/Magento/Cache/Backend/Decorator/Compression.php
@@ -70,14 +70,14 @@ public function load($cacheId, $noTestCacheValidity = false)
* Note : $data is always "string" (serialization is done by the
* core not by the backend)
*
- * @param string $data Datas to cache
- * @param string $cacheId Cache id
- * @param array $tags Array of strings, the cache record will be tagged by each string entry
- * @param bool $specificLifetime If != false, set a specific lifetime for this cache record
+ * @param string $data Datas to cache
+ * @param string $cacheId Cache id
+ * @param string[] $tags Array of strings, the cache record will be tagged by each string entry
+ * @param bool $specificLifetime If != false, set a specific lifetime for this cache record
* (null => infinite lifetime)
- * @param int $priority integer between 0 (very low priority) and 10 (maximum priority) used by
+ * @param int $priority integer between 0 (very low priority) and 10 (maximum priority) used by
* some particular backends
- * @return boolean true if no problem
+ * @return bool true if no problem
*/
public function save($data, $cacheId, $tags = array(), $specificLifetime = false, $priority = 8)
{
diff --git a/lib/Magento/Cache/Backend/Eaccelerator.php b/lib/Magento/Cache/Backend/Eaccelerator.php
index bedc0350e728e..1760e8e47370c 100644
--- a/lib/Magento/Cache/Backend/Eaccelerator.php
+++ b/lib/Magento/Cache/Backend/Eaccelerator.php
@@ -39,7 +39,6 @@ class Eaccelerator extends \Zend_Cache_Backend implements \Zend_Cache_Backend_Ex
*
* @param array $options associative array of options
* @throws \Zend_Cache_Exception
- * @return void
*/
public function __construct(array $options = array())
{
@@ -90,9 +89,9 @@ public function test($id)
*
* @param string $data datas to cache
* @param string $id cache id
- * @param array $tags array of strings, the cache record will be tagged by each string entry
+ * @param string[] $tags array of strings, the cache record will be tagged by each string entry
* @param int $specificLifetime if != false, set a specific lifetime for this cache record (null => infinite lifetime)
- * @return boolean true if no problem
+ * @return bool true if no problem
*/
public function save($data, $id, $tags = array(), $specificLifetime = false)
{
@@ -108,7 +107,7 @@ public function save($data, $id, $tags = array(), $specificLifetime = false)
* Remove a cache record
*
* @param string $id cache id
- * @return boolean true if no problem
+ * @return bool true if no problem
*/
public function remove($id)
{
@@ -125,10 +124,10 @@ public function remove($id)
* 'notMatchingTag' => unsupported
* 'matchingAnyTag' => unsupported
*
- * @param string $mode clean mode
- * @param array $tags array of tags
+ * @param string $mode clean mode
+ * @param string[] $tags array of tags
* @throws \Zend_Cache_Exception
- * @return boolean true if no problem
+ * @return bool true if no problem
*/
public function clean($mode = \Zend_Cache::CLEANING_MODE_ALL, $tags = array())
{
@@ -174,7 +173,7 @@ public function getFillingPercentage()
/**
* Return an array of stored tags
*
- * @return array array of stored tags (string)
+ * @return string[] array of stored tags (string)
*/
public function getTags()
{
@@ -188,7 +187,7 @@ public function getTags()
* In case of multiple tags, a logical AND is made between tags
*
* @param array $tags array of tags
- * @return array array of matching cache ids (string)
+ * @return string[] array of matching cache ids (string)
*/
public function getIdsMatchingTags($tags = array())
{
@@ -201,8 +200,8 @@ public function getIdsMatchingTags($tags = array())
*
* In case of multiple tags, a logical OR is made between tags
*
- * @param array $tags array of tags
- * @return array array of not matching cache ids (string)
+ * @param string[] $tags array of tags
+ * @return string[] array of not matching cache ids (string)
*/
public function getIdsNotMatchingTags($tags = array())
{
@@ -215,8 +214,8 @@ public function getIdsNotMatchingTags($tags = array())
*
* In case of multiple tags, a logical AND is made between tags
*
- * @param array $tags array of tags
- * @return array array of any matching cache ids (string)
+ * @param string[] $tags array of tags
+ * @return string[] array of any matching cache ids (string)
*/
public function getIdsMatchingAnyTags($tags = array())
{
@@ -227,7 +226,7 @@ public function getIdsMatchingAnyTags($tags = array())
/**
* Return an array of stored cache ids
*
- * @return array array of stored cache ids (string)
+ * @return string[] array of stored cache ids (string)
*/
public function getIds()
{
@@ -248,7 +247,7 @@ public function getIds()
* - mtime : timestamp of last modification time
*
* @param string $id cache id
- * @return array array of metadatas (false if the cache id is not found)
+ * @return array|false array of metadatas (false if the cache id is not found)
*/
public function getMetadatas($id)
{
@@ -276,7 +275,7 @@ public function getMetadatas($id)
*
* @param string $id cache id
* @param int $extraLifetime
- * @return boolean true if ok
+ * @return bool true if ok
*/
public function touch($id, $extraLifetime)
{
diff --git a/lib/Magento/Cache/Backend/Memcached.php b/lib/Magento/Cache/Backend/Memcached.php
index 67172cd578f51..8d5c03fc3da85 100644
--- a/lib/Magento/Cache/Backend/Memcached.php
+++ b/lib/Magento/Cache/Backend/Memcached.php
@@ -43,8 +43,8 @@ class Memcached
/**
* Constructor
*
- * @throws \Magento\Exception
* @param array $options @see \Zend_Cache_Backend_Memcached::__construct()
+ * @throws \Magento\Exception
*/
public function __construct(array $options = array())
{
@@ -94,8 +94,8 @@ protected function _cleanTheMess($id, $chunks)
*
* @param string $data @see \Zend_Cache_Backend_Memcached::save()
* @param string $id @see \Zend_Cache_Backend_Memcached::save()
- * @param array $tags @see \Zend_Cache_Backend_Memcached::save()
- * @param bool $specificLifetime @see \Zend_Cache_Backend_Memcached::save()
+ * @param string[] $tags @see \Zend_Cache_Backend_Memcached::save()
+ * @param bool $specificLifetime @see \Zend_Cache_Backend_Memcached::save()
* @return bool
*/
public function save($data, $id, $tags = array(), $specificLifetime = false)
diff --git a/lib/Magento/Cache/Backend/MongoDb.php b/lib/Magento/Cache/Backend/MongoDb.php
index e253a99ade9f3..82236a028ba72 100644
--- a/lib/Magento/Cache/Backend/MongoDb.php
+++ b/lib/Magento/Cache/Backend/MongoDb.php
@@ -97,7 +97,7 @@ protected function _getCollection()
/**
* Return an array of stored cache ids
*
- * @return array array of stored cache ids (string)
+ * @return string[] array of stored cache ids (string)
*/
public function getIds()
{
@@ -107,7 +107,7 @@ public function getIds()
/**
* Return an array of stored tags
*
- * @return array array of stored tags (string)
+ * @return string[] array of stored tags (string)
*/
public function getTags()
{
@@ -120,8 +120,8 @@ public function getTags()
*
* In case of multiple tags, a logical AND is made between tags
*
- * @param array $tags array of tags
- * @return array array of matching cache ids (string)
+ * @param string[] $tags array of tags
+ * @return string[] array of matching cache ids (string)
*/
public function getIdsMatchingTags($tags = array())
{
@@ -138,8 +138,8 @@ public function getIdsMatchingTags($tags = array())
*
* In case of multiple tags, a logical OR is made between tags
*
- * @param array $tags array of tags
- * @return array array of not matching cache ids (string)
+ * @param string[] $tags array of tags
+ * @return string[] array of not matching cache ids (string)
*/
public function getIdsNotMatchingTags($tags = array())
{
@@ -156,8 +156,8 @@ public function getIdsNotMatchingTags($tags = array())
*
* In case of multiple tags, a logical AND is made between tags
*
- * @param array $tags array of tags
- * @return array array of any matching cache ids (string)
+ * @param string[] $tags array of tags
+ * @return string[] array of any matching cache ids (string)
*/
public function getIdsMatchingAnyTags($tags = array())
{
@@ -172,7 +172,7 @@ public function getIdsMatchingAnyTags($tags = array())
/**
* Get query to filter by specified tags and comparison mode
*
- * @param array $tags
+ * @param string[] $tags
* @param string $comparisonMode
* @return array
*/
@@ -214,7 +214,7 @@ public function getFillingPercentage()
* - mtime : timestamp of last modification time
*
* @param string $cacheId cache id
- * @return array array of metadatas (false if the cache id is not found)
+ * @return array|false array of metadatas (false if the cache id is not found)
*/
public function getMetadatas($cacheId)
{
@@ -326,7 +326,7 @@ public function test($cacheId)
*
* @param string $data Datas to cache
* @param string $cacheId Cache id
- * @param array $tags Array of strings, the cache record will be tagged by each string entry
+ * @param string[] $tags Array of strings, the cache record will be tagged by each string entry
* @param int|bool $specificLifetime If != false, set a specific lifetime (null => infinite lifetime)
* @return boolean true if no problem
*/
@@ -371,8 +371,8 @@ public function remove($cacheId)
* ($tags can be an array of strings or a single string)
*
* @param string $mode Clean mode
- * @param array $tags Array of tags
- * @return boolean true if no problem
+ * @param string[] $tags Array of tags
+ * @return bool true if no problem
*/
public function clean($mode = \Zend_Cache::CLEANING_MODE_ALL, $tags = array())
{
@@ -402,7 +402,7 @@ public function clean($mode = \Zend_Cache::CLEANING_MODE_ALL, $tags = array())
/**
* Quote specified value to be used in query as string
*
- * @param $value
+ * @param string $value
* @return string
*/
protected function _quoteString($value)
diff --git a/lib/Magento/Cache/Config.php b/lib/Magento/Cache/Config.php
index 69b47a901873b..783b86e8f5daf 100644
--- a/lib/Magento/Cache/Config.php
+++ b/lib/Magento/Cache/Config.php
@@ -42,6 +42,8 @@ public function __construct(\Magento\Cache\Config\Data $dataStorage)
/**
* {inheritdoc}
+ *
+ * @return array
*/
public function getTypes()
{
@@ -50,6 +52,9 @@ public function getTypes()
/**
* {inheritdoc}
+ *
+ * @param string $type
+ * @return array
*/
public function getType($type)
{
diff --git a/lib/Magento/Cache/Config/Data.php b/lib/Magento/Cache/Config/Data.php
index b646a37e55d39..638739b20bb0b 100644
--- a/lib/Magento/Cache/Config/Data.php
+++ b/lib/Magento/Cache/Config/Data.php
@@ -30,7 +30,7 @@ class Data extends \Magento\Config\Data\Scoped
/**
* Scope priority loading scheme
*
- * @var array
+ * @var string[]
*/
protected $_scopePriorityScheme = array('global');
diff --git a/lib/Magento/Cache/Core.php b/lib/Magento/Cache/Core.php
index 2a66c623c0d19..2800a7f1d187a 100644
--- a/lib/Magento/Cache/Core.php
+++ b/lib/Magento/Cache/Core.php
@@ -64,8 +64,8 @@ protected function _id($cacheId)
/**
* Prepare tags
*
- * @param array $tags
- * @return array
+ * @param string[] $tags
+ * @return string[]
*/
protected function _tags($tags)
{
@@ -81,12 +81,12 @@ protected function _tags($tags)
* @param mixed $data Data to put in cache (can be another type than string if
* automatic_serialization is on)
* @param null|string $cacheId Cache id (if not set, the last cache id will be used)
- * @param array $tags Cache tags
+ * @param string[] $tags Cache tags
* @param bool|int $specificLifetime If != false, set a specific lifetime for this cache record
* (null => infinite lifetime)
* @param int $priority integer between 0 (very low priority) and 10 (maximum priority) used by
* some particular backends
- * @return boolean True if no problem
+ * @return bool True if no problem
*/
public function save($data, $cacheId = null, $tags = array(), $specificLifetime = false, $priority = 8)
{
@@ -110,10 +110,10 @@ public function save($data, $cacheId = null, $tags = array(), $specificLifetime
* 'matchingAnyTag' => remove cache entries matching any given tags
* ($tags can be an array of strings or a single string)
*
- * @param string $mode
- * @param array|string $tags
+ * @param string $mode
+ * @param string[] $tags
* @throws \Zend_Cache_Exception
- * @return boolean True if ok
+ * @return bool True if ok
*/
public function clean($mode = 'all', $tags = array())
{
@@ -126,8 +126,8 @@ public function clean($mode = 'all', $tags = array())
*
* In case of multiple tags, a logical AND is made between tags
*
- * @param array $tags array of tags
- * @return array array of matching cache ids (string)
+ * @param string[] $tags array of tags
+ * @return string[] array of matching cache ids (string)
*/
public function getIdsMatchingTags($tags = array())
{
@@ -140,8 +140,8 @@ public function getIdsMatchingTags($tags = array())
*
* In case of multiple tags, a logical OR is made between tags
*
- * @param array $tags array of tags
- * @return array array of not matching cache ids (string)
+ * @param string[] $tags array of tags
+ * @return string[] array of not matching cache ids (string)
*/
public function getIdsNotMatchingTags($tags = array())
{
@@ -164,7 +164,7 @@ public function setBackend(\Zend_Cache_Backend $backendObject)
/**
* Decorate cache backend with additional functionality
*
- * @param \Zend_Cache_Backend
+ * @param \Zend_Cache_Backend $backendObject
* @return \Zend_Cache_Backend
*/
protected function _decorateBackend(\Zend_Cache_Backend $backendObject)
diff --git a/lib/Magento/Cache/Frontend/Decorator/Profiler.php b/lib/Magento/Cache/Frontend/Decorator/Profiler.php
index 43c9536381dd5..898ca3baa6df7 100644
--- a/lib/Magento/Cache/Frontend/Decorator/Profiler.php
+++ b/lib/Magento/Cache/Frontend/Decorator/Profiler.php
@@ -34,13 +34,13 @@ class Profiler extends \Magento\Cache\Frontend\Decorator\Bare
/**
* Backend class prefixes to be striped from profiler tags
*
- * @var array
+ * @var string[]
*/
private $_backendPrefixes = array();
/**
* @param \Magento\Cache\FrontendInterface $frontend
- * @param array $backendPrefixes Backend class prefixes to be striped for profiling informativeness
+ * @param string[] $backendPrefixes Backend class prefixes to be striped for profiling informativeness
*/
public function __construct(\Magento\Cache\FrontendInterface $frontend, $backendPrefixes = array())
{
diff --git a/lib/Magento/Code/Generator.php b/lib/Magento/Code/Generator.php
index 232b3f2cf46d5..bac451c7f1d06 100644
--- a/lib/Magento/Code/Generator.php
+++ b/lib/Magento/Code/Generator.php
@@ -48,7 +48,7 @@ class Generator
protected $_ioObject;
/**
- * @var array
+ * @var string[]
*/
protected $_generatedEntities = array(
\Magento\Code\Generator\Factory::ENTITY_TYPE,
@@ -76,7 +76,9 @@ public function __construct(
}
/**
- * @return array
+ * Get generated entities
+ *
+ * @return string[]
*/
public function getGeneratedEntities()
{
diff --git a/lib/Magento/Code/Generator/Autoloader.php b/lib/Magento/Code/Generator/Autoloader.php
index 498cd1ee08805..25a7e06276473 100644
--- a/lib/Magento/Code/Generator/Autoloader.php
+++ b/lib/Magento/Code/Generator/Autoloader.php
@@ -43,6 +43,7 @@ public function __construct(\Magento\Code\Generator $generator)
* Load specified class name and generate it if necessary
*
* @param string $className
+ * @return void
*/
public function load($className)
{
diff --git a/lib/Magento/Code/Generator/CodeGenerator/Zend.php b/lib/Magento/Code/Generator/CodeGenerator/Zend.php
index ff5fd4e46cd63..e426eb5000633 100644
--- a/lib/Magento/Code/Generator/CodeGenerator/Zend.php
+++ b/lib/Magento/Code/Generator/CodeGenerator/Zend.php
@@ -26,6 +26,9 @@
namespace Magento\Code\Generator\CodeGenerator;
+use \Zend\Code\Generator\MethodGenerator;
+use \Zend\Code\Generator\PropertyGenerator;
+
class Zend extends \Zend\Code\Generator\ClassGenerator
implements \Magento\Code\Generator\CodeGenerator\CodeGeneratorInterface
{
@@ -98,7 +101,7 @@ protected function _setDataToObject($object, array $data, array $map)
* Set class dock block
*
* @param array $docBlock
- * @return \Magento\Code\Generator\CodeGenerator\Zend
+ * @return $this
*/
public function setClassDocBlock(array $docBlock)
{
@@ -112,12 +115,12 @@ public function setClassDocBlock(array $docBlock)
* addMethods()
*
* @param array $methods
- * @return \Magento\Code\Generator\CodeGenerator\Zend
+ * @return $this
*/
public function addMethods(array $methods)
{
foreach ($methods as $methodOptions) {
- $methodObject = new \Zend\Code\Generator\MethodGenerator();
+ $methodObject = new MethodGenerator();
$this->_setDataToObject($methodObject, $methodOptions, $this->_methodOptions);
if (isset($methodOptions['parameters']) && is_array($methodOptions['parameters'])
@@ -148,11 +151,11 @@ public function addMethods(array $methods)
/**
* Add method from MethodGenerator
*
- * @param \Zend\Code\Generator\MethodGenerator $method
- * @return \Magento\Code\Generator\CodeGenerator\Zend
+ * @param MethodGenerator $method
+ * @return $this
* @throws \InvalidArgumentException
*/
- public function addMethodFromGenerator(\Zend\Code\Generator\MethodGenerator $method)
+ public function addMethodFromGenerator(MethodGenerator $method)
{
if (!is_string($method->getName())) {
throw new \InvalidArgumentException(
@@ -167,13 +170,13 @@ public function addMethodFromGenerator(\Zend\Code\Generator\MethodGenerator $met
* addProperties()
*
* @param array $properties
- * @return \Magento\Code\Generator\CodeGenerator\Zend
+ * @return $this
* @throws \InvalidArgumentException
*/
public function addProperties(array $properties)
{
foreach ($properties as $propertyOptions) {
- $propertyObject = new \Zend\Code\Generator\PropertyGenerator();
+ $propertyObject = new PropertyGenerator();
$this->_setDataToObject($propertyObject, $propertyOptions, $this->_propertyOptions);
if (isset($propertyOptions['docblock'])) {
@@ -194,11 +197,11 @@ public function addProperties(array $properties)
/**
* Add property from PropertyGenerator
*
- * @param \Zend\Code\Generator\PropertyGenerator $property
+ * @param PropertyGenerator $property
+ * @return $this
* @throws \InvalidArgumentException
- * @return \Magento\Code\Generator\CodeGenerator\Zend
*/
- public function addPropertyFromGenerator(\Zend\Code\Generator\PropertyGenerator $property)
+ public function addPropertyFromGenerator(PropertyGenerator $property)
{
if (!is_string($property->getName())) {
throw new \InvalidArgumentException(
diff --git a/lib/Magento/Code/Generator/EntityAbstract.php b/lib/Magento/Code/Generator/EntityAbstract.php
index 21f7259e6ca8b..b1067eeb27c1a 100644
--- a/lib/Magento/Code/Generator/EntityAbstract.php
+++ b/lib/Magento/Code/Generator/EntityAbstract.php
@@ -26,6 +26,8 @@
namespace Magento\Code\Generator;
+use \Magento\Autoload\IncludePath;
+
abstract class EntityAbstract
{
/**
@@ -34,7 +36,7 @@ abstract class EntityAbstract
const ENTITY_TYPE = 'abstract';
/**
- * @var array
+ * @var string[]
*/
private $_errors = array();
@@ -53,47 +55,47 @@ abstract class EntityAbstract
private $_resultClassName;
/**
- * @var \Magento\Code\Generator\Io
+ * @var Io
*/
private $_ioObject;
/**
* Autoloader instance
*
- * @var \Magento\Autoload\IncludePath
+ * @var IncludePath
*/
private $_autoloader;
/**
* Class generator object
*
- * @var \Magento\Code\Generator\CodeGenerator\CodeGeneratorInterface
+ * @var CodeGenerator\CodeGeneratorInterface
*/
protected $_classGenerator;
/**
- * @param null $sourceClassName
- * @param null $resultClassName
+ * @param null|string $sourceClassName
+ * @param null|string $resultClassName
* @param Io $ioObject
* @param CodeGenerator\CodeGeneratorInterface $classGenerator
- * @param \Magento\Autoload\IncludePath $autoLoader
+ * @param IncludePath $autoLoader
*/
public function __construct(
$sourceClassName = null,
$resultClassName = null,
- \Magento\Code\Generator\Io $ioObject = null,
- \Magento\Code\Generator\CodeGenerator\CodeGeneratorInterface $classGenerator = null,
- \Magento\Autoload\IncludePath $autoLoader = null
+ Io $ioObject = null,
+ CodeGenerator\CodeGeneratorInterface $classGenerator = null,
+ IncludePath $autoLoader = null
) {
if ($autoLoader) {
$this->_autoloader = $autoLoader;
} else {
- $this->_autoloader = new \Magento\Autoload\IncludePath();
+ $this->_autoloader = new IncludePath();
}
if ($ioObject) {
$this->_ioObject = $ioObject;
} else {
- $this->_ioObject = new \Magento\Code\Generator\Io(
+ $this->_ioObject = new Io(
new \Magento\Filesystem\Driver\File(),
$this->_autoloader
);
@@ -101,10 +103,10 @@ public function __construct(
if ($classGenerator) {
$this->_classGenerator = $classGenerator;
} else {
- $this->_classGenerator = new \Magento\Code\Generator\CodeGenerator\Zend();
+ $this->_classGenerator = new CodeGenerator\Zend();
}
- $this->_sourceClassName = ltrim($sourceClassName, \Magento\Autoload\IncludePath::NS_SEPARATOR);
+ $this->_sourceClassName = ltrim($sourceClassName, IncludePath::NS_SEPARATOR);
if ($resultClassName) {
$this->_resultClassName = $resultClassName;
} elseif ($sourceClassName) {
@@ -139,7 +141,7 @@ public function generate()
/**
* List of occurred generation errors
*
- * @return array
+ * @return string[]
*/
public function getErrors()
{
@@ -147,6 +149,8 @@ public function getErrors()
}
/**
+ * Get source class name
+ *
* @return string
*/
protected function _getSourceClassName()
@@ -155,16 +159,20 @@ protected function _getSourceClassName()
}
/**
+ * Get fully qualified class name
+ *
* @param string $className
* @return string
*/
protected function _getFullyQualifiedClassName($className)
{
- return \Magento\Autoload\IncludePath::NS_SEPARATOR
- . ltrim($className, \Magento\Autoload\IncludePath::NS_SEPARATOR);
+ return IncludePath::NS_SEPARATOR
+ . ltrim($className, IncludePath::NS_SEPARATOR);
}
/**
+ * Get result class name
+ *
* @return string
*/
protected function _getResultClassName()
@@ -173,6 +181,8 @@ protected function _getResultClassName()
}
/**
+ * Get default result class name
+ *
* @param string $modelClassName
* @return string
*/
@@ -213,11 +223,13 @@ protected abstract function _getDefaultConstructorDefinition();
/**
* Returns list of methods for class generator
*
- * @return mixed
+ * @return array
*/
abstract protected function _getClassMethods();
/**
+ * Generate code
+ *
* @return string
*/
protected function _generateCode()
@@ -232,8 +244,10 @@ protected function _generateCode()
}
/**
+ * Add error message
+ *
* @param string $message
- * @return \Magento\Code\Generator\EntityAbstract
+ * @return $this
*/
protected function _addError($message)
{
@@ -307,7 +321,7 @@ protected function _getGeneratedCode()
/**
* @param string $sourceCode
- * @return mixed
+ * @return string
*/
protected function _fixCodeStyle($sourceCode)
{
@@ -379,6 +393,7 @@ protected function _getMethodParameterInfo(\ReflectionParameter $parameter)
*
* @param string $sourceClassName
* @param string $resultClassName
+ * @return void
*/
public function init($sourceClassName, $resultClassName)
{
diff --git a/lib/Magento/Code/Generator/Interceptor.php b/lib/Magento/Code/Generator/Interceptor.php
index 6810de5d5f4a4..c78ff822a347d 100644
--- a/lib/Magento/Code/Generator/Interceptor.php
+++ b/lib/Magento/Code/Generator/Interceptor.php
@@ -164,7 +164,7 @@ protected function _getDefaultConstructorDefinition()
/**
* Returns list of methods for class generator
*
- * @return mixed
+ * @return array
*/
protected function _getClassMethods()
{
diff --git a/lib/Magento/Code/Generator/Io.php b/lib/Magento/Code/Generator/Io.php
index c91582e787f5f..9b6fb187d26b5 100644
--- a/lib/Magento/Code/Generator/Io.php
+++ b/lib/Magento/Code/Generator/Io.php
@@ -75,7 +75,7 @@ public function __construct(
/**
* Get path to generation directory
*
- * @param $directory
+ * @param null|string $directory
* @return string
*/
protected function initGeneratorDirectory($directory = null)
diff --git a/lib/Magento/Code/Minifier/Strategy/Generate.php b/lib/Magento/Code/Minifier/Strategy/Generate.php
index 1529cdc461ad9..2a1e775e67308 100644
--- a/lib/Magento/Code/Minifier/Strategy/Generate.php
+++ b/lib/Magento/Code/Minifier/Strategy/Generate.php
@@ -65,6 +65,7 @@ public function __construct(
*
* @param string $originalFile path to original file relative to pub/view_cache
* @param string $targetFile path relative to pub/view_cache
+ * @return void
*/
public function minifyFile($originalFile, $targetFile)
{
diff --git a/lib/Magento/Code/Minifier/Strategy/Lite.php b/lib/Magento/Code/Minifier/Strategy/Lite.php
index 6cbc0064ab9f0..6b959700a2b2f 100644
--- a/lib/Magento/Code/Minifier/Strategy/Lite.php
+++ b/lib/Magento/Code/Minifier/Strategy/Lite.php
@@ -68,6 +68,7 @@ public function __construct(
*
* @param string $originalFile path to original file relative to pub/view_cache
* @param string $targetFile path relative to pub/view_cache
+ * @return void
*/
public function minifyFile($originalFile, $targetFile)
{
diff --git a/lib/Magento/Code/Reader/ClassReader.php b/lib/Magento/Code/Reader/ClassReader.php
index f53ea5fe538a2..dd868f97ad65c 100644
--- a/lib/Magento/Code/Reader/ClassReader.php
+++ b/lib/Magento/Code/Reader/ClassReader.php
@@ -70,7 +70,7 @@ public function getConstructor($className)
* )
*
* @param string $className
- * @return array
+ * @return string[]
*/
public function getParents($className)
{
diff --git a/lib/Magento/Code/Validator.php b/lib/Magento/Code/Validator.php
index 2e0c73a1064b6..dcfb16296f743 100644
--- a/lib/Magento/Code/Validator.php
+++ b/lib/Magento/Code/Validator.php
@@ -35,6 +35,7 @@ class Validator implements ValidatorInterface
* Add validator
*
* @param ValidatorInterface $validator
+ * @return void
*/
public function add(ValidatorInterface $validator)
{
diff --git a/lib/Magento/Config/Data.php b/lib/Magento/Config/Data.php
index 300e41f7bd9b8..3d5fad64a48ca 100644
--- a/lib/Magento/Config/Data.php
+++ b/lib/Magento/Config/Data.php
@@ -90,7 +90,7 @@ public function merge(array $config)
* Get config value by key
*
* @param string $path
- * @param null $default
+ * @param mixed $default
* @return mixed
*/
public function get($path = null, $default = null)
diff --git a/lib/Magento/Config/Dom.php b/lib/Magento/Config/Dom.php
index 6cd579b3984dd..94edf8bfb2b40 100644
--- a/lib/Magento/Config/Dom.php
+++ b/lib/Magento/Config/Dom.php
@@ -87,7 +87,6 @@ class Dom
* @param array $idAttributes
* @param string $schemaFile
* @param string $errorFormat
- * @throws \Magento\Config\Dom\ValidationException
*/
public function __construct(
$xml, array $idAttributes = array(), $schemaFile = null, $errorFormat = self::ERROR_FORMAT_DEFAULT
@@ -104,7 +103,6 @@ public function __construct(
*
* @param string $xml
* @return void
- * @throws \Magento\Config\Dom\ValidationException
*/
public function merge($xml)
{
@@ -209,7 +207,12 @@ protected function _findIdAttribute($xPath)
{
$path = preg_replace('/\[@[^\]]+?\]/', '', $xPath);
$path = preg_replace('/\/[^:]+?\:/', '/', $path);
- return isset($this->_idAttributes[$path]) ? $this->_idAttributes[$path] : false;
+ foreach ($this->_idAttributes as $pathPattern => $id) {
+ if (preg_match("#^$pathPattern$#", $path)) {
+ return $id;
+ }
+ }
+ return false;
}
/**
diff --git a/lib/Magento/Config/Dom/Converter/ArrayConverter.php b/lib/Magento/Config/Dom/Converter/ArrayConverter.php
deleted file mode 100644
index e3c6ea49bc80d..0000000000000
--- a/lib/Magento/Config/Dom/Converter/ArrayConverter.php
+++ /dev/null
@@ -1,67 +0,0 @@
-nodeType == XML_ELEMENT_NODE) {
- $arrayElement = array();
- /** @var $attribute \DOMNode */
- foreach ($item->attributes as $attribute) {
- if ($attribute->nodeType == XML_ATTRIBUTE_NODE) {
- $arrayElement[self::ATTRIBUTES][$attribute->nodeName] = $attribute->nodeValue;
- }
- }
- $children = $this->convert($item->childNodes);
-
- if (is_array($children)) {
- $arrayElement = array_merge($arrayElement, $children);
- } else {
- $arrayElement[self::CONTENT] = $children;
- }
- $array[$item->nodeName][] = $arrayElement;
- } elseif ($item->nodeType == XML_CDATA_SECTION_NODE
- || ($item->nodeType == XML_TEXT_NODE && trim($item->nodeValue) != '')
- ) {
- return $item->nodeValue;
- }
- }
- return $array;
- }
-}
diff --git a/lib/Magento/Config/FileIterator.php b/lib/Magento/Config/FileIterator.php
index eafd7478d05cc..3a9f24152580a 100644
--- a/lib/Magento/Config/FileIterator.php
+++ b/lib/Magento/Config/FileIterator.php
@@ -112,7 +112,7 @@ function valid()
public function toArray()
{
$result = [];
- foreach($this as $item) {
+ foreach ($this as $item) {
$result[$this->key()] = $item;
}
return $result;
diff --git a/lib/Magento/Config/FileIteratorFactory.php b/lib/Magento/Config/FileIteratorFactory.php
index 9d94ea4b384c1..74b1e44e7b44d 100644
--- a/lib/Magento/Config/FileIteratorFactory.php
+++ b/lib/Magento/Config/FileIteratorFactory.php
@@ -26,6 +26,13 @@
class FileIteratorFactory
{
+ /**
+ * Create file iterator
+ *
+ * @param \Magento\Filesystem\Directory\ReadInterface $readDirectory
+ * @param array $paths
+ * @return FileIterator
+ */
public function create(\Magento\Filesystem\Directory\ReadInterface $readDirectory, $paths)
{
return new \Magento\Config\FileIterator($readDirectory, $paths);
diff --git a/lib/Magento/Config/Reader/Filesystem.php b/lib/Magento/Config/Reader/Filesystem.php
index e71430462aa78..bcf3da125e83a 100644
--- a/lib/Magento/Config/Reader/Filesystem.php
+++ b/lib/Magento/Config/Reader/Filesystem.php
@@ -142,6 +142,8 @@ public function read($scope = null)
}
/**
+ * Read configuration files
+ *
* @param array $fileList
* @return array
* @throws \Magento\Exception
@@ -154,11 +156,7 @@ protected function _readFiles($fileList)
try {
if (is_null($domDocument)) {
$class = $this->_domDocumentClass;
- $domDocument = new $class(
- $content,
- $this->_idAttributes,
- $this->_perFileSchema
- );
+ $domDocument = new $class($content, $this->_idAttributes, $this->_perFileSchema);
} else {
$domDocument->merge($content);
}
diff --git a/lib/Magento/Config/Theme.php b/lib/Magento/Config/Theme.php
index 96082df850300..9b8db0a67ccd9 100644
--- a/lib/Magento/Config/Theme.php
+++ b/lib/Magento/Config/Theme.php
@@ -30,13 +30,31 @@
*/
namespace Magento\Config;
-class Theme extends \Magento\Config\AbstractXml
+class Theme
{
/**
* Is used for separation path of themes
*/
const THEME_PATH_SEPARATOR = '/';
+ /**
+ * Data extracted from the configuration file
+ *
+ * @var array
+ */
+ protected $_data;
+
+ /**
+ * @param string $configContent
+ */
+ public function __construct($configContent)
+ {
+ $config = new \DOMDocument;
+ $config->loadXML($configContent);
+ // todo: validation of the document
+ $this->_data = $this->_extractData($config);
+ }
+
/**
* Get absolute path to theme.xsd
*
@@ -118,24 +136,4 @@ public function getParentTheme()
}
return explode(self::THEME_PATH_SEPARATOR, $parentTheme);
}
-
- /**
- * Get initial XML of a valid document
- *
- * @return string
- */
- protected function _getInitialXml()
- {
- return '';
- }
-
- /**
- * Design packages are unique by code. Themes are unique by code.
- *
- * @return array
- */
- protected function _getIdAttributes()
- {
- return array('/theme' => 'theme');
- }
}
diff --git a/lib/Magento/Controller/Router/Route/Factory.php b/lib/Magento/Controller/Router/Route/Factory.php
index 6b805eb08138f..70e1401599346 100644
--- a/lib/Magento/Controller/Router/Route/Factory.php
+++ b/lib/Magento/Controller/Router/Route/Factory.php
@@ -24,7 +24,7 @@ public function __construct(\Magento\ObjectManager $objectManager)
/**
* Create route instance.
*
- * @param $routeClass
+ * @param string $routeClass
* @param string $route Map used to match with later submitted URL path
* @param array $defaults Defaults for map variables with keys as variable names
* @param array $reqs Regular expression requirements for variables (keys as variable names)
diff --git a/lib/Magento/Convert/Container/AbstractContainer.php b/lib/Magento/Convert/Container/AbstractContainer.php
index 2d3f8910d50f5..75800696aa6e4 100644
--- a/lib/Magento/Convert/Container/AbstractContainer.php
+++ b/lib/Magento/Convert/Container/AbstractContainer.php
@@ -34,12 +34,30 @@
*/
namespace Magento\Convert\Container;
+use Magento\Convert\ConvertException;
+
abstract class AbstractContainer
{
+ /**
+ * @var array
+ */
protected $_vars;
+
+ /**
+ * @var array
+ */
protected $_data;
+
+ /**
+ * @var int
+ */
protected $_position;
+ /**
+ * @param string $key
+ * @param string|null $default
+ * @return array
+ */
public function getVar($key, $default=null)
{
if (!isset($this->_vars[$key])) {
@@ -48,11 +66,19 @@ public function getVar($key, $default=null)
return $this->_vars[$key];
}
+ /**
+ * @return array
+ */
public function getVars()
{
return $this->_vars;
}
+ /**
+ * @param array|string $key
+ * @param string|null $value
+ * @return $this
+ */
public function setVar($key, $value=null)
{
if (is_array($key) && is_null($value)) {
@@ -63,28 +89,43 @@ public function setVar($key, $value=null)
return $this;
}
+ /**
+ * @return array
+ */
public function getData()
{
return $this->_data;
}
+ /**
+ * @param array $data
+ * @return $this
+ */
public function setData($data)
{
$this->_data = $data;
return $this;
}
+ /**
+ * @param string|null $data
+ * @return true
+ */
public function validateDataString($data=null)
{
if (is_null($data)) {
$data = $this->getData();
}
if (!is_string($data)) {
- $this->addException("Invalid data type, expecting string.", \Magento\Convert\ConvertException::FATAL);
+ $this->addException("Invalid data type, expecting string.", ConvertException::FATAL);
}
return true;
}
+ /**
+ * @param array|null $data
+ * @return true
+ */
public function validateDataGrid($data=null)
{
if (is_null($data)) {
@@ -95,11 +136,15 @@ public function validateDataGrid($data=null)
return true;
}
$this->addException(
- "Invalid data type, expecting 2D grid array.", \Magento\Convert\ConvertException::FATAL);
+ "Invalid data type, expecting 2D grid array.", ConvertException::FATAL);
}
return true;
}
+ /**
+ * @param array $grid
+ * @return array
+ */
public function getGridFields($grid)
{
$fields = array();
@@ -113,21 +158,33 @@ public function getGridFields($grid)
return $fields;
}
+ /**
+ * @param string $error
+ * @param string|null $level
+ * @return ConvertException
+ */
public function addException($error, $level=null)
{
- $exception = new \Magento\Convert\ConvertException($error);
- $exception->setLevel(!is_null($level) ? $level : \Magento\Convert\ConvertException::NOTICE);
+ $exception = new ConvertException($error);
+ $exception->setLevel(!is_null($level) ? $level : ConvertException::NOTICE);
$exception->setContainer($this);
$exception->setPosition($this->getPosition());
return $exception;
}
+ /**
+ * @return int
+ */
public function getPosition()
{
return $this->_position;
}
+ /**
+ * @param int $position
+ * @return $this
+ */
public function setPosition($position)
{
$this->_position = $position;
diff --git a/lib/Magento/Convert/ConvertArray.php b/lib/Magento/Convert/ConvertArray.php
index b3bbe2be0b680..4b08296d37ede 100644
--- a/lib/Magento/Convert/ConvertArray.php
+++ b/lib/Magento/Convert/ConvertArray.php
@@ -24,6 +24,8 @@
namespace Magento\Convert;
+use Magento\Exception;
+
/**
* Convert the array data to SimpleXMLElement object
*/
@@ -36,12 +38,12 @@ class ConvertArray
* @param array $array
* @param string $rootName
* @return \SimpleXMLElement
- * @throws \Magento\Exception
+ * @throws Exception
*/
public function assocToXml(array $array, $rootName = '_')
{
if (empty($rootName) || is_numeric($rootName)) {
- throw new \Magento\Exception('Root element must not be empty or numeric');
+ throw new Exception('Root element must not be empty or numeric');
}
$xmlStr = <<_container = $container;
return $this;
}
+ /**
+ * @return AbstractContainer
+ */
public function getContainer()
{
return $this->_container;
}
+ /**
+ * @return string
+ */
public function getLevel()
{
return $this->_level;
}
+ /**
+ * @param string $level
+ * @return $this
+ */
public function setLevel($level)
{
$this->_level = $level;
return $this;
}
+ /**
+ * @return int
+ */
public function getPosition()
{
return $this->_position;
}
+ /**
+ * @param int $position
+ * @return $this
+ */
public function setPosition($position)
{
$this->_position = $position;
diff --git a/lib/Magento/Convert/Excel.php b/lib/Magento/Convert/Excel.php
index a1fb3e3b051e9..0646649c5c32d 100644
--- a/lib/Magento/Convert/Excel.php
+++ b/lib/Magento/Convert/Excel.php
@@ -26,6 +26,8 @@
namespace Magento\Convert;
+use Magento\Filesystem\File\WriteInterface;
+
/**
* Convert the data to XML Excel
*/
@@ -163,6 +165,7 @@ protected function _getXmlRow($row, $useCallback)
* Set Data Header
*
* @param array $data
+ * @return void
*/
public function setDataHeader($data)
{
@@ -173,6 +176,7 @@ public function setDataHeader($data)
* Set Data Footer
*
* @param array $data
+ * @return void
*/
public function setDataFooter($data)
{
@@ -200,10 +204,11 @@ public function convert($sheetName = '')
/**
* Write Converted XML Data to Temporary File
*
- * @param \Magento\Filesystem\File\WriteInterface $stream
+ * @param WriteInterface $stream
* @param string $sheetName
+ * @return void
*/
- public function write(\Magento\Filesystem\File\WriteInterface $stream, $sheetName = '')
+ public function write(WriteInterface $stream, $sheetName = '')
{
$stream->write($this->_getXmlHeader($sheetName));
diff --git a/lib/Magento/Convert/Mapper/Column.php b/lib/Magento/Convert/Mapper/Column.php
index b8b541cb20dc9..59ddd941bdffb 100644
--- a/lib/Magento/Convert/Mapper/Column.php
+++ b/lib/Magento/Convert/Mapper/Column.php
@@ -34,9 +34,14 @@
*/
namespace Magento\Convert\Mapper;
-class Column extends \Magento\Convert\Container\AbstractContainer
- implements \Magento\Convert\Mapper\MapperInterface
+use Magento\Convert\Container\AbstractContainer;
+
+class Column extends AbstractContainer
+ implements MapperInterface
{
+ /**
+ * @return $this
+ */
public function map()
{
$data = $this->getData();
diff --git a/lib/Magento/Convert/Object.php b/lib/Magento/Convert/Object.php
index 488407282a755..dac8d7696e89c 100644
--- a/lib/Magento/Convert/Object.php
+++ b/lib/Magento/Convert/Object.php
@@ -43,7 +43,7 @@ class Object
* Convert input data into an array and return the resulting array.
* The resulting array should not contain any objects.
*
- * @param mixed $data input data
+ * @param array $data input data
* @return array Data converted to an array
*/
public function convertDataToArray($data)
@@ -107,7 +107,6 @@ protected function _convertObjectToArray($obj, &$objects = array())
* @param array $items
* @param string|callable $idField
* @param string|callable $valueField
- *
* @return array
*/
public function toOptionArray(array $items, $idField, $valueField)
@@ -130,7 +129,6 @@ public function toOptionArray(array $items, $idField, $valueField)
* @param array $items
* @param string|callable $idField
* @param string|callable $valueField
- *
* @return array
*/
public function toOptionHash(array $items, $idField, $valueField)
@@ -151,7 +149,6 @@ public function toOptionHash(array $items, $idField, $valueField)
*
* @param mixed $item
* @param string|callable $field
- *
* @return mixed
*/
protected function _invokeGetter($item, $field)
diff --git a/lib/Magento/Css/PreProcessor/Adapter/Oyejorge.php b/lib/Magento/Css/PreProcessor/Adapter/Oyejorge.php
new file mode 100644
index 0000000000000..eccc8dd6d25bf
--- /dev/null
+++ b/lib/Magento/Css/PreProcessor/Adapter/Oyejorge.php
@@ -0,0 +1,42 @@
+parseFile($sourceFilePath, '');
+ return $parser->getCss();
+ }
+}
diff --git a/lib/Magento/Css/PreProcessor/AdapterInterface.php b/lib/Magento/Css/PreProcessor/AdapterInterface.php
new file mode 100644
index 0000000000000..11b4a95ca453c
--- /dev/null
+++ b/lib/Magento/Css/PreProcessor/AdapterInterface.php
@@ -0,0 +1,37 @@
+viewFileSystem = $viewFileSystem;
+ $this->lessPreProcessor = $lessPreProcessor;
+ $this->adapter = $adapter;
+ }
+
+ /**
+ * @param string $filePath
+ * @param array $params
+ * @param \Magento\Filesystem\Directory\WriteInterface $targetDirectory
+ * @param null|string $sourcePath
+ * @return string
+ */
+ public function process($filePath, $params, $targetDirectory, $sourcePath = null)
+ {
+ // if css file has being already discovered/prepared by previous pre-processor
+ if ($sourcePath) {
+ return $sourcePath;
+ }
+
+ // TODO: if css file is already exist. May compare modification time of .less and .css files here.
+ $sourcePath = $this->viewFileSystem->getViewFile($filePath, $params);
+
+ $lessFilePath = str_replace('.css', '.less', $filePath);
+ $preparedLessFileSourcePath = $this->lessPreProcessor->processLessInstructions($lessFilePath, $params);
+ $cssContent = $this->adapter->process($preparedLessFileSourcePath);
+
+ // doesn't matter where exact file has been found, we use original file identifier
+ // see \Magento\View\Publisher::_buildPublishedFilePath() for details
+ $targetDirectory->writeFile($filePath, $cssContent);
+ return $targetDirectory->getAbsolutePath($filePath);
+ }
+}
diff --git a/lib/Magento/DB/Adapter/AdapterInterface.php b/lib/Magento/DB/Adapter/AdapterInterface.php
index 2aebd42a9999b..20077c703c386 100644
--- a/lib/Magento/DB/Adapter/AdapterInterface.php
+++ b/lib/Magento/DB/Adapter/AdapterInterface.php
@@ -1023,4 +1023,21 @@ public function decodeVarbinary($value);
* @return int
*/
public function getTransactionLevel();
+
+ /**
+ * Create trigger
+ *
+ * @param \Magento\DB\Ddl\Trigger $trigger
+ * @return \Zend_Db_Statement_Pdo
+ */
+ public function createTrigger(\Magento\DB\Ddl\Trigger $trigger);
+
+ /**
+ * Drop trigger from database
+ *
+ * @param $triggerName
+ * @param null $schemaName
+ * @return mixed
+ */
+ public function dropTrigger($triggerName, $schemaName = null);
}
diff --git a/lib/Magento/DB/Adapter/Pdo/Mysql.php b/lib/Magento/DB/Adapter/Pdo/Mysql.php
index 7a1fd5b68ea7f..b1e63e1e79c51 100644
--- a/lib/Magento/DB/Adapter/Pdo/Mysql.php
+++ b/lib/Magento/DB/Adapter/Pdo/Mysql.php
@@ -25,7 +25,19 @@
*/
namespace Magento\DB\Adapter\Pdo;
-class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\AdapterInterface
+use Magento\App\Filesystem;
+use Magento\Cache\FrontendInterface;
+use Magento\DB\Adapter\AdapterInterface;
+use Magento\DB\Ddl\Table;
+use Magento\DB\Helper;
+use Magento\DB\Profiler;
+use Magento\DB\Select;
+use Magento\DB\Statement\Parameter;
+use Magento\Debug;
+use Magento\Stdlib\DateTime;
+use Magento\Stdlib\String;
+
+class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements AdapterInterface
{
const DEBUG_CONNECT = 0;
const DEBUG_TRANSACTION = 1;
@@ -143,7 +155,7 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad
/**
* Filesystem class
*
- * @var \Magento\App\Filesystem
+ * @var Filesystem
*/
protected $_filesystem;
@@ -157,7 +169,7 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad
/**
* Cache frontend adapter instance
*
- * @var \Magento\Cache\FrontendInterface
+ * @var FrontendInterface
*/
protected $_cacheAdapter;
@@ -173,26 +185,26 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad
* @var array
*/
protected $_ddlColumnTypes = array(
- \Magento\DB\Ddl\Table::TYPE_BOOLEAN => 'bool',
- \Magento\DB\Ddl\Table::TYPE_SMALLINT => 'smallint',
- \Magento\DB\Ddl\Table::TYPE_INTEGER => 'int',
- \Magento\DB\Ddl\Table::TYPE_BIGINT => 'bigint',
- \Magento\DB\Ddl\Table::TYPE_FLOAT => 'float',
- \Magento\DB\Ddl\Table::TYPE_DECIMAL => 'decimal',
- \Magento\DB\Ddl\Table::TYPE_NUMERIC => 'decimal',
- \Magento\DB\Ddl\Table::TYPE_DATE => 'date',
- \Magento\DB\Ddl\Table::TYPE_TIMESTAMP => 'timestamp',
- \Magento\DB\Ddl\Table::TYPE_DATETIME => 'datetime',
- \Magento\DB\Ddl\Table::TYPE_TEXT => 'text',
- \Magento\DB\Ddl\Table::TYPE_BLOB => 'blob',
- \Magento\DB\Ddl\Table::TYPE_VARBINARY => 'blob'
+ Table::TYPE_BOOLEAN => 'bool',
+ Table::TYPE_SMALLINT => 'smallint',
+ Table::TYPE_INTEGER => 'int',
+ Table::TYPE_BIGINT => 'bigint',
+ Table::TYPE_FLOAT => 'float',
+ Table::TYPE_DECIMAL => 'decimal',
+ Table::TYPE_NUMERIC => 'decimal',
+ Table::TYPE_DATE => 'date',
+ Table::TYPE_TIMESTAMP => 'timestamp',
+ Table::TYPE_DATETIME => 'datetime',
+ Table::TYPE_TEXT => 'text',
+ Table::TYPE_BLOB => 'blob',
+ Table::TYPE_VARBINARY => 'blob'
);
/**
* All possible DDL statements
* First 3 symbols for each statement
*
- * @var array
+ * @var string[]
*/
protected $_ddlRoutines = array('alt', 'cre', 'ren', 'dro', 'tru');
@@ -218,25 +230,25 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements \Magento\DB\Adapter\Ad
protected $_queryHook = null;
/**
- * @var \Magento\Stdlib\String
+ * @var String
*/
protected $string;
/**
- * @var \Magento\Stdlib\DateTime
+ * @var DateTime
*/
protected $dateTime;
/**
- * @param \Magento\App\Filesystem $filesystem
- * @param \Magento\Stdlib\String $string
- * @param \Magento\Stdlib\DateTime $dateTime
+ * @param Filesystem $filesystem
+ * @param String $string
+ * @param DateTime $dateTime
* @param array $config
*/
public function __construct(
- \Magento\App\Filesystem $filesystem,
- \Magento\Stdlib\String $string,
- \Magento\Stdlib\DateTime $dateTime,
+ Filesystem $filesystem,
+ String $string,
+ DateTime $dateTime,
array $config = array()
) {
$this->_filesystem = $filesystem;
@@ -248,13 +260,13 @@ public function __construct(
/**
* Begin new DB transaction for connection
*
- * @return \Magento\DB\Adapter\Pdo\Mysql
+ * @return $this
* @throws \Exception
*/
public function beginTransaction()
{
if ($this->_isRolledBack) {
- throw new \Exception(\Magento\DB\Adapter\AdapterInterface::ERROR_ROLLBACK_INCOMPLETE_MESSAGE);
+ throw new \Exception(AdapterInterface::ERROR_ROLLBACK_INCOMPLETE_MESSAGE);
}
if ($this->_transactionLevel === 0) {
$this->_debugTimer();
@@ -268,7 +280,7 @@ public function beginTransaction()
/**
* Commit DB transaction
*
- * @return \Magento\DB\Adapter\Pdo\Mysql
+ * @return $this
*/
public function commit()
{
@@ -277,9 +289,9 @@ public function commit()
parent::commit();
$this->_debugStat(self::DEBUG_TRANSACTION, 'COMMIT');
} elseif ($this->_transactionLevel === 0) {
- throw new \Exception(\Magento\DB\Adapter\AdapterInterface::ERROR_ASYMMETRIC_COMMIT_MESSAGE);
+ throw new \Exception(AdapterInterface::ERROR_ASYMMETRIC_COMMIT_MESSAGE);
} elseif ($this->_isRolledBack) {
- throw new \Exception(\Magento\DB\Adapter\AdapterInterface::ERROR_ROLLBACK_INCOMPLETE_MESSAGE);
+ throw new \Exception(AdapterInterface::ERROR_ROLLBACK_INCOMPLETE_MESSAGE);
}
--$this->_transactionLevel;
return $this;
@@ -288,7 +300,7 @@ public function commit()
/**
* Rollback DB transaction
*
- * @return \Magento\DB\Adapter\Pdo\Mysql
+ * @return $this
*/
public function rollBack()
{
@@ -298,7 +310,7 @@ public function rollBack()
$this->_isRolledBack = false;
$this->_debugStat(self::DEBUG_TRANSACTION, 'ROLLBACK');
} elseif ($this->_transactionLevel === 0) {
- throw new \Exception(\Magento\DB\Adapter\AdapterInterface::ERROR_ASYMMETRIC_ROLLBACK_MESSAGE);
+ throw new \Exception(AdapterInterface::ERROR_ASYMMETRIC_ROLLBACK_MESSAGE);
} else {
$this->_isRolledBack = true;
}
@@ -319,8 +331,8 @@ public function getTransactionLevel()
/**
* Convert date to DB format
*
- * @param mixed $date
- * @return string
+ * @param int|string|\Zend_Date $date
+ * @return \Zend_Db_Expr
*/
public function convertDate($date)
{
@@ -330,8 +342,8 @@ public function convertDate($date)
/**
* Convert date and time to DB format
*
- * @param mixed $date
- * @return string
+ * @param int|string|\Zend_Date $datetime
+ * @return \Zend_Db_Expr
*/
public function convertDateTime($datetime)
{
@@ -341,6 +353,7 @@ public function convertDateTime($datetime)
/**
* Creates a PDO object and connects to the database.
*
+ * @return void
* @throws \Zend_Db_Adapter_Exception
*/
protected function _connect()
@@ -406,7 +419,7 @@ public function raw_query($sql)
*
* @param string $sql
* @param string|int $field
- * @return boolean
+ * @return mixed|null
*/
public function raw_fetchRow($sql, $field = null)
{
@@ -430,7 +443,8 @@ public function raw_fetchRow($sql, $field = null)
/**
* Check transaction level in case of DDL query
*
- * @param string|Zend_Db_Select $sql
+ * @param string|\Zend_Db_Select $sql
+ * @return void
* @throws \Zend_Db_Adapter_Exception
*/
protected function _checkDdlTransaction($sql)
@@ -438,7 +452,7 @@ protected function _checkDdlTransaction($sql)
if (is_string($sql) && $this->getTransactionLevel() > 0) {
$startSql = strtolower(substr(ltrim($sql), 0, 3));
if (in_array($startSql, $this->_ddlRoutines)) {
- trigger_error(\Magento\DB\Adapter\AdapterInterface::ERROR_DDL_MESSAGE, E_USER_ERROR);
+ trigger_error(AdapterInterface::ERROR_DDL_MESSAGE, E_USER_ERROR);
}
}
}
@@ -447,7 +461,7 @@ protected function _checkDdlTransaction($sql)
* Special handling for PDO query().
* All bind parameter names must begin with ':'.
*
- * @param string|Zend_Db_Select $sql The SQL statement with placeholders.
+ * @param string|\Zend_Db_Select $sql The SQL statement with placeholders.
* @param mixed $bind An array of data or data itself to bind to the placeholders.
* @return \Zend_Db_Statement_Pdo
* @throws \Zend_Db_Adapter_Exception To re-throw \PDOException.
@@ -471,8 +485,8 @@ public function query($sql, $bind = array())
} catch (\Exception $e) {
// Finalize broken query
$profiler = $this->getProfiler();
- if ($profiler instanceof \Magento\DB\Profiler) {
- /** @var \Magento\DB\Profiler $profiler */
+ if ($profiler instanceof Profiler) {
+ /** @var Profiler $profiler */
$profiler->queryEndLast();
}
@@ -509,7 +523,7 @@ public function query($sql, $bind = array())
*
* @param \Zend_Db_Select|string $sql
* @param mixed $bind
- * @return \Magento\DB\Adapter\Pdo\Mysql
+ * @return $this
*/
protected function _prepareQuery(&$sql, &$bind = array())
{
@@ -548,7 +562,7 @@ protected function _prepareQuery(&$sql, &$bind = array())
* This method writes to $_bindParams, where query bind parameters are kept.
* This method requires further normalizing, if bind array is positional.
*
- * @param array $matches
+ * @param string[] $matches
* @return string
*/
public function proccessBindCallback($matches)
@@ -591,7 +605,7 @@ protected function _unQuote($string)
*
* @param string $sql
* @param array $bind
- * @return \Magento\DB\Adapter\Pdo\Mysql
+ * @return $this
*/
protected function _convertMixedBind(&$sql, &$bind)
{
@@ -646,7 +660,7 @@ protected function _convertMixedBind(&$sql, &$bind)
* Previous hook is returned.
*
* @param array $hook
- * @return mixed
+ * @return array|null
*/
public function setQueryHook($hook)
{
@@ -660,7 +674,7 @@ public function setQueryHook($hook)
*
* @param string $sql
* @throws \Zend_Db_Exception
- * @return \Magento\DB\Adapter\Pdo\Mysql
+ * @return array
*/
public function multiQuery($sql)
{
@@ -698,7 +712,7 @@ public function multi_query($sql)
/**
* Split multi statement query
*
- * @param $sql string
+ * @param string $sql
* @return array
*/
protected function _splitMultiQuery($sql)
@@ -759,7 +773,7 @@ protected function _splitMultiQuery($sql)
* @param string $tableName
* @param string $fkName
* @param string $schemaName
- * @return \Magento\DB\Adapter\Pdo\Mysql
+ * @return $this
*/
public function dropForeignKey($tableName, $fkName, $schemaName = null)
{
@@ -789,14 +803,14 @@ public function dropForeignKey($tableName, $fkName, $schemaName = null)
* @param string $refTableName
* @param string $refColumnName
* @param string $onDelete
- * @return \Magento\DB\Adapter\Pdo\Mysql
+ * @return $this
*/
public function purgeOrphanRecords($tableName, $columnName, $refTableName, $refColumnName,
- $onDelete = \Magento\DB\Adapter\AdapterInterface::FK_ACTION_CASCADE)
+ $onDelete = AdapterInterface::FK_ACTION_CASCADE)
{
$onDelete = strtoupper($onDelete);
- if ($onDelete == \Magento\DB\Adapter\AdapterInterface::FK_ACTION_CASCADE
- || $onDelete == \Magento\DB\Adapter\AdapterInterface::FK_ACTION_RESTRICT
+ if ($onDelete == AdapterInterface::FK_ACTION_CASCADE
+ || $onDelete == AdapterInterface::FK_ACTION_RESTRICT
) {
$sql = sprintf("DELETE p.* FROM %s AS p LEFT JOIN %s AS r ON p.%s = r.%s WHERE r.%s IS NULL",
$this->quoteIdentifier($tableName),
@@ -805,7 +819,7 @@ public function purgeOrphanRecords($tableName, $columnName, $refTableName, $refC
$this->quoteIdentifier($refColumnName),
$this->quoteIdentifier($refColumnName));
$this->raw_query($sql);
- } elseif ($onDelete == \Magento\DB\Adapter\AdapterInterface::FK_ACTION_SET_NULL) {
+ } elseif ($onDelete == AdapterInterface::FK_ACTION_SET_NULL) {
$sql = sprintf("UPDATE %s AS p LEFT JOIN %s AS r ON p.%s = r.%s SET p.%s = NULL WHERE r.%s IS NULL",
$this->quoteIdentifier($tableName),
$this->quoteIdentifier($refTableName),
@@ -825,7 +839,7 @@ public function purgeOrphanRecords($tableName, $columnName, $refTableName, $refC
* @param string $tableName
* @param string $columnName
* @param string $schemaName
- * @return boolean
+ * @return bool
*/
public function tableColumnExists($tableName, $columnName, $schemaName = null)
{
@@ -849,7 +863,7 @@ public function tableColumnExists($tableName, $columnName, $schemaName = null)
* @param string $columnName
* @param array|string $definition string specific or universal array DB Server definition
* @param string $schemaName
- * @return int|boolean
+ * @return true|\Zend_Db_Statement_Pdo
* @throws \Zend_Db_Exception
*/
public function addColumn($tableName, $columnName, $definition, $schemaName = null)
@@ -890,7 +904,7 @@ public function addColumn($tableName, $columnName, $definition, $schemaName = nu
* @param string $tableName
* @param string $columnName
* @param string $schemaName
- * @return bool
+ * @return true|\Zend_Db_Statement_Pdo
*/
public function dropColumn($tableName, $columnName, $schemaName = null)
{
@@ -959,7 +973,7 @@ protected function _getIndexByColumns($tableName, array $columns, $schemaName)
* @param array $definition
* @param boolean $flushData flush table statistic
* @param string $schemaName
- * @return \Magento\DB\Adapter\Pdo\Mysql
+ * @return \Zend_Db_Statement_Pdo
* @throws \Zend_Db_Exception
*/
public function changeColumn($tableName, $oldColumnName, $newColumnName, $definition, $flushData = false,
@@ -1001,7 +1015,7 @@ public function changeColumn($tableName, $oldColumnName, $newColumnName, $defini
* @param array|string $definition
* @param boolean $flushData
* @param string $schemaName
- * @return \Magento\DB\Adapter\Pdo\Mysql
+ * @return $this
* @throws \Zend_Db_Exception
*/
public function modifyColumn($tableName, $columnName, $definition, $flushData = false, $schemaName = null)
@@ -1032,7 +1046,7 @@ public function modifyColumn($tableName, $columnName, $definition, $flushData =
*
* @param string $tableName
* @param string $schemaName
- * @return array|false
+ * @return mixed
*/
public function showTableStatus($tableName, $schemaName = null)
{
@@ -1151,7 +1165,8 @@ public function getForeignKeysTree()
* comment => string; table comment
* engine => string; table engine
*
- * @return \Magento\DB\Adapter\Pdo\Mysql
+ * @param array $tables
+ * @return $this
*/
public function modifyTables($tables)
{
@@ -1182,8 +1197,8 @@ public function modifyTables($tables)
$onDelete = $options['ON_DELETE'];
$onUpdate = $options['ON_UPDATE'];
- if ($onDelete == \Magento\DB\Adapter\AdapterInterface::FK_ACTION_SET_NULL
- || $onUpdate == \Magento\DB\Adapter\AdapterInterface::FK_ACTION_SET_NULL) {
+ if ($onDelete == AdapterInterface::FK_ACTION_SET_NULL
+ || $onUpdate == AdapterInterface::FK_ACTION_SET_NULL) {
$columnDefinition['nullable'] = true;
}
$this->modifyColumn($options['TABLE_NAME'], $options['COLUMN_NAME'], $columnDefinition);
@@ -1193,8 +1208,8 @@ public function modifyTables($tables)
$options['COLUMN_NAME'],
$options['REF_TABLE_NAME'],
$options['REF_COLUMN_NAME'],
- ($onDelete) ? $onDelete : \Magento\DB\Adapter\AdapterInterface::FK_ACTION_NO_ACTION,
- ($onUpdate) ? $onUpdate : \Magento\DB\Adapter\AdapterInterface::FK_ACTION_NO_ACTION
+ ($onDelete) ? $onDelete : AdapterInterface::FK_ACTION_NO_ACTION,
+ ($onUpdate) ? $onUpdate : AdapterInterface::FK_ACTION_NO_ACTION
);
}
}
@@ -1229,7 +1244,7 @@ public function modifyTables($tables)
*
* @param string $tableName
* @param string $schemaName
- * @return array
+ * @return array|string|int
*/
public function getIndexList($tableName, $schemaName = null)
{
@@ -1246,14 +1261,14 @@ public function getIndexList($tableName, $schemaName = null)
$fieldColumn = 'Column_name';
$fieldIndexType = 'Index_type';
- if (strtolower($row[$fieldKeyName]) == \Magento\DB\Adapter\AdapterInterface::INDEX_TYPE_PRIMARY) {
- $indexType = \Magento\DB\Adapter\AdapterInterface::INDEX_TYPE_PRIMARY;
+ if (strtolower($row[$fieldKeyName]) == AdapterInterface::INDEX_TYPE_PRIMARY) {
+ $indexType = AdapterInterface::INDEX_TYPE_PRIMARY;
} elseif ($row[$fieldNonUnique] == 0) {
- $indexType = \Magento\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE;
- } elseif (strtolower($row[$fieldIndexType]) == \Magento\DB\Adapter\AdapterInterface::INDEX_TYPE_FULLTEXT) {
- $indexType = \Magento\DB\Adapter\AdapterInterface::INDEX_TYPE_FULLTEXT;
+ $indexType = AdapterInterface::INDEX_TYPE_UNIQUE;
+ } elseif (strtolower($row[$fieldIndexType]) == AdapterInterface::INDEX_TYPE_FULLTEXT) {
+ $indexType = AdapterInterface::INDEX_TYPE_FULLTEXT;
} else {
- $indexType = \Magento\DB\Adapter\AdapterInterface::INDEX_TYPE_INDEX;
+ $indexType = AdapterInterface::INDEX_TYPE_INDEX;
}
$upperKeyName = strtoupper($row[$fieldKeyName]);
@@ -1284,8 +1299,8 @@ public function getIndexList($tableName, $schemaName = null)
*
* @param string $table
* @param array $fields
- * @param array $ids
- * @return \Magento\DB\Adapter\Pdo\Mysql
+ * @param string[] $ids
+ * @return $this
*/
protected function _removeDuplicateEntry($table, $fields, $ids)
{
@@ -1317,17 +1332,17 @@ protected function _removeDuplicateEntry($table, $fields, $ids)
/**
* Creates and returns a new \Zend_Db_Select object for this adapter.
*
- * @return \Magento\DB\Select
+ * @return Select
*/
public function select()
{
- return new \Magento\DB\Select($this);
+ return new Select($this);
}
/**
* Start debug timer
*
- * @return \Magento\DB\Adapter\Pdo\Mysql
+ * @return $this
*/
protected function _debugTimer()
{
@@ -1345,7 +1360,7 @@ protected function _debugTimer()
* @param string $sql
* @param array $bind
* @param \Zend_Db_Statement_Pdo $result
- * @return \Magento\DB\Adapter\Pdo\Mysql
+ * @return $this
*/
protected function _debugStat($type, $sql, $bind = array(), $result = null)
{
@@ -1381,7 +1396,7 @@ protected function _debugStat($type, $sql, $bind = array(), $result = null)
$code .= 'TIME: ' . $time . $nl;
if ($this->_logCallStack) {
- $code .= 'TRACE: ' . \Magento\Debug::backtrace(true, false) . $nl;
+ $code .= 'TRACE: ' . Debug::backtrace(true, false) . $nl;
}
$code .= $nl;
@@ -1395,6 +1410,7 @@ protected function _debugStat($type, $sql, $bind = array(), $result = null)
* Write exception and thow
*
* @param \Exception $e
+ * @return void
* @throws \Exception
*/
protected function _debugException(\Exception $e)
@@ -1414,12 +1430,13 @@ protected function _debugException(\Exception $e)
* Debug write to file process
*
* @param string $str
+ * @return void
*/
protected function _debugWriteToFile($str)
{
$str = '## ' . date('Y-m-d H:i:s') . "\r\n" . $str;
- $stream = $this->_filesystem->getDirectoryWrite(\Magento\App\Filesystem::ROOT_DIR)->openFile($this->_debugFile, 'a');
+ $stream = $this->_filesystem->getDirectoryWrite(Filesystem::ROOT_DIR)->openFile($this->_debugFile, 'a');
$stream->lock();
$stream->write($str);
$stream->unlock();
@@ -1451,6 +1468,7 @@ public function quoteInto($text, $value, $type = null, $count = null)
*
* @param string $tableName
* @param string $schemaName
+ * @return string
*/
protected function _getTableName($tableName, $schemaName = null)
{
@@ -1504,7 +1522,8 @@ public function loadDdlCache($tableCacheKey, $ddlType)
*
* @param string $tableCacheKey
* @param int $ddlType
- * @return \Magento\DB\Adapter\Pdo\Mysql
+ * @param array $data
+ * @return $this
*/
public function saveDdlCache($tableCacheKey, $ddlType, $data)
{
@@ -1528,7 +1547,7 @@ public function saveDdlCache($tableCacheKey, $ddlType, $data)
*
* @param string $tableName
* @param string $schemaName OPTIONAL
- * @return \Magento\DB\Adapter\Pdo\Mysql
+ * @return $this
*/
public function resetDdlCache($tableName = null, $schemaName = null)
{
@@ -1561,7 +1580,7 @@ public function resetDdlCache($tableName = null, $schemaName = null)
/**
* Disallow DDL caching
- * @return \Magento\DB\Adapter\Pdo\Mysql
+ * @return $this
*/
public function disallowDdlCache()
{
@@ -1571,7 +1590,7 @@ public function disallowDdlCache()
/**
* Allow DDL caching
- * @return \Magento\DB\Adapter\Pdo\Mysql
+ * @return $this
*/
public function allowDdlCache()
{
@@ -1648,7 +1667,7 @@ public function getColumnCreateByDescribe($columnData)
$options['unsigned'] = true;
}
if ($columnData['NULLABLE'] === false
- && !($type == \Magento\DB\Ddl\Table::TYPE_TEXT && strlen($columnData['DEFAULT']) != 0)
+ && !($type == Table::TYPE_TEXT && strlen($columnData['DEFAULT']) != 0)
) {
$options['nullable'] = false;
}
@@ -1656,7 +1675,7 @@ public function getColumnCreateByDescribe($columnData)
$options['primary'] = true;
}
if (!is_null($columnData['DEFAULT'])
- && $type != \Magento\DB\Ddl\Table::TYPE_TEXT
+ && $type != Table::TYPE_TEXT
) {
$options['default'] = $this->quote($columnData['DEFAULT']);
}
@@ -1683,9 +1702,9 @@ public function getColumnCreateByDescribe($columnData)
/**
* Create \Magento\DB\Ddl\Table object by data from describe table
*
- * @param $tableName
- * @param $newTableName
- * @return \Magento\DB\Ddl\Table
+ * @param string $tableName
+ * @param string $newTableName
+ * @return Table
*/
public function createTableByDdl($tableName, $newTableName)
{
@@ -1712,7 +1731,7 @@ public function createTableByDdl($tableName, $newTableName)
* For reliability check both name and type, because these values can start to differ in future.
*/
if (($indexData['KEY_NAME'] == 'PRIMARY')
- || ($indexData['INDEX_TYPE'] == \Magento\DB\Adapter\AdapterInterface::INDEX_TYPE_PRIMARY)
+ || ($indexData['INDEX_TYPE'] == AdapterInterface::INDEX_TYPE_PRIMARY)
) {
continue;
}
@@ -1751,7 +1770,7 @@ public function createTableByDdl($tableName, $newTableName)
* @param array $definition
* @param boolean $flushData
* @param string $schemaName
- * @return \Magento\DB\Adapter\Pdo\Mysql
+ * @return $this
*/
public function modifyColumnByDdl($tableName, $columnName, $definition, $flushData = false, $schemaName = null)
{
@@ -1774,37 +1793,37 @@ protected function _getColumnTypeByDdl($column)
{
switch ($column['DATA_TYPE']) {
case 'bool':
- return \Magento\DB\Ddl\Table::TYPE_BOOLEAN;
+ return Table::TYPE_BOOLEAN;
case 'tinytext':
case 'char':
case 'varchar':
case 'text':
case 'mediumtext':
case 'longtext':
- return \Magento\DB\Ddl\Table::TYPE_TEXT;
+ return Table::TYPE_TEXT;
case 'blob':
case 'mediumblob':
case 'longblob':
- return \Magento\DB\Ddl\Table::TYPE_BLOB;
+ return Table::TYPE_BLOB;
case 'tinyint':
case 'smallint':
- return \Magento\DB\Ddl\Table::TYPE_SMALLINT;
+ return Table::TYPE_SMALLINT;
case 'mediumint':
case 'int':
- return \Magento\DB\Ddl\Table::TYPE_INTEGER;
+ return Table::TYPE_INTEGER;
case 'bigint':
- return \Magento\DB\Ddl\Table::TYPE_BIGINT;
+ return Table::TYPE_BIGINT;
case 'datetime':
- return \Magento\DB\Ddl\Table::TYPE_DATETIME;
+ return Table::TYPE_DATETIME;
case 'timestamp':
- return \Magento\DB\Ddl\Table::TYPE_TIMESTAMP;
+ return Table::TYPE_TIMESTAMP;
case 'date':
- return \Magento\DB\Ddl\Table::TYPE_DATE;
+ return Table::TYPE_DATE;
case 'float':
- return \Magento\DB\Ddl\Table::TYPE_FLOAT;
+ return Table::TYPE_FLOAT;
case 'decimal':
case 'numeric':
- return \Magento\DB\Ddl\Table::TYPE_DECIMAL;
+ return Table::TYPE_DECIMAL;
}
}
@@ -1814,7 +1833,7 @@ protected function _getColumnTypeByDdl($column)
* @param string $tableName
* @param string $engine
* @param string $schemaName
- * @return mixed
+ * @return \Zend_Db_Statement_Pdo
*/
public function changeTableEngine($tableName, $engine, $schemaName = null)
{
@@ -1830,7 +1849,7 @@ public function changeTableEngine($tableName, $engine, $schemaName = null)
* @param string $tableName
* @param string $comment
* @param string $schemaName
- * @return mixed
+ * @return \Zend_Db_Statement_Pdo
*/
public function changeTableComment($tableName, $comment, $schemaName = null)
{
@@ -1860,7 +1879,7 @@ public function insertForce($table, array $bind)
/**
* Inserts a table row with specified data.
*
- * @param mixed $table The table to insert data into.
+ * @param string $table The table to insert data into.
* @param array $data Column-value pairs or array of column-value pairs.
* @param array $fields update fields pairs or values
* @return int The number of affected rows.
@@ -1931,7 +1950,7 @@ public function insertOnDuplicate($table, array $data, array $fields = array())
/**
* Inserts a table multiply rows with specified data.
*
- * @param mixed $table The table to insert data into.
+ * @param string|array|\Zend_Db_Expr $table The table to insert data into.
* @param array $data Column-value pairs or array of Column-value pairs.
* @return int The number of affected rows.
* @throws \Zend_Db_Exception
@@ -2004,10 +2023,10 @@ public function insertArray($table, array $columns, array $data)
/**
* Set cache adapter
*
- * @param \Magento\Cache\FrontendInterface $adapter
- * @return \Magento\DB\Adapter\Pdo\Mysql
+ * @param FrontendInterface $adapter
+ * @return $this
*/
- public function setCacheAdapter(\Magento\Cache\FrontendInterface $adapter)
+ public function setCacheAdapter(FrontendInterface $adapter)
{
$this->_cacheAdapter = $adapter;
return $this;
@@ -2018,11 +2037,11 @@ public function setCacheAdapter(\Magento\Cache\FrontendInterface $adapter)
*
* @param string $tableName the table name
* @param string $schemaName the database/schema name
- * @return \Magento\DB\Ddl\Table
+ * @return Table
*/
public function newTable($tableName = null, $schemaName = null)
{
- $table = new \Magento\DB\Ddl\Table();
+ $table = new Table();
if ($tableName !== null) {
$table->setName($tableName);
}
@@ -2036,11 +2055,11 @@ public function newTable($tableName = null, $schemaName = null)
/**
* Create table
*
- * @param \Magento\DB\Ddl\Table $table
+ * @param Table $table
* @throws \Zend_Db_Exception
- * @return \Zend_Db_Pdo_Statement
+ * @return \Zend_Db_Statement_Pdo
*/
- public function createTable(\Magento\DB\Ddl\Table $table)
+ public function createTable(Table $table)
{
$columns = $table->getColumns();
foreach ($columns as $columnEntry) {
@@ -2066,11 +2085,11 @@ public function createTable(\Magento\DB\Ddl\Table $table)
/**
* Retrieve columns and primary keys definition array for create table
*
- * @param \Magento\DB\Ddl\Table $table
- * @return array
+ * @param Table $table
+ * @return string[]
* @throws \Zend_Db_Exception
*/
- protected function _getColumnsDefinition(\Magento\DB\Ddl\Table $table)
+ protected function _getColumnsDefinition(Table $table)
{
$definition = array();
$primary = array();
@@ -2104,10 +2123,10 @@ protected function _getColumnsDefinition(\Magento\DB\Ddl\Table $table)
/**
* Retrieve table indexes definition array for create table
*
- * @param \Magento\DB\Ddl\Table $table
- * @return array
+ * @param Table $table
+ * @return string[]
*/
- protected function _getIndexesDefinition(\Magento\DB\Ddl\Table $table)
+ protected function _getIndexesDefinition(Table $table)
{
$definition = array();
$indexes = $table->getIndexes();
@@ -2150,10 +2169,10 @@ protected function _getIndexesDefinition(\Magento\DB\Ddl\Table $table)
/**
* Retrieve table foreign keys definition array for create table
*
- * @param \Magento\DB\Ddl\Table $table
- * @return array
+ * @param Table $table
+ * @return string[]
*/
- protected function _getForeignKeysDefinition(\Magento\DB\Ddl\Table $table)
+ protected function _getForeignKeysDefinition(Table $table)
{
$definition = array();
$relations = $table->getForeignKeys();
@@ -2180,11 +2199,11 @@ protected function _getForeignKeysDefinition(\Magento\DB\Ddl\Table $table)
/**
* Retrieve table options definition array for create table
*
- * @param \Magento\DB\Ddl\Table $table
- * @return array
+ * @param Table $table
+ * @return string[]
* @throws \Zend_Db_Exception
*/
- protected function _getOptionsDefinition(\Magento\DB\Ddl\Table $table)
+ protected function _getOptionsDefinition(Table $table)
{
$definition = array();
$comment = $table->getComment();
@@ -2262,15 +2281,15 @@ protected function _getColumnDefinition($options, $ddlType = null)
// column size
$cType = $this->_ddlColumnTypes[$ddlType];
switch ($ddlType) {
- case \Magento\DB\Ddl\Table::TYPE_SMALLINT:
- case \Magento\DB\Ddl\Table::TYPE_INTEGER:
- case \Magento\DB\Ddl\Table::TYPE_BIGINT:
+ case Table::TYPE_SMALLINT:
+ case Table::TYPE_INTEGER:
+ case Table::TYPE_BIGINT:
if (!empty($options['UNSIGNED'])) {
$cUnsigned = true;
}
break;
- case \Magento\DB\Ddl\Table::TYPE_DECIMAL:
- case \Magento\DB\Ddl\Table::TYPE_NUMERIC:
+ case Table::TYPE_DECIMAL:
+ case Table::TYPE_NUMERIC:
$precision = 10;
$scale = 0;
$match = array();
@@ -2287,23 +2306,23 @@ protected function _getColumnDefinition($options, $ddlType = null)
}
$cType .= sprintf('(%d,%d)', $precision, $scale);
break;
- case \Magento\DB\Ddl\Table::TYPE_TEXT:
- case \Magento\DB\Ddl\Table::TYPE_BLOB:
- case \Magento\DB\Ddl\Table::TYPE_VARBINARY:
+ case Table::TYPE_TEXT:
+ case Table::TYPE_BLOB:
+ case Table::TYPE_VARBINARY:
if (empty($options['LENGTH'])) {
- $length = \Magento\DB\Ddl\Table::DEFAULT_TEXT_SIZE;
+ $length = Table::DEFAULT_TEXT_SIZE;
} else {
$length = $this->_parseTextSize($options['LENGTH']);
}
if ($length <= 255) {
- $cType = $ddlType == \Magento\DB\Ddl\Table::TYPE_TEXT ? 'varchar' : 'varbinary';
+ $cType = $ddlType == Table::TYPE_TEXT ? 'varchar' : 'varbinary';
$cType = sprintf('%s(%d)', $cType, $length);
} else if ($length > 255 && $length <= 65536) {
- $cType = $ddlType == \Magento\DB\Ddl\Table::TYPE_TEXT ? 'text' : 'blob';
+ $cType = $ddlType == Table::TYPE_TEXT ? 'text' : 'blob';
} else if ($length > 65536 && $length <= 16777216) {
- $cType = $ddlType == \Magento\DB\Ddl\Table::TYPE_TEXT ? 'mediumtext' : 'mediumblob';
+ $cType = $ddlType == Table::TYPE_TEXT ? 'mediumtext' : 'mediumblob';
} else {
- $cType = $ddlType == \Magento\DB\Ddl\Table::TYPE_TEXT ? 'longtext' : 'longblob';
+ $cType = $ddlType == Table::TYPE_TEXT ? 'longtext' : 'longblob';
}
break;
}
@@ -2327,14 +2346,14 @@ protected function _getColumnDefinition($options, $ddlType = null)
}
// prepare default value string
- if ($ddlType == \Magento\DB\Ddl\Table::TYPE_TIMESTAMP) {
+ if ($ddlType == Table::TYPE_TIMESTAMP) {
if ($cDefault === null) {
$cDefault = new \Zend_Db_Expr('NULL');
- } elseif ($cDefault == \Magento\DB\Ddl\Table::TIMESTAMP_INIT) {
+ } elseif ($cDefault == Table::TIMESTAMP_INIT) {
$cDefault = new \Zend_Db_Expr('CURRENT_TIMESTAMP');
- } else if ($cDefault == \Magento\DB\Ddl\Table::TIMESTAMP_UPDATE) {
+ } else if ($cDefault == Table::TIMESTAMP_UPDATE) {
$cDefault = new \Zend_Db_Expr('0 ON UPDATE CURRENT_TIMESTAMP');
- } else if ($cDefault == \Magento\DB\Ddl\Table::TIMESTAMP_INIT_UPDATE) {
+ } else if ($cDefault == Table::TIMESTAMP_INIT_UPDATE) {
$cDefault = new \Zend_Db_Expr('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP');
} else if ($cNullable && !$cDefault) {
$cDefault = new \Zend_Db_Expr('NULL');
@@ -2366,7 +2385,7 @@ protected function _getColumnDefinition($options, $ddlType = null)
*
* @param string $tableName
* @param string $schemaName
- * @return boolean
+ * @return true
*/
public function dropTable($tableName, $schemaName = null)
{
@@ -2382,7 +2401,7 @@ public function dropTable($tableName, $schemaName = null)
*
* @param string $tableName
* @param string $schemaName
- * @return \Magento\DB\Adapter\Pdo\Mysql
+ * @return $this
* @throws \Zend_Db_Exception
*/
public function truncateTable($tableName, $schemaName = null)
@@ -2403,7 +2422,7 @@ public function truncateTable($tableName, $schemaName = null)
*
* @param string $tableName
* @param string $schemaName
- * @return boolean
+ * @return bool
*/
public function isTableExists($tableName, $schemaName = null)
{
@@ -2416,7 +2435,7 @@ public function isTableExists($tableName, $schemaName = null)
* @param string $oldTableName
* @param string $newTableName
* @param string $schemaName
- * @return boolean
+ * @return true
* @throws \Zend_Db_Exception
*/
public function renameTable($oldTableName, $newTableName, $schemaName = null)
@@ -2451,14 +2470,14 @@ public function renameTable($oldTableName, $newTableName, $schemaName = null)
* @throws \Zend_Db_Exception|Exception
*/
public function addIndex($tableName, $indexName, $fields,
- $indexType = \Magento\DB\Adapter\AdapterInterface::INDEX_TYPE_INDEX, $schemaName = null)
+ $indexType = AdapterInterface::INDEX_TYPE_INDEX, $schemaName = null)
{
$columns = $this->describeTable($tableName, $schemaName);
$keyList = $this->getIndexList($tableName, $schemaName);
$query = sprintf('ALTER TABLE %s', $this->quoteIdentifier($this->_getTableName($tableName, $schemaName)));
if (isset($keyList[strtoupper($indexName)])) {
- if ($keyList[strtoupper($indexName)]['INDEX_TYPE'] == \Magento\DB\Adapter\AdapterInterface::INDEX_TYPE_PRIMARY) {
+ if ($keyList[strtoupper($indexName)]['INDEX_TYPE'] == AdapterInterface::INDEX_TYPE_PRIMARY) {
$query .= ' DROP PRIMARY KEY,';
} else {
$query .= sprintf(' DROP INDEX %s,', $this->quoteIdentifier($indexName));
@@ -2481,13 +2500,13 @@ public function addIndex($tableName, $indexName, $fields,
$fieldSql = implode(',', $fieldSql);
switch (strtolower($indexType)) {
- case \Magento\DB\Adapter\AdapterInterface::INDEX_TYPE_PRIMARY:
+ case AdapterInterface::INDEX_TYPE_PRIMARY:
$condition = 'PRIMARY KEY';
break;
- case \Magento\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE:
+ case AdapterInterface::INDEX_TYPE_UNIQUE:
$condition = 'UNIQUE ' . $this->quoteIdentifier($indexName);
break;
- case \Magento\DB\Adapter\AdapterInterface::INDEX_TYPE_FULLTEXT:
+ case AdapterInterface::INDEX_TYPE_FULLTEXT:
$condition = 'FULLTEXT ' . $this->quoteIdentifier($indexName);
break;
default:
@@ -2526,7 +2545,7 @@ public function addIndex($tableName, $indexName, $fields,
* @param string $tableName
* @param string $keyName
* @param string $schemaName
- * @return bool|Zend_Db_Statement_Interface
+ * @return true|\Zend_Db_Statement_Interface
*/
public function dropIndex($tableName, $keyName, $schemaName = null)
{
@@ -2561,14 +2580,14 @@ public function dropIndex($tableName, $keyName, $schemaName = null)
* @param string $refColumnName
* @param string $onDelete
* @param string $onUpdate
- * @param boolean $purge trying remove invalid data
+ * @param bool $purge trying remove invalid data
* @param string $schemaName
* @param string $refSchemaName
- * @return \Magento\DB\Adapter\Pdo\Mysql
+ * @return \Zend_Db_Statement_Interface
*/
public function addForeignKey($fkName, $tableName, $columnName, $refTableName, $refColumnName,
- $onDelete = \Magento\DB\Adapter\AdapterInterface::FK_ACTION_CASCADE,
- $onUpdate = \Magento\DB\Adapter\AdapterInterface::FK_ACTION_CASCADE,
+ $onDelete = AdapterInterface::FK_ACTION_CASCADE,
+ $onUpdate = AdapterInterface::FK_ACTION_CASCADE,
$purge = false, $schemaName = null, $refSchemaName = null)
{
$this->dropForeignKey($tableName, $fkName, $schemaName);
@@ -2600,8 +2619,8 @@ public function addForeignKey($fkName, $tableName, $columnName, $refTableName, $
/**
* Format Date to internal database date format
*
- * @param int|string|Zend_Date $date
- * @param boolean $includeTime
+ * @param int|string|\Zend_Date $date
+ * @param bool $includeTime
* @return \Zend_Db_Expr
*/
public function formatDate($date, $includeTime = true)
@@ -2618,7 +2637,7 @@ public function formatDate($date, $includeTime = true)
/**
* Run additional environment before setup
*
- * @return \Magento\DB\Adapter\Pdo\Mysql
+ * @return $this
*/
public function startSetup()
{
@@ -2632,7 +2651,7 @@ public function startSetup()
/**
* Run additional environment after setup
*
- * @return \Magento\DB\Adapter\Pdo\Mysql
+ * @return $this
*/
public function endSetup()
{
@@ -2668,7 +2687,7 @@ public function endSetup()
* If non matched - sequential array is expected and OR conditions
* will be built using above mentioned structure
*
- * @param string|array $fieldName
+ * @param string $fieldName
* @param integer|string|array $condition
* @return string
*/
@@ -2739,7 +2758,7 @@ public function prepareSqlCondition($fieldName, $condition)
/**
* Prepare Sql condition
*
- * @param $text Condition value
+ * @param string $text Condition value
* @param mixed $value
* @param string $fieldName
* @return string
@@ -2783,7 +2802,7 @@ public function prepareColumnValue(array $column, $value)
if ($value instanceof \Zend_Db_Expr) {
return $value;
}
- if ($value instanceof \Magento\DB\Statement\Parameter) {
+ if ($value instanceof Parameter) {
return $value;
}
@@ -2857,9 +2876,10 @@ public function prepareColumnValue(array $column, $value)
/**
* Generate fragment of SQL, that check condition and return true or false value
*
- * @param \Zend_Db_Expr|Zend_Db_Select|string $expression
+ * @param \Zend_Db_Expr|\Zend_Db_Select|string $expression
* @param string $true true value
* @param string $false false value
+ * @return \Zend_Db_Expr
*/
public function getCheckSql($expression, $true, $false)
{
@@ -2875,8 +2895,8 @@ public function getCheckSql($expression, $true, $false)
/**
* Returns valid IFNULL expression
*
- * @param \Zend_Db_Expr|Zend_Db_Select|string $expression
- * @param string $value OPTIONAL. Applies when $expression is NULL
+ * @param \Zend_Db_Expr|\Zend_Db_Select|string $expression
+ * @param string|int $value OPTIONAL. Applies when $expression is NULL
* @return \Zend_Db_Expr
*/
public function getIfNullSql($expression, $value = 0)
@@ -2897,6 +2917,7 @@ public function getIfNullSql($expression, $value = 0)
* @param string $valueName Name of value to check
* @param array $casesResults Cases and results
* @param string $defaultValue value to use if value doesn't confirm to any cases
+ * @return \Zend_Db_Expr
*/
public function getCaseSql($valueName, $casesResults, $defaultValue = null)
{
@@ -2916,7 +2937,7 @@ public function getCaseSql($valueName, $casesResults, $defaultValue = null)
* Generate fragment of SQL, that combine together (concatenate) the results from data array
* All arguments in data must be quoted
*
- * @param array $data
+ * @param string[] $data
* @param string $separator concatenate with separator
* @return \Zend_Db_Expr
*/
@@ -2943,7 +2964,7 @@ public function getLengthSql($string)
* (minimum-valued) argument
* All arguments in data must be quoted
*
- * @param array $data
+ * @param string[] $data
* @return \Zend_Db_Expr
*/
public function getLeastSql(array $data)
@@ -2956,7 +2977,7 @@ public function getLeastSql(array $data)
* (maximum-valued) argument
* All arguments in data must be quoted
*
- * @param array $data
+ * @param string[] $data
* @return \Zend_Db_Expr
*/
public function getGreatestSql(array $data)
@@ -3050,8 +3071,8 @@ public function getDatePartSql($date)
* Prepare substring sql function
*
* @param \Zend_Db_Expr|string $stringExpression quoted field name or SQL statement
- * @param int|string|Zend_Db_Expr $pos
- * @param int|string|Zend_Db_Expr|null $len
+ * @param int|string|\Zend_Db_Expr $pos
+ * @param int|string|\Zend_Db_Expr|null $len
* @return \Zend_Db_Expr
*/
public function getSubstringSql($stringExpression, $pos, $len = null)
@@ -3096,9 +3117,9 @@ public function getDateExtractSql($date, $unit)
/**
* Minus superfluous characters from hash.
*
- * @param $hash
- * @param $prefix
- * @param $maxCharacters
+ * @param string $hash
+ * @param string $prefix
+ * @param int $maxCharacters
* @return string
*/
protected function _minusSuperfluous($hash, $prefix, $maxCharacters)
@@ -3121,7 +3142,7 @@ public function getTableName($tableName)
{
$prefix = 't_';
if (strlen($tableName) > self::LENGTH_TABLE_NAME) {
- $shortName = \Magento\DB\Helper::shortName($tableName);
+ $shortName = Helper::shortName($tableName);
if (strlen($shortName) > self::LENGTH_TABLE_NAME) {
$hash = md5($tableName);
if (strlen($prefix.$hash) > self::LENGTH_TABLE_NAME) {
@@ -3142,7 +3163,7 @@ public function getTableName($tableName)
* Check index name length and allowed symbols
*
* @param string $tableName
- * @param string|array $fields the columns list
+ * @param string|string[] $fields the columns list
* @param string $indexType
* @return string
*/
@@ -3153,15 +3174,15 @@ public function getIndexName($tableName, $fields, $indexType = '')
}
switch (strtolower($indexType)) {
- case \Magento\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE:
+ case AdapterInterface::INDEX_TYPE_UNIQUE:
$prefix = 'unq_';
$shortPrefix = 'u_';
break;
- case \Magento\DB\Adapter\AdapterInterface::INDEX_TYPE_FULLTEXT:
+ case AdapterInterface::INDEX_TYPE_FULLTEXT:
$prefix = 'fti_';
$shortPrefix = 'f_';
break;
- case \Magento\DB\Adapter\AdapterInterface::INDEX_TYPE_INDEX:
+ case AdapterInterface::INDEX_TYPE_INDEX:
default:
$prefix = 'idx_';
$shortPrefix = 'i_';
@@ -3170,7 +3191,7 @@ public function getIndexName($tableName, $fields, $indexType = '')
$hash = $tableName . '_' . $fields;
if (strlen($hash) + strlen($prefix) > self::LENGTH_INDEX_NAME) {
- $short = \Magento\DB\Helper::shortName($prefix . $hash);
+ $short = Helper::shortName($prefix . $hash);
if (strlen($short) > self::LENGTH_INDEX_NAME) {
$hash = md5($hash);
if (strlen($hash) + strlen($shortPrefix) > self::LENGTH_INDEX_NAME) {
@@ -3201,7 +3222,7 @@ public function getForeignKeyName($priTableName, $priColumnName, $refTableName,
$prefix = 'fk_';
$hash = sprintf('%s_%s_%s_%s', $priTableName, $priColumnName, $refTableName, $refColumnName);
if (strlen($prefix.$hash) > self::LENGTH_FOREIGN_NAME) {
- $short = \Magento\DB\Helper::shortName($prefix.$hash);
+ $short = Helper::shortName($prefix.$hash);
if (strlen($short) > self::LENGTH_FOREIGN_NAME) {
$hash = md5($hash);
if (strlen($prefix.$hash) > self::LENGTH_FOREIGN_NAME) {
@@ -3224,7 +3245,7 @@ public function getForeignKeyName($priTableName, $priColumnName, $refTableName,
*
* @param string $tableName
* @param string $schemaName
- * @return \Magento\DB\Adapter\Pdo\Mysql
+ * @return $this
*/
public function disableTableKeys($tableName, $schemaName = null)
{
@@ -3240,7 +3261,7 @@ public function disableTableKeys($tableName, $schemaName = null)
*
* @param string $tableName
* @param string $schemaName
- * @return \Magento\DB\Adapter\Pdo\Mysql
+ * @return $this
*/
public function enableTableKeys($tableName, $schemaName = null)
{
@@ -3254,13 +3275,13 @@ public function enableTableKeys($tableName, $schemaName = null)
/**
* Get insert from Select object query
*
- * @param \Magento\DB\Select $select
+ * @param Select $select
* @param string $table insert into table
* @param array $fields
* @param int $mode
* @return string
*/
- public function insertFromSelect(\Magento\DB\Select $select, $table, array $fields = array(), $mode = false)
+ public function insertFromSelect(Select $select, $table, array $fields = array(), $mode = false)
{
$query = 'INSERT';
if ($mode == self::INSERT_IGNORE) {
@@ -3299,11 +3320,11 @@ public function insertFromSelect(\Magento\DB\Select $select, $table, array $fiel
/**
* Get update table query using select object for join and update
*
- * @param \Magento\DB\Select $select
+ * @param Select $select
* @param string|array $table
* @return string
*/
- public function updateFromSelect(\Magento\DB\Select $select, $table)
+ public function updateFromSelect(Select $select, $table)
{
if (!is_array($table)) {
$table = array($table => $table);
@@ -3374,11 +3395,11 @@ public function updateFromSelect(\Magento\DB\Select $select, $table)
/**
* Get delete from select object query
*
- * @param \Magento\DB\Select $select
+ * @param Select $select
* @param string $table the table name or alias used in select
- * @return string|int
+ * @return string
*/
- public function deleteFromSelect(\Magento\DB\Select $select, $table)
+ public function deleteFromSelect(Select $select, $table)
{
$select = clone $select;
$select->reset(\Zend_Db_Select::DISTINCT);
@@ -3394,7 +3415,7 @@ public function deleteFromSelect(\Magento\DB\Select $select, $table)
*
* @param array|string $tableNames array of tables names | table name
* @param string $schemaName schema name
- * @return arrray
+ * @return array
*/
public function getTablesChecksum($tableNames, $schemaName = null)
{
@@ -3413,7 +3434,7 @@ public function getTablesChecksum($tableNames, $schemaName = null)
/**
* Check if the database support STRAIGHT JOIN
*
- * @return boolean
+ * @return true
*/
public function supportStraightJoin()
{
@@ -3424,11 +3445,11 @@ public function supportStraightJoin()
* Adds order by random to select object
* Possible using integer field for optimization
*
- * @param \Magento\DB\Select $select
+ * @param Select $select
* @param string $field
- * @return \Magento\DB\Adapter\Pdo\Mysql
+ * @return $this
*/
- public function orderRand(\Magento\DB\Select $select, $field = null)
+ public function orderRand(Select $select, $field = null)
{
if ($field !== null) {
$expression = new \Zend_Db_Expr(sprintf('RAND() * %s', $this->quoteIdentifier($field)));
@@ -3524,14 +3545,14 @@ protected function _getDdlType($options)
protected function _getDdlAction($action)
{
switch ($action) {
- case \Magento\DB\Adapter\AdapterInterface::FK_ACTION_CASCADE:
- return \Magento\DB\Ddl\Table::ACTION_CASCADE;
- case \Magento\DB\Adapter\AdapterInterface::FK_ACTION_SET_NULL:
- return \Magento\DB\Ddl\Table::ACTION_SET_NULL;
- case \Magento\DB\Adapter\AdapterInterface::FK_ACTION_RESTRICT:
- return \Magento\DB\Ddl\Table::ACTION_RESTRICT;
+ case AdapterInterface::FK_ACTION_CASCADE:
+ return Table::ACTION_CASCADE;
+ case AdapterInterface::FK_ACTION_SET_NULL:
+ return Table::ACTION_SET_NULL;
+ case AdapterInterface::FK_ACTION_RESTRICT:
+ return Table::ACTION_RESTRICT;
default:
- return \Magento\DB\Ddl\Table::ACTION_NO_ACTION;
+ return Table::ACTION_NO_ACTION;
}
}
@@ -3599,10 +3620,10 @@ protected function _parseTextSize($size)
}
if (empty($size)) {
- return \Magento\DB\Ddl\Table::DEFAULT_TEXT_SIZE;
+ return Table::DEFAULT_TEXT_SIZE;
}
- if ($size >= \Magento\DB\Ddl\Table::MAX_TEXT_SIZE) {
- return \Magento\DB\Ddl\Table::MAX_TEXT_SIZE;
+ if ($size >= Table::MAX_TEXT_SIZE) {
+ return Table::MAX_TEXT_SIZE;
}
return intval($size);
@@ -3612,7 +3633,7 @@ protected function _parseTextSize($size)
* Converts fetched blob into raw binary PHP data.
* The MySQL drivers do it nice, no processing required.
*
- * @mixed $value
+ * @param mixed $value
* @return mixed
*/
public function decodeVarbinary($value)
@@ -3620,8 +3641,58 @@ public function decodeVarbinary($value)
return $value;
}
+ /**
+ * Create trigger
+ *
+ * @param \Magento\DB\Ddl\Trigger $trigger
+ * @throws \Zend_Db_Exception
+ * @return \Zend_Db_Statement_Pdo
+ */
+ public function createTrigger(\Magento\DB\Ddl\Trigger $trigger)
+ {
+ if (!$trigger->getStatements()) {
+ throw new \Zend_Db_Exception(sprintf(__('Trigger %s has not statements available'), $trigger->getName()));
+ }
+
+ $statements = implode("\n", $trigger->getStatements());
+
+ $sql = sprintf("CREATE TRIGGER %s %s %s ON %s FOR EACH ROW\nBEGIN\n%s\nEND",
+ $trigger->getName(),
+ $trigger->getTime(),
+ $trigger->getEvent(),
+ $trigger->getTable(),
+ $statements
+ );
+
+ return $this->query($sql);
+ }
+
+ /**
+ * Drop trigger from database
+ *
+ * @param string $triggerName
+ * @param string $schemaName
+ * @throws \InvalidArgumentException
+ * @return bool
+ */
+ public function dropTrigger($triggerName, $schemaName = null)
+ {
+ if (empty($triggerName)) {
+ throw new \InvalidArgumentException(__('Trigger name is not defined'));
+ }
+
+ $triggerName = ($schemaName ? $schemaName . '.' : '') . $triggerName;
+
+ $sql = 'DROP TRIGGER IF EXISTS ' . $this->quoteIdentifier($triggerName);
+ $this->query($sql);
+
+ return true;
+ }
+
/**
* Check if all transactions have been committed
+ *
+ * @return void
*/
public function __destruct()
{
diff --git a/lib/Magento/DB/Ddl/Table.php b/lib/Magento/DB/Ddl/Table.php
index 0a6f4ca7ee1f7..1355ea20717c0 100644
--- a/lib/Magento/DB/Ddl/Table.php
+++ b/lib/Magento/DB/Ddl/Table.php
@@ -34,6 +34,8 @@
*/
namespace Magento\DB\Ddl;
+use \Magento\DB\Adapter\AdapterInterface;
+
class Table
{
/**
@@ -182,7 +184,7 @@ class Table
* Set table name
*
* @param string $name
- * @return \Magento\DB\Ddl\Table
+ * @return $this
*/
public function setName($name)
{
@@ -197,7 +199,7 @@ public function setName($name)
* Set schema name
*
* @param string $name
- * @return \Magento\DB\Ddl\Table
+ * @return $this
*/
public function setSchema($name)
{
@@ -209,7 +211,7 @@ public function setSchema($name)
* Set comment for table
*
* @param string $comment
- * @return \Magento\DB\Ddl\Table
+ * @return $this
*/
public function setComment($comment)
{
@@ -220,8 +222,8 @@ public function setComment($comment)
/**
* Retrieve name of table
*
- * @throws \Zend_Db_Exception
* @return string
+ * @throws \Zend_Db_Exception
*/
public function getName()
{
@@ -269,8 +271,8 @@ public function getComment()
* @param string|int|array $size the column length
* @param array $options array of additional options
* @param string $comment column description
+ * @return $this
* @throws \Zend_Db_Exception
- * @return \Magento\DB\Ddl\Table
*/
public function addColumn($name, $type, $size = null, $options = array(), $comment = null)
{
@@ -404,8 +406,8 @@ public function addColumn($name, $type, $size = null, $options = array(), $comme
* @param string $refColumn the reference table column name
* @param string $onDelete the action on delete row
* @param string $onUpdate the action on update
+ * @return $this
* @throws \Zend_Db_Exception
- * @return \Magento\DB\Ddl\Table
*/
public function addForeignKey($fkName, $column, $refTable, $refColumn, $onDelete = null, $onUpdate = null)
{
@@ -451,14 +453,15 @@ public function addForeignKey($fkName, $column, $refTable, $refColumn, $onDelete
/**
* Add index to table
*
- * @param string $indexName the index name
- * @param array|string $columns array of columns or column string
- * @param array $options array of additional options
- * @return \Magento\DB\Ddl\Table
+ * @param string $indexName the index name
+ * @param array|string $fields array of columns or column string
+ * @param array $options array of additional options
+ * @return $this
+ * @throws \Zend_Db_Exception
*/
public function addIndex($indexName, $fields, $options = array())
{
- $idxType = \Magento\DB\Adapter\AdapterInterface::INDEX_TYPE_INDEX;
+ $idxType = AdapterInterface::INDEX_TYPE_INDEX;
$position = 0;
$columns = array();
if (!is_array($fields)) {
@@ -532,7 +535,7 @@ public function getColumns($normalized = true)
*
* @param array $column
* @see $this->_columns
- * @return \Magento\DB\Ddl\Table
+ * @return $this
*/
public function setColumn($column)
{
@@ -568,7 +571,7 @@ public function getForeignKeys()
*
* @param string $key
* @param string $value
- * @return \Magento\DB\Ddl\Table
+ * @return $this
*/
public function setOption($key, $value)
{
@@ -581,7 +584,7 @@ public function setOption($key, $value)
* Return null if option does not exits
*
* @param string $key
- * @return mixed
+ * @return null|string
*/
public function getOption($key)
{
diff --git a/lib/Magento/DB/Ddl/Trigger.php b/lib/Magento/DB/Ddl/Trigger.php
new file mode 100644
index 0000000000000..3ccd17ce3c61d
--- /dev/null
+++ b/lib/Magento/DB/Ddl/Trigger.php
@@ -0,0 +1,273 @@
+name = strtolower($name);
+ return $this;
+ }
+
+ /**
+ * Retrieve name of trigger
+ *
+ * @throws \Zend_Db_Exception
+ * @return string
+ */
+ public function getName()
+ {
+ if (empty($this->name)) {
+ throw new \Zend_Db_Exception(__('Trigger name is not defined'));
+ }
+ return $this->name;
+ }
+
+ /**
+ * Set trigger time
+ *
+ * @param string $time
+ * @throws \InvalidArgumentException
+ * @return \Magento\DB\Ddl\Trigger
+ */
+ public function setTime($time)
+ {
+ if (in_array($time, self::$listOfTimes)) {
+ $this->time = strtoupper($time);
+ } else {
+ throw new \InvalidArgumentException(__('Trigger unsupported time type'));
+ }
+ return $this;
+ }
+
+ /**
+ * Retrieve time of trigger
+ *
+ * @throws \Zend_Db_Exception
+ * @return string
+ */
+ public function getTime()
+ {
+ if (is_null($this->time)) {
+ throw new \Zend_Db_Exception(__('Trigger time is not defined'));
+ }
+ return $this->time;
+ }
+
+ /**
+ * Set trigger event
+ *
+ * @param string $event
+ * @throws \InvalidArgumentException
+ * @return \Magento\DB\Ddl\Trigger
+ */
+ public function setEvent($event)
+ {
+ if (in_array($event, self::$listOfEvents)) {
+ $this->event = strtoupper($event);
+ } else {
+ throw new \InvalidArgumentException(__('Trigger unsupported event type'));
+ }
+ return $this;
+ }
+
+ /**
+ * Retrieve event of trigger
+ *
+ * @throws \Zend_Db_Exception
+ * @return string
+ */
+ public function getEvent()
+ {
+ if (is_null($this->event)) {
+ throw new \Zend_Db_Exception(__('Trigger event is not defined'));
+ }
+ return $this->event;
+ }
+
+ /**
+ * Set table name
+ *
+ * @param string $name
+ * @throws \InvalidArgumentException
+ * @return \Magento\DB\Ddl\Trigger
+ */
+ public function setTable($name)
+ {
+ if (!is_string($name)) {
+ throw new \InvalidArgumentException(__('Trigger table name should be a string'));
+ }
+ $this->tableName = strtolower($name);
+ return $this;
+ }
+
+ /**
+ * Retrieve table name
+ *
+ * @throws \Zend_Db_Exception
+ * @return string
+ */
+ public function getTable()
+ {
+ if (empty($this->tableName)) {
+ throw new \Zend_Db_Exception(__('Trigger table name is not defined'));
+ }
+ return $this->tableName;
+ }
+
+ /**
+ * Add statement to trigger
+ *
+ * @param string $statement
+ * @throws \InvalidArgumentException
+ * @return \Magento\DB\Ddl\Trigger
+ */
+ public function addStatement($statement)
+ {
+ if (!is_string($statement)) {
+ throw new \InvalidArgumentException(__('Trigger statement should be a string'));
+ }
+
+ $statement = trim($statement);
+ $statement = rtrim($statement, ';') . ';';
+
+ $this->statements[] = $statement;
+
+ return $this;
+ }
+
+ /**
+ * Retrieve list of statements of trigger
+ *
+ * @return array
+ */
+ public function getStatements()
+ {
+ return $this->statements;
+ }
+
+ /**
+ * Retrieve list of times available for trigger
+ *
+ * @return array
+ */
+ public static function getListOfTimes()
+ {
+ return self::$listOfTimes;
+ }
+
+ /**
+ * Retrieve list of events available for trigger
+ *
+ * @return array
+ */
+ public static function getListOfEvents()
+ {
+ return self::$listOfEvents;
+ }
+}
diff --git a/lib/Magento/DB/Ddl/TriggerFactory.php b/lib/Magento/DB/Ddl/TriggerFactory.php
new file mode 100644
index 0000000000000..067844a03ed9d
--- /dev/null
+++ b/lib/Magento/DB/Ddl/TriggerFactory.php
@@ -0,0 +1,57 @@
+_objectManager = $objectManager;
+ }
+
+ /**
+ * Create class instance with specified parameters
+ *
+ * @param array $data
+ * @return \Magento\DB\Ddl\Trigger
+ */
+ public function create(array $data = array())
+ {
+ return $this->_objectManager->create(self::INSTANCE_NAME, $data);
+ }
+}
diff --git a/lib/Magento/DB/Helper.php b/lib/Magento/DB/Helper.php
index e14b803220337..7ac11cdd41aa2 100644
--- a/lib/Magento/DB/Helper.php
+++ b/lib/Magento/DB/Helper.php
@@ -104,6 +104,7 @@ public static function shortName($name)
*
* @param string $from
* @param string $to
+ * @return void
*/
public static function addTranslate($from, $to)
{
diff --git a/lib/Magento/DB/Select.php b/lib/Magento/DB/Select.php
index be28f0de8db86..9ccfc285dd48c 100644
--- a/lib/Magento/DB/Select.php
+++ b/lib/Magento/DB/Select.php
@@ -52,6 +52,8 @@
*/
namespace Magento\DB;
+use Magento\DB\Adapter\AdapterInterface;
+
class Select extends \Zend_Db_Select
{
/**
@@ -111,9 +113,9 @@ public function __construct(\Zend_Db_Adapter_Abstract $adapter)
* $db->fetchAll($select, array('id' => 5));
*
*
- * @param string $cond The WHERE condition.
- * @param string $value OPTIONAL A single value to quote into the condition.
- * @param string|int|null $type OPTIONAL The type of the given value
+ * @param string $cond The WHERE condition.
+ * @param string $value OPTIONAL A single value to quote into the condition.
+ * @param string|int|null $type OPTIONAL The type of the given value
* @return \Magento\DB\Select
*/
public function where($cond, $value = null, $type = null)
@@ -133,7 +135,7 @@ public function where($cond, $value = null, $type = null)
/**
* Reset unused LEFT JOIN(s)
*
- * @return \Magento\DB\Select
+ * @return $this
*/
public function resetJoinLeft()
{
@@ -193,7 +195,7 @@ public function resetJoinLeft()
/**
* Validate LEFT joins, and remove it if not exists
*
- * @return \Magento\DB\Select
+ * @return $this
*/
protected function _resetJoinLeft()
{
@@ -293,7 +295,7 @@ protected function _join($type, $name, $cond, $cols, $schema = null)
*
* @param int $count OPTIONAL The number of rows to return.
* @param int $offset OPTIONAL Start returning after this many rows.
- * @return \Zend_Db_Select This \Zend_Db_Select object.
+ * @return $this
*/
public function limit($count = null, $offset = null)
{
@@ -331,7 +333,7 @@ public function crossUpdateFromSelect($table)
*/
public function insertFromSelect($tableName, $fields = array(), $onDuplicate = true)
{
- $mode = $onDuplicate ? \Magento\DB\Adapter\AdapterInterface::INSERT_ON_DUPLICATE : false;
+ $mode = $onDuplicate ? AdapterInterface::INSERT_ON_DUPLICATE : false;
return $this->getAdapter()->insertFromSelect($this, $tableName, $fields, $mode);
}
@@ -345,7 +347,7 @@ public function insertFromSelect($tableName, $fields = array(), $onDuplicate = t
public function insertIgnoreFromSelect($tableName, $fields = array())
{
return $this->getAdapter()
- ->insertFromSelect($this, $tableName, $fields, \Magento\DB\Adapter\AdapterInterface::INSERT_IGNORE);
+ ->insertFromSelect($this, $tableName, $fields, AdapterInterface::INSERT_IGNORE);
}
/**
@@ -364,7 +366,7 @@ public function deleteFromSelect($table)
*
* @param string $part
* @param mixed $value
- * @return \Magento\DB\Select
+ * @return $this
* @throws \Zend_Db_Select_Exception
*/
public function setPart($part, $value)
@@ -381,7 +383,7 @@ public function setPart($part, $value)
* Use a STRAIGHT_JOIN for the SQL Select
*
* @param bool $flag Whether or not the SELECT use STRAIGHT_JOIN (default true).
- * @return \Zend_Db_Select This \Zend_Db_Select object.
+ * @return $this
*/
public function useStraightJoin($flag = true)
{
@@ -412,6 +414,7 @@ protected function _renderStraightjoin($sql)
* but possibly as a string containing one column.
* @param bool|string $afterCorrelationName True if it should be prepended,
* a correlation name if it should be inserted
+ * @return void
*/
protected function _tableCols($correlationName, $cols, $afterCorrelationName = null)
{
@@ -420,7 +423,7 @@ protected function _tableCols($correlationName, $cols, $afterCorrelationName = n
}
foreach ($cols as $k => $v) {
- if ($v instanceof \Magento\DB\Select) {
+ if ($v instanceof Select) {
$cols[$k] = new \Zend_Db_Expr(sprintf('(%s)', $v->assemble()));
}
}
@@ -432,7 +435,7 @@ protected function _tableCols($correlationName, $cols, $afterCorrelationName = n
* Adds the random order to query
*
* @param string $field integer field name
- * @return \Magento\DB\Select
+ * @return $this
*/
public function orderRand($field = null)
{
@@ -454,13 +457,14 @@ protected function _renderForupdate($sql)
return $sql;
}
+
/**
* Add EXISTS clause
*
- * @param \Magento\DB\Select $select
+ * @param Select $select
* @param string $joinCondition
* @param bool $isExists
- * @return \Magento\DB\Select
+ * @return $this
*/
public function exists($select, $joinCondition, $isExists = true)
{
diff --git a/lib/Magento/DB/Statement/Parameter.php b/lib/Magento/DB/Statement/Parameter.php
index a33d953d7a855..a9fd3f7787333 100644
--- a/lib/Magento/DB/Statement/Parameter.php
+++ b/lib/Magento/DB/Statement/Parameter.php
@@ -43,6 +43,8 @@ class Parameter
{
/**
* Actual parameter value
+ *
+ * @var mixed
*/
protected $_value = null;
@@ -52,26 +54,31 @@ class Parameter
* A shortcut setting to notify DB adapter, that value must be bound in a default way, as adapter binds
* BLOB data to query placeholders. If FALSE, then specific settings from $_dataType, $_length,
* $_driverOptions will be used.
+ * @var bool
*/
protected $_isBlob = false;
/*
* Data type to set to DB driver during parameter bind
+ * @var mixed
*/
protected $_dataType = null;
/*
* Length to set to DB driver during parameter bind
+ * @var mixed
*/
protected $_length = null;
/*
* Specific driver options to set to DB driver during parameter bind
+ * @var mixed
*/
protected $_driverOptions = null;
/*
* Additional information to be used by DB adapter internally
+ * @var \Magento\Object
*/
protected $_additional = null;
@@ -79,7 +86,7 @@ class Parameter
* Inits instance
*
* @param mixed $value
- * @return \Magento\DB\Statement\Parameter
+ * @return $this
*/
public function __construct($value)
{
@@ -92,7 +99,7 @@ public function __construct($value)
* Sets parameter value.
*
* @param mixed $value
- * @return \Magento\DB\Statement\Parameter
+ * @return $this
*/
public function setValue($value)
{
@@ -118,7 +125,7 @@ public function getValue()
* as a BLOB value.
*
* @param bool $isBlob
- * @return \Magento\DB\Statement\Parameter
+ * @return $this
*/
public function setIsBlob($isBlob)
{
@@ -143,7 +150,7 @@ public function getIsBlob()
* Sets data type option to be used during binding parameter value.
*
* @param mixed $dataType
- * @return \Magento\DB\Statement\Parameter
+ * @return $this
*/
public function setDataType($dataType)
{
@@ -165,7 +172,7 @@ public function getDataType()
* Sets length option to be used during binding parameter value.
*
* @param mixed $length
- * @return \Magento\DB\Statement\Parameter
+ * @return $this
*/
public function setLength($length)
{
@@ -187,7 +194,7 @@ public function getLength()
* Sets specific driver options to be used during binding parameter value.
*
* @param mixed $driverOptions
- * @return \Magento\DB\Statement\Parameter
+ * @return $this
*/
public function setDriverOptions($driverOptions)
{
@@ -210,7 +217,7 @@ public function getDriverOptions()
* Set there any data you want to pass along with query parameter.
*
* @param \Magento\Object $additional
- * @return \Magento\DB\Statement\Parameter
+ * @return $this
*/
public function setAdditional($additional)
{
diff --git a/lib/Magento/DB/Statement/Pdo/Mysql.php b/lib/Magento/DB/Statement/Pdo/Mysql.php
index 73b6f6fce90cd..82ccb446977df 100644
--- a/lib/Magento/DB/Statement/Pdo/Mysql.php
+++ b/lib/Magento/DB/Statement/Pdo/Mysql.php
@@ -34,6 +34,8 @@
*/
namespace Magento\DB\Statement\Pdo;
+use Magento\DB\Statement\Parameter;
+
class Mysql extends \Zend_Db_Statement_Pdo
{
/**
@@ -63,7 +65,7 @@ public function _executeWithBinding(array $params)
$length = null;
$driverOptions = null;
- if ($param instanceof \Magento\DB\Statement\Parameter) {
+ if ($param instanceof Parameter) {
if ($param->getIsBlob()) {
// Nothing to do there - default options are fine for MySQL driver
} else {
@@ -99,7 +101,7 @@ public function _execute(array $params = null)
$specialExecute = false;
if ($params) {
foreach ($params as $param) {
- if ($param instanceof \Magento\DB\Statement\Parameter) {
+ if ($param instanceof Parameter) {
$specialExecute = true;
break;
}
diff --git a/lib/Magento/DB/Tree.php b/lib/Magento/DB/Tree.php
index 0f26844807f40..906d4b14ecd33 100644
--- a/lib/Magento/DB/Tree.php
+++ b/lib/Magento/DB/Tree.php
@@ -27,17 +27,44 @@
namespace Magento\DB;
\Zend_Loader::loadClass('\Zend_Db_Select'); \Zend_Loader::loadClass('\Magento\DB\Tree\Node'); \Zend_Loader::loadClass('\Magento\DB\Tree\NodeSet');
+use Magento\DB\Tree\Node;
+use Magento\DB\Tree\NodeSet;
+use Magento\DB\Tree\TreeException;
+
/**
* Magento Library
*/
require_once 'Tree/TreeException.php';
class Tree
{
+ /**
+ * @var string|int
+ */
private $_id;
+
+ /**
+ * @var int
+ */
private $_left;
+
+ /**
+ * @var int
+ */
private $_right;
+
+ /**
+ * @var int
+ */
private $_level;
+
+ /**
+ * @var int
+ */
private $_pid;
+
+ /**
+ * @var array
+ */
private $_nodesInfo = array();
/**
@@ -61,11 +88,14 @@ class Tree
*/
private $_db;
+ /**
+ * @var string
+ */
private $_table;
/**
* @param array $config
- * @throws \Magento\DB\Tree\TreeException
+ * @throws TreeException
*/
public function __construct($config = array())
{
@@ -82,7 +112,7 @@ public function __construct($config = array())
// make sure it's a \Zend_Db_Adapter
if (! $connection instanceof \Zend_Db_Adapter_Abstract) {
- throw new \Magento\DB\Tree\TreeException('db object does not implement \Zend_Db_Adapter_Abstract');
+ throw new TreeException('db object does not implement \Zend_Db_Adapter_Abstract');
}
// save the connection
@@ -92,7 +122,7 @@ public function __construct($config = array())
$conn->setAttribute (\PDO::ATTR_EMULATE_PREPARES, true);
}
} else {
- throw new \Magento\DB\Tree\TreeException('db object is not set in config');
+ throw new TreeException('db object is not set in config');
}
if (!empty($config['table'])) {
@@ -134,7 +164,7 @@ public function __construct($config = array())
* set name of id field
*
* @param string $name
- * @return \Magento\DB\Tree
+ * @return $this
*/
public function setIdField($name)
{
@@ -146,7 +176,7 @@ public function setIdField($name)
* set name of left field
*
* @param string $name
- * @return \Magento\DB\Tree
+ * @return $this
*/
public function setLeftField($name)
{
@@ -158,7 +188,7 @@ public function setLeftField($name)
* set name of right field
*
* @param string $name
- * @return \Magento\DB\Tree
+ * @return $this
*/
public function setRightField($name)
{
@@ -170,7 +200,7 @@ public function setRightField($name)
* set name of level field
*
* @param string $name
- * @return \Magento\DB\Tree
+ * @return $this
*/
public function setLevelField($name)
{
@@ -182,7 +212,7 @@ public function setLevelField($name)
* set name of pid Field
*
* @param string $name
- * @return \Magento\DB\Tree
+ * @return $this
*/
public function setPidField($name)
{
@@ -194,7 +224,7 @@ public function setPidField($name)
* set table name
*
* @param string $name
- * @return \Magento\DB\Tree
+ * @return $this
*/
public function setTable($name)
{
@@ -262,8 +292,8 @@ public function getNodeInfo($nodeId)
/**
* @param string|int $nodeId
- * @param mixed $data
- * @return bool|string
+ * @param array $data
+ * @return false|string
*/
public function appendChild($nodeId, $data)
{
@@ -331,7 +361,7 @@ public function checkNodes()
/**
* @param string|int $nodeId
- * @return bool|\Magento\DB\Tree\Node
+ * @return bool|Node
*/
public function removeNode($nodeId)
{
@@ -365,7 +395,7 @@ public function removeNode($nodeId)
. $this->_right . ' > ' . $info[$this->_right];
$this->_db->query($sql);
$this->_db->commit();
- return new \Magento\DB\Tree\Node($info, $this->getKeys());
+ return new Node($info, $this->getKeys());
} catch (\Exception $e) {
$this->_db->rollBack();
echo $e->getMessage();
@@ -471,6 +501,7 @@ public function moveNode($eId, $pId, $aId = 0) {
* @param string|int $eId
* @param string|int $pId
* @param string|int $aId
+ * @return void
*/
public function moveNodes($eId, $pId, $aId = 0)
{
@@ -562,6 +593,7 @@ public function moveNodes($eId, $pId, $aId = 0)
* @param string $tableName
* @param string $joinCondition
* @param string $fields
+ * @return void
*/
public function addTable($tableName, $joinCondition, $fields = '*')
{
@@ -573,6 +605,7 @@ public function addTable($tableName, $joinCondition, $fields = '*')
/**
* @param \Zend_Db_Select $select
+ * @return void
*/
protected function _addExtTablesToSelect(\Zend_Db_Select &$select)
{
@@ -585,7 +618,7 @@ protected function _addExtTablesToSelect(\Zend_Db_Select &$select)
* @param string|int $nodeId
* @param int $startLevel
* @param int $endLevel
- * @return \Magento\DB\Tree\NodeSet
+ * @return NodeSet
*/
public function getChildren($nodeId, $startLevel = 0, $endLevel = 0)
{
@@ -616,16 +649,16 @@ public function getChildren($nodeId, $startLevel = 0, $endLevel = 0)
//echo $dbSelect->__toString();
$data = $this->_db->fetchAll($dbSelect, $data);
- $nodeSet = new \Magento\DB\Tree\NodeSet();
+ $nodeSet = new NodeSet();
foreach ($data as $node) {
- $nodeSet->addNode(new \Magento\DB\Tree\Node($node, $this->getKeys()));
+ $nodeSet->addNode(new Node($node, $this->getKeys()));
}
return $nodeSet;
}
/**
* @param string|int $nodeId
- * @return \Magento\DB\Tree\Node
+ * @return Node
*/
public function getNode($nodeId)
{
@@ -640,6 +673,6 @@ public function getNode($nodeId)
$data = $this->_db->fetchRow($dbSelect, $data);
- return new \Magento\DB\Tree\Node($data, $this->getKeys());
+ return new Node($data, $this->getKeys());
}
}
diff --git a/lib/Magento/DB/Tree/Node.php b/lib/Magento/DB/Tree/Node.php
index 15586bbfaf803..b9982998ced3d 100644
--- a/lib/Magento/DB/Tree/Node.php
+++ b/lib/Magento/DB/Tree/Node.php
@@ -27,29 +27,68 @@
namespace Magento\DB\Tree;
-
+use Magento\DB\Tree\Node\NodeException;
class Node {
+ /**
+ * @var int
+ */
private $left;
+
+ /**
+ * @var int
+ */
private $right;
+
+ /**
+ * @var string|int
+ */
private $id;
+
+ /**
+ * @var string|int
+ */
private $pid;
+
+ /**
+ * @var int
+ */
private $level;
+
+ /**
+ * @var string
+ */
private $title;
- private $data;
+ /**
+ * @var array
+ */
+ private $data;
+ /**
+ * @var bool
+ */
public $hasChild = false;
+
+ /**
+ * @var float|int
+ */
public $numChild = 0;
+ /**
+ * @param array $nodeData
+ * @param array $keys
+ * @return $this
+ * @throws NodeException
+ */
function __construct($nodeData, $keys) {
if (empty($nodeData)) {
- throw new \Magento\DB\Tree\Node\NodeException('Empty array of node information');
+ throw new NodeException('Empty array of node information');
}
if (empty($keys)) {
- throw new \Magento\DB\Tree\Node\NodeException('Empty keys array');
+ throw new NodeException('Empty keys array');
}
$this->id = $nodeData[$keys['id']];
@@ -67,6 +106,10 @@ function __construct($nodeData, $keys) {
return $this;
}
+ /**
+ * @param string $name
+ * @return null|array
+ */
function getData($name) {
if (isset($this->data[$name])) {
return $this->data[$name];
@@ -75,30 +118,45 @@ function getData($name) {
}
}
+ /**
+ * @return int
+ */
function getLevel() {
return $this->level;
}
+ /**
+ * @return int
+ */
function getLeft() {
return $this->left;
}
+ /**
+ * @return int
+ */
function getRight() {
return $this->right;
}
+ /**
+ * @return string|int
+ */
function getPid() {
return $this->pid;
}
+ /**
+ * @return string|int
+ */
function getId() {
return $this->id;
}
/**
- * Return true if node have chield
+ * Return true if node has child
*
- * @return boolean
+ * @return bool
*/
function isParent() {
if ($this->right - $this->left > 1) {
diff --git a/lib/Magento/DB/Tree/NodeSet.php b/lib/Magento/DB/Tree/NodeSet.php
index 128025653b42e..5bc14f9e50f6c 100644
--- a/lib/Magento/DB/Tree/NodeSet.php
+++ b/lib/Magento/DB/Tree/NodeSet.php
@@ -33,10 +33,20 @@
class NodeSet implements \Iterator
{
+ /**
+ * @var Node[]
+ */
private $_nodes = array();
+
+ /**
+ * @var int
+ */
private $_currentNode = 0;
- private $_current = 0;
+ /**
+ * @var int
+ */
+ private $_current = 0;
function __construct() {
$this->_nodes = array();
@@ -45,23 +55,33 @@ function __construct() {
$this->count = 0;
}
-
-
- function addNode(\Magento\DB\Tree\Node $node) {
+ /**
+ * @param Node $node
+ * @return int
+ */
+ function addNode(Node $node) {
$this->_nodes[$this->_currentNode] = $node;
$this->count++;
return ++$this->_currentNode;
}
+ /**
+ * @return int
+ */
function count() {
return $this->count;
}
-
+ /**
+ * @return bool
+ */
function valid() {
return isset($this->_nodes[$this->_current]);
}
+ /**
+ * @return false|int
+ */
function next() {
if ($this->_current > $this->_currentNode) {
return false;
@@ -70,15 +90,23 @@ function next() {
}
}
+ /**
+ * @return int
+ */
function key() {
return $this->_current;
}
-
+ /**
+ * @return Node
+ */
function current() {
return $this->_nodes[$this->_current];
}
+ /**
+ * @return void
+ */
function rewind() {
$this->_current = 0;
}
diff --git a/lib/Magento/Data/Collection.php b/lib/Magento/Data/Collection.php
index d39caed4dd9b8..a4d58e3b0f558 100644
--- a/lib/Magento/Data/Collection.php
+++ b/lib/Magento/Data/Collection.php
@@ -38,6 +38,8 @@
*/
namespace Magento\Data;
+use Magento\Data\Collection\EntityFactoryInterface;
+
class Collection implements \IteratorAggregate, \Countable, \Magento\Core\Model\Option\ArrayInterface
{
const SORT_ORDER_ASC = 'ASC';
@@ -46,7 +48,7 @@ class Collection implements \IteratorAggregate, \Countable, \Magento\Core\Model\
/**
* Collection items
*
- * @var array
+ * @var \Magento\Object[]
*/
protected $_items = array();
@@ -67,7 +69,7 @@ class Collection implements \IteratorAggregate, \Countable, \Magento\Core\Model\
/**
* Filters configuration
*
- * @var array
+ * @var \Magento\Object[]
*/
protected $_filters = array();
@@ -116,14 +118,14 @@ class Collection implements \IteratorAggregate, \Countable, \Magento\Core\Model\
protected $_flags = array();
/**
- * @var \Magento\Data\Collection\EntityFactoryInterface
+ * @var EntityFactoryInterface
*/
protected $_entityFactory;
/**
- * @param \Magento\Data\Collection\EntityFactoryInterface $entityFactory
+ * @param EntityFactoryInterface $entityFactory
*/
- public function __construct(\Magento\Data\Collection\EntityFactoryInterface $entityFactory)
+ public function __construct(EntityFactoryInterface $entityFactory)
{
$this->_entityFactory = $entityFactory;
}
@@ -134,7 +136,7 @@ public function __construct(\Magento\Data\Collection\EntityFactoryInterface $ent
* @param string $field
* @param string $value
* @param string $type and|or|string
- * @return \Magento\Data\Collection
+ * @return $this
*/
public function addFilter($field, $value, $type = 'and')
{
@@ -157,8 +159,8 @@ public function addFilter($field, $value, $type = 'and')
* - array('foo', 'bar') -- get all filters with field name 'foo' or 'bar'
* - array() -- get all filters
*
- * @param string|array $field
- * @return \Magento\Object|array|null
+ * @param string|string[] $field
+ * @return \Magento\Object|\Magento\Object[]|null
*/
public function getFilter($field)
{
@@ -301,7 +303,7 @@ public function getLastItem()
/**
* Retrieve collection items
*
- * @return array
+ * @return \Magento\Object[]
*/
public function getItems()
{
@@ -369,7 +371,7 @@ public function getItemByColumnValue($column, $value)
* Adding item to item array
*
* @param \Magento\Object $item
- * @return \Magento\Data\Collection
+ * @return $this
* @throws \Exception
*/
public function addItem(\Magento\Object $item)
@@ -393,7 +395,7 @@ public function addItem(\Magento\Object $item)
* Add item that has no id to collection
*
* @param \Magento\Object $item
- * @return \Magento\Data\Collection
+ * @return $this
*/
protected function _addItem($item)
{
@@ -413,7 +415,7 @@ protected function _getItemId(\Magento\Object $item)
}
/**
- * Retrieve ids of all tems
+ * Retrieve ids of all items
*
* @return array
*/
@@ -430,7 +432,7 @@ public function getAllIds()
* Remove item from collection by item key
*
* @param mixed $key
- * @return \Magento\Data\Collection
+ * @return $this
*/
public function removeItemByKey($key)
{
@@ -443,7 +445,7 @@ public function removeItemByKey($key)
/**
* Remove all items from collection
*
- * @return \Magento\Data\Collection
+ * @return $this
*/
public function removeAllItems()
{
@@ -454,7 +456,7 @@ public function removeAllItems()
/**
* Clear collection
*
- * @return \Magento\Data\Collection
+ * @return $this
*/
public function clear()
{
@@ -493,6 +495,7 @@ public function walk($callback, array $args=array())
/**
* @param string|array $objMethod
* @param array $args
+ * @return void
*/
public function each($objMethod, $args = array())
{
@@ -506,7 +509,7 @@ public function each($objMethod, $args = array())
*
* @param mixed $key
* @param mixed $value
- * @return \Magento\Data\Collection
+ * @return $this
*/
public function setDataToAll($key, $value = null)
{
@@ -526,7 +529,7 @@ public function setDataToAll($key, $value = null)
* Set current page
*
* @param int $page
- * @return \Magento\Data\Collection
+ * @return $this
*/
public function setCurPage($page)
{
@@ -538,7 +541,7 @@ public function setCurPage($page)
* Set collection page size
*
* @param int $size
- * @return \Magento\Data\Collection
+ * @return $this
*/
public function setPageSize($size)
{
@@ -551,7 +554,7 @@ public function setPageSize($size)
*
* @param string $field
* @param string $direction
- * @return \Magento\Data\Collection
+ * @return $this
*/
public function setOrder($field, $direction = self::SORT_ORDER_DESC)
{
@@ -563,7 +566,7 @@ public function setOrder($field, $direction = self::SORT_ORDER_DESC)
* Set collection item class name
*
* @param string $className
- * @return \Magento\Data\Collection
+ * @return $this
* @throws \InvalidArgumentException
*/
function setItemObjectClass($className)
@@ -588,7 +591,7 @@ public function getNewEmptyItem()
/**
* Render sql select conditions
*
- * @return \Magento\Data\Collection
+ * @return $this
*/
protected function _renderFilters()
{
@@ -598,7 +601,7 @@ protected function _renderFilters()
/**
* Render sql select orders
*
- * @return \Magento\Data\Collection
+ * @return $this
*/
protected function _renderOrders()
{
@@ -608,7 +611,7 @@ protected function _renderOrders()
/**
* Render sql select limit
*
- * @return \Magento\Data\Collection
+ * @return $this
*/
protected function _renderLimit()
{
@@ -631,7 +634,7 @@ public function distinct($flag)
*
* @param bool $printQuery
* @param bool $logQuery
- * @return \Magento\Data\Collection
+ * @return $this
*/
public function loadData($printQuery = false, $logQuery = false)
{
@@ -643,7 +646,7 @@ public function loadData($printQuery = false, $logQuery = false)
*
* @param bool $printQuery
* @param bool $logQuery
- * @return \Magento\Data\Collection
+ * @return $this
*/
public function load($printQuery = false, $logQuery = false)
{
@@ -771,6 +774,8 @@ public function getItemById($idValue)
/**
* Implementation of \IteratorAggregate::getIterator()
+ *
+ * @return \ArrayIterator
*/
public function getIterator()
{
@@ -779,7 +784,7 @@ public function getIterator()
}
/**
- * Retireve count of collection loaded items
+ * Retrieve count of collection loaded items
*
* @return int
*/
@@ -793,7 +798,7 @@ public function count()
* Retrieve Flag
*
* @param string $flag
- * @return mixed
+ * @return bool|null
*/
public function getFlag($flag)
{
@@ -804,8 +809,8 @@ public function getFlag($flag)
* Set Flag
*
* @param string $flag
- * @param mixed $value
- * @return \Magento\Data\Collection
+ * @param bool|null $value
+ * @return $this
*/
public function setFlag($flag, $value = null)
{
diff --git a/lib/Magento/Data/Collection/Db.php b/lib/Magento/Data/Collection/Db.php
index de0c761e1f2c0..e5e21378b1a38 100644
--- a/lib/Magento/Data/Collection/Db.php
+++ b/lib/Magento/Data/Collection/Db.php
@@ -30,6 +30,11 @@
*/
namespace Magento\Data\Collection;
+use Magento\Data\Collection\Db\FetchStrategyInterface;
+use Magento\DB\Adapter\AdapterInterface;
+use Magento\DB\Select;
+use Magento\Logger;
+
class Db extends \Magento\Data\Collection
{
/**
@@ -92,25 +97,25 @@ class Db extends \Magento\Data\Collection
protected $_isOrdersRendered = false;
/**
- * @var \Magento\Logger
+ * @var Logger
*/
protected $_logger;
/**
- * @var \Magento\Data\Collection\Db\FetchStrategyInterface
+ * @var FetchStrategyInterface
*/
private $_fetchStrategy;
/**
- * @param \Magento\Data\Collection\EntityFactoryInterface $entityFactory
- * @param \Magento\Logger $logger
- * @param \Magento\Data\Collection\Db\FetchStrategyInterface $fetchStrategy
- * @param mixed $connection
+ * @param EntityFactoryInterface $entityFactory
+ * @param Logger $logger
+ * @param FetchStrategyInterface $fetchStrategy
+ * @param \Zend_Db_Adapter_Abstract $connection
*/
public function __construct(
- \Magento\Data\Collection\EntityFactoryInterface $entityFactory,
- \Magento\Logger $logger,
- \Magento\Data\Collection\Db\FetchStrategyInterface $fetchStrategy,
+ EntityFactoryInterface $entityFactory,
+ Logger $logger,
+ FetchStrategyInterface $fetchStrategy,
$connection = null
) {
parent::__construct($entityFactory);
@@ -126,7 +131,7 @@ public function __construct(
*
* @param string $name
* @param mixed $value
- * @return \Magento\Data\Collection\Db
+ * @return $this
*/
public function addBindParam($name, $value)
{
@@ -138,7 +143,7 @@ public function addBindParam($name, $value)
* Specify collection objects id field name
*
* @param string $fieldName
- * @return \Magento\Data\Collection\Db
+ * @return $this
*/
protected function _setIdFieldName($fieldName)
{
@@ -174,7 +179,7 @@ protected function _getItemId(\Magento\Object $item)
* Set database connection adapter
*
* @param \Zend_Db_Adapter_Abstract $conn
- * @return \Magento\Data\Collection\Db
+ * @return $this
* @throws \Zend_Exception
*/
public function setConnection($conn)
@@ -192,7 +197,7 @@ public function setConnection($conn)
/**
* Get \Zend_Db_Select instance
*
- * @return \Magento\DB\Select
+ * @return Select
*/
public function getSelect()
{
@@ -202,7 +207,7 @@ public function getSelect()
/**
* Retrieve connection object
*
- * @return \Magento\DB\Adapter\AdapterInterface
+ * @return AdapterInterface
*/
public function getConnection()
{
@@ -226,7 +231,7 @@ public function getSize()
/**
* Get SQL for get record count
*
- * @return \Magento\DB\Select
+ * @return Select
*/
public function getSelectCountSql()
{
@@ -262,7 +267,7 @@ public function getSelectSql($stringMode = false)
*
* @param string $field
* @param string $direction
- * @return \Magento\Data\Collection\Db
+ * @return $this
*/
public function setOrder($field, $direction = self::SORT_ORDER_DESC)
{
@@ -274,7 +279,7 @@ public function setOrder($field, $direction = self::SORT_ORDER_DESC)
*
* @param string $field
* @param string $direction
- * @return \Magento\Data\Collection\Db
+ * @return $this
*/
public function addOrder($field, $direction = self::SORT_ORDER_DESC)
{
@@ -286,7 +291,7 @@ public function addOrder($field, $direction = self::SORT_ORDER_DESC)
*
* @param string $field
* @param string $direction
- * @return \Magento\Data\Collection\Db
+ * @return $this
*/
public function unshiftOrder($field, $direction = self::SORT_ORDER_DESC)
{
@@ -299,7 +304,7 @@ public function unshiftOrder($field, $direction = self::SORT_ORDER_DESC)
* @param string $field
* @param string $direction
* @param bool $unshift
- * @return \Magento\Data\Collection\Db
+ * @return $this
*/
private function _setOrder($field, $direction, $unshift = false)
{
@@ -323,7 +328,7 @@ private function _setOrder($field, $direction, $unshift = false)
/**
* Render sql select conditions
*
- * @return \Magento\Data\Collection\Db
+ * @return $this
*/
protected function _renderFilters()
{
@@ -346,7 +351,7 @@ protected function _renderFilters()
$field = $this->_getMappedField($filter['field']);
$condition = $filter['value'];
$this->_select->where(
- $this->_getConditionSql($field, $condition), null, \Magento\DB\Select::TYPE_CONDITION
+ $this->_getConditionSql($field, $condition), null, Select::TYPE_CONDITION
);
break;
default:
@@ -360,6 +365,7 @@ protected function _renderFilters()
/**
* Hook for operations before rendering filters
+ * @return void
*/
protected function _renderFiltersBefore()
{
@@ -372,7 +378,7 @@ protected function _renderFiltersBefore()
*
* @param string|array $field
* @param null|string|array $condition
- * @return \Magento\Data\Collection\Db
+ * @return $this
*/
public function addFieldToFilter($field, $condition = null)
{
@@ -387,7 +393,7 @@ public function addFieldToFilter($field, $condition = null)
$resultCondition = $this->_translateCondition($field, $condition);
}
- $this->_select->where($resultCondition, null, \Magento\DB\Select::TYPE_CONDITION);
+ $this->_select->where($resultCondition, null, Select::TYPE_CONDITION);
return $this;
}
@@ -397,7 +403,6 @@ public function addFieldToFilter($field, $condition = null)
*
* @param string|array $field
* @param null|string|array $condition
- *
* @return string
*/
protected function _translateCondition($field, $condition)
@@ -417,12 +422,12 @@ protected function _getMappedField($field)
$mapper = $this->_getMapper();
if (isset($mapper['fields'][$field])) {
- $mappedFiled = $mapper['fields'][$field];
+ $mappedField = $mapper['fields'][$field];
} else {
- $mappedFiled = $field;
+ $mappedField = $field;
}
- return $mappedFiled;
+ return $mappedField;
}
/**
@@ -475,6 +480,12 @@ protected function _getConditionSql($fieldName, $condition)
return $this->getConnection()->prepareSqlCondition($fieldName, $condition);
}
+ /**
+ * Return the field name for the condition.
+ *
+ * @param string $fieldName
+ * @return string
+ */
protected function _getConditionFieldName($fieldName)
{
return $fieldName;
@@ -483,7 +494,7 @@ protected function _getConditionFieldName($fieldName)
/**
* Render sql select orders
*
- * @return \Magento\Data\Collection\Db
+ * @return $this
*/
protected function _renderOrders()
{
@@ -500,7 +511,7 @@ protected function _renderOrders()
/**
* Render sql select limit
*
- * @return \Magento\Data\Collection\Db
+ * @return $this
*/
protected function _renderLimit()
{
@@ -515,8 +526,7 @@ protected function _renderLimit()
* Set select distinct
*
* @param bool $flag
- *
- * @return \Magento\Data\Collection\Db
+ * @return $this
*/
public function distinct($flag)
{
@@ -527,7 +537,7 @@ public function distinct($flag)
/**
* Before load action
*
- * @return \Magento\Data\Collection\Db
+ * @return $this
*/
protected function _beforeLoad()
{
@@ -539,8 +549,7 @@ protected function _beforeLoad()
*
* @param bool $printQuery
* @param bool $logQuery
- *
- * @return \Magento\Data\Collection\Db
+ * @return $this
*/
public function load($printQuery = false, $logQuery = false)
{
@@ -681,7 +690,7 @@ public function getData()
/**
* Process loaded collection data
*
- * @return \Magento\Data\Collection\Db
+ * @return $this
*/
protected function _afterLoadData()
{
@@ -691,7 +700,7 @@ protected function _afterLoadData()
/**
* Reset loaded for collection data array
*
- * @return \Magento\Data\Collection\Db
+ * @return $this
*/
public function resetData()
{
@@ -699,11 +708,23 @@ public function resetData()
return $this;
}
+ /**
+ * Process loaded collection
+ *
+ * @return $this
+ */
protected function _afterLoad()
{
return $this;
}
+ /**
+ * Load the data.
+ *
+ * @param bool $printQuery
+ * @param bool $logQuery
+ * @return $this
+ */
public function loadData($printQuery = false, $logQuery = false)
{
return $this->load($printQuery, $logQuery);
@@ -715,8 +736,7 @@ public function loadData($printQuery = false, $logQuery = false)
* @param bool $printQuery
* @param bool $logQuery
* @param string $sql
- *
- * @return \Magento\Data\Collection\Db
+ * @return $this
*/
public function printLogQuery($printQuery = false, $logQuery = false, $sql = null)
{
@@ -734,6 +754,7 @@ public function printLogQuery($printQuery = false, $logQuery = false, $sql = nul
* Log query
*
* @param string $sql
+ * @return void
*/
protected function _logQuery($sql)
{
@@ -743,7 +764,7 @@ protected function _logQuery($sql)
/**
* Reset collection
*
- * @return \Magento\Data\Collection\Db
+ * @return $this
*/
protected function _reset()
{
@@ -772,8 +793,7 @@ protected function _fetchAll(\Zend_Db_Select $select)
* @param string $filter
* @param string $alias
* @param string $group default 'fields'
- *
- * @return \Magento\Data\Collection\Db
+ * @return $this
*/
public function addFilterToMap($filter, $alias, $group = 'fields')
{
@@ -799,6 +819,8 @@ public function __clone()
/**
* Init select
+ *
+ * @return void
*/
protected function _initSelect()
{
diff --git a/lib/Magento/Data/Collection/Filesystem.php b/lib/Magento/Data/Collection/Filesystem.php
index a12cfdc939b60..9e48e20d52a16 100644
--- a/lib/Magento/Data/Collection/Filesystem.php
+++ b/lib/Magento/Data/Collection/Filesystem.php
@@ -41,6 +41,8 @@
*/
namespace Magento\Data\Collection;
+use Magento\Data\Collection;
+
class Filesystem extends \Magento\Data\Collection
{
/**
@@ -100,21 +102,45 @@ class Filesystem extends \Magento\Data\Collection
protected $_disallowedFilesMask = '';
/**
- * Filter rendering helper variables
+ * Filter rendering helper variable
*
- * @see \Magento\Data\Collection::$_filter
- * @see \Magento\Data\Collection::$_isFiltersRendered
+ * @var int
+ * @see Collection::$_filter
+ * @see Collection::$_isFiltersRendered
*/
private $_filterIncrement = 0;
+
+
+ /**
+ * Filter rendering helper variable
+ *
+ * @var array
+ * @see Collection::$_filter
+ * @see Collection::$_isFiltersRendered
+ */
private $_filterBrackets = array();
+
+ /**
+ * Filter rendering helper variable
+ *
+ * @var string
+ * @see Collection::$_filter
+ * @see Collection::$_isFiltersRendered
+ */
private $_filterEvalRendered = '';
/**
- * Collecting items helper variables
+ * Collecting items helper variable
*
* @var array
*/
protected $_collectedDirs = array();
+
+ /**
+ * Collecting items helper variable
+ *
+ * @var array
+ */
protected $_collectedFiles = array();
/**
@@ -122,7 +148,7 @@ class Filesystem extends \Magento\Data\Collection
* Set empty to not filter
*
* @param string $regex
- * @return \Magento\Data\Collection\Filesystem
+ * @return $this
*/
public function setDirsFilter($regex)
{
@@ -135,7 +161,7 @@ public function setDirsFilter($regex)
* Set empty to not filter
*
* @param string $regex
- * @return \Magento\Data\Collection\Filesystem
+ * @return $this
*/
public function setFilesFilter($regex)
{
@@ -148,7 +174,7 @@ public function setFilesFilter($regex)
* Set empty value to not use this filter
*
* @param string $regex
- * @return \Magento\Data\Collection\Filesystem
+ * @return $this
*/
public function setDisallowedFilesFilter($regex)
{
@@ -160,7 +186,7 @@ public function setDisallowedFilesFilter($regex)
* Set whether to collect dirs
*
* @param bool $value
- * @return \Magento\Data\Collection\Filesystem
+ * @return $this
*/
public function setCollectDirs($value)
{
@@ -172,7 +198,7 @@ public function setCollectDirs($value)
* Set whether to collect files
*
* @param bool $value
- * @return \Magento\Data\Collection\Filesystem
+ * @return $this
*/
public function setCollectFiles($value)
{
@@ -184,7 +210,7 @@ public function setCollectFiles($value)
* Set whether to collect recursively
*
* @param bool $value
- * @return \Magento\Data\Collection\Filesystem
+ * @return $this
*/
public function setCollectRecursively($value)
{
@@ -196,7 +222,8 @@ public function setCollectRecursively($value)
* Target directory setter. Adds directory to be scanned
*
* @param string $value
- * @return \Magento\Data\Collection\Filesystem
+ * @return $this
+ * @throws \Exception
*/
public function addTargetDir($value)
{
@@ -213,7 +240,7 @@ public function addTargetDir($value)
* Works *before* sorting.
*
* @param bool $value
- * @return \Magento\Data\Collection\Filesystem
+ * @return $this
*/
public function setDirsFirst($value)
{
@@ -225,6 +252,7 @@ public function setDirsFirst($value)
* Get files from specified directory recursively (if needed)
*
* @param string|array $dir
+ * @return void
*/
protected function _collectRecursive($dir)
{
@@ -270,7 +298,8 @@ protected function _collectRecursive($dir)
*
* @param bool $printQuery
* @param bool $logQuery
- * @return \Magento\Data\Collection\Filesystem
+ * @return $this
+ * @throws \Exception
*/
public function loadData($printQuery = false, $logQuery = false)
{
@@ -322,6 +351,7 @@ public function loadData($printQuery = false, $logQuery = false)
* - sort
*
* @param string $attributeName '_collectedFiles' | '_collectedDirs'
+ * @return void
*/
private function _generateAndFilterAndSort($attributeName)
{
@@ -368,7 +398,7 @@ protected function _usort($a, $b)
*
* @param string $field
* @param string $direction
- * @return \Magento\Data\Collection
+ * @return Collection
*/
public function setOrder($field, $direction = self::SORT_ORDER_DESC)
{
@@ -395,14 +425,14 @@ protected function _generateRow($filename)
* The callback must take 3 params:
* string $field - field key,
* mixed $filterValue - value to filter by,
- * array $row - a generated row (before generaring varien objects)
+ * array $row - a generated row (before generating varien objects)
*
* @param string $field
* @param mixed $value
* @param string $type 'and'|'or'
* @param callback $callback
* @param bool $isInverted
- * @return \Magento\Data\Collection\Filesystem
+ * @return $this
*/
public function addCallbackFilter($field, $value, $type, $callback, $isInverted = false)
{
@@ -419,7 +449,7 @@ public function addCallbackFilter($field, $value, $type, $callback, $isInverted
/**
* The filters renderer and caller
- * Aplies to each row, renders once.
+ * Applies to each row, renders once.
*
* @param array $row
* @return bool
@@ -474,8 +504,8 @@ protected function _invokeFilter($callback, $callbackParams)
* @param string $field
* @param mixed $cond
* @param string $type 'and' | 'or'
- * @see \Magento\Data\Collection\Db::addFieldToFilter()
- * @return \Magento\Data\Collection\Filesystem
+ * @see Db::addFieldToFilter()
+ * @return $this
*/
public function addFieldToFilter($field, $cond, $type = 'and')
{
@@ -555,7 +585,7 @@ public function addFieldToFilter($field, $cond, $type = 'and')
*
* @param string $bracket
* @param bool $isAnd
- * @return \Magento\Data\Collection\Filesystem
+ * @return $this
*/
protected function _addFilterBracket($bracket = '(', $isAnd = true)
{
@@ -592,8 +622,10 @@ protected function _renderConditionBeforeFilterElement($increment, $isAnd)
/**
* Does nothing. Intentionally disabled parent method
- *
- * @return \Magento\Data\Collection\Filesystem
+ * @param string $field
+ * @param string $value
+ * @param string $type
+ * @return $this
*/
public function addFilter($field, $value, $type = 'and')
{
diff --git a/lib/Magento/Data/Form.php b/lib/Magento/Data/Form.php
index 109f17f782e9a..f9f3c5a7bbd52 100644
--- a/lib/Magento/Data/Form.php
+++ b/lib/Magento/Data/Form.php
@@ -26,12 +26,20 @@
namespace Magento\Data;
+use Magento\Data\Form\Element\AbstractElement;
+use Magento\Data\Form\Element\Collection as ElementCollection;
+use Magento\Data\Form\Element\CollectionFactory as ElementCollectionFactory;
+use Magento\Data\Form\Element\Factory;
+use Magento\Data\Form\Element\Renderer\RendererInterface;
+use Magento\Data\Form\FormKey;
+use Magento\Profiler;
+
class Form extends \Magento\Data\Form\AbstractForm
{
/**
* All form elements collection
*
- * @var \Magento\Data\Form\Element\Collection
+ * @var ElementCollection
*/
protected $_allElements;
@@ -43,24 +51,35 @@ class Form extends \Magento\Data\Form\AbstractForm
protected $_elementsIndex;
/**
- * @var Form\FormKey
+ * @var FormKey
*/
protected $formKey;
+ /**
+ * @var RendererInterface
+ */
static protected $_defaultElementRenderer;
+
+ /**
+ * @var RendererInterface
+ */
static protected $_defaultFieldsetRenderer;
+
+ /**
+ * @var RendererInterface
+ */
static protected $_defaultFieldsetElementRenderer;
/**
- * @param Form\Element\Factory $factoryElement
- * @param Form\Element\CollectionFactory $factoryCollection
- * @param Form\FormKey $formKey
+ * @param Factory $factoryElement
+ * @param ElementCollectionFactory $factoryCollection
+ * @param FormKey $formKey
* @param array $data
*/
public function __construct(
- \Magento\Data\Form\Element\Factory $factoryElement,
- \Magento\Data\Form\Element\CollectionFactory $factoryCollection,
- \Magento\Data\Form\FormKey $formKey,
+ Factory $factoryElement,
+ ElementCollectionFactory $factoryCollection,
+ FormKey $formKey,
$data = array()
) {
parent::__construct($factoryElement, $factoryCollection, $data);
@@ -68,31 +87,52 @@ public function __construct(
$this->formKey = $formKey;
}
- public static function setElementRenderer(\Magento\Data\Form\Element\Renderer\RendererInterface $renderer = null)
+ /**
+ * @param RendererInterface $renderer
+ * @return void
+ */
+ public static function setElementRenderer(RendererInterface $renderer = null)
{
self::$_defaultElementRenderer = $renderer;
}
- public static function setFieldsetRenderer(\Magento\Data\Form\Element\Renderer\RendererInterface $renderer = null)
+ /**
+ * @param RendererInterface $renderer
+ * @return void
+ */
+ public static function setFieldsetRenderer(RendererInterface $renderer = null)
{
self::$_defaultFieldsetRenderer = $renderer;
}
- public static function setFieldsetElementRenderer(\Magento\Data\Form\Element\Renderer\RendererInterface $renderer = null)
+ /**
+ * @param RendererInterface $renderer
+ * @return void
+ */
+ public static function setFieldsetElementRenderer(RendererInterface $renderer = null)
{
self::$_defaultFieldsetElementRenderer = $renderer;
}
+ /**
+ * @return RendererInterface
+ */
public static function getElementRenderer()
{
return self::$_defaultElementRenderer;
}
+ /**
+ * @return RendererInterface
+ */
public static function getFieldsetRenderer()
{
return self::$_defaultFieldsetRenderer;
}
+ /**
+ * @return RendererInterface
+ */
public static function getFieldsetElementRenderer()
{
return self::$_defaultFieldsetElementRenderer;
@@ -100,7 +140,8 @@ public static function getFieldsetElementRenderer()
/**
* Return allowed HTML form attributes
- * @return array
+ *
+ * @return string[]
*/
public function getHtmlAttributes()
{
@@ -110,11 +151,11 @@ public function getHtmlAttributes()
/**
* Add form element
*
- * @param \Magento\Data\Form\Element\AbstractElement $element
+ * @param AbstractElement $element
* @param bool $after
- * @return \Magento\Data\Form
+ * @return $this
*/
- public function addElement(\Magento\Data\Form\Element\AbstractElement $element, $after = false)
+ public function addElement(AbstractElement $element, $after = false)
{
$this->checkElementId($element->getId());
parent::addElement($element, $after);
@@ -134,7 +175,7 @@ protected function _elementIdExists($elementId)
}
/**
- * @param \Magento\Data\Form\Element\AbstractElement $element
+ * @param AbstractElement $element
* @return $this
*/
public function addElementToCollection($element)
@@ -169,7 +210,7 @@ public function getForm()
* Retrieve form element by id
*
* @param string $elementId
- * @return null|\Magento\Data\Form\Element\AbstractElement
+ * @return null|AbstractElement
*/
public function getElement($elementId)
{
@@ -217,7 +258,7 @@ public function addValues($values)
* Add suffix to name of all elements
*
* @param string $suffix
- * @return \Magento\Data\Form
+ * @return $this
*/
public function addFieldNameSuffix($suffix)
{
@@ -253,7 +294,7 @@ public function addSuffixToName($name, $suffix)
/**
* @param string $elementId
- * @return $this|Form\AbstractForm
+ * @return $this
*/
public function removeField($elementId)
{
@@ -286,7 +327,7 @@ public function getFieldContainerIdPrefix()
*/
public function toHtml()
{
- \Magento\Profiler::start('form/toHtml');
+ Profiler::start('form/toHtml');
$html = '';
$useContainer = $this->getUseContainer();
if ($useContainer) {
@@ -307,10 +348,13 @@ public function toHtml()
if ($useContainer) {
$html.= '';
}
- \Magento\Profiler::stop('form/toHtml');
+ Profiler::stop('form/toHtml');
return $html;
}
+ /**
+ * @return string
+ */
public function getHtml()
{
return $this->toHtml();
diff --git a/lib/Magento/Data/Form/AbstractForm.php b/lib/Magento/Data/Form/AbstractForm.php
index 45da8c4f99a0a..2ea5102926728 100644
--- a/lib/Magento/Data/Form/AbstractForm.php
+++ b/lib/Magento/Data/Form/AbstractForm.php
@@ -34,12 +34,19 @@
*/
namespace Magento\Data\Form;
+use Magento\Data\Form\Element\AbstractElement;
+use Magento\Data\Form\Element\Collection;
+use Magento\Data\Form\Element\CollectionFactory;
+use Magento\Data\Form\Element\Column;
+use Magento\Data\Form\Element\Factory;
+use Magento\Data\Form\Element\Fieldset;
+
class AbstractForm extends \Magento\Object
{
/**
* Form level elements collection
*
- * @var \Magento\Data\Form\Element\Collection
+ * @var Collection
*/
protected $_elements;
@@ -51,23 +58,23 @@ class AbstractForm extends \Magento\Object
protected $_types = array();
/**
- * @var \Magento\Data\Form\Element\Factory
+ * @var Factory
*/
protected $_factoryElement;
/**
- * @var \Magento\Data\Form\Element\CollectionFactory
+ * @var CollectionFactory
*/
protected $_factoryCollection;
/**
- * @param \Magento\Data\Form\Element\Factory $factoryElement
- * @param \Magento\Data\Form\Element\CollectionFactory $factoryCollection
+ * @param Factory $factoryElement
+ * @param CollectionFactory $factoryCollection
* @param array $data
*/
public function __construct(
- \Magento\Data\Form\Element\Factory $factoryElement,
- \Magento\Data\Form\Element\CollectionFactory $factoryCollection,
+ Factory $factoryElement,
+ CollectionFactory $factoryCollection,
$data = array()
) {
$this->_factoryElement = $factoryElement;
@@ -91,7 +98,7 @@ protected function _construct()
*
* @param string $type
* @param string $className
- * @return \Magento\Data\Form\AbstractForm
+ * @return $this
*/
public function addType($type, $className)
{
@@ -102,7 +109,7 @@ public function addType($type, $className)
/**
* Get elements collection
*
- * @return \Magento\Data\Form\Element\Collection
+ * @return Collection
*/
public function getElements()
{
@@ -117,7 +124,7 @@ public function getElements()
*
* @param boolean $readonly
* @param boolean $useDisabled
- * @return \Magento\Data\Form\AbstractForm
+ * @return $this
*/
public function setReadonly($readonly, $useDisabled = false)
{
@@ -137,12 +144,11 @@ public function setReadonly($readonly, $useDisabled = false)
/**
* Add form element
*
- * @param \Magento\Data\Form\Element\AbstractElement $element
+ * @param AbstractElement $element
* @param bool|string|null $after
- *
- * @return \Magento\Data\Form
+ * @return $this
*/
- public function addElement(\Magento\Data\Form\Element\AbstractElement $element, $after = null)
+ public function addElement(AbstractElement $element, $after = null)
{
$element->setForm($this);
$this->getElements()->add($element, $after);
@@ -159,8 +165,8 @@ public function addElement(\Magento\Data\Form\Element\AbstractElement $element,
* @param string $elementId
* @param string $type
* @param array $config
- * @param mixed $after
- * @return \Magento\Data\Form\Element\AbstractElement
+ * @param bool|string|null $after
+ * @return AbstractElement
*/
public function addField($elementId, $type, $config, $after = false)
{
@@ -177,7 +183,7 @@ public function addField($elementId, $type, $config, $after = false)
* Enter description here...
*
* @param string $elementId
- * @return \Magento\Data\Form\AbstractForm
+ * @return $this
*/
public function removeField($elementId)
{
@@ -192,7 +198,7 @@ public function removeField($elementId)
* @param array $config
* @param bool|string|null $after
* @param bool $isAdvanced
- * @return \Magento\Data\Form\Element\Fieldset
+ * @return Fieldset
*/
public function addFieldset($elementId, $config, $after = false, $isAdvanced = false)
{
@@ -208,7 +214,7 @@ public function addFieldset($elementId, $config, $after = false, $isAdvanced = f
*
* @param string $elementId
* @param array $config
- * @return \Magento\Data\Form\Element\Column
+ * @return Column
*/
public function addColumn($elementId, $config)
{
diff --git a/lib/Magento/Data/Form/Element/AbstractElement.php b/lib/Magento/Data/Form/Element/AbstractElement.php
index ee560a7f4521d..26600626b466a 100644
--- a/lib/Magento/Data/Form/Element/AbstractElement.php
+++ b/lib/Magento/Data/Form/Element/AbstractElement.php
@@ -34,13 +34,36 @@
*/
namespace Magento\Data\Form\Element;
-abstract class AbstractElement extends \Magento\Data\Form\AbstractForm
+use Magento\Data\Form;
+use Magento\Data\Form\AbstractForm;
+use Magento\Data\Form\Element\Renderer\RendererInterface;
+use Magento\Escaper;
+
+abstract class AbstractElement extends AbstractForm
{
+ /**
+ * @var string|int
+ */
protected $_id;
+
+ /**
+ * @var string
+ */
protected $_type;
- /** @var \Magento\Data\Form */
+
+ /**
+ * @var Form
+ */
protected $_form;
+
+ /**
+ * @var
+ */
protected $_elements;
+
+ /**
+ * @var RendererInterface
+ */
protected $_renderer;
/**
@@ -51,7 +74,7 @@ abstract class AbstractElement extends \Magento\Data\Form\AbstractForm
protected $_advanced = false;
/**
- * @var \Magento\Escaper
+ * @var Escaper
*/
protected $_escaper;
@@ -63,15 +86,15 @@ abstract class AbstractElement extends \Magento\Data\Form\AbstractForm
private $lockHtmlAttribute = 'data-locked';
/**
- * @param \Magento\Data\Form\Element\Factory $factoryElement
- * @param \Magento\Data\Form\Element\CollectionFactory $factoryCollection
- * @param \Magento\Escaper $escaper
+ * @param Factory $factoryElement
+ * @param CollectionFactory $factoryCollection
+ * @param Escaper $escaper
* @param array $data
*/
public function __construct(
- \Magento\Data\Form\Element\Factory $factoryElement,
- \Magento\Data\Form\Element\CollectionFactory $factoryCollection,
- \Magento\Escaper $escaper,
+ Factory $factoryElement,
+ CollectionFactory $factoryCollection,
+ Escaper $escaper,
$data = array()
) {
$this->_escaper = $escaper;
@@ -82,11 +105,11 @@ public function __construct(
/**
* Add form element
*
- * @param \Magento\Data\Form\Element\AbstractElement $element
+ * @param AbstractElement $element
* @param bool $after
- * @return \Magento\Data\Form
+ * @return Form
*/
- public function addElement(\Magento\Data\Form\Element\AbstractElement $element, $after = false)
+ public function addElement(AbstractElement $element, $after = false)
{
if ($this->getForm()) {
$this->getForm()->checkElementId($element->getId());
@@ -100,7 +123,7 @@ public function addElement(\Magento\Data\Form\Element\AbstractElement $element,
/**
* Shows whether current element belongs to Basic or Advanced form layout
*
- * @return bool
+ * @return bool
*/
public function isAdvanced() {
return $this->_advanced;
@@ -110,18 +133,28 @@ public function isAdvanced() {
* Set _advanced layout property
*
* @param bool $advanced
- * @return \Magento\Data\Form\Element\AbstractElement
+ * @return $this
*/
public function setAdvanced($advanced) {
$this->_advanced = $advanced;
return $this;
}
+ /**
+ * Get id.
+ *
+ * @return string|int
+ */
public function getId()
{
return $this->_id;
}
+ /**
+ * Get type.
+ *
+ * @return string
+ */
public function getType()
{
return $this->_type;
@@ -130,13 +163,19 @@ public function getType()
/**
* Get form
*
- * @return \Magento\Data\Form
+ * @return Form
*/
public function getForm()
{
return $this->_form;
}
+ /**
+ * Set the Id.
+ *
+ * @param string|int $id
+ * @return $this
+ */
public function setId($id)
{
$this->_id = $id;
@@ -144,11 +183,21 @@ public function setId($id)
return $this;
}
+ /**
+ * Get the Html Id.
+ *
+ * @return string
+ */
public function getHtmlId()
{
return $this->getForm()->getHtmlIdPrefix() . $this->getData('html_id') . $this->getForm()->getHtmlIdSuffix();
}
+ /**
+ * Get the name.
+ *
+ * @return mixed
+ */
public function getName()
{
$name = $this->getData('name');
@@ -158,6 +207,12 @@ public function getName()
return $name;
}
+ /**
+ * Set the type.
+ *
+ * @param string $type
+ * @return $this
+ */
public function setType($type)
{
$this->_type = $type;
@@ -165,23 +220,44 @@ public function setType($type)
return $this;
}
+ /**
+ * @param Form $form
+ * @return $this
+ */
public function setForm($form)
{
$this->_form = $form;
return $this;
}
+ /**
+ * Remove field
+ *
+ * @param string $elementId
+ * @return AbstractForm
+ */
public function removeField($elementId)
{
$this->getForm()->removeField($elementId);
return parent::removeField($elementId);
}
+ /**
+ * Return the attributes for Html.
+ *
+ * @return string[]
+ */
public function getHtmlAttributes()
{
return array('type', 'title', 'class', 'style', 'onclick', 'onchange', 'disabled', 'readonly', 'tabindex', 'placeholder');
}
+ /**
+ * Add a class.
+ *
+ * @param string $class
+ * @return $this
+ */
public function addClass($class)
{
$oldClass = $this->getClass();
@@ -193,7 +269,7 @@ public function addClass($class)
* Remove CSS class
*
* @param string $class
- * @return \Magento\Data\Form\Element\AbstractElement
+ * @return $this
*/
public function removeClass($class)
{
@@ -205,11 +281,23 @@ public function removeClass($class)
return $this;
}
+ /**
+ * Escape a string's contents.
+ *
+ * @param string $string
+ * @return string
+ */
protected function _escape($string)
{
return htmlspecialchars($string, ENT_COMPAT);
}
+ /**
+ * Return the escaped value of the element specified by the given index.
+ *
+ * @param null|int|string $index
+ * @return string
+ */
public function getEscapedValue($index=null)
{
$value = $this->getValue($index);
@@ -220,17 +308,32 @@ public function getEscapedValue($index=null)
return $this->_escape($value);
}
- public function setRenderer(\Magento\Data\Form\Element\Renderer\RendererInterface $renderer)
+ /**
+ * Set the renderer.
+ *
+ * @param RendererInterface $renderer
+ * @return $this
+ */
+ public function setRenderer(RendererInterface $renderer)
{
$this->_renderer = $renderer;
return $this;
}
+ /**
+ * Get the renderer.
+ *
+ * @return RendererInterface
+ */
public function getRenderer()
{
return $this->_renderer;
}
+ /**
+ * @param null|string $suffix
+ * @return string
+ */
protected function _getUiId($suffix = null)
{
if ($this->_renderer instanceof \Magento\View\Element\AbstractBlock) {
@@ -240,6 +343,11 @@ protected function _getUiId($suffix = null)
}
}
+ /**
+ * Get the Html for the element.
+ *
+ * @return string
+ */
public function getElementHtml()
{
$html = '';
@@ -258,16 +366,31 @@ public function getElementHtml()
return $html;
}
+ /**
+ * Get the before element html.
+ *
+ * @return mixed
+ */
public function getBeforeElementHtml()
{
return $this->getData('before_element_html');
}
+ /**
+ * Get the after element html.
+ *
+ * @return mixed
+ */
public function getAfterElementHtml()
{
return $this->getData('after_element_html');
}
+ /**
+ * Get the after element Javascript.
+ *
+ * @return mixed
+ */
public function getAfterElementJs()
{
return $this->getData('after_element_js');
@@ -292,6 +415,11 @@ public function getLabelHtml($idSuffix = '')
return $html;
}
+ /**
+ * Get the default html.
+ *
+ * @return mixed
+ */
public function getDefaultHtml()
{
$html = $this->getData('default_html');
@@ -304,6 +432,11 @@ public function getDefaultHtml()
return $html;
}
+ /**
+ * Get the html.
+ *
+ * @return mixed
+ */
public function getHtml()
{
if ($this->getRequired()) {
@@ -317,11 +450,25 @@ public function getHtml()
return $html;
}
+ /**
+ * Get the html.
+ *
+ * @return mixed
+ */
public function toHtml()
{
return $this->getHtml();
}
+ /**
+ * Serialize the element.
+ *
+ * @param string[] $attributes
+ * @param string $valueSeparator
+ * @param string $fieldSeparator
+ * @param string $quote
+ * @return string
+ */
public function serialize($attributes = array(), $valueSeparator='=', $fieldSeparator=' ', $quote='"')
{
if ($this->isLocked() && !empty($attributes)) {
@@ -340,6 +487,11 @@ public function serialize($attributes = array(), $valueSeparator='=', $fieldSepa
return parent::serialize($attributes, $valueSeparator, $fieldSeparator, $quote);
}
+ /**
+ * Indicates the elements readonly status.
+ *
+ * @return mixed
+ */
public function getReadonly()
{
if ($this->hasData('readonly_disabled')) {
@@ -349,6 +501,11 @@ public function getReadonly()
return $this->_getData('readonly');
}
+ /**
+ * Get the container Id.
+ *
+ * @return mixed
+ */
public function getHtmlContainerId()
{
if ($this->hasData('container_id')) {
@@ -364,7 +521,7 @@ public function getHtmlContainerId()
*
* @param string|int|array $values
* @param bool $overwrite
- * @return \Magento\Data\Form\Element\AbstractElement
+ * @return $this
*/
public function addElementValues($values, $overwrite = false)
{
@@ -391,6 +548,8 @@ public function addElementValues($values, $overwrite = false)
/**
* Lock element
+ *
+ * @return void
*/
public function lock()
{
diff --git a/lib/Magento/Data/Form/Element/Button.php b/lib/Magento/Data/Form/Element/Button.php
index 7f13ea63c1eb3..db741317a891a 100644
--- a/lib/Magento/Data/Form/Element/Button.php
+++ b/lib/Magento/Data/Form/Element/Button.php
@@ -33,25 +33,27 @@
*/
namespace Magento\Data\Form\Element;
-class Button extends \Magento\Data\Form\Element\AbstractElement
+use Magento\Escaper;
+
+class Button extends AbstractElement
{
/**
* Additional html attributes
*
- * @var array
+ * @var string[]
*/
protected $_htmlAttributes = array('data-mage-init');
/**
- * @param \Magento\Data\Form\Element\Factory $factoryElement
- * @param \Magento\Data\Form\Element\CollectionFactory $factoryCollection
- * @param \Magento\Escaper $escaper
+ * @param Factory $factoryElement
+ * @param CollectionFactory $factoryCollection
+ * @param Escaper $escaper
* @param array $data
*/
public function __construct(
- \Magento\Data\Form\Element\Factory $factoryElement,
- \Magento\Data\Form\Element\CollectionFactory $factoryCollection,
- \Magento\Escaper $escaper,
+ Factory $factoryElement,
+ CollectionFactory $factoryCollection,
+ Escaper $escaper,
$data = array()
) {
parent::__construct($factoryElement, $factoryCollection, $escaper, $data);
@@ -62,7 +64,7 @@ public function __construct(
/**
* Html attributes
*
- * @return array
+ * @return string[]
*/
public function getHtmlAttributes()
{
diff --git a/lib/Magento/Data/Form/Element/Checkbox.php b/lib/Magento/Data/Form/Element/Checkbox.php
index 0076c5e4decfe..7c6610178ef43 100644
--- a/lib/Magento/Data/Form/Element/Checkbox.php
+++ b/lib/Magento/Data/Form/Element/Checkbox.php
@@ -33,18 +33,20 @@
*/
namespace Magento\Data\Form\Element;
-class Checkbox extends \Magento\Data\Form\Element\AbstractElement
+use Magento\Escaper;
+
+class Checkbox extends AbstractElement
{
/**
- * @param \Magento\Data\Form\Element\Factory $factoryElement
- * @param \Magento\Data\Form\Element\CollectionFactory $factoryCollection
- * @param \Magento\Escaper $escaper
+ * @param Factory $factoryElement
+ * @param CollectionFactory $factoryCollection
+ * @param Escaper $escaper
* @param array $data
*/
public function __construct(
- \Magento\Data\Form\Element\Factory $factoryElement,
- \Magento\Data\Form\Element\CollectionFactory $factoryCollection,
- \Magento\Escaper $escaper,
+ Factory $factoryElement,
+ CollectionFactory $factoryCollection,
+ Escaper $escaper,
$data = array()
) {
parent::__construct($factoryElement, $factoryCollection, $escaper, $data);
@@ -52,11 +54,17 @@ public function __construct(
$this->setExtType('checkbox');
}
+ /**
+ * @return string[]
+ */
public function getHtmlAttributes()
{
return array('type', 'title', 'class', 'style', 'checked', 'onclick', 'onchange', 'disabled', 'tabindex');
}
+ /**
+ * @return string
+ */
public function getElementHtml()
{
if ($checked = $this->getChecked()) {
@@ -72,7 +80,7 @@ public function getElementHtml()
* Set check status of checkbox
*
* @param boolean $value
- * @return \Magento\Data\Form\Element\Checkbox
+ * @return Checkbox
*/
public function setIsChecked($value=false)
{
diff --git a/lib/Magento/Data/Form/Element/Checkboxes.php b/lib/Magento/Data/Form/Element/Checkboxes.php
index 52971734929cf..8568ff0330e38 100644
--- a/lib/Magento/Data/Form/Element/Checkboxes.php
+++ b/lib/Magento/Data/Form/Element/Checkboxes.php
@@ -33,18 +33,20 @@
*/
namespace Magento\Data\Form\Element;
-class Checkboxes extends \Magento\Data\Form\Element\AbstractElement
+use Magento\Escaper;
+
+class Checkboxes extends AbstractElement
{
/**
- * @param \Magento\Data\Form\Element\Factory $factoryElement
- * @param \Magento\Data\Form\Element\CollectionFactory $factoryCollection
- * @param \Magento\Escaper $escaper
+ * @param Factory $factoryElement
+ * @param CollectionFactory $factoryCollection
+ * @param Escaper $escaper
* @param array $data
*/
public function __construct(
- \Magento\Data\Form\Element\Factory $factoryElement,
- \Magento\Data\Form\Element\CollectionFactory $factoryCollection,
- \Magento\Escaper $escaper,
+ Factory $factoryElement,
+ CollectionFactory $factoryCollection,
+ Escaper $escaper,
$data = array()
) {
parent::__construct($factoryElement, $factoryCollection, $escaper, $data);
@@ -55,7 +57,7 @@ public function __construct(
/**
* Retrieve allow attributes
*
- * @return array
+ * @return string[]
*/
public function getHtmlAttributes()
{
@@ -127,6 +129,10 @@ public function getElementHtml()
return $html;
}
+ /**
+ * @param mixed $value
+ * @return string
+ */
public function getChecked($value)
{
if ($checked = $this->getValue()) {
@@ -150,6 +156,10 @@ public function getChecked($value)
return ;
}
+ /**
+ * @param mixed $value
+ * @return string
+ */
public function getDisabled($value)
{
if ($disabled = $this->getData('disabled')) {
@@ -168,6 +178,10 @@ public function getDisabled($value)
return ;
}
+ /**
+ * @param mixed $value
+ * @return mixed
+ */
public function getOnclick($value)
{
if ($onclick = $this->getData('onclick')) {
@@ -176,6 +190,10 @@ public function getOnclick($value)
return ;
}
+ /**
+ * @param mixed $value
+ * @return mixed
+ */
public function getOnchange($value)
{
if ($onchange = $this->getData('onchange')) {
@@ -192,6 +210,10 @@ public function getOnchange($value)
// return ;
// }
+ /**
+ * @param array $option
+ * @return string
+ */
protected function _optionToHtml($option)
{
$id = $this->getHtmlId().'_'.$this->_escape($option['value']);
diff --git a/lib/Magento/Data/Form/Element/Collection.php b/lib/Magento/Data/Form/Element/Collection.php
index 5bb9dabad6cb9..74e68f18e981f 100644
--- a/lib/Magento/Data/Form/Element/Collection.php
+++ b/lib/Magento/Data/Form/Element/Collection.php
@@ -33,6 +33,9 @@
*/
namespace Magento\Data\Form\Element;
+use Magento\Data\Form;
+use Magento\Data\Form\AbstractForm;
+
class Collection implements \ArrayAccess, \IteratorAggregate
{
@@ -46,16 +49,16 @@ class Collection implements \ArrayAccess, \IteratorAggregate
/**
* Elements container
*
- * @var \Magento\Data\Form\AbstractForm
+ * @var AbstractForm
*/
private $_container;
/**
* Class constructor
*
- * @param \Magento\Data\Form\AbstractForm $container
+ * @param AbstractForm $container
*/
- public function __construct(\Magento\Data\Form\AbstractForm $container)
+ public function __construct(AbstractForm $container)
{
$this->_elements = array();
$this->_container = $container;
@@ -76,6 +79,7 @@ public function getIterator()
*
* @param mixed $key
* @param mixed $value
+ * @return void
*/
public function offsetSet($key, $value)
{
@@ -86,6 +90,7 @@ public function offsetSet($key, $value)
* Implementation of \ArrayAccess:offsetGet()
*
* @param mixed $key
+ * @return AbstractElement
*/
public function offsetGet($key)
{
@@ -96,6 +101,7 @@ public function offsetGet($key)
* Implementation of \ArrayAccess:offsetUnset()
*
* @param mixed $key
+ * @return void
*/
public function offsetUnset($key)
{
@@ -117,15 +123,14 @@ public function offsetExists($key)
* Add element to collection
*
* @todo get it straight with $after
- * @param \Magento\Data\Form\Element\AbstractElement $element
+ * @param AbstractElement $element
* @param bool|string $after
- *
- * @return \Magento\Data\Form\Element\Collection
+ * @return AbstractElement
*/
- public function add(\Magento\Data\Form\Element\AbstractElement $element, $after = false)
+ public function add(AbstractElement $element, $after = false)
{
// Set the Form for the node
- if ($this->_container->getForm() instanceof \Magento\Data\Form) {
+ if ($this->_container->getForm() instanceof Form) {
$element->setContainer($this->_container);
$element->setForm($this->_container->getForm());
}
@@ -157,7 +162,7 @@ public function add(\Magento\Data\Form\Element\AbstractElement $element, $after
* Sort elements by values using a user-defined comparison function
*
* @param mixed $callback
- * @return \Magento\Data\Form\Element\Collection
+ * @return $this
*/
public function usort($callback)
{
@@ -169,7 +174,7 @@ public function usort($callback)
* Remove element from collection
*
* @param mixed $elementId
- * @return \Magento\Data\Form\Element\Collection
+ * @return $this
*/
public function remove($elementId)
{
@@ -197,7 +202,7 @@ public function count()
* Find element by ID
*
* @param mixed $elementId
- * @return \Magento\Data\Form\Element\AbstractElement|null
+ * @return AbstractElement
*/
public function searchById($elementId)
{
diff --git a/lib/Magento/Data/Form/Element/CollectionFactory.php b/lib/Magento/Data/Form/Element/CollectionFactory.php
index 120cf6694c64b..7494a20d7ae36 100644
--- a/lib/Magento/Data/Form/Element/CollectionFactory.php
+++ b/lib/Magento/Data/Form/Element/CollectionFactory.php
@@ -26,18 +26,21 @@
namespace Magento\Data\Form\Element;
+use Magento\ObjectManager;
+
+
class CollectionFactory
{
/**
- * @var \Magento\ObjectManager
+ * @var ObjectManager
*/
protected $_objectManager;
/**
- * @param \Magento\ObjectManager $objectManager
+ * @param ObjectManager $objectManager
*/
- public function __construct(\Magento\ObjectManager $objectManager)
+ public function __construct(ObjectManager $objectManager)
{
$this->_objectManager = $objectManager;
}
@@ -46,7 +49,7 @@ public function __construct(\Magento\ObjectManager $objectManager)
* Create collection factory with specified parameters
*
* @param array $data
- * @return \Magento\Data\Form\Element\Collection
+ * @return Collection
*/
public function create(array $data = array())
{
diff --git a/lib/Magento/Data/Form/Element/Date.php b/lib/Magento/Data/Form/Element/Date.php
index 892f97e9c60c7..3abff8db7476c 100644
--- a/lib/Magento/Data/Form/Element/Date.php
+++ b/lib/Magento/Data/Form/Element/Date.php
@@ -33,7 +33,10 @@
*/
namespace Magento\Data\Form\Element;
-class Date extends \Magento\Data\Form\Element\AbstractElement
+use Magento\Escaper;
+use Magento\Stdlib\DateTime;
+
+class Date extends AbstractElement
{
/**
* @var \Zend_Date
@@ -41,15 +44,15 @@ class Date extends \Magento\Data\Form\Element\AbstractElement
protected $_value;
/**
- * @param \Magento\Data\Form\Element\Factory $factoryElement
- * @param \Magento\Data\Form\Element\CollectionFactory $factoryCollection
- * @param \Magento\Escaper $escaper
+ * @param Factory $factoryElement
+ * @param CollectionFactory $factoryCollection
+ * @param Escaper $escaper
* @param array $data
*/
public function __construct(
- \Magento\Data\Form\Element\Factory $factoryElement,
- \Magento\Data\Form\Element\CollectionFactory $factoryCollection,
- \Magento\Escaper $escaper,
+ Factory $factoryElement,
+ CollectionFactory $factoryCollection,
+ Escaper $escaper,
$data = array()
) {
parent::__construct($factoryElement, $factoryCollection, $escaper, $data);
@@ -63,6 +66,9 @@ public function __construct(
/**
* If script executes on x64 system, converts large
* numeric values to timestamp limit
+ *
+ * @param int $value
+ * @return int
*/
protected function _toTimestamp($value)
{
@@ -84,7 +90,7 @@ protected function _toTimestamp($value)
* @param mixed $value
* @param string $format
* @param string $locale
- * @return \Magento\Data\Form\Element\Date
+ * @return $this
*/
public function setValue($value, $format = null, $locale = null)
{
@@ -103,7 +109,7 @@ public function setValue($value, $format = null, $locale = null)
}
// last check, if input format was set
if (null === $format) {
- $format = \Magento\Stdlib\DateTime::DATETIME_INTERNAL_FORMAT;
+ $format = DateTime::DATETIME_INTERNAL_FORMAT;
if ($this->getInputFormat()) {
$format = $this->getInputFormat();
}
diff --git a/lib/Magento/Data/Form/Element/Editablemultiselect.php b/lib/Magento/Data/Form/Element/Editablemultiselect.php
index 3680f27058cc6..d9f8c9cb86a31 100644
--- a/lib/Magento/Data/Form/Element/Editablemultiselect.php
+++ b/lib/Magento/Data/Form/Element/Editablemultiselect.php
@@ -79,7 +79,7 @@ public function getElementHtml()
* Retrieve HTML markup of given select option
*
* @param array $option
- * @param array $selected
+ * @param string[] $selected
* @return string
*/
protected function _optionToHtml($option, $selected)
diff --git a/lib/Magento/Data/Form/Element/Editor.php b/lib/Magento/Data/Form/Element/Editor.php
index 8863fc719d8a2..d731bbd3f3d55 100644
--- a/lib/Magento/Data/Form/Element/Editor.php
+++ b/lib/Magento/Data/Form/Element/Editor.php
@@ -33,18 +33,20 @@
*/
namespace Magento\Data\Form\Element;
-class Editor extends \Magento\Data\Form\Element\Textarea
+use Magento\Escaper;
+
+class Editor extends Textarea
{
/**
- * @param \Magento\Data\Form\Element\Factory $factoryElement
- * @param \Magento\Data\Form\Element\CollectionFactory $factoryCollection
- * @param \Magento\Escaper $escaper
+ * @param Factory $factoryElement
+ * @param CollectionFactory $factoryCollection
+ * @param Escaper $escaper
* @param array $data
*/
public function __construct(
- \Magento\Data\Form\Element\Factory $factoryElement,
- \Magento\Data\Form\Element\CollectionFactory $factoryCollection,
- \Magento\Escaper $escaper,
+ Factory $factoryElement,
+ CollectionFactory $factoryCollection,
+ Escaper $escaper,
$data = array()
) {
parent::__construct($factoryElement, $factoryCollection, $escaper, $data);
@@ -58,6 +60,9 @@ public function __construct(
}
}
+ /**
+ * @return string
+ */
public function getElementHtml()
{
$js = '
@@ -153,6 +158,9 @@ public function getElementHtml()
}
}
+ /**
+ * @return mixed
+ */
public function getTheme()
{
if(!$this->hasData('theme')) {
@@ -183,6 +191,7 @@ protected function _getButtonsHtml()
/**
* Return HTML button to toggling WYSIWYG
*
+ * @param bool $visible
* @return string
*/
protected function _getToggleButtonHtml($visible = true)
diff --git a/lib/Magento/Data/Form/Element/Factory.php b/lib/Magento/Data/Form/Element/Factory.php
index 3a892b316ee71..673dd7438ad3f 100644
--- a/lib/Magento/Data/Form/Element/Factory.php
+++ b/lib/Magento/Data/Form/Element/Factory.php
@@ -32,17 +32,19 @@
*/
namespace Magento\Data\Form\Element;
+use Magento\ObjectManager;
+
class Factory
{
/**
- * @var \Magento\ObjectManager
+ * @var ObjectManager
*/
protected $_objectManager;
/**
* Standard library element types
*
- * @var array
+ * @var string[]
*/
protected $_standardTypes = array(
'button',
@@ -76,9 +78,9 @@ class Factory
);
/**
- * @param \Magento\ObjectManager $objectManager
+ * @param ObjectManager $objectManager
*/
- public function __construct(\Magento\ObjectManager $objectManager)
+ public function __construct(ObjectManager $objectManager)
{
$this->_objectManager = $objectManager;
}
@@ -88,7 +90,7 @@ public function __construct(\Magento\ObjectManager $objectManager)
*
* @param string $elementType Standard element type or Custom element class
* @param array $config
- * @return \Magento\Data\Form\Element\AbstractElement
+ * @return AbstractElement
* @throws \InvalidArgumentException
*/
public function create($elementType, array $config = array())
@@ -100,7 +102,7 @@ public function create($elementType, array $config = array())
}
$element = $this->_objectManager->create($className, $config);
- if (!($element instanceof \Magento\Data\Form\Element\AbstractElement)) {
+ if (!($element instanceof AbstractElement)) {
throw new \InvalidArgumentException($className
. ' doesn\'n extend \Magento\Data\Form\Element\AbstractElement');
}
diff --git a/lib/Magento/Data/Form/Element/Fieldset.php b/lib/Magento/Data/Form/Element/Fieldset.php
index a1adc7672a9d5..8b8c3b6ee8bf6 100644
--- a/lib/Magento/Data/Form/Element/Fieldset.php
+++ b/lib/Magento/Data/Form/Element/Fieldset.php
@@ -33,22 +33,25 @@
*/
namespace Magento\Data\Form\Element;
-class Fieldset extends \Magento\Data\Form\Element\AbstractElement
+use Magento\Data\Form;
+use Magento\Escaper;
+
+class Fieldset extends AbstractElement
{
/**
- * @param \Magento\Data\Form\Element\Factory $factoryElement
- * @param \Magento\Data\Form\Element\CollectionFactory $factoryCollection
- * @param \Magento\Escaper $escaper
+ * @param Factory $factoryElement
+ * @param CollectionFactory $factoryCollection
+ * @param Escaper $escaper
* @param array $data
*/
public function __construct(
- \Magento\Data\Form\Element\Factory $factoryElement,
- \Magento\Data\Form\Element\CollectionFactory $factoryCollection,
- \Magento\Escaper $escaper,
+ Factory $factoryElement,
+ CollectionFactory $factoryCollection,
+ Escaper $escaper,
$data = array()
) {
parent::__construct($factoryElement, $factoryCollection, $escaper, $data);
- $this->_renderer = \Magento\Data\Form::getFieldsetRenderer();
+ $this->_renderer = Form::getFieldsetRenderer();
$this->setType('fieldset');
if (isset($data['advancedSection'])) {
$this->setAdvancedLabel($data['advancedSection']);
@@ -76,7 +79,7 @@ public function getElementHtml()
/**
* Get Children element's array
*
- * @return array
+ * @return AbstractElement[]
*/
public function getChildren()
{
@@ -102,7 +105,7 @@ public function getChildrenHtml()
/**
* Get Basic elements' array
*
- * @return array
+ * @return AbstractElement[]
*/
public function getBasicChildren()
{
@@ -126,7 +129,7 @@ public function getBasicChildrenHtml()
}
/**
- * Get Number of Bacic Children
+ * Get Number of Basic Children
*
* @return int
*/
@@ -179,7 +182,7 @@ public function hasAdvanced()
/**
* Get SubFieldset
*
- * @return array
+ * @return AbstractElement[]
*/
public function getSubFieldset()
{
@@ -222,12 +225,12 @@ public function getDefaultHtml()
* @param string $type
* @param array $config
* @param boolean $after
- * @return \Magento\Data\Form\Element\AbstractElement
+ * @return AbstractElement
*/
public function addField($elementId, $type, $config, $after = false, $isAdvanced = false)
{
$element = parent::addField($elementId, $type, $config, $after);
- if ($renderer = \Magento\Data\Form::getFieldsetElementRenderer()) {
+ if ($renderer = Form::getFieldsetElementRenderer()) {
$element->setRenderer($renderer);
}
$element->setAdvanced($isAdvanced);
@@ -237,7 +240,7 @@ public function addField($elementId, $type, $config, $after = false, $isAdvanced
/**
* Return elements as html string
*
- * @param array $elements
+ * @param AbstractElement[] $elements
* @return string
*/
protected function _elementsToHtml($elements)
diff --git a/lib/Magento/Data/Form/Element/Gallery.php b/lib/Magento/Data/Form/Element/Gallery.php
index 319382e3f20fc..ab450c6ec8f8f 100644
--- a/lib/Magento/Data/Form/Element/Gallery.php
+++ b/lib/Magento/Data/Form/Element/Gallery.php
@@ -33,24 +33,29 @@
*/
namespace Magento\Data\Form\Element;
-class Gallery extends \Magento\Data\Form\Element\AbstractElement
+use Magento\Escaper;
+
+class Gallery extends AbstractElement
{
/**
- * @param \Magento\Data\Form\Element\Factory $factoryElement
- * @param \Magento\Data\Form\Element\CollectionFactory $factoryCollection
- * @param \Magento\Escaper $escaper
+ * @param Factory $factoryElement
+ * @param CollectionFactory $factoryCollection
+ * @param Escaper $escaper
* @param array $data
*/
public function __construct(
- \Magento\Data\Form\Element\Factory $factoryElement,
- \Magento\Data\Form\Element\CollectionFactory $factoryCollection,
- \Magento\Escaper $escaper,
+ Factory $factoryElement,
+ CollectionFactory $factoryCollection,
+ Escaper $escaper,
$data = array()
) {
parent::__construct($factoryElement, $factoryCollection, $escaper, $data);
$this->setType('file');
}
+ /**
+ * @return string
+ */
public function getElementHtml()
{
$gallery = $this->getValue();
@@ -173,11 +178,17 @@ function addNewImg(){
return $html;
}
+ /**
+ * @return mixed
+ */
public function getName()
{
return $this->getData('name');
}
+ /**
+ * @return mixed
+ */
public function getParentName()
{
return parent::getName();
diff --git a/lib/Magento/Data/Form/Element/Hidden.php b/lib/Magento/Data/Form/Element/Hidden.php
index 202b3a72ee01f..35af26af0e5f0 100644
--- a/lib/Magento/Data/Form/Element/Hidden.php
+++ b/lib/Magento/Data/Form/Element/Hidden.php
@@ -33,18 +33,20 @@
*/
namespace Magento\Data\Form\Element;
-class Hidden extends \Magento\Data\Form\Element\AbstractElement
+use Magento\Escaper;
+
+class Hidden extends AbstractElement
{
/**
- * @param \Magento\Data\Form\Element\Factory $factoryElement
- * @param \Magento\Data\Form\Element\CollectionFactory $factoryCollection
- * @param \Magento\Escaper $escaper
+ * @param Factory $factoryElement
+ * @param CollectionFactory $factoryCollection
+ * @param Escaper $escaper
* @param array $data
*/
public function __construct(
- \Magento\Data\Form\Element\Factory $factoryElement,
- \Magento\Data\Form\Element\CollectionFactory $factoryCollection,
- \Magento\Escaper $escaper,
+ Factory $factoryElement,
+ CollectionFactory $factoryCollection,
+ Escaper $escaper,
$data = array()
) {
parent::__construct($factoryElement, $factoryCollection, $escaper, $data);
@@ -52,6 +54,9 @@ public function __construct(
$this->setExtType('hiddenfield');
}
+ /**
+ * @return mixed
+ */
public function getDefaultHtml()
{
$html = $this->getData('default_html');
diff --git a/lib/Magento/Data/Form/Element/Link.php b/lib/Magento/Data/Form/Element/Link.php
index 34d338aa36c7d..92e74b8867e82 100644
--- a/lib/Magento/Data/Form/Element/Link.php
+++ b/lib/Magento/Data/Form/Element/Link.php
@@ -33,18 +33,20 @@
*/
namespace Magento\Data\Form\Element;
-class Link extends \Magento\Data\Form\Element\AbstractElement
+use Magento\Escaper;
+
+class Link extends AbstractElement
{
/**
- * @param \Magento\Data\Form\Element\Factory $factoryElement
- * @param \Magento\Data\Form\Element\CollectionFactory $factoryCollection
- * @param \Magento\Escaper $escaper
+ * @param Factory $factoryElement
+ * @param CollectionFactory $factoryCollection
+ * @param Escaper $escaper
* @param array $data
*/
public function __construct(
- \Magento\Data\Form\Element\Factory $factoryElement,
- \Magento\Data\Form\Element\CollectionFactory $factoryCollection,
- \Magento\Escaper $escaper,
+ Factory $factoryElement,
+ CollectionFactory $factoryCollection,
+ Escaper $escaper,
$data = array()
) {
parent::__construct($factoryElement, $factoryCollection, $escaper, $data);
@@ -68,7 +70,7 @@ public function getElementHtml()
/**
* Prepare array of anchor attributes
*
- * @return array
+ * @return string[]
*/
public function getHtmlAttributes()
{
diff --git a/lib/Magento/Data/Form/Element/Multiline.php b/lib/Magento/Data/Form/Element/Multiline.php
index d9e9fe26c2ace..c36f344ed458a 100644
--- a/lib/Magento/Data/Form/Element/Multiline.php
+++ b/lib/Magento/Data/Form/Element/Multiline.php
@@ -31,18 +31,20 @@
*/
namespace Magento\Data\Form\Element;
-class Multiline extends \Magento\Data\Form\Element\AbstractElement
+use Magento\Escaper;
+
+class Multiline extends AbstractElement
{
/**
- * @param \Magento\Data\Form\Element\Factory $factoryElement
- * @param \Magento\Data\Form\Element\CollectionFactory $factoryCollection
- * @param \Magento\Escaper $escaper
+ * @param Factory $factoryElement
+ * @param CollectionFactory $factoryCollection
+ * @param Escaper $escaper
* @param array $data
*/
public function __construct(
- \Magento\Data\Form\Element\Factory $factoryElement,
- \Magento\Data\Form\Element\CollectionFactory $factoryCollection,
- \Magento\Escaper $escaper,
+ Factory $factoryElement,
+ CollectionFactory $factoryCollection,
+ Escaper $escaper,
$data = array()
) {
parent::__construct($factoryElement, $factoryCollection, $escaper, $data);
@@ -50,11 +52,18 @@ public function __construct(
$this->setLineCount(2);
}
+ /**
+ * @return string[]
+ */
public function getHtmlAttributes()
{
return array('type', 'title', 'class', 'style', 'onclick', 'onchange', 'disabled', 'maxlength');
}
+ /**
+ * @param int $suffix
+ * @return string
+ */
public function getLabelHtml($suffix = 0)
{
return parent::getLabelHtml($suffix);
@@ -87,6 +96,9 @@ public function getElementHtml()
return $html;
}
+ /**
+ * @return mixed
+ */
public function getDefaultHtml()
{
$html = '';
diff --git a/lib/Magento/Data/Form/Element/Multiselect.php b/lib/Magento/Data/Form/Element/Multiselect.php
index 5528812755180..4d25bd6f6925e 100644
--- a/lib/Magento/Data/Form/Element/Multiselect.php
+++ b/lib/Magento/Data/Form/Element/Multiselect.php
@@ -33,18 +33,20 @@
*/
namespace Magento\Data\Form\Element;
-class Multiselect extends \Magento\Data\Form\Element\AbstractElement
+use Magento\Escaper;
+
+class Multiselect extends AbstractElement
{
/**
- * @param \Magento\Data\Form\Element\Factory $factoryElement
- * @param \Magento\Data\Form\Element\CollectionFactory $factoryCollection
- * @param \Magento\Escaper $escaper
+ * @param Factory $factoryElement
+ * @param CollectionFactory $factoryCollection
+ * @param Escaper $escaper
* @param array $data
*/
public function __construct(
- \Magento\Data\Form\Element\Factory $factoryElement,
- \Magento\Data\Form\Element\CollectionFactory $factoryCollection,
- \Magento\Escaper $escaper,
+ Factory $factoryElement,
+ CollectionFactory $factoryCollection,
+ Escaper $escaper,
$data = array()
) {
parent::__construct($factoryElement, $factoryCollection, $escaper, $data);
@@ -53,6 +55,11 @@ public function __construct(
$this->setSize(10);
}
+ /**
+ * Get the name
+ *
+ * @return string
+ */
public function getName()
{
$name = parent::getName();
@@ -62,6 +69,11 @@ public function getName()
return $name;
}
+ /**
+ * Get the element as HTML
+ *
+ * @return string
+ */
public function getElementHtml()
{
$this->addClass('select multiselect');
@@ -98,11 +110,21 @@ public function getElementHtml()
return $html;
}
+ /**
+ * Get the HTML attributes
+ *
+ * @return string[]
+ */
public function getHtmlAttributes()
{
return array('title', 'class', 'style', 'onclick', 'onchange', 'disabled', 'size', 'tabindex');
}
+ /**
+ * Get the default HTML
+ *
+ * @return string
+ */
public function getDefaultHtml()
{
$result = $this->getNoSpan() === true ? '' : '' . "\n";
@@ -142,11 +164,21 @@ public function getDefaultHtml()
return $result;
}
+ /**
+ * Get the name of the JS object
+ *
+ * @return string
+ */
public function getJsObjectName()
{
return $this->getHtmlId() . 'ElementControl';
}
+ /**
+ * @param array $option
+ * @param array $selected
+ * @return string
+ */
protected function _optionToHtml($option, $selected)
{
$html = ' |