diff --git a/CHANGELOG.md b/CHANGELOG.md index 1926afa07676f..88806577cdcb0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,25 @@ +2.0.0.0-dev72 +============= +* Framework Improvements: + * Fixed performance degradation caused by DI argument processors +* Modularity improvements: + * Introduced the Magento_UrlRewrite module, and moved corresponding classes from Magento_Core to Magento_UrlRewrite + * Moved all Install logic to the Magento_Install module + * Eliminated the Core\Helper\Js class + * Moved the Email related logic from the Magento_Core module to the Magento_Email module + * Moved the Cache related logic from the Magento_Core module to library +* Indexer improvements: + * Added execution time hints for console reindex +* Customer Service usage: + * Refactored the Magento_Newsletter module to use Customer service layer +* Fixed bugs: + * Fixed an issue with resetting customer password from the frontend + * Fixed an issue where mistakenly the attribute of the Customer Address Edit form was cached + * Fixed an issue where admin could not unsubscribe customer on the customer edit page in the backend + * Fixed an issue where customers were always subscribed to the newsletter even if not selected during registration +* GitHub requests: + * [#325] (https://github.com/magento/magento2/pull/325) -- ImportExport: Fix notice if _attribute_set column is missing + 2.0.0.0-dev71 ============= * Fixed bugs: diff --git a/app/code/Magento/Backend/Block/Page/Head.php b/app/code/Magento/Backend/Block/Page/Head.php index 9c91d25e50081..73be3e9f78523 100644 --- a/app/code/Magento/Backend/Block/Page/Head.php +++ b/app/code/Magento/Backend/Block/Page/Head.php @@ -53,6 +53,7 @@ class Head extends \Magento\Theme\Block\Html\Head * @param \Magento\View\Asset\MergeService $assetMergeService * @param \Magento\View\Asset\MinifyService $assetMinifyService * @param \Magento\Locale\ResolverInterface $localeResolver + * @param \Magento\Translation\Block\Js $jsTranslation * @param \Magento\App\Action\Title $titles * @param \Magento\Data\Form\FormKey $formKey * @param array $data @@ -65,6 +66,7 @@ public function __construct( \Magento\View\Asset\MergeService $assetMergeService, \Magento\View\Asset\MinifyService $assetMinifyService, \Magento\Locale\ResolverInterface $localeResolver, + \Magento\Translation\Block\Js $jsTranslation, \Magento\App\Action\Title $titles, \Magento\Data\Form\FormKey $formKey, array $data = array() @@ -79,6 +81,7 @@ public function __construct( $assetMergeService, $assetMinifyService, $localeResolver, + $jsTranslation, $data ); $this->formKey = $formKey; diff --git a/app/code/Magento/Backend/Block/System/Config/Form/Fieldset.php b/app/code/Magento/Backend/Block/System/Config/Form/Fieldset.php index dc3eadd1345af..a17a612e886c7 100644 --- a/app/code/Magento/Backend/Block/System/Config/Form/Fieldset.php +++ b/app/code/Magento/Backend/Block/System/Config/Form/Fieldset.php @@ -38,20 +38,20 @@ class Fieldset extends \Magento\Backend\Block\AbstractBlock implements protected $_authSession; /** - * @var \Magento\Core\Helper\Js + * @var \Magento\View\Helper\Js */ protected $_jsHelper; /** * @param \Magento\Backend\Block\Context $context * @param \Magento\Backend\Model\Auth\Session $authSession - * @param \Magento\Core\Helper\Js $jsHelper + * @param \Magento\View\Helper\Js $jsHelper * @param array $data */ public function __construct( \Magento\Backend\Block\Context $context, \Magento\Backend\Model\Auth\Session $authSession, - \Magento\Core\Helper\Js $jsHelper, + \Magento\View\Helper\Js $jsHelper, array $data = array() ) { $this->_jsHelper = $jsHelper; diff --git a/app/code/Magento/Backend/Block/System/Config/Form/Fieldset/Modules/DisableOutput.php b/app/code/Magento/Backend/Block/System/Config/Form/Fieldset/Modules/DisableOutput.php index 511570e512ff1..77ddff349216c 100644 --- a/app/code/Magento/Backend/Block/System/Config/Form/Fieldset/Modules/DisableOutput.php +++ b/app/code/Magento/Backend/Block/System/Config/Form/Fieldset/Modules/DisableOutput.php @@ -54,14 +54,14 @@ class DisableOutput extends \Magento\Backend\Block\System\Config\Form\Fieldset /** * @param \Magento\Backend\Block\Context $context * @param \Magento\Backend\Model\Auth\Session $authSession - * @param \Magento\Core\Helper\Js $jsHelper + * @param \Magento\View\Helper\Js $jsHelper * @param \Magento\Module\ModuleListInterface $moduleList * @param array $data */ public function __construct( \Magento\Backend\Block\Context $context, \Magento\Backend\Model\Auth\Session $authSession, - \Magento\Core\Helper\Js $jsHelper, + \Magento\View\Helper\Js $jsHelper, \Magento\Module\ModuleListInterface $moduleList, array $data = array() ) { diff --git a/app/code/Magento/Backend/Block/Urlrewrite/Catalog/Category/Edit.php b/app/code/Magento/Backend/Block/Urlrewrite/Catalog/Category/Edit.php index e717417c2fcda..d3385a0ef03df 100644 --- a/app/code/Magento/Backend/Block/Urlrewrite/Catalog/Category/Edit.php +++ b/app/code/Magento/Backend/Block/Urlrewrite/Catalog/Category/Edit.php @@ -45,14 +45,14 @@ class Edit extends \Magento\Backend\Block\Urlrewrite\Edit /** * @param \Magento\Backend\Block\Template\Context $context - * @param \Magento\Core\Model\Url\RewriteFactory $rewriteFactory + * @param \Magento\UrlRewrite\Model\UrlRewriteFactory $rewriteFactory * @param \Magento\Backend\Helper\Data $adminhtmlData * @param \Magento\Catalog\Model\CategoryFactory $categoryFactory * @param array $data */ public function __construct( \Magento\Backend\Block\Template\Context $context, - \Magento\Core\Model\Url\RewriteFactory $rewriteFactory, + \Magento\UrlRewrite\Model\UrlRewriteFactory $rewriteFactory, \Magento\Backend\Helper\Data $adminhtmlData, \Magento\Catalog\Model\CategoryFactory $categoryFactory, array $data = array() diff --git a/app/code/Magento/Backend/Block/Urlrewrite/Catalog/Edit/Form.php b/app/code/Magento/Backend/Block/Urlrewrite/Catalog/Edit/Form.php index 1f56370777b5f..bad9decfd3949 100644 --- a/app/code/Magento/Backend/Block/Urlrewrite/Catalog/Edit/Form.php +++ b/app/code/Magento/Backend/Block/Urlrewrite/Catalog/Edit/Form.php @@ -64,9 +64,9 @@ class Form extends \Magento\Backend\Block\Urlrewrite\Edit\Form * @param \Magento\Backend\Block\Template\Context $context * @param \Magento\Registry $registry * @param \Magento\Data\FormFactory $formFactory - * @param \Magento\Core\Model\Source\Urlrewrite\TypesFactory $typesFactory - * @param \Magento\Core\Model\Source\Urlrewrite\OptionsFactory $optionFactory - * @param \Magento\Core\Model\Url\RewriteFactory $rewriteFactory + * @param \Magento\UrlRewrite\Model\UrlRewrite\TypeProviderFactory $typesFactory + * @param \Magento\UrlRewrite\Model\UrlRewrite\OptionProviderFactory $optionFactory + * @param \Magento\UrlRewrite\Model\UrlRewriteFactory $rewriteFactory * @param \Magento\Core\Model\System\Store $systemStore * @param \Magento\Backend\Helper\Data $adminhtmlData * @param \Magento\Catalog\Model\ProductFactory $productFactory @@ -80,9 +80,9 @@ public function __construct( \Magento\Backend\Block\Template\Context $context, \Magento\Registry $registry, \Magento\Data\FormFactory $formFactory, - \Magento\Core\Model\Source\Urlrewrite\TypesFactory $typesFactory, - \Magento\Core\Model\Source\Urlrewrite\OptionsFactory $optionFactory, - \Magento\Core\Model\Url\RewriteFactory $rewriteFactory, + \Magento\UrlRewrite\Model\UrlRewrite\TypeProviderFactory $typesFactory, + \Magento\UrlRewrite\Model\UrlRewrite\OptionProviderFactory $optionFactory, + \Magento\UrlRewrite\Model\UrlRewriteFactory $rewriteFactory, \Magento\Core\Model\System\Store $systemStore, \Magento\Backend\Helper\Data $adminhtmlData, \Magento\Catalog\Model\ProductFactory $productFactory, diff --git a/app/code/Magento/Backend/Block/Urlrewrite/Catalog/Product/Edit.php b/app/code/Magento/Backend/Block/Urlrewrite/Catalog/Product/Edit.php index fa8ad22fb423e..17b2c6e4f4404 100644 --- a/app/code/Magento/Backend/Block/Urlrewrite/Catalog/Product/Edit.php +++ b/app/code/Magento/Backend/Block/Urlrewrite/Catalog/Product/Edit.php @@ -53,7 +53,7 @@ class Edit extends \Magento\Backend\Block\Urlrewrite\Edit /** * @param \Magento\Backend\Block\Template\Context $context - * @param \Magento\Core\Model\Url\RewriteFactory $rewriteFactory + * @param \Magento\UrlRewrite\Model\UrlRewriteFactory $rewriteFactory * @param \Magento\Backend\Helper\Data $adminhtmlData * @param \Magento\Catalog\Model\ProductFactory $productFactory * @param \Magento\Catalog\Model\CategoryFactory $categoryFactory @@ -61,7 +61,7 @@ class Edit extends \Magento\Backend\Block\Urlrewrite\Edit */ public function __construct( \Magento\Backend\Block\Template\Context $context, - \Magento\Core\Model\Url\RewriteFactory $rewriteFactory, + \Magento\UrlRewrite\Model\UrlRewriteFactory $rewriteFactory, \Magento\Backend\Helper\Data $adminhtmlData, \Magento\Catalog\Model\ProductFactory $productFactory, \Magento\Catalog\Model\CategoryFactory $categoryFactory, diff --git a/app/code/Magento/Backend/Block/Urlrewrite/Cms/Page/Edit.php b/app/code/Magento/Backend/Block/Urlrewrite/Cms/Page/Edit.php index c50dd0040d613..2f12b6a972b53 100644 --- a/app/code/Magento/Backend/Block/Urlrewrite/Cms/Page/Edit.php +++ b/app/code/Magento/Backend/Block/Urlrewrite/Cms/Page/Edit.php @@ -44,14 +44,14 @@ class Edit extends \Magento\Backend\Block\Urlrewrite\Edit /** * @param \Magento\Backend\Block\Template\Context $context - * @param \Magento\Core\Model\Url\RewriteFactory $rewriteFactory + * @param \Magento\UrlRewrite\Model\UrlRewriteFactory $rewriteFactory * @param \Magento\Backend\Helper\Data $adminhtmlData * @param \Magento\Cms\Model\PageFactory $pageFactory * @param array $data */ public function __construct( \Magento\Backend\Block\Template\Context $context, - \Magento\Core\Model\Url\RewriteFactory $rewriteFactory, + \Magento\UrlRewrite\Model\UrlRewriteFactory $rewriteFactory, \Magento\Backend\Helper\Data $adminhtmlData, \Magento\Cms\Model\PageFactory $pageFactory, array $data = array() diff --git a/app/code/Magento/Backend/Block/Urlrewrite/Cms/Page/Edit/Form.php b/app/code/Magento/Backend/Block/Urlrewrite/Cms/Page/Edit/Form.php index 028afefefbf94..657d747c53e81 100644 --- a/app/code/Magento/Backend/Block/Urlrewrite/Cms/Page/Edit/Form.php +++ b/app/code/Magento/Backend/Block/Urlrewrite/Cms/Page/Edit/Form.php @@ -57,9 +57,9 @@ class Form extends \Magento\Backend\Block\Urlrewrite\Edit\Form * @param \Magento\Backend\Block\Template\Context $context * @param \Magento\Registry $registry * @param \Magento\Data\FormFactory $formFactory - * @param \Magento\Core\Model\Source\Urlrewrite\TypesFactory $typesFactory - * @param \Magento\Core\Model\Source\Urlrewrite\OptionsFactory $optionFactory - * @param \Magento\Core\Model\Url\RewriteFactory $rewriteFactory + * @param \Magento\UrlRewrite\Model\UrlRewrite\TypeProviderFactory $typesFactory + * @param \Magento\UrlRewrite\Model\UrlRewrite\OptionProviderFactory $optionFactory + * @param \Magento\UrlRewrite\Model\UrlRewriteFactory $rewriteFactory * @param \Magento\Core\Model\System\Store $systemStore * @param \Magento\Backend\Helper\Data $adminhtmlData * @param \Magento\Cms\Model\Page\UrlrewriteFactory $urlRewriteFactory @@ -72,9 +72,9 @@ public function __construct( \Magento\Backend\Block\Template\Context $context, \Magento\Registry $registry, \Magento\Data\FormFactory $formFactory, - \Magento\Core\Model\Source\Urlrewrite\TypesFactory $typesFactory, - \Magento\Core\Model\Source\Urlrewrite\OptionsFactory $optionFactory, - \Magento\Core\Model\Url\RewriteFactory $rewriteFactory, + \Magento\UrlRewrite\Model\UrlRewrite\TypeProviderFactory $typesFactory, + \Magento\UrlRewrite\Model\UrlRewrite\OptionProviderFactory $optionFactory, + \Magento\UrlRewrite\Model\UrlRewriteFactory $rewriteFactory, \Magento\Core\Model\System\Store $systemStore, \Magento\Backend\Helper\Data $adminhtmlData, \Magento\Cms\Model\Page\UrlrewriteFactory $urlRewriteFactory, diff --git a/app/code/Magento/Backend/Block/Urlrewrite/Edit.php b/app/code/Magento/Backend/Block/Urlrewrite/Edit.php index 1a2d7bf68e3cc..dc397d549d860 100644 --- a/app/code/Magento/Backend/Block/Urlrewrite/Edit.php +++ b/app/code/Magento/Backend/Block/Urlrewrite/Edit.php @@ -28,8 +28,8 @@ /** * Block for URL rewrites edit page * - * @method \Magento\Core\Model\Url\Rewrite getUrlRewrite() - * @method \Magento\Backend\Block\Urlrewrite\Edit setUrlRewrite(\Magento\Core\Model\Url\Rewrite $urlRewrite) + * @method \Magento\UrlRewrite\Model\UrlRewrite getUrlRewrite() + * @method \Magento\Backend\Block\Urlrewrite\Edit setUrlRewrite(\Magento\UrlRewrite\Model\UrlRewrite $urlRewrite) * * @category Magento * @package Magento_Adminhtml @@ -64,19 +64,19 @@ class Edit extends \Magento\Backend\Block\Widget\Container protected $_adminhtmlData = null; /** - * @var \Magento\Core\Model\Url\RewriteFactory + * @var \Magento\UrlRewrite\Model\UrlRewriteFactory */ protected $_rewriteFactory; /** * @param \Magento\Backend\Block\Template\Context $context - * @param \Magento\Core\Model\Url\RewriteFactory $rewriteFactory + * @param \Magento\UrlRewrite\Model\UrlRewriteFactory $rewriteFactory * @param \Magento\Backend\Helper\Data $adminhtmlData * @param array $data */ public function __construct( \Magento\Backend\Block\Template\Context $context, - \Magento\Core\Model\Url\RewriteFactory $rewriteFactory, + \Magento\UrlRewrite\Model\UrlRewriteFactory $rewriteFactory, \Magento\Backend\Helper\Data $adminhtmlData, array $data = array() ) { @@ -292,7 +292,7 @@ public function getButtonsHtml($area = null) /** * Get or create new instance of URL rewrite * - * @return \Magento\Core\Model\Url\Rewrite + * @return \Magento\UrlRewrite\Model\UrlRewrite */ protected function _getUrlRewrite() { diff --git a/app/code/Magento/Backend/Block/Urlrewrite/Edit/Form.php b/app/code/Magento/Backend/Block/Urlrewrite/Edit/Form.php index b1d3ad0615aa7..5c00e1e87b489 100644 --- a/app/code/Magento/Backend/Block/Urlrewrite/Edit/Form.php +++ b/app/code/Magento/Backend/Block/Urlrewrite/Edit/Form.php @@ -28,8 +28,8 @@ /** * URL rewrites edit form * - * @method \Magento\Core\Model\Url\Rewrite getUrlRewrite() - * @method \Magento\Backend\Block\Urlrewrite\Edit\Form setUrlRewrite(\Magento\Core\Model\Url\Rewrite $model) + * @method \Magento\UrlRewrite\Model\UrlRewrite getUrlRewrite() + * @method \Magento\Backend\Block\Urlrewrite\Edit\Form setUrlRewrite(\Magento\UrlRewrite\Model\UrlRewrite $model) * * @category Magento * @package Magento_Adminhtml @@ -73,17 +73,17 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic protected $_systemStore; /** - * @var \Magento\Core\Model\Url\RewriteFactory + * @var \Magento\UrlRewrite\Model\UrlRewriteFactory */ protected $_rewriteFactory; /** - * @var \Magento\Core\Model\Source\Urlrewrite\OptionsFactory + * @var \Magento\UrlRewrite\Model\UrlRewrite\OptionProviderFactory */ protected $_optionFactory; /** - * @var \Magento\Core\Model\Source\Urlrewrite\TypesFactory + * @var \Magento\UrlRewrite\Model\UrlRewrite\TypeProviderFactory */ protected $_typesFactory; @@ -91,9 +91,9 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic * @param \Magento\Backend\Block\Template\Context $context * @param \Magento\Registry $registry * @param \Magento\Data\FormFactory $formFactory - * @param \Magento\Core\Model\Source\Urlrewrite\TypesFactory $typesFactory - * @param \Magento\Core\Model\Source\Urlrewrite\OptionsFactory $optionFactory - * @param \Magento\Core\Model\Url\RewriteFactory $rewriteFactory + * @param \Magento\UrlRewrite\Model\UrlRewrite\TypeProviderFactory $typesFactory + * @param \Magento\UrlRewrite\Model\UrlRewrite\OptionProviderFactory $optionFactory + * @param \Magento\UrlRewrite\Model\UrlRewriteFactory $rewriteFactory * @param \Magento\Core\Model\System\Store $systemStore * @param \Magento\Backend\Helper\Data $adminhtmlData * @param array $data @@ -104,9 +104,9 @@ public function __construct( \Magento\Backend\Block\Template\Context $context, \Magento\Registry $registry, \Magento\Data\FormFactory $formFactory, - \Magento\Core\Model\Source\Urlrewrite\TypesFactory $typesFactory, - \Magento\Core\Model\Source\Urlrewrite\OptionsFactory $optionFactory, - \Magento\Core\Model\Url\RewriteFactory $rewriteFactory, + \Magento\UrlRewrite\Model\UrlRewrite\TypeProviderFactory $typesFactory, + \Magento\UrlRewrite\Model\UrlRewrite\OptionProviderFactory $optionFactory, + \Magento\UrlRewrite\Model\UrlRewriteFactory $rewriteFactory, \Magento\Core\Model\System\Store $systemStore, \Magento\Backend\Helper\Data $adminhtmlData, array $data = array() @@ -179,7 +179,7 @@ protected function _prepareForm() $fieldset = $form->addFieldset('base_fieldset', array('legend' => __('URL Rewrite Information'))); - /** @var $typesModel \Magento\Core\Model\Source\Urlrewrite\Types */ + /** @var $typesModel \Magento\UrlRewrite\Model\UrlRewrite\TypeProvider */ $typesModel = $this->_typesFactory->create(); $fieldset->addField( 'is_system', @@ -233,7 +233,7 @@ protected function _prepareForm() ) ); - /** @var $optionsModel \Magento\Core\Model\Source\Urlrewrite\Options */ + /** @var $optionsModel \Magento\UrlRewrite\Model\UrlRewrite\OptionProvider */ $optionsModel = $this->_optionFactory->create(); $fieldset->addField( 'options', @@ -339,7 +339,7 @@ protected function _getSessionData() /** * Get URL rewrite model instance * - * @return \Magento\Core\Model\Url\Rewrite + * @return \Magento\UrlRewrite\Model\UrlRewrite */ protected function _getModel() { diff --git a/app/code/Magento/Backend/Controller/Adminhtml/Urlrewrite.php b/app/code/Magento/Backend/Controller/Adminhtml/Urlrewrite.php index 3b9cf64c05bd4..34b14e41417a0 100644 --- a/app/code/Magento/Backend/Controller/Adminhtml/Urlrewrite.php +++ b/app/code/Magento/Backend/Controller/Adminhtml/Urlrewrite.php @@ -29,7 +29,6 @@ use Magento\Catalog\Model\Category; use Magento\Catalog\Model\Product; use Magento\Model\Exception; -use Magento\Core\Model\Url\Rewrite; /** * URL rewrite adminhtml controller @@ -64,7 +63,7 @@ class Urlrewrite extends Action private $_cmsPage; /** - * @var Rewrite + * @var \Magento\UrlRewrite\Model\UrlRewrite */ private $_urlRewrite; @@ -223,12 +222,12 @@ public function saveAction() $session = $this->_objectManager->get('Magento\Backend\Model\Session'); try { // set basic urlrewrite data - /** @var $model Rewrite */ + /** @var $model \Magento\UrlRewrite\Model\UrlRewrite */ $model = $this->_getUrlRewrite(); // Validate request path $requestPath = $this->getRequest()->getParam('request_path'); - $this->_objectManager->get('Magento\Core\Helper\Url\Rewrite')->validateRequestPath($requestPath); + $this->_objectManager->get('Magento\UrlRewrite\Helper\UrlRewrite')->validateRequestPath($requestPath); // Proceed and save request $model->setIdPath( @@ -274,7 +273,7 @@ public function saveAction() /** * Call before save urlrewrite handlers * - * @param Rewrite $model + * @param \Magento\UrlRewrite\Model\UrlRewrite $model * @return void */ protected function _onUrlRewriteSaveBefore($model) @@ -286,7 +285,7 @@ protected function _onUrlRewriteSaveBefore($model) /** * Call after save urlrewrite handlers * - * @param Rewrite $model + * @param \Magento\UrlRewrite\Model\UrlRewrite $model * @return void */ protected function _onUrlRewriteSaveAfter($model) @@ -297,7 +296,7 @@ protected function _onUrlRewriteSaveAfter($model) /** * Override urlrewrite data, basing on current category and product * - * @param Rewrite $model + * @param \Magento\UrlRewrite\Model\UrlRewrite $model * @return void * @throws Exception */ @@ -314,10 +313,10 @@ protected function _handleCatalogUrlRewrite($model) // if redirect specified try to find friendly URL $generateTarget = true; - if ($this->_objectManager->get('Magento\Core\Helper\Url\Rewrite')->hasRedirectOptions($model)) { + if ($this->_objectManager->get('Magento\UrlRewrite\Helper\UrlRewrite')->hasRedirectOptions($model)) { /** @var $rewriteResource \Magento\Catalog\Model\Resource\Url */ $rewriteResource = $this->_objectManager->create('Magento\Catalog\Model\Resource\Url'); - /** @var $rewrite Rewrite */ + /** @var $rewrite \Magento\UrlRewrite\Model\UrlRewrite */ $rewrite = $rewriteResource->getRewriteByIdPath($idPath, $model->getStoreId()); if (!$rewrite) { if ($product) { @@ -341,7 +340,7 @@ protected function _handleCatalogUrlRewrite($model) /** * Get product instance applicable for generatePath * - * @param Rewrite $model + * @param \Magento\UrlRewrite\Model\UrlRewrite $model * @return Product|null */ private function _getInitializedProduct($model) @@ -360,7 +359,7 @@ private function _getInitializedProduct($model) /** * Get category instance applicable for generatePath * - * @param Rewrite $model + * @param \Magento\UrlRewrite\Model\UrlRewrite $model * @return Category|null */ private function _getInitializedCategory($model) @@ -378,7 +377,7 @@ private function _getInitializedCategory($model) /** * Override URL rewrite data, basing on current CMS page * - * @param Rewrite $model + * @param \Magento\UrlRewrite\Model\UrlRewrite $model * @return void * @throws Exception */ @@ -397,10 +396,10 @@ private function _handleCmsPageUrlRewrite($model) // if redirect specified try to find friendly URL $generateTarget = true; - if ($this->_objectManager->get('Magento\Core\Helper\Url\Rewrite')->hasRedirectOptions($model)) { + if ($this->_objectManager->get('Magento\UrlRewrite\Helper\UrlRewrite')->hasRedirectOptions($model)) { /** @var $rewriteResource \Magento\Catalog\Model\Resource\Url */ $rewriteResource = $this->_objectManager->create('Magento\Catalog\Model\Resource\Url'); - /** @var $rewrite Rewrite */ + /** @var $rewrite \Magento\UrlRewrite\Model\UrlRewrite */ $rewrite = $rewriteResource->getRewriteByIdPath($idPath, $model->getStoreId()); if (!$rewrite) { throw new Exception(__('Chosen cms page does not associated with the chosen store.')); @@ -418,7 +417,7 @@ private function _handleCmsPageUrlRewrite($model) /** * Save CMS page URL rewrite additional information * - * @param Rewrite $model + * @param \Magento\UrlRewrite\Model\UrlRewrite $model * @return void */ private function _handleCmsPageUrlRewriteSave($model) @@ -542,12 +541,12 @@ private function _getCmsPage() /** * Get URL rewrite from request * - * @return Rewrite + * @return \Magento\UrlRewrite\Model\UrlRewrite */ private function _getUrlRewrite() { if (!$this->_urlRewrite) { - $this->_urlRewrite = $this->_objectManager->create('Magento\Core\Model\Url\Rewrite'); + $this->_urlRewrite = $this->_objectManager->create('Magento\UrlRewrite\Model\UrlRewrite'); $urlRewriteId = (int)$this->getRequest()->getParam('id', 0); if ($urlRewriteId) { diff --git a/app/code/Magento/Backend/Helper/Js.php b/app/code/Magento/Backend/Helper/Js.php index bfb8827585c22..299d27ed5ba0c 100644 --- a/app/code/Magento/Backend/Helper/Js.php +++ b/app/code/Magento/Backend/Helper/Js.php @@ -33,7 +33,7 @@ */ namespace Magento\Backend\Helper; -class Js extends \Magento\Core\Helper\Js +class Js { /** * Decode serialized grid data diff --git a/app/code/Magento/Backend/Helper/Media/Js.php b/app/code/Magento/Backend/Helper/Media/Js.php deleted file mode 100644 index 639f00639faf9..0000000000000 --- a/app/code/Magento/Backend/Helper/Media/Js.php +++ /dev/null @@ -1,61 +0,0 @@ - - */ -class Js extends \Magento\Core\Helper\Js -{ - /** - * {@inheritdoc} - */ - protected function _populateTranslateData() - { - $this->_addTranslation('Complete', __('Complete')); - $this->_addTranslation( - 'The file size should be more than 0 bytes.', - __('The file size should be more than 0 bytes.') - ); - $this->_addTranslation('Upload Security Error', __('Upload Security Error')); - $this->_addTranslation('Upload HTTP Error', __('Upload HTTP Error')); - $this->_addTranslation('Upload I/O Error', __('Upload I/O Error')); - $this->_addTranslation( - 'SSL Error: Invalid or self-signed certificate', - __('SSL Error: Invalid or self-signed certificate') - ); - $this->_addTranslation('Tb', __('Tb')); - $this->_addTranslation('Gb', __('Gb')); - $this->_addTranslation('Mb', __('Mb')); - $this->_addTranslation('Kb', __('Kb')); - $this->_addTranslation('b', __('b')); - } -} diff --git a/app/code/Magento/Backend/Model/Config.php b/app/code/Magento/Backend/Model/Config.php index c9f44d9dccbec..75cb407b5a497 100644 --- a/app/code/Magento/Backend/Model/Config.php +++ b/app/code/Magento/Backend/Model/Config.php @@ -59,7 +59,7 @@ class Config extends \Magento\Object /** * Application config * - * @var \Magento\App\ConfigInterface + * @var \Magento\App\ReinitableConfigInterface */ protected $_appConfig; @@ -97,7 +97,7 @@ class Config extends \Magento\Object protected $_storeManager; /** - * @param \Magento\App\ConfigInterface $config + * @param \Magento\App\ReinitableConfigInterface $config * @param \Magento\Event\ManagerInterface $eventManager * @param \Magento\Backend\Model\Config\Structure $configStructure * @param \Magento\DB\TransactionFactory $transactionFactory @@ -107,7 +107,7 @@ class Config extends \Magento\Object * @param array $data */ public function __construct( - \Magento\App\ConfigInterface $config, + \Magento\App\ReinitableConfigInterface $config, \Magento\Event\ManagerInterface $eventManager, \Magento\Backend\Model\Config\Structure $configStructure, \Magento\DB\TransactionFactory $transactionFactory, @@ -172,7 +172,7 @@ public function save() $saveTransaction->save(); // re-init configuration - $this->_eventManager->dispatch('application_process_reinit_config'); + $this->_appConfig->reinit(); $this->_storeManager->reinitStores(); // website and store codes can be used in event implementation, so set them as well @@ -182,7 +182,7 @@ public function save() ); } catch (\Exception $e) { // re-init configuration - $this->_eventManager->dispatch('application_process_reinit_config'); + $this->_appConfig->reinit(); $this->_storeManager->reinitStores(); throw $e; } diff --git a/app/code/Magento/Core/Model/Layout/Filter/Acl.php b/app/code/Magento/Backend/Model/Layout/Filter/Acl.php similarity index 97% rename from app/code/Magento/Core/Model/Layout/Filter/Acl.php rename to app/code/Magento/Backend/Model/Layout/Filter/Acl.php index bc9f68d53fc5f..7959498de69ce 100644 --- a/app/code/Magento/Core/Model/Layout/Filter/Acl.php +++ b/app/code/Magento/Backend/Model/Layout/Filter/Acl.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\Core\Model\Layout\Filter; +namespace Magento\Backend\Model\Layout\Filter; class Acl { diff --git a/app/code/Magento/Backend/Model/Url.php b/app/code/Magento/Backend/Model/Url.php index 26fa44a8f6fd9..b431163ce857b 100644 --- a/app/code/Magento/Backend/Model/Url.php +++ b/app/code/Magento/Backend/Model/Url.php @@ -101,6 +101,11 @@ class Url extends \Magento\Url implements \Magento\Backend\Model\UrlInterface */ protected $formKey; + /** + * @var \Magento\Core\Model\Store + */ + protected $_scope; + /** * @param \Magento\App\Route\ConfigInterface $routeConfig * @param \Magento\App\RequestInterface $request @@ -427,12 +432,15 @@ protected function _getActionPath() */ protected function _getScope() { - return $this->_storeFactory->create( - array( - 'url' => $this, - 'data' => array('code' => 'admin', 'force_disable_rewrites' => true, 'disable_store_in_url' => true) - ) - ); + if (!$this->_scope) { + $this->_scope = $this->_storeFactory->create( + array( + 'url' => $this, + 'data' => array('code' => 'admin', 'force_disable_rewrites' => true, 'disable_store_in_url' => true) + ) + ); + } + return $this->_scope; } /** diff --git a/app/code/Magento/Backend/Model/View.php b/app/code/Magento/Backend/Model/View.php index 2b59c4be35e87..cded557c95df8 100644 --- a/app/code/Magento/Backend/Model/View.php +++ b/app/code/Magento/Backend/Model/View.php @@ -26,7 +26,7 @@ class View extends \Magento\App\View { /** - * @var \Magento\Core\Model\Layout\Filter\Acl + * @var Layout\Filter\Acl */ protected $_aclFilter; @@ -38,7 +38,7 @@ class View extends \Magento\App\View * @param \Magento\Event\ManagerInterface $eventManager * @param \Magento\Translate\InlineInterface $translateInline * @param \Magento\App\ActionFlag $actionFlag - * @param \Magento\Core\Model\Layout\Filter\Acl $aclFilter + * @param Layout\Filter\Acl $aclFilter */ public function __construct( \Magento\View\LayoutInterface $layout, @@ -48,7 +48,7 @@ public function __construct( \Magento\Event\ManagerInterface $eventManager, \Magento\Translate\InlineInterface $translateInline, \Magento\App\ActionFlag $actionFlag, - \Magento\Core\Model\Layout\Filter\Acl $aclFilter + Layout\Filter\Acl $aclFilter ) { $this->_aclFilter = $aclFilter; parent::__construct($layout, $request, $response, $configScope, $eventManager, $translateInline, $actionFlag); diff --git a/app/code/Magento/Backend/etc/adminhtml/di.xml b/app/code/Magento/Backend/etc/adminhtml/di.xml index 97a4d138a58d9..1efa27a99d571 100644 --- a/app/code/Magento/Backend/etc/adminhtml/di.xml +++ b/app/code/Magento/Backend/etc/adminhtml/di.xml @@ -94,12 +94,12 @@ - Magento\Backend\App\Router\DefaultRouter + Magento\Backend\App\Router\DefaultRouter false 10 - Magento\App\Router\DefaultRouter + Magento\App\Router\DefaultRouter false 100 diff --git a/app/code/Magento/Backend/etc/di.xml b/app/code/Magento/Backend/etc/di.xml index c4cf726d2ac21..8dd99014def25 100644 --- a/app/code/Magento/Backend/etc/di.xml +++ b/app/code/Magento/Backend/etc/di.xml @@ -74,7 +74,7 @@ - Magento\Backend\App\Router\NoRouteHandler + Magento\Backend\App\Router\NoRouteHandler 10 diff --git a/app/code/Magento/Backend/etc/module.xml b/app/code/Magento/Backend/etc/module.xml index 5b6f60290c1dc..26702f8307909 100644 --- a/app/code/Magento/Backend/etc/module.xml +++ b/app/code/Magento/Backend/etc/module.xml @@ -48,6 +48,8 @@ + + diff --git a/app/code/Magento/Backend/view/adminhtml/layout/adminhtml_urlrewrite_index.xml b/app/code/Magento/Backend/view/adminhtml/layout/adminhtml_urlrewrite_index.xml index 1f3c72254099c..d710505fa24ad 100644 --- a/app/code/Magento/Backend/view/adminhtml/layout/adminhtml_urlrewrite_index.xml +++ b/app/code/Magento/Backend/view/adminhtml/layout/adminhtml_urlrewrite_index.xml @@ -29,7 +29,7 @@ urlrewriteGrid - Magento\Core\Model\Resource\Url\Rewrite\Collection + Magento\UrlRewrite\Model\Resource\UrlRewrite\Collection url_rewrite_id diff --git a/app/code/Magento/Backend/view/adminhtml/page/head.phtml b/app/code/Magento/Backend/view/adminhtml/page/head.phtml index 40d98d69b8f53..b91be770ceeb9 100644 --- a/app/code/Magento/Backend/view/adminhtml/page/head.phtml +++ b/app/code/Magento/Backend/view/adminhtml/page/head.phtml @@ -60,4 +60,4 @@ getChildHtml('components'); ?> getChildHtml('calendar'); ?> getChildHtml('optional_zip_countries'); ?> -helper('Magento\Core\Helper\Js')->getTranslatorScript() ?> +getTranslatorScript(); ?> diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Composite/Update/Result.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Composite/Update/Result.php index 16ebdc3f6c716..c43d7393ffa11 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Composite/Update/Result.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Composite/Update/Result.php @@ -38,11 +38,9 @@ class Result extends \Magento\View\Element\Template { /** - * Adminhtml js - * - * @var \Magento\Backend\Helper\Js + * @var \Magento\View\Helper\Js */ - protected $_adminhtmlJs = null; + protected $_jsHelper = null; /** * Core registry @@ -59,19 +57,19 @@ class Result extends \Magento\View\Element\Template /** * @param \Magento\Backend\Block\Template\Context $context * @param \Magento\Json\EncoderInterface $jsonEncoder - * @param \Magento\Backend\Helper\Js $adminhtmlJs + * @param \Magento\View\Helper\Js $jsHelper * @param \Magento\Registry $registry * @param array $data */ public function __construct( \Magento\Backend\Block\Template\Context $context, \Magento\Json\EncoderInterface $jsonEncoder, - \Magento\Backend\Helper\Js $adminhtmlJs, + \Magento\View\Helper\Js $jsHelper, \Magento\Registry $registry, array $data = array() ) { $this->_jsonEncoder = $jsonEncoder; - $this->_adminhtmlJs = $adminhtmlJs; + $this->_jsHelper = $jsHelper; $this->_coreRegistry = $registry; parent::__construct($context, $data); } @@ -86,6 +84,6 @@ public function _toHtml() $updateResult = $this->_coreRegistry->registry('composite_update_result'); $resultJson = $this->_jsonEncoder->encode($updateResult); $jsVarname = $updateResult->getJsVarName(); - return $this->_adminhtmlJs->getScript(sprintf('var %s = %s', $jsVarname, $resultJson)); + return $this->_jsHelper->getScript(sprintf('var %s = %s', $jsVarname, $resultJson)); } } diff --git a/app/code/Magento/Catalog/Block/Category/Widget/Link.php b/app/code/Magento/Catalog/Block/Category/Widget/Link.php index fa341afde02a1..b115191636f5a 100644 --- a/app/code/Magento/Catalog/Block/Category/Widget/Link.php +++ b/app/code/Magento/Catalog/Block/Category/Widget/Link.php @@ -37,13 +37,13 @@ class Link extends \Magento\Catalog\Block\Widget\Link { /** * @param \Magento\View\Element\Template\Context $context - * @param \Magento\Core\Model\Resource\Url\Rewrite $urlRewrite + * @param \Magento\UrlRewrite\Model\Resource\UrlRewrite $urlRewrite * @param \Magento\Catalog\Model\Resource\Category $resourceCategory * @param array $data */ public function __construct( \Magento\View\Element\Template\Context $context, - \Magento\Core\Model\Resource\Url\Rewrite $urlRewrite, + \Magento\UrlRewrite\Model\Resource\UrlRewrite $urlRewrite, \Magento\Catalog\Model\Resource\Category $resourceCategory, array $data = array() ) { diff --git a/app/code/Magento/Catalog/Block/Product/ListProduct.php b/app/code/Magento/Catalog/Block/Product/ListProduct.php index 4788cf3208c5b..b45779ebadf01 100644 --- a/app/code/Magento/Catalog/Block/Product/ListProduct.php +++ b/app/code/Magento/Catalog/Block/Product/ListProduct.php @@ -68,8 +68,14 @@ class ListProduct extends \Magento\Catalog\Block\Product\AbstractProduct impleme */ protected $_categoryFactory; + /** + * @var \Magento\Core\Helper\PostData + */ + protected $_postDataHelper; + /** * @param Context $context + * @param \Magento\Core\Helper\PostData $postDataHelper * @param \Magento\Catalog\Model\CategoryFactory $categoryFactory * @param \Magento\Catalog\Model\Layer $catalogLayer * @param array $data @@ -77,6 +83,7 @@ class ListProduct extends \Magento\Catalog\Block\Product\AbstractProduct impleme */ public function __construct( \Magento\Catalog\Block\Product\Context $context, + \Magento\Core\Helper\PostData $postDataHelper, \Magento\Catalog\Model\CategoryFactory $categoryFactory, \Magento\Catalog\Model\Layer $catalogLayer, array $data = array(), @@ -84,6 +91,7 @@ public function __construct( ) { $this->_categoryFactory = $categoryFactory; $this->_catalogLayer = $catalogLayer; + $this->_postDataHelper = $postDataHelper; parent::__construct( $context, $data, @@ -332,4 +340,20 @@ public function getIdentities() } return array_merge($this->getLayer()->getCurrentCategory()->getIdentities(), $identities); } + + /** + * Get post parameters + * + * @param \Magento\Catalog\Model\Product $product + * @return string + */ + public function getAddToCartPostParams(\Magento\Catalog\Model\Product $product) + { + $url = $this->getAddToCartUrl($product); + $data = [ + 'product' => $product->getEntityId(), + \Magento\App\Action\Action::PARAM_NAME_URL_ENCODED => $this->_postDataHelper->getEncodedUrl($url) + ]; + return $this->_postDataHelper->getPostData($url, $data); + } } diff --git a/app/code/Magento/Catalog/Block/Product/ProductList/Promotion.php b/app/code/Magento/Catalog/Block/Product/ProductList/Promotion.php index 7a1691fae5e9f..72b6d870be933 100644 --- a/app/code/Magento/Catalog/Block/Product/ProductList/Promotion.php +++ b/app/code/Magento/Catalog/Block/Product/ProductList/Promotion.php @@ -46,6 +46,7 @@ class Promotion extends \Magento\Catalog\Block\Product\ListProduct /** * @param \Magento\Catalog\Block\Product\Context $context + * @param \Magento\Core\Helper\PostData $postDataHelper * @param \Magento\Catalog\Model\CategoryFactory $categoryFactory * @param \Magento\Catalog\Model\Layer\Category $catalogLayer * @param \Magento\Catalog\Model\LayerFactory $layerFactory @@ -55,6 +56,7 @@ class Promotion extends \Magento\Catalog\Block\Product\ListProduct */ public function __construct( \Magento\Catalog\Block\Product\Context $context, + \Magento\Core\Helper\PostData $postDataHelper, \Magento\Catalog\Model\CategoryFactory $categoryFactory, \Magento\Catalog\Model\Layer\Category $catalogLayer, \Magento\Catalog\Model\LayerFactory $layerFactory, @@ -66,6 +68,7 @@ public function __construct( $this->_productCollectionFactory = $productCollectionFactory; parent::__construct( $context, + $postDataHelper, $categoryFactory, $catalogLayer, $data, diff --git a/app/code/Magento/Catalog/Block/Product/ProductList/Random.php b/app/code/Magento/Catalog/Block/Product/ProductList/Random.php index bd6263e11faba..0f953016224d9 100644 --- a/app/code/Magento/Catalog/Block/Product/ProductList/Random.php +++ b/app/code/Magento/Catalog/Block/Product/ProductList/Random.php @@ -48,6 +48,7 @@ class Random extends \Magento\Catalog\Block\Product\ListProduct /** * @param \Magento\Catalog\Block\Product\Context $context + * @param \Magento\Core\Helper\PostData $postDataHelper * @param \Magento\Catalog\Model\CategoryFactory $categoryFactory * @param \Magento\Catalog\Model\Layer\Category $catalogLayer * @param \Magento\Catalog\Model\LayerFactory $layerFactory @@ -57,6 +58,7 @@ class Random extends \Magento\Catalog\Block\Product\ListProduct */ public function __construct( \Magento\Catalog\Block\Product\Context $context, + \Magento\Core\Helper\PostData $postDataHelper, \Magento\Catalog\Model\CategoryFactory $categoryFactory, \Magento\Catalog\Model\Layer\Category $catalogLayer, \Magento\Catalog\Model\LayerFactory $layerFactory, @@ -68,6 +70,7 @@ public function __construct( $this->_productCollectionFactory = $productCollectionFactory; parent::__construct( $context, + $postDataHelper, $categoryFactory, $catalogLayer, $data, diff --git a/app/code/Magento/Catalog/Block/Product/Widget/Link.php b/app/code/Magento/Catalog/Block/Product/Widget/Link.php index c29f71ffdf16c..7d0e2c81d98ab 100644 --- a/app/code/Magento/Catalog/Block/Product/Widget/Link.php +++ b/app/code/Magento/Catalog/Block/Product/Widget/Link.php @@ -37,13 +37,13 @@ class Link extends \Magento\Catalog\Block\Widget\Link { /** * @param \Magento\View\Element\Template\Context $context - * @param \Magento\Core\Model\Resource\Url\Rewrite $urlRewrite + * @param \Magento\UrlRewrite\Model\Resource\UrlRewrite $urlRewrite * @param \Magento\Catalog\Model\Resource\Product $catalogProduct * @param array $data */ public function __construct( \Magento\View\Element\Template\Context $context, - \Magento\Core\Model\Resource\Url\Rewrite $urlRewrite, + \Magento\UrlRewrite\Model\Resource\UrlRewrite $urlRewrite, \Magento\Catalog\Model\Resource\Product $catalogProduct, array $data = array() ) { diff --git a/app/code/Magento/Catalog/Block/Widget/Link.php b/app/code/Magento/Catalog/Block/Widget/Link.php index bc9e505c04dcb..6ae1edb11ca4f 100644 --- a/app/code/Magento/Catalog/Block/Widget/Link.php +++ b/app/code/Magento/Catalog/Block/Widget/Link.php @@ -58,18 +58,18 @@ class Link extends \Magento\View\Element\Html\Link implements \Magento\Widget\Bl /** * Url rewrite * - * @var \Magento\Core\Model\Resource\Url\Rewrite + * @var \Magento\UrlRewrite\Model\Resource\UrlRewrite */ protected $_urlRewrite; /** * @param \Magento\View\Element\Template\Context $context - * @param \Magento\Core\Model\Resource\Url\Rewrite $urlRewrite + * @param \Magento\UrlRewrite\Model\Resource\UrlRewrite $urlRewrite * @param array $data */ public function __construct( \Magento\View\Element\Template\Context $context, - \Magento\Core\Model\Resource\Url\Rewrite $urlRewrite, + \Magento\UrlRewrite\Model\Resource\UrlRewrite $urlRewrite, array $data = array() ) { $this->_urlRewrite = $urlRewrite; diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Initialization/Helper.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Initialization/Helper.php index 2933066822797..f3ae7d5a42c97 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Initialization/Helper.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Initialization/Helper.php @@ -30,11 +30,6 @@ class Helper */ protected $request; - /** - * @var \Magento\Backend\Helper\Js - */ - protected $jsHelper; - /** * @var \Magento\Core\Model\StoreManagerInterface */ @@ -52,20 +47,17 @@ class Helper /** * @param \Magento\App\RequestInterface $request - * @param \Magento\Backend\Helper\Js $jsHelper * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param StockDataFilter $stockFilter * @param Helper\ProductLinks $productLinks */ public function __construct( \Magento\App\RequestInterface $request, - \Magento\Backend\Helper\Js $jsHelper, \Magento\Core\Model\StoreManagerInterface $storeManager, StockDataFilter $stockFilter, Helper\ProductLinks $productLinks ) { $this->request = $request; - $this->jsHelper = $jsHelper; $this->storeManager = $storeManager; $this->stockFilter = $stockFilter; $this->productLinks = $productLinks; diff --git a/app/code/Magento/Catalog/Controller/Product.php b/app/code/Magento/Catalog/Controller/Product.php index 5e04dcf3acce4..2121c09e01165 100644 --- a/app/code/Magento/Catalog/Controller/Product.php +++ b/app/code/Magento/Catalog/Controller/Product.php @@ -57,6 +57,12 @@ protected function _initProductLayout($product) return $this; } + /** + * Product view action + * + * @return void + */ + /** * Product view action * @@ -69,6 +75,19 @@ public function viewAction() $productId = (int)$this->getRequest()->getParam('id'); $specifyOptions = $this->getRequest()->getParam('options'); + if ($this->getRequest()->isPost() && $this->getRequest()->getParam(self::PARAM_NAME_URL_ENCODED)) { + if ($specifyOptions) { + $product = $this->_initProduct(); + if (!$product) { + $this->noProductRedirect(); + } + $notice = $product->getTypeInstance()->getSpecifyOptionMessage(); + $this->messageManager->addNotice($notice); + $this->getResponse()->setRedirect($this->_redirect->getRedirectUrl()); + } + return; + } + // Prepare helper and params /** @var \Magento\Catalog\Helper\Product\View $viewHelper */ $viewHelper = $this->_objectManager->get('Magento\Catalog\Helper\Product\View'); @@ -82,11 +101,7 @@ public function viewAction() $viewHelper->prepareAndRender($productId, $this, $params); } catch (\Exception $e) { if ($e->getCode() == $viewHelper->ERR_NO_PRODUCT_LOADED) { - if (isset($_GET['store']) && !$this->getResponse()->isRedirect()) { - $this->_redirect(''); - } elseif (!$this->getResponse()->isRedirect()) { - $this->_forward('noroute'); - } + $this->noProductRedirect(); } else { $this->_objectManager->get('Magento\Logger')->logException($e); $this->_forward('noroute'); @@ -112,4 +127,18 @@ public function galleryAction() $this->_view->loadLayout(); $this->_view->renderLayout(); } + + /** + * Redirect if product failed to load + * + * @return void + */ + protected function noProductRedirect() + { + if (isset($_GET['store']) && !$this->getResponse()->isRedirect()) { + $this->_redirect(''); + } elseif (!$this->getResponse()->isRedirect()) { + $this->_forward('noroute'); + } + } } diff --git a/app/code/Magento/Catalog/Helper/Product/View.php b/app/code/Magento/Catalog/Helper/Product/View.php index bf67df6afe088..9f4f3b803409f 100644 --- a/app/code/Magento/Catalog/Helper/Product/View.php +++ b/app/code/Magento/Catalog/Helper/Product/View.php @@ -247,11 +247,6 @@ public function prepareAndRender($productId, $controller, $params = null) $this->_eventManager->dispatch('catalog_controller_product_view', array('product' => $product)); - if ($params->getSpecifyOptions()) { - $notice = $product->getTypeInstance()->getSpecifyOptionMessage(); - $this->messageManager->addNotice($notice); - } - $this->_catalogSession->setLastViewedProductId($product->getId()); $this->initProductLayout($product, $controller, $params); diff --git a/app/code/Magento/Catalog/Model/Category.php b/app/code/Magento/Catalog/Model/Category.php index 098d00de30042..bfc2b01f8088d 100644 --- a/app/code/Magento/Catalog/Model/Category.php +++ b/app/code/Magento/Catalog/Model/Category.php @@ -87,7 +87,7 @@ class Category extends \Magento\Catalog\Model\AbstractModel implements \Magento\ /** * URL rewrite model * - * @var \Magento\Core\Model\Url\Rewrite + * @var \Magento\UrlRewrite\Model\UrlRewrite */ protected $_urlRewrite; @@ -150,7 +150,7 @@ class Category extends \Magento\Catalog\Model\AbstractModel implements \Magento\ /** * Url rewrite factory * - * @var \Magento\Core\Model\Url\RewriteFactory + * @var \Magento\UrlRewrite\Model\UrlRewriteFactory */ protected $_urlRewriteFactory; @@ -195,7 +195,7 @@ class Category extends \Magento\Catalog\Model\AbstractModel implements \Magento\ * @param \Magento\Catalog\Model\Resource\Category\Tree $categoryTreeResource * @param \Magento\Catalog\Model\Resource\Category\TreeFactory $categoryTreeFactory * @param \Magento\Catalog\Model\CategoryFactory $categoryFactory - * @param \Magento\Core\Model\Url\RewriteFactory $urlRewriteFactory + * @param \Magento\UrlRewrite\Model\UrlRewriteFactory $urlRewriteFactory * @param \Magento\Core\Model\Resource\Store\CollectionFactory $storeCollectionFactory * @param \Magento\UrlInterface $url * @param \Magento\Catalog\Model\Resource\Product\CollectionFactory $productCollectionFactory @@ -216,7 +216,7 @@ public function __construct( \Magento\Catalog\Model\Resource\Category\Tree $categoryTreeResource, \Magento\Catalog\Model\Resource\Category\TreeFactory $categoryTreeFactory, \Magento\Catalog\Model\CategoryFactory $categoryFactory, - \Magento\Core\Model\Url\RewriteFactory $urlRewriteFactory, + \Magento\UrlRewrite\Model\UrlRewriteFactory $urlRewriteFactory, \Magento\Core\Model\Resource\Store\CollectionFactory $storeCollectionFactory, \Magento\UrlInterface $url, \Magento\Catalog\Model\Resource\Product\CollectionFactory $productCollectionFactory, @@ -301,7 +301,7 @@ public function getUrlInstance() /** * Get url rewrite model * - * @return \Magento\Core\Model\Url\Rewrite + * @return \Magento\UrlRewrite\Model\UrlRewrite */ public function getUrlRewrite() { diff --git a/app/code/Magento/Catalog/Model/Product/Url.php b/app/code/Magento/Catalog/Model/Product/Url.php index 90f2a85d9f2cf..450bb15e7d051 100644 --- a/app/code/Magento/Catalog/Model/Product/Url.php +++ b/app/code/Magento/Catalog/Model/Product/Url.php @@ -48,7 +48,7 @@ class Url extends \Magento\Object /** * Static URL Rewrite Instance * - * @var \Magento\Core\Model\Url\Rewrite + * @var \Magento\UrlRewrite\Model\UrlRewrite */ protected $_urlRewrite; @@ -79,7 +79,7 @@ class Url extends \Magento\Object /** * Construct * - * @param \Magento\Core\Model\Url\RewriteFactory $urlRewriteFactory + * @param \Magento\UrlRewrite\Model\UrlRewriteFactory $urlRewriteFactory * @param \Magento\UrlInterface $url * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\Catalog\Helper\Category $catalogCategory @@ -88,7 +88,7 @@ class Url extends \Magento\Object * @param array $data */ public function __construct( - \Magento\Core\Model\Url\RewriteFactory $urlRewriteFactory, + \Magento\UrlRewrite\Model\UrlRewriteFactory $urlRewriteFactory, \Magento\UrlInterface $url, \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\Catalog\Helper\Category $catalogCategory, @@ -118,7 +118,7 @@ public function getUrlInstance() /** * Retrieve URL Rewrite Instance * - * @return \Magento\Core\Model\Url\Rewrite + * @return \Magento\UrlRewrite\Model\UrlRewrite */ public function getUrlRewrite() { diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Collection.php b/app/code/Magento/Catalog/Model/Resource/Product/Collection.php index aa09cb3ea8785..7296897d6fad3 100644 --- a/app/code/Magento/Catalog/Model/Resource/Product/Collection.php +++ b/app/code/Magento/Catalog/Model/Resource/Product/Collection.php @@ -1224,7 +1224,7 @@ public function joinUrlRewrite() 'core_url_rewrite', 'entity_id=entity_id', array('request_path'), - '{{table}}.type = ' . \Magento\Core\Model\Url\Rewrite::TYPE_PRODUCT, + '{{table}}.type = ' . \Magento\UrlRewrite\Model\UrlRewrite::TYPE_PRODUCT, 'left' ); diff --git a/app/code/Magento/Catalog/Model/System/Config/Backend/Catalog/Url/Rewrite/Suffix.php b/app/code/Magento/Catalog/Model/System/Config/Backend/Catalog/Url/Rewrite/Suffix.php index 79337d55bed23..e1f976875b9e1 100644 --- a/app/code/Magento/Catalog/Model/System/Config/Backend/Catalog/Url/Rewrite/Suffix.php +++ b/app/code/Magento/Catalog/Model/System/Config/Backend/Catalog/Url/Rewrite/Suffix.php @@ -34,7 +34,7 @@ class Suffix extends \Magento\Core\Model\Config\Value /** * Core url rewrite * - * @var \Magento\Core\Helper\Url\Rewrite + * @var \Magento\UrlRewrite\Helper\UrlRewrite */ protected $_coreUrlRewrite = null; @@ -43,7 +43,7 @@ class Suffix extends \Magento\Core\Model\Config\Value * @param \Magento\Registry $registry * @param \Magento\Core\Model\StoreManagerInterface $storeManager * @param \Magento\App\ConfigInterface $config - * @param \Magento\Core\Helper\Url\Rewrite $coreUrlRewrite + * @param \Magento\UrlRewrite\Helper\UrlRewrite $coreUrlRewrite * @param \Magento\Model\Resource\AbstractResource $resource * @param \Magento\Data\Collection\Db $resourceCollection * @param array $data @@ -53,7 +53,7 @@ public function __construct( \Magento\Registry $registry, \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\App\ConfigInterface $config, - \Magento\Core\Helper\Url\Rewrite $coreUrlRewrite, + \Magento\UrlRewrite\Helper\UrlRewrite $coreUrlRewrite, \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() diff --git a/app/code/Magento/Catalog/etc/module.xml b/app/code/Magento/Catalog/etc/module.xml index 7fd7dcedb6ba1..0c029453dbc5b 100644 --- a/app/code/Magento/Catalog/etc/module.xml +++ b/app/code/Magento/Catalog/etc/module.xml @@ -55,6 +55,7 @@ + diff --git a/app/code/Magento/Catalog/view/frontend/js/msrp.js b/app/code/Magento/Catalog/view/frontend/js/msrp.js index b2e34bbf4dce5..893a4db0be247 100644 --- a/app/code/Magento/Catalog/view/frontend/js/msrp.js +++ b/app/code/Magento/Catalog/view/frontend/js/msrp.js @@ -27,15 +27,16 @@ (function($) { $.widget('mage.addToCart', { options: { - showAddToCart: true + showAddToCart: true, + cartForm: '.form.map.checkout' }, _create: function() { - $(document).on('click', this.options.cartButtonId, $.proxy(function() { + $(this.options.cartButtonId).on('click', $.proxy(function() { this._addToCartSubmit(); }, this)); - $(document).on('click', this.options.popupId, $.proxy(function(e) { + $(this.options.popupId).on('click', $.proxy(function(e) { if (this.options.submitUrl) { location.href = this.options.submitUrl; } else { @@ -60,7 +61,7 @@ } }, this)); - $(document).on('click', this.options.helpLinkId, $.proxy(function(e) { + $(this.options.helpLinkId).on('click', $.proxy(function(e) { $('#map-popup-heading').text(this.options.productName); var width = $('#map-popup').width(); var offsetX = e.pageX - (width / 2) + "px"; @@ -71,7 +72,7 @@ return false; }, this)); - $(document).on('click', $.proxy(function() { + $(this.options.closeButtonId).on('click', $.proxy(function() { $('#map-popup').removeClass('active').hide(); return false; }, this)); @@ -81,16 +82,9 @@ _addToCartSubmit: function() { this.element.trigger('addToCart', this.element); if (this.options.addToCartUrl) { - $('#map-popup').hide(); - if (opener) { - opener.location.href = this.options.addToCartUrl; - } else { - location.href = this.options.addToCartUrl; - } - - } else if (this.options.cartForm) { - $(this.options.cartForm).submit(); + $(this.options.cartForm).attr('action', this.options.addToCartUrl); } + $(this.options.cartForm).submit(); } }); })(jQuery); diff --git a/app/code/Magento/Catalog/view/frontend/product/list.phtml b/app/code/Magento/Catalog/view/frontend/product/list.phtml index 14c557c4304c2..5264ade8919ea 100644 --- a/app/code/Magento/Catalog/view/frontend/product/list.phtml +++ b/app/code/Magento/Catalog/view/frontend/product/list.phtml @@ -84,21 +84,10 @@ $imageBlock = $this->getLayout()->createBlock('Magento\Catalog\Block\Product\Im
>
> isSaleable()): ?> - getTypeInstance()->hasRequiredOptions($_product)): ?> - - helper('Magento\Core\Helper\PostData'); - $postData = $postDataHelper->getPostData($this->getAddToCartUrl($_product), ['product' => $_product->getEntityId()]); - ?> - - getIsSalable()): ?>

diff --git a/app/code/Magento/Cms/etc/frontend/di.xml b/app/code/Magento/Cms/etc/frontend/di.xml index 2ac676bafd359..59cdf039bb243 100644 --- a/app/code/Magento/Cms/etc/frontend/di.xml +++ b/app/code/Magento/Cms/etc/frontend/di.xml @@ -28,7 +28,7 @@ - Magento\Cms\Controller\Router + Magento\Cms\Controller\Router false 60 diff --git a/app/code/Magento/Cms/etc/module.xml b/app/code/Magento/Cms/etc/module.xml index 8ef60e63dd0bf..892237ac4f7aa 100644 --- a/app/code/Magento/Cms/etc/module.xml +++ b/app/code/Magento/Cms/etc/module.xml @@ -27,6 +27,7 @@ + diff --git a/app/code/Magento/ConfigurableProduct/Block/Product/View/Type/Configurable.php b/app/code/Magento/ConfigurableProduct/Block/Product/View/Type/Configurable.php index 2d9df1edd2935..f3b9038865694 100644 --- a/app/code/Magento/ConfigurableProduct/Block/Product/View/Type/Configurable.php +++ b/app/code/Magento/ConfigurableProduct/Block/Product/View/Type/Configurable.php @@ -120,7 +120,6 @@ public function __construct( $data, $priceBlockTypes ); - $this->_isScopePrivate = true; } /** diff --git a/app/code/Magento/Core/App/FrontController/Plugin/MessageBox.php b/app/code/Magento/Core/App/FrontController/Plugin/MessageBox.php index a6fe711e97afb..be03ba0abfc95 100644 --- a/app/code/Magento/Core/App/FrontController/Plugin/MessageBox.php +++ b/app/code/Magento/Core/App/FrontController/Plugin/MessageBox.php @@ -57,7 +57,7 @@ class MessageBox protected $config; /** - * @var \Magento\Message\ManagerInterface + * @var \Magento\Message\Manager */ protected $messageManager; @@ -90,20 +90,9 @@ public function __construct( */ public function afterDispatch(\Magento\App\FrontController $subject, \Magento\App\ResponseInterface $response) { - if ($this->request->isPost() && $this->config->isEnabled() && $this->hasMessages()) { + if ($this->request->isPost() && $this->config->isEnabled() && $this->messageManager->hasMessages()) { $this->cookie->set(self::COOKIE_NAME, 1, self::COOKIE_PERIOD, '/'); } return $response; } - - /** - * Returns true if there are any messages for customer, - * false - in other case - * - * @return bool - */ - protected function hasMessages() - { - return ($this->messageManager->getMessages()->getCount() > 0); - } } diff --git a/app/code/Magento/Core/Helper/Js.php b/app/code/Magento/Core/Helper/Js.php deleted file mode 100644 index d5d2c51e8b6a6..0000000000000 --- a/app/code/Magento/Core/Helper/Js.php +++ /dev/null @@ -1,467 +0,0 @@ - - * - * Magento - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-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 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\Core\Helper; - -class Js extends \Magento\App\Helper\AbstractHelper -{ - /** - * Array of sentences of JS translations - * - * @var array - */ - protected $_translateData = []; - - /** - * @var \Magento\View\Url - */ - protected $_viewUrl; - - /** - * @param \Magento\App\Helper\Context $context - * @param \Magento\View\Url $viewUrl - */ - public function __construct( - \Magento\App\Helper\Context $context, - \Magento\View\Url $viewUrl - ) { - parent::__construct($context); - $this->_viewUrl = $viewUrl; - } - - /** - * Retrieve JS translator initialization javascript - * - * @return string - */ - public function getTranslatorScript() - { - $script = '(function($) {$.mage.translate.add(' - . $this->encode($this->getTranslateData()) - . ')})(jQuery);'; - return $this->getScript($script); - } - - /** - * Retrieve framed javascript - * - * @param string $script - * @return string - */ - public function getScript($script) - { - return ''; - } - - /** - * Retrieve javascript include code - * - * @param string $file - * @return string - */ - public function includeScript($file) - { - return '' . "\n"; - } - - /** - * Retrieve JS translation array - * - * @return array - */ - public function getTranslateData() - { - if (!$this->_translateData) { - $this->_populateTranslateData(); - } - return $this->_translateData; - } - - /** - * Helper function that populates _translateData with default values. - * - * @return void - * @SuppressWarnings(PHPMD) - */ - protected function _populateTranslateData() - { - // @codingStandardsIgnoreStart - //flexuploader.js - $this->_addTranslation('Complete', __('Complete')); - $this->_addTranslation('Upload Security Error', __('Upload Security Error')); - $this->_addTranslation('Upload HTTP Error', __('Upload HTTP Error')); - $this->_addTranslation('Upload I/O Error', __('Upload I/O Error')); - $this->_addTranslation( - 'SSL Error: Invalid or self-signed certificate', - __('SSL Error: Invalid or self-signed certificate') - ); - $this->_addTranslation('TB', __('TB')); - $this->_addTranslation('GB', __('GB')); - $this->_addTranslation('MB', __('MB')); - $this->_addTranslation('kB', __('kB')); - $this->_addTranslation('B', __('B')); - $this->_addTranslation('Add Products', __('Add Products')); - //addbysku.js - $this->_addTranslation('Add Products By SKU', __('Add Products By SKU')); - $this->_addTranslation('Insert Widget...', __('Insert Widget...')); - //rules.js - $this->_addTranslation('Please wait, loading...', __('Please wait, loading...')); - //validation.js - $this->_addTranslation('HTML tags are not allowed', __('HTML tags are not allowed')); - $this->_addTranslation('Please select an option.', __('Please select an option.')); - $this->_addTranslation('This is a required field.', __('This is a required field.')); - $this->_addTranslation( - 'Please enter a valid number in this field.', - __('Please enter a valid number in this field.') - ); - $this->_addTranslation( - 'The value is not within the specified range.', - __('The value is not within the specified range.') - ); - $this->_addTranslation( - 'Please use numbers only in this field. Please avoid spaces or other characters such as dots or commas.', - __( - 'Please use numbers only in this field. Please avoid spaces or other characters such as dots or commas.' - ) - ); - $this->_addTranslation( - 'Please use letters only (a-z or A-Z) in this field.', - __('Please use letters only (a-z or A-Z) in this field.') - ); - $this->_addTranslation( - 'Please use only letters (a-z), numbers (0-9) or underscore(_) in this field, first character should be a letter.', - __( - 'Please use only letters (a-z), numbers (0-9) or underscore(_) in this field, first character should be a letter.' - ) - ); - $this->_addTranslation( - 'Please use only letters (a-z or A-Z) or numbers (0-9) only in this field. No spaces or other characters are allowed.', - __( - 'Please use only letters (a-z or A-Z) or numbers (0-9) only in this field. No spaces or other characters are allowed.' - ) - ); - $this->_addTranslation( - 'Please use only letters (a-z or A-Z) or numbers (0-9) or spaces and # only in this field.', - __('Please use only letters (a-z or A-Z) or numbers (0-9) or spaces and # only in this field.') - ); - $this->_addTranslation( - 'Please enter a valid fax number. For example (123) 456-7890 or 123-456-7890.', - __('Please enter a valid fax number. For example (123) 456-7890 or 123-456-7890.') - ); - $this->_addTranslation('Please enter a valid date.', __('Please enter a valid date.')); - $this->_addTranslation( - 'The From Date value should be less than or equal to the To Date value.', - __('The From Date value should be less than or equal to the To Date value.') - ); - $this->_addTranslation( - 'Please enter a valid email address. For example johndoe@domain.com.', - __('Please enter a valid email address. For example johndoe@domain.com.') - ); - $this->_addTranslation( - 'Please use only visible characters and spaces.', - __('Please use only visible characters and spaces.') - ); - $this->_addTranslation( - 'Please enter 6 or more characters. Leading or trailing spaces will be ignored.', - __('Please enter 6 or more characters. Leading or trailing spaces will be ignored.') - ); - $this->_addTranslation( - 'Please enter 7 or more characters. Password should contain both numeric and alphabetic characters.', - __('Please enter 7 or more characters. Password should contain both numeric and alphabetic characters.') - ); - $this->_addTranslation('Please make sure your passwords match.', __('Please make sure your passwords match.')); - $this->_addTranslation( - 'Please enter a valid URL. Protocol is required (http://, https:// or ftp://)', - __('Please enter a valid URL. Protocol is required (http://, https:// or ftp://)') - ); - $this->_addTranslation( - 'Please enter a valid URL Key. For example "example-page", "example-page.html" or "anotherlevel/example-page".', - __( - 'Please enter a valid URL Key. For example "example-page", "example-page.html" or "anotherlevel/example-page".' - ) - ); - $this->_addTranslation( - 'Please enter a valid XML-identifier. For example something_1, block5, id-4.', - __('Please enter a valid XML-identifier. For example something_1, block5, id-4.') - ); - $this->_addTranslation( - 'Please enter a valid social security number. For example 123-45-6789.', - __('Please enter a valid social security number. For example 123-45-6789.') - ); - $this->_addTranslation( - 'Please enter a valid zip code. For example 90602 or 90602-1234.', - __('Please enter a valid zip code. For example 90602 or 90602-1234.') - ); - $this->_addTranslation('Please enter a valid zip code.', __('Please enter a valid zip code.')); - $this->_addTranslation( - 'Please use this date format: dd/mm/yyyy. For example 17/03/2006 for the 17th of March, 2006.', - __('Please use this date format: dd/mm/yyyy. For example 17/03/2006 for the 17th of March, 2006.') - ); - $this->_addTranslation( - 'Please select one of the above options.', - __('Please select one of the above options.') - ); - $this->_addTranslation('Please select one of the options.', __('Please select one of the options.')); - $this->_addTranslation('Please select State/Province.', __('Please select State/Province.')); - $this->_addTranslation( - 'Please enter a number greater than 0 in this field.', - __('Please enter a number greater than 0 in this field.') - ); - $this->_addTranslation( - 'Please enter a number 0 or greater in this field.', - __('Please enter a number 0 or greater in this field.') - ); - $this->_addTranslation( - 'Please enter a valid credit card number.', - __('Please enter a valid credit card number.') - ); - $this->_addTranslation( - 'Credit card number does not match credit card type.', - __('Credit card number does not match credit card type.') - ); - $this->_addTranslation( - 'Card type does not match credit card number.', - __('Card type does not match credit card number.') - ); - $this->_addTranslation('Incorrect credit card expiration date.', __('Incorrect credit card expiration date.')); - $this->_addTranslation( - 'Please enter a valid credit card verification number.', - __('Please enter a valid credit card verification number.') - ); - $this->_addTranslation( - 'Please use only letters (a-z or A-Z), numbers (0-9) or underscore(_) in this field, first character should be a letter.', - __( - 'Please use only letters (a-z or A-Z), numbers (0-9) or underscore(_) in this field, first character should be a letter.' - ) - ); - $this->_addTranslation( - 'Please input a valid CSS-length. For example 100px or 77pt or 20em or .5ex or 50%.', - __('Please input a valid CSS-length. For example 100px or 77pt or 20em or .5ex or 50%.') - ); - $this->_addTranslation( - 'Text length does not satisfy specified text range.', - __('Text length does not satisfy specified text range.') - ); - $this->_addTranslation('Please enter a number lower than 100.', __('Please enter a number lower than 100.')); - $this->_addTranslation('Please select a file', __('Please select a file')); - $this->_addTranslation( - 'Please enter issue number or start date for switch/solo card type.', - __('Please enter issue number or start date for switch/solo card type.') - ); - //js.js - $this->_addTranslation('This date is a required value.', __('This date is a required value.')); - $this->_addTranslation('Please enter a valid day (1-%1).', __('Please enter a valid day (1-%1).')); - $this->_addTranslation('Please enter a valid month (1-12).', __('Please enter a valid month (1-12).')); - $this->_addTranslation('Please enter a valid year (1900-%1).', __('Please enter a valid year (1900-%1).')); - $this->_addTranslation('Please enter a valid full date', __('Please enter a valid full date')); - //various files - $this->_addTranslation('Allow', __('Allow')); - $this->_addTranslation('Activate', __('Activate')); - $this->_addTranslation('Reauthorize', __('Reauthorize')); - $this->_addTranslation('Cancel', __('Cancel')); - $this->_addTranslation('Done', __('Done')); - $this->_addTranslation('Save', __('Save')); - $this->_addTranslation( - 'File extension not known or unsupported type.', - __('File extension not known or unsupported type.') - ); - $this->_addTranslation('Configure Product', __('Configure Product')); - $this->_addTranslation('OK', __('OK')); - $this->_addTranslation('Gift Options for ', __('Gift Options for ')); - $this->_addTranslation('New Option', __('New Option')); - $this->_addTranslation('Add Products to New Option', __('Add Products to New Option')); - $this->_addTranslation('Add Products to Option "%1"', __('Add Products to Option "%1"')); - $this->_addTranslation('Add Selected Products', __('Add Selected Products')); - $this->_addTranslation('Select type of option.', __('Select type of option.')); - $this->_addTranslation('Please add rows to option.', __('Please add rows to option.')); - $this->_addTranslation('Select Product', __('Select Product')); - $this->_addTranslation('Import', __('Import')); - $this->_addTranslation('Please select items.', __('Please select items.')); - $this->_addTranslation('Add Products to Group', __('Add Products to Group')); - $this->_addTranslation('start typing to search category', __('start typing to search category')); - $this->_addTranslation('Choose existing category.', __('Choose existing category.')); - $this->_addTranslation('Create Category', __('Create Category')); - $this->_addTranslation('Sorry, there was an unknown error.', __('Sorry, there was an unknown error.')); - $this->_addTranslation( - 'Something went wrong while loading the theme.', - __('Something went wrong while loading the theme.') - ); - $this->_addTranslation( - 'We don\'t recognize or support this file extension type.', - __('We don\'t recognize or support this file extension type.') - ); - $this->_addTranslation('Error', __('Error')); - $this->_addTranslation('No stores were reassigned.', __('No stores were reassigned.')); - $this->_addTranslation('Assign theme to your live store-view:', __('Assign theme to your live store-view:')); - $this->_addTranslation('Default title', __('Default title')); - $this->_addTranslation( - 'The URL to assign stores is not defined.', - __('The URL to assign stores is not defined.') - ); - $this->_addTranslation('No', __('No')); - $this->_addTranslation('Yes', __('Yes')); - $this->_addTranslation('Some problem with revert action', __('Some problem with revert action')); - $this->_addTranslation('Error: unknown error.', __('Error: unknown error.')); - $this->_addTranslation('Some problem with save action', __('Some problem with save action')); - $this->_addTranslation('Delete', __('Delete')); - $this->_addTranslation('Folder', __('Folder')); - $this->_addTranslation('Delete Folder', __('Delete Folder')); - $this->_addTranslation( - 'Are you sure you want to delete the folder named', - __('Are you sure you want to delete the folder named') - ); - $this->_addTranslation('Delete File', __('Delete File')); - $this->_addTranslation('Method ', __('Method ')); - $this->_addTranslation('Please wait...', __('Please wait...')); - $this->_addTranslation('Loading...', __('Loading...')); - $this->_addTranslation('Translate', __('Translate')); - $this->_addTranslation('Submit', __('Submit')); - $this->_addTranslation('Close', __('Close')); - $this->_addTranslation( - 'Please enter a value less than or equal to %s.', - __('Please enter a value less than or equal to %s.') - ); - $this->_addTranslation( - 'Please enter a value greater than or equal to %s.', - __('Please enter a value greater than or equal to %s.') - ); - $this->_addTranslation( - 'Maximum length of this field must be equal or less than %1 symbols.', - __('Maximum length of this field must be equal or less than %1 symbols.') - ); - $this->_addTranslation('No records found.', __('No records found.')); - $this->_addTranslation('Recent items', __('Recent items')); - $this->_addTranslation('Show all...', __('Show all...')); - $this->_addTranslation('Please enter a date in the past.', __('Please enter a date in the past.')); - $this->_addTranslation( - 'Please enter a date between %min and %max.', - __('Please enter a date between %min and %max.') - ); - // opcheckout.js - $this->_addTranslation( - 'Please choose to register or to checkout as a guest.', - __('Please choose to register or to checkout as a guest.') - ); - $this->_addTranslation( - 'We are not able to ship to the selected shipping address. Please choose another address or edit the current address.', - __( - 'We are not able to ship to the selected shipping address. Please choose another address or edit the current address.' - ) - ); - $this->_addTranslation('Please specify a shipping method.', __('Please specify a shipping method.')); - // opcheckout.js and payment.js - $this->_addTranslation( - 'We can\'t complete your order because you don\'t have a payment method available.', - __('We can\'t complete your order because you don\'t have a payment method available.') - ); - //multiple-wishlist.js - $this->_addTranslation( - 'Error happened while creating wishlist. Please try again later', - __('Error happened while creating wishlist. Please try again later') - ); - $this->_addTranslation('You must select items to move', __('You must select items to move')); - $this->_addTranslation('You must select items to copy', __('You must select items to copy')); - $this->_addTranslation( - 'You are about to delete your wish list. This action cannot be undone. Are you sure you want to continue?', - __( - 'You are about to delete your wish list. This action cannot be undone. Are you sure you want to continue?' - ) - ); - //various files - $this->_addTranslation('Please specify payment method.', __('Please specify payment method.')); - $this->_addTranslation( - 'Are you sure you want to delete this address?', - __('Are you sure you want to delete this address?') - ); - $this->_addTranslation('Use gift registry shipping address', __('Use gift registry shipping address')); - $this->_addTranslation( - 'You can change the number of gift registry items on the Gift Registry Info page or directly in your cart, but not while in checkout.', - __( - 'You can change the number of gift registry items on the Gift Registry Info page or directly in your cart, but not while in checkout.' - ) - ); - $this->_addTranslation('No confirmation', __('No confirmation')); - $this->_addTranslation('Sorry, something went wrong.', __('Sorry, something went wrong.')); - $this->_addTranslation( - 'Sorry, something went wrong. Please try again later.', - __('Sorry, something went wrong. Please try again later.') - ); - $this->_addTranslation('select all', __('select all')); - $this->_addTranslation('unselect all', __('unselect all')); - $this->_addTranslation( - 'Please agree to all Terms and Conditions before placing the orders.', - __('Please agree to all Terms and Conditions before placing the orders.') - ); - $this->_addTranslation( - 'Please choose to register or to checkout as a guest', - __('Please choose to register or to checkout as a guest') - ); - $this->_addTranslation( - 'Your order cannot be completed at this time as there is no shipping methods available for it. Please make necessary changes in your shipping address.', - __( - 'Your order cannot be completed at this time as there is no shipping methods available for it. Please make necessary changes in your shipping address.' - ) - ); - $this->_addTranslation('Please specify shipping method.', __('Please specify shipping method.')); - $this->_addTranslation( - 'Your order cannot be completed at this time as there is no payment methods available for it.', - __('Your order cannot be completed at this time as there is no payment methods available for it.') - ); - // @codingStandardsIgnoreEnd - } - - /** - * Adds some translated text to the translated data array as long as the key and text don't match. - * - * There is no point in having translated text added if the key is already representing the translated text. - * - * @param string $key - * @param string $translatedText - * @return void - */ - protected function _addTranslation($key, $translatedText) - { - if ($key !== $translatedText) { - $this->_translateData[$key] = $translatedText; - } - } - - /** - * Encode the mixed $data into the JSON format. - * - * @param mixed $data - * @return string - */ - public function encode($data) - { - $json = \Zend_Json::encode($data); - $this->translateInline->processResponseBody($json, false); - return $json; - } -} diff --git a/app/code/Magento/Core/Model/Observer.php b/app/code/Magento/Core/Model/Observer.php index 71041357b0687..c78b282a6a841 100644 --- a/app/code/Magento/Core/Model/Observer.php +++ b/app/code/Magento/Core/Model/Observer.php @@ -47,11 +47,6 @@ class Observer */ private $_pageAssets; - /** - * @var \Magento\App\ReinitableConfigInterface - */ - protected $_config; - /** * @var \Magento\View\Asset\PublicFileFactory */ @@ -71,16 +66,14 @@ class Observer * @param \Magento\App\Cache\Frontend\Pool $cacheFrontendPool * @param \Magento\View\DesignInterface $design * @param \Magento\View\Asset\GroupedCollection $assets - * @param \Magento\App\ReinitableConfigInterface $config * @param \Magento\View\Asset\PublicFileFactory $assetFileFactory - * @param \Magento\Core\Model\Theme\Registration $registration + * @param Theme\Registration $registration * @param \Magento\Logger $logger */ public function __construct( \Magento\App\Cache\Frontend\Pool $cacheFrontendPool, \Magento\View\DesignInterface $design, \Magento\View\Asset\GroupedCollection $assets, - \Magento\App\ReinitableConfigInterface $config, \Magento\View\Asset\PublicFileFactory $assetFileFactory, \Magento\Core\Model\Theme\Registration $registration, \Magento\Logger $logger @@ -88,7 +81,6 @@ public function __construct( $this->_cacheFrontendPool = $cacheFrontendPool; $this->_currentTheme = $design->getDesignTheme(); $this->_pageAssets = $assets; - $this->_config = $config; $this->_assetFileFactory = $assetFileFactory; $this->_registration = $registration; $this->_logger = $logger; @@ -151,17 +143,4 @@ public function applyThemeCustomization(\Magento\Event\Observer $observer) } } } - - /** - * Rebuild whole config and save to fast storage - * - * @param \Magento\Event\Observer $observer - * @return $this - * @SuppressWarnings(PHPMD.UnusedFormalParameter) - */ - public function processReinitConfig(\Magento\Event\Observer $observer) - { - $this->_config->reinit(); - return $this; - } } diff --git a/app/code/Magento/Core/Model/Resource/Setup.php b/app/code/Magento/Core/Model/Resource/Setup.php index 81e942c86d421..3b44ad4407c2b 100644 --- a/app/code/Magento/Core/Model/Resource/Setup.php +++ b/app/code/Magento/Core/Model/Resource/Setup.php @@ -93,7 +93,7 @@ class Setup implements \Magento\Module\Updater\SetupInterface protected $_logger; /** - * @var \Magento\Core\Model\Resource\Resource + * @var \Magento\Module\ResourceInterface */ protected $_resourceResource; diff --git a/app/code/Magento/Core/Model/Resource/Setup/Context.php b/app/code/Magento/Core/Model/Resource/Setup/Context.php index 264f1078dfd1a..961117209e067 100644 --- a/app/code/Magento/Core/Model/Resource/Setup/Context.php +++ b/app/code/Magento/Core/Model/Resource/Setup/Context.php @@ -51,7 +51,7 @@ class Context implements \Magento\ObjectManager\ContextInterface protected $_moduleList; /** - * @var \Magento\Core\Model\Resource\Resource + * @var \Magento\Module\ResourceInterface */ protected $_resourceResource; @@ -88,7 +88,7 @@ class Context implements \Magento\ObjectManager\ContextInterface * @param \Magento\App\Resource $resource * @param \Magento\Module\Dir\Reader $modulesReader * @param \Magento\Module\ModuleListInterface $moduleList - * @param \Magento\Core\Model\Resource\Resource $resourceResource + * @param \Magento\Module\ResourceInterface $resourceResource * @param MigrationFactory $migrationFactory * @param \Magento\Core\Model\Resource\Theme\CollectionFactory $themeResourceFactory * @param \Magento\Core\Model\Theme\CollectionFactory $themeFactory @@ -101,7 +101,7 @@ public function __construct( \Magento\App\Resource $resource, \Magento\Module\Dir\Reader $modulesReader, \Magento\Module\ModuleListInterface $moduleList, - \Magento\Core\Model\Resource\Resource $resourceResource, + \Magento\Module\ResourceInterface $resourceResource, \Magento\Core\Model\Resource\Setup\MigrationFactory $migrationFactory, \Magento\Core\Model\Resource\Theme\CollectionFactory $themeResourceFactory, \Magento\Core\Model\Theme\CollectionFactory $themeFactory, @@ -170,7 +170,7 @@ public function getMigrationFactory() } /** - * @return \Magento\Core\Model\Resource\Resource + * @return \Magento\Module\ResourceInterface */ public function getResourceResource() { diff --git a/app/code/Magento/Core/etc/config.xml b/app/code/Magento/Core/etc/config.xml index 11793f11b492a..66381b948fda5 100644 --- a/app/code/Magento/Core/etc/config.xml +++ b/app/code/Magento/Core/etc/config.xml @@ -165,9 +165,6 @@ 0 1 - - 0 - {{base_url}} {{unsecure_base_url}} diff --git a/app/code/Magento/Core/etc/di.xml b/app/code/Magento/Core/etc/di.xml index 5bc0bd73fdca1..ad2b39457f71c 100644 --- a/app/code/Magento/Core/etc/di.xml +++ b/app/code/Magento/Core/etc/di.xml @@ -266,7 +266,7 @@ - Magento\Core\App\Router\NoRouteHandler + Magento\Core\App\Router\NoRouteHandler 100 @@ -444,7 +444,6 @@ - diff --git a/app/code/Magento/Core/etc/events.xml b/app/code/Magento/Core/etc/events.xml index 16f7814f39459..6ccdf7f1a9f0d 100644 --- a/app/code/Magento/Core/etc/events.xml +++ b/app/code/Magento/Core/etc/events.xml @@ -33,7 +33,4 @@ - - - diff --git a/app/code/Magento/Core/etc/frontend/di.xml b/app/code/Magento/Core/etc/frontend/di.xml index e7eb880db17c8..95377dec5279f 100644 --- a/app/code/Magento/Core/etc/frontend/di.xml +++ b/app/code/Magento/Core/etc/frontend/di.xml @@ -38,7 +38,6 @@ - @@ -48,12 +47,12 @@ - Magento\Core\App\Router\Base + Magento\Core\App\Router\Base false 20 - Magento\App\Router\DefaultRouter + Magento\App\Router\DefaultRouter false 100 diff --git a/app/code/Magento/Core/etc/module.xml b/app/code/Magento/Core/etc/module.xml index 5a4a7db225aea..1c2d659e2c3fe 100644 --- a/app/code/Magento/Core/etc/module.xml +++ b/app/code/Magento/Core/etc/module.xml @@ -30,7 +30,6 @@ - @@ -43,7 +42,6 @@ - diff --git a/app/code/Magento/Core/i18n/de_DE.csv b/app/code/Magento/Core/i18n/de_DE.csv index fc018a13627b3..24650af77d88e 100644 --- a/app/code/Magento/Core/i18n/de_DE.csv +++ b/app/code/Magento/Core/i18n/de_DE.csv @@ -25,7 +25,6 @@ "Anchor Text for Next","Link-Text für Weiter" "Anchor Text for Previous","Link-Text für Zurück" "Anchor symbol (#) is not supported in request path","Das Doppelkreuz (#) wird im Anforderungspfad nicht unterstützt" -"Anchor symbol (#) is not supported in url rewrite suffix","Das Doppelkreuz (#) wird beim URL-Überschreiben-Suffix nicht unterstützt" "Are you sure?","Sind Sie sicher?" "Auto-redirect to Base URL","Automatische Weiterleitung zur Basis-URL" "Back","Zurück" @@ -336,7 +335,6 @@ "Translate, blocks and other output caches should be disabled for both frontend and admin inline translations.","Übersetzen, Blöcke und andere Ausgangs-Caches sollten sowohl für Frontend und Admin-Inline-Übersetzungen deaktiviert werden." "Translations","Übersetzungen" "Two and more slashes together are not permitted in request path","Zwei und mehr zusammenhängende Schrägstriche sind in diesem Pfad nicht zulässig" -"Two and more slashes together are not permitted in url rewrite suffix","Zwei und mehr zusammenhängende Schrägstriche sind im URL-Rewrite-Suffix nicht zulässig" "Unable to create directory: %s","Verzeichnis kann nicht angelegt werden: %s" "Unable to delete store view. Please, try again later.","Dieser StoreView kann nicht gelöscht werden. Versuchen Sie es später noch einmal." "Unable to delete store. Please, try again later.","Shop kann nicht gelöscht werden. Bitte versuchen Sie es später noch einmal." diff --git a/app/code/Magento/Core/i18n/en_US.csv b/app/code/Magento/Core/i18n/en_US.csv index 7f163736c5074..6e480a3fce962 100644 --- a/app/code/Magento/Core/i18n/en_US.csv +++ b/app/code/Magento/Core/i18n/en_US.csv @@ -27,7 +27,6 @@ "Anchor Text for Next","Anchor Text for Next" "Anchor Text for Previous","Anchor Text for Previous" "Anchor symbol (#) is not supported in request path","Anchor symbol (#) is not supported in request path" -"Anchor symbol (#) is not supported in url rewrite suffix","Anchor symbol (#) is not supported in url rewrite suffix" "Are you sure?","Are you sure?" "Auto-redirect to Base URL","Auto-redirect to Base URL" "Back","Back" @@ -337,7 +336,6 @@ "Translate, blocks and other output caches should be disabled for both frontend and admin inline translations.","Translate, blocks and other output caches should be disabled for both frontend and admin inline translations." "Translations","Translations" "Two and more slashes together are not permitted in request path","Two and more slashes together are not permitted in request path" -"Two and more slashes together are not permitted in url rewrite suffix","Two and more slashes together are not permitted in url rewrite suffix" "Unable to create directory: %s","Unable to create directory: %s" "Unable to delete store view. Please, try again later.","Unable to delete store view. Please, try again later." "Unable to delete store. Please, try again later.","Unable to delete store. Please, try again later." diff --git a/app/code/Magento/Core/i18n/es_ES.csv b/app/code/Magento/Core/i18n/es_ES.csv index 80bc314650ad3..94139d20d434d 100644 --- a/app/code/Magento/Core/i18n/es_ES.csv +++ b/app/code/Magento/Core/i18n/es_ES.csv @@ -25,7 +25,6 @@ "Anchor Text for Next","Texto de ancla para página siguiente" "Anchor Text for Previous","Texto de ancla para página anterior" "Anchor symbol (#) is not supported in request path","El símbolo ancla (#) no está soportado en la ruta solicitada" -"Anchor symbol (#) is not supported in url rewrite suffix","El símbolo ancla (#) no está soportado en el sufijo de reescritura de url" "Are you sure?","¿Está seguro?" "Auto-redirect to Base URL","Redireccionar automáticamente a la dirección URL básica" "Back","Volver" @@ -336,7 +335,6 @@ "Translate, blocks and other output caches should be disabled for both frontend and admin inline translations.","Traducir, bloques y otros caches de salida deben ser desactivadso para las traducciones de la parte delantera y de admininstración." "Translations","Traducciones" "Two and more slashes together are not permitted in request path","No se permiten dos o más barras juntas en la linea de solicitud" -"Two and more slashes together are not permitted in url rewrite suffix","No se permiten dos o más barras juntas en el sufijo de la url" "Unable to create directory: %s","No ha sido posible crear el directorio: %s" "Unable to delete store view. Please, try again later.","No se puede eliminar la vista de tienda. Vuelva a intentarlo más tarde." "Unable to delete store. Please, try again later.","No se ha podido borrar la tienda. Por favor, inténtelo de nuevo más tarde." diff --git a/app/code/Magento/Core/i18n/fr_FR.csv b/app/code/Magento/Core/i18n/fr_FR.csv index 7241ea4de0bf5..edb7a3c35446e 100644 --- a/app/code/Magento/Core/i18n/fr_FR.csv +++ b/app/code/Magento/Core/i18n/fr_FR.csv @@ -25,7 +25,6 @@ "Anchor Text for Next","Ancrer texte pour suivant" "Anchor Text for Previous","Ancrer texte pour précédent" "Anchor symbol (#) is not supported in request path","Le symbole d'ancrage (#) n'est pas pris en charge dans la demande de chemin d'accès" -"Anchor symbol (#) is not supported in url rewrite suffix","Le symbole d'ancrage (#) n'est pas pris en charge dans le suffixe de réécriture de l'url" "Are you sure?","Etes-vous sûr ?" "Auto-redirect to Base URL","Redirige automatiquement vers base URL" "Back","Retour" @@ -336,7 +335,6 @@ "Translate, blocks and other output caches should be disabled for both frontend and admin inline translations.","Traductions, blocks et autres sorties doivent être désactivés pour la gestion administrateur et utilisateur en ligne." "Translations","Traductions" "Two and more slashes together are not permitted in request path","Deux slashs ou plus ne sont pas autorisés ensemble dans le répertoire" -"Two and more slashes together are not permitted in url rewrite suffix","Deux slashs ou plus ne sont pas autorisés dans le suffixe de réécriture de l'URL" "Unable to create directory: %s","Impossible de créer le répertoire : %s" "Unable to delete store view. Please, try again later.","Incapable d'effacer la vue de boutique. Veuillez réessayer plus tard." "Unable to delete store. Please, try again later.","Impossible de supprimer le magasin. Veuillez réessayer plus tard." diff --git a/app/code/Magento/Core/i18n/nl_NL.csv b/app/code/Magento/Core/i18n/nl_NL.csv index 010635982200c..5780032ec7371 100644 --- a/app/code/Magento/Core/i18n/nl_NL.csv +++ b/app/code/Magento/Core/i18n/nl_NL.csv @@ -25,7 +25,6 @@ "Anchor Text for Next","Ankertekst voor Volgende" "Anchor Text for Previous","Ankertekst voor Vorige" "Anchor symbol (#) is not supported in request path","Ankersymbool (#) wordt niet ondersteund in gevraagd pad" -"Anchor symbol (#) is not supported in url rewrite suffix","Anker symbool (#) is niet ondersteund in URL herschrijvings toevoeging" "Are you sure?","Weet u het zeker" "Auto-redirect to Base URL","Stuur automatisch door naar basis URL" "Back","terug" @@ -336,7 +335,6 @@ "Translate, blocks and other output caches should be disabled for both frontend and admin inline translations.","Vertalingen, blokken en andere uitvoer zouden uitgeschakeld moeten zijn voor zowel front-end en administrator inline vertalingen." "Translations","Vertalingen" "Two and more slashes together are not permitted in request path","Twee of meer schuine strepen zijn niet toegestaan in gevraagde pad." -"Two and more slashes together are not permitted in url rewrite suffix","Twee of meer schuine strepen zijn niet toegestaan in URL herschrijvings navoeging" "Unable to create directory: %s","Niet in staat om directory %s te maken" "Unable to delete store view. Please, try again later.","Niet instaat om het winkelzicht te verwijderen. Probeer het later nogmaals." "Unable to delete store. Please, try again later.","Kan de winkel niet verwijderen. Probeer het later nog eens a.u.b." diff --git a/app/code/Magento/Core/i18n/pt_BR.csv b/app/code/Magento/Core/i18n/pt_BR.csv index 1f9bfa9d64f3e..0008f040aac75 100644 --- a/app/code/Magento/Core/i18n/pt_BR.csv +++ b/app/code/Magento/Core/i18n/pt_BR.csv @@ -27,7 +27,6 @@ local até que o processo de sincronização esteja completo." "Anchor Text for Next","Texto Âncora para Seguinte" "Anchor Text for Previous","Texto Âncora para Anterior" "Anchor symbol (#) is not supported in request path","Símbolo âncora (#) não é suportado no caminho pedido" -"Anchor symbol (#) is not supported in url rewrite suffix","Símbolo âncora (#) não é suportado no sufixo url reescrito" "Are you sure?","Tem certeza?" "Auto-redirect to Base URL","Auto-redirecionado para URL Base" "Back","Voltar" @@ -338,7 +337,6 @@ local até que o processo de sincronização esteja completo." "Translate, blocks and other output caches should be disabled for both frontend and admin inline translations.","Traduzir, blocos e outras caches de saída devem ser desativadas para ambos os frontend e traduções em linha admin." "Translations","Traduções" "Two and more slashes together are not permitted in request path","Duas ou mais barras juntas não são permitidas no caminho pedido" -"Two and more slashes together are not permitted in url rewrite suffix","Duas ou mais barras juntas não são permitidas em sufixo url reescrito" "Unable to create directory: %s","Não é possível criar diretório: %s" "Unable to delete store view. Please, try again later.","Não é possível excluir a vista da loja. Por favor, tente novamente mais tarde." "Unable to delete store. Please, try again later.","Não é possível apagar loja. Por favor, tente novamente mais tarde." diff --git a/app/code/Magento/Core/i18n/zh_CN.csv b/app/code/Magento/Core/i18n/zh_CN.csv index 042555f0eed05..89f40124a8e8c 100644 --- a/app/code/Magento/Core/i18n/zh_CN.csv +++ b/app/code/Magento/Core/i18n/zh_CN.csv @@ -25,7 +25,6 @@ "Anchor Text for Next","下一个的锚点文字" "Anchor Text for Previous","上一个的锚点文字" "Anchor symbol (#) is not supported in request path","锚点符号(#)不能用于请求路径中" -"Anchor symbol (#) is not supported in url rewrite suffix","URL 重写后缀不支持固定标志 (#)" "Are you sure?","您是否确认?" "Auto-redirect to Base URL","自定重定向到基本 URL" "Back","返回" @@ -336,7 +335,6 @@ "Translate, blocks and other output caches should be disabled for both frontend and admin inline translations.","对于前端和管理员内嵌翻译,翻译区块和其它输出缓存应被禁用。" "Translations","翻译" "Two and more slashes together are not permitted in request path","两个或更多斜杠在请求的路径中不被允许" -"Two and more slashes together are not permitted in url rewrite suffix","两个或更多斜杠在 URL 重写后缀中不被允许" "Unable to create directory: %s","无法创建目录:%s" "Unable to delete store view. Please, try again later.","无法删除商店视图。请稍后重试。" "Unable to delete store. Please, try again later.","无法删除商店。请稍后重试。" diff --git a/app/code/Magento/Core/sql/core_setup/install-1.6.0.0.php b/app/code/Magento/Core/sql/core_setup/install-1.6.0.0.php index fd99584cfa39b..d169d08af6b76 100644 --- a/app/code/Magento/Core/sql/core_setup/install-1.6.0.0.php +++ b/app/code/Magento/Core/sql/core_setup/install-1.6.0.0.php @@ -488,96 +488,6 @@ ); $installer->getConnection()->createTable($table); -/** - * Create table 'core_url_rewrite' - */ -$table = $installer->getConnection()->newTable( - $installer->getTable('core_url_rewrite') -)->addColumn( - 'url_rewrite_id', - \Magento\DB\Ddl\Table::TYPE_INTEGER, - null, - array('identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true), - 'Rewrite Id' -)->addColumn( - 'store_id', - \Magento\DB\Ddl\Table::TYPE_SMALLINT, - null, - array('unsigned' => true, 'nullable' => false, 'default' => '0'), - 'Store Id' -)->addColumn( - 'id_path', - \Magento\DB\Ddl\Table::TYPE_TEXT, - 255, - array(), - 'Id Path' -)->addColumn( - 'request_path', - \Magento\DB\Ddl\Table::TYPE_TEXT, - 255, - array(), - 'Request Path' -)->addColumn( - 'target_path', - \Magento\DB\Ddl\Table::TYPE_TEXT, - 255, - array(), - 'Target Path' -)->addColumn( - 'is_system', - \Magento\DB\Ddl\Table::TYPE_SMALLINT, - null, - array('unsigned' => true, 'default' => '1'), - 'Defines is Rewrite System' -)->addColumn( - 'options', - \Magento\DB\Ddl\Table::TYPE_TEXT, - 255, - array('nullable' => true), - 'Options' -)->addColumn( - 'description', - \Magento\DB\Ddl\Table::TYPE_TEXT, - 255, - array(), - 'Deascription' -)->addIndex( - $installer->getIdxName( - 'core_url_rewrite', - array('request_path', 'store_id'), - \Magento\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE - ), - array('request_path', 'store_id'), - array('type' => \Magento\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE) -)->addIndex( - $installer->getIdxName( - 'core_url_rewrite', - array('id_path', 'is_system', 'store_id'), - \Magento\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE - ), - array('id_path', 'is_system', 'store_id'), - array('type' => \Magento\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE) -)->addIndex( - $installer->getIdxName('core_url_rewrite', array('target_path', 'store_id')), - array('target_path', 'store_id') -)->addIndex( - $installer->getIdxName('core_url_rewrite', array('id_path')), - array('id_path') -)->addIndex( - $installer->getIdxName('core_url_rewrite', array('store_id')), - array('store_id') -)->addForeignKey( - $installer->getFkName('core_url_rewrite', 'store_id', 'core_store', 'store_id'), - 'store_id', - $installer->getTable('core_store'), - 'store_id', - \Magento\DB\Ddl\Table::ACTION_CASCADE, - \Magento\DB\Ddl\Table::ACTION_CASCADE -)->setComment( - 'Url Rewrites' -); -$installer->getConnection()->createTable($table); - /** * Create table 'design_change' */ diff --git a/app/code/Magento/Customer/Block/Account/Dashboard.php b/app/code/Magento/Customer/Block/Account/Dashboard.php index 6efc5303eeeab..e1281fe0de859 100644 --- a/app/code/Magento/Customer/Block/Account/Dashboard.php +++ b/app/code/Magento/Customer/Block/Account/Dashboard.php @@ -164,9 +164,8 @@ public function getWishlistUrl() public function getSubscriptionObject() { if (is_null($this->_subscription)) { - $this->_subscription = $this->_createSubscriber()->loadByCustomer( - $this->_customerSession->getCustomerId() - ); + $this->_subscription = + $this->_createSubscriber()->loadByCustomerId($this->_customerSession->getCustomerId()); } return $this->_subscription; diff --git a/app/code/Magento/Customer/Block/Account/Dashboard/Newsletter.php b/app/code/Magento/Customer/Block/Account/Dashboard/Newsletter.php index 0ed6c69ed996a..a10fd9dac01c6 100644 --- a/app/code/Magento/Customer/Block/Account/Dashboard/Newsletter.php +++ b/app/code/Magento/Customer/Block/Account/Dashboard/Newsletter.php @@ -79,9 +79,8 @@ public function __construct( public function getSubscriptionObject() { if (is_null($this->_subscription)) { - $this->_subscription = $this->_createSubscriber()->loadByCustomer( - $this->_customerSession->getCustomerId() - ); + $this->_subscription = + $this->_createSubscriber()->loadByCustomerId($this->_customerSession->getCustomerId()); } return $this->_subscription; } diff --git a/app/code/Magento/Customer/Block/Account/Forgotpassword.php b/app/code/Magento/Customer/Block/Account/Forgotpassword.php index 7daae214e8e34..e206deb50fe19 100644 --- a/app/code/Magento/Customer/Block/Account/Forgotpassword.php +++ b/app/code/Magento/Customer/Block/Account/Forgotpassword.php @@ -28,15 +28,4 @@ */ class Forgotpassword extends \Magento\View\Element\Template { - /** - * Forgot Password Constructor. - * - * @param \Magento\View\Element\Template\Context $context - * @param array $data - */ - public function __construct(\Magento\View\Element\Template\Context $context, array $data = array()) - { - parent::__construct($context, $data); - $this->_isScopePrivate = true; - } } diff --git a/app/code/Magento/Customer/Block/Account/Resetpassword.php b/app/code/Magento/Customer/Block/Account/Resetpassword.php index dddf1a8f9fc66..70a1f5911a973 100644 --- a/app/code/Magento/Customer/Block/Account/Resetpassword.php +++ b/app/code/Magento/Customer/Block/Account/Resetpassword.php @@ -23,22 +23,9 @@ */ namespace Magento\Customer\Block\Account; -use Magento\View\Element\Template\Context; - /** * Customer reset password form */ class Resetpassword extends \Magento\View\Element\Template { - /** - * Reset Password Constructor. - * - * @param Context $context - * @param array $data - */ - public function __construct(Context $context, array $data = array()) - { - parent::__construct($context, $data); - $this->_isScopePrivate = true; - } } diff --git a/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Newsletter.php b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Newsletter.php index 5cbdef028bd98..5d7f82bab7203 100644 --- a/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Newsletter.php +++ b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Newsletter.php @@ -80,7 +80,7 @@ public function initForm() $form = $this->_formFactory->create(); $form->setHtmlIdPrefix('_newsletter'); $customerId = $this->_coreRegistry->registry(RegistryConstants::CURRENT_CUSTOMER_ID); - $subscriber = $this->_subscriberFactory->create()->loadByCustomer($customerId); + $subscriber = $this->_subscriberFactory->create()->loadByCustomerId($customerId); $this->_coreRegistry->register('subscriber', $subscriber); $fieldset = $form->addFieldset('base_fieldset', array('legend' => __('Newsletter Information'))); diff --git a/app/code/Magento/Customer/Controller/Account.php b/app/code/Magento/Customer/Controller/Account.php index 0b5b4a39ae6eb..61c80a239abfe 100644 --- a/app/code/Magento/Customer/Controller/Account.php +++ b/app/code/Magento/Customer/Controller/Account.php @@ -448,7 +448,7 @@ public function createPostAction() $customer = $this->_customerAccountService->createAccount($customerDetails, $password, $redirectUrl); if ($this->getRequest()->getParam('is_subscribed', false)) { - $this->_subscriberFactory->create()->updateSubscription($customer->getId(), true); + $this->_subscriberFactory->create()->subscribeCustomerById($customer->getId()); } $this->_eventManager->dispatch( diff --git a/app/code/Magento/Customer/Controller/Adminhtml/Index.php b/app/code/Magento/Customer/Controller/Adminhtml/Index.php index 9e1337b3c2c50..73b50fcc95f77 100644 --- a/app/code/Magento/Customer/Controller/Adminhtml/Index.php +++ b/app/code/Magento/Customer/Controller/Adminhtml/Index.php @@ -268,10 +268,10 @@ public function editAction() // restore data from SESSION if ($data && (!isset( - $data['customer_id'] - ) || isset( - $data['customer_id'] - ) && $data['customer_id'] == $customerId) + $data['customer_id'] + ) || isset( + $data['customer_id'] + ) && $data['customer_id'] == $customerId) ) { $request = clone $this->getRequest(); $request->setParams($data); @@ -390,7 +390,6 @@ public function saveAction() $addressesData = $this->_extractCustomerAddressData(); $request = $this->getRequest(); $isExistingCustomer = (bool)$customerId; - $customerBuilder = $this->_customerBuilder; if ($isExistingCustomer) { $savedCustomerData = $this->_customerAccountService->getCustomer($customerId); @@ -402,7 +401,6 @@ public function saveAction() unset($customerData[Customer::DEFAULT_BILLING]); unset($customerData[Customer::DEFAULT_SHIPPING]); $customerBuilder->populateWithArray($customerData); - $addresses = array(); foreach ($addressesData as $addressData) { $addresses[] = $this->_addressBuilder->populateWithArray($addressData)->create(); @@ -417,17 +415,22 @@ public function saveAction() // Save customer $customerDetails = $this->_customerDetailsBuilder->setCustomer( $customer - )->setAddresses( - $addresses - )->create(); + )->setAddresses($addresses)->create(); if ($isExistingCustomer) { $this->_customerAccountService->updateCustomer($customerDetails); } else { $customer = $this->_customerAccountService->createAccount($customerDetails); + $customerId = $customer->getId(); } - if ($customerData['is_subscribed']) { - $this->_subscriberFactory->create()->updateSubscription($customerId, true); + $isSubscribed = false; + if ($this->_authorization->isAllowed(null)) { + $isSubscribed = $this->getRequest()->getPost('subscription') !== null; + } + if ($isSubscribed) { + $this->_subscriberFactory->create()->subscribeCustomerById($customerId); + } else { + $this->_subscriberFactory->create()->unsubscribeCustomerById($customerId); } // After save @@ -437,11 +440,8 @@ public function saveAction() ); // Done Saving customer, finish save action - $customerId = $customer->getId(); $this->_coreRegistry->register(RegistryConstants::CURRENT_CUSTOMER_ID, $customerId); - $this->messageManager->addSuccess(__('You saved the customer.')); - $returnToEdit = (bool)$this->getRequest()->getParam('back', false); } catch (\Magento\Validator\ValidatorException $exception) { $this->_addSessionErrorMessages($exception->getMessages()); @@ -465,7 +465,6 @@ public function saveAction() $returnToEdit = true; } } - if ($returnToEdit) { if ($customerId) { $this->_redirect('customer/*/edit', array('id' => $customerId, '_current' => true)); @@ -563,10 +562,6 @@ protected function _extractCustomerData() ); } - if ($this->_authorization->isAllowed(null)) { - $customerData['is_subscribed'] = $this->getRequest()->getPost('subscription') !== null; - } - if (isset($customerData['disable_auto_group_change'])) { $customerData['disable_auto_group_change'] = empty($customerData['disable_auto_group_change']) ? '0' : '1'; } @@ -607,12 +602,12 @@ protected function _extractCustomerAddressData() // Set default billing and shipping flags to address $addressData[Customer::DEFAULT_BILLING] = isset( $customerData[Customer::DEFAULT_BILLING] - ) && + ) && $customerData[Customer::DEFAULT_BILLING] && $customerData[Customer::DEFAULT_BILLING] == $addressId; $addressData[Customer::DEFAULT_SHIPPING] = isset( $customerData[Customer::DEFAULT_SHIPPING] - ) && + ) && $customerData[Customer::DEFAULT_SHIPPING] && $customerData[Customer::DEFAULT_SHIPPING] == $addressId; @@ -685,11 +680,9 @@ public function newsletterAction() { $this->_initCustomer(); $customerId = $this->_coreRegistry->registry(RegistryConstants::CURRENT_CUSTOMER_ID); - $subscriber = $this->_objectManager->create( - 'Magento\Newsletter\Model\Subscriber' - )->loadByCustomer( - $customerId - ); + $subscriber = $this->_objectManager + ->create('Magento\Newsletter\Model\Subscriber') + ->loadByCustomer($customerId); $this->_coreRegistry->register('subscriber', $subscriber); $this->_view->loadLayout()->renderLayout(); @@ -745,13 +738,12 @@ public function cartAction() // delete an item from cart $deleteItemId = $this->getRequest()->getPost('delete'); if ($deleteItemId) { - $quote = $this->_objectManager->create( - 'Magento\Sales\Model\Quote' - )->setWebsite( - $this->_objectManager->get('Magento\Core\Model\StoreManagerInterface')->getWebsite($websiteId) - )->loadByCustomer( - $this->_coreRegistry->registry(RegistryConstants::CURRENT_CUSTOMER_ID) - ); + $quote = $this->_objectManager + ->create('Magento\Sales\Model\Quote') + ->setWebsite( + $this->_objectManager->get('Magento\Core\Model\StoreManagerInterface')->getWebsite($websiteId) + ) + ->loadByCustomer($this->_coreRegistry->registry(RegistryConstants::CURRENT_CUSTOMER_ID)); $item = $quote->getItemById($deleteItemId); if ($item && $item->getId()) { $quote->removeItem($deleteItemId); @@ -773,9 +765,7 @@ public function viewCartAction() { $this->_initCustomer(); $this->_view->loadLayout(); - $this->_view->getLayout()->getBlock( - 'admin.customer.view.cart' - )->setWebsiteId( + $this->_view->getLayout()->getBlock('admin.customer.view.cart')->setWebsiteId( (int)$this->getRequest()->getParam('website_id') ); $this->_view->renderLayout(); @@ -802,13 +792,10 @@ public function productReviewsAction() { $this->_initCustomer(); $this->_view->loadLayout(); - $this->_view->getLayout()->getBlock( - 'admin.customer.reviews' - )->setCustomerId( + $this->_view->getLayout()->getBlock('admin.customer.reviews')->setCustomerId( $this->_coreRegistry->registry(RegistryConstants::CURRENT_CUSTOMER_ID) - )->setUseAjax( - true - ); + ) + ->setUseAjax(true); $this->_view->renderLayout(); } @@ -926,7 +913,7 @@ public function massSubscribeAction() function ($customerId) { // Verify customer exists $this->_customerAccountService->getCustomer($customerId); - $this->_subscriberFactory->create()->updateSubscription($customerId, true); + $this->_subscriberFactory->create()->subscribeCustomerById($customerId); }, $customerIds ); @@ -948,7 +935,7 @@ public function massUnsubscribeAction() function ($customerId) { // Verify customer exists $this->_customerAccountService->getCustomer($customerId); - $this->_subscriberFactory->create()->updateSubscription($customerId, false); + $this->_subscriberFactory->create()->unsubscribeCustomerById($customerId); }, $customerIds ); @@ -1045,9 +1032,7 @@ public function viewfileAction() ->urlDecode($this->getRequest()->getParam('file')); } elseif ($this->getRequest()->getParam('image')) { // show plain image - $file = $this->_objectManager->get( - 'Magento\Core\Helper\Data' - )->urlDecode( + $file = $this->_objectManager->get('Magento\Core\Helper\Data')->urlDecode( $this->getRequest()->getParam('image') ); $plain = true; @@ -1060,13 +1045,8 @@ public function viewfileAction() $directory = $filesystem->getDirectoryRead(\Magento\App\Filesystem::MEDIA_DIR); $fileName = 'customer' . '/' . ltrim($file, '/'); $path = $directory->getAbsolutePath($fileName); - if (!$directory->isFile( - $fileName - ) && !$this->_objectManager->get( - 'Magento\Core\Helper\File\Storage' - )->processStorageFile( - $path - ) + if (!$directory->isFile($fileName) + && !$this->_objectManager->get('Magento\Core\Helper\File\Storage')->processStorageFile($path) ) { throw new NotFoundException(); } @@ -1091,23 +1071,17 @@ public function viewfileAction() $contentLength = $stat['size']; $contentModify = $stat['mtime']; - $this->getResponse()->setHttpResponseCode( - 200 - )->setHeader( - 'Pragma', - 'public', - true - )->setHeader( - 'Content-type', - $contentType, - true - )->setHeader( - 'Content-Length', - $contentLength - )->setHeader( - 'Last-Modified', - date('r', $contentModify) - )->clearBody(); + $this->getResponse() + ->setHttpResponseCode(200) + ->setHeader('Pragma', 'public', true) + ->setHeader( + 'Content-type', + $contentType, + true + ) + ->setHeader('Content-Length', $contentLength) + ->setHeader('Last-Modified', date('r', $contentModify)) + ->clearBody(); $this->getResponse()->sendHeaders(); echo $directory->readFile($fileName); diff --git a/app/code/Magento/Customer/Model/Converter.php b/app/code/Magento/Customer/Model/Converter.php index cf1650eddec17..faf75ff4ccec4 100644 --- a/app/code/Magento/Customer/Model/Converter.php +++ b/app/code/Magento/Customer/Model/Converter.php @@ -160,12 +160,12 @@ public function createCustomerModel(CustomerDataObject $customer) * Update customer model with the data from the data object * * @param Customer $customerModel - * @param \Magento\Customer\Service\V1\Data\Customer $customerData + * @param CustomerDataObject $customerData * @return void */ public function updateCustomerModel( \Magento\Customer\Model\Customer $customerModel, - \Magento\Customer\Service\V1\Data\Customer $customerData + CustomerDataObject $customerData ) { $attributes = \Magento\Service\DataObjectConverter::toFlatArray($customerData); foreach ($attributes as $attributeCode => $attributeValue) { @@ -197,7 +197,7 @@ protected function _populateBuilderWithAttributes(Customer $customerModel) continue; } if ($attrCode == 'entity_id') { - $attributes[\Magento\Customer\Service\V1\Data\Customer::ID] = $value; + $attributes[CustomerDataObject::ID] = $value; } else { $attributes[$attrCode] = $value; } diff --git a/app/code/Magento/Customer/Model/Customer.php b/app/code/Magento/Customer/Model/Customer.php index 390288b6ab8b5..533f0d015f32c 100644 --- a/app/code/Magento/Customer/Model/Customer.php +++ b/app/code/Magento/Customer/Model/Customer.php @@ -29,6 +29,7 @@ use Magento\Customer\Model\Resource\Address\CollectionFactory; use Magento\Customer\Model\Resource\Customer as ResourceCustomer; use Magento\Customer\Service\V1\Data\CustomerBuilder; +use Magento\Customer\Service\V1\Data\Customer as CustomerData; /** * Customer model @@ -353,10 +354,10 @@ protected function _beforeSave() protected function _afterSave() { $customerData = (array)$this->getData(); - $customerData[\Magento\Customer\Service\V1\Data\Customer::ID] = $this->getId(); + $customerData[CustomerData::ID] = $this->getId(); $dataObject = $this->_customerDataBuilder->populateWithArray($customerData)->create(); $customerOrigData = (array)$this->getOrigData(); - $customerOrigData[\Magento\Customer\Service\V1\Data\Customer::ID] = $this->getId(); + $customerOrigData[CustomerData::ID] = $this->getId(); $origDataObject = $this->_customerDataBuilder->populateWithArray($customerOrigData)->create(); $this->_eventManager->dispatch( 'customer_save_after_data_object', diff --git a/app/code/Magento/Customer/view/frontend/layout/customer_address_form.xml b/app/code/Magento/Customer/view/frontend/layout/customer_address_form.xml index cd6aed54f9688..2bf65f6a45707 100644 --- a/app/code/Magento/Customer/view/frontend/layout/customer_address_form.xml +++ b/app/code/Magento/Customer/view/frontend/layout/customer_address_form.xml @@ -31,6 +31,6 @@ - + diff --git a/app/code/Magento/DesignEditor/Controller/Varien/Router/Standard.php b/app/code/Magento/DesignEditor/Controller/Varien/Router/Standard.php index 7c330675a64a1..81c76f0de99a6 100644 --- a/app/code/Magento/DesignEditor/Controller/Varien/Router/Standard.php +++ b/app/code/Magento/DesignEditor/Controller/Varien/Router/Standard.php @@ -49,7 +49,7 @@ class Standard extends \Magento\Core\App\Router\Base protected $_routerList; /** - * @var \Magento\Core\App\Request\RewriteService + * @var \Magento\UrlRewrite\App\Request\RewriteService */ protected $_urlRewriteService; @@ -82,7 +82,7 @@ class Standard extends \Magento\Core\App\Router\Base * @param \Magento\Code\NameBuilder $nameBuilder * @param \Magento\App\RouterListInterface $routerList * @param \Magento\ObjectManager $objectManager - * @param \Magento\Core\App\Request\RewriteService $urlRewriteService + * @param \Magento\UrlRewrite\App\Request\RewriteService $urlRewriteService * @param \Magento\DesignEditor\Helper\Data $designEditorHelper * @param \Magento\DesignEditor\Model\State $designEditorState * @param \Magento\Backend\Model\Auth\Session $session @@ -103,7 +103,7 @@ public function __construct( \Magento\Code\NameBuilder $nameBuilder, \Magento\App\RouterListInterface $routerList, \Magento\ObjectManager $objectManager, - \Magento\Core\App\Request\RewriteService $urlRewriteService, + \Magento\UrlRewrite\App\Request\RewriteService $urlRewriteService, \Magento\DesignEditor\Helper\Data $designEditorHelper, \Magento\DesignEditor\Model\State $designEditorState, \Magento\Backend\Model\Auth\Session $session diff --git a/app/code/Magento/DesignEditor/Model/AreaEmulator.php b/app/code/Magento/DesignEditor/Model/AreaEmulator.php index 96401fd49072e..89210d61f3a2f 100644 --- a/app/code/Magento/DesignEditor/Model/AreaEmulator.php +++ b/app/code/Magento/DesignEditor/Model/AreaEmulator.php @@ -47,10 +47,7 @@ public function emulateLayoutArea($areaCode) $configuration = array( 'Magento\Core\Model\Layout' => array( 'arguments' => array( - 'area' => array( - \Magento\ObjectManager\Config\Reader\Dom::TYPE_ATTRIBUTE => 'string', - 'value' => $areaCode - ) + 'area' => $areaCode ) ) ); diff --git a/app/code/Magento/DesignEditor/etc/frontend/di.xml b/app/code/Magento/DesignEditor/etc/frontend/di.xml index a377d268aef63..afa34908efc86 100644 --- a/app/code/Magento/DesignEditor/etc/frontend/di.xml +++ b/app/code/Magento/DesignEditor/etc/frontend/di.xml @@ -28,7 +28,7 @@ - Magento\DesignEditor\Controller\Varien\Router\Standard + Magento\DesignEditor\Controller\Varien\Router\Standard false 40 diff --git a/app/code/Magento/DesignEditor/etc/module.xml b/app/code/Magento/DesignEditor/etc/module.xml index b894e8f3ef267..bd8504b96d200 100644 --- a/app/code/Magento/DesignEditor/etc/module.xml +++ b/app/code/Magento/DesignEditor/etc/module.xml @@ -33,6 +33,7 @@ + diff --git a/app/code/Magento/Eav/Model/Entity/Setup/Context.php b/app/code/Magento/Eav/Model/Entity/Setup/Context.php index 7036a748551a1..24f657a191f36 100644 --- a/app/code/Magento/Eav/Model/Entity/Setup/Context.php +++ b/app/code/Magento/Eav/Model/Entity/Setup/Context.php @@ -38,7 +38,7 @@ class Context extends \Magento\Core\Model\Resource\Setup\Context * @param \Magento\App\Resource $resource * @param \Magento\Module\Dir\Reader $modulesReader * @param \Magento\Module\ModuleListInterface $moduleList - * @param \Magento\Core\Model\Resource\Resource $resourceResource + * @param \Magento\Module\ResourceInterface $resourceResource * @param \Magento\Core\Model\Resource\Setup\MigrationFactory $migrationFactory * @param \Magento\Core\Model\Resource\Theme\CollectionFactory $themeResourceFactory * @param \Magento\Core\Model\Theme\CollectionFactory $themeFactory @@ -52,7 +52,7 @@ public function __construct( \Magento\App\Resource $resource, \Magento\Module\Dir\Reader $modulesReader, \Magento\Module\ModuleListInterface $moduleList, - \Magento\Core\Model\Resource\Resource $resourceResource, + \Magento\Module\ResourceInterface $resourceResource, \Magento\Core\Model\Resource\Setup\MigrationFactory $migrationFactory, \Magento\Core\Model\Resource\Theme\CollectionFactory $themeResourceFactory, \Magento\Core\Model\Theme\CollectionFactory $themeFactory, diff --git a/app/code/Magento/Core/Model/Template.php b/app/code/Magento/Email/Model/AbstractTemplate.php similarity index 97% rename from app/code/Magento/Core/Model/Template.php rename to app/code/Magento/Email/Model/AbstractTemplate.php index d350ffc83bb4a..424349458e2a8 100644 --- a/app/code/Magento/Core/Model/Template.php +++ b/app/code/Magento/Email/Model/AbstractTemplate.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\Core\Model; +namespace Magento\Email\Model; /** * Template model class @@ -32,7 +32,7 @@ * @package Magento_Core * @author Magento Core Team */ -abstract class Template extends \Magento\Model\AbstractModel implements \Magento\App\TemplateTypesInterface +abstract class AbstractTemplate extends \Magento\Model\AbstractModel implements \Magento\App\TemplateTypesInterface { /** * Default design area for emulation diff --git a/app/code/Magento/Email/Model/Template.php b/app/code/Magento/Email/Model/Template.php index b5ea656352fa5..47204cc6b9934 100644 --- a/app/code/Magento/Email/Model/Template.php +++ b/app/code/Magento/Email/Model/Template.php @@ -70,7 +70,7 @@ * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class Template extends \Magento\Core\Model\Template implements \Magento\Mail\TemplateInterface +class Template extends \Magento\Email\Model\AbstractTemplate implements \Magento\Mail\TemplateInterface { /** * Configuration path for default email templates diff --git a/app/code/Magento/GiftMessage/view/adminhtml/form.phtml b/app/code/Magento/GiftMessage/view/adminhtml/form.phtml deleted file mode 100644 index 5c2611c86c3d2..0000000000000 --- a/app/code/Magento/GiftMessage/view/adminhtml/form.phtml +++ /dev/null @@ -1,57 +0,0 @@ - -helper('Magento\Core\Helper\Js')->includeScript('Magento_Sales::order/create/giftmessage.js') ?> -getSaveMode()): ?> -
- getBlockHtml('formkey')?> - getFormHtml(); ?> - getSaveButtonHtml() ?> - getCancelButtonHtml() ?> - getMessage()->getGiftMessageId()): ?> - getRemoveButtonHtml() ?> - -
-getSaveMode()=='save'): ?> -

-
getCloseButtonHtml() ?> - -

-
getCloseButtonHtml() ?> - - diff --git a/app/code/Magento/GiftMessage/view/adminhtml/helper.phtml b/app/code/Magento/GiftMessage/view/adminhtml/helper.phtml deleted file mode 100644 index 072af8a290251..0000000000000 --- a/app/code/Magento/GiftMessage/view/adminhtml/helper.phtml +++ /dev/null @@ -1,104 +0,0 @@ - -getType()!== 'main' && !$this->getScriptIncluded() && $this->getCanDisplayContainer()): ?> -helper('Magento\Core\Helper\Js')->includeScript('Magento_Sales::order/create/giftmessage.js') ?> -setScriptIncluded(true); ?> - -getCanDisplayContainer()): ?> -
- -getType()): ?> - - - hasGiftMessage()): ?> - - - - - - - - - hasGiftMessage()): ?> - - - - - - - - hasGiftMessage()): ?> - getMessage()): ?> - - - escapeHtml($_giftMessage->getSender()) ?> - - - - escapeHtml($_giftMessage->getRecipient()) ?> - - - -
prepareAsIs($_giftMessage->getMessage()) ?>
-
- - getWidgetButtonHtml(__('Edit'), 'edit') ?> - - getWidgetButtonHtml(__('Add'), 'add') ?> - - - - hasGiftMessage()): ?> - getMessage()): ?> - - - - escapeHtml($_giftMessage->getSender()) ?> - - - - escapeHtml($_giftMessage->getRecipient()) ?> - - - -
prepareAsIs($_giftMessage->getMessage()) ?>
-
- - - getWidgetButtonHtml(__('Edit'), 'edit') ?> - - getWidgetButtonHtml(__('Add'), 'add') ?> - - - -getCanDisplayContainer()): ?> -
- - diff --git a/app/code/Magento/Index/Model/Shell.php b/app/code/Magento/Index/Model/Shell.php index b7e42e46e1c4e..29c0afb6e88d8 100644 --- a/app/code/Magento/Index/Model/Shell.php +++ b/app/code/Magento/Index/Model/Shell.php @@ -192,8 +192,11 @@ protected function _runReindex() foreach ($processes as $process) { /* @var $process \Magento\Index\Model\Process */ try { + $startTime = microtime(true); $process->reindexEverything(); - echo $process->getIndexer()->getName() . " index was rebuilt successfully\n"; + $resultTime = microtime(true) - $startTime; + echo $process->getIndexer()->getName() + . " index was rebuilt successfully in " . gmdate('H:i:s', $resultTime) . "\n"; } catch (\Magento\Model\Exception $e) { echo $e->getMessage() . "\n"; $this->_hasErrors = true; diff --git a/app/code/Magento/Indexer/Model/Shell.php b/app/code/Magento/Indexer/Model/Shell.php index fe5ee2cb764dc..a9c72bdf9a59c 100644 --- a/app/code/Magento/Indexer/Model/Shell.php +++ b/app/code/Magento/Indexer/Model/Shell.php @@ -184,13 +184,16 @@ protected function runReindex() foreach ($indexers as $indexer) { try { + $startTime = microtime(true); $indexer->reindexAll(); - echo $indexer->getTitle() . " index has been rebuilt successfully" . PHP_EOL; + $resultTime = microtime(true) - $startTime; + echo $indexer->getTitle() . ' index has been rebuilt successfully in ' + . gmdate('H:i:s', $resultTime) . PHP_EOL; } catch (\Magento\Model\Exception $e) { echo $e->getMessage() . PHP_EOL; $this->hasErrors = true; } catch (\Exception $e) { - echo $indexer->getTitle() . " indexer process unknown error:" . PHP_EOL; + echo $indexer->getTitle() . ' indexer process unknown error:' . PHP_EOL; echo $e . PHP_EOL; $this->hasErrors = true; } diff --git a/app/code/Magento/Core/App/Action/Plugin/Install.php b/app/code/Magento/Install/App/Action/Plugin/Install.php similarity index 98% rename from app/code/Magento/Core/App/Action/Plugin/Install.php rename to app/code/Magento/Install/App/Action/Plugin/Install.php index e782b7cd40d22..57e3b716c500c 100644 --- a/app/code/Magento/Core/App/Action/Plugin/Install.php +++ b/app/code/Magento/Install/App/Action/Plugin/Install.php @@ -22,7 +22,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\Core\App\Action\Plugin; +namespace Magento\Install\App\Action\Plugin; class Install { diff --git a/app/code/Magento/Core/Model/Resource/Resource.php b/app/code/Magento/Install/Model/Resource/Resource.php similarity index 86% rename from app/code/Magento/Core/Model/Resource/Resource.php rename to app/code/Magento/Install/Model/Resource/Resource.php index 8ce9180fda1d8..e1e613a722926 100644 --- a/app/code/Magento/Core/Model/Resource/Resource.php +++ b/app/code/Magento/Install/Model/Resource/Resource.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_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\Core\Model\Resource; +namespace Magento\Install\Model\Resource; /** - * Core Resource Resource Model - * - * @category Magento - * @package Magento_Core - * @author Magento Core Team + * Resource Resource Model */ -class Resource extends \Magento\Model\Resource\Db\AbstractDb +class Resource extends \Magento\Model\Resource\Db\AbstractDb implements \Magento\Module\ResourceInterface { /** * Database versions @@ -95,10 +89,7 @@ protected function _loadVersionData($needType) } /** - * Get Module version from DB - * - * @param string $resName - * @return false|string + * {@inheritdoc} */ public function getDbVersion($resName) { @@ -110,11 +101,7 @@ public function getDbVersion($resName) } /** - * Set module version into DB - * - * @param string $resName - * @param string $version - * @return int + * {@inheritdoc} */ public function setDbVersion($resName, $version) { @@ -134,10 +121,7 @@ public function setDbVersion($resName, $version) } /** - * Get resource data version - * - * @param string $resName - * @return string|false + * {@inheritdoc} */ public function getDataVersion($resName) { @@ -151,11 +135,7 @@ public function getDataVersion($resName) } /** - * Specify resource data version - * - * @param string $resName - * @param string $version - * @return $this + * {@inheritdoc} */ public function setDataVersion($resName, $version) { @@ -168,6 +148,5 @@ public function setDataVersion($resName, $version) self::$_dataVersions[$resName] = $version; $this->_getWriteAdapter()->insert($this->getMainTable(), $data); } - return $this; } } diff --git a/app/code/Magento/Install/etc/di.xml b/app/code/Magento/Install/etc/di.xml index 9cd09570203e9..547c3f2e3c214 100644 --- a/app/code/Magento/Install/etc/di.xml +++ b/app/code/Magento/Install/etc/di.xml @@ -25,6 +25,7 @@ --> + install @@ -140,4 +141,7 @@ adminhtml + + + diff --git a/app/code/Magento/Install/etc/install/di.xml b/app/code/Magento/Install/etc/install/di.xml index 426b6b60179f6..ec4b144de731b 100644 --- a/app/code/Magento/Install/etc/install/di.xml +++ b/app/code/Magento/Install/etc/install/di.xml @@ -29,7 +29,7 @@ - Magento\Core\App\Router\Base + Magento\Core\App\Router\Base false 20 diff --git a/app/code/Magento/Install/view/install/page.phtml b/app/code/Magento/Install/view/install/page.phtml index cc55f4f7d62bf..6aa82558d6bd3 100644 --- a/app/code/Magento/Install/view/install/page.phtml +++ b/app/code/Magento/Install/view/install/page.phtml @@ -26,7 +26,7 @@ ?> @@ -51,7 +51,7 @@ - helper('Magento\Core\Helper\Js')->getTranslatorScript() ?> + getTranslatorScript(); ?> diff --git a/app/code/Magento/Multishipping/view/frontend/layout/multishipping_checkout_customer_address.xml b/app/code/Magento/Multishipping/view/frontend/layout/multishipping_checkout_customer_address.xml index f3864993932ff..566da08e97d68 100644 --- a/app/code/Magento/Multishipping/view/frontend/layout/multishipping_checkout_customer_address.xml +++ b/app/code/Magento/Multishipping/view/frontend/layout/multishipping_checkout_customer_address.xml @@ -25,7 +25,7 @@ --> - + diff --git a/app/code/Magento/Newsletter/Controller/Manage.php b/app/code/Magento/Newsletter/Controller/Manage.php index df40cdb6b574c..350a6916c57a3 100644 --- a/app/code/Magento/Newsletter/Controller/Manage.php +++ b/app/code/Magento/Newsletter/Controller/Manage.php @@ -25,7 +25,6 @@ */ namespace Magento\Newsletter\Controller; -use Magento\App\Action\NotFoundException; use Magento\App\RequestInterface; /** @@ -50,22 +49,54 @@ class Manage extends \Magento\App\Action\Action */ protected $_storeManager; + /** + * @var \Magento\Customer\Service\V1\CustomerAccountServiceInterface + */ + protected $_customerAccountService; + + /** + * @var \Magento\Customer\Service\V1\Data\CustomerDetailsBuilder + */ + protected $_customerDetailsBuilder; + + /** + * @var \Magento\Customer\Service\V1\Data\CustomerBuilder + */ + protected $_customerBuilder; + + /** + * @var \Magento\Newsletter\Model\SubscriberFactory + */ + protected $_subscriberFactory; + /** * @param \Magento\App\Action\Context $context * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Core\App\Action\FormKeyValidator $formKeyValidator * @param \Magento\Core\Model\StoreManagerInterface $storeManager + * @param \Magento\Customer\Service\V1\CustomerAccountServiceInterface $customerAccountService + * @param \Magento\Customer\Service\V1\Data\CustomerDetailsBuilder $customerDetailsBuilder + * @param \Magento\Customer\Service\V1\Data\CustomerBuilder $customerBuilder + * @param \Magento\Newsletter\Model\SubscriberFactory $subscriberFactory */ public function __construct( \Magento\App\Action\Context $context, \Magento\Customer\Model\Session $customerSession, \Magento\Core\App\Action\FormKeyValidator $formKeyValidator, - \Magento\Core\Model\StoreManagerInterface $storeManager + \Magento\Core\Model\StoreManagerInterface $storeManager, + \Magento\Customer\Service\V1\CustomerAccountServiceInterface $customerAccountService, + \Magento\Customer\Service\V1\Data\CustomerDetailsBuilder $customerDetailsBuilder, + \Magento\Customer\Service\V1\Data\CustomerBuilder $customerBuilder, + \Magento\Newsletter\Model\SubscriberFactory $subscriberFactory ) { $this->_storeManager = $storeManager; parent::__construct($context); $this->_formKeyValidator = $formKeyValidator; $this->_customerSession = $customerSession; + $this->_customerAccountService = $customerAccountService; + $this->_customerDetailsBuilder = $customerDetailsBuilder; + $this->_customerBuilder = $customerBuilder; + $this->_subscriberFactory = $subscriberFactory; } /** @@ -109,19 +140,29 @@ public function saveAction() if (!$this->_formKeyValidator->validate($this->getRequest())) { return $this->_redirect('customer/account/'); } - try { - $this->_customerSession->getCustomer()->setStoreId( - $this->_storeManager->getStore()->getId() - )->setIsSubscribed( - (bool)$this->getRequest()->getParam('is_subscribed', false) - )->save(); - if ((bool)$this->getRequest()->getParam('is_subscribed', false)) { - $this->messageManager->addSuccess(__('We saved the subscription.')); - } else { - $this->messageManager->addSuccess(__('We removed the subscription.')); - } - } catch (\Exception $e) { + + $customerId = $this->_customerSession->getCustomerId(); + if (is_null($customerId)) { $this->messageManager->addError(__('Something went wrong while saving your subscription.')); + } else { + try { + $customer = $this->_customerAccountService->getCustomer($customerId); + $storeId = $this->_storeManager->getStore()->getId(); + $customerDetails = $this->_customerDetailsBuilder->setAddresses(null) + ->setCustomer($this->_customerBuilder->populate($customer)->setStoreId($storeId)->create()) + ->create(); + $this->_customerAccountService->updateCustomer($customerDetails); + + if ((boolean)$this->getRequest()->getParam('is_subscribed', false)) { + $this->_subscriberFactory->create()->subscribeCustomerById($customerId); + $this->messageManager->addSuccess(__('We saved the subscription.')); + } else { + $this->_subscriberFactory->create()->unsubscribeCustomerById($customerId); + $this->messageManager->addSuccess(__('We removed the subscription.')); + } + } catch (\Exception $e) { + $this->messageManager->addError(__('Something went wrong while saving your subscription.')); + } } $this->_redirect('customer/account/'); } diff --git a/app/code/Magento/Newsletter/Controller/Subscriber.php b/app/code/Magento/Newsletter/Controller/Subscriber.php index 1392bf2dfca2a..2fc1a8ab2990c 100644 --- a/app/code/Magento/Newsletter/Controller/Subscriber.php +++ b/app/code/Magento/Newsletter/Controller/Subscriber.php @@ -33,63 +33,68 @@ */ namespace Magento\Newsletter\Controller; +use Magento\App\Action\Context; +use Magento\Core\Model\StoreManagerInterface; +use Magento\Customer\Model\Session; +use Magento\Customer\Service\V1\CustomerAccountServiceInterface; +use Magento\Newsletter\Model\SubscriberFactory; +use Magento\Customer\Helper\Data as CustomerHelper; + class Subscriber extends \Magento\App\Action\Action { - /** - * Session - * - * @var \Magento\Core\Model\Session - */ - protected $_session; - /** * Customer session * - * @var \Magento\Customer\Model\Session + * @var Session */ protected $_customerSession; /** - * Customer factory + * Customer Service * - * @var \Magento\Customer\Model\CustomerFactory + * @var CustomerAccountServiceInterface */ - protected $_customerFactory; + protected $_customerService; /** * Subscriber factory * - * @var \Magento\Newsletter\Model\SubscriberFactory + * @var SubscriberFactory */ protected $_subscriberFactory; /** - * @var \Magento\Core\Model\StoreManagerInterface + * @var StoreManagerInterface */ protected $_storeManager; /** - * @param \Magento\App\Action\Context $context - * @param \Magento\Newsletter\Model\SubscriberFactory $subscriberFactory - * @param \Magento\Customer\Model\CustomerFactory $customerFactory - * @param \Magento\Customer\Model\Session $customerSession - * @param \Magento\Core\Model\Session $session - * @param \Magento\Core\Model\StoreManagerInterface $storeManager + * @var CustomerHelper + */ + protected $_customerHelper; + + /** + * @param Context $context + * @param SubscriberFactory $subscriberFactory + * @param CustomerAccountServiceInterface $customerService + * @param Session $customerSession + * @param StoreManagerInterface $storeManager + * @param CustomerHelper $customerHelper */ public function __construct( - \Magento\App\Action\Context $context, - \Magento\Newsletter\Model\SubscriberFactory $subscriberFactory, - \Magento\Customer\Model\CustomerFactory $customerFactory, - \Magento\Customer\Model\Session $customerSession, - \Magento\Core\Model\Session $session, - \Magento\Core\Model\StoreManagerInterface $storeManager + Context $context, + SubscriberFactory $subscriberFactory, + CustomerAccountServiceInterface $customerService, + Session $customerSession, + StoreManagerInterface $storeManager, + CustomerHelper $customerHelper ) { - $this->_storeManager = $storeManager; parent::__construct($context); + $this->_storeManager = $storeManager; $this->_subscriberFactory = $subscriberFactory; - $this->_customerFactory = $customerFactory; + $this->_customerService = $customerService; $this->_customerSession = $customerSession; - $this->_session = $session; + $this->_customerHelper = $customerHelper; } /** @@ -104,33 +109,9 @@ public function newAction() $email = (string)$this->getRequest()->getPost('email'); try { - if (!\Zend_Validate::is($email, 'EmailAddress')) { - throw new \Magento\Model\Exception(__('Please enter a valid email address.')); - } - - if ($this->_objectManager->get( - 'Magento\Core\Model\Store\Config' - )->getConfig( - \Magento\Newsletter\Model\Subscriber::XML_PATH_ALLOW_GUEST_SUBSCRIBE_FLAG - ) != 1 && !$this->_customerSession->isLoggedIn() - ) { - throw new \Magento\Model\Exception( - __( - 'Sorry, but the administrator denied subscription for guests. ' . - 'Please register.', - $this->_objectManager->get('Magento\Customer\Helper\Data')->getRegisterUrl() - ) - ); - } - - $ownerId = $this->_customerFactory->create()->setWebsiteId( - $this->_storeManager->getStore()->getWebsiteId() - )->loadByEmail( - $email - )->getId(); - if ($ownerId !== null && $ownerId != $this->_customerSession->getId()) { - throw new \Magento\Model\Exception(__('This email address is already assigned to another user.')); - } + $this->validateEmailFormat($email); + $this->validateGuestSubscription(); + $this->validateEmailAvailable($email); $status = $this->_subscriberFactory->create()->subscribe($email); if ($status == \Magento\Newsletter\Model\Subscriber::STATUS_NOT_ACTIVE) { @@ -198,4 +179,57 @@ public function unsubscribeAction() } $this->getResponse()->setRedirect($this->_redirect->getRedirectUrl()); } + + /** + * Validates that the email address isn't being used by a different account. + * + * @param string $email + * @throws \Magento\Model\Exception + * @return void + */ + protected function validateEmailAvailable($email) + { + $websiteId = $this->_storeManager->getStore()->getWebsiteId(); + if ($this->_customerSession->getCustomerDataObject()->getEmail() !== $email + && !$this->_customerService->isEmailAvailable($email, $websiteId) + ) { + throw new \Magento\Model\Exception(__('This email address is already assigned to another user.')); + } + } + + /** + * Validates that if the current user is a guest, that they can subscribe to a newsletter. + * + * @throws \Magento\Model\Exception + * @return void + */ + protected function validateGuestSubscription() + { + if ($this->_objectManager->get('Magento\Core\Model\Store\Config') + ->getConfig(\Magento\Newsletter\Model\Subscriber::XML_PATH_ALLOW_GUEST_SUBSCRIBE_FLAG) != 1 + && !$this->_customerSession->isLoggedIn() + ) { + throw new \Magento\Model\Exception( + __( + 'Sorry, but the administrator denied subscription for guests. ' + . 'Please register.', + $this->_customerHelper->getRegisterUrl() + ) + ); + } + } + + /** + * Validates the format of the email address + * + * @param string $email + * @throws \Magento\Model\Exception + * @return void + */ + protected function validateEmailFormat($email) + { + if (!\Zend_Validate::is($email, 'EmailAddress')) { + throw new \Magento\Model\Exception(__('Please enter a valid email address.')); + } + } } diff --git a/app/code/Magento/Newsletter/Model/Observer.php b/app/code/Magento/Newsletter/Model/Observer.php index 8c126039745a3..4224d15cd1d9c 100644 --- a/app/code/Magento/Newsletter/Model/Observer.php +++ b/app/code/Magento/Newsletter/Model/Observer.php @@ -41,74 +41,33 @@ class Observer */ protected $_queueCollectionFactory; - /** - * Subscriber factory - * - * @var \Magento\Newsletter\Model\SubscriberFactory - */ - protected $_subscriberFactory; - /** * Construct * - * @param \Magento\Newsletter\Model\SubscriberFactory $subscriberFactory * @param \Magento\Newsletter\Model\Resource\Queue\CollectionFactory $queueCollectionFactory */ public function __construct( - \Magento\Newsletter\Model\SubscriberFactory $subscriberFactory, \Magento\Newsletter\Model\Resource\Queue\CollectionFactory $queueCollectionFactory ) { - $this->_subscriberFactory = $subscriberFactory; $this->_queueCollectionFactory = $queueCollectionFactory; } /** - * Subscribe customer handler - * - * @param \Magento\Object $observer - * @return $this - */ - public function subscribeCustomer($observer) - { - $customer = $observer->getEvent()->getCustomer(); - if ($customer instanceof \Magento\Customer\Model\Customer) { - $this->_subscriberFactory->create()->subscribeCustomer($customer); - } - return $this; - } - - /** - * Customer delete handler - * - * @param \Magento\Object $observer - * @return $this - */ - public function customerDeleted($observer) - { - /** @var \Magento\Newsletter\Model\Subscriber $subscriber */ - $subscriber = $this->_subscriberFactory->create(); - $subscriber->loadByEmail($observer->getEvent()->getCustomer()->getEmail()); - if ($subscriber->getId()) { - $subscriber->delete(); - } - return $this; - } - - /** - * Customer delete handler + * Scheduled send handler * * @param Schedule $schedule * @return void + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function scheduledSend($schedule) { - $countOfQueue = 3; - $countOfSubscritions = 20; + $countOfQueue = 3; + $countOfSubscriptions = 20; /** @var \Magento\Newsletter\Model\Resource\Queue\Collection $collection */ $collection = $this->_queueCollectionFactory->create(); $collection->setPageSize($countOfQueue)->setCurPage(1)->addOnlyForSendingFilter()->load(); - $collection->walk('sendPerSubscriber', array($countOfSubscritions)); + $collection->walk('sendPerSubscriber', array($countOfSubscriptions)); } } diff --git a/app/code/Magento/Newsletter/Model/Plugin/CustomerPlugin.php b/app/code/Magento/Newsletter/Model/Plugin/CustomerPlugin.php new file mode 100644 index 0000000000000..e0e1ab094ffa6 --- /dev/null +++ b/app/code/Magento/Newsletter/Model/Plugin/CustomerPlugin.php @@ -0,0 +1,113 @@ +subscriberFactory = $subscriberFactory; + } + + /** + * Plugin after create account that updates any newsletter subscription that may have existed. + * + * @param CustomerAccountServiceInterface $subject + * @param Customer $customer + * @return Customer + * + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function afterCreateAccount(CustomerAccountServiceInterface $subject, Customer $customer) + { + $this->subscriberFactory->create()->updateSubscription($customer->getId()); + + return $customer; + } + + /** + * Plugin around updating a customer account that updates any newsletter subscription that may have existed. + * + * @param CustomerAccountServiceInterface $subject + * @param callable $updateCustomer + * @param CustomerDetails $customerDetails + * @return void + * + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function aroundUpdateCustomer( + CustomerAccountServiceInterface $subject, + callable $updateCustomer, + CustomerDetails $customerDetails + ) { + $updateCustomer($customerDetails); + + $this->subscriberFactory->create()->updateSubscription($customerDetails->getCustomer()->getId()); + } + + /** + * Plugin after delete customer that updates any newsletter subscription that may have existed. + * + * @param CustomerAccountServiceInterface $subject + * @param callable $deleteCustomer Function we are wrapping around + * @param int $customerId Input to the function + * @return void + * + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function aroundDeleteCustomer( + CustomerAccountServiceInterface $subject, + callable $deleteCustomer, + $customerId + ) { + $customer = $subject->getCustomer($customerId); + + $deleteCustomer($customerId); + + /** @var \Magento\Newsletter\Model\Subscriber $subscriber */ + $subscriber = $this->subscriberFactory->create(); + $subscriber->loadByEmail($customer->getEmail()); + if ($subscriber->getId()) { + $subscriber->delete(); + } + } +} diff --git a/app/code/Magento/Newsletter/Model/Queue.php b/app/code/Magento/Newsletter/Model/Queue.php index 8deec1cad0c45..5e934a20930ad 100644 --- a/app/code/Magento/Newsletter/Model/Queue.php +++ b/app/code/Magento/Newsletter/Model/Queue.php @@ -52,7 +52,7 @@ * @method \Magento\Newsletter\Model\Queue setQueueFinishAt(string $value) * @SuppressWarnings(PHPMD.LongVariable) */ -class Queue extends \Magento\Core\Model\Template +class Queue extends \Magento\Email\Model\AbstractTemplate { /** * Newsletter Template object diff --git a/app/code/Magento/Newsletter/Model/Resource/Problem/Collection.php b/app/code/Magento/Newsletter/Model/Resource/Problem/Collection.php index 8f2a95f631ab0..ccb3321ad2eab 100644 --- a/app/code/Magento/Newsletter/Model/Resource/Problem/Collection.php +++ b/app/code/Magento/Newsletter/Model/Resource/Problem/Collection.php @@ -25,6 +25,9 @@ */ namespace Magento\Newsletter\Model\Resource\Problem; +use Magento\Customer\Service\V1\CustomerAccountServiceInterface; +use Magento\Exception\NoSuchEntityException; + /** * Newsletter problems collection * @@ -53,12 +56,35 @@ class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollectio */ protected $_customerCollectionFactory; + /** + * Customer Service + * + * @var CustomerAccountServiceInterface + */ + protected $_customerAccountService; + + /** + * Customer View Helper + * + * @var \Magento\Customer\Helper\View + */ + protected $_customerView; + + /** + * checks if customer data is loaded + * + * @var boolean + */ + protected $_loadCustomersDataFlag = false; + + /** * @param \Magento\Core\Model\EntityFactory $entityFactory * @param \Magento\Logger $logger * @param \Magento\Data\Collection\Db\FetchStrategyInterface $fetchStrategy * @param \Magento\Event\ManagerInterface $eventManager - * @param \Magento\Customer\Model\Resource\Customer\CollectionFactory $customerCollectionFactory + * @param CustomerAccountServiceInterface $customerAccountService, + * @param \Magento\Customer\Helper\View $customerView * @param null|\Zend_Db_Adapter_Abstract $connection * @param \Magento\Model\Resource\Db\AbstractDb $resource */ @@ -67,12 +93,14 @@ public function __construct( \Magento\Logger $logger, \Magento\Data\Collection\Db\FetchStrategyInterface $fetchStrategy, \Magento\Event\ManagerInterface $eventManager, - \Magento\Customer\Model\Resource\Customer\CollectionFactory $customerCollectionFactory, + CustomerAccountServiceInterface $customerAccountService, + \Magento\Customer\Helper\View $customerView, $connection = null, \Magento\Model\Resource\Db\AbstractDb $resource = null ) { parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $connection, $resource); - $this->_customerCollectionFactory = $customerCollectionFactory; + $this->_customerAccountService = $customerAccountService; + $this->_customerView = $customerView; } /** @@ -85,6 +113,19 @@ protected function _construct() $this->_init('Magento\Newsletter\Model\Problem', 'Magento\Newsletter\Model\Resource\Problem'); } + /** + * Set customer loaded status + * + * @param bool $flag + * @return $this + */ + protected function _setIsLoaded($flag = true) + { + if (!$flag) { + $this->_loadCustomersDataFlag = false; + } + return parent::_setIsLoaded($flag); + } /** * Adds subscribers info * @@ -129,34 +170,25 @@ public function addQueueInfo() */ protected function _addCustomersData() { - $customersIds = array(); - - foreach ($this->getItems() as $item) { - if ($item->getCustomerId()) { - $customersIds[] = $item->getCustomerId(); - } - } - - if (count($customersIds) == 0) { + if ($this->_loadCustomersDataFlag) { return; } - - /** @var \Magento\Customer\Model\Resource\Customer\Collection $customers */ - $customers = $this->_customerCollectionFactory->create(); - $customers->addNameToSelect()->addAttributeToFilter('entity_id', array("in" => $customersIds)); - - $customers->load(); - - foreach ($customers->getItems() as $customer) { - $problems = $this->getItemsByColumnValue('customer_id', $customer->getId()); - foreach ($problems as $problem) { - $problem->setCustomerName( - $customer->getName() - )->setCustomerFirstName( - $customer->getFirstName() - )->setCustomerLastName( - $customer->getLastName() - ); + $this->_loadCustomersDataFlag = true; + foreach ($this->getItems() as $item) { + if ($item->getCustomerId()) { + $customerId = $item->getCustomerId(); + try { + $customer = $this->_customerAccountService->getCustomer($customerId); + $problems = $this->getItemsByColumnValue('customer_id', $customerId); + $customerName = $this->_customerView->getCustomerName($customer); + foreach ($problems as $problem) { + $problem->setCustomerName($customerName) + ->setCustomerFirstName($customer->getFirstName()) + ->setCustomerLastName($customer->getLastName()); + } + } catch (NoSuchEntityException $e) { + // do nothing if customer is not found by id + } } } } @@ -171,7 +203,7 @@ protected function _addCustomersData() public function load($printQuery = false, $logQuery = false) { parent::load($printQuery, $logQuery); - if ($this->_subscribersInfoJoinedFlag && !$this->isLoaded()) { + if ($this->_subscribersInfoJoinedFlag) { $this->_addCustomersData(); } return $this; diff --git a/app/code/Magento/Newsletter/Model/Resource/Subscriber.php b/app/code/Magento/Newsletter/Model/Resource/Subscriber.php index 3c82cf898f847..35417d13b4dda 100644 --- a/app/code/Magento/Newsletter/Model/Resource/Subscriber.php +++ b/app/code/Magento/Newsletter/Model/Resource/Subscriber.php @@ -138,10 +138,10 @@ public function loadByEmail($subscriberEmail) /** * Load subscriber by customer * - * @param \Magento\Customer\Model\Customer $customer + * @param \Magento\Customer\Service\V1\Data\Customer $customer * @return array */ - public function loadByCustomer(\Magento\Customer\Model\Customer $customer) + public function loadByCustomerData(\Magento\Customer\Service\V1\Data\Customer $customer) { $select = $this->_read->select()->from($this->getMainTable())->where('customer_id=:customer_id'); diff --git a/app/code/Magento/Newsletter/Model/Resource/Subscriber/Collection.php b/app/code/Magento/Newsletter/Model/Resource/Subscriber/Collection.php index 0788cf15b8f4e..9748a9507c0e2 100644 --- a/app/code/Magento/Newsletter/Model/Resource/Subscriber/Collection.php +++ b/app/code/Magento/Newsletter/Model/Resource/Subscriber/Collection.php @@ -26,6 +26,7 @@ namespace Magento\Newsletter\Model\Resource\Subscriber; use Magento\Newsletter\Model\Queue as ModelQueue; +use Magento\Customer\Service\V1\CustomerMetadataServiceInterface as CustomerMetadataService; /** * Newsletter subscribers collection @@ -72,18 +73,18 @@ class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollectio protected $_countFilterPart = array(); /** - * Customer factory + * Customer Eav data * - * @var \Magento\Customer\Model\CustomerFactory + * @var \Magento\Eav\Helper\Data */ - protected $_customerFactory; + protected $_customerHelperData; /** * @param \Magento\Core\Model\EntityFactory $entityFactory * @param \Magento\Logger $logger * @param \Magento\Data\Collection\Db\FetchStrategyInterface $fetchStrategy * @param \Magento\Event\ManagerInterface $eventManager - * @param \Magento\Customer\Model\CustomerFactory $customerFactory + * @param \Magento\Eav\Helper\Data $customerHelperData * @param null|\Zend_Db_Adapter_Abstract $connection * @param \Magento\Model\Resource\Db\AbstractDb $resource */ @@ -92,12 +93,11 @@ public function __construct( \Magento\Logger $logger, \Magento\Data\Collection\Db\FetchStrategyInterface $fetchStrategy, \Magento\Event\ManagerInterface $eventManager, - \Magento\Customer\Model\CustomerFactory $customerFactory, + \Magento\Eav\Helper\Data $customerHelperData, $connection = null, \Magento\Model\Resource\Db\AbstractDb $resource = null ) { - // _customerFactory is used in parent class constructor - $this->_customerFactory = $customerFactory; + $this->_customerHelperData = $customerHelperData; parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $connection, $resource); } @@ -170,28 +170,35 @@ public function useOnlyUnsent() public function showCustomerInfo() { $adapter = $this->getConnection(); - /** @var \Magento\Customer\Model\Customer $customer */ - $customer = $this->_customerFactory->create(); - $firstname = $customer->getAttribute('firstname'); - $lastname = $customer->getAttribute('lastname'); - $this->getSelect()->joinLeft( - array('customer_lastname_table' => $lastname->getBackend()->getTable()), - $adapter->quoteInto( - 'customer_lastname_table.entity_id=main_table.customer_id - AND customer_lastname_table.attribute_id = ?', - (int)$lastname->getAttributeId() - ), - array('customer_lastname' => 'value') - )->joinLeft( - array('customer_firstname_table' => $firstname->getBackend()->getTable()), - $adapter->quoteInto( - 'customer_firstname_table.entity_id=main_table.customer_id - AND customer_firstname_table.attribute_id = ?', - (int)$firstname->getAttributeId() - ), - array('customer_firstname' => 'value') + $lastNameData = $this->_customerHelperData->getAttributeMetadata( + CustomerMetadataService::ENTITY_TYPE_CUSTOMER, + 'lastname' ); + $firstNameData = $this->_customerHelperData->getAttributeMetadata( + CustomerMetadataService::ENTITY_TYPE_CUSTOMER, + 'firstname' + ); + + $this->getSelect() + ->joinLeft( + array('customer_lastname_table' => $lastNameData['attribute_table']), + $adapter->quoteInto( + 'customer_lastname_table.entity_id=main_table.customer_id + AND customer_lastname_table.attribute_id = ?', + (int)$lastNameData['attribute_id'] + ), + array('customer_lastname' => 'value') + ) + ->joinLeft( + array('customer_firstname_table' => $firstNameData['attribute_table']), + $adapter->quoteInto( + 'customer_firstname_table.entity_id=main_table.customer_id + AND customer_firstname_table.attribute_id = ?', + (int)$firstNameData['attribute_id'] + ), + array('customer_firstname' => 'value') + ); return $this; } diff --git a/app/code/Magento/Newsletter/Model/Subscriber.php b/app/code/Magento/Newsletter/Model/Subscriber.php index d3b6d0b91f911..9e0cb2a6dbd0a 100644 --- a/app/code/Magento/Newsletter/Model/Subscriber.php +++ b/app/code/Magento/Newsletter/Model/Subscriber.php @@ -23,6 +23,9 @@ */ namespace Magento\Newsletter\Model; +use Magento\Customer\Service\V1\CustomerAccountServiceInterface; +use Magento\Exception\NoSuchEntityException; + /** * Subscriber model * @@ -42,31 +45,24 @@ * @method $this setSubscriberConfirmCode(string $value) * @method int getSubscriberId() * @method Subscriber setSubscriberId(int $value) + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ class Subscriber extends \Magento\Model\AbstractModel { const STATUS_SUBSCRIBED = 1; - const STATUS_NOT_ACTIVE = 2; - const STATUS_UNSUBSCRIBED = 3; - const STATUS_UNCONFIRMED = 4; const XML_PATH_CONFIRM_EMAIL_TEMPLATE = 'newsletter/subscription/confirm_email_template'; - const XML_PATH_CONFIRM_EMAIL_IDENTITY = 'newsletter/subscription/confirm_email_identity'; - const XML_PATH_SUCCESS_EMAIL_TEMPLATE = 'newsletter/subscription/success_email_template'; - const XML_PATH_SUCCESS_EMAIL_IDENTITY = 'newsletter/subscription/success_email_identity'; - const XML_PATH_UNSUBSCRIBE_EMAIL_TEMPLATE = 'newsletter/subscription/un_email_template'; - const XML_PATH_UNSUBSCRIBE_EMAIL_IDENTITY = 'newsletter/subscription/un_email_identity'; - const XML_PATH_CONFIRMATION_FLAG = 'newsletter/subscription/confirm'; - const XML_PATH_ALLOW_GUEST_SUBSCRIBE_FLAG = 'newsletter/subscription/allow_guest_subscribe'; /** @@ -121,11 +117,11 @@ class Subscriber extends \Magento\Model\AbstractModel protected $_storeManager; /** - * Customer factory + * Customer account service * - * @var \Magento\Customer\Model\CustomerFactory + * @var CustomerAccountServiceInterface */ - protected $_customerFactory; + protected $_customerAccountService; /** * @var \Magento\Mail\Template\TransportBuilder @@ -138,18 +134,22 @@ class Subscriber extends \Magento\Model\AbstractModel protected $inlineTranslation; /** - * @param \Magento\Model\Context $context - * @param \Magento\Registry $registry - * @param \Magento\Newsletter\Helper\Data $newsletterData - * @param \Magento\Core\Model\Store\Config $coreStoreConfig - * @param \Magento\Mail\Template\TransportBuilder $transportBuilder - * @param \Magento\Customer\Model\CustomerFactory $customerFactory + * Construct + * + * @param \Magento\Model\Context $context + * @param \Magento\Registry $registry + * @param \Magento\Newsletter\Helper\Data $newsletterData + * @param \Magento\Core\Model\Store\Config $coreStoreConfig + * @param \Magento\Mail\Template\TransportBuilder $transportBuilder * @param \Magento\Core\Model\StoreManagerInterface $storeManager - * @param \Magento\Customer\Model\Session $customerSession - * @param \Magento\Translate\Inline\StateInterface $inlineTranslation - * @param \Magento\Model\Resource\AbstractResource $resource - * @param \Magento\Data\Collection\Db $resourceCollection - * @param array $data + * @param \Magento\Customer\Model\Session $customerSession + * @param CustomerAccountServiceInterface $customerAccountService + * @param \Magento\Translate\Inline\StateInterface $inlineTranslation + * @param \Magento\Model\Resource\AbstractResource $resource + * @param \Magento\Data\Collection\Db $resourceCollection + * @param array $data + * + * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( \Magento\Model\Context $context, @@ -157,20 +157,20 @@ public function __construct( \Magento\Newsletter\Helper\Data $newsletterData, \Magento\Core\Model\Store\Config $coreStoreConfig, \Magento\Mail\Template\TransportBuilder $transportBuilder, - \Magento\Customer\Model\CustomerFactory $customerFactory, \Magento\Core\Model\StoreManagerInterface $storeManager, \Magento\Customer\Model\Session $customerSession, + CustomerAccountServiceInterface $customerAccountService, \Magento\Translate\Inline\StateInterface $inlineTranslation, \Magento\Model\Resource\AbstractResource $resource = null, \Magento\Data\Collection\Db $resourceCollection = null, - array $data = array() + array $data = [] ) { $this->_newsletterData = $newsletterData; $this->_coreStoreConfig = $coreStoreConfig; $this->_transportBuilder = $transportBuilder; - $this->_customerFactory = $customerFactory; $this->_storeManager = $storeManager; $this->_customerSession = $customerSession; + $this->_customerAccountService = $customerAccountService; $this->inlineTranslation = $inlineTranslation; parent::__construct($context, $registry, $resource, $resourceCollection, $data); } @@ -274,6 +274,7 @@ public function setStatus($value) * @param boolean $scope * @return $this */ + public function setMessagesScope($scope) { $this->getResource()->setMessagesScope($scope); @@ -307,9 +308,9 @@ public function setEmail($value) * @param boolean $value * @return $this */ - public function setIsStatusChanged($value) + public function setStatusChanged($value) { - $this->_isStatusChanged = (bool)$value; + $this->_isStatusChanged = (boolean) $value; return $this; } @@ -318,7 +319,7 @@ public function setIsStatusChanged($value) * * @return boolean */ - public function getIsStatusChanged() + public function isStatusChanged() { return $this->_isStatusChanged; } @@ -355,19 +356,19 @@ public function loadByEmail($subscriberEmail) * @param int $customerId * @return $this */ - public function loadByCustomer($customerId) + public function loadByCustomerId($customerId) { - /** @var \Magento\Customer\Model\Customer $customer */ - $customer = $this->_customerFactory->create()->load($customerId); - $data = $this->getResource()->loadByCustomer($customer); - $this->addData($data); - if (!empty($data) && $customer->getId() && !$this->getCustomerId()) { - $this->setCustomerId($customer->getId()); - $this->setSubscriberConfirmCode($this->randomSequence()); - if ($this->getStatus() == self::STATUS_NOT_ACTIVE) { - $this->setStatus($customer->getIsSubscribed() ? self::STATUS_SUBSCRIBED : self::STATUS_UNSUBSCRIBED); + try { + /** @var \Magento\Customer\Service\V1\Data\Customer $customerData */ + $customerData = $this->_customerAccountService->getCustomer($customerId); + $data = $this->getResource()->loadByCustomerData($customerData); + $this->addData($data); + if (!empty($data) && $customerData->getId() && !$this->getCustomerId()) { + $this->setCustomerId($customerData->getId()); + $this->setSubscriberConfirmCode($this->randomSequence()); + $this->save(); } - $this->save(); + } catch (\Magento\Exception\NoSuchEntityException $e) { } return $this; } @@ -398,6 +399,9 @@ public function randomSequence($length = 32) * @param string $email * @throws \Exception * @return int + * + * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * @SuppressWarnings(PHPMD.NPathComplexity) */ public function subscribe($email) { @@ -407,18 +411,14 @@ public function subscribe($email) $this->setSubscriberConfirmCode($this->randomSequence()); } - $isConfirmNeed = $this->_coreStoreConfig->getConfig(self::XML_PATH_CONFIRMATION_FLAG) == 1 ? true : false; + $isConfirmNeed = ($this->_coreStoreConfig->getConfig(self::XML_PATH_CONFIRMATION_FLAG) == 1) ? true : false; $isOwnSubscribes = false; - $ownerId = $this->_customerFactory->create()->setWebsiteId( - $this->_storeManager->getStore()->getWebsiteId() - )->loadByEmail( - $email - )->getId(); - $isSubscribeOwnEmail = $this->_customerSession->isLoggedIn() && $ownerId == $this->_customerSession->getId(); - - if (!$this->getId() || - $this->getStatus() == self::STATUS_UNSUBSCRIBED || - $this->getStatus() == self::STATUS_NOT_ACTIVE + + $isSubscribeOwnEmail = $this->_customerSession->isLoggedIn() + && $this->_customerSession->getCustomerDataObject()->getEmail() == $email; + + if (!$this->getId() || $this->getStatus() == self::STATUS_UNSUBSCRIBED + || $this->getStatus() == self::STATUS_NOT_ACTIVE ) { if ($isConfirmNeed === true) { // if user subscribes own login email - confirmation is not needed @@ -435,25 +435,30 @@ public function subscribe($email) } if ($isSubscribeOwnEmail) { - /** @var \Magento\Customer\Model\Customer $customer */ - $customer = $this->_customerFactory->create()->load($this->_customerSession->getCustomerId()); - $this->setStoreId($customer->getStoreId()); - $this->setCustomerId($customer->getId()); + try { + $customer = $this->_customerAccountService->getCustomer($this->_customerSession->getCustomerId()); + $this->setStoreId($customer->getStoreId()); + $this->setCustomerId($customer->getId()); + } catch (NoSuchEntityException $e) { + $this->setStoreId($this->_storeManager->getStore()->getId()); + $this->setCustomerId(0); + } } else { $this->setStoreId($this->_storeManager->getStore()->getId()); $this->setCustomerId(0); } - $this->setIsStatusChanged(true); + $this->setStatusChanged(true); try { $this->save(); - if ($isConfirmNeed === true && $isOwnSubscribes === false) { + if ($isConfirmNeed === true + && $isOwnSubscribes === false + ) { $this->sendConfirmationRequestEmail(); } else { $this->sendConfirmationSuccessEmail(); } - return $this->getStatus(); } catch (\Exception $e) { throw new \Exception($e->getMessage()); @@ -472,46 +477,68 @@ public function unsubscribe() throw new \Magento\Model\Exception(__('This is an invalid subscription confirmation code.')); } - $this->setSubscriberStatus(self::STATUS_UNSUBSCRIBED)->save(); - $this->sendUnsubscriptionEmail(); + if ($this->getSubscriberStatus() != self::STATUS_UNSUBSCRIBED) { + $this->setSubscriberStatus(self::STATUS_UNSUBSCRIBED)->save(); + $this->sendUnsubscriptionEmail(); + } return $this; } /** - * Update newsletter subscription for given customer + * Subscribe the customer with the id provided * * @param int $customerId - * @param boolean $subscribe + * @return $this + */ + public function subscribeCustomerById($customerId) + { + return $this->_updateCustomerSubscription($customerId, true); + } + + /** + * unsubscribe the customer with the id provided * - * @return \Magento\Newsletter\Model\Subscriber + * @param int $customerId + * @return $this */ - public function updateSubscription($customerId, $subscribe) + public function unsubscribeCustomerById($customerId) { - /** @var \Magento\Customer\Model\Customer $customerModel */ - $customerModel = $this->_customerFactory->create()->load($customerId); - $customerModel->setIsSubscribed($subscribe); - $this->subscribeCustomer($customerModel); + return $this->_updateCustomerSubscription($customerId, false); + } + /** + * Update the subscription based on latest information of associated customer. + * + * @param int $customerId + * @return $this + */ + public function updateSubscription($customerId) + { + $this->loadByCustomerId($customerId); + $this->_updateCustomerSubscription($customerId, $this->isSubscribed()); return $this; } /** * Saving customer subscription status * - * @param \Magento\Customer\Model\Customer $customer + * @param int $customerId + * @param bool $subscribe indicates whether the customer should be subscribed or unsubscribed * @return $this + * + * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * @SuppressWarnings(PHPMD.NPathComplexity) */ - public function subscribeCustomer($customer) + protected function _updateCustomerSubscription($customerId, $subscribe) { - $this->loadByCustomer($customer->getId()); - - if ($customer->getImportMode()) { - $this->setImportMode(true); + try { + $customerData = $this->_customerAccountService->getCustomer($customerId); + } catch (NoSuchEntityException $e) { + return $this; } - if (!$customer->getIsSubscribed() && !$this->getId()) { - // If subscription flag not set or customer is not a subscriber - // and no subscribe below + $this->loadByCustomerId($customerId); + if (!$subscribe && !$this->getId()) { return $this; } @@ -519,54 +546,49 @@ public function subscribeCustomer($customer) $this->setSubscriberConfirmCode($this->randomSequence()); } - /* - * Logical mismatch between customer registration confirmation code and customer password confirmation - */ - $confirmation = null; - if ($customer->isConfirmationRequired() && $customer->getConfirmation() != $customer->getPassword()) { - $confirmation = $customer->getConfirmation(); - } - $sendInformationEmail = false; - if ($customer->hasIsSubscribed()) { - $status = $customer->getIsSubscribed() ? !is_null( - $confirmation - ) ? self::STATUS_UNCONFIRMED : self::STATUS_SUBSCRIBED : self::STATUS_UNSUBSCRIBED; - /** - * If subscription status has been changed then send email to the customer - */ - if ($status != self::STATUS_UNCONFIRMED && $status != $this->getStatus()) { - $sendInformationEmail = true; + $status = self::STATUS_SUBSCRIBED; + if ($subscribe) { + if (CustomerAccountServiceInterface::ACCOUNT_CONFIRMATION_REQUIRED + == $this->_customerAccountService->getConfirmationStatus($customerId) + ) { + $status = self::STATUS_UNCONFIRMED; } - } elseif ($this->getStatus() == self::STATUS_UNCONFIRMED && is_null($confirmation)) { - $status = self::STATUS_SUBSCRIBED; - $sendInformationEmail = true; } else { - $status = $this->getStatus() == self::STATUS_NOT_ACTIVE ? self::STATUS_UNSUBSCRIBED : $this->getStatus(); + $status = self::STATUS_UNSUBSCRIBED; + } + /** + * If subscription status has been changed then send email to the customer + */ + if ($status != self::STATUS_UNCONFIRMED && $status != $this->getStatus()) { + $sendInformationEmail = true; } if ($status != $this->getStatus()) { - $this->setIsStatusChanged(true); + $this->setStatusChanged(true); } $this->setStatus($status); if (!$this->getId()) { - $storeId = $customer->getStoreId(); - if ($customer->getStoreId() == 0) { - $storeId = $this->_storeManager->getWebsite($customer->getWebsiteId())->getDefaultStore()->getId(); + $storeId = $customerData->getStoreId(); + if ($customerData->getStoreId() == 0) { + $storeId = $this->_storeManager->getWebsite($customerData->getWebsiteId())->getDefaultStore()->getId(); } - $this->setStoreId($storeId)->setCustomerId($customer->getId())->setEmail($customer->getEmail()); + $this->setStoreId($storeId) + ->setCustomerId($customerData->getId()) + ->setEmail($customerData->getEmail()); } else { - $this->setStoreId($customer->getStoreId())->setEmail($customer->getEmail()); + $this->setStoreId($customerData->getStoreId()) + ->setEmail($customerData->getEmail()); } $this->save(); - $sendSubscription = $customer->getData('sendSubscription') || $sendInformationEmail; + $sendSubscription = $sendInformationEmail; if (is_null($sendSubscription) xor $sendSubscription) { - if ($this->getIsStatusChanged() && $status == self::STATUS_UNSUBSCRIBED) { + if ($this->isStatusChanged() && $status == self::STATUS_UNSUBSCRIBED) { $this->sendUnsubscriptionEmail(); - } elseif ($this->getIsStatusChanged() && $status == self::STATUS_SUBSCRIBED) { + } elseif ($this->isStatusChanged() && $status == self::STATUS_SUBSCRIBED) { $this->sendConfirmationSuccessEmail(); } } @@ -582,7 +604,9 @@ public function subscribeCustomer($customer) public function confirm($code) { if ($this->getCode() == $code) { - $this->setStatus(self::STATUS_SUBSCRIBED)->setIsStatusChanged(true)->save(); + $this->setStatus(self::STATUS_SUBSCRIBED) + ->setStatusChanged(true) + ->save(); return true; } @@ -608,36 +632,32 @@ public function received(\Magento\Newsletter\Model\Queue $queue) */ public function sendConfirmationRequestEmail() { - if ($this->getImportMode()) { - return $this; - } - - if (!$this->_coreStoreConfig->getConfig( - self::XML_PATH_CONFIRM_EMAIL_TEMPLATE - ) || !$this->_coreStoreConfig->getConfig( - self::XML_PATH_CONFIRM_EMAIL_IDENTITY - ) + if (!$this->_coreStoreConfig->getConfig(self::XML_PATH_CONFIRM_EMAIL_TEMPLATE) + || !$this->_coreStoreConfig->getConfig(self::XML_PATH_CONFIRM_EMAIL_IDENTITY) ) { return $this; } $this->inlineTranslation->suspend(); - $this->_transportBuilder->setTemplateIdentifier( - $this->_coreStoreConfig->getConfig(self::XML_PATH_CONFIRM_EMAIL_TEMPLATE) - )->setTemplateOptions( - array( - 'area' => \Magento\Core\Model\App\Area::AREA_FRONTEND, - 'store' => $this->_storeManager->getStore()->getId() + $this->_transportBuilder + ->setTemplateIdentifier( + $this->_coreStoreConfig->getConfig(self::XML_PATH_CONFIRM_EMAIL_TEMPLATE) + ) + ->setTemplateOptions( + array( + 'area' => \Magento\Core\Model\App\Area::AREA_FRONTEND, + 'store' => $this->_storeManager->getStore()->getId(), + ) + ) + ->setTemplateVars( + array( + 'subscriber' => $this, + 'store' => $this->_storeManager->getStore(), + ) ) - )->setTemplateVars( - array('subscriber' => $this, 'store' => $this->_storeManager->getStore()) - )->setFrom( - $this->_coreStoreConfig->getConfig(self::XML_PATH_CONFIRM_EMAIL_IDENTITY) - )->addTo( - $this->getEmail(), - $this->getName() - ); + ->setFrom($this->_coreStoreConfig->getConfig(self::XML_PATH_CONFIRM_EMAIL_IDENTITY)) + ->addTo($this->getEmail(), $this->getName()); $transport = $this->_transportBuilder->getTransport(); $transport->sendMessage(); @@ -653,36 +673,27 @@ public function sendConfirmationRequestEmail() */ public function sendConfirmationSuccessEmail() { - if ($this->getImportMode()) { - return $this; - } - - if (!$this->_coreStoreConfig->getConfig( - self::XML_PATH_SUCCESS_EMAIL_TEMPLATE - ) || !$this->_coreStoreConfig->getConfig( - self::XML_PATH_SUCCESS_EMAIL_IDENTITY - ) + if (!$this->_coreStoreConfig->getConfig(self::XML_PATH_SUCCESS_EMAIL_TEMPLATE) + || !$this->_coreStoreConfig->getConfig(self::XML_PATH_SUCCESS_EMAIL_IDENTITY) ) { return $this; } $this->inlineTranslation->suspend(); - $this->_transportBuilder->setTemplateIdentifier( - $this->_coreStoreConfig->getConfig(self::XML_PATH_SUCCESS_EMAIL_TEMPLATE) - )->setTemplateOptions( - array( - 'area' => \Magento\Core\Model\App\Area::AREA_FRONTEND, - 'store' => $this->_storeManager->getStore()->getId() + $this->_transportBuilder + ->setTemplateIdentifier( + $this->_coreStoreConfig->getConfig(self::XML_PATH_SUCCESS_EMAIL_TEMPLATE) + ) + ->setTemplateOptions( + array( + 'area' => \Magento\Core\Model\App\Area::AREA_FRONTEND, + 'store' => $this->_storeManager->getStore()->getId(), + ) ) - )->setTemplateVars( - array('subscriber' => $this) - )->setFrom( - $this->_coreStoreConfig->getConfig(self::XML_PATH_SUCCESS_EMAIL_IDENTITY) - )->addTo( - $this->getEmail(), - $this->getName() - ); + ->setTemplateVars(array('subscriber' => $this)) + ->setFrom($this->_coreStoreConfig->getConfig(self::XML_PATH_SUCCESS_EMAIL_IDENTITY)) + ->addTo($this->getEmail(), $this->getName()); $transport = $this->_transportBuilder->getTransport(); $transport->sendMessage(); @@ -692,41 +703,35 @@ public function sendConfirmationSuccessEmail() } /** - * Sends out unsubsciption email + * Sends out unsubscription email * * @return $this */ public function sendUnsubscriptionEmail() { - if ($this->getImportMode()) { - return $this; - } - if (!$this->_coreStoreConfig->getConfig( - self::XML_PATH_UNSUBSCRIBE_EMAIL_TEMPLATE - ) || !$this->_coreStoreConfig->getConfig( - self::XML_PATH_UNSUBSCRIBE_EMAIL_IDENTITY - ) + if (!$this->_coreStoreConfig->getConfig(self::XML_PATH_UNSUBSCRIBE_EMAIL_TEMPLATE) + || !$this->_coreStoreConfig->getConfig(self::XML_PATH_UNSUBSCRIBE_EMAIL_IDENTITY) ) { return $this; } $this->inlineTranslation->suspend(); - $this->_transportBuilder->setTemplateIdentifier( - $this->_coreStoreConfig->getConfig(self::XML_PATH_UNSUBSCRIBE_EMAIL_TEMPLATE) - )->setTemplateOptions( - array( - 'area' => \Magento\Core\Model\App\Area::AREA_FRONTEND, - 'store' => $this->_storeManager->getStore()->getId() + $this->_transportBuilder + ->setTemplateIdentifier( + $this->_coreStoreConfig->getConfig(self::XML_PATH_UNSUBSCRIBE_EMAIL_TEMPLATE) + ) + ->setTemplateOptions( + array( + 'area' => \Magento\Core\Model\App\Area::AREA_FRONTEND, + 'store' => $this->_storeManager->getStore()->getId(), + ) + ) + ->setTemplateVars(array('subscriber' => $this)) + ->setFrom( + $this->_coreStoreConfig->getConfig(self::XML_PATH_UNSUBSCRIBE_EMAIL_IDENTITY) ) - )->setTemplateVars( - array('subscriber' => $this) - )->setFrom( - $this->_coreStoreConfig->getConfig(self::XML_PATH_UNSUBSCRIBE_EMAIL_IDENTITY) - )->addTo( - $this->getEmail(), - $this->getName() - ); + ->addTo($this->getEmail(), $this->getName()); $transport = $this->_transportBuilder->getTransport(); $transport->sendMessage(); diff --git a/app/code/Magento/Newsletter/Model/Template.php b/app/code/Magento/Newsletter/Model/Template.php index d89072784581a..7dc5599208062 100644 --- a/app/code/Magento/Newsletter/Model/Template.php +++ b/app/code/Magento/Newsletter/Model/Template.php @@ -55,7 +55,7 @@ * @package Magento_Newsletter * @author Magento Core Team */ -class Template extends \Magento\Core\Model\Template +class Template extends \Magento\Email\Model\AbstractTemplate { /** * Template Text Preprocessed flag diff --git a/app/code/Magento/Newsletter/etc/di.xml b/app/code/Magento/Newsletter/etc/di.xml index 07207a43f0903..0a08e03ee4c76 100644 --- a/app/code/Magento/Newsletter/etc/di.xml +++ b/app/code/Magento/Newsletter/etc/di.xml @@ -41,4 +41,8 @@ Magento\Newsletter\Model\Session\Storage + + + diff --git a/app/code/Magento/Newsletter/etc/module.xml b/app/code/Magento/Newsletter/etc/module.xml index d0a50f7071db7..c42ffa6cf9019 100644 --- a/app/code/Magento/Newsletter/etc/module.xml +++ b/app/code/Magento/Newsletter/etc/module.xml @@ -40,6 +40,7 @@ + diff --git a/app/code/Magento/PageCache/view/frontend/js/page-cache.js b/app/code/Magento/PageCache/view/frontend/js/page-cache.js index 33a3cbb5e6bcd..3dc403f950013 100644 --- a/app/code/Magento/PageCache/view/frontend/js/page-cache.js +++ b/app/code/Magento/PageCache/view/frontend/js/page-cache.js @@ -82,7 +82,7 @@ startReplacing = true; } if (startReplacing) { - element.remove(); + $(element).remove(); } else if (element.nodeType != 8) { //due to comment tag doesn't have siblings we try to find it manually prevSibling = element; diff --git a/app/code/Magento/Paypal/Block/Adminhtml/System/Config/Fieldset/Expanded.php b/app/code/Magento/Paypal/Block/Adminhtml/System/Config/Fieldset/Expanded.php index 3e1a46bc9f932..d099623ee74ff 100644 --- a/app/code/Magento/Paypal/Block/Adminhtml/System/Config/Fieldset/Expanded.php +++ b/app/code/Magento/Paypal/Block/Adminhtml/System/Config/Fieldset/Expanded.php @@ -35,13 +35,13 @@ class Expanded extends \Magento\Backend\Block\System\Config\Form\Fieldset /** * @param \Magento\Backend\Block\Context $context * @param \Magento\Backend\Model\Auth\Session $authSession - * @param \Magento\Core\Helper\Js $jsHelper + * @param \Magento\View\Helper\Js $jsHelper * @param array $data */ public function __construct( \Magento\Backend\Block\Context $context, \Magento\Backend\Model\Auth\Session $authSession, - \Magento\Core\Helper\Js $jsHelper, + \Magento\View\Helper\Js $jsHelper, array $data = array() ) { parent::__construct($context, $authSession, $jsHelper, $data); diff --git a/app/code/Magento/Paypal/Block/Adminhtml/System/Config/Fieldset/Group.php b/app/code/Magento/Paypal/Block/Adminhtml/System/Config/Fieldset/Group.php index 83275c30d84ae..f7da301d31e5f 100644 --- a/app/code/Magento/Paypal/Block/Adminhtml/System/Config/Fieldset/Group.php +++ b/app/code/Magento/Paypal/Block/Adminhtml/System/Config/Fieldset/Group.php @@ -34,13 +34,13 @@ class Group extends \Magento\Backend\Block\System\Config\Form\Fieldset /** * @param \Magento\Backend\Block\Context $context * @param \Magento\Backend\Model\Auth\Session $authSession - * @param \Magento\Core\Helper\Js $jsHelper + * @param \Magento\View\Helper\Js $jsHelper * @param array $data */ public function __construct( \Magento\Backend\Block\Context $context, \Magento\Backend\Model\Auth\Session $authSession, - \Magento\Core\Helper\Js $jsHelper, + \Magento\View\Helper\Js $jsHelper, array $data = array() ) { parent::__construct($context, $authSession, $jsHelper, $data); diff --git a/app/code/Magento/Paypal/Block/Adminhtml/System/Config/Fieldset/Hint.php b/app/code/Magento/Paypal/Block/Adminhtml/System/Config/Fieldset/Hint.php index e473e324d0b77..ac67605590289 100644 --- a/app/code/Magento/Paypal/Block/Adminhtml/System/Config/Fieldset/Hint.php +++ b/app/code/Magento/Paypal/Block/Adminhtml/System/Config/Fieldset/Hint.php @@ -37,18 +37,18 @@ class Hint extends \Magento\Backend\Block\Template implements \Magento\Data\Form protected $_template = 'Magento_Paypal::system/config/fieldset/hint.phtml'; /** - * @var \Magento\Backend\Helper\Js + * @var \Magento\View\Helper\Js */ protected $_jsHelper; /** * @param \Magento\Backend\Block\Template\Context $context - * @param \Magento\Backend\Helper\Js $jsHelper + * @param \Magento\View\Helper\Js $jsHelper * @param array $data */ public function __construct( \Magento\Backend\Block\Template\Context $context, - \Magento\Backend\Helper\Js $jsHelper, + \Magento\View\Helper\Js $jsHelper, array $data = array() ) { $this->_jsHelper = $jsHelper; diff --git a/app/code/Magento/Paypal/Block/Adminhtml/System/Config/Fieldset/Payment.php b/app/code/Magento/Paypal/Block/Adminhtml/System/Config/Fieldset/Payment.php index 48d1a175933dc..15b5e20a3c1fd 100644 --- a/app/code/Magento/Paypal/Block/Adminhtml/System/Config/Fieldset/Payment.php +++ b/app/code/Magento/Paypal/Block/Adminhtml/System/Config/Fieldset/Payment.php @@ -38,14 +38,14 @@ class Payment extends \Magento\Backend\Block\System\Config\Form\Fieldset /** * @param \Magento\Backend\Block\Context $context * @param \Magento\Backend\Model\Auth\Session $authSession - * @param \Magento\Core\Helper\Js $jsHelper + * @param \Magento\View\Helper\Js $jsHelper * @param \Magento\Backend\Model\Config $backendConfig * @param array $data */ public function __construct( \Magento\Backend\Block\Context $context, \Magento\Backend\Model\Auth\Session $authSession, - \Magento\Core\Helper\Js $jsHelper, + \Magento\View\Helper\Js $jsHelper, \Magento\Backend\Model\Config $backendConfig, array $data = array() ) { diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Load.php b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Load.php index b292e265e882e..9371e199b438a 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Load.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Load.php @@ -35,11 +35,9 @@ class Load extends \Magento\View\Element\Template { /** - * Adminhtml js - * - * @var \Magento\Backend\Helper\Js + * @var \Magento\View\Helper\Js */ - protected $_adminhtmlJs = null; + protected $_jsHelper = null; /** * Json encoder @@ -51,17 +49,17 @@ class Load extends \Magento\View\Element\Template /** * @param \Magento\View\Element\Template\Context $context * @param \Magento\Json\EncoderInterface $jsonEncoder - * @param \Magento\Backend\Helper\Js $adminhtmlJs + * @param \Magento\View\Helper\Js $adminhtmlJs * @param array $data */ public function __construct( \Magento\View\Element\Template\Context $context, \Magento\Json\EncoderInterface $jsonEncoder, - \Magento\Backend\Helper\Js $adminhtmlJs, + \Magento\View\Helper\Js $jsHelper, array $data = array() ) { $this->_jsonEncoder = $jsonEncoder; - $this->_adminhtmlJs = $adminhtmlJs; + $this->_jsHelper = $jsHelper; parent::__construct($context, $data); } @@ -80,7 +78,7 @@ protected function _toHtml() $resultJson = $this->_jsonEncoder->encode($result); $jsVarname = $this->getRequest()->getParam('as_js_varname'); if ($jsVarname) { - return $this->_adminhtmlJs->getScript(sprintf('var %s = %s', $jsVarname, $resultJson)); + return $this->_jsHelper->getScript(sprintf('var %s = %s', $jsVarname, $resultJson)); } else { return $resultJson; } diff --git a/app/code/Magento/Sales/Block/Adminhtml/System/Config/Form/Fieldset/Order/Statuses.php b/app/code/Magento/Sales/Block/Adminhtml/System/Config/Form/Fieldset/Order/Statuses.php index 3a8c04b49260b..b3acf2a405be5 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/System/Config/Form/Fieldset/Order/Statuses.php +++ b/app/code/Magento/Sales/Block/Adminhtml/System/Config/Form/Fieldset/Order/Statuses.php @@ -56,14 +56,14 @@ class Statuses extends \Magento\Backend\Block\System\Config\Form\Fieldset /** * @param \Magento\Backend\Block\Context $context * @param \Magento\Backend\Model\Auth\Session $authSession - * @param \Magento\Core\Helper\Js $jsHelper + * @param \Magento\View\Helper\Js $jsHelper * @param \Magento\Sales\Model\Resource\Order\Status\CollectionFactory $orderStatusCollection * @param array $data */ public function __construct( \Magento\Backend\Block\Context $context, \Magento\Backend\Model\Auth\Session $authSession, - \Magento\Core\Helper\Js $jsHelper, + \Magento\View\Helper\Js $jsHelper, \Magento\Sales\Model\Resource\Order\Status\CollectionFactory $orderStatusCollection, array $data = array() ) { diff --git a/app/code/Magento/Sales/Model/Quote.php b/app/code/Magento/Sales/Model/Quote.php index c8ef7835159d1..107be83eeac88 100644 --- a/app/code/Magento/Sales/Model/Quote.php +++ b/app/code/Magento/Sales/Model/Quote.php @@ -520,7 +520,7 @@ protected function _afterSave() */ public function loadByCustomer($customer) { - /* @TODO: remove this if after external usages of loadByCustomer are refactored in MAGETWO-19935 */ + /* @TODO: remove this if after external usages of loadByCustomerId are refactored in MAGETWO-19935 */ if ($customer instanceof \Magento\Customer\Model\Customer) { $customerId = $customer->getId(); } else { @@ -1248,9 +1248,9 @@ public function addItem(\Magento\Sales\Model\Quote\Item $item) */ if ($item->isNominal() && $this->hasItems() || $this->hasNominalItems()) { throw new \Magento\Model\Exception( - __( - 'Sorry, but items with payment agreements must be ordered one at a time To continue, please remove or buy the other items in your cart, then order this item by itself.' - ) + // @codingStandardsIgnoreStart + __('Sorry, but items with payment agreements must be ordered one at a time To continue, please remove or buy the other items in your cart, then order this item by itself.') + // @codingStandardsIgnoreEnd ); } diff --git a/app/code/Magento/Theme/Block/Html/Head.php b/app/code/Magento/Theme/Block/Html/Head.php index 7e0dd63a13a05..7c7ba551b9126 100644 --- a/app/code/Magento/Theme/Block/Html/Head.php +++ b/app/code/Magento/Theme/Block/Html/Head.php @@ -25,6 +25,8 @@ /** * Html page head block + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class Head extends \Magento\View\Element\Template { @@ -81,6 +83,11 @@ class Head extends \Magento\View\Element\Template */ protected $_localeResolver; + /** + * @var \Magento\Translation\Block\Js + */ + protected $jsTranslation; + /** * @param \Magento\View\Element\Template\Context $context * @param \Magento\Core\Helper\File\Storage\Database $fileStorageDatabase @@ -89,6 +96,7 @@ class Head extends \Magento\View\Element\Template * @param \Magento\View\Asset\MergeService $assetMergeService * @param \Magento\View\Asset\MinifyService $assetMinifyService * @param \Magento\Locale\ResolverInterface $localeResolver + * @param \Magento\Translation\Block\Js $jsTranslation * @param array $data */ public function __construct( @@ -99,6 +107,7 @@ public function __construct( \Magento\View\Asset\MergeService $assetMergeService, \Magento\View\Asset\MinifyService $assetMinifyService, \Magento\Locale\ResolverInterface $localeResolver, + \Magento\Translation\Block\Js $jsTranslation, array $data = array() ) { parent::__construct($context, $data); @@ -108,6 +117,7 @@ public function __construct( $this->_assetMinifyService = $assetMinifyService; $this->_pageAssets = $assets; $this->_localeResolver = $localeResolver; + $this->jsTranslation = $jsTranslation; } /** @@ -430,4 +440,14 @@ public function getLocale() { return substr($this->_localeResolver->getLocaleCode(), 0, 2); } + + /** + * Get translation js script + * + * @return string + */ + public function getTranslatorScript() + { + return $this->jsTranslation->render(); + } } diff --git a/app/code/Magento/Theme/etc/module.xml b/app/code/Magento/Theme/etc/module.xml index 7f04c333af8c6..cf9c8838efc64 100644 --- a/app/code/Magento/Theme/etc/module.xml +++ b/app/code/Magento/Theme/etc/module.xml @@ -33,6 +33,7 @@ + diff --git a/app/code/Magento/Theme/view/frontend/html/head.phtml b/app/code/Magento/Theme/view/frontend/html/head.phtml index a28219d0e12d5..f928e850a6934 100644 --- a/app/code/Magento/Theme/view/frontend/html/head.phtml +++ b/app/code/Magento/Theme/view/frontend/html/head.phtml @@ -33,4 +33,4 @@ getCssJsHtml() ?> getChildHtml() ?> getIncludes() ?> -helper('Magento\Core\Helper\Js')->getTranslatorScript() ?> +getTranslatorScript(); ?> diff --git a/app/code/Magento/Translation/Block/Js.php b/app/code/Magento/Translation/Block/Js.php new file mode 100644 index 0000000000000..a04fd25fa6b4f --- /dev/null +++ b/app/code/Magento/Translation/Block/Js.php @@ -0,0 +1,71 @@ +dataProvider = $dataProvider; + $this->translateInline = $translateInline; + } + + /** + * Render js translation + * + * @return string + */ + public function render() + { + $json = \Zend_Json::encode($this->dataProvider->getTranslateData()); + $this->translateInline->processResponseBody($json, false); + $script = '(function($) {$.mage.translate.add(' . $json . ')})(jQuery);'; + return ''; + } +} diff --git a/app/code/Magento/Translation/Model/Js.php b/app/code/Magento/Translation/Model/Js.php new file mode 100644 index 0000000000000..7a6f961ab1a19 --- /dev/null +++ b/app/code/Magento/Translation/Model/Js.php @@ -0,0 +1,60 @@ +getData() as $key => $translatedText) { + if ($key !== $translatedText) { + $this->translateData[$key] = $translatedText; + } + } + } + } + + /** + * Get translated data + * + * @return string[] + */ + public function getTranslateData() + { + return $this->translateData; + } +} diff --git a/app/code/Magento/Translation/Model/Js/DataProvider.php b/app/code/Magento/Translation/Model/Js/DataProvider.php new file mode 100644 index 0000000000000..52bff3f69fb29 --- /dev/null +++ b/app/code/Magento/Translation/Model/Js/DataProvider.php @@ -0,0 +1,176 @@ + __('Complete'), + 'Upload Security Error' => __('Upload Security Error'), + 'Upload HTTP Error' => __('Upload HTTP Error'), + 'Upload I/O Error' => __('Upload I/O Error'), + 'SSL Error: Invalid or self-signed certificate' => __('SSL Error: Invalid or self-signed certificate'), + 'TB' => __('TB'), + 'GB' => __('GB'), + 'MB' => __('MB'), + 'kB' => __('kB'), + 'B' => __('B'), + 'Add Products' => __('Add Products'), + 'Add Products By SKU' => __('Add Products By SKU'), + 'Insert Widget...' => __('Insert Widget...'), + 'Please wait, loading...' => __('Please wait, loading...'), + 'HTML tags are not allowed' => __('HTML tags are not allowed'), + 'Please select an option.' => __('Please select an option.'), + 'This is a required field.' => __('This is a required field.'), + 'Please enter a valid number in this field.' => __('Please enter a valid number in this field.'), + 'The value is not within the specified range.' => __('The value is not within the specified range.'), + 'Please use numbers only in this field. Please avoid spaces or other characters such as dots or commas.' => __('Please use numbers only in this field. Please avoid spaces or other characters such as dots or commas.'), + 'Please use letters only (a-z or A-Z) in this field.' => __('Please use letters only (a-z or A-Z) in this field.'), + 'Please use only letters (a-z), numbers (0-9) or underscore(_) in this field, first character should be a letter.' => __('Please use only letters (a-z), numbers (0-9) or underscore(_) in this field, first character should be a letter.'), + 'Please use only letters (a-z or A-Z) or numbers (0-9) only in this field. No spaces or other characters are allowed.' => __('Please use only letters (a-z or A-Z) or numbers (0-9) only in this field. No spaces or other characters are allowed.'), + 'Please use only letters (a-z or A-Z) or numbers (0-9) or spaces and # only in this field.' => __('Please use only letters (a-z or A-Z) or numbers (0-9) or spaces and # only in this field.'), + 'Please enter a valid fax number. For example (123) 456-7890 or 123-456-7890.' => __('Please enter a valid fax number. For example (123) 456-7890 or 123-456-7890.'), + 'Please enter a valid date.' => __('Please enter a valid date.'), + 'The From Date value should be less than or equal to the To Date value.' => __('The From Date value should be less than or equal to the To Date value.'), + 'Please enter a valid email address. For example johndoe@domain.com.' => __('Please enter a valid email address. For example johndoe@domain.com.'), + 'Please use only visible characters and spaces.' => __('Please use only visible characters and spaces.'), + 'Please enter 6 or more characters. Leading or trailing spaces will be ignored.' => __('Please enter 6 or more characters. Leading or trailing spaces will be ignored.'), + 'Please enter 7 or more characters. Password should contain both numeric and alphabetic characters.' => __('Please enter 7 or more characters. Password should contain both numeric and alphabetic characters.'), + 'Please make sure your passwords match.' => __('Please make sure your passwords match.'), + 'Please enter a valid URL. Protocol is required (http://, https:// or ftp://)' => __('Please enter a valid URL. Protocol is required (http://, https:// or ftp://)'), + 'Please enter a valid URL Key. For example "example-page", "example-page.html" or "anotherlevel/example-page".' => __('Please enter a valid URL Key. For example "example-page", "example-page.html" or "anotherlevel/example-page".'), + 'Please enter a valid XML-identifier. For example something_1, block5, id-4.' => __('Please enter a valid XML-identifier. For example something_1, block5, id-4.'), + 'Please enter a valid social security number. For example 123-45-6789.' => __('Please enter a valid social security number. For example 123-45-6789.'), + 'Please enter a valid zip code. For example 90602 or 90602-1234.' => __('Please enter a valid zip code. For example 90602 or 90602-1234.'), + 'Please enter a valid zip code.' => __('Please enter a valid zip code.'), + 'Please use this date format: dd/mm/yyyy. For example 17/03/2006 for the 17th of March, 2006.' => __('Please use this date format: dd/mm/yyyy. For example 17/03/2006 for the 17th of March, 2006.'), + 'Please select one of the above options.' => __('Please select one of the above options.'), + 'Please select one of the options.' => __('Please select one of the options.'), + 'Please select State/Province.' => __('Please select State/Province.'), + 'Please enter a number greater than 0 in this field.' => __('Please enter a number greater than 0 in this field.'), + 'Please enter a number 0 or greater in this field.' => __('Please enter a number 0 or greater in this field.'), + 'Please enter a valid credit card number.' => __('Please enter a valid credit card number.'), + 'Credit card number does not match credit card type.' => __('Credit card number does not match credit card type.'), + 'Card type does not match credit card number.' => __('Card type does not match credit card number.'), + 'Incorrect credit card expiration date.' => __('Incorrect credit card expiration date.'), + 'Please enter a valid credit card verification number.' => __('Please enter a valid credit card verification number.'), + 'Please use only letters (a-z or A-Z), numbers (0-9) or underscore(_) in this field, first character should be a letter.' => __('Please use only letters (a-z or A-Z), numbers (0-9) or underscore(_) in this field, first character should be a letter.'), + 'Please input a valid CSS-length. For example 100px or 77pt or 20em or .5ex or 50%.' => __('Please input a valid CSS-length. For example 100px or 77pt or 20em or .5ex or 50%.'), + 'Text length does not satisfy specified text range.' => __('Text length does not satisfy specified text range.'), + 'Please enter a number lower than 100.' => __('Please enter a number lower than 100.'), + 'Please select a file' => __('Please select a file'), + 'Please enter issue number or start date for switch/solo card type.' => __('Please enter issue number or start date for switch/solo card type.'), + 'This date is a required value.' => __('This date is a required value.'), + 'Please enter a valid day (1-%1).' => __('Please enter a valid day (1-%1).'), + 'Please enter a valid month (1-12).' => __('Please enter a valid month (1-12).'), + 'Please enter a valid year (1900-%1).' => __('Please enter a valid year (1900-%1).'), + 'Please enter a valid full date' => __('Please enter a valid full date'), + 'Allow' => __('Allow'), + 'Activate' => __('Activate'), + 'Reauthorize' => __('Reauthorize'), + 'Cancel' => __('Cancel'), + 'Done' => __('Done'), + 'Save' => __('Save'), + 'File extension not known or unsupported type.' => __('File extension not known or unsupported type.'), + 'Configure Product' => __('Configure Product'), + 'OK' => __('OK'), + 'Gift Options for ' => __('Gift Options for '), + 'New Option' => __('New Option'), + 'Add Products to New Option' => __('Add Products to New Option'), + 'Add Products to Option "%1"' => __('Add Products to Option "%1"'), + 'Add Selected Products' => __('Add Selected Products'), + 'Select type of option.' => __('Select type of option.'), + 'Please add rows to option.' => __('Please add rows to option.'), + 'Select Product' => __('Select Product'), + 'Import' => __('Import'), + 'Please select items.' => __('Please select items.'), + 'Add Products to Group' => __('Add Products to Group'), + 'start typing to search category' => __('start typing to search category'), + 'Choose existing category.' => __('Choose existing category.'), + 'Create Category' => __('Create Category'), + 'Sorry, there was an unknown error.' => __('Sorry, there was an unknown error.'), + 'Something went wrong while loading the theme.' => __('Something went wrong while loading the theme.'), + 'We don\'t recognize or support this file extension type.' => __('We don\'t recognize or support this file extension type.'), + 'Error' => __('Error'), + 'No stores were reassigned.' => __('No stores were reassigned.'), + 'Assign theme to your live store-view:' => __('Assign theme to your live store-view:'), + 'Default title' => __('Default title'), + 'The URL to assign stores is not defined.' => __('The URL to assign stores is not defined.'), + 'No' => __('No'), + 'Yes' => __('Yes'), + 'Some problem with revert action' => __('Some problem with revert action'), + 'Error: unknown error.' => __('Error: unknown error.'), + 'Some problem with save action' => __('Some problem with save action'), + 'Delete' => __('Delete'), + 'Folder' => __('Folder'), + 'Delete Folder' => __('Delete Folder'), + 'Are you sure you want to delete the folder named' => __('Are you sure you want to delete the folder named'), + 'Delete File' => __('Delete File'), + 'Method ' => __('Method '), + 'Please wait...' => __('Please wait...'), + 'Loading...' => __('Loading...'), + 'Translate' => __('Translate'), + 'Submit' => __('Submit'), + 'Close' => __('Close'), + 'Please enter a value less than or equal to %s.' => __('Please enter a value less than or equal to %s.'), + 'Please enter a value greater than or equal to %s.' => __('Please enter a value greater than or equal to %s.'), + 'Maximum length of this field must be equal or less than %1 symbols.' => __('Maximum length of this field must be equal or less than %1 symbols.'), + 'No records found.' => __('No records found.'), + 'Recent items' => __('Recent items'), + 'Show all...' => __('Show all...'), + 'Please enter a date in the past.' => __('Please enter a date in the past.'), + 'Please enter a date between %min and %max.' => __('Please enter a date between %min and %max.'), + 'Please choose to register or to checkout as a guest.' => __('Please choose to register or to checkout as a guest.'), + 'We are not able to ship to the selected shipping address. Please choose another address or edit the current address.' => __('We are not able to ship to the selected shipping address. Please choose another address or edit the current address.'), + 'Please specify a shipping method.' => __('Please specify a shipping method.'), + 'We can\'t complete your order because you don\'t have a payment method available.' => __('We can\'t complete your order because you don\'t have a payment method available.'), + 'Error happened while creating wishlist. Please try again later' => __('Error happened while creating wishlist. Please try again later'), + 'You must select items to move' => __('You must select items to move'), + 'You must select items to copy' => __('You must select items to copy'), + 'You are about to delete your wish list. This action cannot be undone. Are you sure you want to continue?' => __('You are about to delete your wish list. This action cannot be undone. Are you sure you want to continue?'), + 'Please specify payment method.' => __('Please specify payment method.'), + 'Are you sure you want to delete this address?' => __('Are you sure you want to delete this address?'), + 'Use gift registry shipping address' => __('Use gift registry shipping address'), + 'You can change the number of gift registry items on the Gift Registry Info page or directly in your cart, but not while in checkout.' => __('You can change the number of gift registry items on the Gift Registry Info page or directly in your cart, but not while in checkout.'), + 'No confirmation' => __('No confirmation'), + 'Sorry, something went wrong.' => __('Sorry, something went wrong.'), + 'Sorry, something went wrong. Please try again later.' => __('Sorry, something went wrong. Please try again later.'), + 'select all' => __('select all'), + 'unselect all' => __('unselect all'), + 'Please agree to all Terms and Conditions before placing the orders.' => __('Please agree to all Terms and Conditions before placing the orders.'), + 'Please choose to register or to checkout as a guest' => __('Please choose to register or to checkout as a guest'), + 'Your order cannot be completed at this time as there is no shipping methods available for it. Please make necessary changes in your shipping address.' => __('Your order cannot be completed at this time as there is no shipping methods available for it. Please make necessary changes in your shipping address.'), + 'Please specify shipping method.' => __('Please specify shipping method.'), + 'Your order cannot be completed at this time as there is no payment methods available for it.' => __('Your order cannot be completed at this time as there is no payment methods available for it.'), + ); + } +} diff --git a/app/code/Magento/Translation/Model/Js/DataProviderInterface.php b/app/code/Magento/Translation/Model/Js/DataProviderInterface.php new file mode 100644 index 0000000000000..4a845da2cf5c8 --- /dev/null +++ b/app/code/Magento/Translation/Model/Js/DataProviderInterface.php @@ -0,0 +1,35 @@ +Magento\Translate
+ + + + Magento\Translation\Model\Js\DataProvider + + + diff --git a/app/code/Magento/Core/App/FrontController/Plugin/UrlRewrite.php b/app/code/Magento/UrlRewrite/App/FrontController/Plugin/UrlRewrite.php similarity index 84% rename from app/code/Magento/Core/App/FrontController/Plugin/UrlRewrite.php rename to app/code/Magento/UrlRewrite/App/FrontController/Plugin/UrlRewrite.php index a8b2bbb50d80e..7a709597ed366 100644 --- a/app/code/Magento/Core/App/FrontController/Plugin/UrlRewrite.php +++ b/app/code/Magento/UrlRewrite/App/FrontController/Plugin/UrlRewrite.php @@ -23,12 +23,12 @@ * @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\Core\App\FrontController\Plugin; +namespace Magento\UrlRewrite\App\FrontController\Plugin; class UrlRewrite { /** - * @var \Magento\Core\App\Request\RewriteService RewriteService + * @var \Magento\UrlRewrite\App\Request\RewriteService */ protected $_rewriteService; @@ -38,11 +38,13 @@ class UrlRewrite protected $_state; /** - * @param \Magento\Core\App\Request\RewriteService $rewriteService + * @param \Magento\UrlRewrite\App\Request\RewriteService $rewriteService * @param \Magento\App\State $state */ - public function __construct(\Magento\Core\App\Request\RewriteService $rewriteService, \Magento\App\State $state) - { + public function __construct( + \Magento\UrlRewrite\App\Request\RewriteService $rewriteService, + \Magento\App\State $state + ) { $this->_rewriteService = $rewriteService; $this->_state = $state; } diff --git a/app/code/Magento/Core/App/Request/RewriteService.php b/app/code/Magento/UrlRewrite/App/Request/RewriteService.php similarity index 86% rename from app/code/Magento/Core/App/Request/RewriteService.php rename to app/code/Magento/UrlRewrite/App/Request/RewriteService.php index b9ff9500e9c97..cadd7055f758d 100644 --- a/app/code/Magento/Core/App/Request/RewriteService.php +++ b/app/code/Magento/UrlRewrite/App/Request/RewriteService.php @@ -21,12 +21,12 @@ * @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\Core\App\Request; +namespace Magento\UrlRewrite\App\Request; class RewriteService { /** - * @var \Magento\Core\Model\Url\RewriteFactory + * @var \Magento\UrlRewrite\Model\UrlRewriteFactory */ protected $_rewriteFactory; @@ -42,12 +42,12 @@ class RewriteService /** * @param \Magento\App\RouterList $routerList - * @param \Magento\Core\Model\Url\RewriteFactory $rewriteFactory + * @param \Magento\UrlRewrite\Model\UrlRewriteFactory $rewriteFactory * @param \Magento\App\ConfigInterface $config */ public function __construct( \Magento\App\RouterList $routerList, - \Magento\Core\Model\Url\RewriteFactory $rewriteFactory, + \Magento\UrlRewrite\Model\UrlRewriteFactory $rewriteFactory, \Magento\App\ConfigInterface $config ) { $this->_rewriteFactory = $rewriteFactory; @@ -66,7 +66,7 @@ public function applyRewrites(\Magento\App\RequestInterface $request) // URL rewrite if (!$request->isStraight()) { \Magento\Profiler::start('db_url_rewrite'); - /** @var $urlRewrite \Magento\Core\Model\Url\Rewrite */ + /** @var $urlRewrite \Magento\UrlRewrite\Model\UrlRewrite */ $urlRewrite = $this->_rewriteFactory->create(); $urlRewrite->rewrite($request); \Magento\Profiler::stop('db_url_rewrite'); diff --git a/app/code/Magento/Core/Helper/Url/Rewrite.php b/app/code/Magento/UrlRewrite/Helper/UrlRewrite.php similarity index 88% rename from app/code/Magento/Core/Helper/Url/Rewrite.php rename to app/code/Magento/UrlRewrite/Helper/UrlRewrite.php index d6f5b33c8de30..18b86e6088287 100644 --- a/app/code/Magento/Core/Helper/Url/Rewrite.php +++ b/app/code/Magento/UrlRewrite/Helper/UrlRewrite.php @@ -18,22 +18,12 @@ * 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\UrlRewrite\Helper; -/** - * Url rewrite helper - * - * @category Magento - * @package Magento_Core - * @author Magento Core Team - */ -namespace Magento\Core\Helper\Url; - -class Rewrite extends \Magento\App\Helper\AbstractHelper +class UrlRewrite extends \Magento\App\Helper\AbstractHelper { /** * Validation error constants @@ -46,17 +36,17 @@ class Rewrite extends \Magento\App\Helper\AbstractHelper // Anchor is not supported in request path, e.g. 'foo#bar' /** - * @var \Magento\Core\Model\Source\Urlrewrite\Options + * @var \Magento\UrlRewrite\Model\Source\Urlrewrite\Options */ protected $_urlrewrite; /** * @param \Magento\App\Helper\Context $context - * @param \Magento\Core\Model\Source\Urlrewrite\Options $urlrewrite + * @param \Magento\UrlRewrite\Model\UrlRewrite\OptionProvider $urlrewrite */ public function __construct( \Magento\App\Helper\Context $context, - \Magento\Core\Model\Source\Urlrewrite\Options $urlrewrite + \Magento\UrlRewrite\Model\UrlRewrite\OptionProvider $urlrewrite ) { parent::__construct($context); $this->_urlrewrite = $urlrewrite; @@ -133,7 +123,7 @@ public function validateSuffix($suffix) /** * Has redirect options set * - * @param \Magento\Core\Model\Url\Rewrite $urlRewrite + * @param \Magento\UrlRewrite\Model\UrlRewrite $urlRewrite * @return bool */ public function hasRedirectOptions($urlRewrite) diff --git a/app/code/Magento/Core/Model/Resource/Url/Rewrite.php b/app/code/Magento/UrlRewrite/Model/Resource/UrlRewrite.php similarity index 91% rename from app/code/Magento/Core/Model/Resource/Url/Rewrite.php rename to app/code/Magento/UrlRewrite/Model/Resource/UrlRewrite.php index 11d17a1f2d57a..ee9ef28e47f69 100644 --- a/app/code/Magento/Core/Model/Resource/Url/Rewrite.php +++ b/app/code/Magento/UrlRewrite/Model/Resource/UrlRewrite.php @@ -1,5 +1,7 @@ - */ -class Rewrite extends \Magento\Model\Resource\Db\AbstractDb +class UrlRewrite extends \Magento\Model\Resource\Db\AbstractDb { /** * Define main table @@ -63,7 +56,7 @@ protected function _initUniqueFields() * * @param string $field * @param mixed $value - * @param \Magento\Core\Model\Url\Rewrite $object + * @param \Magento\UrlRewrite\Model\UrlRewrite $object * @return \Zend_Db_Select */ protected function _getLoadSelect($field, $value, $object) @@ -120,11 +113,11 @@ public function getRequestPathByIdPath($idPath, $store) * Load rewrite information for request * If $path is array - we must load all possible records and choose one matching earlier record in array * - * @param \Magento\Core\Model\Url\Rewrite $object + * @param \Magento\UrlRewrite\Model\UrlRewrite $object * @param array|string $path * @return $this */ - public function loadByRequestPath(\Magento\Core\Model\Url\Rewrite $object, $path) + public function loadByRequestPath(\Magento\UrlRewrite\Model\UrlRewrite $object, $path) { if (!is_array($path)) { $path = array($path); diff --git a/app/code/Magento/Core/Model/Resource/Url/Rewrite/Collection.php b/app/code/Magento/UrlRewrite/Model/Resource/UrlRewrite/Collection.php similarity index 86% rename from app/code/Magento/Core/Model/Resource/Url/Rewrite/Collection.php rename to app/code/Magento/UrlRewrite/Model/Resource/UrlRewrite/Collection.php index dbce2f608f3ab..9b3f12cb545c6 100644 --- a/app/code/Magento/Core/Model/Resource/Url/Rewrite/Collection.php +++ b/app/code/Magento/UrlRewrite/Model/Resource/UrlRewrite/Collection.php @@ -1,5 +1,7 @@ - */ -namespace Magento\Core\Model\Resource\Url\Rewrite; +namespace Magento\UrlRewrite\Model\Resource\UrlRewrite; class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollection { @@ -44,7 +35,7 @@ class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollectio protected $_storeManager; /** - * @param \Magento\Core\Model\EntityFactory $entityFactory + * @param \Magento\Data\Collection\EntityFactoryInterface $entityFactory * @param \Magento\Logger $logger * @param \Magento\Data\Collection\Db\FetchStrategyInterface $fetchStrategy * @param \Magento\Event\ManagerInterface $eventManager @@ -53,7 +44,7 @@ class Collection extends \Magento\Model\Resource\Db\Collection\AbstractCollectio * @param \Magento\Model\Resource\Db\AbstractDb $resource */ public function __construct( - \Magento\Core\Model\EntityFactory $entityFactory, + \Magento\Data\Collection\EntityFactoryInterface $entityFactory, \Magento\Logger $logger, \Magento\Data\Collection\Db\FetchStrategyInterface $fetchStrategy, \Magento\Event\ManagerInterface $eventManager, @@ -72,7 +63,7 @@ public function __construct( */ protected function _construct() { - $this->_init('Magento\Core\Model\Url\Rewrite', 'Magento\Core\Model\Resource\Url\Rewrite'); + $this->_init('Magento\UrlRewrite\Model\UrlRewrite', 'Magento\UrlRewrite\Model\Resource\UrlRewrite'); } /** diff --git a/app/code/Magento/Core/Model/Url/Rewrite.php b/app/code/Magento/UrlRewrite/Model/UrlRewrite.php similarity index 91% rename from app/code/Magento/Core/Model/Url/Rewrite.php rename to app/code/Magento/UrlRewrite/Model/UrlRewrite.php index 1dbf71fbce773..8b547035a494f 100644 --- a/app/code/Magento/Core/Model/Url/Rewrite.php +++ b/app/code/Magento/UrlRewrite/Model/UrlRewrite.php @@ -1,5 +1,7 @@ + * @method \Magento\UrlRewrite\Model\UrlRewrite setDescription(string $value) */ -namespace Magento\Core\Model\Url; - -class Rewrite extends \Magento\Model\AbstractModel +class UrlRewrite extends \Magento\Model\AbstractModel { const TYPE_CATEGORY = 1; @@ -113,19 +103,21 @@ public function __construct( \Magento\Data\Collection\Db $resourceCollection = null, array $data = array() ) { + parent::__construct($context, $registry, $resource, $resourceCollection, $data); $this->_coreStoreConfig = $coreStoreConfig; $this->_cookie = $cookie; $this->_storeManager = $storeManager; $this->_httpContext = $httpContext; - parent::__construct($context, $registry, $resource, $resourceCollection, $data); } /** + * Initialize corresponding resource model + * * @return void */ protected function _construct() { - $this->_init('Magento\Core\Model\Resource\Url\Rewrite'); + $this->_init('Magento\UrlRewrite\Model\Resource\UrlRewrite'); } /** @@ -284,7 +276,8 @@ public function rewrite(\Magento\App\RequestInterface $request = null) /** * We have two cases of incoming paths - with and without slashes at the end ("/somepath/" and "/somepath"). - * Each of them matches two url rewrite request paths - with and without slashes at the end ("/somepath/" and "/somepath"). + * Each of them matches two url rewrite request paths - with and without slashes at the end + * ("/somepath/" and "/somepath"). * Choose any matched rewrite, but in priority order that depends on same presence of slash and query params. */ $requestCases = array(); diff --git a/app/code/Magento/Core/Model/Source/Urlrewrite/Options.php b/app/code/Magento/UrlRewrite/Model/UrlRewrite/OptionProvider.php similarity index 82% rename from app/code/Magento/Core/Model/Source/Urlrewrite/Options.php rename to app/code/Magento/UrlRewrite/Model/UrlRewrite/OptionProvider.php index 8ffc2ee928893..572522bc49700 100644 --- a/app/code/Magento/Core/Model/Source/Urlrewrite/Options.php +++ b/app/code/Magento/UrlRewrite/Model/UrlRewrite/OptionProvider.php @@ -1,5 +1,7 @@ - */ -namespace Magento\Core\Model\Source\Urlrewrite; +use Magento\Option\ArrayInterface; -class Options implements \Magento\Option\ArrayInterface +class OptionProvider implements ArrayInterface { const TEMPORARY = 'R'; @@ -55,7 +49,7 @@ public function getAllOptions() $this->_options = array( '' => __('No'), self::TEMPORARY => __('Temporary (302)'), - self::PERMANENT => __('Permanent (301)') + self::PERMANENT => __('Permanent (301)'), ); } return $this->_options; diff --git a/app/code/Magento/Core/Model/Source/Urlrewrite/Types.php b/app/code/Magento/UrlRewrite/Model/UrlRewrite/TypeProvider.php similarity index 77% rename from app/code/Magento/Core/Model/Source/Urlrewrite/Types.php rename to app/code/Magento/UrlRewrite/Model/UrlRewrite/TypeProvider.php index 8abd3c7b19ff8..892afa728bbe2 100644 --- a/app/code/Magento/Core/Model/Source/Urlrewrite/Types.php +++ b/app/code/Magento/UrlRewrite/Model/UrlRewrite/TypeProvider.php @@ -1,5 +1,7 @@ - */ -namespace Magento\Core\Model\Source\Urlrewrite; +use Magento\Option\ArrayInterface; -class Types implements \Magento\Option\ArrayInterface +class TypeProvider implements ArrayInterface { const SYSTEM = 1; @@ -52,7 +46,10 @@ class Types implements \Magento\Option\ArrayInterface public function getAllOptions() { if (is_null($this->_options)) { - $this->_options = array(self::SYSTEM => __('System'), self::CUSTOM => __('Custom')); + $this->_options = array( + self::SYSTEM => __('System'), + self::CUSTOM => __('Custom'), + ); } return $this->_options; } diff --git a/app/code/Magento/Newsletter/etc/adminhtml/events.xml b/app/code/Magento/UrlRewrite/etc/config.xml similarity index 69% rename from app/code/Magento/Newsletter/etc/adminhtml/events.xml rename to app/code/Magento/UrlRewrite/etc/config.xml index 3943d18e216f6..597ed131ecbf6 100644 --- a/app/code/Magento/Newsletter/etc/adminhtml/events.xml +++ b/app/code/Magento/UrlRewrite/etc/config.xml @@ -19,15 +19,18 @@ * 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/afl-3.0.php Academic Free License (AFL 3.0) */ --> - - - - - - - + + + + + 0 + + + diff --git a/app/code/Magento/Newsletter/etc/frontend/events.xml b/app/code/Magento/UrlRewrite/etc/frontend/di.xml similarity index 69% rename from app/code/Magento/Newsletter/etc/frontend/events.xml rename to app/code/Magento/UrlRewrite/etc/frontend/di.xml index 3943d18e216f6..b4d43a0e76d8b 100644 --- a/app/code/Magento/Newsletter/etc/frontend/events.xml +++ b/app/code/Magento/UrlRewrite/etc/frontend/di.xml @@ -23,11 +23,8 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ --> - - - - - - - + + + + diff --git a/app/code/Magento/UrlRewrite/etc/module.xml b/app/code/Magento/UrlRewrite/etc/module.xml new file mode 100644 index 0000000000000..ab2f27dd4196c --- /dev/null +++ b/app/code/Magento/UrlRewrite/etc/module.xml @@ -0,0 +1,33 @@ + + + + + + + + + + diff --git a/app/code/Magento/UrlRewrite/i18n/de_DE.csv b/app/code/Magento/UrlRewrite/i18n/de_DE.csv new file mode 100644 index 0000000000000..3f29d50645be5 --- /dev/null +++ b/app/code/Magento/UrlRewrite/i18n/de_DE.csv @@ -0,0 +1,2 @@ +"Anchor symbol (#) is not supported in url rewrite suffix","Das Doppelkreuz (#) wird beim URL-Überschreiben-Suffix nicht unterstützt" +"Two and more slashes together are not permitted in url rewrite suffix","Zwei und mehr zusammenhängende Schrägstriche sind im URL-Rewrite-Suffix nicht zulässig" diff --git a/app/code/Magento/UrlRewrite/i18n/en_US.csv b/app/code/Magento/UrlRewrite/i18n/en_US.csv new file mode 100644 index 0000000000000..4624360515163 --- /dev/null +++ b/app/code/Magento/UrlRewrite/i18n/en_US.csv @@ -0,0 +1,2 @@ +"Anchor symbol (#) is not supported in url rewrite suffix","Anchor symbol (#) is not supported in url rewrite suffix" +"Two and more slashes together are not permitted in url rewrite suffix","Two and more slashes together are not permitted in url rewrite suffix" diff --git a/app/code/Magento/UrlRewrite/i18n/es_ES.csv b/app/code/Magento/UrlRewrite/i18n/es_ES.csv new file mode 100644 index 0000000000000..f4dfad107e7a0 --- /dev/null +++ b/app/code/Magento/UrlRewrite/i18n/es_ES.csv @@ -0,0 +1,2 @@ +"Anchor symbol (#) is not supported in url rewrite suffix","El símbolo ancla (#) no está soportado en el sufijo de reescritura de url" +"Two and more slashes together are not permitted in url rewrite suffix","No se permiten dos o más barras juntas en el sufijo de la url" diff --git a/app/code/Magento/UrlRewrite/i18n/fr_FR.csv b/app/code/Magento/UrlRewrite/i18n/fr_FR.csv new file mode 100644 index 0000000000000..f8cbb54983664 --- /dev/null +++ b/app/code/Magento/UrlRewrite/i18n/fr_FR.csv @@ -0,0 +1,2 @@ +"Anchor symbol (#) is not supported in url rewrite suffix","Le symbole d'ancrage (#) n'est pas pris en charge dans le suffixe de réécriture de l'url" +"Two and more slashes together are not permitted in url rewrite suffix","Deux slashs ou plus ne sont pas autorisés dans le suffixe de réécriture de l'URL" diff --git a/app/code/Magento/UrlRewrite/i18n/nl_NL.csv b/app/code/Magento/UrlRewrite/i18n/nl_NL.csv new file mode 100644 index 0000000000000..c49b40a314457 --- /dev/null +++ b/app/code/Magento/UrlRewrite/i18n/nl_NL.csv @@ -0,0 +1,2 @@ +"Anchor symbol (#) is not supported in url rewrite suffix","Anker symbool (#) is niet ondersteund in URL herschrijvings toevoeging" +"Two and more slashes together are not permitted in url rewrite suffix","Twee of meer schuine strepen zijn niet toegestaan in URL herschrijvings navoeging" diff --git a/app/code/Magento/UrlRewrite/i18n/pt_BR.csv b/app/code/Magento/UrlRewrite/i18n/pt_BR.csv new file mode 100644 index 0000000000000..4a03c4c3ed53d --- /dev/null +++ b/app/code/Magento/UrlRewrite/i18n/pt_BR.csv @@ -0,0 +1,2 @@ +"Anchor symbol (#) is not supported in url rewrite suffix","Símbolo âncora (#) não é suportado no sufixo url reescrito" +"Two and more slashes together are not permitted in url rewrite suffix","Duas ou mais barras juntas não são permitidas em sufixo url reescrito" diff --git a/app/code/Magento/UrlRewrite/i18n/zh_CN.csv b/app/code/Magento/UrlRewrite/i18n/zh_CN.csv new file mode 100644 index 0000000000000..e9f47e3a77ba2 --- /dev/null +++ b/app/code/Magento/UrlRewrite/i18n/zh_CN.csv @@ -0,0 +1,2 @@ +"Anchor symbol (#) is not supported in url rewrite suffix","URL 重写后缀不支持固定标志 (#)" +"Two and more slashes together are not permitted in url rewrite suffix","两个或更多斜杠在 URL 重写后缀中不被允许" diff --git a/app/code/Magento/UrlRewrite/sql/urlrewrite_setup/install-1.0.0.0.php b/app/code/Magento/UrlRewrite/sql/urlrewrite_setup/install-1.0.0.0.php new file mode 100644 index 0000000000000..acc29da8a9e64 --- /dev/null +++ b/app/code/Magento/UrlRewrite/sql/urlrewrite_setup/install-1.0.0.0.php @@ -0,0 +1,120 @@ +startSetup(); + +/** + * Create table 'core_url_rewrite' + */ +$table = $installer->getConnection()->newTable( + $installer->getTable('core_url_rewrite') +)->addColumn( + 'url_rewrite_id', + \Magento\DB\Ddl\Table::TYPE_INTEGER, + null, + array('identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true), + 'Rewrite Id' +)->addColumn( + 'store_id', + \Magento\DB\Ddl\Table::TYPE_SMALLINT, + null, + array('unsigned' => true, 'nullable' => false, 'default' => '0'), + 'Store Id' +)->addColumn( + 'id_path', + \Magento\DB\Ddl\Table::TYPE_TEXT, + 255, + array(), + 'Id Path' +)->addColumn( + 'request_path', + \Magento\DB\Ddl\Table::TYPE_TEXT, + 255, + array(), + 'Request Path' +)->addColumn( + 'target_path', + \Magento\DB\Ddl\Table::TYPE_TEXT, + 255, + array(), + 'Target Path' +)->addColumn( + 'is_system', + \Magento\DB\Ddl\Table::TYPE_SMALLINT, + null, + array('unsigned' => true, 'default' => '1'), + 'Defines is Rewrite System' +)->addColumn( + 'options', + \Magento\DB\Ddl\Table::TYPE_TEXT, + 255, + array('nullable' => true), + 'Options' +)->addColumn( + 'description', + \Magento\DB\Ddl\Table::TYPE_TEXT, + 255, + array(), + 'Deascription' +)->addIndex( + $installer->getIdxName( + 'core_url_rewrite', + array('request_path', 'store_id'), + \Magento\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE + ), + array('request_path', 'store_id'), + array('type' => \Magento\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE) +)->addIndex( + $installer->getIdxName( + 'core_url_rewrite', + array('id_path', 'is_system', 'store_id'), + \Magento\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE + ), + array('id_path', 'is_system', 'store_id'), + array('type' => \Magento\DB\Adapter\AdapterInterface::INDEX_TYPE_UNIQUE) +)->addIndex( + $installer->getIdxName('core_url_rewrite', array('target_path', 'store_id')), + array('target_path', 'store_id') +)->addIndex( + $installer->getIdxName('core_url_rewrite', array('id_path')), + array('id_path') +)->addIndex( + $installer->getIdxName('core_url_rewrite', array('store_id')), + array('store_id') +)->addForeignKey( + $installer->getFkName('core_url_rewrite', 'store_id', 'core_store', 'store_id'), + 'store_id', + $installer->getTable('core_store'), + 'store_id', + \Magento\DB\Ddl\Table::ACTION_CASCADE, + \Magento\DB\Ddl\Table::ACTION_CASCADE +)->setComment( + 'Url Rewrites' +); +$installer->getConnection()->createTable($table); + +$installer->endSetup(); diff --git a/app/etc/di.xml b/app/etc/di.xml index 189debd0ccdc8..305434cb7eae9 100644 --- a/app/etc/di.xml +++ b/app/etc/di.xml @@ -61,7 +61,7 @@ - + @@ -70,7 +70,7 @@ - + diff --git a/dev/tests/integration/framework/Magento/TestFramework/ObjectManager.php b/dev/tests/integration/framework/Magento/TestFramework/ObjectManager.php index 9482d50e8283d..844d9f5e4922b 100644 --- a/dev/tests/integration/framework/Magento/TestFramework/ObjectManager.php +++ b/dev/tests/integration/framework/Magento/TestFramework/ObjectManager.php @@ -44,7 +44,8 @@ class ObjectManager extends \Magento\App\ObjectManager 'Magento\ObjectManager\Config', 'Magento\Interception\Definition', 'Magento\ObjectManager\Definition', - 'Magento\Core\Model\Session\Config' + 'Magento\Core\Model\Session\Config', + 'Magento\ObjectManager\Config\Mapper\Dom' ); /** diff --git a/dev/tests/integration/framework/Magento/TestFramework/ObjectManagerFactory.php b/dev/tests/integration/framework/Magento/TestFramework/ObjectManagerFactory.php index 5183f56d432c1..202e6159d12c4 100644 --- a/dev/tests/integration/framework/Magento/TestFramework/ObjectManagerFactory.php +++ b/dev/tests/integration/framework/Magento/TestFramework/ObjectManagerFactory.php @@ -100,6 +100,7 @@ public function restore(ObjectManager $objectManager, $rootDir, array $arguments $appArguments = parent::createAppArguments($directoryList, $arguments); $this->appArgumentsProxy->setSubject($appArguments); + $this->factory->setArguments($appArguments->get()); $objectManager->addSharedInstance($appArguments, 'Magento\App\Arguments'); $objectManager->get('Magento\Interception\PluginList')->reset(); @@ -109,25 +110,25 @@ public function restore(ObjectManager $objectManager, $rootDir, array $arguments } /** - * Load primary config data + * Load primary config * - * @param string $configDirectoryPath + * @param \Magento\App\Filesystem\DirectoryList $directoryList + * @param mixed $argumentMapper * @param string $appMode * @return array - * @throws \Magento\BootstrapException */ - protected function _loadPrimaryConfig($configDirectoryPath, $appMode) - { + protected function _loadPrimaryConfig( + \Magento\App\Filesystem\DirectoryList $directoryList, + $argumentMapper, + $appMode + ) { if (null === $this->_primaryConfigData) { $this->_primaryConfigData = array_replace( - parent::_loadPrimaryConfig($configDirectoryPath, $appMode), + parent::_loadPrimaryConfig($directoryList, $argumentMapper, $appMode), array( 'Magento\View\Design\FileResolution\Strategy\Fallback\CachingProxy' => array( 'arguments' => array( - 'canSaveMap' => array( - \Magento\ObjectManager\Config\Reader\Dom::TYPE_ATTRIBUTE => 'boolean', - 'value' => false - ) + 'canSaveMap' => false ) ), 'default_setup' => array('type' => 'Magento\TestFramework\Db\ConnectionAdapter') @@ -135,7 +136,7 @@ protected function _loadPrimaryConfig($configDirectoryPath, $appMode) ); $this->_primaryConfigData['preferences'] = array_replace( $this->_primaryConfigData['preferences'], - array( + [ 'Magento\Stdlib\Cookie' => 'Magento\TestFramework\Cookie', 'Magento\App\RequestInterface' => 'Magento\TestFramework\Request', 'Magento\App\Request\Http' => 'Magento\TestFramework\Request', @@ -144,7 +145,7 @@ protected function _loadPrimaryConfig($configDirectoryPath, $appMode) 'Magento\Interception\PluginList' => 'Magento\TestFramework\Interception\PluginList', 'Magento\Interception\ObjectManager\Config' => 'Magento\TestFramework\ObjectManager\Config', 'Magento\View\LayoutInterface' => 'Magento\TestFramework\View\Layout' - ) + ] ); } return $this->_primaryConfigData; diff --git a/dev/tests/integration/framework/Magento/TestFramework/Request.php b/dev/tests/integration/framework/Magento/TestFramework/Request.php index 90ad2e654ea74..e6aa9fd9b403e 100644 --- a/dev/tests/integration/framework/Magento/TestFramework/Request.php +++ b/dev/tests/integration/framework/Magento/TestFramework/Request.php @@ -80,4 +80,16 @@ public function getServer($key = null, $default = null) return isset($this->_server[$key]) ? $this->_server[$key] : $default; } + + /** + * Set the HTTP Method type. + * + * Examples are POST, PUT, GET, DELETE + * + * @param string $type + */ + public function setMethod($type) + { + $this->_server['REQUEST_METHOD'] = $type; + } } diff --git a/dev/tests/integration/framework/Magento/TestFramework/TestCase/AbstractController.php b/dev/tests/integration/framework/Magento/TestFramework/TestCase/AbstractController.php index 0690631c2a165..7edc1aa8fce5c 100644 --- a/dev/tests/integration/framework/Magento/TestFramework/TestCase/AbstractController.php +++ b/dev/tests/integration/framework/Magento/TestFramework/TestCase/AbstractController.php @@ -205,19 +205,24 @@ public function assertRedirect(\PHPUnit_Framework_Constraint $urlConstraint = nu * * @param \PHPUnit_Framework_Constraint $constraint Constraint to compare actual messages against * @param string|null $messageType Message type filter, one of the constants \Magento\Message\MessageInterface::* - * @param string $messageManager Class of the session model that manages messages + * @param string $messageManagerClass Class of the session model that manages messages */ public function assertSessionMessages( \PHPUnit_Framework_Constraint $constraint, $messageType = null, - $messageManager = 'Magento\Message\Manager' + $messageManagerClass = 'Magento\Message\Manager' ) { $this->_assertSessionErrors = false; - /** @var $messages \Magento\Message\ManagerInterface */ - $messages = $this->_objectManager->get($messageManager); - $actualMessages = array(); - /** @var $message \Magento\Message\AbstractMessage */ - foreach ($messages->getMessages()->getItemsByType($messageType) as $message) { + /** @var $messageManager \Magento\Message\ManagerInterface */ + $messageManager = $this->_objectManager->get($messageManagerClass); + /** @var $messages \Magento\Message\AbstractMessage[] */ + if (is_null($messageType)) { + $messages = $messageManager->getMessages()->getItems(); + } else { + $messages = $messageManager->getMessages()->getItemsByType($messageType); + } + $actualMessages = []; + foreach ($messages as $message) { $actualMessages[] = $message->getText(); } $this->assertThat( diff --git a/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/TestCase/ControllerAbstractTest.php b/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/TestCase/ControllerAbstractTest.php index 98a41f84c4d4f..be4d999c8bebe 100644 --- a/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/TestCase/ControllerAbstractTest.php +++ b/dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/TestCase/ControllerAbstractTest.php @@ -33,21 +33,12 @@ class ControllerAbstractTest extends \Magento\TestFramework\TestCase\AbstractCon { protected $_bootstrap; + /** @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Message\Manager */ + private $messageManager; + protected function setUp() { - // emulate session messages - $messagesCollection = new \Magento\Message\Collection(); - $messagesCollection->addMessage( - new \Magento\Message\Warning('some_warning') - )->addMessage( - new \Magento\Message\Error('error_one') - )->addMessage( - new \Magento\Message\Error('error_two') - )->addMessage( - new \Magento\Message\Notice('some_notice') - ); - $messageManager = $this->getMock('\Magento\Message\Manager', array(), array(), '', false); - $messageManager->expects($this->any())->method('getMessages')->will($this->returnValue($messagesCollection)); + $this->messageManager = $this->getMock('\Magento\Message\Manager', array(), array(), '', false); $request = new \Magento\TestFramework\Request( $this->getMock('\Magento\App\Route\ConfigInterface', array(), array(), '', false), $this->getMock('Magento\App\Request\PathInfoProcessorInterface', array(), array(), '', false) @@ -64,19 +55,17 @@ protected function setUp() '', false ); - $this->_objectManager->expects( - $this->any() - )->method( - 'get' - )->will( - $this->returnValueMap( - array( - array('Magento\App\RequestInterface', $request), - array('Magento\App\ResponseInterface', $response), - array('Magento\Message\Manager', $messageManager) + $this->_objectManager->expects($this->any()) + ->method('get') + ->will( + $this->returnValueMap( + array( + array('Magento\App\RequestInterface', $request), + array('Magento\App\ResponseInterface', $response), + array('Magento\Message\Manager', $this->messageManager), + ) ) - ) - ); + ); } /** @@ -162,17 +151,14 @@ public function testAssertRedirect() */ public function testAssertSessionMessagesSuccess(array $expectedMessages, $messageTypeFilter) { + $this->addSessionMessages(); /** @var \PHPUnit_Framework_MockObject_MockObject|\PHPUnit_Framework_Constraint $constraint */ $constraint = $this->getMock('PHPUnit_Framework_Constraint', array('toString', 'matches')); $constraint->expects( $this->once() - )->method( - 'matches' - )->with( - $expectedMessages - )->will( - $this->returnValue(true) - ); + )->method('matches') + ->with($expectedMessages) + ->will($this->returnValue(true)); $this->assertSessionMessages($constraint, $messageTypeFilter); } @@ -186,12 +172,51 @@ public function assertSessionMessagesDataProvider() 'message error type filtering' => array( array('error_one', 'error_two'), \Magento\Message\MessageInterface::TYPE_ERROR + ), + 'message success type filtering' => array( + array('success!'), + \Magento\Message\MessageInterface::TYPE_SUCCESS + ), + ); + } + + public function testAssertSessionMessagesAll() + { + $this->addSessionMessages(); + + $this->assertSessionMessages( + $this->equalTo( + [ + 'some_warning', + 'error_one', + 'error_two', + 'some_notice', + 'success!', + ] ) ); } - public function testAssertSessionMessagesFailure() + public function testAssertSessionMessagesEmpty() { + $messagesCollection = new \Magento\Message\Collection(); + $this->messageManager->expects($this->any())->method('getMessages') + ->will($this->returnValue($messagesCollection)); + $this->assertSessionMessages($this->isEmpty()); } + + private function addSessionMessages() + { + // emulate session messages + $messagesCollection = new \Magento\Message\Collection(); + $messagesCollection + ->addMessage(new \Magento\Message\Warning('some_warning')) + ->addMessage(new \Magento\Message\Error('error_one')) + ->addMessage(new \Magento\Message\Error('error_two')) + ->addMessage(new \Magento\Message\Notice('some_notice')) + ->addMessage(new \Magento\Message\Success('success!')); + $this->messageManager->expects($this->any())->method('getMessages') + ->will($this->returnValue($messagesCollection)); + } } diff --git a/dev/tests/integration/testsuite/Magento/Core/Model/Resource/CacheTest.php b/dev/tests/integration/testsuite/Magento/App/Cache/State/OptionsTest.php similarity index 90% rename from dev/tests/integration/testsuite/Magento/Core/Model/Resource/CacheTest.php rename to dev/tests/integration/testsuite/Magento/App/Cache/State/OptionsTest.php index 103b2696c1eb8..ca0f04841ba07 100644 --- a/dev/tests/integration/testsuite/Magento/Core/Model/Resource/CacheTest.php +++ b/dev/tests/integration/testsuite/Magento/App/Cache/State/OptionsTest.php @@ -18,20 +18,18 @@ * 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 * @subpackage integration_tests * @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\Core\Model\Resource; +namespace Magento\App\Cache\State; -class CacheTest extends \PHPUnit_Framework_TestCase +class OptionsTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Core\Model\Resource\Cache + * @var \Magento\App\Cache\State\Options */ - protected $_model; + protected $_model; /** * @var \PHPUnit_Framework_MockObject_MockObject @@ -41,7 +39,7 @@ class CacheTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Core\Model\Resource\Cache' + 'Magento\App\Cache\State\Options' ); } @@ -53,7 +51,7 @@ public function testGetTable() ); $this->_model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Core\Model\Resource\Cache', + 'Magento\App\Cache\State\Options', array('resource' => $this->_resourceMock) ); $this->assertEquals('prefix_core_cache_option', $this->_model->getTable('core_cache_option')); diff --git a/dev/tests/integration/testsuite/Magento/App/FrontController/Plugin/InstallTest.php b/dev/tests/integration/testsuite/Magento/App/FrontController/Plugin/InstallTest.php index a7ad13c98fcd7..e76f7be0deaef 100644 --- a/dev/tests/integration/testsuite/Magento/App/FrontController/Plugin/InstallTest.php +++ b/dev/tests/integration/testsuite/Magento/App/FrontController/Plugin/InstallTest.php @@ -48,13 +48,13 @@ public function testApplyAllDataUpdates() { /*reset versions*/ \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Core\Model\Resource\Resource' + 'Magento\Module\ResourceInterface' )->setDbVersion( 'adminnotification_setup', false ); \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Core\Model\Resource\Resource' + 'Magento\Module\ResourceInterface' )->setDataVersion( 'adminnotification_setup', false diff --git a/dev/tests/integration/testsuite/Magento/Backend/Block/Urlrewrite/Catalog/Category/EditTest.php b/dev/tests/integration/testsuite/Magento/Backend/Block/Urlrewrite/Catalog/Category/EditTest.php index fba63096662b5..0be268e261718 100644 --- a/dev/tests/integration/testsuite/Magento/Backend/Block/Urlrewrite/Catalog/Category/EditTest.php +++ b/dev/tests/integration/testsuite/Magento/Backend/Block/Urlrewrite/Catalog/Category/EditTest.php @@ -283,18 +283,18 @@ private function _checkCategoriesTree($block, $expected) */ public function prepareLayoutDataProvider() { - /** @var $urlRewrite \Magento\Core\Model\Url\Rewrite */ + /** @var $urlRewrite \Magento\UrlRewrite\Model\UrlRewrite */ $urlRewrite = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Core\Model\Url\Rewrite' + 'Magento\UrlRewrite\Model\UrlRewrite' ); /** @var $category \Magento\Catalog\Model\Category */ $category = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( 'Magento\Catalog\Model\Category', array('data' => array('entity_id' => 1, 'name' => 'Test category')) ); - /** @var $existingUrlRewrite \Magento\Core\Model\Url\Rewrite */ + /** @var $existingUrlRewrite \Magento\UrlRewrite\Model\UrlRewrite */ $existingUrlRewrite = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Core\Model\Url\Rewrite', + 'Magento\UrlRewrite\Model\UrlRewrite', array('data' => array('url_rewrite_id' => 1)) ); diff --git a/dev/tests/integration/testsuite/Magento/Backend/Block/Urlrewrite/Catalog/Product/EditTest.php b/dev/tests/integration/testsuite/Magento/Backend/Block/Urlrewrite/Catalog/Product/EditTest.php index 8a68085896a55..f6e8b66c35153 100644 --- a/dev/tests/integration/testsuite/Magento/Backend/Block/Urlrewrite/Catalog/Product/EditTest.php +++ b/dev/tests/integration/testsuite/Magento/Backend/Block/Urlrewrite/Catalog/Product/EditTest.php @@ -362,9 +362,9 @@ private function _checkCategories($block, $expected) */ public function prepareLayoutDataProvider() { - /** @var $urlRewrite \Magento\Core\Model\Url\Rewrite */ + /** @var $urlRewrite \Magento\UrlRewrite\Model\UrlRewrite */ $urlRewrite = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Core\Model\Url\Rewrite' + 'Magento\UrlRewrite\Model\UrlRewrite' ); /** @var $product \Magento\Catalog\Model\Product */ $product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( @@ -376,9 +376,9 @@ public function prepareLayoutDataProvider() 'Magento\Catalog\Model\Category', array('data' => array('entity_id' => 1, 'name' => 'Test category')) ); - /** @var $existingUrlRewrite \Magento\Core\Model\Url\Rewrite */ + /** @var $existingUrlRewrite \Magento\UrlRewrite\Model\UrlRewrite */ $existingUrlRewrite = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Core\Model\Url\Rewrite', + 'Magento\UrlRewrite\Model\UrlRewrite', array('data' => array('url_rewrite_id' => 1)) ); return array( diff --git a/dev/tests/integration/testsuite/Magento/Backend/Block/Urlrewrite/Cms/Page/EditTest.php b/dev/tests/integration/testsuite/Magento/Backend/Block/Urlrewrite/Cms/Page/EditTest.php index 25423602792c2..ba701007826b4 100644 --- a/dev/tests/integration/testsuite/Magento/Backend/Block/Urlrewrite/Cms/Page/EditTest.php +++ b/dev/tests/integration/testsuite/Magento/Backend/Block/Urlrewrite/Cms/Page/EditTest.php @@ -283,18 +283,18 @@ private function _checkGrid($block, $expected) */ public function prepareLayoutDataProvider() { - /** @var $urlRewrite \Magento\Core\Model\Url\Rewrite */ + /** @var $urlRewrite \Magento\UrlRewrite\Model\UrlRewrite */ $urlRewrite = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Core\Model\Url\Rewrite' + 'Magento\UrlRewrite\Model\UrlRewrite' ); /** @var $cmsPage \Magento\Cms\Model\Page */ $cmsPage = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( 'Magento\Cms\Model\Page', array('data' => array('page_id' => 1, 'title' => 'Test CMS Page')) ); - /** @var $existingUrlRewrite \Magento\Core\Model\Url\Rewrite */ + /** @var $existingUrlRewrite \Magento\UrlRewrite\Model\UrlRewrite */ $existingUrlRewrite = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Core\Model\Url\Rewrite', + 'Magento\UrlRewrite\Model\UrlRewrite', array('data' => array('url_rewrite_id' => 1)) ); diff --git a/dev/tests/integration/testsuite/Magento/Backend/Block/Urlrewrite/EditTest.php b/dev/tests/integration/testsuite/Magento/Backend/Block/Urlrewrite/EditTest.php index 58283d7676437..0a583809942e3 100644 --- a/dev/tests/integration/testsuite/Magento/Backend/Block/Urlrewrite/EditTest.php +++ b/dev/tests/integration/testsuite/Magento/Backend/Block/Urlrewrite/EditTest.php @@ -159,13 +159,13 @@ private function _checkButtons($block, $expected) */ public function prepareLayoutDataProvider() { - /** @var $urlRewrite \Magento\Core\Model\Url\Rewrite */ + /** @var $urlRewrite \Magento\UrlRewrite\Model\UrlRewrite */ $urlRewrite = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Core\Model\Url\Rewrite' + 'Magento\UrlRewrite\Model\UrlRewrite' ); - /** @var $existingUrlRewrite \Magento\Core\Model\Url\Rewrite */ + /** @var $existingUrlRewrite \Magento\UrlRewrite\Model\UrlRewrite */ $existingUrlRewrite = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Core\Model\Url\Rewrite', + 'Magento\UrlRewrite\Model\UrlRewrite', array('data' => array('url_rewrite_id' => 1)) ); diff --git a/dev/tests/integration/testsuite/Magento/Backend/Utility/Controller.php b/dev/tests/integration/testsuite/Magento/Backend/Utility/Controller.php index b2fd5625ac3ce..6014d99921f45 100644 --- a/dev/tests/integration/testsuite/Magento/Backend/Utility/Controller.php +++ b/dev/tests/integration/testsuite/Magento/Backend/Utility/Controller.php @@ -82,13 +82,13 @@ protected function tearDown() * * @param \PHPUnit_Framework_Constraint $constraint * @param string|null $messageType - * @param string $messageManager + * @param string $messageManagerClass */ public function assertSessionMessages( \PHPUnit_Framework_Constraint $constraint, $messageType = null, - $messageManager = 'Magento\Message\Manager' + $messageManagerClass = 'Magento\Message\Manager' ) { - parent::assertSessionMessages($constraint, $messageType, $messageManager); + parent::assertSessionMessages($constraint, $messageType, $messageManagerClass); } } diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/CategoryTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/CategoryTest.php index 971207b24585b..f63cf98ee4979 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Model/CategoryTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/CategoryTest.php @@ -82,7 +82,7 @@ public function testGetUrlInstance() public function testGetUrlRewrite() { $rewrite = $this->_model->getUrlRewrite(); - $this->assertInstanceOf('Magento\Core\Model\Url\Rewrite', $rewrite); + $this->assertInstanceOf('Magento\UrlRewrite\Model\UrlRewrite', $rewrite); $this->assertSame($rewrite, $this->_model->getUrlRewrite()); } 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 d043ff0b126cb..d8f37a05581a8 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/UrlTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/UrlTest.php @@ -55,7 +55,7 @@ public function testGetUrlInstance() public function testGetUrlRewrite() { $instance = $this->_model->getUrlRewrite(); - $this->assertInstanceOf('Magento\Core\Model\Url\Rewrite', $instance); + $this->assertInstanceOf('Magento\UrlRewrite\Model\UrlRewrite', $instance); $this->assertSame($instance, $this->_model->getUrlRewrite()); } diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/UrlTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/UrlTest.php index acc9d791f59d9..f1aea2936e6ea 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Model/UrlTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/UrlTest.php @@ -49,13 +49,13 @@ protected function setUp() * Retrieve loaded url rewrite * * @param string $idPath - * @return \Magento\Core\Model\Url\Rewrite + * @return \Magento\UrlRewrite\Model\UrlRewrite */ protected function _loadRewrite($idPath) { - /** @var $rewrite \Magento\Core\Model\Url\Rewrite */ + /** @var $rewrite \Magento\UrlRewrite\Model\UrlRewrite */ $rewrite = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Core\Model\Url\Rewrite' + 'Magento\UrlRewrite\Model\UrlRewrite' ); $rewrite->loadByIdPath($idPath); return $rewrite; diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/url_rewrites_invalid.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/url_rewrites_invalid.php index 89acef9d39fae..0f34abb07825e 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/_files/url_rewrites_invalid.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/url_rewrites_invalid.php @@ -33,8 +33,8 @@ /** * Invalid rewrite for product assigned to different category */ -/** @var $rewrite \Magento\Core\Model\Url\Rewrite */ -$rewrite = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Core\Model\Url\Rewrite'); +/** @var $rewrite \Magento\UrlRewrite\Model\UrlRewrite */ +$rewrite = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\UrlRewrite\Model\UrlRewrite'); $rewrite->setStoreId( 1 )->setIdPath( @@ -54,7 +54,7 @@ /** * Invalid rewrite for product assigned to category that doesn't belong to store */ -$rewrite = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Core\Model\Url\Rewrite'); +$rewrite = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\UrlRewrite\Model\UrlRewrite'); $rewrite->setStoreId( 1 )->setIdPath( diff --git a/dev/tests/integration/testsuite/Magento/Core/Helper/JsTest.php b/dev/tests/integration/testsuite/Magento/Core/Helper/JsTest.php deleted file mode 100644 index 9e322f8d53ea3..0000000000000 --- a/dev/tests/integration/testsuite/Magento/Core/Helper/JsTest.php +++ /dev/null @@ -1,72 +0,0 @@ -_helper = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Core\Helper\Js'); - } - - public function testGetTranslatorScript() - { - $this->assertEquals( - "", - $this->_helper->getTranslatorScript() - ); - } - - public function testGetScript() - { - $this->assertEquals( - "", - $this->_helper->getScript('test') - ); - } - - public function testIncludeScript() - { - $this->assertEquals( - '' . "\n", - $this->_helper->includeScript(self::FILE) - ); - $script = ''; - $this->assertStringMatchesFormat($script, $this->_helper->includeScript('images/spacer.gif')); - } -} diff --git a/dev/tests/integration/testsuite/Magento/Core/Model/Resource/SetupTest.php b/dev/tests/integration/testsuite/Magento/Core/Model/Resource/SetupTest.php index 3fd053cc783f2..8213200322a25 100644 --- a/dev/tests/integration/testsuite/Magento/Core/Model/Resource/SetupTest.php +++ b/dev/tests/integration/testsuite/Magento/Core/Model/Resource/SetupTest.php @@ -51,13 +51,13 @@ public function testApplyAllDataUpdates() { /*reset versions*/ \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Core\Model\Resource\Resource' + '\Magento\Module\ResourceInterface' )->setDbVersion( 'adminnotification_setup', false ); \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Core\Model\Resource\Resource' + '\Magento\Module\ResourceInterface' )->setDataVersion( 'adminnotification_setup', false diff --git a/dev/tests/integration/testsuite/Magento/Core/_files/url_rewrite.php b/dev/tests/integration/testsuite/Magento/Core/_files/url_rewrite.php index 400310348275c..b4da9b3ad5dcc 100644 --- a/dev/tests/integration/testsuite/Magento/Core/_files/url_rewrite.php +++ b/dev/tests/integration/testsuite/Magento/Core/_files/url_rewrite.php @@ -39,8 +39,8 @@ } // create URL rewrite -/** @var $rewrite \Magento\Core\Model\Url\Rewrite */ -$rewrite = $objectManager->create('Magento\Core\Model\Url\Rewrite'); +/** @var $rewrite \Magento\UrlRewrite\Model\UrlRewrite */ +$rewrite = $objectManager->create('Magento\UrlRewrite\Model\UrlRewrite'); $rewrite->setIdPath( 'cms_page/' . $cmsPage->getId() )->setRequestPath( diff --git a/dev/tests/integration/testsuite/Magento/Customer/Controller/AccountTest.php b/dev/tests/integration/testsuite/Magento/Customer/Controller/AccountTest.php index 608455b8a6367..fc8bb5111dc93 100755 --- a/dev/tests/integration/testsuite/Magento/Customer/Controller/AccountTest.php +++ b/dev/tests/integration/testsuite/Magento/Customer/Controller/AccountTest.php @@ -22,27 +22,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\Customer\Controller; +use Magento\Message\MessageInterface; use Magento\TestFramework\Helper\Bootstrap; class AccountTest extends \Magento\TestFramework\TestCase\AbstractController { /** * Login the user + * + * @param string $customerId Customer to mark as logged in for the session + * @return void */ - protected function _login() + protected function login($customerId) { - $logger = $this->getMock('Magento\Logger', array(), array(), '', false); - $session = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Customer\Model\Session', - array($logger) - ); - $service = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Customer\Service\V1\CustomerAccountService' - ); - $customer = $service->authenticate('customer@example.com', 'password'); - $session->setCustomerDataAsLoggedIn($customer); + /** @var \Magento\Customer\Model\Session $session */ + $session = Bootstrap::getObjectManager() + ->get('Magento\Customer\Model\Session'); + $session->loginById($customerId); } /** @@ -51,7 +50,7 @@ protected function _login() */ public function testIndexAction() { - $this->_login(); + $this->login(1); $this->dispatch('customer/account/index'); $body = $this->getResponse()->getBody(); @@ -77,7 +76,7 @@ public function testCreateAction() */ public function testLogoutAction() { - $this->_login(); + $this->login(1); $this->dispatch('customer/account/logout'); $this->assertRedirect($this->stringContains('customer/account/logoutSuccess')); } @@ -88,15 +87,11 @@ public function testLogoutAction() public function testCreatepasswordAction() { /** @var \Magento\Customer\Model\Customer $customer */ - $customer = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Customer\Model\Customer' - )->load( - 1 - ); + $customer = Bootstrap::getObjectManager() + ->create('Magento\Customer\Model\Customer')->load(1); - $token = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Customer\Helper\Data' - )->generateResetPasswordLinkToken(); + $token = Bootstrap::getObjectManager()->get('Magento\Customer\Helper\Data') + ->generateResetPasswordLinkToken(); $customer->changeResetPasswordLinkToken($token); $this->getRequest()->setParam('token', $token); @@ -113,15 +108,11 @@ public function testCreatepasswordAction() public function testCreatepasswordActionInvalidToken() { /** @var \Magento\Customer\Model\Customer $customer */ - $customer = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Customer\Model\Customer' - )->load( - 1 - ); + $customer = Bootstrap::getObjectManager() + ->create('Magento\Customer\Model\Customer')->load(1); - $token = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Customer\Helper\Data' - )->generateResetPasswordLinkToken(); + $token = Bootstrap::getObjectManager()->get('Magento\Customer\Helper\Data') + ->generateResetPasswordLinkToken(); $customer->changeResetPasswordLinkToken($token); $this->getRequest()->setParam('token', 'INVALIDTOKEN'); @@ -141,11 +132,8 @@ public function testCreatepasswordActionInvalidToken() public function testConfirmActionAlreadyActive() { /** @var \Magento\Customer\Model\Customer $customer */ - $customer = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Customer\Model\Customer' - )->load( - 1 - ); + $customer = Bootstrap::getObjectManager() + ->create('Magento\Customer\Model\Customer')->load(1); $this->getRequest()->setParam('key', 'abc'); $this->getRequest()->setParam('id', $customer->getId()); @@ -162,66 +150,31 @@ public function testConfirmActionAlreadyActive() public function testNoConfirmCreatePostAction() { // Setting data for request - $this->getRequest()->setServer( - array('REQUEST_METHOD' => 'POST') - )->setParam( - 'firstname', - 'firstname1' - )->setParam( - 'lastname', - 'lastname1' - )->setParam( - 'company', - '' - )->setParam( - 'email', - 'test1@email.com' - )->setParam( - 'password', - 'password' - )->setParam( - 'confirmation', - 'password' - )->setParam( - 'telephone', - '5123334444' - )->setParam( - 'street', - array('1234 fake street', '') - )->setParam( - 'city', - 'Austin' - )->setParam( - 'region_id', - 57 - )->setParam( - 'region', - '' - )->setParam( - 'postcode', - '78701' - )->setParam( - 'country_id', - 'US' - )->setParam( - 'default_billing', - '1' - )->setParam( - 'default_shipping', - '1' - )->setParam( - 'is_subscribed', - '0' - )->setPost( - 'create_address', - true - ); + $this->getRequest() + ->setServer(array('REQUEST_METHOD' => 'POST')) + ->setParam('firstname', 'firstname1') + ->setParam('lastname', 'lastname1') + ->setParam('company', '') + ->setParam('email', 'test1@email.com') + ->setParam('password', 'password') + ->setParam('confirmation', 'password') + ->setParam('telephone', '5123334444') + ->setParam('street', array('1234 fake street', '')) + ->setParam('city', 'Austin') + ->setParam('region_id', 57) + ->setParam('region', '') + ->setParam('postcode', '78701') + ->setParam('country_id', 'US') + ->setParam('default_billing', '1') + ->setParam('default_shipping', '1') + ->setParam('is_subscribed', '0') + ->setPost('create_address', true); $this->dispatch('customer/account/createPost'); $this->assertRedirect($this->stringContains('customer/account/index/')); $this->assertSessionMessages( - $this->equalTo(array('Thank you for registering with Main Website Store.')), - \Magento\Message\MessageInterface::TYPE_SUCCESS + $this->equalTo(['Thank you for registering with Main Website Store.']), + MessageInterface::TYPE_SUCCESS ); } @@ -234,74 +187,36 @@ public function testWithConfirmCreatePostAction() { // Setting data for request $email = 'test2@email.com'; - $this->getRequest()->setServer( - array('REQUEST_METHOD' => 'POST') - )->setParam( - 'firstname', - 'firstname2' - )->setParam( - 'lastname', - 'lastname2' - )->setParam( - 'company', - '' - )->setParam( - 'email', - $email - )->setParam( - 'password', - 'password' - )->setParam( - 'confirmation', - 'password' - )->setParam( - 'telephone', - '5123334444' - )->setParam( - 'street', - array('1234 fake street', '') - )->setParam( - 'city', - 'Austin' - )->setParam( - 'region_id', - 57 - )->setParam( - 'region', - '' - )->setParam( - 'postcode', - '78701' - )->setParam( - 'country_id', - 'US' - )->setParam( - 'default_billing', - '1' - )->setParam( - 'default_shipping', - '1' - )->setParam( - 'is_subscribed', - '1' - )->setPost( - 'create_address', - true - ); + $this->getRequest() + ->setServer(array('REQUEST_METHOD' => 'POST')) + ->setParam('firstname', 'firstname2') + ->setParam('lastname', 'lastname2') + ->setParam('company', '') + ->setParam('email', $email) + ->setParam('password', 'password') + ->setParam('confirmation', 'password') + ->setParam('telephone', '5123334444') + ->setParam('street', array('1234 fake street', '')) + ->setParam('city', 'Austin') + ->setParam('region_id', 57) + ->setParam('region', '') + ->setParam('postcode', '78701') + ->setParam('country_id', 'US') + ->setParam('default_billing', '1') + ->setParam('default_shipping', '1') + ->setParam('is_subscribed', '1') + ->setPost('create_address', true); $this->dispatch('customer/account/createPost'); $this->assertRedirect($this->stringContains('customer/account/index/')); $this->assertSessionMessages( - $this->equalTo( - array( - 'Account confirmation is required. Please, check your email for the confirmation link. ' . - 'To resend the confirmation email please ' . - 'click here.' - ) - ), - \Magento\Message\MessageInterface::TYPE_SUCCESS + $this->equalTo([ + 'Account confirmation is required. Please, check your email for the confirmation link. ' . + 'To resend the confirmation email please ' . + 'click here.' + ]), + MessageInterface::TYPE_SUCCESS ); } @@ -311,73 +226,34 @@ public function testWithConfirmCreatePostAction() public function testExistingEmailCreatePostAction() { // Setting data for request - $this->getRequest()->setServer( - array('REQUEST_METHOD' => 'POST') - )->setParam( - 'firstname', - 'firstname' - )->setParam( - 'lastname', - 'lastname' - )->setParam( - 'company', - '' - )->setParam( - 'email', - 'customer@example.com' - )->setParam( - 'password', - 'password' - )->setParam( - 'confirmation', - 'password' - )->setParam( - 'telephone', - '5123334444' - )->setParam( - 'street', - array('1234 fake street', '') - )->setParam( - 'city', - 'Austin' - )->setParam( - 'region_id', - 57 - )->setParam( - 'region', - '' - )->setParam( - 'postcode', - '78701' - )->setParam( - 'country_id', - 'US' - )->setParam( - 'default_billing', - '1' - )->setParam( - 'default_shipping', - '1' - )->setParam( - 'is_subscribed', - '1' - )->setPost( - 'create_address', - true - ); + $this->getRequest() + ->setServer(array('REQUEST_METHOD' => 'POST')) + ->setParam('firstname', 'firstname') + ->setParam('lastname', 'lastname') + ->setParam('company', '') + ->setParam('email', 'customer@example.com') + ->setParam('password', 'password') + ->setParam('confirmation', 'password') + ->setParam('telephone', '5123334444') + ->setParam('street', array('1234 fake street', '')) + ->setParam('city', 'Austin') + ->setParam('region_id', 57) + ->setParam('region', '') + ->setParam('postcode', '78701') + ->setParam('country_id', 'US') + ->setParam('default_billing', '1') + ->setParam('default_shipping', '1') + ->setParam('is_subscribed', '1') + ->setPost('create_address', true); $this->dispatch('customer/account/createPost'); $this->assertRedirect($this->stringContains('customer/account/create/')); $this->assertSessionMessages( - $this->equalTo( - array( - 'There is already an account with this email address. ' . - 'If you are sure that it is your email address, ' . - 'click here' . - ' to get your password and access your account.' - ) - ), - \Magento\Message\MessageInterface::TYPE_ERROR + $this->equalTo(['There is already an account with this email address. ' . + 'If you are sure that it is your email address, ' . + 'click here' . + ' to get your password and access your account.']), + MessageInterface::TYPE_ERROR ); } @@ -387,15 +263,11 @@ public function testExistingEmailCreatePostAction() public function testOpenActionCreatepasswordAction() { /** @var \Magento\Customer\Model\Customer $customer */ - $customer = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Customer\Model\Customer' - )->load( - 1 - ); + $customer = Bootstrap::getObjectManager() + ->create('Magento\Customer\Model\Customer')->load(1); - $token = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Customer\Helper\Data' - )->generateResetPasswordLinkToken(); + $token = Bootstrap::getObjectManager()->get('Magento\Customer\Helper\Data') + ->generateResetPasswordLinkToken(); $customer->changeResetPasswordLinkToken($token); $this->getRequest()->setParam('token', $token); @@ -420,17 +292,15 @@ public function testOpenActionCreatepasswordAction() */ public function testInactiveUserConfirmationAction() { - $this->getRequest()->setServer( - array('REQUEST_METHOD' => 'POST') - )->setPost( - array('email' => 'customer@needAconfirmation.com') - ); + $this->getRequest() + ->setServer(['REQUEST_METHOD' => 'POST']) + ->setPost(['email' => 'customer@needAconfirmation.com']); $this->dispatch('customer/account/confirmation'); $this->assertRedirect($this->stringContains('customer/account/index')); $this->assertSessionMessages( - $this->equalTo(array('Please, check your email for confirmation key.')), - \Magento\Message\MessageInterface::TYPE_SUCCESS + $this->equalTo(['Please, check your email for confirmation key.']), + MessageInterface::TYPE_SUCCESS ); } @@ -439,17 +309,17 @@ public function testInactiveUserConfirmationAction() */ public function testActiveUserConfirmationAction() { - $this->getRequest()->setServer( - array('REQUEST_METHOD' => 'POST') - )->setPost( - array('email' => 'customer@example.com') - ); + $this->getRequest() + ->setServer(['REQUEST_METHOD' => 'POST']) + ->setPost([ + 'email' => 'customer@example.com' + ]); $this->dispatch('customer/account/confirmation'); $this->assertRedirect($this->stringContains('customer/account/index')); $this->assertSessionMessages( - $this->equalTo(array('This email does not require confirmation.')), - \Magento\Message\MessageInterface::TYPE_SUCCESS + $this->equalTo(['This email does not require confirmation.']), + MessageInterface::TYPE_SUCCESS ); } @@ -457,30 +327,34 @@ public function testForgotPasswordPostAction() { $email = 'customer@example.com'; - $this->getRequest()->setPost(array('email' => $email)); + $this->getRequest() + ->setPost([ + 'email' => $email + ]); $this->dispatch('customer/account/forgotPasswordPost'); $this->assertRedirect($this->stringContains('customer/account/')); $this->assertSessionMessages( - $this->equalTo( - array( - "If there is an account associated with {$email} you will receive an email " . - 'with a link to reset your password.' - ) - ), - \Magento\Message\MessageInterface::TYPE_SUCCESS + $this->equalTo([ + "If there is an account associated with {$email} you will receive an email " . + 'with a link to reset your password.' + ]), + MessageInterface::TYPE_SUCCESS ); } public function testForgotPasswordPostWithBadEmailAction() { - $this->getRequest()->setPost(array('email' => 'bad@email')); + $this->getRequest() + ->setPost([ + 'email' => 'bad@email' + ]); $this->dispatch('customer/account/forgotPasswordPost'); $this->assertRedirect($this->stringContains('customer/account/forgotpassword')); $this->assertSessionMessages( - $this->equalTo(array('Please correct the email address.')), - \Magento\Message\MessageInterface::TYPE_ERROR + $this->equalTo(['Please correct the email address.']), + MessageInterface::TYPE_ERROR ); } @@ -489,21 +363,19 @@ public function testForgotPasswordPostWithBadEmailAction() */ public function testResetPasswordPostNoTokenAction() { - $this->getRequest()->setParam( - 'id', - 1 - )->setParam( - 'token', - '8ed8677e6c79e68b94e61658bd756ea5' - )->setPost( - array('password' => 'new-password', 'confirmation' => 'new-password') - ); + $this->getRequest() + ->setParam('id', 1) + ->setParam('token', '8ed8677e6c79e68b94e61658bd756ea5') + ->setPost([ + 'password' => 'new-password', + 'confirmation' => 'new-password' + ]); $this->dispatch('customer/account/resetPasswordPost'); $this->assertRedirect($this->stringContains('customer/account/')); $this->assertSessionMessages( - $this->equalTo(array('There was an error saving the new password.')), - \Magento\Message\MessageInterface::TYPE_ERROR + $this->equalTo(['There was an error saving the new password.']), + MessageInterface::TYPE_ERROR ); } @@ -513,21 +385,19 @@ public function testResetPasswordPostNoTokenAction() */ public function testResetPasswordPostAction() { - $this->getRequest()->setQuery( - 'id', - 1 - )->setQuery( - 'token', - '8ed8677e6c79e68b94e61658bd756ea5' - )->setPost( - array('password' => 'new-password', 'confirmation' => 'new-password') - ); + $this->getRequest() + ->setQuery('id', 1) + ->setQuery('token', '8ed8677e6c79e68b94e61658bd756ea5') + ->setPost([ + 'password' => 'new-password', + 'confirmation' => 'new-password' + ]); $this->dispatch('customer/account/resetPasswordPost'); $this->assertRedirect($this->stringContains('customer/account/login')); $this->assertSessionMessages( - $this->equalTo(array('Your password has been updated.')), - \Magento\Message\MessageInterface::TYPE_SUCCESS + $this->equalTo(['Your password has been updated.']), + MessageInterface::TYPE_SUCCESS ); } @@ -536,7 +406,7 @@ public function testResetPasswordPostAction() */ public function testEditAction() { - $this->_login(); + $this->login(1); $this->dispatch('customer/account/edit'); @@ -544,11 +414,8 @@ public function testEditAction() $this->assertEquals(200, $this->getResponse()->getHttpResponseCode(), $body); $this->assertContains('
', $body); // Verify the password check box is not checked - $this->assertContains( - '', - $body - ); + $this->assertContains('', $body); } /** @@ -556,7 +423,7 @@ public function testEditAction() */ public function testChangePasswordEditAction() { - $this->_login(); + $this->login(1); $this->dispatch('customer/account/edit/changepass/1'); @@ -564,45 +431,40 @@ public function testChangePasswordEditAction() $this->assertEquals(200, $this->getResponse()->getHttpResponseCode(), $body); $this->assertContains('
', $body); // Verify the password check box is checked - $this->assertContains( - '', - $body - ); + $this->assertContains('', $body); } + /** * @magentoDataFixture Magento/Customer/_files/customer.php */ public function testEditPostAction() { /** @var $customerAccountService \Magento\Customer\Service\V1\CustomerAccountServiceInterface */ - $customerAccountService = Bootstrap::getObjectManager()->get( - 'Magento\Customer\Service\V1\CustomerAccountServiceInterface' - ); + $customerAccountService = Bootstrap::getObjectManager() + ->get('Magento\Customer\Service\V1\CustomerAccountServiceInterface'); $customer = $customerAccountService->getCustomer(1); $this->assertEquals('Firstname', $customer->getFirstname()); $this->assertEquals('Lastname', $customer->getLastname()); $this->assertEquals('customer@example.com', $customer->getEmail()); - $this->_login(); - $this->getRequest()->setServer( - array('REQUEST_METHOD' => 'POST') - )->setPost( - array( - 'form_key' => $this->_objectManager->get('Magento\Data\Form\FormKey')->getFormKey(), + $this->login(1); + $this->getRequest() + ->setServer(['REQUEST_METHOD' => 'POST']) + ->setPost([ + 'form_key' => $this->_objectManager->get('Magento\Data\Form\FormKey')->getFormKey(), 'firstname' => 'John', - 'lastname' => 'Doe', - 'email' => 'johndoe@email.com' - ) - ); + 'lastname' => 'Doe', + 'email' => 'johndoe@email.com' + ]); $this->dispatch('customer/account/editPost'); $this->assertRedirect($this->stringEndsWith('customer/account/')); $this->assertSessionMessages( - $this->equalTo(array('The account information has been saved.')), - \Magento\Message\MessageInterface::TYPE_SUCCESS + $this->equalTo(['The account information has been saved.']), + MessageInterface::TYPE_SUCCESS ); $customer = $customerAccountService->getCustomer(1); @@ -617,41 +479,37 @@ public function testEditPostAction() public function testChangePasswordEditPostAction() { /** @var $customerAccountService \Magento\Customer\Service\V1\CustomerAccountServiceInterface */ - $customerAccountService = Bootstrap::getObjectManager()->get( - 'Magento\Customer\Service\V1\CustomerAccountServiceInterface' - ); + $customerAccountService = Bootstrap::getObjectManager() + ->get('Magento\Customer\Service\V1\CustomerAccountServiceInterface'); $customer = $customerAccountService->getCustomer(1); $this->assertEquals('Firstname', $customer->getFirstname()); $this->assertEquals('Lastname', $customer->getLastname()); $this->assertEquals('customer@example.com', $customer->getEmail()); /** @var $customerAccountService \Magento\Customer\Service\V1\CustomerAccountServiceInterface */ - $customerAccountService = Bootstrap::getObjectManager()->get( - 'Magento\Customer\Service\V1\CustomerAccountServiceInterface' - ); - - $this->_login(); - $this->getRequest()->setServer( - array('REQUEST_METHOD' => 'POST') - )->setPost( - array( - 'form_key' => $this->_objectManager->get('Magento\Data\Form\FormKey')->getFormKey(), - 'firstname' => 'John', - 'lastname' => 'Doe', - 'email' => 'johndoe@email.com', - 'change_password' => 1, + $customerAccountService = Bootstrap::getObjectManager() + ->get('Magento\Customer\Service\V1\CustomerAccountServiceInterface'); + + $this->login(1); + $this->getRequest() + ->setServer(['REQUEST_METHOD' => 'POST']) + ->setPost([ + 'form_key' => $this->_objectManager->get('Magento\Data\Form\FormKey')->getFormKey(), + 'firstname' => 'John', + 'lastname' => 'Doe', + 'email' => 'johndoe@email.com', + 'change_password' => 1, 'current_password' => 'password', - 'password' => 'new-password', - 'confirmation' => 'new-password' - ) - ); + 'password' => 'new-password', + 'confirmation' => 'new-password' + ]); $this->dispatch('customer/account/editPost'); $this->assertRedirect($this->stringEndsWith('customer/account/')); $this->assertSessionMessages( - $this->equalTo(array('The account information has been saved.')), - \Magento\Message\MessageInterface::TYPE_SUCCESS + $this->equalTo(['The account information has been saved.']), + MessageInterface::TYPE_SUCCESS ); $customer = $customerAccountService->getCustomer(1); @@ -665,24 +523,22 @@ public function testChangePasswordEditPostAction() */ public function testMissingDataEditPostAction() { - $this->_login(); - $this->getRequest()->setServer( - array('REQUEST_METHOD' => 'POST') - )->setPost( - array( - 'form_key' => $this->_objectManager->get('Magento\Data\Form\FormKey')->getFormKey(), + $this->login(1); + $this->getRequest() + ->setServer(['REQUEST_METHOD' => 'POST']) + ->setPost([ + 'form_key' => $this->_objectManager->get('Magento\Data\Form\FormKey')->getFormKey(), 'firstname' => 'John', - 'lastname' => 'Doe', - 'email' => 'bad-email' - ) - ); + 'lastname' => 'Doe', + 'email' => 'bad-email' + ]); $this->dispatch('customer/account/editPost'); $this->assertRedirect($this->stringEndsWith('customer/account/edit/')); $this->assertSessionMessages( - $this->equalTo(array('Invalid input')), - \Magento\Message\MessageInterface::TYPE_ERROR + $this->equalTo(['Invalid input']), + MessageInterface::TYPE_ERROR ); } @@ -691,28 +547,26 @@ public function testMissingDataEditPostAction() */ public function testWrongPasswordEditPostAction() { - $this->_login(); - $this->getRequest()->setServer( - array('REQUEST_METHOD' => 'POST') - )->setPost( - array( - 'form_key' => $this->_objectManager->get('Magento\Data\Form\FormKey')->getFormKey(), - 'firstname' => 'John', - 'lastname' => 'Doe', - 'email' => 'johndoe@email.com', - 'change_password' => 1, + $this->login(1); + $this->getRequest() + ->setServer(['REQUEST_METHOD' => 'POST']) + ->setPost([ + 'form_key' => $this->_objectManager->get('Magento\Data\Form\FormKey')->getFormKey(), + 'firstname' => 'John', + 'lastname' => 'Doe', + 'email' => 'johndoe@email.com', + 'change_password' => 1, 'current_password' => 'wrong-password', - 'password' => 'new-password', - 'confirmation' => 'new-password' - ) - ); + 'password' => 'new-password', + 'confirmation' => 'new-password' + ]); $this->dispatch('customer/account/editPost'); $this->assertRedirect($this->stringEndsWith('customer/account/edit/')); $this->assertSessionMessages( - $this->equalTo(array("Password doesn't match for this account.")), - \Magento\Message\MessageInterface::TYPE_ERROR + $this->equalTo(["Password doesn't match for this account."]), + MessageInterface::TYPE_ERROR ); } @@ -721,28 +575,26 @@ public function testWrongPasswordEditPostAction() */ public function testWrongConfirmationEditPostAction() { - $this->_login(); - $this->getRequest()->setServer( - array('REQUEST_METHOD' => 'POST') - )->setPost( - array( - 'form_key' => $this->_objectManager->get('Magento\Data\Form\FormKey')->getFormKey(), - 'firstname' => 'John', - 'lastname' => 'Doe', - 'email' => 'johndoe@email.com', - 'change_password' => 1, + $this->login(1); + $this->getRequest() + ->setServer(['REQUEST_METHOD' => 'POST']) + ->setPost([ + 'form_key' => $this->_objectManager->get('Magento\Data\Form\FormKey')->getFormKey(), + 'firstname' => 'John', + 'lastname' => 'Doe', + 'email' => 'johndoe@email.com', + 'change_password' => 1, 'current_password' => 'password', - 'password' => 'new-password', - 'confirmation' => 'new-password-no-match' - ) - ); + 'password' => 'new-password', + 'confirmation' => 'new-password-no-match' + ]); $this->dispatch('customer/account/editPost'); $this->assertRedirect($this->stringEndsWith('customer/account/edit/')); $this->assertSessionMessages( - $this->equalTo(array('Confirm your new password')), - \Magento\Message\MessageInterface::TYPE_ERROR + $this->equalTo(['Confirm your new password']), + MessageInterface::TYPE_ERROR ); } } diff --git a/dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/IndexTest.php b/dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/IndexTest.php index 00d0399ce5179..40e9a576d4a8b 100755 --- a/dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/IndexTest.php +++ b/dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/IndexTest.php @@ -72,6 +72,9 @@ protected function tearDown() Bootstrap::getObjectManager()->get('Magento\Backend\Model\Session')->getMessages(true); } + /** + * @magentoDbIsolation enabled + */ public function testSaveActionWithEmptyPostData() { $this->getRequest()->setPost(array()); @@ -79,6 +82,9 @@ public function testSaveActionWithEmptyPostData() $this->assertRedirect($this->stringStartsWith($this->_baseControllerUrl)); } + /** + * @magentoDbIsolation enabled + */ public function testSaveActionWithInvalidFormData() { $post = array('account' => array('middlename' => 'test middlename', 'group_id' => 1)); @@ -175,6 +181,7 @@ public function testSaveActionWithValidCustomerDataAndValidAddressData() * Check that errors was generated and set to session */ $this->assertSessionMessages($this->isEmpty(), \Magento\Message\MessageInterface::TYPE_ERROR); + /** * Check that customer data were set to session */ @@ -203,6 +210,12 @@ public function testSaveActionWithValidCustomerDataAndValidAddressData() $this->assertRedirect( $this->stringStartsWith($this->_baseControllerUrl . 'edit/id/' . $customerId . '/back/1') ); + + /** @var \Magento\Newsletter\Model\Subscriber $subscriber */ + $subscriber = $objectManager->get("Magento\Newsletter\Model\SubscriberFactory")->create(); + $this->assertEmpty($subscriber->getId()); + $subscriber->loadByCustomerId($customerId); + $this->assertEmpty($subscriber->getId()); } /** @@ -252,7 +265,8 @@ public function testSaveActionExistingCustomerAndExistingAddressData() 'postcode' => '', 'telephone' => '' ) - ) + ), + 'subscription' => '' ); $this->getRequest()->setPost($post); $this->getRequest()->setParam('customer_id', 1); @@ -290,6 +304,56 @@ public function testSaveActionExistingCustomerAndExistingAddressData() $newAddress = $this->customerAddressService->getDefaultShippingAddress($customerId); $this->assertEquals('new firstname', $newAddress->getFirstname()); + /** @var \Magento\Newsletter\Model\Subscriber $subscriber */ + $subscriber = $objectManager->get("Magento\Newsletter\Model\SubscriberFactory")->create(); + $this->assertEmpty($subscriber->getId()); + $subscriber->loadByCustomerId($customerId); + $this->assertNotEmpty($subscriber->getId()); + $this->assertEquals(1, $subscriber->getStatus()); + + $this->assertRedirect($this->stringStartsWith($this->_baseControllerUrl . 'index/key/')); + } + + /** + * @magentoDataFixture Magento/Newsletter/_files/subscribers.php + */ + public function testSaveActionExistingCustomerUnsubscribeNewsletter() + { + $customerId = 1; + /** @var $objectManager \Magento\TestFramework\ObjectManager */ + $objectManager = Bootstrap::getObjectManager(); + + /** @var \Magento\Newsletter\Model\Subscriber $subscriber */ + $subscriber = $objectManager->get("Magento\Newsletter\Model\SubscriberFactory")->create(); + $this->assertEmpty($subscriber->getId()); + $subscriber->loadByCustomerId($customerId); + $this->assertNotEmpty($subscriber->getId()); + $this->assertEquals(1, $subscriber->getStatus()); + + $post = array( + 'customer_id' => $customerId, + ); + $this->getRequest()->setPost($post); + $this->getRequest()->setParam('customer_id', 1); + $this->dispatch('backend/customer/index/save'); + + /** @var \Magento\Newsletter\Model\Subscriber $subscriber */ + $subscriber = $objectManager->get("Magento\Newsletter\Model\SubscriberFactory")->create(); + $this->assertEmpty($subscriber->getId()); + $subscriber->loadByCustomerId($customerId); + $this->assertNotEmpty($subscriber->getId()); + $this->assertEquals(3, $subscriber->getStatus()); + + /** + * Check that success message is set + */ + $this->assertSessionMessages( + $this->equalTo(array('You saved the customer.')), + \Magento\Message\MessageInterface::TYPE_SUCCESS + ); + + + $this->assertRedirect($this->stringStartsWith($this->_baseControllerUrl . 'index/key/')); } @@ -536,8 +600,8 @@ public function testMassSubscriberAction() // Pre-condition /** @var \Magento\Newsletter\Model\SubscriberFactory $subscriberFactory */ $subscriberFactory = Bootstrap::getObjectManager()->get('Magento\Newsletter\Model\SubscriberFactory'); - $this->assertNull($subscriberFactory->create()->loadByCustomer(1)->getSubscriberStatus()); - $this->assertNull($subscriberFactory->create()->loadByCustomer(2)->getSubscriberStatus()); + $this->assertNull($subscriberFactory->create()->loadByCustomerId(1)->getSubscriberStatus()); + $this->assertNull($subscriberFactory->create()->loadByCustomerId(2)->getSubscriberStatus()); // Setup $this->getRequest()->setParam('customer', array(1, 2)); @@ -552,14 +616,17 @@ public function testMassSubscriberAction() ); $this->assertEquals( Subscriber::STATUS_SUBSCRIBED, - $subscriberFactory->create()->loadByCustomer(1)->getSubscriberStatus() + $subscriberFactory->create()->loadByCustomerId(1)->getSubscriberStatus() ); $this->assertEquals( Subscriber::STATUS_SUBSCRIBED, - $subscriberFactory->create()->loadByCustomer(2)->getSubscriberStatus() + $subscriberFactory->create()->loadByCustomerId(2)->getSubscriberStatus() ); } + /** + * @magentoDbIsolation enabled + */ public function testMassSubscriberActionNoSelection() { $this->dispatch('backend/customer/index/massSubscribe'); @@ -571,6 +638,9 @@ public function testMassSubscriberActionNoSelection() ); } + /** + * @magentoDbIsolation enabled + */ public function testMassSubscriberActionInvalidId() { $this->getRequest()->setParam('customer', array(4200)); @@ -592,8 +662,8 @@ public function testMassSubscriberActionPartialUpdate() // Pre-condition /** @var \Magento\Newsletter\Model\SubscriberFactory $subscriberFactory */ $subscriberFactory = Bootstrap::getObjectManager()->get('Magento\Newsletter\Model\SubscriberFactory'); - $this->assertNull($subscriberFactory->create()->loadByCustomer(1)->getSubscriberStatus()); - $this->assertNull($subscriberFactory->create()->loadByCustomer(2)->getSubscriberStatus()); + $this->assertNull($subscriberFactory->create()->loadByCustomerId(1)->getSubscriberStatus()); + $this->assertNull($subscriberFactory->create()->loadByCustomerId(2)->getSubscriberStatus()); // Setup $this->getRequest()->setParam('customer', array(1, 4200, 2)); @@ -612,11 +682,11 @@ public function testMassSubscriberActionPartialUpdate() ); $this->assertEquals( Subscriber::STATUS_SUBSCRIBED, - $subscriberFactory->create()->loadByCustomer(1)->getSubscriberStatus() + $subscriberFactory->create()->loadByCustomerId(1)->getSubscriberStatus() ); $this->assertEquals( Subscriber::STATUS_SUBSCRIBED, - $subscriberFactory->create()->loadByCustomer(2)->getSubscriberStatus() + $subscriberFactory->create()->loadByCustomerId(2)->getSubscriberStatus() ); } @@ -634,6 +704,9 @@ public function testMassDeleteAction() $this->assertRedirect($this->stringContains('customer/index')); } + /** + * @magentoDbIsolation enabled + */ public function testInvalidIdMassDeleteAction() { $this->getRequest()->setPost('customer', array(1)); @@ -646,6 +719,7 @@ public function testInvalidIdMassDeleteAction() /** * Valid group Id but no customer Ids specified + * @magentoDbIsolation enabled */ public function testMassDeleteActionNoCustomerIds() { @@ -695,6 +769,7 @@ public function testMassAssignGroupAction() /** * Valid group Id but no data fixture so no customer exists with customer Id = 1 + * @magentoDbIsolation enabled */ public function testMassAssignGroupActionInvalidCustomerId() { @@ -708,6 +783,7 @@ public function testMassAssignGroupActionInvalidCustomerId() /** * Valid group Id but no customer Ids specified + * @magentoDbIsolation enabled */ public function testMassAssignGroupActionNoCustomerIds() { @@ -750,9 +826,9 @@ public function testMassUnsubscriberAction() // Setup /** @var \Magento\Newsletter\Model\SubscriberFactory $subscriberFactory */ $subscriberFactory = Bootstrap::getObjectManager()->get('Magento\Newsletter\Model\SubscriberFactory'); - $subscriberFactory->create()->updateSubscription(1, true); - $subscriberFactory->create()->updateSubscription(2, true); - $this->getRequest()->setParam('customer', array(1, 2)); + $subscriberFactory->create()->subscribeCustomerById(1); + $subscriberFactory->create()->subscribeCustomerById(2); + $this->getRequest()->setParam('customer', [1, 2]); // Test $this->dispatch('backend/customer/index/massUnsubscribe'); @@ -765,14 +841,17 @@ public function testMassUnsubscriberAction() ); $this->assertEquals( Subscriber::STATUS_UNSUBSCRIBED, - $subscriberFactory->create()->loadByCustomer(1)->getSubscriberStatus() + $subscriberFactory->create()->loadByCustomerId(1)->getSubscriberStatus() ); $this->assertEquals( Subscriber::STATUS_UNSUBSCRIBED, - $subscriberFactory->create()->loadByCustomer(2)->getSubscriberStatus() + $subscriberFactory->create()->loadByCustomerId(2)->getSubscriberStatus() ); } + /** + * @magentoDbIsolation enabled + */ public function testMassUnsubscriberActionNoSelection() { $this->dispatch('backend/customer/index/massUnsubscribe'); @@ -784,6 +863,9 @@ public function testMassUnsubscriberActionNoSelection() ); } + /** + * @magentoDbIsolation enabled + */ public function testMassUnsubscriberActionInvalidId() { $this->getRequest()->setParam('customer', array(4200)); @@ -805,9 +887,9 @@ public function testMassUnsubscriberActionPartialUpdate() // Setup /** @var \Magento\Newsletter\Model\SubscriberFactory $subscriberFactory */ $subscriberFactory = Bootstrap::getObjectManager()->get('Magento\Newsletter\Model\SubscriberFactory'); - $subscriberFactory->create()->updateSubscription(1, true); - $subscriberFactory->create()->updateSubscription(2, true); - $this->getRequest()->setParam('customer', array(1, 4200, 2)); + $subscriberFactory->create()->subscribeCustomerById(1); + $subscriberFactory->create()->subscribeCustomerById(2); + $this->getRequest()->setParam('customer', [1, 4200, 2]); // Test $this->dispatch('backend/customer/index/massUnsubscribe'); @@ -824,11 +906,11 @@ public function testMassUnsubscriberActionPartialUpdate() ); $this->assertEquals( Subscriber::STATUS_UNSUBSCRIBED, - $subscriberFactory->create()->loadByCustomer(1)->getSubscriberStatus() + $subscriberFactory->create()->loadByCustomerId(1)->getSubscriberStatus() ); $this->assertEquals( Subscriber::STATUS_UNSUBSCRIBED, - $subscriberFactory->create()->loadByCustomer(2)->getSubscriberStatus() + $subscriberFactory->create()->loadByCustomerId(2)->getSubscriberStatus() ); } @@ -945,6 +1027,9 @@ public function testValidateCustomerWithAddressFailure() $this->assertContains('\"Country\" is a required value.', $body); } + /** + * @magentoDbIsolation enabled + */ public function testResetPasswordActionNoCustomerId() { // No customer ID in post, will just get redirected to base @@ -952,6 +1037,9 @@ public function testResetPasswordActionNoCustomerId() $this->assertRedirect($this->stringStartsWith($this->_baseControllerUrl)); } + /** + * @magentoDbIsolation enabled + */ public function testResetPasswordActionBadCustomerId() { // Bad customer ID in post, will just get redirected to base diff --git a/dev/tests/integration/testsuite/Magento/Interception/GeneralTest.php b/dev/tests/integration/testsuite/Magento/Interception/GeneralTest.php index 2c063ebe0a6a0..35a7fb1be9e3e 100644 --- a/dev/tests/integration/testsuite/Magento/Interception/GeneralTest.php +++ b/dev/tests/integration/testsuite/Magento/Interception/GeneralTest.php @@ -47,12 +47,9 @@ public function setUp() $relations = new \Magento\ObjectManager\Relations\Runtime($classReader); $definitions = new \Magento\ObjectManager\Definition\Runtime($classReader); $config = new \Magento\Interception\ObjectManager\Config($relations, $definitions); - $argInterpreter = new \Magento\Data\Argument\Interpreter\Composite(array(), 'type'); - $argObjectFactory = new \Magento\ObjectManager\Config\Argument\ObjectFactory($config); $factory = new \Magento\ObjectManager\Factory\Factory( $config, - $argInterpreter, - $argObjectFactory, + null, $definitions ); @@ -112,7 +109,7 @@ public function setUp() 'Magento\Interception\Definition' => $interceptionDefinitions ) ); - $argObjectFactory->setObjectManager($this->_objectManager); + $factory->setObjectManager($this->_objectManager); $config->setInterceptionConfig($interceptionConfig); $config->extend( array( diff --git a/dev/tests/integration/testsuite/Magento/Newsletter/Controller/ManageTest.php b/dev/tests/integration/testsuite/Magento/Newsletter/Controller/ManageTest.php new file mode 100644 index 0000000000000..142dd56174668 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Newsletter/Controller/ManageTest.php @@ -0,0 +1,108 @@ +customerSession = $objectManager->get('Magento\Customer\Model\Session'); + $this->customerSession->setCustomerId(1); + $this->coreSession = $objectManager->get('Magento\Core\Model\Session'); + $this->coreSession->setData('_form_key', 'formKey'); + } + + protected function tearDown() + { + $this->customerSession->setCustomerId(null); + $this->coreSession->unsData('_form_key'); + } + + /** + * @magentoDataFixture Magento/Customer/_files/customer.php + */ + public function testSaveAction() + { + $this->getRequest() + ->setParam('form_key', 'formKey') + ->setParam('is_subscribed', '1'); + $this->dispatch('newsletter/manage/save'); + + $this->assertRedirect($this->stringContains('customer/account/')); + + /** + * Check that errors + */ + $this->assertSessionMessages($this->isEmpty(), \Magento\Message\MessageInterface::TYPE_ERROR); + + /** + * Check that success message + */ + $this->assertSessionMessages( + $this->equalTo(['We saved the subscription.']), + \Magento\Message\MessageInterface::TYPE_SUCCESS + ); + } + + /** + * @magentoDataFixture Magento/Customer/_files/customer.php + */ + public function testSaveActionRemoveSubscription() + { + $this->getRequest() + ->setParam('form_key', 'formKey') + ->setParam('is_subscribed', '0'); + $this->dispatch('newsletter/manage/save'); + + $this->assertRedirect($this->stringContains('customer/account/')); + + /** + * Check that errors + */ + $this->assertSessionMessages($this->isEmpty(), \Magento\Message\MessageInterface::TYPE_ERROR); + + /** + * Check that success message + */ + $this->assertSessionMessages( + $this->equalTo(['We removed the subscription.']), + \Magento\Message\MessageInterface::TYPE_SUCCESS + ); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Newsletter/Controller/SubscriberTest.php b/dev/tests/integration/testsuite/Magento/Newsletter/Controller/SubscriberTest.php new file mode 100644 index 0000000000000..de09e1ea8d261 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Newsletter/Controller/SubscriberTest.php @@ -0,0 +1,109 @@ +getRequest()->setMethod('POST'); + + $this->dispatch('newsletter/subscriber/new'); + + $this->assertSessionMessages($this->isEmpty()); + $this->assertRedirect($this->anything()); + } + + /** + * @magentoDbIsolation enabled + */ + public function testNewActionUnusedEmail() + { + $this->getRequest()->setMethod('POST'); + $this->getRequest()->setPost([ + 'email' => 'not_used@example.com' + ]); + + $this->dispatch('newsletter/subscriber/new'); + + $this->assertSessionMessages($this->equalTo(['Thank you for your subscription.'])); + $this->assertRedirect($this->anything()); + } + + /** + * @magentoDataFixture Magento/Customer/_files/customer.php + */ + public function testNewActionUsedEmail() + { + $this->getRequest()->setMethod('POST'); + $this->getRequest()->setPost([ + 'email' => 'customer@example.com' + ]); + + $this->dispatch('newsletter/subscriber/new'); + + $this->assertSessionMessages($this->equalTo([ + 'There was a problem with the subscription: This email address is already assigned to another user.' + ])); + $this->assertRedirect($this->anything()); + } + + /** + * @magentoDataFixture Magento/Customer/_files/customer.php + */ + public function testNewActionOwnerEmail() + { + $this->getRequest()->setMethod('POST'); + $this->getRequest()->setPost([ + 'email' => 'customer@example.com' + ]); + $this->login(1); + + $this->dispatch('newsletter/subscriber/new'); + + $this->assertSessionMessages($this->equalTo(['Thank you for your subscription.'])); + $this->assertRedirect($this->anything()); + } + + /** + * Login the user + * + * @param string $customerId Customer to mark as logged in for the session + * @return void + */ + protected function login($customerId) + { + /** @var \Magento\Customer\Model\Session $session */ + $session = Bootstrap::getObjectManager() + ->get('Magento\Customer\Model\Session'); + $session->loginById($customerId); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Newsletter/Model/Plugin/PluginTest.php b/dev/tests/integration/testsuite/Magento/Newsletter/Model/Plugin/PluginTest.php new file mode 100644 index 0000000000000..da41c854b76af --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Newsletter/Model/Plugin/PluginTest.php @@ -0,0 +1,162 @@ +accountService = Bootstrap::getObjectManager() + ->get('Magento\Customer\Service\V1\CustomerAccountServiceInterface'); + } + + /** + * @magentoAppArea adminhtml + * @magentoDataFixture Magento/Newsletter/_files/subscribers.php + */ + public function testCustomerCreated() + { + $objectManager = Bootstrap::getObjectManager(); + + /** @var \Magento\Newsletter\Model\Subscriber $subscriber */ + $subscriber = $objectManager->create('Magento\Newsletter\Model\Subscriber'); + $subscriber->loadByEmail('customer_two@example.com'); + $this->assertTrue($subscriber->isSubscribed()); + $this->assertEquals(0, (int)$subscriber->getCustomerId()); + + /** @var \Magento\Customer\Service\V1\Data\CustomerBuilder $customerBuilder */ + $customerBuilder = $objectManager->get('Magento\Customer\Service\V1\Data\CustomerBuilder'); + $customerBuilder->setFirstname('Firstname') + ->setLastname('Lastname') + ->setEmail('customer_two@example.com'); + /** @var \Magento\Customer\Service\V1\Data\CustomerDetailsBuilder $customerDetailsBuilder */ + $customerDetailsBuilder = $objectManager->get('Magento\Customer\Service\V1\Data\CustomerDetailsBuilder'); + $customerDetailsBuilder->setCustomer($customerBuilder->create()); + $createdCustomer = $this->accountService->createAccount($customerDetailsBuilder->create()); + + $subscriber->loadByEmail('customer_two@example.com'); + $this->assertTrue($subscriber->isSubscribed()); + $this->assertEquals($createdCustomer->getId(), (int)$subscriber->getCustomerId()); + } + + + /** + * @magentoAppArea adminhtml + * @magentoDbIsolation enabled + */ + public function testCustomerCreatedNotSubscribed() + { + $this->verifySubscriptionNotExist('customer@example.com'); + + $objectManager = Bootstrap::getObjectManager(); + /** @var \Magento\Customer\Service\V1\Data\CustomerBuilder $customerBuilder */ + $customerBuilder = $objectManager->get('Magento\Customer\Service\V1\Data\CustomerBuilder'); + $customerBuilder->setFirstname('Firstname') + ->setLastname('Lastname') + ->setEmail('customer@example.com'); + /** @var \Magento\Customer\Service\V1\Data\CustomerDetailsBuilder $customerDetailsBuilder */ + $customerDetailsBuilder = $objectManager->get('Magento\Customer\Service\V1\Data\CustomerDetailsBuilder'); + $customerDetailsBuilder->setCustomer($customerBuilder->create()); + $this->accountService->createAccount($customerDetailsBuilder->create()); + + $this->verifySubscriptionNotExist('customer@example.com'); + } + + /** + * @magentoAppArea adminhtml + * @magentoDataFixture Magento/Newsletter/_files/subscribers.php + */ + public function testCustomerUpdatedEmail() + { + $objectManager = Bootstrap::getObjectManager(); + + /** @var \Magento\Newsletter\Model\Subscriber $subscriber */ + $subscriber = $objectManager->create('Magento\Newsletter\Model\Subscriber'); + $subscriber->loadByEmail('customer@example.com'); + $this->assertTrue($subscriber->isSubscribed()); + $this->assertEquals(1, (int)$subscriber->getCustomerId()); + + $customer = $this->accountService->getCustomer(1); + /** @var \Magento\Customer\Service\V1\Data\CustomerBuilder $customerBuilder */ + $customerBuilder = $objectManager->get('Magento\Customer\Service\V1\Data\CustomerBuilder'); + $customerBuilder->populate($customer) + ->setEmail('new@example.com'); + /** @var \Magento\Customer\Service\V1\Data\CustomerDetailsBuilder $customerDetailsBuilder */ + $customerDetailsBuilder = $objectManager->get('Magento\Customer\Service\V1\Data\CustomerDetailsBuilder'); + $customerDetailsBuilder->setCustomer($customerBuilder->create()); + $this->accountService->updateCustomer($customerDetailsBuilder->create()); + + $subscriber->loadByEmail('new@example.com'); + $this->assertTrue($subscriber->isSubscribed()); + $this->assertEquals(1, (int)$subscriber->getCustomerId()); + } + + /** + * @magentoAppArea adminhtml + * @magentoDataFixture Magento/Newsletter/_files/subscribers.php + */ + public function testCustomerDeletedAdminArea() + { + $objectManager = Bootstrap::getObjectManager(); + + /** @var \Magento\Newsletter\Model\Subscriber $subscriber */ + $subscriber = $objectManager->create('Magento\Newsletter\Model\Subscriber'); + $subscriber->loadByEmail('customer@example.com'); + $this->assertTrue($subscriber->isSubscribed()); + + $this->accountService->deleteCustomer(1); + + $this->verifySubscriptionNotExist('customer@example.com'); + } + + /** + * Verify a subscription doesn't exist for a given email address + * + * @param string $email + * @return \Magento\Newsletter\Model\Subscriber + */ + private function verifySubscriptionNotExist($email) + { + $objectManager = Bootstrap::getObjectManager(); + + /** @var \Magento\Newsletter\Model\Subscriber $subscriber */ + $subscriber = $objectManager->create('Magento\Newsletter\Model\Subscriber'); + $subscriber->loadByEmail($email); + $this->assertFalse($subscriber->isSubscribed()); + $this->assertEquals(0, (int)$subscriber->getId()); + return $subscriber; + } +} diff --git a/dev/tests/integration/testsuite/Magento/Newsletter/Model/Resource/Problem/CollectionTest.php b/dev/tests/integration/testsuite/Magento/Newsletter/Model/Resource/Problem/CollectionTest.php new file mode 100644 index 0000000000000..d1cf82a28333c --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Newsletter/Model/Resource/Problem/CollectionTest.php @@ -0,0 +1,69 @@ +_collection = Bootstrap::getObjectManager() + ->create('Magento\Newsletter\Model\Resource\Problem\Collection'); + } + + /** + * @magentoDataFixture Magento/Newsletter/_files/problems.php + */ + public function testAddCustomersData() + { + /** @var \Magento\Customer\Service\V1\CustomerAccountServiceInterface $customerAccountService */ + $customerAccountService = Bootstrap::getObjectManager() + ->create('Magento\Customer\Service\V1\CustomerAccountServiceInterface'); + $customer = $customerAccountService->getCustomerDetails(1)->getCustomer(); + /** @var \Magento\Newsletter\Model\Subscriber $subscriber */ + $subscriber = Bootstrap::getObjectManager() + ->create('Magento\Newsletter\Model\Subscriber')->loadByEmail($customer->getEmail()); + /** @var \Magento\Newsletter\Model\Problem $problem */ + $problem = Bootstrap::getObjectManager() + ->create('Magento\Newsletter\Model\Problem')->addSubscriberData($subscriber); + + $item = $this->_collection->addSubscriberInfo()->load()->getFirstItem(); + + $this->assertEquals($problem->getProblemErrorCode(), $item->getErrorCode()); + $this->assertEquals($problem->getProblemErrorText(), $item->getErrorText()); + $this->assertEquals($problem->getSubscriberId(), $item->getSubscriberId()); + $this->assertEquals($customer->getEmail(), $item->getSubscriberEmail()); + $this->assertEquals($customer->getFirstname(), $item->getCustomerFirstName()); + $this->assertEquals($customer->getLastname(), $item->getCustomerLastName()); + $this->assertContains($customer->getFirstname(), $item->getCustomerName()); + } + +} diff --git a/dev/tests/integration/testsuite/Magento/Newsletter/Model/Resource/Subscriber/CollectionTest.php b/dev/tests/integration/testsuite/Magento/Newsletter/Model/Resource/Subscriber/CollectionTest.php new file mode 100644 index 0000000000000..d711fb4cf113b --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Newsletter/Model/Resource/Subscriber/CollectionTest.php @@ -0,0 +1,57 @@ +_collectionModel = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\Newsletter\Model\Resource\Subscriber\Collection'); + } + + /** + * @magentoDataFixture Magento/Newsletter/_files/subscribers.php + */ + public function testShowCustomerInfo() + { + $this->_collectionModel->showCustomerInfo()->load(); + + /** @var \Magento\Newsletter\Model\Subscriber[] $subscribers */ + $subscribers = $this->_collectionModel->getItems(); + $this->assertCount(2, $subscribers); + $subscriber = array_shift($subscribers); + $this->assertEquals('Firstname', $subscriber->getCustomerFirstname(), $subscriber->getSubscriberEmail()); + $this->assertEquals('Lastname', $subscriber->getCustomerLastname(), $subscriber->getSubscriberEmail()); + $subscriber = array_shift($subscribers); + $this->assertNull($subscriber->getCustomerFirstname(), $subscriber->getSubscriberEmail()); + $this->assertNull($subscriber->getCustomerLastname(), $subscriber->getSubscriberEmail()); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Newsletter/Model/Resource/SubscriberTest.php b/dev/tests/integration/testsuite/Magento/Newsletter/Model/Resource/SubscriberTest.php new file mode 100644 index 0000000000000..2e5d73b7d08df --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Newsletter/Model/Resource/SubscriberTest.php @@ -0,0 +1,72 @@ +_resourceModel = Bootstrap::getObjectManager() + ->create('Magento\Newsletter\Model\Resource\Subscriber'); + } + + /** + * @magentoDataFixture Magento/Newsletter/_files/subscribers.php + */ + public function testLoadByCustomerDataWithCustomerId() + { + /** @var \Magento\Customer\Service\V1\CustomerAccountServiceInterface $customerAccountService */ + $customerAccountService = Bootstrap::getObjectManager() + ->create('Magento\Customer\Service\V1\CustomerAccountServiceInterface'); + $customerData = $customerAccountService->getCustomerDetails(1)->getCustomer(); + $result = $this->_resourceModel->loadByCustomerData($customerData); + + $this->assertEquals(1, $result['customer_id']); + $this->assertEquals('customer@example.com', $result['subscriber_email']); + } + + /** + * @magentoDataFixture Magento/Newsletter/_files/subscribers.php + * @magentoDataFixture Magento/Customer/_files/two_customers.php + */ + public function testLoadByCustomerDataWithoutCustomerId() + { + /** @var \Magento\Customer\Service\V1\CustomerAccountServiceInterface $customerAccountService */ + $customerAccountService = Bootstrap::getObjectManager() + ->create('Magento\Customer\Service\V1\CustomerAccountServiceInterface'); + $customerData = $customerAccountService->getCustomerDetails(2)->getCustomer(); + $result = $this->_resourceModel->loadByCustomerData($customerData); + + $this->assertEquals(0, $result['customer_id']); + $this->assertEquals('customer_two@example.com', $result['subscriber_email']); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Newsletter/Model/SubscriberTest.php b/dev/tests/integration/testsuite/Magento/Newsletter/Model/SubscriberTest.php new file mode 100644 index 0000000000000..9c1fdf6dc08e5 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Newsletter/Model/SubscriberTest.php @@ -0,0 +1,81 @@ +_model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( + 'Magento\Newsletter\Model\Subscriber' + ); + } + + /** + * @magentoDataFixture Magento/Newsletter/_files/subscribers.php + */ + public function testLoadByCustomerId() + { + $this->assertSame($this->_model, $this->_model->loadByCustomerId(1)); + $this->assertEquals('customer@example.com', $this->_model->getSubscriberEmail()); + } + + /** + * @magentoDataFixture Magento/Newsletter/_files/subscribers.php + * @magentoAppArea frontend + */ + public function testUnsubscribeSubscribe() + { + // Unsubscribe and verify + $this->assertSame($this->_model, $this->_model->loadByCustomerId(1)); + $this->assertEquals($this->_model, $this->_model->unsubscribe()); + $this->assertEquals(Subscriber::STATUS_UNSUBSCRIBED, $this->_model->getSubscriberStatus()); + + // Subscribe and verify + $this->assertEquals(Subscriber::STATUS_SUBSCRIBED, $this->_model->subscribe('customer@example.com')); + $this->assertEquals(Subscriber::STATUS_SUBSCRIBED, $this->_model->getSubscriberStatus()); + } + + /** + * @magentoDataFixture Magento/Newsletter/_files/subscribers.php + * @magentoAppArea frontend + */ + public function testUnsubscribeSubscribeByCustomerId() + { + // Unsubscribe and verify + $this->assertSame($this->_model, $this->_model->unsubscribeCustomerById(1)); + $this->assertEquals(Subscriber::STATUS_UNSUBSCRIBED, $this->_model->getSubscriberStatus()); + + // Subscribe and verify + $this->assertSame($this->_model, $this->_model->subscribeCustomerById(1)); + $this->assertEquals(Subscriber::STATUS_SUBSCRIBED, $this->_model->getSubscriberStatus()); + } +} + \ No newline at end of file diff --git a/dev/tests/integration/testsuite/Magento/Newsletter/_files/problems.php b/dev/tests/integration/testsuite/Magento/Newsletter/_files/problems.php new file mode 100644 index 0000000000000..326025748cb0a --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Newsletter/_files/problems.php @@ -0,0 +1,36 @@ +create('Magento\Newsletter\Model\problem'); +// $firstSubscriberId comes from subscribers.php +$problem->setSubscriberId($firstSubscriberId) + ->setQueueId($queue->getQueueId()) + ->setProblemErrorCode(11) + ->setProblemErrorText('error text') + ->save(); + + diff --git a/dev/tests/integration/testsuite/Magento/Newsletter/_files/subscribers.php b/dev/tests/integration/testsuite/Magento/Newsletter/_files/subscribers.php index c947eabecd07c..c6185c303d57f 100644 --- a/dev/tests/integration/testsuite/Magento/Newsletter/_files/subscribers.php +++ b/dev/tests/integration/testsuite/Magento/Newsletter/_files/subscribers.php @@ -26,33 +26,30 @@ */ require __DIR__ . '/../../../Magento/Core/_files/store.php'; +require __DIR__ . '/../../../Magento/Customer/_files/customer.php'; -$currentStore = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Core\Model\StoreManagerInterface' -)->getStore()->getId(); -$otherStore = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Core\Model\StoreManagerInterface' -)->getStore( - 'fixturestore' -)->getId(); +$currentStore = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->get('Magento\Core\Model\StoreManagerInterface')->getStore()->getId(); +$otherStore = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->get('Magento\Core\Model\StoreManagerInterface')->getStore('fixturestore')->getId(); -$subscriber = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Newsletter\Model\Subscriber' -); -$subscriber->setStoreId( - $currentStore -)->setSubscriberEmail( - 'test1@example.com' -)->setSubscriberStatus( - \Magento\Newsletter\Model\Subscriber::STATUS_SUBSCRIBED -)->save(); -$subscriber = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Newsletter\Model\Subscriber' -); -$subscriber->setStoreId( - $otherStore -)->setSubscriberEmail( - 'test2@example.com' -)->setSubscriberStatus( - \Magento\Newsletter\Model\Subscriber::STATUS_SUBSCRIBED -)->save(); +/** @var \Magento\Newsletter\Model\Subscriber $subscriber */ +$subscriber = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\Newsletter\Model\Subscriber'); +$subscriber->setStoreId($currentStore) + ->setCustomerId(1) + ->setSubscriberEmail('customer@example.com') + ->setSubscriberStatus(\Magento\Newsletter\Model\Subscriber::STATUS_SUBSCRIBED) + ->save() +; +$firstSubscriberId = $subscriber->getId(); + +$subscriber = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create('Magento\Newsletter\Model\Subscriber'); +$subscriber->setStoreId($otherStore) + // Intentionally setting ID to 0 instead of 2 to test fallback mechanism in Subscriber model + ->setCustomerId(0) + ->setSubscriberEmail('customer_two@example.com') + ->setSubscriberStatus(\Magento\Newsletter\Model\Subscriber::STATUS_SUBSCRIBED) + ->save() +; diff --git a/dev/tests/integration/testsuite/Magento/ObjectManager/ObjectManagerTest.php b/dev/tests/integration/testsuite/Magento/ObjectManager/ObjectManagerTest.php index d83415db31880..c23172c4f3600 100644 --- a/dev/tests/integration/testsuite/Magento/ObjectManager/ObjectManagerTest.php +++ b/dev/tests/integration/testsuite/Magento/ObjectManager/ObjectManagerTest.php @@ -93,22 +93,13 @@ class ObjectManagerTest extends \PHPUnit_Framework_TestCase public static function setUpBeforeClass() { $config = new \Magento\ObjectManager\Config\Config(); - - $dirList = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\App\Filesystem\DirectoryList' - ); - $loader = new \Magento\App\Arguments\Loader($dirList); - $arguments = new \Magento\App\Arguments(array(), $loader); - $const = new \Magento\Data\Argument\Interpreter\Constant(); - $argInterpreter = new \Magento\App\Arguments\ArgumentInterpreter($arguments, $const); - $argObjectFactory = new \Magento\ObjectManager\Config\Argument\ObjectFactory($config); - $factory = new \Magento\ObjectManager\Factory\Factory($config, $argInterpreter, $argObjectFactory); + $factory = new \Magento\ObjectManager\Factory\Factory($config); self::$_objectManager = new \Magento\ObjectManager\ObjectManager($factory, $config); self::$_objectManager->configure( array('preferences' => array(self::TEST_INTERFACE => self::TEST_INTERFACE_IMPLEMENTATION)) ); - $argObjectFactory->setObjectManager(self::$_objectManager); + $factory->setObjectManager(self::$_objectManager); } public static function tearDownAfterClass() diff --git a/dev/tests/integration/testsuite/Magento/Core/Helper/Url/RewriteTest.php b/dev/tests/integration/testsuite/Magento/UrlRewrite/Helper/UrlRewriteTest.php similarity index 91% rename from dev/tests/integration/testsuite/Magento/Core/Helper/Url/RewriteTest.php rename to dev/tests/integration/testsuite/Magento/UrlRewrite/Helper/UrlRewriteTest.php index 8dc1a33797574..7c1c66ddf34df 100644 --- a/dev/tests/integration/testsuite/Magento/Core/Helper/Url/RewriteTest.php +++ b/dev/tests/integration/testsuite/Magento/UrlRewrite/Helper/UrlRewriteTest.php @@ -18,25 +18,23 @@ * 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 * @subpackage integration_tests * @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\Core\Helper\Url; +namespace Magento\UrlRewrite\Helper; -class RewriteTest extends \PHPUnit_Framework_TestCase +class UrlRewriteTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Core\Helper\Url\Rewrite + * @var \Magento\UrlRewrite\Helper\UrlRewrite */ protected $_helper; protected function setUp() { $this->_helper = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - 'Magento\Core\Helper\Url\Rewrite' + 'Magento\UrlRewrite\Helper\UrlRewrite' ); } diff --git a/dev/tests/integration/testsuite/Magento/Core/Model/Url/RewriteTest.php b/dev/tests/integration/testsuite/Magento/UrlRewrite/Model/UrlRewriteTest.php similarity index 95% rename from dev/tests/integration/testsuite/Magento/Core/Model/Url/RewriteTest.php rename to dev/tests/integration/testsuite/Magento/UrlRewrite/Model/UrlRewriteTest.php index bc7629ba295e2..46bdfd1aa778a 100644 --- a/dev/tests/integration/testsuite/Magento/Core/Model/Url/RewriteTest.php +++ b/dev/tests/integration/testsuite/Magento/UrlRewrite/Model/UrlRewriteTest.php @@ -18,25 +18,23 @@ * 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 * @subpackage integration_tests * @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\Core\Model\Url; +namespace Magento\UrlRewrite\Model; -class RewriteTest extends \PHPUnit_Framework_TestCase +class UrlRewriteTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Core\Model\Url\Rewrite + * @var \Magento\UrlRewrite\Model\UrlRewrite */ protected $_model; protected function setUp() { $this->_model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Core\Model\Url\Rewrite' + 'Magento\UrlRewrite\Model\UrlRewrite' ); } @@ -58,7 +56,7 @@ public function testLoadByRequestPath() try { $read = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Core\Model\Url\Rewrite' + 'Magento\UrlRewrite\Model\UrlRewrite' ); $read->setStoreId( \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( @@ -100,7 +98,7 @@ public function testLoadByIdPath() try { $read = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Core\Model\Url\Rewrite' + 'Magento\UrlRewrite\Model\UrlRewrite' ); $read->setStoreId( \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( diff --git a/dev/tests/integration/testsuite/Magento/View/PublicationTest.php b/dev/tests/integration/testsuite/Magento/View/PublicationTest.php index 6713a818d9095..ff17317d32de0 100644 --- a/dev/tests/integration/testsuite/Magento/View/PublicationTest.php +++ b/dev/tests/integration/testsuite/Magento/View/PublicationTest.php @@ -349,9 +349,7 @@ public function testPublishCssFileFromModule( 'Magento\View\Design\Fallback\Factory' => array( 'arguments' => array( 'filesystem' => array( - 'value' => 'Magento\View\MockedFilesystem', - 'name' => 'filesystem', - \Magento\ObjectManager\Config\Reader\Dom::TYPE_ATTRIBUTE => 'object' + 'instance' => 'Magento\View\MockedFilesystem', ) ) ) @@ -598,20 +596,12 @@ protected function _initTestTheme($allowDuplication = null) array( 'Magento\View\Publisher\CssFile' => array( 'arguments' => array( - 'allowDuplication' => array( - 'name' => 'allowDuplication', - \Magento\ObjectManager\Config\Reader\Dom::TYPE_ATTRIBUTE => 'boolean', - 'value' => $allowDuplication - ) + 'allowDuplication' => $allowDuplication ) ), 'Magento\View\Publisher\File' => array( 'arguments' => array( - 'allowDuplication' => array( - 'name' => 'allowDuplication', - \Magento\ObjectManager\Config\Reader\Dom::TYPE_ATTRIBUTE => 'boolean', - 'value' => $allowDuplication - ) + 'allowDuplication' => $allowDuplication ) ) ) diff --git a/dev/tests/performance/framework/Magento/TestFramework/Application.php b/dev/tests/performance/framework/Magento/TestFramework/Application.php index 1485f25356638..8b5486df62f92 100644 --- a/dev/tests/performance/framework/Magento/TestFramework/Application.php +++ b/dev/tests/performance/framework/Magento/TestFramework/Application.php @@ -285,4 +285,15 @@ public function getObjectManager() } return $this->_objectManager; } + + /** + * Reset object manager + * + * @return \Magento\ObjectManager + */ + public function resetObjectManager() + { + $this->_objectManager = null; + return $this; + } } diff --git a/dev/tests/static/framework/Magento/TestFramework/Utility/Files.php b/dev/tests/static/framework/Magento/TestFramework/Utility/Files.php index b5a22f477ac4b..f6e808e2b3aa6 100644 --- a/dev/tests/static/framework/Magento/TestFramework/Utility/Files.php +++ b/dev/tests/static/framework/Magento/TestFramework/Utility/Files.php @@ -599,6 +599,7 @@ public function classFileExists($class, &$path = '') '/downloader/app/', '/downloader/lib/', '/dev/tools/', + '/dev/tools/performance_toolkit/framework/', '/dev/tests/api-functional/framework/', '/dev/tests/integration/framework/', '/dev/tests/integration/framework/tests/unit/testsuite/', diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/Di/CompilerTest.php b/dev/tests/static/testsuite/Magento/Test/Integrity/Di/CompilerTest.php index 36f30006e0ed6..ee2fcd49b6cd5 100644 --- a/dev/tests/static/testsuite/Magento/Test/Integrity/Di/CompilerTest.php +++ b/dev/tests/static/testsuite/Magento/Test/Integrity/Di/CompilerTest.php @@ -87,8 +87,30 @@ protected function setUp() ); $this->_command = 'php ' . $basePath . '/dev/tools/Magento/Tools/Di/compiler.php --generation=%s --di=%s'; + + $booleanUtils = new \Magento\Stdlib\BooleanUtils(); + $constInterpreter = new \Magento\Data\Argument\Interpreter\Constant(); + $argumentInterpreter = new \Magento\Data\Argument\Interpreter\Composite( + [ + 'boolean' => new \Magento\Data\Argument\Interpreter\Boolean($booleanUtils), + 'string' => new \Magento\Data\Argument\Interpreter\String($booleanUtils), + 'number' => new \Magento\Data\Argument\Interpreter\Number(), + 'null' => new \Magento\Data\Argument\Interpreter\NullType(), + 'object' => new \Magento\Data\Argument\Interpreter\Object($booleanUtils), + 'const' => $constInterpreter, + 'init_parameter' => new \Magento\App\Arguments\ArgumentInterpreter($constInterpreter) + ], + \Magento\ObjectManager\Config\Reader\Dom::TYPE_ATTRIBUTE + ); + // Add interpreters that reference the composite + $argumentInterpreter->addInterpreter( + 'array', + new \Magento\Data\Argument\Interpreter\ArrayType($argumentInterpreter) + ); + $this->_mapper = new \Magento\ObjectManager\Config\Mapper\Dom( - new \Magento\Stdlib\BooleanUtils(), + $argumentInterpreter, + $booleanUtils, new \Magento\ObjectManager\Config\Mapper\ArgumentParser() ); $this->_validator = new \Magento\Code\Validator(); diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/Phrase/ArgumentsTest.php b/dev/tests/static/testsuite/Magento/Test/Integrity/Phrase/ArgumentsTest.php index ddec81d35de99..fa61754b98579 100644 --- a/dev/tests/static/testsuite/Magento/Test/Integrity/Phrase/ArgumentsTest.php +++ b/dev/tests/static/testsuite/Magento/Test/Integrity/Phrase/ArgumentsTest.php @@ -55,7 +55,7 @@ protected function setUp() $rootDir = \Magento\TestFramework\Utility\Files::init()->getPathToSource(); $this->blackList = array( // the file below is the only file where strings are translated without corresponding arguments - $rootDir . str_replace('/', DIRECTORY_SEPARATOR, '/app/code/Magento/Core/Helper/Js.php') + $rootDir . str_replace('/', DIRECTORY_SEPARATOR, '/app/code/Magento/Translation/Model/Js/DataProvider.php') ); } diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/Phrase/JsTest.php b/dev/tests/static/testsuite/Magento/Test/Integrity/Phrase/JsTest.php index d14355f50a526..2b5a2ba2c4968 100644 --- a/dev/tests/static/testsuite/Magento/Test/Integrity/Phrase/JsTest.php +++ b/dev/tests/static/testsuite/Magento/Test/Integrity/Phrase/JsTest.php @@ -59,6 +59,7 @@ public function testGetPhrasesAdminhtml() $registeredPhrases = $this->_getRegisteredPhrases(); + require_once BP . '/app/code/Magento/Backend/App/Area/FrontNameResolver.php'; foreach ($this->_getJavascriptPhrases(\Magento\Backend\App\Area\FrontNameResolver::AREA_CODE) as $phrase) { if (!in_array($phrase['phrase'], $registeredPhrases)) { $unregisteredMessages[] = sprintf( @@ -121,7 +122,9 @@ public function testGetPhrasesFrontend() */ protected function _getRegisteredPhrases() { - $jsHelperFile = __DIR__ . '../../../../../../../../../app/code/Magento/Core/Helper/Js.php'; + $jsHelperFile = realpath( + __DIR__ . '/../../../../../../../../app/code/Magento/Translation/Model/Js/DataProvider.php' + ); $this->_phraseCollector->parse($jsHelperFile); 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 1766f231afb5c..4671fad457a24 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 @@ -806,6 +806,7 @@ array('Magento\Core\Model\Resource\Entity\Table', 'Magento\Model\Resource\Entity\Table'), array('Magento\Core\Model\Resource\Flag', 'Magento\Flag\Resource'), array('Magento\Core\Model\Resource\Iterator', 'Magento\Model\Resource\Iterator'), + array('Magento\Core\Model\Resource\Resource', 'Magento\Install\Model\Resource\Resource'), array('Magento\Core\Model\Resource\Type\AbstractType', 'Magento\Model\Resource\Type\AbstractType'), array('Magento\Core\Model\Resource\Type\Db', 'Magento\Model\Resource\Type\Db'), array('Magento\Core\Model\Resource\Type\Db\Pdo\Mysql', 'Magento\Model\Resource\Type\Db\Pdo\Mysql'), @@ -1970,6 +1971,7 @@ ), array('Magento\Core\Model\Layout\Argument\Updater', 'Magento\View\Layout\Argument\Interpreter\Decorator\Updater'), array('Magento\Core\Model\Layout\Argument\UpdaterInterface', 'Magento\View\Layout\Argument\UpdaterInterface'), + array('Magento\Core\Model\Layout\Filter\Acl', 'Magento\Backend\Model\Layout\Filter\Acl'), array('Magento\View\Layout\Argument\HandlerInterface', 'Magento\Data\Argument\InterpreterInterface'), array('Magento\View\Layout\Argument\HandlerFactory', 'Magento\Data\Argument\Interpreter\Composite'), array('Magento\Phrase\Renderer\Factory'), @@ -2022,6 +2024,7 @@ array('Recurring\Profile', 'Recurring\Payment'), // recurring profile was renamed to recurring payment array('Magento\Catalog\Helper\Product\Flat'), array('Magento\Catalog\Helper\Flat\AbstractFlat'), + array('Magento\Core\App\Action\Plugin\Install', 'Magento\Install\App\Action\Plugin\Install'), array('Magento\Core\App\Action\Plugin\Session', 'Magento\Core\Block\RequireCookie'), array( 'Magento\Core\Model\LocaleInterface', @@ -2165,4 +2168,39 @@ ['Magento\Backend\Model\Translate\Inline'], ['Magento\Backend\Model\Translate\Inline\ConfigFactory'], ['Magento\Translate\Inline\ConfigFactory'], + array('Magento\Core\Model\Template', 'Magento\Email\Model\AbstractTemplate'), + array('Magento\Core\Helper\Js'), + array('Magento\Backend\Helper\Media\Js'), + array( + 'Magento\Core\Model\Resource\Url\Rewrite\Collection', + 'Magento\UrlRewrite\Model\Resource\UrlRewrite\Collection' + ), + array( + 'Magento\Core\Model\Resource\Url\Rewrite', + 'Magento\UrlRewrite\Model\Resource\UrlRewrite' + ), + array( + 'Magento\Core\Model\Url\Rewrite', + 'Magento\UrlRewrite\Model\UrlRewrite' + ), + array( + 'Magento\Core\Model\Source\Urlrewrite\Options', + 'Magento\UrlRewrite\Model\UrlRewrite\OptionProvider' + ), + array( + 'Magento\Core\Model\Source\Urlrewrite\Types', + 'Magento\UrlRewrite\Model\UrlRewrite\TypeProvider' + ), + array( + 'Magento\Core\Helper\Url\Rewrite', + 'Magento\UrlRewrite\Helper\UrlRewrite' + ), + array( + 'Magento\Core\App\FrontController\Plugin\UrlRewrite', + 'Magento\UrlRewrite\App\FrontController\Plugin\UrlRewrite' + ), + array( + 'Magento\Core\App\Request\RewriteService', + 'Magento\UrlRewrite\App\Request\RewriteService' + ), ); 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 762f6fc6c6c71..1003f04019e4b 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 @@ -670,6 +670,7 @@ array('load', 'Magento\Core\Model\Layout\Update', 'Magento\Core\Model\Layout\Merge'), array('loadBaseContents', 'Magento\Email\Model\Template'), array('loadBase', 'Magento\Core\Model\Config'), + array('loadByCustomer', 'Magento\Newsletter\Model\Resource\Subscriber', 'loadByCustomerData'), array('loadDb', 'Magento\Core\Model\Config'), array('loadDiConfiguration', 'Magento\Core\Model\Config'), array('loadEventObservers', 'Magento\Core\Model\Config'), @@ -1348,24 +1349,6 @@ array('_getSession', 'Magento\CatalogSearch\Controller\Result'), array('addPriceBlockType', 'Magento\Rss\Block\Catalog\AbstractCatalog'), array('getAttributeDisabledTypes', 'Magento\Catalog\Helper\Data'), - array('setArguments', 'Magento\ObjectManager\Factory', 'Magento\App\Arguments\ArgumentInterpreter'), - array('setArguments', 'Magento\ObjectManager\Factory\Factory', 'Magento\App\Arguments\ArgumentInterpreter'), - array('setArguments', 'Magento\Interception\FactoryDecorator', 'Magento\App\Arguments\ArgumentInterpreter'), - array( - 'setObjectManager', - 'Magento\ObjectManager\Factory', - 'Magento\ObjectManager\Config\Argument\ObjectFactory::setObjectManager' - ), - array( - 'setObjectManager', - 'Magento\ObjectManager\Factory\Factory', - 'Magento\ObjectManager\Config\Argument\ObjectFactory::setObjectManager' - ), - array( - 'setObjectManager', - 'Magento\Interception\FactoryDecorator', - 'Magento\ObjectManager\Config\Argument\ObjectFactory::setObjectManager' - ), array( '_processArrayNode', 'Magento\ObjectManager\Config\Mapper\Dom', @@ -1585,6 +1568,7 @@ array('quoteSubmitAfter', 'Magento\Customer\Model\Observer'), array('loadByCustomer', 'Magento\Wishlist\Model\Wishlist'), ['_sessionVarCallback', 'Magento\Url', 'Replaced with inlined closure'], + array('processReinitConfig', 'Magento\Core\Model\Observer'), array( 'reviewsAction', 'Magento\Catalog\Controller\Adminhtml\Product', @@ -1592,7 +1576,6 @@ ), ['_insertInlineScriptsHtml', 'Magento\DesignEditor\Model\Translate\Inline', 'addInlineScript'], ['initializeTranslation', 'Magento\Backend\Model\Observer'], - ['getTranslateJson', 'Magento\Core\Helper\Js'], ['_isEmptyTranslateArg', 'Magento\Translate'], ['_getTranslatedString', 'Magento\Translate'], ['initLocale', 'Magento\Translate'], diff --git a/dev/tests/unit/framework/Magento/TestFramework/Helper/ObjectManager.php b/dev/tests/unit/framework/Magento/TestFramework/Helper/ObjectManager.php index 71895ee10704e..0fba8a1596a81 100644 --- a/dev/tests/unit/framework/Magento/TestFramework/Helper/ObjectManager.php +++ b/dev/tests/unit/framework/Magento/TestFramework/Helper/ObjectManager.php @@ -101,12 +101,12 @@ protected function _processSpecialCases($className, $arguments) /** * Retrieve specific mock of core resource model * - * @return \Magento\Core\Model\Resource\Resource|\PHPUnit_Framework_MockObject_MockObject + * @return \Magento\Module\ResourceInterface|\PHPUnit_Framework_MockObject_MockObject */ protected function _getResourceModelMock() { $resourceMock = $this->_testObject->getMock( - 'Magento\Core\Model\Resource\Resource', + 'Magento\Install\Model\Resource\Resource', array('getIdFieldName', '__sleep', '__wakeup'), array(), '', 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 0f48d33875a3b..fe80118fb58c0 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 @@ -99,7 +99,7 @@ public function testGetModel() /** @var $resourceMock \Magento\Core\Model\Resource\Resource */ $resourceMock = $this->getMock( - 'Magento\Core\Model\Resource\Resource', + 'Magento\Install\Model\Resource\Resource', array('_getReadAdapter', 'getIdFieldName', '__sleep', '__wakeup'), array(), '', diff --git a/dev/tests/unit/testsuite/Magento/App/Arguments/ArgumentInterpreterTest.php b/dev/tests/unit/testsuite/Magento/App/Arguments/ArgumentInterpreterTest.php index 90b08ce8a9f68..4e3d4e619b125 100644 --- a/dev/tests/unit/testsuite/Magento/App/Arguments/ArgumentInterpreterTest.php +++ b/dev/tests/unit/testsuite/Magento/App/Arguments/ArgumentInterpreterTest.php @@ -30,14 +30,8 @@ class ArgumentInterpreterTest extends \PHPUnit_Framework_TestCase */ private $object; - /** - * @var \Magento\App\Arguments|\PHPUnit_Framework_MockObject_MockObject - */ - private $arguments; - protected function setUp() { - $this->arguments = $this->getMock('\Magento\App\Arguments', array('get'), array(), '', false); $const = $this->getMock('\Magento\Data\Argument\Interpreter\Constant', array('evaluate'), array(), '', false); $const->expects( $this->once() @@ -48,39 +42,12 @@ protected function setUp() )->will( $this->returnValue('init_param_value') ); - $this->object = new ArgumentInterpreter($this->arguments, $const); + $this->object = new ArgumentInterpreter($const); } public function testEvaluate() { - $expected = 'test_value'; - $this->arguments->expects( - $this->once() - )->method( - 'get' - )->with( - 'init_param_value' - )->will( - $this->returnValue($expected) - ); + $expected = array('argument' => 'init_param_value'); $this->assertEquals($expected, $this->object->evaluate(array('value' => 'FIXTURE_INIT_PARAMETER'))); } - - /** - * @expectedException \Magento\Data\Argument\MissingOptionalValueException - * @expectedExceptionMessage Value of application argument 'init_param_value' is not defined. - */ - public function testEvaluateException() - { - $this->arguments->expects( - $this->once() - )->method( - 'get' - )->with( - 'init_param_value' - )->will( - $this->returnValue(null) - ); - $this->object->evaluate(array('value' => 'FIXTURE_INIT_PARAMETER')); - } } diff --git a/dev/tests/unit/testsuite/Magento/App/Cache/StateTest.php b/dev/tests/unit/testsuite/Magento/App/Cache/StateTest.php index 5c6900f25569e..a66b477d244e1 100644 --- a/dev/tests/unit/testsuite/Magento/App/Cache/StateTest.php +++ b/dev/tests/unit/testsuite/Magento/App/Cache/StateTest.php @@ -31,7 +31,7 @@ class StateTest extends \PHPUnit_Framework_TestCase protected $_model; /** - * @var \Magento\Core\Model\Resource\Cache|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\App\Cache\State\Options|\PHPUnit_Framework_MockObject_MockObject */ protected $_resource; @@ -135,7 +135,7 @@ protected function _buildModel( $this->returnValue($this->_cacheFrontend) ); - $this->_resource = $this->getMock('Magento\Core\Model\Resource\Cache', array(), array(), '', false); + $this->_resource = $this->getMock('Magento\App\Cache\State\Options', array(), array(), '', false); $this->_resource->expects( $this->any() )->method( diff --git a/dev/tests/unit/testsuite/Magento/App/RouterListTest.php b/dev/tests/unit/testsuite/Magento/App/RouterListTest.php index 1ddc5c037ab27..0906f2c4c8e2d 100644 --- a/dev/tests/unit/testsuite/Magento/App/RouterListTest.php +++ b/dev/tests/unit/testsuite/Magento/App/RouterListTest.php @@ -45,9 +45,9 @@ class RouterListTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_routerList = array( - 'adminRouter' => array('instance' => 'AdminClass', 'disable' => true, 'sortOrder' => 10), - 'frontendRouter' => array('instance' => 'FrontClass', 'disable' => false, 'sortOrder' => 10), - 'default' => array('instance' => 'DefaultClass', 'disable' => false, 'sortOrder' => 5) + 'adminRouter' => array('class' => 'AdminClass', 'disable' => true, 'sortOrder' => 10), + 'frontendRouter' => array('class' => 'FrontClass', 'disable' => false, 'sortOrder' => 10), + 'default' => array('class' => 'DefaultClass', 'disable' => false, 'sortOrder' => 5) ); $this->_objectManagerMock = $this->getMock('Magento\ObjectManager'); diff --git a/dev/tests/unit/testsuite/Magento/Backend/Block/System/Config/Form/FieldsetTest.php b/dev/tests/unit/testsuite/Magento/Backend/Block/System/Config/Form/FieldsetTest.php index 36be6cda4f245..8646a071a7655 100644 --- a/dev/tests/unit/testsuite/Magento/Backend/Block/System/Config/Form/FieldsetTest.php +++ b/dev/tests/unit/testsuite/Magento/Backend/Block/System/Config/Form/FieldsetTest.php @@ -82,7 +82,7 @@ protected function setUp() ); $groupMock->expects($this->once())->method('getFieldsetCss')->will($this->returnValue('test_fieldset_css')); - $this->_helperMock = $this->getMock('Magento\Core\Helper\Js', array(), array(), '', false, false); + $this->_helperMock = $this->getMock('Magento\View\Helper\Js', array(), array(), '', false, false); $data = array( 'request' => $this->_requestMock, diff --git a/dev/tests/unit/testsuite/Magento/Backend/Controller/Adminhtml/DashboardTest.php b/dev/tests/unit/testsuite/Magento/Backend/Controller/Adminhtml/DashboardTest.php index bc4ddad74dbb1..afff0a5fca130 100644 --- a/dev/tests/unit/testsuite/Magento/Backend/Controller/Adminhtml/DashboardTest.php +++ b/dev/tests/unit/testsuite/Magento/Backend/Controller/Adminhtml/DashboardTest.php @@ -250,7 +250,9 @@ protected function _factory($request, $response = null) $response = $this->getMock('Magento\App\Response\Http', array(), array(), '', false); $response->headersSentThrowsException = false; } - $rewriteFactory = $this->getMock('Magento\Core\Model\Url\RewriteFactory', array('create'), array(), '', false); + $rewriteFactory = $this->getMock( + 'Magento\UrlRewrite\Model\UrlRewriteFactory', array('create'), array(), '', false + ); $helper = new \Magento\TestFramework\Helper\ObjectManager($this); $varienFront = $helper->getObject('Magento\App\FrontController', array('rewriteFactory' => $rewriteFactory)); diff --git a/dev/tests/unit/testsuite/Magento/Backend/Model/ConfigTest.php b/dev/tests/unit/testsuite/Magento/Backend/Model/ConfigTest.php index af723b9a82bd3..9462383369d5d 100644 --- a/dev/tests/unit/testsuite/Magento/Backend/Model/ConfigTest.php +++ b/dev/tests/unit/testsuite/Magento/Backend/Model/ConfigTest.php @@ -97,7 +97,7 @@ protected function setUp() 'Magento\DB\TransactionFactory', array('create'), array(), '', false ); - $this->_appConfigMock = $this->getMock('Magento\App\ConfigInterface', array(), array(), '', false); + $this->_appConfigMock = $this->getMock('Magento\App\ReinitableConfigInterface', array(), array(), '', false); $this->_configLoaderMock = $this->getMock( 'Magento\Backend\Model\Config\Loader', array('getConfigByPath'), @@ -155,7 +155,7 @@ public function testSaveToCheckAdminSystemConfigChangedSectionEvent() $this->_configLoaderMock->expects($this->any())->method('getConfigByPath')->will($this->returnValue(array())); $this->_eventManagerMock->expects( - $this->at(1) + $this->at(0) )->method( 'dispatch' )->with( @@ -164,7 +164,7 @@ public function testSaveToCheckAdminSystemConfigChangedSectionEvent() ); $this->_eventManagerMock->expects( - $this->at(1) + $this->at(0) )->method( 'dispatch' )->with( diff --git a/dev/tests/unit/testsuite/Magento/Backend/Model/ViewTest.php b/dev/tests/unit/testsuite/Magento/Backend/Model/ViewTest.php index 83f9912c3126b..69cb92d0339eb 100644 --- a/dev/tests/unit/testsuite/Magento/Backend/Model/ViewTest.php +++ b/dev/tests/unit/testsuite/Magento/Backend/Model/ViewTest.php @@ -38,7 +38,7 @@ class ViewTest extends \PHPUnit_Framework_TestCase protected function setUp() { $helper = new \Magento\TestFramework\Helper\ObjectManager($this); - $aclFilter = $this->getMock('Magento\Core\Model\Layout\Filter\Acl', array(), array(), '', false); + $aclFilter = $this->getMock('Magento\Backend\Model\Layout\Filter\Acl', array(), array(), '', false); $this->_layoutMock = $this->getMock('Magento\Core\Model\Layout', array(), array(), '', false); $layoutProcessor = $this->getMock('Magento\View\Layout\ProcessorInterface'); $node = new \Magento\Simplexml\Element(''); diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Block/Product/ListProductTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Block/Product/ListProductTest.php index 6760bef48ceb7..8c83c7bc77393 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Block/Product/ListProductTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Block/Product/ListProductTest.php @@ -40,14 +40,68 @@ class ListProductTest extends \PHPUnit_Framework_TestCase */ protected $layerMock; + /** + * @var \Magento\Core\Helper\PostData|\PHPUnit_Framework_MockObject_MockObject + */ + protected $postDataHelperMock; + + /** + * @var \Magento\Catalog\Model\Product|\PHPUnit_Framework_MockObject_MockObject + */ + protected $productMock; + + /** + * @var \Magento\Checkout\Helper\Cart|\PHPUnit_Framework_MockObject_MockObject + */ + protected $cartHelperMock; + + /** + * @var \Magento\Catalog\Model\Product\Type\Simple|\PHPUnit_Framework_MockObject_MockObject + */ + protected $typeInstanceMock; + protected function setUp() { $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); $this->registryMock = $this->getMock('Magento\Registry', array(), array(), '', false); $this->layerMock = $this->getMock('Magento\Catalog\Model\Layer', array(), array(), '', false); + $this->postDataHelperMock = $this->getMock( + 'Magento\Core\Helper\PostData', + array(), + array(), + '', + false + ); + $this->typeInstanceMock = $this->getMock( + 'Magento\Catalog\Model\Product\Type\Simple', + array(), + array(), + '', + false, + false + ); + $this->productMock = $this->getMock( + 'Magento\Catalog\Model\Product', + array(), + array(), + '', + false + ); + $this->cartHelperMock = $this->getMock( + 'Magento\Checkout\Helper\Cart', + array(), + array(), + '', + false + ); $this->block = $objectManager->getObject( 'Magento\Catalog\Block\Product\ListProduct', - array('registry' => $this->registryMock, 'catalogLayer' => $this->layerMock) + array( + 'registry' => $this->registryMock, + 'catalogLayer' => $this->layerMock, + 'cartHelper' => $this->cartHelperMock, + 'postDataHelper' => $this->postDataHelperMock + ) ); } @@ -61,18 +115,13 @@ public function testGetIdentities() $productTag = 'catalog_product_1'; $categoryTag = 'catalog_category_1'; - $product = $this->getMock( - 'Magento\Catalog\Model\Product', - array('getIdentities', '__wakeup'), - array(), - '', - false - ); - $product->expects($this->once())->method('getIdentities')->will($this->returnValue(array($productTag))); + $this->productMock->expects($this->once()) + ->method('getIdentities') + ->will($this->returnValue(array($productTag))); $itemsCollection = new \ReflectionProperty('Magento\Catalog\Block\Product\ListProduct', '_productCollection'); $itemsCollection->setAccessible(true); - $itemsCollection->setValue($this->block, array($product)); + $itemsCollection->setValue($this->block, array($this->productMock)); $currentCategory = $this->getMock('Magento\Catalog\Model\Category', array(), array(), '', false); $currentCategory->expects($this->once()) @@ -88,4 +137,43 @@ public function testGetIdentities() $this->block->getIdentities() ); } + + public function testGetAddToCartPostParams() + { + $url = 'http://localhost.com/dev/'; + $id = 1; + $uenc = strtr(base64_encode($url), '+/=', '-_,'); + $data = array('product' => $id, \Magento\App\Action\Action::PARAM_NAME_URL_ENCODED => $uenc); + $expectedPostData = json_encode( + array( + 'action' => $url, + 'data' => array('product' => $id, 'uenc' => $uenc) + ) + ); + + $this->typeInstanceMock->expects($this->once()) + ->method('hasRequiredOptions') + ->with($this->equalTo($this->productMock)) + ->will($this->returnValue(false)); + $this->cartHelperMock->expects($this->any()) + ->method('getAddUrl') + ->with($this->equalTo($this->productMock), $this->equalTo(array())) + ->will($this->returnValue($url)); + $this->productMock->expects($this->once()) + ->method('getEntityId') + ->will($this->returnValue($id)); + $this->productMock->expects($this->once()) + ->method('getTypeInstance') + ->will($this->returnValue($this->typeInstanceMock)); + $this->postDataHelperMock->expects($this->once()) + ->method('getEncodedUrl') + ->with($this->equalTo($url)) + ->will($this->returnValue($uenc)); + $this->postDataHelperMock->expects($this->once()) + ->method('getPostData') + ->with($this->equalTo($url), $this->equalTo($data)) + ->will($this->returnValue($expectedPostData)); + $result = $this->block->getAddToCartPostParams($this->productMock); + $this->assertEquals($expectedPostData, $result); + } } diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Initialization/HelperTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Initialization/HelperTest.php index bcb405236f33e..61c2284c5ce8a 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Initialization/HelperTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Initialization/HelperTest.php @@ -30,11 +30,6 @@ class HelperTest extends \PHPUnit_Framework_TestCase */ protected $requestMock; - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $jsHelperMock; - /** * @var \PHPUnit_Framework_MockObject_MockObject */ @@ -78,7 +73,6 @@ class HelperTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->requestMock = $this->getMock('Magento\App\Request\Http', array(), array(), '', false); - $this->jsHelperMock = $this->getMock('Magento\Backend\Helper\Js', array(), array(), '', false); $this->storeMock = $this->getMock('Magento\Core\Model\Store', array(), array(), '', false); $this->websiteMock = $this->getMock('Magento\Core\Model\Website', array(), array(), '', false); $this->storeManagerMock = $this->getMock('Magento\Core\Model\StoreManagerInterface'); @@ -135,7 +129,6 @@ protected function setUp() $this->helper = new Helper( $this->requestMock, - $this->jsHelperMock, $this->storeManagerMock, $this->stockFilterMock, $this->productLinksMock diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Product/UrlTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Product/UrlTest.php index ff5d83f68710b..b70054fa9f3a6 100644 --- a/dev/tests/unit/testsuite/Magento/Catalog/Model/Product/UrlTest.php +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/Product/UrlTest.php @@ -47,7 +47,7 @@ protected function setUp() )->getMock(); $rewriteFactory = $this->getMockBuilder( - 'Magento\Core\Model\Url\RewriteFactory' + 'Magento\UrlRewrite\Model\UrlRewriteFactory' )->disableOriginalConstructor()->setMethods( array('create') )->getMock(); diff --git a/dev/tests/unit/testsuite/Magento/Core/App/FrontController/Plugin/MessageBoxTest.php b/dev/tests/unit/testsuite/Magento/Core/App/FrontController/Plugin/MessageBoxTest.php index 77514b8a137cc..fd07ae05e1337 100644 --- a/dev/tests/unit/testsuite/Magento/Core/App/FrontController/Plugin/MessageBoxTest.php +++ b/dev/tests/unit/testsuite/Magento/Core/App/FrontController/Plugin/MessageBoxTest.php @@ -55,7 +55,7 @@ class MessageBoxTest extends \PHPUnit_Framework_TestCase protected $requestMock; /** - * @var \Magento\View\Element\Messages|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Message\Manager|\PHPUnit_Framework_MockObject_MockObject */ protected $messageManagerMock; @@ -74,13 +74,12 @@ class MessageBoxTest extends \PHPUnit_Framework_TestCase */ public function setUp() { - $this->cookieMock = $this->getMock('Magento\Stdlib\Cookie', array('set', 'get'), array(), '', false); + $this->cookieMock = $this->getMock('Magento\Stdlib\Cookie', array(), array(), '', false); $this->requestMock = $this->getMock('Magento\App\Request\Http', array('isPost'), array(), '', false); $this->configMock = $this->getMock('Magento\PageCache\Model\Config', array('isEnabled'), array(), '', false); - $this->messageManagerMock = $this->getMockBuilder('Magento\Message\ManagerInterface') - ->setMethods(array('getMessages', 'getCount')) + $this->messageManagerMock = $this->getMockBuilder('Magento\Message\Manager') ->disableOriginalConstructor() - ->getMockForAbstractClass(); + ->getMock(); $this->msgBox = new MessageBox( $this->cookieMock, @@ -101,13 +100,9 @@ public function setUp() */ public function testAfterDispatch() { - $messageCollectionMock = $this->getMock('Magento\Message\Collection', array('getCount'), array(), '', false); - $messageCollectionMock->expects($this->once()) - ->method('getCount') - ->will($this->returnValue(5)); $this->messageManagerMock->expects($this->once()) - ->method('getMessages') - ->will($this->returnValue($messageCollectionMock)); + ->method('hasMessages') + ->will($this->returnValue(true)); $this->requestMock->expects($this->once()) ->method('isPost') ->will($this->returnValue(true)); @@ -119,7 +114,8 @@ public function testAfterDispatch() ->with( $this->equalTo(\Magento\Core\App\FrontController\Plugin\MessageBox::COOKIE_NAME), 1, - $this->equalTo(\Magento\Core\App\FrontController\Plugin\MessageBox::COOKIE_PERIOD) + $this->equalTo(\Magento\Core\App\FrontController\Plugin\MessageBox::COOKIE_PERIOD), + '/' ); $this->assertInstanceOf( '\Magento\App\ResponseInterface', diff --git a/dev/tests/unit/testsuite/Magento/Core/Model/NoRouteHandlerListTest.php b/dev/tests/unit/testsuite/Magento/Core/Model/NoRouteHandlerListTest.php index eddfc0a5a865e..eb91cbeac3cb5 100644 --- a/dev/tests/unit/testsuite/Magento/Core/Model/NoRouteHandlerListTest.php +++ b/dev/tests/unit/testsuite/Magento/Core/Model/NoRouteHandlerListTest.php @@ -39,8 +39,8 @@ protected function setUp() { $this->_objectManagerMock = $this->getMock('Magento\ObjectManager'); $handlersList = array( - 'default_handler' => array('instance' => 'Magento\Core\App\Router\NoRouteHandler', 'sortOrder' => 100), - 'backend_handler' => array('instance' => 'Magento\Backend\App\Router\NoRouteHandler', 'sortOrder' => 10) + 'default_handler' => array('class' => 'Magento\Core\App\Router\NoRouteHandler', 'sortOrder' => 100), + 'backend_handler' => array('class' => 'Magento\Backend\App\Router\NoRouteHandler', 'sortOrder' => 10) ); $this->_model = new \Magento\App\Router\NoRouteHandlerList($this->_objectManagerMock, $handlersList); diff --git a/dev/tests/unit/testsuite/Magento/Core/Model/ObserverTest.php b/dev/tests/unit/testsuite/Magento/Core/Model/ObserverTest.php index 95db716f13af1..747686cf3d665 100644 --- a/dev/tests/unit/testsuite/Magento/Core/Model/ObserverTest.php +++ b/dev/tests/unit/testsuite/Magento/Core/Model/ObserverTest.php @@ -50,11 +50,6 @@ class ObserverTest extends \PHPUnit_Framework_TestCase */ protected $_assetsMock; - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $_configMock; - /** * @var \Magento\Core\Model\Observer */ @@ -107,14 +102,6 @@ protected function setUp() false, false ); - $this->_configMock = $this->getMock( - '\Magento\App\ReinitableConfigInterface', - array(), - array(), - '', - false, - false - ); $this->_assetFactory = $this->getMock( 'Magento\View\Asset\PublicFileFactory', @@ -131,7 +118,6 @@ protected function setUp() 'cacheFrontendPool' => $this->_frontendPoolMock, 'design' => $designMock, 'assets' => $this->_assetsMock, - 'config' => $this->_configMock, 'assetFileFactory' => $this->_assetFactory ) ); @@ -143,7 +129,6 @@ protected function tearDown() $this->_frontendPoolMock = null; $this->_themeCustomization = null; $this->_assetsMock = null; - $this->_configMock = null; $this->_model = null; } @@ -190,11 +175,4 @@ public function testApplyThemeCustomization() $observer = new \Magento\Event\Observer(); $this->_model->applyThemeCustomization($observer); } - - public function testProcessReinitConfig() - { - $observer = new \Magento\Event\Observer(); - $this->_configMock->expects($this->once())->method('reinit'); - $this->_model->processReinitConfig($observer); - } } 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 ea825e1ed73f8..5d0c371866a9d 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 @@ -268,7 +268,7 @@ public function testDoUpdateClassAliases($replaceRules, $tableData, $expected, $ $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), + $this->getMock('Magento\Install\Model\Resource\Resource', array(), array(), '', false), $this->getMock('Magento\Core\Model\Resource\Theme\CollectionFactory', array(), array(), '', false), $this->getMock('Magento\Core\Model\Theme\CollectionFactory', array(), array(), '', false), $this->getMock('Magento\Core\Model\Resource\Setup\MigrationFactory', array(), array(), '', false), 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 a0141f2a82703..c2b5bd8f56921 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 @@ -243,7 +243,7 @@ protected function _getObjectManagerMap($countCustomization) ); $inlineMock = $this->getMock('Magento\Translate\Inline', array(), array(), '', false); - $aclFilterMock = $this->getMock('Magento\Core\Model\Layout\Filter\Acl', array(), array(), '', false); + $aclFilterMock = $this->getMock('Magento\Backend\Model\Layout\Filter\Acl', array(), array(), '', false); return array( array( @@ -257,7 +257,7 @@ protected function _getObjectManagerMap($countCustomization) array('Magento\AuthorizationInterface', $authMock), array('Magento\Backend\Model\Session', $backendSession), array('Magento\Translate\Inline', $inlineMock), - array('Magento\Core\Model\Layout\Filter\Acl', $aclFilterMock) + array('Magento\Backend\Model\Layout\Filter\Acl', $aclFilterMock) ); } } 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 1c2e9a8d9cff5..b0629957cd45c 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 @@ -190,7 +190,9 @@ protected function _prepareMocksForTestMatch( $helperMock = $this->_getHelperMock($isVde); $backendSessionMock = $this->_getBackendSessionMock($isVde, $isLoggedIn); $stateMock = $this->_getStateModelMock($routers); - $rewriteServiceMock = $this->getMock('Magento\Core\App\Request\RewriteService', array(), array(), '', false); + $rewriteServiceMock = $this->getMock( + 'Magento\UrlRewrite\App\Request\RewriteService', array(), array(), '', false + ); $routerListMock = $this->getMock('Magento\App\RouterList', array( 'current', diff --git a/dev/tests/unit/testsuite/Magento/DesignEditor/Model/AreaEmulatorTest.php b/dev/tests/unit/testsuite/Magento/DesignEditor/Model/AreaEmulatorTest.php index 2f7ea5e3b8ebd..9f52a3947804b 100644 --- a/dev/tests/unit/testsuite/Magento/DesignEditor/Model/AreaEmulatorTest.php +++ b/dev/tests/unit/testsuite/Magento/DesignEditor/Model/AreaEmulatorTest.php @@ -46,10 +46,7 @@ public function testEmulateLayoutArea() $configuration = array( 'Magento\Core\Model\Layout' => array( 'arguments' => array( - 'area' => array( - \Magento\ObjectManager\Config\Reader\Dom::TYPE_ATTRIBUTE => 'string', - 'value' => 'test_area' - ) + 'area' => 'test_area' ) ) ); diff --git a/dev/tests/unit/testsuite/Magento/Core/Model/TemplateTest.php b/dev/tests/unit/testsuite/Magento/Email/Model/AbstractTemplateTest.php similarity index 88% rename from dev/tests/unit/testsuite/Magento/Core/Model/TemplateTest.php rename to dev/tests/unit/testsuite/Magento/Email/Model/AbstractTemplateTest.php index 82ad5fcf7e74d..0fcea1ee3a52b 100644 --- a/dev/tests/unit/testsuite/Magento/Core/Model/TemplateTest.php +++ b/dev/tests/unit/testsuite/Magento/Email/Model/AbstractTemplateTest.php @@ -26,16 +26,16 @@ */ /** - * Test class for \Magento\Core\Model\Template. + * Test class for \Magento\Email\Model\AbstractTemplate. */ -namespace Magento\Core\Model; +namespace Magento\Email\Model; -class TemplateTest extends \PHPUnit_Framework_TestCase +class AbstractTemplateTest extends \PHPUnit_Framework_TestCase { /** * Template mock * - * @var \Magento\Core\Model\Template + * @var AbstractTemplate */ protected $_model; @@ -43,9 +43,9 @@ protected function setUp() { $helper = new \Magento\TestFramework\Helper\ObjectManager($this); $this->_model = $this->getMockForAbstractClass( - 'Magento\Core\Model\Template', + 'Magento\Email\Model\AbstractTemplate', $helper->getConstructArguments( - 'Magento\Core\Model\Template', + 'Magento\Email\Model\AbstractTemplate', array( 'design' => $this->getMock('Magento\View\DesignInterface'), 'data' => array('area' => \Magento\Core\Model\App\Area::AREA_FRONTEND, 'store' => 1) diff --git a/dev/tests/unit/testsuite/Magento/Core/App/Action/Plugin/InstallTest.php b/dev/tests/unit/testsuite/Magento/Install/App/Action/Plugin/InstallTest.php similarity index 94% rename from dev/tests/unit/testsuite/Magento/Core/App/Action/Plugin/InstallTest.php rename to dev/tests/unit/testsuite/Magento/Install/App/Action/Plugin/InstallTest.php index c821be3268dec..715444df815f7 100644 --- a/dev/tests/unit/testsuite/Magento/Core/App/Action/Plugin/InstallTest.php +++ b/dev/tests/unit/testsuite/Magento/Install/App/Action/Plugin/InstallTest.php @@ -21,12 +21,12 @@ * @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\Core\App\Action\Plugin; +namespace Magento\Install\App\Action\Plugin; class InstallTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Core\App\Action\Plugin\Install + * @var \Magento\Install\App\Action\Plugin\Install */ protected $_plugin; @@ -70,7 +70,7 @@ protected function setUp() }; $this->subjectMock = $this->getMock('Magento\App\Action\Action', array(), array(), '', false); $this->requestMock = $this->getMock('Magento\App\RequestInterface'); - $this->_plugin = new \Magento\Core\App\Action\Plugin\Install( + $this->_plugin = new \Magento\Install\App\Action\Plugin\Install( $this->_appStateMock, $this->_response, $this->_urlMock, 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 54e7b92e0b896..c1b609c6b57c6 100644 --- a/dev/tests/unit/testsuite/Magento/Integration/Controller/Adminhtml/IntegrationTest.php +++ b/dev/tests/unit/testsuite/Magento/Integration/Controller/Adminhtml/IntegrationTest.php @@ -44,7 +44,7 @@ class IntegrationTest extends \PHPUnit_Framework_TestCase /** @var \Magento\ObjectManager|\PHPUnit_Framework_MockObject_MockObject */ protected $_objectManagerMock; - /** @var \Magento\Core\Model\Layout\Filter\Acl|\PHPUnit_Framework_MockObject_MockObject */ + /** @var \Magento\Backend\Model\Layout\Filter\Acl|\PHPUnit_Framework_MockObject_MockObject */ protected $_layoutFilterMock; /** @var \Magento\App\ConfigInterface|\PHPUnit_Framework_MockObject_MockObject */ @@ -121,7 +121,7 @@ protected function setUp() 'Magento\Event\ManagerInterface' )->disableOriginalConstructor()->getMock(); $this->_layoutFilterMock = $this->getMockBuilder( - 'Magento\Core\Model\Layout\Filter\Acl' + 'Magento\Backend\Model\Layout\Filter\Acl' )->disableOriginalConstructor()->getMock(); $this->_backendSessionMock = $this->getMockBuilder( 'Magento\Backend\Model\Session' @@ -884,7 +884,7 @@ protected function _verifyLoadAndRenderLayout() { $map = array( array('Magento\App\ConfigInterface', $this->_configMock), - array('Magento\Core\Model\Layout\Filter\Acl', $this->_layoutFilterMock), + array('Magento\Backend\Model\Layout\Filter\Acl', $this->_layoutFilterMock), array('Magento\Backend\Model\Session', $this->_backendSessionMock), array('Magento\TranslateInterface', $this->_translateModelMock), array('Magento\Config\ScopeInterface', $this->_configScopeMock) diff --git a/dev/tests/unit/testsuite/Magento/Message/ManagerTest.php b/dev/tests/unit/testsuite/Magento/Message/ManagerTest.php index 9a3d95d0fe013..f5096d4f7e4ca 100644 --- a/dev/tests/unit/testsuite/Magento/Message/ManagerTest.php +++ b/dev/tests/unit/testsuite/Magento/Message/ManagerTest.php @@ -258,6 +258,7 @@ public function testAddException() */ public function testAddMessage($type, $methodName) { + $this->assertFalse($this->model->hasMessages()); $message = 'Message'; $messageCollection = $this->getMock('Magento\Message\Collection', array('addMessage'), array(), '', false); $this->session->expects($this->any()) @@ -265,11 +266,11 @@ public function testAddMessage($type, $methodName) ->will($this->returnValue($messageCollection)); $this->eventManager->expects($this->once()) ->method('dispatch')->with('core_session_abstract_add_message'); - $this->messageFactory->expects($this->once()) ->method('create')->with($type, $message) ->will($this->returnValue($this->messageMock)); $this->model->$methodName($message, 'group'); + $this->assertTrue($this->model->hasMessages()); } public function addMessageDataProvider() diff --git a/dev/tests/unit/testsuite/Magento/Newsletter/Controller/ManageTest.php b/dev/tests/unit/testsuite/Magento/Newsletter/Controller/ManageTest.php new file mode 100644 index 0000000000000..217eecc6fd161 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Newsletter/Controller/ManageTest.php @@ -0,0 +1,166 @@ +requestMock = $this->getMockBuilder('Magento\App\RequestInterface') + ->disableOriginalConstructor() + ->getMock(); + $this->responseMock = $this->getMockBuilder('Magento\App\ResponseInterface') + ->disableOriginalConstructor() + ->getMock(); + $this->messageManagerMock = $this->getMockBuilder('Magento\Message\ManagerInterface') + ->disableOriginalConstructor() + ->getMock(); + $this->redirectMock = $this->getMockBuilder('Magento\App\Response\RedirectInterface') + ->disableOriginalConstructor() + ->getMock(); + $this->customerSessionMock = $this->getMockBuilder('Magento\Customer\Model\Session') + ->disableOriginalConstructor() + ->getMock(); + $this->customerSessionMock->expects($this->any()) + ->method('isLoggedIn') + ->will($this->returnValue(true)); + $this->formKeyValidatorMock = $this->getMockBuilder('Magento\Core\App\Action\FormKeyValidator') + ->disableOriginalConstructor() + ->getMock(); + $this->customerAccountServiceMock = + $this->getMockBuilder('Magento\Customer\Service\V1\CustomerAccountServiceInterface') + ->disableOriginalConstructor() + ->getMock(); + $objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); + + $this->controller = $objectManager->getObject('Magento\Newsletter\Controller\Manage', [ + 'request' => $this->requestMock, + 'response' => $this->responseMock, + 'messageManager' => $this->messageManagerMock, + 'redirect' => $this->redirectMock, + 'customerSession' => $this->customerSessionMock, + 'formKeyValidator' => $this->formKeyValidatorMock, + 'customerAccountService' => $this->customerAccountServiceMock + ]); + } + + public function testSaveActionInvalidFormKey() + { + $this->formKeyValidatorMock->expects($this->once()) + ->method('validate') + ->will($this->returnValue(false)); + $this->redirectMock->expects($this->once()) + ->method('redirect') + ->with($this->responseMock, 'customer/account/', []); + $this->messageManagerMock->expects($this->never()) + ->method('addSuccess'); + $this->messageManagerMock->expects($this->never()) + ->method('addError'); + $this->controller->saveAction(); + } + + public function testSaveActionNoCustomerInSession() + { + $this->formKeyValidatorMock->expects($this->once()) + ->method('validate') + ->will($this->returnValue(true)); + $this->customerSessionMock->expects($this->any()) + ->method('getCustomerId') + ->will($this->returnValue(null)); + $this->redirectMock->expects($this->once()) + ->method('redirect') + ->with($this->responseMock, 'customer/account/', []); + $this->messageManagerMock->expects($this->never()) + ->method('addSuccess'); + $this->messageManagerMock->expects($this->once()) + ->method('addError') + ->with('Something went wrong while saving your subscription.'); + $this->controller->saveAction(); + } + + public function testSaveActionWithException() + { + $this->formKeyValidatorMock->expects($this->once()) + ->method('validate') + ->will($this->returnValue(true)); + $this->customerSessionMock->expects($this->any()) + ->method('getCustomerId') + ->will($this->returnValue(1)); + $this->customerAccountServiceMock->expects($this->any()) + ->method('getCustomer') + ->will($this->throwException(new \Magento\Exception\NoSuchEntityException('customerId', 'value'))); + $this->redirectMock->expects($this->once()) + ->method('redirect') + ->with($this->responseMock, 'customer/account/', []); + $this->messageManagerMock->expects($this->never()) + ->method('addSuccess'); + $this->messageManagerMock->expects($this->once()) + ->method('addError') + ->with('Something went wrong while saving your subscription.'); + $this->controller->saveAction(); + } +} diff --git a/dev/tests/unit/testsuite/Magento/ObjectManager/Config/Argument/Interpreter/ObjectTest.php b/dev/tests/unit/testsuite/Magento/ObjectManager/Config/Argument/Interpreter/ObjectTest.php deleted file mode 100644 index 747a0e5fe9322..0000000000000 --- a/dev/tests/unit/testsuite/Magento/ObjectManager/Config/Argument/Interpreter/ObjectTest.php +++ /dev/null @@ -1,103 +0,0 @@ -getMock( - '\Magento\ObjectManager\Config\Argument\ObjectFactory', - array('create'), - array(), - '', - false - ); - $factory->expects( - $this->once() - )->method( - 'create' - )->with( - $className, - $isShared - )->will( - $this->returnValue($expected) - ); - $interpreter = new Object(new BooleanUtils(), $factory); - $this->assertSame($expected, $interpreter->evaluate($data)); - } - - /** - * @return array - */ - public function evaluateDataProvider() - { - return array( - array(array('value' => 'Class'), 'Class', false), - array(array('value' => 'Class', 'shared' => false), 'Class', false), - array(array('value' => 'Class', 'shared' => 0), 'Class', false), - array(array('value' => 'Class', 'shared' => '0'), 'Class', false), - array(array('value' => 'Class', 'shared' => 'false'), 'Class', false), - array(array('value' => 'Class', 'shared' => true), 'Class', true), - array(array('value' => 'Class', 'shared' => 1), 'Class', true), - array(array('value' => 'Class', 'shared' => '1'), 'Class', true), - array(array('value' => 'Class', 'shared' => 'true'), 'Class', true) - ); - } - - /** - * @param array $data - * @dataProvider evaluateErrorDataProvider - * @expectedException \InvalidArgumentException - * @expectedExceptionMessage Object class name is missing. - */ - public function testEvaluateNoClass($data) - { - $factory = $this->getMock('\Magento\ObjectManager\Config\Argument\ObjectFactory', array(), array(), '', false); - $interpreter = new Object(new BooleanUtils(), $factory); - $interpreter->evaluate($data); - } - - /** - * @return array - */ - public function evaluateErrorDataProvider() - { - return array( - array(array()), - array(array('value' => '')), - array(array('value' => false)), - array(array('value' => 0)) - ); - } -} diff --git a/dev/tests/unit/testsuite/Magento/ObjectManager/Config/Argument/ObjectFactoryTest.php b/dev/tests/unit/testsuite/Magento/ObjectManager/Config/Argument/ObjectFactoryTest.php deleted file mode 100644 index d9b37f898cd30..0000000000000 --- a/dev/tests/unit/testsuite/Magento/ObjectManager/Config/Argument/ObjectFactoryTest.php +++ /dev/null @@ -1,106 +0,0 @@ -objectManager = $this->getMockForAbstractClass('\Magento\ObjectManager'); - $this->config = $this->getMockForAbstractClass('\Magento\ObjectManager\Config'); - } - - public function testSetGetObjectManager() - { - $factory = new ObjectFactory($this->config); - $factory->setObjectManager($this->objectManager); - $this->objectManager->expects($this->once())->method('create'); - $factory->create('type', false); - } - - /** - * @expectedException \LogicException - * @expectedExceptionMessage Object manager has not been assigned yet. - */ - public function testGetObjectManagerException() - { - $factory = new ObjectFactory($this->config); - $factory->create('type', false); - } - - /** - * @param bool $isShared - * @param string $expectedMethod - * @dataProvider createDataProvider - */ - public function testCreateLookup($isShared, $expectedMethod) - { - $value = new \StdClass(); - $factory = new ObjectFactory($this->config, $this->objectManager); - $this->objectManager->expects( - $this->once() - )->method( - $expectedMethod - )->with( - 'type' - )->will( - $this->returnValue($value) - ); - $this->config->expects($this->once())->method('isShared')->with('type')->will($this->returnValue($isShared)); - $this->assertSame($value, $factory->create('type')); - } - - /** - * Returns "is shared" and expectation of which ObjectManager method should be called depending on it - * - * @return array - */ - public function createDataProvider() - { - return array(array(true, 'get'), array(false, 'create')); - } - - /** - * @param bool $isShared - * @param string $expectedMethod - * @dataProvider createDataProvider - */ - public function testCreateNoLookup($isShared, $expectedMethod) - { - $factory = new ObjectFactory($this->config, $this->objectManager); - $this->objectManager->expects($this->once())->method($expectedMethod)->with('type'); - $this->config->expects($this->never())->method('isShared'); - $factory->create('type', $isShared); - } -} diff --git a/dev/tests/unit/testsuite/Magento/ObjectManager/Config/Mapper/DomTest.php b/dev/tests/unit/testsuite/Magento/ObjectManager/Config/Mapper/DomTest.php index e544fa4a0f26f..798efab9fc3a3 100644 --- a/dev/tests/unit/testsuite/Magento/ObjectManager/Config/Mapper/DomTest.php +++ b/dev/tests/unit/testsuite/Magento/ObjectManager/Config/Mapper/DomTest.php @@ -30,6 +30,11 @@ class DomTest extends \PHPUnit_Framework_TestCase */ protected $_mapper; + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $argumentInterpreter; + protected function setUp() { $argumentParser = $this->getMock('\Magento\ObjectManager\Config\Mapper\ArgumentParser'); @@ -50,7 +55,17 @@ protected function setUp() $this->returnValueMap(array(array('true', true), array('false', false))) ); - $this->_mapper = new Dom($booleanUtils, $argumentParser); + $this->argumentInterpreter = $this->getMock('Magento\Data\Argument\InterpreterInterface'); + $this->argumentInterpreter->expects( + $this->any() + )->method( + 'evaluate' + )->with( + array('xsi:type' => 'string', 'value' => 'test value') + )->will( + $this->returnValue('test value') + ); + $this->_mapper = new Dom($this->argumentInterpreter, $booleanUtils, $argumentParser); } public function testConvert() @@ -74,7 +89,7 @@ public function parserMockCallback(\DOMElement $argument) { $this->assertNotEmpty($argument->getAttribute('name')); $this->assertNotEmpty($argument->getAttribute('xsi:type')); - return 'test value'; + return array('xsi:type' => 'string', 'value' => 'test value'); } /** diff --git a/dev/tests/unit/testsuite/Magento/ObjectManager/Factory/FactoryTest.php b/dev/tests/unit/testsuite/Magento/ObjectManager/Factory/FactoryTest.php index e37756545c3f0..9201e6528f827 100644 --- a/dev/tests/unit/testsuite/Magento/ObjectManager/Factory/FactoryTest.php +++ b/dev/tests/unit/testsuite/Magento/ObjectManager/Factory/FactoryTest.php @@ -25,7 +25,6 @@ use Magento\ObjectManager\Config\Config; use Magento\ObjectManager\ObjectManager; -use Magento\ObjectManager\Config\Argument\ObjectFactory; class FactoryTest extends \PHPUnit_Framework_TestCase { @@ -39,29 +38,17 @@ class FactoryTest extends \PHPUnit_Framework_TestCase */ private $config; - /** - * @var ObjectFactory - */ - private $objectFactory; - /** * @var ObjectManager */ private $objectManager; - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - private $interpreterMock; - protected function setUp() { $this->config = new Config(); - $this->objectFactory = new ObjectFactory($this->config); - $this->interpreterMock = $this->getMockForAbstractClass('\Magento\Data\Argument\InterpreterInterface'); - $this->factory = new Factory($this->config, $this->interpreterMock, $this->objectFactory); + $this->factory = new Factory($this->config); $this->objectManager = new ObjectManager($this->factory, $this->config); - $this->objectFactory->setObjectManager($this->objectManager); + $this->factory->setObjectManager($this->objectManager); } public function testCreateNoArgs() @@ -89,12 +76,11 @@ public function testResolveArgumentsException() $this->factory = new Factory( $configMock, - $this->interpreterMock, - $this->objectFactory, + null, $definitionsMock ); $this->objectManager = new ObjectManager($this->factory, $this->config); - $this->objectFactory->setObjectManager($this->objectManager); + $this->factory->setObjectManager($this->objectManager); $this->factory->create('Magento\ObjectManager\Factory\Fixture\OneScalar', array('foo' => 'bar')); } @@ -112,16 +98,10 @@ public function testCreateWithInjectable() $this->config->extend( array( 'Magento\ObjectManager\Factory\Fixture\OneScalar' => array( - 'arguments' => array('foo' => array('value' => 'bar')) + 'arguments' => array('foo' => 'bar') ) ) ); - $this->interpreterMock - ->expects($this->once()) - ->method('evaluate') - ->with(array('value' => 'bar')) - ->will($this->returnValue('bar')) - ; /** @var \Magento\ObjectManager\Factory\Fixture\Two $result */ $result = $this->factory->create('Magento\ObjectManager\Factory\Fixture\Two'); $this->assertInstanceOf('\Magento\ObjectManager\Factory\Fixture\Two', $result); @@ -163,12 +143,12 @@ public function testCreateUsingReflection() $definitions = $this->getMockForAbstractClass('\Magento\ObjectManager\Definition'); // should be more than defined in "switch" of create() method $definitions->expects($this->once())->method('getParameters')->with($type)->will($this->returnValue(array( - array('one', 'int', false, null), array('two', 'int', false, null), array('three', 'int', false, null), - array('four', 'int', false, null), array('five', 'int', false, null), array('six', 'int', false, null), - array('seven', 'int', false, null), array('eight', 'int', false, null), array('nine', 'int', false, null), - array('ten', 'int', false, null), + array('one', null, false, null), array('two', null, false, null), array('three', null, false, null), + array('four', null, false, null), array('five', null, false, null), array('six', null, false, null), + array('seven', null, false, null), array('eight', null, false, null), array('nine', null, false, null), + array('ten', null, false, null), ))); - $factory = new Factory($this->config, $this->interpreterMock, $this->objectFactory, $definitions); + $factory = new Factory($this->config, null, $definitions); $result = $factory->create($type, array( 'one' => 1, 'two' => 2, 'three' => 3, 'four' => 4, 'five' => 5, 'six' => 6, 'seven' => 7, 'eight' => 8, 'nine' => 9, 'ten' => 10, diff --git a/dev/tests/unit/testsuite/Magento/ObjectManager/ObjectManagerTest.php b/dev/tests/unit/testsuite/Magento/ObjectManager/ObjectManagerTest.php index 4a9faf1169195..1fa30d9a6fbf2 100644 --- a/dev/tests/unit/testsuite/Magento/ObjectManager/ObjectManagerTest.php +++ b/dev/tests/unit/testsuite/Magento/ObjectManager/ObjectManagerTest.php @@ -40,30 +40,15 @@ class ObjectManagerTest extends \PHPUnit_Framework_TestCase */ protected $_object; - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $_argInterpreterMock; - protected function setUp() { - $this->_argInterpreterMock = $this->getMock( - '\Magento\Data\Argument\InterpreterInterface', - array(), - array(), - '', - false - ); $config = new \Magento\ObjectManager\Config\Config(new \Magento\ObjectManager\Relations\Runtime()); - $argObjectFactory = new \Magento\ObjectManager\Config\Argument\ObjectFactory($config); - $factory = new \Magento\ObjectManager\Factory\Factory( - $config, - $this->_argInterpreterMock, - $argObjectFactory, - null - ); + $factory = new \Magento\ObjectManager\Factory\Factory($config, null, null, array( + 'first_param' => 'first_param_value', + 'second_param' => 'second_param_value' + )); $this->_object = new \Magento\ObjectManager\ObjectManager($factory, $config); - $argObjectFactory->setObjectManager($this->_object); + $factory->setObjectManager($this->_object); } public function testCreateCreatesNewInstanceEveryTime() @@ -143,20 +128,6 @@ public function testCreateThrowsExceptionIfRequiredConstructorParameterIsNotProv public function testCreateResolvesScalarParametersAutomatically() { - $childAMock = $this->getMock('Magento\Test\Di\Child\A', array(), array(), '', false); - $this->_argInterpreterMock->expects( - $this->any() - )->method( - 'evaluate' - )->will( - $this->returnValueMap( - array( - array(array('xsi:type' => 'object', 'value' => 'Magento\Test\Di\Child\A'), $childAMock), - array(array('xsi:type' => 'string', 'value' => 'scalarValue'), 'scalarValue') - ) - ) - ); - $this->_object->configure( array( 'preferences' => array( @@ -165,8 +136,8 @@ public function testCreateResolvesScalarParametersAutomatically() ), 'Magento\Test\Di\Aggregate\AggregateParent' => array( 'arguments' => array( - 'child' => array('xsi:type' => 'object', 'value' => 'Magento\Test\Di\Child\A'), - 'scalar' => array('xsi:type' => 'string', 'value' => 'scalarValue') + 'child' => array('instance' => 'Magento\Test\Di\Child\A'), + 'scalar' => 'scalarValue' ) ) ) @@ -191,7 +162,7 @@ public function testGetCreatesSharedInstancesEveryTime() ), 'Magento\Test\Di\DiInterface' => array('shared' => 0), 'Magento\Test\Di\Aggregate\AggregateParent' => array( - 'arguments' => array('scalar' => array('xsi:type' => 'string', 'value' => 'scalarValue')) + 'arguments' => array('scalar' => 'scalarValue') ) ) ); @@ -233,26 +204,6 @@ public function testCreateIgnoresOptionalArguments() public function testCreateCreatesPreconfiguredInstance() { - $this->_argInterpreterMock->expects( - $this->any() - )->method( - 'evaluate' - )->will( - $this->returnValueMap( - array( - array(array('xsi:type' => 'string', 'value' => 'configuredScalar'), 'configuredScalar'), - array( - array('xsi:type' => 'string', 'value' => 'configuredSecondScalar'), - 'configuredSecondScalar' - ), - array( - array('xsi:type' => 'string', 'value' => 'configuredOptionalScalar'), - 'configuredOptionalScalar' - ) - ) - ) - ); - $this->_object->configure( array( 'preferences' => array( @@ -262,9 +213,9 @@ public function testCreateCreatesPreconfiguredInstance() 'customChildType' => array( 'type' => 'Magento\Test\Di\Aggregate\Child', 'arguments' => array( - 'scalar' => array('xsi:type' => 'string', 'value' => 'configuredScalar'), - 'secondScalar' => array('xsi:type' => 'string', 'value' => 'configuredSecondScalar'), - 'secondOptionalScalar' => array('xsi:type' => 'string', 'value' => 'configuredOptionalScalar') + 'scalar' => 'configuredScalar', + 'secondScalar' => 'configuredSecondScalar', + 'secondOptionalScalar' => 'configuredOptionalScalar' ) ) ) @@ -280,32 +231,14 @@ public function testCreateCreatesPreconfiguredInstance() public function testParameterShareabilityConfigurationIsApplied() { - $diParentMock = $this->getMock('Magento\Test\Di\DiParent', array(), array(), '', false); - $this->_argInterpreterMock->expects($this->any())->method('evaluate')->will( - $this->returnCallback( - function (array $array) use ($diParentMock) { - if ($array === array('xsi:type' => 'object', 'value' => 'Magento\Test\Di\DiParent')) { - return $diParentMock; - } elseif ($array === array( - 'xsi:type' => 'object', - 'value' => 'Magento\Test\Di\DiParent', - 'shared' => false - ) - ) { - return $this->getMock('Magento\Test\Di\DiParent', array(), array(), '', false); - } - } - ) - ); - $this->_object->configure( array( 'customChildType' => array( 'type' => 'Magento\Test\Di\Aggregate\Child', 'arguments' => array( - 'interface' => array('xsi:type' => 'object', 'value' => 'Magento\Test\Di\DiParent'), - 'scalar' => array('xsi:type' => 'string', 'value' => 'configuredScalar'), - 'secondScalar' => array('xsi:type' => 'string', 'value' => 'configuredSecondScalar') + 'interface' => array('instance' => 'Magento\Test\Di\DiParent'), + 'scalar' => 'configuredScalar', + 'secondScalar' => 'configuredSecondScalar' ) ) ) @@ -320,8 +253,7 @@ function (array $array) use ($diParentMock) { 'customChildType' => array( 'arguments' => array( 'interface' => array( - 'xsi:type' => 'object', - 'value' => 'Magento\Test\Di\DiParent', + 'instance' => 'Magento\Test\Di\DiParent', 'shared' => false ) ) @@ -336,25 +268,14 @@ function (array $array) use ($diParentMock) { public function testTypeShareabilityConfigurationIsApplied() { - $diParentMock = $this->getMock('Magento\Test\Di\DiParent', array(), array(), '', false); - $this->_argInterpreterMock->expects( - $this->any() - )->method( - 'evaluate' - )->will( - $this->returnValueMap( - array(array(array('xsi:type' => 'object', 'value' => 'Magento\Test\Di\DiParent'), $diParentMock)) - ) - ); - $this->_object->configure( array( 'customChildType' => array( 'type' => 'Magento\Test\Di\Aggregate\Child', 'arguments' => array( - 'interface' => array('xsi:type' => 'object', 'value' => 'Magento\Test\Di\DiParent'), - 'scalar' => array('xsi:type' => 'string', 'value' => 'configuredScalar'), - 'secondScalar' => array('xsi:type' => 'string', 'value' => 'configuredSecondScalar') + 'interface' => array('instance' => 'Magento\Test\Di\DiParent'), + 'scalar' => 'configuredScalar', + 'secondScalar' => 'configuredSecondScalar' ) ) ) @@ -377,33 +298,15 @@ public function testTypeShareabilityConfigurationIsApplied() public function testParameterShareabilityConfigurationOverridesTypeShareability() { - $diParentMock = $this->getMock('Magento\Test\Di\DiParent', array(), array(), '', false); - $this->_argInterpreterMock->expects($this->any())->method('evaluate')->will( - $this->returnCallback( - function (array $array) use ($diParentMock) { - if ($array === array('xsi:type' => 'object', 'value' => 'Magento\Test\Di\DiParent')) { - return $this->_object->create('Magento\Test\Di\DiParent'); - } elseif ($array === array( - 'xsi:type' => 'object', - 'value' => 'Magento\Test\Di\DiParent', - 'shared' => true - ) - ) { - return $diParentMock; - } - } - ) - ); - $this->_object->configure( array( 'Magento\Test\Di\DiParent' => array('shared' => false), 'customChildType' => array( 'type' => 'Magento\Test\Di\Aggregate\Child', 'arguments' => array( - 'interface' => array('xsi:type' => 'object', 'value' => 'Magento\Test\Di\DiParent'), - 'scalar' => array('xsi:type' => 'string', 'value' => 'configuredScalar'), - 'secondScalar' => array('xsi:type' => 'string', 'value' => 'configuredSecondScalar') + 'interface' => array('instance' => 'Magento\Test\Di\DiParent'), + 'scalar' => 'configuredScalar', + 'secondScalar' => 'configuredSecondScalar' ) ) ) @@ -418,8 +321,7 @@ function (array $array) use ($diParentMock) { 'customChildType' => array( 'arguments' => array( 'interface' => array( - 'xsi:type' => 'object', - 'value' => 'Magento\Test\Di\DiParent', + 'instance' => 'Magento\Test\Di\DiParent', 'shared' => true ) ) @@ -434,66 +336,37 @@ function (array $array) use ($diParentMock) { public function testGlobalArgumentsCanBeConfigured() { - $this->_argInterpreterMock->expects( - $this->any() - )->method( - 'evaluate' - )->will( - $this->returnValueMap( - array( - array(array('xsi:type' => 'init_parameter', 'value' => 'one'), 'first_val'), - array(array('xsi:type' => 'init_parameter', 'value' => 'two'), 'second_val') - ) - ) - ); - $this->_object->configure( array( 'preferences' => array('Magento\Test\Di\DiInterface' => 'Magento\Test\Di\DiParent'), 'Magento\Test\Di\Aggregate\AggregateParent' => array( 'arguments' => array( - 'scalar' => array('xsi:type' => 'init_parameter', 'value' => 'one'), - 'optionalScalar' => array('xsi:type' => 'init_parameter', 'value' => 'two') + 'scalar' => array('argument' => 'first_param'), + 'optionalScalar' => array('argument' => 'second_param') ) ) ) ); /** @var $result \Magento\Test\Di\Aggregate\AggregateParent */ $result = $this->_object->create('Magento\Test\Di\Aggregate\AggregateParent'); - $this->assertEquals('first_val', $result->scalar); - $this->assertEquals('second_val', $result->optionalScalar); + $this->assertEquals('first_param_value', $result->scalar); + $this->assertEquals('second_param_value', $result->optionalScalar); } public function testConfiguredArgumentsAreInherited() { - $diParentMock = $this->getMock('Magento\Test\Di\DiParent', array(), array(), '', false); - $this->_argInterpreterMock->expects( - $this->any() - )->method( - 'evaluate' - )->will( - $this->returnValueMap( - array( - array(array('xsi:type' => 'init_parameter', 'value' => 'one'), 'first_val'), - array(array('xsi:type' => 'object', 'value' => 'Magento\Test\Di\DiParent'), $diParentMock), - array(array('xsi:type' => 'string', 'value' => 'parentOptionalScalar'), 'parentOptionalScalar'), - array(array('xsi:type' => 'string', 'value' => 'childSecondScalar'), 'childSecondScalar') - ) - ) - ); - $this->_object->configure( array( 'Magento\Test\Di\Aggregate\AggregateParent' => array( 'arguments' => array( - 'interface' => array('xsi:type' => 'object', 'value' => 'Magento\Test\Di\DiParent'), - 'scalar' => array('xsi:type' => 'init_parameter', 'value' => 'one'), - 'optionalScalar' => array('xsi:type' => 'string', 'value' => 'parentOptionalScalar') + 'interface' => array('instance' => 'Magento\Test\Di\DiParent'), + 'scalar' => array('argument' => 'first_param'), + 'optionalScalar' => 'parentOptionalScalar' ) ), 'Magento\Test\Di\Aggregate\Child' => array( 'arguments' => array( - 'secondScalar' => array('xsi:type' => 'string', 'value' => 'childSecondScalar') + 'secondScalar' => 'childSecondScalar' ) ) ) @@ -502,44 +375,28 @@ public function testConfiguredArgumentsAreInherited() /** @var $result \Magento\Test\Di\Aggregate\AggregateParent */ $result = $this->_object->create('Magento\Test\Di\Aggregate\Child'); $this->assertInstanceOf('Magento\Test\Di\DiParent', $result->interface); - $this->assertEquals('first_val', $result->scalar); + $this->assertEquals('first_param_value', $result->scalar); $this->assertEquals('childSecondScalar', $result->secondScalar); $this->assertEquals('parentOptionalScalar', $result->optionalScalar); } public function testConfiguredArgumentsOverrideInheritedArguments() { - $diChildMock = $this->getMock('Magento\Test\Di\Child', array(), array(), '', false); - $this->_argInterpreterMock->expects( - $this->any() - )->method( - 'evaluate' - )->will( - $this->returnValueMap( - array( - array(array('xsi:type' => 'object', 'value' => 'Magento\Test\Di\Child'), $diChildMock), - array(array('xsi:type' => 'init_parameter', 'value' => 'two'), 'second_val'), - array(array('xsi:type' => 'string', 'value' => 'childSecondScalar'), 'childSecondScalar'), - array(array('xsi:type' => 'string', 'value' => 'childOptionalScalar'), 'childOptionalScalar') - ) - ) - ); - $this->_object->configure( array( 'Magento\Test\Di\Aggregate\AggregateParent' => array( 'arguments' => array( - 'interface' => array('xsi:type' => 'object', 'value' => 'Magento\Test\Di\DiParent'), - 'scalar' => array('xsi:type' => 'init_parameter', 'value' => 'one'), - 'optionalScalar' => array('xsi:type' => 'string', 'value' => 'parentOptionalScalar') + 'interface' => array('instance' => 'Magento\Test\Di\DiParent'), + 'scalar' => array('argument' => 'first_param'), + 'optionalScalar' => 'parentOptionalScalar' ) ), 'Magento\Test\Di\Aggregate\Child' => array( 'arguments' => array( - 'interface' => array('xsi:type' => 'object', 'value' => 'Magento\Test\Di\Child'), - 'scalar' => array('xsi:type' => 'init_parameter', 'value' => 'two'), - 'secondScalar' => array('xsi:type' => 'string', 'value' => 'childSecondScalar'), - 'optionalScalar' => array('xsi:type' => 'string', 'value' => 'childOptionalScalar') + 'interface' => array('instance' => 'Magento\Test\Di\Child'), + 'scalar' => array('argument' => 'second_param'), + 'secondScalar' => 'childSecondScalar', + 'optionalScalar' => 'childOptionalScalar' ) ) ) @@ -548,7 +405,7 @@ public function testConfiguredArgumentsOverrideInheritedArguments() /** @var $result \Magento\Test\Di\Aggregate\AggregateParent */ $result = $this->_object->create('Magento\Test\Di\Aggregate\Child'); $this->assertInstanceOf('Magento\Test\Di\Child', $result->interface); - $this->assertEquals('second_val', $result->scalar); + $this->assertEquals('second_param_value', $result->scalar); $this->assertEquals('childSecondScalar', $result->secondScalar); $this->assertEquals('childOptionalScalar', $result->optionalScalar); } diff --git a/dev/tests/unit/testsuite/Magento/Core/App/Request/RewriteServiceTest.php b/dev/tests/unit/testsuite/Magento/UrlRewrite/App/Request/RewriteServiceTest.php similarity index 89% rename from dev/tests/unit/testsuite/Magento/Core/App/Request/RewriteServiceTest.php rename to dev/tests/unit/testsuite/Magento/UrlRewrite/App/Request/RewriteServiceTest.php index 16268abf467f7..d3b2ccaccea93 100644 --- a/dev/tests/unit/testsuite/Magento/Core/App/Request/RewriteServiceTest.php +++ b/dev/tests/unit/testsuite/Magento/UrlRewrite/App/Request/RewriteServiceTest.php @@ -21,12 +21,12 @@ * @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\Core\App\Request; +namespace Magento\UrlRewrite\App\Request; class RewriteServiceTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Core\App\Request\RewriteService + * @var \Magento\UrlRewrite\App\Request\RewriteService */ protected $_model; @@ -56,14 +56,14 @@ protected function setUp() $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', + '\Magento\UrlRewrite\Model\UrlRewriteFactory', array('create'), array(), '', false ); - $this->_model = new \Magento\Core\App\Request\RewriteService( + $this->_model = new \Magento\UrlRewrite\App\Request\RewriteService( $this->_routerListMock, $this->_rewriteFactoryMock, $this->_configMock @@ -80,7 +80,7 @@ public function testApplyRewritesWhenRequestIsStraight() public function testApplyRewritesWhenRequestIsNotStraight() { $this->_requestMock->expects($this->once())->method('isStraight')->will($this->returnValue(false)); - $urlRewriteMock = $this->getMock('\Magento\Core\Model\Url\Rewrite', array(), array(), '', false); + $urlRewriteMock = $this->getMock('\Magento\UrlRewrite\Model\UrlRewrite', array(), array(), '', false); $this->_rewriteFactoryMock->expects( $this->once() )->method( diff --git a/dev/tests/unit/testsuite/Magento/Core/Helper/Url/RewriteTest.php b/dev/tests/unit/testsuite/Magento/UrlRewrite/Helper/UrlRewriteTest.php similarity index 86% rename from dev/tests/unit/testsuite/Magento/Core/Helper/Url/RewriteTest.php rename to dev/tests/unit/testsuite/Magento/UrlRewrite/Helper/UrlRewriteTest.php index 7c75be7115dcc..b2b3d52a98d9b 100644 --- a/dev/tests/unit/testsuite/Magento/Core/Helper/Url/RewriteTest.php +++ b/dev/tests/unit/testsuite/Magento/UrlRewrite/Helper/UrlRewriteTest.php @@ -18,19 +18,13 @@ * 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 * @subpackage unit_tests * @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\UrlRewrite\Helper; -/** - * Test for \Magento\Core\Helper\Url\RewriteTest - */ -namespace Magento\Core\Helper\Url; - -class RewriteTest extends \PHPUnit_Framework_TestCase +class UrlRewriteTest extends \PHPUnit_Framework_TestCase { /** * Test hasRedirectOptions @@ -40,7 +34,7 @@ class RewriteTest extends \PHPUnit_Framework_TestCase public function testHasRedirectOptions($option, $expected) { $optionsMock = $this->getMock( - 'Magento\Core\Model\Source\Urlrewrite\Options', + 'Magento\UrlRewrite\Model\UrlRewrite\OptionProvider', array('getRedirectOptions'), array(), '', @@ -48,7 +42,7 @@ public function testHasRedirectOptions($option, $expected) false ); $optionsMock->expects($this->any())->method('getRedirectOptions')->will($this->returnValue(array('R', 'RP'))); - $helper = new \Magento\Core\Helper\Url\Rewrite( + $helper = new \Magento\UrlRewrite\Helper\UrlRewrite( $this->getMock('Magento\App\Helper\Context', array(), array(), '', false, false), $optionsMock ); diff --git a/dev/tests/unit/testsuite/Magento/Core/Model/Source/Urlrewrite/OptionsTest.php b/dev/tests/unit/testsuite/Magento/UrlRewrite/Model/UrlRewrite/OptionProviderTest.php similarity index 79% rename from dev/tests/unit/testsuite/Magento/Core/Model/Source/Urlrewrite/OptionsTest.php rename to dev/tests/unit/testsuite/Magento/UrlRewrite/Model/UrlRewrite/OptionProviderTest.php index 7c8ee511d531d..dee5cb6f3ab0a 100644 --- a/dev/tests/unit/testsuite/Magento/Core/Model/Source/Urlrewrite/OptionsTest.php +++ b/dev/tests/unit/testsuite/Magento/UrlRewrite/Model/UrlRewrite/OptionProviderTest.php @@ -26,18 +26,18 @@ */ /** - * Test class for \Magento\Core\Model\Source\Urlrewrite\OptionsTest. + * Test class for \Magento\UrlRewrite\Model\UrlRewrite\OptionProvider. */ -namespace Magento\Core\Model\Source\Urlrewrite; +namespace Magento\UrlRewrite\Model\UrlRewrite; -class OptionsTest extends \PHPUnit_Framework_TestCase +class OptionProviderTest extends \PHPUnit_Framework_TestCase { /** - * @covers \Magento\Core\Model\Source\Urlrewrite\Options::getAllOptions + * @covers \Magento\UrlRewrite\Model\UrlRewrite\OptionProvider::getAllOptions */ public function testGetAllOptions() { - $model = new \Magento\Core\Model\Source\Urlrewrite\Options(); + $model = new \Magento\UrlRewrite\Model\UrlRewrite\OptionProvider(); $options = $model->getAllOptions(); $this->assertInternalType('array', $options); $expectedOptions = array('' => 'No', 'R' => 'Temporary (302)', 'RP' => 'Permanent (301)'); diff --git a/dev/tests/unit/testsuite/Magento/Core/Model/Source/Urlrewrite/TypesTest.php b/dev/tests/unit/testsuite/Magento/UrlRewrite/Model/UrlRewrite/TypeProviderTest.php similarity index 77% rename from dev/tests/unit/testsuite/Magento/Core/Model/Source/Urlrewrite/TypesTest.php rename to dev/tests/unit/testsuite/Magento/UrlRewrite/Model/UrlRewrite/TypeProviderTest.php index 4114ea3004f7e..c2976bceb312b 100644 --- a/dev/tests/unit/testsuite/Magento/Core/Model/Source/Urlrewrite/TypesTest.php +++ b/dev/tests/unit/testsuite/Magento/UrlRewrite/Model/UrlRewrite/TypeProviderTest.php @@ -18,26 +18,20 @@ * 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 * @subpackage unit_tests * @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\UrlRewrite\Model\UrlRewrite; -/** - * Test class for \Magento\Core\Model\Source\Urlrewrite\Types. - */ -namespace Magento\Core\Model\Source\Urlrewrite; - -class TypesTest extends \PHPUnit_Framework_TestCase +class TypeProviderTest extends \PHPUnit_Framework_TestCase { /** - * @covers \Magento\Core\Model\Source\Urlrewrite\Types::getAllOptions + * @covers \Magento\UrlRewrite\Model\UrlRewrite\TypeProvider::getAllOptions */ public function testGetAllOptions() { - $model = new \Magento\Core\Model\Source\Urlrewrite\Types(); + $model = new \Magento\UrlRewrite\Model\UrlRewrite\TypeProvider(); $options = $model->getAllOptions(); $this->assertInternalType('array', $options); $expectedOptions = array(1 => 'System', 0 => 'Custom'); diff --git a/dev/tests/unit/testsuite/Magento/Validator/BuilderTest.php b/dev/tests/unit/testsuite/Magento/Validator/BuilderTest.php index 16c4572b31889..5fa381ed27344 100644 --- a/dev/tests/unit/testsuite/Magento/Validator/BuilderTest.php +++ b/dev/tests/unit/testsuite/Magento/Validator/BuilderTest.php @@ -47,17 +47,10 @@ protected function setUp() { $this->_objectManager = new \Magento\TestFramework\Helper\ObjectManager($this); - $argInterpreter = $this->getMock('\Magento\Data\Argument\InterpreterInterface', array(), array(), '', false); - $argObjectFactory = $this->getMock( - '\Magento\ObjectManager\Config\Argument\ObjectFactory', - array(), - array(), - '', - false - ); $config = new \Magento\ObjectManager\Config\Config(new \Magento\ObjectManager\Relations\Runtime()); - $factory = new \Magento\ObjectManager\Factory\Factory($config, $argInterpreter, $argObjectFactory, null); + $factory = new \Magento\ObjectManager\Factory\Factory($config); $this->_realObjectManager = new \Magento\ObjectManager\ObjectManager($factory, $config); + $factory->setObjectManager($this->_realObjectManager); } /** diff --git a/dev/tests/unit/testsuite/Magento/Validator/ConfigTest.php b/dev/tests/unit/testsuite/Magento/Validator/ConfigTest.php index e0dd14b4fc381..ef3718b17841d 100644 --- a/dev/tests/unit/testsuite/Magento/Validator/ConfigTest.php +++ b/dev/tests/unit/testsuite/Magento/Validator/ConfigTest.php @@ -65,36 +65,11 @@ protected function _initConfig(array $files = null) foreach ($files as $path) { $configFiles[$path] = file_get_contents($path); } - $argInterpreter = $this->getMock('\Magento\Data\Argument\InterpreterInterface', array(), array(), '', false); - - $argObjectFactory = $this->getMock( - '\Magento\ObjectManager\Config\Argument\ObjectFactory', - array(), - array(), - '', - false - ); - $config = new \Magento\ObjectManager\Config\Config(new \Magento\ObjectManager\Relations\Runtime()); - $factory = new \Magento\ObjectManager\Factory\Factory($config, $argInterpreter, $argObjectFactory, null); + $factory = new \Magento\ObjectManager\Factory\Factory($config); $realObjectManager = new \Magento\ObjectManager\ObjectManager($factory, $config); - - $constraintFactory = new \Magento\Validator\ConstraintFactory($realObjectManager); - $validatorFactory = new \Magento\ValidatorFactory($realObjectManager); - $universalFactory = new \Magento\Validator\UniversalFactory($realObjectManager); - $argObjectFactory->expects( - $this->any() - )->method( - 'create' - )->will( - $this->returnValueMap( - array( - array('Magento\Validator\ConstraintFactory', null, $constraintFactory), - array('Magento\ValidatorFactory', null, $validatorFactory), - array('Magento\Validator\UniversalFactory', null, $universalFactory) - ) - ) - ); + $factory->setObjectManager($realObjectManager); + $universalFactory = $realObjectManager->get('\Magento\Validator\UniversalFactory'); $this->_config = $this->_objectManager->getObject( 'Magento\Validator\Config', array('configFiles' => $configFiles, 'builderFactory' => $universalFactory) diff --git a/dev/tests/integration/testsuite/Magento/App/ObjectManager/ConfigLoader/PrimaryTest.php b/dev/tests/unit/testsuite/Magento/View/Helper/JsTest.php similarity index 60% rename from dev/tests/integration/testsuite/Magento/App/ObjectManager/ConfigLoader/PrimaryTest.php rename to dev/tests/unit/testsuite/Magento/View/Helper/JsTest.php index abe48f9b62588..bfaebea8cc32e 100644 --- a/dev/tests/integration/testsuite/Magento/App/ObjectManager/ConfigLoader/PrimaryTest.php +++ b/dev/tests/unit/testsuite/Magento/View/Helper/JsTest.php @@ -21,20 +21,20 @@ * @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\ObjectManager\ConfigLoader; +namespace Magento\View\Helper; -use Magento\TestFramework\ObjectManager; - -class PrimaryTest extends \PHPUnit_Framework_TestCase +class JsTest extends \PHPUnit_Framework_TestCase { - public function testLoad() + + /** + * @covers \Magento\View\Helper\Js::getScript + */ + public function testGetScript() { - /** @var \Magento\App\ObjectManager\ConfigLoader\Primary $loader */ - $loader = ObjectManager::getInstance()->get('Magento\App\ObjectManager\ConfigLoader\Primary'); - $result = $loader->load(); - $this->assertNotEmpty($result); - $this->assertInternalType('array', $result); - $this->assertArrayHasKey('preferences', $result); - $this->assertArrayHasKey('Magento\App\State', $result); + $helper = new \Magento\View\Helper\Js(); + $this->assertEquals( + "", + $helper->getScript('test') + ); } } diff --git a/dev/tests/unit/testsuite/Magento/Wishlist/Controller/IndexTest.php b/dev/tests/unit/testsuite/Magento/Wishlist/Controller/IndexTest.php index 0b159a3417d2f..afec8bf396abd 100644 --- a/dev/tests/unit/testsuite/Magento/Wishlist/Controller/IndexTest.php +++ b/dev/tests/unit/testsuite/Magento/Wishlist/Controller/IndexTest.php @@ -136,7 +136,9 @@ protected function _factory($request, $response = null, $objectManager = null) if (!$objectManager) { $objectManager = new \Magento\ObjectManager\ObjectManager(); } - $rewriteFactory = $this->getMock('Magento\Core\Model\Url\RewriteFactory', array('create'), array(), '', false); + $rewriteFactory = $this->getMock( + 'Magento\UrlRewrite\Model\UrlRewriteFactory', array('create'), array(), '', false + ); $helper = new \Magento\TestFramework\Helper\ObjectManager($this); $varienFront = $helper->getObject('Magento\App\FrontController', array('rewriteFactory' => $rewriteFactory)); diff --git a/lib/Magento/App/AreaList/Proxy.php b/lib/Magento/App/AreaList/Proxy.php new file mode 100644 index 0000000000000..38442be3a7804 --- /dev/null +++ b/lib/Magento/App/AreaList/Proxy.php @@ -0,0 +1,172 @@ +_objectManager = $objectManager; + $this->_instanceName = $instanceName; + $this->_isShared = $shared; + } + + /** + * @return array + */ + public function __sleep() + { + return array('_subject', '_isShared'); + } + + /** + * Retrieve ObjectManager from global scope + * + * @return void + */ + public function __wakeup() + { + $this->_objectManager = \Magento\App\ObjectManager::getInstance(); + } + + /** + * Clone proxied instance + * + * @return void + */ + public function __clone() + { + $this->_subject = clone $this->_getSubject(); + } + + /** + * Get proxied instance + * + * @return \Magento\Locale\Resolver + */ + protected function _getSubject() + { + if (!$this->_subject) { + $this->_subject = true === $this->_isShared + ? $this->_objectManager->get($this->_instanceName) + : $this->_objectManager->create($this->_instanceName); + } + return $this->_subject; + } + + + /** + * Retrieve area code by front name + * + * @param string $frontName + * @return null|string + */ + public function getCodeByFrontName($frontName) + { + return $this->_getSubject()->getCodeByFrontName($frontName); + } + + /** + * Retrieve area front name by code + * + * @param string $areaCode + * @return string + */ + public function getFrontName($areaCode) + { + return $this->_getSubject()->getFrontName($areaCode); + } + + /** + * Retrieve area codes + * + * @return string[] + */ + public function getCodes() + { + return $this->_getSubject()->getCodes(); + } + + /** + * Retrieve default area router id + * + * @param string $areaCode + * @return string + */ + public function getDefaultRouter($areaCode) + { + return $this->_getSubject()->getDefaultRouter($areaCode); + } + + /** + * Retrieve application area + * + * @param string $code + * @return \Magento\Core\Model\App\Area + */ + public function getArea($code) + { + return $this->_getSubject()->getArea($code); + } +} diff --git a/lib/Magento/App/Arguments/ArgumentInterpreter.php b/lib/Magento/App/Arguments/ArgumentInterpreter.php index eaf2324f6b2da..5dce1cf0ad63d 100644 --- a/lib/Magento/App/Arguments/ArgumentInterpreter.php +++ b/lib/Magento/App/Arguments/ArgumentInterpreter.php @@ -33,23 +33,16 @@ */ class ArgumentInterpreter implements InterpreterInterface { - /** - * @var Arguments - */ - private $arguments; - /** * @var Constant */ private $constInterpreter; /** - * @param Arguments $arguments * @param Constant $constInterpreter */ - public function __construct(Arguments $arguments, Constant $constInterpreter) + public function __construct(Constant $constInterpreter) { - $this->arguments = $arguments; $this->constInterpreter = $constInterpreter; } @@ -60,11 +53,6 @@ public function __construct(Arguments $arguments, Constant $constInterpreter) */ public function evaluate(array $data) { - $argumentName = $this->constInterpreter->evaluate($data); - $result = $this->arguments->get($argumentName); - if ($result === null) { - throw new MissingOptionalValueException("Value of application argument '{$argumentName}' is not defined."); - } - return $result; + return array('argument' => $this->constInterpreter->evaluate($data)); } } diff --git a/app/code/Magento/Core/Model/Resource/Cache.php b/lib/Magento/App/Cache/State/Options.php similarity index 87% rename from app/code/Magento/Core/Model/Resource/Cache.php rename to lib/Magento/App/Cache/State/Options.php index 4ec67829de437..26392552d347b 100644 --- a/app/code/Magento/Core/Model/Resource/Cache.php +++ b/lib/Magento/App/Cache/State/Options.php @@ -1,5 +1,7 @@ - */ -class Cache extends \Magento\Model\Resource\Db\AbstractDb implements \Magento\App\Cache\State\OptionsInterface +class Options extends \Magento\Model\Resource\Db\AbstractDb implements \Magento\App\Cache\State\OptionsInterface { /** * Define main table diff --git a/lib/Magento/App/EntryPoint/EntryPoint.php b/lib/Magento/App/EntryPoint/EntryPoint.php index ceeec368d7272..e2a5990ea1ac5 100644 --- a/lib/Magento/App/EntryPoint/EntryPoint.php +++ b/lib/Magento/App/EntryPoint/EntryPoint.php @@ -59,7 +59,6 @@ public function __construct($rootDir, array $parameters = array(), ObjectManager $this->_rootDir = $rootDir; $this->_parameters = $parameters; $this->_locator = $objectManager; - $this->_parameters[State::PARAM_MODE] = State::MODE_DEVELOPER; } /** diff --git a/lib/Magento/App/ObjectManager/ConfigLoader/Primary.php b/lib/Magento/App/ObjectManager/ConfigLoader/Primary.php deleted file mode 100644 index cb1dcb72a1a67..0000000000000 --- a/lib/Magento/App/ObjectManager/ConfigLoader/Primary.php +++ /dev/null @@ -1,81 +0,0 @@ -_directoryList = $directoryList; - $this->_appMode = $appMode; - } - - /** - * Retrieve merged configuration from primary config files - * - * @return array - */ - public function load() - { - $reader = new \Magento\ObjectManager\Config\Reader\Dom( - new \Magento\App\Arguments\FileResolver\Primary( - new \Magento\App\Filesystem( - $this->_directoryList, - new \Magento\Filesystem\Directory\ReadFactory(), - new \Magento\Filesystem\Directory\WriteFactory() - ), - new \Magento\Config\FileIteratorFactory() - ), - new \Magento\ObjectManager\Config\Mapper\Dom( - new \Magento\Stdlib\BooleanUtils(), - new \Magento\ObjectManager\Config\Mapper\ArgumentParser() - ), - new \Magento\ObjectManager\Config\SchemaLocator(), - 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 572430d5d7c4f..3bb06bff79c60 100644 --- a/lib/Magento/App/ObjectManagerFactory.php +++ b/lib/Magento/App/ObjectManagerFactory.php @@ -49,6 +49,13 @@ class ObjectManagerFactory */ protected $_configClassName = 'Magento\Interception\ObjectManager\Config'; + /** + * Factory + * + * @var \Magento\ObjectManager\Factory + */ + protected $factory; + /** * Create object manager * @@ -85,36 +92,42 @@ public function create($rootDir, array $arguments) $diConfig = new $configClass($relations, $definitions); $appMode = $appArguments->get(State::PARAM_MODE, State::MODE_DEFAULT); - $configData = $this->_loadPrimaryConfig($directoryList, $appMode); + $booleanUtils = new \Magento\Stdlib\BooleanUtils(); + $argInterpreter = $this->createArgumentInterpreter($booleanUtils); + + $argumentMapper = new \Magento\ObjectManager\Config\Mapper\Dom($argInterpreter); + $configData = $this->_loadPrimaryConfig($directoryList, $argumentMapper, $appMode); if ($configData) { $diConfig->extend($configData); } - $booleanUtils = new \Magento\Stdlib\BooleanUtils(); - $argFactory = new \Magento\ObjectManager\Config\Argument\ObjectFactory($diConfig); - $argInterpreter = $this->createArgumentInterpreter($booleanUtils, $argFactory, $appArguments); - $factory = new \Magento\ObjectManager\Factory\Factory($diConfig, $argInterpreter, $argFactory, $definitions); + $this->factory = new \Magento\ObjectManager\Factory\Factory( + $diConfig, + null, + $definitions, + $appArguments->get() + ); $className = $this->_locatorClassName; + + $sharedInstances = [ + 'Magento\App\Arguments' => $appArguments, + 'Magento\App\Filesystem\DirectoryList' => $directoryList, + 'Magento\Filesystem\DirectoryList' => $directoryList, + 'Magento\ObjectManager\Relations' => $relations, + 'Magento\Interception\Definition' => $definitionFactory->createPluginDefinition(), + 'Magento\ObjectManager\Config' => $diConfig, + 'Magento\ObjectManager\Definition' => $definitions, + 'Magento\Stdlib\BooleanUtils' => $booleanUtils, + 'Magento\ObjectManager\Config\Mapper\Dom' => $argumentMapper, + $configClass => $diConfig + ]; + /** @var \Magento\ObjectManager $objectManager */ - $objectManager = new $className( - $factory, - $diConfig, - array( - 'Magento\App\Arguments' => $appArguments, - 'Magento\App\Filesystem\DirectoryList' => $directoryList, - 'Magento\Filesystem\DirectoryList' => $directoryList, - 'Magento\ObjectManager\Relations' => $relations, - 'Magento\Interception\Definition' => $definitionFactory->createPluginDefinition(), - 'Magento\ObjectManager\Config' => $diConfig, - 'Magento\ObjectManager\Definition' => $definitions, - 'Magento\Stdlib\BooleanUtils' => $booleanUtils, - $configClass => $diConfig - ) - ); + $objectManager = new $className($this->factory, $diConfig, $sharedInstances); - $argFactory->setObjectManager($objectManager); + $this->factory->setObjectManager($objectManager); ObjectManager::setInstance($objectManager); /** @var \Magento\App\Filesystem\DirectoryList\Verification $verification */ @@ -157,26 +170,22 @@ protected function createAppArguments(DirectoryList $directoryList, array $argum * Return newly created instance on an argument interpreter, suitable for processing DI arguments * * @param \Magento\Stdlib\BooleanUtils $booleanUtils - * @param \Magento\ObjectManager\Config\Argument\ObjectFactory $objFactory - * @param Arguments $appArguments * @return \Magento\Data\Argument\InterpreterInterface */ protected function createArgumentInterpreter( - \Magento\Stdlib\BooleanUtils $booleanUtils, - \Magento\ObjectManager\Config\Argument\ObjectFactory $objFactory, - Arguments $appArguments + \Magento\Stdlib\BooleanUtils $booleanUtils ) { $constInterpreter = new \Magento\Data\Argument\Interpreter\Constant(); $result = new \Magento\Data\Argument\Interpreter\Composite( - array( + [ 'boolean' => new \Magento\Data\Argument\Interpreter\Boolean($booleanUtils), 'string' => new \Magento\Data\Argument\Interpreter\String($booleanUtils), 'number' => new \Magento\Data\Argument\Interpreter\Number(), 'null' => new \Magento\Data\Argument\Interpreter\NullType(), + 'object' => new \Magento\Data\Argument\Interpreter\Object($booleanUtils), 'const' => $constInterpreter, - 'object' => new \Magento\ObjectManager\Config\Argument\Interpreter\Object($booleanUtils, $objFactory), - 'init_parameter' => new \Magento\App\Arguments\ArgumentInterpreter($appArguments, $constInterpreter) - ), + 'init_parameter' => new \Magento\App\Arguments\ArgumentInterpreter($constInterpreter) + ], \Magento\ObjectManager\Config\Reader\Dom::TYPE_ATTRIBUTE ); // Add interpreters that reference the composite @@ -196,19 +205,36 @@ protected function configureDirectories(\Magento\ObjectManager $objectManager) } /** - * Load primary config data + * Load primary config * * @param DirectoryList $directoryList + * @param mixed $argumentMapper * @param string $appMode * @return array * @throws \Magento\BootstrapException */ - protected function _loadPrimaryConfig($directoryList, $appMode) + protected function _loadPrimaryConfig(DirectoryList $directoryList, $argumentMapper, $appMode) { $configData = null; - $primaryLoader = new \Magento\App\ObjectManager\ConfigLoader\Primary($directoryList, $appMode); try { - $configData = $primaryLoader->load(); + $fileResolver = new \Magento\App\Arguments\FileResolver\Primary( + new \Magento\App\Filesystem( + $directoryList, + new \Magento\Filesystem\Directory\ReadFactory(), + new \Magento\Filesystem\Directory\WriteFactory() + ), + new \Magento\Config\FileIteratorFactory() + ); + $schemaLocator = new \Magento\ObjectManager\Config\SchemaLocator(); + $validationState = new \Magento\App\Arguments\ValidationState($appMode); + + $reader = new \Magento\ObjectManager\Config\Reader\Dom( + $fileResolver, + $argumentMapper, + $schemaLocator, + $validationState + ); + $configData = $reader->read('primary'); } catch (\Exception $e) { throw new \Magento\BootstrapException($e->getMessage()); } @@ -234,13 +260,13 @@ protected function _createPluginList( ) { return $objectManager->create( 'Magento\Interception\PluginList\PluginList', - array( + [ 'relations' => $relations, 'definitions' => $definitionFactory->createPluginDefinition(), 'omConfig' => $diConfig, 'classDefinitions' => $definitions instanceof \Magento\ObjectManager\Definition\Compiled ? $definitions : null - ) + ] ); } } diff --git a/lib/Magento/App/Router/NoRouteHandlerList.php b/lib/Magento/App/Router/NoRouteHandlerList.php index 6280e77a215e7..d9a55d3db96bd 100644 --- a/lib/Magento/App/Router/NoRouteHandlerList.php +++ b/lib/Magento/App/Router/NoRouteHandlerList.php @@ -66,8 +66,8 @@ public function getHandlers() //sorting handlers list $sortedHandlersList = array(); foreach ($this->_handlerList as $handlerInfo) { - if (isset($handlerInfo['instance']) && isset($handlerInfo['sortOrder'])) { - $sortedHandlersList[$handlerInfo['instance']] = $handlerInfo['sortOrder']; + if (isset($handlerInfo['class']) && isset($handlerInfo['sortOrder'])) { + $sortedHandlersList[$handlerInfo['class']] = $handlerInfo['sortOrder']; } } diff --git a/lib/Magento/App/RouterList.php b/lib/Magento/App/RouterList.php index 5045945154296..bfb3cc531ee3e 100644 --- a/lib/Magento/App/RouterList.php +++ b/lib/Magento/App/RouterList.php @@ -51,7 +51,7 @@ public function __construct(\Magento\ObjectManager $objectManager, array $router $this->_routerList = array_filter( $routerList, function ($item) { - return (!isset($item['disable']) || !$item['disable']) && $item['instance']; + return (!isset($item['disable']) || !$item['disable']) && $item['class']; } ); uasort($this->_routerList, array($this, '_compareRoutersSortOrder')); @@ -67,7 +67,7 @@ protected function _getRouterInstance($routerId) { if (!isset($this->_routerList[$routerId]['object'])) { $this->_routerList[$routerId]['object'] = $this->_objectManager->create( - $this->_routerList[$routerId]['instance'] + $this->_routerList[$routerId]['class'] ); } return $this->_routerList[$routerId]['object']; diff --git a/lib/Magento/AppInterface.php b/lib/Magento/AppInterface.php index 8bf3f0de29370..b5c09bccfe4af 100644 --- a/lib/Magento/AppInterface.php +++ b/lib/Magento/AppInterface.php @@ -35,7 +35,7 @@ interface AppInterface /** * Magento version */ - const VERSION = '2.0.0.0-dev71'; + const VERSION = '2.0.0.0-dev72'; /** * Launch application diff --git a/lib/Magento/ObjectManager/Config/Argument/Interpreter/Object.php b/lib/Magento/Data/Argument/Interpreter/Object.php similarity index 58% rename from lib/Magento/ObjectManager/Config/Argument/Interpreter/Object.php rename to lib/Magento/Data/Argument/Interpreter/Object.php index c31bb77be3d74..8c12bac9d911b 100644 --- a/lib/Magento/ObjectManager/Config/Argument/Interpreter/Object.php +++ b/lib/Magento/Data/Argument/Interpreter/Object.php @@ -1,5 +1,6 @@ booleanUtils = $booleanUtils; - $this->objectFactory = $objectFactory; } /** - * {@inheritdoc} - * @return object + * Compute and return effective value of an argument + * + * @param array $data + * @return mixed * @throws \InvalidArgumentException + * @throws \UnexpectedValueException */ public function evaluate(array $data) { - if (empty($data['value'])) { - throw new \InvalidArgumentException('Object class name is missing.'); + $result = array('instance' => $data['value']); + if (isset($data['shared'])) { + $result['shared'] = $this->booleanUtils->toBoolean($data['shared']); } - $className = $data['value']; - $isShared = isset($data['shared']) ? $this->booleanUtils->toBoolean($data['shared']) : null; - $result = $this->objectFactory->create($className, $isShared); return $result; } } diff --git a/lib/Magento/Message/Manager.php b/lib/Magento/Message/Manager.php index fd66a2065650b..74e357a0d6bcb 100644 --- a/lib/Magento/Message/Manager.php +++ b/lib/Magento/Message/Manager.php @@ -57,10 +57,15 @@ class Manager implements ManagerInterface protected $logger; /** - * @var $string + * @var string */ protected $defaultGroup; + /** + * @var bool + */ + protected $hasMessages = false; + /** * @param Session $session * @param Factory $messageFactory @@ -138,6 +143,7 @@ public function getMessages($clear = false, $group = null) */ public function addMessage(MessageInterface $message, $group = null) { + $this->hasMessages = true; $this->getMessages(false, $group)->addMessage($message); $this->eventManager->dispatch('core_session_abstract_add_message'); return $this; @@ -275,4 +281,14 @@ public function addException(\Exception $exception, $alternativeText, $group = n $this->addMessage($this->messageFactory->create(MessageInterface::TYPE_ERROR, $alternativeText), $group); return $this; } + + /** + * Returns false if there are any messages for customer, true - in other case + * + * @return bool + */ + public function hasMessages() + { + return $this->hasMessages; + } } diff --git a/lib/Magento/Model/AbstractModel.php b/lib/Magento/Model/AbstractModel.php index 0b38933e50589..b6ef85b794cd2 100644 --- a/lib/Magento/Model/AbstractModel.php +++ b/lib/Magento/Model/AbstractModel.php @@ -316,7 +316,10 @@ public function load($modelId, $field = null) */ protected function _getEventData() { - return array('data_object' => $this, $this->_eventObject => $this); + return array( + 'data_object' => $this, + $this->_eventObject => $this, + ); } /** diff --git a/lib/Magento/Module/ResourceInterface.php b/lib/Magento/Module/ResourceInterface.php new file mode 100644 index 0000000000000..5876ade60cca6 --- /dev/null +++ b/lib/Magento/Module/ResourceInterface.php @@ -0,0 +1,61 @@ +config = $config; - $this->objectManager = $objectManager; - } - - /** - * Assign object manager instance - * - * @param ObjectManager $objectManager - * @return void - */ - public function setObjectManager(ObjectManager $objectManager) - { - $this->objectManager = $objectManager; - } - - /** - * Retrieve instance of the object manager - * - * @return ObjectManager - * @throws \LogicException - */ - protected function getObjectManager() - { - if (!$this->objectManager) { - throw new \LogicException('Object manager has not been assigned yet.'); - } - return $this->objectManager; - } - - /** - * Return new or shared instance of a given type - * - * @param string $type - * @param bool|null $isShared NULL - use the sharing configuration - * @return object - */ - public function create($type, $isShared = null) - { - $objectManager = $this->getObjectManager(); - $isShared = isset($isShared) ? $isShared : $this->config->isShared($type); - $result = $isShared ? $objectManager->get($type) : $objectManager->create($type); - return $result; - } -} diff --git a/lib/Magento/ObjectManager/Config/Config.php b/lib/Magento/ObjectManager/Config/Config.php index 0b520e9f665b3..62cd64d2bfe13 100644 --- a/lib/Magento/ObjectManager/Config/Config.php +++ b/lib/Magento/ObjectManager/Config/Config.php @@ -132,11 +132,9 @@ public function setCache(ConfigCache $cache) */ public function getArguments($type) { - return isset( - $this->_mergedArguments[$type] - ) ? $this->_mergedArguments[$type] : $this->_collectConfiguration( - $type - ); + return isset($this->_mergedArguments[$type]) + ? $this->_mergedArguments[$type] + : $this->_collectConfiguration($type); } /** diff --git a/lib/Magento/ObjectManager/Config/Mapper/Dom.php b/lib/Magento/ObjectManager/Config/Mapper/Dom.php index 2b4523ffa5f31..4e9fe89c067c9 100644 --- a/lib/Magento/ObjectManager/Config/Mapper/Dom.php +++ b/lib/Magento/ObjectManager/Config/Mapper/Dom.php @@ -23,6 +23,7 @@ */ namespace Magento\ObjectManager\Config\Mapper; +use Magento\Data\Argument\InterpreterInterface; use Magento\Stdlib\BooleanUtils; class Dom implements \Magento\Config\ConverterInterface @@ -37,14 +38,24 @@ class Dom implements \Magento\Config\ConverterInterface */ private $argumentParser; + /** + * @var InterpreterInterface + */ + private $argumentInterpreter; + /** * @param BooleanUtils $booleanUtils * @param ArgumentParser $argumentParser + * @param InterpreterInterface $argumentInterpreter */ - public function __construct(BooleanUtils $booleanUtils, ArgumentParser $argumentParser) - { - $this->booleanUtils = $booleanUtils; - $this->argumentParser = $argumentParser; + public function __construct( + InterpreterInterface $argumentInterpreter, + BooleanUtils $booleanUtils = null, + ArgumentParser $argumentParser = null + ) { + $this->argumentInterpreter = $argumentInterpreter; + $this->booleanUtils = $booleanUtils ?: new BooleanUtils(); + $this->argumentParser = $argumentParser ?: new ArgumentParser(); } /** @@ -105,7 +116,9 @@ public function convert($config) } $argumentName = $argumentNode->attributes->getNamedItem('name')->nodeValue; $argumentData = $this->argumentParser->parse($argumentNode); - $typeArguments[$argumentName] = $argumentData; + $typeArguments[$argumentName] = $this->argumentInterpreter->evaluate( + $argumentData + ); } break; case 'plugin': diff --git a/lib/Magento/ObjectManager/Factory/Factory.php b/lib/Magento/ObjectManager/Factory/Factory.php index 69c2e3c2e7ae1..07ed691f9348a 100644 --- a/lib/Magento/ObjectManager/Factory/Factory.php +++ b/lib/Magento/ObjectManager/Factory/Factory.php @@ -26,48 +26,60 @@ class Factory implements \Magento\ObjectManager\Factory { /** + * Object manager + * + * @var \Magento\ObjectManager + */ + protected $objectManager; + + /** + * Object manager config + * * @var \Magento\ObjectManager\Config */ - protected $_config; + protected $config; /** * Definition list * * @var \Magento\ObjectManager\Definition */ - protected $_definitions; + protected $definitions; /** + * Object creation stack + * * @var array */ - private $_creationStack = array(); - - /** - * @var \Magento\Data\Argument\InterpreterInterface - */ - protected $_argInterpreter; - - /** - * @var \Magento\ObjectManager\Config\Argument\ObjectFactory - */ - protected $_argObjectFactory; + protected $creationStack = array(); /** * @param \Magento\ObjectManager\Config $config - * @param \Magento\Data\Argument\InterpreterInterface $argInterpreter - * @param \Magento\ObjectManager\Config\Argument\ObjectFactory $argObjectFactory + * @param \Magento\ObjectManager $objectManager * @param \Magento\ObjectManager\Definition $definitions + * @param array $globalArguments */ public function __construct( \Magento\ObjectManager\Config $config, - \Magento\Data\Argument\InterpreterInterface $argInterpreter, - \Magento\ObjectManager\Config\Argument\ObjectFactory $argObjectFactory, - \Magento\ObjectManager\Definition $definitions = null + \Magento\ObjectManager $objectManager = null, + \Magento\ObjectManager\Definition $definitions = null, + $globalArguments = array() ) { - $this->_config = $config; - $this->_argInterpreter = $argInterpreter; - $this->_argObjectFactory = $argObjectFactory; - $this->_definitions = $definitions ?: new \Magento\ObjectManager\Definition\Runtime(); + $this->config = $config; + $this->objectManager = $objectManager; + $this->definitions = $definitions ?: new \Magento\ObjectManager\Definition\Runtime(); + $this->globalArguments = $globalArguments; + } + + /** + * Set object manager + * + * @param \Magento\ObjectManager $objectManager + * @return void + */ + public function setObjectManager(\Magento\ObjectManager $objectManager) + { + $this->objectManager = $objectManager; } /** @@ -75,7 +87,7 @@ public function __construct( * * @param string $requestedType * @param array $parameters - * @param array $argumentValues + * @param array $arguments * @return array * @throws \UnexpectedValueException * @throws \BadMethodCallException @@ -83,43 +95,78 @@ public function __construct( * @SuppressWarnings(PHPMD.CyclomaticComplexity) * @SuppressWarnings(PHPMD.NPathComplexity) */ - protected function _resolveArguments($requestedType, array $parameters, array $argumentValues = array()) + protected function _resolveArguments($requestedType, array $parameters, array $arguments = array()) { - $result = array(); - $arguments = $this->_config->getArguments($requestedType); + $resolvedArguments = array(); + $arguments = count($arguments) + ? array_replace($this->config->getArguments($requestedType), $arguments) + : $this->config->getArguments($requestedType); foreach ($parameters as $parameter) { list($paramName, $paramType, $paramRequired, $paramDefault) = $parameter; - if (array_key_exists($paramName, $argumentValues)) { - $value = $argumentValues[$paramName]; - } else if (array_key_exists($paramName, $arguments)) { - $argumentData = $arguments[$paramName]; - if (!is_array($argumentData)) { - throw new \UnexpectedValueException( - sprintf( - 'Invalid parameter configuration provided for $%s argument of %s.', - $paramName, - $requestedType - ) - ); - } - try { - $value = $this->_argInterpreter->evaluate($argumentData); - } catch (\Magento\Data\Argument\MissingOptionalValueException $e) { - $value = $paramDefault; - } + $argument = null; + if (array_key_exists($paramName, $arguments)) { + $argument = $arguments[$paramName]; } else if ($paramRequired) { - if (!$paramType) { + if ($paramType) { + $argument = array('instance' => $paramType); + } else { + $this->creationStack = array(); throw new \BadMethodCallException( - sprintf('Missing required argument $%s of %s.', $paramName, $requestedType) + 'Missing required argument $' . $paramName . ' of ' . $requestedType . '.' ); } - $value = $this->_argObjectFactory->create($paramType); } else { - $value = $paramDefault; + $argument = $paramDefault; + } + if ($paramType && !is_object($argument) && $argument !== $paramDefault) { + if (!is_array($argument) || !isset($argument['instance'])) { + throw new \UnexpectedValueException( + 'Invalid parameter configuration provided for $' . $paramName . ' argument of ' . $requestedType + ); + } + $argumentType = $argument['instance']; + $isShared = (isset($argument['shared']) ? $argument['shared'] :$this->config->isShared($argumentType)); + $argument = $isShared + ? $this->objectManager->get($argumentType) + : $this->objectManager->create($argumentType); + } else if (is_array($argument)) { + if (isset($argument['argument'])) { + $argKey = $argument['argument']; + $argument = isset($this->globalArguments[$argKey]) ? $this->globalArguments[$argKey] : $paramDefault; + } else if (!empty($argument)) { + $this->parseArray($argument); + } + } + $resolvedArguments[] = $argument; + } + return $resolvedArguments; + } + + /** + * Parse array argument + * + * @param array $array + * @return void + */ + protected function parseArray(&$array) + { + foreach ($array as $key => $item) { + if (is_array($item)) { + if (isset($item['instance'])) { + $itemType = $item['instance']; + $isShared = (isset($item['shared'])) ? $item['shared'] : $this->config->isShared($itemType); + $array[$key] = $isShared + ? $this->objectManager->get($itemType) + : $this->objectManager->create($itemType); + } elseif (isset($item['argument'])) { + $array[$key] = isset($this->globalArguments[$item['argument']]) + ? $this->globalArguments[$item['argument']] + : null; + } else { + $this->parseArray($item); + } } - $result[] = $value; } - return $result; } /** @@ -134,18 +181,22 @@ protected function _resolveArguments($requestedType, array $parameters, array $a */ public function create($requestedType, array $arguments = array()) { - $type = $this->_config->getInstanceType($requestedType); - $parameters = $this->_definitions->getParameters($type); + $type = $this->config->getInstanceType($requestedType); + $parameters = $this->definitions->getParameters($type); if ($parameters == null) { return new $type(); } - $this->_assertNoCircularDependency($requestedType); - $this->_creationStack[$requestedType] = $requestedType; + if (isset($this->creationStack[$requestedType])) { + $lastFound = end($this->creationStack); + $this->creationStack = array(); + throw new \LogicException("Circular dependency: {$requestedType} depends on {$lastFound} and vice versa."); + } + $this->creationStack[$requestedType] = $requestedType; try { $args = $this->_resolveArguments($requestedType, $parameters, $arguments); - unset($this->_creationStack[$requestedType]); + unset($this->creationStack[$requestedType]); } catch (\Exception $e) { - unset($this->_creationStack[$requestedType]); + unset($this->creationStack[$requestedType]); throw $e; } switch (count($args)) { @@ -172,18 +223,13 @@ public function create($requestedType, array $arguments = array()) } /** - * Prevent circular dependencies using creation stack + * Set global arguments * - * @param string $type - * @throws \LogicException + * @param array $arguments * @return void */ - private function _assertNoCircularDependency($type) + public function setArguments($arguments) { - if (isset($this->_creationStack[$type])) { - $lastFound = end($this->_creationStack); - $this->_creationStack = array(); - throw new \LogicException("Circular dependency: {$type} depends on {$lastFound} and vice versa."); - } + $this->globalArguments = $arguments; } } diff --git a/lib/Magento/View/Element/AbstractBlock.php b/lib/Magento/View/Element/AbstractBlock.php index 40886401533c6..8a53707103984 100644 --- a/lib/Magento/View/Element/AbstractBlock.php +++ b/lib/Magento/View/Element/AbstractBlock.php @@ -198,7 +198,6 @@ public function __construct(\Magento\View\Element\Context $context, array $data $this->filterManager = $context->getFilterManager(); $this->_localeDate = $context->getLocaleDate(); $this->inlineTranslation = $context->getInlineTranslation(); - $this->_isScopePrivate = false; parent::__construct($data); $this->_construct(); } diff --git a/lib/Magento/View/Helper/Js.php b/lib/Magento/View/Helper/Js.php new file mode 100644 index 0000000000000..f2666819451c3 --- /dev/null +++ b/lib/Magento/View/Helper/Js.php @@ -0,0 +1,44 @@ + + * + * Magento + * + * NOTICE OF LICENSE + * + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available through the world-wide-web at this URL: + * http://opensource.org/licenses/osl-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 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\View\Helper; + +class Js +{ + /** + * Retrieve framed javascript + * + * @param string $script + * @return string + */ + public function getScript($script) + { + return ''; + } +}