diff --git a/.php_cs b/.php_cs index 7ae5d11f4ad1c9c4d65a3b9b59644885e99b327e..743cab6ee0d17db99cfd1373cf35f246772921fe 100644 --- a/.php_cs +++ b/.php_cs @@ -15,7 +15,6 @@ $finder = Symfony\CS\Finder\DefaultFinder::create() ->exclude('dev/tests/functional/vendor') ->exclude('dev/tests/integration/tmp') ->exclude('dev/tests/integration/var') - ->exclude('lib/internal/Apache') ->exclude('lib/internal/CardinalCommerce') ->exclude('lib/internal/Cm') ->exclude('lib/internal/Credis') diff --git a/app/code/Magento/AdminNotification/Controller/Adminhtml/System/Message/ListAction.php b/app/code/Magento/AdminNotification/Controller/Adminhtml/System/Message/ListAction.php index e55da17969880f938970e312edb04d7670fd0506..c40ff5a1659cc1512af4efef6c2185ae5f7f559c 100644 --- a/app/code/Magento/AdminNotification/Controller/Adminhtml/System/Message/ListAction.php +++ b/app/code/Magento/AdminNotification/Controller/Adminhtml/System/Message/ListAction.php @@ -8,24 +8,56 @@ namespace Magento\AdminNotification\Controller\Adminhtml\System\Message; class ListAction extends \Magento\Backend\App\AbstractAction { + /** + * @var \Magento\Framework\Json\Helper\Data + */ + protected $jsonHelper; + + /** + * @var \Magento\AdminNotification\Model\Resource\System\Message\Collection + */ + protected $messageCollection; + + /** + * Initialize ListAction + * + * @param \Magento\Backend\App\Action\Context $context + * @param \Magento\Framework\Json\Helper\Data $jsonHelper + * @param \Magento\AdminNotification\Model\Resource\System\Message\Collection $messageCollection + */ + public function __construct( + \Magento\Backend\App\Action\Context $context, + \Magento\Framework\Json\Helper\Data $jsonHelper, + \Magento\AdminNotification\Model\Resource\System\Message\Collection $messageCollection + ) { + $this->jsonHelper = $jsonHelper; + $this->messageCollection = $messageCollection; + parent::__construct($context); + } + /** * @return void */ public function execute() { $severity = $this->getRequest()->getParam('severity'); - $messageCollection = $this->_objectManager->get( - 'Magento\AdminNotification\Model\Resource\System\Message\Collection' - ); if ($severity) { - $messageCollection->setSeverity($severity); + $this->messageCollection->setSeverity($severity); } $result = []; - foreach ($messageCollection->getItems() as $item) { - $result[] = ['severity' => $item->getSeverity(), 'text' => $item->getText()]; + foreach ($this->messageCollection->getItems() as $item) { + $result[] = [ + 'severity' => $item->getSeverity(), + 'text' => $item->getText(), + ]; + } + if (empty($result)) { + $result[] = [ + 'severity' => (string)\Magento\Framework\Notification\MessageInterface::SEVERITY_NOTICE, + 'text' => 'You have viewed and resolved all recent system notices. ' + . 'Please refresh the web page to clear the notice alert.', + ]; } - $this->getResponse()->representJson( - $this->_objectManager->get('Magento\Framework\Json\Helper\Data')->jsonEncode($result) - ); + $this->getResponse()->representJson($this->jsonHelper->jsonEncode($result)); } } diff --git a/app/code/Magento/AdminNotification/etc/config.xml b/app/code/Magento/AdminNotification/etc/config.xml index 35643f62753d250562fa1f5c9f4e568ebb00f059..63c65f9ed9bfe8f6a121cc171d1778eac64f7652 100644 --- a/app/code/Magento/AdminNotification/etc/config.xml +++ b/app/code/Magento/AdminNotification/etc/config.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Core/etc/config.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Store/etc/config.xsd"> <default> <system> <adminnotification> diff --git a/app/code/Magento/AdminNotification/etc/module.xml b/app/code/Magento/AdminNotification/etc/module.xml index cfc791e9072d98610989d0585f175278b306f91a..dd60aeb295b79ab9516a5482f221a1748bf27382 100644 --- a/app/code/Magento/AdminNotification/etc/module.xml +++ b/app/code/Magento/AdminNotification/etc/module.xml @@ -8,7 +8,6 @@ <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd"> <module name="Magento_AdminNotification" setup_version="2.0.0"> <sequence> - <module name="Magento_Core"/> <module name="Magento_Store"/> </sequence> </module> diff --git a/app/code/Magento/Authorization/Model/Acl/AclRetriever.php b/app/code/Magento/Authorization/Model/Acl/AclRetriever.php index e96a83a31eba907e26515f87bcf4439e6999112a..e31de3cde7727f6a6ed98b5795098c42d64a5ed3 100644 --- a/app/code/Magento/Authorization/Model/Acl/AclRetriever.php +++ b/app/code/Magento/Authorization/Model/Acl/AclRetriever.php @@ -75,7 +75,9 @@ class AclRetriever try { $role = $this->_getUserRole($userType, $userId); if (!$role) { - throw new AuthorizationException('The role associated with the specified user cannot be found.'); + throw new AuthorizationException( + __('The role associated with the specified user cannot be found.') + ); } $allowedResources = $this->getAllowedResourcesByRole($role->getId()); } catch (AuthorizationException $e) { diff --git a/app/code/Magento/Authorization/Setup/InstallData.php b/app/code/Magento/Authorization/Setup/InstallData.php index 68c2f5fdc469da597e3c0987b19306c5ebe7cd37..17fd1fd4039e10dad8ee75e402265cc6d7504f88 100644 --- a/app/code/Magento/Authorization/Setup/InstallData.php +++ b/app/code/Magento/Authorization/Setup/InstallData.php @@ -85,5 +85,17 @@ class InstallData implements InstallDataInterface $rule->setData('resource_id', 'Magento_Backend::all')->save(); } } + + /** + * Delete rows by condition from authorization_rule + */ + $setup->startSetup(); + + $tableName = $setup->getTable('authorization_rule'); + if ($tableName) { + $setup->getConnection()->delete($tableName, ['resource_id = ?' => 'admin/system/tools/compiler']); + } + + $setup->endSetup(); } } diff --git a/app/code/Magento/Backend/Controller/Adminhtml/Ajax/Translate.php b/app/code/Magento/Backend/Controller/Adminhtml/Ajax/Translate.php index fa374e9cbd2568dedf9316289cc6e1932c900671..143b12d06c3c933884219888577c3e06e856869c 100644 --- a/app/code/Magento/Backend/Controller/Adminhtml/Ajax/Translate.php +++ b/app/code/Magento/Backend/Controller/Adminhtml/Ajax/Translate.php @@ -16,19 +16,19 @@ class Translate extends \Magento\Backend\App\Action protected $inlineParser; /** - * @var \Magento\Framework\Controller\Result\JSONFactory + * @var \Magento\Framework\Controller\Result\JsonFactory */ protected $resultJsonFactory; /** * @param Action\Context $context * @param \Magento\Framework\Translate\Inline\ParserInterface $inlineParser - * @param \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory + * @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory */ public function __construct( Action\Context $context, \Magento\Framework\Translate\Inline\ParserInterface $inlineParser, - \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory + \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory ) { parent::__construct($context); $this->resultJsonFactory = $resultJsonFactory; @@ -38,13 +38,13 @@ class Translate extends \Magento\Backend\App\Action /** * Ajax action for inline translation * - * @return \Magento\Framework\Controller\Result\JSON + * @return \Magento\Framework\Controller\Result\Json */ public function execute() { $translate = (array)$this->getRequest()->getPost('translate'); - /** @var \Magento\Framework\Controller\Result\JSON $resultJson */ + /** @var \Magento\Framework\Controller\Result\Json $resultJson */ $resultJson = $this->resultJsonFactory->create(); try { $this->inlineParser->processAjaxPost($translate); diff --git a/app/code/Magento/Backend/Controller/Adminhtml/Auth/DeniedJson.php b/app/code/Magento/Backend/Controller/Adminhtml/Auth/DeniedJson.php index 33b251ca19dc30e1e590e05c4a13036ac9e2b0d4..43062aa6908a3bf411201bee43ecf28852e14d19 100644 --- a/app/code/Magento/Backend/Controller/Adminhtml/Auth/DeniedJson.php +++ b/app/code/Magento/Backend/Controller/Adminhtml/Auth/DeniedJson.php @@ -9,17 +9,17 @@ namespace Magento\Backend\Controller\Adminhtml\Auth; class DeniedJson extends \Magento\Backend\Controller\Adminhtml\Auth { /** - * @var \Magento\Framework\Controller\Result\JSONFactory + * @var \Magento\Framework\Controller\Result\JsonFactory */ protected $resultJsonFactory; /** * @param \Magento\Backend\App\Action\Context $context - * @param \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory + * @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory */ public function __construct( \Magento\Backend\App\Action\Context $context, - \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory + \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory ) { parent::__construct($context); $this->resultJsonFactory = $resultJsonFactory; @@ -41,11 +41,11 @@ class DeniedJson extends \Magento\Backend\Controller\Adminhtml\Auth /** * Denied JSON action * - * @return \Magento\Framework\Controller\Result\JSON + * @return \Magento\Framework\Controller\Result\Json */ public function execute() { - /** @var \Magento\Framework\Controller\Result\JSON $resultJson */ + /** @var \Magento\Framework\Controller\Result\Json $resultJson */ $resultJson = $this->resultJsonFactory->create(); return $resultJson->setData($this->_getDeniedJson()); } diff --git a/app/code/Magento/Backend/Controller/Adminhtml/Cache.php b/app/code/Magento/Backend/Controller/Adminhtml/Cache.php index 7b0e02e7d1e113e666fbbfb497790123344be1c9..f200ef062d37f9ef991f581fb20636b8677919b7 100644 --- a/app/code/Magento/Backend/Controller/Adminhtml/Cache.php +++ b/app/code/Magento/Backend/Controller/Adminhtml/Cache.php @@ -74,7 +74,7 @@ class Cache extends Action $allTypes = array_keys($this->_cacheTypeList->getTypes()); $invalidTypes = array_diff($types, $allTypes); if (count($invalidTypes) > 0) { - throw new LocalizedException(__("Specified cache type(s) don't exist: " . join(', ', $invalidTypes))); + throw new LocalizedException(__('Specified cache type(s) don\'t exist: %1', join(', ', $invalidTypes))); } } diff --git a/app/code/Magento/Backend/Controller/Adminhtml/Index/GlobalSearch.php b/app/code/Magento/Backend/Controller/Adminhtml/Index/GlobalSearch.php index c0017958a0bc88b09ab151f24faae155f483fd78..ba71fa71ec1d8dd23c085509d9f2672cc092824f 100644 --- a/app/code/Magento/Backend/Controller/Adminhtml/Index/GlobalSearch.php +++ b/app/code/Magento/Backend/Controller/Adminhtml/Index/GlobalSearch.php @@ -9,7 +9,7 @@ namespace Magento\Backend\Controller\Adminhtml\Index; class GlobalSearch extends \Magento\Backend\Controller\Adminhtml\Index { /** - * @var \Magento\Framework\Controller\Result\JSONFactory + * @var \Magento\Framework\Controller\Result\JsonFactory */ protected $resultJsonFactory; @@ -22,12 +22,12 @@ class GlobalSearch extends \Magento\Backend\Controller\Adminhtml\Index /** * @param \Magento\Backend\App\Action\Context $context - * @param \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory + * @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory * @param array $searchModules */ public function __construct( \Magento\Backend\App\Action\Context $context, - \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory, + \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory, array $searchModules = [] ) { $this->_searchModules = $searchModules; @@ -38,7 +38,7 @@ class GlobalSearch extends \Magento\Backend\Controller\Adminhtml\Index /** * Global Search Action * - * @return \Magento\Framework\Controller\Result\JSON + * @return \Magento\Framework\Controller\Result\Json */ public function execute() { @@ -87,7 +87,7 @@ class GlobalSearch extends \Magento\Backend\Controller\Adminhtml\Index } } - /** @var \Magento\Framework\Controller\Result\JSON $resultJson */ + /** @var \Magento\Framework\Controller\Result\Json $resultJson */ $resultJson = $this->resultJsonFactory->create(); return $resultJson->setData($items); } diff --git a/app/code/Magento/Backend/Controller/Adminhtml/System/Account/Save.php b/app/code/Magento/Backend/Controller/Adminhtml/System/Account/Save.php index d12a3141841d9d9b1b32ea400c347c6c6673c29b..86ec95f344e19d2fade1d60582365ffa98bfedf3 100644 --- a/app/code/Magento/Backend/Controller/Adminhtml/System/Account/Save.php +++ b/app/code/Magento/Backend/Controller/Adminhtml/System/Account/Save.php @@ -78,7 +78,7 @@ class Save extends \Magento\Backend\Controller\Adminhtml\System\Account $user->sendPasswordResetNotificationEmail(); } $this->messageManager->addSuccess(__('The account has been saved.')); - } catch (\Magento\Framework\Validator\ValidatorException $e) { + } catch (\Magento\Framework\Validator\Exception $e) { $this->messageManager->addMessages($e->getMessages()); if ($e->getMessage()) { $this->messageManager->addError($e->getMessage()); diff --git a/app/code/Magento/Backend/Model/Auth.php b/app/code/Magento/Backend/Model/Auth.php index 883bd5c2ddadee1847d47d409c6b1a75439276e9..53cf5d5a6f94e9a814a1fa8483b174ab34e5e55c 100644 --- a/app/code/Magento/Backend/Model/Auth.php +++ b/app/code/Magento/Backend/Model/Auth.php @@ -7,6 +7,7 @@ namespace Magento\Backend\Model; use Magento\Framework\Exception\AuthenticationException; use Magento\Framework\Exception\Plugin\AuthenticationException as PluginAuthenticationException; +use Magento\Framework\Phrase; /** * Backend Auth model @@ -81,7 +82,7 @@ class Auth public function setAuthStorage($storage) { if (!$storage instanceof \Magento\Backend\Model\Auth\StorageInterface) { - self::throwException('Authentication storage is incorrect.'); + self::throwException(__('Authentication storage is incorrect.')); } $this->_authStorage = $storage; return $this; @@ -199,12 +200,12 @@ class Auth /** * Throws specific Backend Authentication \Exception * - * @param string $msg + * @param \Magento\Framework\Phrase $msg * @return void * @throws \Magento\Framework\Exception\AuthenticationException * @static */ - public static function throwException($msg = null) + public static function throwException(Phrase $msg = null) { if (is_null($msg)) { $msg = __('Authentication error occurred.'); diff --git a/app/code/Magento/Backend/Model/View/Layout/GeneratorPool.php b/app/code/Magento/Backend/Model/View/Layout/GeneratorPool.php index 8cb5621e70f311c6845c580b748e87f29e2aa7ba..d27a5f464ec1243651cd387240a1c21b90630698 100644 --- a/app/code/Magento/Backend/Model/View/Layout/GeneratorPool.php +++ b/app/code/Magento/Backend/Model/View/Layout/GeneratorPool.php @@ -22,6 +22,7 @@ class GeneratorPool extends \Magento\Framework\View\Layout\GeneratorPool * @param ScheduledStructure\Helper $helper * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Framework\App\ScopeResolverInterface $scopeResolver + * @param \Psr\Log\LoggerInterface $logger * @param Filter\Acl $aclFilter * @param array $generators */ @@ -29,6 +30,7 @@ class GeneratorPool extends \Magento\Framework\View\Layout\GeneratorPool ScheduledStructure\Helper $helper, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Framework\App\ScopeResolverInterface $scopeResolver, + \Psr\Log\LoggerInterface $logger, Filter\Acl $aclFilter, array $generators = null ) { @@ -37,6 +39,7 @@ class GeneratorPool extends \Magento\Framework\View\Layout\GeneratorPool $helper, $scopeConfig, $scopeResolver, + $logger, $generators ); } diff --git a/app/code/Magento/Backend/Test/Unit/Model/Menu/Filter/IteratorTest.php b/app/code/Magento/Backend/Test/Unit/Model/Menu/Filter/IteratorTest.php index 6d65d43ef4a9ce4e9e4a72d4ea9c756d7b8408c7..83b1f1c8958831d3b0daa6eeb4c9b71b40a68e05 100644 --- a/app/code/Magento/Backend/Test/Unit/Model/Menu/Filter/IteratorTest.php +++ b/app/code/Magento/Backend/Test/Unit/Model/Menu/Filter/IteratorTest.php @@ -12,11 +12,6 @@ class IteratorTest extends \PHPUnit_Framework_TestCase */ protected $_menuModel; - /** - * @var \Magento\Backend\Model\Menu\Filter\Iterator - */ - protected $_filterIteratorModel; - /** * @var \Magento\Backend\Model\Menu\Item[] */ @@ -42,9 +37,6 @@ class IteratorTest extends \PHPUnit_Framework_TestCase $loggerMock = $this->getMock('Psr\Log\LoggerInterface'); $this->_menuModel = new \Magento\Backend\Model\Menu($loggerMock); - $this->_filterIteratorModel = new \Magento\Backend\Model\Menu\Filter\Iterator( - $this->_menuModel->getIterator() - ); } public function testLoopWithAllItemsDisabledDoesntIterate() @@ -54,8 +46,12 @@ class IteratorTest extends \PHPUnit_Framework_TestCase $this->_menuModel->add($this->getMock('Magento\Backend\Model\Menu\Item', [], [], '', false)); $this->_menuModel->add($this->getMock('Magento\Backend\Model\Menu\Item', [], [], '', false)); $this->_menuModel->add($this->getMock('Magento\Backend\Model\Menu\Item', [], [], '', false)); + $filterIteratorModel = new \Magento\Backend\Model\Menu\Filter\Iterator( + $this->_menuModel->getIterator() + ); + $items = []; - foreach ($this->_filterIteratorModel as $item) { + foreach ($filterIteratorModel as $item) { $items[] = $item; } $this->assertCount(0, $items); @@ -70,9 +66,12 @@ class IteratorTest extends \PHPUnit_Framework_TestCase $this->_menuModel->add($this->getMock('Magento\Backend\Model\Menu\Item', [], [], '', false)); $this->_menuModel->add($this->getMock('Magento\Backend\Model\Menu\Item', [], [], '', false)); + $filterIteratorModel = new \Magento\Backend\Model\Menu\Filter\Iterator( + $this->_menuModel->getIterator() + ); $items = []; - foreach ($this->_filterIteratorModel as $item) { + foreach ($filterIteratorModel as $item) { $items[] = $item; } $this->assertCount(1, $items); @@ -88,9 +87,12 @@ class IteratorTest extends \PHPUnit_Framework_TestCase $this->_menuModel->add($this->getMock('Magento\Backend\Model\Menu\Item', [], [], '', false)); $this->_menuModel->add($this->getMock('Magento\Backend\Model\Menu\Item', [], [], '', false)); + $filterIteratorModel = new \Magento\Backend\Model\Menu\Filter\Iterator( + $this->_menuModel->getIterator() + ); $items = []; - foreach ($this->_filterIteratorModel as $item) { + foreach ($filterIteratorModel as $item) { $items[] = $item; } $this->assertCount(1, $items); @@ -106,9 +108,12 @@ class IteratorTest extends \PHPUnit_Framework_TestCase $this->_menuModel->add($this->getMock('Magento\Backend\Model\Menu\Item', [], [], '', false)); $this->_menuModel->add($this->getMock('Magento\Backend\Model\Menu\Item', [], [], '', false)); + $filterIteratorModel = new \Magento\Backend\Model\Menu\Filter\Iterator( + $this->_menuModel->getIterator() + ); $items = []; - foreach ($this->_filterIteratorModel as $item) { + foreach ($filterIteratorModel as $item) { $items[] = $item; } $this->assertCount(1, $items); @@ -125,9 +130,12 @@ class IteratorTest extends \PHPUnit_Framework_TestCase $this->_menuModel->add($this->getMock('Magento\Backend\Model\Menu\Item', [], [], '', false)); $this->_menuModel->add($this->getMock('Magento\Backend\Model\Menu\Item', [], [], '', false)); + $filterIteratorModel = new \Magento\Backend\Model\Menu\Filter\Iterator( + $this->_menuModel->getIterator() + ); $items = []; - foreach ($this->_filterIteratorModel as $item) { + foreach ($filterIteratorModel as $item) { $items[] = $item; } $this->assertCount(1, $items); diff --git a/app/code/Magento/Backend/etc/adminhtml/menu.xml b/app/code/Magento/Backend/etc/adminhtml/menu.xml index e3eee55cf4e3b90e3ce046578cc988867079c4c4..08f50423e98189a9cf95a5fa031bd62658c833b9 100644 --- a/app/code/Magento/Backend/etc/adminhtml/menu.xml +++ b/app/code/Magento/Backend/etc/adminhtml/menu.xml @@ -9,7 +9,7 @@ <menu> <add id="Magento_Backend::system_design_schedule" title="Schedule" module="Magento_Backend" sortOrder="30" parent="Magento_Backend::system_design" action="adminhtml/system_design" resource="Magento_Backend::schedule"/> <add id="Magento_Backend::system_currency" title="Currency" module="Magento_Backend" sortOrder="30" parent="Magento_Backend::stores" action="adminhtml/system_currency" resource="Magento_CurrencySymbol::system_currency"/> - <add id="Magento_Backend::system_store" title="All Stores" module="Magento_Core" sortOrder="10" parent="Magento_Backend::stores_settings" action="adminhtml/system_store/" resource="Magento_Backend::store"/> + <add id="Magento_Backend::system_store" title="All Stores" module="Magento_Backend" sortOrder="10" parent="Magento_Backend::stores_settings" action="adminhtml/system_store/" resource="Magento_Backend::store"/> <add id="Magento_Backend::dashboard" title="Dashboard" module="Magento_Backend" sortOrder="10" action="adminhtml/dashboard" resource="Magento_Backend::dashboard"/> <add id="Magento_Backend::system" title="System" module="Magento_Backend" sortOrder="80" resource="Magento_Backend::system"/> <add id="Magento_Backend::system_tools" title="Tools" module="Magento_Backend" sortOrder="50" parent="Magento_Backend::system" resource="Magento_Backend::tools"/> diff --git a/app/code/Magento/Backend/etc/config.xml b/app/code/Magento/Backend/etc/config.xml index 9e58d76efd228d17e7df66ec80a1d687753d64bc..0d4c5d7180513828a1fd452c6c17d3847b8910d3 100644 --- a/app/code/Magento/Backend/etc/config.xml +++ b/app/code/Magento/Backend/etc/config.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Core/etc/config.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Store/etc/config.xsd"> <default> <system> <media_storage_configuration> diff --git a/app/code/Magento/Backup/Model/Backup.php b/app/code/Magento/Backup/Model/Backup.php index 73f9ec7cac8b6a6e3295ab3187cb65abf3048c45..a0d44f44641b9d801d546a3869e73c34e48cf0d7 100755 --- a/app/code/Magento/Backup/Model/Backup.php +++ b/app/code/Magento/Backup/Model/Backup.php @@ -246,7 +246,7 @@ class Backup extends \Magento\Framework\Object implements \Magento\Framework\Bac public function &getFile() { if (!$this->exists()) { - throw new \Magento\Framework\Exception\LocalizedException(__("The backup file does not exist.")); + throw new \Magento\Framework\Exception\LocalizedException(__('The backup file does not exist.')); } return $this->varDirectory->read($this->_getFilePath()); @@ -261,7 +261,7 @@ class Backup extends \Magento\Framework\Object implements \Magento\Framework\Bac public function deleteFile() { if (!$this->exists()) { - throw new \Magento\Framework\Exception\LocalizedException(__("The backup file does not exist.")); + throw new \Magento\Framework\Exception\LocalizedException(__('The backup file does not exist.')); } $this->varDirectory->delete($this->_getFilePath()); diff --git a/app/code/Magento/Bundle/Api/Data/LinkInterface.php b/app/code/Magento/Bundle/Api/Data/LinkInterface.php index 77ca71986d8a217100401a29533d913c5bcfd30a..e16fad7f555bee04fb7f42743598acff877c6c6b 100644 --- a/app/code/Magento/Bundle/Api/Data/LinkInterface.php +++ b/app/code/Magento/Bundle/Api/Data/LinkInterface.php @@ -144,4 +144,19 @@ interface LinkInterface extends \Magento\Framework\Api\ExtensibleDataInterface * @return $this */ public function setCanChangeQuantity($canChangeQuantity); + + /** + * Retrieve existing extension attributes object or create a new one. + * + * @return \Magento\Bundle\Api\Data\LinkExtensionInterface|null + */ + public function getExtensionAttributes(); + + /** + * Set an extension attributes object. + * + * @param \Magento\Bundle\Api\Data\LinkExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes(\Magento\Bundle\Api\Data\LinkExtensionInterface $extensionAttributes); } diff --git a/app/code/Magento/Bundle/Api/Data/OptionInterface.php b/app/code/Magento/Bundle/Api/Data/OptionInterface.php index f15c1856981ba02b77f560bc8040d48a4d4bb761..47d52ba713c6410e935ccab66e3ea3b66a96416e 100644 --- a/app/code/Magento/Bundle/Api/Data/OptionInterface.php +++ b/app/code/Magento/Bundle/Api/Data/OptionInterface.php @@ -113,4 +113,19 @@ interface OptionInterface extends \Magento\Framework\Api\ExtensibleDataInterface * @return $this */ public function setProductLinks(array $productLinks = null); + + /** + * Retrieve existing extension attributes object or create a new one. + * + * @return \Magento\Bundle\Api\Data\OptionExtensionInterface|null + */ + public function getExtensionAttributes(); + + /** + * Set an extension attributes object. + * + * @param \Magento\Bundle\Api\Data\OptionExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes(\Magento\Bundle\Api\Data\OptionExtensionInterface $extensionAttributes); } diff --git a/app/code/Magento/Bundle/Api/Data/OptionTypeInterface.php b/app/code/Magento/Bundle/Api/Data/OptionTypeInterface.php index 9132f2babc7f53470b02ad93f3a2d6ef1f4d1b45..9883c8535da83ca0dd252e30d64cfe82b4144cf7 100644 --- a/app/code/Magento/Bundle/Api/Data/OptionTypeInterface.php +++ b/app/code/Magento/Bundle/Api/Data/OptionTypeInterface.php @@ -37,4 +37,19 @@ interface OptionTypeInterface extends \Magento\Framework\Api\ExtensibleDataInter * @return $this */ public function setCode($code); + + /** + * Retrieve existing extension attributes object or create a new one. + * + * @return \Magento\Bundle\Api\Data\OptionTypeExtensionInterface|null + */ + public function getExtensionAttributes(); + + /** + * Set an extension attributes object. + * + * @param \Magento\Bundle\Api\Data\OptionTypeExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes(\Magento\Bundle\Api\Data\OptionTypeExtensionInterface $extensionAttributes); } diff --git a/app/code/Magento/Bundle/Api/ProductLinkManagementInterface.php b/app/code/Magento/Bundle/Api/ProductLinkManagementInterface.php index f10ef9e27291ebad1a1a97e8d2fac5621b538c37..2109cde0f95d452be9456038b8cfc2fa8ca30726 100644 --- a/app/code/Magento/Bundle/Api/ProductLinkManagementInterface.php +++ b/app/code/Magento/Bundle/Api/ProductLinkManagementInterface.php @@ -21,7 +21,7 @@ interface ProductLinkManagementInterface /** * Add child product to specified Bundle option by product sku * - * @param string $productSku + * @param string $sku * @param int $optionId * @param \Magento\Bundle\Api\Data\LinkInterface $linkedProduct * @throws \Magento\Framework\Exception\NoSuchEntityException @@ -29,7 +29,7 @@ interface ProductLinkManagementInterface * @throws \Magento\Framework\Exception\InputException * @return int */ - public function addChildByProductSku($productSku, $optionId, \Magento\Bundle\Api\Data\LinkInterface $linkedProduct); + public function addChildByProductSku($sku, $optionId, \Magento\Bundle\Api\Data\LinkInterface $linkedProduct); /** * @param \Magento\Catalog\Api\Data\ProductInterface $product @@ -49,12 +49,12 @@ interface ProductLinkManagementInterface /** * Remove product from Bundle product option * - * @param string $productSku + * @param string $sku * @param int $optionId * @param string $childSku * @throws \Magento\Framework\Exception\NoSuchEntityException * @throws \Magento\Framework\Exception\InputException * @return bool */ - public function removeChild($productSku, $optionId, $childSku); + public function removeChild($sku, $optionId, $childSku); } diff --git a/app/code/Magento/Bundle/Api/ProductOptionRepositoryInterface.php b/app/code/Magento/Bundle/Api/ProductOptionRepositoryInterface.php index 61c942a3b15344a5ed715f7279c6a9d8b7fb9bca..26857e69449cd04a3e130a3feb1432d87aaa198c 100644 --- a/app/code/Magento/Bundle/Api/ProductOptionRepositoryInterface.php +++ b/app/code/Magento/Bundle/Api/ProductOptionRepositoryInterface.php @@ -11,23 +11,23 @@ interface ProductOptionRepositoryInterface /** * Get option for bundle product * - * @param string $productSku + * @param string $sku * @param int $optionId * @return \Magento\Bundle\Api\Data\OptionInterface * @throws \Magento\Framework\Exception\NoSuchEntityException * @throws \Magento\Framework\Exception\InputException */ - public function get($productSku, $optionId); + public function get($sku, $optionId); /** * Get all options for bundle product * - * @param string $productSku + * @param string $sku * @return \Magento\Bundle\Api\Data\OptionInterface[] * @throws \Magento\Framework\Exception\NoSuchEntityException * @throws \Magento\Framework\Exception\InputException */ - public function getList($productSku); + public function getList($sku); /** * Remove bundle option @@ -42,13 +42,13 @@ interface ProductOptionRepositoryInterface /** * Remove bundle option * - * @param string $productSku + * @param string $sku * @param int $optionId * @return bool * @throws \Magento\Framework\Exception\CouldNotSaveException * @throws \Magento\Framework\Exception\InputException */ - public function deleteById($productSku, $optionId); + public function deleteById($sku, $optionId); /** * Add new option for bundle product diff --git a/app/code/Magento/Bundle/Model/Link.php b/app/code/Magento/Bundle/Model/Link.php index f20685ee211fde7efe7c4f484a7455e169f68d90..eb99eff55e334fd9c878af2054243956b76a115c 100644 --- a/app/code/Magento/Bundle/Model/Link.php +++ b/app/code/Magento/Bundle/Model/Link.php @@ -7,6 +7,7 @@ namespace Magento\Bundle\Model; /** + * Class Link * @codeCoverageIgnore */ class Link extends \Magento\Framework\Model\AbstractExtensibleModel implements @@ -196,4 +197,25 @@ class Link extends \Magento\Framework\Model\AbstractExtensibleModel implements { return $this->setData(self::KEY_CAN_CHANGE_QUANTITY, $canChangeQuantity); } + + /** + * {@inheritdoc} + * + * @return \Magento\Bundle\Api\Data\LinkExtensionInterface|null + */ + public function getExtensionAttributes() + { + return $this->_getExtensionAttributes(); + } + + /** + * {@inheritdoc} + * + * @param \Magento\Bundle\Api\Data\LinkExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes(\Magento\Bundle\Api\Data\LinkExtensionInterface $extensionAttributes) + { + return $this->_setExtensionAttributes($extensionAttributes); + } } diff --git a/app/code/Magento/Bundle/Model/LinkManagement.php b/app/code/Magento/Bundle/Model/LinkManagement.php index d6afcd452770da6fddd3b506edcacaa7a91c8860..fe2c0d85d7b168d21183813afc8b72ffbb9f280e 100644 --- a/app/code/Magento/Bundle/Model/LinkManagement.php +++ b/app/code/Magento/Bundle/Model/LinkManagement.php @@ -79,9 +79,7 @@ class LinkManagement implements \Magento\Bundle\Api\ProductLinkManagementInterfa { $product = $this->productRepository->get($productId); if ($product->getTypeId() != \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE) { - throw new InputException( - 'Only implemented for bundle product' - ); + throw new InputException(__('Only implemented for bundle product')); } $childrenList = []; @@ -97,10 +95,10 @@ class LinkManagement implements \Magento\Bundle\Api\ProductLinkManagementInterfa /** * {@inheritdoc} */ - public function addChildByProductSku($productSku, $optionId, \Magento\Bundle\Api\Data\LinkInterface $linkedProduct) + public function addChildByProductSku($sku, $optionId, \Magento\Bundle\Api\Data\LinkInterface $linkedProduct) { /** @var \Magento\Catalog\Model\Product $product */ - $product = $this->productRepository->get($productSku); + $product = $this->productRepository->get($sku); return $this->addChild($product, $optionId, $linkedProduct); } @@ -115,7 +113,9 @@ class LinkManagement implements \Magento\Bundle\Api\ProductLinkManagementInterfa \Magento\Bundle\Api\Data\LinkInterface $linkedProduct ) { if ($product->getTypeId() != \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE) { - throw new InputException('Product with specified sku: "%1" is not a bundle product', [$product->getSku()]); + throw new InputException( + __('Product with specified sku: "%1" is not a bundle product', $product->getSku()) + ); } $options = $this->optionCollection->create(); @@ -131,8 +131,10 @@ class LinkManagement implements \Magento\Bundle\Api\ProductLinkManagementInterfa if ($isNewOption) { throw new InputException( - 'Product with specified sku: "%1" does not contain option: "%2"', - [$product->getSku(), $optionId] + __( + 'Product with specified sku: "%1" does not contain option: "%2"', + [$product->getSku(), $optionId] + ) ); } @@ -142,15 +144,17 @@ class LinkManagement implements \Magento\Bundle\Api\ProductLinkManagementInterfa /** @var \Magento\Catalog\Model\Product $linkProductModel */ $linkProductModel = $this->productRepository->get($linkedProduct->getSku()); if ($linkProductModel->isComposite()) { - throw new InputException('Bundle product could not contain another composite product'); + throw new InputException(__('Bundle product could not contain another composite product')); } if ($selections) { foreach ($selections as $selection) { if ($selection['option_id'] == $optionId && $selection['product_id'] == $linkProductModel->getId()) { throw new CouldNotSaveException( - 'Child with specified sku: "%1" already assigned to product: "%2"', - [$linkedProduct->getSku(), $product->getSku()] + __( + 'Child with specified sku: "%1" already assigned to product: "%2"', + [$linkedProduct->getSku(), $product->getSku()] + ) ); } } @@ -171,7 +175,7 @@ class LinkManagement implements \Magento\Bundle\Api\ProductLinkManagementInterfa try { $selectionModel->save(); } catch (\Exception $e) { - throw new CouldNotSaveException('Could not save child: "%1"', [$e->getMessage()], $e); + throw new CouldNotSaveException(__('Could not save child: "%1"', $e->getMessage()), $e); } return $selectionModel->getId(); @@ -180,14 +184,12 @@ class LinkManagement implements \Magento\Bundle\Api\ProductLinkManagementInterfa /** * {@inheritdoc} */ - public function removeChild($productSku, $optionId, $childSku) + public function removeChild($sku, $optionId, $childSku) { - $product = $this->productRepository->get($productSku); + $product = $this->productRepository->get($sku); if ($product->getTypeId() != \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE) { - throw new InputException( - sprintf('Product with specified sku: %s is not a bundle product', $productSku) - ); + throw new InputException(__('Product with specified sku: %1 is not a bundle product', $sku)); } $excludeSelectionIds = []; @@ -206,7 +208,7 @@ class LinkManagement implements \Magento\Bundle\Api\ProductLinkManagementInterfa } if (empty($removeSelectionIds)) { throw new \Magento\Framework\Exception\NoSuchEntityException( - 'Requested bundle option product doesn\'t exist' + __('Requested bundle option product doesn\'t exist') ); } /* @var $resource \Magento\Bundle\Model\Resource\Bundle */ diff --git a/app/code/Magento/Bundle/Model/Option.php b/app/code/Magento/Bundle/Model/Option.php index dd265884d84999cb2f007c7a4a1c39b19f020f67..a541f00b80e24c7c6b8d221169b9f2efea55a900 100644 --- a/app/code/Magento/Bundle/Model/Option.php +++ b/app/code/Magento/Bundle/Model/Option.php @@ -269,5 +269,26 @@ class Option extends \Magento\Framework\Model\AbstractExtensibleModel implements { return $this->setData(self::KEY_PRODUCT_LINKS, $productLinks); } + + /** + * {@inheritdoc} + * + * @return \Magento\Bundle\Api\Data\OptionExtensionInterface|null + */ + public function getExtensionAttributes() + { + return $this->_getExtensionAttributes(); + } + + /** + * {@inheritdoc} + * + * @param \Magento\Bundle\Api\Data\OptionExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes(\Magento\Bundle\Api\Data\OptionExtensionInterface $extensionAttributes) + { + return $this->_setExtensionAttributes($extensionAttributes); + } //@codeCoverageIgnoreEnd } diff --git a/app/code/Magento/Bundle/Model/OptionManagement.php b/app/code/Magento/Bundle/Model/OptionManagement.php index e4053895111dbc12c4f5d6aabb1170e61ec84a95..714cb45a5662535884a5cfeb2f03fb6176171ba7 100644 --- a/app/code/Magento/Bundle/Model/OptionManagement.php +++ b/app/code/Magento/Bundle/Model/OptionManagement.php @@ -39,7 +39,7 @@ class OptionManagement implements \Magento\Bundle\Api\ProductOptionManagementInt { $product = $this->productRepository->get($option->getSku()); if ($product->getTypeId() != \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE) { - throw new InputException('Only implemented for bundle product'); + throw new InputException(__('Only implemented for bundle product')); } return $this->optionRepository->save($product, $option); } diff --git a/app/code/Magento/Bundle/Model/OptionRepository.php b/app/code/Magento/Bundle/Model/OptionRepository.php index 6fed5aa5798aed4aa722bb8dacb52a2d9f8ebe1f..264a7f1d159eccde62e0d2b6ce90855627c648d2 100644 --- a/app/code/Magento/Bundle/Model/OptionRepository.php +++ b/app/code/Magento/Bundle/Model/OptionRepository.php @@ -96,14 +96,14 @@ class OptionRepository implements \Magento\Bundle\Api\ProductOptionRepositoryInt /** * {@inheritdoc} */ - public function get($productSku, $optionId) + public function get($sku, $optionId) { - $product = $this->getProduct($productSku); + $product = $this->getProduct($sku); /** @var \Magento\Bundle\Model\Option $option */ $option = $this->type->getOptionsCollection($product)->getItemById($optionId); if (!$option || !$option->getId()) { - throw new NoSuchEntityException('Requested option doesn\'t exist'); + throw new NoSuchEntityException(__('Requested option doesn\'t exist')); } $productLinks = $this->linkList->getItems($product, $optionId); @@ -126,9 +126,9 @@ class OptionRepository implements \Magento\Bundle\Api\ProductOptionRepositoryInt /** * {@inheritdoc} */ - public function getList($productSku) + public function getList($sku) { - $product = $this->getProduct($productSku); + $product = $this->getProduct($sku); return $this->productOptionList->getItems($product); } @@ -141,8 +141,7 @@ class OptionRepository implements \Magento\Bundle\Api\ProductOptionRepositoryInt $this->optionResource->delete($option); } catch (\Exception $exception) { throw new \Magento\Framework\Exception\StateException( - 'Cannot delete option with id %option_id', - ['option_id' => $option->getOptionId()], + __('Cannot delete option with id %1', $option->getOptionId()), $exception ); } @@ -152,9 +151,9 @@ class OptionRepository implements \Magento\Bundle\Api\ProductOptionRepositoryInt /** * {@inheritdoc} */ - public function deleteById($productSku, $optionId) + public function deleteById($sku, $optionId) { - $product = $this->getProduct($productSku); + $product = $this->getProduct($sku); $optionCollection = $this->type->getOptionsCollection($product); $optionCollection->setIdFilter($optionId); return $this->delete($optionCollection->getFirstItem()); @@ -182,7 +181,7 @@ class OptionRepository implements \Magento\Bundle\Api\ProductOptionRepositoryInt $existingOption = $optionCollection->getFirstItem(); if (!$existingOption->getOptionId()) { - throw new NoSuchEntityException('Requested option doesn\'t exist'); + throw new NoSuchEntityException(__('Requested option doesn\'t exist')); } $option->setData(array_merge($existingOption->getData(), $option->getData())); @@ -205,7 +204,7 @@ class OptionRepository implements \Magento\Bundle\Api\ProductOptionRepositoryInt try { $this->optionResource->save($option); } catch (\Exception $e) { - throw new CouldNotSaveException('Could not save option', [], $e); + throw new CouldNotSaveException(__('Could not save option'), $e); } /** @var \Magento\Bundle\Api\Data\LinkInterface $linkedProduct */ @@ -217,15 +216,15 @@ class OptionRepository implements \Magento\Bundle\Api\ProductOptionRepositoryInt } /** - * @param string $productSku + * @param string $sku * @return \Magento\Catalog\Api\Data\ProductInterface * @throws \Magento\Framework\Exception\InputException */ - private function getProduct($productSku) + private function getProduct($sku) { - $product = $this->productRepository->get($productSku); + $product = $this->productRepository->get($sku); if ($product->getTypeId() != \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE) { - throw new InputException('Only implemented for bundle product'); + throw new InputException(__('Only implemented for bundle product')); } return $product; } diff --git a/app/code/Magento/Bundle/Model/Plugin/BundleLoadOptions.php b/app/code/Magento/Bundle/Model/Plugin/BundleLoadOptions.php index 7e7294d98bc1e766709bb8ed2cf668e50076de1e..76b5dd84b3620c4ee3fa4da5eae8fc6490b602ce 100644 --- a/app/code/Magento/Bundle/Model/Plugin/BundleLoadOptions.php +++ b/app/code/Magento/Bundle/Model/Plugin/BundleLoadOptions.php @@ -15,20 +15,21 @@ class BundleLoadOptions protected $productOptionList; /** - * @var \Magento\Framework\Api\AttributeValueFactory + * @var \Magento\Catalog\Api\Data\ProductExtensionFactory */ - protected $customAttributeFactory; + protected $productExtensionFactory; /** * @param \Magento\Bundle\Model\Product\OptionList $productOptionList - * @param \Magento\Framework\Api\AttributeValueFactory $customAttributeFactory + * @param \Magento\Framework\Api\AttributeDataBuilder $customAttributeBuilder + * @param \Magento\Catalog\Api\Data\ProductExtensionFactory $productExtensionFactory */ public function __construct( \Magento\Bundle\Model\Product\OptionList $productOptionList, - \Magento\Framework\Api\AttributeValueFactory $customAttributeFactory + \Magento\Catalog\Api\Data\ProductExtensionFactory $productExtensionFactory ) { $this->productOptionList = $productOptionList; - $this->customAttributeFactory = $customAttributeFactory; + $this->productExtensionFactory = $productExtensionFactory; } /** @@ -50,11 +51,12 @@ class BundleLoadOptions if ($product->getTypeId() != \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE) { return $product; } - $customAttribute = $this->customAttributeFactory->create() - ->setAttributeCode('bundle_product_options') - ->setValue($this->productOptionList->getItems($product)); - $attributes = array_merge($product->getCustomAttributes(), ['bundle_product_options' => $customAttribute]); - $product->setData('custom_attributes', $attributes); + + $productExtension = $this->productExtensionFactory->create(); + $productExtension->setBundleProductOptions($this->productOptionList->getItems($product)); + + $product->setExtensionAttributes($productExtension); + return $product; } } diff --git a/app/code/Magento/Bundle/Model/Plugin/BundleSaveOptions.php b/app/code/Magento/Bundle/Model/Plugin/BundleSaveOptions.php index 715feaab8e8220cc2396a076b7f2ed361647d198..b0e9ee6de4700da4651aee4c31aaed0b03db657b 100644 --- a/app/code/Magento/Bundle/Model/Plugin/BundleSaveOptions.php +++ b/app/code/Magento/Bundle/Model/Plugin/BundleSaveOptions.php @@ -44,13 +44,8 @@ class BundleSaveOptions return $result; } - /* @var \Magento\Framework\Api\AttributeValue $bundleProductOptionsAttrValue */ - $bundleProductOptionsAttrValue = $product->getCustomAttribute('bundle_product_options'); - if (is_null($bundleProductOptionsAttrValue) || !is_array($bundleProductOptionsAttrValue->getValue())) { - $bundleProductOptions = []; - } else { - $bundleProductOptions = $bundleProductOptionsAttrValue->getValue(); - } + /* @var \Magento\Bundle\Api\Data\OptionInterface[] $options */ + $bundleProductOptions = $product->getExtensionAttributes()->getBundleProductOptions(); if (is_array($bundleProductOptions)) { foreach ($bundleProductOptions as $option) { diff --git a/app/code/Magento/Bundle/Model/Product/Type.php b/app/code/Magento/Bundle/Model/Product/Type.php index 887aebbf7f669f30bd8cb463d6e6b147e4e3dc9e..1fdd7bad95292de7c985b119b155091be9659950 100644 --- a/app/code/Magento/Bundle/Model/Product/Type.php +++ b/app/code/Magento/Bundle/Model/Product/Type.php @@ -678,7 +678,7 @@ class Type extends \Magento\Catalog\Model\Product\Type\AbstractType try { if (is_string($result)) { - throw new \Magento\Framework\Exception\LocalizedException($result); + throw new \Magento\Framework\Exception\LocalizedException(__($result)); } $selections = []; @@ -1314,7 +1314,7 @@ class Type extends \Magento\Catalog\Model\Product\Type\AbstractType protected function checkIsResult($_result) { if (is_string($_result)) { - throw new \Magento\Framework\Exception\LocalizedException($_result); + throw new \Magento\Framework\Exception\LocalizedException(__($_result)); } if (!isset($_result[0])) { diff --git a/app/code/Magento/Bundle/Model/Source/Option/Type.php b/app/code/Magento/Bundle/Model/Source/Option/Type.php index 711b94c2a554735aca2e24cb968e983518723316..98ecd93865d4cc25ca07963e2a1fe6866f25a04a 100644 --- a/app/code/Magento/Bundle/Model/Source/Option/Type.php +++ b/app/code/Magento/Bundle/Model/Source/Option/Type.php @@ -9,8 +9,12 @@ namespace Magento\Bundle\Model\Source\Option; use Magento\Framework\Api\AttributeValueFactory; -use Magento\Framework\Api\MetadataServiceInterface; +use Magento\Framework\Api\ExtensionAttributesFactory; +/** + * Class Type + * + */ class Type extends \Magento\Framework\Model\AbstractExtensibleModel implements \Magento\Framework\Option\ArrayInterface, \Magento\Bundle\Api\Data\OptionTypeInterface @@ -30,7 +34,7 @@ class Type extends \Magento\Framework\Model\AbstractExtensibleModel implements /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry - * @param MetadataServiceInterface $metadataService + * @param ExtensionAttributesFactory $extensionFactory * @param AttributeValueFactory $customAttributeFactory * @param array $options * @param \Magento\Framework\Model\Resource\AbstractResource $resource @@ -40,7 +44,7 @@ class Type extends \Magento\Framework\Model\AbstractExtensibleModel implements public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, - MetadataServiceInterface $metadataService, + ExtensionAttributesFactory $extensionFactory, AttributeValueFactory $customAttributeFactory, array $options, \Magento\Framework\Model\Resource\AbstractResource $resource = null, @@ -51,7 +55,7 @@ class Type extends \Magento\Framework\Model\AbstractExtensibleModel implements parent::__construct( $context, $registry, - $metadataService, + $extensionFactory, $customAttributeFactory, $resource, $resourceCollection, @@ -111,5 +115,26 @@ class Type extends \Magento\Framework\Model\AbstractExtensibleModel implements { return $this->setData(self::KEY_CODE, $code); } + + /** + * {@inheritdoc} + * + * @return \Magento\Bundle\Api\Data\OptionTypeExtensionInterface|null + */ + public function getExtensionAttributes() + { + return $this->_getExtensionAttributes(); + } + + /** + * {@inheritdoc} + * + * @param \Magento\Bundle\Api\Data\OptionTypeExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes(\Magento\Bundle\Api\Data\OptionTypeExtensionInterface $extensionAttributes) + { + return $this->_setExtensionAttributes($extensionAttributes); + } //@codeCoverageIgnoreEnd } diff --git a/app/code/Magento/Bundle/Test/Unit/Model/OptionRepositoryTest.php b/app/code/Magento/Bundle/Test/Unit/Model/OptionRepositoryTest.php index 2ed7bdb1b29e5864135cfa067f78a7022c28ec7a..7b91140a3bfe6fd0aa0196384d298e656afbb5bd 100644 --- a/app/code/Magento/Bundle/Test/Unit/Model/OptionRepositoryTest.php +++ b/app/code/Magento/Bundle/Test/Unit/Model/OptionRepositoryTest.php @@ -4,6 +4,9 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ + +// @codingStandardsIgnoreFile + namespace Magento\Bundle\Test\Unit\Model; class OptionRepositoryTest extends \PHPUnit_Framework_TestCase @@ -71,6 +74,7 @@ class OptionRepositoryTest extends \PHPUnit_Framework_TestCase $this->optionFactoryMock = $this->getMockBuilder('\Magento\Bundle\Api\Data\OptionInterfaceFactory') ->disableOriginalConstructor() ->setMethods(['create']) + ->disableOriginalConstructor() ->getMock(); $this->dataObjectHelperMock = $this->getMockBuilder('\Magento\Framework\Api\DataObjectHelper') ->disableOriginalConstructor() diff --git a/app/code/Magento/Bundle/Test/Unit/Model/Plugin/BundleLoadOptionsTest.php b/app/code/Magento/Bundle/Test/Unit/Model/Plugin/BundleLoadOptionsTest.php index 0618065c4e80bacd68fe211d7a433209636aa97a..e4050d99040ca61dacc97b54731fd79e67719af1 100644 --- a/app/code/Magento/Bundle/Test/Unit/Model/Plugin/BundleLoadOptionsTest.php +++ b/app/code/Magento/Bundle/Test/Unit/Model/Plugin/BundleLoadOptionsTest.php @@ -4,6 +4,9 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ + +// @codingStandardsIgnoreFile + namespace Magento\Bundle\Test\Unit\Model\Plugin; class BundleLoadOptionsTest extends \PHPUnit_Framework_TestCase @@ -23,13 +26,20 @@ class BundleLoadOptionsTest extends \PHPUnit_Framework_TestCase */ protected $attributeFactoryMock; + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $productExtensionFactory; + protected function setUp() { $this->optionListMock = $this->getMock('\Magento\Bundle\Model\Product\OptionList', [], [], '', false); - $this->attributeFactoryMock = $this->getMock('\Magento\Framework\Api\AttributeValueFactory', [], [], '', false); + $this->productExtensionFactory = $this->getMockBuilder('\Magento\Catalog\Api\Data\ProductExtensionFactory') + ->disableOriginalConstructor() + ->getMock(); $this->model = new \Magento\Bundle\Model\Plugin\BundleLoadOptions( $this->optionListMock, - $this->attributeFactoryMock + $this->productExtensionFactory ); } @@ -50,9 +60,10 @@ class BundleLoadOptionsTest extends \PHPUnit_Framework_TestCase public function testAroundLoad() { + $this->markTestSkipped('MAGETWO-34577'); $productMock = $this->getMock( '\Magento\Catalog\Model\Product', - ['getTypeId', 'getCustomAttributes', 'setData'], + ['getTypeId', 'setExtensionAttributes'], [], '', false @@ -69,22 +80,19 @@ class BundleLoadOptionsTest extends \PHPUnit_Framework_TestCase ->method('getItems') ->with($productMock) ->willReturn([$optionMock]); - $customAttributeMock = $this->getMock('\Magento\Framework\Api\AttributeValue', [], [], '', false); - $customAttributeMock->expects($this->once()) - ->method('setAttributeCode') - ->with('bundle_product_options') - ->willReturnSelf(); - $customAttributeMock->expects($this->once()) - ->method('setValue') + $productExtensionMock = $this->getMockBuilder('\Magento\Catalog\Api\Data\ProductExtension') + ->disableOriginalConstructor() + ->getMock(); + $this->productExtensionFactory->expects($this->once()) + ->method('create') + ->willReturn($productExtensionMock); + $productExtensionMock->expects($this->once()) + ->method('setBundleProductOptions') ->with([$optionMock]) ->willReturnSelf(); - $this->attributeFactoryMock->expects($this->once())->method('create')->willReturn($customAttributeMock); - - $productAttributeMock = $this->getMock('\Magento\Framework\Api\AttributeValue', [], [], '', false); - $productMock->expects($this->once())->method('getCustomAttributes')->willReturn([$productAttributeMock]); $productMock->expects($this->once()) - ->method('setData') - ->with('custom_attributes', ['bundle_product_options' => $customAttributeMock, $productAttributeMock]) + ->method('setExtensionAttributes') + ->with($productExtensionMock) ->willReturnSelf(); $this->assertEquals( diff --git a/app/code/Magento/Bundle/Test/Unit/Model/Plugin/BundleSaveOptionsTest.php b/app/code/Magento/Bundle/Test/Unit/Model/Plugin/BundleSaveOptionsTest.php index 7bf90801c4620a0d40b47265b39aebac41531251..1615760e6dbee5b4ad44d0d30cd81b53b19e691e 100644 --- a/app/code/Magento/Bundle/Test/Unit/Model/Plugin/BundleSaveOptionsTest.php +++ b/app/code/Magento/Bundle/Test/Unit/Model/Plugin/BundleSaveOptionsTest.php @@ -5,6 +5,8 @@ * See COPYING.txt for license details. */ +// @codingStandardsIgnoreFile + namespace Magento\Bundle\Test\Unit\Model\Plugin; use \Magento\Bundle\Model\Plugin\BundleSaveOptions; @@ -31,6 +33,16 @@ class BundleSaveOptionsTest extends \PHPUnit_Framework_TestCase */ protected $productMock; + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $productExtensionMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $productBundleOptionsMock; + /** * @var \Closure */ @@ -40,17 +52,37 @@ class BundleSaveOptionsTest extends \PHPUnit_Framework_TestCase { $this->productRepositoryMock = $this->getMock('Magento\Catalog\Api\ProductRepositoryInterface'); $this->productOptionRepositoryMock = $this->getMock('Magento\Bundle\Api\ProductOptionRepositoryInterface'); - $this->productMock = $this->getMock('Magento\Catalog\Model\Product', [], [], '', false); + $this->productMock = $this->getMock( + 'Magento\Catalog\Model\Product', + ['getExtensionAttributes', 'getTypeId'], + [], + '', + false + ); $this->closureMock = function () { return $this->productMock; }; $this->plugin = new BundleSaveOptions($this->productOptionRepositoryMock); + $this->productExtensionMock = $this->getMock( + 'Magento\Catalog\Api\Data\ProductExtension', + ['getBundleProductOptions'], + [], + '', + false + ); + $this->productBundleOptionsMock = $this->getMock( + 'Magento\Bundle\Api\Data\OptionInterface', + [], + [], + '', + false + ); } public function testAroundSaveWhenProductIsSimple() { $this->productMock->expects($this->once())->method('getTypeId')->willReturn('simple'); - $this->productMock->expects($this->never())->method('getCustomAttribute'); + $this->productMock->expects($this->never())->method('getExtensionAttributes'); $this->assertEquals( $this->productMock, @@ -62,9 +94,11 @@ class BundleSaveOptionsTest extends \PHPUnit_Framework_TestCase { $this->productMock->expects($this->once())->method('getTypeId')->willReturn('bundle'); $this->productMock->expects($this->once()) - ->method('getCustomAttribute') - ->with('bundle_product_options') - ->willReturn(null); + ->method('getExtensionAttributes') + ->willReturn($this->productExtensionMock); + $this->productExtensionMock->expects($this->once()) + ->method('getBundleProductOptions') + ->willReturn([]); $this->productOptionRepositoryMock->expects($this->never())->method('save'); @@ -76,16 +110,17 @@ class BundleSaveOptionsTest extends \PHPUnit_Framework_TestCase public function testAroundSaveWhenProductIsBundleWithOptions() { - $option = $this->getMock('\Magento\Bundle\Api\Data\OptionInterface'); - $bundleProductOptionsAttrValue = $this->getMock('\Magento\Framework\Api\AttributeValue', [], [], '', false); - $bundleProductOptionsAttrValue->expects($this->atLeastOnce())->method('getValue')->willReturn([$option]); $this->productMock->expects($this->once())->method('getTypeId')->willReturn('bundle'); $this->productMock->expects($this->once()) - ->method('getCustomAttribute') - ->with('bundle_product_options') - ->willReturn($bundleProductOptionsAttrValue); - - $this->productOptionRepositoryMock->expects($this->once())->method('save')->with($this->productMock, $option); + ->method('getExtensionAttributes') + ->willReturn($this->productExtensionMock); + $this->productExtensionMock->expects($this->once()) + ->method('getBundleProductOptions') + ->willReturn([$this->productBundleOptionsMock]); + + $this->productOptionRepositoryMock->expects($this->once()) + ->method('save') + ->with($this->productMock, $this->productBundleOptionsMock); $this->assertEquals( $this->productMock, diff --git a/app/code/Magento/Bundle/Test/Unit/Model/Product/TypeTest.php b/app/code/Magento/Bundle/Test/Unit/Model/Product/TypeTest.php index c4aab7ef84c20a7829f64b6f0ef538eb82b54f37..168fa5363ab0a943f185f78b345169a1f0427d98 100644 --- a/app/code/Magento/Bundle/Test/Unit/Model/Product/TypeTest.php +++ b/app/code/Magento/Bundle/Test/Unit/Model/Product/TypeTest.php @@ -61,6 +61,9 @@ class TypeTest extends \PHPUnit_Framework_TestCase */ private $priceCurrency; + /** + * @return void + */ protected function setUp() { $this->bundleCollection = $this->getMockBuilder('Magento\Bundle\Model\Resource\Selection\CollectionFactory') @@ -119,6 +122,7 @@ class TypeTest extends \PHPUnit_Framework_TestCase } /** + * @return void * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ public function testPrepareForCartAdvancedWithoutOptions() @@ -227,6 +231,7 @@ class TypeTest extends \PHPUnit_Framework_TestCase } /** + * @return void * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ public function testPrepareForCartAdvancedWithShoppingCart() @@ -466,6 +471,7 @@ class TypeTest extends \PHPUnit_Framework_TestCase } /** + * @return void * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ public function testPrepareForCartAdvancedEmptyShoppingCart() @@ -684,6 +690,7 @@ class TypeTest extends \PHPUnit_Framework_TestCase } /** + * @return void * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ public function testPrepareForCartAdvancedStringInResult() @@ -902,6 +909,7 @@ class TypeTest extends \PHPUnit_Framework_TestCase } /** + * @return void * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ public function testPrepareForCartAdvancedWithoutSelections() @@ -1007,6 +1015,7 @@ class TypeTest extends \PHPUnit_Framework_TestCase } /** + * @return void * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ public function testPrepareForCartAdvancedSelectionsSelectionIdsExists() @@ -1134,6 +1143,7 @@ class TypeTest extends \PHPUnit_Framework_TestCase } /** + * @return void * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ public function testPrepareForCartAdvancedSelectRequiredOptions() @@ -1255,6 +1265,9 @@ class TypeTest extends \PHPUnit_Framework_TestCase $this->assertEquals('The required options you selected are not available.', $result); } + /** + * @return void + */ public function testPrepareForCartAdvancedParentClassReturnString() { $exceptedResult = 'String message'; @@ -1270,13 +1283,15 @@ class TypeTest extends \PHPUnit_Framework_TestCase ->getMock(); $product->expects($this->at(0)) ->method('getOptions') - ->willThrowException(new LocalizedException($exceptedResult)); + ->willThrowException(new LocalizedException(__($exceptedResult))); $result = $this->model->prepareForCartAdvanced($buyRequest, $product); $this->assertEquals($exceptedResult, $result); } - + /** + * @return void + */ public function testPrepareForCartAdvancedAllrequiredOption() { /** @var \PHPUnit_Framework_MockObject_MockObject|DefaultType $group */ @@ -1374,6 +1389,9 @@ class TypeTest extends \PHPUnit_Framework_TestCase $this->assertEquals('Please select all required options.', $result); } + /** + * @return void + */ public function testPrepareForCartAdvancedSpecifyProductOptions() { /** @var \PHPUnit_Framework_MockObject_MockObject|DefaultType $group */ @@ -1423,11 +1441,17 @@ class TypeTest extends \PHPUnit_Framework_TestCase $this->assertEquals('Please specify product option(s).', $result); } + /** + * @return void + */ public function testHasWeightTrue() { $this->assertTrue($this->model->hasWeight(), 'This product has no weight, but it should'); } + /** + * @return void + */ public function testGetIdentities() { $identities = ['id1', 'id2']; @@ -1469,6 +1493,9 @@ class TypeTest extends \PHPUnit_Framework_TestCase $this->assertEquals($identities, $this->model->getIdentities($productMock)); } + /** + * @return void + */ public function testGetSkuWithType() { $sku = 'sku'; @@ -1487,6 +1514,9 @@ class TypeTest extends \PHPUnit_Framework_TestCase $this->assertEquals($sku, $this->model->getSku($productMock)); } + /** + * @return void + */ public function testGetSkuWithoutType() { $sku = 'sku'; @@ -1539,6 +1569,9 @@ class TypeTest extends \PHPUnit_Framework_TestCase $this->assertEquals($sku . '-' . $itemSku, $this->model->getSku($productMock)); } + /** + * @return void + */ public function testGetWeightWithoutCustomOption() { $weight = 5; @@ -1559,6 +1592,9 @@ class TypeTest extends \PHPUnit_Framework_TestCase $this->assertEquals($weight, $this->model->getWeight($productMock)); } + /** + * @return void + */ public function testGetWeightWithCustomOption() { $weight = 5; @@ -1610,6 +1646,9 @@ class TypeTest extends \PHPUnit_Framework_TestCase $this->assertEquals($weight, $this->model->getWeight($productMock)); } + /** + * @return void + */ public function testGetWeightWithSeveralCustomOption() { $weight = 5; @@ -1668,6 +1707,9 @@ class TypeTest extends \PHPUnit_Framework_TestCase $this->assertEquals($weight * $qtyOption, $this->model->getWeight($productMock)); } + /** + * @return void + */ public function testIsVirtualWithoutCustomOption() { $productMock = $this->getMockBuilder('Magento\Catalog\Model\Product') @@ -1681,6 +1723,9 @@ class TypeTest extends \PHPUnit_Framework_TestCase $this->assertFalse($this->model->isVirtual($productMock)); } + /** + * @return void + */ public function testIsVirtual() { $selectionIds = [1, 2, 3]; @@ -1726,10 +1771,10 @@ class TypeTest extends \PHPUnit_Framework_TestCase } /** - * @param $selectionIds - * @param $productMock - * @param $getSelectionsIndex - * @param $getSelectionsIdsIndex + * @param array $selectionIds + * @param \PHPUnit_Framework_MockObject_MockObject $productMock + * @param int $getSelectionsIndex + * @param int $getSelectionsIdsIndex * @return \PHPUnit_Framework_MockObject_MockObject */ @@ -1752,9 +1797,10 @@ class TypeTest extends \PHPUnit_Framework_TestCase } /** - * @param $expected - * @param $firstId - * @param $secondId + * @param int $expected + * @param int $firstId + * @param int $secondId + * @return void * @dataProvider shakeSelectionsDataProvider */ public function testShakeSelections($expected, $firstId, $secondId) @@ -1823,6 +1869,7 @@ class TypeTest extends \PHPUnit_Framework_TestCase } /** + * @return void * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ public function testGetSelectionsByIds() @@ -1926,6 +1973,9 @@ class TypeTest extends \PHPUnit_Framework_TestCase $this->model->getSelectionsByIds($selectionIds, $productMock); } + /** + * @return void + */ public function testGetOptionsByIds() { $optionsIds = [1, 2, 3]; @@ -1997,6 +2047,9 @@ class TypeTest extends \PHPUnit_Framework_TestCase $this->model->getOptionsByIds($optionsIds, $productMock); } + /** + * @return void + */ public function testIsSalableFalse() { $product = new \Magento\Framework\Object( @@ -2009,6 +2062,9 @@ class TypeTest extends \PHPUnit_Framework_TestCase $this->assertFalse($this->model->isSalable($product)); } + /** + * @return void + */ public function testIsSalableWithoutOptions() { $optionCollectionMock = $this->getMockBuilder('\Magento\Bundle\Model\Resource\Option\Collection') @@ -2026,6 +2082,9 @@ class TypeTest extends \PHPUnit_Framework_TestCase $this->assertFalse($this->model->isSalable($product)); } + /** + * @return void + */ public function testIsSalableWithRequiredOptionsTrue() { $option1 = $this->getRequiredOptionMock(10, 10); @@ -2071,6 +2130,9 @@ class TypeTest extends \PHPUnit_Framework_TestCase $this->assertTrue($this->model->isSalable($product)); } + /** + * @return void + */ public function testIsSalableCache() { $product = new \Magento\Framework\Object( @@ -2084,6 +2146,9 @@ class TypeTest extends \PHPUnit_Framework_TestCase $this->assertTrue($this->model->isSalable($product)); } + /** + * @return void + */ public function testIsSalableWithEmptySelectionsCollection() { $option = $this->getRequiredOptionMock(1, 10); @@ -2102,6 +2167,9 @@ class TypeTest extends \PHPUnit_Framework_TestCase $this->assertFalse($this->model->isSalable($product)); } + /** + * @return void + */ public function testIsSalableWithRequiredOptionsOutOfStock() { $option1 = $this->getRequiredOptionMock(10, 10); @@ -2145,6 +2213,9 @@ class TypeTest extends \PHPUnit_Framework_TestCase $this->assertFalse($this->model->isSalable($product)); } + /** + * @return void + */ public function testIsSalableNoManageStock() { $option1 = $this->getRequiredOptionMock(10, 10); @@ -2274,11 +2345,13 @@ class TypeTest extends \PHPUnit_Framework_TestCase return $optionCollectionMock; } + /** + * @param bool $isManageStock + * @return \Magento\CatalogInventory\Api\Data\StockItemInterface|\PHPUnit_Framework_MockObject_MockObject + */ protected function getStockItem($isManageStock) { - $result = $this->getMockBuilder('\Magento\CatalogInventory\Api\Data\StockItem') - ->setMethods(['getManageStock']) - ->disableOriginalConstructor() + $result = $this->getMockBuilder('Magento\CatalogInventory\Api\Data\StockItemInterface') ->getMock(); $result->method('getManageStock') ->willReturn($isManageStock); @@ -2291,6 +2364,7 @@ class TypeTest extends \PHPUnit_Framework_TestCase * @param \PHPUnit_Framework_MockObject_MockObject|\Magento\Catalog\Model\Product\Option $option * @param \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\Object $buyRequest * @param \PHPUnit_Framework_MockObject_MockObject|\Magento\Catalog\Model\Product $product + * @return void */ protected function parentClass($group, $option, $buyRequest, $product) { diff --git a/app/code/Magento/Bundle/Test/Unit/Pricing/Price/DiscountCalculatorTest.php b/app/code/Magento/Bundle/Test/Unit/Pricing/Price/DiscountCalculatorTest.php index f15939bfd5add7b635db8fd8a39a875b1cf5e91c..8ebcc1cb67a8b5d2b7dc606cc99ca5e740d2f1e5 100644 --- a/app/code/Magento/Bundle/Test/Unit/Pricing/Price/DiscountCalculatorTest.php +++ b/app/code/Magento/Bundle/Test/Unit/Pricing/Price/DiscountCalculatorTest.php @@ -8,8 +8,6 @@ namespace Magento\Bundle\Test\Unit\Pricing\Price; -use Magento\Catalog\Pricing\Price\FinalPrice; - /** * Class DiscountCalculatorTest */ @@ -95,7 +93,7 @@ class DiscountCalculatorTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue($this->priceInfoMock)); $this->priceInfoMock->expects($this->once()) ->method('getPrice') - ->with($this->equalTo(FinalPrice::PRICE_CODE)) + ->with($this->equalTo(\Magento\Catalog\Pricing\Price\FinalPrice::PRICE_CODE)) ->will($this->returnValue($this->finalPriceMock)); $this->finalPriceMock->expects($this->once()) ->method('getValue') diff --git a/app/code/Magento/Bundle/etc/config.xml b/app/code/Magento/Bundle/etc/config.xml index 45baec43c5ab09a3ea80b77b16e83a02da0e350d..10a14c0aab73d501f8581ba9245116e6b5246df9 100644 --- a/app/code/Magento/Bundle/etc/config.xml +++ b/app/code/Magento/Bundle/etc/config.xml @@ -5,5 +5,5 @@ * See COPYING.txt for license details. */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Core/etc/config.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Store/etc/config.xsd"> </config> diff --git a/app/code/Magento/Bundle/etc/data_object.xml b/app/code/Magento/Bundle/etc/data_object.xml index 2b3da013978f971bb20baca3a5e0ca95f2b501fc..88e317dafc78c8ce9d0c9a3fe6f703b777361e4a 100644 --- a/app/code/Magento/Bundle/etc/data_object.xml +++ b/app/code/Magento/Bundle/etc/data_object.xml @@ -8,5 +8,7 @@ <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Api/etc/data_object.xsd"> <custom_attributes for="Magento\Catalog\Api\Data\ProductInterface"> <attribute code="bundle_product_options" type="Magento\Bundle\Api\Data\OptionInterface[]" /> + <attribute code="price_type" type="integer" /> + <attribute code="price_view" type="string" /> </custom_attributes> </config> diff --git a/app/code/Magento/Bundle/etc/webapi.xml b/app/code/Magento/Bundle/etc/webapi.xml index 36bb8f577597f238c0dce61748b7f33294bdb5a7..ec0dffcf1049e2d29da72bb80d02e8fba97ee316 100644 --- a/app/code/Magento/Bundle/etc/webapi.xml +++ b/app/code/Magento/Bundle/etc/webapi.xml @@ -7,7 +7,7 @@ --> <routes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../app/code/Magento/Webapi/etc/webapi.xsd"> - <route url="/V1/bundle-products/:productSku/links/:optionId" method="POST"> + <route url="/V1/bundle-products/:sku/links/:optionId" method="POST"> <service class="Magento\Bundle\Api\ProductLinkManagementInterface" method="addChildByProductSku"/> <resources> <resource ref="Magento_Catalog::products"/> @@ -19,43 +19,43 @@ <resource ref="Magento_Catalog::products"/> </resources> </route> - <route url="/V1/bundle-products/:productSku/option/:optionId/child/:childSku" method="DELETE"> + <route url="/V1/bundle-products/:sku/options/:optionId/children/:childSku" method="DELETE"> <service class="Magento\Bundle\Api\ProductLinkManagementInterface" method="removeChild"/> <resources> <resource ref="Magento_Catalog::products"/> </resources> </route> - <route url="/V1/bundle-products/:productSku/option/all" method="GET"> + <route url="/V1/bundle-products/:sku/options/all" method="GET"> <service class="Magento\Bundle\Api\ProductOptionRepositoryInterface" method="getList" /> <resources> <resource ref="Magento_Catalog::products" /> </resources> </route> - <route url="/V1/bundle-products/option/types" method="GET"> + <route url="/V1/bundle-products/options/types" method="GET"> <service class="Magento\Bundle\Api\ProductOptionTypeListInterface" method="getItems" /> <resources> <resource ref="Magento_Catalog::products" /> </resources> </route> - <route url="/V1/bundle-products/:productSku/option/:optionId" method="GET"> + <route url="/V1/bundle-products/:sku/options/:optionId" method="GET"> <service class="Magento\Bundle\Api\ProductOptionRepositoryInterface" method="get" /> <resources> <resource ref="Magento_Catalog::products" /> </resources> </route> - <route url="/V1/bundle-products/option/add" method="POST"> + <route url="/V1/bundle-products/options/add" method="POST"> <service class="Magento\Bundle\Api\ProductOptionManagementInterface" method="save" /> <resources> <resource ref="Magento_Catalog::products" /> </resources> </route> - <route url="/V1/bundle-products/option/:optionId" method="PUT"> + <route url="/V1/bundle-products/options/:optionId" method="PUT"> <service class="Magento\Bundle\Api\ProductOptionManagementInterface" method="save" /> <resources> <resource ref="Magento_Catalog::products" /> </resources> </route> - <route url="/V1/bundle-products/:productSku/option/:optionId" method="DELETE"> + <route url="/V1/bundle-products/:sku/options/:optionId" method="DELETE"> <service class="Magento\Bundle\Api\ProductOptionRepositoryInterface" method="deleteById" /> <resources> <resource ref="Magento_Catalog::products" /> diff --git a/app/code/Magento/Captcha/etc/config.xml b/app/code/Magento/Captcha/etc/config.xml index ac0f4486c7456da6bc5e3b0b397d49b326368bcd..8c91d2c706f152873ceedd4c1da7ec8de75531d6 100644 --- a/app/code/Magento/Captcha/etc/config.xml +++ b/app/code/Magento/Captcha/etc/config.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Core/etc/config.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Store/etc/config.xsd"> <default> <system> <media_storage_configuration> diff --git a/app/code/Magento/Catalog/Api/CategoryLinkRepositoryInterface.php b/app/code/Magento/Catalog/Api/CategoryLinkRepositoryInterface.php index d5d2500d4b1777ddbb09f8a4a4fcda67994af507..a84719da120793448d3a12d26d4606755a219f3a 100644 --- a/app/code/Magento/Catalog/Api/CategoryLinkRepositoryInterface.php +++ b/app/code/Magento/Catalog/Api/CategoryLinkRepositoryInterface.php @@ -34,12 +34,12 @@ interface CategoryLinkRepositoryInterface /** * Remove the product assignment from the category by category id and sku * - * @param string $productSku - * @param string $productSku + * @param string $sku + * @param string $sku * @return bool will returned True if products successfully deleted * * @throws \Magento\Framework\Exception\CouldNotSaveException * @throws \Magento\Framework\Exception\StateException */ - public function deleteByIds($categoryId, $productSku); + public function deleteByIds($categoryId, $sku); } diff --git a/app/code/Magento/Catalog/Api/Data/CategoryAttributeInterface.php b/app/code/Magento/Catalog/Api/Data/CategoryAttributeInterface.php index d004784f72e0c5834889b949ba51e9f2e5d15fad..8ea0563b44b9fc26f41bf8385fc0402b1604587b 100644 --- a/app/code/Magento/Catalog/Api/Data/CategoryAttributeInterface.php +++ b/app/code/Magento/Catalog/Api/Data/CategoryAttributeInterface.php @@ -9,6 +9,4 @@ namespace Magento\Catalog\Api\Data; interface CategoryAttributeInterface extends \Magento\Catalog\Api\Data\EavAttributeInterface { const ENTITY_TYPE_CODE = 'catalog_category'; - - const DEFAULT_ATTRIBUTE_SET_ID = 3; } diff --git a/app/code/Magento/Catalog/Api/Data/CategoryInterface.php b/app/code/Magento/Catalog/Api/Data/CategoryInterface.php index fe49eab7d10b1a5e31e3bb7319ec0a14658fc9e8..8ca5780579cf2f6062e9ba8df686e1f0eba56463 100644 --- a/app/code/Magento/Catalog/Api/Data/CategoryInterface.php +++ b/app/code/Magento/Catalog/Api/Data/CategoryInterface.php @@ -8,7 +8,7 @@ namespace Magento\Catalog\Api\Data; -interface CategoryInterface extends \Magento\Framework\Api\ExtensibleDataInterface +interface CategoryInterface extends \Magento\Framework\Api\CustomAttributesDataInterface { /** * @return int|null @@ -149,4 +149,19 @@ interface CategoryInterface extends \Magento\Framework\Api\ExtensibleDataInterfa * @return $this */ public function setIncludeInMenu($includeInMenu); + + /** + * Retrieve existing extension attributes object or create a new one. + * + * @return \Magento\Catalog\Api\Data\CategoryExtensionInterface|null + */ + public function getExtensionAttributes(); + + /** + * Set an extension attributes object. + * + * @param \Magento\Catalog\Api\Data\CategoryExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes(\Magento\Catalog\Api\Data\CategoryExtensionInterface $extensionAttributes); } diff --git a/app/code/Magento/Catalog/Api/Data/CategoryProductLinkInterface.php b/app/code/Magento/Catalog/Api/Data/CategoryProductLinkInterface.php index 04b8f8fe5b7a54c2e3dc4fa3857b7b8db5b9ad8b..ba9b235f9f4032658509039c0b970ae51fb2699d 100644 --- a/app/code/Magento/Catalog/Api/Data/CategoryProductLinkInterface.php +++ b/app/code/Magento/Catalog/Api/Data/CategoryProductLinkInterface.php @@ -6,7 +6,9 @@ namespace Magento\Catalog\Api\Data; -interface CategoryProductLinkInterface +use Magento\Framework\Api\ExtensibleDataInterface; + +interface CategoryProductLinkInterface extends ExtensibleDataInterface { /** * @return string|null @@ -44,4 +46,21 @@ interface CategoryProductLinkInterface * @return $this */ public function setCategoryId($categoryId); + + /** + * Retrieve existing extension attributes object. + * + * @return \Magento\Catalog\Api\Data\CategoryProductLinkExtensionInterface|null + */ + public function getExtensionAttributes(); + + /** + * Set an extension attributes object. + * + * @param \Magento\Catalog\Api\Data\CategoryProductLinkExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes( + \Magento\Catalog\Api\Data\CategoryProductLinkExtensionInterface $extensionAttributes + ); } diff --git a/app/code/Magento/Catalog/Api/Data/CategoryTreeInterface.php b/app/code/Magento/Catalog/Api/Data/CategoryTreeInterface.php index 42f5b2c56edef8d7f18e5e438848538ecb0d10bb..66078497c25e0c479eded4aedea9fe8610a5688e 100644 --- a/app/code/Magento/Catalog/Api/Data/CategoryTreeInterface.php +++ b/app/code/Magento/Catalog/Api/Data/CategoryTreeInterface.php @@ -7,7 +7,7 @@ namespace Magento\Catalog\Api\Data; -interface CategoryTreeInterface extends \Magento\Framework\Api\ExtensibleDataInterface +interface CategoryTreeInterface { /** * @return int|null diff --git a/app/code/Magento/Catalog/Api/Data/EavAttributeInterface.php b/app/code/Magento/Catalog/Api/Data/EavAttributeInterface.php index 02e9c54f2dc400c37bdf46044bd1fcea28cc0824..6fa35baa0f9a8257a9ad6a128477aa9321c5d11c 100644 --- a/app/code/Magento/Catalog/Api/Data/EavAttributeInterface.php +++ b/app/code/Magento/Catalog/Api/Data/EavAttributeInterface.php @@ -275,4 +275,9 @@ interface EavAttributeInterface extends \Magento\Eav\Api\Data\AttributeInterface * @return $this */ public function setScope($scope); + + /** + * @return \Magento\Catalog\Api\Data\EavAttributeExtensionInterface|null + */ + public function getExtensionAttributes(); } diff --git a/app/code/Magento/Catalog/Api/Data/ProductAttributeInterface.php b/app/code/Magento/Catalog/Api/Data/ProductAttributeInterface.php index a6ec3a93a7d2f81c5aec4803515df9525c0a28bb..7ebf031245f8487597af670ed8c88446161c2e8a 100644 --- a/app/code/Magento/Catalog/Api/Data/ProductAttributeInterface.php +++ b/app/code/Magento/Catalog/Api/Data/ProductAttributeInterface.php @@ -9,6 +9,4 @@ namespace Magento\Catalog\Api\Data; interface ProductAttributeInterface extends \Magento\Catalog\Api\Data\EavAttributeInterface { const ENTITY_TYPE_CODE = 'catalog_product'; - - const DEFAULT_ATTRIBUTE_SET_ID = 4; } diff --git a/app/code/Magento/Catalog/Api/Data/ProductAttributeMediaGalleryEntryContentInterface.php b/app/code/Magento/Catalog/Api/Data/ProductAttributeMediaGalleryEntryContentInterface.php index f6651f1caf686750296ee754e5d33b21a69e05d4..ccad19926c342f7a16a46c67897fcac8da48f769 100644 --- a/app/code/Magento/Catalog/Api/Data/ProductAttributeMediaGalleryEntryContentInterface.php +++ b/app/code/Magento/Catalog/Api/Data/ProductAttributeMediaGalleryEntryContentInterface.php @@ -1,13 +1,17 @@ <?php /** - * Product Media Content - * * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ + namespace Magento\Catalog\Api\Data; -interface ProductAttributeMediaGalleryEntryContentInterface +use Magento\Framework\Api\ExtensibleDataInterface; + +/** + * Product Media Content + */ +interface ProductAttributeMediaGalleryEntryContentInterface extends ExtensibleDataInterface { const DATA = 'entry_data'; const MIME_TYPE = 'mime_type'; @@ -57,4 +61,21 @@ interface ProductAttributeMediaGalleryEntryContentInterface * @return $this */ public function setName($name); + + /** + * Retrieve existing extension attributes object. + * + * @return \Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryContentExtensionInterface|null + */ + public function getExtensionAttributes(); + + /** + * Set an extension attributes object. + * + * @param \Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryContentExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes( + \Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryContentExtensionInterface $extensionAttributes + ); } diff --git a/app/code/Magento/Catalog/Api/Data/ProductAttributeMediaGalleryEntryInterface.php b/app/code/Magento/Catalog/Api/Data/ProductAttributeMediaGalleryEntryInterface.php index 1d9a494a8958f04aab057c7a0cb72ebd06dc9107..afac0c209edd87374d0bfbcfd40655e131a0dcc3 100644 --- a/app/code/Magento/Catalog/Api/Data/ProductAttributeMediaGalleryEntryInterface.php +++ b/app/code/Magento/Catalog/Api/Data/ProductAttributeMediaGalleryEntryInterface.php @@ -7,14 +7,17 @@ */ namespace Magento\Catalog\Api\Data; -interface ProductAttributeMediaGalleryEntryInterface +use Magento\Framework\Api\ExtensibleDataInterface; + +interface ProductAttributeMediaGalleryEntryInterface extends ExtensibleDataInterface { const ID = 'id'; const LABEL = 'label'; const POSITION = 'position'; - const DISABLED = 'is_disabled'; + const DISABLED = 'disabled'; const TYPES = 'types'; const FILE = 'file'; + const CONTENT = 'content'; /** * Retrieve gallery entry ID @@ -52,7 +55,7 @@ interface ProductAttributeMediaGalleryEntryInterface * @return int */ public function getPosition(); - + /** * Set gallery entry position (sort order) * @@ -65,17 +68,16 @@ interface ProductAttributeMediaGalleryEntryInterface * Check if gallery entry is hidden from product page * * @return bool - * @SuppressWarnings(PHPMD.BooleanGetMethodName) */ - public function getIsDisabled(); + public function isDisabled(); /** * Set whether gallery entry is hidden from product page * - * @param bool $isDisabled + * @param bool $disabled * @return $this */ - public function setIsDisabled($isDisabled); + public function setDisabled($disabled); /** * Retrieve gallery entry image types (thumbnail, image, small_image etc) @@ -106,4 +108,36 @@ interface ProductAttributeMediaGalleryEntryInterface * @return $this */ public function setFile($file); + + /** + * Get media gallery content + * + * @return \Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryContentInterface|null + */ + public function getContent(); + + /** + * Set media gallery content + * + * @param $content \Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryContentInterface + * @return $this + */ + public function setContent($content); + + /** + * Retrieve existing extension attributes object or create a new one. + * + * @return \Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryExtensionInterface|null + */ + public function getExtensionAttributes(); + + /** + * Set an extension attributes object. + * + * @param \Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes( + \Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryExtensionInterface $extensionAttributes + ); } diff --git a/app/code/Magento/Catalog/Api/Data/ProductAttributeTypeInterface.php b/app/code/Magento/Catalog/Api/Data/ProductAttributeTypeInterface.php index 759f359748a8dcf15d875a9f747cd3c473346391..eebbfb307a252827cc567bd3217d640471222f69 100644 --- a/app/code/Magento/Catalog/Api/Data/ProductAttributeTypeInterface.php +++ b/app/code/Magento/Catalog/Api/Data/ProductAttributeTypeInterface.php @@ -1,12 +1,14 @@ <?php /** - * * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ + namespace Magento\Catalog\Api\Data; -interface ProductAttributeTypeInterface +use Magento\Framework\Api\ExtensibleDataInterface; + +interface ProductAttributeTypeInterface extends ExtensibleDataInterface { const VALUE = 'value'; @@ -41,4 +43,21 @@ interface ProductAttributeTypeInterface * @return $this */ public function setLabel($label); + + /** + * Retrieve existing extension attributes object. + * + * @return \Magento\Catalog\Api\Data\ProductAttributeTypeExtensionInterface|null + */ + public function getExtensionAttributes(); + + /** + * Set an extension attributes object. + * + * @param \Magento\Catalog\Api\Data\ProductAttributeTypeExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes( + \Magento\Catalog\Api\Data\ProductAttributeTypeExtensionInterface $extensionAttributes + ); } diff --git a/app/code/Magento/Catalog/Api/Data/ProductCustomOptionInterface.php b/app/code/Magento/Catalog/Api/Data/ProductCustomOptionInterface.php index 8a2183bf8e8cd61f095b8daf8a6fc97050dd5a9b..352df7305118b354b5a21e560d3bb0a48ace8376 100644 --- a/app/code/Magento/Catalog/Api/Data/ProductCustomOptionInterface.php +++ b/app/code/Magento/Catalog/Api/Data/ProductCustomOptionInterface.php @@ -18,10 +18,10 @@ interface ProductCustomOptionInterface /** * Set product SKU * - * @param string $productSku + * @param string $sku * @return $this */ - public function setProductSku($productSku); + public function setProductSku($sku); /** * Get option id diff --git a/app/code/Magento/Catalog/Api/Data/ProductCustomOptionTypeInterface.php b/app/code/Magento/Catalog/Api/Data/ProductCustomOptionTypeInterface.php index c4f137a0cb355e74c415cf78e9728324d055e795..6a562efc3b0c73326f9d1c9a436325414f77ba72 100644 --- a/app/code/Magento/Catalog/Api/Data/ProductCustomOptionTypeInterface.php +++ b/app/code/Magento/Catalog/Api/Data/ProductCustomOptionTypeInterface.php @@ -6,7 +6,9 @@ namespace Magento\Catalog\Api\Data; -interface ProductCustomOptionTypeInterface +use Magento\Framework\Api\ExtensibleDataInterface; + +interface ProductCustomOptionTypeInterface extends ExtensibleDataInterface { /** * Get option type label @@ -52,4 +54,21 @@ interface ProductCustomOptionTypeInterface * @return $this */ public function setGroup($group); + + /** + * Retrieve existing extension attributes object. + * + * @return \Magento\Catalog\Api\Data\ProductCustomOptionTypeExtensionInterface|null + */ + public function getExtensionAttributes(); + + /** + * Set an extension attributes object. + * + * @param \Magento\Catalog\Api\Data\ProductCustomOptionTypeExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes( + \Magento\Catalog\Api\Data\ProductCustomOptionTypeExtensionInterface $extensionAttributes + ); } diff --git a/app/code/Magento/Catalog/Api/Data/ProductGroupPriceInterface.php b/app/code/Magento/Catalog/Api/Data/ProductGroupPriceInterface.php index 9e2162f41f2439a5e4fa82ddaa70f4293f636465..4c2b9bd80abc1e3bdbc62958d9cd5fd0739798ec 100644 --- a/app/code/Magento/Catalog/Api/Data/ProductGroupPriceInterface.php +++ b/app/code/Magento/Catalog/Api/Data/ProductGroupPriceInterface.php @@ -6,7 +6,9 @@ */ namespace Magento\Catalog\Api\Data; -interface ProductGroupPriceInterface +use Magento\Framework\Api\ExtensibleDataInterface; + +interface ProductGroupPriceInterface extends ExtensibleDataInterface { /** * Retrieve customer group id @@ -37,4 +39,21 @@ interface ProductGroupPriceInterface * @return $this */ public function setValue($value); + + /** + * Retrieve existing extension attributes object. + * + * @return \Magento\Catalog\Api\Data\ProductGroupPriceExtensionInterface|null + */ + public function getExtensionAttributes(); + + /** + * Set an extension attributes object. + * + * @param \Magento\Catalog\Api\Data\ProductGroupPriceExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes( + \Magento\Catalog\Api\Data\ProductGroupPriceExtensionInterface $extensionAttributes + ); } diff --git a/app/code/Magento/Catalog/Api/Data/ProductInterface.php b/app/code/Magento/Catalog/Api/Data/ProductInterface.php index b0021ca89cdfa04e3e126784bad1f08dd460fb0b..34eed7fdf7bab210c1ff8c75a6690973bcc1cbca 100644 --- a/app/code/Magento/Catalog/Api/Data/ProductInterface.php +++ b/app/code/Magento/Catalog/Api/Data/ProductInterface.php @@ -7,7 +7,7 @@ namespace Magento\Catalog\Api\Data; -interface ProductInterface extends \Magento\Framework\Api\ExtensibleDataInterface +interface ProductInterface extends \Magento\Framework\Api\CustomAttributesDataInterface { /**#@+ * Constants defined for keys of data array @@ -214,4 +214,19 @@ interface ProductInterface extends \Magento\Framework\Api\ExtensibleDataInterfac * @return $this */ public function setWeight($weight); + + /** + * Retrieve existing extension attributes object or create a new one. + * + * @return \Magento\Catalog\Api\Data\ProductExtensionInterface|null + */ + public function getExtensionAttributes(); + + /** + * Set an extension attributes object. + * + * @param \Magento\Catalog\Api\Data\ProductExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes(\Magento\Catalog\Api\Data\ProductExtensionInterface $extensionAttributes); } diff --git a/app/code/Magento/Catalog/Api/Data/ProductLinkAttributeInterface.php b/app/code/Magento/Catalog/Api/Data/ProductLinkAttributeInterface.php index 794d60b99b6c9d793e2ad957474b7152cbbf0938..bad462ff801c942b967308d12e30c5a68199a66c 100644 --- a/app/code/Magento/Catalog/Api/Data/ProductLinkAttributeInterface.php +++ b/app/code/Magento/Catalog/Api/Data/ProductLinkAttributeInterface.php @@ -6,7 +6,9 @@ namespace Magento\Catalog\Api\Data; -interface ProductLinkAttributeInterface +use Magento\Framework\Api\ExtensibleDataInterface; + +interface ProductLinkAttributeInterface extends ExtensibleDataInterface { /** * Get attribute code @@ -37,4 +39,21 @@ interface ProductLinkAttributeInterface * @return $this */ public function setType($type); + + /** + * Retrieve existing extension attributes object. + * + * @return \Magento\Catalog\Api\Data\ProductLinkAttributeExtensionInterface|null + */ + public function getExtensionAttributes(); + + /** + * Set an extension attributes object. + * + * @param \Magento\Catalog\Api\Data\ProductLinkAttributeExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes( + \Magento\Catalog\Api\Data\ProductLinkAttributeExtensionInterface $extensionAttributes + ); } diff --git a/app/code/Magento/Catalog/Api/Data/ProductLinkInterface.php b/app/code/Magento/Catalog/Api/Data/ProductLinkInterface.php index ddf61179c1507b0b18198a09bf7694eb31265946..7a19d3c465a4b77d79b910e641c4333193c74e0e 100644 --- a/app/code/Magento/Catalog/Api/Data/ProductLinkInterface.php +++ b/app/code/Magento/Catalog/Api/Data/ProductLinkInterface.php @@ -18,10 +18,10 @@ interface ProductLinkInterface extends \Magento\Framework\Api\ExtensibleDataInte /** * Set product SKU * - * @param string $productSku + * @param string $sku * @return $this */ - public function setProductSku($productSku); + public function setProductSku($sku); /** * Get link type @@ -82,4 +82,21 @@ interface ProductLinkInterface extends \Magento\Framework\Api\ExtensibleDataInte * @return $this */ public function setPosition($position); + + /** + * Retrieve existing extension attributes object or create a new one. + * + * @return \Magento\Catalog\Api\Data\ProductLinkExtensionInterface|null + */ + public function getExtensionAttributes(); + + /** + * Set an extension attributes object. + * + * @param \Magento\Catalog\Api\Data\ProductLinkExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes( + \Magento\Catalog\Api\Data\ProductLinkExtensionInterface $extensionAttributes + ); } diff --git a/app/code/Magento/Catalog/Api/Data/ProductLinkTypeInterface.php b/app/code/Magento/Catalog/Api/Data/ProductLinkTypeInterface.php index 617f9cde2c1ebad2ff2f71c6a54c4b79c590e462..a5863c09f5f099eb772b9412423523496e87c1b8 100644 --- a/app/code/Magento/Catalog/Api/Data/ProductLinkTypeInterface.php +++ b/app/code/Magento/Catalog/Api/Data/ProductLinkTypeInterface.php @@ -6,7 +6,9 @@ namespace Magento\Catalog\Api\Data; -interface ProductLinkTypeInterface +use Magento\Framework\Api\ExtensibleDataInterface; + +interface ProductLinkTypeInterface extends ExtensibleDataInterface { /** * Get link type code @@ -37,4 +39,21 @@ interface ProductLinkTypeInterface * @return $this */ public function setName($name); + + /** + * Retrieve existing extension attributes object. + * + * @return \Magento\Catalog\Api\Data\ProductLinkTypeExtensionInterface|null + */ + public function getExtensionAttributes(); + + /** + * Set an extension attributes object. + * + * @param \Magento\Catalog\Api\Data\ProductLinkTypeExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes( + \Magento\Catalog\Api\Data\ProductLinkTypeExtensionInterface $extensionAttributes + ); } diff --git a/app/code/Magento/Catalog/Api/Data/ProductTierPriceInterface.php b/app/code/Magento/Catalog/Api/Data/ProductTierPriceInterface.php index ee7f92d622bb929128188ce385137db23a43f5e5..bee553af0f504824cb8c85b50d2a4c0fa485f9fe 100644 --- a/app/code/Magento/Catalog/Api/Data/ProductTierPriceInterface.php +++ b/app/code/Magento/Catalog/Api/Data/ProductTierPriceInterface.php @@ -7,10 +7,12 @@ namespace Magento\Catalog\Api\Data; +use Magento\Framework\Api\ExtensibleDataInterface; + /** * @todo remove this interface if framework support return array */ -interface ProductTierPriceInterface +interface ProductTierPriceInterface extends ExtensibleDataInterface { const QTY = 'qty'; @@ -45,4 +47,21 @@ interface ProductTierPriceInterface * @return $this */ public function setValue($value); + + /** + * Retrieve existing extension attributes object. + * + * @return \Magento\Catalog\Api\Data\ProductTierPriceExtensionInterface|null + */ + public function getExtensionAttributes(); + + /** + * Set an extension attributes object. + * + * @param \Magento\Catalog\Api\Data\ProductTierPriceExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes( + \Magento\Catalog\Api\Data\ProductTierPriceExtensionInterface $extensionAttributes + ); } diff --git a/app/code/Magento/Catalog/Api/Data/ProductTypeInterface.php b/app/code/Magento/Catalog/Api/Data/ProductTypeInterface.php index 0d888145c3fd6db515c5d92f22d9512c84b598a1..50599c36231e1b74611c1c1238d05c541627b53f 100644 --- a/app/code/Magento/Catalog/Api/Data/ProductTypeInterface.php +++ b/app/code/Magento/Catalog/Api/Data/ProductTypeInterface.php @@ -1,13 +1,17 @@ <?php /** - * Product type details - * * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ + namespace Magento\Catalog\Api\Data; -interface ProductTypeInterface +use Magento\Framework\Api\ExtensibleDataInterface; + +/** + * Product type details + */ +interface ProductTypeInterface extends ExtensibleDataInterface { /** * Get product type code @@ -38,4 +42,21 @@ interface ProductTypeInterface * @return $this */ public function setLabel($label); + + /** + * Retrieve existing extension attributes object. + * + * @return \Magento\Catalog\Api\Data\ProductTypeExtensionInterface|null + */ + public function getExtensionAttributes(); + + /** + * Set an extension attributes object. + * + * @param \Magento\Catalog\Api\Data\ProductTypeExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes( + \Magento\Catalog\Api\Data\ProductTypeExtensionInterface $extensionAttributes + ); } diff --git a/app/code/Magento/Catalog/Api/ProductAttributeMediaGalleryManagementInterface.php b/app/code/Magento/Catalog/Api/ProductAttributeMediaGalleryManagementInterface.php index c0e4cd9b0d8fc44291a8f75f1bb2f3850cda35fa..2dfe8e5a30976dfeb65d37dd337bf73382d81093 100644 --- a/app/code/Magento/Catalog/Api/ProductAttributeMediaGalleryManagementInterface.php +++ b/app/code/Magento/Catalog/Api/ProductAttributeMediaGalleryManagementInterface.php @@ -16,26 +16,18 @@ interface ProductAttributeMediaGalleryManagementInterface /** * Create new gallery entry * - * @param string $productSku - * @param \Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface $entry - * @param \Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryContentInterface $entryContent - * @param int $storeId + * @param \Magento\Catalog\Api\Data\ProductInterface $product * @return int gallery entry ID * @throws \Magento\Framework\Exception\InputException * @throws \Magento\Framework\Exception\NoSuchEntityException * @throws \Magento\Framework\Exception\StateException */ - public function create( - $productSku, - \Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface $entry, - \Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryContentInterface $entryContent, - $storeId = 0 - ); + public function create($product); /** * Update gallery entry * - * @param string $productSku + * @param string $sku * @param \Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface $entry * @param int $storeId * @return bool @@ -43,7 +35,7 @@ interface ProductAttributeMediaGalleryManagementInterface * @throws \Magento\Framework\Exception\StateException */ public function update( - $productSku, + $sku, \Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface $entry, $storeId = 0 ); @@ -51,29 +43,29 @@ interface ProductAttributeMediaGalleryManagementInterface /** * Remove gallery entry * - * @param string $productSku + * @param string $sku * @param int $entryId * @return bool * @throws \Magento\Framework\Exception\NoSuchEntityException * @throws \Magento\Framework\Exception\StateException */ - public function remove($productSku, $entryId); + public function remove($sku, $entryId); /** * Return information about gallery entry * - * @param string $productSku + * @param string $sku * @param int $imageId * @throws \Magento\Framework\Exception\NoSuchEntityException * @return \Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface */ - public function get($productSku, $imageId); + public function get($sku, $imageId); /** * Retrieve the list of gallery entries associated with given product * - * @param string $productSku + * @param string $sku * @return \Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface[] */ - public function getList($productSku); + public function getList($sku); } diff --git a/app/code/Magento/Catalog/Api/ProductCustomOptionRepositoryInterface.php b/app/code/Magento/Catalog/Api/ProductCustomOptionRepositoryInterface.php index 1b2329931b1a9dceb34256716b58aad2c548e9a8..50b45a3b3dc8b283eaf8ea6431fb365814461b83 100644 --- a/app/code/Magento/Catalog/Api/ProductCustomOptionRepositoryInterface.php +++ b/app/code/Magento/Catalog/Api/ProductCustomOptionRepositoryInterface.php @@ -11,19 +11,19 @@ interface ProductCustomOptionRepositoryInterface /** * Get the list of custom options for a specific product * - * @param string $productSku + * @param string $sku * @return \Magento\Catalog\Api\Data\ProductCustomOptionInterface[] */ - public function getList($productSku); + public function getList($sku); /** * Get custom option for a specific product * - * @param string $productSku + * @param string $sku * @param int $optionId * @return \Magento\Catalog\Api\Data\ProductCustomOptionInterface */ - public function get($productSku, $optionId); + public function get($sku, $optionId); /** * Delete custom option from product @@ -42,9 +42,9 @@ interface ProductCustomOptionRepositoryInterface public function save(\Magento\Catalog\Api\Data\ProductCustomOptionInterface $option); /** - * @param string $productSku + * @param string $sku * @param int $optionId * @return bool */ - public function deleteByIdentifier($productSku, $optionId); + public function deleteByIdentifier($sku, $optionId); } diff --git a/app/code/Magento/Catalog/Api/ProductGroupPriceManagementInterface.php b/app/code/Magento/Catalog/Api/ProductGroupPriceManagementInterface.php index 7278ab50c342f3493457210e665a2cac4e2b5303..bbe7fdc66fd87a18b69c7b80658b96edc30b4a2a 100644 --- a/app/code/Magento/Catalog/Api/ProductGroupPriceManagementInterface.php +++ b/app/code/Magento/Catalog/Api/ProductGroupPriceManagementInterface.php @@ -12,32 +12,32 @@ interface ProductGroupPriceManagementInterface /** * Set group price for product * - * @param string $productSku + * @param string $sku * @param int $customerGroupId * @param float $price * @return boolean * @throws \Magento\Framework\Exception\NoSuchEntityException * @throws \Magento\Framework\Exception\CouldNotSaveException */ - public function add($productSku, $customerGroupId, $price); + public function add($sku, $customerGroupId, $price); /** * Remove group price from product * - * @param string $productSku + * @param string $sku * @param int $customerGroupId * @return boolean * @throws \Magento\Framework\Exception\NoSuchEntityException * @throws \Magento\Framework\Exception\CouldNotSaveException */ - public function remove($productSku, $customerGroupId); + public function remove($sku, $customerGroupId); /** * Retrieve list of product prices * - * @param string $productSku + * @param string $sku * @return \Magento\Catalog\Api\Data\ProductGroupPriceInterface[] * @throws \Magento\Framework\Exception\NoSuchEntityException */ - public function getList($productSku); + public function getList($sku); } diff --git a/app/code/Magento/Catalog/Api/ProductLinkManagementInterface.php b/app/code/Magento/Catalog/Api/ProductLinkManagementInterface.php index 3daf804de0af0c205a3ac4d02cd91006e99ea45c..ee2ef0f062eab8ea68eea1fa9045272deb4f18e3 100644 --- a/app/code/Magento/Catalog/Api/ProductLinkManagementInterface.php +++ b/app/code/Magento/Catalog/Api/ProductLinkManagementInterface.php @@ -11,21 +11,21 @@ interface ProductLinkManagementInterface /** * Provide the list of links for a specific product * - * @param string $productSku + * @param string $sku * @param string $type * @return \Magento\Catalog\Api\Data\ProductLinkInterface[] */ - public function getLinkedItemsByType($productSku, $type); + public function getLinkedItemsByType($sku, $type); /** * Assign a product link to another product * - * @param string $productSku + * @param string $sku * @param string $type * @param \Magento\Catalog\Api\Data\ProductLinkInterface[] $items * @throws \Magento\Framework\Exception\NoSuchEntityException * @throws \Magento\Framework\Exception\CouldNotSaveException * @return bool */ - public function setProductLinks($productSku, $type, array $items); + public function setProductLinks($sku, $type, array $items); } diff --git a/app/code/Magento/Catalog/Api/ProductLinkRepositoryInterface.php b/app/code/Magento/Catalog/Api/ProductLinkRepositoryInterface.php index 6af76811e585739e6e9469f82eabfcc3f4fcbef3..7b4d79d902b25835e6a28d09bb8622deef61f89f 100644 --- a/app/code/Magento/Catalog/Api/ProductLinkRepositoryInterface.php +++ b/app/code/Magento/Catalog/Api/ProductLinkRepositoryInterface.php @@ -32,12 +32,12 @@ interface ProductLinkRepositoryInterface public function delete(\Magento\Catalog\Api\Data\ProductLinkInterface $entity); /** - * @param string $productSku + * @param string $sku * @param string $type * @param string $linkedProductSku * @throws \Magento\Framework\Exception\NoSuchEntityException * @throws \Magento\Framework\Exception\CouldNotSaveException * @return bool */ - public function deleteById($productSku, $type, $linkedProductSku); + public function deleteById($sku, $type, $linkedProductSku); } diff --git a/app/code/Magento/Catalog/Api/ProductRepositoryInterface.php b/app/code/Magento/Catalog/Api/ProductRepositoryInterface.php index bad476db4bc439ebe7fac316453722a6b30be650..8205f68fca6095f9d516c01f5ad04be1a8515725 100644 --- a/app/code/Magento/Catalog/Api/ProductRepositoryInterface.php +++ b/app/code/Magento/Catalog/Api/ProductRepositoryInterface.php @@ -24,13 +24,13 @@ interface ProductRepositoryInterface /** * Get info about product by product SKU * - * @param string $productSku + * @param string $sku * @param bool $editMode * @param null|int $storeId * @return \Magento\Catalog\Api\Data\ProductInterface * @throws \Magento\Framework\Exception\NoSuchEntityException */ - public function get($productSku, $editMode = false, $storeId = null); + public function get($sku, $editMode = false, $storeId = null); /** * Get info about product by product id @@ -53,12 +53,12 @@ interface ProductRepositoryInterface public function delete(\Magento\Catalog\Api\Data\ProductInterface $product); /** - * @param string $productSku + * @param string $sku * @return bool Will returned True if deleted * @throws \Magento\Framework\Exception\NoSuchEntityException * @throws \Magento\Framework\Exception\StateException */ - public function deleteById($productSku); + public function deleteById($sku); /** * Get product list diff --git a/app/code/Magento/Catalog/Api/ProductTierPriceManagementInterface.php b/app/code/Magento/Catalog/Api/ProductTierPriceManagementInterface.php index 1f9dea7edc06e66a7bd0d09ab747867b9fc159db..c8e3a5361e72acfe0ca9e68ac64ed934037e52df 100644 --- a/app/code/Magento/Catalog/Api/ProductTierPriceManagementInterface.php +++ b/app/code/Magento/Catalog/Api/ProductTierPriceManagementInterface.php @@ -11,7 +11,7 @@ interface ProductTierPriceManagementInterface /** * Create tier price for product * - * @param string $productSku + * @param string $sku * @param string $customerGroupId * @param float $price * @param float $qty @@ -19,27 +19,27 @@ interface ProductTierPriceManagementInterface * @throws \Magento\Framework\Exception\NoSuchEntityException * @throws \Magento\Framework\Exception\CouldNotSaveException */ - public function add($productSku, $customerGroupId, $price, $qty); + public function add($sku, $customerGroupId, $price, $qty); /** * Remove tire price from product * - * @param string $productSku + * @param string $sku * @param string $customerGroupId * @param float $qty * @return boolean * @throws \Magento\Framework\Exception\NoSuchEntityException * @throws \Magento\Framework\Exception\CouldNotSaveException */ - public function remove($productSku, $customerGroupId, $qty); + public function remove($sku, $customerGroupId, $qty); /** * Get tire price of product * - * @param string $productSku + * @param string $sku * @param string $customerGroupId * @return \Magento\Catalog\Api\Data\ProductTierPriceInterface[] * @throws \Magento\Framework\Exception\NoSuchEntityException */ - public function getList($productSku, $customerGroupId); + public function getList($sku, $customerGroupId); } diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Category/CategoriesJson.php b/app/code/Magento/Catalog/Controller/Adminhtml/Category/CategoriesJson.php index d8bb23af05313da1f5ca6e4712f49aa0b6c9af97..5fec84fb27a853f3eccfccab7abd20425672dd7f 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Category/CategoriesJson.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Category/CategoriesJson.php @@ -9,7 +9,7 @@ namespace Magento\Catalog\Controller\Adminhtml\Category; class CategoriesJson extends \Magento\Catalog\Controller\Adminhtml\Category { /** - * @var \Magento\Framework\Controller\Result\JSONFactory + * @var \Magento\Framework\Controller\Result\JsonFactory */ protected $resultJsonFactory; @@ -21,13 +21,13 @@ class CategoriesJson extends \Magento\Catalog\Controller\Adminhtml\Category /** * @param \Magento\Backend\App\Action\Context $context * @param \Magento\Backend\Model\View\Result\RedirectFactory $resultRedirectFactory - * @param \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory + * @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory * @param \Magento\Framework\View\LayoutFactory $layoutFactory */ public function __construct( \Magento\Backend\App\Action\Context $context, \Magento\Backend\Model\View\Result\RedirectFactory $resultRedirectFactory, - \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory, + \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory, \Magento\Framework\View\LayoutFactory $layoutFactory ) { parent::__construct($context, $resultRedirectFactory); @@ -57,7 +57,7 @@ class CategoriesJson extends \Magento\Catalog\Controller\Adminhtml\Category $resultRedirect = $this->resultRedirectFactory->create(); return $resultRedirect->setPath('catalog/*/', ['_current' => true, 'id' => null]); } - /** @var \Magento\Framework\Controller\Result\JSON $resultJson */ + /** @var \Magento\Framework\Controller\Result\Json $resultJson */ $resultJson = $this->resultJsonFactory->create(); return $resultJson->setJsonData( $this->layoutFactory->create()->createBlock('Magento\Catalog\Block\Adminhtml\Category\Tree') diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Category/Edit.php b/app/code/Magento/Catalog/Controller/Adminhtml/Category/Edit.php index f6b54278aa3eabc0a117ebf45ad491337a5fe39a..0d0b763cfec6bc93832e2ebd25fff308328a3030 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Category/Edit.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Category/Edit.php @@ -9,7 +9,7 @@ namespace Magento\Catalog\Controller\Adminhtml\Category; class Edit extends \Magento\Catalog\Controller\Adminhtml\Category { /** - * @var \Magento\Framework\Controller\Result\JSONFactory + * @var \Magento\Framework\Controller\Result\JsonFactory */ protected $resultJsonFactory; @@ -22,13 +22,13 @@ class Edit extends \Magento\Catalog\Controller\Adminhtml\Category * @param \Magento\Backend\App\Action\Context $context * @param \Magento\Backend\Model\View\Result\RedirectFactory $resultRedirectFactory * @param \Magento\Framework\View\Result\PageFactory $resultPageFactory - * @param \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory + * @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory */ public function __construct( \Magento\Backend\App\Action\Context $context, \Magento\Backend\Model\View\Result\RedirectFactory $resultRedirectFactory, \Magento\Framework\View\Result\PageFactory $resultPageFactory, - \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory + \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory ) { parent::__construct($context, $resultRedirectFactory); $this->resultPageFactory = $resultPageFactory; @@ -106,7 +106,7 @@ class Edit extends \Magento\Catalog\Controller\Adminhtml\Category 'category_prepare_ajax_response', ['response' => $eventResponse, 'controller' => $this] ); - /** @var \Magento\Framework\Controller\Result\JSON $resultJson */ + /** @var \Magento\Framework\Controller\Result\Json $resultJson */ $resultJson = $this->resultJsonFactory->create(); $resultJson->setHeader('Content-type', 'application/json', true); $resultJson->setData($eventResponse->getData()); diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Category/Move.php b/app/code/Magento/Catalog/Controller/Adminhtml/Category/Move.php index 4a1fc8d7ea995ab2f132402f6b048e33f5aed705..c35247eaacf7946444fb1fa0d89f1a47ff8a8a86 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Category/Move.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Category/Move.php @@ -9,7 +9,7 @@ namespace Magento\Catalog\Controller\Adminhtml\Category; class Move extends \Magento\Catalog\Controller\Adminhtml\Category { /** - * @var \Magento\Framework\Controller\Result\JSONFactory + * @var \Magento\Framework\Controller\Result\JsonFactory */ protected $resultJsonFactory; @@ -26,14 +26,14 @@ class Move extends \Magento\Catalog\Controller\Adminhtml\Category /** * @param \Magento\Backend\App\Action\Context $context * @param \Magento\Backend\Model\View\Result\RedirectFactory $resultRedirectFactory - * @param \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory + * @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory * @param \Magento\Framework\View\LayoutFactory $layoutFactory, * @param \Psr\Log\LoggerInterface $logger, */ public function __construct( \Magento\Backend\App\Action\Context $context, \Magento\Backend\Model\View\Result\RedirectFactory $resultRedirectFactory, - \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory, + \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory, \Magento\Framework\View\LayoutFactory $layoutFactory, \Psr\Log\LoggerInterface $logger ) { diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Category/RefreshPath.php b/app/code/Magento/Catalog/Controller/Adminhtml/Category/RefreshPath.php index 8f1af886e441e14b83b43c7a71d459eefc359d2c..8b19840c3c083f0b8ec8554d7f48eb2133849583 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Category/RefreshPath.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Category/RefreshPath.php @@ -9,19 +9,19 @@ namespace Magento\Catalog\Controller\Adminhtml\Category; class RefreshPath extends \Magento\Catalog\Controller\Adminhtml\Category { /** - * @var \Magento\Framework\Controller\Result\JSONFactory + * @var \Magento\Framework\Controller\Result\JsonFactory */ protected $resultJsonFactory; /** * @param \Magento\Backend\App\Action\Context $context * @param \Magento\Backend\Model\View\Result\RedirectFactory $resultRedirectFactory - * @param \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory + * @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory */ public function __construct( \Magento\Backend\App\Action\Context $context, \Magento\Backend\Model\View\Result\RedirectFactory $resultRedirectFactory, - \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory + \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory ) { parent::__construct($context, $resultRedirectFactory); $this->resultJsonFactory = $resultJsonFactory; @@ -30,7 +30,7 @@ class RefreshPath extends \Magento\Catalog\Controller\Adminhtml\Category /** * Build response for refresh input element 'path' in form * - * @return \Magento\Framework\Controller\Result\JSON + * @return \Magento\Framework\Controller\Result\Json */ public function execute() { @@ -38,7 +38,7 @@ class RefreshPath extends \Magento\Catalog\Controller\Adminhtml\Category if ($categoryId) { $category = $this->_objectManager->create('Magento\Catalog\Model\Category')->load($categoryId); - /** @var \Magento\Framework\Controller\Result\JSON $resultJson */ + /** @var \Magento\Framework\Controller\Result\Json $resultJson */ $resultJson = $this->resultJsonFactory->create(); return $resultJson->setData(['id' => $categoryId, 'path' => $category->getPath()]); } diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Category/Save.php b/app/code/Magento/Catalog/Controller/Adminhtml/Category/Save.php index 92b1f5609332922b96e14e3ef1cb8f6883ed97ff..01f622f6996f39a791fa04ebc25eb16c4bce79a9 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Category/Save.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Category/Save.php @@ -16,7 +16,7 @@ class Save extends \Magento\Catalog\Controller\Adminhtml\Category protected $resultRawFactory; /** - * @var \Magento\Framework\Controller\Result\JSONFactory + * @var \Magento\Framework\Controller\Result\JsonFactory */ protected $resultJsonFactory; @@ -31,14 +31,14 @@ class Save extends \Magento\Catalog\Controller\Adminhtml\Category * @param \Magento\Backend\App\Action\Context $context * @param \Magento\Backend\Model\View\Result\RedirectFactory $resultRedirectFactory * @param \Magento\Framework\Controller\Result\RawFactory $resultRawFactory - * @param \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory + * @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory * @param \Magento\Framework\View\LayoutFactory $layoutFactory */ public function __construct( \Magento\Backend\App\Action\Context $context, \Magento\Backend\Model\View\Result\RedirectFactory $resultRedirectFactory, \Magento\Framework\Controller\Result\RawFactory $resultRawFactory, - \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory, + \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory, \Magento\Framework\View\LayoutFactory $layoutFactory ) { parent::__construct($context, $resultRedirectFactory); @@ -153,7 +153,7 @@ class Save extends \Magento\Catalog\Controller\Adminhtml\Category __('Attribute "%1" is required.', $attribute) ); } else { - throw new \Magento\Framework\Exception\LocalizedException($error); + throw new \Magento\Framework\Exception\LocalizedException(__($error)); } } } @@ -180,7 +180,7 @@ class Save extends \Magento\Catalog\Controller\Adminhtml\Category $block = $this->layoutFactory->create()->getMessagesBlock(); $block->setMessages($this->messageManager->getMessages(true)); - /** @var \Magento\Framework\Controller\Result\JSON $resultJson */ + /** @var \Magento\Framework\Controller\Result\Json $resultJson */ $resultJson = $this->resultJsonFactory->create(); return $resultJson->setData( [ diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Category/SuggestCategories.php b/app/code/Magento/Catalog/Controller/Adminhtml/Category/SuggestCategories.php index 800a4726e96cd3be2f2fde25ff701b82f72b4a47..14d7bf780c053563758b86b5e8cd39a8fa3b519c 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Category/SuggestCategories.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Category/SuggestCategories.php @@ -9,7 +9,7 @@ namespace Magento\Catalog\Controller\Adminhtml\Category; class SuggestCategories extends \Magento\Catalog\Controller\Adminhtml\Category { /** - * @var \Magento\Framework\Controller\Result\JSONFactory + * @var \Magento\Framework\Controller\Result\JsonFactory */ protected $resultJsonFactory; @@ -21,13 +21,13 @@ class SuggestCategories extends \Magento\Catalog\Controller\Adminhtml\Category /** * @param \Magento\Backend\App\Action\Context $context * @param \Magento\Backend\Model\View\Result\RedirectFactory $resultRedirectFactory - * @param \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory + * @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory * @param \Magento\Framework\View\LayoutFactory $layoutFactory */ public function __construct( \Magento\Backend\App\Action\Context $context, \Magento\Backend\Model\View\Result\RedirectFactory $resultRedirectFactory, - \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory, + \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory, \Magento\Framework\View\LayoutFactory $layoutFactory ) { parent::__construct($context, $resultRedirectFactory); @@ -38,11 +38,11 @@ class SuggestCategories extends \Magento\Catalog\Controller\Adminhtml\Category /** * Category list suggestion based on already entered symbols * - * @return \Magento\Framework\Controller\Result\JSON + * @return \Magento\Framework\Controller\Result\Json */ public function execute() { - /** @var \Magento\Framework\Controller\Result\JSON $resultJson */ + /** @var \Magento\Framework\Controller\Result\Json $resultJson */ $resultJson = $this->resultJsonFactory->create(); return $resultJson->setJsonData( $this->layoutFactory->create()->createBlock('Magento\Catalog\Block\Adminhtml\Category\Tree') diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Category/Tree.php b/app/code/Magento/Catalog/Controller/Adminhtml/Category/Tree.php index b7410f3ada3ee5558c1c7a1825eee36ac2d3c7aa..6604d3fc116a0b06793eece09e869076c6a663b6 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Category/Tree.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Category/Tree.php @@ -9,7 +9,7 @@ namespace Magento\Catalog\Controller\Adminhtml\Category; class Tree extends \Magento\Catalog\Controller\Adminhtml\Category { /** - * @var \Magento\Framework\Controller\Result\JSONFactory + * @var \Magento\Framework\Controller\Result\JsonFactory */ protected $resultJsonFactory; @@ -21,13 +21,13 @@ class Tree extends \Magento\Catalog\Controller\Adminhtml\Category /** * @param \Magento\Backend\App\Action\Context $context * @param \Magento\Backend\Model\View\Result\RedirectFactory $resultRedirectFactory - * @param \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory + * @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory * @param \Magento\Framework\View\LayoutFactory $layoutFactory */ public function __construct( \Magento\Backend\App\Action\Context $context, \Magento\Backend\Model\View\Result\RedirectFactory $resultRedirectFactory, - \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory, + \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory, \Magento\Framework\View\LayoutFactory $layoutFactory ) { parent::__construct($context, $resultRedirectFactory); @@ -65,7 +65,7 @@ class Tree extends \Magento\Catalog\Controller\Adminhtml\Category $block = $this->layoutFactory->create()->createBlock('Magento\Catalog\Block\Adminhtml\Category\Tree'); $root = $block->getRoot(); - /** @var \Magento\Framework\Controller\Result\JSON $resultJson */ + /** @var \Magento\Framework\Controller\Result\Json $resultJson */ $resultJson = $this->resultJsonFactory->create(); return $resultJson->setData([ 'data' => $block->getTree(), diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Category/Widget/CategoriesJson.php b/app/code/Magento/Catalog/Controller/Adminhtml/Category/Widget/CategoriesJson.php index aeb4186f9118b5cc57ccbfc67b0a22413c9e1951..329f786314fb2f972cdc769f08ef68305c0d469b 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Category/Widget/CategoriesJson.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Category/Widget/CategoriesJson.php @@ -16,20 +16,20 @@ class CategoriesJson extends \Magento\Catalog\Controller\Adminhtml\Category\Widg protected $_coreRegistry; /** - * @var \Magento\Framework\Controller\Result\JSONFactory + * @var \Magento\Framework\Controller\Result\JsonFactory */ protected $resultJsonFactory; /** * @param \Magento\Backend\App\Action\Context $context * @param \Magento\Framework\View\LayoutFactory $layoutFactory - * @param \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory + * @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory * @param \Magento\Framework\Registry $coreRegistry */ public function __construct( \Magento\Backend\App\Action\Context $context, \Magento\Framework\View\LayoutFactory $layoutFactory, - \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory, + \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory, \Magento\Framework\Registry $coreRegistry ) { parent::__construct($context, $layoutFactory); @@ -40,7 +40,7 @@ class CategoriesJson extends \Magento\Catalog\Controller\Adminhtml\Category\Widg /** * Categories tree node (Ajax version) * - * @return \Magento\Framework\Controller\Result\JSON + * @return \Magento\Framework\Controller\Result\Json */ public function execute() { @@ -53,7 +53,7 @@ class CategoriesJson extends \Magento\Catalog\Controller\Adminhtml\Category\Widg $this->_coreRegistry->register('current_category', $category); } $categoryTreeBlock = $this->_getCategoryTreeBlock()->setSelectedCategories(explode(',', $selected)); - /** @var \Magento\Framework\Controller\Result\JSON $resultJson */ + /** @var \Magento\Framework\Controller\Result\Json $resultJson */ $resultJson = $this->resultJsonFactory->create(); return $resultJson->setJsonData($categoryTreeBlock->getTreeJson($category)); } diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Validate.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Validate.php index b487743f5c69934bbb79f375e7c0ade9ab728f10..096e32642cbe2dc2c23148cdc46cb9714e5e885a 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Validate.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Validate.php @@ -9,7 +9,7 @@ namespace Magento\Catalog\Controller\Adminhtml\Product\Action\Attribute; class Validate extends \Magento\Catalog\Controller\Adminhtml\Product\Action\Attribute { /** - * @var \Magento\Framework\Controller\Result\JSONFactory + * @var \Magento\Framework\Controller\Result\JsonFactory */ protected $resultJsonFactory; @@ -21,13 +21,13 @@ class Validate extends \Magento\Catalog\Controller\Adminhtml\Product\Action\Attr /** * @param \Magento\Backend\App\Action\Context $context * @param \Magento\Catalog\Helper\Product\Edit\Action\Attribute $attributeHelper - * @param \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory + * @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory * @param \Magento\Framework\View\LayoutFactory $layoutFactory */ public function __construct( \Magento\Backend\App\Action\Context $context, \Magento\Catalog\Helper\Product\Edit\Action\Attribute $attributeHelper, - \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory, + \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory, \Magento\Framework\View\LayoutFactory $layoutFactory ) { parent::__construct($context, $attributeHelper); diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/AddAttributeToTemplate.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/AddAttributeToTemplate.php index 8f0a3de052a755ba072cbd7064c1d39f1395297a..6cd7b5d2546bfcf7a0761cc902efb9e930ccff21 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/AddAttributeToTemplate.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/AddAttributeToTemplate.php @@ -9,19 +9,19 @@ namespace Magento\Catalog\Controller\Adminhtml\Product; class AddAttributeToTemplate extends \Magento\Catalog\Controller\Adminhtml\Product { /** - * @var \Magento\Framework\Controller\Result\JSONFactory + * @var \Magento\Framework\Controller\Result\JsonFactory */ protected $resultJsonFactory; /** * @param \Magento\Backend\App\Action\Context $context * @param \Magento\Catalog\Controller\Adminhtml\Product\Builder $productBuilder - * @param \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory + * @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory */ public function __construct( \Magento\Backend\App\Action\Context $context, \Magento\Catalog\Controller\Adminhtml\Product\Builder $productBuilder, - \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory + \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory ) { parent::__construct($context, $productBuilder); $this->resultJsonFactory = $resultJsonFactory; @@ -29,7 +29,7 @@ class AddAttributeToTemplate extends \Magento\Catalog\Controller\Adminhtml\Produ /** * Add attribute to product template * - * @return \Magento\Framework\Controller\Result\JSON + * @return \Magento\Framework\Controller\Result\Json */ public function execute() { diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Attribute/Validate.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Attribute/Validate.php index f6b4582d3a882a9e9ab81ffc05ffdf410ccd40e9..4f564351eae2418de9a738ebb50d28348a7c5d96 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Attribute/Validate.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Attribute/Validate.php @@ -9,7 +9,7 @@ namespace Magento\Catalog\Controller\Adminhtml\Product\Attribute; class Validate extends \Magento\Catalog\Controller\Adminhtml\Product\Attribute { /** - * @var \Magento\Framework\Controller\Result\JSONFactory + * @var \Magento\Framework\Controller\Result\JsonFactory */ protected $resultJsonFactory; @@ -25,7 +25,7 @@ class Validate extends \Magento\Catalog\Controller\Adminhtml\Product\Attribute * @param \Magento\Framework\Cache\FrontendInterface $attributeLabelCache * @param \Magento\Framework\Registry $coreRegistry * @param \Magento\Framework\View\Result\PageFactory $resultPageFactory - * @param \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory + * @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory * @param \Magento\Framework\View\LayoutFactory $layoutFactory */ public function __construct( @@ -33,7 +33,7 @@ class Validate extends \Magento\Catalog\Controller\Adminhtml\Product\Attribute \Magento\Framework\Cache\FrontendInterface $attributeLabelCache, \Magento\Framework\Registry $coreRegistry, \Magento\Framework\View\Result\PageFactory $resultPageFactory, - \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory, + \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory, \Magento\Framework\View\LayoutFactory $layoutFactory ) { parent::__construct($context, $attributeLabelCache, $coreRegistry, $resultPageFactory); diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Gallery/Upload.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Gallery/Upload.php index da0208cf65a10a4857df5fdc2dc206d007b7b8f3..507f86a2673ce96ccfc4c3399d31aba7ba4727b7 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Gallery/Upload.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Gallery/Upload.php @@ -11,17 +11,17 @@ use Magento\Framework\App\Filesystem\DirectoryList; class Upload extends \Magento\Backend\App\Action { /** - * @var \Magento\Framework\Controller\Result\JSONFactory + * @var \Magento\Framework\Controller\Result\JsonFactory */ protected $resultJsonFactory; /** * @param \Magento\Backend\App\Action\Context $context - * @param \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory + * @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory */ public function __construct( \Magento\Backend\App\Action\Context $context, - \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory + \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory ) { parent::__construct($context); $this->resultJsonFactory = $resultJsonFactory; @@ -36,7 +36,7 @@ class Upload extends \Magento\Backend\App\Action } /** - * @return \Magento\Framework\Controller\Result\JSON + * @return \Magento\Framework\Controller\Result\Json */ public function execute() { diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/MassStatus.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/MassStatus.php index 09c968830b1e8aeb78e6a6759634efd12e2a872b..26665c88a5f2fef3e5f49a91dee577a14a0e6415 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/MassStatus.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/MassStatus.php @@ -74,7 +74,7 @@ class MassStatus extends \Magento\Catalog\Controller\Adminhtml\Product ->updateAttributes($productIds, ['status' => $status], $storeId); $this->messageManager->addSuccess(__('A total of %1 record(s) have been updated.', count($productIds))); $this->_productPriceIndexerProcessor->reindexList($productIds); - } catch (\Magento\Core\Model\Exception $e) { + } catch (\Magento\Framework\Exception $e) { $this->messageManager->addError($e->getMessage()); } catch (\Magento\Framework\Exception\LocalizedException $e) { $this->messageManager->addError($e->getMessage()); diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Set/Save.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Set/Save.php index 68b77495dda89e6769437d5010e06e2ffc7f981a..5c69eeaf87b0b19ae9206456fa12b1330c7f53eb 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Set/Save.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Set/Save.php @@ -19,7 +19,7 @@ class Save extends \Magento\Catalog\Controller\Adminhtml\Product\Set protected $resultRedirectFactory; /** - * @var \Magento\Framework\Controller\Result\JSONFactory + * @var \Magento\Framework\Controller\Result\JsonFactory */ protected $resultJsonFactory; @@ -28,14 +28,14 @@ class Save extends \Magento\Catalog\Controller\Adminhtml\Product\Set * @param \Magento\Framework\Registry $coreRegistry * @param \Magento\Framework\View\LayoutFactory $layoutFactory * @param \Magento\Backend\Model\View\Result\RedirectFactory $resultRedirectFactory - * @param \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory + * @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory */ public function __construct( \Magento\Backend\App\Action\Context $context, \Magento\Framework\Registry $coreRegistry, \Magento\Framework\View\LayoutFactory $layoutFactory, \Magento\Backend\Model\View\Result\RedirectFactory $resultRedirectFactory, - \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory + \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory ) { parent::__construct($context, $coreRegistry); $this->layoutFactory = $layoutFactory; diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/SuggestAttributes.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/SuggestAttributes.php index 45ca2a12df79d7fe537adf197ade35045c146cdc..6b60c4f74810fc5cc445384205066ba752efe4a5 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/SuggestAttributes.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/SuggestAttributes.php @@ -9,7 +9,7 @@ namespace Magento\Catalog\Controller\Adminhtml\Product; class SuggestAttributes extends \Magento\Catalog\Controller\Adminhtml\Product { /** - * @var \Magento\Framework\Controller\Result\JSONFactory + * @var \Magento\Framework\Controller\Result\JsonFactory */ protected $resultJsonFactory; @@ -21,13 +21,13 @@ class SuggestAttributes extends \Magento\Catalog\Controller\Adminhtml\Product /** * @param \Magento\Backend\App\Action\Context $context * @param \Magento\Catalog\Controller\Adminhtml\Product\Builder $productBuilder - * @param \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory + * @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory * @param \Magento\Framework\View\LayoutFactory $layoutFactory */ public function __construct( \Magento\Backend\App\Action\Context $context, \Magento\Catalog\Controller\Adminhtml\Product\Builder $productBuilder, - \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory, + \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory, \Magento\Framework\View\LayoutFactory $layoutFactory ) { parent::__construct($context, $productBuilder); @@ -38,7 +38,7 @@ class SuggestAttributes extends \Magento\Catalog\Controller\Adminhtml\Product /** * Search for attributes by part of attribute's label in admin store * - * @return \Magento\Framework\Controller\Result\JSON + * @return \Magento\Framework\Controller\Result\Json */ public function execute() { diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/SuggestProductTemplates.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/SuggestProductTemplates.php index 5e883b9f85f0d4e8132a38090556c1e06a59b5f3..72a29b9183088a4f3329ab8054b93d583f2f2286 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/SuggestProductTemplates.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/SuggestProductTemplates.php @@ -9,7 +9,7 @@ namespace Magento\Catalog\Controller\Adminhtml\Product; class SuggestProductTemplates extends \Magento\Catalog\Controller\Adminhtml\Product { /** - * @var \Magento\Framework\Controller\Result\JSONFactory + * @var \Magento\Framework\Controller\Result\JsonFactory */ protected $resultJsonFactory; @@ -21,13 +21,13 @@ class SuggestProductTemplates extends \Magento\Catalog\Controller\Adminhtml\Prod /** * @param \Magento\Backend\App\Action\Context $context * @param \Magento\Catalog\Controller\Adminhtml\Product\Builder $productBuilder - * @param \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory + * @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory * @param \Magento\Framework\View\LayoutFactory $layoutFactory */ public function __construct( \Magento\Backend\App\Action\Context $context, \Magento\Catalog\Controller\Adminhtml\Product\Builder $productBuilder, - \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory, + \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory, \Magento\Framework\View\LayoutFactory $layoutFactory ) { parent::__construct($context, $productBuilder); @@ -38,7 +38,7 @@ class SuggestProductTemplates extends \Magento\Catalog\Controller\Adminhtml\Prod /** * Action for product template selector * - * @return \Magento\Framework\Controller\Result\JSON + * @return \Magento\Framework\Controller\Result\Json */ public function execute() { diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Validate.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Validate.php old mode 100644 new mode 100755 index befec2129c66c23d71061597defe3af86ec77b46..40fb55c7a6626723e2ecd66afe8a16a3f36fb860 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Validate.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Validate.php @@ -9,6 +9,11 @@ namespace Magento\Catalog\Controller\Adminhtml\Product; use Magento\Backend\App\Action; use Magento\Catalog\Controller\Adminhtml\Product; +/** + * Product validate + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class Validate extends \Magento\Catalog\Controller\Adminhtml\Product { /** @@ -22,7 +27,7 @@ class Validate extends \Magento\Catalog\Controller\Adminhtml\Product protected $productValidator; /** - * @var \Magento\Framework\Controller\Result\JSONFactory + * @var \Magento\Framework\Controller\Result\JsonFactory */ protected $resultJsonFactory; @@ -31,33 +36,39 @@ class Validate extends \Magento\Catalog\Controller\Adminhtml\Product */ protected $layoutFactory; + /** @var \Magento\Catalog\Model\ProductFactory */ + protected $productFactory; + /** * @param Action\Context $context * @param Builder $productBuilder * @param \Magento\Framework\Stdlib\DateTime\Filter\Date $dateFilter * @param \Magento\Catalog\Model\Product\Validator $productValidator - * @param \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory + * @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory * @param \Magento\Framework\View\LayoutFactory $layoutFactory + * @param \Magento\Catalog\Model\ProductFactory $productFactory */ public function __construct( \Magento\Backend\App\Action\Context $context, Product\Builder $productBuilder, \Magento\Framework\Stdlib\DateTime\Filter\Date $dateFilter, \Magento\Catalog\Model\Product\Validator $productValidator, - \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory, - \Magento\Framework\View\LayoutFactory $layoutFactory + \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory, + \Magento\Framework\View\LayoutFactory $layoutFactory, + \Magento\Catalog\Model\ProductFactory $productFactory ) { $this->_dateFilter = $dateFilter; $this->productValidator = $productValidator; parent::__construct($context, $productBuilder); $this->resultJsonFactory = $resultJsonFactory; $this->layoutFactory = $layoutFactory; + $this->productFactory = $productFactory; } /** * Validate product * - * @return \Magento\Framework\Controller\Result\JSON + * @return \Magento\Framework\Controller\Result\Json * @SuppressWarnings(PHPMD.CyclomaticComplexity) * @SuppressWarnings(PHPMD.NPathComplexity) */ @@ -73,13 +84,13 @@ class Validate extends \Magento\Catalog\Controller\Adminhtml\Product $productData['stock_data']['use_config_manage_stock'] = 0; } /* @var $product \Magento\Catalog\Model\Product */ - $product = $this->_objectManager->create('Magento\Catalog\Model\Product'); + $product = $this->productFactory->create(); $product->setData('_edit_mode', true); $storeId = $this->getRequest()->getParam('store'); if ($storeId) { $product->setStoreId($storeId); } - $setId = $this->getRequest()->getParam('set'); + $setId = $this->getRequest()->getPost('set'); if ($setId) { $product->setAttributeSetId($setId); } diff --git a/app/code/Magento/Catalog/Helper/Product/Composite.php b/app/code/Magento/Catalog/Helper/Product/Composite.php index 38dc682a4c4ad41264446792c3da7d1aafe40d8d..971d6c6b10de0be0702ade569305c64f53adc400 100644 --- a/app/code/Magento/Catalog/Helper/Product/Composite.php +++ b/app/code/Magento/Catalog/Helper/Product/Composite.php @@ -145,7 +145,7 @@ class Composite extends \Magento\Framework\App\Helper\AbstractHelper { try { if (!$configureResult->getOk()) { - throw new \Magento\Framework\Exception\LocalizedException($configureResult->getMessage()); + throw new \Magento\Framework\Exception\LocalizedException(__($configureResult->getMessage())); } $currentStoreId = (int)$configureResult->getCurrentStoreId(); diff --git a/app/code/Magento/Catalog/Model/AbstractModel.php b/app/code/Magento/Catalog/Model/AbstractModel.php index 19c70245700c41c2c56f1f42aa645ab8a4f23cc5..738a88b5c04c9a1fafbc77c767c1e20e544c3967 100644 --- a/app/code/Magento/Catalog/Model/AbstractModel.php +++ b/app/code/Magento/Catalog/Model/AbstractModel.php @@ -62,7 +62,7 @@ abstract class AbstractModel extends \Magento\Framework\Model\AbstractExtensible /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry - * @param \Magento\Framework\Api\MetadataServiceInterface $metadataService + * @param \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory * @param AttributeValueFactory $customAttributeFactory * @param \Magento\Store\Model\StoreManagerInterface $storeManager * @param \Magento\Framework\Model\Resource\AbstractResource $resource @@ -72,7 +72,7 @@ abstract class AbstractModel extends \Magento\Framework\Model\AbstractExtensible public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, - \Magento\Framework\Api\MetadataServiceInterface $metadataService, + \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory, AttributeValueFactory $customAttributeFactory, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Framework\Model\Resource\AbstractResource $resource = null, @@ -83,7 +83,7 @@ abstract class AbstractModel extends \Magento\Framework\Model\AbstractExtensible parent::__construct( $context, $registry, - $metadataService, + $extensionFactory, $customAttributeFactory, $resource, $resourceCollection, diff --git a/app/code/Magento/Catalog/Model/Category.php b/app/code/Magento/Catalog/Model/Category.php index 2a0519a89d625cfaef579fe6f3bcae92d10573e9..88e82011381c2b1e6a929a191fe2bef1c620d1b6 100644 --- a/app/code/Magento/Catalog/Model/Category.php +++ b/app/code/Magento/Catalog/Model/Category.php @@ -189,12 +189,18 @@ class Category extends \Magento\Catalog\Model\AbstractModel implements */ protected $categoryRepository; + /** + * @var \Magento\Framework\Api\MetadataServiceInterface + */ + protected $metadataService; + /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry - * @param \Magento\Catalog\Api\CategoryAttributeRepositoryInterface $metadataService + * @param \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory * @param AttributeValueFactory $customAttributeFactory * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Catalog\Api\CategoryAttributeRepositoryInterface $metadataService * @param Resource\Category\Tree $categoryTreeResource * @param Resource\Category\TreeFactory $categoryTreeFactory * @param \Magento\Store\Model\Resource\Store\CollectionFactory $storeCollectionFactory @@ -215,9 +221,10 @@ class Category extends \Magento\Catalog\Model\AbstractModel implements public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, - \Magento\Catalog\Api\CategoryAttributeRepositoryInterface $metadataService, + \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory, AttributeValueFactory $customAttributeFactory, \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Catalog\Api\CategoryAttributeRepositoryInterface $metadataService, \Magento\Catalog\Model\Resource\Category\Tree $categoryTreeResource, \Magento\Catalog\Model\Resource\Category\TreeFactory $categoryTreeFactory, \Magento\Store\Model\Resource\Store\CollectionFactory $storeCollectionFactory, @@ -234,6 +241,7 @@ class Category extends \Magento\Catalog\Model\AbstractModel implements \Magento\Framework\Data\Collection\Db $resourceCollection = null, array $data = [] ) { + $this->metadataService = $metadataService; $this->_treeModel = $categoryTreeResource; $this->_categoryTreeFactory = $categoryTreeFactory; $this->_storeCollectionFactory = $storeCollectionFactory; @@ -249,7 +257,7 @@ class Category extends \Magento\Catalog\Model\AbstractModel implements parent::__construct( $context, $registry, - $metadataService, + $extensionFactory, $customAttributeFactory, $storeManager, $resource, @@ -274,6 +282,17 @@ class Category extends \Magento\Catalog\Model\AbstractModel implements } } + /** + * {@inheritdoc} + */ + protected function getCustomAttributesCodes() + { + if ($this->customAttributesCodes === null) { + $this->customAttributesCodes = $this->getEavAttributesCodes($this->metadataService); + } + return $this->customAttributesCodes; + } + /** * Get flat resource model flag * @@ -337,7 +356,6 @@ class Category extends \Magento\Catalog\Model\AbstractModel implements 'Sorry, but we can\'t move the category because we can\'t find the new parent category you' . ' selected.' ), - [], $e ); } @@ -1324,5 +1342,26 @@ class Category extends \Magento\Catalog\Model\AbstractModel implements { return $this->setData(self::KEY_CHILDREN_DATA, $childrenData); } + + /** + * {@inheritdoc} + * + * @return \Magento\Catalog\Api\Data\CategoryExtensionInterface|null + */ + public function getExtensionAttributes() + { + return $this->_getExtensionAttributes(); + } + + /** + * {@inheritdoc} + * + * @param \Magento\Catalog\Api\Data\CategoryExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes(\Magento\Catalog\Api\Data\CategoryExtensionInterface $extensionAttributes) + { + return $this->_setExtensionAttributes($extensionAttributes); + } //@codeCoverageIgnoreEnd } diff --git a/app/code/Magento/Catalog/Model/Category/Attribute.php b/app/code/Magento/Catalog/Model/Category/Attribute.php index 99659b6760e6eb7b4311559fe7be113561c6615d..faf1fbd8c12194e79b04a91ff00c5e5c0d0ac434 100644 --- a/app/code/Magento/Catalog/Model/Category/Attribute.php +++ b/app/code/Magento/Catalog/Model/Category/Attribute.php @@ -5,6 +5,11 @@ */ namespace Magento\Catalog\Model\Category; +/** + * Class Attribute + * + * @method \Magento\Eav\Api\Data\AttributeExtensionInterface getExtensionAttributes() + */ class Attribute extends \Magento\Catalog\Model\Entity\Attribute implements \Magento\Catalog\Api\Data\CategoryAttributeInterface { diff --git a/app/code/Magento/Catalog/Model/Category/AttributeRepository.php b/app/code/Magento/Catalog/Model/Category/AttributeRepository.php index bf52fc7acb6dc2c02ae364cc603460edb96c2d58..38ee0f02fccdd16a5e5aad62b53a71a1429e5e9c 100644 --- a/app/code/Magento/Catalog/Model/Category/AttributeRepository.php +++ b/app/code/Magento/Catalog/Model/Category/AttributeRepository.php @@ -25,21 +25,21 @@ class AttributeRepository implements CategoryAttributeRepositoryInterface protected $eavAttributeRepository; /** - * @param \Magento\Framework\Api\Config\MetadataConfig $metadataConfig * @param \Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder * @param \Magento\Framework\Api\FilterBuilder $filterBuilder * @param \Magento\Eav\Api\AttributeRepositoryInterface $eavAttributeRepository + * @param \Magento\Eav\Model\Config $eavConfig */ public function __construct( - \Magento\Framework\Api\Config\MetadataConfig $metadataConfig, \Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder, \Magento\Framework\Api\FilterBuilder $filterBuilder, - \Magento\Eav\Api\AttributeRepositoryInterface $eavAttributeRepository + \Magento\Eav\Api\AttributeRepositoryInterface $eavAttributeRepository, + \Magento\Eav\Model\Config $eavConfig ) { - $this->metadataConfig = $metadataConfig; $this->searchCriteriaBuilder = $searchCriteriaBuilder; $this->filterBuilder = $filterBuilder; $this->eavAttributeRepository = $eavAttributeRepository; + $this->eavConfig = $eavConfig; } /** @@ -66,24 +66,22 @@ class AttributeRepository implements CategoryAttributeRepositoryInterface /** * {@inheritdoc} + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function getCustomAttributesMetadata($dataObjectClassName = null) { + $defaultAttributeSetId = $this->eavConfig + ->getEntityType(\Magento\Catalog\Api\Data\CategoryAttributeInterface::ENTITY_TYPE_CODE) + ->getDefaultAttributeSetId(); $searchCriteria = $this->searchCriteriaBuilder->addFilter( [ $this->filterBuilder ->setField('attribute_set_id') - ->setValue(\Magento\Catalog\Api\Data\CategoryAttributeInterface::DEFAULT_ATTRIBUTE_SET_ID) + ->setValue($defaultAttributeSetId) ->create(), ] ); - $customAttributes = []; - $entityAttributes = $this->getList($searchCriteria->create())->getItems(); - - foreach ($entityAttributes as $attributeMetadata) { - $customAttributes[] = $attributeMetadata; - } - return array_merge($customAttributes, $this->metadataConfig->getCustomAttributesMetadata($dataObjectClassName)); + return $this->getList($searchCriteria->create())->getItems(); } } diff --git a/app/code/Magento/Catalog/Model/CategoryLinkRepository.php b/app/code/Magento/Catalog/Model/CategoryLinkRepository.php index 23f40ce3c9313bfc06b3cbf9f0f611edb2af5c65..3b407ed5d4b8d9553368ebbb3527516930985639 100644 --- a/app/code/Magento/Catalog/Model/CategoryLinkRepository.php +++ b/app/code/Magento/Catalog/Model/CategoryLinkRepository.php @@ -47,12 +47,12 @@ class CategoryLinkRepository implements \Magento\Catalog\Api\CategoryLinkReposit $category->save(); } catch (\Exception $e) { throw new CouldNotSaveException( - 'Could not save product "%product_id" with position %position to category %category_id', - [ - 'product_id' => $product->getId(), - 'position' => $productLink->getPosition(), - 'category_id' => $category->getId() - ], + __( + 'Could not save product "%1" with position %2 to category %3', + $product->getId(), + $productLink->getPosition(), + $category->getId() + ), $e ); } @@ -70,15 +70,15 @@ class CategoryLinkRepository implements \Magento\Catalog\Api\CategoryLinkReposit /** * {@inheritdoc} */ - public function deleteByIds($categoryId, $productSku) + public function deleteByIds($categoryId, $sku) { $category = $this->categoryRepository->get($categoryId); - $product = $this->productRepository->get($productSku); + $product = $this->productRepository->get($sku); $productPositions = $category->getProductsPosition(); $productID = $product->getId(); if (!isset($productPositions[$productID])) { - throw new InputException('Category does not contain specified product'); + throw new InputException(__('Category does not contain specified product')); } unset($productPositions[$productID]); @@ -87,11 +87,11 @@ class CategoryLinkRepository implements \Magento\Catalog\Api\CategoryLinkReposit $category->save(); } catch (\Exception $e) { throw new CouldNotSaveException( - 'Could not save product "%product_id" with position %position to category %category_id', - [ - 'product_id' => $product->getId(), - 'category_id' => $category->getId() - ], + __( + 'Could not save product "%1" with position %position to category %2', + $product->getId(), + $category->getId() + ), $e ); } diff --git a/app/code/Magento/Catalog/Model/CategoryProductLink.php b/app/code/Magento/Catalog/Model/CategoryProductLink.php index b8912fcf08e7c00f7d42114c258c5842de8040c7..2250d914d58f8e23d25c159ef1c5f9d3459829cf 100644 --- a/app/code/Magento/Catalog/Model/CategoryProductLink.php +++ b/app/code/Magento/Catalog/Model/CategoryProductLink.php @@ -72,4 +72,26 @@ class CategoryProductLink extends \Magento\Framework\Api\AbstractExtensibleObjec { return $this->setData(self::KEY_CATEGORY_ID, $categoryId); } + + /** + * {@inheritdoc} + * + * @return \Magento\Catalog\Api\Data\CategoryProductLinkExtensionInterface|null + */ + public function getExtensionAttributes() + { + return $this->_getExtensionAttributes(); + } + + /** + * {@inheritdoc} + * + * @param \Magento\Catalog\Api\Data\CategoryProductLinkExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes( + \Magento\Catalog\Api\Data\CategoryProductLinkExtensionInterface $extensionAttributes + ) { + return $this->_setExtensionAttributes($extensionAttributes); + } } diff --git a/app/code/Magento/Catalog/Model/CategoryRepository.php b/app/code/Magento/Catalog/Model/CategoryRepository.php index e1fc8c0c2d670313b30e961f5e51dfff09df15c8..6fdba349dd044588c29d85c50372ecf815aa407b 100644 --- a/app/code/Magento/Catalog/Model/CategoryRepository.php +++ b/app/code/Magento/Catalog/Model/CategoryRepository.php @@ -77,6 +77,8 @@ class CategoryRepository implements \Magento\Catalog\Api\CategoryRepositoryInter } else { $parentId = $category->getParentId() ?: $this->storeManager->getStore()->getRootCategoryId(); $parentCategory = $this->get($parentId); + $existingData['include_in_menu'] = + isset($existingData['include_in_menu']) ? (bool)$existingData['include_in_menu'] : false; /** @var $category Category */ $category->setData($existingData); $category->setPath($parentCategory->getPath()); @@ -85,7 +87,13 @@ class CategoryRepository implements \Magento\Catalog\Api\CategoryRepositoryInter $this->validateCategory($category); $this->categoryResource->save($category); } catch (\Exception $e) { - throw new CouldNotSaveException('Could not save category: %message', ['message' => $e->getMessage()], $e); + throw new CouldNotSaveException( + __( + 'Could not save category: %1', + $e->getMessage() + ), + $e + ); } unset($this->instances[$category->getId()]); return $category; @@ -121,10 +129,10 @@ class CategoryRepository implements \Magento\Catalog\Api\CategoryRepositoryInter $this->categoryResource->delete($category); } catch (\Exception $e) { throw new StateException( - 'Cannot delete category with id %category_id', - [ - 'category_id' => $category->getId() - ], + __( + 'Cannot delete category with id %1', + $category->getId() + ), $e ); } @@ -166,7 +174,7 @@ class CategoryRepository implements \Magento\Catalog\Api\CategoryRepositoryInter __('Attribute "%1" is required.', $attribute) ); } else { - throw new \Magento\Framework\Exception\LocalizedException($error); + throw new \Magento\Framework\Exception\LocalizedException(__($error)); } } } diff --git a/app/code/Magento/Catalog/Model/Entity/Attribute.php b/app/code/Magento/Catalog/Model/Entity/Attribute.php index 7ca6107c0518590941e8e2cee3a92cbcd074d60d..da907bde71f75ca5ef9f2147cfc89c3070ef8c41 100644 --- a/app/code/Magento/Catalog/Model/Entity/Attribute.php +++ b/app/code/Magento/Catalog/Model/Entity/Attribute.php @@ -43,6 +43,7 @@ use Magento\Framework\Api\AttributeValueFactory; * @method \Magento\Catalog\Model\Entity\Attribute setIsWysiwygEnabled(int $value) * @method int getIsUsedForPromoRules() * @method \Magento\Catalog\Model\Entity\Attribute setIsUsedForPromoRules(int $value) + * @method \Magento\Eav\Api\Data\AttributeExtensionInterface getExtensionAttributes() * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class Attribute extends \Magento\Eav\Model\Entity\Attribute @@ -71,7 +72,7 @@ class Attribute extends \Magento\Eav\Model\Entity\Attribute /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry - * @param \Magento\Framework\Api\MetadataServiceInterface $metadataService + * @param \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory * @param AttributeValueFactory $customAttributeFactory * @param \Magento\Eav\Model\Config $eavConfig * @param \Magento\Eav\Model\Entity\TypeFactory $eavTypeFactory @@ -93,7 +94,7 @@ class Attribute extends \Magento\Eav\Model\Entity\Attribute public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, - \Magento\Framework\Api\MetadataServiceInterface $metadataService, + \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory, AttributeValueFactory $customAttributeFactory, \Magento\Eav\Model\Config $eavConfig, \Magento\Eav\Model\Entity\TypeFactory $eavTypeFactory, @@ -115,7 +116,7 @@ class Attribute extends \Magento\Eav\Model\Entity\Attribute parent::__construct( $context, $registry, - $metadataService, + $extensionFactory, $customAttributeFactory, $eavConfig, $eavTypeFactory, @@ -145,7 +146,7 @@ class Attribute extends \Magento\Eav\Model\Entity\Attribute try { $this->attrLockValidator->validate($this); } catch (\Magento\Framework\Exception\LocalizedException $exception) { - throw new \Magento\Eav\Exception($exception->getMessage()); + throw new \Magento\Eav\Exception(__($exception->getMessage())); } $this->setData('modulePrefix', self::MODULE_NAME); diff --git a/app/code/Magento/Catalog/Model/Factory.php b/app/code/Magento/Catalog/Model/Factory.php index 5b2298df6a968da6df47bee345d9dd4c434a07fe..96ce8f0b5bc45c89acaa4b1e72057554c1849a88 100644 --- a/app/code/Magento/Catalog/Model/Factory.php +++ b/app/code/Magento/Catalog/Model/Factory.php @@ -43,7 +43,9 @@ class Factory $model = $this->_objectManager->create($className, $data); if (!$model instanceof \Magento\Framework\Model\AbstractModel) { - throw new \Magento\Framework\Exception\LocalizedException($className . ' doesn\'t extends \Magento\Framework\Model\AbstractModel'); + throw new \Magento\Framework\Exception\LocalizedException( + __('%1 doesn\'t extends \Magento\Framework\Model\AbstractModel', $className) + ); } return $model; } diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Flat/Action/Full.php b/app/code/Magento/Catalog/Model/Indexer/Product/Flat/Action/Full.php index b42b312614673a13667ffef2ee9a5a184fceadaa..9860c748d27cdb5fd662e9c76bf7ef120186fc41 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Flat/Action/Full.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Flat/Action/Full.php @@ -28,7 +28,7 @@ class Full extends \Magento\Catalog\Model\Indexer\Product\Flat\AbstractAction $this->_reindex($store->getId()); } } catch (\Exception $e) { - throw new \Magento\Framework\Exception\LocalizedException($e->getMessage(), [], $e); + throw new \Magento\Framework\Exception\LocalizedException(__($e->getMessage()), $e); } return $this; } diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Flat/FlatTableBuilder.php b/app/code/Magento/Catalog/Model/Indexer/Product/Flat/FlatTableBuilder.php index c06d8fc97ad563567e80c00559f190865fba2fc4..9d9170cd291ce83fdf3ea5649c332686f96c8a1c 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Flat/FlatTableBuilder.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Flat/FlatTableBuilder.php @@ -113,9 +113,9 @@ class FlatTableBuilder if ($maxIndex && count($indexesNeed) > $maxIndex) { throw new \Magento\Framework\Exception\LocalizedException( __( - "The Flat Catalog module has a limit of %2\$d filterable and/or sortable attributes." . - "Currently there are %1\$d of them." . - "Please reduce the number of filterable/sortable attributes in order to use this module", + 'The Flat Catalog module has a limit of %2$d filterable and/or sortable attributes.' + . 'Currently there are %1$d of them.' + . 'Please reduce the number of filterable/sortable attributes in order to use this module', count($indexesNeed), $maxIndex ) diff --git a/app/code/Magento/Catalog/Model/Layer.php b/app/code/Magento/Catalog/Model/Layer.php index 2373865b0182f41d5c4c9db43be0d72684cd10a9..38bdfaa7b4772ddc527576a701e4999386cc7f92 100644 --- a/app/code/Magento/Catalog/Model/Layer.php +++ b/app/code/Magento/Catalog/Model/Layer.php @@ -217,7 +217,7 @@ class Layer extends \Magento\Framework\Object try { $category = $this->categoryRepository->get($category); } catch (NoSuchEntityException $e) { - throw new \Magento\Framework\Exception\LocalizedException(__('Please correct the category.'), [], $e); + throw new \Magento\Framework\Exception\LocalizedException(__('Please correct the category.'), $e); } } elseif ($category instanceof \Magento\Catalog\Model\Category) { if (!$category->getId()) { diff --git a/app/code/Magento/Catalog/Model/Layer/Filter/Dynamic/AlgorithmFactory.php b/app/code/Magento/Catalog/Model/Layer/Filter/Dynamic/AlgorithmFactory.php index 9339907d04faeb7f9151b4688d4775b9d3c90a28..ac27484c3bd3ed522833ed11261bfbf0cad7e1d5 100644 --- a/app/code/Magento/Catalog/Model/Layer/Filter/Dynamic/AlgorithmFactory.php +++ b/app/code/Magento/Catalog/Model/Layer/Filter/Dynamic/AlgorithmFactory.php @@ -67,7 +67,7 @@ class AlgorithmFactory $calculationType = $this->scopeConfig->getValue(self::XML_PATH_RANGE_CALCULATION, ScopeInterface::SCOPE_STORE); if (!isset($this->algorithms[$calculationType])) { - throw new LocalizedException($calculationType . ' was not found in algorithms'); + throw new LocalizedException(__('%1 was not found in algorithms', $calculationType)); } $className = $this->algorithms[$calculationType]; @@ -75,7 +75,7 @@ class AlgorithmFactory if (!$model instanceof AlgorithmInterface) { throw new LocalizedException( - $className . ' doesn\'t extends \Magento\Catalog\Model\Layer\Filter\Dynamic\AlgorithmInterface' + __('%1 doesn\'t extend \Magento\Catalog\Model\Layer\Filter\Dynamic\AlgorithmInterface', $className) ); } diff --git a/app/code/Magento/Catalog/Model/Layer/Filter/Factory.php b/app/code/Magento/Catalog/Model/Layer/Filter/Factory.php index fd09131faeb9cbe55fdf7100d9a82a828779f0e0..a86c970d74a3be98c532ce59dc78177c7f07a873 100644 --- a/app/code/Magento/Catalog/Model/Layer/Filter/Factory.php +++ b/app/code/Magento/Catalog/Model/Layer/Filter/Factory.php @@ -42,7 +42,7 @@ class Factory if (!$filter instanceof \Magento\Catalog\Model\Layer\Filter\AbstractFilter) { throw new \Magento\Framework\Exception\LocalizedException( - $className . ' doesn\'t extends \Magento\Catalog\Model\Layer\Filter\AbstractFilter' + __('%1 doesn\'t extends \Magento\Catalog\Model\Layer\Filter\AbstractFilter', $className) ); } return $filter; diff --git a/app/code/Magento/Catalog/Model/Layer/Filter/Item.php b/app/code/Magento/Catalog/Model/Layer/Filter/Item.php index 70977d63008307aedd4bd7ce2d5dca57648f3172..3ac15cc5cd688738d9bd9c257a7000cdd8ebd36f 100644 --- a/app/code/Magento/Catalog/Model/Layer/Filter/Item.php +++ b/app/code/Magento/Catalog/Model/Layer/Filter/Item.php @@ -56,7 +56,9 @@ class Item extends \Magento\Framework\Object { $filter = $this->getData('filter'); if (!is_object($filter)) { - throw new \Magento\Framework\Exception\LocalizedException(__('The filter must be an object. Please set correct filter.')); + throw new \Magento\Framework\Exception\LocalizedException( + __('The filter must be an object. Please set correct filter.') + ); } return $filter; } diff --git a/app/code/Magento/Catalog/Model/Product.php b/app/code/Magento/Catalog/Model/Product.php index 0b9af7cceaa0747fb642f549866b96a02e0468f1..1510c2aad137a65fe3de9b8e515c50dd001d5571 100644 --- a/app/code/Magento/Catalog/Model/Product.php +++ b/app/code/Magento/Catalog/Model/Product.php @@ -237,6 +237,11 @@ class Product extends \Magento\Catalog\Model\AbstractModel implements */ protected $imageCacheFactory; + /** + * @var \Magento\Catalog\Api\ProductAttributeRepositoryInterface + */ + protected $metadataService; + /** * @var \Magento\Framework\Api\DataObjectHelper */ @@ -245,9 +250,10 @@ class Product extends \Magento\Catalog\Model\AbstractModel implements /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry - * @param \Magento\Catalog\Api\ProductAttributeRepositoryInterface $metadataService + * @param \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory * @param AttributeValueFactory $customAttributeFactory * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Catalog\Api\ProductAttributeRepositoryInterface $metadataService * @param Product\Url $url * @param Product\Link $productLink * @param Product\Configuration\Item\OptionFactory $itemOptionFactory @@ -277,9 +283,10 @@ class Product extends \Magento\Catalog\Model\AbstractModel implements public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, - \Magento\Catalog\Api\ProductAttributeRepositoryInterface $metadataService, + \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory, AttributeValueFactory $customAttributeFactory, \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Catalog\Api\ProductAttributeRepositoryInterface $metadataService, Product\Url $url, Product\Link $productLink, \Magento\Catalog\Model\Product\Configuration\Item\OptionFactory $itemOptionFactory, @@ -304,6 +311,7 @@ class Product extends \Magento\Catalog\Model\AbstractModel implements \Magento\Framework\Api\DataObjectHelper $dataObjectHelper, array $data = [] ) { + $this->metadataService = $metadataService; $this->_itemOptionFactory = $itemOptionFactory; $this->_stockItemFactory = $stockItemFactory; $this->_optionInstance = $catalogProductOption; @@ -327,7 +335,7 @@ class Product extends \Magento\Catalog\Model\AbstractModel implements parent::__construct( $context, $registry, - $metadataService, + $extensionFactory, $customAttributeFactory, $storeManager, $resource, @@ -346,6 +354,17 @@ class Product extends \Magento\Catalog\Model\AbstractModel implements $this->_init('Magento\Catalog\Model\Resource\Product'); } + /** + * {@inheritdoc} + */ + protected function getCustomAttributesCodes() + { + if ($this->customAttributesCodes === null) { + $this->customAttributesCodes = $this->getEavAttributesCodes($this->metadataService); + } + return $this->customAttributesCodes; + } + /** * Retrieve Store Id * @@ -2215,5 +2234,26 @@ class Product extends \Magento\Catalog\Model\AbstractModel implements { return $this->setData(self::TYPE_ID, $typeId); } + + /** + * {@inheritdoc} + * + * @return \Magento\Catalog\Api\Data\ProductExtensionInterface|null + */ + public function getExtensionAttributes() + { + return $this->_getExtensionAttributes(); + } + + /** + * {@inheritdoc} + * + * @param \Magento\Catalog\Api\Data\ProductExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes(\Magento\Catalog\Api\Data\ProductExtensionInterface $extensionAttributes) + { + return $this->_setExtensionAttributes($extensionAttributes); + } //@codeCoverageIgnoreEnd } diff --git a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/GroupPrice/AbstractGroupPrice.php b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/GroupPrice/AbstractGroupPrice.php index ac0c1a12a19a3c58986f463dbe8e2e40ea4a4f67..f5337a699139fe3e6e8c46aa007be00b7c738355 100644 --- a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/GroupPrice/AbstractGroupPrice.php +++ b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/GroupPrice/AbstractGroupPrice.php @@ -161,7 +161,7 @@ abstract class AbstractGroupPrice extends Price ) ); if (isset($duplicates[$compare])) { - throw new \Magento\Framework\Exception\LocalizedException($this->_getDuplicateErrorMessage()); + throw new \Magento\Framework\Exception\LocalizedException(__($this->_getDuplicateErrorMessage())); } if (!preg_match('/^\d*(\.|,)?\d{0,4}$/i', $priceRow['price']) || $priceRow['price'] < 0) { @@ -209,7 +209,7 @@ abstract class AbstractGroupPrice extends Price $websiteCurrency = $rates[$priceRow['website_id']]['code']; if ($baseCurrency == $websiteCurrency && isset($duplicates[$globalCompare])) { - throw new \Magento\Framework\Exception\LocalizedException($this->_getDuplicateErrorMessage()); + throw new \Magento\Framework\Exception\LocalizedException(__($this->_getDuplicateErrorMessage())); } } diff --git a/app/code/Magento/Catalog/Model/Product/Attribute/Group.php b/app/code/Magento/Catalog/Model/Product/Attribute/Group.php index 97a6572077121baa53401bac3b9b8d58c85ee848..7bbabfc9b3fc8c2b62cfbb7e95a76a0c8f54cc7c 100644 --- a/app/code/Magento/Catalog/Model/Product/Attribute/Group.php +++ b/app/code/Magento/Catalog/Model/Product/Attribute/Group.php @@ -20,7 +20,7 @@ class Group extends \Magento\Eav\Model\Entity\Attribute\Group /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry - * @param \Magento\Framework\Api\MetadataServiceInterface $metadataService + * @param \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory * @param AttributeValueFactory $customAttributeFactory * @param \Magento\Catalog\Model\Resource\Product\Attribute\CollectionFactory $attributeCollectionFactory * @param \Magento\Framework\Model\Resource\AbstractResource $resource @@ -30,7 +30,7 @@ class Group extends \Magento\Eav\Model\Entity\Attribute\Group public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, - \Magento\Framework\Api\MetadataServiceInterface $metadataService, + \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory, AttributeValueFactory $customAttributeFactory, \Magento\Catalog\Model\Resource\Product\Attribute\CollectionFactory $attributeCollectionFactory, \Magento\Framework\Model\Resource\AbstractResource $resource = null, @@ -41,7 +41,7 @@ class Group extends \Magento\Eav\Model\Entity\Attribute\Group parent::__construct( $context, $registry, - $metadataService, + $extensionFactory, $customAttributeFactory, $resource, $resourceCollection, diff --git a/app/code/Magento/Catalog/Model/Product/Attribute/OptionManagement.php b/app/code/Magento/Catalog/Model/Product/Attribute/OptionManagement.php index 6c639d2a2a09204a5a7cd9f820df2cf257a5c02d..9d3dcc266bc10aa9b1b33325342120fc5e0ee3d8 100644 --- a/app/code/Magento/Catalog/Model/Product/Attribute/OptionManagement.php +++ b/app/code/Magento/Catalog/Model/Product/Attribute/OptionManagement.php @@ -53,7 +53,7 @@ class OptionManagement implements \Magento\Catalog\Api\ProductAttributeOptionMan public function delete($attributeCode, $optionId) { if (empty($optionId)) { - throw new InputException(sprintf('Invalid option id %s', $optionId)); + throw new InputException(__('Invalid option id %1', $optionId)); } return $this->eavOptionManagement->delete( diff --git a/app/code/Magento/Catalog/Model/Product/Attribute/Repository.php b/app/code/Magento/Catalog/Model/Product/Attribute/Repository.php index 6bbae5a2350c1005e73cbb8abf46f7ae87ef6159..49fdcf4a8a892783d3fde5fb652f67cfbf6eee2d 100644 --- a/app/code/Magento/Catalog/Model/Product/Attribute/Repository.php +++ b/app/code/Magento/Catalog/Model/Product/Attribute/Repository.php @@ -44,11 +44,6 @@ class Repository implements \Magento\Catalog\Api\ProductAttributeRepositoryInter */ protected $filterManager; - /** - * @var \Magento\Framework\Api\Config\MetadataConfig - */ - protected $metadataConfig; - /** * @var \Magento\Framework\Api\SearchCriteriaBuilder */ @@ -66,7 +61,6 @@ class Repository implements \Magento\Catalog\Api\ProductAttributeRepositoryInter * @param \Magento\Eav\Api\AttributeRepositoryInterface $eavAttributeRepository * @param \Magento\Eav\Model\Config $eavConfig * @param \Magento\Eav\Model\Adminhtml\System\Config\Source\Inputtype\ValidatorFactory $validatorFactory - * @param \Magento\Framework\Api\Config\MetadataConfig $metadataConfig * @param \Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder * @param \Magento\Framework\Api\FilterBuilder $filterBuilder * @SuppressWarnings(PHPMD.ExcessiveParameterList) @@ -78,7 +72,6 @@ class Repository implements \Magento\Catalog\Api\ProductAttributeRepositoryInter \Magento\Eav\Api\AttributeRepositoryInterface $eavAttributeRepository, \Magento\Eav\Model\Config $eavConfig, \Magento\Eav\Model\Adminhtml\System\Config\Source\Inputtype\ValidatorFactory $validatorFactory, - \Magento\Framework\Api\Config\MetadataConfig $metadataConfig, \Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder, \Magento\Framework\Api\FilterBuilder $filterBuilder ) { @@ -88,7 +81,6 @@ class Repository implements \Magento\Catalog\Api\ProductAttributeRepositoryInter $this->eavAttributeRepository = $eavAttributeRepository; $this->eavConfig = $eavConfig; $this->inputtypeValidatorFactory = $validatorFactory; - $this->metadataConfig = $metadataConfig; $this->searchCriteriaBuilder = $searchCriteriaBuilder; $this->filterBuilder = $filterBuilder; } @@ -213,25 +205,23 @@ class Repository implements \Magento\Catalog\Api\ProductAttributeRepositoryInter /** * {@inheritdoc} + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function getCustomAttributesMetadata($dataObjectClassName = null) { + $defaultAttributeSetId = $this->eavConfig + ->getEntityType(\Magento\Catalog\Api\Data\ProductAttributeInterface::ENTITY_TYPE_CODE) + ->getDefaultAttributeSetId(); $searchCriteria = $this->searchCriteriaBuilder->addFilter( [ $this->filterBuilder ->setField('attribute_set_id') - ->setValue(\Magento\Catalog\Api\Data\ProductAttributeInterface::DEFAULT_ATTRIBUTE_SET_ID) + ->setValue($defaultAttributeSetId) ->create(), ] ); - $customAttributes = []; - $entityAttributes = $this->getList($searchCriteria->create())->getItems(); - - foreach ($entityAttributes as $attributeMetadata) { - $customAttributes[] = $attributeMetadata; - } - return array_merge($customAttributes, $this->metadataConfig->getCustomAttributesMetadata($dataObjectClassName)); + return $this->getList($searchCriteria->create())->getItems(); } /** diff --git a/app/code/Magento/Catalog/Model/Product/Attribute/SetManagement.php b/app/code/Magento/Catalog/Model/Product/Attribute/SetManagement.php index 12fd5d96014888f3c0ac2e878c961af0cd946261..c58f0d053d574cc0a8c7d8105de4ea693a33c742 100644 --- a/app/code/Magento/Catalog/Model/Product/Attribute/SetManagement.php +++ b/app/code/Magento/Catalog/Model/Product/Attribute/SetManagement.php @@ -64,10 +64,14 @@ class SetManagement implements \Magento\Catalog\Api\AttributeSetManagementInterf $skeletonSet = $this->attributeSetRepository->get($skeletonId); $productEntityId = $this->eavConfig->getEntityType(\Magento\Catalog\Model\Product::ENTITY)->getId(); if ($skeletonSet->getEntityTypeId() != $productEntityId) { - throw new StateException('Can not create attribute set based on non product attribute set.'); + throw new StateException( + __('Can not create attribute set based on non product attribute set.') + ); } } catch (\Magento\Framework\Exception\NoSuchEntityException $exception) { - throw new StateException('Can not create attribute set based on not existing attribute set'); + throw new StateException( + __('Can not create attribute set based on not existing attribute set') + ); } } } diff --git a/app/code/Magento/Catalog/Model/Product/Attribute/SetRepository.php b/app/code/Magento/Catalog/Model/Product/Attribute/SetRepository.php index 372cda91ef3bc9f08f5a297888b98d51fcca04a5..1ff9a50bea62cdfaf3a73887e9a68b6be4fdffea 100644 --- a/app/code/Magento/Catalog/Model/Product/Attribute/SetRepository.php +++ b/app/code/Magento/Catalog/Model/Product/Attribute/SetRepository.php @@ -115,7 +115,9 @@ class SetRepository implements \Magento\Catalog\Api\AttributeSetRepositoryInterf { $productEntityId = $this->eavConfig->getEntityType(\Magento\Catalog\Model\Product::ENTITY)->getId(); if ($attributeSet->getEntityTypeId() != $productEntityId) { - throw new \Magento\Framework\Exception\StateException('Provided Attribute set non product Attribute set.'); + throw new \Magento\Framework\Exception\StateException( + __('Provided Attribute set non product Attribute set.') + ); } } } diff --git a/app/code/Magento/Catalog/Model/Product/Attribute/Type.php b/app/code/Magento/Catalog/Model/Product/Attribute/Type.php index f3935642a168c4cf16050825e508d9f3c0470be7..a809df6591d7c34a04951cd6d330636f07ff3c05 100644 --- a/app/code/Magento/Catalog/Model/Product/Attribute/Type.php +++ b/app/code/Magento/Catalog/Model/Product/Attribute/Type.php @@ -1,9 +1,9 @@ <?php /** - * * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ + namespace Magento\Catalog\Model\Product\Attribute; /** @@ -49,4 +49,26 @@ class Type extends \Magento\Framework\Model\AbstractExtensibleModel implements { return $this->setData(self::LABEL, $label); } + + /** + * {@inheritdoc} + * + * @return \Magento\Catalog\Api\Data\ProductAttributeTypeExtensionInterface|null + */ + public function getExtensionAttributes() + { + return $this->_getExtensionAttributes(); + } + + /** + * {@inheritdoc} + * + * @param \Magento\Catalog\Api\Data\ProductAttributeTypeExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes( + \Magento\Catalog\Api\Data\ProductAttributeTypeExtensionInterface $extensionAttributes + ) { + return $this->_setExtensionAttributes($extensionAttributes); + } } diff --git a/app/code/Magento/Catalog/Model/Product/Gallery/ContentValidator.php b/app/code/Magento/Catalog/Model/Product/Gallery/ContentValidator.php index f546ff90b9ebef3c6d715d85da3d616cdac97c3e..c067da69a5b803a1f3f4c22ca79d37984cae4c2c 100644 --- a/app/code/Magento/Catalog/Model/Product/Gallery/ContentValidator.php +++ b/app/code/Magento/Catalog/Model/Product/Gallery/ContentValidator.php @@ -46,18 +46,18 @@ class ContentValidator { $fileContent = @base64_decode($entryContent->getEntryData(), true); if (empty($fileContent)) { - throw new InputException('The image content must be valid base64 encoded data.'); + throw new InputException(__('The image content must be valid base64 encoded data.')); } $imageProperties = @getimagesizefromstring($fileContent); if (empty($imageProperties)) { - throw new InputException('The image content must be valid base64 encoded data.'); + throw new InputException(__('The image content must be valid base64 encoded data.')); } $sourceMimeType = $imageProperties['mime']; if ($sourceMimeType != $entryContent->getMimeType() || !$this->isMimeTypeValid($sourceMimeType)) { - throw new InputException('The image MIME type is not valid or not supported.'); + throw new InputException(__('The image MIME type is not valid or not supported.')); } if (!$this->isNameValid($entryContent->getName())) { - throw new InputException('Provided image name contains forbidden characters.'); + throw new InputException(__('Provided image name contains forbidden characters.')); } return true; } diff --git a/app/code/Magento/Catalog/Model/Product/Gallery/Entry.php b/app/code/Magento/Catalog/Model/Product/Gallery/Entry.php index 116899bda07e86a3128494e4a134f45a687ee99e..54c8123415d9050806de6a0509cc1c51b4828696 100644 --- a/app/code/Magento/Catalog/Model/Product/Gallery/Entry.php +++ b/app/code/Magento/Catalog/Model/Product/Gallery/Entry.php @@ -6,11 +6,14 @@ */ namespace Magento\Catalog\Model\Product\Gallery; +use Magento\Framework\Model\AbstractExtensibleModel; +use Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface; +use Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryExtensionInterface; + /** * @codeCoverageIgnore */ -class Entry extends \Magento\Framework\Model\AbstractExtensibleModel implements - \Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface +class Entry extends AbstractExtensibleModel implements ProductAttributeMediaGalleryEntryInterface { /** * Retrieve gallery entry ID @@ -46,9 +49,8 @@ class Entry extends \Magento\Framework\Model\AbstractExtensibleModel implements * Check if gallery entry is hidden from product page * * @return bool - * @SuppressWarnings(PHPMD.BooleanGetMethodName) */ - public function getIsDisabled() + public function isDisabled() { return $this->getData(self::DISABLED); } @@ -73,6 +75,14 @@ class Entry extends \Magento\Framework\Model\AbstractExtensibleModel implements return $this->getData(self::FILE); } + /** + * @return \Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryContentInterface|null + */ + public function getContent() + { + return $this->getData(self::CONTENT); + } + /** * Set gallery entry alternative text * @@ -98,12 +108,12 @@ class Entry extends \Magento\Framework\Model\AbstractExtensibleModel implements /** * Set whether gallery entry is hidden from product page * - * @param bool $isDisabled + * @param bool $disabled * @return $this */ - public function setIsDisabled($isDisabled) + public function setDisabled($disabled) { - return $this->setData(self::DISABLED, $isDisabled); + return $this->setData(self::DISABLED, $disabled); } /** @@ -127,4 +137,36 @@ class Entry extends \Magento\Framework\Model\AbstractExtensibleModel implements { return $this->setData(self::FILE, $file); } + + /** + * Set media gallery content + * + * @param $content \Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryContentInterface + * @return $this + */ + public function setContent($content) + { + return $this->setData(self::CONTENT, $content); + } + + /** + * {@inheritdoc} + * + * @return ProductAttributeMediaGalleryEntryExtensionInterface|null + */ + public function getExtensionAttributes() + { + return $this->_getExtensionAttributes(); + } + + /** + * {@inheritdoc} + * + * @param ProductAttributeMediaGalleryEntryExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes(ProductAttributeMediaGalleryEntryExtensionInterface $extensionAttributes) + { + return $this->_setExtensionAttributes($extensionAttributes); + } } diff --git a/app/code/Magento/Catalog/Model/Product/Gallery/GalleryManagement.php b/app/code/Magento/Catalog/Model/Product/Gallery/GalleryManagement.php index 7a9302300cea955e89fdc871a70f60c6025d8c61..1ed06f39bfa84a452223218604b8006f9c7b0569 100644 --- a/app/code/Magento/Catalog/Model/Product/Gallery/GalleryManagement.php +++ b/app/code/Magento/Catalog/Model/Product/Gallery/GalleryManagement.php @@ -6,14 +6,13 @@ */ namespace Magento\Catalog\Model\Product\Gallery; -use Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryContentInterface as ContentInterface; use Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface; use Magento\Catalog\Api\Data\ProductInterface as Product; use Magento\Catalog\Model\Product\Media\Config as MediaConfig; +use Magento\Framework\App\Filesystem\DirectoryList; use Magento\Framework\Exception\InputException; use Magento\Framework\Exception\NoSuchEntityException; use Magento\Framework\Exception\StateException; -use Magento\Framework\App\Filesystem\DirectoryList; /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) @@ -128,7 +127,7 @@ class GalleryManagement implements \Magento\Catalog\Api\ProductAttributeMediaGal if (!isset($attributes['media_gallery']) || !($attributes['media_gallery'] instanceof \Magento\Eav\Model\Entity\Attribute\AbstractAttribute) ) { - throw new StateException('Requested product does not support images.'); + throw new StateException(__('Requested product does not support images.')); } /** @var $galleryAttribute \Magento\Eav\Model\Entity\Attribute\AbstractAttribute */ $galleryAttribute = $attributes['media_gallery']; @@ -154,21 +153,21 @@ class GalleryManagement implements \Magento\Catalog\Api\ProductAttributeMediaGal /** * {@inheritdoc} */ - public function create( - $productSku, - ProductAttributeMediaGalleryEntryInterface $entry, - ContentInterface $entryContent, - $storeId = 0 - ) { + public function create($product) + { try { - $this->storeManager->getStore($storeId); + $this->storeManager->getStore($product->getStoreId()); } catch (\Exception $exception) { - throw new NoSuchEntityException('There is no store with provided ID.'); + throw new NoSuchEntityException(__('There is no store with provided ID.')); } + /** @var $entry ProductAttributeMediaGalleryEntryInterface */ + $entry = $product->getCustomAttribute('media_gallery')->getValue(); + $entryContent = $entry->getContent(); + if (!$this->contentValidator->isValid($entryContent)) { - throw new InputException('The image content is not valid.'); + throw new InputException(__('The image content is not valid.')); } - $product = $this->productRepository->get($productSku); + $product = $this->productRepository->get($product->getSku()); $fileContent = @base64_decode($entryContent->getEntryData(), true); $mediaTmpPath = $this->mediaConfig->getBaseTmpMediaPath(); @@ -186,20 +185,23 @@ class GalleryManagement implements \Magento\Catalog\Api\ProductAttributeMediaGal $absoluteFilePath, $entry->getTypes(), true, - $entry->getIsDisabled() + $entry->isDisabled() ); // Update additional fields that are still empty after addImage call - $productMediaGallery->updateImage($product, $imageFileUri, [ + $productMediaGallery->updateImage( + $product, + $imageFileUri, + [ 'label' => $entry->getLabel(), 'position' => $entry->getPosition(), - 'disabled' => $entry->getIsDisabled(), - ]); - $product->setStoreId($storeId); + 'disabled' => $entry->isDisabled(), + ] + ); try { $this->productRepository->save($product); } catch (\Exception $e) { - throw new StateException('Cannot save product.'); + throw new StateException(__('Cannot save product.')); } // Remove all temporary files $mediaDirectory->delete($relativeFilePath); @@ -213,26 +215,30 @@ class GalleryManagement implements \Magento\Catalog\Api\ProductAttributeMediaGal /** * {@inheritdoc} */ - public function update($productSku, ProductAttributeMediaGalleryEntryInterface $entry, $storeId = 0) + public function update($sku, ProductAttributeMediaGalleryEntryInterface $entry, $storeId = 0) { try { $this->storeManager->getStore($storeId); } catch (\Exception $exception) { - throw new NoSuchEntityException('There is no store with provided ID.'); + throw new NoSuchEntityException(__('There is no store with provided ID.')); } - $product = $this->productRepository->get($productSku); + $product = $this->productRepository->get($sku); /** @var $productMediaGallery \Magento\Catalog\Model\Product\Attribute\Backend\Media */ $productMediaGallery = $this->getGalleryAttributeBackend($product); $filePath = $this->entryResolver->getEntryFilePathById($product, $entry->getId()); if (is_null($filePath)) { - throw new NoSuchEntityException('There is no image with provided ID.'); + throw new NoSuchEntityException(__('There is no image with provided ID.')); } - $productMediaGallery->updateImage($product, $filePath, [ - 'label' => $entry->getLabel(), - 'position' => $entry->getPosition(), - 'disabled' => $entry->getIsDisabled(), - ]); + $productMediaGallery->updateImage( + $product, + $filePath, + [ + 'label' => $entry->getLabel(), + 'position' => $entry->getPosition(), + 'disabled' => $entry->isDisabled(), + ] + ); $productMediaGallery->clearMediaAttribute($product, array_keys($product->getMediaAttributes())); $productMediaGallery->setMediaAttribute($product, $entry->getTypes(), $filePath); $product->setStoreId($storeId); @@ -240,7 +246,7 @@ class GalleryManagement implements \Magento\Catalog\Api\ProductAttributeMediaGal try { $this->productRepository->save($product); } catch (\Exception $exception) { - throw new StateException('Cannot save product.'); + throw new StateException(__('Cannot save product.')); } return true; } @@ -248,14 +254,14 @@ class GalleryManagement implements \Magento\Catalog\Api\ProductAttributeMediaGal /** * {@inheritdoc} */ - public function remove($productSku, $entryId) + public function remove($sku, $entryId) { - $product = $this->productRepository->get($productSku); + $product = $this->productRepository->get($sku); /** @var $productMediaGallery \Magento\Catalog\Model\Product\Attribute\Backend\Media */ $productMediaGallery = $this->getGalleryAttributeBackend($product); $filePath = $this->entryResolver->getEntryFilePathById($product, $entryId); if (is_null($filePath)) { - throw new NoSuchEntityException('There is no image with provided ID.'); + throw new NoSuchEntityException(__('There is no image with provided ID.')); } $productMediaGallery->removeImage($product, $filePath); @@ -266,12 +272,12 @@ class GalleryManagement implements \Magento\Catalog\Api\ProductAttributeMediaGal /** * {@inheritdoc} */ - public function get($productSku, $imageId) + public function get($sku, $imageId) { try { - $product = $this->productRepository->get($productSku); + $product = $this->productRepository->get($sku); } catch (\Exception $exception) { - throw new NoSuchEntityException("Such product doesn't exist"); + throw new NoSuchEntityException(__('Such product doesn\'t exist')); } $output = null; @@ -290,7 +296,7 @@ class GalleryManagement implements \Magento\Catalog\Api\ProductAttributeMediaGal } if (is_null($output)) { - throw new NoSuchEntityException("Such image doesn't exist"); + throw new NoSuchEntityException(__('Such image doesn\'t exist')); } return $output; } @@ -298,11 +304,11 @@ class GalleryManagement implements \Magento\Catalog\Api\ProductAttributeMediaGal /** * {@inheritdoc} */ - public function getList($productSku) + public function getList($sku) { $result = []; /** @var \Magento\Catalog\Model\Product $product */ - $product = $this->productRepository->get($productSku); + $product = $this->productRepository->get($sku); /** @var \Magento\Catalog\Api\Data\ProductAttributeInterface $galleryAttribute */ $galleryAttribute = $this->attributeRepository->get('media_gallery'); @@ -318,7 +324,7 @@ class GalleryManagement implements \Magento\Catalog\Api\ProductAttributeMediaGal $entry->setId($image['value_id']) ->setLabel($image['label_default']) ->setTypes(array_keys($productImages, $image['file'])) - ->setIsDisabled($image['disabled_default']) + ->setDisabled($image['disabled_default']) ->setPosition($image['position_default']) ->setFile($image['file']); $result[] = $entry; diff --git a/app/code/Magento/Catalog/Model/Product/GroupPrice.php b/app/code/Magento/Catalog/Model/Product/GroupPrice.php index 531546e1a4a086f55fc2d2170e23b1d882f91f01..740a2b1b976b47d16b07166bb7551220cf779dbf 100644 --- a/app/code/Magento/Catalog/Model/Product/GroupPrice.php +++ b/app/code/Magento/Catalog/Model/Product/GroupPrice.php @@ -61,4 +61,26 @@ class GroupPrice extends \Magento\Framework\Model\AbstractExtensibleModel implem { return $this->setData(self::KEY_VALUE, $value); } + + /** + * {@inheritdoc} + * + * @return \Magento\Catalog\Api\Data\ProductGroupPriceExtensionInterface|null + */ + public function getExtensionAttributes() + { + return $this->_getExtensionAttributes(); + } + + /** + * {@inheritdoc} + * + * @param \Magento\Catalog\Api\Data\ProductGroupPriceExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes( + \Magento\Catalog\Api\Data\ProductGroupPriceExtensionInterface $extensionAttributes + ) { + return $this->_setExtensionAttributes($extensionAttributes); + } } diff --git a/app/code/Magento/Catalog/Model/Product/GroupPriceManagement.php b/app/code/Magento/Catalog/Model/Product/GroupPriceManagement.php index 82d4985cdab134586f2823199469a082e8003eb7..9dca54ee7ebd52fc62098ff3ab77c67f21eac864 100644 --- a/app/code/Magento/Catalog/Model/Product/GroupPriceManagement.php +++ b/app/code/Magento/Catalog/Model/Product/GroupPriceManagement.php @@ -72,13 +72,13 @@ class GroupPriceManagement implements \Magento\Catalog\Api\ProductGroupPriceMana * @SuppressWarnings(PHPMD.CyclomaticComplexity) * @SuppressWarnings(PHPMD.NPathComplexity) */ - public function add($productSku, $customerGroupId, $price) + public function add($sku, $customerGroupId, $price) { if (!\Zend_Validate::is($price, 'Float') || $price <= 0 || !\Zend_Validate::is($price, 'Float')) { - throw new InputException('Please provide valid data'); + throw new InputException(__('Please provide valid data')); } $customerGroup = $this->groupRepository->getById($customerGroupId); - $product = $this->productRepository->get($productSku, true); + $product = $this->productRepository->get($sku, true); $groupPrices = $product->getData('group_price'); $websiteIdentifier = 0; $value = $this->config->getValue('catalog/price/scope', \Magento\Store\Model\ScopeInterface::SCOPE_WEBSITE); @@ -108,13 +108,13 @@ class GroupPriceManagement implements \Magento\Catalog\Api\ProductGroupPriceMana if (is_array($errors) && count($errors)) { $errorAttributeCodes = implode(', ', array_keys($errors)); throw new InputException( - sprintf('Values of following attributes are invalid: %s', $errorAttributeCodes) + __('Values of following attributes are invalid: %1', $errorAttributeCodes) ); } try { $this->productRepository->save($product); } catch (\Exception $e) { - throw new CouldNotSaveException('Could not save group price'); + throw new CouldNotSaveException(__('Could not save group price')); } return true; } @@ -122,9 +122,9 @@ class GroupPriceManagement implements \Magento\Catalog\Api\ProductGroupPriceMana /** * {@inheritdoc} */ - public function remove($productSku, $customerGroupId) + public function remove($sku, $customerGroupId) { - $product = $this->productRepository->get($productSku, true); + $product = $this->productRepository->get($sku, true); $websiteIdentifier = 0; $value = $this->config->getValue('catalog/price/scope', \Magento\Store\Model\ScopeInterface::SCOPE_WEBSITE); if ($value != 0) { @@ -137,9 +137,9 @@ class GroupPriceManagement implements \Magento\Catalog\Api\ProductGroupPriceMana /** * {@inheritdoc} */ - public function getList($productSku, $websiteId = null) + public function getList($sku, $websiteId = null) { - $product = $this->productRepository->get($productSku, true); + $product = $this->productRepository->get($sku, true); $priceKey = 'website_price'; $value = $this->config->getValue('catalog/price/scope', \Magento\Store\Model\ScopeInterface::SCOPE_WEBSITE); if ($value == 0) { diff --git a/app/code/Magento/Catalog/Model/Product/Media/GalleryEntryContent.php b/app/code/Magento/Catalog/Model/Product/Media/GalleryEntryContent.php index 4844a001a86add8567c691a387fa875049f7709e..48c0b4dc10739a0c8902656999fc856e701ca841 100644 --- a/app/code/Magento/Catalog/Model/Product/Media/GalleryEntryContent.php +++ b/app/code/Magento/Catalog/Model/Product/Media/GalleryEntryContent.php @@ -1,9 +1,9 @@ <?php /** - * * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ + namespace Magento\Catalog\Model\Product\Media; /** @@ -68,4 +68,26 @@ class GalleryEntryContent extends \Magento\Framework\Model\AbstractExtensibleMod { return $this->setData(self::NAME, $name); } + + /** + * {@inheritdoc} + * + * @return \Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryContentExtensionInterface|null + */ + public function getExtensionAttributes() + { + return $this->_getExtensionAttributes(); + } + + /** + * {@inheritdoc} + * + * @param \Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryContentExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes( + \Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryContentExtensionInterface $extensionAttributes + ) { + return $this->_setExtensionAttributes($extensionAttributes); + } } diff --git a/app/code/Magento/Catalog/Model/Product/Option.php b/app/code/Magento/Catalog/Model/Product/Option.php index a6ba38bc1703dbb1becb1ea4404385ccdd81a757..3afdf86af8f964579c65ced1115c779102f3a8c7 100644 --- a/app/code/Magento/Catalog/Model/Product/Option.php +++ b/app/code/Magento/Catalog/Model/Product/Option.php @@ -9,11 +9,9 @@ namespace Magento\Catalog\Model\Product; use Magento\Catalog\Api\Data\ProductCustomOptionValuesInterface; -use Magento\Framework\Model\AbstractExtensibleModel; use Magento\Catalog\Model\Product; use Magento\Catalog\Model\Resource\Product\Option\Value\Collection; use Magento\Catalog\Pricing\Price\BasePrice; -use Magento\Framework\Api\AttributeValueFactory; use Magento\Framework\Model\AbstractModel; use Magento\Framework\Exception\LocalizedException; @@ -28,7 +26,7 @@ use Magento\Framework\Exception\LocalizedException; * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @SuppressWarnings(PHPMD.ExcessivePublicCount) */ -class Option extends AbstractExtensibleModel implements \Magento\Catalog\Api\Data\ProductCustomOptionInterface +class Option extends AbstractModel implements \Magento\Catalog\Api\Data\ProductCustomOptionInterface { const OPTION_GROUP_TEXT = 'text'; @@ -118,8 +116,6 @@ class Option extends AbstractExtensibleModel implements \Magento\Catalog\Api\Dat /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry - * @param \Magento\Catalog\Api\CategoryAttributeRepositoryInterface $metadataService - * @param AttributeValueFactory $customAttributeFactory * @param Option\Value $productOptionValue * @param Option\Type\Factory $optionFactory * @param \Magento\Framework\Stdlib\String $string @@ -132,8 +128,6 @@ class Option extends AbstractExtensibleModel implements \Magento\Catalog\Api\Dat public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, - \Magento\Catalog\Api\CategoryAttributeRepositoryInterface $metadataService, - AttributeValueFactory $customAttributeFactory, Option\Value $productOptionValue, \Magento\Catalog\Model\Product\Option\Type\Factory $optionFactory, \Magento\Framework\Stdlib\String $string, @@ -149,8 +143,6 @@ class Option extends AbstractExtensibleModel implements \Magento\Catalog\Api\Dat parent::__construct( $context, $registry, - $metadataService, - $customAttributeFactory, $resource, $resourceCollection, $data diff --git a/app/code/Magento/Catalog/Model/Product/Option/Repository.php b/app/code/Magento/Catalog/Model/Product/Option/Repository.php index 936b6569c44ecb851b59c12daf50cba9f3951e1a..4d5103958d55dc2828b4350716a48ce0a0f94981 100644 --- a/app/code/Magento/Catalog/Model/Product/Option/Repository.php +++ b/app/code/Magento/Catalog/Model/Product/Option/Repository.php @@ -44,18 +44,18 @@ class Repository implements \Magento\Catalog\Api\ProductCustomOptionRepositoryIn /** * {@inheritdoc} */ - public function getList($productSku) + public function getList($sku) { - $product = $this->productRepository->get($productSku, true); + $product = $this->productRepository->get($sku, true); return $product->getOptions(); } /** * {@inheritdoc} */ - public function get($productSku, $optionId) + public function get($sku, $optionId) { - $product = $this->productRepository->get($productSku); + $product = $this->productRepository->get($sku); $option = $product->getOptionById($optionId); if (is_null($option)) { throw NoSuchEntityException::singleField('optionId', $optionId); @@ -77,8 +77,8 @@ class Repository implements \Magento\Catalog\Api\ProductCustomOptionRepositoryIn */ public function save(\Magento\Catalog\Api\Data\ProductCustomOptionInterface $option) { - $productSku = $option->getProductSku(); - $product = $this->productRepository->get($productSku, true); + $sku = $option->getProductSku(); + $product = $this->productRepository->get($sku, true); $optionData = $this->converter->toArray($option); if ($option->getOptionId()) { if (!$product->getOptionById($option->getOptionId())) { @@ -97,31 +97,31 @@ class Repository implements \Magento\Catalog\Api\ProductCustomOptionRepositoryIn try { $this->productRepository->save($product, true); } catch (\Exception $e) { - throw new CouldNotSaveException('Could not save product option'); + throw new CouldNotSaveException(__('Could not save product option')); } - $product = $this->productRepository->get($productSku, true); + $product = $this->productRepository->get($sku, true); if (!$option->getOptionId()) { $currentOptions = $product->getOptions(); $newID = array_diff(array_keys($currentOptions), array_keys($existingOptions)); if (empty($newID)) { - throw new CouldNotSaveException('Could not save product option'); + throw new CouldNotSaveException(__('Could not save product option')); } $newID = current($newID); } else { $newID = $option->getOptionId(); } - $option = $this->get($productSku, $newID); + $option = $this->get($sku, $newID); return $option; } /** * {@inheritdoc} */ - public function deleteByIdentifier($productSku, $optionId) + public function deleteByIdentifier($sku, $optionId) { - $product = $this->productRepository->get($productSku, true); + $product = $this->productRepository->get($sku, true); $options = $product->getOptions(); $option = $product->getOptionById($optionId); if (is_null($option)) { @@ -134,7 +134,7 @@ class Repository implements \Magento\Catalog\Api\ProductCustomOptionRepositoryIn $this->productRepository->save($product); } } catch (\Exception $e) { - throw new CouldNotSaveException('Could not remove custom option'); + throw new CouldNotSaveException(__('Could not remove custom option')); } return true; } diff --git a/app/code/Magento/Catalog/Model/Product/Option/Type.php b/app/code/Magento/Catalog/Model/Product/Option/Type.php index cb69c24a1c8ee27f32df3ac87c4bbbbc44b3b7cc..045bb591e8b3ea86e53f2db46c79c1ab3b54550e 100644 --- a/app/code/Magento/Catalog/Model/Product/Option/Type.php +++ b/app/code/Magento/Catalog/Model/Product/Option/Type.php @@ -82,4 +82,26 @@ class Type extends \Magento\Framework\Model\AbstractExtensibleModel implements { return $this->setData(self::KEY_GROUP, $group); } + + /** + * {@inheritdoc} + * + * @return \Magento\Catalog\Api\Data\ProductCustomOptionTypeExtensionInterface|null + */ + public function getExtensionAttributes() + { + return $this->_getExtensionAttributes(); + } + + /** + * {@inheritdoc} + * + * @param \Magento\Catalog\Api\Data\ProductCustomOptionTypeExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes( + \Magento\Catalog\Api\Data\ProductCustomOptionTypeExtensionInterface $extensionAttributes + ) { + return $this->_setExtensionAttributes($extensionAttributes); + } } diff --git a/app/code/Magento/Catalog/Model/Product/Option/Type/DefaultType.php b/app/code/Magento/Catalog/Model/Product/Option/Type/DefaultType.php index 2ecf3b8eb659eac7c66d3ebbf6a771466ec18480..3074ed6fdf26e803747f172091c3508b90496908 100644 --- a/app/code/Magento/Catalog/Model/Product/Option/Type/DefaultType.php +++ b/app/code/Magento/Catalog/Model/Product/Option/Type/DefaultType.php @@ -239,7 +239,9 @@ class DefaultType extends \Magento\Framework\Object if ($this->getIsValid()) { return $this->getUserValue(); } - throw new LocalizedException(__('We couldn\'t add the product to the cart because of an option validation issue.')); + throw new LocalizedException( + __('We couldn\'t add the product to the cart because of an option validation issue.') + ); } /** diff --git a/app/code/Magento/Catalog/Model/Product/Option/Type/Factory.php b/app/code/Magento/Catalog/Model/Product/Option/Type/Factory.php index ea5440461e9e7dca11f81d654cf02780e15dc53e..55f5ef434ab21d916f4a8b3d02e616c227c415e5 100644 --- a/app/code/Magento/Catalog/Model/Product/Option/Type/Factory.php +++ b/app/code/Magento/Catalog/Model/Product/Option/Type/Factory.php @@ -42,7 +42,7 @@ class Factory if (!$option instanceof \Magento\Catalog\Model\Product\Option\Type\DefaultType) { throw new \Magento\Framework\Exception\LocalizedException( - $className . ' doesn\'t extends \Magento\Catalog\Model\Product\Option\Type\DefaultType' + __('%1 doesn\'t extends \Magento\Catalog\Model\Product\Option\Type\DefaultType', $className) ); } return $option; diff --git a/app/code/Magento/Catalog/Model/Product/Option/Type/File.php b/app/code/Magento/Catalog/Model/Product/Option/Type/File.php index d89d038144e44b449eaf3430baf382525207da13..b68f8f1bec8e78078d3e9601d11139dd15fcb1d9 100644 --- a/app/code/Magento/Catalog/Model/Product/Option/Type/File.php +++ b/app/code/Magento/Catalog/Model/Product/Option/Type/File.php @@ -224,7 +224,7 @@ class File extends \Magento\Catalog\Model\Product\Option\Type\DefaultType $this->setUserValue($value); } catch (\Magento\Framework\Exception\File\LargeSizeException $largeSizeException) { $this->setIsValid(false); - throw new LocalizedException($largeSizeException->getMessage()); + throw new LocalizedException(__($largeSizeException->getMessage())); } catch (ProductException $e) { switch ($this->getProcessMode()) { case \Magento\Catalog\Model\Product\Type\AbstractType::PROCESS_MODE_FULL: @@ -234,16 +234,16 @@ class File extends \Magento\Catalog\Model\Product\Option\Type\DefaultType $this->setUserValue(null); break; } - } catch (\Magento\Framework\Validator\ValidatorException $e) { + } catch (\Magento\Framework\Validator\Exception $e) { $this->setUserValue(null); } catch (\Magento\Framework\Exception\File\ValidatorException $e) { $this->setIsValid(false); - throw new LocalizedException($e->getMessage()); + throw new LocalizedException(__($e->getMessage())); } catch (\Exception $e) { if ($this->getSkipCheckRequiredOption()) { $this->setUserValue(null); } else { - throw new LocalizedException($e->getMessage()); + throw new LocalizedException(__($e->getMessage())); } } return $this; @@ -341,7 +341,7 @@ class File extends \Magento\Catalog\Model\Product\Option\Type\DefaultType $sizes ); } catch (\Exception $e) { - throw new LocalizedException(__("The file options format is not valid.")); + throw new LocalizedException(__('The file options format is not valid.')); } } diff --git a/app/code/Magento/Catalog/Model/Product/Option/Type/File/ValidatorFile.php b/app/code/Magento/Catalog/Model/Product/Option/Type/File/ValidatorFile.php index 051681c4c319186a54020a6d0e1a9744cfb8d9d4..2338b3ca6ea9822c8ebcd7d095c140ac4ee7f6e4 100644 --- a/app/code/Magento/Catalog/Model/Product/Option/Type/File/ValidatorFile.php +++ b/app/code/Magento/Catalog/Model/Product/Option/Type/File/ValidatorFile.php @@ -91,7 +91,7 @@ class ValidatorFile extends Validator * @return array * @throws \Magento\Framework\Exception\LocalizedException * @throws \Zend_File_Transfer_Exception - * @throws \Magento\Framework\Validator\ValidatorException + * @throws \Magento\Framework\Validator\Exception * @throws \Magento\Catalog\Model\Product\Exception * @SuppressWarnings(PHPMD.CyclomaticComplexity) * @SuppressWarnings(PHPMD.ExcessiveMethodLength) @@ -103,21 +103,21 @@ class ValidatorFile extends Validator try { $runValidation = $option->getIsRequire() || $upload->isUploaded($file); if (!$runValidation) { - throw new \Magento\Framework\Validator\ValidatorException( + throw new \Magento\Framework\Validator\Exception( __('Validation failed. Required options were not filled or file was not uploaded.') ); } $fileInfo = $upload->getFileInfo($file)[$file]; $fileInfo['title'] = $fileInfo['name']; - } catch (\Magento\Framework\Validator\ValidatorException $e) { + } catch (\Magento\Framework\Validator\Exception $e) { throw $e; } catch (\Exception $e) { // when file exceeds the upload_max_filesize, $_FILES is empty if ($this->validateContentLength()) { $value = $this->fileSize->getMaxFileSizeInMb(); throw new \Magento\Framework\Exception\File\LargeSizeException( - __("The file you uploaded is larger than %1 Megabytes allowed by server", $value) + __('The file you uploaded is larger than %1 Megabytes allowed by server', $value) ); } else { throw new ProductException(__('Option required.')); @@ -150,7 +150,6 @@ class ValidatorFile extends Validator $upload->addFilter(new \Zend_Filter_File_Rename(['target' => $fileFullPath, 'overwrite' => true])); - // TODO: I don't know how change this if (!is_null($this->product)) { $this->product->getTypeInstance()->addFileQueue( [ @@ -189,7 +188,7 @@ class ValidatorFile extends Validator $errors = $this->getValidatorErrors($upload->getErrors(), $fileInfo, $option); if (count($errors) > 0) { - throw new \Magento\Framework\Exception\File\ValidatorException(implode("\n", $errors)); + throw new \Magento\Framework\Exception\File\ValidatorException(__(implode("\n", $errors))); } } else { throw new \Magento\Framework\Exception\File\ValidatorException( diff --git a/app/code/Magento/Catalog/Model/Product/Option/Type/File/ValidatorInfo.php b/app/code/Magento/Catalog/Model/Product/Option/Type/File/ValidatorInfo.php index 8e9a92be8bb1f6664cee0ac0cc5c2f6bf2dd6a74..373b8a63db3fe28bce01645bd8eb36bd5d9ae406 100644 --- a/app/code/Magento/Catalog/Model/Product/Option/Type/File/ValidatorInfo.php +++ b/app/code/Magento/Catalog/Model/Product/Option/Type/File/ValidatorInfo.php @@ -98,7 +98,7 @@ class ValidatorInfo extends Validator $errors = $this->getValidatorErrors($validatorChain->getErrors(), $optionValue, $option); if (count($errors) > 0) { - throw new \Magento\Framework\Exception\LocalizedException(implode("\n", $errors)); + throw new \Magento\Framework\Exception\LocalizedException(__(implode("\n", $errors))); } } else { throw new \Magento\Framework\Exception\LocalizedException( diff --git a/app/code/Magento/Catalog/Model/Product/Option/Value.php b/app/code/Magento/Catalog/Model/Product/Option/Value.php index 37f706b2a8163bc125810af9deae309bf33ff413..227f070a683e75e67bf464442b8c5c5c35b7381e 100644 --- a/app/code/Magento/Catalog/Model/Product/Option/Value.php +++ b/app/code/Magento/Catalog/Model/Product/Option/Value.php @@ -8,10 +8,9 @@ namespace Magento\Catalog\Model\Product\Option; -use Magento\Framework\Model\AbstractExtensibleModel; +use Magento\Framework\Model\AbstractModel; use Magento\Catalog\Model\Product; use Magento\Catalog\Model\Product\Option; -use Magento\Framework\Api\AttributeValueFactory; /** * Catalog product option select type model @@ -23,7 +22,7 @@ use Magento\Framework\Api\AttributeValueFactory; * * @SuppressWarnings(PHPMD.LongVariable) */ -class Value extends AbstractExtensibleModel implements \Magento\Catalog\Api\Data\ProductCustomOptionValuesInterface +class Value extends AbstractModel implements \Magento\Catalog\Api\Data\ProductCustomOptionValuesInterface { /** * Option type percent @@ -66,8 +65,6 @@ class Value extends AbstractExtensibleModel implements \Magento\Catalog\Api\Data /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry - * @param \Magento\Catalog\Api\CategoryAttributeRepositoryInterface $metadataService - * @param AttributeValueFactory $customAttributeFactory * @param \Magento\Catalog\Model\Resource\Product\Option\Value\CollectionFactory $valueCollectionFactory * @param \Magento\Framework\Model\Resource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\Db $resourceCollection @@ -76,8 +73,6 @@ class Value extends AbstractExtensibleModel implements \Magento\Catalog\Api\Data public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, - \Magento\Catalog\Api\CategoryAttributeRepositoryInterface $metadataService, - AttributeValueFactory $customAttributeFactory, \Magento\Catalog\Model\Resource\Product\Option\Value\CollectionFactory $valueCollectionFactory, \Magento\Framework\Model\Resource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\Db $resourceCollection = null, @@ -87,8 +82,6 @@ class Value extends AbstractExtensibleModel implements \Magento\Catalog\Api\Data parent::__construct( $context, $registry, - $metadataService, - $customAttributeFactory, $resource, $resourceCollection, $data diff --git a/app/code/Magento/Catalog/Model/Product/PriceModifier.php b/app/code/Magento/Catalog/Model/Product/PriceModifier.php index 56db5467cbe53959b691c05befeac43498e598c2..d4a2403fbbfe75250e62112f298167b3001def4c 100644 --- a/app/code/Magento/Catalog/Model/Product/PriceModifier.php +++ b/app/code/Magento/Catalog/Model/Product/PriceModifier.php @@ -37,7 +37,7 @@ class PriceModifier { $prices = $product->getData('group_price'); if (is_null($prices)) { - throw new NoSuchEntityException("This product doesn't have group price"); + throw new NoSuchEntityException(__('This product doesn\'t have group price')); } $groupPriceQty = count($prices); @@ -50,15 +50,17 @@ class PriceModifier } if ($groupPriceQty == count($prices)) { throw new NoSuchEntityException( - "Product hasn't group price with such data: customerGroupId = '$customerGroupId'," - . "website = $websiteId." + __( + 'Product hasn\'t group price with such data: customerGroupId = \'%1\', website = %2.', + [$customerGroupId, $websiteId] + ) ); } $product->setData('group_price', $prices); try { $this->productRepository->save($product); } catch (\Exception $exception) { - throw new CouldNotSaveException("Invalid data provided for group price"); + throw new CouldNotSaveException(__('Invalid data provided for group price')); } } @@ -77,7 +79,7 @@ class PriceModifier $prices = $product->getData('tier_price'); // verify if price exist if (is_null($prices)) { - throw new NoSuchEntityException("This product doesn't have tier price"); + throw new NoSuchEntityException(__('This product doesn\'t have tier price')); } $tierPricesQty = count($prices); @@ -95,15 +97,18 @@ class PriceModifier if ($tierPricesQty == count($prices)) { throw new NoSuchEntityException( - "Product hasn't group price with such data: customerGroupId = '$customerGroupId'," - . "website = $websiteId, qty = $qty" + __( + 'Product hasn\'t group price with such data: customerGroupId = \'%1\'' + . ', website = %2, qty = %3', + [$customerGroupId, $websiteId, $qty] + ) ); } $product->setData('tier_price', $prices); try { $this->productRepository->save($product); } catch (\Exception $exception) { - throw new CouldNotSaveException("Invalid data provided for tier_price"); + throw new CouldNotSaveException(__('Invalid data provided for tier_price')); } } } diff --git a/app/code/Magento/Catalog/Model/Product/TierPrice.php b/app/code/Magento/Catalog/Model/Product/TierPrice.php index 6bc86d069d488df581917d40dac7a344791b2f39..4f28981a036f82c1da0c118483cd3f1bc5a1fb8f 100644 --- a/app/code/Magento/Catalog/Model/Product/TierPrice.php +++ b/app/code/Magento/Catalog/Model/Product/TierPrice.php @@ -54,4 +54,26 @@ class TierPrice extends \Magento\Framework\Model\AbstractExtensibleModel impleme { return $this->setData(self::VALUE, $value); } + + /** + * {@inheritdoc} + * + * @return \Magento\Catalog\Api\Data\ProductTierPriceExtensionInterface|null + */ + public function getExtensionAttributes() + { + return $this->_getExtensionAttributes(); + } + + /** + * {@inheritdoc} + * + * @param \Magento\Catalog\Api\Data\ProductTierPriceExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes( + \Magento\Catalog\Api\Data\ProductTierPriceExtensionInterface $extensionAttributes + ) { + return $this->_setExtensionAttributes($extensionAttributes); + } } diff --git a/app/code/Magento/Catalog/Model/Product/TierPriceManagement.php b/app/code/Magento/Catalog/Model/Product/TierPriceManagement.php index e0e4c1695bb786171e377df14fcb73c3240ab628..73ae4f96ea9becf98147146a80eb2b87286b2695 100644 --- a/app/code/Magento/Catalog/Model/Product/TierPriceManagement.php +++ b/app/code/Magento/Catalog/Model/Product/TierPriceManagement.php @@ -85,12 +85,12 @@ class TierPriceManagement implements \Magento\Catalog\Api\ProductTierPriceManage * @SuppressWarnings(PHPMD.CyclomaticComplexity) * @SuppressWarnings(PHPMD.NPathComplexity) */ - public function add($productSku, $customerGroupId, $price, $qty) + public function add($sku, $customerGroupId, $price, $qty) { if (!\Zend_Validate::is($price, 'Float') || $price <= 0 || !\Zend_Validate::is($qty, 'Float') || $qty <= 0) { - throw new InputException('Please provide valid data'); + throw new InputException(__('Please provide valid data')); } - $product = $this->productRepository->get($productSku, ['edit_mode' => true]); + $product = $this->productRepository->get($sku, ['edit_mode' => true]); $tierPrices = $product->getData('tier_price'); $websiteIdentifier = 0; $value = $this->config->getValue('catalog/price/scope', \Magento\Store\Model\ScopeInterface::SCOPE_WEBSITE); @@ -131,13 +131,13 @@ class TierPriceManagement implements \Magento\Catalog\Api\ProductTierPriceManage if (is_array($errors) && count($errors)) { $errorAttributeCodes = implode(', ', array_keys($errors)); throw new InputException( - sprintf('Values of following attributes are invalid: %s', $errorAttributeCodes) + __('Values of following attributes are invalid: %1', $errorAttributeCodes) ); } try { $this->productRepository->save($product); } catch (\Exception $e) { - throw new CouldNotSaveException('Could not save group price'); + throw new CouldNotSaveException(__('Could not save group price')); } return true; } @@ -145,9 +145,9 @@ class TierPriceManagement implements \Magento\Catalog\Api\ProductTierPriceManage /** * {@inheritdoc} */ - public function remove($productSku, $customerGroupId, $qty) + public function remove($sku, $customerGroupId, $qty) { - $product = $this->productRepository->get($productSku, ['edit_mode' => true]); + $product = $this->productRepository->get($sku, ['edit_mode' => true]); $websiteIdentifier = 0; $value = $this->config->getValue('catalog/price/scope', \Magento\Store\Model\ScopeInterface::SCOPE_WEBSITE); if ($value != 0) { @@ -160,9 +160,9 @@ class TierPriceManagement implements \Magento\Catalog\Api\ProductTierPriceManage /** * {@inheritdoc} */ - public function getList($productSku, $customerGroupId) + public function getList($sku, $customerGroupId) { - $product = $this->productRepository->get($productSku, ['edit_mode' => true]); + $product = $this->productRepository->get($sku, ['edit_mode' => true]); $priceKey = 'website_price'; $value = $this->config->getValue('catalog/price/scope', \Magento\Store\Model\ScopeInterface::SCOPE_WEBSITE); diff --git a/app/code/Magento/Catalog/Model/Product/Type/AbstractType.php b/app/code/Magento/Catalog/Model/Product/Type/AbstractType.php index fe9863c9f2cb1703c491fb7673a273b58350ea6c..2a59073ff7f5fb5cca087f9a331c2fd48c7fa013 100644 --- a/app/code/Magento/Catalog/Model/Product/Type/AbstractType.php +++ b/app/code/Magento/Catalog/Model/Product/Type/AbstractType.php @@ -503,7 +503,7 @@ abstract class AbstractType if (isset($queueOptions['option'])) { $queueOptions['option']->setIsValid(false); } - throw new \Magento\Framework\Exception\LocalizedException(__("The file upload failed.")); + throw new \Magento\Framework\Exception\LocalizedException(__('The file upload failed.')); } $this->_fileStorageDb->saveFile($dst); break; diff --git a/app/code/Magento/Catalog/Model/Product/Type/Pool.php b/app/code/Magento/Catalog/Model/Product/Type/Pool.php index 05d9b00bd763dd3cbe4efc89769653abf9766110..fed0942d794009ac05cb47bbb6e543164016dcf9 100644 --- a/app/code/Magento/Catalog/Model/Product/Type/Pool.php +++ b/app/code/Magento/Catalog/Model/Product/Type/Pool.php @@ -42,7 +42,7 @@ class Pool if (!$product instanceof \Magento\Catalog\Model\Product\Type\AbstractType) { throw new \Magento\Framework\Exception\LocalizedException( - $className . ' doesn\'t extends \Magento\Catalog\Model\Product\Type\AbstractType' + __('%1 doesn\'t extends \Magento\Catalog\Model\Product\Type\AbstractType', $className) ); } return $product; diff --git a/app/code/Magento/Catalog/Model/Product/Type/Price/Factory.php b/app/code/Magento/Catalog/Model/Product/Type/Price/Factory.php index b3276c807759c711901de23f2d9acd0ff55f792b..d8015f9390d6b6da18ec4d5a470660b05b4341ae 100644 --- a/app/code/Magento/Catalog/Model/Product/Type/Price/Factory.php +++ b/app/code/Magento/Catalog/Model/Product/Type/Price/Factory.php @@ -42,7 +42,7 @@ class Factory if (!$price instanceof \Magento\Catalog\Model\Product\Type\Price) { throw new \Magento\Framework\Exception\LocalizedException( - $className . ' doesn\'t extends \Magento\Catalog\Model\Product\Type\Price' + __('%1 doesn\'t extends \Magento\Catalog\Model\Product\Type\Price', $className) ); } return $price; diff --git a/app/code/Magento/Catalog/Model/Product/Website.php b/app/code/Magento/Catalog/Model/Product/Website.php index 7782fb5bc260d88988b53b09fbb549ff063928e7..0a389baf909c6472b329f654fbd2d176724f232f 100644 --- a/app/code/Magento/Catalog/Model/Product/Website.php +++ b/app/code/Magento/Catalog/Model/Product/Website.php @@ -53,7 +53,9 @@ class Website extends \Magento\Framework\Model\AbstractModel try { $this->_getResource()->removeProducts($websiteIds, $productIds); } catch (\Exception $e) { - throw new \Magento\Framework\Exception\LocalizedException(__('Something went wrong removing products from the websites.')); + throw new \Magento\Framework\Exception\LocalizedException( + __('Something went wrong removing products from the websites.') + ); } return $this; } @@ -71,7 +73,9 @@ class Website extends \Magento\Framework\Model\AbstractModel try { $this->_getResource()->addProducts($websiteIds, $productIds); } catch (\Exception $e) { - throw new \Magento\Framework\Exception\LocalizedException(__('Something went wrong adding products to websites.')); + throw new \Magento\Framework\Exception\LocalizedException( + __('Something went wrong adding products to websites.') + ); } return $this; } diff --git a/app/code/Magento/Catalog/Model/ProductAttributeGroupRepository.php b/app/code/Magento/Catalog/Model/ProductAttributeGroupRepository.php index 28e1c5cea9bcf6f4797727445c5d12cc5b897ce7..980843c9df25199d036cb861c225cfc5402d9f18 100644 --- a/app/code/Magento/Catalog/Model/ProductAttributeGroupRepository.php +++ b/app/code/Magento/Catalog/Model/ProductAttributeGroupRepository.php @@ -66,7 +66,7 @@ class ProductAttributeGroupRepository implements \Magento\Catalog\Api\ProductAtt $group = $this->groupFactory->create(); $this->groupResource->load($group, $groupId); if (!$group->getId()) { - throw new NoSuchEntityException(sprintf('Group with id "%s" does not exist.', $groupId)); + throw new NoSuchEntityException(__('Group with id "%1" does not exist.', $groupId)); } return $group; } @@ -89,7 +89,9 @@ class ProductAttributeGroupRepository implements \Magento\Catalog\Api\ProductAtt { /** @var \Magento\Catalog\Model\Product\Attribute\Group $group */ if ($group->hasSystemAttributes()) { - throw new StateException('Attribute group that contains system attributes can not be deleted'); + throw new StateException( + __('Attribute group that contains system attributes can not be deleted') + ); } return $this->groupRepository->delete($group); } diff --git a/app/code/Magento/Catalog/Model/ProductLink/Attribute.php b/app/code/Magento/Catalog/Model/ProductLink/Attribute.php index 2a2f15daa3d3856fa5aa14cf447a99f35d791253..ede2f7e22ebc204a430ca75884ab9a726df43510 100644 --- a/app/code/Magento/Catalog/Model/ProductLink/Attribute.php +++ b/app/code/Magento/Catalog/Model/ProductLink/Attribute.php @@ -57,4 +57,26 @@ class Attribute extends \Magento\Framework\Api\AbstractExtensibleObject implemen { return $this->setData(self::KEY_TYPE, $type); } + + /** + * {@inheritdoc} + * + * @return \Magento\Catalog\Api\Data\ProductLinkAttributeExtensionInterface|null + */ + public function getExtensionAttributes() + { + return $this->_getExtensionAttributes(); + } + + /** + * {@inheritdoc} + * + * @param \Magento\Catalog\Api\Data\ProductLinkAttributeExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes( + \Magento\Catalog\Api\Data\ProductLinkAttributeExtensionInterface $extensionAttributes + ) { + return $this->_setExtensionAttributes($extensionAttributes); + } } diff --git a/app/code/Magento/Catalog/Model/ProductLink/CollectionProvider.php b/app/code/Magento/Catalog/Model/ProductLink/CollectionProvider.php index 3a744449e6f23aefa381112a6a1134deaabdcfd8..885ded02d329c339c131e06cc7e4b07d3aa9aa78 100644 --- a/app/code/Magento/Catalog/Model/ProductLink/CollectionProvider.php +++ b/app/code/Magento/Catalog/Model/ProductLink/CollectionProvider.php @@ -42,7 +42,7 @@ class CollectionProvider public function getCollection(\Magento\Catalog\Model\Product $product, $type) { if (!isset($this->providers[$type])) { - throw new NoSuchEntityException('Collection provider is not registered'); + throw new NoSuchEntityException(__('Collection provider is not registered')); } $products = $this->providers[$type]->getLinkedProducts($product); diff --git a/app/code/Magento/Catalog/Model/ProductLink/Link.php b/app/code/Magento/Catalog/Model/ProductLink/Link.php index e105ca4317652fdbb2bfb2ba6384ff1adf58d442..84fdd67df676b354d497de50667e43d0b949ea26 100644 --- a/app/code/Magento/Catalog/Model/ProductLink/Link.php +++ b/app/code/Magento/Catalog/Model/ProductLink/Link.php @@ -167,4 +167,30 @@ class Link extends \Magento\Framework\Model\AbstractExtensibleModel implements { return $this->setData(self::KEY_POSITION, $position); } + + /** + * {@inheritdoc} + * + * @return \Magento\Catalog\Api\Data\ProductLinkExtensionInterface|null + */ + public function getExtensionAttributes() + { + if (!$this->_getExtensionAttributes()) { + $this->setExtensionAttributes( + $this->extensionAttributesFactory->create('Magento\Catalog\Model\ProductLink\Link') + ); + } + return $this->_getExtensionAttributes(); + } + + /** + * {@inheritdoc} + * + * @param \Magento\Catalog\Api\Data\ProductLinkExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes(\Magento\Catalog\Api\Data\ProductLinkExtensionInterface $extensionAttributes) + { + return $this->_setExtensionAttributes($extensionAttributes); + } } diff --git a/app/code/Magento/Catalog/Model/ProductLink/Management.php b/app/code/Magento/Catalog/Model/ProductLink/Management.php index b6d64659e3963c94cbbe52c633a7130541dea79c..558561d22de50af6f402f9201a6138aaba441496 100644 --- a/app/code/Magento/Catalog/Model/ProductLink/Management.php +++ b/app/code/Magento/Catalog/Model/ProductLink/Management.php @@ -70,14 +70,14 @@ class Management implements \Magento\Catalog\Api\ProductLinkManagementInterface /** * {@inheritdoc} */ - public function getLinkedItemsByType($productSku, $type) + public function getLinkedItemsByType($sku, $type) { $output = []; - $product = $this->productRepository->get($productSku); + $product = $this->productRepository->get($sku); try { $collection = $this->entityCollectionProvider->getCollection($product, $type); } catch (NoSuchEntityException $e) { - throw new NoSuchEntityException('Unknown link type: ' . (string)$type); + throw new NoSuchEntityException(__('Unknown link type: %1', (string)$type)); } foreach ($collection as $item) { /** @var \Magento\Catalog\Api\Data\ProductLinkInterface $productLink */ @@ -89,10 +89,7 @@ class Management implements \Magento\Catalog\Api\ProductLinkManagementInterface ->setPosition($item['position']); if (isset($item['custom_attributes'])) { foreach ($item['custom_attributes'] as $option) { - $productLink->setCustomAttribute( - $option['attribute_code'], - $option['value'] - ); + $productLink->getExtensionAttributes()->setQty($option['value']); } } $output[] = $productLink; @@ -103,17 +100,17 @@ class Management implements \Magento\Catalog\Api\ProductLinkManagementInterface /** * {@inheritdoc} */ - public function setProductLinks($productSku, $type, array $items) + public function setProductLinks($sku, $type, array $items) { $linkTypes = $this->linkTypeProvider->getLinkTypes(); if (!isset($linkTypes[$type])) { throw new NoSuchEntityException( - sprintf("Provided link type \"%s\" does not exist", $type) + __('Provided link type "%1" does not exist', $type) ); } - $product = $this->productRepository->get($productSku); + $product = $this->productRepository->get($sku); $assignedSkuList = []; /** @var \Magento\Catalog\Api\Data\ProductLinkInterface $link */ foreach ($items as $link) { @@ -128,7 +125,7 @@ class Management implements \Magento\Catalog\Api\ProductLinkManagementInterface $linkedSku = $link->getLinkedProductSku(); if (!isset($linkedProductIds[$linkedSku])) { throw new NoSuchEntityException( - sprintf("Product with SKU \"%s\" does not exist", $linkedSku) + __('Product with SKU "%1" does not exist', $linkedSku) ); } $data['product_id'] = $linkedProductIds[$linkedSku]; @@ -138,7 +135,7 @@ class Management implements \Magento\Catalog\Api\ProductLinkManagementInterface try { $product->save(); } catch (\Exception $exception) { - throw new CouldNotSaveException('Invalid data provided for linked products'); + throw new CouldNotSaveException(__('Invalid data provided for linked products')); } return true; } diff --git a/app/code/Magento/Catalog/Model/ProductLink/Repository.php b/app/code/Magento/Catalog/Model/ProductLink/Repository.php index 0b18b48b82ca19522f1ad198148a329034e6e21f..282d14bb2c243d74792c7ed4e647af56812bcfcf 100644 --- a/app/code/Magento/Catalog/Model/ProductLink/Repository.php +++ b/app/code/Magento/Catalog/Model/ProductLink/Repository.php @@ -34,21 +34,31 @@ class Repository implements \Magento\Catalog\Api\ProductLinkRepositoryInterface protected $linkManagement; /** + * @var \Magento\Framework\Reflection\DataObjectProcessor + */ + protected $dataObjectProcessor; + + /** + * Initialize dependencies. + * * @param \Magento\Catalog\Api\ProductRepositoryInterface $productRepository * @param CollectionProvider $entityCollectionProvider * @param LinksInitializer $linkInitializer * @param Management $linkManagement + * @param \Magento\Framework\Reflection\DataObjectProcessor $dataObjectProcessor */ public function __construct( \Magento\Catalog\Api\ProductRepositoryInterface $productRepository, \Magento\Catalog\Model\ProductLink\CollectionProvider $entityCollectionProvider, \Magento\Catalog\Model\Product\Initialization\Helper\ProductLinks $linkInitializer, - \Magento\Catalog\Model\ProductLink\Management $linkManagement + \Magento\Catalog\Model\ProductLink\Management $linkManagement, + \Magento\Framework\Reflection\DataObjectProcessor $dataObjectProcessor ) { $this->productRepository = $productRepository; $this->entityCollectionProvider = $entityCollectionProvider; $this->linkInitializer = $linkInitializer; $this->linkManagement = $linkManagement; + $this->dataObjectProcessor = $dataObjectProcessor; } /** @@ -59,18 +69,23 @@ class Repository implements \Magento\Catalog\Api\ProductLinkRepositoryInterface $linkedProduct = $this->productRepository->get($entity->getLinkedProductSku()); $product = $this->productRepository->get($entity->getProductSku()); $links = $this->entityCollectionProvider->getCollection($product, $entity->getLinkType()); - + $extensions = $this->dataObjectProcessor->buildOutputDataArray( + $entity->getExtensionAttributes(), + 'Magento\Catalog\Api\Data\ProductLinkExtensionInterface' + ); + $extensions = is_array($extensions) ? $extensions : []; $data = $entity->__toArray(); - foreach ($entity->getCustomAttributes() as $attribute) { - $data[$attribute->getAttributeCode()] = $attribute->getValue(); + foreach ($extensions as $attributeCode => $attribute) { + $data[$attributeCode] = $attribute; } + unset($data['extension_attributes']); $data['product_id'] = $linkedProduct->getId(); $links[$linkedProduct->getId()] = $data; $this->linkInitializer->initializeLinks($product, [$entity->getLinkType() => $links]); try { $product->save(); } catch (\Exception $exception) { - throw new CouldNotSaveException('Invalid data provided for linked products'); + throw new CouldNotSaveException(__('Invalid data provided for linked products')); } return true; } @@ -86,8 +101,8 @@ class Repository implements \Magento\Catalog\Api\ProductLinkRepositoryInterface if (!isset($links[$linkedProduct->getId()])) { throw new NoSuchEntityException( - sprintf( - 'Product with SKU %s is not linked to product with SKU %s', + __( + 'Product with SKU %1 is not linked to product with SKU %2', $entity->getLinkedProductSku(), $entity->getProductSku() ) @@ -100,7 +115,7 @@ class Repository implements \Magento\Catalog\Api\ProductLinkRepositoryInterface try { $product->save(); } catch (\Exception $exception) { - throw new CouldNotSaveException('Invalid data provided for linked products'); + throw new CouldNotSaveException(__('Invalid data provided for linked products')); } return true; } @@ -108,9 +123,9 @@ class Repository implements \Magento\Catalog\Api\ProductLinkRepositoryInterface /** * {@inheritdoc} */ - public function deleteById($productSku, $type, $linkedProductSku) + public function deleteById($sku, $type, $linkedProductSku) { - $linkItems = $this->linkManagement->getLinkedItemsByType($productSku, $type); + $linkItems = $this->linkManagement->getLinkedItemsByType($sku, $type); /** @var \Magento\Catalog\Api\Data\ProductLinkInterface $linkItem */ foreach ($linkItems as $linkItem) { if ($linkItem->getLinkedProductSku() == $linkedProductSku) { @@ -118,12 +133,14 @@ class Repository implements \Magento\Catalog\Api\ProductLinkRepositoryInterface } } throw new NoSuchEntityException( - 'Product %s doesn\'t have linked %s as %s', - [ - $productSku, - $linkedProductSku, - $type - ] + __( + 'Product %1 doesn\'t have linked %2 as %3', + [ + $sku, + $linkedProductSku, + $type + ] + ) ); } } diff --git a/app/code/Magento/Catalog/Model/ProductLink/Type.php b/app/code/Magento/Catalog/Model/ProductLink/Type.php index 493bece24b31469e1b6d35608335a710949ec1f7..278662033f544a84c4121449205c05473f7a76f4 100644 --- a/app/code/Magento/Catalog/Model/ProductLink/Type.php +++ b/app/code/Magento/Catalog/Model/ProductLink/Type.php @@ -57,4 +57,26 @@ class Type extends \Magento\Framework\Api\AbstractExtensibleObject implements Pr { return $this->setData(self::KEY_NAME, $name); } + + /** + * {@inheritdoc} + * + * @return \Magento\Catalog\Api\Data\ProductLinkTypeExtensionInterface|null + */ + public function getExtensionAttributes() + { + return $this->_getExtensionAttributes(); + } + + /** + * {@inheritdoc} + * + * @param \Magento\Catalog\Api\Data\ProductLinkTypeExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes( + \Magento\Catalog\Api\Data\ProductLinkTypeExtensionInterface $extensionAttributes + ) { + return $this->_setExtensionAttributes($extensionAttributes); + } } diff --git a/app/code/Magento/Catalog/Model/ProductRepository.php b/app/code/Magento/Catalog/Model/ProductRepository.php index a42e163a2b0b6ee5d0f3c037c9efc102e4c3917e..ae3fd0df2e6c8a4f5963957eead7caff999ba57f 100644 --- a/app/code/Magento/Catalog/Model/ProductRepository.php +++ b/app/code/Magento/Catalog/Model/ProductRepository.php @@ -71,6 +71,16 @@ class ProductRepository implements \Magento\Catalog\Api\ProductRepositoryInterfa */ protected $metadataService; + /** + * @var \Magento\Eav\Model\Config + */ + protected $eavConfig; + + /** + * @var \Magento\Framework\Api\ExtensibleDataObjectConverter + */ + protected $extensibleDataObjectConverter; + /** * @param ProductFactory $productFactory * @param \Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper $initializationHelper @@ -81,6 +91,9 @@ class ProductRepository implements \Magento\Catalog\Api\ProductRepositoryInterfa * @param Resource\Product $resourceModel * @param \Magento\Framework\Api\FilterBuilder $filterBuilder * @param \Magento\Catalog\Api\ProductAttributeRepositoryInterface $metadataServiceInterface + * @param \Magento\Framework\Api\ExtensibleDataObjectConverter $extensibleDataObjectConverter + * @param \Magento\Eav\Model\Config $eavConfig + * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( ProductFactory $productFactory, @@ -91,7 +104,9 @@ class ProductRepository implements \Magento\Catalog\Api\ProductRepositoryInterfa \Magento\Catalog\Api\ProductAttributeRepositoryInterface $attributeRepository, \Magento\Catalog\Model\Resource\Product $resourceModel, \Magento\Framework\Api\FilterBuilder $filterBuilder, - \Magento\Catalog\Api\ProductAttributeRepositoryInterface $metadataServiceInterface + \Magento\Catalog\Api\ProductAttributeRepositoryInterface $metadataServiceInterface, + \Magento\Framework\Api\ExtensibleDataObjectConverter $extensibleDataObjectConverter, + \Magento\Eav\Model\Config $eavConfig ) { $this->productFactory = $productFactory; $this->collectionFactory = $collectionFactory; @@ -102,6 +117,8 @@ class ProductRepository implements \Magento\Catalog\Api\ProductRepositoryInterfa $this->attributeRepository = $attributeRepository; $this->filterBuilder = $filterBuilder; $this->metadataService = $metadataServiceInterface; + $this->extensibleDataObjectConverter = $extensibleDataObjectConverter; + $this->eavConfig = $eavConfig; } /** @@ -115,7 +132,7 @@ class ProductRepository implements \Magento\Catalog\Api\ProductRepositoryInterfa $productId = $this->resourceModel->getIdBySku($sku); if (!$productId) { - throw new NoSuchEntityException('Requested product doesn\'t exist'); + throw new NoSuchEntityException(__('Requested product doesn\'t exist')); } if ($editMode) { $product->setData('_edit_mode', true); @@ -144,7 +161,7 @@ class ProductRepository implements \Magento\Catalog\Api\ProductRepositoryInterfa } $product->load($productId); if (!$product->getId()) { - throw new NoSuchEntityException('Requested product doesn\'t exist'); + throw new NoSuchEntityException(__('Requested product doesn\'t exist')); } $this->instancesById[$productId][$cacheKey] = $product; $this->instances[$product->getSku()][$cacheKey] = $product; @@ -201,18 +218,29 @@ class ProductRepository implements \Magento\Catalog\Api\ProductRepositoryInterfa */ public function save(\Magento\Catalog\Api\Data\ProductInterface $product, $saveOptions = false) { + if ($saveOptions) { + $productOptions = $product->getProductOptions(); + } + $groupPrices = $product->getData('group_price'); + $tierPrices = $product->getData('tier_price'); + $productId = $this->resourceModel->getIdBySku($product->getSku()); - $product = $this->initializeProductData($product->toFlatArray(), empty($productId)); + $productDataArray = $this->extensibleDataObjectConverter + ->toNestedArray($product, [], 'Magento\Catalog\Api\Data\ProductInterface'); + $product = $this->initializeProductData($productDataArray, empty($productId)); $validationResult = $this->resourceModel->validate($product); if (true !== $validationResult) { throw new \Magento\Framework\Exception\CouldNotSaveException( - sprintf('Invalid product data: %s', implode(',', $validationResult)) + __('Invalid product data: %1', implode(',', $validationResult)) ); } try { if ($saveOptions) { + $product->setProductOptions($productOptions); $product->setCanSaveCustomOptions(true); } + $product->setData('group_price', $groupPrices); + $product->setData('tier_price', $tierPrices); $this->resourceModel->save($product); } catch (\Magento\Eav\Model\Entity\Attribute\Exception $exception) { throw \Magento\Framework\Exception\InputException::invalidFieldValue( @@ -221,7 +249,7 @@ class ProductRepository implements \Magento\Catalog\Api\ProductRepositoryInterfa $exception ); } catch (\Exception $e) { - throw new \Magento\Framework\Exception\CouldNotSaveException('Unable to save product'); + throw new \Magento\Framework\Exception\CouldNotSaveException(__('Unable to save product')); } unset($this->instances[$product->getSku()]); unset($this->instancesById[$product->getId()]); @@ -233,14 +261,16 @@ class ProductRepository implements \Magento\Catalog\Api\ProductRepositoryInterfa */ public function delete(\Magento\Catalog\Api\Data\ProductInterface $product) { - $productSku = $product->getSku(); + $sku = $product->getSku(); $productId = $product->getId(); try { $this->resourceModel->delete($product); } catch (\Exception $e) { - throw new \Magento\Framework\Exception\StateException('Unable to remove product ' . $productSku); + throw new \Magento\Framework\Exception\StateException( + __('Unable to remove product %1', $sku) + ); } - unset($this->instances[$productSku]); + unset($this->instances[$sku]); unset($this->instancesById[$productId]); return true; } @@ -248,9 +278,9 @@ class ProductRepository implements \Magento\Catalog\Api\ProductRepositoryInterfa /** * {@inheritdoc} */ - public function deleteById($productSku) + public function deleteById($sku) { - $product = $this->get($productSku); + $product = $this->get($sku); return $this->delete($product); } @@ -261,12 +291,14 @@ class ProductRepository implements \Magento\Catalog\Api\ProductRepositoryInterfa { /** @var \Magento\Catalog\Model\Resource\Product\Collection $collection */ $collection = $this->collectionFactory->create(); - + $defaultAttributeSetId = $this->eavConfig + ->getEntityType(\Magento\Catalog\Api\Data\ProductAttributeInterface::ENTITY_TYPE_CODE) + ->getDefaultAttributeSetId(); $extendedSearchCriteria = $this->searchCriteriaBuilder->addFilter( [ $this->filterBuilder ->setField('attribute_set_id') - ->setValue(\Magento\Catalog\Api\Data\ProductAttributeInterface::DEFAULT_ATTRIBUTE_SET_ID) + ->setValue($defaultAttributeSetId) ->create(), ] ); diff --git a/app/code/Magento/Catalog/Model/ProductType.php b/app/code/Magento/Catalog/Model/ProductType.php index 2f5f266b2a6a0cf44456353cdf94252cf87f3bc3..ba9a7e5c4150d092bf100967d2ebc9599404f983 100644 --- a/app/code/Magento/Catalog/Model/ProductType.php +++ b/app/code/Magento/Catalog/Model/ProductType.php @@ -58,4 +58,26 @@ class ProductType extends \Magento\Framework\Api\AbstractExtensibleObject implem { return $this->setData(self::KEY_LABEL, $label); } + + /** + * {@inheritdoc} + * + * @return \Magento\Catalog\Api\Data\ProductTypeExtensionInterface|null + */ + public function getExtensionAttributes() + { + return $this->_getExtensionAttributes(); + } + + /** + * {@inheritdoc} + * + * @param \Magento\Catalog\Api\Data\ProductTypeExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes( + \Magento\Catalog\Api\Data\ProductTypeExtensionInterface $extensionAttributes + ) { + return $this->_setExtensionAttributes($extensionAttributes); + } } diff --git a/app/code/Magento/Catalog/Model/Resource/Attribute.php b/app/code/Magento/Catalog/Model/Resource/Attribute.php index 31d0da053ba201b7f390b40143b3913c35708f8c..b54445ceaa95d1e48ee91becc731e0d1b344abb9 100644 --- a/app/code/Magento/Catalog/Model/Resource/Attribute.php +++ b/app/code/Magento/Catalog/Model/Resource/Attribute.php @@ -132,7 +132,7 @@ class Attribute extends \Magento\Eav\Model\Resource\Entity\Attribute $this->attrLockValidator->validate($attribute, $result['attribute_set_id']); } catch (\Magento\Framework\Exception\LocalizedException $exception) { throw new \Magento\Framework\Exception\LocalizedException( - __("Attribute '%1' is locked. ", $attribute->getAttributeCode()) . $exception->getMessage() + __('Attribute \'%1\' is locked. %2', $attribute->getAttributeCode(), $exception->getMessage()) ); } diff --git a/app/code/Magento/Catalog/Model/Resource/Eav/Attribute.php b/app/code/Magento/Catalog/Model/Resource/Eav/Attribute.php index 0a0800ce27bcd3617a68ead274a74662adcbf419..63b02e7e2308251a9a66f489806f2f5ef0c783e7 100644 --- a/app/code/Magento/Catalog/Model/Resource/Eav/Attribute.php +++ b/app/code/Magento/Catalog/Model/Resource/Eav/Attribute.php @@ -23,6 +23,7 @@ use Magento\Framework\Api\AttributeValueFactory; * @method int setSearchWeight(int $value) * @method \Magento\Catalog\Model\Resource\Eav\Attribute getIsUsedForPriceRules() * @method int setIsUsedForPriceRules(int $value) + * @method \Magento\Eav\Api\Data\AttributeExtensionInterface getExtensionAttributes() * * @author Magento Core Team <core@magentocommerce.com> * @SuppressWarnings(PHPMD.CouplingBetweenObjects) @@ -88,7 +89,7 @@ class Attribute extends \Magento\Eav\Model\Entity\Attribute implements /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry - * @param \Magento\Framework\Api\MetadataServiceInterface $metadataService + * @param \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory * @param AttributeValueFactory $customAttributeFactory * @param \Magento\Eav\Model\Config $eavConfig * @param \Magento\Eav\Model\Entity\TypeFactory $eavTypeFactory @@ -113,7 +114,7 @@ class Attribute extends \Magento\Eav\Model\Entity\Attribute implements public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, - \Magento\Framework\Api\MetadataServiceInterface $metadataService, + \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory, AttributeValueFactory $customAttributeFactory, \Magento\Eav\Model\Config $eavConfig, \Magento\Eav\Model\Entity\TypeFactory $eavTypeFactory, @@ -141,7 +142,7 @@ class Attribute extends \Magento\Eav\Model\Entity\Attribute implements parent::__construct( $context, $registry, - $metadataService, + $extensionFactory, $customAttributeFactory, $eavConfig, $eavTypeFactory, @@ -186,7 +187,9 @@ class Attribute extends \Magento\Eav\Model\Entity\Attribute implements try { $this->attrLockValidator->validate($this); } catch (\Magento\Framework\Exception\LocalizedException $exception) { - throw new \Magento\Framework\Exception\LocalizedException(__('Do not change the scope. ' . $exception->getMessage())); + throw new \Magento\Framework\Exception\LocalizedException( + __('Do not change the scope. %1', $exception->getMessage()) + ); } } } diff --git a/app/code/Magento/Catalog/Model/Template/Filter/Factory.php b/app/code/Magento/Catalog/Model/Template/Filter/Factory.php index f91726c700c126971ed1eeb5c8be433d122df1fa..569bed1e495c6515f2ff0d3b9743ed263c62c971 100644 --- a/app/code/Magento/Catalog/Model/Template/Filter/Factory.php +++ b/app/code/Magento/Catalog/Model/Template/Filter/Factory.php @@ -43,7 +43,9 @@ class Factory $filter = $this->_objectManager->create($className, $data); if (!$filter instanceof \Magento\Framework\Filter\Template) { - throw new \Magento\Framework\Exception\LocalizedException($className . ' doesn\'t extends \Magento\Framework\Filter\Template'); + throw new \Magento\Framework\Exception\LocalizedException( + __('%1 doesn\'t extend \Magento\Framework\Filter\Template', $className) + ); } return $filter; } diff --git a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/SaveTest.php b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/SaveTest.php index 94b386f8c656e9f31d8a1beb0e08d4e2d71fa73e..9b5bb8d759b6b78396f9bf4db5792c1259e3d56f 100644 --- a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/SaveTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/SaveTest.php @@ -22,7 +22,7 @@ class SaveTest extends \PHPUnit_Framework_TestCase protected $resultRawFactoryMock; /** - * @var \Magento\Framework\Controller\Result\JSONFactory|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Controller\Result\JsonFactory|\PHPUnit_Framework_MockObject_MockObject */ protected $resultJsonFactoryMock; @@ -115,7 +115,7 @@ class SaveTest extends \PHPUnit_Framework_TestCase false ); $this->resultJsonFactoryMock = $this->getMock( - 'Magento\Framework\Controller\Result\JSONFactory', + 'Magento\Framework\Controller\Result\JsonFactory', ['create'], [], '', @@ -350,7 +350,7 @@ class SaveTest extends \PHPUnit_Framework_TestCase ['getMessagesBlock'] ); /** - * @var \Magento\Framework\Controller\Result\JSON + * @var \Magento\Framework\Controller\Result\Json * |\PHPUnit_Framework_MockObject_MockObject $resultJsonMock */ $resultJsonMock = $this->getMock( diff --git a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/Widget/CategoriesJsonTest.php b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/Widget/CategoriesJsonTest.php index 5846a299d0e5573ad4468abea1722047719eaf28..26b7598e03b0f7609ea78634148aa01d4a227799 100644 --- a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/Widget/CategoriesJsonTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/Widget/CategoriesJsonTest.php @@ -52,7 +52,7 @@ class CategoriesJsonTest extends \PHPUnit_Framework_TestCase protected $objectManagerMock; /** - * @var \Magento\Framework\Controller\Result\JSON|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Controller\Result\Json|\PHPUnit_Framework_MockObject_MockObject */ protected $resultJson; @@ -84,10 +84,10 @@ class CategoriesJsonTest extends \PHPUnit_Framework_TestCase ) ); - $this->resultJson = $this->getMockBuilder('Magento\Framework\Controller\Result\JSON') + $this->resultJson = $this->getMockBuilder('Magento\Framework\Controller\Result\Json') ->disableOriginalConstructor() ->getMock(); - $resultJsonFactory = $this->getMockBuilder('Magento\Framework\Controller\Result\JSONFactory') + $resultJsonFactory = $this->getMockBuilder('Magento\Framework\Controller\Result\JsonFactory') ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); diff --git a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/SaveTest.php b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/SaveTest.php index 84bf8ed85a12bda25808f7b258bc33ceaf0365f7..77f31ab47a4f6636792d227686854e328e0ac3a2 100644 --- a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/SaveTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/SaveTest.php @@ -27,6 +27,9 @@ class SaveTest extends \Magento\Catalog\Test\Unit\Controller\Adminhtml\ProductTe /** @var Helper|\PHPUnit_Framework_MockObject_MockObject */ protected $initializationHelper; + /** + * @return void + */ protected function setUp() { $this->productBuilder = $this->getMock( @@ -101,8 +104,9 @@ class SaveTest extends \Magento\Catalog\Test\Unit\Controller\Adminhtml\ProductTe } /** - * @dataProvider exceptionTypeDataProvider * @param string $exceptionType + * @return void + * @dataProvider exceptionTypeDataProvider */ public function testExecuteSetsProductDataToSessionAndRedirectsToNewActionOnError($exceptionType) { @@ -111,7 +115,7 @@ class SaveTest extends \Magento\Catalog\Test\Unit\Controller\Adminhtml\ProductTe $this->request->expects($this->any())->method('getPostValue')->willReturn($productData); $this->initializationHelper->expects($this->any())->method('initialize') ->willReturn($this->product); - $this->product->expects($this->any())->method('getSku')->willThrowException(new $exceptionType('message')); + $this->product->expects($this->any())->method('getSku')->willThrowException(new $exceptionType(__('message'))); $this->session->expects($this->once())->method('setProductData')->with($productData); $this->resultRedirect->expects($this->once())->method('setPath')->with('catalog/*/new'); diff --git a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/ValidateTest.php b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/ValidateTest.php new file mode 100644 index 0000000000000000000000000000000000000000..2de489fa7a9e3a5eff966359a1dd3e5eb3e65e09 --- /dev/null +++ b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/ValidateTest.php @@ -0,0 +1,140 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Catalog\Test\Unit\Controller\Adminhtml\Product; + +use Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper; +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; + +class ValidateTest extends \Magento\Catalog\Test\Unit\Controller\Adminhtml\ProductTest +{ + /** @var \Magento\Catalog\Controller\Adminhtml\Product\Validate */ + protected $action; + /** @var \Magento\Backend\Model\View\Result\Page|\PHPUnit_Framework_MockObject_MockObject */ + protected $resultPage; + /** @var \Magento\Backend\Model\View\Result\Forward|\PHPUnit_Framework_MockObject_MockObject */ + protected $resultForward; + /** @var \Magento\Catalog\Controller\Adminhtml\Product\Builder|\PHPUnit_Framework_MockObject_MockObject */ + protected $productBuilder; + /** @var \Magento\Catalog\Model\Product|\PHPUnit_Framework_MockObject_MockObject */ + protected $product; + /** @var \Magento\Backend\Model\View\Result\RedirectFactory|\PHPUnit_Framework_MockObject_MockObject */ + protected $resultRedirectFactory; + /** @var \Magento\Backend\Model\View\Result\Redirect|\PHPUnit_Framework_MockObject_MockObject */ + protected $resultRedirect; + /** @var Helper|\PHPUnit_Framework_MockObject_MockObject */ + protected $initializationHelper; + /** @var \Magento\Catalog\Model\ProductFactory|\PHPUnit_Framework_MockObject_MockObject */ + protected $productFactory; + /** @var \Magento\Framework\Controller\Result\JSON|\PHPUnit_Framework_MockObject_MockObject */ + protected $resultJson; + /** @var \Magento\Framework\Controller\Result\JSONFactory|\PHPUnit_Framework_MockObject_MockObject */ + protected $resultJsonFactory; + + protected function setUp() + { + $this->productBuilder = $this->getMock( + 'Magento\Catalog\Controller\Adminhtml\Product\Builder', + ['build'], + [], + '', + false + ); + $this->product = $this->getMockBuilder('Magento\Catalog\Model\Product')->disableOriginalConstructor() + ->setMethods([ + 'addData', 'getSku', 'getTypeId', 'getStoreId', '__sleep', '__wakeup', 'getAttributes', + 'setAttributeSetId', + ]) + ->getMock(); + $this->product->expects($this->any())->method('getTypeId')->will($this->returnValue('simple')); + $this->product->expects($this->any())->method('getStoreId')->will($this->returnValue('1')); + $this->product->expects($this->any())->method('getAttributes')->will($this->returnValue([])); + $this->productBuilder->expects($this->any())->method('build')->will($this->returnValue($this->product)); + + $this->resultPage = $this->getMockBuilder('Magento\Backend\Model\View\Result\Page') + ->disableOriginalConstructor() + ->getMock(); + + $resultPageFactory = $this->getMockBuilder('Magento\Framework\View\Result\PageFactory') + ->disableOriginalConstructor() + ->setMethods(['create']) + ->getMock(); + $resultPageFactory->expects($this->any())->method('create')->willReturn($this->resultPage); + + $this->resultForward = $this->getMockBuilder('Magento\Backend\Model\View\Result\Forward') + ->disableOriginalConstructor() + ->getMock(); + $resultForwardFactory = $this->getMockBuilder('Magento\Backend\Model\View\Result\ForwardFactory') + ->disableOriginalConstructor() + ->setMethods(['create']) + ->getMock(); + $resultForwardFactory->expects($this->any()) + ->method('create') + ->willReturn($this->resultForward); + $this->resultPage->expects($this->any())->method('getLayout')->willReturn($this->layout); + $this->resultRedirectFactory = $this->getMock( + 'Magento\Backend\Model\View\Result\RedirectFactory', + ['create'], + [], + '', + false + ); + $this->resultRedirect = $this->getMock( + 'Magento\Backend\Model\View\Result\Redirect', + [], + [], + '', + false + ); + $this->resultRedirectFactory->expects($this->any())->method('create')->willReturn($this->resultRedirect); + + $this->initializationHelper = $this->getMock( + 'Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper', + [], + [], + '', + false + ); + + $this->productFactory = $this->getMockBuilder('Magento\Catalog\Model\ProductFactory') + ->disableOriginalConstructor() + ->setMethods(['create']) + ->getMock(); + $this->productFactory->expects($this->any())->method('create')->willReturn($this->product); + + $this->resultJson = $this->getMock('Magento\Framework\Controller\Result\JSON', [], [], '', false); + $this->resultJsonFactory = $this->getMockBuilder('Magento\Framework\Controller\Result\JSONFactory') + ->disableOriginalConstructor() + ->setMethods(['create']) + ->getMock(); + $this->resultJsonFactory->expects($this->any())->method('create')->willReturn($this->resultJson); + + $this->action = (new ObjectManagerHelper($this))->getObject( + 'Magento\Catalog\Controller\Adminhtml\Product\Validate', + [ + 'context' => $this->initContext(), + 'productBuilder' => $this->productBuilder, + 'resultPageFactory' => $resultPageFactory, + 'resultForwardFactory' => $resultForwardFactory, + 'resultRedirectFactory' => $this->resultRedirectFactory, + 'initializationHelper' => $this->initializationHelper, + 'resultJsonFactory' => $this->resultJsonFactory, + 'productFactory' => $this->productFactory, + ] + ); + } + + /** + * @return void + */ + public function testAttributeSetIsObtainedFromPost() + { + $this->request->expects($this->any())->method('getPost')->willReturnMap([['set', null, 9]]); + + $this->product->expects($this->once())->method('setAttributeSetId')->with(9); + + $this->action->execute(); + } +} diff --git a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/ProductTest.php b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/ProductTest.php index 0deb8c5810accfe642978c0b698292da42b0ba71..3e04c8a0c27f345cb2ef5892098f65a04f61b667 100644 --- a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/ProductTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/ProductTest.php @@ -41,7 +41,7 @@ abstract class ProductTest extends \PHPUnit_Framework_TestCase ->setMethods(['add'])->disableOriginalConstructor()->getMock(); $title->expects($this->any())->method('prepend')->withAnyParameters()->will($this->returnSelf()); $requestInterfaceMock = $this->getMockBuilder('Magento\Framework\App\Request\Http')->setMethods( - ['getParam', 'getFullActionName', 'getPostValue'] + ['getParam', 'getPost', 'getFullActionName', 'getPostValue'] )->disableOriginalConstructor()->getMock(); $responseInterfaceMock = $this->getMockBuilder('Magento\Framework\App\ResponseInterface')->setMethods( diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Category/AttributeRepositoryTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Category/AttributeRepositoryTest.php index e5948f941ab03c593376010814923b26705c193b..c2c63a0ed168c2dab56f20bf9044fd9310bed2fa 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Category/AttributeRepositoryTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Category/AttributeRepositoryTest.php @@ -9,7 +9,8 @@ namespace Magento\Catalog\Test\Unit\Model\Category; -use \Magento\Catalog\Model\Category\AttributeRepository; +use Magento\Catalog\Model\Category\AttributeRepository; +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; class AttributeRepositoryTest extends \PHPUnit_Framework_TestCase { @@ -36,12 +37,12 @@ class AttributeRepositoryTest extends \PHPUnit_Framework_TestCase /** * @var \PHPUnit_Framework_MockObject_MockObject */ - protected $metadataConfigMock; + protected $searchResultMock; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Eav\Model\Config|\PHPUnit_Framework_MockObject_MockObject */ - protected $searchResultMock; + protected $eavConfigMock; protected function setUp() { @@ -51,8 +52,6 @@ class AttributeRepositoryTest extends \PHPUnit_Framework_TestCase $this->getMock('Magento\Framework\Api\FilterBuilder', [], [], '', false); $this->attributeRepositoryMock = $this->getMock('Magento\Eav\Api\AttributeRepositoryInterface', [], [], '', false); - $this->metadataConfigMock = - $this->getMock('Magento\Framework\Api\Config\MetadataConfig', [], [], '', false); $this->searchResultMock = $this->getMock( 'Magento\Framework\Api\SearchResultsInterface', @@ -63,16 +62,22 @@ class AttributeRepositoryTest extends \PHPUnit_Framework_TestCase 'setItems', 'setSearchCriteria', 'setTotalCount', - '__wakeup' + '__wakeup', ], [], '', false); - $this->model = new AttributeRepository( - $this->metadataConfigMock, - $this->searchBuilderMock, - $this->filterBuilderMock, - $this->attributeRepositoryMock + $this->eavConfigMock = $this->getMock('Magento\Eav\Model\Config', [], [], '', false); + $this->eavConfigMock->expects($this->any())->method('getEntityType') + ->willReturn(new \Magento\Framework\Object(['default_attribute_set_id' => 3])); + $this->model = (new ObjectManager($this))->getObject( + 'Magento\Catalog\Model\Category\AttributeRepository', + [ + 'searchCriteriaBuilder' => $this->searchBuilderMock, + 'filterBuilder' => $this->filterBuilderMock, + 'eavAttributeRepository' => $this->attributeRepositoryMock, + 'eavConfig' => $this->eavConfigMock, + ] ); } @@ -106,7 +111,7 @@ class AttributeRepositoryTest extends \PHPUnit_Framework_TestCase $this->filterBuilderMock->expects($this->once())->method('setField') ->with('attribute_set_id')->willReturnSelf(); $this->filterBuilderMock->expects($this->once())->method('setValue')->with( - \Magento\Catalog\Api\Data\CategoryAttributeInterface::DEFAULT_ATTRIBUTE_SET_ID + 3 )->willReturnSelf(); $this->filterBuilderMock->expects($this->once())->method('create')->willReturn($filterMock); $this->searchBuilderMock->expects($this->once())->method('addFilter')->with([$filterMock])->willReturnSelf(); @@ -118,9 +123,7 @@ class AttributeRepositoryTest extends \PHPUnit_Framework_TestCase $searchCriteriaMock )->willReturn($this->searchResultMock); $this->searchResultMock->expects($this->once())->method('getItems')->willReturn([$itemMock]); - $this->metadataConfigMock->expects($this->once()) - ->method('getCustomAttributesMetadata')->with(null)->willReturn(['attribute']); - $expected = array_merge([$itemMock], ['attribute']); + $expected = [$itemMock]; $this->assertEquals($expected, $this->model->getCustomAttributesMetadata(null)); } diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Entity/AttributeTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Entity/AttributeTest.php index 0ecf9b024aa0704ace1dfca1bdca098d9e8a5402..ca53d6b6fec5f0d7b2276692bdb65bd86a88b0d8 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Entity/AttributeTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Entity/AttributeTest.php @@ -4,6 +4,8 @@ * See COPYING.txt for license details. */ +// @codingStandardsIgnoreFile + namespace Magento\Catalog\Test\Unit\Model\Entity; use Magento\Catalog\Model\Entity\Attribute; @@ -114,6 +116,11 @@ class AttributeTest extends \PHPUnit_Framework_TestCase */ private $dataObjectHelperMock; + /** + * @var \Magento\Framework\Api\ExtensionAttributesFactory|\PHPUnit_Framework_MockObject_MockObject + */ + private $extensionAttributesFactory; + protected function setUp() { $this->contextMock = $this->getMockBuilder('Magento\Framework\Model\Context') @@ -124,6 +131,9 @@ class AttributeTest extends \PHPUnit_Framework_TestCase ->getMock(); $this->metadataServiceMock = $this->getMockBuilder('Magento\Framework\Api\MetadataServiceInterface') ->getMock(); + $this->extensionAttributesFactory = $this->getMockBuilder('Magento\Framework\Api\ExtensionAttributesFactory') + ->disableOriginalConstructor() + ->getMock(); $this->attributeValueFactoryMock = $this->getMockBuilder('Magento\Framework\Api\AttributeValueFactory') ->disableOriginalConstructor() ->getMock(); @@ -181,7 +191,7 @@ class AttributeTest extends \PHPUnit_Framework_TestCase $this->attribute = new Attribute( $this->contextMock, $this->registryMock, - $this->metadataServiceMock, + $this->extensionAttributesFactory, $this->attributeValueFactoryMock, $this->configMock, $this->typeFactoryMock, diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ObserverTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ObserverTest.php index d9d783495bd1332cd1d432a201e86e8b0b8969ea..5da2e23ba4b8268b5ec9b21a8b910a6c75597a46 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/ObserverTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/ObserverTest.php @@ -4,6 +4,8 @@ * See COPYING.txt for license details. */ +// @codingStandardsIgnoreFile + namespace Magento\Catalog\Test\Unit\Model; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; @@ -63,7 +65,6 @@ class ObserverTest extends \PHPUnit_Framework_TestCase ->getMock(); $this->_observer = (new ObjectManager($this))->getObject('Magento\Catalog\Model\Observer', [ - 'urlFactory' => $this->_getCleanMock('\Magento\Catalog\Model\UrlFactory'), 'categoryResource' => $this->_getCleanMock('\Magento\Catalog\Model\Resource\Category'), 'catalogProduct' => $this->_getCleanMock('\Magento\Catalog\Model\Resource\Product'), 'storeManager' => $this->_storeManager, diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/RepositoryTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/RepositoryTest.php index e738b7e96bfeee4c68abcb87a6f07cfeffdf56fe..0689f5062dcca1d5ab7f07efd57b35de33e81b6d 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/RepositoryTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/RepositoryTest.php @@ -79,14 +79,14 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase $this->eavAttributeRepositoryMock = $this->getMock('Magento\Eav\Api\AttributeRepositoryInterface', [], [], '', false); $this->eavConfigMock = $this->getMock('Magento\Eav\Model\Config', [], [], '', false); + $this->eavConfigMock->expects($this->any())->method('getEntityType') + ->willReturn(new \Magento\Framework\Object(['default_attribute_set_id' => 4])); $this->validatorFactoryMock = $this->getMock( 'Magento\Eav\Model\Adminhtml\System\Config\Source\Inputtype\ValidatorFactory', [], [], '', false); - $this->metadataConfigMock = - $this->getMock('Magento\Framework\Api\Config\MetadataConfig', [], [], '', false); $this->searchCriteriaBuilderMock = $this->getMock('Magento\Framework\Api\SearchCriteriaBuilder', [], [], '', false); $this->filterBuilderMock = @@ -101,7 +101,7 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase 'setItems', 'setSearchCriteria', 'setTotalCount', - '__wakeup' + '__wakeup', ], [], '', @@ -114,7 +114,6 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase $this->eavAttributeRepositoryMock, $this->eavConfigMock, $this->validatorFactoryMock, - $this->metadataConfigMock, $this->searchCriteriaBuilderMock, $this->filterBuilderMock ); @@ -177,9 +176,7 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase ->willReturnSelf(); $this->filterBuilderMock->expects($this->once()) ->method('setValue') - ->with( - \Magento\Catalog\Api\Data\ProductAttributeInterface::DEFAULT_ATTRIBUTE_SET_ID - ) + ->with(4) ->willReturnSelf(); $this->filterBuilderMock->expects($this->once())->method('create')->willReturn($filterMock); $this->searchCriteriaBuilderMock->expects($this->once()) @@ -196,11 +193,7 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase $searchCriteriaMock )->willReturn($this->searchResultMock); $this->searchResultMock->expects($this->once())->method('getItems')->willReturn([$itemMock]); - $this->metadataConfigMock->expects($this->once()) - ->method('getCustomAttributesMetadata') - ->with(null) - ->willReturn(['Attribute metadata']); - $expected = array_merge([$itemMock], ['Attribute metadata']); + $expected = [$itemMock]; $this->assertEquals($expected, $this->model->getCustomAttributesMetadata()); } diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Gallery/GalleryManagementTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Gallery/GalleryManagementTest.php index 1d5e2965e56891741975efd17a09321020095e1f..8da00cc15b23018240ae436100afdefd3019671e 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Gallery/GalleryManagementTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Gallery/GalleryManagementTest.php @@ -4,6 +4,9 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ + +// @codingStandardsIgnoreFile + namespace Magento\Catalog\Test\Unit\Model\Product\Gallery; class GalleryManagementTest extends \PHPUnit_Framework_TestCase @@ -68,6 +71,11 @@ class GalleryManagementTest extends \PHPUnit_Framework_TestCase */ protected $dataObjectHelperMock; + /** + * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\Api\AttributeValue + */ + protected $attributeValueMock; + protected function setUp() { $this->storeManagerMock = $this->getMock('\Magento\Store\Model\StoreManagerInterface'); @@ -108,7 +116,17 @@ class GalleryManagementTest extends \PHPUnit_Framework_TestCase ); $this->productMock = $this->getMock( '\Magento\Catalog\Model\Product', - ['getTypeInstance', 'getSetAttributes', 'setStoreId', 'getMediaAttributes', 'getMediaGallery', 'getData'], + [ + 'getTypeInstance', + 'getSetAttributes', + 'setStoreId', + 'getMediaAttributes', + 'getMediaGallery', + 'getData', + 'getStoreId', + 'getSku', + 'getCustomAttribute' + ], [], '', false @@ -125,6 +143,9 @@ class GalleryManagementTest extends \PHPUnit_Framework_TestCase $this->mediaGalleryMock, $this->dataObjectHelperMock ); + $this->attributeValueMock = $this->getMockBuilder('\Magento\Framework\Api\AttributeValue') + ->disableOriginalConstructor() + ->getMock(); } /** @@ -133,16 +154,9 @@ class GalleryManagementTest extends \PHPUnit_Framework_TestCase */ public function testCreateWithNoStoreException() { - $productSku = 'mediaProduct'; - $storeId = 0; - $entryMock = $this->getMock('\Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface'); - $entryContentMock = $this->getMock( - '\Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryContentInterface' - ); - $this->storeManagerMock->expects($this->once())->method('getStore')->with($storeId) + $this->storeManagerMock->expects($this->once())->method('getStore') ->willThrowException(new \Exception()); - $this->entryResolverMock->expects($this->never())->method('getEntryIdByFilePath'); - $this->model->create($productSku, $entryMock, $entryContentMock, $storeId); + $this->model->create($this->productMock); } /** @@ -151,17 +165,26 @@ class GalleryManagementTest extends \PHPUnit_Framework_TestCase */ public function testCreateWithInvalidImageException() { - $productSku = 'mediaProduct'; - $storeId = 0; $entryMock = $this->getMock('\Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface'); $entryContentMock = $this->getMock( '\Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryContentInterface' ); + $entryMock->expects($this->any())->method('getContent')->willReturn($entryContentMock); + $this->attributeValueMock->expects($this->any())->method('getValue')->willReturn($entryMock); + + $storeId = 0; + $this->productMock->expects($this->any())->method('getStoreId')->willReturn($storeId); + $this->productMock->expects($this->any()) + ->method('getCustomAttribute') + ->with('media_gallery') + ->willReturn($this->attributeValueMock); + $this->storeManagerMock->expects($this->once())->method('getStore')->with($storeId); $this->contentValidatorMock->expects($this->once())->method('isValid')->with($entryContentMock) ->willReturn(false); $this->entryResolverMock->expects($this->never())->method('getEntryIdByFilePath'); - $this->model->create($productSku, $entryMock, $entryContentMock, $storeId); + + $this->model->create($this->productMock); } /** @@ -171,11 +194,24 @@ class GalleryManagementTest extends \PHPUnit_Framework_TestCase public function testCreateWithProductWithoutImagesSupport() { $productSku = 'mediaProduct'; - $storeId = 0; $entryMock = $this->getMock('\Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface'); $entryContentMock = $this->getMock( '\Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryContentInterface' ); + $entryMock->expects($this->any())->method('getContent')->willReturn($entryContentMock); + $this->attributeValueMock->expects($this->any())->method('getValue')->willReturn($entryMock); + + $storeId = 0; + $this->productMock->expects($this->any())->method('getStoreId')->willReturn($storeId); + $this->productMock->expects($this->any())->method('getSku')->willReturn($productSku); + $this->productMock->expects($this->any()) + ->method('getCustomAttribute') + ->with('media_gallery') + ->willReturn($this->attributeValueMock); + + $this->storeManagerMock->expects($this->once())->method('getStore')->with($storeId); + $this->entryResolverMock->expects($this->never())->method('getEntryIdByFilePath'); + $writeInterfaceMock = $this->getMock('\Magento\Framework\Filesystem\Directory\WriteInterface'); $entryData = 'entryData'; $mediaTmpPath = '/media/tmp/path'; @@ -200,7 +236,7 @@ class GalleryManagementTest extends \PHPUnit_Framework_TestCase $this->productMock->expects($this->once())->method('getSetAttributes')->with($this->productMock) ->willReturn([]); $this->entryResolverMock->expects($this->never())->method('getEntryIdByFilePath'); - $this->model->create($productSku, $entryMock, $entryContentMock, $storeId); + $this->model->create($this->productMock); } /** @@ -210,13 +246,23 @@ class GalleryManagementTest extends \PHPUnit_Framework_TestCase public function testCreateWithCannotSaveException() { $productSku = 'mediaProduct'; - $storeId = 0; - $entryPosition = 'entryPosition'; - $absolutePath = 'absolute/path'; $entryMock = $this->getMock('\Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface'); $entryContentMock = $this->getMock( '\Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryContentInterface' ); + $entryMock->expects($this->any())->method('getContent')->willReturn($entryContentMock); + $this->attributeValueMock->expects($this->any())->method('getValue')->willReturn($entryMock); + + $storeId = 0; + $this->productMock->expects($this->any())->method('getStoreId')->willReturn($storeId); + $this->productMock->expects($this->any())->method('getSku')->willReturn($productSku); + $this->productMock->expects($this->any()) + ->method('getCustomAttribute') + ->with('media_gallery') + ->willReturn($this->attributeValueMock); + + $entryPosition = 'entryPosition'; + $absolutePath = 'absolute/path'; $productMediaGalleryMock = $this->getMock( '\Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend', ['addImage', 'updateImage'], @@ -252,7 +298,7 @@ class GalleryManagementTest extends \PHPUnit_Framework_TestCase ->willReturn(['media_gallery' => $attributeMock]); $attributeMock->expects($this->once())->method('getBackend')->willReturn($productMediaGalleryMock); $entryMock->expects($this->once())->method('getTypes')->willReturn(['jpg']); - $entryMock->expects($this->exactly(2))->method('getIsDisabled')->willReturn(false); + $entryMock->expects($this->exactly(2))->method('isDisabled')->willReturn(false); $entryMock->expects($this->once())->method('getPosition')->willReturn($entryPosition); $entryMock->expects($this->once())->method('getLabel')->willReturn('entryLabel'); $productMediaGalleryMock->expects($this->once())->method('addImage')->with( @@ -271,23 +317,33 @@ class GalleryManagementTest extends \PHPUnit_Framework_TestCase 'disabled' => false ] ); - $this->productMock->expects($this->once())->method('setStoreId')->with($storeId); $this->productRepositoryMock->expects($this->once())->method('save')->with($this->productMock) ->willThrowException(new \Exception()); $this->entryResolverMock->expects($this->never())->method('getEntryIdByFilePath'); - $this->model->create($productSku, $entryMock, $entryContentMock, $storeId); + $this->model->create($this->productMock); } public function testCreate() { $productSku = 'mediaProduct'; - $storeId = 0; - $entryPosition = 'entryPosition'; - $absolutePath = 'absolute/path'; $entryMock = $this->getMock('\Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface'); $entryContentMock = $this->getMock( '\Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryContentInterface' ); + $entryMock->expects($this->any())->method('getContent')->willReturn($entryContentMock); + $this->attributeValueMock->expects($this->any())->method('getValue')->willReturn($entryMock); + + $storeId = 0; + $this->productMock->expects($this->any())->method('getStoreId')->willReturn($storeId); + $this->productMock->expects($this->any())->method('getSku')->willReturn($productSku); + $this->productMock->expects($this->any()) + ->method('getCustomAttribute') + ->with('media_gallery') + ->willReturn($this->attributeValueMock); + + $entryPosition = 'entryPosition'; + $absolutePath = 'absolute/path'; + $productMediaGalleryMock = $this->getMock( '\Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend', ['addImage', 'updateImage', 'getRenamedImage'], @@ -323,7 +379,7 @@ class GalleryManagementTest extends \PHPUnit_Framework_TestCase ->willReturn(['media_gallery' => $attributeMock]); $attributeMock->expects($this->once())->method('getBackend')->willReturn($productMediaGalleryMock); $entryMock->expects($this->once())->method('getTypes')->willReturn(['jpg']); - $entryMock->expects($this->exactly(2))->method('getIsDisabled')->willReturn(false); + $entryMock->expects($this->exactly(2))->method('isDisabled')->willReturn(false); $entryMock->expects($this->once())->method('getPosition')->willReturn($entryPosition); $entryMock->expects($this->once())->method('getLabel')->willReturn('entryLabel'); $productMediaGalleryMock->expects($this->once())->method('addImage')->with( @@ -342,7 +398,6 @@ class GalleryManagementTest extends \PHPUnit_Framework_TestCase 'disabled' => false ] ); - $this->productMock->expects($this->once())->method('setStoreId')->with($storeId); $this->productRepositoryMock->expects($this->once())->method('save')->with($this->productMock); $writeInterfaceMock->expects($this->once())->method('delete')->with($relativeFilePath); $productMediaGalleryMock->expects($this->once())->method('getRenamedImage')->with($imageFileUri) @@ -351,7 +406,7 @@ class GalleryManagementTest extends \PHPUnit_Framework_TestCase $this->productMock, 'renamed' )->willReturn(42); - $this->assertEquals(42, $this->model->create($productSku, $entryMock, $entryContentMock, $storeId)); + $this->assertEquals(42, $this->model->create($this->productMock)); } /** @@ -430,7 +485,7 @@ class GalleryManagementTest extends \PHPUnit_Framework_TestCase $entryMock->expects($this->once())->method('getId')->willReturn($entryId); $this->entryResolverMock->expects($this->once())->method('getEntryFilePathById') ->with($this->productMock, $entryId)->willReturn($filePath); - $entryMock->expects($this->once())->method('getIsDisabled')->willReturn(false); + $entryMock->expects($this->once())->method('isDisabled')->willReturn(false); $entryMock->expects($this->once())->method('getPosition')->willReturn($entryPosition); $entryMock->expects($this->once())->method('getLabel')->willReturn('entryLabel'); $productMediaGalleryMock->expects($this->once())->method('updateImage')->with( @@ -485,7 +540,7 @@ class GalleryManagementTest extends \PHPUnit_Framework_TestCase $entryMock->expects($this->once())->method('getId')->willReturn($entryId); $this->entryResolverMock->expects($this->once())->method('getEntryFilePathById') ->with($this->productMock, $entryId)->willReturn($filePath); - $entryMock->expects($this->once())->method('getIsDisabled')->willReturn(false); + $entryMock->expects($this->once())->method('isDisabled')->willReturn(false); $entryMock->expects($this->once())->method('getPosition')->willReturn($entryPosition); $entryMock->expects($this->once())->method('getLabel')->willReturn('entryLabel'); $productMediaGalleryMock->expects($this->once())->method('updateImage')->with( @@ -640,7 +695,7 @@ class GalleryManagementTest extends \PHPUnit_Framework_TestCase ->with($gallery[0]['label_default'])->willReturnSelf(); $entryMock->expects($this->once())->method('setTypes') ->with([])->willReturnSelf(); - $entryMock->expects($this->once())->method('setIsDisabled') + $entryMock->expects($this->once())->method('setDisabled') ->with($gallery[0]['disabled_default'])->willReturnSelf(); $entryMock->expects($this->once())->method('setPosition') ->with($gallery[0]['position_default'])->willReturnSelf(); diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ProductLink/ManagementTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ProductLink/ManagementTest.php index cf436ae14b35b862f0d8297f2c704115d90bee03..ed28dc6fda78135af0e50f4e57d7db7c656dac67 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/ProductLink/ManagementTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/ProductLink/ManagementTest.php @@ -3,6 +3,9 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ + +// @codingStandardsIgnoreFile + namespace Magento\Catalog\Test\Unit\Model\ProductLink; use Magento\Framework\Exception\NoSuchEntityException; @@ -155,7 +158,7 @@ class ManagementTest extends \PHPUnit_Framework_TestCase $this->collectionProviderMock->expects($this->once()) ->method('getCollection') ->with($this->productMock, $linkType) - ->willThrowException(new NoSuchEntityException('Collection provider is not registered')); + ->willThrowException(new NoSuchEntityException(__('Collection provider is not registered'))); $this->model->getLinkedItemsByType($productSku, $linkType); } @@ -228,7 +231,8 @@ class ManagementTest extends \PHPUnit_Framework_TestCase 'getLinkedProductSku', 'getProductSku', 'getLinkType', '__toArray', 'getLinkedProductType', 'getPosition', 'getCustomAttribute', 'getCustomAttributes', 'setCustomAttribute', 'setCustomAttributes', 'getMetadataServiceInterface', - 'setLinkedProductSku', 'setProductSku', 'setLinkType', 'setLinkedProductType', 'setPosition', + 'getExtensionAttributes', 'setExtensionAttributes', + 'setLinkedProductSku', 'setProductSku', 'setLinkType', 'setLinkedProductType', 'setPosition' ] ); $productLinkMock->expects($this->any()) diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ProductLink/RepositoryTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ProductLink/RepositoryTest.php index 24213fbc4ca9485260dff7ca74527fa015af6a0d..affded52e9586413fb24378919bf538fdf4b74fb 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/ProductLink/RepositoryTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/ProductLink/RepositoryTest.php @@ -3,6 +3,9 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ + +// @codingStandardsIgnoreFile + namespace Magento\Catalog\Test\Unit\Model\ProductLink; class RepositoryTest extends \PHPUnit_Framework_TestCase @@ -28,6 +31,9 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase */ protected $linkInitializerMock; + /** + * Test method + */ protected function setUp() { $linkManagementMock = $this->getMock('\Magento\Catalog\Model\ProductLink\Management', [], [], '', false); @@ -58,6 +64,9 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase ); } + /** + * Test method + */ public function testSave() { $entityMock = $this->getMock('\Magento\Catalog\Model\ProductLink\Link', [], [], '', false); @@ -70,18 +79,14 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase ['linkedProduct', false, null, $linkedProductMock], ] )); - $customAttributeMock = $this->getMock('\Magento\Framework\Api\AttributeInterface'); - $customAttributeMock->expects($this->once())->method('getAttributeCode')->willReturn('attribute_code'); - $customAttributeMock->expects($this->once())->method('getValue')->willReturn('value'); $entityMock->expects($this->once())->method('getLinkedProductSku')->willReturn('linkedProduct'); $entityMock->expects($this->once())->method('getProductSku')->willReturn('product'); $entityMock->expects($this->exactly(2))->method('getLinkType')->willReturn('linkType'); $entityMock->expects($this->once())->method('__toArray')->willReturn([]); - $entityMock->expects($this->once())->method('getCustomAttributes')->willReturn([$customAttributeMock]); $linkedProductMock->expects($this->exactly(2))->method('getId')->willReturn(42); $this->entityCollectionProviderMock->expects($this->once())->method('getCollection')->willReturn([]); $this->linkInitializerMock->expects($this->once())->method('initializeLinks')->with($productMock, [ - 'linkType' => [42 => ['attribute_code' => 'value', 'product_id' => 42]] + 'linkType' => [42 => ['product_id' => 42]] ]); $this->assertTrue($this->model->save($entityMock)); } @@ -101,10 +106,6 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase ['linkedProduct', false, null, $linkedProductMock], ] )); - $customAttributeMock = $this->getMock('\Magento\Framework\Api\AttributeInterface'); - $customAttributeMock->expects($this->once())->method('getAttributeCode')->willReturn('attribute_code'); - $customAttributeMock->expects($this->once())->method('getValue')->willReturn('value'); - $entityMock->expects($this->once())->method('getCustomAttributes')->willReturn([$customAttributeMock]); $entityMock->expects($this->once())->method('getLinkedProductSku')->willReturn('linkedProduct'); $entityMock->expects($this->once())->method('getProductSku')->willReturn('product'); $entityMock->expects($this->exactly(2))->method('getLinkType')->willReturn('linkType'); @@ -112,12 +113,15 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase $linkedProductMock->expects($this->exactly(2))->method('getId')->willReturn(42); $this->entityCollectionProviderMock->expects($this->once())->method('getCollection')->willReturn([]); $this->linkInitializerMock->expects($this->once())->method('initializeLinks')->with($productMock, [ - 'linkType' => [42 => ['attribute_code' => 'value', 'product_id' => 42]] + 'linkType' => [42 => ['product_id' => 42]] ]); $productMock->expects($this->once())->method('save')->willThrowException(new \Exception()); $this->model->save($entityMock); } + /** + * Test method + */ public function testDelete() { $entityMock = $this->getMock('\Magento\Catalog\Model\ProductLink\Link', [], [], '', false); diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ProductRepositoryTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ProductRepositoryTest.php index 33e3305cefa18a734566e56cfb55cd3d2985949e..8a7930bb0f6d7243e66fc68fcbc51751d517f6d5 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/ProductRepositoryTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/ProductRepositoryTest.php @@ -4,6 +4,9 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ + +// @codingStandardsIgnoreFile + namespace Magento\Catalog\Test\Unit\Model; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; @@ -60,6 +63,16 @@ class ProductRepositoryTest extends \PHPUnit_Framework_TestCase */ protected $searchResultsFactoryMock; + /** + * @var \Magento\Eav\Model\Config|\PHPUnit_Framework_MockObject_MockObject + */ + protected $eavConfigMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $extensibleDataObjectConverterMock; + /** * @var array data to create product */ @@ -114,8 +127,17 @@ class ProductRepositoryTest extends \PHPUnit_Framework_TestCase false ); $this->resourceModelMock = $this->getMock('\Magento\Catalog\Model\Resource\Product', [], [], '', false); + $this->eavConfigMock = $this->getMock('Magento\Eav\Model\Config', [], [], '', false); + $this->eavConfigMock->expects($this->any())->method('getEntityType') + ->willReturn(new \Magento\Framework\Object(['default_attribute_set_id' => 4])); $this->objectManager = new ObjectManager($this); + $this->extensibleDataObjectConverterMock = $this + ->getMockBuilder('\Magento\Framework\Api\ExtensibleDataObjectConverter') + ->setMethods(['toNestedArray']) + ->disableOriginalConstructor() + ->getMock(); + $this->model = $this->objectManager->getObject( 'Magento\Catalog\Model\ProductRepository', [ @@ -126,7 +148,9 @@ class ProductRepositoryTest extends \PHPUnit_Framework_TestCase 'collectionFactory' => $this->collectionFactoryMock, 'searchCriteriaBuilder' => $this->searchCriteriaBuilderMock, 'metadataServiceInterface' => $this->metadataServiceMock, - 'searchResultsFactory' => $this->searchResultsFactoryMock + 'searchResultsFactory' => $this->searchResultsFactoryMock, + 'extensibleDataObjectConverter' => $this->extensibleDataObjectConverterMock, + 'eavConfig' => $this->eavConfigMock, ] ); } @@ -243,30 +267,34 @@ class ProductRepositoryTest extends \PHPUnit_Framework_TestCase public function testSaveExisting() { $this->resourceModelMock->expects($this->exactly(2))->method('getIdBySku')->will($this->returnValue(100)); - $this->productMock->expects($this->once())->method('toFlatArray')->will($this->returnValue($this->productData)); $this->productFactoryMock->expects($this->once()) ->method('create') ->will($this->returnValue($this->productMock)); $this->initializationHelperMock->expects($this->once())->method('initialize')->with($this->productMock); $this->resourceModelMock->expects($this->once())->method('validate')->with($this->productMock) ->willReturn(true); - $this->productMock->expects($this->once())->method('toFlatArray')->will($this->returnValue($this->productData)); $this->resourceModelMock->expects($this->once())->method('save')->with($this->productMock)->willReturn(true); + $this->extensibleDataObjectConverterMock + ->expects($this->once()) + ->method('toNestedArray') + ->will($this->returnValue($this->productData)); $this->assertEquals($this->productMock, $this->model->save($this->productMock)); } public function testSaveNew() { $this->resourceModelMock->expects($this->exactly(1))->method('getIdBySku')->will($this->returnValue(null)); - $this->productMock->expects($this->once())->method('toFlatArray')->will($this->returnValue($this->productData)); $this->productFactoryMock->expects($this->once()) ->method('create') ->will($this->returnValue($this->productMock)); $this->initializationHelperMock->expects($this->never())->method('initialize')->with($this->productMock); $this->resourceModelMock->expects($this->once())->method('validate')->with($this->productMock) ->willReturn(true); - $this->productMock->expects($this->once())->method('toFlatArray')->will($this->returnValue($this->productData)); $this->resourceModelMock->expects($this->once())->method('save')->with($this->productMock)->willReturn(true); + $this->extensibleDataObjectConverterMock + ->expects($this->once()) + ->method('toNestedArray') + ->will($this->returnValue($this->productData)); $this->assertEquals($this->productMock, $this->model->save($this->productMock)); } @@ -277,7 +305,6 @@ class ProductRepositoryTest extends \PHPUnit_Framework_TestCase public function testSaveUnableToSaveException() { $this->resourceModelMock->expects($this->exactly(1))->method('getIdBySku')->will($this->returnValue(null)); - $this->productMock->expects($this->once())->method('toFlatArray')->will($this->returnValue($this->productData)); $this->productFactoryMock->expects($this->once()) ->method('create') ->will($this->returnValue($this->productMock)); @@ -286,6 +313,10 @@ class ProductRepositoryTest extends \PHPUnit_Framework_TestCase ->willReturn(true); $this->resourceModelMock->expects($this->once())->method('save')->with($this->productMock) ->willThrowException(new \Exception()); + $this->extensibleDataObjectConverterMock + ->expects($this->once()) + ->method('toNestedArray') + ->will($this->returnValue($this->productData)); $this->model->save($this->productMock); } @@ -296,7 +327,6 @@ class ProductRepositoryTest extends \PHPUnit_Framework_TestCase public function testSaveException() { $this->resourceModelMock->expects($this->exactly(1))->method('getIdBySku')->will($this->returnValue(null)); - $this->productMock->expects($this->once())->method('toFlatArray')->will($this->returnValue($this->productData)); $this->productFactoryMock->expects($this->once()) ->method('create') ->will($this->returnValue($this->productMock)); @@ -306,6 +336,10 @@ class ProductRepositoryTest extends \PHPUnit_Framework_TestCase $this->resourceModelMock->expects($this->once())->method('save')->with($this->productMock) ->willThrowException(new \Magento\Eav\Model\Entity\Attribute\Exception('123')); $this->productMock->expects($this->never())->method('getId'); + $this->extensibleDataObjectConverterMock + ->expects($this->once()) + ->method('toNestedArray') + ->will($this->returnValue($this->productData)); $this->model->save($this->productMock); } @@ -316,7 +350,6 @@ class ProductRepositoryTest extends \PHPUnit_Framework_TestCase public function testSaveInvalidProductException() { $this->resourceModelMock->expects($this->exactly(1))->method('getIdBySku')->will($this->returnValue(null)); - $this->productMock->expects($this->once())->method('toFlatArray')->will($this->returnValue($this->productData)); $this->productFactoryMock->expects($this->once()) ->method('create') ->will($this->returnValue($this->productMock)); @@ -324,6 +357,10 @@ class ProductRepositoryTest extends \PHPUnit_Framework_TestCase $this->resourceModelMock->expects($this->once())->method('validate')->with($this->productMock) ->willReturn(['error1', 'error2']); $this->productMock->expects($this->never())->method('getId'); + $this->extensibleDataObjectConverterMock + ->expects($this->once()) + ->method('toNestedArray') + ->will($this->returnValue($this->productData)); $this->model->save($this->productMock); } @@ -392,7 +429,7 @@ class ProductRepositoryTest extends \PHPUnit_Framework_TestCase ->will($this->returnSelf()); $this->filterBuilderMock->expects($this->once())->method('create')->willReturn($filterMock); $this->filterBuilderMock->expects($this->once())->method('setValue') - ->with(\Magento\Catalog\Api\Data\ProductAttributeInterface::DEFAULT_ATTRIBUTE_SET_ID) + ->with(4) ->willReturn($this->filterBuilderMock); $this->searchCriteriaBuilderMock->expects($this->once())->method('addFilter')->with([$filterMock]) ->willReturn($searchCriteriaBuilderMock); @@ -461,44 +498,44 @@ class ProductRepositoryTest extends \PHPUnit_Framework_TestCase [ 'identifier' => 'test-sku', 'editMode' => false, - 'storeId' => null + 'storeId' => null, ], [ 'identifier' => 25, 'editMode' => false, - 'storeId' => null + 'storeId' => null, ], [ 'identifier' => 25, 'editMode' => true, - 'storeId' => null + 'storeId' => null, ], [ 'identifier' => 'test-sku', 'editMode' => true, - 'storeId' => null + 'storeId' => null, ], [ 'identifier' => 25, 'editMode' => true, - 'storeId' => $anyObject + 'storeId' => $anyObject, ], [ 'identifier' => 'test-sku', 'editMode' => true, - 'storeId' => $anyObject + 'storeId' => $anyObject, ], [ 'identifier' => 25, 'editMode' => false, - 'storeId' => $anyObject + 'storeId' => $anyObject, ], [ 'identifier' => 'test-sku', 'editMode' => false, - 'storeId' => $anyObject - ] + 'storeId' => $anyObject, + ], ]; } } diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Template/Filter/FactoryTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Template/Filter/FactoryTest.php old mode 100644 new mode 100755 index 77a8bd953da00be195c161d932aabba938cd4985..ec50e2fcbc476c73b2a5fedbe264f782f09a2de0 --- a/app/code/Magento/Catalog/Test/Unit/Model/Template/Filter/FactoryTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Template/Filter/FactoryTest.php @@ -17,6 +17,11 @@ class FactoryTest extends \PHPUnit_Framework_TestCase */ protected $_factory; + /** + * SetUp method + * + * @return void + */ protected function setUp() { $this->_objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface'); @@ -28,6 +33,11 @@ class FactoryTest extends \PHPUnit_Framework_TestCase ); } + /** + * Test create + * + * @return void + */ public function testCreate() { $className = 'Magento\Framework\Filter\Template'; @@ -47,6 +57,11 @@ class FactoryTest extends \PHPUnit_Framework_TestCase $this->assertEquals($filterMock, $this->_factory->create($className)); } + /** + * Test create with arguments + * + * @return void + */ public function testCreateWithArguments() { $className = 'Magento\Framework\Filter\Template'; @@ -68,8 +83,11 @@ class FactoryTest extends \PHPUnit_Framework_TestCase } /** + * Test wrong type exception + * * @expectedException \Magento\Framework\Exception\LocalizedException - * @expectedExceptionMessage WrongClass doesn't extends \Magento\Framework\Filter\Template + * @expectedExceptionMessage WrongClass doesn't extend \Magento\Framework\Filter\Template + * @return void */ public function testWrongTypeException() { diff --git a/app/code/Magento/Catalog/composer.json b/app/code/Magento/Catalog/composer.json index 92b97c635b087e12dfe820a58502df8d5e23322c..f6e7adcc008d5c41bcffa81f1aad61c587900316 100644 --- a/app/code/Magento/Catalog/composer.json +++ b/app/code/Magento/Catalog/composer.json @@ -8,7 +8,6 @@ "magento/module-cms": "0.42.0-beta11", "magento/module-indexer": "0.42.0-beta11", "magento/module-customer": "0.42.0-beta11", - "magento/module-core": "0.42.0-beta11", "magento/module-theme": "0.42.0-beta11", "magento/module-checkout": "0.42.0-beta11", "magento/module-log": "0.42.0-beta11", diff --git a/app/code/Magento/Catalog/etc/config.xml b/app/code/Magento/Catalog/etc/config.xml index 27791541c72009b293df7ae93d4cd044c1d0ea67..9d4433c045425e2902dbc8b60c43ba01fcbeba7a 100644 --- a/app/code/Magento/Catalog/etc/config.xml +++ b/app/code/Magento/Catalog/etc/config.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Core/etc/config.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Store/etc/config.xsd"> <default> <catalog> <navigation> diff --git a/app/code/Magento/Catalog/etc/frontend/page_types.xml b/app/code/Magento/Catalog/etc/frontend/page_types.xml index 2f789b816c75f328b7c05bd487c02064f88aefdc..7dc0beef39a5bfe7c47a704f09831547c1e9629d 100644 --- a/app/code/Magento/Catalog/etc/frontend/page_types.xml +++ b/app/code/Magento/Catalog/etc/frontend/page_types.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> -<page_types xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../Core/etc/page_types.xsd"> +<page_types xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_types.xsd"> <type id="catalog_category_view" label="Catalog Category"/> <type id="catalog_product_compare_index" label="Catalog Product Compare List"/> <type id="catalog_product_gallery" label="Catalog Product Image Gallery Popup"/> diff --git a/app/code/Magento/Catalog/etc/webapi.xml b/app/code/Magento/Catalog/etc/webapi.xml index ab2485a26fd46723617e522964bb4724a5af8285..a4fb44c7eae061b3547fee1c93d61889dd923b7a 100644 --- a/app/code/Magento/Catalog/etc/webapi.xml +++ b/app/code/Magento/Catalog/etc/webapi.xml @@ -21,7 +21,7 @@ <resource ref="Magento_Catalog::products" /> </resources> </route> - <route url="/V1/products/:productSku" method="DELETE"> + <route url="/V1/products/:sku" method="DELETE"> <service class="Magento\Catalog\Api\ProductRepositoryInterface" method="deleteById"/> <resources> <resource ref="Magento_Catalog::products" /> @@ -33,7 +33,7 @@ <resource ref="anonymous" /> </resources> </route> - <route url="/V1/products/:productSku" method="GET"> + <route url="/V1/products/:sku" method="GET"> <service class="Magento\Catalog\Api\ProductRepositoryInterface" method="get"/> <resources> <resource ref="anonymous" /> @@ -196,31 +196,31 @@ <resource ref="anonymous"/> </resources> </route> - <route url="/V1/products/:productSku/media/:imageId" method="GET"> + <route url="/V1/products/:sku/media/:imageId" method="GET"> <service class="Magento\Catalog\Api\ProductAttributeMediaGalleryManagementInterface" method="get"/> <resources> <resource ref="anonymous"/> </resources> </route> - <route url="/V1/products/:productSku/media" method="POST"> + <route url="/V1/products/media" method="POST"> <service class="Magento\Catalog\Api\ProductAttributeMediaGalleryManagementInterface" method="create"/> <resources> <resource ref="Magento_Catalog::catalog"/> </resources> </route> - <route url="/V1/products/:productSku/media/:entryId" method="PUT"> + <route url="/V1/products/:sku/media/:entryId" method="PUT"> <service class="Magento\Catalog\Api\ProductAttributeMediaGalleryManagementInterface" method="update"/> <resources> <resource ref="Magento_Catalog::catalog"/> </resources> </route> - <route url="/V1/products/:productSku/media/:entryId" method="DELETE"> + <route url="/V1/products/:sku/media/:entryId" method="DELETE"> <service class="Magento\Catalog\Api\ProductAttributeMediaGalleryManagementInterface" method="remove"/> <resources> <resource ref="Magento_Catalog::catalog"/> </resources> </route> - <route url="/V1/products/:productSku/media" method="GET"> + <route url="/V1/products/:sku/media" method="GET"> <service class="Magento\Catalog\Api\ProductAttributeMediaGalleryManagementInterface" method="getList"/> <resources> <resource ref="anonymous"/> @@ -228,19 +228,19 @@ </route> <!-- Group Price --> - <route url="/V1/products/:productSku/group-prices/" method="GET"> + <route url="/V1/products/:sku/group-prices/" method="GET"> <service class="Magento\Catalog\Api\ProductGroupPriceManagementInterface" method="getList"/> <resources> <resource ref="anonymous"/> </resources> </route> - <route url="/V1/products/:productSku/group-prices/:customerGroupId/price/:price" method="POST"> + <route url="/V1/products/:sku/group-prices/:customerGroupId/price/:price" method="POST"> <service class="Magento\Catalog\Api\ProductGroupPriceManagementInterface" method="add"/> <resources> <resource ref="Magento_Catalog::catalog"/> </resources> </route> - <route url="/V1/products/:productSku/group-prices/:customerGroupId/" method="DELETE"> + <route url="/V1/products/:sku/group-prices/:customerGroupId/" method="DELETE"> <service class="Magento\Catalog\Api\ProductGroupPriceManagementInterface" method="remove"/> <resources> <resource ref="Magento_Catalog::catalog"/> @@ -248,19 +248,19 @@ </route> <!-- Tear Price --> - <route url="/V1/products/:productSku/group-prices/:customerGroupId/tiers" method="GET"> + <route url="/V1/products/:sku/group-prices/:customerGroupId/tiers" method="GET"> <service class="Magento\Catalog\Api\ProductTierPriceManagementInterface" method="getList"/> <resources> <resource ref="anonymous"/> </resources> </route> - <route url="/V1/products/:productSku/group-prices/:customerGroupId/tiers/:qty/price/:price" method="POST"> + <route url="/V1/products/:sku/group-prices/:customerGroupId/tiers/:qty/price/:price" method="POST"> <service class="Magento\Catalog\Api\ProductTierPriceManagementInterface" method="add"/> <resources> <resource ref="Magento_Catalog::catalog"/> </resources> </route> - <route url="/V1/products/:productSku/group-prices/:customerGroupId/tiers/:qty" method="DELETE"> + <route url="/V1/products/:sku/group-prices/:customerGroupId/tiers/:qty" method="DELETE"> <service class="Magento\Catalog\Api\ProductTierPriceManagementInterface" method="remove"/> <resources> <resource ref="Magento_Catalog::catalog"/> @@ -311,13 +311,13 @@ <resource ref="Magento_Catalog::catalog"/> </resources> </route> - <route url="/V1/products/:productSku/options" method="GET"> + <route url="/V1/products/:sku/options" method="GET"> <service class="Magento\Catalog\Api\ProductCustomOptionRepositoryInterface" method="getList"/> <resources> <resource ref="anonymous"/> </resources> </route> - <route url="/V1/products/:productSku/options/:optionId" method="GET"> + <route url="/V1/products/:sku/options/:optionId" method="GET"> <service class="Magento\Catalog\Api\ProductCustomOptionRepositoryInterface" method="get"/> <resources> <resource ref="anonymous"/> @@ -335,7 +335,7 @@ <resource ref="Magento_Catalog::catalog"/> </resources> </route> - <route url="/V1/products/:productSku/options/:optionId" method="DELETE"> + <route url="/V1/products/:sku/options/:optionId" method="DELETE"> <service class="Magento\Catalog\Api\ProductCustomOptionRepositoryInterface" method="deleteByIdentifier"/> <resources> <resource ref="Magento_Catalog::catalog"/> @@ -355,25 +355,25 @@ <resource ref="anonymous"/> </resources> </route> - <route url="/V1/products/:productSku/links/:type" method="GET"> + <route url="/V1/products/:sku/links/:type" method="GET"> <service class="Magento\Catalog\Api\ProductLinkManagementInterface" method="getLinkedItemsByType"/> <resources> <resource ref="anonymous"/> </resources> </route> - <route url="/V1/products/:productSku/links/:type" method="POST"> + <route url="/V1/products/:sku/links/:type" method="POST"> <service class="Magento\Catalog\Api\ProductLinkManagementInterface" method="setProductLinks"/> <resources> <resource ref="Magento_Catalog::catalog"/> </resources> </route> - <route url="/V1/products/:productSku/links/:type/:linkedProductSku" method="DELETE"> + <route url="/V1/products/:sku/links/:type/:linkedProductSku" method="DELETE"> <service class="Magento\Catalog\Api\ProductLinkRepositoryInterface" method="deleteById"/> <resources> <resource ref="Magento_Catalog::catalog"/> </resources> </route> - <route url="/V1/products/:product_sku/links/:link_type" method="PUT"> + <route url="/V1/products/:sku/links/:link_type" method="PUT"> <service class="Magento\Catalog\Api\ProductLinkRepositoryInterface" method="save"/> <resources> <resource ref="Magento_Catalog::catalog"/> @@ -399,7 +399,7 @@ <resource ref="Magento_Catalog::categories" /> </resources> </route> - <route url="/V1/categories/:categoryId/products/:productSku" method="DELETE"> + <route url="/V1/categories/:categoryId/products/:sku" method="DELETE"> <service class="Magento\Catalog\Api\CategoryLinkRepositoryInterface" method="deleteByIds" /> <resources> <resource ref="Magento_Catalog::categories" /> diff --git a/app/code/Magento/Catalog/view/adminhtml/templates/catalog/category/checkboxes/tree.phtml b/app/code/Magento/Catalog/view/adminhtml/templates/catalog/category/checkboxes/tree.phtml index f56ab28a4b7cf8d1fd1271c769f51860b233cf4e..999e11608c9218837b8b8ddec5f542c9afb84431 100644 --- a/app/code/Magento/Catalog/view/adminhtml/templates/catalog/category/checkboxes/tree.phtml +++ b/app/code/Magento/Catalog/view/adminhtml/templates/catalog/category/checkboxes/tree.phtml @@ -13,10 +13,11 @@ <script> require([ + 'jquery', "prototype", "extjs/ext-tree-checkbox", "mage/adminhtml/form" - ], function(){ + ], function(jQuery){ //<![CDATA[ @@ -69,7 +70,7 @@ Ext.extend(Ext.tree.TreePanel.Enhanced, Ext.tree.TreePanel, { } }); -Ext.onReady(function() +jQuery(function() { var categoryLoader = new Ext.tree.TreeLoader({ dataUrl: '<?php echo $block->getLoadTreeUrl() ?>' diff --git a/app/code/Magento/Catalog/view/adminhtml/templates/catalog/category/tree.phtml b/app/code/Magento/Catalog/view/adminhtml/templates/catalog/category/tree.phtml index 11ee3d968ae71456177951cdbcd337a4eef7aab5..f80c4d2ac53cdf71f504450e1c6b74ce4cff440a 100644 --- a/app/code/Magento/Catalog/view/adminhtml/templates/catalog/category/tree.phtml +++ b/app/code/Magento/Catalog/view/adminhtml/templates/catalog/category/tree.phtml @@ -276,7 +276,7 @@ function _renderNewTree(config, scopeParams) { //updateContent(url); //commented since ajax requests replaced with http ones to load a category } -Ext.onReady(function () { +jQuery(function () { categoryLoader = new Ext.tree.TreeLoader({ dataUrl:'<?php echo $block->getLoadTreeUrl() ?>' }); diff --git a/app/code/Magento/Catalog/view/adminhtml/templates/catalog/category/widget/tree.phtml b/app/code/Magento/Catalog/view/adminhtml/templates/catalog/category/widget/tree.phtml index 45dcffcf34afd2c03acc10c4fbc56f17320d648f..c578a7e5e17b2dadf607f62421daefcc24ba8866 100644 --- a/app/code/Magento/Catalog/view/adminhtml/templates/catalog/category/widget/tree.phtml +++ b/app/code/Magento/Catalog/view/adminhtml/templates/catalog/category/widget/tree.phtml @@ -12,7 +12,7 @@ <div id="<?php echo $_divId ?>" class="tree"></div> <script> -require(["prototype", "extjs/ext-tree-checkbox"], function(){ +require(['jquery', "prototype", "extjs/ext-tree-checkbox"], function(jQuery){ var tree<?php echo $block->getId() ?>; @@ -54,7 +54,7 @@ Ext.extend(Ext.tree.TreePanel.Enhanced, Ext.tree.TreePanel, { } }); -Ext.onReady(function() +jQuery(function() { var emptyNodeAdded = <?php echo($block->getWithEmptyNode() ? 'false' : 'true') ?>; diff --git a/app/code/Magento/CatalogImportExport/Model/Import/Product.php b/app/code/Magento/CatalogImportExport/Model/Import/Product.php index 0bcac43699d1cc037b309bbedc1f384f7bec0e51..e8bba488c9612ebe32cd9124212f1f5640daf127 100644 --- a/app/code/Magento/CatalogImportExport/Model/Import/Product.php +++ b/app/code/Magento/CatalogImportExport/Model/Import/Product.php @@ -618,14 +618,14 @@ class Product extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity if (!($model = $this->_productTypeFactory->create($productTypeConfig['model'], ['params' => $params])) ) { throw new \Magento\Framework\Exception\LocalizedException( - __("Entity type model '%1' is not found", $productTypeConfig['model']) + __('Entity type model \'%1\' is not found', $productTypeConfig['model']) ); } if (!$model instanceof \Magento\CatalogImportExport\Model\Import\Product\Type\AbstractType) { throw new \Magento\Framework\Exception\LocalizedException( __( - 'Entity type model must be an instance of ' . - 'Magento\CatalogImportExport\Model\Import\Product\Type\AbstractType' + 'Entity type model must be an instance of ' + . 'Magento\CatalogImportExport\Model\Import\Product\Type\AbstractType' ) ); } @@ -1233,7 +1233,7 @@ class Product extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity $tmpPath = $this->_mediaDirectory->getAbsolutePath('import'); if (!$this->_fileUploader->setTmpDir($tmpPath)) { throw new \Magento\Framework\Exception\LocalizedException( - __("File directory '%1' is not readable.", $tmpPath) + __('File directory \'%1\' is not readable.', $tmpPath) ); } $destinationDir = "catalog/product"; @@ -1242,7 +1242,7 @@ class Product extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity $this->_mediaDirectory->create($destinationDir); if (!$this->_fileUploader->setDestDir($destinationPath)) { throw new \Magento\Framework\Exception\LocalizedException( - __("File directory '%1' is not writable.", $destinationPath) + __('File directory \'%1\' is not writable.', $destinationPath) ); } } diff --git a/app/code/Magento/CatalogImportExport/Model/Import/Product/Option.php b/app/code/Magento/CatalogImportExport/Model/Import/Product/Option.php index b1b556466c5e587b90357824435bad027b6ac123..1f0e83871d4f29837b390a0b992f1756134f55de 100644 --- a/app/code/Magento/CatalogImportExport/Model/Import/Product/Option.php +++ b/app/code/Magento/CatalogImportExport/Model/Import/Product/Option.php @@ -472,7 +472,9 @@ class Option extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity if (isset($data['product_entity'])) { $this->_productEntity = $data['product_entity']; } else { - throw new \Magento\Framework\Exception\LocalizedException(__('Option entity must have a parent product entity.')); + throw new \Magento\Framework\Exception\LocalizedException( + __('Option entity must have a parent product entity.') + ); } if (isset($data['collection_by_pages_iterator'])) { $this->_byPagesIterator = $data['collection_by_pages_iterator']; diff --git a/app/code/Magento/CatalogImportExport/Model/Import/Product/Type/AbstractType.php b/app/code/Magento/CatalogImportExport/Model/Import/Product/Type/AbstractType.php index d16f877a7e83e02db75601a7c5f0fb4e35c2e9b0..be21e3e2019ab885b08ed7c87ef0969175b379a9 100644 --- a/app/code/Magento/CatalogImportExport/Model/Import/Product/Type/AbstractType.php +++ b/app/code/Magento/CatalogImportExport/Model/Import/Product/Type/AbstractType.php @@ -96,13 +96,10 @@ abstract class AbstractType $this->_prodAttrColFac = $prodAttrColFac; if ($this->isSuitable()) { - if (!isset( - $params[0] - ) || !isset( - $params[1] - ) || !is_object( - $params[0] - ) || !$params[0] instanceof \Magento\CatalogImportExport\Model\Import\Product + if (!isset($params[0]) + || !isset($params[1]) + || !is_object($params[0]) + || !$params[0] instanceof \Magento\CatalogImportExport\Model\Import\Product ) { throw new \Magento\Framework\Exception\LocalizedException(__('Please correct the parameters.')); } diff --git a/app/code/Magento/CatalogImportExport/etc/config.xml b/app/code/Magento/CatalogImportExport/etc/config.xml index cdd8b60e4ccc8765bd9f371848fb36f118660528..707ae08d9c77fe25b799ff5199b36bf69f93de61 100644 --- a/app/code/Magento/CatalogImportExport/etc/config.xml +++ b/app/code/Magento/CatalogImportExport/etc/config.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Core/etc/config.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Store/etc/config.xsd"> <default> <export> </export> diff --git a/app/code/Magento/CatalogInventory/Api/Data/StockInterface.php b/app/code/Magento/CatalogInventory/Api/Data/StockInterface.php index 31aa3678440faeb85e0788a651a0a56f67318197..47bd9b85cc321a7a945c15d38304b4a97bf33059 100644 --- a/app/code/Magento/CatalogInventory/Api/Data/StockInterface.php +++ b/app/code/Magento/CatalogInventory/Api/Data/StockInterface.php @@ -62,4 +62,21 @@ interface StockInterface extends ExtensibleDataInterface * @return $this */ public function setStockName($stockName); + + /** + * Retrieve existing extension attributes object or create a new one. + * + * @return \Magento\CatalogInventory\Api\Data\StockExtensionInterface|null + */ + public function getExtensionAttributes(); + + /** + * Set an extension attributes object. + * + * @param \Magento\CatalogInventory\Api\Data\StockExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes( + \Magento\CatalogInventory\Api\Data\StockExtensionInterface $extensionAttributes + ); } diff --git a/app/code/Magento/CatalogInventory/Api/Data/StockItemInterface.php b/app/code/Magento/CatalogInventory/Api/Data/StockItemInterface.php index e32c4178e5767f73b989f983446eebe1d8802a54..46163c26be6d3df33831a35e9344333ffeaef7ef 100644 --- a/app/code/Magento/CatalogInventory/Api/Data/StockItemInterface.php +++ b/app/code/Magento/CatalogInventory/Api/Data/StockItemInterface.php @@ -398,4 +398,21 @@ interface StockItemInterface extends ExtensibleDataInterface * @return $this */ public function setStockStatusChangedAuto($stockStatusChangedAuto); + + /** + * Retrieve existing extension attributes object or create a new one. + * + * @return \Magento\CatalogInventory\Api\Data\StockItemExtensionInterface|null + */ + public function getExtensionAttributes(); + + /** + * Set an extension attributes object. + * + * @param \Magento\CatalogInventory\Api\Data\StockItemExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes( + \Magento\CatalogInventory\Api\Data\StockItemExtensionInterface $extensionAttributes + ); } diff --git a/app/code/Magento/CatalogInventory/Api/Data/StockStatusInterface.php b/app/code/Magento/CatalogInventory/Api/Data/StockStatusInterface.php index 7788b53df36bf73670eab34f72e0532ce5f7e400..3c90ea451776a752c578ffb0e741de06fac46f3c 100644 --- a/app/code/Magento/CatalogInventory/Api/Data/StockStatusInterface.php +++ b/app/code/Magento/CatalogInventory/Api/Data/StockStatusInterface.php @@ -83,4 +83,21 @@ interface StockStatusInterface extends ExtensibleDataInterface * @return \Magento\CatalogInventory\Api\Data\StockItemInterface */ public function getStockItem(); + + /** + * Retrieve existing extension attributes object or create a new one. + * + * @return \Magento\CatalogInventory\Api\Data\StockStatusExtensionInterface|null + */ + public function getExtensionAttributes(); + + /** + * Set an extension attributes object. + * + * @param \Magento\CatalogInventory\Api\Data\StockStatusExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes( + \Magento\CatalogInventory\Api\Data\StockStatusExtensionInterface $extensionAttributes + ); } diff --git a/app/code/Magento/CatalogInventory/Model/Adminhtml/Stock/Item.php b/app/code/Magento/CatalogInventory/Model/Adminhtml/Stock/Item.php index fe76faa8934a55a6a68915f800849af506442f84..56c05595a2c4c93020ab65fe15be63086dbba902 100644 --- a/app/code/Magento/CatalogInventory/Model/Adminhtml/Stock/Item.php +++ b/app/code/Magento/CatalogInventory/Model/Adminhtml/Stock/Item.php @@ -10,10 +10,11 @@ use Magento\CatalogInventory\Api\StockItemRepositoryInterface as StockItemReposi use Magento\CatalogInventory\Api\StockRegistryInterface; use Magento\Customer\Api\GroupManagementInterface; use Magento\Framework\Api\AttributeValueFactory; -use Magento\Framework\Api\MetadataServiceInterface; +use Magento\Framework\Api\ExtensionAttributesFactory; /** * Catalog Inventory Stock Model for adminhtml area + * @method \Magento\CatalogInventory\Api\Data\StockItemExtensionInterface getExtensionAttributes() * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class Item extends \Magento\CatalogInventory\Model\Stock\Item @@ -26,7 +27,7 @@ class Item extends \Magento\CatalogInventory\Model\Stock\Item /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry - * @param MetadataServiceInterface $metadataService + * @param ExtensionAttributesFactory $extensionFactory * @param AttributeValueFactory $customAttributeFactory * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Store\Model\StoreManagerInterface $storeManager @@ -42,7 +43,7 @@ class Item extends \Magento\CatalogInventory\Model\Stock\Item public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, - MetadataServiceInterface $metadataService, + ExtensionAttributesFactory $extensionFactory, AttributeValueFactory $customAttributeFactory, \Magento\Customer\Model\Session $customerSession, \Magento\Store\Model\StoreManagerInterface $storeManager, @@ -57,7 +58,7 @@ class Item extends \Magento\CatalogInventory\Model\Stock\Item parent::__construct( $context, $registry, - $metadataService, + $extensionFactory, $customAttributeFactory, $customerSession, $storeManager, diff --git a/app/code/Magento/CatalogInventory/Model/Stock.php b/app/code/Magento/CatalogInventory/Model/Stock.php index 8ba03fa36a0727b8b52d13384e62d09f89d9af6e..1eed06294edaf05139695e5048ba6725e91de515 100644 --- a/app/code/Magento/CatalogInventory/Model/Stock.php +++ b/app/code/Magento/CatalogInventory/Model/Stock.php @@ -10,6 +10,7 @@ use Magento\Framework\Model\AbstractExtensibleModel; /** * Class Stock + * */ class Stock extends AbstractExtensibleModel implements StockInterface { @@ -119,5 +120,27 @@ class Stock extends AbstractExtensibleModel implements StockInterface { return $this->setData(self::STOCK_NAME, $stockName); } + + /** + * {@inheritdoc} + * + * @return \Magento\CatalogInventory\Api\Data\StockExtensionInterface|null + */ + public function getExtensionAttributes() + { + return $this->_getExtensionAttributes(); + } + + /** + * {@inheritdoc} + * + * @param \Magento\CatalogInventory\Api\Data\StockExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes( + \Magento\CatalogInventory\Api\Data\StockExtensionInterface $extensionAttributes + ) { + return $this->_setExtensionAttributes($extensionAttributes); + } //@codeCoverageIgnoreEnd } diff --git a/app/code/Magento/CatalogInventory/Model/Stock/Item.php b/app/code/Magento/CatalogInventory/Model/Stock/Item.php index 322eb0812d8f88cd4e348afecb48494fb78a9921..cb622e904c6bbab1838275d66a5f9129e6640a24 100644 --- a/app/code/Magento/CatalogInventory/Model/Stock/Item.php +++ b/app/code/Magento/CatalogInventory/Model/Stock/Item.php @@ -11,7 +11,7 @@ use Magento\CatalogInventory\Api\StockConfigurationInterface as StockConfigurati use Magento\CatalogInventory\Api\StockItemRepositoryInterface as StockItemRepositoryInterface; use Magento\CatalogInventory\Api\StockRegistryInterface; use Magento\Framework\Api\AttributeValueFactory; -use Magento\Framework\Api\MetadataServiceInterface; +use Magento\Framework\Api\ExtensionAttributesFactory; use Magento\Framework\Model\AbstractExtensibleModel; /** @@ -92,7 +92,7 @@ class Item extends AbstractExtensibleModel implements StockItemInterface /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry - * @param MetadataServiceInterface $metadataService + * @param ExtensionAttributesFactory $extensionFactory * @param AttributeValueFactory $customAttributeFactory * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Store\Model\StoreManagerInterface $storeManager @@ -107,7 +107,7 @@ class Item extends AbstractExtensibleModel implements StockItemInterface public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, - MetadataServiceInterface $metadataService, + ExtensionAttributesFactory $extensionFactory, AttributeValueFactory $customAttributeFactory, \Magento\Customer\Model\Session $customerSession, \Magento\Store\Model\StoreManagerInterface $storeManager, @@ -121,7 +121,7 @@ class Item extends AbstractExtensibleModel implements StockItemInterface parent::__construct( $context, $registry, - $metadataService, + $extensionFactory, $customAttributeFactory, $resource, $resourceCollection, @@ -807,5 +807,27 @@ class Item extends AbstractExtensibleModel implements StockItemInterface { return $this->setData(self::STOCK_STATUS_CHANGED_AUTO, $stockStatusChangedAuto); } + + /** + * {@inheritdoc} + * + * @return \Magento\CatalogInventory\Api\Data\StockItemExtensionInterface|null + */ + public function getExtensionAttributes() + { + return $this->_getExtensionAttributes(); + } + + /** + * {@inheritdoc} + * + * @param \Magento\CatalogInventory\Api\Data\StockItemExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes( + \Magento\CatalogInventory\Api\Data\StockItemExtensionInterface $extensionAttributes + ) { + return $this->_setExtensionAttributes($extensionAttributes); + } //@codeCoverageIgnoreEnd } diff --git a/app/code/Magento/CatalogInventory/Model/Stock/Status.php b/app/code/Magento/CatalogInventory/Model/Stock/Status.php index a930ab4169d2f86f50f3e9429b6eabaa95da4eec..4b91ba19d267e8dea109408f44978215d7c3f29c 100644 --- a/app/code/Magento/CatalogInventory/Model/Stock/Status.php +++ b/app/code/Magento/CatalogInventory/Model/Stock/Status.php @@ -9,7 +9,7 @@ use Magento\CatalogInventory\Api\Data\StockItemInterface; use Magento\CatalogInventory\Api\Data\StockStatusInterface; use Magento\CatalogInventory\Api\StockRegistryInterface; use Magento\Framework\Api\AttributeValueFactory; -use Magento\Framework\Api\MetadataServiceInterface; +use Magento\Framework\Api\ExtensionAttributesFactory; use Magento\Framework\Model\AbstractExtensibleModel; /** @@ -38,7 +38,7 @@ class Status extends AbstractExtensibleModel implements StockStatusInterface /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry - * @param MetadataServiceInterface $metadataService + * @param ExtensionAttributesFactory $extensionFactory * @param AttributeValueFactory $customAttributeFactory * @param StockRegistryInterface $stockRegistry * @param \Magento\Framework\Model\Resource\AbstractResource $resource @@ -48,7 +48,7 @@ class Status extends AbstractExtensibleModel implements StockStatusInterface public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, - MetadataServiceInterface $metadataService, + ExtensionAttributesFactory $extensionFactory, AttributeValueFactory $customAttributeFactory, StockRegistryInterface $stockRegistry, \Magento\Framework\Model\Resource\AbstractResource $resource = null, @@ -58,7 +58,7 @@ class Status extends AbstractExtensibleModel implements StockStatusInterface parent::__construct( $context, $registry, - $metadataService, + $extensionFactory, $customAttributeFactory, $resource, $resourceCollection, @@ -172,5 +172,27 @@ class Status extends AbstractExtensibleModel implements StockStatusInterface { return $this->setData(self::KEY_STOCK_STATUS, $stockStatus); } + + /** + * {@inheritdoc} + * + * @return \Magento\CatalogInventory\Api\Data\StockStatusExtensionInterface|null + */ + public function getExtensionAttributes() + { + return $this->_getExtensionAttributes(); + } + + /** + * {@inheritdoc} + * + * @param \Magento\CatalogInventory\Api\Data\StockStatusExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes( + \Magento\CatalogInventory\Api\Data\StockStatusExtensionInterface $extensionAttributes + ) { + return $this->_setExtensionAttributes($extensionAttributes); + } //@codeCoverageIgnoreEnd } diff --git a/app/code/Magento/CatalogInventory/Model/Stock/StockItemRepository.php b/app/code/Magento/CatalogInventory/Model/Stock/StockItemRepository.php index d41f2951dadeab5d2c610f0609c94e5e8e1d0670..4a5cc92f8f87e9ed80554525a5394cf8e4e7bbe6 100644 --- a/app/code/Magento/CatalogInventory/Model/Stock/StockItemRepository.php +++ b/app/code/Magento/CatalogInventory/Model/Stock/StockItemRepository.php @@ -156,7 +156,7 @@ class StockItemRepository implements StockItemRepositoryInterface $this->indexProcessor->reindexRow($stockItem->getProductId()); } catch (\Exception $exception) { - throw new CouldNotSaveException($exception->getMessage()); + throw new CouldNotSaveException(__($exception->getMessage())); } return $stockItem; } @@ -169,7 +169,7 @@ class StockItemRepository implements StockItemRepositoryInterface $stockItem = $this->stockItemFactory->create(); $this->resource->load($stockItem, $stockItemId); if (!$stockItem->getItemId()) { - throw new NoSuchEntityException(sprintf('Stock Item with id "%s" does not exist.', $stockItemId)); + throw new NoSuchEntityException(__('Stock Item with id "%1" does not exist.', $stockItemId)); } return $stockItem; } @@ -195,7 +195,7 @@ class StockItemRepository implements StockItemRepositoryInterface try { $this->resource->delete($stockItem); } catch (\Exception $exception) { - throw new CouldNotDeleteException($exception->getMessage()); + throw new CouldNotDeleteException(__($exception->getMessage())); } return true; } @@ -209,7 +209,7 @@ class StockItemRepository implements StockItemRepositoryInterface $stockItem = $this->get($id); $this->delete($stockItem); } catch (\Exception $exception) { - throw new CouldNotDeleteException($exception->getMessage()); + throw new CouldNotDeleteException(__($exception->getMessage())); } return true; } diff --git a/app/code/Magento/CatalogInventory/Model/Stock/StockRepository.php b/app/code/Magento/CatalogInventory/Model/Stock/StockRepository.php index bc3f7774e874cf186638f0f71f0d4ae7afd0cc60..590f98813c9049a411ee4d9395c4d377e2417afc 100644 --- a/app/code/Magento/CatalogInventory/Model/Stock/StockRepository.php +++ b/app/code/Magento/CatalogInventory/Model/Stock/StockRepository.php @@ -78,7 +78,7 @@ class StockRepository implements StockRepositoryInterface try { $this->resource->save($stock); } catch (\Exception $exception) { - throw new CouldNotSaveException($exception->getMessage()); + throw new CouldNotSaveException(__($exception->getMessage())); } return $stock; } @@ -93,7 +93,7 @@ class StockRepository implements StockRepositoryInterface $stock = $this->stockFactory->create(); $this->resource->load($stock, $stockId); if (!$stock->getId()) { - throw new NoSuchEntityException(sprintf('Stock with id "%s" does not exist.', $stockId)); + throw new NoSuchEntityException(__('Stock with id "%1" does not exist.', $stockId)); } return $stock; } @@ -122,7 +122,7 @@ class StockRepository implements StockRepositoryInterface try { $this->resource->delete($stock); } catch (\Exception $exception) { - throw new CouldNotDeleteException($exception->getMessage()); + throw new CouldNotDeleteException(__($exception->getMessage())); } return true; } @@ -138,7 +138,7 @@ class StockRepository implements StockRepositoryInterface $stock = $this->get($id); $this->delete($stock); } catch (\Exception $exception) { - throw new CouldNotDeleteException($exception->getMessage()); + throw new CouldNotDeleteException(__($exception->getMessage())); } return true; } diff --git a/app/code/Magento/CatalogInventory/Model/Stock/StockStatusRepository.php b/app/code/Magento/CatalogInventory/Model/Stock/StockStatusRepository.php index 2c1e24a42c024e1f2512b2e89951be3c69d0673c..cef158fe1d44f1fd5cde737099c7d1d11fb4a80c 100644 --- a/app/code/Magento/CatalogInventory/Model/Stock/StockStatusRepository.php +++ b/app/code/Magento/CatalogInventory/Model/Stock/StockStatusRepository.php @@ -76,7 +76,7 @@ class StockStatusRepository implements StockStatusRepositoryInterface try { $this->resource->save($stockStatus); } catch (\Exception $exception) { - throw new CouldNotSaveException($exception->getMessage()); + throw new CouldNotSaveException(__($exception->getMessage())); } return $stockStatus; } @@ -116,7 +116,7 @@ class StockStatusRepository implements StockStatusRepositoryInterface try { $this->resource->delete($stockStatus); } catch (\Exception $exception) { - throw new CouldNotDeleteException($exception->getMessage()); + throw new CouldNotDeleteException(__($exception->getMessage())); } return true; } @@ -132,7 +132,7 @@ class StockStatusRepository implements StockStatusRepositoryInterface $stockStatus = $this->get($id); $this->delete($stockStatus); } catch (\Exception $exception) { - throw new CouldNotDeleteException($exception->getMessage()); + throw new CouldNotDeleteException(__($exception->getMessage())); } return true; } diff --git a/app/code/Magento/CatalogInventory/Model/StockRegistry.php b/app/code/Magento/CatalogInventory/Model/StockRegistry.php index 999a786214e17a304fcce637917f37527206d6d3..fefbf9f34899f031a374d551e390b24235d3f9c0 100644 --- a/app/code/Magento/CatalogInventory/Model/StockRegistry.php +++ b/app/code/Magento/CatalogInventory/Model/StockRegistry.php @@ -205,7 +205,10 @@ class StockRegistry implements StockRegistryInterface $productId = $product->getIdBySku($productSku); if (!$productId) { throw new \Magento\Framework\Exception\NoSuchEntityException( - "Product with SKU \"{$productSku}\" does not exist" + __( + 'Product with SKU "%1" does not exist', + $productSku + ) ); } return $productId; diff --git a/app/code/Magento/CatalogInventory/etc/config.xml b/app/code/Magento/CatalogInventory/etc/config.xml index 3b19e058fe0001cd78538f82d540785941484aef..52c6f7ce2f7b2e11a2cff2c3bd2f3e066e916835 100644 --- a/app/code/Magento/CatalogInventory/etc/config.xml +++ b/app/code/Magento/CatalogInventory/etc/config.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Core/etc/config.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Store/etc/config.xsd"> <default> <cataloginventory> <options> diff --git a/app/code/Magento/CatalogInventory/etc/webapi.xml b/app/code/Magento/CatalogInventory/etc/webapi.xml index 238794f1796574fe5b3633880c7083eb0f32e8d0..80317eccf51a7dd8ba3e7d24fe0497cef61e9df2 100644 --- a/app/code/Magento/CatalogInventory/etc/webapi.xml +++ b/app/code/Magento/CatalogInventory/etc/webapi.xml @@ -7,25 +7,25 @@ --> <routes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../app/code/Magento/Webapi/etc/webapi.xsd"> - <route url="/V1/stockItem/:productSku" method="GET"> + <route url="/V1/stockItems/:productSku" method="GET"> <service class="Magento\CatalogInventory\Api\StockRegistryInterface" method="getStockItemBySku"/> <resources> <resource ref="Magento_CatalogInventory::cataloginventory"/> </resources> </route> - <route url="/V1/stockItem/:productSku" method="PUT"> + <route url="/V1/stockItems/:productSku" method="PUT"> <service class="Magento\CatalogInventory\Api\StockRegistryInterface" method="updateStockItemBySku"/> <resources> <resource ref="Magento_CatalogInventory::cataloginventory"/> </resources> </route> - <route url="/V1/stockItem/lowStock/" method="GET"> + <route url="/V1/stockItems/lowStock/" method="GET"> <service class="Magento\CatalogInventory\Api\StockRegistryInterface" method="getLowStockItems"/> <resources> <resource ref="Magento_CatalogInventory::cataloginventory"/> </resources> </route> - <route url="/V1/stockStatus/:productSku" method="GET"> + <route url="/V1/stockStatuses/:productSku" method="GET"> <service class="Magento\CatalogInventory\Api\StockRegistryInterface" method="getStockStatusBySku"/> <resources> <resource ref="anonymous"/> diff --git a/app/code/Magento/CatalogRule/Model/Indexer/AbstractIndexer.php b/app/code/Magento/CatalogRule/Model/Indexer/AbstractIndexer.php index cf52ebbe0669ae45c8ec130f440f557b22865427..a4d8b53934937cd2342f00bfd5505f6d59953ecc 100644 --- a/app/code/Magento/CatalogRule/Model/Indexer/AbstractIndexer.php +++ b/app/code/Magento/CatalogRule/Model/Indexer/AbstractIndexer.php @@ -16,12 +16,23 @@ abstract class AbstractIndexer implements IndexerActionInterface, MviewActionInt */ protected $indexBuilder; + /** + * Application Event Dispatcher + * + * @var \Magento\Framework\Event\ManagerInterface + */ + protected $_eventManager; + /** * @param IndexBuilder $indexBuilder + * @param \Magento\Framework\Event\ManagerInterface $eventManager */ - public function __construct(IndexBuilder $indexBuilder) - { + public function __construct( + IndexBuilder $indexBuilder, + \Magento\Framework\Event\ManagerInterface $eventManager + ) { $this->indexBuilder = $indexBuilder; + $this->_eventManager = $eventManager; } /** @@ -43,6 +54,20 @@ abstract class AbstractIndexer implements IndexerActionInterface, MviewActionInt public function executeFull() { $this->indexBuilder->reindexFull(); + $this->_eventManager->dispatch('clean_cache_by_tags', ['object' => $this]); + } + + /** + * Get affected cache tags + * + * @return array + */ + public function getIdentities() + { + return [ + \Magento\Catalog\Model\Category::CACHE_TAG, + \Magento\Catalog\Model\Product::CACHE_TAG + ]; } /** diff --git a/app/code/Magento/CatalogRule/Model/Rule.php b/app/code/Magento/CatalogRule/Model/Rule.php index 61eac7c2b59f204a98ee782994d04eed6e97bfbf..99eb4752f691cb88006c3cd108782aa53600e991 100644 --- a/app/code/Magento/CatalogRule/Model/Rule.php +++ b/app/code/Magento/CatalogRule/Model/Rule.php @@ -143,6 +143,11 @@ class Rule extends \Magento\Rule\Model\AbstractModel */ protected $dateTime; + /** + * @var \Magento\CatalogRule\Model\Indexer\Rule\RuleProductProcessor; + */ + protected $_ruleProductProcessor; + /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry @@ -158,6 +163,7 @@ class Rule extends \Magento\Rule\Model\AbstractModel * @param \Magento\CatalogRule\Helper\Data $catalogRuleData * @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypesList * @param \Magento\Framework\Stdlib\DateTime $dateTime + * @param \Magento\CatalogRule\Model\Indexer\Rule\RuleProductProcessor $ruleProductProcessor * @param \Magento\Framework\Model\Resource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\Db $resourceCollection * @param array $relatedCacheTypes @@ -179,6 +185,7 @@ class Rule extends \Magento\Rule\Model\AbstractModel \Magento\CatalogRule\Helper\Data $catalogRuleData, \Magento\Framework\App\Cache\TypeListInterface $cacheTypesList, \Magento\Framework\Stdlib\DateTime $dateTime, + \Magento\CatalogRule\Model\Indexer\Rule\RuleProductProcessor $ruleProductProcessor, \Magento\Framework\Model\Resource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\Db $resourceCollection = null, array $relatedCacheTypes = [], @@ -195,6 +202,7 @@ class Rule extends \Magento\Rule\Model\AbstractModel $this->_cacheTypesList = $cacheTypesList; $this->_relatedCacheTypes = $relatedCacheTypes; $this->dateTime = $dateTime; + $this->_ruleProductProcessor = $ruleProductProcessor; parent::__construct($context, $registry, $formFactory, $localeDate, $resource, $resourceCollection, $data); } @@ -445,4 +453,33 @@ class Rule extends \Magento\Rule\Model\AbstractModel } return $this; } + + /** + * {@inheritdoc} + * + * @return $this + */ + public function afterSave() + { + if ($this->isObjectNew()) { + $this->getMatchingProductIds(); + if (!empty($this->_productIds) && is_array($this->_productIds)) { + $this->_ruleProductProcessor->reindexList($this->_productIds); + } + } else { + $this->_ruleProductProcessor->getIndexer()->invalidate(); + } + return parent::afterSave(); + } + + /** + * {@inheritdoc} + * + * @return $this + */ + public function afterDelete() + { + $this->_ruleProductProcessor->getIndexer()->invalidate(); + return parent::afterDelete(); + } } diff --git a/app/code/Magento/CatalogRule/Test/Unit/Model/Indexer/AbstractIndexerTest.php b/app/code/Magento/CatalogRule/Test/Unit/Model/Indexer/AbstractIndexerTest.php index 526ea7786417882ee711161a4021d27b66fcf7e7..b9a21020e4120a7218a7af66fc9ba0d833a2ebc8 100644 --- a/app/code/Magento/CatalogRule/Test/Unit/Model/Indexer/AbstractIndexerTest.php +++ b/app/code/Magento/CatalogRule/Test/Unit/Model/Indexer/AbstractIndexerTest.php @@ -18,16 +18,35 @@ class AbstractIndexerTest extends \PHPUnit_Framework_TestCase */ protected $indexer; + /** + * @var \Magento\Framework\Event\ManagerInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $_eventManagerMock; + + /** + * Set up test + * + * @return void + */ protected function setUp() { + $this->_eventManagerMock = $this->getMock('\Magento\Framework\Event\ManagerInterface'); $this->indexBuilder = $this->getMock('Magento\CatalogRule\Model\Indexer\IndexBuilder', [], [], '', false); $this->indexer = $this->getMockForAbstractClass( 'Magento\CatalogRule\Model\Indexer\AbstractIndexer', - [$this->indexBuilder] + [ + $this->indexBuilder, + $this->_eventManagerMock + ] ); } + /** + * Test execute + * + * @return void + */ public function testExecute() { $ids = [1, 2, 5]; @@ -36,9 +55,20 @@ class AbstractIndexerTest extends \PHPUnit_Framework_TestCase $this->indexer->execute($ids); } + /** + * Test execute full reindex action + * + * @return void + */ public function testExecuteFull() { $this->indexBuilder->expects($this->once())->method('reindexFull'); + $this->_eventManagerMock->expects($this->once()) + ->method('dispatch') + ->with( + 'clean_cache_by_tags', + ['object' => $this->indexer] + ); $this->indexer->executeFull(); } @@ -46,12 +76,19 @@ class AbstractIndexerTest extends \PHPUnit_Framework_TestCase /** * @expectedException \Magento\CatalogRule\CatalogRuleException * @expectedExceptionMessage Could not rebuild index for empty products array + * + * @return void */ public function testExecuteListWithEmptyIds() { $this->indexer->executeList([]); } + /** + * @throws \Magento\CatalogRule\CatalogRuleException + * + * @return void + */ public function testExecuteList() { $ids = [1, 2, 5]; @@ -63,12 +100,19 @@ class AbstractIndexerTest extends \PHPUnit_Framework_TestCase /** * @expectedException \Magento\CatalogRule\CatalogRuleException * @expectedExceptionMessage Could not rebuild index for undefined product + * + * @return void */ public function testExecuteRowWithEmptyId() { $this->indexer->executeRow(null); } + /** + * @throws \Magento\CatalogRule\CatalogRuleException + * + * @return void + */ public function testExecuteRow() { $id = 5; diff --git a/app/code/Magento/CatalogRule/Test/Unit/Model/Rule/JobTest.php b/app/code/Magento/CatalogRule/Test/Unit/Model/Rule/JobTest.php index be0dcc77b2cad4d271761ea1c379ddbec323f869..ead5a8829f774d7ebdfac0d3f0d190e3cea0fdd9 100644 --- a/app/code/Magento/CatalogRule/Test/Unit/Model/Rule/JobTest.php +++ b/app/code/Magento/CatalogRule/Test/Unit/Model/Rule/JobTest.php @@ -44,7 +44,7 @@ class JobTest extends \PHPUnit_Framework_TestCase ); $exceptionMessage = 'Test exception message'; $exceptionCallback = function () use ($exceptionMessage) { - throw new \Magento\Framework\Exception\LocalizedException($exceptionMessage); + throw new \Magento\Framework\Exception\LocalizedException(__($exceptionMessage)); }; $ruleProcessorMock->expects($this->once()) ->method('markIndexerAsInvalid') diff --git a/app/code/Magento/CatalogRule/Test/Unit/Model/RuleTest.php b/app/code/Magento/CatalogRule/Test/Unit/Model/RuleTest.php index 095ca9891a7405407df9b759950721b4d2676d40..4b3d8d2edd1875f00b0244b31f82a2796e6bc60e 100644 --- a/app/code/Magento/CatalogRule/Test/Unit/Model/RuleTest.php +++ b/app/code/Magento/CatalogRule/Test/Unit/Model/RuleTest.php @@ -31,6 +31,31 @@ class RuleTest extends \PHPUnit_Framework_TestCase /** @var \Magento\Rule\Model\Condition\Combine|\PHPUnit_Framework_MockObject_MockObject */ protected $condition; + /** + * @var \Magento\CatalogRule\Model\Indexer\Rule\RuleProductProcessor|\PHPUnit_Framework_MockObject_MockObject + */ + protected $_ruleProductProcessor; + + /** + * @var \Magento\Catalog\Model\Resource\Product\CollectionFactory|\PHPUnit_Framework_MockObject_MockObject + */ + protected $_productCollectionFactory; + + /** + * @var \Magento\Framework\Model\Resource\Iterator|\PHPUnit_Framework_MockObject_MockObject + */ + protected $_resourceIterator; + + /** + * @var \Magento\Catalog\Model\Product|\PHPUnit_Framework_MockObject_MockObject + */ + protected $productModel; + + /** + * Set up before test + * + * @return void + */ protected function setUp() { $this->storeManager = $this->getMock('Magento\Store\Model\StoreManagerInterface'); @@ -74,13 +99,39 @@ class RuleTest extends \PHPUnit_Framework_TestCase '', false ); + $this->_ruleProductProcessor = $this->getMock( + '\Magento\CatalogRule\Model\Indexer\Rule\RuleProductProcessor', + [], + [], + '', + false + ); + + $this->_productCollectionFactory = $this->getMock( + '\Magento\Catalog\Model\Resource\Product\CollectionFactory', + ['create'], + [], + '', + false + ); + + $this->_resourceIterator = $this->getMock( + '\Magento\Framework\Model\Resource\Iterator', + ['walk'], + [], + '', + false + ); $this->objectManagerHelper = new ObjectManagerHelper($this); $this->rule = $this->objectManagerHelper->getObject( 'Magento\CatalogRule\Model\Rule', [ 'storeManager' => $this->storeManager, - 'combineFactory' => $this->combineFactory + 'combineFactory' => $this->combineFactory, + 'ruleProductProcessor' => $this->_ruleProductProcessor, + 'productCollectionFactory' => $this->_productCollectionFactory, + 'resourceIterator' => $this->_resourceIterator, ] ); } @@ -88,6 +139,8 @@ class RuleTest extends \PHPUnit_Framework_TestCase /** * @dataProvider dataProviderCallbackValidateProduct * @param bool $validate + * + * @return void */ public function testCallbackValidateProduct($validate) { @@ -134,6 +187,11 @@ class RuleTest extends \PHPUnit_Framework_TestCase } } + /** + * Data provider for callbackValidateProduct test + * + * @return array + */ public function dataProviderCallbackValidateProduct() { return [ @@ -141,4 +199,31 @@ class RuleTest extends \PHPUnit_Framework_TestCase [true], ]; } + + /** + * Test after delete action + * + * @return void + */ + public function testAfterDelete() + { + $indexer = $this->getMock('\Magento\Indexer\Model\IndexerInterface'); + $indexer->expects($this->once())->method('invalidate'); + $this->_ruleProductProcessor->expects($this->once())->method('getIndexer')->will($this->returnValue($indexer)); + $this->rule->afterDelete(); + } + + /** + * Test after update action + * + * @return void + */ + public function testAfterUpdate() + { + $this->rule->isObjectNew(false); + $indexer = $this->getMock('\Magento\Indexer\Model\IndexerInterface'); + $indexer->expects($this->once())->method('invalidate'); + $this->_ruleProductProcessor->expects($this->once())->method('getIndexer')->will($this->returnValue($indexer)); + $this->rule->afterSave(); + } } diff --git a/app/code/Magento/CatalogSearch/etc/config.xml b/app/code/Magento/CatalogSearch/etc/config.xml index e6812e9c2629a7555da67222270e2f16db705ce1..a29db223f42df34564539bff7af30620bee812c4 100644 --- a/app/code/Magento/CatalogSearch/etc/config.xml +++ b/app/code/Magento/CatalogSearch/etc/config.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Core/etc/config.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Store/etc/config.xsd"> <default> <catalog> <seo> diff --git a/app/code/Magento/CatalogSearch/etc/frontend/page_types.xml b/app/code/Magento/CatalogSearch/etc/frontend/page_types.xml index 8aa580b0ef888b5b82d90e1909cd79139cb89f29..5f4367132ae9b7dd9ce2095e035c01302234fe3c 100644 --- a/app/code/Magento/CatalogSearch/etc/frontend/page_types.xml +++ b/app/code/Magento/CatalogSearch/etc/frontend/page_types.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> -<page_types xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../Core/etc/page_types.xsd"> +<page_types xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_types.xsd"> <type id="catalogsearch_advanced_index" label="Advanced Search Form"/> <type id="catalogsearch_advanced_result" label="Advanced Search Result"/> <type id="catalogsearch_result_index" label="Quick Search Form"/> diff --git a/app/code/Magento/CatalogUrlRewrite/Model/Category/CanonicalUrlRewriteGenerator.php b/app/code/Magento/CatalogUrlRewrite/Model/Category/CanonicalUrlRewriteGenerator.php index 749b746ca8e8e2853b8c29f7732753adf257dde0..1e71af266597a15bc4d580dffff8afb86ccf4e26 100644 --- a/app/code/Magento/CatalogUrlRewrite/Model/Category/CanonicalUrlRewriteGenerator.php +++ b/app/code/Magento/CatalogUrlRewrite/Model/Category/CanonicalUrlRewriteGenerator.php @@ -39,12 +39,14 @@ class CanonicalUrlRewriteGenerator */ public function generate($storeId, Category $category) { - return [ - $this->urlRewriteFactory->create()->setStoreId($storeId) + $urlPath = $this->categoryUrlPathGenerator->getUrlPathWithSuffix($category, $storeId); + $result = [ + $urlPath . '_' . $storeId => $this->urlRewriteFactory->create()->setStoreId($storeId) ->setEntityType(CategoryUrlRewriteGenerator::ENTITY_TYPE) ->setEntityId($category->getId()) - ->setRequestPath($this->categoryUrlPathGenerator->getUrlPathWithSuffix($category, $storeId)) + ->setRequestPath($urlPath) ->setTargetPath($this->categoryUrlPathGenerator->getCanonicalUrlPath($category)) ]; + return $result; } } diff --git a/app/code/Magento/CatalogUrlRewrite/Model/Category/CurrentUrlRewritesRegenerator.php b/app/code/Magento/CatalogUrlRewrite/Model/Category/CurrentUrlRewritesRegenerator.php index fc7107801aca1499d67eb3ec16e6dbd385f7a588..6f0cfdb2b5ccd65a3de26d869daab89465728498 100644 --- a/app/code/Magento/CatalogUrlRewrite/Model/Category/CurrentUrlRewritesRegenerator.php +++ b/app/code/Magento/CatalogUrlRewrite/Model/Category/CurrentUrlRewritesRegenerator.php @@ -83,7 +83,7 @@ class CurrentUrlRewritesRegenerator if ($this->category->getData('save_rewrites_history')) { $targetPath = $this->categoryUrlPathGenerator->getUrlPathWithSuffix($this->category, $storeId); if ($url->getRequestPath() !== $targetPath) { - $urls[] = $this->urlRewriteFactory->create() + $urls[$url->getRequestPath() . '_' . $storeId] = $this->urlRewriteFactory->create() ->setEntityType(CategoryUrlRewriteGenerator::ENTITY_TYPE) ->setEntityId($this->category->getId()) ->setRequestPath($url->getRequestPath()) @@ -108,7 +108,7 @@ class CurrentUrlRewritesRegenerator ? $url->getTargetPath() : $this->categoryUrlPathGenerator->getUrlPathWithSuffix($this->category, $storeId); if ($url->getRequestPath() !== $targetPath) { - $urls[] = $this->urlRewriteFactory->create() + $urls[$url->getRequestPath() . '_' . $storeId] = $this->urlRewriteFactory->create() ->setEntityType(CategoryUrlRewriteGenerator::ENTITY_TYPE) ->setEntityId($this->category->getId()) ->setRequestPath($url->getRequestPath()) diff --git a/app/code/Magento/CatalogUrlRewrite/Model/ProductUrlRewriteGenerator.php b/app/code/Magento/CatalogUrlRewrite/Model/ProductUrlRewriteGenerator.php index a8661bfdc9eaa358ead6ad52b74989d4bf705794..74158ce4093d3be02799dba710e235bbbc305095 100644 --- a/app/code/Magento/CatalogUrlRewrite/Model/ProductUrlRewriteGenerator.php +++ b/app/code/Magento/CatalogUrlRewrite/Model/ProductUrlRewriteGenerator.php @@ -137,13 +137,22 @@ class ProductUrlRewriteGenerator } } $this->productCategories = $this->objectRegistryFactory->create(['entities' => $categories]); + /** + * @var $urls \Magento\UrlRewrite\Service\V1\Data\UrlRewrite[] + */ $urls = array_merge( $this->canonicalUrlRewriteGenerator->generate($storeId, $this->product), $this->categoriesUrlRewriteGenerator->generate($storeId, $this->product, $this->productCategories), $this->currentUrlRewritesRegenerator->generate($storeId, $this->product, $this->productCategories) ); + + /* Reduce duplicates. Last wins */ + $result = []; + foreach ($urls as $url) { + $result[$url->getTargetPath() . '-' . $url->getStoreId()] = $url; + } $this->productCategories = null; - return $urls; + return $result; } /** diff --git a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Category/CanonicalUrlRewriteGeneratorTest.php b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Category/CanonicalUrlRewriteGeneratorTest.php index 93a09f24ea8ac466b08ac4d8c2ce0d0771476a81..80983cad9beeda486da557f9b373216fbb993c54 100644 --- a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Category/CanonicalUrlRewriteGeneratorTest.php +++ b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Category/CanonicalUrlRewriteGeneratorTest.php @@ -3,6 +3,7 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ +// @codingStandardsIgnoreFile namespace Magento\CatalogUrlRewrite\Test\Unit\Model\Category; use Magento\CatalogUrlRewrite\Model\CategoryUrlRewriteGenerator; @@ -70,7 +71,7 @@ class CanonicalUrlRewriteGeneratorTest extends \PHPUnit_Framework_TestCase ->will($this->returnSelf()); $this->urlRewriteFactory->expects($this->any())->method('create')->will($this->returnValue($this->urlRewrite)); $this->assertEquals( - [$this->urlRewrite], + ['category.html_store_id' => $this->urlRewrite], $this->canonicalUrlRewriteGenerator->generate($storeId, $this->category) ); } diff --git a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Category/CurrentUrlRewritesRegeneratorTest.php b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Category/CurrentUrlRewritesRegeneratorTest.php index db8545333579635b506339ead620e789fd8551de..4e1b56ce6eeb5c9c474b27606bda50a7c3e37456 100644 --- a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Category/CurrentUrlRewritesRegeneratorTest.php +++ b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Category/CurrentUrlRewritesRegeneratorTest.php @@ -3,6 +3,7 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ +// @codingStandardsIgnoreFile namespace Magento\CatalogUrlRewrite\Test\Unit\Model\Category; use Magento\CatalogUrlRewrite\Model\CategoryUrlRewriteGenerator; @@ -128,7 +129,7 @@ class CurrentUrlRewritesRegeneratorTest extends \PHPUnit_Framework_TestCase $this->prepareUrlRewriteMock($storeId, $categoryId, $requestPath, $targetPath, OptionProvider::PERMANENT); $this->assertEquals( - [$this->urlRewrite], + ['autogenerated.html_2' => $this->urlRewrite], $this->currentUrlRewritesRegenerator->generate($storeId, $this->category) ); } @@ -191,7 +192,7 @@ class CurrentUrlRewritesRegeneratorTest extends \PHPUnit_Framework_TestCase $this->prepareUrlRewriteMock($storeId, $categoryId, $requestPath, $targetPath, 0); $this->assertEquals( - [$this->urlRewrite], + ['generate-for-custom-without-redirect-type.html_12' => $this->urlRewrite], $this->currentUrlRewritesRegenerator->generate($storeId, $this->category) ); } @@ -230,7 +231,7 @@ class CurrentUrlRewritesRegeneratorTest extends \PHPUnit_Framework_TestCase $this->prepareUrlRewriteMock($storeId, $categoryId, $requestPath, $targetPath, 'code'); $this->assertEquals( - [$this->urlRewrite], + ['generate-for-custom-without-redirect-type.html_12' => $this->urlRewrite], $this->currentUrlRewritesRegenerator->generate($storeId, $this->category) ); } diff --git a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/CategoryUrlRewriteGeneratorTest.php b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/CategoryUrlRewriteGeneratorTest.php index 239dcffcbba3ee19b64ef4fe372e6eb1336a50a5..c435eda8c7bd345a5a0c9e700e097a8362ee28c6 100644 --- a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/CategoryUrlRewriteGeneratorTest.php +++ b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/CategoryUrlRewriteGeneratorTest.php @@ -3,6 +3,9 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ + +// @codingStandardsIgnoreFile + namespace Magento\CatalogUrlRewrite\Test\Unit\Model; use Magento\Catalog\Model\Category; @@ -28,6 +31,9 @@ class CategoryUrlRewriteGeneratorTest extends \PHPUnit_Framework_TestCase /** @var \Magento\Catalog\Model\Category|\PHPUnit_Framework_MockObject_MockObject */ protected $category; + /** + * Test method + */ protected function setUp() { $this->currentUrlRewritesRegenerator = $this->getMockBuilder( @@ -54,39 +60,60 @@ class CategoryUrlRewriteGeneratorTest extends \PHPUnit_Framework_TestCase ); } + /** + * Test method + */ public function testGenerationForGlobalScope() { $this->category->expects($this->any())->method('getStoreId')->will($this->returnValue(null)); $this->category->expects($this->any())->method('getStoreIds')->will($this->returnValue([1])); $this->storeViewService->expects($this->once())->method('doesEntityHaveOverriddenUrlKeyForStore') ->will($this->returnValue(false)); + $canonical = new \Magento\UrlRewrite\Service\V1\Data\UrlRewrite(); + $canonical->setTargetPath('category-1') + ->setStoreId(1); $this->canonicalUrlRewriteGenerator->expects($this->any())->method('generate') - ->will($this->returnValue(['canonical'])); + ->will($this->returnValue([$canonical])); + $children = new \Magento\UrlRewrite\Service\V1\Data\UrlRewrite(); + $children->setTargetPath('category-2') + ->setStoreId(2); $this->childrenUrlRewriteGenerator->expects($this->any())->method('generate') - ->will($this->returnValue(['children'])); + ->will($this->returnValue([$children])); + $current = new \Magento\UrlRewrite\Service\V1\Data\UrlRewrite(); + $current->setTargetPath('category-3') + ->setStoreId(3); $this->currentUrlRewritesRegenerator->expects($this->any())->method('generate') - ->will($this->returnValue(['current'])); + ->will($this->returnValue([$current])); $this->assertEquals( - ['canonical', 'children', 'current'], + [$canonical, $children, $current], $this->categoryUrlRewriteGenerator->generate($this->category) ); } + /** + * Test method + */ public function testGenerationForSpecificStore() { $this->category->expects($this->any())->method('getStoreId')->will($this->returnValue(1)); $this->category->expects($this->never())->method('getStoreIds'); + $canonical = new \Magento\UrlRewrite\Service\V1\Data\UrlRewrite(); + $canonical->setTargetPath('category-1') + ->setStoreId(1); $this->canonicalUrlRewriteGenerator->expects($this->any())->method('generate') - ->will($this->returnValue(['canonical'])); + ->will($this->returnValue([$canonical])); $this->childrenUrlRewriteGenerator->expects($this->any())->method('generate') ->will($this->returnValue([])); $this->currentUrlRewritesRegenerator->expects($this->any())->method('generate') ->will($this->returnValue([])); - $this->assertEquals(['canonical'], $this->categoryUrlRewriteGenerator->generate($this->category)); + $this->assertEquals([$canonical], $this->categoryUrlRewriteGenerator->generate($this->category)); } + /** + * Test method + */ public function testSkipGenerationForGlobalScope() { $this->category->expects($this->any())->method('getStoreIds')->will($this->returnValue([1, 2])); diff --git a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/ProductUrlRewriteGeneratorTest.php b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/ProductUrlRewriteGeneratorTest.php index 0608f755137936d1c6b8c612f3bb97f0c55d546e..861516a338f1bc8c92f86d98815741f78ef899b5 100644 --- a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/ProductUrlRewriteGeneratorTest.php +++ b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/ProductUrlRewriteGeneratorTest.php @@ -3,6 +3,9 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ + +// @codingStandardsIgnoreFile + namespace Magento\CatalogUrlRewrite\Test\Unit\Model; use Magento\Catalog\Model\Category; @@ -37,6 +40,9 @@ class ProductUrlRewriteGeneratorTest extends \PHPUnit_Framework_TestCase /** @var \Magento\Catalog\Model\Resource\Category\Collection|\PHPUnit_Framework_MockObject_MockObject */ protected $categoriesCollection; + /** + * Test method + */ protected function setUp() { $this->product = $this->getMock('Magento\Catalog\Model\Product', [], [], '', false); @@ -75,6 +81,9 @@ class ProductUrlRewriteGeneratorTest extends \PHPUnit_Framework_TestCase ); } + /** + * Test method + */ public function testGenerationForGlobalScope() { $this->product->expects($this->any())->method('getStoreId')->will($this->returnValue(null)); @@ -84,19 +93,31 @@ class ProductUrlRewriteGeneratorTest extends \PHPUnit_Framework_TestCase $this->categoriesCollection->expects($this->any())->method('getIterator') ->willReturn(new \ArrayIterator([])); $this->initObjectRegistryFactory([]); + $canonical = new \Magento\UrlRewrite\Service\V1\Data\UrlRewrite(); + $canonical->setTargetPath('category-1') + ->setStoreId(1); $this->canonicalUrlRewriteGenerator->expects($this->any())->method('generate') - ->will($this->returnValue(['canonical'])); + ->will($this->returnValue([$canonical])); + $categories = new \Magento\UrlRewrite\Service\V1\Data\UrlRewrite(); + $categories->setTargetPath('category-2') + ->setStoreId(2); $this->categoriesUrlRewriteGenerator->expects($this->any())->method('generate') - ->will($this->returnValue(['categories'])); + ->will($this->returnValue([$categories])); + $current = new \Magento\UrlRewrite\Service\V1\Data\UrlRewrite(); + $current->setTargetPath('category-3') + ->setStoreId(3); $this->currentUrlRewritesRegenerator->expects($this->any())->method('generate') - ->will($this->returnValue(['current'])); + ->will($this->returnValue([$current])); $this->assertEquals( - ['canonical', 'categories', 'current'], + ['category-1-1' => $canonical, 'category-2-2' => $categories, 'category-3-3' => $current], $this->productUrlRewriteGenerator->generate($this->product) ); } + /** + * Test method + */ public function testGenerationForSpecificStore() { $this->product->expects($this->any())->method('getStoreId')->will($this->returnValue(1)); @@ -113,16 +134,22 @@ class ProductUrlRewriteGeneratorTest extends \PHPUnit_Framework_TestCase $this->categoriesCollection->expects($this->any())->method('getIterator') ->willReturn(new \ArrayIterator([$category])); $this->initObjectRegistryFactory([$category]); + $canonical = new \Magento\UrlRewrite\Service\V1\Data\UrlRewrite(); + $canonical->setTargetPath('category-1') + ->setStoreId(1); $this->canonicalUrlRewriteGenerator->expects($this->any())->method('generate') - ->will($this->returnValue(['canonical'])); + ->will($this->returnValue([$canonical])); $this->categoriesUrlRewriteGenerator->expects($this->any())->method('generate') ->will($this->returnValue([])); $this->currentUrlRewritesRegenerator->expects($this->any())->method('generate') ->will($this->returnValue([])); - $this->assertEquals(['canonical'], $this->productUrlRewriteGenerator->generate($this->product)); + $this->assertEquals(['category-1-1' => $canonical], $this->productUrlRewriteGenerator->generate($this->product)); } + /** + * Test method + */ public function testSkipRootCategoryForCategoriesGenerator() { $this->product->expects($this->any())->method('getStoreId')->will($this->returnValue(1)); @@ -136,16 +163,22 @@ class ProductUrlRewriteGeneratorTest extends \PHPUnit_Framework_TestCase $this->categoriesCollection->expects($this->any())->method('getIterator') ->willReturn(new \ArrayIterator([$rootCategory])); $this->initObjectRegistryFactory([]); + $canonical = new \Magento\UrlRewrite\Service\V1\Data\UrlRewrite(); + $canonical->setTargetPath('category-1') + ->setStoreId(1); $this->canonicalUrlRewriteGenerator->expects($this->any())->method('generate') - ->will($this->returnValue(['canonical'])); + ->will($this->returnValue([$canonical])); $this->categoriesUrlRewriteGenerator->expects($this->any())->method('generate') ->will($this->returnValue([])); $this->currentUrlRewritesRegenerator->expects($this->any())->method('generate') ->will($this->returnValue([])); - $this->assertEquals(['canonical'], $this->productUrlRewriteGenerator->generate($this->product)); + $this->assertEquals(['category-1-1' => $canonical], $this->productUrlRewriteGenerator->generate($this->product)); } + /** + * Test method + */ public function testSkipGenerationForNotStoreRootCategory() { $this->product->expects($this->any())->method('getStoreId')->will($this->returnValue(1)); @@ -159,16 +192,22 @@ class ProductUrlRewriteGeneratorTest extends \PHPUnit_Framework_TestCase $this->categoriesCollection->expects($this->any())->method('getIterator') ->willReturn(new \ArrayIterator([$category])); $this->initObjectRegistryFactory([]); + $canonical = new \Magento\UrlRewrite\Service\V1\Data\UrlRewrite(); + $canonical->setTargetPath('category-1') + ->setStoreId(1); $this->canonicalUrlRewriteGenerator->expects($this->any())->method('generate') - ->will($this->returnValue(['canonical'])); + ->will($this->returnValue([$canonical])); $this->categoriesUrlRewriteGenerator->expects($this->any())->method('generate') ->will($this->returnValue([])); $this->currentUrlRewritesRegenerator->expects($this->any())->method('generate') ->will($this->returnValue([])); - $this->assertEquals(['canonical'], $this->productUrlRewriteGenerator->generate($this->product)); + $this->assertEquals(['category-1-1' => $canonical], $this->productUrlRewriteGenerator->generate($this->product)); } + /** + * Test method + */ public function testSkipGenerationForGlobalScope() { $this->product->expects($this->any())->method('getStoreIds')->will($this->returnValue([1, 2])); diff --git a/app/code/Magento/Checkout/Block/Cart/EmptyCart.php b/app/code/Magento/Checkout/Block/Cart/EmptyCart.php new file mode 100644 index 0000000000000000000000000000000000000000..75928dc465489f8df30e1f465471ed0f5d30f0d0 --- /dev/null +++ b/app/code/Magento/Checkout/Block/Cart/EmptyCart.php @@ -0,0 +1,39 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Checkout\Block\Cart; + +class EmptyCart extends \Magento\Checkout\Block\Cart +{ + /** + * @param \Magento\Framework\View\Element\Template\Context $context + * @param \Magento\Customer\Model\Session $customerSession + * @param \Magento\Checkout\Model\Session $checkoutSession + * @param \Magento\Catalog\Model\Resource\Url $catalogUrlBuilder + * @param \Magento\Checkout\Helper\Cart $cartHelper + * @param \Magento\Framework\App\Http\Context $httpContext + * @param array $data + */ + public function __construct( + \Magento\Framework\View\Element\Template\Context $context, + \Magento\Customer\Model\Session $customerSession, + \Magento\Checkout\Model\Session $checkoutSession, + \Magento\Catalog\Model\Resource\Url $catalogUrlBuilder, + \Magento\Checkout\Helper\Cart $cartHelper, + \Magento\Framework\App\Http\Context $httpContext, + array $data = [] + ) { + parent::__construct( + $context, + $customerSession, + $checkoutSession, + $catalogUrlBuilder, + $cartHelper, + $httpContext, + $data + ); + $this->_isScopePrivate = false; + } +} diff --git a/app/code/Magento/Checkout/Block/Cart/ValidationMessages.php b/app/code/Magento/Checkout/Block/Cart/ValidationMessages.php new file mode 100644 index 0000000000000000000000000000000000000000..867be6583a61e8c17cdc5809dcf2d040a3c8cdfb --- /dev/null +++ b/app/code/Magento/Checkout/Block/Cart/ValidationMessages.php @@ -0,0 +1,107 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Checkout\Block\Cart; + +/** + * Shopping cart validation messages block + */ +class ValidationMessages extends \Magento\Framework\View\Element\Messages +{ + /** @var \Magento\Checkout\Helper\Cart */ + protected $cartHelper; + + /** @var \Magento\Framework\Locale\CurrencyInterface */ + protected $currency; + + /** + * @param \Magento\Framework\View\Element\Template\Context $context + * @param \Magento\Framework\Message\Factory $messageFactory + * @param \Magento\Framework\Message\CollectionFactory $collectionFactory + * @param \Magento\Framework\Message\ManagerInterface $messageManager + * @param \Magento\Checkout\Helper\Cart $cartHelper + * @param \Magento\Framework\Locale\CurrencyInterface $currency + * @param array $data + */ + public function __construct( + \Magento\Framework\View\Element\Template\Context $context, + \Magento\Framework\Message\Factory $messageFactory, + \Magento\Framework\Message\CollectionFactory $collectionFactory, + \Magento\Framework\Message\ManagerInterface $messageManager, + \Magento\Checkout\Helper\Cart $cartHelper, + \Magento\Framework\Locale\CurrencyInterface $currency, + array $data = [] + ) { + parent::__construct( + $context, + $messageFactory, + $collectionFactory, + $messageManager, + $data + ); + $this->cartHelper = $cartHelper; + $this->currency = $currency; + $this->_isScopePrivate = true; + } + + /** + * @return $this + */ + protected function _prepareLayout() + { + if ($this->cartHelper->getItemsCount()) { + $this->validateMinimunAmount(); + $this->addQuoteMessages(); + return parent::_prepareLayout(); + } + return $this; + } + + /** + * Validate minimum amount and display notice in error + * + * @return void + */ + public function validateMinimunAmount() + { + if (!$this->cartHelper->getQuote()->validateMinimumAmount()) { + $warning = $this->_scopeConfig->getValue( + 'sales/minimum_order/description', + \Magento\Store\Model\ScopeInterface::SCOPE_STORE + ); + if (!$warning) { + $currencyCode = $this->_storeManager->getStore()->getCurrentCurrencyCode(); + $minimumAmount = $this->currency->getCurrency($currencyCode)->toCurrency( + $this->_scopeConfig->getValue( + 'sales/minimum_order/amount', + \Magento\Store\Model\ScopeInterface::SCOPE_STORE + ) + ); + $warning = __('Minimum order amount is %1', $minimumAmount); + } + $this->messageManager->addNotice($warning); + } + } + + /** + * Add quote messages + * + * @return void + */ + public function addQuoteMessages() + { + // Compose array of messages to add + $messages = []; + /** @var \Magento\Framework\Message\MessageInterface $message */ + foreach ($this->cartHelper->getQuote()->getMessages() as $message) { + if ($message) { + // Escape HTML entities in quote message to prevent XSS + $message->setText($this->escapeHtml($message->getText())); + $messages[] = $message; + } + } + $this->messageManager->addUniqueMessages($messages); + } +} diff --git a/app/code/Magento/Checkout/Controller/Cart/Add.php b/app/code/Magento/Checkout/Controller/Cart/Add.php index d9cf864bd356fc02a1d18210cb4c451a523158da..69aa88b0b3dc81e75993c2e7fb99689b175b71a4 100644 --- a/app/code/Magento/Checkout/Controller/Cart/Add.php +++ b/app/code/Magento/Checkout/Controller/Cart/Add.php @@ -108,8 +108,6 @@ class Add extends \Magento\Checkout\Controller\Cart $this->cart->save(); - $this->_checkoutSession->setCartWasUpdated(true); - /** * @todo remove wishlist observer processAddToCart */ diff --git a/app/code/Magento/Checkout/Controller/Cart/Addgroup.php b/app/code/Magento/Checkout/Controller/Cart/Addgroup.php index 3ee2d8c653078e84c9dd5b5beae9c844ccf4bb11..f3f8a349b6a80948ca037c6387c91c10aec3bf71 100644 --- a/app/code/Magento/Checkout/Controller/Cart/Addgroup.php +++ b/app/code/Magento/Checkout/Controller/Cart/Addgroup.php @@ -36,7 +36,6 @@ class Addgroup extends \Magento\Checkout\Controller\Cart } } $this->cart->save(); - $this->_checkoutSession->setCartWasUpdated(true); } return $this->_goBack(); } diff --git a/app/code/Magento/Checkout/Controller/Cart/CouponPost.php b/app/code/Magento/Checkout/Controller/Cart/CouponPost.php index 92541c821e5162613938ceb03334e47cc89540fd..26225b39fa6f9732cb5562c4ffda4d28c0f7eacd 100644 --- a/app/code/Magento/Checkout/Controller/Cart/CouponPost.php +++ b/app/code/Magento/Checkout/Controller/Cart/CouponPost.php @@ -94,6 +94,7 @@ class CouponPost extends \Magento\Checkout\Controller\Cart $this->_objectManager->get('Magento\Framework\Escaper')->escapeHtml($couponCode) ) ); + $this->cart->save(); } } else { $this->messageManager->addSuccess(__('The coupon code was canceled.')); diff --git a/app/code/Magento/Checkout/Controller/Cart/EstimatePost.php b/app/code/Magento/Checkout/Controller/Cart/EstimatePost.php index 1a9f88450bf2ff1f047d518aaf80efa57513e9b5..88a1d46d971e69146a4b0f40ff2fb4fe19c3d9d3 100644 --- a/app/code/Magento/Checkout/Controller/Cart/EstimatePost.php +++ b/app/code/Magento/Checkout/Controller/Cart/EstimatePost.php @@ -68,6 +68,7 @@ class EstimatePost extends \Magento\Checkout\Controller\Cart ->setRegion($region) ->setCollectShippingRates(true); $this->quoteRepository->save($this->cart->getQuote()); + $this->cart->save(); return $this->_goBack(); } } diff --git a/app/code/Magento/Checkout/Controller/Cart/EstimateUpdatePost.php b/app/code/Magento/Checkout/Controller/Cart/EstimateUpdatePost.php index 4f873d1e10254ecbfeafbb8003dcf8f0438f2f2e..0dcd81a8e01856f4aa677f79362d4db96b732233 100644 --- a/app/code/Magento/Checkout/Controller/Cart/EstimateUpdatePost.php +++ b/app/code/Magento/Checkout/Controller/Cart/EstimateUpdatePost.php @@ -16,6 +16,7 @@ class EstimateUpdatePost extends \Magento\Checkout\Controller\Cart $code = (string)$this->getRequest()->getParam('estimate_method'); if (!empty($code)) { $this->cart->getQuote()->getShippingAddress()->setShippingMethod($code)->save(); + $this->cart->save(); } return $this->_goBack(); } diff --git a/app/code/Magento/Checkout/Controller/Cart/Index.php b/app/code/Magento/Checkout/Controller/Cart/Index.php index 46cd798d74e9d3d4a0e94692b6772c4f7e8056aa..8a29029fd18365c618a3c0f5fede9a0edfd7a0d1 100644 --- a/app/code/Magento/Checkout/Controller/Cart/Index.php +++ b/app/code/Magento/Checkout/Controller/Cart/Index.php @@ -5,8 +5,6 @@ * See COPYING.txt for license details. */ -// @codingStandardsIgnoreFile - namespace Magento\Checkout\Controller\Cart; class Index extends \Magento\Checkout\Controller\Cart @@ -55,63 +53,9 @@ class Index extends \Magento\Checkout\Controller\Cart */ public function execute() { - $this->_eventManager->dispatch('collect_totals_failed_items'); - if ($this->cart->getQuote()->getItemsCount()) { - $this->cart->init(); - $this->cart->save(); - - if (!$this->cart->getQuote()->validateMinimumAmount()) { - $currencyCode = $this->_objectManager->get('Magento\Store\Model\StoreManagerInterface') - ->getStore() - ->getCurrentCurrencyCode(); - $minimumAmount = $this->_objectManager->get('Magento\Framework\Locale\CurrencyInterface') - ->getCurrency($currencyCode) - ->toCurrency( - $this->_scopeConfig->getValue( - 'sales/minimum_order/amount', - \Magento\Store\Model\ScopeInterface::SCOPE_STORE - ) - ); - - $warning = $this->_scopeConfig->getValue( - 'sales/minimum_order/description', - \Magento\Store\Model\ScopeInterface::SCOPE_STORE - ) ? $this->_scopeConfig->getValue( - 'sales/minimum_order/description', - \Magento\Store\Model\ScopeInterface::SCOPE_STORE - ) : __( - 'Minimum order amount is %1', - $minimumAmount - ); - - $this->messageManager->addNotice($warning); - } - } - - // Compose array of messages to add - $messages = []; - /** @var \Magento\Framework\Message\MessageInterface $message */ - foreach ($this->cart->getQuote()->getMessages() as $message) { - if ($message) { - // Escape HTML entities in quote message to prevent XSS - $message->setText($this->_objectManager->get('Magento\Framework\Escaper')->escapeHtml($message->getText())); - $messages[] = $message; - } - } - $this->messageManager->addUniqueMessages($messages); - - /** - * if customer enteres shopping cart we should mark quote - * as modified bc he can has checkout page in another window. - */ - $this->_checkoutSession->setCartWasUpdated(true); - - \Magento\Framework\Profiler::start(__METHOD__ . 'cart_display'); - $resultPage = $this->resultPageFactory->create(); $resultPage->getLayout()->initMessages(); $resultPage->getConfig()->getTitle()->set(__('Shopping Cart')); - \Magento\Framework\Profiler::stop(__METHOD__ . 'cart_display'); return $resultPage; } } diff --git a/app/code/Magento/Checkout/Controller/Cart/UpdateItemOptions.php b/app/code/Magento/Checkout/Controller/Cart/UpdateItemOptions.php index 61be91b6a1e925178502254081decb8d0cc3112d..f15ccfdede8694ac96cdd2a991ce179e232474dd 100644 --- a/app/code/Magento/Checkout/Controller/Cart/UpdateItemOptions.php +++ b/app/code/Magento/Checkout/Controller/Cart/UpdateItemOptions.php @@ -36,15 +36,15 @@ class UpdateItemOptions extends \Magento\Checkout\Controller\Cart $quoteItem = $this->cart->getQuote()->getItemById($id); if (!$quoteItem) { - throw new \Magento\Framework\Exception\LocalizedException(__("We can't find the quote item.")); + throw new \Magento\Framework\Exception\LocalizedException(__('We can\'t find the quote item.')); } $item = $this->cart->updateItem($id, new \Magento\Framework\Object($params)); if (is_string($item)) { - throw new \Magento\Framework\Exception\LocalizedException($item); + throw new \Magento\Framework\Exception\LocalizedException(__($item)); } if ($item->getHasError()) { - throw new \Magento\Framework\Exception\LocalizedException($item->getMessage()); + throw new \Magento\Framework\Exception\LocalizedException(__($item->getMessage())); } $related = $this->getRequest()->getParam('related_product'); @@ -54,8 +54,6 @@ class UpdateItemOptions extends \Magento\Checkout\Controller\Cart $this->cart->save(); - $this->_checkoutSession->setCartWasUpdated(true); - $this->_eventManager->dispatch( 'checkout_cart_update_item_complete', ['item' => $item, 'request' => $this->getRequest(), 'response' => $this->getResponse()] diff --git a/app/code/Magento/Checkout/Controller/Cart/UpdatePost.php b/app/code/Magento/Checkout/Controller/Cart/UpdatePost.php index dc71ca01354e36206279c5a580c9a5f4be0b71c8..31d94cb623031c751834ec5e49b38259eaf820ed 100644 --- a/app/code/Magento/Checkout/Controller/Cart/UpdatePost.php +++ b/app/code/Magento/Checkout/Controller/Cart/UpdatePost.php @@ -20,7 +20,6 @@ class UpdatePost extends \Magento\Checkout\Controller\Cart { try { $this->cart->truncate()->save(); - $this->_checkoutSession->setCartWasUpdated(true); } catch (\Magento\Framework\Exception\LocalizedException $exception) { $this->messageManager->addError($exception->getMessage()); } catch (\Exception $exception) { @@ -53,7 +52,6 @@ class UpdatePost extends \Magento\Checkout\Controller\Cart $cartData = $this->cart->suggestItemsQty($cartData); $this->cart->updateItems($cartData)->save(); } - $this->_checkoutSession->setCartWasUpdated(true); } catch (\Magento\Framework\Exception\LocalizedException $e) { $this->messageManager->addError( $this->_objectManager->get('Magento\Framework\Escaper')->escapeHtml($e->getMessage()) diff --git a/app/code/Magento/Checkout/Controller/Onepage.php b/app/code/Magento/Checkout/Controller/Onepage.php index 83da6a58c07353ae9cbedbf035bad67bd67b25a2..3a47eca2e4f86807ed665c56deed717b2b89319a 100644 --- a/app/code/Magento/Checkout/Controller/Onepage.php +++ b/app/code/Magento/Checkout/Controller/Onepage.php @@ -77,7 +77,7 @@ class Onepage extends Action protected $resultRawFactory; /** - * @var \Magento\Framework\Controller\Result\JSONFactory + * @var \Magento\Framework\Controller\Result\JsonFactory */ protected $resultJsonFactory; @@ -96,7 +96,7 @@ class Onepage extends Action * @param \Magento\Framework\View\Result\PageFactory $resultPageFactory * @param \Magento\Framework\View\Result\LayoutFactory $resultLayoutFactory * @param \Magento\Framework\Controller\Result\RawFactory $resultRawFactory - * @param \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory + * @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory * * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ @@ -115,7 +115,7 @@ class Onepage extends Action \Magento\Framework\View\Result\PageFactory $resultPageFactory, \Magento\Framework\View\Result\LayoutFactory $resultLayoutFactory, \Magento\Framework\Controller\Result\RawFactory $resultRawFactory, - \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory + \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory ) { $this->_coreRegistry = $coreRegistry; $this->_translateInline = $translateInline; diff --git a/app/code/Magento/Checkout/Model/Cart.php b/app/code/Magento/Checkout/Model/Cart.php index b119b7744530a1f5f0bb15a38d6392d86e37c12f..69060c34e2058287cab7bbac92815ab7ff257d51 100644 --- a/app/code/Magento/Checkout/Model/Cart.php +++ b/app/code/Magento/Checkout/Model/Cart.php @@ -220,23 +220,19 @@ class Cart extends Object implements CartInterface } /** - * Initialize cart quote state to be able use it on cart page + * Reinitialize cart quote state * * @return $this */ - public function init() + protected function reinitializeState() { $quote = $this->getQuote()->setCheckoutMethod(''); - + $this->_checkoutSession->setCartWasUpdated(true); + // reset for multiple address checkout if ($this->_checkoutSession->getCheckoutState() !== Session::CHECKOUT_STATE_BEGIN) { $quote->removeAllAddresses()->removePayment(); $this->_checkoutSession->resetCheckout(); } - - if (!$quote->hasItems()) { - $quote->getShippingAddress()->setCollectShippingRates(false)->removeAllShippingRates(); - } - return $this; } @@ -290,7 +286,7 @@ class Cart extends Object implements CartInterface try { $product = $this->productRepository->getById($productInfo, false, $storeId); } catch (NoSuchEntityException $e) { - throw new \Magento\Framework\Exception\LocalizedException(__('We can\'t find the product.'), [], $e); + throw new \Magento\Framework\Exception\LocalizedException(__('We can\'t find the product.'), $e); } } else { throw new \Magento\Framework\Exception\LocalizedException(__('We can\'t find the product.')); @@ -376,7 +372,7 @@ class Cart extends Object implements CartInterface if ($this->_checkoutSession->getUseNotice() === null) { $this->_checkoutSession->setUseNotice(true); } - throw new \Magento\Framework\Exception\LocalizedException($result); + throw new \Magento\Framework\Exception\LocalizedException(__($result)); } } else { throw new \Magento\Framework\Exception\LocalizedException(__('The product does not exist.')); @@ -506,7 +502,7 @@ class Cart extends Object implements CartInterface $itemInQuote = $this->getQuote()->getItemById($item->getId()); if (!$itemInQuote && $item->getHasError()) { - throw new \Magento\Framework\Exception\LocalizedException($item->getMessage()); + throw new \Magento\Framework\Exception\LocalizedException(__($item->getMessage())); } if (isset($itemInfo['before_suggest_qty']) && $itemInfo['before_suggest_qty'] != $qty) { @@ -562,6 +558,7 @@ class Cart extends Object implements CartInterface * Cart save usually called after changes with cart items. */ $this->_eventManager->dispatch('checkout_cart_save_after', ['cart' => $this]); + $this->reinitializeState(); return $this; } @@ -701,7 +698,7 @@ class Cart extends Object implements CartInterface if ($this->_checkoutSession->getUseNotice() === null) { $this->_checkoutSession->setUseNotice(true); } - throw new \Magento\Framework\Exception\LocalizedException($result); + throw new \Magento\Framework\Exception\LocalizedException(__($result)); } $this->_eventManager->dispatch( diff --git a/app/code/Magento/Checkout/Test/Unit/Controller/Cart/IndexTest.php b/app/code/Magento/Checkout/Test/Unit/Controller/Cart/IndexTest.php new file mode 100644 index 0000000000000000000000000000000000000000..43b5fb8657ded5fc413dc2aaa4f5a627d5af6183 --- /dev/null +++ b/app/code/Magento/Checkout/Test/Unit/Controller/Cart/IndexTest.php @@ -0,0 +1,170 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Checkout\Test\Unit\Controller\Cart; + +use Magento\Checkout\Controller\Cart\Index; + +/** + * Class IndexTest + */ +class IndexTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var Index + */ + protected $controller; + + /** + * @var \Magento\Checkout\Model\Session | \PHPUnit_Framework_MockObject_MockObject + */ + protected $checkoutSession; + + /** + * @var \Magento\Framework\App\Request\Http | \PHPUnit_Framework_MockObject_MockObject + */ + protected $request; + + /** + * @var \Magento\Framework\App\Response\Http | \PHPUnit_Framework_MockObject_MockObject + */ + protected $response; + + /** + * @var \Magento\Quote\Model\Quote | \PHPUnit_Framework_MockObject_MockObject + */ + protected $quote; + + /** + * @var \Magento\Framework\Event\Manager | \PHPUnit_Framework_MockObject_MockObject + */ + protected $eventManager; + + /** + * @var \Magento\Framework\Event\Manager | \PHPUnit_Framework_MockObject_MockObject + */ + protected $objectManagerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $cart; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $scopeConfig; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $messageManager; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $resultPageFactory; + + /** + * @return void + */ + public function setUp() + { + $this->request = $this->getMock('Magento\Framework\App\Request\Http', [], [], '', false); + $this->response = $this->getMock('Magento\Framework\App\Response\Http', [], [], '', false); + $this->quote = $this->getMock('Magento\Quote\Model\Quote', [], [], '', false); + $this->eventManager = $this->getMock('Magento\Framework\Event\Manager', [], [], '', false); + $this->checkoutSession = $this->getMock('Magento\Checkout\Model\Session', [], [], '', false); + + $this->objectManagerMock = $this->getMock('Magento\Framework\ObjectManager\ObjectManager', [], [], '', false); + + $this->messageManager = $this->getMockBuilder('Magento\Framework\Message\ManagerInterface') + ->disableOriginalConstructor() + ->getMock(); + + $context = $this->getMock('Magento\Framework\App\Action\Context', [], [], '', false); + $context->expects($this->once()) + ->method('getObjectManager') + ->willReturn($this->objectManagerMock); + $context->expects($this->once()) + ->method('getRequest') + ->willReturn($this->request); + $context->expects($this->once()) + ->method('getResponse') + ->willReturn($this->response); + $context->expects($this->once()) + ->method('getEventManager') + ->willReturn($this->eventManager); + $context->expects($this->once()) + ->method('getMessageManager') + ->willReturn($this->messageManager); + + $this->cart = $this->getMockBuilder('Magento\Checkout\Model\Cart') + ->disableOriginalConstructor() + ->getMock(); + $this->scopeConfig = $this->getMockBuilder('Magento\Framework\App\Config\ScopeConfigInterface') + ->disableOriginalConstructor() + ->getMock(); + $this->resultPageFactory = $this->getMockBuilder('Magento\Framework\View\Result\PageFactory') + ->disableOriginalConstructor() + ->setMethods(['create']) + ->getMock(); + + $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); + + $this->controller = $objectManagerHelper->getObject( + 'Magento\Checkout\Controller\Cart\Index', + [ + 'context' => $context, + 'checkoutSession' => $this->checkoutSession, + 'cart' => $this->cart, + 'scopeConfig' => $this->scopeConfig, + 'resultPageFactory' => $this->resultPageFactory + ] + ); + } + + /** + * @return void + */ + public function testExecuteWithMessages() + { + $layout = $this->getMockBuilder('Magento\Framework\View\Layout') + ->disableOriginalConstructor() + ->getMock(); + $layout->expects($this->once()) + ->method('initMessages'); + + $title = $this->getMockBuilder('Magento\Framework\View\Page\Title') + ->disableOriginalConstructor() + ->getMock(); + $title->expects($this->once()) + ->method('set') + ->with('Shopping Cart'); + + $config = $this->getMockBuilder('Magento\Framework\View\Page\Config') + ->disableOriginalConstructor() + ->getMock(); + $config->expects($this->once()) + ->method('getTitle') + ->willReturn($title); + + $page = $this->getMockBuilder('Magento\Framework\View\Result\Page') + ->disableOriginalConstructor() + ->getMock(); + $page->expects($this->once()) + ->method('getLayout') + ->willReturn($layout); + $page->expects($this->once()) + ->method('getConfig') + ->willReturn($config); + + $this->resultPageFactory->expects($this->once()) + ->method('create') + ->willReturn($page); + $result = $this->controller->execute(); + $this->assertInstanceOf('Magento\Framework\View\Result\Page', $result); + } +} diff --git a/app/code/Magento/Checkout/Test/Unit/Controller/Onepage/SaveBillingTest.php b/app/code/Magento/Checkout/Test/Unit/Controller/Onepage/SaveBillingTest.php old mode 100644 new mode 100755 index d9cb30e55e34905336d7155b3bd75d23a40c30f5..f1a5b1c882dac2aee11c342f53ed2424c5ec0b9a --- a/app/code/Magento/Checkout/Test/Unit/Controller/Onepage/SaveBillingTest.php +++ b/app/code/Magento/Checkout/Test/Unit/Controller/Onepage/SaveBillingTest.php @@ -79,6 +79,11 @@ class SaveBillingTest extends \PHPUnit_Framework_TestCase */ protected $resultJson; + /** + * SetUp method + * + * @return void + */ protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); @@ -142,10 +147,11 @@ class SaveBillingTest extends \PHPUnit_Framework_TestCase ->method('create') ->willReturn($this->resultRaw); - $this->resultJson = $this->getMockBuilder('Magento\Framework\Controller\Result\JSON') + $this->resultJson = $this->getMockBuilder('Magento\Framework\Controller\Result\Json') ->disableOriginalConstructor() + ->setMethods(['setData']) ->getMock(); - $resultJsonFactory = $this->getMockBuilder('Magento\Framework\Controller\Result\JSONFactory') + $resultJsonFactory = $this->getMockBuilder('Magento\Framework\Controller\Result\JsonFactory') ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); @@ -165,6 +171,11 @@ class SaveBillingTest extends \PHPUnit_Framework_TestCase ); } + /** + * Test execute + * + * @return void + */ public function testExecute() { $this->request->expects($this->once()) @@ -181,6 +192,11 @@ class SaveBillingTest extends \PHPUnit_Framework_TestCase $this->assertSame($this->resultRaw, $this->controller->execute()); } + /** + * Test validate minimum amount + * + * @return void + */ public function testValidateMinimumAmount() { $expectedResult = [ @@ -253,6 +269,11 @@ class SaveBillingTest extends \PHPUnit_Framework_TestCase $this->assertSame($this->resultJson, $this->controller->execute()); } + /** + * Test validate minimum amount negative + * + * @return void + */ public function testValidateMinimumAmountNegative() { $errorMessage = 'error_message'; diff --git a/app/code/Magento/Checkout/Test/Unit/Controller/Onepage/SaveShippingTest.php b/app/code/Magento/Checkout/Test/Unit/Controller/Onepage/SaveShippingTest.php index e2cd55295d11e9c12cfd1eda8c20fe1501920319..480e9fe957d808908c970bbca413aec2cf515c06 100644 --- a/app/code/Magento/Checkout/Test/Unit/Controller/Onepage/SaveShippingTest.php +++ b/app/code/Magento/Checkout/Test/Unit/Controller/Onepage/SaveShippingTest.php @@ -144,6 +144,7 @@ class SaveShippingTest extends \PHPUnit_Framework_TestCase $this->resultJson = $this->getMockBuilder('Magento\Framework\Controller\Result\Json') ->disableOriginalConstructor() + ->setMethods(['setData']) ->getMock(); $resultJsonFactory = $this->getMockBuilder('Magento\Framework\Controller\Result\JsonFactory') ->disableOriginalConstructor() diff --git a/app/code/Magento/Checkout/composer.json b/app/code/Magento/Checkout/composer.json index 6a4b0255686f84d78b71a80df174311f155b9999..ed8f574a7005d5cf7aa498cff6670c9cf6027f40 100644 --- a/app/code/Magento/Checkout/composer.json +++ b/app/code/Magento/Checkout/composer.json @@ -6,7 +6,7 @@ "magento/module-store": "0.42.0-beta11", "magento/module-sales": "0.42.0-beta11", "magento/module-catalog-inventory": "0.42.0-beta11", - "magento/module-core": "0.42.0-beta11", + "magento/module-config": "0.42.0-beta11", "magento/module-customer": "0.42.0-beta11", "magento/module-catalog": "0.42.0-beta11", "magento/module-payment": "0.42.0-beta11", diff --git a/app/code/Magento/Checkout/etc/config.xml b/app/code/Magento/Checkout/etc/config.xml index 5d709676cb3b6ceedd9b7d25109914f1900a0a8f..31f59f6d891c5af880e55ec5d2dda30c5d26ab28 100644 --- a/app/code/Magento/Checkout/etc/config.xml +++ b/app/code/Magento/Checkout/etc/config.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Core/etc/config.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Store/etc/config.xsd"> <default> <checkout> <options> diff --git a/app/code/Magento/Checkout/etc/frontend/page_types.xml b/app/code/Magento/Checkout/etc/frontend/page_types.xml index 10c6563f3e27306d7d44cd691fe0c359c35e7bc3..dc770ab1d1bb794e1de7d404ce9ea6a132badb4f 100644 --- a/app/code/Magento/Checkout/etc/frontend/page_types.xml +++ b/app/code/Magento/Checkout/etc/frontend/page_types.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> -<page_types xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../Core/etc/page_types.xsd"> +<page_types xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_types.xsd"> <type id="checkout_cart_configure" label="Configure Cart Item (Any)"/> <type id="checkout_cart_index" label="Shopping Cart"/> <type id="checkout_onepage_failure" label="One Page Checkout Failure"/> diff --git a/app/code/Magento/Checkout/view/frontend/layout/checkout_cart_index.xml b/app/code/Magento/Checkout/view/frontend/layout/checkout_cart_index.xml index b794a949e28849ff8795677e6458ea29a2ca00dd..9b690c5b43fbd0ccee106decb8ea17b9a2d8dca5 100644 --- a/app/code/Magento/Checkout/view/frontend/layout/checkout_cart_index.xml +++ b/app/code/Magento/Checkout/view/frontend/layout/checkout_cart_index.xml @@ -9,6 +9,9 @@ <update handle="checkout_cart_item_renderers"/> <update handle="checkout_shipping_price_renderer"/> <body> + <referenceContainer name="page.messages"> + <block class="Magento\Checkout\Block\Cart\ValidationMessages" name="checkout.cart.validationmessages"/> + </referenceContainer> <referenceContainer name="content"> <block class="Magento\Checkout\Block\Cart" name="checkout.cart" template="cart.phtml"> <container name="checkout.cart.items" as="with-items"> @@ -35,7 +38,7 @@ </block> </container> <container name="checkout.cart.noitems" as="no-items"> - <block class="Magento\Checkout\Block\Cart" name="checkout.cart.empty" before="-" template="cart/noItems.phtml"/> + <block class="Magento\Checkout\Block\Cart\EmptyCart" name="checkout.cart.empty" before="-" template="cart/noItems.phtml"/> <container name="checkout.cart.empty.widget" as="checkout_cart_empty_widget" label="Empty Shopping Cart Content Before"/> </container> </block> diff --git a/app/code/Magento/Checkout/view/frontend/templates/cart/noItems.phtml b/app/code/Magento/Checkout/view/frontend/templates/cart/noItems.phtml index 9fe14c75f86a8eda4d403233b02c2f8c9f5cee93..b3e8bcd4d6792b189fd0df5bb7b00ad97babacc6 100644 --- a/app/code/Magento/Checkout/view/frontend/templates/cart/noItems.phtml +++ b/app/code/Magento/Checkout/view/frontend/templates/cart/noItems.phtml @@ -4,7 +4,7 @@ * See COPYING.txt for license details. */ -/** @var $block \Magento\Checkout\Block\Cart */ +/** @var $block \Magento\Checkout\Block\Cart\EmptyCart */ ?> <div class="cart-empty"> <?php echo $block->getChildHtml('checkout_cart_empty_widget'); ?> diff --git a/app/code/Magento/Checkout/view/frontend/templates/cart/shipping.phtml b/app/code/Magento/Checkout/view/frontend/templates/cart/shipping.phtml index b2f1360d69d4f01e6f8eb88da2622fc166f52bec..7585ca9388f9034e59d9b0a3e3d17434acbb258a 100644 --- a/app/code/Magento/Checkout/view/frontend/templates/cart/shipping.phtml +++ b/app/code/Magento/Checkout/view/frontend/templates/cart/shipping.phtml @@ -77,7 +77,7 @@ } </script> <?php if (($_shippingRateGroups = $block->getEstimateRates())): ?> - <form id="co-shipping-method-form" action="<?php echo $block->getUrl('checkout/cart/estimateUpdatePost') ?>"> + <form id="co-shipping-method-form" action="<?php echo $block->getUrl('checkout/cart/estimateUpdatePost') ?>" method="post"> <fieldset class="fieldset rates"> <dl class="items methods"> <?php foreach ($_shippingRateGroups as $code => $_rates): ?> diff --git a/app/code/Magento/Checkout/view/frontend/web/js/opc-checkout-method.js b/app/code/Magento/Checkout/view/frontend/web/js/opc-checkout-method.js index 21b896ecf549ab69eebdc51606ab470afdfa7aa1..bdc635d337b1bd760aa82fa043ec8074b25236e1 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/opc-checkout-method.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/opc-checkout-method.js @@ -234,11 +234,9 @@ define([ if (msg) { if (Array.isArray(msg)) { msg = msg.reduce(function (str, chunk) { - str += '\n' + $.mage.__(chunk); + str += '\n' + chunk; return str; }, ''); - } else { - msg = $.mage.__(msg); } $(this.options.countrySelector).trigger('change'); diff --git a/app/code/Magento/Checkout/view/frontend/web/js/opcheckout.js b/app/code/Magento/Checkout/view/frontend/web/js/opcheckout.js index d8ccb7eecc89cffc5a06899d03e43795c139740d..ac833eb7df2a1ab41c4cf827fa36ccc6b4458de8 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/opcheckout.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/opcheckout.js @@ -198,9 +198,9 @@ define([ $(this.options.countrySelector).trigger('change'); - alert($.mage.__(msg)); + alert(msg); } else { - alert($.mage.__(response.error)); + alert(response.error); } return; diff --git a/app/code/Magento/CheckoutAgreements/Model/Agreement.php b/app/code/Magento/CheckoutAgreements/Model/Agreement.php index ceca39fa477ea584e4a8531fd08c7a6baab76dc2..6f951c12d5b629bc304cb0d80933030654598d1b 100644 --- a/app/code/Magento/CheckoutAgreements/Model/Agreement.php +++ b/app/code/Magento/CheckoutAgreements/Model/Agreement.php @@ -6,9 +6,9 @@ namespace Magento\CheckoutAgreements\Model; use Magento\CheckoutAgreements\Api\Data\AgreementInterface; -use Magento\Framework\Model\AbstractExtensibleModel; +use Magento\Framework\Model\AbstractModel; -class Agreement extends AbstractExtensibleModel implements AgreementInterface +class Agreement extends AbstractModel implements AgreementInterface { /** * Allowed CSS units for height field diff --git a/app/code/Magento/CheckoutAgreements/etc/module.xml b/app/code/Magento/CheckoutAgreements/etc/module.xml index 36bad32ebf304277292947dd3b01f54704cc0b7b..249c7b190e363da6ada252358dc4e4f8f4ca3c29 100644 --- a/app/code/Magento/CheckoutAgreements/etc/module.xml +++ b/app/code/Magento/CheckoutAgreements/etc/module.xml @@ -8,7 +8,6 @@ <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd"> <module name="Magento_CheckoutAgreements" setup_version="2.0.0"> <sequence> - <module name="Magento_Core"/> <module name="Magento_Store"/> </sequence> </module> diff --git a/app/code/Magento/Cms/Controller/Adminhtml/Wysiwyg/Images/Contents.php b/app/code/Magento/Cms/Controller/Adminhtml/Wysiwyg/Images/Contents.php index 5306fdb26fd41f4b771b98b6f7b1013909dc0e15..0b1155258377a7144234d4bf6333bc842d489cd5 100755 --- a/app/code/Magento/Cms/Controller/Adminhtml/Wysiwyg/Images/Contents.php +++ b/app/code/Magento/Cms/Controller/Adminhtml/Wysiwyg/Images/Contents.php @@ -14,7 +14,7 @@ class Contents extends \Magento\Cms\Controller\Adminhtml\Wysiwyg\Images protected $resultLayoutFactory; /** - * @var \Magento\Framework\Controller\Result\JSONFactory + * @var \Magento\Framework\Controller\Result\JsonFactory */ protected $resultJsonFactory; @@ -22,13 +22,13 @@ class Contents extends \Magento\Cms\Controller\Adminhtml\Wysiwyg\Images * @param \Magento\Backend\App\Action\Context $context * @param \Magento\Framework\Registry $coreRegistry * @param \Magento\Framework\View\Result\LayoutFactory $resultLayoutFactory - * @param \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory + * @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory */ public function __construct( \Magento\Backend\App\Action\Context $context, \Magento\Framework\Registry $coreRegistry, \Magento\Framework\View\Result\LayoutFactory $resultLayoutFactory, - \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory + \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory ) { $this->resultLayoutFactory = $resultLayoutFactory; $this->resultJsonFactory = $resultJsonFactory; @@ -62,7 +62,7 @@ class Contents extends \Magento\Cms\Controller\Adminhtml\Wysiwyg\Images return $resultLayout; } catch (\Exception $e) { $result = ['error' => true, 'message' => $e->getMessage()]; - /** @var \Magento\Framework\Controller\Result\JSON $resultJson */ + /** @var \Magento\Framework\Controller\Result\Json $resultJson */ $resultJson = $this->resultJsonFactory->create(); $resultJson->setData($result); return $resultJson; diff --git a/app/code/Magento/Cms/Controller/Adminhtml/Wysiwyg/Images/DeleteFiles.php b/app/code/Magento/Cms/Controller/Adminhtml/Wysiwyg/Images/DeleteFiles.php index c415e2331c36c68641046758bee3c390b6ac0db2..73389122633f1ccb2dca17a283aadc247aa87a8d 100755 --- a/app/code/Magento/Cms/Controller/Adminhtml/Wysiwyg/Images/DeleteFiles.php +++ b/app/code/Magento/Cms/Controller/Adminhtml/Wysiwyg/Images/DeleteFiles.php @@ -11,7 +11,7 @@ use Magento\Framework\App\Filesystem\DirectoryList; class DeleteFiles extends \Magento\Cms\Controller\Adminhtml\Wysiwyg\Images { /** - * @var \Magento\Framework\Controller\Result\JSONFactory + * @var \Magento\Framework\Controller\Result\JsonFactory */ protected $resultJsonFactory; @@ -23,13 +23,13 @@ class DeleteFiles extends \Magento\Cms\Controller\Adminhtml\Wysiwyg\Images /** * @param \Magento\Backend\App\Action\Context $context * @param \Magento\Framework\Registry $coreRegistry - * @param \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory + * @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory * @param \Magento\Framework\Controller\Result\RawFactory $resultRawFactory */ public function __construct( \Magento\Backend\App\Action\Context $context, \Magento\Framework\Registry $coreRegistry, - \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory, + \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory, \Magento\Framework\Controller\Result\RawFactory $resultRawFactory ) { $this->resultRawFactory = $resultRawFactory; @@ -67,7 +67,7 @@ class DeleteFiles extends \Magento\Cms\Controller\Adminhtml\Wysiwyg\Images return $this->resultRawFactory->create(); } catch (\Exception $e) { $result = ['error' => true, 'message' => $e->getMessage()]; - /** @var \Magento\Framework\Controller\Result\JSON $resultJson */ + /** @var \Magento\Framework\Controller\Result\Json $resultJson */ $resultJson = $this->resultJsonFactory->create(); return $resultJson->setData($result); } diff --git a/app/code/Magento/Cms/Controller/Adminhtml/Wysiwyg/Images/DeleteFolder.php b/app/code/Magento/Cms/Controller/Adminhtml/Wysiwyg/Images/DeleteFolder.php index a9fde1794b9da9fac7365961c40ba097e3750b89..2566d3159e47103ffc2dbcc22420a9bd904241fa 100755 --- a/app/code/Magento/Cms/Controller/Adminhtml/Wysiwyg/Images/DeleteFolder.php +++ b/app/code/Magento/Cms/Controller/Adminhtml/Wysiwyg/Images/DeleteFolder.php @@ -9,7 +9,7 @@ namespace Magento\Cms\Controller\Adminhtml\Wysiwyg\Images; class DeleteFolder extends \Magento\Cms\Controller\Adminhtml\Wysiwyg\Images { /** - * @var \Magento\Framework\Controller\Result\JSONFactory + * @var \Magento\Framework\Controller\Result\JsonFactory */ protected $resultJsonFactory; @@ -21,13 +21,13 @@ class DeleteFolder extends \Magento\Cms\Controller\Adminhtml\Wysiwyg\Images /** * @param \Magento\Backend\App\Action\Context $context * @param \Magento\Framework\Registry $coreRegistry - * @param \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory + * @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory * @param \Magento\Framework\Controller\Result\RawFactory $resultRawFactory */ public function __construct( \Magento\Backend\App\Action\Context $context, \Magento\Framework\Registry $coreRegistry, - \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory, + \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory, \Magento\Framework\Controller\Result\RawFactory $resultRawFactory ) { $this->resultRawFactory = $resultRawFactory; @@ -48,7 +48,7 @@ class DeleteFolder extends \Magento\Cms\Controller\Adminhtml\Wysiwyg\Images return $this->resultRawFactory->create(); } catch (\Exception $e) { $result = ['error' => true, 'message' => $e->getMessage()]; - /** @var \Magento\Framework\Controller\Result\JSON $resultJson */ + /** @var \Magento\Framework\Controller\Result\Json $resultJson */ $resultJson = $this->resultJsonFactory->create(); return $resultJson->setData($result); } diff --git a/app/code/Magento/Cms/Controller/Adminhtml/Wysiwyg/Images/NewFolder.php b/app/code/Magento/Cms/Controller/Adminhtml/Wysiwyg/Images/NewFolder.php index c270e3463f9189d5d0cd1f9eae97d001fb900ae3..24240b5ab25e7ce921706eb32a34b3688c1318da 100755 --- a/app/code/Magento/Cms/Controller/Adminhtml/Wysiwyg/Images/NewFolder.php +++ b/app/code/Magento/Cms/Controller/Adminhtml/Wysiwyg/Images/NewFolder.php @@ -9,19 +9,19 @@ namespace Magento\Cms\Controller\Adminhtml\Wysiwyg\Images; class NewFolder extends \Magento\Cms\Controller\Adminhtml\Wysiwyg\Images { /** - * @var \Magento\Framework\Controller\Result\JSONFactory + * @var \Magento\Framework\Controller\Result\JsonFactory */ protected $resultJsonFactory; /** * @param \Magento\Backend\App\Action\Context $context * @param \Magento\Framework\Registry $coreRegistry - * @param \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory + * @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory */ public function __construct( \Magento\Backend\App\Action\Context $context, \Magento\Framework\Registry $coreRegistry, - \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory + \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory ) { $this->resultJsonFactory = $resultJsonFactory; parent::__construct($context, $coreRegistry); @@ -42,7 +42,7 @@ class NewFolder extends \Magento\Cms\Controller\Adminhtml\Wysiwyg\Images } catch (\Exception $e) { $result = ['error' => true, 'message' => $e->getMessage()]; } - /** @var \Magento\Framework\Controller\Result\JSON $resultJson */ + /** @var \Magento\Framework\Controller\Result\Json $resultJson */ $resultJson = $this->resultJsonFactory->create(); return $resultJson->setData($result); } diff --git a/app/code/Magento/Cms/Controller/Adminhtml/Wysiwyg/Images/TreeJson.php b/app/code/Magento/Cms/Controller/Adminhtml/Wysiwyg/Images/TreeJson.php index 00950a5390e6b3d61f2c38f43131b99d40ff6b5a..9d70dd5a038de40c035962a5230ff3ad9d6789d6 100755 --- a/app/code/Magento/Cms/Controller/Adminhtml/Wysiwyg/Images/TreeJson.php +++ b/app/code/Magento/Cms/Controller/Adminhtml/Wysiwyg/Images/TreeJson.php @@ -9,7 +9,7 @@ namespace Magento\Cms\Controller\Adminhtml\Wysiwyg\Images; class TreeJson extends \Magento\Cms\Controller\Adminhtml\Wysiwyg\Images { /** - * @var \Magento\Framework\Controller\Result\JSONFactory + * @var \Magento\Framework\Controller\Result\JsonFactory */ protected $resultJsonFactory; @@ -21,13 +21,13 @@ class TreeJson extends \Magento\Cms\Controller\Adminhtml\Wysiwyg\Images /** * @param \Magento\Backend\App\Action\Context $context * @param \Magento\Framework\Registry $coreRegistry - * @param \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory + * @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory * @param \Magento\Framework\View\LayoutFactory $layoutFactory */ public function __construct( \Magento\Backend\App\Action\Context $context, \Magento\Framework\Registry $coreRegistry, - \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory, + \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory, \Magento\Framework\View\LayoutFactory $layoutFactory ) { $this->layoutFactory = $layoutFactory; @@ -42,7 +42,7 @@ class TreeJson extends \Magento\Cms\Controller\Adminhtml\Wysiwyg\Images */ public function execute() { - /** @var \Magento\Framework\Controller\Result\JSON $resultJson */ + /** @var \Magento\Framework\Controller\Result\Json $resultJson */ $resultJson = $this->resultJsonFactory->create(); try { $this->_initAction(); diff --git a/app/code/Magento/Cms/Controller/Adminhtml/Wysiwyg/Images/Upload.php b/app/code/Magento/Cms/Controller/Adminhtml/Wysiwyg/Images/Upload.php index 61b1c8f631b49b27a981880e13e0e1fb6fd4370e..b05ff1ac92bd142d687d9647d0aa666be4e62fc4 100755 --- a/app/code/Magento/Cms/Controller/Adminhtml/Wysiwyg/Images/Upload.php +++ b/app/code/Magento/Cms/Controller/Adminhtml/Wysiwyg/Images/Upload.php @@ -9,19 +9,19 @@ namespace Magento\Cms\Controller\Adminhtml\Wysiwyg\Images; class Upload extends \Magento\Cms\Controller\Adminhtml\Wysiwyg\Images { /** - * @var \Magento\Framework\Controller\Result\JSONFactory + * @var \Magento\Framework\Controller\Result\JsonFactory */ protected $resultJsonFactory; /** * @param \Magento\Backend\App\Action\Context $context * @param \Magento\Framework\Registry $coreRegistry - * @param \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory + * @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory */ public function __construct( \Magento\Backend\App\Action\Context $context, \Magento\Framework\Registry $coreRegistry, - \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory + \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory ) { $this->resultJsonFactory = $resultJsonFactory; parent::__construct($context, $coreRegistry); @@ -41,7 +41,7 @@ class Upload extends \Magento\Cms\Controller\Adminhtml\Wysiwyg\Images } catch (\Exception $e) { $result = ['error' => $e->getMessage(), 'errorcode' => $e->getCode()]; } - /** @var \Magento\Framework\Controller\Result\JSON $resultJson */ + /** @var \Magento\Framework\Controller\Result\Json $resultJson */ $resultJson = $this->resultJsonFactory->create(); return $resultJson->setData($result); } diff --git a/app/code/Magento/Cms/Model/BlockRepository.php b/app/code/Magento/Cms/Model/BlockRepository.php index 5b1607cc23cd59492dbced7a224ae9f2292d60fd..520add71eb28b864280d9cc2979859400fb04c6f 100644 --- a/app/code/Magento/Cms/Model/BlockRepository.php +++ b/app/code/Magento/Cms/Model/BlockRepository.php @@ -73,7 +73,7 @@ class BlockRepository try { $this->resource->save($block); } catch (\Exception $exception) { - throw new CouldNotSaveException($exception->getMessage()); + throw new CouldNotSaveException(__($exception->getMessage())); } return $block; } @@ -90,7 +90,7 @@ class BlockRepository $block = $this->blockFactory->create(); $this->resource->load($block, $blockId); if (!$block->getId()) { - throw new NoSuchEntityException(sprintf('CMS Block with id "%s" does not exist.', $blockId)); + throw new NoSuchEntityException(__('CMS Block with id "%1" does not exist.', $blockId)); } return $block; } @@ -123,7 +123,7 @@ class BlockRepository try { $this->resource->delete($block); } catch (\Exception $exception) { - throw new CouldNotDeleteException($exception->getMessage()); + throw new CouldNotDeleteException(__($exception->getMessage())); } return true; } diff --git a/app/code/Magento/Cms/Model/PageRepository.php b/app/code/Magento/Cms/Model/PageRepository.php index 2faccd03d4a3e52b456f8255f07ae86bcde747e0..67815ec24adb01de14531640a2cdbeec49f2a471 100644 --- a/app/code/Magento/Cms/Model/PageRepository.php +++ b/app/code/Magento/Cms/Model/PageRepository.php @@ -72,7 +72,7 @@ class PageRepository try { $this->resource->save($page); } catch (\Exception $exception) { - throw new CouldNotSaveException($exception->getMessage()); + throw new CouldNotSaveException(__($exception->getMessage())); } return $page; } @@ -89,7 +89,7 @@ class PageRepository $page = $this->pageFactory->create(); $this->resource->load($page, $pageId); if (!$page->getId()) { - throw new NoSuchEntityException(sprintf('CMS Page with id "%s" does not exist.', $pageId)); + throw new NoSuchEntityException(__('CMS Page with id "%1" does not exist.', $pageId)); } return $page; } @@ -122,7 +122,7 @@ class PageRepository try { $this->resource->delete($page); } catch (\Exception $exception) { - throw new CouldNotDeleteException($exception->getMessage()); + throw new CouldNotDeleteException(__($exception->getMessage())); } return true; } diff --git a/app/code/Magento/Cms/Model/Resource/Page.php b/app/code/Magento/Cms/Model/Resource/Page.php index 8d080ae79d40927e232f61d55d39bd8de8387de6..fea879a1ca63397557bfc749d2dafaf9fd8ee5e6 100644 --- a/app/code/Magento/Cms/Model/Resource/Page.php +++ b/app/code/Magento/Cms/Model/Resource/Page.php @@ -105,11 +105,15 @@ class Page extends \Magento\Framework\Model\Resource\Db\AbstractDb } if (!$this->isValidPageIdentifier($object)) { - throw new \Magento\Framework\Exception\LocalizedException(__('The page URL key contains capital letters or disallowed symbols.')); + throw new \Magento\Framework\Exception\LocalizedException( + __('The page URL key contains capital letters or disallowed symbols.') + ); } if ($this->isNumericPageIdentifier($object)) { - throw new \Magento\Framework\Exception\LocalizedException(__('The page URL key cannot be made of only numbers.')); + throw new \Magento\Framework\Exception\LocalizedException( + __('The page URL key cannot be made of only numbers.') + ); } if ($object->isObjectNew() && !$object->hasCreationTime()) { diff --git a/app/code/Magento/Cms/Test/Unit/Block/Adminhtml/Block/Edit/FormTest.php b/app/code/Magento/Cms/Test/Unit/Block/Adminhtml/Block/Edit/FormTest.php new file mode 100755 index 0000000000000000000000000000000000000000..9fd408462cfc6a5918fa511605c160c3ad05c7fd --- /dev/null +++ b/app/code/Magento/Cms/Test/Unit/Block/Adminhtml/Block/Edit/FormTest.php @@ -0,0 +1,289 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Cms\Test\Unit\Block\Adminhtml\Block\Edit; + +/** + * @SuppressWarnings(PHPMD.TooManyFields) + */ +class FormTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $registry; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $systemStore; + + /** + * @var array + */ + protected $storeValues = [1, 2]; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $field; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $config; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $wysiwygConfig; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $store; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $storeManager; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $fieldSet; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $form; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $formFactory; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $eventManager; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $scopeConfig; + + /** + * @var string + */ + protected $action = 'test'; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $urlBuilder; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $appState; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $viewFileSystem; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $rootDirectory; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $logger; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $fileSystem; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $context; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $layout; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $model; + + /** + * @var \Magento\Cms\Block\Adminhtml\Block\Edit\Form + */ + protected $block; + + /** + * Sets up the fixture, for example, open a network connection. + * This method is called before a test is executed. + * + * @return void + */ + public function setUp() + { + $this->model = $this->getMock('Magento\Cms\Model\Block', ['getBlockId', 'setStoreId'], [], '', false); + + $this->registry = $this->getMock('Magento\Framework\Registry', [], [], '', false); + $this->registry->expects($this->once())->method('registry')->with('cms_block')->willReturn($this->model); + + $this->systemStore = $this->getMock('Magento\Store\Model\System\Store', [], [], '', false); + $this->systemStore->expects($this->any()) + ->method('getStoreValuesForForm') + ->with(false, true) + ->willReturn($this->storeValues); + + $this->field = $this->getMock('Magento\Framework\Data\Form\Element\AbstractElement', [], [], '', false); + $this->config = $this->getMock('Magento\Framework\Object', [], [], '', false); + $this->store = $this->getMock('Magento\Store\Model\Store', [], [], '', false); + $this->storeManager = $this->getMock('Magento\Store\Model\StoreManagerInterface', [], [], '', false); + $this->fieldSet = $this->getMock('Magento\Framework\Data\Form\Element\Fieldset', [], [], '', false); + $this->eventManager = $this->getMock('Magento\Framework\Event\ManagerInterface', [], [], '', false); + $this->scopeConfig = $this->getMock('Magento\Framework\App\Config\ScopeConfigInterface', [], [], '', false); + $this->urlBuilder = $this->getMock('Magento\Framework\UrlInterface', [], [], '', false); + $this->appState = $this->getMock('Magento\Framework\App\State', [], [], '', false); + $this->viewFileSystem = $this->getMock('Magento\Framework\View\FileSystem', [], [], '', false); + $this->logger = $this->getMock('Psr\Log\LoggerInterface', [], [], '', false); + $this->rootDirectory = $this->getMock( + 'Magento\Framework\Filesystem\Directory\ReadInterface', + [], + [], + '', + false + ); + $this->layout = $this->getMock('Magento\Framework\View\LayoutInterface', [], [], '', false); + + $this->fileSystem = $this->getMock('Magento\Framework\Filesystem', [], [], '', false); + $this->fileSystem->expects($this->atLeastOnce())->method('getDirectoryRead')->willReturn($this->rootDirectory); + + $this->wysiwygConfig = $this->getMock('Magento\Cms\Model\Wysiwyg\Config', [], [], '', false); + $this->wysiwygConfig->expects($this->once())->method('getConfig')->willReturn($this->config); + + $this->form = $this->getMock('Magento\Framework\Data\Form', [], [], '', false); + $this->form->expects($this->once())->method('addFieldset')->with( + 'base_fieldset', + ['legend' => __('General Information'), 'class' => 'fieldset-wide'] + )->willReturn($this->fieldSet); + + $this->formFactory = $this->getMock('\Magento\Framework\Data\FormFactory', [], [], '', false); + $this->formFactory->expects($this->once()) + ->method('create') + ->with(['data' => ['id' => 'edit_form', 'action' => $this->action, 'method' => 'post']]) + ->willReturn($this->form); + + $this->context = $this->getMock('Magento\Backend\Block\Template\Context', [], [], '', false); + $this->context->expects($this->once())->method('getEventManager')->willReturn($this->eventManager); + $this->context->expects($this->once())->method('getScopeConfig')->willReturn($this->scopeConfig); + $this->context->expects($this->once())->method('getStoreManager')->willReturn($this->storeManager); + $this->context->expects($this->once())->method('getUrlBuilder')->willReturn($this->urlBuilder); + $this->context->expects($this->once())->method('getAppState')->willReturn($this->appState); + $this->context->expects($this->once())->method('getViewFileSystem')->willReturn($this->viewFileSystem); + $this->context->expects($this->once())->method('getFilesystem')->willReturn($this->fileSystem); + $this->context->expects($this->once())->method('getLogger')->willReturn($this->logger); + $this->context->expects($this->once())->method('getLayout')->willReturn($this->layout); + + /** @var \Magento\Cms\Block\Adminhtml\Block\Edit\Form $block */ + $this->block = (new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this)) + ->getObject( + 'Magento\Cms\Block\Adminhtml\Block\Edit\Form', + [ + 'formFactory' => $this->formFactory, + 'registry' => $this->registry, + 'wysiwygConfig' => $this->wysiwygConfig, + 'context' => $this->context, + 'systemStore' => $this->systemStore + ] + ); + $this->block->setData('action', $this->action); + } + + /** + * Test prepare form model has no block id and single store mode is on + * + * @return void + */ + public function testPrepareFormModelHasNoBlockIdAndSingleStoreMode() + { + $blockId = null; + $storeId = 1; + + $this->model->expects($this->once())->method('getBlockId')->willReturn($blockId); + $this->model->expects($this->once())->method('setStoreId')->with($storeId); + + $this->store->expects($this->atLeastOnce())->method('getId')->willReturn($storeId); + + $this->storeManager->expects($this->once())->method('isSingleStoreMode')->willReturn(true); + $this->storeManager->expects($this->atLeastOnce())->method('getStore')->with(true)->willReturn($this->store); + + $this->fieldSet->expects($this->at(2)) + ->method('addField') + ->with( + 'store_id', + 'hidden', + ['name' => 'stores[]', 'value' => $storeId] + ) + ->willReturn($this->field); + + $this->block->toHtml(); + } + + /** + * Test prepare form model has block id and signle store mode is off + * + * @return void + */ + public function testPrepareFormModelHasBlockIdAndNonSingleStoreMode() + { + $blockId = 'id'; + + $renderer = $this->getMock( + 'Magento\Backend\Block\Store\Switcher\Form\Renderer\Fieldset\Element', + [], + [], + '', + false + ); + + $this->model->expects($this->once())->method('getBlockId')->willReturn($blockId); + + $this->layout->expects($this->once()) + ->method('createBlock') + ->with('Magento\Backend\Block\Store\Switcher\Form\Renderer\Fieldset\Element') + ->willReturn($renderer); + + $this->field->expects($this->once())->method('setRenderer')->with($renderer); + + $this->fieldSet->expects($this->at(0))->method('addField')->with('block_id', 'hidden', ['name' => 'block_id']); + $this->fieldSet->expects($this->at(3)) + ->method('addField') + ->with( + 'store_id', + 'multiselect', + [ + 'name' => 'stores[]', + 'label' => __('Store View'), + 'title' => __('Store View'), + 'required' => true, + 'values' => $this->storeValues + ] + )->willReturn($this->field); + + $this->block->toHtml(); + } +} diff --git a/app/code/Magento/Cms/Test/Unit/Block/Adminhtml/Block/EditTest.php b/app/code/Magento/Cms/Test/Unit/Block/Adminhtml/Block/EditTest.php index 421989782a9634fb21747e9d99828763185cfe98..3b0d1837ed3b1dd99d33f5dc0bfe2bb7a3121e4d 100644 --- a/app/code/Magento/Cms/Test/Unit/Block/Adminhtml/Block/EditTest.php +++ b/app/code/Magento/Cms/Test/Unit/Block/Adminhtml/Block/EditTest.php @@ -53,7 +53,7 @@ class EditTest extends \PHPUnit_Framework_TestCase 'Magento\Cms\Block\Adminhtml\Block\Edit', [ 'registry' => $this->registryMock, - 'escaper' => $this->escaperMock + 'escaper' => $this->escaperMock, ] ); } @@ -91,7 +91,7 @@ class EditTest extends \PHPUnit_Framework_TestCase { return [ 'modelBlockId NOT EMPTY' => ['modelBlockId' => 1], - 'modelBlockId IS EMPTY' => ['modelBlockId' => null] + 'modelBlockId IS EMPTY' => ['modelBlockId' => null], ]; } } diff --git a/app/code/Magento/Cms/Test/Unit/Controller/Index/IndexTest.php b/app/code/Magento/Cms/Test/Unit/Controller/Index/IndexTest.php new file mode 100644 index 0000000000000000000000000000000000000000..3b4ecc8ee107011d0271ede942c226a198e065b2 --- /dev/null +++ b/app/code/Magento/Cms/Test/Unit/Controller/Index/IndexTest.php @@ -0,0 +1,110 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Cms\Test\Unit\Controller\Index; + +class IndexTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Cms\Controller\Index\Index + */ + protected $controller; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $cmsHelperMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $requestMock; + + /** + * @var \Magento\Framework\Controller\Result\ForwardFactory|\PHPUnit_Framework_MockObject_MockObject + */ + protected $forwardFactoryMock; + + /** + * @var \Magento\Framework\Controller\Result\Forward|\PHPUnit_Framework_MockObject_MockObject + */ + protected $forwardMock; + + /** + * @var \Magento\Framework\View\Result\Page|\PHPUnit_Framework_MockObject_MockObject + */ + protected $resultPageMock; + + /** + * @var string + */ + protected $pageId = 'home'; + + protected function setUp() + { + $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); + $objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface'); + $responseMock = $this->getMock('Magento\Framework\App\Response\Http', [], [], '', false); + $this->resultPageMock = $this->getMockBuilder('\Magento\Framework\View\Result\Page') + ->disableOriginalConstructor() + ->getMock(); + $this->forwardFactoryMock = $this->getMockBuilder('\Magento\Framework\Controller\Result\ForwardFactory') + ->setMethods(['create']) + ->disableOriginalConstructor() + ->getMock(); + $this->forwardMock = $this->getMockBuilder('Magento\Framework\Controller\Result\Forward') + ->disableOriginalConstructor() + ->getMock(); + $this->forwardFactoryMock->expects($this->any()) + ->method('create') + ->willReturn($this->forwardMock); + + $scopeConfigMock = $this->getMock('Magento\Framework\App\Config\ScopeConfigInterface'); + $this->requestMock = $this->getMock('Magento\Framework\App\Request\Http', [], [], '', false); + $this->cmsHelperMock = $this->getMock('Magento\Cms\Helper\Page', [], [], '', false); + $valueMap = [ + [ + 'Magento\Framework\App\Config\ScopeConfigInterface', + $scopeConfigMock, + ], + ['Magento\Cms\Helper\Page', $this->cmsHelperMock], + ]; + $objectManagerMock->expects($this->any())->method('get')->willReturnMap($valueMap); + $scopeConfigMock->expects($this->once()) + ->method('getValue') + ->with( + \Magento\Cms\Helper\Page::XML_PATH_HOME_PAGE, + \Magento\Store\Model\ScopeInterface::SCOPE_STORE + ) + ->willReturn($this->pageId); + $this->controller = $helper->getObject( + 'Magento\Cms\Controller\Index\Index', + [ + 'response' => $responseMock, + 'objectManager' => $objectManagerMock, + 'request' => $this->requestMock, + 'resultForwardFactory' => $this->forwardFactoryMock + ] + ); + } + + public function testExecuteResultPage() + { + $this->cmsHelperMock->expects($this->once()) + ->method('prepareResultPage') + ->with($this->controller, $this->pageId) + ->willReturn($this->resultPageMock); + $this->assertSame($this->resultPageMock, $this->controller->execute()); + } + + public function testExecuteResultForward() + { + $this->forwardMock->expects($this->once()) + ->method('forward') + ->with('defaultIndex') + ->willReturnSelf(); + $this->assertSame($this->forwardMock, $this->controller->execute()); + } +} diff --git a/app/code/Magento/Cms/Test/Unit/Controller/Page/ViewTest.php b/app/code/Magento/Cms/Test/Unit/Controller/Page/ViewTest.php new file mode 100644 index 0000000000000000000000000000000000000000..df009be3bb0c7a71d9d0f7040d4215b40c7a7003 --- /dev/null +++ b/app/code/Magento/Cms/Test/Unit/Controller/Page/ViewTest.php @@ -0,0 +1,111 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Cms\Test\Unit\Controller\Page; + +class ViewTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Cms\Controller\Page\View + */ + protected $controller; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $cmsHelperMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $requestMock; + + /** + * @var \Magento\Framework\Controller\Result\ForwardFactory|\PHPUnit_Framework_MockObject_MockObject + */ + protected $forwardFactoryMock; + + /** + * @var \Magento\Framework\Controller\Result\Forward|\PHPUnit_Framework_MockObject_MockObject + */ + protected $forwardMock; + + /** + * @var \Magento\Framework\View\Result\Page|\PHPUnit_Framework_MockObject_MockObject + */ + protected $resultPageMock; + + /** + * @var string + */ + protected $pageId = '2'; + + protected function setUp() + { + $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); + $objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface'); + $responseMock = $this->getMock('Magento\Framework\App\Response\Http', [], [], '', false); + $this->resultPageMock = $this->getMockBuilder('\Magento\Framework\View\Result\Page') + ->disableOriginalConstructor() + ->getMock(); + $this->forwardFactoryMock = $this->getMockBuilder('\Magento\Framework\Controller\Result\ForwardFactory') + ->setMethods(['create']) + ->disableOriginalConstructor() + ->getMock(); + $this->forwardMock = $this->getMockBuilder('Magento\Framework\Controller\Result\Forward') + ->disableOriginalConstructor() + ->getMock(); + $this->forwardFactoryMock->expects($this->any()) + ->method('create') + ->willReturn($this->forwardMock); + + $this->requestMock = $this->getMock('Magento\Framework\App\Request\Http', [], [], '', false); + $this->cmsHelperMock = $this->getMock('Magento\Cms\Helper\Page', [], [], '', false); + $objectManagerMock->expects($this->once())->method('get')->willReturn($this->cmsHelperMock); + $this->controller = $helper->getObject( + 'Magento\Cms\Controller\Page\View', + [ + 'response' => $responseMock, + 'objectManager' => $objectManagerMock, + 'request' => $this->requestMock, + 'resultForwardFactory' => $this->forwardFactoryMock + ] + ); + } + + public function testExecuteResultPage() + { + $this->requestMock->expects($this->atLeastOnce()) + ->method('getParam') + ->willReturnMap( + [ + ['page_id', $this->pageId, $this->pageId], + ['id', false, $this->pageId] + ] + ); + $this->cmsHelperMock->expects($this->once()) + ->method('prepareResultPage') + ->with($this->controller, $this->pageId) + ->willReturn($this->resultPageMock); + $this->assertSame($this->resultPageMock, $this->controller->execute()); + } + + public function testExecuteResultForward() + { + $this->requestMock->expects($this->atLeastOnce()) + ->method('getParam') + ->willReturnMap( + [ + ['page_id', $this->pageId, $this->pageId], + ['id', false, $this->pageId] + ] + ); + $this->forwardMock->expects($this->once()) + ->method('forward') + ->with('noroute') + ->willReturnSelf(); + $this->assertSame($this->forwardMock, $this->controller->execute()); + } +} diff --git a/app/code/Magento/Cms/etc/config.xml b/app/code/Magento/Cms/etc/config.xml index 159fffe75e0734b6f1186375afda5460a90d5852..5b25edb764f4d8e03ddb79a8c404d3475707c2fb 100644 --- a/app/code/Magento/Cms/etc/config.xml +++ b/app/code/Magento/Cms/etc/config.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Core/etc/config.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Store/etc/config.xsd"> <default> <web> <default> diff --git a/app/code/Magento/Cms/etc/frontend/page_types.xml b/app/code/Magento/Cms/etc/frontend/page_types.xml index ac2f917542bcc6bddaa28fa8de7701d5fa6b9aa1..a6284ce44454b14ce4a256d0fa0db37d49cb0999 100644 --- a/app/code/Magento/Cms/etc/frontend/page_types.xml +++ b/app/code/Magento/Cms/etc/frontend/page_types.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> -<page_types xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../Core/etc/page_types.xsd"> +<page_types xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_types.xsd"> <type id="cms_index_defaultindex" label="CMS Home Default Page"/> <type id="cms_index_defaultnoroute" label="CMS No-Route Default Page"/> <type id="cms_index_index" label="CMS Home Page"/> diff --git a/app/code/Magento/Cms/etc/module.xml b/app/code/Magento/Cms/etc/module.xml index e083de84b5d1cde2788572eeca66dc552fbbb8c1..9103575c3a6b146e2e8fa1559ac1eeb91fd4625c 100644 --- a/app/code/Magento/Cms/etc/module.xml +++ b/app/code/Magento/Cms/etc/module.xml @@ -8,7 +8,6 @@ <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd"> <module name="Magento_Cms" setup_version="2.0.0"> <sequence> - <module name="Magento_Core"/> <module name="Magento_Store"/> <module name="Magento_Theme"/> </sequence> diff --git a/app/code/Magento/Config/Model/Config/Backend/Baseurl.php b/app/code/Magento/Config/Model/Config/Backend/Baseurl.php index a5249fc44892f7406362377ef3d2b3b03dadbe03..3c51993ca6e1e886558342fd81850ff5102823eb 100644 --- a/app/code/Magento/Config/Model/Config/Backend/Baseurl.php +++ b/app/code/Magento/Config/Model/Config/Backend/Baseurl.php @@ -51,7 +51,7 @@ class Baseurl extends \Magento\Framework\App\Config\Value $field = $this->getFieldConfig(); $label = $field && is_array($field) ? $field['label'] : 'value'; $msg = __('Invalid %1. %2', $label, $e->getMessage()); - $error = new \Magento\Framework\Exception\LocalizedException($msg, [], $e); + $error = new \Magento\Framework\Exception\LocalizedException($msg, $e); throw $error; } } @@ -164,7 +164,7 @@ class Baseurl extends \Magento\Framework\App\Config\Value $this->_assertStartsWithValuesOrUrl($values, $value); } catch (\Magento\Framework\Exception\LocalizedException $e) { $msg = __('%1 An empty value is allowed as well.', $e->getMessage()); - $error = new \Magento\Framework\Exception\LocalizedException($msg, [], $e); + $error = new \Magento\Framework\Exception\LocalizedException($msg, $e); throw $error; } } diff --git a/app/code/Magento/Config/Model/Config/Backend/Currency/Allow.php b/app/code/Magento/Config/Model/Config/Backend/Currency/Allow.php index d798402b72fdb599708cc0b4dd837be37044fa9a..5103829ca9c727eca0c514a364604491ae1b3e24 100644 --- a/app/code/Magento/Config/Model/Config/Backend/Currency/Allow.php +++ b/app/code/Magento/Config/Model/Config/Backend/Currency/Allow.php @@ -68,7 +68,7 @@ class Allow extends AbstractCurrency } if ($exceptions) { - throw new \Magento\Framework\Exception\LocalizedException(join("\n", $exceptions)); + throw new \Magento\Framework\Exception\LocalizedException(__(join("\n", $exceptions))); } return $this; diff --git a/app/code/Magento/Config/Model/Config/Backend/File.php b/app/code/Magento/Config/Model/Config/Backend/File.php index ad8d2de49e2f1d84d1b869a40f6dcef449898c7c..e7a119f79af9f0bf78d8f459ff0d30875abd097b 100644 --- a/app/code/Magento/Config/Model/Config/Backend/File.php +++ b/app/code/Magento/Config/Model/Config/Backend/File.php @@ -98,7 +98,7 @@ class File extends \Magento\Framework\App\Config\Value $uploader->addValidateCallback('size', $this, 'validateMaxSize'); $result = $uploader->save($uploadDir); } catch (\Exception $e) { - throw new \Magento\Framework\Exception\LocalizedException($e->getMessage()); + throw new \Magento\Framework\Exception\LocalizedException(__($e->getMessage())); } $filename = $result['file']; diff --git a/app/code/Magento/Config/Model/Config/Backend/Locale.php b/app/code/Magento/Config/Model/Config/Backend/Locale.php index 5f4b102a4b0a63685cb72547ef9ab1e1bfd6f71f..0881afdebfc3839d52d0c27de0052ae6a8bd68b1 100644 --- a/app/code/Magento/Config/Model/Config/Backend/Locale.php +++ b/app/code/Magento/Config/Model/Config/Backend/Locale.php @@ -115,7 +115,7 @@ class Locale extends \Magento\Framework\App\Config\Value } } if ($exceptions) { - throw new \Magento\Framework\Exception\LocalizedException(join("\n", $exceptions)); + throw new \Magento\Framework\Exception\LocalizedException(__(join("\n", $exceptions))); } return $this; diff --git a/app/code/Magento/Config/Test/Unit/Model/Config/Source/Email/TemplateTest.php b/app/code/Magento/Config/Test/Unit/Model/Config/Source/Email/TemplateTest.php index 12a6aaa4103648be57f326ea5190e834ce51e8f0..03dd7a71d0c22c9534beca8babb44334b0ce446b 100644 --- a/app/code/Magento/Config/Test/Unit/Model/Config/Source/Email/TemplateTest.php +++ b/app/code/Magento/Config/Test/Unit/Model/Config/Source/Email/TemplateTest.php @@ -3,6 +3,9 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ + +// @codingStandardsIgnoreFile + namespace Magento\Config\Test\Unit\Model\Config\Source\Email; class TemplateTest extends \PHPUnit_Framework_TestCase @@ -23,7 +26,7 @@ class TemplateTest extends \PHPUnit_Framework_TestCase protected $_emailConfig; /** - * @var /Magento\Core\Model\Resource\Email\Template\CollectionFactory + * @var \Magento\Email\Model\Resource\Email\Template\CollectionFactory */ protected $_templatesFactory; diff --git a/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Element/FieldTest.php b/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Element/FieldTest.php index 900ec273d690e6853f528c8a2d92e70a64c0b444..c9457d003b374eae3006746308c56aac7709e7a6 100644 --- a/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Element/FieldTest.php +++ b/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Element/FieldTest.php @@ -5,6 +5,9 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ + +// @codingStandardsIgnoreFile + namespace Magento\Config\Test\Unit\Model\Config\Structure\Element; class FieldTest extends \PHPUnit_Framework_TestCase @@ -171,7 +174,7 @@ class FieldTest extends \PHPUnit_Framework_TestCase public function testGetTooltipCreatesTooltipBlock() { - $this->_model->setData(['tooltip_block' => 'Magento\Core\Block\Tooltip'], 'scope'); + $this->_model->setData(['tooltip_block' => 'Magento\Config\Block\Tooltip'], 'scope'); $tooltipBlock = $this->getMock('Magento\Framework\View\Element\BlockInterface'); $tooltipBlock->expects($this->once())->method('toHtml')->will($this->returnValue('tooltip block')); $this->_blockFactoryMock->expects( @@ -179,7 +182,7 @@ class FieldTest extends \PHPUnit_Framework_TestCase )->method( 'createBlock' )->with( - 'Magento\Core\Block\Tooltip' + 'Magento\Config\Block\Tooltip' )->will( $this->returnValue($tooltipBlock) ); diff --git a/app/code/Magento/Config/composer.json b/app/code/Magento/Config/composer.json index 34ebbca138848ab22af73c0dd1f39fb0deadcebf..9fdfc97389801480818889a96c47d96ce1b2dd11 100644 --- a/app/code/Magento/Config/composer.json +++ b/app/code/Magento/Config/composer.json @@ -4,7 +4,6 @@ "require": { "php": "~5.5.0|~5.6.0", "magento/framework": "0.42.0-beta11", - "magento/module-core": "0.42.0-beta11", "magento/module-store": "0.42.0-beta11", "magento/module-cron": "0.42.0-beta11", "magento/module-email": "0.42.0-beta11", diff --git a/app/code/Magento/Config/i18n/de_DE.csv b/app/code/Magento/Config/i18n/de_DE.csv new file mode 100644 index 0000000000000000000000000000000000000000..0aa412938948174cc2ccbb853f05ff5f6de51522 --- /dev/null +++ b/app/code/Magento/Config/i18n/de_DE.csv @@ -0,0 +1 @@ +Configuration,Configuration diff --git a/app/code/Magento/Config/i18n/en_US.csv b/app/code/Magento/Config/i18n/en_US.csv new file mode 100644 index 0000000000000000000000000000000000000000..0aa412938948174cc2ccbb853f05ff5f6de51522 --- /dev/null +++ b/app/code/Magento/Config/i18n/en_US.csv @@ -0,0 +1 @@ +Configuration,Configuration diff --git a/app/code/Magento/Config/i18n/es_ES.csv b/app/code/Magento/Config/i18n/es_ES.csv new file mode 100644 index 0000000000000000000000000000000000000000..0aa412938948174cc2ccbb853f05ff5f6de51522 --- /dev/null +++ b/app/code/Magento/Config/i18n/es_ES.csv @@ -0,0 +1 @@ +Configuration,Configuration diff --git a/app/code/Magento/Config/i18n/fr_FR.csv b/app/code/Magento/Config/i18n/fr_FR.csv new file mode 100644 index 0000000000000000000000000000000000000000..0aa412938948174cc2ccbb853f05ff5f6de51522 --- /dev/null +++ b/app/code/Magento/Config/i18n/fr_FR.csv @@ -0,0 +1 @@ +Configuration,Configuration diff --git a/app/code/Magento/Config/i18n/nl_NL.csv b/app/code/Magento/Config/i18n/nl_NL.csv new file mode 100644 index 0000000000000000000000000000000000000000..0aa412938948174cc2ccbb853f05ff5f6de51522 --- /dev/null +++ b/app/code/Magento/Config/i18n/nl_NL.csv @@ -0,0 +1 @@ +Configuration,Configuration diff --git a/app/code/Magento/Config/i18n/pt_BR.csv b/app/code/Magento/Config/i18n/pt_BR.csv new file mode 100644 index 0000000000000000000000000000000000000000..0aa412938948174cc2ccbb853f05ff5f6de51522 --- /dev/null +++ b/app/code/Magento/Config/i18n/pt_BR.csv @@ -0,0 +1 @@ +Configuration,Configuration diff --git a/app/code/Magento/Config/i18n/zh_CN.csv b/app/code/Magento/Config/i18n/zh_CN.csv new file mode 100644 index 0000000000000000000000000000000000000000..0aa412938948174cc2ccbb853f05ff5f6de51522 --- /dev/null +++ b/app/code/Magento/Config/i18n/zh_CN.csv @@ -0,0 +1 @@ +Configuration,Configuration diff --git a/app/code/Magento/ConfigurableProduct/Api/Data/OptionInterface.php b/app/code/Magento/ConfigurableProduct/Api/Data/OptionInterface.php index 8f4bbba818b2cbef6eddadca0c2a357e0a32139b..82e73fe8686e268e1b3701c216fe3bb8a2d4ee95 100644 --- a/app/code/Magento/ConfigurableProduct/Api/Data/OptionInterface.php +++ b/app/code/Magento/ConfigurableProduct/Api/Data/OptionInterface.php @@ -84,4 +84,21 @@ interface OptionInterface extends \Magento\Framework\Api\ExtensibleDataInterface * @return $this */ public function setValues(array $values = null); + + /** + * Retrieve existing extension attributes object or create a new one. + * + * @return \Magento\ConfigurableProduct\Api\Data\OptionExtensionInterface|null + */ + public function getExtensionAttributes(); + + /** + * Set an extension attributes object. + * + * @param \Magento\ConfigurableProduct\Api\Data\OptionExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes( + \Magento\ConfigurableProduct\Api\Data\OptionExtensionInterface $extensionAttributes + ); } diff --git a/app/code/Magento/ConfigurableProduct/Api/Data/OptionValueInterface.php b/app/code/Magento/ConfigurableProduct/Api/Data/OptionValueInterface.php index b24f4702da96fd9a496c709cf2523e53b3f86840..a6838c3b72d8d31f43457ecb7c356cefc0ed82be 100644 --- a/app/code/Magento/ConfigurableProduct/Api/Data/OptionValueInterface.php +++ b/app/code/Magento/ConfigurableProduct/Api/Data/OptionValueInterface.php @@ -40,4 +40,21 @@ interface OptionValueInterface extends \Magento\Framework\Api\ExtensibleDataInte * @return $this */ public function setValueIndex($valueIndex); + + /** + * Retrieve existing extension attributes object or create a new one. + * + * @return \Magento\ConfigurableProduct\Api\Data\OptionValueExtensionInterface|null + */ + public function getExtensionAttributes(); + + /** + * Set an extension attributes object. + * + * @param \Magento\ConfigurableProduct\Api\Data\OptionValueExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes( + \Magento\ConfigurableProduct\Api\Data\OptionValueExtensionInterface $extensionAttributes + ); } diff --git a/app/code/Magento/ConfigurableProduct/Api/LinkManagementInterface.php b/app/code/Magento/ConfigurableProduct/Api/LinkManagementInterface.php index 92d408658636e4e6f58de24865b406f4de1a69a6..2b62e7c3e73eb31cfaf79d42dbef93c2a6e48914 100644 --- a/app/code/Magento/ConfigurableProduct/Api/LinkManagementInterface.php +++ b/app/code/Magento/ConfigurableProduct/Api/LinkManagementInterface.php @@ -11,26 +11,26 @@ interface LinkManagementInterface /** * Get all children for Bundle product * - * @param string $productSku + * @param string $sku * @return \Magento\Catalog\Api\Data\ProductInterface[] */ - public function getChildren($productSku); + public function getChildren($sku); /** - * @param string $productSku + * @param string $sku * @param string $childSku * @return bool */ - public function addChild($productSku, $childSku); + public function addChild($sku, $childSku); /** * Remove configurable product option * - * @param string $productSku + * @param string $sku * @param string $childSku * @throws \Magento\Framework\Exception\NoSuchEntityException * @throws \Magento\Framework\Exception\InputException * @return bool */ - public function removeChild($productSku, $childSku); + public function removeChild($sku, $childSku); } diff --git a/app/code/Magento/ConfigurableProduct/Api/OptionRepositoryInterface.php b/app/code/Magento/ConfigurableProduct/Api/OptionRepositoryInterface.php index 0c27db8c4fa4c67d4542294f2823c569e40adf38..990d8fd6dcaf8f64c36c43127a4dd8b763cdc2b1 100644 --- a/app/code/Magento/ConfigurableProduct/Api/OptionRepositoryInterface.php +++ b/app/code/Magento/ConfigurableProduct/Api/OptionRepositoryInterface.php @@ -11,23 +11,23 @@ interface OptionRepositoryInterface /** * Get option for configurable product * - * @param string $productSku - * @param int $optionId + * @param string $sku + * @param int $id * @return \Magento\ConfigurableProduct\Api\Data\OptionInterface * @throws \Magento\Framework\Exception\NoSuchEntityException * @throws \Magento\Framework\Exception\InputException */ - public function get($productSku, $optionId); + public function get($sku, $id); /** * Get all options for configurable product * - * @param string $productSku + * @param string $sku * @return \Magento\ConfigurableProduct\Api\Data\OptionInterface[] * @throws \Magento\Framework\Exception\NoSuchEntityException * @throws \Magento\Framework\Exception\InputException */ - public function getList($productSku); + public function getList($sku); /** * Remove option from configurable product @@ -40,23 +40,23 @@ interface OptionRepositoryInterface /** * Remove option from configurable product * - * @param string $productSku - * @param int $optionId + * @param string $sku + * @param int $id * @return bool * @throws \Magento\Framework\Exception\NoSuchEntityException * @throws \Magento\Framework\Exception\InputException */ - public function deleteById($productSku, $optionId); + public function deleteById($sku, $id); /** * Save option * - * @param string $productSku + * @param string $sku * @param \Magento\ConfigurableProduct\Api\Data\OptionInterface $option * @return int * @throws \Magento\Framework\Exception\NoSuchEntityException * @throws \Magento\Framework\Exception\CouldNotSaveException * @throws \InvalidArgumentException */ - public function save($productSku, \Magento\ConfigurableProduct\Api\Data\OptionInterface $option); + public function save($sku, \Magento\ConfigurableProduct\Api\Data\OptionInterface $option); } diff --git a/app/code/Magento/ConfigurableProduct/Model/LinkManagement.php b/app/code/Magento/ConfigurableProduct/Model/LinkManagement.php index 7f57b5e9b2dc7a2594bb0b17599b04d849e74623..51f425d487f302c4062622c25db1e4fa8ef0f1bc 100644 --- a/app/code/Magento/ConfigurableProduct/Model/LinkManagement.php +++ b/app/code/Magento/ConfigurableProduct/Model/LinkManagement.php @@ -53,10 +53,10 @@ class LinkManagement implements \Magento\ConfigurableProduct\Api\LinkManagementI /** * {@inheritdoc} */ - public function getChildren($productSku) + public function getChildren($sku) { /** @var \Magento\Catalog\Model\Product $product */ - $product = $this->productRepository->get($productSku); + $product = $this->productRepository->get($sku); if ($product->getTypeId() != \Magento\ConfigurableProduct\Model\Product\Type\Configurable::TYPE_CODE) { return []; } @@ -92,14 +92,14 @@ class LinkManagement implements \Magento\ConfigurableProduct\Api\LinkManagementI /** * {@inheritdoc} */ - public function addChild($productSku, $childSku) + public function addChild($sku, $childSku) { - $product = $this->productRepository->get($productSku); + $product = $this->productRepository->get($sku); $child = $this->productRepository->get($childSku); $childrenIds = array_values($this->configurableType->getChildrenIds($product->getId())[0]); if (in_array($child->getId(), $childrenIds)) { - throw new StateException('Product has been already attached'); + throw new StateException(__('Product has been already attached')); } $childrenIds[] = $child->getId(); @@ -111,13 +111,13 @@ class LinkManagement implements \Magento\ConfigurableProduct\Api\LinkManagementI /** * {@inheritdoc} */ - public function removeChild($productSku, $childSku) + public function removeChild($sku, $childSku) { - $product = $this->productRepository->get($productSku); + $product = $this->productRepository->get($sku); if ($product->getTypeId() != \Magento\ConfigurableProduct\Model\Product\Type\Configurable::TYPE_CODE) { throw new InputException( - sprintf('Product with specified sku: %s is not a configurable product', $productSku) + __('Product with specified sku: %1 is not a configurable product', $sku) ); } @@ -130,7 +130,7 @@ class LinkManagement implements \Magento\ConfigurableProduct\Api\LinkManagementI $ids[] = $option->getId(); } if (count($options) == count($ids)) { - throw new NoSuchEntityException('Requested option doesn\'t exist'); + throw new NoSuchEntityException(__('Requested option doesn\'t exist')); } $product->addData(['associated_product_ids' => $ids]); $product->save(); diff --git a/app/code/Magento/ConfigurableProduct/Model/OptionRepository.php b/app/code/Magento/ConfigurableProduct/Model/OptionRepository.php index 6de09a43ddd59eba1fb5b46ceb00680abf08afe5..da8e040874852d2af958a2d52345192c7cbc75b1 100644 --- a/app/code/Magento/ConfigurableProduct/Model/OptionRepository.php +++ b/app/code/Magento/ConfigurableProduct/Model/OptionRepository.php @@ -84,15 +84,15 @@ class OptionRepository implements \Magento\ConfigurableProduct\Api\OptionReposit /** * {@inheritdoc} */ - public function get($productSku, $optionId) + public function get($sku, $id) { - $product = $this->getProduct($productSku); + $product = $this->getProduct($sku); $collection = $this->getConfigurableAttributesCollection($product); - $collection->addFieldToFilter($collection->getResource()->getIdFieldName(), $optionId); + $collection->addFieldToFilter($collection->getResource()->getIdFieldName(), $id); /** @var \Magento\ConfigurableProduct\Model\Product\Type\Configurable\Attribute $configurableAttribute */ $configurableAttribute = $collection->getFirstItem(); if (!$configurableAttribute->getId()) { - throw new NoSuchEntityException(sprintf('Requested option doesn\'t exist: %s', $optionId)); + throw new NoSuchEntityException(__('Requested option doesn\'t exist: %1', $id)); } $prices = $configurableAttribute->getPrices(); if (is_array($prices)) { @@ -112,10 +112,10 @@ class OptionRepository implements \Magento\ConfigurableProduct\Api\OptionReposit /** * {@inheritdoc} */ - public function getList($productSku) + public function getList($sku) { $options = []; - $product = $this->getProduct($productSku); + $product = $this->getProduct($sku); foreach ($this->getConfigurableAttributesCollection($product) as $option) { $values = []; $prices = $option->getPrices(); @@ -144,7 +144,7 @@ class OptionRepository implements \Magento\ConfigurableProduct\Api\OptionReposit $this->optionResource->delete($option); } catch (\Exception $exception) { throw new StateException( - sprintf('Cannot delete option with id: %s', $option->getId()) + __('Cannot delete option with id: %1', $option->getId()) ); } return true; @@ -153,14 +153,14 @@ class OptionRepository implements \Magento\ConfigurableProduct\Api\OptionReposit /** * {@inheritdoc} */ - public function deleteById($productSku, $optionId) + public function deleteById($sku, $id) { - $product = $this->getProduct($productSku); + $product = $this->getProduct($sku); $attributeCollection = $this->configurableType->getConfigurableAttributeCollection($product); /** @var \Magento\ConfigurableProduct\Model\Product\Type\Configurable\Attribute $option */ - $option = $attributeCollection->getItemById($optionId); + $option = $attributeCollection->getItemById($id); if ($option === null) { - throw new NoSuchEntityException('Requested option doesn\'t exist'); + throw new NoSuchEntityException(__('Requested option doesn\'t exist')); } return $this->delete($option); } @@ -169,18 +169,20 @@ class OptionRepository implements \Magento\ConfigurableProduct\Api\OptionReposit * {@inheritdoc} * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ - public function save($productSku, \Magento\ConfigurableProduct\Api\Data\OptionInterface $option) + public function save($sku, \Magento\ConfigurableProduct\Api\Data\OptionInterface $option) { /** @var $configurableAttribute \Magento\ConfigurableProduct\Model\Product\Type\Configurable\Attribute */ $configurableAttribute = $this->configurableAttributeFactory->create(); if ($option->getId()) { /** @var \Magento\Catalog\Model\Product $product */ - $product = $this->getProduct($productSku); + $product = $this->getProduct($sku); $configurableAttribute->load($option->getId()); if (!$configurableAttribute->getId() || $configurableAttribute->getProductId() != $product->getId()) { throw new NoSuchEntityException( - 'Option with id "%option_id" not found', - ['option_id' => $option->getId()] + __( + 'Option with id "%1" not found', + $option->getId() + ) ); } $configurableAttribute->addData($option->getData()); @@ -192,14 +194,16 @@ class OptionRepository implements \Magento\ConfigurableProduct\Api\OptionReposit $configurableAttribute->save(); } catch (\Exception $e) { throw new CouldNotSaveException( - 'Could not update option with id "%option_id"', - ['option_id' => $option->getId()] + __( + 'Could not update option with id "%1"', + $option->getId() + ) ); } } else { $this->validateNewOptionData($option); /** @var \Magento\Catalog\Model\Product $product */ - $product = $this->productRepository->get($productSku); + $product = $this->productRepository->get($sku); $allowedTypes = [ProductType::TYPE_SIMPLE, ProductType::TYPE_VIRTUAL, ConfigurableType::TYPE_CODE]; if (!in_array($product->getTypeId(), $allowedTypes)) { throw new \InvalidArgumentException('Incompatible product type'); @@ -208,7 +212,7 @@ class OptionRepository implements \Magento\ConfigurableProduct\Api\OptionReposit $eavAttribute = $this->productAttributeRepository->get($option->getAttributeId()); $configurableAttribute->loadByProductAndAttribute($product, $eavAttribute); if ($configurableAttribute->getId()) { - throw new CouldNotSaveException('Product already has this option'); + throw new CouldNotSaveException(__('Product already has this option')); } $configurableAttributesData = [ @@ -225,14 +229,14 @@ class OptionRepository implements \Magento\ConfigurableProduct\Api\OptionReposit $product->setStoreId($this->storeManager->getStore(Store::ADMIN_CODE)->getId()); $product->save(); } catch (\Exception $e) { - throw new CouldNotSaveException('An error occurred while saving option'); + throw new CouldNotSaveException(__('An error occurred while saving option')); } $configurableAttribute = $this->configurableAttributeFactory->create(); $configurableAttribute->loadByProductAndAttribute($product, $eavAttribute); } if (!$configurableAttribute->getId()) { - throw new CouldNotSaveException('An error occurred while saving option'); + throw new CouldNotSaveException(__('An error occurred while saving option')); } return $configurableAttribute->getId(); } @@ -240,16 +244,16 @@ class OptionRepository implements \Magento\ConfigurableProduct\Api\OptionReposit /** * Retrieve product instance by sku * - * @param string $productSku + * @param string $sku * @return \Magento\Catalog\Model\Product * @throws InputException */ - private function getProduct($productSku) + private function getProduct($sku) { - $product = $this->productRepository->get($productSku); + $product = $this->productRepository->get($sku); if (\Magento\ConfigurableProduct\Model\Product\Type\Configurable::TYPE_CODE !== $product->getTypeId()) { throw new InputException( - sprintf('Only implemented for configurable product: %s', $productSku) + __('Only implemented for configurable product: %1', $sku) ); } return $product; @@ -278,26 +282,26 @@ class OptionRepository implements \Magento\ConfigurableProduct\Api\OptionReposit { $inputException = new InputException(); if (!$option->getAttributeId()) { - $inputException->addError('Option attribute ID is not specified.'); + $inputException->addError(__('Option attribute ID is not specified.')); } if (!$option->getType()) { - $inputException->addError('Option type is not specified.'); + $inputException->addError(__('Option type is not specified.')); } if (!$option->getLabel()) { - $inputException->addError('Option label is not specified.'); + $inputException->addError(__('Option label is not specified.')); } if (!$option->getValues()) { - $inputException->addError('Option values are not specified.'); + $inputException->addError(__('Option values are not specified.')); } else { foreach ($option->getValues() as $optionValue) { if (!$optionValue->getValueIndex()) { - $inputException->addError('Value index is not specified for an option.'); + $inputException->addError(__('Value index is not specified for an option.')); } if (null === $optionValue->getPricingValue()) { - $inputException->addError('Price is not specified for an option.'); + $inputException->addError(__('Price is not specified for an option.')); } if (null === $optionValue->getIsPercent()) { - $inputException->addError('Percent/absolute is not specified for an option.'); + $inputException->addError(__('Percent/absolute is not specified for an option.')); } } } diff --git a/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable/Attribute.php b/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable/Attribute.php index d2e9954bd1cfa4fab7cb11016829042ebf36eb94..73c029fe5db46074da69204e5a48c6e90ea7959d 100644 --- a/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable/Attribute.php +++ b/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable/Attribute.php @@ -209,5 +209,27 @@ class Attribute extends \Magento\Framework\Model\AbstractExtensibleModel impleme { return $this->setData(self::KEY_VALUES, $values); } + + /** + * {@inheritdoc} + * + * @return \Magento\ConfigurableProduct\Api\Data\OptionExtensionInterface|null + */ + public function getExtensionAttributes() + { + return $this->_getExtensionAttributes(); + } + + /** + * {@inheritdoc} + * + * @param \Magento\ConfigurableProduct\Api\Data\OptionExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes( + \Magento\ConfigurableProduct\Api\Data\OptionExtensionInterface $extensionAttributes + ) { + return $this->_setExtensionAttributes($extensionAttributes); + } //@codeCoverageIgnoreEnd } diff --git a/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable/OptionValue.php b/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable/OptionValue.php index 7acd37f43cab707da519717e3788d4cd4156f0ee..8a551ed9e5f362d998da7e1504c178be0a1cd88b 100644 --- a/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable/OptionValue.php +++ b/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable/OptionValue.php @@ -9,6 +9,10 @@ namespace Magento\ConfigurableProduct\Model\Product\Type\Configurable; use Magento\ConfigurableProduct\Api\Data\OptionValueInterface; +/** + * Class OptionValue + * + */ class OptionValue extends \Magento\Framework\Model\AbstractExtensibleModel implements \Magento\ConfigurableProduct\Api\Data\OptionValueInterface { @@ -44,6 +48,7 @@ class OptionValue extends \Magento\Framework\Model\AbstractExtensibleModel imple { return $this->getData(self::KEY_VALUE_INDEX); } + /** * @param float $pricingValue * @return $this @@ -70,5 +75,27 @@ class OptionValue extends \Magento\Framework\Model\AbstractExtensibleModel imple { return $this->setData(self::KEY_VALUE_INDEX, $valueIndex); } + + /** + * {@inheritdoc} + * + * @return \Magento\ConfigurableProduct\Api\Data\OptionValueExtensionInterface|null + */ + public function getExtensionAttributes() + { + return $this->_getExtensionAttributes(); + } + + /** + * {@inheritdoc} + * + * @param \Magento\ConfigurableProduct\Api\Data\OptionValueExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes( + \Magento\ConfigurableProduct\Api\Data\OptionValueExtensionInterface $extensionAttributes + ) { + return $this->_setExtensionAttributes($extensionAttributes); + } //@codeCoverageIgnoreEnd } diff --git a/app/code/Magento/ConfigurableProduct/Model/Product/Validator/Plugin.php b/app/code/Magento/ConfigurableProduct/Model/Product/Validator/Plugin.php index c5fcd0eed8f45f2dcd99255b7c3017e30a69fdde..7b9feeb1d1a64269354d2ca21ba3774e0f218e4b 100644 --- a/app/code/Magento/ConfigurableProduct/Model/Product/Validator/Plugin.php +++ b/app/code/Magento/ConfigurableProduct/Model/Product/Validator/Plugin.php @@ -8,7 +8,6 @@ namespace Magento\ConfigurableProduct\Model\Product\Validator; use Closure; use Magento\Catalog\Model\Product; use Magento\Catalog\Model\ProductFactory; -use Magento\Core\Helper; use Magento\Framework\App\RequestInterface; use Magento\Framework\Event\Manager; use Magento\Framework\Json\Helper\Data; diff --git a/app/code/Magento/ConfigurableProduct/composer.json b/app/code/Magento/ConfigurableProduct/composer.json index d893a9a579d497a9ffb1e24a944cdf351bc37447..8e5ed6d41420f3511ea04f64c73aae01705a0d98 100644 --- a/app/code/Magento/ConfigurableProduct/composer.json +++ b/app/code/Magento/ConfigurableProduct/composer.json @@ -7,7 +7,6 @@ "magento/module-catalog": "0.42.0-beta11", "magento/module-catalog-inventory": "0.42.0-beta11", "magento/module-sales": "0.42.0-beta11", - "magento/module-core": "0.42.0-beta11", "magento/module-checkout": "0.42.0-beta11", "magento/module-backend": "0.42.0-beta11", "magento/module-eav": "0.42.0-beta11", diff --git a/app/code/Magento/ConfigurableProduct/etc/config.xml b/app/code/Magento/ConfigurableProduct/etc/config.xml index f634fdfd21a81a63bf7c4c072c1450b1c4f30898..9cbd5d1e351f252168756cac3dd03ade2e3cc296 100644 --- a/app/code/Magento/ConfigurableProduct/etc/config.xml +++ b/app/code/Magento/ConfigurableProduct/etc/config.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Core/etc/config.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Store/etc/config.xsd"> <default> <checkout> <cart> diff --git a/app/code/Magento/ConfigurableProduct/etc/webapi.xml b/app/code/Magento/ConfigurableProduct/etc/webapi.xml index d48569ce61b337753067bd160f1627a84dd261f2..9c68aa71869f44782120dda382eb7de6c34e9f2d 100644 --- a/app/code/Magento/ConfigurableProduct/etc/webapi.xml +++ b/app/code/Magento/ConfigurableProduct/etc/webapi.xml @@ -7,13 +7,13 @@ --> <routes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../app/code/Magento/Webapi/etc/webapi.xsd"> - <route url="/V1/configurable-products/:productSku/children" method="GET"> + <route url="/V1/configurable-products/:sku/children" method="GET"> <service class="Magento\ConfigurableProduct\Api\LinkManagementInterface" method="getChildren"/> <resources> <resource ref="Magento_Catalog::products"/> </resources> </route> - <route url="/V1/configurable-products/:productSku/child/:childSku" method="DELETE"> + <route url="/V1/configurable-products/:sku/children/:childSku" method="DELETE"> <service class="Magento\ConfigurableProduct\Api\LinkManagementInterface" method="removeChild"/> <resources> <resource ref="Magento_Catalog::products"/> @@ -25,19 +25,19 @@ <resource ref="Magento_Catalog::products" /> </resources> </route> - <route url="/V1/configurable-products/:productSku/child" method="POST"> + <route url="/V1/configurable-products/:sku/child" method="POST"> <service class="Magento\ConfigurableProduct\Api\LinkManagementInterface" method="addChild"/> <resources> <resource ref="Magento_Catalog::products" /> </resources> </route> - <route url="/V1/configurable-products/:productSku/options/:optionId" method="GET"> + <route url="/V1/configurable-products/:sku/options/:id" method="GET"> <service class="Magento\ConfigurableProduct\Api\OptionRepositoryInterface" method="get"/> <resources> <resource ref="Magento_Catalog::products"/> </resources> </route> - <route url="/V1/configurable-products/:productSku/options/all" method="GET"> + <route url="/V1/configurable-products/:sku/options/all" method="GET"> <service class="Magento\ConfigurableProduct\Api\OptionRepositoryInterface" method="getList"/> <resources> <resource ref="Magento_Catalog::products"/> @@ -49,19 +49,19 @@ <resource ref="Magento_Catalog::products" /> </resources> </route> - <route url="/V1/configurable-products/:productSku/options" method="POST"> + <route url="/V1/configurable-products/:sku/options" method="POST"> <service class="Magento\ConfigurableProduct\Api\OptionRepositoryInterface" method="save" /> <resources> <resource ref="Magento_Catalog::products" /> </resources> </route> - <route url="/V1/configurable-products/:productSku/options/:id" method="PUT"> + <route url="/V1/configurable-products/:sku/options/:id" method="PUT"> <service class="Magento\ConfigurableProduct\Api\OptionRepositoryInterface" method="save" /> <resources> <resource ref="Magento_Catalog::products" /> </resources> </route> - <route url="/V1/configurable-products/:productSku/options/:optionId" method="DELETE"> + <route url="/V1/configurable-products/:sku/options/:id" method="DELETE"> <service class="Magento\ConfigurableProduct\Api\OptionRepositoryInterface" method="deleteById" /> <resources> <resource ref="Magento_Catalog::products" /> diff --git a/app/code/Magento/ConfigurableProduct/view/frontend/layout/checkout_cart_item_renderers.xml b/app/code/Magento/ConfigurableProduct/view/frontend/layout/checkout_cart_item_renderers.xml index c430e91be2cc8ab9ac2134ff68bd9785ec284a29..ed335b6babce89860d2af06041a59957ce9dcea5 100644 --- a/app/code/Magento/ConfigurableProduct/view/frontend/layout/checkout_cart_item_renderers.xml +++ b/app/code/Magento/ConfigurableProduct/view/frontend/layout/checkout_cart_item_renderers.xml @@ -8,7 +8,7 @@ <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd"> <body> <referenceBlock name="checkout.cart.item.renderers"> - <block class="Magento\ConfigurableProduct\Block\Cart\Item\Renderer\Configurable" as="configurable" template="Magento_Checkout::cart/item/default.phtml" cacheable="false"/> + <block class="Magento\ConfigurableProduct\Block\Cart\Item\Renderer\Configurable" as="configurable" template="Magento_Checkout::cart/item/default.phtml"/> </referenceBlock> </body> </page> diff --git a/app/code/Magento/Contact/etc/config.xml b/app/code/Magento/Contact/etc/config.xml index f075a4e53a954f1aedaa8bbf705921857eac6dc2..fb2a17aa0100cbc9524c4692881ac265f7fe2275 100644 --- a/app/code/Magento/Contact/etc/config.xml +++ b/app/code/Magento/Contact/etc/config.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Core/etc/config.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Store/etc/config.xsd"> <default> <contact> <contact> diff --git a/app/code/Magento/Contact/etc/frontend/page_types.xml b/app/code/Magento/Contact/etc/frontend/page_types.xml index 9bcf7e9ca9774e395810ebab93590bea9ef4c401..9e85e85522a1557017ebbb649332049502d381fb 100644 --- a/app/code/Magento/Contact/etc/frontend/page_types.xml +++ b/app/code/Magento/Contact/etc/frontend/page_types.xml @@ -5,6 +5,6 @@ * See COPYING.txt for license details. */ --> -<page_types xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../Core/etc/page_types.xsd"> +<page_types xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_types.xsd"> <type id="contact_index_index" label="Contact Us Form"/> </page_types> diff --git a/app/code/Magento/Contact/etc/module.xml b/app/code/Magento/Contact/etc/module.xml index 9962113cf348f736f2f61a98ac2e1b54761b3625..96f06a6c555a729a02b8643f7e01b3987e5a9bf0 100644 --- a/app/code/Magento/Contact/etc/module.xml +++ b/app/code/Magento/Contact/etc/module.xml @@ -8,7 +8,6 @@ <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd"> <module name="Magento_Contact" setup_version="2.0.0"> <sequence> - <module name="Magento_Core"/> <module name="Magento_Store"/> </sequence> </module> diff --git a/app/code/Magento/Cookie/etc/config.xml b/app/code/Magento/Cookie/etc/config.xml index cdeb99d4195ea29343fec69aaf2b69fcfd9ed508..7ebaec497d7bfd166822f31eb274c3e2feeb3692 100644 --- a/app/code/Magento/Cookie/etc/config.xml +++ b/app/code/Magento/Cookie/etc/config.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Core/etc/config.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Store/etc/config.xsd"> <default> <web> <cookie> diff --git a/app/code/Magento/Core/Controller/Index/NotFound.php b/app/code/Magento/Core/Controller/Index/NotFound.php deleted file mode 100644 index 3e0a46abf199a8ac1da81af408f8940d170d09fa..0000000000000000000000000000000000000000 --- a/app/code/Magento/Core/Controller/Index/NotFound.php +++ /dev/null @@ -1,21 +0,0 @@ -<?php -/** - * - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Core\Controller\Index; - -class NotFound extends \Magento\Framework\App\Action\Action -{ - /** - * 404 not found action - * - * @return void - */ - public function execute() - { - $this->getResponse()->setStatusHeader(404, '1.1', 'Not Found'); - $this->getResponse()->setBody(__('Requested resource not found')); - } -} diff --git a/app/code/Magento/Core/Setup/InstallData.php b/app/code/Magento/Core/Setup/InstallData.php deleted file mode 100755 index 52d8e6bea687733db2bd6fb477bcc1f11a9ed24e..0000000000000000000000000000000000000000 --- a/app/code/Magento/Core/Setup/InstallData.php +++ /dev/null @@ -1,37 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -namespace Magento\Core\Setup; - -use Magento\Framework\Module\Setup\Migration; -use Magento\Framework\Setup\InstallDataInterface; -use Magento\Framework\Setup\ModuleContextInterface; -use Magento\Framework\Setup\ModuleDataSetupInterface; - -/** - * @codeCoverageIgnore - */ -class InstallData implements InstallDataInterface -{ - /** - * {@inheritdoc} - */ - public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context) - { - $setup->startSetup(); - - /** - * Delete rows by condition from authorization_rule - */ - $tableName = $setup->getTable('authorization_rule'); - if ($tableName) { - $setup->getConnection()->delete($tableName, ['resource_id = ?' => 'admin/system/tools/compiler']); - } - - $setup->endSetup(); - - } -} diff --git a/app/code/Magento/Core/Setup/InstallSchema.php b/app/code/Magento/Core/Setup/InstallSchema.php deleted file mode 100644 index 5a9c92b58b1e6fcaf355c817a34c16f74d5c46c5..0000000000000000000000000000000000000000 --- a/app/code/Magento/Core/Setup/InstallSchema.php +++ /dev/null @@ -1,231 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -namespace Magento\Core\Setup; - -use Magento\Framework\Setup\InstallSchemaInterface; -use Magento\Framework\Setup\ModuleContextInterface; -use Magento\Framework\Setup\SchemaSetupInterface; - -/** - * @codeCoverageIgnore - */ -class InstallSchema implements InstallSchemaInterface -{ - /** - * {@inheritdoc} - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) - */ - public function install(SchemaSetupInterface $setup, ModuleContextInterface $context) - { - $installer = $setup; - - /* @var $connection \Magento\Framework\DB\Adapter\AdapterInterface */ - $connection = $installer->getConnection(); - - $installer->startSetup(); - - /** - * Create table 'core_session' - */ - $table = $connection->newTable( - $installer->getTable('core_session') - )->addColumn( - 'session_id', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 255, - ['nullable' => false, 'primary' => true], - 'Session Id' - )->addColumn( - 'session_expires', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['unsigned' => true, 'nullable' => false, 'default' => '0'], - 'Date of Session Expiration' - )->addColumn( - 'session_data', - \Magento\Framework\DB\Ddl\Table::TYPE_BLOB, - '2M', - ['nullable' => false], - 'Session Data' - )->setComment( - 'Database Sessions Storage' - ); - $connection->createTable($table); - - /** - * Create table 'design_change' - */ - $table = $connection->newTable( - $installer->getTable('design_change') - )->addColumn( - 'design_change_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['identity' => true, 'nullable' => false, 'primary' => true], - 'Design Change Id' - )->addColumn( - 'store_id', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - ['unsigned' => true, 'nullable' => false, 'default' => '0'], - 'Store Id' - )->addColumn( - 'design', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 255, - [], - 'Design' - )->addColumn( - 'date_from', - \Magento\Framework\DB\Ddl\Table::TYPE_DATE, - null, - [], - 'First Date of Design Activity' - )->addColumn( - 'date_to', - \Magento\Framework\DB\Ddl\Table::TYPE_DATE, - null, - [], - 'Last Date of Design Activity' - )->addIndex( - $installer->getIdxName('design_change', ['store_id']), - ['store_id'] - )->addForeignKey( - $installer->getFkName('design_change', 'store_id', 'store', 'store_id'), - 'store_id', - $installer->getTable('store'), - 'store_id', - \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE, - \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE - )->setComment( - 'Design Changes' - ); - $connection->createTable($table); - - /** - * Create table 'core_cache' - */ - $table = $connection->newTable( - $installer->getTable('core_cache') - )->addColumn( - 'id', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 200, - ['nullable' => false, 'primary' => true], - 'Cache Id' - )->addColumn( - 'data', - \Magento\Framework\DB\Ddl\Table::TYPE_BLOB, - '2M', - [], - 'Cache Data' - )->addColumn( - 'create_time', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - [], - 'Cache Creation Time' - )->addColumn( - 'update_time', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - [], - 'Time of Cache Updating' - )->addColumn( - 'expire_time', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - [], - 'Cache Expiration Time' - )->addIndex( - $installer->getIdxName('core_cache', ['expire_time']), - ['expire_time'] - )->setComment( - 'Caches' - ); - $connection->createTable($table); - - /** - * Create table 'core_cache_tag' - */ - $table = $connection->newTable( - $installer->getTable('core_cache_tag') - )->addColumn( - 'tag', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 100, - ['nullable' => false, 'primary' => true], - 'Tag' - )->addColumn( - 'cache_id', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 200, - ['nullable' => false, 'primary' => true], - 'Cache Id' - )->addIndex( - $installer->getIdxName('core_cache_tag', ['cache_id']), - ['cache_id'] - )->setComment( - 'Tag Caches' - ); - $connection->createTable($table); - - /** - * Create table 'core_flag' - */ - $table = $connection->newTable( - $installer->getTable('core_flag') - )->addColumn( - 'flag_id', - \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, - null, - ['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true], - 'Flag Id' - )->addColumn( - 'flag_code', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 255, - ['nullable' => false], - 'Flag Code' - )->addColumn( - 'state', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - ['unsigned' => true, 'nullable' => false, 'default' => '0'], - 'Flag State' - )->addColumn( - 'flag_data', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - '64k', - [], - 'Flag Data' - )->addColumn( - 'last_update', - \Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP, - null, - ['nullable' => false, 'default' => \Magento\Framework\DB\Ddl\Table::TIMESTAMP_INIT_UPDATE], - 'Date of Last Flag Update' - )->addIndex( - $installer->getIdxName('core_flag', ['last_update']), - ['last_update'] - )->setComment( - 'Flag' - ); - $connection->createTable($table); - - /** - * Drop Foreign Key on core_cache_tag.cache_id - */ - $connection->dropForeignKey( - $installer->getTable('core_cache_tag'), - $installer->getFkName('core_cache_tag', 'cache_id', 'core_cache', 'id') - ); - - $installer->endSetup(); - - } -} diff --git a/app/code/Magento/Core/Test/Unit/Controller/Index/NotFoundTest.php b/app/code/Magento/Core/Test/Unit/Controller/Index/NotFoundTest.php deleted file mode 100644 index e8ceda3d3a5bbed2558b98f823443f0e9201002e..0000000000000000000000000000000000000000 --- a/app/code/Magento/Core/Test/Unit/Controller/Index/NotFoundTest.php +++ /dev/null @@ -1,37 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Core\Test\Unit\Controller\Index; - -use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; - -class NotFoundTest extends \PHPUnit_Framework_TestCase -{ - public function testExecute() - { - /** - * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Framework\App\Response\Http - */ - $responseMock = $this->getMockBuilder('Magento\Framework\App\Response\Http') - ->disableOriginalConstructor() - ->getMock(); - - $responseMock->expects($this->once())->method('setStatusHeader')->with(404, '1.1', 'Not Found'); - $responseMock->expects($this->once())->method('setBody')->with('Requested resource not found'); - - $objectManager = new ObjectManager($this); - - /** - * @var \Magento\Core\Controller\Index\NotFound - */ - $controller = $objectManager->getObject( - 'Magento\Core\Controller\Index\NotFound', - ['response' => $responseMock] - ); - - // Make the call to test - $controller->execute(); - } -} diff --git a/app/code/Magento/Core/Test/Unit/Model/App/StateTest.php b/app/code/Magento/Core/Test/Unit/Model/App/StateTest.php deleted file mode 100644 index 70a30989405ff292ca66ed649979877b267d1c75..0000000000000000000000000000000000000000 --- a/app/code/Magento/Core/Test/Unit/Model/App/StateTest.php +++ /dev/null @@ -1,48 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Core\Test\Unit\Model\App; - -use Magento\Framework\App\State; - -class StateTest extends \PHPUnit_Framework_TestCase -{ - /** - * @param string $mode - * @dataProvider constructorDataProvider - */ - public function testConstructor($mode) - { - $model = new \Magento\Framework\App\State( - $this->getMockForAbstractClass('Magento\Framework\Config\ScopeInterface', [], '', false), - $mode - ); - $this->assertEquals($mode, $model->getMode()); - } - - /** - * @return array - */ - public static function constructorDataProvider() - { - return [ - 'default mode' => [\Magento\Framework\App\State::MODE_DEFAULT], - 'production mode' => [\Magento\Framework\App\State::MODE_PRODUCTION], - 'developer mode' => [\Magento\Framework\App\State::MODE_DEVELOPER] - ]; - } - - /** - * @expectedException \Exception - * @expectedExceptionMessage Unknown application mode: unknown mode - */ - public function testConstructorException() - { - new \Magento\Framework\App\State( - $this->getMockForAbstractClass('Magento\Framework\Config\ScopeInterface', [], '', false), - "unknown mode" - ); - } -} diff --git a/app/code/Magento/Core/Test/Unit/Model/EntryPoint/_files/config.xml b/app/code/Magento/Core/Test/Unit/Model/EntryPoint/_files/config.xml deleted file mode 100644 index b1c3bbd854f56ddf4ce0d12f797ecc123bfe0e45..0000000000000000000000000000000000000000 --- a/app/code/Magento/Core/Test/Unit/Model/EntryPoint/_files/config.xml +++ /dev/null @@ -1,16 +0,0 @@ -<?xml version="1.0"?> -<!-- -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ ---> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../../../app/code/Magento/Core/etc/config.xsd"> - <default> - <resources> - <fixture_module_setup> - <setup/> - </fixture_module_setup> - </resources> - </default> -</config> diff --git a/app/code/Magento/Core/Test/Unit/Model/Resource/SessionTest.php b/app/code/Magento/Core/Test/Unit/Model/Resource/SessionTest.php deleted file mode 100644 index 9e871c965e466f00111ec8a993d0a83e89972b5c..0000000000000000000000000000000000000000 --- a/app/code/Magento/Core/Test/Unit/Model/Resource/SessionTest.php +++ /dev/null @@ -1,267 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Core\Test\Unit\Model\Resource; - -class SessionTest extends \PHPUnit_Framework_TestCase -{ - /** - * Session table name - */ - const SESSION_TABLE = 'session_table_name'; - - /**#@+ - * Table column names - */ - const COLUMN_SESSION_ID = 'session_id'; - - const COLUMN_SESSION_DATA = 'session_data'; - - const COLUMN_SESSION_EXPIRES = 'session_expires'; - - /**#@-*/ - - /** - * Test select object - */ - const SELECT_OBJECT = 'select_object'; - - /**#@+ - * Test session data - */ - const SESSION_ID = 'custom_session_id'; - - const SESSION_DATA = 'custom_session_data'; - - /**#@-*/ - - /** - * Model under test - * - * @var \Magento\Framework\Session\SaveHandler\DbTable - */ - protected $_model; - - protected function tearDown() - { - unset($this->_model); - } - - /** - * Data provider for testRead - * - * @return array - */ - public function readDataProvider() - { - return [ - 'session_encoded' => ['$dataEncoded' => true], - 'session_not_encoded' => ['$dataEncoded' => false] - ]; - } - - /** - * @param bool $isDataEncoded - * - * @dataProvider readDataProvider - */ - public function testRead($isDataEncoded) - { - $this->_prepareMockForRead($isDataEncoded); - $result = $this->_model->read(self::SESSION_ID); - $this->assertEquals(self::SESSION_DATA, $result); - } - - /** - * Prepares mock for test model with specified connections - * - * @param \PHPUnit_Framework_MockObject_MockObject $connection - */ - protected function _prepareResourceMock($connection) - { - $resource = $this->getMock( - 'Magento\Framework\App\Resource', - [], - [], - '', - false, - false - ); - $resource->expects($this->once())->method('getTableName')->will($this->returnValue(self::SESSION_TABLE)); - $resource->expects($this->once())->method('getConnection')->will($this->returnValue($connection)); - - $this->_model = new \Magento\Framework\Session\SaveHandler\DbTable($resource); - } - - /** - * Prepare mocks for testRead - * - * @param bool $isDataEncoded - */ - protected function _prepareMockForRead($isDataEncoded) - { - $connection = $this->getMock( - 'Magento\Framework\DB\Adapter\Pdo\Mysql', - ['select', 'from', 'where', 'fetchOne', 'isTableExists'], - [], - '', - false - ); - $connection->expects($this->atLeastOnce())->method('isTableExists')->will($this->returnValue(true)); - $connection->expects($this->once())->method('select')->will($this->returnSelf()); - $connection->expects( - $this->once() - )->method( - 'from' - )->with( - self::SESSION_TABLE, - [self::COLUMN_SESSION_DATA] - )->will( - $this->returnSelf() - ); - $connection->expects( - $this->once() - )->method( - 'where' - )->with( - self::COLUMN_SESSION_ID . ' = :' . self::COLUMN_SESSION_ID - )->will( - $this->returnValue(self::SELECT_OBJECT) - ); - - $sessionData = self::SESSION_DATA; - if ($isDataEncoded) { - $sessionData = base64_encode($sessionData); - } - $connection->expects( - $this->once() - )->method( - 'fetchOne' - )->with( - self::SELECT_OBJECT, - [self::COLUMN_SESSION_ID => self::SESSION_ID] - )->will( - $this->returnValue($sessionData) - ); - - $this->_prepareResourceMock($connection); - } - - /** - * Data provider for testWrite - * - * @return array - */ - public function writeDataProvider() - { - return [ - 'session_exists' => ['$sessionExists' => true], - 'session_not_exists' => ['$sessionExists' => false] - ]; - } - - /** - * @param bool $sessionExists - * - * @dataProvider writeDataProvider - */ - public function testWrite($sessionExists) - { - $this->_prepareMockForWrite($sessionExists); - $this->assertTrue($this->_model->write(self::SESSION_ID, self::SESSION_DATA)); - } - - /** - * Prepare mocks for testWrite - * - * @param bool $sessionExists - */ - protected function _prepareMockForWrite($sessionExists) - { - $connection = $this->getMock( - 'Magento\Framework\DB\Adapter\Pdo\Mysql', - ['select', 'from', 'where', 'fetchOne', 'update', 'insert', 'isTableExists'], - [], - '', - false - ); - $connection->expects($this->atLeastOnce())->method('isTableExists')->will($this->returnValue(true)); - $connection->expects($this->once())->method('select')->will($this->returnSelf()); - $connection->expects($this->once())->method('from')->with(self::SESSION_TABLE)->will($this->returnSelf()); - $connection->expects( - $this->once() - )->method( - 'where' - )->with( - self::COLUMN_SESSION_ID . ' = :' . self::COLUMN_SESSION_ID - )->will( - $this->returnValue(self::SELECT_OBJECT) - ); - $connection->expects( - $this->once() - )->method( - 'fetchOne' - )->with( - self::SELECT_OBJECT, - [self::COLUMN_SESSION_ID => self::SESSION_ID] - )->will( - $this->returnValue($sessionExists) - ); - - if ($sessionExists) { - $connection->expects($this->never())->method('insert'); - $connection->expects( - $this->once() - )->method( - 'update' - )->will( - $this->returnCallback([$this, 'verifyUpdate']) - ); - } else { - $connection->expects( - $this->once() - )->method( - 'insert' - )->will( - $this->returnCallback([$this, 'verifyInsert']) - ); - $connection->expects($this->never())->method('update'); - } - - $this->_prepareResourceMock($connection); - } - - /** - * Verify arguments of insert method - * - * @param string $table - * @param array $bind - */ - public function verifyInsert($table, array $bind) - { - $this->assertEquals(self::SESSION_TABLE, $table); - - $this->assertInternalType('int', $bind[self::COLUMN_SESSION_EXPIRES]); - $this->assertEquals(base64_encode(self::SESSION_DATA), $bind[self::COLUMN_SESSION_DATA]); - $this->assertEquals(self::SESSION_ID, $bind[self::COLUMN_SESSION_ID]); - } - - /** - * Verify arguments of update method - * - * @param string $table - * @param array $bind - * @param array $where - */ - public function verifyUpdate($table, array $bind, array $where) - { - $this->assertEquals(self::SESSION_TABLE, $table); - - $this->assertInternalType('int', $bind[self::COLUMN_SESSION_EXPIRES]); - $this->assertEquals(base64_encode(self::SESSION_DATA), $bind[self::COLUMN_SESSION_DATA]); - - $this->assertEquals([self::COLUMN_SESSION_ID . '=?' => self::SESSION_ID], $where); - } -} diff --git a/app/code/Magento/Core/composer.json b/app/code/Magento/Core/composer.json deleted file mode 100644 index f32ffb2a52f0fb36d5621b638074afd2626acf2f..0000000000000000000000000000000000000000 --- a/app/code/Magento/Core/composer.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "name": "magento/module-core", - "description": "N/A", - "require": { - "php": "~5.5.0|~5.6.0", - "magento/module-authorization": "0.42.0-beta11", - "magento/module-store": "0.42.0-beta11", - "magento/framework": "0.42.0-beta11", - "lib-libxml": "*", - "magento/magento-composer-installer": "*" - }, - "type": "magento2-module", - "version": "0.42.0-beta11", - "license": [ - "OSL-3.0", - "AFL-3.0" - ], - "extra": { - "map": [ - [ - "*", - "Magento/Core" - ] - ] - } -} diff --git a/app/code/Magento/Core/etc/di.xml b/app/code/Magento/Core/etc/di.xml deleted file mode 100644 index 7c0da9d131ee661dffc057d94b4c413292dfd8c5..0000000000000000000000000000000000000000 --- a/app/code/Magento/Core/etc/di.xml +++ /dev/null @@ -1,55 +0,0 @@ -<?xml version="1.0"?> -<!-- -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ ---> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd"> - <type name="Magento\Framework\App\Config\Initial\SchemaLocator"> - <arguments> - <argument name="moduleName" xsi:type="string">Magento_Core</argument> - </arguments> - </type> - <type name="Magento\Framework\App\Router\Base"> - <arguments> - <argument name="routerId" xsi:type="string">standard</argument> - </arguments> - </type> - <type name="Magento\Framework\DB\Helper"> - <arguments> - <argument name="modulePrefix" xsi:type="string">core</argument> - </arguments> - </type> - <type name="Magento\Framework\Module\Setup\Migration"> - <arguments> - <argument name="confPathToMapFile" xsi:type="string">app/etc/aliases_to_classes_map.json</argument> - <argument name="resourceName" xsi:type="string">core_setup</argument> - <argument name="moduleName" xsi:type="string">Magento_Core</argument> - <argument name="connectionName" xsi:type="string">\Magento\Framework\Setup\ModuleDataResourceInterface::DEFAULT_SETUP_CONNECTION</argument> - </arguments> - </type> - <virtualType name="Magento\Core\Model\Session\Storage" type="Magento\Framework\Session\Storage"> - <arguments> - <argument name="namespace" xsi:type="string">core</argument> - </arguments> - </virtualType> - <type name="Magento\Framework\Session\Generic"> - <arguments> - <argument name="storage" xsi:type="object">Magento\Core\Model\Session\Storage</argument> - </arguments> - </type> - <type name="Magento\Framework\Stdlib\DateTime\Timezone"> - <arguments> - <argument name="defaultTimezonePath" xsi:type="const">Magento\Directory\Helper\Data::XML_PATH_DEFAULT_TIMEZONE</argument> - <argument name="scopeType" xsi:type="const">Magento\Store\Model\ScopeInterface::SCOPE_STORE</argument> - </arguments> - </type> - <type name="Magento\Framework\Locale\Resolver"> - <plugin name="initLocale" type="Magento\Framework\Translate\Locale\Resolver\Plugin" sortOrder="10"/> - <arguments> - <argument name="defaultLocalePath" xsi:type="const">Magento\Directory\Helper\Data::XML_PATH_DEFAULT_LOCALE</argument> - <argument name="scopeType" xsi:type="const">Magento\Store\Model\ScopeInterface::SCOPE_STORE</argument> - </arguments> - </type> -</config> diff --git a/app/code/Magento/Core/etc/frontend/di.xml b/app/code/Magento/Core/etc/frontend/di.xml deleted file mode 100644 index a86435f16a24a2380745cfe6fdb78b11c277768d..0000000000000000000000000000000000000000 --- a/app/code/Magento/Core/etc/frontend/di.xml +++ /dev/null @@ -1,12 +0,0 @@ -<?xml version="1.0"?> -<!-- -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ ---> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd"> - <type name="Magento\Framework\App\FrontController"> - <plugin name="requestPreprocessor" type="Magento\Store\App\FrontController\Plugin\RequestPreprocessor" sortOrder="50"/> - </type> -</config> diff --git a/app/code/Magento/Core/etc/frontend/routes.xml b/app/code/Magento/Core/etc/frontend/routes.xml deleted file mode 100644 index 6fbeceb9b8ede1d5932b14e330a7a0be8aaba488..0000000000000000000000000000000000000000 --- a/app/code/Magento/Core/etc/frontend/routes.xml +++ /dev/null @@ -1,14 +0,0 @@ -<?xml version="1.0"?> -<!-- -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ ---> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/App/etc/routes.xsd"> - <router id="standard"> - <route id="core" frontName="core"> - <module name="Magento_Core" /> - </route> - </router> -</config> \ No newline at end of file diff --git a/app/code/Magento/Core/etc/module.xml b/app/code/Magento/Core/etc/module.xml deleted file mode 100644 index 665171f5a6ad8f1f6fe9e10384cb1cfd0e2d9b8c..0000000000000000000000000000000000000000 --- a/app/code/Magento/Core/etc/module.xml +++ /dev/null @@ -1,11 +0,0 @@ -<?xml version="1.0"?> -<!-- -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ ---> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd"> - <module name="Magento_Core" setup_version="2.0.1"> - </module> -</config> diff --git a/app/code/Magento/Core/etc/resources.xml b/app/code/Magento/Core/etc/resources.xml deleted file mode 100644 index 067547b086c152f7b83474548961e1dbff9e3e75..0000000000000000000000000000000000000000 --- a/app/code/Magento/Core/etc/resources.xml +++ /dev/null @@ -1,10 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ ---> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/App/etc/resources.xsd"> - <resource name="core_setup" extends="default_setup" /> -</config> diff --git a/app/code/Magento/Core/i18n/de_DE.csv b/app/code/Magento/Core/i18n/de_DE.csv deleted file mode 100644 index 7299a44c88475bd6e9038603984d8f9f7ad3d47b..0000000000000000000000000000000000000000 --- a/app/code/Magento/Core/i18n/de_DE.csv +++ /dev/null @@ -1,42 +0,0 @@ -Configuration,Configuration -"-- Please Select --","-- Bitte auswählen --" -"Custom Variables","Angepasste Variablen" -"Requested resource not found","Requested resource not found" -"File %1 does not exist","File %1 does not exist" -"File %1 is not readable","File %1 is not readable" -"Invalid regular expression: ""%1"".","Invalid regular expression: ""%1""." -"database ""%1""","database ""%1""" -"Parent directory does not exist: %1","Parent directory does not exist: %1" -"File system",Dateisystem -"Unable to save file ""%1"" at ""%2""","Unable to save file ""%1"" at ""%2""" -"Wrong file info format","Falsches Format Dateiinfo" -"Path ""%value%"" is protected and cannot be used.","Der Pfad ""%value%"" ist geschützt und kann nicht verwendet werden." -"Path ""%value%"" is not available and cannot be used.","Der Pfad ""%value%"" ist nicht verfügbar und kann nicht verwendet werden." -"Path ""%value%"" may not include parent directory traversal (""../"", ""..\").","Der Pfad ""%value%"" darf keinen Verweis auf das übergeordnete Verzeichnis enthalten (""../"", ""..\")." -"Please set available and/or protected paths list(s) before validation.","Bitte stellen Sie vor der Bestätigung die Liste(n) der verfügbaren und/oder geschützten Pfade ein." -"File with an extension ""%value%"" is protected and cannot be uploaded","Dateien mit der Endung ""%value%"" sind geschützt und können nicht hochgeladen werden" -"Helper arguments should not be used in custom layout updates.","Helper arguments should not be used in custom layout updates." -"Updater model should not be used in custom layout updates.","Updater model should not be used in custom layout updates." -"Please correct the XML data and try again. %value%","Please correct the XML data and try again. %value%" -"Start date cannot be greater than end date.","Das Anfangsdatum darf nicht nach dem Enddatum liegen." -"Your design change for the specified store intersects with another one, please specify another date range.","Ihre Design-Änderung für den ausgewählten Store überschneidet sich mit einer anderen, bitte wählen Sie einen anderen Zeitraum." -"Unable to create directory: %1","Unable to create directory: %1" -"Unable to save file: %1","Unable to save file: %1" -Copy,Copy -"Theme isn't deletable.","Theme isn't deletable." -"Circular-reference in theme inheritance detected for ""%1""","Circular-reference in theme inheritance detected for ""%1""" -"Variable Code must be unique.","Variabler Code muß eindeutig sein." -"Validation has failed.","Prüfung fehlgeschlagen." -%1,%1 -"Insert Variable...","Insert Variable..." -"System(config.xml, local.xml) and modules configuration files(config.xml).","System(config.xml, local.xml) and modules configuration files(config.xml)." -Layouts,Layouts -"Layout building instructions.","Layout building instructions." -"Blocks HTML output","Blocks HTML output" -"Page blocks HTML.","Page blocks HTML." -"View files fallback","View files fallback" -"Paths to view files (e.g., PHTML templates, images, CSS, JS files).","Paths to view files (e.g., PHTML templates, images, CSS, JS files)." -"View files pre-processing","View files pre-processing" -"Paths to pre-processed view files (e.g, CSS files with fixed paths or generated from LESS files).","Paths to pre-processed view files (e.g, CSS files with fixed paths or generated from LESS files)." -"Collections Data","Collections Data" -"Collection data files.","Collection data files." diff --git a/app/code/Magento/Core/i18n/en_US.csv b/app/code/Magento/Core/i18n/en_US.csv deleted file mode 100644 index 1505afedfcd4b501b6b295521c78d29a73a86ea2..0000000000000000000000000000000000000000 --- a/app/code/Magento/Core/i18n/en_US.csv +++ /dev/null @@ -1,42 +0,0 @@ -Configuration,Configuration -"-- Please Select --","-- Please Select --" -"Custom Variables","Custom Variables" -"Requested resource not found","Requested resource not found" -"File %1 does not exist","File %1 does not exist" -"File %1 is not readable","File %1 is not readable" -"Invalid regular expression: ""%1"".","Invalid regular expression: ""%1""." -"database ""%1""","database ""%1""" -"Parent directory does not exist: %1","Parent directory does not exist: %1" -"File system","File system" -"Unable to save file ""%1"" at ""%2""","Unable to save file ""%1"" at ""%2""" -"Wrong file info format","Wrong file info format" -"Path ""%value%"" is protected and cannot be used.","Path ""%value%"" is protected and cannot be used." -"Path ""%value%"" is not available and cannot be used.","Path ""%value%"" is not available and cannot be used." -"Path ""%value%"" may not include parent directory traversal (""../"", ""..\").","Path ""%value%"" may not include parent directory traversal (""../"", ""..\")." -"Please set available and/or protected paths list(s) before validation.","Please set available and/or protected paths list(s) before validation." -"File with an extension ""%value%"" is protected and cannot be uploaded","File with an extension ""%value%"" is protected and cannot be uploaded" -"Helper arguments should not be used in custom layout updates.","Helper arguments should not be used in custom layout updates." -"Updater model should not be used in custom layout updates.","Updater model should not be used in custom layout updates." -"Please correct the XML data and try again. %value%","Please correct the XML data and try again. %value%" -"Start date cannot be greater than end date.","Start date cannot be greater than end date." -"Your design change for the specified store intersects with another one, please specify another date range.","Your design change for the specified store intersects with another one, please specify another date range." -"Unable to create directory: %1","Unable to create directory: %1" -"Unable to save file: %1","Unable to save file: %1" -Copy,Copy -"Theme isn't deletable.","Theme isn't deletable." -"Circular-reference in theme inheritance detected for ""%1""","Circular-reference in theme inheritance detected for ""%1""" -"Variable Code must be unique.","Variable Code must be unique." -"Validation has failed.","Validation has failed." -%1,%1 -"Insert Variable...","Insert Variable..." -"System(config.xml, local.xml) and modules configuration files(config.xml).","System(config.xml, local.xml) and modules configuration files(config.xml)." -Layouts,Layouts -"Layout building instructions.","Layout building instructions." -"Blocks HTML output","Blocks HTML output" -"Page blocks HTML.","Page blocks HTML." -"View files fallback","View files fallback" -"Paths to view files (e.g., PHTML templates, images, CSS, JS files).","Paths to view files (e.g., PHTML templates, images, CSS, JS files)." -"View files pre-processing","View files pre-processing" -"Paths to pre-processed view files (e.g, CSS files with fixed paths or generated from LESS files).","Paths to pre-processed view files (e.g, CSS files with fixed paths or generated from LESS files)." -"Collections Data","Collections Data" -"Collection data files.","Collection data files." diff --git a/app/code/Magento/Core/i18n/es_ES.csv b/app/code/Magento/Core/i18n/es_ES.csv deleted file mode 100644 index eb11b11e933fbe7ccd774b0c82482028a0eb4769..0000000000000000000000000000000000000000 --- a/app/code/Magento/Core/i18n/es_ES.csv +++ /dev/null @@ -1,42 +0,0 @@ -Configuration,Configuration -"-- Please Select --","-- Seleccionar, por favor --" -"Custom Variables","Variables personalizadas" -"Requested resource not found","Requested resource not found" -"File %1 does not exist","File %1 does not exist" -"File %1 is not readable","File %1 is not readable" -"Invalid regular expression: ""%1"".","Invalid regular expression: ""%1""." -"database ""%1""","database ""%1""" -"Parent directory does not exist: %1","Parent directory does not exist: %1" -"File system","Sistema de archivos" -"Unable to save file ""%1"" at ""%2""","Unable to save file ""%1"" at ""%2""" -"Wrong file info format","Formato de información del archivo incorrecto" -"Path ""%value%"" is protected and cannot be used.","La ruta ""%value%"" está protegida y no se puede utilizar." -"Path ""%value%"" is not available and cannot be used.","La ruta ""%value%"" no está disponible y no puede usarse." -"Path ""%value%"" may not include parent directory traversal (""../"", ""..\").","La ruta ""%value%"" no puede incluir accesos de ejecución transversal (""../"", ""..\")." -"Please set available and/or protected paths list(s) before validation.","Por favor, indique la(s) lista(s) de rutas disponibles y/o protegidas antes de la validación." -"File with an extension ""%value%"" is protected and cannot be uploaded","El archivo con extensión ""%value%"" está protegido y no se puede subir" -"Helper arguments should not be used in custom layout updates.","Helper arguments should not be used in custom layout updates." -"Updater model should not be used in custom layout updates.","Updater model should not be used in custom layout updates." -"Please correct the XML data and try again. %value%","Please correct the XML data and try again. %value%" -"Start date cannot be greater than end date.","La fecha de inicio no puede ser mayor que la de fin." -"Your design change for the specified store intersects with another one, please specify another date range.","Su cambio de diseño para la tienda especificada se superpone con otro. Especifique otro rango de fecha." -"Unable to create directory: %1","Unable to create directory: %1" -"Unable to save file: %1","Unable to save file: %1" -Copy,Copy -"Theme isn't deletable.","Theme isn't deletable." -"Circular-reference in theme inheritance detected for ""%1""","Circular-reference in theme inheritance detected for ""%1""" -"Variable Code must be unique.","El código de variable debe ser único." -"Validation has failed.","Falló la validación." -%1,%1 -"Insert Variable...","Insert Variable..." -"System(config.xml, local.xml) and modules configuration files(config.xml).","System(config.xml, local.xml) and modules configuration files(config.xml)." -Layouts,Layouts -"Layout building instructions.","Layout building instructions." -"Blocks HTML output","Blocks HTML output" -"Page blocks HTML.","Page blocks HTML." -"View files fallback","View files fallback" -"Paths to view files (e.g., PHTML templates, images, CSS, JS files).","Paths to view files (e.g., PHTML templates, images, CSS, JS files)." -"View files pre-processing","View files pre-processing" -"Paths to pre-processed view files (e.g, CSS files with fixed paths or generated from LESS files).","Paths to pre-processed view files (e.g, CSS files with fixed paths or generated from LESS files)." -"Collections Data","Collections Data" -"Collection data files.","Collection data files." diff --git a/app/code/Magento/Core/i18n/fr_FR.csv b/app/code/Magento/Core/i18n/fr_FR.csv deleted file mode 100644 index 7afba82f7fea613c31c1d5403e634c92e2354c19..0000000000000000000000000000000000000000 --- a/app/code/Magento/Core/i18n/fr_FR.csv +++ /dev/null @@ -1,42 +0,0 @@ -Configuration,Configuration -"-- Please Select --","-- Veuillez sélectionner --" -"Custom Variables","Variables sur mesure" -"Requested resource not found","Requested resource not found" -"File %1 does not exist","File %1 does not exist" -"File %1 is not readable","File %1 is not readable" -"Invalid regular expression: ""%1"".","Invalid regular expression: ""%1""." -"database ""%1""","database ""%1""" -"Parent directory does not exist: %1","Parent directory does not exist: %1" -"File system","Système de fichiers" -"Unable to save file ""%1"" at ""%2""","Unable to save file ""%1"" at ""%2""" -"Wrong file info format","Informations du format de fichiers incorrectes" -"Path ""%value%"" is protected and cannot be used.","Le chemin ""%value%"" est protégé et ne peut pas être utilisé." -"Path ""%value%"" is not available and cannot be used.","Le chemin ""%value%"" est indisponible et ne peut être utilisé." -"Path ""%value%"" may not include parent directory traversal (""../"", ""..\").","Il se peut que le chemin ""%value%"" ne contienne pas de traversée de répertoire parent (""../"", ""..\")." -"Please set available and/or protected paths list(s) before validation.","Veuillez définir la/les liste(s) de chemins disponibles et/ou protégés avant la validation." -"File with an extension ""%value%"" is protected and cannot be uploaded","Le fichier avec une ""%valeur%"" d'extension est protégé et ne peut être téléchargé." -"Helper arguments should not be used in custom layout updates.","Helper arguments should not be used in custom layout updates." -"Updater model should not be used in custom layout updates.","Updater model should not be used in custom layout updates." -"Please correct the XML data and try again. %value%","Please correct the XML data and try again. %value%" -"Start date cannot be greater than end date.","La date de début ne peut pas être après la date de fin." -"Your design change for the specified store intersects with another one, please specify another date range.","Votre changement de dessin pour la boutique spécifiée se mélange à une autre, veuillez spécifier une autre fourchette de dates." -"Unable to create directory: %1","Unable to create directory: %1" -"Unable to save file: %1","Unable to save file: %1" -Copy,Copy -"Theme isn't deletable.","Theme isn't deletable." -"Circular-reference in theme inheritance detected for ""%1""","Circular-reference in theme inheritance detected for ""%1""" -"Variable Code must be unique.","La variable code doit être unique." -"Validation has failed.","Validation a échouée" -%1,%1 -"Insert Variable...","Insert Variable..." -"System(config.xml, local.xml) and modules configuration files(config.xml).","System(config.xml, local.xml) and modules configuration files(config.xml)." -Layouts,Layouts -"Layout building instructions.","Layout building instructions." -"Blocks HTML output","Blocks HTML output" -"Page blocks HTML.","Page blocks HTML." -"View files fallback","View files fallback" -"Paths to view files (e.g., PHTML templates, images, CSS, JS files).","Paths to view files (e.g., PHTML templates, images, CSS, JS files)." -"View files pre-processing","View files pre-processing" -"Paths to pre-processed view files (e.g, CSS files with fixed paths or generated from LESS files).","Paths to pre-processed view files (e.g, CSS files with fixed paths or generated from LESS files)." -"Collections Data","Collections Data" -"Collection data files.","Collection data files." diff --git a/app/code/Magento/Core/i18n/nl_NL.csv b/app/code/Magento/Core/i18n/nl_NL.csv deleted file mode 100644 index 7b321e76f829245e6e1a05eed30ed0f7556590b4..0000000000000000000000000000000000000000 --- a/app/code/Magento/Core/i18n/nl_NL.csv +++ /dev/null @@ -1,42 +0,0 @@ -Configuration,Configuration -"-- Please Select --","-- Selecteer a.u.b.--" -"Custom Variables","Aangepaste variabelen" -"Requested resource not found","Requested resource not found" -"File %1 does not exist","File %1 does not exist" -"File %1 is not readable","File %1 is not readable" -"Invalid regular expression: ""%1"".","Invalid regular expression: ""%1""." -"database ""%1""","database ""%1""" -"Parent directory does not exist: %1","Parent directory does not exist: %1" -"File system",Bestandssysteem -"Unable to save file ""%1"" at ""%2""","Unable to save file ""%1"" at ""%2""" -"Wrong file info format","Verkeerde bestandsinformatiebestand" -"Path ""%value%"" is protected and cannot be used.","Pad ""%value%"" is beschermd en kan niet worden gebruikt." -"Path ""%value%"" is not available and cannot be used.","Pad ""%value%"" is niet beschikbaar en kan niet gebruikt worden." -"Path ""%value%"" may not include parent directory traversal (""../"", ""..\").","Pad ""%value%"" mag geen parent directory traversal bevatten (""../"", ""..\")." -"Please set available and/or protected paths list(s) before validation.","Stel beschikbare en/of beschermde pad lijst(en) in voor validatie." -"File with an extension ""%value%"" is protected and cannot be uploaded","Bestand met de uitgang ""%value%"" is beschermd en kan niet worden geüpload." -"Helper arguments should not be used in custom layout updates.","Helper arguments should not be used in custom layout updates." -"Updater model should not be used in custom layout updates.","Updater model should not be used in custom layout updates." -"Please correct the XML data and try again. %value%","Please correct the XML data and try again. %value%" -"Start date cannot be greater than end date.","Begin datum kan niet later zijn dan eind datum." -"Your design change for the specified store intersects with another one, please specify another date range.","Uw ontwerp verandering voor de gespecificeerde store komt in conflict met een andere, specificeer a.u.b. een andere datumrange." -"Unable to create directory: %1","Unable to create directory: %1" -"Unable to save file: %1","Unable to save file: %1" -Copy,Copy -"Theme isn't deletable.","Theme isn't deletable." -"Circular-reference in theme inheritance detected for ""%1""","Circular-reference in theme inheritance detected for ""%1""" -"Variable Code must be unique.","Variabele Code moet uniek zijn." -"Validation has failed.","Validatie is mislukt." -%1,%1 -"Insert Variable...","Insert Variable..." -"System(config.xml, local.xml) and modules configuration files(config.xml).","System(config.xml, local.xml) and modules configuration files(config.xml)." -Layouts,Layouts -"Layout building instructions.","Layout building instructions." -"Blocks HTML output","Blocks HTML output" -"Page blocks HTML.","Page blocks HTML." -"View files fallback","View files fallback" -"Paths to view files (e.g., PHTML templates, images, CSS, JS files).","Paths to view files (e.g., PHTML templates, images, CSS, JS files)." -"View files pre-processing","View files pre-processing" -"Paths to pre-processed view files (e.g, CSS files with fixed paths or generated from LESS files).","Paths to pre-processed view files (e.g, CSS files with fixed paths or generated from LESS files)." -"Collections Data","Collections Data" -"Collection data files.","Collection data files." diff --git a/app/code/Magento/Core/i18n/pt_BR.csv b/app/code/Magento/Core/i18n/pt_BR.csv deleted file mode 100644 index cd8f160c2165c578e9847a6224bb5da8a0699c35..0000000000000000000000000000000000000000 --- a/app/code/Magento/Core/i18n/pt_BR.csv +++ /dev/null @@ -1,42 +0,0 @@ -Configuration,Configuration -"-- Please Select --","- Por Favor Selecione -" -"Custom Variables","Variáveis de Personalização." -"Requested resource not found","Requested resource not found" -"File %1 does not exist","File %1 does not exist" -"File %1 is not readable","File %1 is not readable" -"Invalid regular expression: ""%1"".","Invalid regular expression: ""%1""." -"database ""%1""","database ""%1""" -"Parent directory does not exist: %1","Parent directory does not exist: %1" -"File system","Sistema de arquivo" -"Unable to save file ""%1"" at ""%2""","Unable to save file ""%1"" at ""%2""" -"Wrong file info format","Formato de arquivo de informação errado" -"Path ""%value%"" is protected and cannot be used.","Caminho ""%valor%"" é protegido e não pode ser usado." -"Path ""%value%"" is not available and cannot be used.","Caminho ""%valor%"" não está disponÃvel e não pode ser usado." -"Path ""%value%"" may not include parent directory traversal (""../"", ""..\").","Caminho ""%valor%"" não pode incluir passagem pelo diretório principal (""../"", ""..\")." -"Please set available and/or protected paths list(s) before validation.","Por favor defina lista(s) de caminhos disponÃveis e/ou protegidos antes da validação." -"File with an extension ""%value%"" is protected and cannot be uploaded","O arquivo de extensão ""%value%"" está protegido, e seu upload não pode ser feito" -"Helper arguments should not be used in custom layout updates.","Helper arguments should not be used in custom layout updates." -"Updater model should not be used in custom layout updates.","Updater model should not be used in custom layout updates." -"Please correct the XML data and try again. %value%","Please correct the XML data and try again. %value%" -"Start date cannot be greater than end date.","Data de inÃcio não pode ser maior que a data do término." -"Your design change for the specified store intersects with another one, please specify another date range.","Sua mudança de design para a loja especificada cruza com outra, por favor especifique outro intervalo de datas." -"Unable to create directory: %1","Unable to create directory: %1" -"Unable to save file: %1","Unable to save file: %1" -Copy,Copy -"Theme isn't deletable.","Theme isn't deletable." -"Circular-reference in theme inheritance detected for ""%1""","Circular-reference in theme inheritance detected for ""%1""" -"Variable Code must be unique.","Código da Variável deve ser único." -"Validation has failed.","Validação falhou." -%1,%1 -"Insert Variable...","Insert Variable..." -"System(config.xml, local.xml) and modules configuration files(config.xml).","System(config.xml, local.xml) and modules configuration files(config.xml)." -Layouts,Layouts -"Layout building instructions.","Layout building instructions." -"Blocks HTML output","Blocks HTML output" -"Page blocks HTML.","Page blocks HTML." -"View files fallback","View files fallback" -"Paths to view files (e.g., PHTML templates, images, CSS, JS files).","Paths to view files (e.g., PHTML templates, images, CSS, JS files)." -"View files pre-processing","View files pre-processing" -"Paths to pre-processed view files (e.g, CSS files with fixed paths or generated from LESS files).","Paths to pre-processed view files (e.g, CSS files with fixed paths or generated from LESS files)." -"Collections Data","Collections Data" -"Collection data files.","Collection data files." diff --git a/app/code/Magento/Core/i18n/zh_CN.csv b/app/code/Magento/Core/i18n/zh_CN.csv deleted file mode 100644 index b1066712eddd06607c3442aee3372575c4efc924..0000000000000000000000000000000000000000 --- a/app/code/Magento/Core/i18n/zh_CN.csv +++ /dev/null @@ -1,42 +0,0 @@ -Configuration,Configuration -"-- Please Select --","-- 请选择 --" -"Custom Variables",自定义å˜é‡ -"Requested resource not found","Requested resource not found" -"File %1 does not exist","File %1 does not exist" -"File %1 is not readable","File %1 is not readable" -"Invalid regular expression: ""%1"".","Invalid regular expression: ""%1""." -"database ""%1""","database ""%1""" -"Parent directory does not exist: %1","Parent directory does not exist: %1" -"File system",文件系统 -"Unable to save file ""%1"" at ""%2""","Unable to save file ""%1"" at ""%2""" -"Wrong file info format",é”™è¯¯çš„æ–‡ä»¶ä¿¡æ¯æ ¼å¼ -"Path ""%value%"" is protected and cannot be used.","路径 ""%value%"" å—ä¿æŠ¤ï¼Œæ— æ³•ä½¿ç”¨ã€‚" -"Path ""%value%"" is not available and cannot be used.","路径 ""%value%"" ä¸å¯ç”¨ï¼Œå› æ¤æ— 法使用。" -"Path ""%value%"" may not include parent directory traversal (""../"", ""..\").","路径 ""%value%"" å¯èƒ½ä¸åŒ…å«çˆ¶ç›®å½•é历 (""../"", ""..\")." -"Please set available and/or protected paths list(s) before validation.",请设置有效并/或å—ä¿æŠ¤çš„è·¯å¾„åˆ—è¡¨ï¼ŒéšåŽå†éªŒè¯ã€‚ -"File with an extension ""%value%"" is protected and cannot be uploaded","扩展为 ""%value%"" 的文件å—åˆ°ä¿æŠ¤ï¼Œæ— æ³•ä¸Šä¼ " -"Helper arguments should not be used in custom layout updates.","Helper arguments should not be used in custom layout updates." -"Updater model should not be used in custom layout updates.","Updater model should not be used in custom layout updates." -"Please correct the XML data and try again. %value%","Please correct the XML data and try again. %value%" -"Start date cannot be greater than end date.",开始日期ä¸èƒ½å¤§äºŽç»“æŸæ—¥æœŸã€‚ -"Your design change for the specified store intersects with another one, please specify another date range.",您对指定商店设计的更改和å¦ä¸€ä¸ªæœ‰äº¤å‰ï¼Œè¯·é‡æ–°æŒ‡å®šæ—¥æœŸèŒƒå›´ã€‚ -"Unable to create directory: %1","Unable to create directory: %1" -"Unable to save file: %1","Unable to save file: %1" -Copy,Copy -"Theme isn't deletable.","Theme isn't deletable." -"Circular-reference in theme inheritance detected for ""%1""","Circular-reference in theme inheritance detected for ""%1""" -"Variable Code must be unique.",å˜é‡ä»£ç 必须是唯一的。 -"Validation has failed.",验è¯å¤±è´¥ã€‚ -%1,%1 -"Insert Variable...","Insert Variable..." -"System(config.xml, local.xml) and modules configuration files(config.xml).","System(config.xml, local.xml) and modules configuration files(config.xml)." -Layouts,Layouts -"Layout building instructions.","Layout building instructions." -"Blocks HTML output","Blocks HTML output" -"Page blocks HTML.","Page blocks HTML." -"View files fallback","View files fallback" -"Paths to view files (e.g., PHTML templates, images, CSS, JS files).","Paths to view files (e.g., PHTML templates, images, CSS, JS files)." -"View files pre-processing","View files pre-processing" -"Paths to pre-processed view files (e.g, CSS files with fixed paths or generated from LESS files).","Paths to pre-processed view files (e.g, CSS files with fixed paths or generated from LESS files)." -"Collections Data","Collections Data" -"Collection data files.","Collection data files." diff --git a/app/code/Magento/Customer/Api/Data/AddressInterface.php b/app/code/Magento/Customer/Api/Data/AddressInterface.php index f1180ce71bb59440c7e10b08c0d848d903449ab4..d4828f5abc8e67580ca9abcfb338bffb8b172cdf 100644 --- a/app/code/Magento/Customer/Api/Data/AddressInterface.php +++ b/app/code/Magento/Customer/Api/Data/AddressInterface.php @@ -7,12 +7,10 @@ namespace Magento\Customer\Api\Data; -use Magento\Framework\Api\ExtensibleDataInterface; - /** * Customer address interface. */ -interface AddressInterface extends ExtensibleDataInterface +interface AddressInterface extends \Magento\Framework\Api\CustomAttributesDataInterface { /**#@+ * Constants for keys of data array. Identical to the name of the getter in snake case @@ -306,4 +304,19 @@ interface AddressInterface extends ExtensibleDataInterface * @return $this */ public function setIsDefaultBilling($isDefaultBilling); + + /** + * Retrieve existing extension attributes object or create a new one. + * + * @return \Magento\Customer\Api\Data\AddressExtensionInterface|null + */ + public function getExtensionAttributes(); + + /** + * Set an extension attributes object. + * + * @param \Magento\Customer\Api\Data\AddressExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes(\Magento\Customer\Api\Data\AddressExtensionInterface $extensionAttributes); } diff --git a/app/code/Magento/Customer/Api/Data/AttributeMetadataInterface.php b/app/code/Magento/Customer/Api/Data/AttributeMetadataInterface.php index 5db373c70a3ca8c662c0243ebe154209a553ad2b..d5af12db20d6176e3621b0b155eb083f704b0bba 100644 --- a/app/code/Magento/Customer/Api/Data/AttributeMetadataInterface.php +++ b/app/code/Magento/Customer/Api/Data/AttributeMetadataInterface.php @@ -9,7 +9,7 @@ namespace Magento\Customer\Api\Data; /** * Customer attribute metadata interface. */ -interface AttributeMetadataInterface +interface AttributeMetadataInterface extends \Magento\Framework\Api\MetadataObjectInterface { /**#@+ * Constants used as keys of data array @@ -33,21 +33,6 @@ interface AttributeMetadataInterface const BACKEND_TYPE = 'backend_type'; /**#@-*/ - /** - * Retrieve code of the attribute. - * - * @return string - */ - public function getAttributeCode(); - - /** - * Set attribute code - * - * @param string $attributeCode - * @return $this - */ - public function setAttributeCode($attributeCode); - /** * Frontend HTML for input element. * diff --git a/app/code/Magento/Customer/Api/Data/CustomerInterface.php b/app/code/Magento/Customer/Api/Data/CustomerInterface.php index a5b781439ae1b600a7e0495f35667be9d38a3031..78be9d556014ac871eff29a9053153033690a736 100644 --- a/app/code/Magento/Customer/Api/Data/CustomerInterface.php +++ b/app/code/Magento/Customer/Api/Data/CustomerInterface.php @@ -5,12 +5,10 @@ */ namespace Magento\Customer\Api\Data; -use Magento\Framework\Api\ExtensibleDataInterface; - /** * Customer interface. */ -interface CustomerInterface extends ExtensibleDataInterface +interface CustomerInterface extends \Magento\Framework\Api\CustomAttributesDataInterface { /**#@+ * Constants defined for keys of the data array. Identical to the name of the getter in snake case @@ -320,4 +318,19 @@ interface CustomerInterface extends ExtensibleDataInterface * @return $this */ public function setAddresses(array $addresses = null); + + /** + * Retrieve existing extension attributes object or create a new one. + * + * @return \Magento\Customer\Api\Data\CustomerExtensionInterface|null + */ + public function getExtensionAttributes(); + + /** + * Set an extension attributes object. + * + * @param \Magento\Customer\Api\Data\CustomerExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes(\Magento\Customer\Api\Data\CustomerExtensionInterface $extensionAttributes); } diff --git a/app/code/Magento/Customer/Api/Data/GroupInterface.php b/app/code/Magento/Customer/Api/Data/GroupInterface.php index 9062e8f4732de593e20ccb813c333772e76b65a5..7bb583d433a33e3ad16129038c9c03d7abf95cb9 100644 --- a/app/code/Magento/Customer/Api/Data/GroupInterface.php +++ b/app/code/Magento/Customer/Api/Data/GroupInterface.php @@ -85,4 +85,19 @@ interface GroupInterface extends ExtensibleDataInterface * @return string|null */ public function setTaxClassName($taxClassName); + + /** + * Retrieve existing extension attributes object or create a new one. + * + * @return \Magento\Customer\Api\Data\GroupExtensionInterface|null + */ + public function getExtensionAttributes(); + + /** + * Set an extension attributes object. + * + * @param \Magento\Customer\Api\Data\GroupExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes(\Magento\Customer\Api\Data\GroupExtensionInterface $extensionAttributes); } diff --git a/app/code/Magento/Customer/Api/Data/RegionInterface.php b/app/code/Magento/Customer/Api/Data/RegionInterface.php index 2d698fefc473039ce85c4990262d074bee0a1c28..808274c02f051b2decca7e39a2f7d0b614ca22a6 100644 --- a/app/code/Magento/Customer/Api/Data/RegionInterface.php +++ b/app/code/Magento/Customer/Api/Data/RegionInterface.php @@ -65,4 +65,19 @@ interface RegionInterface extends ExtensibleDataInterface * @return $this */ public function setRegionId($regionId); + + /** + * Retrieve existing extension attributes object or create a new one. + * + * @return \Magento\Customer\Api\Data\RegionExtensionInterface|null + */ + public function getExtensionAttributes(); + + /** + * Set an extension attributes object. + * + * @param \Magento\Customer\Api\Data\RegionExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes(\Magento\Customer\Api\Data\RegionExtensionInterface $extensionAttributes); } diff --git a/app/code/Magento/Customer/Block/Account/Dashboard/Info.php b/app/code/Magento/Customer/Block/Account/Dashboard/Info.php index 26cf7b0f6fc2b278202b2246d015009100b2abde..8244f9f253ab3e92ed44cea29e148835c702ff79 100644 --- a/app/code/Magento/Customer/Block/Account/Dashboard/Info.php +++ b/app/code/Magento/Customer/Block/Account/Dashboard/Info.php @@ -84,7 +84,7 @@ class Info extends \Magento\Framework\View\Element\Template */ public function getChangePasswordUrl() { - return $this->_urlBuilder->getUrl('*/account/edit/changepass/1'); + return $this->_urlBuilder->getUrl('customer/account/edit/changepass/1'); } /** @@ -133,4 +133,12 @@ class Info extends \Magento\Framework\View\Element\Template { return $this->_subscriberFactory->create(); } + + /** + * @return string + */ + protected function _toHtml() + { + return $this->currentCustomer->getCustomerId() ? parent::_toHtml() : ''; + } } diff --git a/app/code/Magento/Customer/Block/Account/Link.php b/app/code/Magento/Customer/Block/Account/Link.php index e6d3898b4836b2eca372b850665ef4b682cabc96..ae7f7b6831bdc099efa3fc377bee629bb989163e 100644 --- a/app/code/Magento/Customer/Block/Account/Link.php +++ b/app/code/Magento/Customer/Block/Account/Link.php @@ -29,7 +29,6 @@ class Link extends \Magento\Framework\View\Element\Html\Link ) { $this->_customerUrl = $customerUrl; parent::__construct($context, $data); - $this->_isScopePrivate = true; } /** diff --git a/app/code/Magento/Customer/Block/Account/RegisterLink.php b/app/code/Magento/Customer/Block/Account/RegisterLink.php index a286b05fb17d8f2395f65f0d2825242f184b1b4d..a9496c3c4784c4f1f5434680a93b2c990d18099c 100644 --- a/app/code/Magento/Customer/Block/Account/RegisterLink.php +++ b/app/code/Magento/Customer/Block/Account/RegisterLink.php @@ -49,7 +49,6 @@ class RegisterLink extends \Magento\Framework\View\Element\Html\Link $this->httpContext = $httpContext; $this->_registration = $registration; $this->_customerUrl = $customerUrl; - $this->_isScopePrivate = true; } /** diff --git a/app/code/Magento/Customer/Block/Address/Renderer/DefaultRenderer.php b/app/code/Magento/Customer/Block/Address/Renderer/DefaultRenderer.php index eff04d6e3d725842551df57e3d37b86db0a0bff1..1db7f1964955a8e524eba4c4125aefb9beae7e33 100644 --- a/app/code/Magento/Customer/Block/Address/Renderer/DefaultRenderer.php +++ b/app/code/Magento/Customer/Block/Address/Renderer/DefaultRenderer.php @@ -47,7 +47,7 @@ class DefaultRenderer extends AbstractBlock implements RendererInterface * * @param \Magento\Framework\View\Element\Context $context * @param ElementFactory $elementFactory - * @param \Magento\Directory\Model\CountryFactory $countryFactory , + * @param \Magento\Directory\Model\CountryFactory $countryFactory * @param \Magento\Customer\Api\AddressMetadataInterface $metadataService * @param Mapper $addressMapper * @param array $data diff --git a/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/View/PersonalInfo.php b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/View/PersonalInfo.php index 7520b9d412947e3b731941d1b43f31547d8c3096..dfd4fcce3fd7b34aad809a63f249975896741d9a 100644 --- a/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/View/PersonalInfo.php +++ b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/View/PersonalInfo.php @@ -7,43 +7,76 @@ namespace Magento\Customer\Block\Adminhtml\Edit\Tab\View; use Magento\Customer\Api\AccountManagementInterface; use Magento\Customer\Controller\RegistryConstants; -use Magento\Customer\Model\AccountManagement; use Magento\Customer\Model\Address\Mapper; use Magento\Framework\Exception\NoSuchEntityException; use Magento\Framework\Stdlib\DateTime\TimezoneInterface; /** - * Adminhtml customer view personal information sales block + * Adminhtml customer view personal information sales block. + * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class PersonalInfo extends \Magento\Backend\Block\Template { /** + * Interval in minutes that shows how long customer will be marked 'Online' + * since his last activity. Used only if it's impossible to get such setting + * from configuration. + */ + const DEFAULT_ONLINE_MINUTES_INTERVAL = 15; + + /** + * Customer + * * @var \Magento\Customer\Api\Data\CustomerInterface */ protected $customer; /** + * Customer log + * + * @var \Magento\Customer\Model\Log + */ + protected $customerLog; + + /** + * Customer logger + * + * @var \Magento\Customer\Model\Logger + */ + protected $customerLogger; + + /** + * Account management + * * @var AccountManagementInterface */ protected $accountManagement; /** + * Customer group repository + * * @var \Magento\Customer\Api\GroupRepositoryInterface */ protected $groupRepository; /** + * Customer data factory + * * @var \Magento\Customer\Api\Data\CustomerInterfaceFactory */ protected $customerDataFactory; /** + * Address helper + * * @var \Magento\Customer\Helper\Address */ protected $addressHelper; /** + * Date time + * * @var \Magento\Framework\Stdlib\DateTime */ protected $dateTime; @@ -56,11 +89,15 @@ class PersonalInfo extends \Magento\Backend\Block\Template protected $coreRegistry; /** + * Address mapper + * * @var Mapper */ protected $addressMapper; /** + * Data object helper + * * @var \Magento\Framework\Api\DataObjectHelper */ protected $dataObjectHelper; @@ -75,6 +112,7 @@ class PersonalInfo extends \Magento\Backend\Block\Template * @param \Magento\Framework\Registry $registry * @param Mapper $addressMapper * @param \Magento\Framework\Api\DataObjectHelper $dataObjectHelper + * @param \Magento\Customer\Model\Logger $customerLogger * @param array $data * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ @@ -88,6 +126,7 @@ class PersonalInfo extends \Magento\Backend\Block\Template \Magento\Framework\Registry $registry, Mapper $addressMapper, \Magento\Framework\Api\DataObjectHelper $dataObjectHelper, + \Magento\Customer\Model\Logger $customerLogger, array $data = [] ) { $this->coreRegistry = $registry; @@ -98,10 +137,14 @@ class PersonalInfo extends \Magento\Backend\Block\Template $this->dateTime = $dateTime; $this->addressMapper = $addressMapper; $this->dataObjectHelper = $dataObjectHelper; + $this->customerLogger = $customerLogger; + parent::__construct($context, $data); } /** + * Retrieve customer object + * * @return \Magento\Customer\Api\Data\CustomerInterface */ public function getCustomer() @@ -118,6 +161,8 @@ class PersonalInfo extends \Magento\Backend\Block\Template } /** + * Retrieve customer id + * * @return string|null */ public function getCustomerId() @@ -125,6 +170,22 @@ class PersonalInfo extends \Magento\Backend\Block\Template return $this->coreRegistry->registry(RegistryConstants::CURRENT_CUSTOMER_ID); } + /** + * Retrieves customer log model + * + * @return \Magento\Customer\Model\Log + */ + protected function getCustomerLog() + { + if (!$this->customerLog) { + $this->customerLog = $this->customerLogger->get( + $this->getCustomer()->getId() + ); + } + + return $this->customerLog; + } + /** * Returns customer's created date in the assigned store * @@ -143,6 +204,8 @@ class PersonalInfo extends \Magento\Backend\Block\Template } /** + * Retrieve store default timezone from configuration + * * @return string */ public function getStoreCreateDateTimezone() @@ -169,6 +232,8 @@ class PersonalInfo extends \Magento\Backend\Block\Template } /** + * Check if account is confirmed + * * @return \Magento\Framework\Phrase */ public function getIsConfirmedStatus() @@ -186,6 +251,8 @@ class PersonalInfo extends \Magento\Backend\Block\Template } /** + * Retrieve store + * * @return null|string */ public function getCreatedInStore() @@ -196,6 +263,8 @@ class PersonalInfo extends \Magento\Backend\Block\Template } /** + * Retrieve billing address html + * * @return \Magento\Framework\Phrase|string */ public function getBillingAddressHtml() @@ -218,6 +287,8 @@ class PersonalInfo extends \Magento\Backend\Block\Template } /** + * Retrieve group name + * * @return string|null */ public function getGroupName() @@ -233,6 +304,8 @@ class PersonalInfo extends \Magento\Backend\Block\Template } /** + * Retrieve customer group by id + * * @param int $groupId * @return \Magento\Customer\Api\Data\GroupInterface|null */ @@ -245,4 +318,106 @@ class PersonalInfo extends \Magento\Backend\Block\Template } return $group; } + + /** + * Returns timezone of the store to which customer assigned. + * + * @return string + */ + public function getStoreLastLoginDateTimezone() + { + return $this->_scopeConfig->getValue( + $this->_localeDate->getDefaultTimezonePath(), + \Magento\Store\Model\ScopeInterface::SCOPE_STORE, + $this->getCustomer()->getStoreId() + ); + } + + /** + * Get customer's current status. + * + * Customer considered 'Offline' in the next cases: + * + * - customer has never been logged in; + * - customer clicked 'Log Out' link\button; + * - predefined interval has passed since customer's last activity. + * + * In all other cases customer considered 'Online'. + * + * @return \Magento\Framework\Phrase + */ + public function getCurrentStatus() + { + $lastLoginTime = $this->getCustomerLog()->getLastLoginAt(); + + // Customer has never been logged in. + if (!$lastLoginTime) { + return __('Offline'); + } + + $lastLogoutTime = $this->getCustomerLog()->getLastLogoutAt(); + + // Customer clicked 'Log Out' link\button. + if ($lastLogoutTime && strtotime($lastLogoutTime) > strtotime($lastLoginTime)) { + return __('Offline'); + } + + // Predefined interval has passed since customer's last activity. + $interval = $this->getOnlineMinutesInterval(); + $currentTimestamp = (new \DateTime())->getTimestamp(); + $lastVisitTime = $this->getCustomerLog()->getLastVisitAt(); + + if ($lastVisitTime && $currentTimestamp - strtotime($lastVisitTime) > $interval * 60) { + return __('Offline'); + } + + return __('Online'); + } + + /** + * Get customer last login date. + * + * @return \Magento\Framework\Phrase|string + */ + public function getLastLoginDate() + { + $date = $this->getCustomerLog()->getLastLoginAt(); + + if ($date) { + return $this->formatDate($date, \IntlDateFormatter::MEDIUM, true); + } + + return __('Never'); + } + + /** + * Returns customer last login date in store's timezone. + * + * @return \Magento\Framework\Phrase|string + */ + public function getStoreLastLoginDate() + { + $date = strtotime($this->getCustomerLog()->getLastLoginAt()); + + if ($date) { + $date = $this->_localeDate->scopeDate($this->getCustomer()->getStoreId(), $date, true); + return $this->formatDate($date, \IntlDateFormatter::MEDIUM, true); + } + + return __('Never'); + } + + /** + * Returns interval that shows how long customer will be considered 'Online'. + * + * @return int Interval in minutes + */ + protected function getOnlineMinutesInterval() + { + $configValue = $this->_scopeConfig->getValue( + 'customer/online_customers/online_minutes_interval', + \Magento\Store\Model\ScopeInterface::SCOPE_STORE + ); + return intval($configValue) > 0 ? intval($configValue) : self::DEFAULT_ONLINE_MINUTES_INTERVAL; + } } diff --git a/app/code/Magento/Customer/Block/Form/Login.php b/app/code/Magento/Customer/Block/Form/Login.php index cd10974d943c75e37b5659be9e51a95ec6be6d87..256b49c9e931d19ce47957bccc1320830f19764e 100644 --- a/app/code/Magento/Customer/Block/Form/Login.php +++ b/app/code/Magento/Customer/Block/Form/Login.php @@ -27,53 +27,22 @@ class Login extends \Magento\Framework\View\Element\Template */ protected $_customerUrl; - /** - * Checkout data - * - * @var \Magento\Checkout\Helper\Data - */ - protected $checkoutData; - - /** - * Core url - * - * @var \Magento\Framework\Url\Helper\Data - */ - protected $coreUrl; - - /** - * Registration - * - * @var \Magento\Customer\Model\Registration - */ - protected $registration; - /** * @param \Magento\Framework\View\Element\Template\Context $context - * @param \Magento\Customer\Model\Registration $registration * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Customer\Model\Url $customerUrl - * @param \Magento\Checkout\Helper\Data $checkoutData - * @param \Magento\Framework\Url\Helper\Data $coreUrl * @param array $data */ public function __construct( \Magento\Framework\View\Element\Template\Context $context, - \Magento\Customer\Model\Registration $registration, \Magento\Customer\Model\Session $customerSession, \Magento\Customer\Model\Url $customerUrl, - \Magento\Checkout\Helper\Data $checkoutData, - \Magento\Framework\Url\Helper\Data $coreUrl, array $data = [] ) { - $this->registration = $registration; - $this->_customerUrl = $customerUrl; - $this->_customerSession = $customerSession; - $this->checkoutData = $checkoutData; - $this->coreUrl = $coreUrl; - parent::__construct($context, $data); $this->_isScopePrivate = true; + $this->_customerUrl = $customerUrl; + $this->_customerSession = $customerSession; } /** @@ -85,16 +54,6 @@ class Login extends \Magento\Framework\View\Element\Template return parent::_prepareLayout(); } - /** - * Return registration - * - * @return \Magento\Customer\Model\Registration - */ - public function getRegistration() - { - return $this->registration; - } - /** * Retrieve form posting url * @@ -105,23 +64,6 @@ class Login extends \Magento\Framework\View\Element\Template return $this->_customerUrl->getLoginPostUrl(); } - /** - * Retrieve create new account url - * - * @return string - */ - public function getCreateAccountUrl() - { - $url = $this->getData('create_account_url'); - if (is_null($url)) { - $url = $this->_customerUrl->getRegisterUrl(); - } - if ($this->checkoutData->isContextCheckout()) { - $url = $this->coreUrl->addRequestParam($url, ['context' => 'checkout']); - } - return $url; - } - /** * Retrieve password forgotten url * diff --git a/app/code/Magento/Customer/Block/Form/Login/Info.php b/app/code/Magento/Customer/Block/Form/Login/Info.php new file mode 100644 index 0000000000000000000000000000000000000000..1cfb3afac43663e0c0caabdc06a8c6450ff6480c --- /dev/null +++ b/app/code/Magento/Customer/Block/Form/Login/Info.php @@ -0,0 +1,88 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Customer\Block\Form\Login; + +/** + * Customer login info block + */ +class Info extends \Magento\Framework\View\Element\Template +{ + /** + * @var \Magento\Customer\Model\Url + */ + protected $_customerUrl; + + /** + * Checkout data + * + * @var \Magento\Checkout\Helper\Data + */ + protected $checkoutData; + + /** + * Core url + * + * @var \Magento\Framework\Url\Helper\Data + */ + protected $coreUrl; + + /** + * Registration + * + * @var \Magento\Customer\Model\Registration + */ + protected $registration; + + /** + * @param \Magento\Framework\View\Element\Template\Context $context + * @param \Magento\Customer\Model\Registration $registration + * @param \Magento\Customer\Model\Url $customerUrl + * @param \Magento\Checkout\Helper\Data $checkoutData + * @param \Magento\Framework\Url\Helper\Data $coreUrl + * @param array $data + */ + public function __construct( + \Magento\Framework\View\Element\Template\Context $context, + \Magento\Customer\Model\Registration $registration, + \Magento\Customer\Model\Url $customerUrl, + \Magento\Checkout\Helper\Data $checkoutData, + \Magento\Framework\Url\Helper\Data $coreUrl, + array $data = [] + ) { + parent::__construct($context, $data); + $this->registration = $registration; + $this->_customerUrl = $customerUrl; + $this->checkoutData = $checkoutData; + $this->coreUrl = $coreUrl; + } + + /** + * Return registration + * + * @return \Magento\Customer\Model\Registration + */ + public function getRegistration() + { + return $this->registration; + } + + /** + * Retrieve create new account url + * + * @return string + */ + public function getCreateAccountUrl() + { + $url = $this->getData('create_account_url'); + if (is_null($url)) { + $url = $this->_customerUrl->getRegisterUrl(); + } + if ($this->checkoutData->isContextCheckout()) { + $url = $this->coreUrl->addRequestParam($url, ['context' => 'checkout']); + } + return $url; + } +} diff --git a/app/code/Magento/Customer/Controller/Account/CreatePost.php b/app/code/Magento/Customer/Controller/Account/CreatePost.php index 55d7bf4c4a11535abe6f9220af2a3f69e68b3b6e..50824c3972cf7036d1d4230229c50cfe155748cb 100644 --- a/app/code/Magento/Customer/Controller/Account/CreatePost.php +++ b/app/code/Magento/Customer/Controller/Account/CreatePost.php @@ -297,7 +297,7 @@ class CreatePost extends \Magento\Customer\Controller\Account protected function checkPasswordConfirmation($password, $confirmation) { if ($password != $confirmation) { - throw new InputException('Please make sure your passwords match.'); + throw new InputException(__('Please make sure your passwords match.')); } } diff --git a/app/code/Magento/Customer/Controller/Adminhtml/Index.php b/app/code/Magento/Customer/Controller/Adminhtml/Index.php index 3ff36759a343142790e6636cd6dd23d4d501668e..eec31225f83eaf86c8d9ea536e45fd82c558e60f 100644 --- a/app/code/Magento/Customer/Controller/Adminhtml/Index.php +++ b/app/code/Magento/Customer/Controller/Adminhtml/Index.php @@ -144,7 +144,7 @@ class Index extends \Magento\Backend\App\Action protected $resultForwardFactory; /** - * @var \Magento\Framework\Controller\Result\JSONFactory + * @var \Magento\Framework\Controller\Result\JsonFactory */ protected $resultJsonFactory; @@ -174,7 +174,7 @@ class Index extends \Magento\Backend\App\Action * @param \Magento\Framework\View\Result\PageFactory $resultPageFactory * @param \Magento\Backend\Model\View\Result\RedirectFactory $resultRedirectFactory * @param \Magento\Backend\Model\View\Result\ForwardFactory $resultForwardFactory - * @param \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory + * @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory * * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ @@ -204,7 +204,7 @@ class Index extends \Magento\Backend\App\Action \Magento\Framework\View\Result\PageFactory $resultPageFactory, \Magento\Backend\Model\View\Result\RedirectFactory $resultRedirectFactory, \Magento\Backend\Model\View\Result\ForwardFactory $resultForwardFactory, - \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory + \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory ) { $this->_coreRegistry = $coreRegistry; $this->_fileFactory = $fileFactory; diff --git a/app/code/Magento/Customer/Controller/Adminhtml/Index/ResetPassword.php b/app/code/Magento/Customer/Controller/Adminhtml/Index/ResetPassword.php index 48b8430d70877c115627c07c2f3b277f5c0782f8..bd74b364b82266759ee55ee967a9327293e5a396 100644 --- a/app/code/Magento/Customer/Controller/Adminhtml/Index/ResetPassword.php +++ b/app/code/Magento/Customer/Controller/Adminhtml/Index/ResetPassword.php @@ -34,7 +34,7 @@ class ResetPassword extends \Magento\Customer\Controller\Adminhtml\Index } catch (NoSuchEntityException $exception) { $resultRedirect->setPath('customer/index'); return $resultRedirect; - } catch (\Magento\Framework\Validator\ValidatorException $exception) { + } catch (\Magento\Framework\Validator\Exception $exception) { $messages = $exception->getMessages(\Magento\Framework\Message\MessageInterface::TYPE_ERROR); if (!count($messages)) { $messages = $exception->getMessage(); diff --git a/app/code/Magento/Customer/Controller/Adminhtml/Index/Save.php b/app/code/Magento/Customer/Controller/Adminhtml/Index/Save.php index 3c2b02d7a7f06dd356600bb33420202d3792fec6..afe64d9c98455be2d298dd702485ef7851725e1f 100644 --- a/app/code/Magento/Customer/Controller/Adminhtml/Index/Save.php +++ b/app/code/Magento/Customer/Controller/Adminhtml/Index/Save.php @@ -252,7 +252,7 @@ class Save extends \Magento\Customer\Controller\Adminhtml\Index $this->_coreRegistry->register(RegistryConstants::CURRENT_CUSTOMER_ID, $customerId); $this->messageManager->addSuccess(__('You saved the customer.')); $returnToEdit = (bool)$this->getRequest()->getParam('back', false); - } catch (\Magento\Framework\Validator\ValidatorException $exception) { + } catch (\Magento\Framework\Validator\Exception $exception) { $messages = $exception->getMessages(); if (empty($messages)) { $messages = $exception->getMessage(); diff --git a/app/code/Magento/Customer/Controller/Adminhtml/Index/Validate.php b/app/code/Magento/Customer/Controller/Adminhtml/Index/Validate.php index 3f925ba579e8f9c72a271b03677ee49d7fd2626f..3986551d78389058e3f503511c7bf9d621ee66f5 100644 --- a/app/code/Magento/Customer/Controller/Adminhtml/Index/Validate.php +++ b/app/code/Magento/Customer/Controller/Adminhtml/Index/Validate.php @@ -49,7 +49,7 @@ class Validate extends \Magento\Customer\Controller\Adminhtml\Index '\Magento\Customer\Api\Data\CustomerInterface' ); $errors = $this->customerAccountManagement->validate($customer); - } catch (\Magento\Framework\Validator\ValidatorException $exception) { + } catch (\Magento\Framework\Validator\Exception $exception) { /* @var $error Error */ foreach ($exception->getMessages(\Magento\Framework\Message\MessageInterface::TYPE_ERROR) as $error) { $errors[] = $error->getText(); @@ -102,7 +102,7 @@ class Validate extends \Magento\Customer\Controller\Adminhtml\Index /** * AJAX customer validation action * - * @return \Magento\Framework\Controller\Result\JSON + * @return \Magento\Framework\Controller\Result\Json */ public function execute() { diff --git a/app/code/Magento/Customer/Controller/Adminhtml/Index/Viewfile.php b/app/code/Magento/Customer/Controller/Adminhtml/Index/Viewfile.php index c06a9540a4edf5c7932260ea45db498fda0e71da..86f937f8981a7fc110e63a31aee8e6ae0f40f1c6 100755 --- a/app/code/Magento/Customer/Controller/Adminhtml/Index/Viewfile.php +++ b/app/code/Magento/Customer/Controller/Adminhtml/Index/Viewfile.php @@ -56,7 +56,7 @@ class Viewfile extends \Magento\Customer\Controller\Adminhtml\Index * @param \Magento\Framework\View\Result\PageFactory $resultPageFactory * @param \Magento\Backend\Model\View\Result\RedirectFactory $resultRedirectFactory * @param \Magento\Backend\Model\View\Result\ForwardFactory $resultForwardFactory - * @param \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory + * @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory * @param \Magento\Framework\Controller\Result\RawFactory $resultRawFactory * @param \Magento\Framework\Url\DecoderInterface $urlDecoder * @@ -88,7 +88,7 @@ class Viewfile extends \Magento\Customer\Controller\Adminhtml\Index \Magento\Framework\View\Result\PageFactory $resultPageFactory, \Magento\Backend\Model\View\Result\RedirectFactory $resultRedirectFactory, \Magento\Backend\Model\View\Result\ForwardFactory $resultForwardFactory, - \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory, + \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory, \Magento\Framework\Controller\Result\RawFactory $resultRawFactory, \Magento\Framework\Url\DecoderInterface $urlDecoder ) { diff --git a/app/code/Magento/Customer/Controller/Adminhtml/System/Config/Validatevat/ValidateAdvanced.php b/app/code/Magento/Customer/Controller/Adminhtml/System/Config/Validatevat/ValidateAdvanced.php index c267c46b590efc38cd6bab77a56920d36c70a766..af85244627703f4619e76ff433957d0e782a6d5d 100644 --- a/app/code/Magento/Customer/Controller/Adminhtml/System/Config/Validatevat/ValidateAdvanced.php +++ b/app/code/Magento/Customer/Controller/Adminhtml/System/Config/Validatevat/ValidateAdvanced.php @@ -9,17 +9,17 @@ namespace Magento\Customer\Controller\Adminhtml\System\Config\Validatevat; class ValidateAdvanced extends \Magento\Customer\Controller\Adminhtml\System\Config\Validatevat { /** - * @var \Magento\Framework\Controller\Result\JSONFactory + * @var \Magento\Framework\Controller\Result\JsonFactory */ protected $resultJsonFactory; /** * @param \Magento\Backend\App\Action\Context $context - * @param \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory + * @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory */ public function __construct( \Magento\Backend\App\Action\Context $context, - \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory + \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory ) { parent::__construct($context); $this->resultJsonFactory = $resultJsonFactory; @@ -28,7 +28,7 @@ class ValidateAdvanced extends \Magento\Customer\Controller\Adminhtml\System\Con /** * Retrieve validation result as JSON * - * @return \Magento\Framework\Controller\Result\JSON + * @return \Magento\Framework\Controller\Result\Json */ public function execute() { @@ -49,7 +49,7 @@ class ValidateAdvanced extends \Magento\Customer\Controller\Adminhtml\System\Con $storeId ); - /** @var \Magento\Framework\Controller\Result\JSON $resultJson */ + /** @var \Magento\Framework\Controller\Result\Json $resultJson */ $resultJson = $this->resultJsonFactory->create(); return $resultJson->setData(['valid' => $valid, 'group' => $groupId, 'success' => $success]); } diff --git a/app/code/Magento/Customer/Controller/Ajax/Login.php b/app/code/Magento/Customer/Controller/Ajax/Login.php index b705069c7c9b309de11eb665d394dbe8a2a54021..ad1e2cdd0cf74eadb20db3dde864b2545b2784e1 100644 --- a/app/code/Magento/Customer/Controller/Ajax/Login.php +++ b/app/code/Magento/Customer/Controller/Ajax/Login.php @@ -34,7 +34,7 @@ class Login extends \Magento\Framework\App\Action\Action protected $helper; /** - * @var \Magento\Framework\Controller\Result\JSONFactory + * @var \Magento\Framework\Controller\Result\JsonFactory */ protected $resultJsonFactory; @@ -50,7 +50,7 @@ class Login extends \Magento\Framework\App\Action\Action * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Framework\Json\Helper\Data $helper * @param AccountManagementInterface $customerAccountManagement - * @param \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory + * @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory * @param \Magento\Framework\Controller\Result\RawFactory $resultRawFactory */ public function __construct( @@ -58,7 +58,7 @@ class Login extends \Magento\Framework\App\Action\Action \Magento\Customer\Model\Session $customerSession, \Magento\Framework\Json\Helper\Data $helper, AccountManagementInterface $customerAccountManagement, - \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory, + \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory, \Magento\Framework\Controller\Result\RawFactory $resultRawFactory ) { parent::__construct($context); @@ -112,7 +112,7 @@ class Login extends \Magento\Framework\App\Action\Action } else { $responseText = __('Login successful.'); } - /** @var \Magento\Framework\Controller\Result\JSON $resultJson */ + /** @var \Magento\Framework\Controller\Result\Json $resultJson */ $resultJson = $this->resultJsonFactory->create(); return $resultJson->setData(['message' => $responseText]); } diff --git a/app/code/Magento/Customer/Controller/Ajax/Logout.php b/app/code/Magento/Customer/Controller/Ajax/Logout.php index 999f3d45fa7bf3b2bcb0328d2a2d2ea26183f959..69ce4693b035ebc3644eb74a74b28afc1725b146 100644 --- a/app/code/Magento/Customer/Controller/Ajax/Logout.php +++ b/app/code/Magento/Customer/Controller/Ajax/Logout.php @@ -21,7 +21,7 @@ class Logout extends \Magento\Framework\App\Action\Action protected $session; /** - * @var \Magento\Framework\Controller\Result\JSONFactory + * @var \Magento\Framework\Controller\Result\JsonFactory */ protected $resultJsonFactory; @@ -30,12 +30,12 @@ class Logout extends \Magento\Framework\App\Action\Action * * @param \Magento\Framework\App\Action\Context $context * @param \Magento\Customer\Model\Session $customerSession - * @param \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory + * @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory */ public function __construct( \Magento\Framework\App\Action\Context $context, \Magento\Customer\Model\Session $customerSession, - \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory + \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory ) { parent::__construct($context); $this->customerSession = $customerSession; @@ -45,7 +45,7 @@ class Logout extends \Magento\Framework\App\Action\Action /** * Customer logout action * - * @return \Magento\Framework\Controller\Result\JSON + * @return \Magento\Framework\Controller\Result\Json */ public function execute() { @@ -54,7 +54,7 @@ class Logout extends \Magento\Framework\App\Action\Action ->setBeforeAuthUrl($this->_redirect->getRefererUrl()) ->setLastCustomerId($lastCustomerId); - /** @var \Magento\Framework\Controller\Result\JSON $resultJson */ + /** @var \Magento\Framework\Controller\Result\Json $resultJson */ $resultJson = $this->resultJsonFactory->create(); return $resultJson->setData(['message' => 'Logout Successful']); } diff --git a/app/code/Magento/Customer/Model/AccountManagement.php b/app/code/Magento/Customer/Model/AccountManagement.php index 7fb85ee1caf5ab41cce6309d8843ccacd43f070b..c850e8c5a8e16b1f7a2fd8a7f176099b99b123d0 100644 --- a/app/code/Magento/Customer/Model/AccountManagement.php +++ b/app/code/Magento/Customer/Model/AccountManagement.php @@ -30,7 +30,7 @@ use Magento\Framework\Exception\NoSuchEntityException; use Magento\Framework\Exception\State\ExpiredException; use Magento\Framework\Exception\State\InputMismatchException; use Magento\Framework\Exception\State\InvalidTransitionException; -use Psr\Log\LoggerInterface as Logger; +use Psr\Log\LoggerInterface as PsrLogger; use Magento\Framework\Mail\Exception as MailException; use Magento\Framework\Mail\Template\TransportBuilder; use Magento\Framework\Math\Random; @@ -132,7 +132,7 @@ class AccountManagement implements AccountManagementInterface private $url; /** - * @var Logger + * @var PsrLogger */ protected $logger; @@ -215,7 +215,7 @@ class AccountManagement implements AccountManagementInterface * @param CustomerMetadataInterface $customerMetadataService * @param CustomerRegistry $customerRegistry * @param \Magento\Framework\Url $url - * @param Logger $logger + * @param PsrLogger $logger * @param Encryptor $encryptor * @param ConfigShare $configShare * @param StringHelper $stringHelper @@ -243,7 +243,7 @@ class AccountManagement implements AccountManagementInterface CustomerMetadataInterface $customerMetadataService, CustomerRegistry $customerRegistry, \Magento\Framework\Url $url, - Logger $logger, + PsrLogger $logger, Encryptor $encryptor, ConfigShare $configShare, StringHelper $stringHelper, @@ -291,7 +291,7 @@ class AccountManagement implements AccountManagementInterface { $customer = $this->customerRepository->get($email, $websiteId); if (!$customer->getConfirmation()) { - throw new InvalidTransitionException('No confirmation needed.'); + throw new InvalidTransitionException(__('No confirmation needed.')); } try { @@ -336,11 +336,11 @@ class AccountManagement implements AccountManagementInterface { // check if customer is inactive if (!$customer->getConfirmation()) { - throw new InvalidTransitionException('Account already active'); + throw new InvalidTransitionException(__('Account already active')); } if ($customer->getConfirmation() !== $confirmationKey) { - throw new InputMismatchException('Invalid confirmation token'); + throw new InputMismatchException(__('Invalid confirmation token')); } $customer->setConfirmation(null); @@ -359,16 +359,16 @@ class AccountManagement implements AccountManagementInterface try { $customer = $this->customerRepository->get($username); } catch (NoSuchEntityException $e) { - throw new InvalidEmailOrPasswordException('Invalid login or password.', []); + throw new InvalidEmailOrPasswordException(__('Invalid login or password.')); } $hash = $this->customerRegistry->retrieveSecureData($customer->getId())->getPasswordHash(); if (!$this->encryptor->validateHash($password, $hash)) { - throw new InvalidEmailOrPasswordException('Invalid login or password.', []); + throw new InvalidEmailOrPasswordException(__('Invalid login or password.')); } if ($customer->getConfirmation() && $this->isConfirmationRequired($customer)) { - throw new EmailNotConfirmedException('This account is not confirmed.', []); + throw new EmailNotConfirmedException(__('This account is not confirmed.')); } $this->eventManager->dispatch( @@ -414,8 +414,10 @@ class AccountManagement implements AccountManagementInterface break; default: throw new InputException( - InputException::INVALID_FIELD_VALUE, - ['value' => $template, 'fieldName' => 'email type'] + __( + InputException::INVALID_FIELD_VALUE, + ['value' => $template, 'fieldName' => 'email type'] + ) ); } } catch (MailException $e) { @@ -490,7 +492,7 @@ class AccountManagement implements AccountManagementInterface $websiteId = $customer->getWebsiteId(); if ($this->isCustomerInStore($websiteId, $customer->getStoreId())) { - throw new InputException('Customer already exists in this store.'); + throw new InputException(__('Customer already exists in this store.')); } // Existing password hash will be used from secured customer data registry when saving customer } @@ -509,7 +511,9 @@ class AccountManagement implements AccountManagementInterface // If customer exists existing hash will be used by Repository $customer = $this->customerRepository->save($customer, $hash); } catch (AlreadyExistsException $e) { - throw new InputMismatchException('Customer with the same email already exists in associated website.'); + throw new InputMismatchException( + __('Customer with the same email already exists in associated website.') + ); } catch (LocalizedException $e) { throw $e; } @@ -582,7 +586,7 @@ class AccountManagement implements AccountManagementInterface try { $customer = $this->customerRepository->get($email); } catch (NoSuchEntityException $e) { - throw new InvalidEmailOrPasswordException('Invalid login or password.'); + throw new InvalidEmailOrPasswordException(__('Invalid login or password.')); } return $this->changePasswordForCustomer($customer, $currentPassword, $newPassword); } @@ -595,7 +599,7 @@ class AccountManagement implements AccountManagementInterface try { $customer = $this->customerRepository->getById($customerId); } catch (NoSuchEntityException $e) { - throw new InvalidEmailOrPasswordException('Invalid login or password.'); + throw new InvalidEmailOrPasswordException(__('Invalid login or password.')); } return $this->changePasswordForCustomer($customer, $currentPassword, $newPassword); } @@ -613,7 +617,8 @@ class AccountManagement implements AccountManagementInterface $customerSecure = $this->customerRegistry->retrieveSecureData($customer->getId()); $hash = $customerSecure->getPasswordHash(); if (!$this->encryptor->validateHash($currentPassword, $hash)) { - throw new InvalidEmailOrPasswordException("Password doesn't match for this account.", []); + throw new InvalidEmailOrPasswordException( + __('Password doesn\'t match for this account.')); } $customerSecure->setRpToken(null); $customerSecure->setRpTokenCreatedAt(null); @@ -642,12 +647,14 @@ class AccountManagement implements AccountManagementInterface $length = $this->stringHelper->strlen($password); if ($length < self::MIN_PASSWORD_LENGTH) { throw new InputException( - 'The password must have at least %min_length characters.', - ['min_length' => self::MIN_PASSWORD_LENGTH] + __( + 'The password must have at least %1 characters.', + self::MIN_PASSWORD_LENGTH + ) ); } if ($this->stringHelper->strlen(trim($password)) != $length) { - throw new InputException('The password can not begin or end with a space.'); + throw new InputException(__('The password can not begin or end with a space.')); } } @@ -742,11 +749,11 @@ class AccountManagement implements AccountManagementInterface { if (empty($customerId) || $customerId < 0) { $params = ['value' => $customerId, 'fieldName' => 'customerId']; - throw new InputException(InputException::INVALID_FIELD_VALUE, $params); + throw new InputException(__(InputException::INVALID_FIELD_VALUE, $params)); } if (!is_string($resetPasswordLinkToken) || empty($resetPasswordLinkToken)) { $params = ['fieldName' => 'resetPasswordLinkToken']; - throw new InputException(InputException::REQUIRED_FIELD, $params); + throw new InputException(__(InputException::REQUIRED_FIELD, $params)); } $customerSecureData = $this->customerRegistry->retrieveSecureData($customerId); @@ -754,9 +761,9 @@ class AccountManagement implements AccountManagementInterface $rpTokenCreatedAt = $customerSecureData->getRpTokenCreatedAt(); if (strcmp($rpToken, $resetPasswordLinkToken) !== 0) { - throw new InputMismatchException('Reset password token mismatch.'); + throw new InputMismatchException(__('Reset password token mismatch.')); } elseif ($this->isResetPasswordLinkTokenExpired($rpToken, $rpTokenCreatedAt)) { - throw new ExpiredException('Reset password token expired.'); + throw new ExpiredException(__('Reset password token expired.')); } return true; @@ -1009,8 +1016,10 @@ class AccountManagement implements AccountManagementInterface { if (!is_string($passwordLinkToken) || empty($passwordLinkToken)) { throw new InputException( - InputException::INVALID_FIELD_VALUE, - ['value' => $passwordLinkToken, 'fieldName' => 'password reset token'] + __( + InputException::INVALID_FIELD_VALUE, + ['value' => $passwordLinkToken, 'fieldName' => 'password reset token'] + ) ); } if (is_string($passwordLinkToken) && !empty($passwordLinkToken)) { diff --git a/app/code/Magento/Customer/Model/Address.php b/app/code/Magento/Customer/Model/Address.php index 3aa89244fbefdb7886e674cd7e021a5d4575b984..9a66ec376f5641136eb146ddd9aae9ba66249013 100644 --- a/app/code/Magento/Customer/Model/Address.php +++ b/app/code/Magento/Customer/Model/Address.php @@ -9,7 +9,6 @@ use Magento\Customer\Api\AddressMetadataInterface; use Magento\Customer\Api\Data\AddressInterfaceFactory; use Magento\Customer\Api\Data\AddressInterface; use Magento\Customer\Api\Data\RegionInterfaceFactory; -use Magento\Framework\Api\AttributeValueFactory; /** * Customer address model @@ -45,14 +44,14 @@ class Address extends \Magento\Customer\Model\Address\AbstractAddress /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry - * @param \Magento\Framework\Api\MetadataServiceInterface $metadataService - * @param AttributeValueFactory $customAttributeFactory + * @param \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory + * @param \Magento\Framework\Api\AttributeValueFactory $customAttributeFactory * @param \Magento\Directory\Helper\Data $directoryData * @param \Magento\Eav\Model\Config $eavConfig * @param Address\Config $addressConfig * @param \Magento\Directory\Model\RegionFactory $regionFactory * @param \Magento\Directory\Model\CountryFactory $countryFactory - * @param AddressMetadataInterface $addressMetadataService + * @param AddressMetadataInterface $metadataService * @param AddressInterfaceFactory $addressDataFactory * @param RegionInterfaceFactory $regionDataFactory * @param \Magento\Framework\Api\DataObjectHelper $dataObjectHelper @@ -66,14 +65,14 @@ class Address extends \Magento\Customer\Model\Address\AbstractAddress public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, - \Magento\Framework\Api\MetadataServiceInterface $metadataService, - AttributeValueFactory $customAttributeFactory, + \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory, + \Magento\Framework\Api\AttributeValueFactory $customAttributeFactory, \Magento\Directory\Helper\Data $directoryData, \Magento\Eav\Model\Config $eavConfig, \Magento\Customer\Model\Address\Config $addressConfig, \Magento\Directory\Model\RegionFactory $regionFactory, \Magento\Directory\Model\CountryFactory $countryFactory, - AddressMetadataInterface $addressMetadataService, + AddressMetadataInterface $metadataService, AddressInterfaceFactory $addressDataFactory, RegionInterfaceFactory $regionDataFactory, \Magento\Framework\Api\DataObjectHelper $dataObjectHelper, @@ -88,14 +87,14 @@ class Address extends \Magento\Customer\Model\Address\AbstractAddress parent::__construct( $context, $registry, - $metadataService, + $extensionFactory, $customAttributeFactory, $directoryData, $eavConfig, $addressConfig, $regionFactory, $countryFactory, - $addressMetadataService, + $metadataService, $addressDataFactory, $regionDataFactory, $dataObjectHelper, diff --git a/app/code/Magento/Customer/Model/Address/AbstractAddress.php b/app/code/Magento/Customer/Model/Address/AbstractAddress.php index 65c9db82bf0ee887255c4c05c774f8071fe7a61a..d6be608bea7a70cb267c91f215523f9e5d2a691a 100644 --- a/app/code/Magento/Customer/Model/Address/AbstractAddress.php +++ b/app/code/Magento/Customer/Model/Address/AbstractAddress.php @@ -12,7 +12,7 @@ use Magento\Customer\Api\Data\AddressInterface; use Magento\Customer\Api\Data\RegionInterfaceFactory; use Magento\Customer\Api\Data\RegionInterface; use Magento\Customer\Model\Data\Address as AddressData; -use Magento\Framework\Api\AttributeValueFactory; +use Magento\Framework\Model\AbstractExtensibleModel; /** * Address abstract model @@ -29,7 +29,7 @@ use Magento\Framework\Api\AttributeValueFactory; * @method bool getShouldIgnoreValidation() * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class AbstractAddress extends \Magento\Framework\Model\AbstractExtensibleModel +class AbstractAddress extends AbstractExtensibleModel { /** * Possible customer address types @@ -96,7 +96,7 @@ class AbstractAddress extends \Magento\Framework\Model\AbstractExtensibleModel /** * @var AddressMetadataInterface */ - protected $_addressMetadataService; + protected $metadataService; /** * @var AddressInterfaceFactory @@ -116,14 +116,14 @@ class AbstractAddress extends \Magento\Framework\Model\AbstractExtensibleModel /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry - * @param \Magento\Framework\Api\MetadataServiceInterface $metadataService - * @param AttributeValueFactory $customAttributeFactory + * @param \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory + * @param \Magento\Framework\Api\AttributeValueFactory $customAttributeFactory * @param \Magento\Directory\Helper\Data $directoryData * @param \Magento\Eav\Model\Config $eavConfig * @param Config $addressConfig * @param \Magento\Directory\Model\RegionFactory $regionFactory * @param \Magento\Directory\Model\CountryFactory $countryFactory - * @param AddressMetadataInterface $addressMetadataService + * @param AddressMetadataInterface $metadataService * @param AddressInterfaceFactory $addressDataFactory * @param RegionInterfaceFactory $regionDataFactory * @param \Magento\Framework\Api\DataObjectHelper $dataObjectHelper @@ -135,14 +135,14 @@ class AbstractAddress extends \Magento\Framework\Model\AbstractExtensibleModel public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, - \Magento\Framework\Api\MetadataServiceInterface $metadataService, - AttributeValueFactory $customAttributeFactory, + \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory, + \Magento\Framework\Api\AttributeValueFactory $customAttributeFactory, \Magento\Directory\Helper\Data $directoryData, \Magento\Eav\Model\Config $eavConfig, Config $addressConfig, \Magento\Directory\Model\RegionFactory $regionFactory, \Magento\Directory\Model\CountryFactory $countryFactory, - AddressMetadataInterface $addressMetadataService, + AddressMetadataInterface $metadataService, AddressInterfaceFactory $addressDataFactory, RegionInterfaceFactory $regionDataFactory, \Magento\Framework\Api\DataObjectHelper $dataObjectHelper, @@ -156,14 +156,14 @@ class AbstractAddress extends \Magento\Framework\Model\AbstractExtensibleModel $this->_addressConfig = $addressConfig; $this->_regionFactory = $regionFactory; $this->_countryFactory = $countryFactory; - $this->_addressMetadataService = $addressMetadataService; + $this->metadataService = $metadataService; $this->addressDataFactory = $addressDataFactory; $this->regionDataFactory = $regionDataFactory; $this->dataObjectHelper = $dataObjectHelper; parent::__construct( $context, $registry, - $metadataService, + $extensionFactory, $customAttributeFactory, $resource, $resourceCollection, @@ -488,7 +488,7 @@ class AbstractAddress extends \Magento\Framework\Model\AbstractExtensibleModel { $addressId = $this->getId(); - $attributes = $this->_addressMetadataService->getAllAttributesMetadata(); + $attributes = $this->metadataService->getAllAttributesMetadata(); $addressData = []; foreach ($attributes as $attribute) { $code = $attribute->getAttributeCode(); diff --git a/app/code/Magento/Customer/Model/Attribute/Data/Postcode.php b/app/code/Magento/Customer/Model/Attribute/Data/Postcode.php index dfab0a4e277e5280e96c0e2a3df6209393b7682b..247ce01208341bebd1dfbbe7088034771a0be672 100644 --- a/app/code/Magento/Customer/Model/Attribute/Data/Postcode.php +++ b/app/code/Magento/Customer/Model/Attribute/Data/Postcode.php @@ -9,7 +9,7 @@ use Magento\Directory\Helper\Data as DirectoryHelper; use Magento\Eav\Model\AttributeDataFactory; use Magento\Framework\App\RequestInterface; use Magento\Framework\Locale\ResolverInterface; -use Psr\Log\LoggerInterface as Logger; +use Psr\Log\LoggerInterface as PsrLogger; use Magento\Framework\Stdlib\DateTime\TimezoneInterface as MagentoTimezone; /** @@ -25,13 +25,13 @@ class Postcode extends \Magento\Eav\Model\Attribute\Data\AbstractData /** * @param MagentoTimezone $localeDate - * @param Logger $logger + * @param PsrLogger $logger * @param ResolverInterface $localeResolver * @param DirectoryHelper $directoryHelper */ public function __construct( MagentoTimezone $localeDate, - Logger $logger, + PsrLogger $logger, ResolverInterface $localeResolver, DirectoryHelper $directoryHelper ) { @@ -108,6 +108,7 @@ class Postcode extends \Magento\Eav\Model\Attribute\Data\AbstractData * * @param string $format * @return string|array + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function outputValue($format = AttributeDataFactory::OUTPUT_FORMAT_TEXT) { diff --git a/app/code/Magento/Customer/Model/Customer.php b/app/code/Magento/Customer/Model/Customer.php index c4d6a3e6c360e3f38740f0710839ab483de8dca5..cefc5f867f66f30274cbf6007f18d13856189979 100644 --- a/app/code/Magento/Customer/Model/Customer.php +++ b/app/code/Magento/Customer/Model/Customer.php @@ -13,7 +13,6 @@ use Magento\Customer\Model\Resource\Customer as ResourceCustomer; use Magento\Customer\Api\Data\CustomerInterfaceFactory; use Magento\Customer\Model\Data\Customer as CustomerData; use Magento\Framework\Reflection\DataObjectProcessor; -use Magento\Framework\Api\AttributeValueFactory; use Magento\Framework\Exception\EmailNotConfirmedException; use Magento\Framework\Exception\InvalidEmailOrPasswordException; use Magento\Framework\Exception\AuthenticationException; @@ -39,7 +38,7 @@ use Magento\Framework\Exception\AuthenticationException; * @SuppressWarnings(PHPMD.ExcessiveClassComplexity) * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class Customer extends \Magento\Framework\Model\AbstractExtensibleModel +class Customer extends \Magento\Framework\Model\AbstractModel { /** * Configuration paths for email templates and identities @@ -194,18 +193,21 @@ class Customer extends \Magento\Framework\Model\AbstractExtensibleModel */ protected $dataObjectHelper; + /** + * @var \Magento\Customer\Api\CustomerMetadataInterface + */ + protected $metadataService; + /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry - * @param \Magento\Framework\Api\MetadataServiceInterface $metadataService - * @param AttributeValueFactory $customAttributeFactory * @param \Magento\Store\Model\StoreManagerInterface $storeManager * @param \Magento\Eav\Model\Config $config * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - * @param Resource\Customer $resource - * @param Config\Share $configShare + * @param ResourceCustomer $resource + * @param Share $configShare * @param AddressFactory $addressFactory - * @param Resource\Address\CollectionFactory $addressesFactory + * @param CollectionFactory $addressesFactory * @param \Magento\Framework\Mail\Template\TransportBuilder $transportBuilder * @param GroupRepositoryInterface $groupRepository * @param AttributeFactory $attributeFactory @@ -214,6 +216,7 @@ class Customer extends \Magento\Framework\Model\AbstractExtensibleModel * @param CustomerInterfaceFactory $customerDataFactory * @param DataObjectProcessor $dataObjectProcessor * @param \Magento\Framework\Api\DataObjectHelper $dataObjectHelper + * @param CustomerMetadataInterface $metadataService * @param \Magento\Framework\Data\Collection\Db $resourceCollection * @param array $data * @SuppressWarnings(PHPMD.ExcessiveParameterList) @@ -221,8 +224,6 @@ class Customer extends \Magento\Framework\Model\AbstractExtensibleModel public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, - \Magento\Framework\Api\MetadataServiceInterface $metadataService, - AttributeValueFactory $customAttributeFactory, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Eav\Model\Config $config, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, @@ -237,9 +238,11 @@ class Customer extends \Magento\Framework\Model\AbstractExtensibleModel CustomerInterfaceFactory $customerDataFactory, DataObjectProcessor $dataObjectProcessor, \Magento\Framework\Api\DataObjectHelper $dataObjectHelper, + \Magento\Customer\Api\CustomerMetadataInterface $metadataService, \Magento\Framework\Data\Collection\Db $resourceCollection = null, array $data = [] ) { + $this->metadataService = $metadataService; $this->_scopeConfig = $scopeConfig; $this->_storeManager = $storeManager; $this->_config = $config; @@ -256,8 +259,6 @@ class Customer extends \Magento\Framework\Model\AbstractExtensibleModel parent::__construct( $context, $registry, - $metadataService, - $customAttributeFactory, $resource, $resourceCollection, $data diff --git a/app/code/Magento/Customer/Model/CustomerRegistry.php b/app/code/Magento/Customer/Model/CustomerRegistry.php index cc4ea04078b95398a7ab715b76552df2e4f843a2..a6bd4bfc5705e7cbd94897610726c3c5b4c5c801 100644 --- a/app/code/Magento/Customer/Model/CustomerRegistry.php +++ b/app/code/Magento/Customer/Model/CustomerRegistry.php @@ -119,13 +119,15 @@ class CustomerRegistry if (!$customer->getEmail()) { // customer does not exist throw new NoSuchEntityException( - NoSuchEntityException::MESSAGE_DOUBLE_FIELDS, - [ + __( + NoSuchEntityException::MESSAGE_DOUBLE_FIELDS, + [ 'fieldName' => 'email', - 'fieldValue' => $customerEmail, - 'field2Name' => 'websiteId', - 'field2Value' => $websiteId, - ] + 'fieldValue' => $customerEmail, + 'field2Name' => 'websiteId', + 'field2Value' => $websiteId, + ] + ) ); } else { $this->customerRegistryById[$customer->getId()] = $customer; diff --git a/app/code/Magento/Customer/Model/Data/Address.php b/app/code/Magento/Customer/Model/Data/Address.php index a4785786c8c21bbc0fa720e86646b933acd60ab8..d44fbda0bbba599c71f28e661dd3b65695b8e2ed 100644 --- a/app/code/Magento/Customer/Model/Data/Address.php +++ b/app/code/Magento/Customer/Model/Data/Address.php @@ -10,20 +10,43 @@ namespace Magento\Customer\Model\Data; use Magento\Customer\Api\Data\RegionInterface; use \Magento\Framework\Api\AttributeValueFactory; +/** + * Class Address + * + */ class Address extends \Magento\Framework\Api\AbstractExtensibleObject implements \Magento\Customer\Api\Data\AddressInterface { /** - * @param \Magento\Customer\Api\AddressMetadataInterface $metadataService + * @var \Magento\Customer\Api\AddressMetadataInterface + */ + protected $metadataService; + + /** + * @param \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory * @param AttributeValueFactory $attributeValueFactory + * @param \Magento\Customer\Api\AddressMetadataInterface $metadataService * @param array $data */ public function __construct( - \Magento\Customer\Api\AddressMetadataInterface $metadataService, + \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory, AttributeValueFactory $attributeValueFactory, + \Magento\Customer\Api\AddressMetadataInterface $metadataService, $data = [] ) { - parent::__construct($metadataService, $attributeValueFactory, $data); + $this->metadataService = $metadataService; + parent::__construct($extensionFactory, $attributeValueFactory, $data); + } + + /** + * {@inheritdoc} + */ + protected function getCustomAttributesCodes() + { + if ($this->customAttributesCodes === null) { + $this->customAttributesCodes = $this->getEavAttributesCodes($this->metadataService); + } + return $this->customAttributesCodes; } /** @@ -403,4 +426,25 @@ class Address extends \Magento\Framework\Api\AbstractExtensibleObject implements { return $this->setData(self::DEFAULT_BILLING, $isDefaultBilling); } + + /** + * {@inheritdoc} + * + * @return \Magento\Customer\Api\Data\AddressExtensionInterface|null + */ + public function getExtensionAttributes() + { + return $this->_getExtensionAttributes(); + } + + /** + * {@inheritdoc} + * + * @param \Magento\Customer\Api\Data\AddressExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes(\Magento\Customer\Api\Data\AddressExtensionInterface $extensionAttributes) + { + return $this->_setExtensionAttributes($extensionAttributes); + } } diff --git a/app/code/Magento/Customer/Model/Data/AttributeMetadata.php b/app/code/Magento/Customer/Model/Data/AttributeMetadata.php index 5b4010e4ebc408495d91efcd94e870e5c71be4f9..dbf7feb726e23ba71d7bbf9dcef3b79a4433c1d7 100644 --- a/app/code/Magento/Customer/Model/Data/AttributeMetadata.php +++ b/app/code/Magento/Customer/Model/Data/AttributeMetadata.php @@ -9,7 +9,7 @@ namespace Magento\Customer\Model\Data; /** * Customer attribute metadata class. */ -class AttributeMetadata extends \Magento\Framework\Api\AbstractExtensibleObject implements +class AttributeMetadata extends \Magento\Framework\Api\AbstractSimpleObject implements \Magento\Customer\Api\Data\AttributeMetadataInterface { /** diff --git a/app/code/Magento/Customer/Model/Data/Customer.php b/app/code/Magento/Customer/Model/Data/Customer.php index 995bdd421c93383298a0106a70da28b3530b8d8a..4daf096e5ccd15268988e368107e41db8c48dcc2 100644 --- a/app/code/Magento/Customer/Model/Data/Customer.php +++ b/app/code/Magento/Customer/Model/Data/Customer.php @@ -6,23 +6,47 @@ namespace Magento\Customer\Model\Data; -use Magento\Customer\Api\Data\CustomerInterface; use \Magento\Framework\Api\AttributeValueFactory; +/** + * Class Customer + * + */ class Customer extends \Magento\Framework\Api\AbstractExtensibleObject implements \Magento\Customer\Api\Data\CustomerInterface { /** - * @param \Magento\Customer\Api\CustomerMetadataInterface $metadataService + * @var \Magento\Customer\Api\CustomerMetadataInterface + */ + protected $metadataService; + + /** + * Initialize dependencies. + * + * @param \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory * @param AttributeValueFactory $attributeValueFactory + * @param \Magento\Customer\Api\CustomerMetadataInterface $metadataService * @param array $data */ public function __construct( - \Magento\Customer\Api\CustomerMetadataInterface $metadataService, + \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory, AttributeValueFactory $attributeValueFactory, + \Magento\Customer\Api\CustomerMetadataInterface $metadataService, $data = [] ) { - parent::__construct($metadataService, $attributeValueFactory, $data); + $this->metadataService = $metadataService; + parent::__construct($extensionFactory, $attributeValueFactory, $data); + } + + /** + * {@inheritdoc} + */ + protected function getCustomAttributesCodes() + { + if ($this->customAttributesCodes === null) { + $this->customAttributesCodes = $this->getEavAttributesCodes($this->metadataService); + } + return $this->customAttributesCodes; } /** @@ -421,4 +445,25 @@ class Customer extends \Magento\Framework\Api\AbstractExtensibleObject implement { return $this->setData(self::KEY_ADDRESSES, $addresses); } + + /** + * {@inheritdoc} + * + * @return \Magento\Customer\Api\Data\CustomerExtensionInterface|null + */ + public function getExtensionAttributes() + { + return $this->_getExtensionAttributes(); + } + + /** + * {@inheritdoc} + * + * @param \Magento\Customer\Api\Data\CustomerExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes(\Magento\Customer\Api\Data\CustomerExtensionInterface $extensionAttributes) + { + return $this->_setExtensionAttributes($extensionAttributes); + } } diff --git a/app/code/Magento/Customer/Model/Data/Group.php b/app/code/Magento/Customer/Model/Data/Group.php index 7f2883670308e7d37231282922a5d306ba661b00..9edc461f982c0a963f6c8aa29c8e391ffd81ef08 100644 --- a/app/code/Magento/Customer/Model/Data/Group.php +++ b/app/code/Magento/Customer/Model/Data/Group.php @@ -95,4 +95,25 @@ class Group extends \Magento\Framework\Api\AbstractExtensibleObject implements { return $this->setData(self::TAX_CLASS_NAME, $taxClassName); } + + /** + * {@inheritdoc} + * + * @return \Magento\Customer\Api\Data\GroupExtensionInterface|null + */ + public function getExtensionAttributes() + { + return $this->_getExtensionAttributes(); + } + + /** + * {@inheritdoc} + * + * @param \Magento\Customer\Api\Data\GroupExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes(\Magento\Customer\Api\Data\GroupExtensionInterface $extensionAttributes) + { + return $this->_setExtensionAttributes($extensionAttributes); + } } diff --git a/app/code/Magento/Customer/Model/Data/Option.php b/app/code/Magento/Customer/Model/Data/Option.php index 7ebf6893d15136b692a1eb05e5d4049d1f4d97c3..080f9449ca1443555645d06ca7ad4f6d5af0d2a1 100644 --- a/app/code/Magento/Customer/Model/Data/Option.php +++ b/app/code/Magento/Customer/Model/Data/Option.php @@ -11,7 +11,7 @@ namespace Magento\Customer\Model\Data; /** * Class Option */ -class Option extends \Magento\Framework\Api\AbstractExtensibleObject implements +class Option extends \Magento\Framework\Api\AbstractSimpleObject implements \Magento\Customer\Api\Data\OptionInterface { /** diff --git a/app/code/Magento/Customer/Model/Data/Region.php b/app/code/Magento/Customer/Model/Data/Region.php index 42b5a1c944afbca4b58284ebcb1617c40c6af27c..ddea4c3a90ceb1597c497b516cd53a656548c2dd 100644 --- a/app/code/Magento/Customer/Model/Data/Region.php +++ b/app/code/Magento/Customer/Model/Data/Region.php @@ -7,6 +7,7 @@ namespace Magento\Customer\Model\Data; /** * Data Model implementing Address Region interface + * */ class Region extends \Magento\Framework\Api\AbstractExtensibleObject implements \Magento\Customer\Api\Data\RegionInterface @@ -73,4 +74,25 @@ class Region extends \Magento\Framework\Api\AbstractExtensibleObject implements { return $this->setData(self::REGION_ID, $regionId); } + + /** + * {@inheritdoc} + * + * @return \Magento\Customer\Api\Data\RegionExtensionInterface|null + */ + public function getExtensionAttributes() + { + return $this->_getExtensionAttributes(); + } + + /** + * {@inheritdoc} + * + * @param \Magento\Customer\Api\Data\RegionExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes(\Magento\Customer\Api\Data\RegionExtensionInterface $extensionAttributes) + { + return $this->_setExtensionAttributes($extensionAttributes); + } } diff --git a/app/code/Magento/Customer/Model/Data/ValidationResults.php b/app/code/Magento/Customer/Model/Data/ValidationResults.php index 684b451360d4c8be6180ad0e86cf8ef0464a21bc..6c473ed0f167da0aa95aee4f42e8b1044549d595 100644 --- a/app/code/Magento/Customer/Model/Data/ValidationResults.php +++ b/app/code/Magento/Customer/Model/Data/ValidationResults.php @@ -10,7 +10,7 @@ namespace Magento\Customer\Model\Data; /** * Validation results data model. */ -class ValidationResults extends \Magento\Framework\Api\AbstractExtensibleObject implements +class ValidationResults extends \Magento\Framework\Api\AbstractSimpleObject implements \Magento\Customer\Api\Data\ValidationResultsInterface { /** diff --git a/app/code/Magento/Customer/Model/Data/ValidationRule.php b/app/code/Magento/Customer/Model/Data/ValidationRule.php index 5d8234cce281a0439e083e5e1b5d997f2bff6a0f..ce5a4a419a8e2fc962dbb2e7d5df4e4cb52a10cc 100644 --- a/app/code/Magento/Customer/Model/Data/ValidationRule.php +++ b/app/code/Magento/Customer/Model/Data/ValidationRule.php @@ -7,7 +7,7 @@ namespace Magento\Customer\Model\Data; use Magento\Customer\Api\Data\ValidationRuleInterface; -class ValidationRule extends \Magento\Framework\Api\AbstractExtensibleObject implements +class ValidationRule extends \Magento\Framework\Api\AbstractSimpleObject implements \Magento\Customer\Api\Data\ValidationRuleInterface { /** diff --git a/app/code/Magento/Customer/Model/Group.php b/app/code/Magento/Customer/Model/Group.php index 252b62393b6d9c24136fba6bb59990ac982837cf..b11d73f55bfac12c7f9b6f7a28cc271441543e8e 100644 --- a/app/code/Magento/Customer/Model/Group.php +++ b/app/code/Magento/Customer/Model/Group.php @@ -5,8 +5,6 @@ */ namespace Magento\Customer\Model; -use Magento\Framework\Api\AttributeValueFactory; - /** * Customer group model * @@ -17,7 +15,7 @@ use Magento\Framework\Api\AttributeValueFactory; * @method \Magento\Customer\Model\Group setTaxClassId(int $value) * @method Group setTaxClassName(string $value) */ -class Group extends \Magento\Framework\Model\AbstractExtensibleModel +class Group extends \Magento\Framework\Model\AbstractModel { const NOT_LOGGED_IN_ID = 0; @@ -63,8 +61,6 @@ class Group extends \Magento\Framework\Model\AbstractExtensibleModel * * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry - * @param \Magento\Framework\Api\MetadataServiceInterface $metadataService - * @param AttributeValueFactory $customAttributeFactory * @param \Magento\Store\Model\StoresConfig $storesConfig * @param \Magento\Framework\Reflection\DataObjectProcessor $dataObjectProcessor * @param \Magento\Tax\Model\ClassModelFactory $classModelFactory @@ -76,8 +72,6 @@ class Group extends \Magento\Framework\Model\AbstractExtensibleModel public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, - \Magento\Framework\Api\MetadataServiceInterface $metadataService, - AttributeValueFactory $customAttributeFactory, \Magento\Store\Model\StoresConfig $storesConfig, \Magento\Framework\Reflection\DataObjectProcessor $dataObjectProcessor, \Magento\Tax\Model\ClassModelFactory $classModelFactory, @@ -91,8 +85,6 @@ class Group extends \Magento\Framework\Model\AbstractExtensibleModel parent::__construct( $context, $registry, - $metadataService, - $customAttributeFactory, $resource, $resourceCollection, $data diff --git a/app/code/Magento/Customer/Model/Log.php b/app/code/Magento/Customer/Model/Log.php new file mode 100644 index 0000000000000000000000000000000000000000..2c65bdcb20cc46472e603af03cd819a08b0a675a --- /dev/null +++ b/app/code/Magento/Customer/Model/Log.php @@ -0,0 +1,96 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Customer\Model; + +/** + * Customer log model. + * + * Contains customer log data. + */ +class Log +{ + /** + * Customer ID. + * + * @var int + */ + protected $customerId; + + /** + * Date and time of customer's last login. + * + * @var string + */ + protected $lastLoginAt; + + /** + * Date and time of customer's last logout. + * + * @var string + */ + protected $lastVisitAt; + + /** + * Date and time of customer's last visit. + * + * @var string + */ + protected $lastLogoutAt; + + /** + * @param int $customerId + * @param string $lastLoginAt + * @param string $lastVisitAt + * @param string $lastLogoutAt + */ + public function __construct($customerId = null, $lastLoginAt = null, $lastVisitAt = null, $lastLogoutAt = null) + { + $this->customerId = $customerId; + $this->lastLoginAt = $lastLoginAt; + $this->lastVisitAt = $lastVisitAt; + $this->lastLogoutAt = $lastLogoutAt; + } + + /** + * Retrieve customer id + * + * @return int + */ + public function getCustomerId() + { + return $this->customerId; + } + + /** + * Retrieve last login date as string + * + * @return string + */ + public function getLastLoginAt() + { + return $this->lastLoginAt; + } + + /** + * Retrieve last visit date as string + * + * @return string + */ + public function getLastVisitAt() + { + return $this->lastVisitAt; + } + + /** + * Retrieve last logout date as string + * + * @return string + */ + public function getLastLogoutAt() + { + return $this->lastLogoutAt; + } +} diff --git a/app/code/Magento/Customer/Model/Logger.php b/app/code/Magento/Customer/Model/Logger.php new file mode 100644 index 0000000000000000000000000000000000000000..e29ceb3cf0c09c805b8eecbf46a05b1356213e6f --- /dev/null +++ b/app/code/Magento/Customer/Model/Logger.php @@ -0,0 +1,118 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Customer\Model; + +/** + * Customer log data logger. + * + * Saves and retrieves customer log data. + */ +class Logger +{ + /** + * Resource instance. + * + * @var \Magento\Framework\App\Resource + */ + protected $resource; + + /** + * @var \Magento\Customer\Model\LogFactory + */ + protected $logFactory; + + /** + * @param \Magento\Framework\App\Resource $resource + * @param \Magento\Customer\Model\LogFactory $logFactory + */ + public function __construct( + \Magento\Framework\App\Resource $resource, + \Magento\Customer\Model\LogFactory $logFactory + ) { + $this->resource = $resource; + $this->logFactory = $logFactory; + } + + /** + * Save (insert new or update existing) log. + * + * @param int $customerId + * @param array $data + * @return $this + * @throws \InvalidArgumentException + */ + public function log($customerId, array $data) + { + $data = array_filter($data); + + if (!$data) { + throw new \InvalidArgumentException("Log data is empty"); + } + + /** @var \Magento\Framework\DB\Adapter\AdapterInterface $adapter */ + $adapter = $this->resource->getConnection('write'); + + $adapter->insertOnDuplicate( + $this->resource->getTableName('customer_log'), + array_merge(['customer_id' => $customerId], $data), + array_keys($data) + ); + + return $this; + } + + /** + * Load log by Customer Id. + * + * @param int $customerId + * @return Log + */ + public function get($customerId = null) + { + $data = (null !== $customerId) ? $this->loadLogData($customerId) : []; + + return $this->logFactory->create( + [ + 'customerId' => isset($data['customer_id']) ? $data['customer_id'] : null, + 'lastLoginAt' => isset($data['last_login_at']) ? $data['last_login_at'] : null, + 'lastLogoutAt' => isset($data['last_logout_at']) ? $data['last_logout_at'] : null, + 'lastVisitAt' => isset($data['last_visit_at']) ? $data['last_visit_at'] : null + ] + ); + } + + /** + * Load customer log data by customer id + * + * @param int $customerId + * @return array + */ + protected function loadLogData($customerId) + { + /** @var \Magento\Framework\DB\Adapter\AdapterInterface $adapter */ + $adapter = $this->resource->getConnection('read'); + + $select = $adapter->select() + ->from( + ['cl' => $this->resource->getTableName('customer_log')] + ) + ->joinLeft( + ['cv' => $this->resource->getTableName('customer_visitor')], + 'cv.customer_id = cl.customer_id', + ['last_visit_at'] + ) + ->where( + 'cl.customer_id = ?', + $customerId + ) + ->order( + 'cv.visitor_id DESC' + ) + ->limit(1); + + return $adapter->fetchRow($select); + } +} diff --git a/app/code/Magento/Customer/Model/Metadata/AddressMetadata.php b/app/code/Magento/Customer/Model/Metadata/AddressMetadata.php index 08a1ea6a1d263ee28d42fe18c79c01b5ea5c4bb3..31a62c6e527d182b19050ad4fb979bc3499b41db 100644 --- a/app/code/Magento/Customer/Model/Metadata/AddressMetadata.php +++ b/app/code/Magento/Customer/Model/Metadata/AddressMetadata.php @@ -10,7 +10,6 @@ use Magento\Customer\Api\AddressMetadataInterface; use Magento\Customer\Model\AttributeMetadataConverter; use Magento\Customer\Model\AttributeMetadataDataProvider; use Magento\Eav\Model\Entity\Attribute\AbstractAttribute; -use Magento\Framework\Api\Config\MetadataConfig; use Magento\Framework\Api\SimpleDataObjectConverter; use Magento\Framework\Exception\NoSuchEntityException; @@ -24,11 +23,6 @@ class AddressMetadata implements AddressMetadataInterface */ private $addressDataObjectMethods; - /** - * @var MetadataConfig - */ - private $metadataConfig; - /** * @var AttributeMetadataConverter */ @@ -40,16 +34,13 @@ class AddressMetadata implements AddressMetadataInterface private $attributeMetadataDataProvider; /** - * @param MetadataConfig $metadataConfig * @param AttributeMetadataConverter $attributeMetadataConverter * @param AttributeMetadataDataProvider $attributeMetadataDataProvider */ public function __construct( - MetadataConfig $metadataConfig, AttributeMetadataConverter $attributeMetadataConverter, AttributeMetadataDataProvider $attributeMetadataDataProvider ) { - $this->metadataConfig = $metadataConfig; $this->attributeMetadataConverter = $attributeMetadataConverter; $this->attributeMetadataDataProvider = $attributeMetadataDataProvider; } @@ -87,13 +78,15 @@ class AddressMetadata implements AddressMetadataInterface return $attributeMetadata; } else { throw new NoSuchEntityException( - NoSuchEntityException::MESSAGE_DOUBLE_FIELDS, - [ - 'fieldName' => 'entityType', - 'fieldValue' => AddressMetadataInterface::ENTITY_TYPE_ADDRESS, - 'field2Name' => 'attributeCode', - 'field2Value' => $attributeCode, - ] + __( + NoSuchEntityException::MESSAGE_DOUBLE_FIELDS, + [ + 'fieldName' => 'entityType', + 'fieldValue' => AddressMetadataInterface::ENTITY_TYPE_ADDRESS, + 'field2Name' => 'attributeCode', + 'field2Value' => $attributeCode, + ] + ) ); } } @@ -127,7 +120,6 @@ class AddressMetadata implements AddressMetadataInterface */ public function getCustomAttributesMetadata($dataObjectClassName = AddressMetadataInterface::DATA_INTERFACE_NAME) { - $customAttributes = []; if (!$this->addressDataObjectMethods) { $dataObjectMethods = array_flip(get_class_methods($dataObjectClassName)); $baseClassDataObjectMethods = array_flip( @@ -135,6 +127,7 @@ class AddressMetadata implements AddressMetadataInterface ); $this->addressDataObjectMethods = array_diff_key($dataObjectMethods, $baseClassDataObjectMethods); } + $customAttributes = []; foreach ($this->getAllAttributesMetadata() as $attributeMetadata) { $attributeCode = $attributeMetadata->getAttributeCode(); $camelCaseKey = SimpleDataObjectConverter::snakeCaseToUpperCamelCase($attributeCode); @@ -145,6 +138,6 @@ class AddressMetadata implements AddressMetadataInterface $customAttributes[] = $attributeMetadata; } } - return array_merge($customAttributes, $this->metadataConfig->getCustomAttributesMetadata($dataObjectClassName)); + return $customAttributes; } } diff --git a/app/code/Magento/Customer/Model/Metadata/CustomerMetadata.php b/app/code/Magento/Customer/Model/Metadata/CustomerMetadata.php index 46e696cb17f86639ab00ba9bebcf3b62ad9a3ca7..074561544878130aa63d015151e83e9f6c8a7106 100644 --- a/app/code/Magento/Customer/Model/Metadata/CustomerMetadata.php +++ b/app/code/Magento/Customer/Model/Metadata/CustomerMetadata.php @@ -10,7 +10,6 @@ use Magento\Customer\Api\CustomerMetadataInterface; use Magento\Customer\Model\AttributeMetadataConverter; use Magento\Customer\Model\AttributeMetadataDataProvider; use Magento\Eav\Model\Entity\Attribute\AbstractAttribute; -use Magento\Framework\Api\Config\MetadataConfig; use Magento\Framework\Api\SimpleDataObjectConverter; use Magento\Framework\Exception\NoSuchEntityException; @@ -24,11 +23,6 @@ class CustomerMetadata implements CustomerMetadataInterface */ private $customerDataObjectMethods; - /** - * @var MetadataConfig - */ - private $metadataConfig; - /** * @var AttributeMetadataConverter */ @@ -40,16 +34,13 @@ class CustomerMetadata implements CustomerMetadataInterface private $attributeMetadataDataProvider; /** - * @param MetadataConfig $metadataConfig * @param AttributeMetadataConverter $attributeMetadataConverter * @param AttributeMetadataDataProvider $attributeMetadataDataProvider */ public function __construct( - MetadataConfig $metadataConfig, AttributeMetadataConverter $attributeMetadataConverter, AttributeMetadataDataProvider $attributeMetadataDataProvider ) { - $this->metadataConfig = $metadataConfig; $this->attributeMetadataConverter = $attributeMetadataConverter; $this->attributeMetadataDataProvider = $attributeMetadataDataProvider; } @@ -87,13 +78,15 @@ class CustomerMetadata implements CustomerMetadataInterface return $attributeMetadata; } else { throw new NoSuchEntityException( - NoSuchEntityException::MESSAGE_DOUBLE_FIELDS, - [ - 'fieldName' => 'entityType', - 'fieldValue' => self::ENTITY_TYPE_CUSTOMER, - 'field2Name' => 'attributeCode', - 'field2Value' => $attributeCode, - ] + __( + NoSuchEntityException::MESSAGE_DOUBLE_FIELDS, + [ + 'fieldName' => 'entityType', + 'fieldValue' => self::ENTITY_TYPE_CUSTOMER, + 'field2Name' => 'attributeCode', + 'field2Value' => $attributeCode, + ] + ) ); } } @@ -148,6 +141,6 @@ class CustomerMetadata implements CustomerMetadataInterface $customAttributes[] = $attributeMetadata; } } - return array_merge($customAttributes, $this->metadataConfig->getCustomAttributesMetadata($dataObjectClassName)); + return $customAttributes; } } diff --git a/app/code/Magento/Customer/Model/Metadata/Form/Postcode.php b/app/code/Magento/Customer/Model/Metadata/Form/Postcode.php index c65d0e7adaa2208981f16ac3de73566ae711570c..0af212b81b191a9c2d8cca6094fafdc6b996865f 100644 --- a/app/code/Magento/Customer/Model/Metadata/Form/Postcode.php +++ b/app/code/Magento/Customer/Model/Metadata/Form/Postcode.php @@ -9,7 +9,7 @@ use Magento\Customer\Api\Data\AttributeMetadataInterface; use Magento\Customer\Model\Metadata\ElementFactory; use Magento\Directory\Helper\Data as DirectoryHelper; use Magento\Framework\Locale\ResolverInterface; -use Psr\Log\LoggerInterface as Logger; +use Psr\Log\LoggerInterface as PsrLogger; use Magento\Framework\Stdlib\DateTime\TimezoneInterface as MagentoTimezone; /** @@ -24,7 +24,7 @@ class Postcode extends AbstractData /** * @param MagentoTimezone $localeDate - * @param Logger $logger + * @param PsrLogger $logger * @param AttributeMetadataInterface $attribute * @param ResolverInterface $localeResolver * @param string $value @@ -34,7 +34,7 @@ class Postcode extends AbstractData */ public function __construct( MagentoTimezone $localeDate, - Logger $logger, + PsrLogger $logger, AttributeMetadataInterface $attribute, ResolverInterface $localeResolver, $value, diff --git a/app/code/Magento/Customer/Model/Observer/Log.php b/app/code/Magento/Customer/Model/Observer/Log.php new file mode 100644 index 0000000000000000000000000000000000000000..539221b5e378f47a537816c4d1e3a14457ab6ea1 --- /dev/null +++ b/app/code/Magento/Customer/Model/Observer/Log.php @@ -0,0 +1,59 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Customer\Model\Observer; + +use Magento\Customer\Model\Logger; +use Magento\Framework\Stdlib\DateTime; +use Magento\Framework\Event\Observer; + +/** + * Customer log observer. + */ +class Log +{ + /** + * Logger of customer's log data. + * + * @var Logger + */ + protected $logger; + + /** + * @param Logger $logger + */ + public function __construct(Logger $logger) + { + $this->logger = $logger; + } + + /** + * Handler for 'customer_login' event. + * + * @param Observer $observer + * @return void + */ + public function logLastLoginAt(Observer $observer) + { + $this->logger->log( + $observer->getEvent()->getCustomer()->getId(), + ['last_login_at' => (new \DateTime())->format(\Magento\Framework\Stdlib\DateTime::DATETIME_PHP_FORMAT)] + ); + } + + /** + * Handler for 'customer_logout' event. + * + * @param Observer $observer + * @return void + */ + public function logLastLogoutAt(Observer $observer) + { + $this->logger->log( + $observer->getEvent()->getCustomer()->getId(), + ['last_logout_at' => (new \DateTime())->format(\Magento\Framework\Stdlib\DateTime::DATETIME_PHP_FORMAT)] + ); + } +} diff --git a/app/code/Magento/Customer/Model/Resource/Address.php b/app/code/Magento/Customer/Model/Resource/Address.php index 3fbe59955af8a57d7f69fe27f2070a2df37d5bca..57a5c1cbcf3d9c28e975a999395d5ffd18600696 100644 --- a/app/code/Magento/Customer/Model/Resource/Address.php +++ b/app/code/Magento/Customer/Model/Resource/Address.php @@ -99,16 +99,15 @@ class Address extends \Magento\Eav\Model\Entity\AbstractEntity * * @param \Magento\Framework\Object $address * @return void - * @throws \Magento\Framework\Validator\ValidatorException When validation failed + * @throws \Magento\Framework\Validator\Exception When validation failed */ protected function _validate($address) { $validator = $this->_validatorFactory->createValidator('customer_address', 'save'); if (!$validator->isValid($address)) { - throw new \Magento\Framework\Validator\ValidatorException( - InputException::DEFAULT_MESSAGE, - [], + throw new \Magento\Framework\Validator\Exception( + null, null, $validator->getMessages() ); diff --git a/app/code/Magento/Customer/Model/Resource/AddressRepository.php b/app/code/Magento/Customer/Model/Resource/AddressRepository.php index ce60b52c51c20722c26ab4bbf8c23dfcb8c521e2..54f51092c34cdfec9042dee1c36f9c9b50466368 100644 --- a/app/code/Magento/Customer/Model/Resource/AddressRepository.php +++ b/app/code/Magento/Customer/Model/Resource/AddressRepository.php @@ -248,41 +248,41 @@ class AddressRepository implements \Magento\Customer\Api\AddressRepositoryInterf } if (!\Zend_Validate::is($customerAddressModel->getFirstname(), 'NotEmpty')) { - $exception->addError(InputException::REQUIRED_FIELD, ['fieldName' => 'firstname']); + $exception->addError(__(InputException::REQUIRED_FIELD, ['fieldName' => 'firstname'])); } if (!\Zend_Validate::is($customerAddressModel->getLastname(), 'NotEmpty')) { - $exception->addError(InputException::REQUIRED_FIELD, ['fieldName' => 'lastname']); + $exception->addError(__(InputException::REQUIRED_FIELD, ['fieldName' => 'lastname'])); } if (!\Zend_Validate::is($customerAddressModel->getStreetLine(1), 'NotEmpty')) { - $exception->addError(InputException::REQUIRED_FIELD, ['fieldName' => 'street']); + $exception->addError(__(InputException::REQUIRED_FIELD, ['fieldName' => 'street'])); } if (!\Zend_Validate::is($customerAddressModel->getCity(), 'NotEmpty')) { - $exception->addError(InputException::REQUIRED_FIELD, ['fieldName' => 'city']); + $exception->addError(__(InputException::REQUIRED_FIELD, ['fieldName' => 'city'])); } if (!\Zend_Validate::is($customerAddressModel->getTelephone(), 'NotEmpty')) { - $exception->addError(InputException::REQUIRED_FIELD, ['fieldName' => 'telephone']); + $exception->addError(__(InputException::REQUIRED_FIELD, ['fieldName' => 'telephone'])); } $havingOptionalZip = $this->directoryData->getCountriesWithOptionalZip(); if (!in_array($customerAddressModel->getCountryId(), $havingOptionalZip) && !\Zend_Validate::is($customerAddressModel->getPostcode(), 'NotEmpty') ) { - $exception->addError(InputException::REQUIRED_FIELD, ['fieldName' => 'postcode']); + $exception->addError(__(InputException::REQUIRED_FIELD, ['fieldName' => 'postcode'])); } if (!\Zend_Validate::is($customerAddressModel->getCountryId(), 'NotEmpty')) { - $exception->addError(InputException::REQUIRED_FIELD, ['fieldName' => 'countryId']); + $exception->addError(__(InputException::REQUIRED_FIELD, ['fieldName' => 'countryId'])); } if ($customerAddressModel->getCountryModel()->getRegionCollection()->getSize() && !\Zend_Validate::is($customerAddressModel->getRegionId(), 'NotEmpty') && $this->directoryData->isRegionRequired($customerAddressModel->getCountryId()) ) { - $exception->addError(InputException::REQUIRED_FIELD, ['fieldName' => 'regionId']); + $exception->addError(__(InputException::REQUIRED_FIELD, ['fieldName' => 'regionId'])); } return $exception; diff --git a/app/code/Magento/Customer/Model/Resource/Customer.php b/app/code/Magento/Customer/Model/Resource/Customer.php index 9e14f1091ccb5954da6fd2663967ea7e466b2619..ae27ce56ce01b89308ca7a562d05448b34c95c54 100644 --- a/app/code/Magento/Customer/Model/Resource/Customer.php +++ b/app/code/Magento/Customer/Model/Resource/Customer.php @@ -5,7 +5,7 @@ */ namespace Magento\Customer\Model\Resource; -use Magento\Framework\Validator\ValidatorException; +use Magento\Framework\Validator\Exception as ValidatorException; use Magento\Framework\Exception\AlreadyExistsException; /** @@ -131,7 +131,7 @@ class Customer extends \Magento\Eav\Model\Entity\AbstractEntity * * @param \Magento\Customer\Model\Customer $customer * @return void - * @throws \Magento\Framework\Validator\ValidatorException + * @throws \Magento\Framework\Validator\Exception */ protected function _validate($customer) { @@ -139,8 +139,7 @@ class Customer extends \Magento\Eav\Model\Entity\AbstractEntity if (!$validator->isValid($customer)) { throw new ValidatorException( - ValidatorException::DEFAULT_MESSAGE, - [], + null, null, $validator->getMessages() ); diff --git a/app/code/Magento/Customer/Model/Resource/CustomerRepository.php b/app/code/Magento/Customer/Model/Resource/CustomerRepository.php index 757ef49198d792f77de17761bd01f7d30e67e8b4..58adabf2ba9b0bccd93e69bf39da32a2226ef966 100644 --- a/app/code/Magento/Customer/Model/Resource/CustomerRepository.php +++ b/app/code/Magento/Customer/Model/Resource/CustomerRepository.php @@ -283,11 +283,11 @@ class CustomerRepository implements \Magento\Customer\Api\CustomerRepositoryInte { $exception = new InputException(); if (!\Zend_Validate::is(trim($customer->getFirstname()), 'NotEmpty')) { - $exception->addError(InputException::REQUIRED_FIELD, ['fieldName' => 'firstname']); + $exception->addError(__(InputException::REQUIRED_FIELD, ['fieldName' => 'firstname'])); } if (!\Zend_Validate::is(trim($customer->getLastname()), 'NotEmpty')) { - $exception->addError(InputException::REQUIRED_FIELD, ['fieldName' => 'lastname']); + $exception->addError(__(InputException::REQUIRED_FIELD, ['fieldName' => 'lastname'])); } $isEmailAddress = \Zend_Validate::is( @@ -298,24 +298,26 @@ class CustomerRepository implements \Magento\Customer\Api\CustomerRepositoryInte if (!$isEmailAddress) { $exception->addError( - InputException::INVALID_FIELD_VALUE, - ['fieldName' => 'email', 'value' => $customer->getEmail()] + __( + InputException::INVALID_FIELD_VALUE, + ['fieldName' => 'email', 'value' => $customer->getEmail()] + ) ); } $dob = $this->getAttributeMetadata('dob'); if (!is_null($dob) && $dob->isRequired() && '' == trim($customer->getDob())) { - $exception->addError(InputException::REQUIRED_FIELD, ['fieldName' => 'dob']); + $exception->addError(__(InputException::REQUIRED_FIELD, ['fieldName' => 'dob'])); } $taxvat = $this->getAttributeMetadata('taxvat'); if (!is_null($taxvat) && $taxvat->isRequired() && '' == trim($customer->getTaxvat())) { - $exception->addError(InputException::REQUIRED_FIELD, ['fieldName' => 'taxvat']); + $exception->addError(__(InputException::REQUIRED_FIELD, ['fieldName' => 'taxvat'])); } $gender = $this->getAttributeMetadata('gender'); if (!is_null($gender) && $gender->isRequired() && '' == trim($customer->getGender())) { - $exception->addError(InputException::REQUIRED_FIELD, ['fieldName' => 'gender']); + $exception->addError(__(InputException::REQUIRED_FIELD, ['fieldName' => 'gender'])); } if ($exception->wasErrorAdded()) { diff --git a/app/code/Magento/Customer/Model/Resource/GroupRepository.php b/app/code/Magento/Customer/Model/Resource/GroupRepository.php index 74f227df9ebf71c99d6b4765cd41530dda28d63f..73b59ff2dd1e54166d149019ae8585076b46b37d 100644 --- a/app/code/Magento/Customer/Model/Resource/GroupRepository.php +++ b/app/code/Magento/Customer/Model/Resource/GroupRepository.php @@ -125,7 +125,7 @@ class GroupRepository implements \Magento\Customer\Api\GroupRepositoryInterface * difficult to do without imposing more database calls */ if ($e->getMessage() == (string)__('Customer Group already exists.')) { - throw new InvalidTransitionException('Customer Group already exists.'); + throw new InvalidTransitionException(__('Customer Group already exists.')); } throw $e; } @@ -266,7 +266,7 @@ class GroupRepository implements \Magento\Customer\Api\GroupRepositoryInterface $groupModel = $this->groupRegistry->retrieve($id); if ($id <= 0 || $groupModel->usesAsDefault()) { - throw new \Magento\Framework\Exception\StateException('Cannot delete group.'); + throw new \Magento\Framework\Exception\StateException(__('Cannot delete group.')); } $groupModel->delete(); @@ -288,7 +288,7 @@ class GroupRepository implements \Magento\Customer\Api\GroupRepositoryInterface { $exception = new InputException(); if (!\Zend_Validate::is($group->getCode(), 'NotEmpty')) { - $exception->addError(InputException::REQUIRED_FIELD, ['fieldName' => 'code']); + $exception->addError(__(InputException::REQUIRED_FIELD, ['fieldName' => 'code'])); } if ($exception->wasErrorAdded()) { diff --git a/app/code/Magento/Customer/Model/Resource/Visitor.php b/app/code/Magento/Customer/Model/Resource/Visitor.php index 639590bd07e85009d7002a63e1d16f678f875f18..8cc63d45988cad52b67034d5f07a32af0bfbc338 100644 --- a/app/code/Magento/Customer/Model/Resource/Visitor.php +++ b/app/code/Magento/Customer/Model/Resource/Visitor.php @@ -58,6 +58,7 @@ class Visitor extends \Magento\Framework\Model\Resource\Db\AbstractDb protected function _prepareDataForSave(\Magento\Framework\Model\AbstractModel $visitor) { return [ + 'customer_id' => $visitor->getCustomerId(), 'session_id' => $visitor->getSessionId(), 'last_visit_at' => $visitor->getLastVisitAt() ]; diff --git a/app/code/Magento/Customer/Model/Vat.php b/app/code/Magento/Customer/Model/Vat.php index d20d51b2f788155be9e6b62bea29cbe69e5cecad..0930595e6758900822694ea2b2b410ff490999df 100644 --- a/app/code/Magento/Customer/Model/Vat.php +++ b/app/code/Magento/Customer/Model/Vat.php @@ -6,7 +6,7 @@ namespace Magento\Customer\Model; use Magento\Framework\App\Config\ScopeConfigInterface; -use Psr\Log\LoggerInterface as Logger; +use Psr\Log\LoggerInterface as PsrLogger; use Magento\Store\Model\ScopeInterface; /** @@ -68,17 +68,17 @@ class Vat protected $scopeConfig; /** - * @var Logger + * @var PsrLogger */ protected $logger; /** * @param ScopeConfigInterface $scopeConfig - * @param Logger $logger + * @param PsrLogger $logger */ public function __construct( ScopeConfigInterface $scopeConfig, - Logger $logger + PsrLogger $logger ) { $this->scopeConfig = $scopeConfig; $this->logger = $logger; diff --git a/app/code/Magento/Customer/Model/Visitor.php b/app/code/Magento/Customer/Model/Visitor.php index 4fc1c3a8026535a7f3bad674f5c1abea19b7fb16..132fd35acc9d1c66adc5be763fd2214760fb6247 100644 --- a/app/code/Magento/Customer/Model/Visitor.php +++ b/app/code/Magento/Customer/Model/Visitor.php @@ -133,14 +133,15 @@ class Visitor extends \Magento\Framework\Model\AbstractModel if ($this->skipRequestLogging || $this->isModuleIgnored($observer)) { return $this; } + if ($this->session->getVisitorData()) { $this->setData($this->session->getVisitorData()); } + + $this->setLastVisitAt((new \DateTime())->format(\Magento\Framework\Stdlib\DateTime::DATETIME_PHP_FORMAT)); + if (!$this->getId()) { $this->setSessionId($this->session->getSessionId()); - $this->setLastVisitAt( - (new \DateTime())->format(\Magento\Framework\Stdlib\DateTime::DATETIME_PHP_FORMAT) - ); $this->save(); $this->_eventManager->dispatch('visitor_init', ['visitor' => $this]); $this->session->setVisitorData($this->getData()); diff --git a/app/code/Magento/Customer/Setup/UpgradeSchema.php b/app/code/Magento/Customer/Setup/UpgradeSchema.php index 6ebf692405649991e59149a9f47a5ffda6508ce3..2b7a160eb3de8495fa5fa096bb76dd41a3e748e3 100644 --- a/app/code/Magento/Customer/Setup/UpgradeSchema.php +++ b/app/code/Magento/Customer/Setup/UpgradeSchema.php @@ -6,6 +6,8 @@ namespace Magento\Customer\Setup; +use Magento\Framework\DB\Ddl\Table; +use Magento\Framework\DB\Adapter\AdapterInterface; use Magento\Framework\Setup\UpgradeSchemaInterface; use Magento\Framework\Setup\ModuleContextInterface; use Magento\Framework\Setup\SchemaSetupInterface; @@ -17,12 +19,14 @@ class UpgradeSchema implements UpgradeSchemaInterface { /** * {@inheritdoc} + * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $context) { + $setup->startSetup(); + if (version_compare($context->getVersion(), '2.0.0.1') < 0) { $installer = $setup; - $installer->startSetup(); $connection = $installer->getConnection(); $tableNames = [ @@ -57,7 +61,96 @@ class UpgradeSchema implements UpgradeSchemaInterface ); $connection->dropColumn($installer->getTable('customer_entity'), 'entity_type_id'); $connection->dropColumn($installer->getTable('customer_entity'), 'attribute_set_id'); - $installer->endSetup(); } + + if (version_compare($context->getVersion(), '2.0.0.2') < 0) { + /** + * Update 'customer_visitor' table. + */ + $setup->getConnection() + ->addColumn( + $setup->getTable('customer_visitor'), + 'customer_id', + [ + 'type' => Table::TYPE_INTEGER, + 'after' => 'visitor_id', + 'comment' => 'Customer ID' + ] + ); + + $setup->getConnection() + ->addIndex( + $setup->getTable('customer_visitor'), + $setup->getIdxName( + $setup->getTable('customer_visitor'), + ['customer_id'] + ), + 'customer_id' + ); + + /** + * Create 'customer_log' table. + */ + $table = $setup->getConnection() + ->newTable( + $setup->getTable('customer_log') + ) + ->addColumn( + 'log_id', + Table::TYPE_INTEGER, + null, + [ + 'nullable' => false, + 'identity' => true, + 'primary' => true + ], + 'Log ID' + ) + ->addColumn( + 'customer_id', + Table::TYPE_INTEGER, + null, + [ + 'nullable' => false + ], + 'Customer ID' + ) + ->addColumn( + 'last_login_at', + Table::TYPE_TIMESTAMP, + null, + [ + 'nullable' => true, + 'default' => null + ], + 'Last Login Time' + ) + ->addColumn( + 'last_logout_at', + Table::TYPE_TIMESTAMP, + null, + [ + 'nullable' => true, + 'default' => null + ], + 'Last Logout Time' + ) + ->addIndex( + $setup->getIdxName( + $setup->getTable('customer_log'), + ['customer_id'], + AdapterInterface::INDEX_TYPE_UNIQUE + ), + ['customer_id'], + [ + 'type' => AdapterInterface::INDEX_TYPE_UNIQUE + ] + ) + ->setComment('Customer Log Table'); + + $setup->getConnection()->createTable($table); + } + + $setup->endSetup(); } } diff --git a/app/code/Magento/Customer/Test/Unit/Block/Account/Dashboard/InfoTest.php b/app/code/Magento/Customer/Test/Unit/Block/Account/Dashboard/InfoTest.php index 54babee0fd4231e4ec44b7709f4616d216dfda4f..feaf248f233fed187703debc236d69e4d696d821 100644 --- a/app/code/Magento/Customer/Test/Unit/Block/Account/Dashboard/InfoTest.php +++ b/app/code/Magento/Customer/Test/Unit/Block/Account/Dashboard/InfoTest.php @@ -133,15 +133,15 @@ class InfoTest extends \PHPUnit_Framework_TestCase public function testGetCustomerException() { - $this->currentCustomer->expects( - $this->once() - )->method( - 'getCustomer' - )->will($this->throwException(new NoSuchEntityException( + $this->currentCustomer->expects($this->once()) + ->method('getCustomer') + ->will( + $this->throwException(new NoSuchEntityException( + __( NoSuchEntityException::MESSAGE_SINGLE_FIELD, ['fieldName' => 'customerId', 'fieldValue' => 1] ) - ) + )) ); $this->assertNull($this->_block->getCustomer()); diff --git a/app/code/Magento/Customer/Test/Unit/Block/Adminhtml/Edit/Tab/View/PersonalInfoTest.php b/app/code/Magento/Customer/Test/Unit/Block/Adminhtml/Edit/Tab/View/PersonalInfoTest.php new file mode 100644 index 0000000000000000000000000000000000000000..a196a2917f99477245f5f7e8cc7fd6b74533dfcb --- /dev/null +++ b/app/code/Magento/Customer/Test/Unit/Block/Adminhtml/Edit/Tab/View/PersonalInfoTest.php @@ -0,0 +1,239 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Customer\Test\Unit\Block\Adminhtml\Edit\Tab\View; + +use Magento\Customer\Block\Adminhtml\Edit\Tab\View\PersonalInfo; +use Magento\Framework\Stdlib\DateTime; + +/** + * Customer personal information template block test. + */ +class PersonalInfoTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var string + */ + protected $defaultTimezone = 'America/Los_Angeles'; + + /** + * @var string + */ + protected $pathToDefaultTimezone = 'path/to/default/timezone'; + + /** + * @var PersonalInfo + */ + protected $block; + + /** + * @var \Magento\Customer\Model\Log|\PHPUnit_Framework_MockObject_MockObject + */ + protected $customerLog; + + /** + * @var \Magento\Framework\Stdlib\DateTime\TimezoneInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $localeDate; + + /** + * @var \Magento\Framework\App\Config\ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $scopeConfig; + + /** + * @return void + */ + protected function setUp() + { + $customer = $this->getMock( + 'Magento\Customer\Api\Data\CustomerInterface', + [], + [], + '', + false + ); + $customer->expects($this->any())->method('getId')->willReturn(1); + $customer->expects($this->any())->method('getStoreId')->willReturn(1); + + $customerDataFactory = $this->getMock( + 'Magento\Customer\Api\Data\CustomerInterfaceFactory', + ['create'], + [], + '', + false + ); + $customerDataFactory->expects($this->any())->method('create')->willReturn($customer); + + $backendSession = $this->getMock( + 'Magento\Backend\Model\Session', + ['getCustomerData'], + [], + '', + false + ); + $backendSession->expects($this->any())->method('getCustomerData')->willReturn(['account' => []]); + + $this->customerLog = $this->getMock( + 'Magento\Customer\Model\Log', + ['getLastLoginAt', 'getLastVisitAt', 'getLastLogoutAt'], + [], + '', + false + ); + $this->customerLog->expects($this->any())->method('loadByCustomer')->willReturnSelf(); + + $customerLogger = $this->getMock( + 'Magento\Customer\Model\Logger', + ['get'], + [], + '', + false + ); + $customerLogger->expects($this->any())->method('get')->willReturn($this->customerLog); + + $dateTime = $this->getMock( + 'Magento\Framework\Stdlib\DateTime', + ['now'], + [], + '', + false + ); + $dateTime->expects($this->any())->method('now')->willReturn('2015-03-04 12:00:00'); + + $this->localeDate = $this->getMock( + 'Magento\Framework\Stdlib\DateTime\Timezone', + ['scopeDate', 'formatDateTime', 'getDefaultTimezonePath'], + [], + '', + false + ); + $this->localeDate + ->expects($this->any()) + ->method('getDefaultTimezonePath') + ->willReturn($this->pathToDefaultTimezone); + + $this->scopeConfig = $this->getMock( + 'Magento\Framework\App\Config', + ['getValue'], + [], + '', + false + ); + + $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); + + $this->block = $objectManagerHelper->getObject( + 'Magento\Customer\Block\Adminhtml\Edit\Tab\View\PersonalInfo', + [ + 'customerDataFactory' => $customerDataFactory, + 'dateTime' => $dateTime, + 'customerLogger' => $customerLogger, + 'localeDate' => $this->localeDate, + 'scopeConfig' => $this->scopeConfig, + 'backendSession' => $backendSession, + ] + ); + } + + /** + * @return void + */ + public function testGetStoreLastLoginDateTimezone() + { + $this->scopeConfig + ->expects($this->once()) + ->method('getValue') + ->with( + $this->pathToDefaultTimezone, + \Magento\Store\Model\ScopeInterface::SCOPE_STORE + ) + ->willReturn($this->defaultTimezone); + + $this->assertEquals($this->defaultTimezone, $this->block->getStoreLastLoginDateTimezone()); + } + + /** + * @param string $status + * @param string|null $lastLoginAt + * @param string|null $lastVisitAt + * @param string|null $lastLogoutAt + * @return void + * @dataProvider getCurrentStatusDataProvider + */ + public function testGetCurrentStatus($status, $lastLoginAt, $lastVisitAt, $lastLogoutAt) + { + $this->customerLog->expects($this->any())->method('getLastLoginAt')->willReturn($lastLoginAt); + $this->customerLog->expects($this->any())->method('getLastVisitAt')->willReturn($lastVisitAt); + $this->customerLog->expects($this->any())->method('getLastLogoutAt')->willReturn($lastLogoutAt); + + $this->assertEquals($status, (string) $this->block->getCurrentStatus()); + } + + /** + * @return array + */ + public function getCurrentStatusDataProvider() + { + return [ + ['Offline', null, null, null], + ['Offline', '2015-03-04 11:00:00', null, '2015-03-04 12:00:00'], + ['Offline', '2015-03-04 11:00:00', '2015-03-04 11:40:00', null], + ['Online', '2015-03-04 11:00:00', (new \DateTime())->format(DateTime::DATETIME_PHP_FORMAT), null] + ]; + } + + /** + * @param string $result + * @param string|null $lastLoginAt + * @dataProvider getLastLoginDateDataProvider + * @return void + */ + public function testGetLastLoginDate($result, $lastLoginAt) + { + $this->customerLog->expects($this->once())->method('getLastLoginAt')->willReturn($lastLoginAt); + $this->localeDate->expects($this->any())->method('formatDateTime')->willReturn($lastLoginAt); + + $this->assertEquals($result, $this->block->getLastLoginDate()); + } + + /** + * @return array + */ + public function getLastLoginDateDataProvider() + { + return [ + ['2015-03-04 12:00:00', '2015-03-04 12:00:00'], + ['Never', null] + ]; + } + + /** + * @param string $result + * @param string|null $lastLoginAt + * @dataProvider getStoreLastLoginDateDataProvider + * @return void + */ + public function testGetStoreLastLoginDate($result, $lastLoginAt) + { + $this->customerLog->expects($this->once())->method('getLastLoginAt')->willReturn($lastLoginAt); + + $this->localeDate->expects($this->any())->method('scopeDate')->will($this->returnValue($lastLoginAt)); + $this->localeDate->expects($this->any())->method('formatDateTime')->willReturn($lastLoginAt); + + $this->assertEquals($result, $this->block->getStoreLastLoginDate()); + } + + /** + * @return array + */ + public function getStoreLastLoginDateDataProvider() + { + return [ + ['2015-03-04 12:00:00', '2015-03-04 12:00:00'], + ['Never', null] + ]; + } +} diff --git a/app/code/Magento/Customer/Test/Unit/Block/Form/LoginTest.php b/app/code/Magento/Customer/Test/Unit/Block/Form/Login/InfoTest.php similarity index 68% rename from app/code/Magento/Customer/Test/Unit/Block/Form/LoginTest.php rename to app/code/Magento/Customer/Test/Unit/Block/Form/Login/InfoTest.php index 493674bf0ad7290d4591bf1915fa5843e7d35168..b45a2811d9dd36cb67bcb332a667737915df0f64 100644 --- a/app/code/Magento/Customer/Test/Unit/Block/Form/LoginTest.php +++ b/app/code/Magento/Customer/Test/Unit/Block/Form/Login/InfoTest.php @@ -3,17 +3,12 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Customer\Test\Unit\Block\Form; +namespace Magento\Customer\Test\Unit\Block\Form\Login; -class LoginTest extends \PHPUnit_Framework_TestCase +class InfoTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager - */ - protected $objectManager; - - /** - * @var \Magento\Customer\Block\Form\Login + * @var \Magento\Customer\Block\Form\Login\Info */ protected $block; @@ -50,9 +45,8 @@ class LoginTest extends \PHPUnit_Framework_TestCase ['addRequestParam'] )->getMock(); - $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->block = $this->objectManager->getObject( - 'Magento\Customer\Block\Form\Login', + $this->block = (new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this))->getObject( + 'Magento\Customer\Block\Form\Login\Info', [ 'customerUrl' => $this->customerUrl, 'checkoutData' => $this->checkoutData, @@ -61,13 +55,20 @@ class LoginTest extends \PHPUnit_Framework_TestCase ); } - public function testGetCreateAccountUrl() + public function testGetExistingCreateAccountUrl() { $expectedUrl = 'Custom Url'; $this->block->setCreateAccountUrl($expectedUrl); $this->checkoutData->expects($this->any())->method('isContextCheckout')->will($this->returnValue(false)); $this->assertEquals($expectedUrl, $this->block->getCreateAccountUrl()); + } + + public function testGetCreateAccountUrlWithContext() + { + $url = 'Custom Url'; + $expectedUrl = 'Custom Url with context'; + $this->block->setCreateAccountUrl($url); $this->checkoutData->expects($this->any())->method('isContextCheckout')->will($this->returnValue(true)); $this->coreUrl->expects( @@ -75,30 +76,20 @@ class LoginTest extends \PHPUnit_Framework_TestCase )->method( 'addRequestParam' )->with( - $expectedUrl, + $url, ['context' => 'checkout'] )->will( $this->returnValue($expectedUrl) ); $this->assertEquals($expectedUrl, $this->block->getCreateAccountUrl()); + } - $this->block->unsCreateAccountUrl(); - $this->customerUrl->expects($this->any())->method('getRegisterUrl')->will($this->returnValue($expectedUrl)); - $this->checkoutData->expects($this->any())->method('isContextCheckout')->will($this->returnValue(false)); - $this->assertEquals($expectedUrl, $this->block->getCreateAccountUrl()); + public function testGetCreateAccountUrl() + { + $expectedUrl = 'Custom Url'; $this->customerUrl->expects($this->any())->method('getRegisterUrl')->will($this->returnValue($expectedUrl)); - $this->checkoutData->expects($this->any())->method('isContextCheckout')->will($this->returnValue(true)); - $this->coreUrl->expects( - $this->any() - )->method( - 'addRequestParam' - )->with( - $expectedUrl, - ['context' => 'checkout'] - )->will( - $this->returnValue($expectedUrl) - ); + $this->checkoutData->expects($this->any())->method('isContextCheckout')->will($this->returnValue(false)); $this->assertEquals($expectedUrl, $this->block->getCreateAccountUrl()); } } diff --git a/app/code/Magento/Customer/Test/Unit/Block/Widget/DobTest.php b/app/code/Magento/Customer/Test/Unit/Block/Widget/DobTest.php index 347ad1ee35a4f2e2816c1a42204aa6968d02740e..5d1e91708b4fcd6da306011c551415bf3586d66a 100644 --- a/app/code/Magento/Customer/Test/Unit/Block/Widget/DobTest.php +++ b/app/code/Magento/Customer/Test/Unit/Block/Widget/DobTest.php @@ -118,16 +118,15 @@ class DobTest extends \PHPUnit_Framework_TestCase public function testIsEnabledWithException() { - $this->customerMetadata->expects( - $this->any() - )->method( - 'getAttributeMetadata' - )->will( + $this->customerMetadata->expects($this->any()) + ->method('getAttributeMetadata') + ->will( $this->throwException(new NoSuchEntityException( + __( NoSuchEntityException::MESSAGE_SINGLE_FIELD, ['fieldName' => 'field', 'fieldValue' => 'value'] ) - ) + )) ); $this->assertSame(false, $this->_block->isEnabled()); } @@ -146,16 +145,15 @@ class DobTest extends \PHPUnit_Framework_TestCase public function testIsRequiredWithException() { - $this->customerMetadata->expects( - $this->any() - )->method( - 'getAttributeMetadata' - )->will( + $this->customerMetadata->expects($this->any()) + ->method('getAttributeMetadata') + ->will( $this->throwException(new NoSuchEntityException( + __( NoSuchEntityException::MESSAGE_SINGLE_FIELD, ['fieldName' => 'field', 'fieldValue' => 'value'] ) - ) + )) ); $this->assertSame(false, $this->_block->isRequired()); } @@ -346,16 +344,15 @@ class DobTest extends \PHPUnit_Framework_TestCase public function testGetMinDateRangeWithException() { - $this->customerMetadata->expects( - $this->any() - )->method( - 'getAttributeMetadata' - )->will( + $this->customerMetadata->expects($this->any()) + ->method('getAttributeMetadata') + ->will( $this->throwException(new NoSuchEntityException( + __( NoSuchEntityException::MESSAGE_SINGLE_FIELD, ['fieldName' => 'field', 'fieldValue' => 'value'] ) - ) + )) ); $this->assertNull($this->_block->getMinDateRange()); } @@ -416,16 +413,15 @@ class DobTest extends \PHPUnit_Framework_TestCase public function testGetMaxDateRangeWithException() { - $this->customerMetadata->expects( - $this->any() - )->method( - 'getAttributeMetadata' - )->will( + $this->customerMetadata->expects($this->any()) + ->method('getAttributeMetadata') + ->will( $this->throwException(new NoSuchEntityException( + __( NoSuchEntityException::MESSAGE_SINGLE_FIELD, ['fieldName' => 'field', 'fieldValue' => 'value'] ) - ) + )) ); $this->assertNull($this->_block->getMaxDateRange()); } diff --git a/app/code/Magento/Customer/Test/Unit/Block/Widget/GenderTest.php b/app/code/Magento/Customer/Test/Unit/Block/Widget/GenderTest.php index 74ae91c3c4293cfaf022cefa6e94867eb87c0075..ed42e290f660c720620941122ef46e86a94ef0e7 100644 --- a/app/code/Magento/Customer/Test/Unit/Block/Widget/GenderTest.php +++ b/app/code/Magento/Customer/Test/Unit/Block/Widget/GenderTest.php @@ -94,10 +94,11 @@ class GenderTest extends \PHPUnit_Framework_TestCase 'getAttributeMetadata' )->will( $this->throwException(new NoSuchEntityException( + __( NoSuchEntityException::MESSAGE_SINGLE_FIELD, ['fieldName' => 'field', 'fieldValue' => 'value'] ) - ) + )) ); $this->assertSame(false, $this->block->isEnabled()); } @@ -134,10 +135,11 @@ class GenderTest extends \PHPUnit_Framework_TestCase 'getAttributeMetadata' )->will( $this->throwException(new NoSuchEntityException( + __( NoSuchEntityException::MESSAGE_SINGLE_FIELD, ['fieldName' => 'field', 'fieldValue' => 'value'] ) - ) + )) ); $this->assertSame(false, $this->block->isRequired()); } diff --git a/app/code/Magento/Customer/Test/Unit/Block/Widget/NameTest.php b/app/code/Magento/Customer/Test/Unit/Block/Widget/NameTest.php index c58604088c81bbac849ef58b6f61f3d41cbc15d9..5f15f240fd977aba2ce1e7a0f32f061fc682d81c 100644 --- a/app/code/Magento/Customer/Test/Unit/Block/Widget/NameTest.php +++ b/app/code/Magento/Customer/Test/Unit/Block/Widget/NameTest.php @@ -127,10 +127,11 @@ class NameTest extends \PHPUnit_Framework_TestCase 'getAttributeMetadata' )->will( $this->throwException(new NoSuchEntityException( + __( NoSuchEntityException::MESSAGE_SINGLE_FIELD, ['fieldName' => 'field', 'fieldValue' => 'value'] ) - ) + )) ); $this->assertFalse($this->_block->showPrefix()); } @@ -147,10 +148,11 @@ class NameTest extends \PHPUnit_Framework_TestCase 'getAttributeMetadata' )->will( $this->throwException(new NoSuchEntityException( + __( NoSuchEntityException::MESSAGE_SINGLE_FIELD, ['fieldName' => 'field', 'fieldValue' => 'value'] ) - ) + )) ); $this->assertFalse($this->_block->{$method}()); } @@ -395,10 +397,11 @@ class NameTest extends \PHPUnit_Framework_TestCase 'getAttributeMetadata' )->will( $this->throwException(new NoSuchEntityException( + __( NoSuchEntityException::MESSAGE_SINGLE_FIELD, ['fieldName' => 'field', 'fieldValue' => 'value'] ) - ) + )) ); $this->assertSame('', (string)$this->_block->getStoreLabel('attributeCode')); } diff --git a/app/code/Magento/Customer/Test/Unit/Block/Widget/TaxvatTest.php b/app/code/Magento/Customer/Test/Unit/Block/Widget/TaxvatTest.php index 474f6c42467aeab94cc08a8bf18a8a3044ca869d..356d748dab9db6d29f92eae976356cb1b25a7c78 100644 --- a/app/code/Magento/Customer/Test/Unit/Block/Widget/TaxvatTest.php +++ b/app/code/Magento/Customer/Test/Unit/Block/Widget/TaxvatTest.php @@ -81,10 +81,11 @@ class TaxvatTest extends \PHPUnit_Framework_TestCase 'getAttributeMetadata' )->will( $this->throwException(new NoSuchEntityException( + __( NoSuchEntityException::MESSAGE_SINGLE_FIELD, ['fieldName' => 'field', 'fieldValue' => 'value'] ) - ) + )) ); $this->assertSame(false, $this->_block->isEnabled()); } @@ -118,10 +119,11 @@ class TaxvatTest extends \PHPUnit_Framework_TestCase 'getAttributeMetadata' )->will( $this->throwException(new NoSuchEntityException( + __( NoSuchEntityException::MESSAGE_SINGLE_FIELD, ['fieldName' => 'field', 'fieldValue' => 'value'] ) - ) + )) ); $this->assertSame(false, $this->_block->isRequired()); } diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Account/ConfirmTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Account/ConfirmTest.php index 6323dec97d41723037ebf55067c6a088d3c6f5bd..a4fe4832056411b7453b2eaa2b8b01ea04d3b010 100644 --- a/app/code/Magento/Customer/Test/Unit/Controller/Account/ConfirmTest.php +++ b/app/code/Magento/Customer/Test/Unit/Controller/Account/ConfirmTest.php @@ -19,7 +19,7 @@ use Magento\Store\Model\ScopeInterface; class ConfirmTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Customer\Controller\Account + * @var \Magento\Customer\Controller\Account\Confirm */ protected $model; @@ -171,7 +171,7 @@ class ConfirmTest extends \PHPUnit_Framework_TestCase 'customerRepository' => $this->customerRepositoryMock, 'addressHelper' => $this->addressHelperMock, 'urlFactory' => $urlFactoryMock, - 'resultRedirectFactory' => $redirectFactoryMock + 'resultRedirectFactory' => $redirectFactoryMock, ] ); } @@ -426,7 +426,7 @@ class ConfirmTest extends \PHPUnit_Framework_TestCase 'http://example.com/success', 'http://example.com/success', true, - __('Thank you for registering with') + __('Thank you for registering with'), ], [ 1, @@ -435,7 +435,7 @@ class ConfirmTest extends \PHPUnit_Framework_TestCase 'http://example.com/success', 'http://example.com/success', false, - __('Thank you for registering with') + __('Thank you for registering with'), ], ]; } diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/ResetPasswordTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/ResetPasswordTest.php index 10056504ec33f3fba2f7efaee609ee226dd13a25..53ffa02b353e2fdb921a19e0b1f52063359ac365 100644 --- a/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/ResetPasswordTest.php +++ b/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/ResetPasswordTest.php @@ -281,8 +281,10 @@ class ResetPasswordTest extends \PHPUnit_Framework_TestCase )->will( $this->throwException( new NoSuchEntityException( - NoSuchEntityException::MESSAGE_SINGLE_FIELD, - ['fieldName' => 'customerId', 'fieldValue' => $customerId] + __( + NoSuchEntityException::MESSAGE_SINGLE_FIELD, + ['fieldName' => 'customerId', 'fieldValue' => $customerId] + ) ) ) ); @@ -324,7 +326,7 @@ class ResetPasswordTest extends \PHPUnit_Framework_TestCase ); // Setup a core exception to return - $exception = new \Magento\Framework\Validator\ValidatorException(); + $exception = new \Magento\Framework\Validator\Exception(); $error = new \Magento\Framework\Message\Error('Something Bad happened'); $exception->addMessage($error); @@ -357,7 +359,7 @@ class ResetPasswordTest extends \PHPUnit_Framework_TestCase ->willReturn($customerId); // Setup a core exception to return - $exception = new \Magento\Framework\Validator\ValidatorException($warningText); + $exception = new \Magento\Framework\Validator\Exception(__($warningText)); $error = new \Magento\Framework\Message\Warning('Something Not So Bad happened'); $exception->addMessage($error); diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Ajax/LoginTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Ajax/LoginTest.php old mode 100644 new mode 100755 index ed14df9d4b7776c3e24239cf46a57b4aaa9fac5c..55518d9fab215f8d19bba5576e326393153add2b --- a/app/code/Magento/Customer/Test/Unit/Controller/Ajax/LoginTest.php +++ b/app/code/Magento/Customer/Test/Unit/Controller/Ajax/LoginTest.php @@ -51,12 +51,12 @@ class LoginTest extends \PHPUnit_Framework_TestCase protected $jsonHelperMock; /** - * @var \Magento\Framework\Controller\Result\JSON|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Controller\Result\Json|\PHPUnit_Framework_MockObject_MockObject */ protected $resultJson; /** - * @var \Magento\Framework\Controller\Result\JSONFactory| \PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Controller\Result\JsonFactory| \PHPUnit_Framework_MockObject_MockObject */ protected $resultJsonFactory; @@ -114,10 +114,10 @@ class LoginTest extends \PHPUnit_Framework_TestCase false ); - $this->resultJson = $this->getMockBuilder('Magento\Framework\Controller\Result\JSON') + $this->resultJson = $this->getMockBuilder('Magento\Framework\Controller\Result\Json') ->disableOriginalConstructor() ->getMock(); - $this->resultJsonFactory = $this->getMockBuilder('Magento\Framework\Controller\Result\JSONFactory') + $this->resultJsonFactory = $this->getMockBuilder('Magento\Framework\Controller\Result\JsonFactory') ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); @@ -238,7 +238,7 @@ class LoginTest extends \PHPUnit_Framework_TestCase ->expects($this->any()) ->method('authenticate') ->with('invalid@example.com', 'invalid') - ->willThrowException(new InvalidEmailOrPasswordException('Invalid login or password.', [])); + ->willThrowException(new InvalidEmailOrPasswordException(__('Invalid login or password.'))); $this->customerSession->expects($this->never()) ->method('setCustomerDataAsLoggedIn') diff --git a/app/code/Magento/Customer/Test/Unit/Model/AttributeTest.php b/app/code/Magento/Customer/Test/Unit/Model/AttributeTest.php index aed47c9e45898f0b9e4ea6dc6877c06c87f92d1f..81fdf472c365eb9e7ff2348ac3922b320a28b1bf 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/AttributeTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/AttributeTest.php @@ -4,6 +4,8 @@ * See COPYING.txt for license details. */ +// @codingStandardsIgnoreFile + namespace Magento\Customer\Test\Unit\Model; use Magento\Customer\Model\Attribute; @@ -29,11 +31,6 @@ class AttributeTest extends \PHPUnit_Framework_TestCase */ protected $registryMock; - /** - * @var \Magento\Framework\Api\MetadataServiceInterface|\PHPUnit_Framework_MockObject_MockObject - */ - protected $metadataServiceMock; - /** * @var \Magento\Framework\Api\AttributeValueFactory|\PHPUnit_Framework_MockObject_MockObject */ @@ -109,6 +106,14 @@ class AttributeTest extends \PHPUnit_Framework_TestCase */ private $dataObjectHelperMock; + /** + * @var \Magento\Framework\Api\ExtensionAttributesFactory|\PHPUnit_Framework_MockObject_MockObject + */ + private $extensionAttributesFactory; + + /** + * Test method + */ protected function setUp() { $this->contextMock = $this->getMockBuilder('Magento\Framework\Model\Context') @@ -116,7 +121,8 @@ class AttributeTest extends \PHPUnit_Framework_TestCase ->getMock(); $this->registryMock = $this->getMockBuilder('Magento\Framework\Registry') ->getMock(); - $this->metadataServiceMock = $this->getMockBuilder('Magento\Framework\Api\MetadataServiceInterface') + $this->extensionAttributesFactory = $this->getMockBuilder('Magento\Framework\Api\ExtensionAttributesFactory') + ->disableOriginalConstructor() ->getMock(); $this->attributeValueFactoryMock = $this->getMockBuilder('Magento\Framework\Api\AttributeValueFactory') ->disableOriginalConstructor() @@ -173,7 +179,7 @@ class AttributeTest extends \PHPUnit_Framework_TestCase $this->attribute = new Attribute( $this->contextMock, $this->registryMock, - $this->metadataServiceMock, + $this->extensionAttributesFactory, $this->attributeValueFactoryMock, $this->configMock, $this->typeFactoryMock, @@ -190,6 +196,9 @@ class AttributeTest extends \PHPUnit_Framework_TestCase ); } + /** + * Test method + */ public function testAfterSaveEavCache() { $this->configMock @@ -199,6 +208,9 @@ class AttributeTest extends \PHPUnit_Framework_TestCase $this->attribute->afterSave(); } + /** + * Test method + */ public function testAfterDeleteEavCache() { $this->configMock diff --git a/app/code/Magento/Customer/Test/Unit/Model/LogTest.php b/app/code/Magento/Customer/Test/Unit/Model/LogTest.php new file mode 100644 index 0000000000000000000000000000000000000000..96ce27aef717692871d99e6702bfde5a5314d6a9 --- /dev/null +++ b/app/code/Magento/Customer/Test/Unit/Model/LogTest.php @@ -0,0 +1,79 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Customer\Test\Unit\Model; + +/** + * Customer log model test. + */ +class LogTest extends \PHPUnit_Framework_TestCase +{ + /** + * Customer log model. + * + * @var \Magento\Customer\Model\Log + */ + protected $log; + + /** + * @var array + */ + protected $logData = [ + 'customer_id' => 369, + 'last_login_at' => '2015-03-04 12:00:00', + 'last_visit_at' => '2015-03-04 12:01:00', + 'last_logout_at' => '2015-03-04 12:05:00', + ]; + + /** + * @return void + */ + protected function setUp() + { + $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); + + $this->log = $objectManagerHelper->getObject( + 'Magento\Customer\Model\Log', + [ + 'customerId' => $this->logData['customer_id'], + 'lastLoginAt' => $this->logData['last_login_at'], + 'lastVisitAt' => $this->logData['last_visit_at'], + 'lastLogoutAt' => $this->logData['last_logout_at'] + ] + ); + } + + /** + * @return void + */ + public function testGetCustomerId() + { + $this->assertEquals($this->logData['customer_id'], $this->log->getCustomerId()); + } + + /** + * @return void + */ + public function testGetLastLoginAt() + { + $this->assertEquals($this->logData['last_login_at'], $this->log->getLastLoginAt()); + } + + /** + * @return void + */ + public function testGetLastVisitAt() + { + $this->assertEquals($this->logData['last_visit_at'], $this->log->getLastVisitAt()); + } + + /** + * @return void + */ + public function testGetLastLogoutAt() + { + $this->assertEquals($this->logData['last_logout_at'], $this->log->getLastLogoutAt()); + } +} diff --git a/app/code/Magento/Customer/Test/Unit/Model/LoggerTest.php b/app/code/Magento/Customer/Test/Unit/Model/LoggerTest.php new file mode 100644 index 0000000000000000000000000000000000000000..88c7f55c22a3eb5ad0c5666d8ab0fcf77b87dac9 --- /dev/null +++ b/app/code/Magento/Customer/Test/Unit/Model/LoggerTest.php @@ -0,0 +1,193 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Customer\Test\Unit\Model; + +/** + * Customer log data logger test. + */ +class LoggerTest extends \PHPUnit_Framework_TestCase +{ + /** + * Customer log data logger. + * + * @var \Magento\Customer\Model\Logger + */ + protected $logger; + + /** + * @var \Magento\Customer\Model\LogFactory|\PHPUnit_Framework_MockObject_MockObject + */ + protected $logFactory; + + /** + * Resource instance. + * + * @var \Magento\Framework\App\Resource|\PHPUnit_Framework_MockObject_MockObject + */ + protected $resource; + + /** + * DB connection instance. + * + * @var \Magento\Framework\DB\Adapter\Pdo|\PHPUnit_Framework_MockObject_MockObject + */ + protected $adapter; + + /** + * @return void + */ + protected function setUp() + { + $this->adapter = $this->getMock( + 'Magento\Framework\DB\Adapter\Pdo', + ['select', 'insertOnDuplicate', 'fetchRow'], + [], + '', + false + ); + $this->resource = $this->getMock('Magento\Framework\App\Resource', [], [], '', false); + $this->logFactory = $this->getMock('\Magento\Customer\Model\LogFactory', ['create'], [], '', false); + + $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); + + $this->logger = $objectManagerHelper->getObject( + '\Magento\Customer\Model\Logger', + [ + 'resource' => $this->resource, + 'logFactory' => $this->logFactory + ] + ); + } + + /** + * @param int $customerId + * @param array $data + * @dataProvider testLogDataProvider + * @return void + */ + public function testLog($customerId, $data) + { + $tableName = 'customer_log_table_name'; + $data = array_filter($data); + + if (!$data) { + $this->setExpectedException('\InvalidArgumentException', 'Log data is empty'); + $this->logger->log($customerId, $data); + return; + } + + $this->resource->expects($this->once()) + ->method('getConnection') + ->with('write') + ->willReturn($this->adapter); + $this->resource->expects($this->once()) + ->method('getTableName') + ->with('customer_log') + ->willReturn($tableName); + $this->adapter->expects($this->once()) + ->method('insertOnDuplicate') + ->with($tableName, array_merge(['customer_id' => $customerId], $data), array_keys($data)); + + $this->assertEquals($this->logger, $this->logger->log($customerId, $data)); + } + + /** + * @return array + */ + public function testLogDataProvider() + { + return [ + [235, ['last_login_at' => '2015-03-04 12:00:00']], + [235, ['last_login_at' => null]], + ]; + } + + /** + * @param int $customerId + * @param array $data + * @dataProvider testGetDataProvider + * @return void + */ + public function testGet($customerId, $data) + { + $logArguments = [ + 'customerId' => $data['customer_id'], + 'lastLoginAt' => $data['last_login_at'], + 'lastLogoutAt' => $data['last_logout_at'], + 'lastVisitAt' => $data['last_visit_at'] + ]; + + $select = $this->getMock('Magento\Framework\DB\Select', [], [], '', false); + + $select->expects($this->any())->method('from')->willReturnSelf(); + $select->expects($this->any())->method('joinLeft')->willReturnSelf(); + $select->expects($this->any())->method('where')->willReturnSelf(); + $select->expects($this->any())->method('order')->willReturnSelf(); + $select->expects($this->any())->method('limit')->willReturnSelf(); + + $this->adapter->expects($this->any()) + ->method('select') + ->willReturn($select); + + $this->resource->expects($this->once()) + ->method('getConnection') + ->with('read') + ->willReturn($this->adapter); + $this->adapter->expects($this->any()) + ->method('fetchRow') + ->with($select) + ->willReturn($data); + + $log = $this->getMock( + 'Magento\Customer\Model\Log', + [], + $logArguments + ); + + $this->logFactory->expects($this->any()) + ->method('create') + ->with($logArguments) + ->willReturn($log); + + $this->assertEquals($log, $this->logger->get($customerId)); + } + + /** + * @return array + */ + public function testGetDataProvider() + { + return [ + [ + 235, + [ + 'customer_id' => 369, + 'last_login_at' => '2015-03-04 12:00:00', + 'last_visit_at' => '2015-03-04 12:01:00', + 'last_logout_at' => '2015-03-04 12:05:00', + ] + ], + [ + 235, + [ + 'customer_id' => 369, + 'last_login_at' => '2015-03-04 12:00:00', + 'last_visit_at' => '2015-03-04 12:01:00', + 'last_logout_at' => null, + ] + ], + [ + 235, + [ + 'customer_id' => null, + 'last_login_at' => null, + 'last_visit_at' => null, + 'last_logout_at' => null, + ] + ], + ]; + } +} diff --git a/app/code/Magento/Customer/Test/Unit/Model/Observer/LogTest.php b/app/code/Magento/Customer/Test/Unit/Model/Observer/LogTest.php new file mode 100644 index 0000000000000000000000000000000000000000..fcd3ff2c58f76fff1619f3804c0c079eb8c5c397 --- /dev/null +++ b/app/code/Magento/Customer/Test/Unit/Model/Observer/LogTest.php @@ -0,0 +1,90 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Customer\Test\Unit\Model\Observer; + +use Magento\Customer\Model\Logger; +use Magento\Framework\Stdlib\DateTime; +use Magento\Framework\Event\Observer; +use Magento\Customer\Model\Observer\Log; + +/** + * Class LogTest + */ +class LogTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var Log + */ + protected $logObserver; + + /** + * @var Logger | \PHPUnit_Framework_MockObject_MockObject + */ + protected $loggerMock; + + /** + * @return void + */ + public function setUp() + { + $this->loggerMock = $this->getMock('Magento\Customer\Model\Logger', [], [], '', false); + $this->logObserver = new Log($this->loggerMock); + } + + /** + * @return void + */ + public function testLogLastLoginAt() + { + $id = 1; + + $observerMock = $this->getMock('Magento\Framework\Event\Observer', [], [], '', false); + $eventMock = $this->getMock('Magento\Framework\Event', ['getCustomer'], [], '', false); + $customerMock = $this->getMock('Magento\Customer\Model\Customer', [], [], '', false); + + $observerMock->expects($this->once()) + ->method('getEvent') + ->willReturn($eventMock); + $eventMock->expects($this->once()) + ->method('getCustomer') + ->willReturn($customerMock); + $customerMock->expects($this->once()) + ->method('getId') + ->willReturn($id); + + $this->loggerMock->expects($this->once()) + ->method('log'); + + $this->logObserver->logLastLoginAt($observerMock); + } + + /** + * @return void + */ + public function testLogLastLogoutAt() + { + $id = 1; + + $observerMock = $this->getMock('Magento\Framework\Event\Observer', [], [], '', false); + $eventMock = $this->getMock('Magento\Framework\Event', ['getCustomer'], [], '', false); + $customerMock = $this->getMock('Magento\Customer\Model\Customer', [], [], '', false); + + $observerMock->expects($this->once()) + ->method('getEvent') + ->willReturn($eventMock); + $eventMock->expects($this->once()) + ->method('getCustomer') + ->willReturn($customerMock); + $customerMock->expects($this->once()) + ->method('getId') + ->willReturn($id); + + $this->loggerMock->expects($this->once()) + ->method('log'); + + $this->logObserver->logLastLogoutAt($observerMock); + } +} diff --git a/app/code/Magento/Customer/etc/config.xml b/app/code/Magento/Customer/etc/config.xml index 12d5639d3636fc6ad657bfe0b8f20da83260f10b..981e8734fd3d1b44983ad150b25d5b284e20874b 100644 --- a/app/code/Magento/Customer/etc/config.xml +++ b/app/code/Magento/Customer/etc/config.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Core/etc/config.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Store/etc/config.xsd"> <default> <customer> <account_share> diff --git a/app/code/Magento/Customer/etc/di.xml b/app/code/Magento/Customer/etc/di.xml index fb07378f191ad35ad2f3ff3e6c0105e381570bd8..acf37638c3915db937145e8245c1a59b14cac1c9 100644 --- a/app/code/Magento/Customer/etc/di.xml +++ b/app/code/Magento/Customer/etc/di.xml @@ -63,20 +63,6 @@ </argument> </arguments> </type> - <virtualType name="Magento\Customer\Api\Config\CustomerMetadataConfig" type="Magento\Framework\Api\Config\MetadataConfig"> - </virtualType> - <type name="Magento\Customer\Model\Metadata\CustomerMetadata"> - <arguments> - <argument name="metadataConfig" xsi:type="object">Magento\Customer\Api\Config\CustomerMetadataConfig</argument> - </arguments> - </type> - <virtualType name="Magento\Customer\Api\Config\AddressMetadataConfig" type="Magento\Framework\Api\Config\MetadataConfig"> - </virtualType> - <type name="Magento\Customer\Model\Metadata\AddressMetadata"> - <arguments> - <argument name="metadataConfig" xsi:type="object">Magento\Customer\Api\Config\AddressMetadataConfig</argument> - </arguments> - </type> <type name="Magento\Framework\Model\ActionValidator\RemoveAction"> <arguments> <argument name="protectedModels" xsi:type="array"> diff --git a/app/code/Magento/Customer/etc/frontend/events.xml b/app/code/Magento/Customer/etc/frontend/events.xml index 81c65b5aa1c648e3cfe5e9f422e16ab4a268bd4e..a91b32c0ea159ab5e69b7d80732252cf72f16814 100644 --- a/app/code/Magento/Customer/etc/frontend/events.xml +++ b/app/code/Magento/Customer/etc/frontend/events.xml @@ -17,6 +17,7 @@ </event> <event name="customer_logout"> <observer name="customer_visitor" instance="Magento\Customer\Model\Visitor" method="bindCustomerLogout" /> + <observer name="customer_log_logout" instance="Magento\Customer\Model\Observer\Log" method="logLastLogoutAt" /> </event> <event name="sales_quote_save_after"> <observer name="customer_visitor" instance="Magento\Customer\Model\Visitor" method="bindQuoteCreate" /> @@ -24,4 +25,7 @@ <event name="checkout_quote_destroy"> <observer name="customer_visitor" instance="Magento\Customer\Model\Visitor" method="bindQuoteDestroy" /> </event> + <event name="customer_login"> + <observer name="customer_log_login" instance="Magento\Customer\Model\Observer\Log" method="logLastLoginAt" /> + </event> </config> diff --git a/app/code/Magento/Customer/etc/frontend/page_types.xml b/app/code/Magento/Customer/etc/frontend/page_types.xml index 3b4093e12cc0bb6a0250e33c66a7aa1a0ad3fb78..e895bca1e8bd6ec9f833b43d0b15754d5b0e1495 100644 --- a/app/code/Magento/Customer/etc/frontend/page_types.xml +++ b/app/code/Magento/Customer/etc/frontend/page_types.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> -<page_types xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../Core/etc/page_types.xsd"> +<page_types xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_types.xsd"> <type id="customer_account_confirmation" label="Customer Account Confirmation"/> <type id="customer_account_create" label="Customer Account Registration Form"/> <type id="customer_account_createpassword" label="Reset a Password"/> diff --git a/app/code/Magento/Customer/etc/module.xml b/app/code/Magento/Customer/etc/module.xml index 33f923e05015b2ac6618f497ca5ea129be68bb74..973c14db73d61034756a46694f3abab1856ed480 100644 --- a/app/code/Magento/Customer/etc/module.xml +++ b/app/code/Magento/Customer/etc/module.xml @@ -6,7 +6,7 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd"> - <module name="Magento_Customer" setup_version="2.0.0.1"> + <module name="Magento_Customer" setup_version="2.0.0.2"> <sequence> <module name="Magento_Eav"/> <module name="Magento_Directory"/> diff --git a/app/code/Magento/Customer/view/adminhtml/templates/tab/view/personal_info.phtml b/app/code/Magento/Customer/view/adminhtml/templates/tab/view/personal_info.phtml index 51204820fd18123d88d90b6c07aadda993728468..e87d3005a1dad3e90d4d06b8c67ea73f561627e7 100644 --- a/app/code/Magento/Customer/view/adminhtml/templates/tab/view/personal_info.phtml +++ b/app/code/Magento/Customer/view/adminhtml/templates/tab/view/personal_info.phtml @@ -10,8 +10,11 @@ * Template for block \Magento\Customer\Block\Adminhtml\Edit\Tab\View\Status\PersonalInfo */ -$createDateAdmin = $block->getCreateDate(); -$createDateStore = $block->getStoreCreateDate(); +$lastLoginDateAdmin = $block->getLastLoginDate(); +$lastLoginDateStore = $block->getStoreLastLoginDate(); + +$createDateAdmin = $block->getCreateDate(); +$createDateStore = $block->getStoreCreateDate(); ?> <div class="fieldset-wrapper customer-information"> @@ -21,6 +24,16 @@ $createDateStore = $block->getStoreCreateDate(); <table class="data-table"> <tbody> <?php echo $block->getChildHtml(); ?> + <tr> + <th><?php echo __('Last Logged In:') ?></th> + <td><?php echo $lastLoginDateAdmin ?> (<?php echo $block->getCurrentStatus() ?>)</td> + </tr> + <?php if ($lastLoginDateAdmin != $lastLoginDateStore): ?> + <tr> + <th><?php echo __('Last Logged In (%1):', $block->getStoreLastLoginDateTimezone()) ?></th> + <td><?php echo $lastLoginDateStore ?> (<?php echo $block->getCurrentStatus() ?>)</td> + </tr> + <?php endif; ?> <tr> <th><?php echo __('Confirmed email:') ?></th> <td><?php echo $block->getIsConfirmedStatus() ?></td> diff --git a/app/code/Magento/Customer/view/frontend/layout/customer_account_create.xml b/app/code/Magento/Customer/view/frontend/layout/customer_account_create.xml index c5b7b4ed77af6114c5ee5edc8d46901c256b8e42..c931d10ffacfca9771214fa8b2186555d5e516de 100644 --- a/app/code/Magento/Customer/view/frontend/layout/customer_account_create.xml +++ b/app/code/Magento/Customer/view/frontend/layout/customer_account_create.xml @@ -11,7 +11,7 @@ <block class="Magento\Framework\View\Element\Js\Components" name="customer_account_create_head_components" template="Magento_Customer::js/components.phtml"/> </referenceBlock> <referenceContainer name="content"> - <block class="Magento\Customer\Block\Form\Register" name="customer_form_register" template="form/register.phtml" cacheable="false"> + <block class="Magento\Customer\Block\Form\Register" name="customer_form_register" template="form/register.phtml"> <container name="form.additional.info" as="form_additional_info"/> <container name="customer.form.register.fields.before" as="form_fields_before" label="Form Fields Before" htmlTag="div" htmlClass="customer-form-before"/> </block> diff --git a/app/code/Magento/Customer/view/frontend/layout/customer_account_login.xml b/app/code/Magento/Customer/view/frontend/layout/customer_account_login.xml index 6a2d849c364d45f46a674d4ab4c011053cb0cc94..6dafbfb6cecb2b19cc5f787050abb2065a05d163 100644 --- a/app/code/Magento/Customer/view/frontend/layout/customer_account_login.xml +++ b/app/code/Magento/Customer/view/frontend/layout/customer_account_login.xml @@ -10,10 +10,10 @@ <referenceContainer name="content"> <!-- customer.form.login.extra --> <container name="customer.login.container" label="Customer Login Container" htmlTag="div" htmlClass="login-container"> - <block class="Magento\Customer\Block\Form\Login" name="customer_form_login" template="form/login.phtml" cacheable="false"> + <block class="Magento\Customer\Block\Form\Login" name="customer_form_login" template="form/login.phtml"> <container name="form.additional.info" as="form_additional_info"/> </block> - <block class="Magento\Customer\Block\Form\Login" name="customer.new" template="newcustomer.phtml" cacheable="false"/> + <block class="Magento\Customer\Block\Form\Login\Info" name="customer.new" template="newcustomer.phtml"/> </container> <block class="Magento\Cookie\Block\RequireCookie" name="require-cookie" template="Magento_Cookie::require_cookie.phtml"> <arguments> diff --git a/app/code/Magento/Customer/view/frontend/templates/newcustomer.phtml b/app/code/Magento/Customer/view/frontend/templates/newcustomer.phtml index 31e31a9dfa48c4db9eda150b348df3a10a12e637..e4609e91131483a037adc9d592d72d6455cb2f09 100644 --- a/app/code/Magento/Customer/view/frontend/templates/newcustomer.phtml +++ b/app/code/Magento/Customer/view/frontend/templates/newcustomer.phtml @@ -11,7 +11,7 @@ /** * New Customer block template * - * @var $block \Magento\Customer\Block\Form\Login + * @var $block \Magento\Customer\Block\Form\Login\Info */ ?> <?php if ($block->getRegistration()->isAllowed()): ?> diff --git a/app/code/Magento/CustomerImportExport/etc/config.xml b/app/code/Magento/CustomerImportExport/etc/config.xml index 02000ca611d79749eb2fa68a74a39ff5bd3953be..000eef6ea21c83cdda49761e7cc61d40484fa993 100644 --- a/app/code/Magento/CustomerImportExport/etc/config.xml +++ b/app/code/Magento/CustomerImportExport/etc/config.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Core/etc/config.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Store/etc/config.xsd"> <default> <export> <customer_page_size> diff --git a/app/code/Magento/DesignEditor/Model/Editor/Tools/QuickStyles/Form/Renderer/Factory.php b/app/code/Magento/DesignEditor/Model/Editor/Tools/QuickStyles/Form/Renderer/Factory.php index 54233608509d82a0bb112dc23682e5279c2ab1d7..1dc6754f3de9f173f9a8550c462b122cb8ab756a 100644 --- a/app/code/Magento/DesignEditor/Model/Editor/Tools/QuickStyles/Form/Renderer/Factory.php +++ b/app/code/Magento/DesignEditor/Model/Editor/Tools/QuickStyles/Form/Renderer/Factory.php @@ -72,7 +72,7 @@ class Factory { if (!isset($this->_rendererByElement[$elementClassName])) { throw new \Magento\Framework\Exception\LocalizedException( - sprintf('No renderer registered for elements of class "%s"', $elementClassName) + __('No renderer registered for elements of class "%1"', $elementClassName) ); } $rendererClass = $this->_rendererByElement[$elementClassName]; diff --git a/app/code/Magento/DesignEditor/etc/config.xml b/app/code/Magento/DesignEditor/etc/config.xml index c343d59d0bb703575be2d01364566f11d74aafd6..f977f5d456b01c2edeed42f04491d9050fd87e6a 100644 --- a/app/code/Magento/DesignEditor/etc/config.xml +++ b/app/code/Magento/DesignEditor/etc/config.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Core/etc/config.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Store/etc/config.xsd"> <default> <theme> <customization> diff --git a/app/code/Magento/DesignEditor/view/adminhtml/templates/editor/tools/files/tree.phtml b/app/code/Magento/DesignEditor/view/adminhtml/templates/editor/tools/files/tree.phtml index 705b5bcde58bb20c707e747c50bc73ef38b0fb36..c16bce0be3303278b3aa6c8643b22e77229a034b 100644 --- a/app/code/Magento/DesignEditor/view/adminhtml/templates/editor/tools/files/tree.phtml +++ b/app/code/Magento/DesignEditor/view/adminhtml/templates/editor/tools/files/tree.phtml @@ -35,8 +35,7 @@ require([ "extjs/ext-tree-checkbox", 'Magento_DesignEditor/js/tools-files' ], function(jQuery){ - -Ext.onReady(function(){ +jQuery(function(){ var Tree = Ext.tree; var tree = new Tree.TreePanel('tree', { animate:true, diff --git a/app/code/Magento/DesignEditor/view/adminhtml/web/js/dialog.js b/app/code/Magento/DesignEditor/view/adminhtml/web/js/dialog.js index ad58d32bcbe86077a511d6c2971e2e2efbe943ea..d19339d3f2552893755b919cf4232eef13dc86e3 100644 --- a/app/code/Magento/DesignEditor/view/adminhtml/web/js/dialog.js +++ b/app/code/Magento/DesignEditor/view/adminhtml/web/js/dialog.js @@ -99,9 +99,6 @@ define([ * @param {Array.<Object>|Object} buttons */ set: function (title, text, buttons) { - title = $.mage.__(title); - text = $.mage.__(text); - this.text.set(text); this.title.set(title); this.setButtons(buttons); @@ -120,9 +117,6 @@ define([ if ($.type(buttons) !== 'array') { buttons = [buttons]; } - buttons.each(function(button){ - button.text = $.mage.__(button.text) - }); } var hasToAddCancel = (addCancel == undefined && buttons.length <= 1) || addCancel == true; @@ -146,8 +140,6 @@ define([ * @param {number} position */ addButton: function(button, position) { - button.text = $.mage.__(button.text) - var buttons = this.options.buttons; buttons.splice(position, 0, button); this._setOption('buttons', buttons); @@ -166,7 +158,7 @@ define([ position = buttonPointer; } else { //Find 1st button with given title - var title = $.mage.__(buttonPointer); + var title = buttonPointer; this.options.buttons.each(function(button, index) { if (button.text == title) { position = index; diff --git a/app/code/Magento/Developer/etc/config.xml b/app/code/Magento/Developer/etc/config.xml index c57832ea23ed5afba771bf70366c0703dd15c37a..21e898035fb4b6c828aac28a65584eb13af0acd8 100644 --- a/app/code/Magento/Developer/etc/config.xml +++ b/app/code/Magento/Developer/etc/config.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Core/etc/config.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Store/etc/config.xsd"> <default> <dev> <restrict> diff --git a/app/code/Magento/Dhl/composer.json b/app/code/Magento/Dhl/composer.json index 024ef97396a6f20436526ca37ff0c47b86c4bb56..6c64a3d0f59f0196fa54970d40fb641cf582323c 100644 --- a/app/code/Magento/Dhl/composer.json +++ b/app/code/Magento/Dhl/composer.json @@ -8,7 +8,6 @@ "magento/module-shipping": "0.42.0-beta11", "magento/module-backend": "0.42.0-beta11", "magento/module-directory": "0.42.0-beta11", - "magento/module-core": "0.42.0-beta11", "magento/module-sales": "0.42.0-beta11", "magento/module-checkout": "0.42.0-beta11", "magento/module-catalog": "0.42.0-beta11", diff --git a/app/code/Magento/Dhl/etc/config.xml b/app/code/Magento/Dhl/etc/config.xml index c491e6e10f53538c51ba195997e5be8ca846f498..0d60e087a0e35b88c4d858b5332e5338dea2385c 100644 --- a/app/code/Magento/Dhl/etc/config.xml +++ b/app/code/Magento/Dhl/etc/config.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Core/etc/config.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Store/etc/config.xsd"> <default> <system> <media_storage_configuration> diff --git a/app/code/Magento/Directory/composer.json b/app/code/Magento/Directory/composer.json index 8e66ab394fbb810a2f46479afb74b859b3472301..d13968038ae92aa7d937ba680efeaaf6f043de8f 100644 --- a/app/code/Magento/Directory/composer.json +++ b/app/code/Magento/Directory/composer.json @@ -5,7 +5,6 @@ "php": "~5.5.0|~5.6.0", "magento/module-config": "0.42.0-beta11", "magento/module-store": "0.42.0-beta11", - "magento/module-core": "0.42.0-beta11", "magento/module-backend": "0.42.0-beta11", "magento/framework": "0.42.0-beta11", "lib-libxml": "*", diff --git a/app/code/Magento/Directory/etc/config.xml b/app/code/Magento/Directory/etc/config.xml index 60328d17d8c195a18c7ff7434a4f22abd4aac4ab..54cec22d63ee92e7b5143778d51b003a09dc604f 100644 --- a/app/code/Magento/Directory/etc/config.xml +++ b/app/code/Magento/Directory/etc/config.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Core/etc/config.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Store/etc/config.xsd"> <default> <system> <currency> diff --git a/app/code/Magento/Directory/etc/module.xml b/app/code/Magento/Directory/etc/module.xml index c2f5119fbd915909fea91d4cdabe08b702d6de7a..385b4422a936a867361ddb7f3c0cc21f94f5b52b 100644 --- a/app/code/Magento/Directory/etc/module.xml +++ b/app/code/Magento/Directory/etc/module.xml @@ -8,7 +8,6 @@ <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd"> <module name="Magento_Directory" setup_version="2.0.0"> <sequence> - <module name="Magento_Core"/> <module name="Magento_Store"/> </sequence> </module> diff --git a/app/code/Magento/Downloadable/Api/Data/File/ContentInterface.php b/app/code/Magento/Downloadable/Api/Data/File/ContentInterface.php index ce1e4b8afa1e879f97a18a87ad68bbc2d35f2a68..01194703cbb86cb65e151634f862f7fa794f46df 100644 --- a/app/code/Magento/Downloadable/Api/Data/File/ContentInterface.php +++ b/app/code/Magento/Downloadable/Api/Data/File/ContentInterface.php @@ -39,4 +39,21 @@ interface ContentInterface extends \Magento\Framework\Api\ExtensibleDataInterfac * @return $this */ public function setName($name); + + /** + * Retrieve existing extension attributes object or create a new one. + * + * @return \Magento\Downloadable\Api\Data\File\ContentExtensionInterface|null + */ + public function getExtensionAttributes(); + + /** + * Set an extension attributes object. + * + * @param \Magento\Downloadable\Api\Data\File\ContentExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes( + \Magento\Downloadable\Api\Data\File\ContentExtensionInterface $extensionAttributes + ); } diff --git a/app/code/Magento/Downloadable/Api/Data/LinkContentInterface.php b/app/code/Magento/Downloadable/Api/Data/LinkContentInterface.php index ec82d46a008cbfd001d906913eefbd35a81497c7..1972068f435512611b3d564f875ec666f6d20b56 100644 --- a/app/code/Magento/Downloadable/Api/Data/LinkContentInterface.php +++ b/app/code/Magento/Downloadable/Api/Data/LinkContentInterface.php @@ -174,4 +174,21 @@ interface LinkContentInterface extends \Magento\Framework\Api\ExtensibleDataInte * @return $this */ public function setSampleType($sampleType); + + /** + * Retrieve existing extension attributes object or create a new one. + * + * @return \Magento\Downloadable\Api\Data\LinkContentExtensionInterface|null + */ + public function getExtensionAttributes(); + + /** + * Set an extension attributes object. + * + * @param \Magento\Downloadable\Api\Data\LinkContentExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes( + \Magento\Downloadable\Api\Data\LinkContentExtensionInterface $extensionAttributes + ); } diff --git a/app/code/Magento/Downloadable/Api/Data/LinkInterface.php b/app/code/Magento/Downloadable/Api/Data/LinkInterface.php index df4f97a055ee838142ac05c0e5ee91f9bd0663b9..0152a1a256540db9b0cab423e2804bd906475245 100644 --- a/app/code/Magento/Downloadable/Api/Data/LinkInterface.php +++ b/app/code/Magento/Downloadable/Api/Data/LinkInterface.php @@ -173,4 +173,19 @@ interface LinkInterface extends \Magento\Framework\Api\ExtensibleDataInterface * @return $this */ public function setSampleUrl($sampleUrl); + + /** + * Retrieve existing extension attributes object or create a new one. + * + * @return \Magento\Downloadable\Api\Data\LinkExtensionInterface|null + */ + public function getExtensionAttributes(); + + /** + * Set an extension attributes object. + * + * @param \Magento\Downloadable\Api\Data\LinkExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes(\Magento\Downloadable\Api\Data\LinkExtensionInterface $extensionAttributes); } diff --git a/app/code/Magento/Downloadable/Api/Data/SampleContentInterface.php b/app/code/Magento/Downloadable/Api/Data/SampleContentInterface.php index 03864afad3dd6a7b98683ed4a7ae53bf2e1f0734..b4b0580bda1879b6aa75ab70371f6c522b7d1100 100644 --- a/app/code/Magento/Downloadable/Api/Data/SampleContentInterface.php +++ b/app/code/Magento/Downloadable/Api/Data/SampleContentInterface.php @@ -84,4 +84,21 @@ interface SampleContentInterface extends \Magento\Framework\Api\ExtensibleDataIn * @return $this */ public function setSampleUrl($sampleUrl); + + /** + * Retrieve existing extension attributes object or create a new one. + * + * @return \Magento\Downloadable\Api\Data\SampleContentExtensionInterface|null + */ + public function getExtensionAttributes(); + + /** + * Set an extension attributes object. + * + * @param \Magento\Downloadable\Api\Data\SampleContentExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes( + \Magento\Downloadable\Api\Data\SampleContentExtensionInterface $extensionAttributes + ); } diff --git a/app/code/Magento/Downloadable/Api/Data/SampleInterface.php b/app/code/Magento/Downloadable/Api/Data/SampleInterface.php index aff31bf3f413f1b8ae20691678faaa0261d6b023..3d6dfc937f3871a4a489e43c1f1912c5a7498082 100644 --- a/app/code/Magento/Downloadable/Api/Data/SampleInterface.php +++ b/app/code/Magento/Downloadable/Api/Data/SampleInterface.php @@ -96,4 +96,21 @@ interface SampleInterface extends \Magento\Framework\Api\ExtensibleDataInterface * @return $this */ public function setSampleUrl($sampleUrl); + + /** + * Retrieve existing extension attributes object or create a new one. + * + * @return \Magento\Downloadable\Api\Data\SampleExtensionInterface|null + */ + public function getExtensionAttributes(); + + /** + * Set an extension attributes object. + * + * @param \Magento\Downloadable\Api\Data\SampleExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes( + \Magento\Downloadable\Api\Data\SampleExtensionInterface $extensionAttributes + ); } diff --git a/app/code/Magento/Downloadable/Api/LinkRepositoryInterface.php b/app/code/Magento/Downloadable/Api/LinkRepositoryInterface.php index 58bad33a356c9262d1bee8cb6308ed87560e8d3c..a8bd6f83d9be190834e0e92d34c039010a4d870c 100644 --- a/app/code/Magento/Downloadable/Api/LinkRepositoryInterface.php +++ b/app/code/Magento/Downloadable/Api/LinkRepositoryInterface.php @@ -12,29 +12,29 @@ interface LinkRepositoryInterface /** * List of samples for downloadable product * - * @param string $productSku + * @param string $sku * @return \Magento\Downloadable\Api\Data\SampleInterface[] */ - public function getSamples($productSku); + public function getSamples($sku); /** * List of links with associated samples * - * @param string $productSku + * @param string $sku * @return \Magento\Downloadable\Api\Data\LinkInterface[] */ - public function getLinks($productSku); + public function getLinks($sku); /** * Update downloadable link of the given product (link type and its resources cannot be changed) * - * @param string $productSku + * @param string $sku * @param \Magento\Downloadable\Api\Data\LinkContentInterface $linkContent * @param int $linkId * @param bool $isGlobalScopeContent * @return int */ - public function save($productSku, LinkContentInterface $linkContent, $linkId = null, $isGlobalScopeContent = false); + public function save($sku, LinkContentInterface $linkContent, $linkId = null, $isGlobalScopeContent = false); /** * Delete downloadable link diff --git a/app/code/Magento/Downloadable/Block/Customer/Products/ListProducts.php b/app/code/Magento/Downloadable/Block/Customer/Products/ListProducts.php index 5b6c1b0960b4d8366c54d9be8bbcefb02e7c438b..1e09a35920dae97946d759c147f82b3b264ef7e0 100644 --- a/app/code/Magento/Downloadable/Block/Customer/Products/ListProducts.php +++ b/app/code/Magento/Downloadable/Block/Customer/Products/ListProducts.php @@ -155,7 +155,7 @@ class ListProducts extends \Magento\Framework\View\Element\Template */ public function getDownloadUrl($item) { - return $this->getUrl('*/download/link', ['id' => $item->getLinkHash(), '_secure' => true]); + return $this->getUrl('downloadable/download/link', ['id' => $item->getLinkHash(), '_secure' => true]); } /** diff --git a/app/code/Magento/Downloadable/Model/File/Content.php b/app/code/Magento/Downloadable/Model/File/Content.php index e59ffc9dd605df594e47245d6fb41c15396615c1..5fdd65fa9440b49cde9988cf97516e42a335fbed 100644 --- a/app/code/Magento/Downloadable/Model/File/Content.php +++ b/app/code/Magento/Downloadable/Model/File/Content.php @@ -56,4 +56,26 @@ class Content extends \Magento\Framework\Model\AbstractExtensibleModel implement { return $this->setData(self::NAME, $name); } + + /** + * {@inheritdoc} + * + * @return \Magento\Downloadable\Api\Data\File\ContentExtensionInterface|null + */ + public function getExtensionAttributes() + { + return $this->_getExtensionAttributes(); + } + + /** + * {@inheritdoc} + * + * @param \Magento\Downloadable\Api\Data\File\ContentExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes( + \Magento\Downloadable\Api\Data\File\ContentExtensionInterface $extensionAttributes + ) { + return $this->_setExtensionAttributes($extensionAttributes); + } } diff --git a/app/code/Magento/Downloadable/Model/File/ContentValidator.php b/app/code/Magento/Downloadable/Model/File/ContentValidator.php index 4f3293fc8be042c0309f1b4a94829f1a53829921..535ccab5bb459d6e1913e738c14749a0d09c20fc 100644 --- a/app/code/Magento/Downloadable/Model/File/ContentValidator.php +++ b/app/code/Magento/Downloadable/Model/File/ContentValidator.php @@ -21,11 +21,11 @@ class ContentValidator { $decodedContent = @base64_decode($fileContent->getFileData(), true); if (empty($decodedContent)) { - throw new InputException('Provided content must be valid base64 encoded data.'); + throw new InputException(__('Provided content must be valid base64 encoded data.')); } if (!$this->isFileNameValid($fileContent->getName())) { - throw new InputException('Provided file name contains forbidden characters.'); + throw new InputException(__('Provided file name contains forbidden characters.')); } return true; } diff --git a/app/code/Magento/Downloadable/Model/Link.php b/app/code/Magento/Downloadable/Model/Link.php index 776e2983fdac58a8d627c637cac8237363b81f03..84de54915ab0edec47b492ac19a2fde4f5d131b4 100644 --- a/app/code/Magento/Downloadable/Model/Link.php +++ b/app/code/Magento/Downloadable/Model/Link.php @@ -6,7 +6,6 @@ namespace Magento\Downloadable\Model; use Magento\Downloadable\Api\Data\LinkInterface; -use Magento\Framework\Api\MetadataServiceInterface; use Magento\Downloadable\Model\Resource\Link as Resource; /** @@ -50,15 +49,10 @@ class Link extends \Magento\Framework\Model\AbstractExtensibleModel implements C const KEY_SAMPLE_URL = 'sample_url'; /**#@-*/ - /** - * @var MetadataServiceInterface - */ - protected $metadataService; - /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry - * @param \Magento\Framework\Api\MetadataServiceInterface $metadataService + * @param \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory * @param \Magento\Framework\Api\AttributeValueFactory $customAttributeFactory * @param \Magento\Framework\Model\Resource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\Db $resourceCollection @@ -67,7 +61,7 @@ class Link extends \Magento\Framework\Model\AbstractExtensibleModel implements C public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, - \Magento\Framework\Api\MetadataServiceInterface $metadataService, + \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory, \Magento\Framework\Api\AttributeValueFactory $customAttributeFactory, \Magento\Framework\Model\Resource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\Db $resourceCollection = null, @@ -76,7 +70,7 @@ class Link extends \Magento\Framework\Model\AbstractExtensibleModel implements C parent::__construct( $context, $registry, - $metadataService, + $extensionFactory, $customAttributeFactory, $resource, $resourceCollection, @@ -367,5 +361,26 @@ class Link extends \Magento\Framework\Model\AbstractExtensibleModel implements C { return $this->setData(self::KEY_SAMPLE_URL, $sampleUrl); } + + /** + * {@inheritdoc} + * + * @return \Magento\Downloadable\Api\Data\LinkExtensionInterface|null + */ + public function getExtensionAttributes() + { + return $this->_getExtensionAttributes(); + } + + /** + * {@inheritdoc} + * + * @param \Magento\Downloadable\Api\Data\LinkExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes(\Magento\Downloadable\Api\Data\LinkExtensionInterface $extensionAttributes) + { + return $this->_setExtensionAttributes($extensionAttributes); + } //@codeCoverageIgnoreEnd } diff --git a/app/code/Magento/Downloadable/Model/Link/Content.php b/app/code/Magento/Downloadable/Model/Link/Content.php index 071e130a25de07bdc7af2306dacd793eec172f52..a40f76faf1cff5c353a8406943c9b51b4f95e428 100644 --- a/app/code/Magento/Downloadable/Model/Link/Content.php +++ b/app/code/Magento/Downloadable/Model/Link/Content.php @@ -243,4 +243,26 @@ class Content extends \Magento\Framework\Model\AbstractExtensibleModel implement { return $this->setData(self::SAMPLE_TYPE, $sampleType); } + + /** + * {@inheritdoc} + * + * @return \Magento\Downloadable\Api\Data\LinkContentExtensionInterface|null + */ + public function getExtensionAttributes() + { + return $this->_getExtensionAttributes(); + } + + /** + * {@inheritdoc} + * + * @param \Magento\Downloadable\Api\Data\LinkContentExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes( + \Magento\Downloadable\Api\Data\LinkContentExtensionInterface $extensionAttributes + ) { + return $this->_setExtensionAttributes($extensionAttributes); + } } diff --git a/app/code/Magento/Downloadable/Model/Link/ContentValidator.php b/app/code/Magento/Downloadable/Model/Link/ContentValidator.php index 508536408a5e69e53af9d30d64cfe33038dbe68d..708302b7871c21c7bd1921b7a522019cbcd25aef 100644 --- a/app/code/Magento/Downloadable/Model/Link/ContentValidator.php +++ b/app/code/Magento/Downloadable/Model/Link/ContentValidator.php @@ -44,13 +44,13 @@ class ContentValidator public function isValid(LinkContentInterface $linkContent) { if (!is_numeric($linkContent->getPrice()) || $linkContent->getPrice() < 0) { - throw new InputException('Link price must have numeric positive value.'); + throw new InputException(__('Link price must have numeric positive value.')); } if (!is_int($linkContent->getNumberOfDownloads()) || $linkContent->getNumberOfDownloads() < 0) { - throw new InputException('Number of downloads must be a positive integer.'); + throw new InputException(__('Number of downloads must be a positive integer.')); } if (!is_int($linkContent->getSortOrder()) || $linkContent->getSortOrder() < 0) { - throw new InputException('Sort order must be a positive integer.'); + throw new InputException(__('Sort order must be a positive integer.')); } $this->validateLinkResource($linkContent); @@ -70,12 +70,12 @@ class ContentValidator if ($linkContent->getLinkType() == 'url' && !$this->urlValidator->isValid($linkContent->getLinkUrl()) ) { - throw new InputException('Link URL must have valid format.'); + throw new InputException(__('Link URL must have valid format.')); } if ($linkContent->getLinkType() == 'file' && (!$linkContent->getLinkFile() || !$this->fileContentValidator->isValid($linkContent->getLinkFile())) ) { - throw new InputException('Provided file content must be valid base64 encoded data.'); + throw new InputException(__('Provided file content must be valid base64 encoded data.')); } } @@ -91,12 +91,12 @@ class ContentValidator if ($linkContent->getSampleType() == 'url' && !$this->urlValidator->isValid($linkContent->getSampleUrl()) ) { - throw new InputException('Sample URL must have valid format.'); + throw new InputException(__('Sample URL must have valid format.')); } if ($linkContent->getSampleType() == 'file' && (!$linkContent->getSampleFile() || !$this->fileContentValidator->isValid($linkContent->getSampleFile())) ) { - throw new InputException('Provided file content must be valid base64 encoded data.'); + throw new InputException(__('Provided file content must be valid base64 encoded data.')); } } } diff --git a/app/code/Magento/Downloadable/Model/LinkRepository.php b/app/code/Magento/Downloadable/Model/LinkRepository.php index 586c22a32d4dc5dc4a1ce18ca029fb6feb4feee3..426e8bf63f21ed644dae4394470c8bf71d6482b4 100644 --- a/app/code/Magento/Downloadable/Model/LinkRepository.php +++ b/app/code/Magento/Downloadable/Model/LinkRepository.php @@ -90,11 +90,11 @@ class LinkRepository implements \Magento\Downloadable\Api\LinkRepositoryInterfac /** * {@inheritdoc} */ - public function getLinks($productSku) + public function getLinks($sku) { $linkList = []; /** @var \Magento\Catalog\Model\Product $product */ - $product = $this->productRepository->get($productSku); + $product = $this->productRepository->get($sku); $links = $this->downloadableType->getLinks($product); /** @var \Magento\Downloadable\Model\Link $link */ foreach ($links as $link) { @@ -150,11 +150,11 @@ class LinkRepository implements \Magento\Downloadable\Api\LinkRepositoryInterfac /** * {@inheritdoc} */ - public function getSamples($productSku) + public function getSamples($sku) { $sampleList = []; /** @var \Magento\Catalog\Model\Product $product */ - $product = $this->productRepository->get($productSku); + $product = $this->productRepository->get($sku); $samples = $this->downloadableType->getSamples($product); /** @var \Magento\Downloadable\Model\Sample $sample */ foreach ($samples as $sample) { @@ -181,21 +181,21 @@ class LinkRepository implements \Magento\Downloadable\Api\LinkRepositoryInterfac * @SuppressWarnings(PHPMD.CyclomaticComplexity) * @SuppressWarnings(PHPMD.NPathComplexity) */ - public function save($productSku, LinkContentInterface $linkContent, $linkId = null, $isGlobalScopeContent = false) + public function save($sku, LinkContentInterface $linkContent, $linkId = null, $isGlobalScopeContent = false) { - $product = $this->productRepository->get($productSku, true); + $product = $this->productRepository->get($sku, true); if ($linkId) { /** @var $link \Magento\Downloadable\Model\Link */ $link = $this->linkFactory->create()->load($linkId); if (!$link->getId()) { - throw new NoSuchEntityException('There is no downloadable link with provided ID.'); + throw new NoSuchEntityException(__('There is no downloadable link with provided ID.')); } if ($link->getProductId() != $product->getId()) { - throw new InputException('Provided downloadable link is not related to given product.'); + throw new InputException(__('Provided downloadable link is not related to given product.')); } if (!$this->contentValidator->isValid($linkContent)) { - throw new InputException('Provided link information is invalid.'); + throw new InputException(__('Provided link information is invalid.')); } if ($isGlobalScopeContent) { $product->setStoreId(0); @@ -203,7 +203,7 @@ class LinkRepository implements \Magento\Downloadable\Api\LinkRepositoryInterfac $title = $linkContent->getTitle(); if (empty($title)) { if ($isGlobalScopeContent) { - throw new InputException('Link title cannot be empty.'); + throw new InputException(__('Link title cannot be empty.')); } // use title from GLOBAL scope $link->setTitle(null); @@ -222,20 +222,20 @@ class LinkRepository implements \Magento\Downloadable\Api\LinkRepositoryInterfac ->save(); return $link->getId(); } else { - $product = $this->productRepository->get($productSku, true); + $product = $this->productRepository->get($sku, true); if ($product->getTypeId() !== \Magento\Downloadable\Model\Product\Type::TYPE_DOWNLOADABLE) { - throw new InputException('Product type of the product must be \'downloadable\'.'); + throw new InputException(__('Product type of the product must be \'downloadable\'.')); } if (!$this->contentValidator->isValid($linkContent)) { - throw new InputException('Provided link information is invalid.'); + throw new InputException(__('Provided link information is invalid.')); } if (!in_array($linkContent->getLinkType(), ['url', 'file'])) { - throw new InputException('Invalid link type.'); + throw new InputException(__('Invalid link type.')); } $title = $linkContent->getTitle(); if (empty($title)) { - throw new InputException('Link title cannot be empty.'); + throw new InputException(__('Link title cannot be empty.')); } $linkData = [ @@ -289,7 +289,7 @@ class LinkRepository implements \Magento\Downloadable\Api\LinkRepositoryInterfac /** @var $link \Magento\Downloadable\Model\Link */ $link = $this->linkFactory->create()->load($linkId); if (!$link->getId()) { - throw new NoSuchEntityException('There is no downloadable link with provided ID.'); + throw new NoSuchEntityException(__('There is no downloadable link with provided ID.')); } $link->delete(); return true; diff --git a/app/code/Magento/Downloadable/Model/Sample.php b/app/code/Magento/Downloadable/Model/Sample.php index 23cd6bd9408e61195d3f1eb6955363cc77fa514c..07dd821050aad1d60ae18abc38211afdd1fb4a55 100644 --- a/app/code/Magento/Downloadable/Model/Sample.php +++ b/app/code/Magento/Downloadable/Model/Sample.php @@ -33,7 +33,7 @@ class Sample extends \Magento\Framework\Model\AbstractExtensibleModel implements /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry - * @param \Magento\Framework\Api\MetadataServiceInterface $metadataService + * @param \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory * @param \Magento\Framework\Api\AttributeValueFactory $customAttributeFactory * @param \Magento\Framework\Model\Resource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\Db $resourceCollection @@ -42,7 +42,7 @@ class Sample extends \Magento\Framework\Model\AbstractExtensibleModel implements public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, - \Magento\Framework\Api\MetadataServiceInterface $metadataService, + \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory, \Magento\Framework\Api\AttributeValueFactory $customAttributeFactory, \Magento\Framework\Model\Resource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\Db $resourceCollection = null, @@ -51,7 +51,7 @@ class Sample extends \Magento\Framework\Model\AbstractExtensibleModel implements parent::__construct( $context, $registry, - $metadataService, + $extensionFactory, $customAttributeFactory, $resource, $resourceCollection, @@ -224,4 +224,25 @@ class Sample extends \Magento\Framework\Model\AbstractExtensibleModel implements { return $this->setData(self::KEY_SAMPLE_URL, $sampleUrl); } + + /** + * {@inheritdoc} + * + * @return \Magento\Downloadable\Api\Data\SampleExtensionInterface|null + */ + public function getExtensionAttributes() + { + return $this->_getExtensionAttributes(); + } + + /** + * {@inheritdoc} + * + * @param \Magento\Downloadable\Api\Data\SampleExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes(\Magento\Downloadable\Api\Data\SampleExtensionInterface $extensionAttributes) + { + return $this->_setExtensionAttributes($extensionAttributes); + } } diff --git a/app/code/Magento/Downloadable/Model/Sample/Content.php b/app/code/Magento/Downloadable/Model/Sample/Content.php index f60f92f9d11f91e86de522f3d346030e694f5178..0fcf613353966548cfbf6ec83e2ca47837ff9f54 100644 --- a/app/code/Magento/Downloadable/Model/Sample/Content.php +++ b/app/code/Magento/Downloadable/Model/Sample/Content.php @@ -117,4 +117,26 @@ class Content extends \Magento\Framework\Model\AbstractExtensibleModel implement { return $this->setData(self::SAMPLE_URL, $sampleUrl); } + + /** + * {@inheritdoc} + * + * @return \Magento\Downloadable\Api\Data\SampleContentExtensionInterface|null + */ + public function getExtensionAttributes() + { + return $this->_getExtensionAttributes(); + } + + /** + * {@inheritdoc} + * + * @param \Magento\Downloadable\Api\Data\SampleContentExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes( + \Magento\Downloadable\Api\Data\SampleContentExtensionInterface $extensionAttributes + ) { + return $this->_setExtensionAttributes($extensionAttributes); + } } diff --git a/app/code/Magento/Downloadable/Model/Sample/ContentValidator.php b/app/code/Magento/Downloadable/Model/Sample/ContentValidator.php index d316ef4ccd93bc39d0391847b309974c1c213257..294bd783d463560a5846eada1cc400f5e6a97ce7 100644 --- a/app/code/Magento/Downloadable/Model/Sample/ContentValidator.php +++ b/app/code/Magento/Downloadable/Model/Sample/ContentValidator.php @@ -44,7 +44,7 @@ class ContentValidator public function isValid(SampleContentInterface $sampleContent) { if (!is_int($sampleContent->getSortOrder()) || $sampleContent->getSortOrder() < 0) { - throw new InputException('Sort order must be a positive integer.'); + throw new InputException(__('Sort order must be a positive integer.')); } $this->validateSampleResource($sampleContent); @@ -64,13 +64,13 @@ class ContentValidator if ($sampleContent->getSampleType() == 'file' && (!$sampleFile || !$this->fileContentValidator->isValid($sampleFile)) ) { - throw new InputException('Provided file content must be valid base64 encoded data.'); + throw new InputException(__('Provided file content must be valid base64 encoded data.')); } if ($sampleContent->getSampleType() == 'url' && !$this->urlValidator->isValid($sampleContent->getSampleUrl()) ) { - throw new InputException('Sample URL must have valid format.'); + throw new InputException(__('Sample URL must have valid format.')); } } } diff --git a/app/code/Magento/Downloadable/Model/SampleRepository.php b/app/code/Magento/Downloadable/Model/SampleRepository.php index d77aaaf1825f8ca3702e29225299067e22897351..b97702bd9adaf8c143dbf0f62823c460121fe02c 100644 --- a/app/code/Magento/Downloadable/Model/SampleRepository.php +++ b/app/code/Magento/Downloadable/Model/SampleRepository.php @@ -75,14 +75,14 @@ class SampleRepository implements \Magento\Downloadable\Api\SampleRepositoryInte $sample = $this->sampleFactory->create()->load($sampleId); if (!$sample->getId()) { - throw new NoSuchEntityException('There is no downloadable sample with provided ID.'); + throw new NoSuchEntityException(__('There is no downloadable sample with provided ID.')); } if ($sample->getProductId() != $product->getId()) { - throw new InputException('Provided downloadable sample is not related to given product.'); + throw new InputException(__('Provided downloadable sample is not related to given product.')); } if (!$this->contentValidator->isValid($sampleContent)) { - throw new InputException('Provided sample information is invalid.'); + throw new InputException(__('Provided sample information is invalid.')); } if ($isGlobalScopeContent) { $product->setStoreId(0); @@ -91,7 +91,7 @@ class SampleRepository implements \Magento\Downloadable\Api\SampleRepositoryInte $title = $sampleContent->getTitle(); if (empty($title)) { if ($isGlobalScopeContent) { - throw new InputException('Sample title cannot be empty.'); + throw new InputException(__('Sample title cannot be empty.')); } // use title from GLOBAL scope $sample->setTitle(null); @@ -108,19 +108,19 @@ class SampleRepository implements \Magento\Downloadable\Api\SampleRepositoryInte } else { if ($product->getTypeId() !== \Magento\Downloadable\Model\Product\Type::TYPE_DOWNLOADABLE) { - throw new InputException('Product type of the product must be \'downloadable\'.'); + throw new InputException(__('Product type of the product must be \'downloadable\'.')); } if (!$this->contentValidator->isValid($sampleContent)) { - throw new InputException('Provided sample information is invalid.'); + throw new InputException(__('Provided sample information is invalid.')); } if (!in_array($sampleContent->getSampleType(), ['url', 'file'])) { - throw new InputException('Invalid sample type.'); + throw new InputException(__('Invalid sample type.')); } $title = $sampleContent->getTitle(); if (empty($title)) { - throw new InputException('Sample title cannot be empty.'); + throw new InputException(__('Sample title cannot be empty.')); } $sampleData = [ @@ -159,7 +159,7 @@ class SampleRepository implements \Magento\Downloadable\Api\SampleRepositoryInte /** @var $sample \Magento\Downloadable\Model\Sample */ $sample = $this->sampleFactory->create()->load($sampleId); if (!$sample->getId()) { - throw new NoSuchEntityException('There is no downloadable sample with provided ID.'); + throw new NoSuchEntityException(__('There is no downloadable sample with provided ID.')); } $sample->delete(); return true; diff --git a/app/code/Magento/Downloadable/etc/config.xml b/app/code/Magento/Downloadable/etc/config.xml index e0460f6028eeb68ff4c51eb964a9d97e9ac32198..4cd8938ad25e8124510f74e2ce8e4395de9573ef 100644 --- a/app/code/Magento/Downloadable/etc/config.xml +++ b/app/code/Magento/Downloadable/etc/config.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Core/etc/config.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Store/etc/config.xsd"> <default> <catalog> <downloadable> diff --git a/app/code/Magento/Downloadable/etc/frontend/page_types.xml b/app/code/Magento/Downloadable/etc/frontend/page_types.xml index caa1839665d6da8eb350758d7d39f415e3bb1bba..609bc5837c17881bbedddb11c42a5e61e8de729a 100644 --- a/app/code/Magento/Downloadable/etc/frontend/page_types.xml +++ b/app/code/Magento/Downloadable/etc/frontend/page_types.xml @@ -5,6 +5,6 @@ * See COPYING.txt for license details. */ --> -<page_types xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../Core/etc/page_types.xsd"> +<page_types xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_types.xsd"> <type id="downloadable_customer_products" label="Customer My Account Downloadable Items"/> </page_types> diff --git a/app/code/Magento/Downloadable/etc/webapi.xml b/app/code/Magento/Downloadable/etc/webapi.xml index 7a95a353ded05feb876d90d6b96361cce19ef9eb..0291fe5322f8328380ab63b58dfd7b8b8322dbe2 100644 --- a/app/code/Magento/Downloadable/etc/webapi.xml +++ b/app/code/Magento/Downloadable/etc/webapi.xml @@ -7,25 +7,25 @@ --> <routes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../app/code/Magento/Webapi/etc/webapi.xsd"> - <route url="/V1/products/:productSku/downloadable-links" method="GET"> + <route url="/V1/products/:sku/downloadable-links" method="GET"> <service class="Magento\Downloadable\Api\LinkRepositoryInterface" method="getLinks"/> <resources> <resource ref="Magento_Downloadable::downloadable" /> </resources> </route> - <route url="/V1/products/:productSku/downloadable-links/samples" method="GET"> + <route url="/V1/products/:sku/downloadable-links/samples" method="GET"> <service class="Magento\Downloadable\Api\LinkRepositoryInterface" method="getSamples"/> <resources> <resource ref="Magento_Downloadable::downloadable" /> </resources> </route> - <route url="/V1/products/:productSku/downloadable-links" method="POST"> + <route url="/V1/products/:sku/downloadable-links" method="POST"> <service class="Magento\Downloadable\Api\LinkRepositoryInterface" method="save"/> <resources> <resource ref="Magento_Downloadable::downloadable" /> </resources> </route> - <route url="/V1/products/:productSku/downloadable-links/:linkId" method="PUT"> + <route url="/V1/products/:sku/downloadable-links/:linkId" method="PUT"> <service class="Magento\Downloadable\Api\LinkRepositoryInterface" method="save"/> <resources> <resource ref="Magento_Downloadable::downloadable" /> @@ -37,13 +37,13 @@ <resource ref="Magento_Downloadable::downloadable" /> </resources> </route> - <route url="/V1/products/:productSku/downloadable-links/samples" method="POST"> + <route url="/V1/products/:sku/downloadable-links/samples" method="POST"> <service class="Magento\Downloadable\Api\SampleRepositoryInterface" method="save"/> <resources> <resource ref="Magento_Downloadable::downloadable" /> </resources> </route> - <route url="/V1/products/:productSku/downloadable-links/samples/:sampleId" method="PUT"> + <route url="/V1/products/:sku/downloadable-links/samples/:sampleId" method="PUT"> <service class="Magento\Downloadable\Api\SampleRepositoryInterface" method="save"/> <resources> <resource ref="Magento_Downloadable::downloadable" /> diff --git a/app/code/Magento/Eav/Api/Data/AttributeGroupInterface.php b/app/code/Magento/Eav/Api/Data/AttributeGroupInterface.php index 074bc9c6721d0cbf944c5d5b5a07542b69143c1b..9c02bda805670c87d5870d4e8828769666d474ae 100644 --- a/app/code/Magento/Eav/Api/Data/AttributeGroupInterface.php +++ b/app/code/Magento/Eav/Api/Data/AttributeGroupInterface.php @@ -1,12 +1,13 @@ <?php /** - * * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ namespace Magento\Eav\Api\Data; -interface AttributeGroupInterface +use Magento\Framework\Api\ExtensibleDataInterface; + +interface AttributeGroupInterface extends ExtensibleDataInterface { const GROUP_ID = 'attribute_group_id'; @@ -58,4 +59,21 @@ interface AttributeGroupInterface * @return $this */ public function setAttributeSetId($attributeSetId); + + /** + * Retrieve existing extension attributes object. + * + * @return \Magento\Eav\Api\Data\AttributeGroupExtensionInterface|null + */ + public function getExtensionAttributes(); + + /** + * Set an extension attributes object. + * + * @param \Magento\Eav\Api\Data\AttributeGroupExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes( + \Magento\Eav\Api\Data\AttributeGroupExtensionInterface $extensionAttributes + ); } diff --git a/app/code/Magento/Eav/Api/Data/AttributeInterface.php b/app/code/Magento/Eav/Api/Data/AttributeInterface.php index 45f61ee56dd2aa920b225bbb66a2404fdd81ba3c..614d75a1279454b3aed41b98788e85cd15c193d8 100644 --- a/app/code/Magento/Eav/Api/Data/AttributeInterface.php +++ b/app/code/Magento/Eav/Api/Data/AttributeInterface.php @@ -6,7 +6,7 @@ */ namespace Magento\Eav\Api\Data; -interface AttributeInterface extends \Magento\Framework\Api\ExtensibleDataInterface +interface AttributeInterface extends \Magento\Framework\Api\CustomAttributesDataInterface { const ATTRIBUTE_ID = 'attribute_id'; @@ -297,4 +297,9 @@ interface AttributeInterface extends \Magento\Framework\Api\ExtensibleDataInterf * @return $this */ public function setValidationRules(array $validationRules = null); + + /** + * @return \Magento\Eav\Api\Data\AttributeExtensionInterface|null + */ + public function getExtensionAttributes(); } diff --git a/app/code/Magento/Eav/Api/Data/AttributeSetInterface.php b/app/code/Magento/Eav/Api/Data/AttributeSetInterface.php index 0c8e66dae0f0e09bf519e21875ca6acc90bcc24e..a44a0bd4dae93040d2903c97b4355362ce872b2d 100644 --- a/app/code/Magento/Eav/Api/Data/AttributeSetInterface.php +++ b/app/code/Magento/Eav/Api/Data/AttributeSetInterface.php @@ -5,7 +5,7 @@ */ namespace Magento\Eav\Api\Data; -interface AttributeSetInterface +interface AttributeSetInterface extends \Magento\Framework\Api\ExtensibleDataInterface { /** * Get attribute set ID @@ -66,4 +66,19 @@ interface AttributeSetInterface * @return $this */ public function setEntityTypeId($entityTypeId); + + /** + * Retrieve existing extension attributes object or create a new one. + * + * @return \Magento\Eav\Api\Data\AttributeSetExtensionInterface|null + */ + public function getExtensionAttributes(); + + /** + * Set an extension attributes object. + * + * @param \Magento\Eav\Api\Data\AttributeSetExtensionInterface|null $extensionAttributes + * @return $this + */ + public function setExtensionAttributes(\Magento\Eav\Api\Data\AttributeSetExtensionInterface $extensionAttributes); } diff --git a/app/code/Magento/Eav/Model/Attribute/GroupRepository.php b/app/code/Magento/Eav/Model/Attribute/GroupRepository.php index 558964315f315229a58605dbc3adf0698fb86629..5b1b7d539d930520b1c118b01f405cc07aa1c171 100644 --- a/app/code/Magento/Eav/Model/Attribute/GroupRepository.php +++ b/app/code/Magento/Eav/Model/Attribute/GroupRepository.php @@ -78,14 +78,16 @@ class GroupRepository implements \Magento\Eav\Api\AttributeGroupRepositoryInterf throw NoSuchEntityException::singleField('attributeGroupId', $existingGroup->getId()); } if ($existingGroup->getAttributeSetId() != $group->getAttributeSetId()) { - throw new StateException('Attribute group does not belong to provided attribute set'); + throw new StateException( + __('Attribute group does not belong to provided attribute set') + ); } } try { $this->groupResource->save($group); } catch (\Exception $e) { - throw new StateException('Cannot save attributeGroup'); + throw new StateException(__('Cannot save attributeGroup')); } return $group; } @@ -125,7 +127,7 @@ class GroupRepository implements \Magento\Eav\Api\AttributeGroupRepositoryInterf $group = $this->groupFactory->create(); $this->groupResource->load($group, $groupId); if (!$group->getId()) { - throw new NoSuchEntityException(sprintf('Group with id "%s" does not exist.', $groupId)); + throw new NoSuchEntityException(__('Group with id "%1" does not exist.', $groupId)); } return $group; } @@ -139,10 +141,10 @@ class GroupRepository implements \Magento\Eav\Api\AttributeGroupRepositoryInterf $this->groupResource->delete($group); } catch (\Exception $e) { throw new StateException( - 'Cannot delete attributeGroup with id %attribute_group_id', - [ - 'attribute_group_id' => $group->getId() - ], + __( + 'Cannot delete attributeGroup with id %1', + $group->getId() + ), $e ); } diff --git a/app/code/Magento/Eav/Model/AttributeManagement.php b/app/code/Magento/Eav/Model/AttributeManagement.php index eb541cb2ebb3bf84d5ccffba84bc2fabf5711718..b687a853039e30474484fd614ead44a2ca69c454 100644 --- a/app/code/Magento/Eav/Model/AttributeManagement.php +++ b/app/code/Magento/Eav/Model/AttributeManagement.php @@ -82,19 +82,19 @@ class AttributeManagement implements \Magento\Eav\Api\AttributeManagementInterfa try { $attributeSet = $this->setRepository->get($attributeSetId); } catch (NoSuchEntityException $ex) { - throw new NoSuchEntityException(sprintf('AttributeSet with id "%s" does not exist.', $attributeSetId)); + throw new NoSuchEntityException(__('AttributeSet with id "%1" does not exist.', $attributeSetId)); } $setEntityType = $this->entityTypeFactory->create()->getEntityType($attributeSet->getEntityTypeId()); if ($setEntityType->getEntityTypeCode() != $entityTypeCode) { - throw new InputException('Wrong attribute set id provided'); + throw new InputException(__('Wrong attribute set id provided')); } //Check if group exists. If not - expected exception $attributeGroup = $this->groupRepository->get($attributeGroupId); if ($attributeGroup->getAttributeSetId() != $attributeSetId) { - throw new InputException('Attribute group does not belong to attribute set'); + throw new InputException(__('Attribute group does not belong to attribute set')); } /** @var \Magento\Eav\Api\Data\AttributeInterface $attribute */ @@ -119,7 +119,7 @@ class AttributeManagement implements \Magento\Eav\Api\AttributeManagementInterfa try { $attributeSet = $this->setRepository->get($attributeSetId); } catch (NoSuchEntityException $e) { - throw new NoSuchEntityException('Attribute set not found: ' . $attributeSetId); + throw new NoSuchEntityException(__('Attribute set not found: %1', $attributeSetId)); } $setEntityType = $this->entityTypeFactory->create()->getEntityType($attributeSet->getEntityTypeId()); @@ -132,11 +132,11 @@ class AttributeManagement implements \Magento\Eav\Api\AttributeManagementInterfa if (!$attribute->getEntityAttributeId()) { throw new InputException( - sprintf('Attribute "%s" not found in attribute set %s.', $attributeCode, $attributeSetId) + __('Attribute "%1" not found in attribute set %2.', $attributeCode, $attributeSetId) ); } if (!$attribute->getIsUserDefined()) { - throw new StateException('System attribute can not be deleted'); + throw new StateException(__('System attribute can not be deleted')); } $attribute->deleteEntity(); return true; diff --git a/app/code/Magento/Eav/Model/AttributeRepository.php b/app/code/Magento/Eav/Model/AttributeRepository.php index b3dfb59a88829a072cf65e6dc7fb4c9336459a10..e325fea2f4717844fc93a076076fb13731b3407a 100644 --- a/app/code/Magento/Eav/Model/AttributeRepository.php +++ b/app/code/Magento/Eav/Model/AttributeRepository.php @@ -71,7 +71,7 @@ class AttributeRepository implements \Magento\Eav\Api\AttributeRepositoryInterfa try { $this->eavResource->save($attribute); } catch (\Exception $e) { - throw new StateException('Cannot save attribute'); + throw new StateException(__('Cannot save attribute')); } return $attribute; } @@ -142,10 +142,9 @@ class AttributeRepository implements \Magento\Eav\Api\AttributeRepositoryInterfa /** @var \Magento\Eav\Api\Data\AttributeInterface $attribute */ $attribute = $this->eavConfig->getAttribute($entityTypeCode, $attributeCode); if (!$attribute || !$attribute->getAttributeId()) { - throw new NoSuchEntityException(sprintf( - 'Attribute with attributeCode "%s" does not exist.', - $attributeCode - )); + throw new NoSuchEntityException( + __('Attribute with attributeCode "%1" does not exist.', $attributeCode) + ); } return $attribute; } @@ -158,7 +157,7 @@ class AttributeRepository implements \Magento\Eav\Api\AttributeRepositoryInterfa try { $this->eavResource->delete($attribute); } catch (\Exception $e) { - throw new StateException('Cannot delete attribute.'); + throw new StateException(__('Cannot delete attribute.')); } return true; } @@ -173,7 +172,7 @@ class AttributeRepository implements \Magento\Eav\Api\AttributeRepositoryInterfa $this->eavResource->load($attribute, $attributeId); if (!$attribute->getAttributeId()) { - throw new NoSuchEntityException(sprintf('Attribute with id "%s" does not exist.', $attributeId)); + throw new NoSuchEntityException(__('Attribute with id "%1" does not exist.', $attributeId)); } $this->delete($attribute); diff --git a/app/code/Magento/Eav/Model/AttributeSetManagement.php b/app/code/Magento/Eav/Model/AttributeSetManagement.php index 729b64b4bb0b81f7f5f81ffd09fb4a47824955b7..4b155096bdb03b862158b1786d31d6ba8ab01f09 100644 --- a/app/code/Magento/Eav/Model/AttributeSetManagement.php +++ b/app/code/Magento/Eav/Model/AttributeSetManagement.php @@ -54,7 +54,7 @@ class AttributeSetManagement implements AttributeSetManagementInterface $attributeSet->setEntityTypeId($this->eavConfig->getEntityType($entityTypeCode)->getId()); $attributeSet->validate(); } catch (\Exception $exception) { - throw new InputException($exception->getMessage()); + throw new InputException(__($exception->getMessage())); } $this->repository->save($attributeSet); diff --git a/app/code/Magento/Eav/Model/AttributeSetRepository.php b/app/code/Magento/Eav/Model/AttributeSetRepository.php index dc989a741f09d3dc6a825b156da200cfabf42dea..b54ca8e171e01e394a02fc6ebc380b547dc67700 100644 --- a/app/code/Magento/Eav/Model/AttributeSetRepository.php +++ b/app/code/Magento/Eav/Model/AttributeSetRepository.php @@ -75,7 +75,7 @@ class AttributeSetRepository implements AttributeSetRepositoryInterface try { $this->attributeSetResource->save($attributeSet); } catch (\Exception $exception) { - throw new CouldNotSaveException('There was an error saving attribute set.'); + throw new CouldNotSaveException(__('There was an error saving attribute set.')); } return $attributeSet; } @@ -146,9 +146,9 @@ class AttributeSetRepository implements AttributeSetRepositoryInterface try { $this->attributeSetResource->delete($attributeSet); } catch (\Magento\Framework\Exception\StateException $exception) { - throw new CouldNotDeleteException('Default attribute set can not be deleted'); + throw new CouldNotDeleteException(__('Default attribute set can not be deleted')); } catch (\Exception $exception) { - throw new CouldNotDeleteException('There was an error deleting attribute set.'); + throw new CouldNotDeleteException(__('There was an error deleting attribute set.')); } return true; } diff --git a/app/code/Magento/Eav/Model/EavCustomAttributeTypeLocator.php b/app/code/Magento/Eav/Model/EavCustomAttributeTypeLocator.php new file mode 100644 index 0000000000000000000000000000000000000000..958c645190806499496440018d332fb1caf0f750 --- /dev/null +++ b/app/code/Magento/Eav/Model/EavCustomAttributeTypeLocator.php @@ -0,0 +1,72 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Eav\Model; + +use Magento\Eav\Api\AttributeRepositoryInterface; +use Magento\Framework\Exception\NoSuchEntityException; +use Magento\Framework\Webapi\CustomAttributeTypeLocatorInterface; + +class EavCustomAttributeTypeLocator implements CustomAttributeTypeLocatorInterface +{ + /** + * @var AttributeRepositoryInterface + */ + private $attributeRepository; + + /** + * @var array + */ + private $serviceEntityTypeMap; + + /** + * @var array + */ + private $serviceBackendModelDataInterfaceMap; + + /** + * Initialize EavCustomAttributeTypeLocator + * + * @param AttributeRepositoryInterface $attributeRepository + * @param array $serviceEntityTypeMap + * @param array $serviceBackendModelDataInterfaceMap + */ + public function __construct( + AttributeRepositoryInterface $attributeRepository, + array $serviceEntityTypeMap = [], + array $serviceBackendModelDataInterfaceMap = [] + ) { + $this->attributeRepository = $attributeRepository; + $this->serviceEntityTypeMap = $serviceEntityTypeMap; + $this->serviceBackendModelDataInterfaceMap = $serviceBackendModelDataInterfaceMap; + } + + /** + * {@inheritdoc} + */ + public function getType($attributeCode, $serviceClass) + { + if (!$serviceClass || !$attributeCode || !isset($this->serviceEntityTypeMap[$serviceClass]) + || !isset($this->serviceBackendModelDataInterfaceMap[$serviceClass]) + ) { + return null; + } + + try { + $backendModel = $this->attributeRepository + ->get($this->serviceEntityTypeMap[$serviceClass], $attributeCode) + ->getBackendModel(); + } catch (NoSuchEntityException $e) { + return null; + } + + $dataInterface = isset($this->serviceBackendModelDataInterfaceMap[$serviceClass][$backendModel]) + ? $this->serviceBackendModelDataInterfaceMap[$serviceClass][$backendModel] + : null; + + return $dataInterface; + } +} diff --git a/app/code/Magento/Eav/Model/Entity/AbstractEntity.php b/app/code/Magento/Eav/Model/Entity/AbstractEntity.php index 5a2b8365a25204491b4c079f86ef3aca4768b3b6..6c2dcc71ed12a164f6a8675b18aef512523a97d0 100644 --- a/app/code/Magento/Eav/Model/Entity/AbstractEntity.php +++ b/app/code/Magento/Eav/Model/Entity/AbstractEntity.php @@ -1024,6 +1024,9 @@ abstract class AbstractEntity extends \Magento\Framework\Model\Resource\Abstract if (empty($attributes)) { $this->loadAllAttributes($object); } else { + if (!is_array($attributes)) { + $attributes = [$attributes]; + } foreach ($attributes as $attrCode) { $this->getAttribute($attrCode); } diff --git a/app/code/Magento/Eav/Model/Entity/Attribute.php b/app/code/Magento/Eav/Model/Entity/Attribute.php index ef74bb1e59e968598de052ba3c08707c67f402cd..df877f97a92afdec4ea0cdb857e10d3a90f84ba9 100644 --- a/app/code/Magento/Eav/Model/Entity/Attribute.php +++ b/app/code/Magento/Eav/Model/Entity/Attribute.php @@ -12,6 +12,7 @@ use Magento\Framework\Api\AttributeValueFactory; * EAV Entity attribute model * * @method \Magento\Eav\Model\Entity\Attribute setOption($value) + * @method \Magento\Eav\Api\Data\AttributeExtensionInterface getExtensionAttributes() * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class Attribute extends \Magento\Eav\Model\Entity\Attribute\AbstractAttribute implements @@ -66,7 +67,7 @@ class Attribute extends \Magento\Eav\Model\Entity\Attribute\AbstractAttribute im /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry - * @param \Magento\Framework\Api\MetadataServiceInterface $metadataService + * @param \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory * @param AttributeValueFactory $customAttributeFactory * @param \Magento\Eav\Model\Config $eavConfig * @param TypeFactory $eavTypeFactory @@ -87,7 +88,7 @@ class Attribute extends \Magento\Eav\Model\Entity\Attribute\AbstractAttribute im public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, - \Magento\Framework\Api\MetadataServiceInterface $metadataService, + \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory, AttributeValueFactory $customAttributeFactory, \Magento\Eav\Model\Config $eavConfig, \Magento\Eav\Model\Entity\TypeFactory $eavTypeFactory, @@ -107,7 +108,7 @@ class Attribute extends \Magento\Eav\Model\Entity\Attribute\AbstractAttribute im parent::__construct( $context, $registry, - $metadataService, + $extensionFactory, $customAttributeFactory, $eavConfig, $eavTypeFactory, diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/AbstractAttribute.php b/app/code/Magento/Eav/Model/Entity/Attribute/AbstractAttribute.php index 155f3a0f0e1fb2ed46c73c472a57ee8b9b92ee9c..d241a3234fa697bfdb4c833f511a8159d1998d06 100644 --- a/app/code/Magento/Eav/Model/Entity/Attribute/AbstractAttribute.php +++ b/app/code/Magento/Eav/Model/Entity/Attribute/AbstractAttribute.php @@ -114,7 +114,7 @@ abstract class AbstractAttribute extends \Magento\Framework\Model\AbstractExtens /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry - * @param \Magento\Framework\Api\MetadataServiceInterface $metadataService + * @param \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory * @param AttributeValueFactory $customAttributeFactory * @param \Magento\Eav\Model\Config $eavConfig * @param \Magento\Eav\Model\Entity\TypeFactory $eavTypeFactory @@ -132,7 +132,7 @@ abstract class AbstractAttribute extends \Magento\Framework\Model\AbstractExtens public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, - \Magento\Framework\Api\MetadataServiceInterface $metadataService, + \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory, AttributeValueFactory $customAttributeFactory, \Magento\Eav\Model\Config $eavConfig, \Magento\Eav\Model\Entity\TypeFactory $eavTypeFactory, @@ -149,7 +149,7 @@ abstract class AbstractAttribute extends \Magento\Framework\Model\AbstractExtens parent::__construct( $context, $registry, - $metadataService, + $extensionFactory, $customAttributeFactory, $resource, $resourceCollection, @@ -1184,4 +1184,25 @@ abstract class AbstractAttribute extends \Magento\Framework\Model\AbstractExtens { return $this->setData(self::VALIDATE_RULES, $validationRules); } + + /** + * {@inheritdoc} + * + * @return \Magento\Eav\Api\Data\AttributeExtensionInterface|null + */ + public function getExtensionAttributes() + { + return $this->_getExtensionAttributes(); + } + + /** + * {@inheritdoc} + * + * @param \Magento\Eav\Api\Data\AttributeExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes(\Magento\Eav\Api\Data\AttributeExtensionInterface $extensionAttributes) + { + return $this->_setExtensionAttributes($extensionAttributes); + } } diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/Backend/Time/Created.php b/app/code/Magento/Eav/Model/Entity/Attribute/Backend/Time/Created.php index 5e14ddca8729ee2299fc60b3c4dd28488d75eb10..b12ddf75a716d052c30e7b0a2d4edeb623f076dc 100644 --- a/app/code/Magento/Eav/Model/Entity/Attribute/Backend/Time/Created.php +++ b/app/code/Magento/Eav/Model/Entity/Attribute/Backend/Time/Created.php @@ -26,7 +26,7 @@ class Created extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBacken /** * Set created date * - * @param \Magento\Core\Model\Object $object + * @param \Magento\Framework\Model\AbstractModel $object * @return $this */ public function beforeSave($object) diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/Group.php b/app/code/Magento/Eav/Model/Entity/Attribute/Group.php index 1e68ac3ccbf19c3e0961a381b7c334b99f082114..4248f1523d4d517c4061b453cb6353832206d4b0 100644 --- a/app/code/Magento/Eav/Model/Entity/Attribute/Group.php +++ b/app/code/Magento/Eav/Model/Entity/Attribute/Group.php @@ -3,6 +3,7 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ + namespace Magento\Eav\Model\Entity\Attribute; /** @@ -124,5 +125,27 @@ class Group extends \Magento\Framework\Model\AbstractExtensibleModel implements { return $this->setData(self::ATTRIBUTE_SET_ID, $attributeSetId); } + + /** + * {@inheritdoc} + * + * @return \Magento\Eav\Api\Data\AttributeGroupExtensionInterface|null + */ + public function getExtensionAttributes() + { + return $this->_getExtensionAttributes(); + } + + /** + * {@inheritdoc} + * + * @param \Magento\Eav\Api\Data\AttributeGroupExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes( + \Magento\Eav\Api\Data\AttributeGroupExtensionInterface $extensionAttributes + ) { + return $this->_setExtensionAttributes($extensionAttributes); + } //@codeCoverageIgnoreEnd } diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/Option.php b/app/code/Magento/Eav/Model/Entity/Attribute/Option.php index f884585623b3be172c84067a7293f53c3ac95237..57cbb324ef7c81b39cdb76d140ed697b90ce999f 100644 --- a/app/code/Magento/Eav/Model/Entity/Attribute/Option.php +++ b/app/code/Magento/Eav/Model/Entity/Attribute/Option.php @@ -6,7 +6,7 @@ namespace Magento\Eav\Model\Entity\Attribute; use Magento\Eav\Api\Data\AttributeOptionInterface; -use Magento\Framework\Model\AbstractExtensibleModel; +use Magento\Framework\Model\AbstractModel; /** * Emtity attribute option model @@ -18,7 +18,7 @@ use Magento\Framework\Model\AbstractExtensibleModel; * * @author Magento Core Team <core@magentocommerce.com> */ -class Option extends AbstractExtensibleModel implements AttributeOptionInterface +class Option extends AbstractModel implements AttributeOptionInterface { /** * Resource initialization diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/OptionLabel.php b/app/code/Magento/Eav/Model/Entity/Attribute/OptionLabel.php index 5319477495b36e0e87e8a3e294db2a6d5c3a8ece..dfb45c211041d8dd89fb05974df32a7af9930901 100644 --- a/app/code/Magento/Eav/Model/Entity/Attribute/OptionLabel.php +++ b/app/code/Magento/Eav/Model/Entity/Attribute/OptionLabel.php @@ -6,13 +6,13 @@ namespace Magento\Eav\Model\Entity\Attribute; use Magento\Eav\Api\Data\AttributeOptionLabelInterface; -use Magento\Framework\Model\AbstractExtensibleModel; +use Magento\Framework\Model\AbstractModel; /** * Entity attribute option label model * */ -class OptionLabel extends AbstractExtensibleModel implements AttributeOptionLabelInterface +class OptionLabel extends AbstractModel implements AttributeOptionLabelInterface { /** * {@inheritdoc} diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/OptionManagement.php b/app/code/Magento/Eav/Model/Entity/Attribute/OptionManagement.php index a9deaed6b17eb98f6ebf630df6c5c66ee755c946..188f9818c2da25400fb65320fdc5c3fe30ea94f2 100644 --- a/app/code/Magento/Eav/Model/Entity/Attribute/OptionManagement.php +++ b/app/code/Magento/Eav/Model/Entity/Attribute/OptionManagement.php @@ -40,12 +40,12 @@ class OptionManagement implements \Magento\Eav\Api\AttributeOptionManagementInte public function add($entityType, $attributeCode, $option) { if (empty($attributeCode)) { - throw new InputException('Empty attribute code'); + throw new InputException(__('Empty attribute code')); } $attribute = $this->attributeRepository->get($entityType, $attributeCode); if (!$attribute->usesSource()) { - throw new StateException(sprintf('Attribute %s doesn\'t work with options', $attributeCode)); + throw new StateException(__('Attribute %1 doesn\'t work with options', $attributeCode)); } $key = 'new_option'; @@ -67,7 +67,7 @@ class OptionManagement implements \Magento\Eav\Api\AttributeOptionManagementInte try { $this->resourceModel->save($attribute); } catch (\Exception $e) { - throw new StateException(sprintf('Cannot save attribute %s', $attributeCode)); + throw new StateException(__('Cannot save attribute %1', $attributeCode)); } return true; @@ -79,17 +79,17 @@ class OptionManagement implements \Magento\Eav\Api\AttributeOptionManagementInte public function delete($entityType, $attributeCode, $optionId) { if (empty($attributeCode)) { - throw new InputException('Empty attribute code'); + throw new InputException(__('Empty attribute code')); } $attribute = $this->attributeRepository->get($entityType, $attributeCode); if (!$attribute->usesSource()) { - throw new StateException(sprintf('Attribute %s doesn\'t have any option', $attributeCode)); + throw new StateException(__('Attribute %1 doesn\'t have any option', $attributeCode)); } if (!$attribute->getSource()->getOptionText($optionId)) { throw new NoSuchEntityException( - sprintf('Attribute %s does not contain option with Id %s', $attribute->getId(), $optionId) + __('Attribute %1 does not contain option with Id %2', $attribute->getId(), $optionId) ); } @@ -103,7 +103,7 @@ class OptionManagement implements \Magento\Eav\Api\AttributeOptionManagementInte try { $this->resourceModel->save($attribute); } catch (\Exception $e) { - throw new StateException(sprintf('Cannot save attribute %s', $attributeCode)); + throw new StateException(__('Cannot save attribute %1', $attributeCode)); } return true; @@ -115,14 +115,14 @@ class OptionManagement implements \Magento\Eav\Api\AttributeOptionManagementInte public function getItems($entityType, $attributeCode) { if (empty($attributeCode)) { - throw new InputException('Empty attribute code'); + throw new InputException(__('Empty attribute code')); } $attribute = $this->attributeRepository->get($entityType, $attributeCode); try { $options = $attribute->getOptions(); } catch (\Exception $e) { - throw new StateException(sprintf('Cannot load options for attribute %s', $attributeCode)); + throw new StateException(__('Cannot load options for attribute %1', $attributeCode)); } return $options; diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/Set.php b/app/code/Magento/Eav/Model/Entity/Attribute/Set.php index 75122ca097d4d06a0b459d2d688632dcf925dd8d..c8eb151622d4d235b8460fc548ac202d504b0e4a 100644 --- a/app/code/Magento/Eav/Model/Entity/Attribute/Set.php +++ b/app/code/Magento/Eav/Model/Entity/Attribute/Set.php @@ -19,8 +19,8 @@ */ namespace Magento\Eav\Model\Entity\Attribute; -use Magento\Eav\Model\Entity\Type; use Magento\Eav\Exception as EavException; +use Magento\Eav\Model\Entity\Type; use Magento\Framework\Api\AttributeValueFactory; /** @@ -47,6 +47,7 @@ class Set extends \Magento\Framework\Model\AbstractExtensibleModel implements /** * Prefix of model events names + * * @var string */ protected $_eventPrefix = 'eav_entity_attribute_set'; @@ -74,7 +75,7 @@ class Set extends \Magento\Framework\Model\AbstractExtensibleModel implements /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry - * @param \Magento\Framework\Api\MetadataServiceInterface $metadataService + * @param \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory * @param AttributeValueFactory $customAttributeFactory * @param \Magento\Eav\Model\Config $eavConfig * @param GroupFactory $attrGroupFactory @@ -88,7 +89,7 @@ class Set extends \Magento\Framework\Model\AbstractExtensibleModel implements public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, - \Magento\Framework\Api\MetadataServiceInterface $metadataService, + \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory, AttributeValueFactory $customAttributeFactory, \Magento\Eav\Model\Config $eavConfig, \Magento\Eav\Model\Entity\Attribute\GroupFactory $attrGroupFactory, @@ -101,7 +102,7 @@ class Set extends \Magento\Framework\Model\AbstractExtensibleModel implements parent::__construct( $context, $registry, - $metadataService, + $extensionFactory, $customAttributeFactory, $resource, $resourceCollection, @@ -439,5 +440,26 @@ class Set extends \Magento\Framework\Model\AbstractExtensibleModel implements { return $this->setData(self::KEY_ENTITY_TYPE_ID, $entityTypeId); } + + /** + * {@inheritdoc} + * + * @return \Magento\Eav\Api\Data\AttributeSetExtensionInterface|null|null + */ + public function getExtensionAttributes() + { + return $this->_getExtensionAttributes(); + } + + /** + * {@inheritdoc} + * + * @param \Magento\Eav\Api\Data\AttributeSetExtensionInterface|null $extensionAttributes + * @return $this + */ + public function setExtensionAttributes(\Magento\Eav\Api\Data\AttributeSetExtensionInterface $extensionAttributes) + { + return $this->_setExtensionAttributes($extensionAttributes); + } //@codeCoverageIgnoreEnd } diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/ValidationRule.php b/app/code/Magento/Eav/Model/Entity/Attribute/ValidationRule.php index c3d4743674af8fa0a459ef9dd42ee344973d31f7..ee9367705335ae4fe6f4212bb23beabee05760e4 100644 --- a/app/code/Magento/Eav/Model/Entity/Attribute/ValidationRule.php +++ b/app/code/Magento/Eav/Model/Entity/Attribute/ValidationRule.php @@ -9,7 +9,7 @@ namespace Magento\Eav\Model\Entity\Attribute; /** * @codeCoverageIgnore */ -class ValidationRule extends \Magento\Framework\Model\AbstractExtensibleModel implements +class ValidationRule extends \Magento\Framework\Model\AbstractModel implements \Magento\Eav\Api\Data\AttributeValidationRuleInterface { /** diff --git a/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Set.php b/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Set.php index 0c083a7d88c9ca12325e9bca91d3ab870debac6f..a8be4ca3978edb155c11000b5fea88bee281f744 100644 --- a/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Set.php +++ b/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Set.php @@ -104,7 +104,9 @@ class Set extends \Magento\Framework\Model\Resource\Db\AbstractDb ->getEntityType($object->getEntityTypeId()) ->getDefaultAttributeSetId(); if ($object->getAttributeSetId() == $defaultAttributeSetId) { - throw new \Magento\Framework\Exception\StateException('Default attribute set can not be deleted'); + throw new \Magento\Framework\Exception\StateException( + __('Default attribute set can not be deleted') + ); } return parent::_beforeDelete($object); } diff --git a/app/code/Magento/Eav/Test/Unit/Model/Attribute/GroupRepositoryTest.php b/app/code/Magento/Eav/Test/Unit/Model/Attribute/GroupRepositoryTest.php index 377aa2277184687d8ad6f6c20ef2d9166c0466c2..41dc92df72f0fdcc2c8b21dd868934e55d3427c5 100644 --- a/app/code/Magento/Eav/Test/Unit/Model/Attribute/GroupRepositoryTest.php +++ b/app/code/Magento/Eav/Test/Unit/Model/Attribute/GroupRepositoryTest.php @@ -37,6 +37,11 @@ class GroupRepositoryTest extends \PHPUnit_Framework_TestCase */ protected $groupListFactoryMock; + /** + * SetUp method + * + * @return void + */ protected function setUp() { $this->groupResourceMock = $this->getMock( @@ -82,6 +87,13 @@ class GroupRepositoryTest extends \PHPUnit_Framework_TestCase ); } + /** + * Test saving if object is new + * + * @throws \Magento\Framework\Exception\NoSuchEntityException + * @throws \Magento\Framework\Exception\StateException + * @return void + */ public function testSaveIfObjectNew() { $attributeSetId = 42; @@ -100,6 +112,13 @@ class GroupRepositoryTest extends \PHPUnit_Framework_TestCase $this->assertEquals($groupMock, $this->model->save($groupMock)); } + /** + * Test saving if object is not new + * + * @throws \Magento\Framework\Exception\NoSuchEntityException + * @throws \Magento\Framework\Exception\StateException + * @return void + */ public function testSaveIfObjectNotNew() { $attributeSetId = 42; @@ -127,8 +146,13 @@ class GroupRepositoryTest extends \PHPUnit_Framework_TestCase } /** + * Test saving throws exception if attribute set does not exist + * * @expectedException \Magento\Framework\Exception\NoSuchEntityException * @expectedExceptionMessage No such entity with attributeSetId = -1 + * @throws \Magento\Framework\Exception\NoSuchEntityException + * @throws \Magento\Framework\Exception\StateException + * @return void */ public function testSaveThrowExceptionIfAttributeSetDoesNotExist() { @@ -140,15 +164,20 @@ class GroupRepositoryTest extends \PHPUnit_Framework_TestCase ->with($attributeSetId) ->will( $this->throwException( - new \Magento\Framework\Exception\NoSuchEntityException('AttributeSet does not exist.') + new \Magento\Framework\Exception\NoSuchEntityException(__('AttributeSet does not exist.')) ) ); $this->model->save($groupMock); } /** + * Test saving throws exception if cannot save group + * * @expectedException \Magento\Framework\Exception\StateException * @expectedExceptionMessage Cannot save attributeGroup + * @throws \Magento\Framework\Exception\NoSuchEntityException + * @throws \Magento\Framework\Exception\StateException + * @return void */ public function testSaveThrowExceptionIfCannotSaveGroup() { @@ -170,8 +199,13 @@ class GroupRepositoryTest extends \PHPUnit_Framework_TestCase } /** + * Test saving throws exception if group does not belong to provided set + * * @expectedException \Magento\Framework\Exception\StateException * @expectedExceptionMessage Attribute group does not belong to provided attribute set + * @throws \Magento\Framework\Exception\NoSuchEntityException + * @throws \Magento\Framework\Exception\StateException + * @return void */ public function testSaveThrowExceptionIfGroupDoesNotBelongToProvidedSet() { @@ -192,8 +226,13 @@ class GroupRepositoryTest extends \PHPUnit_Framework_TestCase } /** + * Test saving throws exception if provided group does not exist + * * @expectedException \Magento\Framework\Exception\NoSuchEntityException * @expectedExceptionMessage No such entity with attributeGroupId = + * @throws \Magento\Framework\Exception\NoSuchEntityException + * @throws \Magento\Framework\Exception\StateException + * @return void */ public function testSaveThrowExceptionIfProvidedGroupDoesNotExist() { @@ -213,6 +252,13 @@ class GroupRepositoryTest extends \PHPUnit_Framework_TestCase $this->model->save($groupMock); } + /** + * Test get list + * + * @throws \Magento\Framework\Exception\InputException + * @throws \Magento\Framework\Exception\NoSuchEntityException + * @return void + */ public function testGetList() { $attributeSetId = 'filter'; @@ -261,8 +307,13 @@ class GroupRepositoryTest extends \PHPUnit_Framework_TestCase } /** + * Test get list with invalid input exception + * * @expectedException \Magento\Framework\Exception\InputException * @expectedExceptionMessage attribute_set_id is a required field. + * @throws \Magento\Framework\Exception\InputException + * @throws \Magento\Framework\Exception\NoSuchEntityException + * @return void */ public function testGetListWithInvalidInputException() { @@ -272,8 +323,13 @@ class GroupRepositoryTest extends \PHPUnit_Framework_TestCase } /** + * Test get list with no such entity exception + * * @expectedException \Magento\Framework\Exception\NoSuchEntityException * @expectedExceptionMessage No such entity with attributeSetId = filter + * @throws \Magento\Framework\Exception\InputException + * @throws \Magento\Framework\Exception\NoSuchEntityException + * @return void */ public function testGetListWithNoSuchEntityException() { @@ -296,6 +352,12 @@ class GroupRepositoryTest extends \PHPUnit_Framework_TestCase $this->model->getList($searchCriteriaMock); } + /** + * Test get + * + * @throws \Magento\Framework\Exception\NoSuchEntityException + * @return void + */ public function testGet() { $groupId = 42; @@ -307,8 +369,12 @@ class GroupRepositoryTest extends \PHPUnit_Framework_TestCase } /** + * Test get throws exception if provided group does not exist + * * @expectedException \Magento\Framework\Exception\NoSuchEntityException * @expectedExceptionMessage Group with id "42" does not exist. + * @throws \Magento\Framework\Exception\NoSuchEntityException + * @return void */ public function testGetThrowExceptionIfProvidedGroupDoesNotExist() { @@ -320,6 +386,12 @@ class GroupRepositoryTest extends \PHPUnit_Framework_TestCase $this->assertEquals($groupMock, $this->model->get($groupId)); } + /** + * Test delete + * + * @throws \Magento\Framework\Exception\StateException + * @return void + */ public function testDelete() { $groupMock = $this->getMock('\Magento\Eav\Model\Entity\Attribute\Group', [], [], '', false); @@ -328,8 +400,12 @@ class GroupRepositoryTest extends \PHPUnit_Framework_TestCase } /** + * Test deletion throws exception if provided group does not exist + * * @expectedException \Magento\Framework\Exception\StateException * @expectedExceptionMessage Cannot delete attributeGroup with id + * @throws \Magento\Framework\Exception\StateException + * @return void */ public function testDeleteThrowExceptionIfProvidedGroupDoesNotExist() { @@ -342,6 +418,11 @@ class GroupRepositoryTest extends \PHPUnit_Framework_TestCase $this->model->delete($groupMock); } + /** + * Test delete by id + * + * @return void + */ public function testDeleteById() { $groupId = 42; diff --git a/app/code/Magento/Eav/Test/Unit/Model/AttributeManagementTest.php b/app/code/Magento/Eav/Test/Unit/Model/AttributeManagementTest.php index 7f78d74400132cffe78494e01573be27706a5dd2..8d2dd6fcbcbea2ec94b68cf3a141e20fea1c13d3 100644 --- a/app/code/Magento/Eav/Test/Unit/Model/AttributeManagementTest.php +++ b/app/code/Magento/Eav/Test/Unit/Model/AttributeManagementTest.php @@ -312,7 +312,7 @@ class AttributeManagementTest extends \PHPUnit_Framework_TestCase $this->setRepositoryMock->expects($this->once()) ->method('get') ->with($attributeSetId) - ->willThrowException(new NoSuchEntityException('hello')); + ->willThrowException(new NoSuchEntityException(__('hello'))); $this->model->unassign($attributeSetId, $attributeCode); } diff --git a/app/code/Magento/Eav/Test/Unit/Model/AttributeSetRepositoryTest.php b/app/code/Magento/Eav/Test/Unit/Model/AttributeSetRepositoryTest.php index 2b710da0cfab25d5cda2f9c97db05aeff4b91124..5975bf3b5f422e39a24faf4c58e8c4d3354bc50b 100644 --- a/app/code/Magento/Eav/Test/Unit/Model/AttributeSetRepositoryTest.php +++ b/app/code/Magento/Eav/Test/Unit/Model/AttributeSetRepositoryTest.php @@ -42,6 +42,9 @@ class AttributeSetRepositoryTest extends \PHPUnit_Framework_TestCase */ private $resultFactoryMock; + /** + * @return void + */ protected function setUp() { $this->resourceMock = $this->getMock( @@ -82,6 +85,9 @@ class AttributeSetRepositoryTest extends \PHPUnit_Framework_TestCase ); } + /** + * @return void + */ public function testGet() { $attributeSetId = 1; @@ -93,6 +99,7 @@ class AttributeSetRepositoryTest extends \PHPUnit_Framework_TestCase } /** + * @return void * @expectedException \Magento\Framework\Exception\NoSuchEntityException * @expectedExceptionMessage No such entity with id = 9999 */ @@ -105,6 +112,9 @@ class AttributeSetRepositoryTest extends \PHPUnit_Framework_TestCase $this->model->get($attributeSetId); } + /** + * @return void + */ public function testSave() { $attributeSetMock = $this->getMock('Magento\Eav\Model\Entity\Attribute\Set', [], [], '', false); @@ -113,6 +123,7 @@ class AttributeSetRepositoryTest extends \PHPUnit_Framework_TestCase } /** + * @return void * @expectedException \Magento\Framework\Exception\CouldNotSaveException * @expectedExceptionMessage There was an error saving attribute set. */ @@ -125,6 +136,9 @@ class AttributeSetRepositoryTest extends \PHPUnit_Framework_TestCase $this->model->save($attributeSetMock); } + /** + * @return void + */ public function testDelete() { $attributeSetMock = $this->getMock('Magento\Eav\Model\Entity\Attribute\Set', [], [], '', false); @@ -133,6 +147,7 @@ class AttributeSetRepositoryTest extends \PHPUnit_Framework_TestCase } /** + * @return void * @expectedException \Magento\Framework\Exception\CouldNotDeleteException * @expectedExceptionMessage There was an error deleting attribute set. */ @@ -140,12 +155,13 @@ class AttributeSetRepositoryTest extends \PHPUnit_Framework_TestCase { $attributeSetMock = $this->getMock('Magento\Eav\Model\Entity\Attribute\Set', [], [], '', false); $this->resourceMock->expects($this->once())->method('delete')->with($attributeSetMock)->willThrowException( - new \Magento\Framework\Exception\CouldNotDeleteException('Some internal exception message.') + new \Magento\Framework\Exception\CouldNotDeleteException(__('Some internal exception message.')) ); $this->model->delete($attributeSetMock); } /** + * @return void * @expectedException \Magento\Framework\Exception\CouldNotDeleteException * @expectedExceptionMessage Default attribute set can not be deleted */ @@ -153,11 +169,14 @@ class AttributeSetRepositoryTest extends \PHPUnit_Framework_TestCase { $attributeSetMock = $this->getMock('Magento\Eav\Model\Entity\Attribute\Set', [], [], '', false); $this->resourceMock->expects($this->once())->method('delete')->with($attributeSetMock)->willThrowException( - new \Magento\Framework\Exception\StateException('Some internal exception message.') + new \Magento\Framework\Exception\StateException(__('Some internal exception message.')) ); $this->model->delete($attributeSetMock); } + /** + * @return void + */ public function testDeleteById() { $attributeSetId = 1; @@ -169,6 +188,9 @@ class AttributeSetRepositoryTest extends \PHPUnit_Framework_TestCase $this->assertTrue($this->model->deleteById($attributeSetId)); } + /** + * @return void + */ public function testGetList() { $entityTypeCode = 'entity_type_code_value'; diff --git a/app/code/Magento/Eav/Test/Unit/Model/EavCustomAttributeTypeLocatorTest.php b/app/code/Magento/Eav/Test/Unit/Model/EavCustomAttributeTypeLocatorTest.php new file mode 100644 index 0000000000000000000000000000000000000000..89690484c74835f76a52415371a65c2f3ce6c531 --- /dev/null +++ b/app/code/Magento/Eav/Test/Unit/Model/EavCustomAttributeTypeLocatorTest.php @@ -0,0 +1,150 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +// @codingStandardsIgnoreFile + +namespace Magento\Eav\Test\Unit\Model; + +use Magento\Eav\Api\AttributeRepositoryInterface; +use Magento\Eav\Model\EavCustomAttributeTypeLocator; + +class EavCustomAttributeTypeLocatorTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var EavCustomAttributeTypeLocator + */ + private $eavCustomAttributeTypeLocator; + + /** + * @var AttributeRepositoryInterface|\PHPUnit_Framework_MockObject_MockObject + */ + private $attributeRepository = []; + + protected function setUp() + { + $this->attributeRepository = $this->getMock( + 'Magento\Eav\Model\AttributeRepository', + ['get'], + [], + '', + false + ); + } + + /** + * Test getType method + * + * @param string $attributeCode + * @param string $serviceClass + * @param array $attributeRepositoryResponse + * @param array $serviceEntityTypeMapData + * @param array $serviceBackendModelDataInterfaceMapData + * @param string $expected + * @dataProvider getTypeDataProvider + */ + public function testGetType( + $attributeCode, + $serviceClass, + $attributeRepositoryResponse, + $serviceEntityTypeMapData, + $serviceBackendModelDataInterfaceMapData, + $expected + ) { + $this->attributeRepository + ->expects($this->any()) + ->method('get') + ->willReturn($attributeRepositoryResponse); + + + $this->eavCustomAttributeTypeLocator = new EavCustomAttributeTypeLocator( + $this->attributeRepository, + $serviceEntityTypeMapData, + $serviceBackendModelDataInterfaceMapData + ); + + $type = $this->eavCustomAttributeTypeLocator->getType($attributeCode, $serviceClass); + + $this->assertEquals($expected, $type, 'Expected: ' . $expected . 'but got: ' . $type); + } + + public function getTypeDataProvider() + { + $serviceInterface = 'Magento\Catalog\Api\Data\ProductInterface'; + $eavEntityType = 'catalog_product'; + $mediaBackEndModelClass = 'Magento\Catalog\Model\Product\Attribute\Backend\Media'; + $mediaAttributeDataInterface = '\Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface'; + $serviceBackendModelDataInterfaceMapData = [ + $serviceInterface => [$mediaBackEndModelClass => $mediaAttributeDataInterface] + ]; + + $attribute = $this->getMock( + 'Magento\Catalog\Model\Resource\Eav\Attribute', + ['getBackendModel'], + [], + '', + false + ); + + $attribute->expects($this->any()) + ->method('getBackendModel') + ->willReturn($mediaBackEndModelClass); + + $attributeNoBackendModel = $this->getMock( + 'Magento\Catalog\Model\Resource\Eav\Attribute', + ['getBackendModel'], + [], + '', + false + ); + + $attributeNoBackendModel->expects($this->any()) + ->method('getBackendModel') + ->willReturn(null); + + return [ + [ + 'attributeCode' => 'media_galley', + 'serviceClass' => $serviceInterface, + 'attributeRepositoryResponse' => $attribute, + 'serviceEntityTypeMapData' => [$serviceInterface => $eavEntityType], + 'serviceBackendModelDataInterfaceMapData' => $serviceBackendModelDataInterfaceMapData, + 'expected' => $mediaAttributeDataInterface + ], + [ + 'attributeCode' => null, + 'serviceClass' => $serviceInterface, + 'attributeRepositoryResponse' => $attribute, + 'serviceEntityTypeMapData' => [$serviceInterface => $eavEntityType], + 'serviceBackendModelDataInterfaceMapData' => $serviceBackendModelDataInterfaceMapData, + 'expected' => null + ], + [ + 'attributeCode' => 'media_galley', + 'serviceClass' => null, + 'attributeRepositoryResponse' => $attribute, + 'serviceEntityTypeMapData' => [$serviceInterface => $eavEntityType], + 'serviceBackendModelDataInterfaceMapData' => $serviceBackendModelDataInterfaceMapData, + 'expected' => null + ], + [ + 'attributeCode' => 'media_galley', + 'serviceClass' => $serviceInterface, + 'attributeRepositoryResponse' => $attributeNoBackendModel, + 'serviceEntityTypeMapData' => [], + 'serviceBackendModelDataInterfaceMapData' => [], + 'expected' => null + ], + [ + 'attributeCode' => 'media_galley', + 'serviceClass' => 'Magento\Catalog\Api\Data\ProductInterface', + 'attributeRepositoryResponse' => $attribute, + 'serviceEntityTypeMapData' => [$serviceInterface => $eavEntityType], + 'serviceBackendModelDataInterfaceMapData' => [], + 'expected' => null + ] + ]; + } +} diff --git a/app/code/Magento/Eav/etc/config.xml b/app/code/Magento/Eav/etc/config.xml index f5d8d72d90d6b0706f3a102fcf33b1b263342e81..d6b5873aaf92e121cf985d6d1ad03f42c16e55ff 100644 --- a/app/code/Magento/Eav/etc/config.xml +++ b/app/code/Magento/Eav/etc/config.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Core/etc/config.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Store/etc/config.xsd"> <default> <general> <validator_data> diff --git a/app/code/Magento/Eav/etc/di.xml b/app/code/Magento/Eav/etc/di.xml index 42c3fc13ef7d9524b43f34797a689b27d9f227ce..3dfebf456c7ff4ae26f6f8a118431872c7c2f67e 100644 --- a/app/code/Magento/Eav/etc/di.xml +++ b/app/code/Magento/Eav/etc/di.xml @@ -23,6 +23,8 @@ <preference for="Magento\Eav\Api\Data\AttributeSearchResultsInterface" type="Magento\Framework\Api\SearchResults" /> <preference for="Magento\Eav\Api\Data\AttributeSetSearchResultsInterface" type="Magento\Framework\Api\SearchResults" /> <preference for="Magento\Eav\Api\Data\AttributeGroupSearchResultsInterface" type="Magento\Framework\Api\SearchResults" /> + <preference for="Magento\Framework\Webapi\CustomAttributeTypeLocatorInterface" type="Magento\Eav\Model\EavCustomAttributeTypeLocator" /> + <type name="Magento\Eav\Model\Entity\Attribute\Config"> <arguments> <argument name="reader" xsi:type="object">Magento\Eav\Model\Entity\Attribute\Config\Reader\Proxy</argument> @@ -43,4 +45,16 @@ <type name="Magento\Eav\Model\Resource\Entity\Attribute"> <plugin name="storeLabelCaching" type="Magento\Eav\Plugin\Model\Resource\Entity\Attribute" /> </type> + <type name="Magento\Eav\Model\EavCustomAttributeTypeLocator"> + <arguments> + <argument name="serviceEntityTypeMap" xsi:type="array"> + <item name="Magento\Catalog\Api\Data\ProductInterface" xsi:type="const">Magento\Catalog\Api\Data\ProductAttributeInterface::ENTITY_TYPE_CODE</item> + </argument> + <argument name="serviceBackendModelDataInterfaceMap" xsi:type="array"> + <item name="Magento\Catalog\Api\Data\ProductInterface" xsi:type="array"> + <item name="Magento\Catalog\Model\Product\Attribute\Backend\Media" xsi:type="string">Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface</item> + </item> + </argument> + </arguments> + </type> </config> diff --git a/app/code/Magento/Eav/etc/module.xml b/app/code/Magento/Eav/etc/module.xml index 156e78c1bdd64de754d9f2ee5274ef9dc65788d7..c4b4e458bd89df75bbe667371a54c90867752df2 100644 --- a/app/code/Magento/Eav/etc/module.xml +++ b/app/code/Magento/Eav/etc/module.xml @@ -8,7 +8,6 @@ <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd"> <module name="Magento_Eav" setup_version="2.0.0"> <sequence> - <module name="Magento_Core"/> <module name="Magento_Store"/> </sequence> </module> diff --git a/app/code/Magento/Eav/etc/webapi.xml b/app/code/Magento/Eav/etc/webapi.xml index ca246c7cf3a97038d6b11bac5e949149bdfdcdc7..bb5bd767dc8fad16cc1ec95fc814174777cdae55 100644 --- a/app/code/Magento/Eav/etc/webapi.xml +++ b/app/code/Magento/Eav/etc/webapi.xml @@ -31,7 +31,7 @@ <resource ref="Magento_Catalog::sets"/> </resources> </route> - <route url="/V1/eav/attribute-sets" method="PUT"> + <route url="/V1/eav/attribute-sets/:attributeSetId" method="PUT"> <service class="Magento\Eav\Api\AttributeSetRepositoryInterface" method="save"/> <resources> <resource ref="Magento_Catalog::sets"/> diff --git a/app/code/Magento/Email/Test/Unit/Model/AbstractTemplateTest.php b/app/code/Magento/Email/Test/Unit/Model/AbstractTemplateTest.php index e9ea334e776dab2079d0167ca86a9e67c5380ebf..bfdd32f7e55421599563f7da80f170a757111b31 100644 --- a/app/code/Magento/Email/Test/Unit/Model/AbstractTemplateTest.php +++ b/app/code/Magento/Email/Test/Unit/Model/AbstractTemplateTest.php @@ -4,6 +4,8 @@ * See COPYING.txt for license details. */ +// @codingStandardsIgnoreFile + /** * Test class for \Magento\Email\Model\AbstractTemplate. */ @@ -56,4 +58,46 @@ class AbstractTemplateTest extends \PHPUnit_Framework_TestCase { return [[[]], [['area' => 'some_area']], [['store' => 'any_store']]]; } + + public function testEmulateDesignAndRevertDesign() + { + $originalConfig = ['area' => 'some_area', 'store' => 1]; + $expectedConfig = ['area' => 'frontend', 'store' => 2]; + $this->_model->setDesignConfig($originalConfig); + + $this->_model->emulateDesign(2); + // assert config data has been emulated + $this->assertEquals($expectedConfig, $this->_model->getDesignConfig()->getData()); + + $this->_model->revertDesign(); + // assert config data has been reverted to the original state + $this->assertEquals($originalConfig, $this->_model->getDesignConfig()->getData()); + } + + public function testGetDesignConfig() + { + $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); + + $designMock = $this->getMock('Magento\Framework\View\DesignInterface'); + $designMock->expects($this->any())->method('getArea')->willReturn('test_area'); + + $storeMock = $this->getMock('Magento\Store\Model\Store', [], [], '', false); + $storeMock->expects($this->any())->method('getId')->willReturn(2); + $storeManagerMock = $this->getMock('Magento\Store\Model\StoreManagerInterface'); + $storeManagerMock->expects($this->any())->method('getStore')->willReturn($storeMock); + + $model = $this->getMockForAbstractClass( + 'Magento\Email\Model\AbstractTemplate', + $helper->getConstructArguments( + 'Magento\Email\Model\AbstractTemplate', + [ + 'design' => $designMock, + 'storeManager' => $storeManagerMock + ] + ) + ); + + $expectedConfig = ['area' => 'test_area', 'store' => 2]; + $this->assertEquals($expectedConfig, $model->getDesignConfig()->getData()); + } } diff --git a/app/code/Magento/Email/Test/Unit/Model/BackendTemplateTest.php b/app/code/Magento/Email/Test/Unit/Model/BackendTemplateTest.php new file mode 100644 index 0000000000000000000000000000000000000000..6a51e983e3b53191e4265d5f9f7d857825c86d1f --- /dev/null +++ b/app/code/Magento/Email/Test/Unit/Model/BackendTemplateTest.php @@ -0,0 +1,86 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +// @codingStandardsIgnoreFile + +/** + * Test class for Magento\Email\Model\BackendTemplate. + */ +namespace Magento\Email\Test\Unit\Model; + +use Magento\Email\Model\BackendTemplate; + +class BackendTemplateTest extends \PHPUnit_Framework_TestCase +{ + /** + * Backend template mock + * + * @var BackendTemplate + */ + protected $model; + + /** + * @var \Magento\Framework\App\Config\ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $scopeConfigMock; + + /** + * @var \Magento\Config\Model\Config\Structure|\PHPUnit_Framework_MockObject_MockObject + */ + protected $structureMock; + + /** + * @var \Magento\Email\Model\Resource\Template|\PHPUnit_Framework_MockObject_MockObject + */ + protected $resourceModelMock; + + protected function setUp() + { + $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); + + $this->scopeConfigMock = $this->getMock('Magento\Framework\App\Config\ScopeConfigInterface'); + $this->scopeConfigMock->expects($this->any())->method('getValue')->willReturn(['test' => 1]); + + $this->structureMock = $this->getMock('Magento\Config\Model\Config\Structure', [], [], '', false); + $this->structureMock->expects($this->any())->method('getFieldPathsByAttribute')->willReturn(['path' => 'test']); + + $this->resourceModelMock = $this->getMock('Magento\Email\Model\Resource\Template', [], [], '', false); + $this->resourceModelMock->expects($this->any())->method('getSystemConfigByPathsAndTemplateId')->willReturn(['test_config' => 2015]); + $objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface'); + $objectManagerMock->expects($this->any()) + ->method('get') + ->with('Magento\Email\Model\Resource\Template') + ->will($this->returnValue($this->resourceModelMock)); + \Magento\Framework\App\ObjectManager::setInstance($objectManagerMock); + + $this->model = $helper->getObject( + 'Magento\Email\Model\BackendTemplate', + ['scopeConfig' => $this->scopeConfigMock, 'structure' => $this->structureMock] + ); + } + + public function testGetSystemConfigPathsWhereUsedAsDefaultNoTemplateCode() + { + $this->assertEquals([], $this->model->getSystemConfigPathsWhereUsedAsDefault()); + } + + public function testGetSystemConfigPathsWhereUsedAsDefaultValidTemplateCode() + { + $this->model->setData('orig_template_code', 1); + $this->assertEquals([['path' => 'test']], $this->model->getSystemConfigPathsWhereUsedAsDefault()); + } + + public function testGetSystemConfigPathsWhereUsedCurrentlyNoId() + { + $this->assertEquals([], $this->model->getSystemConfigPathsWhereUsedCurrently()); + } + + public function testGetSystemConfigPathsWhereUsedCurrentlyValidId() + { + $this->model->setId(1); + $this->assertEquals(['test_config' => 2015], $this->model->getSystemConfigPathsWhereUsedCurrently()); + } +} diff --git a/app/code/Magento/Email/composer.json b/app/code/Magento/Email/composer.json index 7eae5d149b013397761753c02789deb21b2abc46..cf75e8fdd529bb89688f2cc12bdd4d92efc527f0 100644 --- a/app/code/Magento/Email/composer.json +++ b/app/code/Magento/Email/composer.json @@ -3,7 +3,6 @@ "description": "N/A", "require": { "php": "~5.5.0|~5.6.0", - "magento/module-core": "0.42.0-beta11", "magento/module-config": "0.42.0-beta11", "magento/module-store": "0.42.0-beta11", "magento/module-cms": "0.42.0-beta11", diff --git a/app/code/Magento/Email/etc/config.xml b/app/code/Magento/Email/etc/config.xml index e966e4c1ed4c14dbcdfb5f0d4275f01a170d238a..700f625c9541c224cdbbf74dfdbcec7bf7390370 100644 --- a/app/code/Magento/Email/etc/config.xml +++ b/app/code/Magento/Email/etc/config.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Core/etc/config.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Store/etc/config.xsd"> <default> <system> <media_storage_configuration> diff --git a/app/code/Magento/Email/etc/module.xml b/app/code/Magento/Email/etc/module.xml index 30252dd178b9eaefd8b68eca5814954dd5935310..3e5126d0e7e3a7c4997164f737f0fd6428bc9ead 100644 --- a/app/code/Magento/Email/etc/module.xml +++ b/app/code/Magento/Email/etc/module.xml @@ -8,7 +8,6 @@ <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd"> <module name="Magento_Email" setup_version="2.0.0"> <sequence> - <module name="Magento_Core"/> <module name="Magento_Store"/> <module name="Magento_Cms"/> </sequence> diff --git a/app/code/Magento/Fedex/composer.json b/app/code/Magento/Fedex/composer.json index 9959c31c0264e069e40a70b15d0c145f6222819e..8997dc97ac88704304a484e44b7062d5a0399953 100644 --- a/app/code/Magento/Fedex/composer.json +++ b/app/code/Magento/Fedex/composer.json @@ -6,11 +6,11 @@ "magento/module-store": "0.42.0-beta11", "magento/module-shipping": "0.42.0-beta11", "magento/module-directory": "0.42.0-beta11", - "magento/module-core": "0.42.0-beta11", "magento/module-catalog": "0.42.0-beta11", "magento/module-sales": "0.42.0-beta11", "magento/module-catalog-inventory": "0.42.0-beta11", "magento/module-quote": "0.42.0-beta11", + "magento/module-config": "0.42.0-beta11", "magento/framework": "0.42.0-beta11", "lib-libxml": "*", "magento/magento-composer-installer": "*" diff --git a/app/code/Magento/Fedex/etc/config.xml b/app/code/Magento/Fedex/etc/config.xml index d20fd9f2d1b1f66350a8bf1b1bb98cac7abc6c59..9d99b8997487bad3eae596d0b7b026be93f524d3 100644 --- a/app/code/Magento/Fedex/etc/config.xml +++ b/app/code/Magento/Fedex/etc/config.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Core/etc/config.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Store/etc/config.xsd"> <default> <carriers> <fedex> diff --git a/app/code/Magento/GiftMessage/Api/Data/MessageInterface.php b/app/code/Magento/GiftMessage/Api/Data/MessageInterface.php index c360ca4e8f1f2539e7be29789da17de5108ceb1c..a044e7c0ab0c72253dc3b375c1ed2677fb47c389 100644 --- a/app/code/Magento/GiftMessage/Api/Data/MessageInterface.php +++ b/app/code/Magento/GiftMessage/Api/Data/MessageInterface.php @@ -91,4 +91,21 @@ interface MessageInterface extends \Magento\Framework\Api\ExtensibleDataInterfac * @return $this */ public function setMessage($message); + + /** + * Retrieve existing extension attributes object or create a new one. + * + * @return \Magento\GiftMessage\Api\Data\MessageExtensionInterface|null + */ + public function getExtensionAttributes(); + + /** + * Set an extension attributes object. + * + * @param \Magento\GiftMessage\Api\Data\MessageExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes( + \Magento\GiftMessage\Api\Data\MessageExtensionInterface $extensionAttributes + ); } diff --git a/app/code/Magento/GiftMessage/Model/CartRepository.php b/app/code/Magento/GiftMessage/Model/CartRepository.php index 528ccf78320b624bdbdcf75bbf5aac889108dbc9..bb1b66db7d20d0f5b42e2321eaf354030e4661f9 100644 --- a/app/code/Magento/GiftMessage/Model/CartRepository.php +++ b/app/code/Magento/GiftMessage/Model/CartRepository.php @@ -101,14 +101,14 @@ class CartRepository implements \Magento\GiftMessage\Api\CartRepositoryInterface $quote = $this->quoteRepository->getActive($cartId); if (0 == $quote->getItemsCount()) { - throw new InputException('Gift Messages is not applicable for empty cart'); + throw new InputException(__('Gift Messages is not applicable for empty cart')); } if ($quote->isVirtual()) { - throw new InvalidTransitionException('Gift Messages is not applicable for virtual products'); + throw new InvalidTransitionException(__('Gift Messages is not applicable for virtual products')); } if (!$this->helper->getIsMessagesAvailable('quote', $quote, $this->storeManager->getStore())) { - throw new CouldNotSaveException('Gift Message is not available'); + throw new CouldNotSaveException(__('Gift Message is not available')); } $this->giftMessageManager->setMessage($quote, 'quote', $giftMessage); return true; diff --git a/app/code/Magento/GiftMessage/Model/GiftMessageManager.php b/app/code/Magento/GiftMessage/Model/GiftMessageManager.php index 55c2b0020c15cea8c26846897e7357693f03e515..f1d2cfbfb95170505c32cbe150907db060de5e8e 100644 --- a/app/code/Magento/GiftMessage/Model/GiftMessageManager.php +++ b/app/code/Magento/GiftMessage/Model/GiftMessageManager.php @@ -105,12 +105,12 @@ class GiftMessageManager public function setMessage(\Magento\Quote\Model\Quote $quote, $type, $giftMessage, $entityId = null) { if (is_null($quote->getBillingAddress()->getCountryId())) { - throw new InvalidTransitionException('Billing address is not set'); + throw new InvalidTransitionException(__('Billing address is not set')); } // check if shipping address is set if (is_null($quote->getShippingAddress()->getCountryId())) { - throw new InvalidTransitionException('Shipping address is not set'); + throw new InvalidTransitionException(__('Shipping address is not set')); } $message[$type][$entityId] = [ 'from' => $giftMessage->getSender(), @@ -121,7 +121,7 @@ class GiftMessageManager try { $this->add($message, $quote); } catch (\Exception $e) { - throw new CouldNotSaveException('Could not add gift message to shopping cart'); + throw new CouldNotSaveException(__('Could not add gift message to shopping cart')); } } } diff --git a/app/code/Magento/GiftMessage/Model/ItemRepository.php b/app/code/Magento/GiftMessage/Model/ItemRepository.php index 90db371ca8fbdf8ffad383f375a9350e81fdbd01..16d442a769240fef8fb93ced6c29ea8fc479d022 100644 --- a/app/code/Magento/GiftMessage/Model/ItemRepository.php +++ b/app/code/Magento/GiftMessage/Model/ItemRepository.php @@ -85,7 +85,7 @@ class ItemRepository implements \Magento\GiftMessage\Api\ItemRepositoryInterface */ $quote = $this->quoteRepository->getActive($cartId); if (!$item = $quote->getItemById($itemId)) { - throw new NoSuchEntityException('There is no item with provided id in the cart'); + throw new NoSuchEntityException(__('There is no item with provided id in the cart')); }; $messageId = $item->getGiftMessageId(); if (!$messageId) { @@ -113,14 +113,16 @@ class ItemRepository implements \Magento\GiftMessage\Api\ItemRepositoryInterface $quote = $this->quoteRepository->getActive($cartId); if (!$item = $quote->getItemById($itemId)) { - throw new NoSuchEntityException("There is no product with provided itemId: $itemId in the cart"); + throw new NoSuchEntityException( + __('There is no product with provided itemId: %1 in the cart', $itemId) + ); }; if ($item->getIsVirtual()) { - throw new InvalidTransitionException('Gift Messages is not applicable for virtual products'); + throw new InvalidTransitionException(__('Gift Messages is not applicable for virtual products')); } if (!$this->helper->getIsMessagesAvailable('items', $quote, $this->storeManager->getStore())) { - throw new CouldNotSaveException('Gift Message is not available'); + throw new CouldNotSaveException(__('Gift Message is not available')); } $this->giftMessageManager->setMessage($quote, 'quote_item', $giftMessage, $itemId); return true; diff --git a/app/code/Magento/GiftMessage/Model/Message.php b/app/code/Magento/GiftMessage/Model/Message.php index 4dda8d5546d9fd788a4f295555297e8936f4d1e9..be07b6cfb242c50d11fc7a9cf691d91b717150ef 100644 --- a/app/code/Magento/GiftMessage/Model/Message.php +++ b/app/code/Magento/GiftMessage/Model/Message.php @@ -26,7 +26,7 @@ class Message extends \Magento\Framework\Model\AbstractExtensibleModel implement /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry - * @param \Magento\Framework\Api\MetadataServiceInterface $metadataService + * @param \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory * @param AttributeValueFactory $customAttributeFactory * @param Resource\Message $resource * @param \Magento\Framework\Data\Collection\Db $resourceCollection @@ -36,7 +36,7 @@ class Message extends \Magento\Framework\Model\AbstractExtensibleModel implement public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, - \Magento\Framework\Api\MetadataServiceInterface $metadataService, + \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory, AttributeValueFactory $customAttributeFactory, \Magento\GiftMessage\Model\Resource\Message $resource, \Magento\Framework\Data\Collection\Db $resourceCollection, @@ -47,7 +47,7 @@ class Message extends \Magento\Framework\Model\AbstractExtensibleModel implement parent::__construct( $context, $registry, - $metadataService, + $extensionFactory, $customAttributeFactory, $resource, $resourceCollection, @@ -164,5 +164,26 @@ class Message extends \Magento\Framework\Model\AbstractExtensibleModel implement { return $this->setData(self::MESSAGE, $message); } + + /** + * Retrieve existing extension attributes object or create a new one. + * + * @return \Magento\GiftMessage\Api\Data\MessageExtensionInterface|null + */ + public function getExtensionAttributes() + { + return $this->_getExtensionAttributes(); + } + + /** + * Set an extension attributes object. + * + * @param \Magento\GiftMessage\Api\Data\MessageExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes(\Magento\GiftMessage\Api\Data\MessageExtensionInterface $extensionAttributes) + { + return $this->_setExtensionAttributes($extensionAttributes); + } //@codeCoverageIgnoreEnd } diff --git a/app/code/Magento/GiftMessage/composer.json b/app/code/Magento/GiftMessage/composer.json index cdc15af4279b4934754adee08f63e97497cdec0e..575d83a28cc8e0fd75f7b8262697cfe213d19845 100644 --- a/app/code/Magento/GiftMessage/composer.json +++ b/app/code/Magento/GiftMessage/composer.json @@ -15,9 +15,6 @@ "magento/framework": "0.42.0-beta11", "magento/magento-composer-installer": "*" }, - "suggest": { - "magento/module-core": "0.42.0-beta11" - }, "type": "magento2-module", "version": "0.42.0-beta11", "license": [ diff --git a/app/code/Magento/GiftMessage/etc/config.xml b/app/code/Magento/GiftMessage/etc/config.xml index 2bebc1173ef729e22de095815520c3be2d900759..dc21f3cfecaf4055397c3ee28d0e225f3135eb2c 100644 --- a/app/code/Magento/GiftMessage/etc/config.xml +++ b/app/code/Magento/GiftMessage/etc/config.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Core/etc/config.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Store/etc/config.xsd"> <default> <sales> <gift_messages> diff --git a/app/code/Magento/GoogleAdwords/etc/config.xml b/app/code/Magento/GoogleAdwords/etc/config.xml index 1fa6ffc95967943ca3106e10c4e21960e85ac912..71bd7813ad22278703215c1cb7c052cc72d16b5f 100644 --- a/app/code/Magento/GoogleAdwords/etc/config.xml +++ b/app/code/Magento/GoogleAdwords/etc/config.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Core/etc/config.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Store/etc/config.xsd"> <default> <google> <adwords> diff --git a/app/code/Magento/GoogleAnalytics/etc/module.xml b/app/code/Magento/GoogleAnalytics/etc/module.xml index 0012f962d97a81dbd3ff8bbcc3f0f3db09443cd8..bcb1b0ed7573d5f672b2c5bf77f1869b1ff16c1a 100644 --- a/app/code/Magento/GoogleAnalytics/etc/module.xml +++ b/app/code/Magento/GoogleAnalytics/etc/module.xml @@ -8,7 +8,6 @@ <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd"> <module name="Magento_GoogleAnalytics" setup_version="2.0.0"> <sequence> - <module name="Magento_Core"/> <module name="Magento_Store"/> </sequence> </module> diff --git a/app/code/Magento/GoogleOptimizer/etc/config.xml b/app/code/Magento/GoogleOptimizer/etc/config.xml index 5c2c3fde8a40869d6fbb9a203289c06c3eefcb57..fa510197464776407fb36f4f791bc34f827669f1 100644 --- a/app/code/Magento/GoogleOptimizer/etc/config.xml +++ b/app/code/Magento/GoogleOptimizer/etc/config.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Core/etc/config.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Store/etc/config.xsd"> <default> <google> <optimizer> diff --git a/app/code/Magento/GoogleShopping/Model/Attribute/Tax.php b/app/code/Magento/GoogleShopping/Model/Attribute/Tax.php index 3bef3409371aa89dbae008a25c17dd2fe54aae98..2703f0b1087d41cbba7516091f98ccb91ed795f4 100644 --- a/app/code/Magento/GoogleShopping/Model/Attribute/Tax.php +++ b/app/code/Magento/GoogleShopping/Model/Attribute/Tax.php @@ -164,7 +164,7 @@ class Tax extends \Magento\GoogleShopping\Model\Attribute\DefaultAttribute $ratesTotal += count($regions); if ($ratesTotal > self::RATES_MAX) { throw new \Magento\Framework\Exception\LocalizedException( - __("Google shopping only supports %1 tax rates per product", self::RATES_MAX) + __('Google shopping only supports %1 tax rates per product', self::RATES_MAX) ); } foreach ($regions as $region) { diff --git a/app/code/Magento/GoogleShopping/Model/Service.php b/app/code/Magento/GoogleShopping/Model/Service.php index 7481a8007e6db19343202cb558001129d9a07232..63a8ef94917b91e63867f21b7d7e4543c399ac93 100644 --- a/app/code/Magento/GoogleShopping/Model/Service.php +++ b/app/code/Magento/GoogleShopping/Model/Service.php @@ -90,9 +90,8 @@ class Service extends \Magento\Framework\Object $type = $this->getConfig()->getAccountType($storeId); // Create an authenticated HTTP client - $errorMsg = __( - 'Sorry, but we can\'t connect to Google Content. Please check the account settings in your store configuration.' - ); + $errorMsg = 'Sorry, but we can\'t connect to Google Content.' + . 'Please check the account settings in your store configuration.'; try { if (!$this->_coreRegistry->registry($this->_clientRegistryId)) { $client = \Zend_Gdata_ClientLogin::getHttpClient( @@ -113,9 +112,9 @@ class Service extends \Magento\Framework\Object } catch (\Zend_Gdata_App_CaptchaRequiredException $e) { throw $e; } catch (\Zend_Gdata_App_HttpException $e) { - throw new \Magento\Framework\Exception\LocalizedException($errorMsg . __('Error: %1', $e->getMessage())); + throw new \Magento\Framework\Exception\LocalizedException(__('%1 Error: %2', $errorMsg, $e->getMessage())); } catch (\Zend_Gdata_App_AuthException $e) { - throw new \Magento\Framework\Exception\LocalizedException($errorMsg . __('Error: %1', $e->getMessage())); + throw new \Magento\Framework\Exception\LocalizedException(__('%1 Error: %2', $errorMsg, $e->getMessage())); } return $this->_coreRegistry->registry($this->_clientRegistryId); diff --git a/app/code/Magento/GoogleShopping/Test/Unit/Model/MassOperationsTest.php b/app/code/Magento/GoogleShopping/Test/Unit/Model/MassOperationsTest.php index bb417b4f0fe478e97833f6650bcf854b3bd4e0d8..fa6854a990f3b44eec48499b1285c6cb9debe660 100644 --- a/app/code/Magento/GoogleShopping/Test/Unit/Model/MassOperationsTest.php +++ b/app/code/Magento/GoogleShopping/Test/Unit/Model/MassOperationsTest.php @@ -43,6 +43,9 @@ class MassOperationsTest extends \PHPUnit_Framework_TestCase /** @var \Magento\GoogleShopping\Model\Flag|\PHPUnit_Framework_MockObject_MockObject */ protected $flag; + /** + * @return void + */ protected function setUp() { $this->collectionFactory = $this->getMockBuilder( @@ -80,6 +83,9 @@ class MassOperationsTest extends \PHPUnit_Framework_TestCase ); } + /** + * @return void + */ public function testAddProducts() { $products = ['1','2']; @@ -93,6 +99,9 @@ class MassOperationsTest extends \PHPUnit_Framework_TestCase $this->assertEquals($this->massOperations->addProducts($products, 1), $this->massOperations); } + /** + * @return void + */ public function testAddProductsExpiredFlag() { $products = ['1','2']; @@ -102,8 +111,9 @@ class MassOperationsTest extends \PHPUnit_Framework_TestCase } /** - * @dataProvider dataAddProductsExceptions * @param string $exception + * @return void + * @dataProvider dataAddProductsExceptions */ public function testAddProductsExceptions($exception) { @@ -113,7 +123,7 @@ class MassOperationsTest extends \PHPUnit_Framework_TestCase $this->productRepository->expects($this->once())->method('getById')->will($this->returnValue($product)); $this->itemFactory->expects($this->once()) ->method('create') - ->willThrowException(new $exception('message')); + ->willThrowException(new $exception(__('message'))); $this->massOperations->setFlag($this->flag); $this->massOperations->addProducts($products, 1); } @@ -132,6 +142,9 @@ class MassOperationsTest extends \PHPUnit_Framework_TestCase ]; } + /** + * @return void + */ public function testSynchronizeItems() { $collection = $this->getMockBuilder('Magento\GoogleShopping\Model\Resource\Item\Collection') @@ -154,6 +167,9 @@ class MassOperationsTest extends \PHPUnit_Framework_TestCase $this->massOperations->synchronizeItems([1]); } + /** + * @return void + */ public function testSynchronizeItemsWithException() { $collection = $this->getMockBuilder('Magento\GoogleShopping\Model\Resource\Item\Collection') @@ -182,6 +198,9 @@ class MassOperationsTest extends \PHPUnit_Framework_TestCase $this->massOperations->synchronizeItems([1]); } + /** + * @return void + */ public function testDeleteItems() { $item = $this->getMockBuilder('Magento\GoogleShopping\Model\Item')->disableOriginalConstructor()->getMock(); @@ -206,6 +225,9 @@ class MassOperationsTest extends \PHPUnit_Framework_TestCase $this->massOperations->deleteItems([1]); } + /** + * @return void + */ public function testDeleteItemsWitException() { $product = $this->getMockBuilder('Magento\Catalog\Model\Product')->disableOriginalConstructor() diff --git a/app/code/Magento/GoogleShopping/etc/config.xml b/app/code/Magento/GoogleShopping/etc/config.xml index d5daf823e33eec7a1104abb4abfda0ec2a2a47fa..82d68fde8927948a6bbdd118a543e1628a100f25 100644 --- a/app/code/Magento/GoogleShopping/etc/config.xml +++ b/app/code/Magento/GoogleShopping/etc/config.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Core/etc/config.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Store/etc/config.xsd"> <default> <google> <googleshopping> diff --git a/app/code/Magento/GroupedProduct/Model/Product/Type/Grouped.php b/app/code/Magento/GroupedProduct/Model/Product/Type/Grouped.php index f5139b50c8737e7cea0d5e9dc9cc1b7c2d36aac8..f44fe22015929528a2d7decdcc81858696c76e11 100644 --- a/app/code/Magento/GroupedProduct/Model/Product/Type/Grouped.php +++ b/app/code/Magento/GroupedProduct/Model/Product/Type/Grouped.php @@ -262,7 +262,7 @@ class Grouped extends \Magento\Catalog\Model\Product\Type\AbstractType if (!$product->hasData($this->_keyStatusFilters)) { return [ \Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED, - \Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_DISABLED + \Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_DISABLED, ]; } return $product->getData($this->_keyStatusFilters); diff --git a/app/code/Magento/GroupedProduct/etc/config.xml b/app/code/Magento/GroupedProduct/etc/config.xml index 6dcf6efdac0dc24ff4f21b451e2982c991743713..676a5554de340408a34f6244f78d2a3571c138f7 100644 --- a/app/code/Magento/GroupedProduct/etc/config.xml +++ b/app/code/Magento/GroupedProduct/etc/config.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Core/etc/config.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Store/etc/config.xsd"> <default> <checkout> <cart> diff --git a/app/code/Magento/ImportExport/Helper/Data.php b/app/code/Magento/ImportExport/Helper/Data.php index 2694d4a0201dfa5a6b119544adf0ae7438d2aa00..462fd7f424b3e4d76d838191ed09efb7700227e0 100644 --- a/app/code/Magento/ImportExport/Helper/Data.php +++ b/app/code/Magento/ImportExport/Helper/Data.php @@ -46,7 +46,7 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper /** * Get maximum upload size message * - * @return string + * @return \Magento\Framework\Phrase */ public function getMaxUploadSizeMessage() { diff --git a/app/code/Magento/ImportExport/Model/Export.php b/app/code/Magento/ImportExport/Model/Export.php index c3030a1cff44b313eceeebc5ea572bb0323f7fa7..227fd2fab3c54d489adb565b8fd1187a01fee832 100644 --- a/app/code/Magento/ImportExport/Model/Export.php +++ b/app/code/Magento/ImportExport/Model/Export.php @@ -97,7 +97,9 @@ class Export extends \Magento\ImportExport\Model\AbstractModel $this->_entityAdapter = $this->_entityFactory->create($entities[$this->getEntity()]['model']); } catch (\Exception $e) { $this->_logger->critical($e); - throw new \Magento\Framework\Exception\LocalizedException(__('Please enter a correct entity model')); + throw new \Magento\Framework\Exception\LocalizedException( + __('Please enter a correct entity model') + ); } if (!$this->_entityAdapter instanceof \Magento\ImportExport\Model\Export\Entity\AbstractEntity && !$this->_entityAdapter instanceof \Magento\ImportExport\Model\Export\AbstractEntity @@ -141,7 +143,9 @@ class Export extends \Magento\ImportExport\Model\AbstractModel $this->_writer = $this->_exportAdapterFac->create($fileFormats[$this->getFileFormat()]['model']); } catch (\Exception $e) { $this->_logger->critical($e); - throw new \Magento\Framework\Exception\LocalizedException(__('Please enter a correct entity model')); + throw new \Magento\Framework\Exception\LocalizedException( + __('Please enter a correct entity model') + ); } if (!$this->_writer instanceof \Magento\ImportExport\Model\Export\Adapter\AbstractAdapter) { throw new \Magento\Framework\Exception\LocalizedException( diff --git a/app/code/Magento/ImportExport/Model/Import.php b/app/code/Magento/ImportExport/Model/Import.php index 678d2889b01f0dd0a14fe0dc74e6c97d2b7f17a8..c09a012798e1d6f3fc9075440cedf77aa8277c38 100644 --- a/app/code/Magento/ImportExport/Model/Import.php +++ b/app/code/Magento/ImportExport/Model/Import.php @@ -504,7 +504,7 @@ class Import extends \Magento\ImportExport\Model\AbstractModel $this->_getSourceAdapter($sourceFile); } catch (\Exception $e) { $this->_varDirectory->delete($sourceFileRelative); - throw new \Magento\Framework\Exception\LocalizedException($e->getMessage()); + throw new \Magento\Framework\Exception\LocalizedException(__($e->getMessage())); } return $sourceFile; } diff --git a/app/code/Magento/ImportExport/etc/config.xml b/app/code/Magento/ImportExport/etc/config.xml index 84e0568291fb3e97e06338107c3e60bc03e455b5..b10fbc4e34c2cfe47314390998c47d13001f77a6 100644 --- a/app/code/Magento/ImportExport/etc/config.xml +++ b/app/code/Magento/ImportExport/etc/config.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Core/etc/config.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Store/etc/config.xsd"> <default> <general> <file> diff --git a/app/code/Magento/Indexer/Test/Unit/Model/Config/ConverterTest.php b/app/code/Magento/Indexer/Test/Unit/Model/Config/ConverterTest.php index b352c126ad3bcee98de67385eea22a472a73ffe5..3be90c1459b5a6f773450d9debaf86cf673d2e2d 100644 --- a/app/code/Magento/Indexer/Test/Unit/Model/Config/ConverterTest.php +++ b/app/code/Magento/Indexer/Test/Unit/Model/Config/ConverterTest.php @@ -25,24 +25,4 @@ class ConverterTest extends \PHPUnit_Framework_TestCase $this->assertEquals($data['expected'], $this->_model->convert($dom)); } - - /** - * @param string $xmlData - * @dataProvider wrongXmlDataProvider - * @expectedException \Exception - */ - public function testMapThrowsExceptionWhenXmlHasWrongFormat($xmlData) - { - $dom = new \DOMDocument(); - $dom->loadXML($xmlData); - $this->_model->convert($dom); - } - - /** - * @return array - */ - public function wrongXmlDataProvider() - { - return [['<?xml version="1.0"?><config>']]; - } } diff --git a/app/code/Magento/Indexer/Test/Unit/Model/Resource/AbstractResourceTest.php b/app/code/Magento/Indexer/Test/Unit/Model/Resource/AbstractResourceTest.php index 353e5cfaf83f0d9ec0c36fd718a6f6c8a74cb74c..b35dd6e74c6a9b0aa4a9ef75d5421b2220449819 100644 --- a/app/code/Magento/Indexer/Test/Unit/Model/Resource/AbstractResourceTest.php +++ b/app/code/Magento/Indexer/Test/Unit/Model/Resource/AbstractResourceTest.php @@ -86,13 +86,13 @@ class AbstractResourceTest extends \PHPUnit_Framework_TestCase /** * @expectedException \Exception - * @expectedExceptionMessage array_keys() expects parameter 1 to be array, null given */ public function testSyncDataException() { $connectionMock = $this->getMock('Magento\Framework\DB\Adapter\AdapterInterface', [], [], '', false); $this->_resourceMock->expects($this->any())->method('getConnection')->will($this->returnValue($connectionMock)); $this->_resourceMock->expects($this->any())->method('getTableName')->will($this->returnArgument(0)); + $connectionMock->expects($this->once())->method('rollback'); $this->model->syncData(); } diff --git a/app/code/Magento/Indexer/etc/module.xml b/app/code/Magento/Indexer/etc/module.xml index 4105ec2268543b68e0694380f2337541e7e3a8e7..f03aca19f0cc4ce32b6ce1b4b168d3d1ab391c37 100644 --- a/app/code/Magento/Indexer/etc/module.xml +++ b/app/code/Magento/Indexer/etc/module.xml @@ -8,7 +8,6 @@ <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd"> <module name="Magento_Indexer" setup_version="2.0.0"> <sequence> - <module name="Magento_Core"/> <module name="Magento_Store"/> </sequence> </module> diff --git a/app/code/Magento/Integration/Model/CredentialsValidator.php b/app/code/Magento/Integration/Model/CredentialsValidator.php index 2e86222cb702c783adbcc74d28b3851c111ff237..18a8938658951fb3c6cdfa8b7521c18646b60d66 100644 --- a/app/code/Magento/Integration/Model/CredentialsValidator.php +++ b/app/code/Magento/Integration/Model/CredentialsValidator.php @@ -25,10 +25,10 @@ class CredentialsValidator { $exception = new InputException(); if (!is_string($username) || strlen($username) == 0) { - $exception->addError(InputException::REQUIRED_FIELD, ['fieldName' => 'username']); + $exception->addError(__(InputException::REQUIRED_FIELD, ['fieldName' => 'username'])); } if (!is_string($username) || strlen($password) == 0) { - $exception->addError(InputException::REQUIRED_FIELD, ['fieldName' => 'password']); + $exception->addError(__(InputException::REQUIRED_FIELD, ['fieldName' => 'password'])); } if ($exception->wasErrorAdded()) { throw $exception; diff --git a/app/code/Magento/Integration/Model/Oauth/Consumer.php b/app/code/Magento/Integration/Model/Oauth/Consumer.php index faf3531395b57e596a19567322b7f2547d34b7af..7a40e1b5b693290f2efe84935a9a01f002be0daf 100644 --- a/app/code/Magento/Integration/Model/Oauth/Consumer.php +++ b/app/code/Magento/Integration/Model/Oauth/Consumer.php @@ -120,14 +120,14 @@ class Consumer extends \Magento\Framework\Model\AbstractModel implements Consume $validatorLength->setName('Consumer Key'); if (!$validatorLength->isValid($this->getKey())) { $messages = $validatorLength->getMessages(); - throw new \Magento\Framework\Exception\LocalizedException(array_shift($messages)); + throw new \Magento\Framework\Exception\LocalizedException(__(array_shift($messages))); } $validatorLength->setLength(\Magento\Framework\Oauth\Helper\Oauth::LENGTH_CONSUMER_SECRET); $validatorLength->setName('Consumer Secret'); if (!$validatorLength->isValid($this->getSecret())) { $messages = $validatorLength->getMessages(); - throw new \Magento\Framework\Exception\LocalizedException(array_shift($messages)); + throw new \Magento\Framework\Exception\LocalizedException(__(array_shift($messages))); } return true; } diff --git a/app/code/Magento/Integration/Model/Oauth/Nonce/Generator.php b/app/code/Magento/Integration/Model/Oauth/Nonce/Generator.php index 697561a24cc61d76c807834ff30cd4153b950295..a10cdcb07d37a9a2d16616d67e615937568939e6 100644 --- a/app/code/Magento/Integration/Model/Oauth/Nonce/Generator.php +++ b/app/code/Magento/Integration/Model/Oauth/Nonce/Generator.php @@ -78,7 +78,7 @@ class Generator implements NonceGeneratorInterface $timestamp = (int)$timestamp; if ($timestamp <= 0 || $timestamp > time() + self::TIME_DEVIATION) { throw new \Magento\Framework\Oauth\OauthInputException( - 'Incorrect timestamp value in the oauth_timestamp parameter' + __('Incorrect timestamp value in the oauth_timestamp parameter') ); } @@ -87,8 +87,10 @@ class Generator implements NonceGeneratorInterface if ($nonceObj->getNonce()) { throw new \Magento\Framework\Oauth\Exception( - 'The nonce is already being used by the consumer with ID %1', - [$consumer->getId()] + __( + 'The nonce is already being used by the consumer with ID %1', + [$consumer->getId()] + ) ); } @@ -96,7 +98,7 @@ class Generator implements NonceGeneratorInterface } catch (\Magento\Framework\Oauth\Exception $exception) { throw $exception; } catch (\Exception $exception) { - throw new \Magento\Framework\Oauth\Exception('An error occurred validating the nonce'); + throw new \Magento\Framework\Oauth\Exception(__('An error occurred validating the nonce')); } } } diff --git a/app/code/Magento/Integration/Model/Oauth/Token.php b/app/code/Magento/Integration/Model/Oauth/Token.php index 7757ed194ffd3e2a249cc5c83f67a97887e59613..88f2efb713cff4cbf69bdf568d608d32951a63f0 100644 --- a/app/code/Magento/Integration/Model/Oauth/Token.php +++ b/app/code/Magento/Integration/Model/Oauth/Token.php @@ -186,7 +186,7 @@ class Token extends \Magento\Framework\Model\AbstractModel public function convertToAccess() { if (self::TYPE_REQUEST != $this->getType()) { - throw new OauthException('Cannot convert to access token due to token is not request type'); + throw new OauthException(__('Cannot convert to access token due to token is not request type')); } return $this->saveAccessToken(UserContextInterface::USER_TYPE_INTEGRATION); } @@ -278,7 +278,7 @@ class Token extends \Magento\Framework\Model\AbstractModel ) ) { $messages = $this->_urlValidator->getMessages(); - throw new OauthException(array_shift($messages)); + throw new OauthException(__(array_shift($messages))); } /** @var $validatorLength \Magento\Integration\Model\Oauth\Consumer\Validator\KeyLength */ @@ -287,14 +287,14 @@ class Token extends \Magento\Framework\Model\AbstractModel $validatorLength->setName('Token Secret Key'); if (!$validatorLength->isValid($this->getSecret())) { $messages = $validatorLength->getMessages(); - throw new OauthException(array_shift($messages)); + throw new OauthException(__(array_shift($messages))); } $validatorLength->setLength(OauthHelper::LENGTH_TOKEN); $validatorLength->setName('Token Key'); if (!$validatorLength->isValid($this->getToken())) { $messages = $validatorLength->getMessages(); - throw new OauthException(array_shift($messages)); + throw new OauthException(__(array_shift($messages))); } if (null !== ($verifier = $this->getVerifier())) { @@ -302,7 +302,7 @@ class Token extends \Magento\Framework\Model\AbstractModel $validatorLength->setName('Verifier Key'); if (!$validatorLength->isValid($verifier)) { $messages = $validatorLength->getMessages(); - throw new OauthException(array_shift($messages)); + throw new OauthException(__(array_shift($messages))); } } return true; diff --git a/app/code/Magento/Integration/Model/Oauth/Token/Provider.php b/app/code/Magento/Integration/Model/Oauth/Token/Provider.php index 8d12af0f3c4ad25747db41ff423502265a606678..550d895dac700073cab0807f4cee245eea758cc2 100644 --- a/app/code/Magento/Integration/Model/Oauth/Token/Provider.php +++ b/app/code/Magento/Integration/Model/Oauth/Token/Provider.php @@ -50,7 +50,7 @@ class Provider implements TokenProviderInterface // Must use consumer within expiration period. if (!$consumer->isValidForTokenExchange()) { throw new \Magento\Framework\Oauth\Exception( - 'Consumer key has expired' + __('Consumer key has expired') ); } return true; @@ -64,7 +64,7 @@ class Provider implements TokenProviderInterface $token = $this->getIntegrationTokenByConsumerId($consumer->getId()); if ($token->getType() != Token::TYPE_VERIFIER) { throw new \Magento\Framework\Oauth\Exception( - 'Cannot create request token because consumer token is not a verifier token' + __('Cannot create request token because consumer token is not a verifier token') ); } $requestToken = $token->createRequestToken($token->getId(), $consumer->getCallbackUrl()); @@ -80,7 +80,7 @@ class Provider implements TokenProviderInterface if (!$this->_isTokenAssociatedToConsumer($token, $consumer)) { throw new \Magento\Framework\Oauth\Exception( - 'Request token is not associated with the specified consumer' + __('Request token is not associated with the specified consumer') ); } @@ -88,7 +88,7 @@ class Provider implements TokenProviderInterface // In this flow (token flow) the token has to be of type "request" else its marked as reused. if (Token::TYPE_REQUEST != $token->getType()) { throw new \Magento\Framework\Oauth\Exception( - 'Token is already being used' + __('Token is already being used') ); } @@ -106,7 +106,7 @@ class Provider implements TokenProviderInterface $token = $this->getIntegrationTokenByConsumerId($consumerId); if (Token::TYPE_REQUEST != $token->getType()) { throw new \Magento\Framework\Oauth\Exception( - 'Cannot get access token because consumer token is not a request token' + __('Cannot get access token because consumer token is not a request token') ); } $accessToken = $token->convertToAccess(); @@ -125,17 +125,17 @@ class Provider implements TokenProviderInterface if (!$this->_isTokenAssociatedToConsumer($token, $consumer)) { throw new \Magento\Framework\Oauth\Exception( - 'Token is not associated with the specified consumer' + __('Token is not associated with the specified consumer') ); } if (Token::TYPE_ACCESS != $token->getType()) { throw new \Magento\Framework\Oauth\Exception( - 'Token is not an access token' + __('Token is not an access token') ); } if ($token->getRevoked()) { throw new \Magento\Framework\Oauth\Exception( - 'Access token has been revoked' + __('Access token has been revoked') ); } @@ -153,13 +153,13 @@ class Provider implements TokenProviderInterface if (Token::TYPE_ACCESS != $token->getType()) { throw new \Magento\Framework\Oauth\Exception( - 'Token is not an access token' + __('Token is not an access token') ); } if ($token->getRevoked()) { throw new \Magento\Framework\Oauth\Exception( - 'Access token has been revoked' + __('Access token has been revoked') ); } @@ -181,7 +181,7 @@ class Provider implements TokenProviderInterface { if (strlen($consumerKey) != \Magento\Framework\Oauth\Helper\Oauth::LENGTH_CONSUMER_KEY) { throw new \Magento\Framework\Oauth\Exception( - 'Consumer key is not the correct length' + __('Consumer key is not the correct length') ); } @@ -189,7 +189,7 @@ class Provider implements TokenProviderInterface if (!$consumer->getId()) { throw new \Magento\Framework\Oauth\Exception( - 'A consumer having the specified key does not exist' + __('A consumer having the specified key does not exist') ); } @@ -208,17 +208,17 @@ class Provider implements TokenProviderInterface { if (!is_string($oauthVerifier)) { throw new \Magento\Framework\Oauth\Exception( - 'Verifier is invalid' + __('Verifier is invalid') ); } if (!$this->validateOauthToken($oauthVerifier)) { throw new \Magento\Framework\Oauth\Exception( - 'Verifier is not the correct length' + __('Verifier is not the correct length') ); } if ($tokenVerifier != $oauthVerifier) { throw new \Magento\Framework\Oauth\Exception( - 'Token verifier and verifier token do not match' + __('Token verifier and verifier token do not match') ); } } @@ -236,8 +236,10 @@ class Provider implements TokenProviderInterface if (!$consumer->getId()) { throw new \Magento\Framework\Oauth\Exception( - 'A consumer with the ID %1 does not exist', - [$consumerId] + __( + 'A consumer with the ID %1 does not exist', + [$consumerId] + ) ); } @@ -255,7 +257,7 @@ class Provider implements TokenProviderInterface { if (!$this->validateOauthToken($token)) { throw new \Magento\Framework\Oauth\Exception( - 'Token is not the correct length' + __('Token is not the correct length') ); } @@ -263,7 +265,7 @@ class Provider implements TokenProviderInterface if (!$tokenObj->getId()) { throw new \Magento\Framework\Oauth\Exception( - 'Specified token does not exist' + __('Specified token does not exist') ); } @@ -285,8 +287,10 @@ class Provider implements TokenProviderInterface if (!$token->getId()) { throw new \Magento\Framework\Oauth\Exception( - 'A token with consumer ID %1 does not exist', - [$consumerId] + __( + 'A token with consumer ID %1 does not exist', + [$consumerId] + ) ); } diff --git a/app/code/Magento/Integration/Service/V1/AdminTokenService.php b/app/code/Magento/Integration/Service/V1/AdminTokenService.php index 5393184ff9bceb5e8386194049b9b8ed1161b1bf..7fb947eacd8204163b825656ec3b702c85cef445 100644 --- a/app/code/Magento/Integration/Service/V1/AdminTokenService.php +++ b/app/code/Magento/Integration/Service/V1/AdminTokenService.php @@ -22,7 +22,7 @@ class AdminTokenService implements AdminTokenServiceInterface { /** * Token Model - * + *a * @var TokenModelFactory */ private $tokenModelFactory; @@ -72,20 +72,14 @@ class AdminTokenService implements AdminTokenServiceInterface public function createAdminAccessToken($username, $password) { $this->validatorHelper->validate($username, $password); - try { - $this->userModel->login($username, $password); - if (!$this->userModel->getId()) { - /* - * This message is same as one thrown in \Magento\Backend\Model\Auth to keep the behavior consistent. - * Constant cannot be created in Auth Model since it uses legacy translation that doesn't support it. - * Need to make sure that this is refactored once exception handling is updated in Auth Model. - */ - throw new AuthenticationException('Please correct the user name or password.'); - } - } catch (\Magento\Framework\Exception\AuthenticationException $e) { - throw new AuthenticationException($e->getMessage(), [], $e); - } catch (\Magento\Framework\Exception\LocalizedException $e) { - throw new LocalizedException($e->getMessage(), [], $e); + $this->userModel->login($username, $password); + if (!$this->userModel->getId()) { + /* + * This message is same as one thrown in \Magento\Backend\Model\Auth to keep the behavior consistent. + * Constant cannot be created in Auth Model since it uses legacy translation that doesn't support it. + * Need to make sure that this is refactored once exception handling is updated in Auth Model. + */ + throw new AuthenticationException(__('Please correct the user name or password.')); } return $this->tokenModelFactory->create()->createAdminToken($this->userModel->getId())->getToken(); } diff --git a/app/code/Magento/Integration/Service/V1/Oauth.php b/app/code/Magento/Integration/Service/V1/Oauth.php index ff45e641fa1e5bc11d910f031ae7750934c21aa7..9f59d33da5b6826b032d8948b180a55bcb5b6a33 100644 --- a/app/code/Magento/Integration/Service/V1/Oauth.php +++ b/app/code/Magento/Integration/Service/V1/Oauth.php @@ -108,7 +108,7 @@ class Oauth implements OauthInterface throw $exception; } catch (\Exception $exception) { throw new \Magento\Framework\Oauth\Exception( - 'Unexpected error. Unable to create oAuth consumer account.' + __('Unexpected error. Unable to create oAuth consumer account.') ); } } @@ -165,7 +165,7 @@ class Oauth implements OauthInterface throw $exception; } catch (\Exception $exception) { throw new \Magento\Framework\Oauth\Exception( - 'Unexpected error. Unable to load oAuth consumer account.' + __('Unexpected error. Unable to load oAuth consumer account.') ); } } @@ -181,7 +181,7 @@ class Oauth implements OauthInterface throw $exception; } catch (\Exception $exception) { throw new \Magento\Framework\Oauth\Exception( - 'Unexpected error. Unable to load oAuth consumer account.' + __('Unexpected error. Unable to load oAuth consumer account.') ); } } @@ -195,8 +195,7 @@ class Oauth implements OauthInterface $consumer = $this->_consumerFactory->create()->load($consumerId); if (!$consumer->getId()) { throw new \Magento\Framework\Oauth\Exception( - __('A consumer with ID %1 does not exist', $consumerId), - OauthInterface::ERR_PARAMETER_REJECTED + __('A consumer with ID %1 does not exist', $consumerId) ); } $consumerData = $consumer->getData(); @@ -223,7 +222,7 @@ class Oauth implements OauthInterface } catch (\Exception $exception) { $this->_logger->critical($exception); throw new \Magento\Framework\Oauth\Exception( - 'Unable to post data to consumer due to an unexpected error' + __('Unable to post data to consumer due to an unexpected error') ); } } diff --git a/app/code/Magento/Integration/Test/Unit/Controller/Adminhtml/Integration/EditTest.php b/app/code/Magento/Integration/Test/Unit/Controller/Adminhtml/Integration/EditTest.php index 07f779a676cd7c028cceca2857c68a04c0562673..0bd7ab3e4663269734c5a9fabe3adbf0e0b76c7d 100644 --- a/app/code/Magento/Integration/Test/Unit/Controller/Adminhtml/Integration/EditTest.php +++ b/app/code/Magento/Integration/Test/Unit/Controller/Adminhtml/Integration/EditTest.php @@ -71,7 +71,7 @@ class EditTest extends \Magento\Integration\Test\Unit\Controller\Adminhtml\Integ $this->returnValue(['name' => 'nonExistentInt']) ); - $invalidIdException = new IntegrationException($exceptionMessage); + $invalidIdException = new IntegrationException(__($exceptionMessage)); $this->_integrationSvcMock->expects( $this->any() )->method( diff --git a/app/code/Magento/Integration/Test/Unit/Controller/Adminhtml/Integration/SaveTest.php b/app/code/Magento/Integration/Test/Unit/Controller/Adminhtml/Integration/SaveTest.php index e1057b4f40a010a7ea3bb60493a5a63dad0a80bf..d29767e6091b2b1c86647e2ec61cbc6aaeefbafe 100644 --- a/app/code/Magento/Integration/Test/Unit/Controller/Adminhtml/Integration/SaveTest.php +++ b/app/code/Magento/Integration/Test/Unit/Controller/Adminhtml/Integration/SaveTest.php @@ -75,7 +75,7 @@ class SaveTest extends \Magento\Integration\Test\Unit\Controller\Adminhtml\Integ )->with( self::INTEGRATION_ID )->will( - $this->throwException(new \Magento\Framework\Exception\LocalizedException($exceptionMessage)) + $this->throwException(new \Magento\Framework\Exception\LocalizedException(__($exceptionMessage))) ); // Verify error $this->_messageManager->expects($this->once())->method('addError')->with($this->equalTo($exceptionMessage)); @@ -96,7 +96,7 @@ class SaveTest extends \Magento\Integration\Test\Unit\Controller\Adminhtml\Integ )->with( self::INTEGRATION_ID )->will( - $this->throwException(new IntegrationException($exceptionMessage)) + $this->throwException(new IntegrationException(__($exceptionMessage))) ); // Verify error $this->_messageManager->expects($this->once())->method('addError')->with($this->equalTo($exceptionMessage)); @@ -170,7 +170,7 @@ class SaveTest extends \Magento\Integration\Test\Unit\Controller\Adminhtml\Integ )->with( $this->anything() )->will( - $this->throwException(new IntegrationException($exceptionMessage)) + $this->throwException(new IntegrationException(__($exceptionMessage))) ); $this->_integrationSvcMock->expects( $this->any() diff --git a/app/code/Magento/Integration/Test/Unit/Service/V1/OauthTest.php b/app/code/Magento/Integration/Test/Unit/Service/V1/OauthTest.php index 1a938b865a368a1d5e564a254057b52f8b7750e1..01d17a14abf7fdaa7f6dcfdd141e3ffce7872414 100644 --- a/app/code/Magento/Integration/Test/Unit/Service/V1/OauthTest.php +++ b/app/code/Magento/Integration/Test/Unit/Service/V1/OauthTest.php @@ -46,6 +46,9 @@ class OauthTest extends \PHPUnit_Framework_TestCase */ private $_tokenFactoryMock; + /** + * @return void + */ protected function setUp() { $this->_consumerFactory = $this->getMockBuilder( @@ -108,6 +111,9 @@ class OauthTest extends \PHPUnit_Framework_TestCase $this->_emptyConsumerMock->expects($this->any())->method('getId')->will($this->returnValue(null)); } + /** + * @return void + */ public function testDelete() { $this->_consumerMock->expects( @@ -133,6 +139,7 @@ class OauthTest extends \PHPUnit_Framework_TestCase } /** + * @return void * @expectedException \Magento\Framework\Exception\IntegrationException * @expectedExceptionMessage Consumer with ID '1' does not exist. */ @@ -144,6 +151,9 @@ class OauthTest extends \PHPUnit_Framework_TestCase $this->_service->deleteConsumer(self::VALUE_CONSUMER_ID); } + /** + * @return void + */ public function testCreateAccessTokenAndClearExisting() { @@ -182,6 +192,9 @@ class OauthTest extends \PHPUnit_Framework_TestCase $this->assertTrue($this->_service->createAccessToken(self::VALUE_CONSUMER_ID, true)); } + /** + * @return void + */ public function testCreateAccessTokenWithoutClearingExisting() { $this->_consumerMock->expects( @@ -207,6 +220,9 @@ class OauthTest extends \PHPUnit_Framework_TestCase $this->assertFalse($this->_service->createAccessToken(self::VALUE_CONSUMER_ID, false)); } + /** + * @return void + */ public function testCreateAccessTokenInvalidConsumerId() { $this->_consumerMock->expects( @@ -226,7 +242,7 @@ class OauthTest extends \PHPUnit_Framework_TestCase )->will( $this->throwException( new \Magento\Framework\Oauth\Exception( - 'A token with consumer ID 0 does not exist' + __('A token with consumer ID 0 does not exist') ) ) ); @@ -250,6 +266,9 @@ class OauthTest extends \PHPUnit_Framework_TestCase $this->assertTrue($this->_service->createAccessToken(0, false)); } + /** + * @return void + */ public function testLoadConsumer() { $this->_consumerMock->expects( @@ -268,6 +287,7 @@ class OauthTest extends \PHPUnit_Framework_TestCase } /** + * @return void * @expectedException \Magento\Framework\Oauth\Exception * @expectedExceptionMessage Unexpected error. Unable to load oAuth consumer account. */ @@ -279,12 +299,15 @@ class OauthTest extends \PHPUnit_Framework_TestCase 'load' )->will( $this->throwException( - new \Magento\Framework\Oauth\Exception('Unexpected error. Unable to load oAuth consumer account.') + new \Magento\Framework\Oauth\Exception(__('Unexpected error. Unable to load oAuth consumer account.')) ) ); $this->_service->loadConsumer(self::VALUE_CONSUMER_ID); } + /** + * @return void + */ public function testLoadConsumerByKey() { $this->_consumerMock->expects( @@ -304,6 +327,7 @@ class OauthTest extends \PHPUnit_Framework_TestCase } /** + * @return void * @expectedException \Magento\Framework\Oauth\Exception * @expectedExceptionMessage Unexpected error. Unable to load oAuth consumer account. */ @@ -315,12 +339,15 @@ class OauthTest extends \PHPUnit_Framework_TestCase 'load' )->will( $this->throwException( - new \Magento\Framework\Oauth\Exception('Unexpected error. Unable to load oAuth consumer account.') + new \Magento\Framework\Oauth\Exception(__('Unexpected error. Unable to load oAuth consumer account.')) ) ); $this->_service->loadConsumerByKey(self::VALUE_CONSUMER_KEY); } + /** + * @return void + */ public function testDeleteToken() { $this->_consumerMock->expects( @@ -346,6 +373,9 @@ class OauthTest extends \PHPUnit_Framework_TestCase $this->assertTrue($this->_service->deleteIntegrationToken(self::VALUE_CONSUMER_ID)); } + /** + * @return void + */ public function testDeleteTokenNegative() { $this->_consumerMock->expects( @@ -371,6 +401,9 @@ class OauthTest extends \PHPUnit_Framework_TestCase $this->assertFalse($this->_service->deleteIntegrationToken(null)); } + /** + * @return void + */ public function testGetAccessTokenNoAccess() { $this->_consumerMock->expects( @@ -394,6 +427,9 @@ class OauthTest extends \PHPUnit_Framework_TestCase $this->assertFalse($this->_service->getAccessToken(self::VALUE_CONSUMER_ID), false); } + /** + * @return void + */ public function testGetAccessSuccess() { $this->_consumerMock->expects( diff --git a/app/code/Magento/Integration/etc/config.xml b/app/code/Magento/Integration/etc/config.xml index 8f525ccda1b7c6fa654df5a6b79fc1792df0f25c..6223b5bdc2d90b1dcd5c7facf13b46fa189589c8 100644 --- a/app/code/Magento/Integration/etc/config.xml +++ b/app/code/Magento/Integration/etc/config.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Core/etc/config.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Store/etc/config.xsd"> <default> <oauth> <cleanup> diff --git a/app/code/Magento/Integration/etc/module.xml b/app/code/Magento/Integration/etc/module.xml index 7ae7bc0918f138db78083e39678ac75e08ee10a9..ca7838bfbb11cdfa6f9b6eeddf527786b87493f5 100644 --- a/app/code/Magento/Integration/etc/module.xml +++ b/app/code/Magento/Integration/etc/module.xml @@ -8,7 +8,6 @@ <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd"> <module name="Magento_Integration" setup_version="2.0.0"> <sequence> - <module name="Magento_Core"/> <module name="Magento_Store"/> <module name="Magento_User"/> </sequence> diff --git a/app/code/Magento/LayeredNavigation/etc/config.xml b/app/code/Magento/LayeredNavigation/etc/config.xml index 21e2b707da9e34d6b927bfc2c9ff47b42af2d01d..d8cfd0f552c797148358e62578f119f794cf695a 100644 --- a/app/code/Magento/LayeredNavigation/etc/config.xml +++ b/app/code/Magento/LayeredNavigation/etc/config.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Core/etc/config.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Store/etc/config.xsd"> <default> <catalog> <layered_navigation> diff --git a/app/code/Magento/Log/Block/Adminhtml/Customer/Edit/Tab/View/Status.php b/app/code/Magento/Log/Block/Adminhtml/Customer/Edit/Tab/View/Status.php deleted file mode 100644 index c95e4ba9827f3facf32bf1257a2c4081a48e3a18..0000000000000000000000000000000000000000 --- a/app/code/Magento/Log/Block/Adminhtml/Customer/Edit/Tab/View/Status.php +++ /dev/null @@ -1,155 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Log\Block\Adminhtml\Customer\Edit\Tab\View; - -/** - * Class Status - * @SuppressWarnings(PHPMD.CouplingBetweenObjects) - */ -class Status extends \Magento\Backend\Block\Template -{ - /** - * @var \Magento\Customer\Api\Data\CustomerInterface - */ - protected $customer; - - /** - * @var \Magento\Log\Model\Customer - */ - protected $customerLog; - - /** - * @var \Magento\Log\Model\Visitor - */ - protected $modelLog; - - /** - * @var \Magento\Log\Model\CustomerFactory - */ - protected $logFactory; - - /** - * @var \Magento\Customer\Api\Data\CustomerInterfaceFactory - */ - protected $customerFactory; - - /** - * @var \Magento\Framework\Api\DataObjectHelper - */ - protected $dataObjectHelper; - - /** - * @param \Magento\Backend\Block\Template\Context $context - * @param \Magento\Log\Model\CustomerFactory $logFactory - * @param \Magento\Log\Model\Log $modelLog - * @param \Magento\Framework\Stdlib\DateTime $dateTime - * @param \Magento\Customer\Api\Data\CustomerInterfaceFactory $customerFactory - * @param \Magento\Framework\Api\DataObjectHelper $dataObjectHelper - * @param array $data - */ - public function __construct( - \Magento\Backend\Block\Template\Context $context, - \Magento\Log\Model\CustomerFactory $logFactory, - \Magento\Log\Model\Log $modelLog, - \Magento\Framework\Stdlib\DateTime $dateTime, - \Magento\Customer\Api\Data\CustomerInterfaceFactory $customerFactory, - \Magento\Framework\Api\DataObjectHelper $dataObjectHelper, - array $data = [] - ) { - $this->logFactory = $logFactory; - $this->modelLog = $modelLog; - $this->dateTime = $dateTime; - $this->customerFactory = $customerFactory; - $this->dataObjectHelper = $dataObjectHelper; - parent::__construct($context, $data); - } - - /** - * @return string - */ - public function getStoreLastLoginDateTimezone() - { - return $this->_scopeConfig->getValue( - $this->_localeDate->getDefaultTimezonePath(), - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $this->getCustomer()->getStoreId() - ); - } - - /** - * @return \Magento\Customer\Api\Data\CustomerInterface - */ - public function getCustomer() - { - if (!$this->customer) { - $this->customer = $this->customerFactory->create(); - $this->dataObjectHelper - ->populateWithArray( - $this->customer, - $this->_backendSession->getCustomerData()['account'], - '\Magento\Customer\Api\Data\CustomerInterface' - ); - } - return $this->customer; - } - - /** - * Get customer's current status - * - * @return \Magento\Framework\Phrase - */ - public function getCurrentStatus() - { - $log = $this->getCustomerLog(); - $interval = $this->modelLog->getOnlineMinutesInterval(); - if ($log->getLogoutAt() || - (new \DateTime())->getTimestamp() - strtotime($log->getLastVisitAt()) > $interval * 60 - ) { - return __('Offline'); - } - return __('Online'); - } - - /** - * Get customer last login date - * - * @return \Magento\Framework\Phrase|string - */ - public function getLastLoginDate() - { - $date = $this->getCustomerLog()->getLoginAt(); - if ($date) { - return $this->formatDate($date, \IntlDateFormatter::MEDIUM, true); - } - return __('Never'); - } - - /** - * @return \Magento\Framework\Phrase|string - */ - public function getStoreLastLoginDate() - { - $date = $this->getCustomerLog()->getLoginAtTimestamp(); - if ($date) { - $date = $this->_localeDate->scopeDate($this->getCustomer()->getStoreId(), $date, true); - return $this->formatDate($date, \IntlDateFormatter::MEDIUM, true); - } - return __('Never'); - } - - /** - * Load Customer Log model - * - * @return \Magento\Log\Model\Customer - */ - public function getCustomerLog() - { - if (!$this->customerLog) { - $this->customerLog = $this->logFactory->create()->loadByCustomer($this->getCustomer()->getId()); - } - return $this->customerLog; - } -} diff --git a/app/code/Magento/Log/Test/Unit/Block/Adminhtml/Customer/Edit/Tab/View/StatusTest.php b/app/code/Magento/Log/Test/Unit/Block/Adminhtml/Customer/Edit/Tab/View/StatusTest.php deleted file mode 100644 index c155c22aca514c592d5a87f4b04c3d99ef491e35..0000000000000000000000000000000000000000 --- a/app/code/Magento/Log/Test/Unit/Block/Adminhtml/Customer/Edit/Tab/View/StatusTest.php +++ /dev/null @@ -1,162 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Log\Test\Unit\Block\Adminhtml\Customer\Edit\Tab\View; - -use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; - -/** - * Class StatusTest - * @package Magento\Log\Block\Adminhtml\Edit\Tab\View - */ -class StatusTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var \Magento\Log\Block\Adminhtml\Customer\Edit\Tab\View\Status - */ - protected $block; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $logFactory; - - /** - * @var \Magento\Log\Model\Customer|\PHPUnit_Framework_MockObject_MockObject - */ - protected $customerLog; - - /** - * @var \Magento\Framework\Stdlib\DateTime\TimezoneInterface|\PHPUnit_Framework_MockObject_MockObject - */ - protected $localeDate; - - /** - * @var \Magento\Framework\App\Config\ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject - */ - protected $scopeConfig; - - protected function setUp() - { - $log = $this->getMock('Magento\Log\Model\Log', ['getOnlineMinutesInterval'], [], '', false); - $log->expects($this->any())->method('getOnlineMinutesInterval')->will($this->returnValue(1)); - - $this->customerLog = $this->getMockBuilder('Magento\Log\Model\Customer')->disableOriginalConstructor() - ->setMethods(['getLoginAt', 'getLoginAtTimestamp', 'loadByCustomer', 'getLogoutAt', 'getLastVisitAt']) - ->getMock(); - $this->customerLog->expects($this->any())->method('loadByCustomer')->will($this->returnSelf()); - - $this->logFactory = $this->getMockBuilder('Magento\Log\Model\CustomerFactory')->setMethods(['create']) - ->disableOriginalConstructor() - ->getMock(); - $this->logFactory->expects($this->any())->method('create')->will($this->returnValue($this->customerLog)); - - $dateTime = $this->getMockBuilder('Magento\Framework\Stdlib\DateTime')->setMethods(['now']) - ->disableOriginalConstructor() - ->getMock(); - $dateTime->expects($this->any())->method('now')->will($this->returnCallback(function () { - return date('Y-m-d H:i:s'); - })); - - $customer = $this->getMock('\Magento\Customer\Api\Data\CustomerInterface'); - $customer->expects($this->any())->method('getId')->will($this->returnValue(1)); - $customer->expects($this->any())->method('getStoreId')->will($this->returnValue(1)); - - $customerFactory = $this->getMockBuilder('\Magento\Customer\Api\Data\CustomerInterfaceFactory') - ->setMethods(['create']) - ->disableOriginalConstructor() - ->getMock(); - $customerFactory->expects($this->any())->method('create') - ->will($this->returnValue($customer)); - - $customerData = ['account' => ['id' => 1, 'store_id' => 1]]; - $backendSession = $this->getMockBuilder('\Magento\Backend\Model\Session') - ->setMethods(['getCustomerData'])->disableOriginalConstructor()->getMock(); - $backendSession->expects($this->any())->method('getCustomerData')->will($this->returnValue($customerData)); - - $this->localeDate = $this->getMockBuilder('Magento\Framework\Stdlib\DateTime\Timezone') - ->setMethods(['scopeDate', 'formatDateTime', 'getDefaultTimezonePath']) - ->disableOriginalConstructor()->getMock(); - $this->localeDate->expects($this->any())->method('getDefaultTimezonePath') - ->will($this->returnValue('path/to/default/timezone')); - - $this->scopeConfig = $this->getMockBuilder('Magento\Framework\App\Config') - ->setMethods(['getValue']) - ->disableOriginalConstructor()->getMock(); - - $objectManagerHelper = new ObjectManagerHelper($this); - $this->block = $objectManagerHelper->getObject( - 'Magento\Log\Block\Adminhtml\Customer\Edit\Tab\View\Status', - [ - 'logFactory' => $this->logFactory, - 'localeDate' => $this->localeDate, - 'scopeConfig' => $this->scopeConfig, - 'modelLog' => $log, - 'dateTime' => $dateTime, - 'customerFactory' => $customerFactory, - 'backendSession' => $backendSession - ] - ); - } - - public function testGetCustomerLog() - { - $this->logFactory->expects($this->once())->method('create')->will($this->returnValue($this->customerLog)); - $this->assertSame($this->customerLog, $this->block->getCustomerLog()); - } - - public function testGetCurrentStatusOffline() - { - $date = date('Y-m-d H:i:s'); - $this->customerLog->expects($this->any())->method('getLogoutAt')->will($this->returnValue($date)); - $this->assertEquals('Offline', $this->block->getCurrentStatus()); - } - - public function testGetCurrentStatusOnline() - { - $date = date('Y-m-d H:i:s'); - $this->customerLog->expects($this->any())->method('getLogoutAt')->will($this->returnValue(0)); - $this->customerLog->expects($this->any())->method('getLastVisitAt')->will($this->returnValue($date)); - $this->assertEquals('Online', $this->block->getCurrentStatus()); - } - - public function testGetLastLoginDate() - { - $date = date('Y-m-d H:i:s'); - $this->customerLog->expects($this->any())->method('getLoginAt')->will($this->returnValue($date)); - $this->localeDate->expects($this->once())->method('formatDateTime')->will($this->returnValue($date)); - $this->assertEquals($date, $this->block->getLastLoginDate()); - } - - public function testAfterGetLastLoginDateNever() - { - $this->assertEquals('Never', $this->block->getLastLoginDate()); - } - - public function testGetStoreLastLoginDate() - { - $date = date('Y-m-d H:i:s'); - $time = strtotime($date); - - $this->localeDate->expects($this->once())->method('scopeDate')->will($this->returnValue($date)); - $this->localeDate->expects($this->once())->method('formatDateTime')->will($this->returnValue($date)); - - $this->customerLog->expects($this->any())->method('getLoginAtTimestamp')->will($this->returnValue($time)); - $this->assertEquals($date, $this->block->getStoreLastLoginDate()); - } - - public function testGetStoreLastLoginDateNever() - { - $this->assertEquals('Never', $this->block->getStoreLastLoginDate()); - } - - public function testGetStoreLastLoginDateTimezone() - { - $this->scopeConfig->expects($this->once())->method('getValue') - ->with('path/to/default/timezone', 'store', 1) - ->will($this->returnValue('America/Los_Angeles')); - $this->block->getStoreLastLoginDateTimezone(); - } -} diff --git a/app/code/Magento/Log/etc/config.xml b/app/code/Magento/Log/etc/config.xml index f77e48a2099d1be7ffdd14754097719b9f701434..0ca74bb05b554e466039793a3e89238a1ac18ebe 100644 --- a/app/code/Magento/Log/etc/config.xml +++ b/app/code/Magento/Log/etc/config.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Core/etc/config.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Store/etc/config.xsd"> <default> <log> <visitor> diff --git a/app/code/Magento/Log/view/adminhtml/layout/customer_form.xml b/app/code/Magento/Log/view/adminhtml/layout/customer_form.xml deleted file mode 100644 index f53b7241321ea6154c32b08cab9e066644c755d2..0000000000000000000000000000000000000000 --- a/app/code/Magento/Log/view/adminhtml/layout/customer_form.xml +++ /dev/null @@ -1,14 +0,0 @@ -<?xml version="1.0"?> -<!-- -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ ---> -<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd"> - <body> - <referenceBlock name="personal_info"> - <block class="Magento\Log\Block\Adminhtml\Customer\Edit\Tab\View\Status" name="view_customer_status" template="customer/status.phtml"/> - </referenceBlock> - </body> -</page> diff --git a/app/code/Magento/Log/view/adminhtml/templates/customer/status.phtml b/app/code/Magento/Log/view/adminhtml/templates/customer/status.phtml deleted file mode 100644 index 3d8c1ac2912e2e312967a447b2908791598aae14..0000000000000000000000000000000000000000 --- a/app/code/Magento/Log/view/adminhtml/templates/customer/status.phtml +++ /dev/null @@ -1,25 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -// @codingStandardsIgnoreFile - -/** - * Template for block \Magento\Log\Block\Adminhtml\Customer\Edit\Tab\View\Status - */ - -$lastLoginDateAdmin = $block->getLastLoginDate(); -$lastLoginDateStore = $block->getStoreLastLoginDate(); -?> -<tr> - <th><?php echo __('Last Logged In:') ?></th> - <td><?php echo $lastLoginDateAdmin ?> (<?php echo $block->getCurrentStatus() ?>)</td> -</tr> -<?php if ($lastLoginDateAdmin != $lastLoginDateStore): ?> -<tr> - <th><?php echo __('Last Logged In (%1):', $block->getStoreLastLoginDateTimezone()) ?></th> - <td><?php echo $lastLoginDateStore ?> (<?php echo $block->getCurrentStatus() ?>)</td> -</tr> -<?php endif; ?> diff --git a/app/code/Magento/MediaStorage/Controller/Adminhtml/System/Config/System/Storage/Status.php b/app/code/Magento/MediaStorage/Controller/Adminhtml/System/Config/System/Storage/Status.php index 56ad4ad93c8ec7033626be3cd35e671952915563..527a932ee63ea47bb473fb4cd48c21dd84eaaa11 100644 --- a/app/code/Magento/MediaStorage/Controller/Adminhtml/System/Config/System/Storage/Status.php +++ b/app/code/Magento/MediaStorage/Controller/Adminhtml/System/Config/System/Storage/Status.php @@ -9,17 +9,17 @@ namespace Magento\MediaStorage\Controller\Adminhtml\System\Config\System\Storage class Status extends \Magento\MediaStorage\Controller\Adminhtml\System\Config\System\Storage { /** - * @var \Magento\Framework\Controller\Result\JSONFactory + * @var \Magento\Framework\Controller\Result\JsonFactory */ protected $resultJsonFactory; /** * @param \Magento\Backend\App\Action\Context $context - * @param \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory + * @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory */ public function __construct( \Magento\Backend\App\Action\Context $context, - \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory + \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory ) { parent::__construct($context); $this->resultJsonFactory = $resultJsonFactory; @@ -28,7 +28,7 @@ class Status extends \Magento\MediaStorage\Controller\Adminhtml\System\Config\Sy /** * Retrieve synchronize process state and it's parameters in json format * - * @return \Magento\Framework\Controller\Result\JSON + * @return \Magento\Framework\Controller\Result\Json * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ public function execute() @@ -111,7 +111,7 @@ class Status extends \Magento\MediaStorage\Controller\Adminhtml\System\Config\Sy $state = \Magento\MediaStorage\Model\File\Storage\Flag::STATE_INACTIVE; } $result['state'] = $state; - /** @var \Magento\Framework\Controller\Result\JSON $resultJson */ + /** @var \Magento\Framework\Controller\Result\Json $resultJson */ $resultJson = $this->resultJsonFactory->create(); return $resultJson->setData($result); } diff --git a/app/code/Magento/Core/LICENSE.txt b/app/code/Magento/MediaStorage/LICENSE.txt similarity index 100% rename from app/code/Magento/Core/LICENSE.txt rename to app/code/Magento/MediaStorage/LICENSE.txt diff --git a/app/code/Magento/Core/LICENSE_AFL.txt b/app/code/Magento/MediaStorage/LICENSE_AFL.txt similarity index 100% rename from app/code/Magento/Core/LICENSE_AFL.txt rename to app/code/Magento/MediaStorage/LICENSE_AFL.txt diff --git a/app/code/Magento/MediaStorage/Test/Unit/Model/File/Storage/_files/config.xml b/app/code/Magento/MediaStorage/Test/Unit/Model/File/Storage/_files/config.xml index beb583cb58d9941ab51927d7f124495d0547f07c..4cffed1a1cc9e003d9a125797275c1787eca1afc 100644 --- a/app/code/Magento/MediaStorage/Test/Unit/Model/File/Storage/_files/config.xml +++ b/app/code/Magento/MediaStorage/Test/Unit/Model/File/Storage/_files/config.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../../../../app/code/Magento/Core/etc/config.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../../../../app/code/Magento/Store/etc/config.xsd"> <default> <resources> <fixture_module_setup> diff --git a/app/code/Magento/MediaStorage/composer.json b/app/code/Magento/MediaStorage/composer.json index bfd1965a73ff2009fb06f04efa3d4d43a4620706..ccc5a944717a31326fcdcb7af0248c7781ab14ce 100644 --- a/app/code/Magento/MediaStorage/composer.json +++ b/app/code/Magento/MediaStorage/composer.json @@ -5,7 +5,6 @@ "php": "~5.5.0|~5.6.0", "magento/module-store": "0.42.0-beta11", "magento/module-backend": "0.42.0-beta11", - "magento/module-core": "0.42.0-beta11", "magento/module-config": "0.42.0-beta11", "magento/framework": "0.42.0-beta11", "magento/magento-composer-installer": "*" diff --git a/app/code/Magento/MediaStorage/i18n/de_DE.csv b/app/code/Magento/MediaStorage/i18n/de_DE.csv new file mode 100644 index 0000000000000000000000000000000000000000..7cfc4ae6c12b63ecc839587142d3f9d8c6c9f8f6 --- /dev/null +++ b/app/code/Magento/MediaStorage/i18n/de_DE.csv @@ -0,0 +1,10 @@ +"Requested resource not found","Requested resource not found" +"File %1 does not exist","File %1 does not exist" +"File %1 is not readable","File %1 is not readable" +"Parent directory does not exist: %1","Parent directory does not exist: %1" +"File system",Dateisystem +"Unable to save file ""%1"" at ""%2""","Unable to save file ""%1"" at ""%2""" +"Wrong file info format","Falsches Format Dateiinfo" +"Please set available and/or protected paths list(s) before validation.","Bitte stellen Sie vor der Bestätigung die Liste(n) der verfügbaren und/oder geschützten Pfade ein." +"Unable to create directory: %1","Unable to create directory: %1" +"Unable to save file: %1","Unable to save file: %1" diff --git a/app/code/Magento/MediaStorage/i18n/en_US.csv b/app/code/Magento/MediaStorage/i18n/en_US.csv new file mode 100644 index 0000000000000000000000000000000000000000..b5cc34a4d49630ed633b764052b2d4e443bb615e --- /dev/null +++ b/app/code/Magento/MediaStorage/i18n/en_US.csv @@ -0,0 +1,10 @@ +"Requested resource not found","Requested resource not found" +"File %1 does not exist","File %1 does not exist" +"File %1 is not readable","File %1 is not readable" +"Parent directory does not exist: %1","Parent directory does not exist: %1" +"File system","File system" +"Unable to save file ""%1"" at ""%2""","Unable to save file ""%1"" at ""%2""" +"Wrong file info format","Wrong file info format" +"Please set available and/or protected paths list(s) before validation.","Please set available and/or protected paths list(s) before validation." +"Unable to create directory: %1","Unable to create directory: %1" +"Unable to save file: %1","Unable to save file: %1" diff --git a/app/code/Magento/MediaStorage/i18n/es_ES.csv b/app/code/Magento/MediaStorage/i18n/es_ES.csv new file mode 100644 index 0000000000000000000000000000000000000000..0ad1da242f2a656889e6444a114fb019844bd88f --- /dev/null +++ b/app/code/Magento/MediaStorage/i18n/es_ES.csv @@ -0,0 +1,10 @@ +"Requested resource not found","Requested resource not found" +"File %1 does not exist","File %1 does not exist" +"File %1 is not readable","File %1 is not readable" +"Parent directory does not exist: %1","Parent directory does not exist: %1" +"File system","Sistema de archivos" +"Unable to save file ""%1"" at ""%2""","Unable to save file ""%1"" at ""%2""" +"Wrong file info format","Formato de información del archivo incorrecto" +"Please set available and/or protected paths list(s) before validation.","Por favor, indique la(s) lista(s) de rutas disponibles y/o protegidas antes de la validación." +"Unable to create directory: %1","Unable to create directory: %1" +"Unable to save file: %1","Unable to save file: %1" diff --git a/app/code/Magento/MediaStorage/i18n/fr_FR.csv b/app/code/Magento/MediaStorage/i18n/fr_FR.csv new file mode 100644 index 0000000000000000000000000000000000000000..0d2d7dab58b82227c16c77ffbf4bee0805edb2e9 --- /dev/null +++ b/app/code/Magento/MediaStorage/i18n/fr_FR.csv @@ -0,0 +1,10 @@ +"Requested resource not found","Requested resource not found" +"File %1 does not exist","File %1 does not exist" +"File %1 is not readable","File %1 is not readable" +"Parent directory does not exist: %1","Parent directory does not exist: %1" +"File system","Système de fichiers" +"Unable to save file ""%1"" at ""%2""","Unable to save file ""%1"" at ""%2""" +"Wrong file info format","Informations du format de fichiers incorrectes" +"Please set available and/or protected paths list(s) before validation.","Veuillez définir la/les liste(s) de chemins disponibles et/ou protégés avant la validation." +"Unable to create directory: %1","Unable to create directory: %1" +"Unable to save file: %1","Unable to save file: %1" diff --git a/app/code/Magento/MediaStorage/i18n/nl_NL.csv b/app/code/Magento/MediaStorage/i18n/nl_NL.csv new file mode 100644 index 0000000000000000000000000000000000000000..abedda328cd459219fe19ec933cbaebc8d7115bd --- /dev/null +++ b/app/code/Magento/MediaStorage/i18n/nl_NL.csv @@ -0,0 +1,10 @@ +"Requested resource not found","Requested resource not found" +"File %1 does not exist","File %1 does not exist" +"File %1 is not readable","File %1 is not readable" +"Parent directory does not exist: %1","Parent directory does not exist: %1" +"File system",Bestandssysteem +"Unable to save file ""%1"" at ""%2""","Unable to save file ""%1"" at ""%2""" +"Wrong file info format","Verkeerde bestandsinformatiebestand" +"Please set available and/or protected paths list(s) before validation.","Stel beschikbare en/of beschermde pad lijst(en) in voor validatie." +"Unable to create directory: %1","Unable to create directory: %1" +"Unable to save file: %1","Unable to save file: %1" diff --git a/app/code/Magento/MediaStorage/i18n/pt_BR.csv b/app/code/Magento/MediaStorage/i18n/pt_BR.csv new file mode 100644 index 0000000000000000000000000000000000000000..d9022058d08f66c809ffd2c697aff9cea6bf7e56 --- /dev/null +++ b/app/code/Magento/MediaStorage/i18n/pt_BR.csv @@ -0,0 +1,10 @@ +"Requested resource not found","Requested resource not found" +"File %1 does not exist","File %1 does not exist" +"File %1 is not readable","File %1 is not readable" +"Parent directory does not exist: %1","Parent directory does not exist: %1" +"File system","Sistema de arquivo" +"Unable to save file ""%1"" at ""%2""","Unable to save file ""%1"" at ""%2""" +"Wrong file info format","Formato de arquivo de informação errado" +"Please set available and/or protected paths list(s) before validation.","Por favor defina lista(s) de caminhos disponÃveis e/ou protegidos antes da validação." +"Unable to create directory: %1","Unable to create directory: %1" +"Unable to save file: %1","Unable to save file: %1" diff --git a/app/code/Magento/MediaStorage/i18n/zh_CN.csv b/app/code/Magento/MediaStorage/i18n/zh_CN.csv new file mode 100644 index 0000000000000000000000000000000000000000..c0847a9f4600e53e9662f2b682a52efa1b48d1f1 --- /dev/null +++ b/app/code/Magento/MediaStorage/i18n/zh_CN.csv @@ -0,0 +1,10 @@ +"Requested resource not found","Requested resource not found" +"File %1 does not exist","File %1 does not exist" +"File %1 is not readable","File %1 is not readable" +"Parent directory does not exist: %1","Parent directory does not exist: %1" +"File system",文件系统 +"Unable to save file ""%1"" at ""%2""","Unable to save file ""%1"" at ""%2""" +"Wrong file info format",é”™è¯¯çš„æ–‡ä»¶ä¿¡æ¯æ ¼å¼ +"Please set available and/or protected paths list(s) before validation.",请设置有效并/或å—ä¿æŠ¤çš„è·¯å¾„åˆ—è¡¨ï¼ŒéšåŽå†éªŒè¯ã€‚ +"Unable to create directory: %1","Unable to create directory: %1" +"Unable to save file: %1","Unable to save file: %1" diff --git a/app/code/Magento/Msrp/etc/config.xml b/app/code/Magento/Msrp/etc/config.xml index e0a72f95dab6a9f8cf3dff985f3561407f87a41d..dd50e9de8178b9fb198156ab16074b9eede44a8f 100644 --- a/app/code/Magento/Msrp/etc/config.xml +++ b/app/code/Magento/Msrp/etc/config.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Core/etc/config.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Store/etc/config.xsd"> <default> <sales> <msrp> diff --git a/app/code/Magento/Multishipping/Model/Checkout/Type/Multishipping/Plugin.php b/app/code/Magento/Multishipping/Model/Checkout/Type/Multishipping/Plugin.php index fb09bbfca7410a68c6ea4b2395792af9c6dfd3b7..d0fe99eda0571a212c1c5657dbba5721a3b8d8c6 100644 --- a/app/code/Magento/Multishipping/Model/Checkout/Type/Multishipping/Plugin.php +++ b/app/code/Magento/Multishipping/Model/Checkout/Type/Multishipping/Plugin.php @@ -31,7 +31,7 @@ class Plugin * @return void * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function beforeInit(\Magento\Checkout\Model\Cart $subject) + public function beforeSave(\Magento\Checkout\Model\Cart $subject) { if ($this->checkoutSession->getCheckoutState() === State::STEP_SELECT_ADDRESSES) { $this->checkoutSession->setCheckoutState(\Magento\Checkout\Model\Session::CHECKOUT_STATE_BEGIN); diff --git a/app/code/Magento/Multishipping/Test/Unit/Model/Checkout/Type/Multishipping/PluginTest.php b/app/code/Magento/Multishipping/Test/Unit/Model/Checkout/Type/Multishipping/PluginTest.php index 10f158e0e893817f76c1b1e637054a70957895d0..a0eea6088d081f56dc27ae3c79fcda9e06def353 100644 --- a/app/code/Magento/Multishipping/Test/Unit/Model/Checkout/Type/Multishipping/PluginTest.php +++ b/app/code/Magento/Multishipping/Test/Unit/Model/Checkout/Type/Multishipping/PluginTest.php @@ -44,7 +44,7 @@ class PluginTest extends \PHPUnit_Framework_TestCase ->willReturn(State::STEP_SELECT_ADDRESSES); $this->checkoutSessionMock->expects($this->once())->method('setCheckoutState') ->with(Session::CHECKOUT_STATE_BEGIN); - $this->model->beforeInit($this->cartMock); + $this->model->beforeSave($this->cartMock); } public function testBeforeInitCaseFalse() @@ -52,6 +52,6 @@ class PluginTest extends \PHPUnit_Framework_TestCase $this->checkoutSessionMock->expects($this->once())->method('getCheckoutState') ->willReturn(''); $this->checkoutSessionMock->expects($this->never())->method('setCheckoutState'); - $this->model->beforeInit($this->cartMock); + $this->model->beforeSave($this->cartMock); } } diff --git a/app/code/Magento/Multishipping/etc/config.xml b/app/code/Magento/Multishipping/etc/config.xml index 76621b4a03bff0de66ee39c828fbb18e6feabce5..c08c0590401b67429190c650e3ae3f80a9d728f7 100644 --- a/app/code/Magento/Multishipping/etc/config.xml +++ b/app/code/Magento/Multishipping/etc/config.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Core/etc/config.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Store/etc/config.xsd"> <default> <multishipping> <options> diff --git a/app/code/Magento/Multishipping/etc/frontend/page_types.xml b/app/code/Magento/Multishipping/etc/frontend/page_types.xml index 11be8441bb63b38b3ba5fc75319e8b988f241ab3..f58e8c5bb6a69f2c9d05fb543fd08eec5f1fd284 100644 --- a/app/code/Magento/Multishipping/etc/frontend/page_types.xml +++ b/app/code/Magento/Multishipping/etc/frontend/page_types.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> -<page_types xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../Core/etc/page_types.xsd"> +<page_types xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_types.xsd"> <type id="checkout_cart_multishipping" label="Catalog Quick Search Form Suggestions"/> <type id="checkout_cart_multishipping_address_editaddress" label="Multishipping Checkout One Address Edit Form"/> <type id="checkout_cart_multishipping_address_editbilling" label="Multishipping Checkout Billing Address Edit Form"/> diff --git a/app/code/Magento/Multishipping/etc/module.xml b/app/code/Magento/Multishipping/etc/module.xml index 3ea0ac29db5ebb261f3a9dd4a7d17704bac1acfc..b6ea0b6ce80cad9020365e8fc77bfe09629ddbb9 100644 --- a/app/code/Magento/Multishipping/etc/module.xml +++ b/app/code/Magento/Multishipping/etc/module.xml @@ -8,7 +8,6 @@ <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd"> <module name="Magento_Multishipping" setup_version="2.0.0.0"> <sequence> - <module name="Magento_Core"/> <module name="Magento_Store"/> <module name="Magento_Catalog"/> </sequence> diff --git a/app/code/Magento/Multishipping/view/frontend/layout/multishipping_checkout_overview.xml b/app/code/Magento/Multishipping/view/frontend/layout/multishipping_checkout_overview.xml index b71e35b9b4c706d22a15c6ae0e40b994c2a253b7..8ea4f26cae9086940879b09517d88a63951acce2 100644 --- a/app/code/Magento/Multishipping/view/frontend/layout/multishipping_checkout_overview.xml +++ b/app/code/Magento/Multishipping/view/frontend/layout/multishipping_checkout_overview.xml @@ -15,7 +15,7 @@ </action> </referenceBlock> <referenceContainer name="content"> - <block class="Magento\Multishipping\Block\Checkout\Overview" name="checkout_overview" template="checkout/overview.phtml"> + <block class="Magento\Multishipping\Block\Checkout\Overview" name="checkout_overview" template="checkout/overview.phtml" cacheable="false"> <arguments> <argument name="renderer_template" xsi:type="string">Magento_Multishipping::checkout/item/default.phtml</argument> <argument name="row_renderer_template" xsi:type="string">Magento_Multishipping::checkout/overview/item.phtml</argument> diff --git a/app/code/Magento/Newsletter/Block/Subscribe.php b/app/code/Magento/Newsletter/Block/Subscribe.php index 66ecb517455a96c3c46816e9b789144587d67b3e..ae9549930d6b67849ffa9b0079b513622c1db053 100644 --- a/app/code/Magento/Newsletter/Block/Subscribe.php +++ b/app/code/Magento/Newsletter/Block/Subscribe.php @@ -13,48 +13,6 @@ namespace Magento\Newsletter\Block; class Subscribe extends \Magento\Framework\View\Element\Template { - /** - * Newsletter session - * - * @var \Magento\Newsletter\Model\Session - */ - protected $_newsletterSession; - - /** - * @param \Magento\Framework\View\Element\Template\Context $context - * @param \Magento\Newsletter\Model\Session $newsletterSession - * @param array $data - */ - public function __construct( - \Magento\Framework\View\Element\Template\Context $context, - \Magento\Newsletter\Model\Session $newsletterSession, - array $data = [] - ) { - parent::__construct($context, $data); - $this->_newsletterSession = $newsletterSession; - $this->_isScopePrivate = true; - } - - /** - * Get success message - * - * @return string - */ - public function getSuccessMessage() - { - return $this->_newsletterSession->getSuccess(); - } - - /** - * Get error message - * - * @return string - */ - public function getErrorMessage() - { - return $this->_newsletterSession->getError(); - } - /** * Retrieve form action url and set "secure" param to avoid confirm * message when we submit form from secure page to unsecure diff --git a/app/code/Magento/Newsletter/Controller/Subscriber/NewAction.php b/app/code/Magento/Newsletter/Controller/Subscriber/NewAction.php index 09a65144fe469a9952d2825d50bf8df74c96e814..5e8850de308daea3b0c9c4b114744a1412318e97 100644 --- a/app/code/Magento/Newsletter/Controller/Subscriber/NewAction.php +++ b/app/code/Magento/Newsletter/Controller/Subscriber/NewAction.php @@ -84,8 +84,7 @@ class NewAction extends \Magento\Newsletter\Controller\Subscriber ) { throw new \Magento\Framework\Exception\LocalizedException( __( - 'Sorry, but the administrator denied subscription for guests. ' - . 'Please <a href="%1">register</a>.', + 'Sorry, but the administrator denied subscription for guests. Please <a href="%1">register</a>.', $this->_customerUrl->getRegisterUrl() ) ); diff --git a/app/code/Magento/Newsletter/Model/Template.php b/app/code/Magento/Newsletter/Model/Template.php index a417f55fc79d5a47ea6bfc08a523c16daa0e4053..9f2dc723b155c0da2015d5cae3d906f5069ec660 100644 --- a/app/code/Magento/Newsletter/Model/Template.php +++ b/app/code/Magento/Newsletter/Model/Template.php @@ -168,7 +168,7 @@ class Template extends \Magento\Email\Model\AbstractTemplate } } - throw new \Magento\Framework\Exception\LocalizedException(join("\n", $errorMessages)); + throw new \Magento\Framework\Exception\LocalizedException(__(join("\n", $errorMessages))); } } diff --git a/app/code/Magento/Newsletter/Test/Unit/Controller/Manage/SaveTest.php b/app/code/Magento/Newsletter/Test/Unit/Controller/Manage/SaveTest.php index 1042abf6c82f0de6983286fe2b6ed8b0030a3feb..f592aafcbc9c269a47e716130dd693af76f8e338 100644 --- a/app/code/Magento/Newsletter/Test/Unit/Controller/Manage/SaveTest.php +++ b/app/code/Magento/Newsletter/Test/Unit/Controller/Manage/SaveTest.php @@ -141,8 +141,10 @@ class SaveTest extends \PHPUnit_Framework_TestCase ->method('getById') ->will($this->throwException( new NoSuchEntityException( - NoSuchEntityException::MESSAGE_SINGLE_FIELD, - ['fieldName' => 'customerId', 'value' => 'value'] + __( + NoSuchEntityException::MESSAGE_SINGLE_FIELD, + ['fieldName' => 'customerId', 'value' => 'value'] + ) ) ) ); diff --git a/app/code/Magento/Newsletter/etc/config.xml b/app/code/Magento/Newsletter/etc/config.xml index 1ee0d4f45b4dbc1eb4560a5d34128003dd4b30ec..92b70813d46942884b7a4a55c7c69627612fef32 100644 --- a/app/code/Magento/Newsletter/etc/config.xml +++ b/app/code/Magento/Newsletter/etc/config.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Core/etc/config.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Store/etc/config.xsd"> <default> <newsletter> <subscription> diff --git a/app/code/Magento/Newsletter/etc/frontend/page_types.xml b/app/code/Magento/Newsletter/etc/frontend/page_types.xml index 39889513a5efc5bd26ece50a48f04713cd008cfc..f6976324e9a862bec0d095ce8ada89ced4ee086f 100644 --- a/app/code/Magento/Newsletter/etc/frontend/page_types.xml +++ b/app/code/Magento/Newsletter/etc/frontend/page_types.xml @@ -5,6 +5,6 @@ * See COPYING.txt for license details. */ --> -<page_types xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../Core/etc/page_types.xsd"> +<page_types xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_types.xsd"> <type id="newsletter_manage_index" label="Customer My Account Newsletter Subscriptions"/> </page_types> diff --git a/app/code/Magento/Newsletter/etc/module.xml b/app/code/Magento/Newsletter/etc/module.xml index 13a4697cc7900c7ff670756ad6768ca439988b36..7d5356b547755df7fd21858f504d8208d1339fd8 100644 --- a/app/code/Magento/Newsletter/etc/module.xml +++ b/app/code/Magento/Newsletter/etc/module.xml @@ -8,7 +8,6 @@ <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd"> <module name="Magento_Newsletter" setup_version="2.0.0"> <sequence> - <module name="Magento_Core"/> <module name="Magento_Store"/> <module name="Magento_Customer"/> <module name="Magento_Eav"/> diff --git a/app/code/Magento/OfflinePayments/Model/Banktransfer.php b/app/code/Magento/OfflinePayments/Model/Banktransfer.php index 4cc48a575272039644fe0c1211c4172249647f60..9eee92e1e2478a960e71e599bc4d78bea4d97334 100644 --- a/app/code/Magento/OfflinePayments/Model/Banktransfer.php +++ b/app/code/Magento/OfflinePayments/Model/Banktransfer.php @@ -7,6 +7,8 @@ namespace Magento\OfflinePayments\Model; /** * Bank Transfer payment method model + * + * @method \Magento\Quote\Api\Data\PaymentMethodExtensionInterface getExtensionAttributes() */ class Banktransfer extends \Magento\Payment\Model\Method\AbstractMethod { diff --git a/app/code/Magento/OfflinePayments/Model/Cashondelivery.php b/app/code/Magento/OfflinePayments/Model/Cashondelivery.php index c1a125463d926cf328e42fb4b9c43b9102112430..06f2862acd07e6e7ed30da8a1dd3351e639014d8 100644 --- a/app/code/Magento/OfflinePayments/Model/Cashondelivery.php +++ b/app/code/Magento/OfflinePayments/Model/Cashondelivery.php @@ -7,6 +7,8 @@ namespace Magento\OfflinePayments\Model; /** * Cash on delivery payment method model + * + * @method \Magento\Quote\Api\Data\PaymentMethodExtensionInterface getExtensionAttributes() */ class Cashondelivery extends \Magento\Payment\Model\Method\AbstractMethod { diff --git a/app/code/Magento/OfflinePayments/Model/Checkmo.php b/app/code/Magento/OfflinePayments/Model/Checkmo.php index 2de8ab28e97bc2e099d3579e75965cb49726fbd3..e282b502979df74feecf1ffc6a6509e7de651a71 100644 --- a/app/code/Magento/OfflinePayments/Model/Checkmo.php +++ b/app/code/Magento/OfflinePayments/Model/Checkmo.php @@ -5,6 +5,11 @@ */ namespace Magento\OfflinePayments\Model; +/** + * Class Checkmo + * + * @method \Magento\Quote\Api\Data\PaymentMethodExtensionInterface getExtensionAttributes() + */ class Checkmo extends \Magento\Payment\Model\Method\AbstractMethod { /** diff --git a/app/code/Magento/OfflinePayments/Model/Purchaseorder.php b/app/code/Magento/OfflinePayments/Model/Purchaseorder.php index 180ec57133db7e6eadf0964a33cea8797fd60eca..3a4aa15d089031bbb5aafd87523d4bba1999516f 100644 --- a/app/code/Magento/OfflinePayments/Model/Purchaseorder.php +++ b/app/code/Magento/OfflinePayments/Model/Purchaseorder.php @@ -5,6 +5,11 @@ */ namespace Magento\OfflinePayments\Model; +/** + * Class Purchaseorder + * + * @method \Magento\Quote\Api\Data\PaymentMethodExtensionInterface getExtensionAttributes() + */ class Purchaseorder extends \Magento\Payment\Model\Method\AbstractMethod { /** diff --git a/app/code/Magento/OfflinePayments/etc/config.xml b/app/code/Magento/OfflinePayments/etc/config.xml index 3aac1bcdd6ca892ca4fa3c7a4f766f22963f84e6..67b15cb57e22d428d611630b43dd3fbf39af3c83 100644 --- a/app/code/Magento/OfflinePayments/etc/config.xml +++ b/app/code/Magento/OfflinePayments/etc/config.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Core/etc/config.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Store/etc/config.xsd"> <default> <payment> <checkmo> diff --git a/app/code/Magento/OfflinePayments/etc/module.xml b/app/code/Magento/OfflinePayments/etc/module.xml index e458b0120953520956ab910a5e7a0ad7f49b54b6..c6cc2bf889da1d50dd65d60f2205c291d3f94b8d 100644 --- a/app/code/Magento/OfflinePayments/etc/module.xml +++ b/app/code/Magento/OfflinePayments/etc/module.xml @@ -8,7 +8,6 @@ <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd"> <module name="Magento_OfflinePayments" setup_version="2.0.0"> <sequence> - <module name="Magento_Core"/> <module name="Magento_Store"/> <module name="Magento_Catalog"/> </sequence> diff --git a/app/code/Magento/OfflineShipping/Model/Resource/Carrier/Tablerate.php b/app/code/Magento/OfflineShipping/Model/Resource/Carrier/Tablerate.php index c505620b5ff5f4b1869c1ddaae16b25346727a6b..ef18f302791d625c3fbd3be3ed516d461ae389af 100644 --- a/app/code/Magento/OfflineShipping/Model/Resource/Carrier/Tablerate.php +++ b/app/code/Magento/OfflineShipping/Model/Resource/Carrier/Tablerate.php @@ -321,7 +321,7 @@ class Tablerate extends \Magento\Framework\Model\Resource\Db\AbstractDb } catch (\Magento\Framework\Exception\LocalizedException $e) { $adapter->rollback(); $stream->close(); - throw new \Magento\Framework\Exception\LocalizedException($e->getMessage()); + throw new \Magento\Framework\Exception\LocalizedException(__($e->getMessage())); } catch (\Exception $e) { $adapter->rollback(); $stream->close(); diff --git a/app/code/Magento/OfflineShipping/etc/config.xml b/app/code/Magento/OfflineShipping/etc/config.xml index e10269983be960658e0244257c2e3a513dfe1434..09dd89a88e3aa8da935ca5297094b58f1b67ee05 100644 --- a/app/code/Magento/OfflineShipping/etc/config.xml +++ b/app/code/Magento/OfflineShipping/etc/config.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Core/etc/config.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Store/etc/config.xsd"> <default> <carriers> <flatrate> diff --git a/app/code/Magento/PageCache/etc/config.xml b/app/code/Magento/PageCache/etc/config.xml index 8bb6fd48f64a1ef1e00e1400ac914a63cb11d3c2..a1530794673bb554448856fb64d4346d5a44c40b 100644 --- a/app/code/Magento/PageCache/etc/config.xml +++ b/app/code/Magento/PageCache/etc/config.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Core/etc/config.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Store/etc/config.xsd"> <default> <system> <full_page_cache> diff --git a/app/code/Magento/PageCache/etc/module.xml b/app/code/Magento/PageCache/etc/module.xml index 27fb178b409af4f29751c943930b30bd3edaac66..bd152d0a9e584b886647f50874c10a515eccd8d6 100644 --- a/app/code/Magento/PageCache/etc/module.xml +++ b/app/code/Magento/PageCache/etc/module.xml @@ -8,7 +8,6 @@ <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd"> <module name="Magento_PageCache" setup_version="1.6.0.0"> <sequence> - <module name="Magento_Core"/> <module name="Magento_Store"/> </sequence> </module> diff --git a/app/code/Magento/Payment/Model/Info.php b/app/code/Magento/Payment/Model/Info.php index f00d9117f4f5792fbc69b4236c278889e47f9cb6..0fd732033538183850c40b55d5bf32f233362def 100644 --- a/app/code/Magento/Payment/Model/Info.php +++ b/app/code/Magento/Payment/Model/Info.php @@ -5,7 +5,6 @@ */ namespace Magento\Payment\Model; -use Magento\Framework\Api\AttributeValueFactory; use Magento\Framework\Model\AbstractExtensibleModel; /** @@ -35,8 +34,8 @@ class Info extends AbstractExtensibleModel /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry - * @param \Magento\Framework\Api\MetadataServiceInterface $metadataService - * @param AttributeValueFactory $customAttributeFactory + * @param \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory + * @param \Magento\Framework\Api\AttributeValueFactory $customAttributeFactory, * @param \Magento\Payment\Helper\Data $paymentData * @param \Magento\Framework\Encryption\EncryptorInterface $encryptor * @param \Magento\Framework\Model\Resource\AbstractResource $resource @@ -46,8 +45,8 @@ class Info extends AbstractExtensibleModel public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, - \Magento\Framework\Api\MetadataServiceInterface $metadataService, - AttributeValueFactory $customAttributeFactory, + \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory, + \Magento\Framework\Api\AttributeValueFactory $customAttributeFactory, \Magento\Payment\Helper\Data $paymentData, \Magento\Framework\Encryption\EncryptorInterface $encryptor, \Magento\Framework\Model\Resource\AbstractResource $resource = null, @@ -59,7 +58,7 @@ class Info extends AbstractExtensibleModel parent::__construct( $context, $registry, - $metadataService, + $extensionFactory, $customAttributeFactory, $resource, $resourceCollection, diff --git a/app/code/Magento/Payment/Model/Method/AbstractMethod.php b/app/code/Magento/Payment/Model/Method/AbstractMethod.php index fa331dd477414a2113dceee2ed2a447f2c7c8a07..926017b8bcce80f53a492ad3cb6849d4cbc2d2eb 100644 --- a/app/code/Magento/Payment/Model/Method/AbstractMethod.php +++ b/app/code/Magento/Payment/Model/Method/AbstractMethod.php @@ -222,7 +222,7 @@ abstract class AbstractMethod extends \Magento\Framework\Model\AbstractExtensibl /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry - * @param \Magento\Framework\Api\MetadataServiceInterface $metadataService + * @param \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory * @param \Magento\Framework\Api\AttributeValueFactory $customAttributeFactory * @param \Magento\Payment\Helper\Data $paymentData * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig @@ -233,7 +233,7 @@ abstract class AbstractMethod extends \Magento\Framework\Model\AbstractExtensibl public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, - \Magento\Framework\Api\MetadataServiceInterface $metadataService, + \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory, \Magento\Framework\Api\AttributeValueFactory $customAttributeFactory, \Magento\Payment\Helper\Data $paymentData, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, @@ -244,7 +244,7 @@ abstract class AbstractMethod extends \Magento\Framework\Model\AbstractExtensibl parent::__construct( $context, $registry, - $metadataService, + $extensionFactory, $customAttributeFactory, $resource, $resourceCollection, @@ -848,4 +848,25 @@ abstract class AbstractMethod extends \Magento\Framework\Model\AbstractExtensibl { $this->_debug($debugData); } + + /** + * {@inheritdoc} + * + * @return \Magento\Quote\Api\Data\PaymentMethodExtensionInterface|null + */ + public function getExtensionAttributes() + { + return $this->_getExtensionAttributes(); + } + + /** + * {@inheritdoc} + * + * @param \Magento\Quote\Api\Data\PaymentMethodExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes(\Magento\Quote\Api\Data\PaymentMethodExtensionInterface $extensionAttributes) + { + return $this->_setExtensionAttributes($extensionAttributes); + } } diff --git a/app/code/Magento/Payment/Model/Method/Cc.php b/app/code/Magento/Payment/Model/Method/Cc.php index 23e7dfda59a9b40a4da2e115d01deb1ff1017307..8fdec55da4492bdcbe1c38fd2c3587bcf4a830eb 100644 --- a/app/code/Magento/Payment/Model/Method/Cc.php +++ b/app/code/Magento/Payment/Model/Method/Cc.php @@ -6,6 +6,7 @@ namespace Magento\Payment\Model\Method; /** + * @method \Magento\Quote\Api\Data\PaymentMethodExtensionInterface getExtensionAttributes() * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class Cc extends \Magento\Payment\Model\Method\AbstractMethod @@ -45,7 +46,7 @@ class Cc extends \Magento\Payment\Model\Method\AbstractMethod /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry - * @param \Magento\Framework\Api\MetadataServiceInterface $metadataService + * @param \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory * @param \Magento\Framework\Api\AttributeValueFactory $customAttributeFactory * @param \Magento\Payment\Helper\Data $paymentData * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig @@ -60,7 +61,7 @@ class Cc extends \Magento\Payment\Model\Method\AbstractMethod public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, - \Magento\Framework\Api\MetadataServiceInterface $metadataService, + \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory, \Magento\Framework\Api\AttributeValueFactory $customAttributeFactory, \Magento\Payment\Helper\Data $paymentData, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, @@ -74,7 +75,7 @@ class Cc extends \Magento\Payment\Model\Method\AbstractMethod parent::__construct( $context, $registry, - $metadataService, + $extensionFactory, $customAttributeFactory, $paymentData, $scopeConfig, diff --git a/app/code/Magento/Payment/Model/Method/Factory.php b/app/code/Magento/Payment/Model/Method/Factory.php index 590bb7a7b08cbc0476e2ed29e5619e360295b5ce..c5be7dd97cba2662e9f6d55b11c1f96f34f41a26 100644 --- a/app/code/Magento/Payment/Model/Method/Factory.php +++ b/app/code/Magento/Payment/Model/Method/Factory.php @@ -40,7 +40,7 @@ class Factory $method = $this->_objectManager->create($className, $data); if (!$method instanceof \Magento\Payment\Model\MethodInterface) { throw new \Magento\Framework\Exception\LocalizedException( - sprintf("%s class doesn't implement \Magento\Payment\Model\MethodInterface", $className) + __('%1 class doesn\'t implement \Magento\Payment\Model\MethodInterface', $className) ); } return $method; diff --git a/app/code/Magento/Payment/Model/Method/Free.php b/app/code/Magento/Payment/Model/Method/Free.php index 00c4145d7ba58687e1361b1d109a2645c79775c4..3793669383195a50c582674ed89ce19c634f6e82 100644 --- a/app/code/Magento/Payment/Model/Method/Free.php +++ b/app/code/Magento/Payment/Model/Method/Free.php @@ -9,6 +9,7 @@ use Magento\Framework\Pricing\PriceCurrencyInterface; /** * Free payment method + * @method \Magento\Quote\Api\Data\PaymentMethodExtensionInterface getExtensionAttributes() */ class Free extends \Magento\Payment\Model\Method\AbstractMethod { @@ -43,7 +44,7 @@ class Free extends \Magento\Payment\Model\Method\AbstractMethod /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry - * @param \Magento\Framework\Api\MetadataServiceInterface $metadataService + * @param \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory * @param \Magento\Framework\Api\AttributeValueFactory $customAttributeFactory * @param \Magento\Payment\Helper\Data $paymentData * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig @@ -56,7 +57,7 @@ class Free extends \Magento\Payment\Model\Method\AbstractMethod public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, - \Magento\Framework\Api\MetadataServiceInterface $metadataService, + \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory, \Magento\Framework\Api\AttributeValueFactory $customAttributeFactory, \Magento\Payment\Helper\Data $paymentData, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, @@ -68,7 +69,7 @@ class Free extends \Magento\Payment\Model\Method\AbstractMethod parent::__construct( $context, $registry, - $metadataService, + $extensionFactory, $customAttributeFactory, $paymentData, $scopeConfig, diff --git a/app/code/Magento/Payment/Model/Method/Substitution.php b/app/code/Magento/Payment/Model/Method/Substitution.php index 98563e5092d778de27d06e54b523c7e5753bf216..819ecc267d130dee4be334565a961cb5a8184d9d 100644 --- a/app/code/Magento/Payment/Model/Method/Substitution.php +++ b/app/code/Magento/Payment/Model/Method/Substitution.php @@ -8,6 +8,8 @@ namespace Magento\Payment\Model\Method; /** * Substitution payment method for non-existing payments + * + * @method \Magento\Quote\Api\Data\PaymentMethodExtensionInterface getExtensionAttributes() */ class Substitution extends AbstractMethod { diff --git a/app/code/Magento/Payment/Test/Unit/Model/Method/FreeTest.php b/app/code/Magento/Payment/Test/Unit/Model/Method/FreeTest.php index 064beb8b5428e3468b0c12a64e5652412d8d49ef..9976a46c96dee56bd06824421b160a98ef2e91e2 100644 --- a/app/code/Magento/Payment/Test/Unit/Model/Method/FreeTest.php +++ b/app/code/Magento/Payment/Test/Unit/Model/Method/FreeTest.php @@ -3,6 +3,9 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ + +// @codingStandardsIgnoreFile + namespace Magento\Payment\Test\Unit\Model\Method; class FreeTest extends \PHPUnit_Framework_TestCase @@ -27,13 +30,19 @@ class FreeTest extends \PHPUnit_Framework_TestCase $context->expects($this->any())->method('getEventDispatcher')->willReturn($eventManagerMock); $registry = $this->getMock('\Magento\Framework\Registry', [], [], '', false); - $metadataService = $this->getMock('\Magento\Framework\Api\MetadataServiceInterface'); + $extensionAttributesFactory = $this->getMock( + 'Magento\Framework\Api\ExtensionAttributesFactory', + [], + [], + '', + false + ); $customAttributeFactory = $this->getMock('\Magento\Framework\Api\AttributeValueFactory', [], [], '', false); $this->methodFree = new \Magento\Payment\Model\Method\Free( $context, $registry, - $metadataService, + $extensionAttributesFactory, $customAttributeFactory, $paymentData, $this->scopeConfig, diff --git a/app/code/Magento/Payment/etc/config.xml b/app/code/Magento/Payment/etc/config.xml index 79f703ef82aa1d1b1d7654b66f348ceac4c51a99..3fc78a9194a2cb6e78fc764c2734fa904cb8664d 100644 --- a/app/code/Magento/Payment/etc/config.xml +++ b/app/code/Magento/Payment/etc/config.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Core/etc/config.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Store/etc/config.xsd"> <default> <payment> <free> diff --git a/app/code/Magento/Persistent/etc/config.xml b/app/code/Magento/Persistent/etc/config.xml index 0dd16042c81fe4e9c0cac6dd176c65a1faedc591..c34916a7735a29fff1ff7e2c9c6dbc90face6310 100644 --- a/app/code/Magento/Persistent/etc/config.xml +++ b/app/code/Magento/Persistent/etc/config.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Core/etc/config.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Store/etc/config.xsd"> <default> <persistent> <options> diff --git a/app/code/Magento/ProductAlert/etc/config.xml b/app/code/Magento/ProductAlert/etc/config.xml index 23edc92c8f01e34aa136710ef54008f2382c9ea2..aae9903bfd345db05443b7180a285e3026c85aa5 100644 --- a/app/code/Magento/ProductAlert/etc/config.xml +++ b/app/code/Magento/ProductAlert/etc/config.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Core/etc/config.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Store/etc/config.xsd"> <default> <catalog> <productalert> diff --git a/app/code/Magento/Quote/Api/Data/AddressInterface.php b/app/code/Magento/Quote/Api/Data/AddressInterface.php index 689ec768e2b5a8082057fed91962eceffa03b780..4b0487a3431dcb3859814f8bcdaefe14a2c8719a 100644 --- a/app/code/Magento/Quote/Api/Data/AddressInterface.php +++ b/app/code/Magento/Quote/Api/Data/AddressInterface.php @@ -334,4 +334,19 @@ interface AddressInterface extends \Magento\Framework\Api\ExtensibleDataInterfac * @return $this */ public function setEmail($email); + + /** + * Retrieve existing extension attributes object or create a new one. + * + * @return \Magento\Quote\Api\Data\AddressExtensionInterface|null + */ + public function getExtensionAttributes(); + + /** + * Set an extension attributes object. + * + * @param \Magento\Quote\Api\Data\AddressExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes(\Magento\Quote\Api\Data\AddressExtensionInterface $extensionAttributes); } diff --git a/app/code/Magento/Quote/Api/Data/CartInterface.php b/app/code/Magento/Quote/Api/Data/CartInterface.php index 1fe5372c518bb2fabc106f13a11ef7d289181e65..2a56c448336bf4f8ad5bd9da2b588b6ac7582598 100644 --- a/app/code/Magento/Quote/Api/Data/CartInterface.php +++ b/app/code/Magento/Quote/Api/Data/CartInterface.php @@ -345,4 +345,19 @@ interface CartInterface extends \Magento\Framework\Api\ExtensibleDataInterface * @return $this */ public function setCustomerTaxClassId($customerTaxClassId); + + /** + * Retrieve existing extension attributes object or create a new one. + * + * @return \Magento\Quote\Api\Data\CartExtensionInterface|null + */ + public function getExtensionAttributes(); + + /** + * Set an extension attributes object. + * + * @param \Magento\Quote\Api\Data\CartExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes(\Magento\Quote\Api\Data\CartExtensionInterface $extensionAttributes); } diff --git a/app/code/Magento/Quote/Api/Data/CartItemInterface.php b/app/code/Magento/Quote/Api/Data/CartItemInterface.php index 511184992ab89c18d0177a9eca99ce3312bfb20f..4951fe1698006419285934bc95c4645537394e1c 100644 --- a/app/code/Magento/Quote/Api/Data/CartItemInterface.php +++ b/app/code/Magento/Quote/Api/Data/CartItemInterface.php @@ -130,4 +130,19 @@ interface CartItemInterface extends \Magento\Framework\Api\ExtensibleDataInterfa * @return $this */ public function setQuoteId($quoteId); + + /** + * Retrieve existing extension attributes object or create a new one. + * + * @return \Magento\Quote\Api\Data\CartItemExtensionInterface|null + */ + public function getExtensionAttributes(); + + /** + * Set an extension attributes object. + * + * @param \Magento\Quote\Api\Data\CartItemExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes(\Magento\Quote\Api\Data\CartItemExtensionInterface $extensionAttributes); } diff --git a/app/code/Magento/Quote/Api/Data/CurrencyInterface.php b/app/code/Magento/Quote/Api/Data/CurrencyInterface.php index b00350c5f600c2fc3917dbaa33c4315f56bf8c03..81a0ff8d3fad21400625f7c51c0634ede6dc2901 100644 --- a/app/code/Magento/Quote/Api/Data/CurrencyInterface.php +++ b/app/code/Magento/Quote/Api/Data/CurrencyInterface.php @@ -147,4 +147,19 @@ interface CurrencyInterface extends \Magento\Framework\Api\ExtensibleDataInterfa * @return $this */ public function setBaseToQuoteRate($baseToQuoteRate); + + /** + * Retrieve existing extension attributes object or create a new one. + * + * @return \Magento\Quote\Api\Data\CurrencyExtensionInterface|null + */ + public function getExtensionAttributes(); + + /** + * Set an extension attributes object. + * + * @param \Magento\Quote\Api\Data\CurrencyExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes(\Magento\Quote\Api\Data\CurrencyExtensionInterface $extensionAttributes); } diff --git a/app/code/Magento/Quote/Api/Data/PaymentInterface.php b/app/code/Magento/Quote/Api/Data/PaymentInterface.php index 7d437b97e2326a9044b57a481e06ce8393346f77..7f0704edbfe32782368afd6ff87d0d633037dbd5 100644 --- a/app/code/Magento/Quote/Api/Data/PaymentInterface.php +++ b/app/code/Magento/Quote/Api/Data/PaymentInterface.php @@ -147,4 +147,19 @@ interface PaymentInterface extends \Magento\Framework\Api\ExtensibleDataInterfac * @return $this */ public function setAdditionalData($additionalData); + + /** + * Retrieve existing extension attributes object or create a new one. + * + * @return \Magento\Quote\Api\Data\PaymentExtensionInterface|null + */ + public function getExtensionAttributes(); + + /** + * Set an extension attributes object. + * + * @param \Magento\Quote\Api\Data\PaymentExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes(\Magento\Quote\Api\Data\PaymentExtensionInterface $extensionAttributes); } diff --git a/app/code/Magento/Quote/Api/Data/PaymentMethodInterface.php b/app/code/Magento/Quote/Api/Data/PaymentMethodInterface.php index 3be900400f305ed076761bfab80a498dd7637d24..4ae7a9100508b4dadbaad4713f342061c7c93e93 100644 --- a/app/code/Magento/Quote/Api/Data/PaymentMethodInterface.php +++ b/app/code/Magento/Quote/Api/Data/PaymentMethodInterface.php @@ -20,4 +20,21 @@ interface PaymentMethodInterface extends \Magento\Framework\Api\ExtensibleDataIn * @return string */ public function getTitle(); + + /** + * Retrieve existing extension attributes object or create a new one. + * + * @return \Magento\Quote\Api\Data\PaymentMethodExtensionInterface|null + */ + public function getExtensionAttributes(); + + /** + * Set an extension attributes object. + * + * @param \Magento\Quote\Api\Data\PaymentMethodExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes( + \Magento\Quote\Api\Data\PaymentMethodExtensionInterface $extensionAttributes + ); } diff --git a/app/code/Magento/Quote/Api/Data/ShippingMethodInterface.php b/app/code/Magento/Quote/Api/Data/ShippingMethodInterface.php index 92a60cbb3ad1f70d1d80391f89d4b156e0df33f7..ccebbdaa679e0a002971379aa4d5b6206bbd88b0 100644 --- a/app/code/Magento/Quote/Api/Data/ShippingMethodInterface.php +++ b/app/code/Magento/Quote/Api/Data/ShippingMethodInterface.php @@ -147,4 +147,21 @@ interface ShippingMethodInterface extends \Magento\Framework\Api\ExtensibleDataI * @return $this */ public function setAvailable($available); + + /** + * Retrieve existing extension attributes object or create a new one. + * + * @return \Magento\Quote\Api\Data\ShippingMethodExtensionInterface|null + */ + public function getExtensionAttributes(); + + /** + * Set an extension attributes object. + * + * @param \Magento\Quote\Api\Data\ShippingMethodExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes( + \Magento\Quote\Api\Data\ShippingMethodExtensionInterface $extensionAttributes + ); } diff --git a/app/code/Magento/Quote/Api/Data/TotalsInterface.php b/app/code/Magento/Quote/Api/Data/TotalsInterface.php index b3594a9209f6bb063537a6cda701ce4ad5cf09c4..76684c5a75e196a29cec604f56cd5d5ca5a5402e 100644 --- a/app/code/Magento/Quote/Api/Data/TotalsInterface.php +++ b/app/code/Magento/Quote/Api/Data/TotalsInterface.php @@ -402,4 +402,19 @@ interface TotalsInterface extends \Magento\Framework\Api\ExtensibleDataInterface * @return $this */ public function setItems(array $items = null); + + /** + * Retrieve existing extension attributes object or create a new one. + * + * @return \Magento\Quote\Api\Data\TotalsExtensionInterface|null + */ + public function getExtensionAttributes(); + + /** + * Set an extension attributes object. + * + * @param \Magento\Quote\Api\Data\TotalsExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes(\Magento\Quote\Api\Data\TotalsExtensionInterface $extensionAttributes); } diff --git a/app/code/Magento/Quote/Api/Data/TotalsItemInterface.php b/app/code/Magento/Quote/Api/Data/TotalsItemInterface.php index a37c78802f8ae767b08cc4fb0c3e4ae00faffa94..21b895553a4daeb6438b6000cd117f7a112bdf88 100644 --- a/app/code/Magento/Quote/Api/Data/TotalsItemInterface.php +++ b/app/code/Magento/Quote/Api/Data/TotalsItemInterface.php @@ -332,4 +332,19 @@ interface TotalsItemInterface extends \Magento\Framework\Api\ExtensibleDataInter * @return $this */ public function setBaseRowTotalInclTax($baseRowTotalInclTax); + + /** + * Retrieve existing extension attributes object or create a new one. + * + * @return \Magento\Quote\Api\Data\TotalsItemExtensionInterface|null + */ + public function getExtensionAttributes(); + + /** + * Set an extension attributes object. + * + * @param \Magento\Quote\Api\Data\TotalsItemExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes(\Magento\Quote\Api\Data\TotalsItemExtensionInterface $extensionAttributes); } diff --git a/app/code/Magento/Quote/Model/BillingAddressManagement.php b/app/code/Magento/Quote/Model/BillingAddressManagement.php index 5e5140fc9e749bc5a05a04d3ccd79e73478c3a3a..502e4421bcb20c85cd263ed51121fd3aa6d9f72e 100644 --- a/app/code/Magento/Quote/Model/BillingAddressManagement.php +++ b/app/code/Magento/Quote/Model/BillingAddressManagement.php @@ -64,7 +64,7 @@ class BillingAddressManagement implements BillingAddressManagementInterface $this->quoteRepository->save($quote); } catch (\Exception $e) { $this->logger->critical($e); - throw new InputException('Unable to save address. Please, check input data.'); + throw new InputException(__('Unable to save address. Please, check input data.')); } return $quote->getBillingAddress()->getId(); } diff --git a/app/code/Magento/Quote/Model/Cart/Access/CartManagementPlugin.php b/app/code/Magento/Quote/Model/Cart/Access/CartManagementPlugin.php index f46eee82917f5701cfd5c90a815b3a1c696e56ae..f7ab6e07b0ecd9b135f3b800cd9f05e7c29e3791 100644 --- a/app/code/Magento/Quote/Model/Cart/Access/CartManagementPlugin.php +++ b/app/code/Magento/Quote/Model/Cart/Access/CartManagementPlugin.php @@ -51,7 +51,7 @@ class CartManagementPlugin $storeId ) { if (!in_array($this->userContext->getUserType(), $this->allowedUserTypes)) { - throw new AuthorizationException('Access denied'); + throw new AuthorizationException(__('Access denied')); } } } diff --git a/app/code/Magento/Quote/Model/Cart/Access/CartRepositoryPlugin.php b/app/code/Magento/Quote/Model/Cart/Access/CartRepositoryPlugin.php index 562332c96dcf6c5161ffa3384820484282900310..0410af82ca10c736cda6c151f8bd34e81e30d60d 100644 --- a/app/code/Magento/Quote/Model/Cart/Access/CartRepositoryPlugin.php +++ b/app/code/Magento/Quote/Model/Cart/Access/CartRepositoryPlugin.php @@ -48,7 +48,7 @@ class CartRepositoryPlugin $cartId ) { if (!in_array($this->userContext->getUserType(), $this->allowedUserTypes)) { - throw new AuthorizationException('Access denied'); + throw new AuthorizationException(__('Access denied')); } } @@ -67,7 +67,7 @@ class CartRepositoryPlugin SearchCriteria $searchCriteria ) { if (!in_array($this->userContext->getUserType(), $this->allowedUserTypes)) { - throw new AuthorizationException('Access denied'); + throw new AuthorizationException(__('Access denied')); } } } diff --git a/app/code/Magento/Quote/Model/Cart/Currency.php b/app/code/Magento/Quote/Model/Cart/Currency.php index 67e6e95b32a572717dfd6b8ff4f1ead6a06ba184..5f7b57a9508168e2b6f4ab136aa0c716fd30806c 100644 --- a/app/code/Magento/Quote/Model/Cart/Currency.php +++ b/app/code/Magento/Quote/Model/Cart/Currency.php @@ -162,4 +162,25 @@ class Currency extends \Magento\Framework\Model\AbstractExtensibleModel implemen { return $this->setData(self::KEY_BASE_TO_QUOTE_RATE, $baseToQuoteRate); } + + /** + * {@inheritdoc} + * + * @return \Magento\Quote\Api\Data\CurrencyExtensionInterface|null + */ + public function getExtensionAttributes() + { + return $this->_getExtensionAttributes(); + } + + /** + * {@inheritdoc} + * + * @param \Magento\Quote\Api\Data\CurrencyExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes(\Magento\Quote\Api\Data\CurrencyExtensionInterface $extensionAttributes) + { + return $this->_setExtensionAttributes($extensionAttributes); + } } diff --git a/app/code/Magento/Quote/Model/Cart/ShippingMethod.php b/app/code/Magento/Quote/Model/Cart/ShippingMethod.php index da61bf9820df6263a6d079a7b30ec6a3644818ec..75cba2f03cad98c8b53e727e1f4c0e699dde4bdd 100644 --- a/app/code/Magento/Quote/Model/Cart/ShippingMethod.php +++ b/app/code/Magento/Quote/Model/Cart/ShippingMethod.php @@ -162,4 +162,26 @@ class ShippingMethod extends \Magento\Framework\Api\AbstractExtensibleObject imp { return $this->setData(self::KEY_AVAILABLE, $available); } + + /** + * {@inheritdoc} + * + * @return \Magento\Quote\Api\Data\ShippingMethodExtensionInterface|null + */ + public function getExtensionAttributes() + { + return $this->_getExtensionAttributes(); + } + + /** + * {@inheritdoc} + * + * @param \Magento\Quote\Api\Data\ShippingMethodExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes( + \Magento\Quote\Api\Data\ShippingMethodExtensionInterface $extensionAttributes + ) { + return $this->_setExtensionAttributes($extensionAttributes); + } } diff --git a/app/code/Magento/Quote/Model/Cart/Totals.php b/app/code/Magento/Quote/Model/Cart/Totals.php index a1c8969dc954b50b4efd34192860fa855ee839c7..4612824f9cebb05dc6c4dedbb00bd8827e4019a3 100644 --- a/app/code/Magento/Quote/Model/Cart/Totals.php +++ b/app/code/Magento/Quote/Model/Cart/Totals.php @@ -498,4 +498,25 @@ class Totals extends AbstractExtensibleModel implements TotalsInterface { return $this->setData(self::KEY_ITEMS, $items); } + + /** + * {@inheritdoc} + * + * @return \Magento\Quote\Api\Data\TotalsExtensionInterface|null + */ + public function getExtensionAttributes() + { + return $this->_getExtensionAttributes(); + } + + /** + * {@inheritdoc} + * + * @param \Magento\Quote\Api\Data\TotalsExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes(\Magento\Quote\Api\Data\TotalsExtensionInterface $extensionAttributes) + { + return $this->_setExtensionAttributes($extensionAttributes); + } } diff --git a/app/code/Magento/Quote/Model/Cart/Totals/Item.php b/app/code/Magento/Quote/Model/Cart/Totals/Item.php index 1cd39994d7c644a1277d83906765625c5fbfc79c..0cd716b5082d7ae9f7ef82f82806a2b894959dd3 100644 --- a/app/code/Magento/Quote/Model/Cart/Totals/Item.php +++ b/app/code/Magento/Quote/Model/Cart/Totals/Item.php @@ -350,4 +350,25 @@ class Item extends AbstractExtensibleObject implements TotalsItemInterface { return $this->setData(self::KEY_BASE_ROW_TOTAL_INCL_TAX, $baseRowTotalInclTax); } + + /** + * {@inheritdoc} + * + * @return \Magento\Quote\Api\Data\TotalsItemExtensionInterface|null + */ + public function getExtensionAttributes() + { + return $this->_getExtensionAttributes(); + } + + /** + * {@inheritdoc} + * + * @param \Magento\Quote\Api\Data\TotalsItemExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes(\Magento\Quote\Api\Data\TotalsItemExtensionInterface $extensionAttributes) + { + return $this->_setExtensionAttributes($extensionAttributes); + } } diff --git a/app/code/Magento/Quote/Model/CouponManagement.php b/app/code/Magento/Quote/Model/CouponManagement.php index dc9fb49b6eacb87861b3fc8f0c468aacf8c9e5af..c57172b122c8bf323810b012fd8c8414b49e0b0c 100644 --- a/app/code/Magento/Quote/Model/CouponManagement.php +++ b/app/code/Magento/Quote/Model/CouponManagement.php @@ -53,7 +53,7 @@ class CouponManagement implements CouponManagementInterface /** @var \Magento\Quote\Model\Quote $quote */ $quote = $this->quoteRepository->getActive($cartId); if (!$quote->getItemsCount()) { - throw new NoSuchEntityException("Cart $cartId doesn't contain products"); + throw new NoSuchEntityException(__('Cart %1 doesn\'t contain products', $cartId)); } $quote->getShippingAddress()->setCollectShippingRates(true); @@ -61,10 +61,10 @@ class CouponManagement implements CouponManagementInterface $quote->setCouponCode($couponCode); $this->quoteRepository->save($quote->collectTotals()); } catch (\Exception $e) { - throw new CouldNotSaveException('Could not apply coupon code'); + throw new CouldNotSaveException(__('Could not apply coupon code')); } if ($quote->getCouponCode() != $couponCode) { - throw new NoSuchEntityException('Coupon code is not valid'); + throw new NoSuchEntityException(__('Coupon code is not valid')); } return true; } @@ -77,17 +77,17 @@ class CouponManagement implements CouponManagementInterface /** @var \Magento\Quote\Model\Quote $quote */ $quote = $this->quoteRepository->getActive($cartId); if (!$quote->getItemsCount()) { - throw new NoSuchEntityException("Cart $cartId doesn't contain products"); + throw new NoSuchEntityException(__('Cart %1 doesn\'t contain products', $cartId)); } $quote->getShippingAddress()->setCollectShippingRates(true); try { $quote->setCouponCode(''); $this->quoteRepository->save($quote->collectTotals()); } catch (\Exception $e) { - throw new CouldNotDeleteException('Could not delete coupon code'); + throw new CouldNotDeleteException(__('Could not delete coupon code')); } if ($quote->getCouponCode() != '') { - throw new CouldNotDeleteException('Could not delete coupon code'); + throw new CouldNotDeleteException(__('Could not delete coupon code')); } return true; } diff --git a/app/code/Magento/Quote/Model/PaymentMethodManagement.php b/app/code/Magento/Quote/Model/PaymentMethodManagement.php index 37a61c905ff4f160f3e3c873fe3d6a46e15344d4..55c493e80204dea29fd2178594d8fd7661e43b4e 100644 --- a/app/code/Magento/Quote/Model/PaymentMethodManagement.php +++ b/app/code/Magento/Quote/Model/PaymentMethodManagement.php @@ -59,13 +59,13 @@ class PaymentMethodManagement implements \Magento\Quote\Api\PaymentMethodManagem if ($quote->isVirtual()) { // check if billing address is set if (is_null($quote->getBillingAddress()->getCountryId())) { - throw new InvalidTransitionException('Billing address is not set'); + throw new InvalidTransitionException(__('Billing address is not set')); } $quote->getBillingAddress()->setPaymentMethod($payment->getMethod()); } else { // check if shipping address is set if (is_null($quote->getShippingAddress()->getCountryId())) { - throw new InvalidTransitionException('Shipping address is not set'); + throw new InvalidTransitionException(__('Shipping address is not set')); } $quote->getShippingAddress()->setPaymentMethod($payment->getMethod()); } @@ -74,7 +74,7 @@ class PaymentMethodManagement implements \Magento\Quote\Api\PaymentMethodManagem } if (!$this->zeroTotalValidator->isApplicable($payment->getMethodInstance(), $quote)) { - throw new InvalidTransitionException('The requested Payment Method is not available.'); + throw new InvalidTransitionException(__('The requested Payment Method is not available.')); } $quote->setTotalsCollectedFlag(false)->collectTotals()->save(); diff --git a/app/code/Magento/Quote/Model/Quote.php b/app/code/Magento/Quote/Model/Quote.php index 22971a88af7530ee0c4c254d1a6d97b4d744b846..ef130e2e6597203b74b35e6066678fedc712ac20 100644 --- a/app/code/Magento/Quote/Model/Quote.php +++ b/app/code/Magento/Quote/Model/Quote.php @@ -325,7 +325,7 @@ class Quote extends AbstractExtensibleModel implements \Magento\Quote\Api\Data\C /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry - * @param \Magento\Framework\Api\MetadataServiceInterface $metadataService + * @param \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory * @param AttributeValueFactory $customAttributeFactory * @param QuoteValidator $quoteValidator * @param \Magento\Catalog\Helper\Product $catalogProduct @@ -363,7 +363,7 @@ class Quote extends AbstractExtensibleModel implements \Magento\Quote\Api\Data\C public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, - \Magento\Framework\Api\MetadataServiceInterface $metadataService, + \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory, AttributeValueFactory $customAttributeFactory, \Magento\Quote\Model\QuoteValidator $quoteValidator, \Magento\Catalog\Helper\Product $catalogProduct, @@ -428,7 +428,7 @@ class Quote extends AbstractExtensibleModel implements \Magento\Quote\Api\Data\C parent::__construct( $context, $registry, - $metadataService, + $extensionFactory, $customAttributeFactory, $resource, $resourceCollection, @@ -1588,7 +1588,7 @@ class Quote extends AbstractExtensibleModel implements \Magento\Quote\Api\Data\C } } if (!empty($errors)) { - throw new \Magento\Framework\Exception\LocalizedException(implode("\n", $errors)); + throw new \Magento\Framework\Exception\LocalizedException(__(implode("\n", $errors))); } $this->_eventManager->dispatch('sales_quote_product_add_after', ['items' => $items]); @@ -1685,7 +1685,7 @@ class Quote extends AbstractExtensibleModel implements \Magento\Quote\Api\Data\C $resultItem = $this->addProduct($product, $buyRequest); if (is_string($resultItem)) { - throw new \Magento\Framework\Exception\LocalizedException($resultItem); + throw new \Magento\Framework\Exception\LocalizedException(__($resultItem)); } if ($resultItem->getParentItem()) { @@ -2525,4 +2525,25 @@ class Quote extends AbstractExtensibleModel implements \Magento\Quote\Api\Data\C { return \count($this->getAllShippingAddresses()) > 1; } + + /** + * {@inheritdoc} + * + * @return \Magento\Quote\Api\Data\CartExtensionInterface|null + */ + public function getExtensionAttributes() + { + return $this->_getExtensionAttributes(); + } + + /** + * {@inheritdoc} + * + * @param \Magento\Quote\Api\Data\CartExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes(\Magento\Quote\Api\Data\CartExtensionInterface $extensionAttributes) + { + return $this->_setExtensionAttributes($extensionAttributes); + } } diff --git a/app/code/Magento/Quote/Model/Quote/Address.php b/app/code/Magento/Quote/Model/Quote/Address.php index 01b4582cea36f116cddf6fba40e123c25c1c91d4..c57a8d0d5e8163661cdb1e240d60924801c3e5bb 100644 --- a/app/code/Magento/Quote/Model/Quote/Address.php +++ b/app/code/Magento/Quote/Model/Quote/Address.php @@ -8,7 +8,6 @@ namespace Magento\Quote\Model\Quote; use Magento\Customer\Api\AddressMetadataInterface; use Magento\Customer\Api\Data\AddressInterfaceFactory; use Magento\Customer\Api\Data\RegionInterfaceFactory; -use Magento\Framework\Api\AttributeValueFactory; /** * Sales Quote address model @@ -228,14 +227,14 @@ class Address extends \Magento\Customer\Model\Address\AbstractAddress implements /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry - * @param \Magento\Framework\Api\MetadataServiceInterface $metadataService - * @param AttributeValueFactory $customAttributeFactory + * @param \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory + * @param \Magento\Framework\Api\AttributeValueFactory $customAttributeFactory * @param \Magento\Directory\Helper\Data $directoryData * @param \Magento\Eav\Model\Config $eavConfig * @param \Magento\Customer\Model\Address\Config $addressConfig * @param \Magento\Directory\Model\RegionFactory $regionFactory * @param \Magento\Directory\Model\CountryFactory $countryFactory - * @param AddressMetadataInterface $addressMetadataService + * @param AddressMetadataInterface $metadataService * @param AddressInterfaceFactory $addressDataFactory * @param RegionInterfaceFactory $regionDataFactory * @param \Magento\Framework\Api\DataObjectHelper $dataObjectHelper @@ -260,14 +259,14 @@ class Address extends \Magento\Customer\Model\Address\AbstractAddress implements public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, - \Magento\Framework\Api\MetadataServiceInterface $metadataService, - AttributeValueFactory $customAttributeFactory, + \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory, + \Magento\Framework\Api\AttributeValueFactory $customAttributeFactory, \Magento\Directory\Helper\Data $directoryData, \Magento\Eav\Model\Config $eavConfig, \Magento\Customer\Model\Address\Config $addressConfig, \Magento\Directory\Model\RegionFactory $regionFactory, \Magento\Directory\Model\CountryFactory $countryFactory, - AddressMetadataInterface $addressMetadataService, + AddressMetadataInterface $metadataService, AddressInterfaceFactory $addressDataFactory, RegionInterfaceFactory $regionDataFactory, \Magento\Framework\Api\DataObjectHelper $dataObjectHelper, @@ -305,14 +304,14 @@ class Address extends \Magento\Customer\Model\Address\AbstractAddress implements parent::__construct( $context, $registry, - $metadataService, + $extensionFactory, $customAttributeFactory, $directoryData, $eavConfig, $addressConfig, $regionFactory, $countryFactory, - $addressMetadataService, + $metadataService, $addressDataFactory, $regionDataFactory, $dataObjectHelper, @@ -1611,4 +1610,25 @@ class Address extends \Magento\Customer\Model\Address\AbstractAddress implements return $this->setData(self::KEY_REGION_CODE, $regionCode); } //@codeCoverageIgnoreEnd + + /** + * {@inheritdoc} + * + * @return \Magento\Quote\Api\Data\AddressExtensionInterface|null + */ + public function getExtensionAttributes() + { + return $this->_getExtensionAttributes(); + } + + /** + * {@inheritdoc} + * + * @param \Magento\Quote\Api\Data\AddressExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes(\Magento\Quote\Api\Data\AddressExtensionInterface $extensionAttributes) + { + return $this->_setExtensionAttributes($extensionAttributes); + } } diff --git a/app/code/Magento/Quote/Model/Quote/Item.php b/app/code/Magento/Quote/Model/Quote/Item.php index 8f48eadab4877255c12fe54372edda53fed1947e..8dab6a6d2bf42f326b6397b3e239e943003954a0 100644 --- a/app/code/Magento/Quote/Model/Quote/Item.php +++ b/app/code/Magento/Quote/Model/Quote/Item.php @@ -9,7 +9,7 @@ namespace Magento\Quote\Model\Quote; use Magento\Framework\Api\AttributeValueFactory; -use Magento\Framework\Api\MetadataServiceInterface; +use Magento\Framework\Api\ExtensionAttributesFactory; /** * Sales Quote Item Model @@ -181,7 +181,7 @@ class Item extends \Magento\Quote\Model\Quote\Item\AbstractItem implements \Mage /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry - * @param MetadataServiceInterface $metadataService + * @param ExtensionAttributesFactory $extensionFactory * @param AttributeValueFactory $customAttributeFactory * @param \Magento\Catalog\Api\ProductRepositoryInterface $productRepository * @param \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency @@ -199,7 +199,7 @@ class Item extends \Magento\Quote\Model\Quote\Item\AbstractItem implements \Mage public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, - MetadataServiceInterface $metadataService, + ExtensionAttributesFactory $extensionFactory, AttributeValueFactory $customAttributeFactory, \Magento\Catalog\Api\ProductRepositoryInterface $productRepository, \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency, @@ -220,7 +220,7 @@ class Item extends \Magento\Quote\Model\Quote\Item\AbstractItem implements \Mage parent::__construct( $context, $registry, - $metadataService, + $extensionFactory, $customAttributeFactory, $productRepository, $priceCurrency, @@ -1002,4 +1002,25 @@ class Item extends \Magento\Quote\Model\Quote\Item\AbstractItem implements \Mage return $this->setData(self::KEY_QUOTE_ID, $quoteId); } //@codeCoverageIgnoreEnd + + /** + * {@inheritdoc} + * + * @return \Magento\Quote\Api\Data\CartItemExtensionInterface|null + */ + public function getExtensionAttributes() + { + return $this->_getExtensionAttributes(); + } + + /** + * {@inheritdoc} + * + * @param \Magento\Quote\Api\Data\CartItemExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes(\Magento\Quote\Api\Data\CartItemExtensionInterface $extensionAttributes) + { + return $this->_setExtensionAttributes($extensionAttributes); + } } diff --git a/app/code/Magento/Quote/Model/Quote/Item/AbstractItem.php b/app/code/Magento/Quote/Model/Quote/Item/AbstractItem.php index 5a689e03d994a9afb8185c9fe8b6ea5a5c5034bf..8542ee1e6abb22406a447ba1386c372fc564a7db 100644 --- a/app/code/Magento/Quote/Model/Quote/Item/AbstractItem.php +++ b/app/code/Magento/Quote/Model/Quote/Item/AbstractItem.php @@ -83,7 +83,7 @@ abstract class AbstractItem extends \Magento\Framework\Model\AbstractExtensibleM /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry - * @param \Magento\Framework\Api\MetadataServiceInterface $metadataService + * @param \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory * @param AttributeValueFactory $customAttributeFactory * @param \Magento\Catalog\Api\ProductRepositoryInterface $productRepository * @param \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency @@ -94,7 +94,7 @@ abstract class AbstractItem extends \Magento\Framework\Model\AbstractExtensibleM public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, - \Magento\Framework\Api\MetadataServiceInterface $metadataService, + \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory, AttributeValueFactory $customAttributeFactory, \Magento\Catalog\Api\ProductRepositoryInterface $productRepository, \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency, @@ -105,7 +105,7 @@ abstract class AbstractItem extends \Magento\Framework\Model\AbstractExtensibleM parent::__construct( $context, $registry, - $metadataService, + $extensionFactory, $customAttributeFactory, $resource, $resourceCollection, diff --git a/app/code/Magento/Quote/Model/Quote/Item/Repository.php b/app/code/Magento/Quote/Model/Quote/Item/Repository.php index 7ba19cd37d3670834e82eeae5596739c2021145d..fc4a0f7db7ef47c3b71ea4bbab5be324167a7425 100644 --- a/app/code/Magento/Quote/Model/Quote/Item/Repository.php +++ b/app/code/Magento/Quote/Model/Quote/Item/Repository.php @@ -84,7 +84,9 @@ class Repository implements \Magento\Quote\Api\CartItemRepositoryInterface if (isset($itemId)) { $cartItem = $quote->getItemById($itemId); if (!$cartItem) { - throw new NoSuchEntityException("Cart $cartId doesn't contain item $itemId"); + throw new NoSuchEntityException( + __('Cart %1 doesn\'t contain item %2', $cartId, $itemId) + ); } $product = $this->productRepository->get($cartItem->getSku()); $cartItem->setData('qty', $qty); @@ -97,7 +99,7 @@ class Repository implements \Magento\Quote\Api\CartItemRepositoryInterface if ($e instanceof NoSuchEntityException) { throw $e; } - throw new CouldNotSaveException('Could not save quote'); + throw new CouldNotSaveException(__('Could not save quote')); } return $quote->getItemByProduct($product); } @@ -117,13 +119,15 @@ class Repository implements \Magento\Quote\Api\CartItemRepositoryInterface $quote = $this->quoteRepository->getActive($cartId); $quoteItem = $quote->getItemById($itemId); if (!$quoteItem) { - throw new NoSuchEntityException("Cart $cartId doesn't contain item $itemId"); + throw new NoSuchEntityException( + __('Cart %1 doesn\'t contain item %2', $cartId, $itemId) + ); } try { $quote->removeItem($itemId); $this->quoteRepository->save($quote->collectTotals()); } catch (\Exception $e) { - throw new CouldNotSaveException('Could not remove item from quote'); + throw new CouldNotSaveException(__('Could not remove item from quote')); } } diff --git a/app/code/Magento/Quote/Model/Quote/Payment.php b/app/code/Magento/Quote/Model/Quote/Payment.php index f420bad2202e58d972379a4202203b1a3f210ac7..f071b845cbb1fe3509696882da93882829db3f2a 100644 --- a/app/code/Magento/Quote/Model/Quote/Payment.php +++ b/app/code/Magento/Quote/Model/Quote/Payment.php @@ -5,8 +5,6 @@ */ namespace Magento\Quote\Model\Quote; -use Magento\Framework\Api\AttributeValueFactory; - /** * Quote payment information * @@ -63,8 +61,8 @@ class Payment extends \Magento\Payment\Model\Info implements \Magento\Quote\Api\ /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry - * @param \Magento\Framework\Api\MetadataServiceInterface $metadataService - * @param AttributeValueFactory $customAttributeFactory + * @param \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory + * @param \Magento\Framework\Api\AttributeValueFactory $customAttributeFactory * @param \Magento\Payment\Helper\Data $paymentData * @param \Magento\Framework\Encryption\EncryptorInterface $encryptor * @param \Magento\Payment\Model\Checks\SpecificationFactory $methodSpecificationFactory @@ -76,8 +74,8 @@ class Payment extends \Magento\Payment\Model\Info implements \Magento\Quote\Api\ public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, - \Magento\Framework\Api\MetadataServiceInterface $metadataService, - AttributeValueFactory $customAttributeFactory, + \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory, + \Magento\Framework\Api\AttributeValueFactory $customAttributeFactory, \Magento\Payment\Helper\Data $paymentData, \Magento\Framework\Encryption\EncryptorInterface $encryptor, \Magento\Payment\Model\Checks\SpecificationFactory $methodSpecificationFactory, @@ -89,7 +87,7 @@ class Payment extends \Magento\Payment\Model\Info implements \Magento\Quote\Api\ parent::__construct( $context, $registry, - $metadataService, + $extensionFactory, $customAttributeFactory, $paymentData, $encryptor, @@ -414,4 +412,25 @@ class Payment extends \Magento\Payment\Model\Info implements \Magento\Quote\Api\ return $this->setData(self::KEY_ADDITIONAL_DATA, $additionalData); } //@codeCoverageIgnoreEnd + + /** + * {@inheritdoc} + * + * @return \Magento\Quote\Api\Data\PaymentExtensionInterface|null + */ + public function getExtensionAttributes() + { + return $this->_getExtensionAttributes(); + } + + /** + * {@inheritdoc} + * + * @param \Magento\Quote\Api\Data\PaymentExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes(\Magento\Quote\Api\Data\PaymentExtensionInterface $extensionAttributes) + { + return $this->_setExtensionAttributes($extensionAttributes); + } } diff --git a/app/code/Magento/Quote/Model/QuoteAddressValidator.php b/app/code/Magento/Quote/Model/QuoteAddressValidator.php index b195066721af0a0885cd49c631154d7fb0fe986a..0098e459fd848d3476b317d934850e9ebda75857 100644 --- a/app/code/Magento/Quote/Model/QuoteAddressValidator.php +++ b/app/code/Magento/Quote/Model/QuoteAddressValidator.php @@ -52,7 +52,7 @@ class QuoteAddressValidator $customer->load($addressData->getCustomerId()); if (!$customer->getId()) { throw new \Magento\Framework\Exception\NoSuchEntityException( - 'Invalid customer id ' . $addressData->getCustomerId() + __('Invalid customer id %1', $addressData->getCustomerId()) ); } } @@ -63,7 +63,7 @@ class QuoteAddressValidator $address->load($addressData->getId()); if (!$address->getId()) { throw new \Magento\Framework\Exception\NoSuchEntityException( - 'Invalid address id ' . $addressData->getId() + __('Invalid address id %1', $addressData->getId()) ); } @@ -71,7 +71,7 @@ class QuoteAddressValidator if ($addressData->getCustomerId()) { if ($address->getCustomerId() != $addressData->getCustomerId()) { throw new \Magento\Framework\Exception\InputException( - 'Address with id ' . $addressData->getId() . ' belongs to another customer' + __('Address with id %1 belongs to another customer', $addressData->getId()) ); } } diff --git a/app/code/Magento/Quote/Model/QuoteManagement.php b/app/code/Magento/Quote/Model/QuoteManagement.php index 0f53de853e9c123685bab4ffaac707a6d55ce94d..7adb722ba25f868a9d7aa16717afbc099d1e915a 100644 --- a/app/code/Magento/Quote/Model/QuoteManagement.php +++ b/app/code/Magento/Quote/Model/QuoteManagement.php @@ -156,7 +156,7 @@ class QuoteManagement implements \Magento\Quote\Api\CartManagementInterface try { $this->quoteRepository->save($quote); } catch (\Exception $e) { - throw new CouldNotSaveException('Cannot create quote'); + throw new CouldNotSaveException(__('Cannot create quote')); } return $quote->getId(); } @@ -171,14 +171,20 @@ class QuoteManagement implements \Magento\Quote\Api\CartManagementInterface $customerModel = $this->customerModelFactory->create(); if (!in_array($storeId, $customerModel->load($customerId)->getSharedStoreIds())) { - throw new StateException('Cannot assign customer to the given cart. The cart belongs to different store.'); + throw new StateException( + __('Cannot assign customer to the given cart. The cart belongs to different store.') + ); } if ($quote->getCustomerId()) { - throw new StateException('Cannot assign customer to the given cart. The cart is not anonymous.'); + throw new StateException( + __('Cannot assign customer to the given cart. The cart is not anonymous.') + ); } try { $this->quoteRepository->getForCustomer($customerId); - throw new StateException('Cannot assign customer to the given cart. Customer already has active cart.'); + throw new StateException( + __('Cannot assign customer to the given cart. Customer already has active cart.') + ); } catch (\Magento\Framework\Exception\NoSuchEntityException $e) { } @@ -217,7 +223,7 @@ class QuoteManagement implements \Magento\Quote\Api\CartManagementInterface try { $this->quoteRepository->getActiveForCustomer($this->userContext->getUserId()); - throw new CouldNotSaveException('Cannot create quote'); + throw new CouldNotSaveException(__('Cannot create quote')); } catch (\Magento\Framework\Exception\NoSuchEntityException $e) { } diff --git a/app/code/Magento/Quote/Model/ShippingAddressManagement.php b/app/code/Magento/Quote/Model/ShippingAddressManagement.php index 13b92793ab36844f3cdf414f76379990ebf86dda..40133907d2934db443b7c7ff8cf885720b2dde27 100644 --- a/app/code/Magento/Quote/Model/ShippingAddressManagement.php +++ b/app/code/Magento/Quote/Model/ShippingAddressManagement.php @@ -60,7 +60,7 @@ class ShippingAddressManagement implements ShippingAddressManagementInterface $quote = $this->quoteRepository->getActive($cartId); if ($quote->isVirtual()) { throw new NoSuchEntityException( - 'Cart contains virtual product(s) only. Shipping address is not applicable' + __('Cart contains virtual product(s) only. Shipping address is not applicable.') ); } $this->addressValidator->validate($address); @@ -73,7 +73,7 @@ class ShippingAddressManagement implements ShippingAddressManagementInterface $this->quoteRepository->save($quote); } catch (\Exception $e) { $this->logger->critical($e); - throw new InputException('Unable to save address. Please, check input data.'); + throw new InputException(__('Unable to save address. Please, check input data.')); } return $quote->getShippingAddress()->getId(); } @@ -91,7 +91,7 @@ class ShippingAddressManagement implements ShippingAddressManagementInterface $quote = $this->quoteRepository->getActive($cartId); if ($quote->isVirtual()) { throw new NoSuchEntityException( - 'Cart contains virtual product(s) only. Shipping address is not applicable' + __('Cart contains virtual product(s) only. Shipping address is not applicable.') ); } diff --git a/app/code/Magento/Quote/Model/ShippingMethodManagement.php b/app/code/Magento/Quote/Model/ShippingMethodManagement.php index a0aff7f9641e19ddb69df4c4faf8e38096d5ee6b..c951f228edbdbbca5371dad67e33df26d53f30c9 100644 --- a/app/code/Magento/Quote/Model/ShippingMethodManagement.php +++ b/app/code/Magento/Quote/Model/ShippingMethodManagement.php @@ -69,7 +69,7 @@ class ShippingMethodManagement implements ShippingMethodManagementInterface /** @var \Magento\Quote\Model\Quote\Address $shippingAddress */ $shippingAddress = $quote->getShippingAddress(); if (!$shippingAddress->getCountryId()) { - throw new StateException('Shipping address not set.'); + throw new StateException(__('Shipping address not set.')); } $shippingMethod = $shippingAddress->getShippingMethod(); @@ -101,7 +101,9 @@ class ShippingMethodManagement implements ShippingMethodManagementInterface protected function divideNames($delimiter, $line) { if (strpos($line, $delimiter) === false) { - throw new InputException('Line "' . $line . '" doesn\'t contain delimiter ' . $delimiter); + throw new InputException( + __('Line "%1" doesn\'t contain delimiter %2', $line, $delimiter) + ); } return explode($delimiter, $line); } @@ -123,7 +125,7 @@ class ShippingMethodManagement implements ShippingMethodManagementInterface $shippingAddress = $quote->getShippingAddress(); if (!$shippingAddress->getCountryId()) { - throw new StateException('Shipping address not set.'); + throw new StateException(__('Shipping address not set.')); } $shippingAddress->collectShippingRates(); $shippingRates = $shippingAddress->getGroupedAllShippingRates(); @@ -152,31 +154,33 @@ class ShippingMethodManagement implements ShippingMethodManagementInterface /** @var \Magento\Quote\Model\Quote $quote */ $quote = $this->quoteRepository->getActive($cartId); if (0 == $quote->getItemsCount()) { - throw new InputException('Shipping method is not applicable for empty cart'); + throw new InputException(__('Shipping method is not applicable for empty cart')); } if ($quote->isVirtual()) { throw new NoSuchEntityException( - 'Cart contains virtual product(s) only. Shipping method is not applicable.' + __('Cart contains virtual product(s) only. Shipping method is not applicable.') ); } $shippingAddress = $quote->getShippingAddress(); if (!$shippingAddress->getCountryId()) { - throw new StateException('Shipping address is not set'); + throw new StateException(__('Shipping address is not set')); } $billingAddress = $quote->getBillingAddress(); if (!$billingAddress->getCountryId()) { - throw new StateException('Billing address is not set'); + throw new StateException(__('Billing address is not set')); } $shippingAddress->setShippingMethod($carrierCode . '_' . $methodCode); if (!$shippingAddress->requestShippingRates()) { - throw new NoSuchEntityException('Carrier with such method not found: ' . $carrierCode . ', ' . $methodCode); + throw new NoSuchEntityException( + __('Carrier with such method not found: %1, %2', $carrierCode, $methodCode) + ); } try { $this->quoteRepository->save($quote->collectTotals()); } catch (\Exception $e) { - throw new CouldNotSaveException('Cannot set shipping method. ' . $e->getMessage()); + throw new CouldNotSaveException(__('Cannot set shipping method. %1', $e->getMessage())); } return true; } diff --git a/app/code/Magento/Quote/Test/Unit/Model/BillingAddressManagementTest.php b/app/code/Magento/Quote/Test/Unit/Model/BillingAddressManagementTest.php index bfe59ec37ca4f5daeaef190ed4fed51d2226e7fc..244c1fb1778afd8d497c28b47199b009c9ac89f4 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/BillingAddressManagementTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/BillingAddressManagementTest.php @@ -26,6 +26,9 @@ class BillingAddressManagementTest extends \PHPUnit_Framework_TestCase */ protected $validatorMock; + /** + * @return void + */ protected function setUp() { $this->quoteRepositoryMock = $this->getMock('\Magento\Quote\Model\QuoteRepository', [], [], '', false); @@ -34,6 +37,9 @@ class BillingAddressManagementTest extends \PHPUnit_Framework_TestCase $this->model = new BillingAddressManagement($this->quoteRepositoryMock, $this->validatorMock, $logger); } + /** + * @return void + */ public function testGetAddress() { $quoteMock = $this->getMock('\Magento\Quote\Model\Quote', [], [], '', false); @@ -48,6 +54,7 @@ class BillingAddressManagementTest extends \PHPUnit_Framework_TestCase /** + * @return void * @expectedException \Magento\Framework\Exception\NoSuchEntityException * @expectedExceptionMessage error123 */ @@ -61,11 +68,14 @@ class BillingAddressManagementTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue($quoteMock)); $this->validatorMock->expects($this->once())->method('validate') - ->will($this->throwException(new \Magento\Framework\Exception\NoSuchEntityException('error123'))); + ->will($this->throwException(new \Magento\Framework\Exception\NoSuchEntityException(__('error123')))); $this->model->assign('cartId', $address); } + /** + * @return void + */ public function testSetAddress() { $address = $this->getMock('Magento\Quote\Model\Quote\Address', [], [], '', false, false); @@ -93,6 +103,7 @@ class BillingAddressManagementTest extends \PHPUnit_Framework_TestCase } /** + * @return void * @expectedException \Magento\Framework\Exception\InputException * @expectedExceptionMessage Unable to save address. Please, check input data. */ diff --git a/app/code/Magento/Quote/Test/Unit/Model/CouponManagementTest.php b/app/code/Magento/Quote/Test/Unit/Model/CouponManagementTest.php index 7cdfa9aba7931604a040e2354aaba25d71c7f0c7..dc119a34be8a532f02115b22d1482bac427f8b56 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/CouponManagementTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/CouponManagementTest.php @@ -120,7 +120,7 @@ class CouponManagementTest extends \PHPUnit_Framework_TestCase $this->quoteAddressMock->expects($this->once())->method('setCollectShippingRates')->with(true); $this->quoteMock->expects($this->once())->method('setCouponCode')->with($couponCode); $exceptionMessage = 'Could not apply coupon code'; - $exception = new \Magento\Framework\Exception\CouldNotDeleteException($exceptionMessage); + $exception = new \Magento\Framework\Exception\CouldNotDeleteException(__($exceptionMessage)); $this->quoteMock->expects($this->once())->method('collectTotals')->will($this->returnValue($this->quoteMock)); $this->quoteRepositoryMock->expects($this->once()) ->method('save') @@ -205,7 +205,7 @@ class CouponManagementTest extends \PHPUnit_Framework_TestCase $this->quoteMock->expects($this->once())->method('setCouponCode')->with(''); $this->quoteMock->expects($this->once())->method('collectTotals')->will($this->returnValue($this->quoteMock)); $exceptionMessage = 'Could not delete coupon code'; - $exception = new \Magento\Framework\Exception\CouldNotSaveException($exceptionMessage); + $exception = new \Magento\Framework\Exception\CouldNotSaveException(__($exceptionMessage)); $this->quoteMock->expects($this->once())->method('collectTotals')->will($this->returnValue($this->quoteMock)); $this->quoteRepositoryMock->expects($this->once()) ->method('save') diff --git a/app/code/Magento/Quote/Test/Unit/Model/Quote/Item/RepositoryTest.php b/app/code/Magento/Quote/Test/Unit/Model/Quote/Item/RepositoryTest.php index 573acd5a8e792fac4dd316e8c49d214a22aef7ee..b90d93933827cbe676a413b79cbc4ed2e0d615b4 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/Quote/Item/RepositoryTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/Quote/Item/RepositoryTest.php @@ -51,6 +51,9 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase */ protected $itemDataFactoryMock; + /** + * @return void + */ protected function setUp() { $this->quoteRepositoryMock = @@ -74,6 +77,7 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase /** * @param null|string|bool|int|float $value + * @return void * @expectedException \Magento\Framework\Exception\InputException * @expectedExceptionMessage Invalid value of * @dataProvider addItemWithInvalidQtyDataProvider @@ -84,6 +88,9 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase $this->repository->save($this->dataMock); } + /** + * @return array + */ public function addItemWithInvalidQtyDataProvider() { return [ @@ -98,6 +105,7 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase } /** + * @return void * @expectedException \Magento\Framework\Exception\CouldNotSaveException * @expectedExceptionMessage Could not save quote */ @@ -116,7 +124,7 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase $this->quoteMock->expects($this->once())->method('addProduct')->with($this->productMock, 12); $this->quoteMock->expects($this->once())->method('collectTotals')->will($this->returnValue($this->quoteMock)); $exceptionMessage = 'Could not save quote'; - $exception = new \Magento\Framework\Exception\CouldNotSaveException($exceptionMessage); + $exception = new \Magento\Framework\Exception\CouldNotSaveException(__($exceptionMessage)); $this->quoteRepositoryMock->expects($this->once()) ->method('save') ->with($this->quoteMock) @@ -125,6 +133,9 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase $this->repository->save($this->dataMock); } + /** + * @return void + */ public function testSave() { $cartId = 13; @@ -150,6 +161,7 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase } /** + * @return void * @expectedException \Magento\Framework\Exception\NoSuchEntityException * @expectedExceptionMessage Cart 11 doesn't contain item 5 */ @@ -171,6 +183,7 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase } /** + * @return void * @expectedException \Magento\Framework\Exception\CouldNotSaveException * @expectedExceptionMessage Could not save quote */ @@ -196,7 +209,7 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase $this->quoteMock->expects($this->once())->method('collectTotals')->will($this->returnValue($this->quoteMock)); $this->quoteItemMock->expects($this->never())->method('addProduct'); $exceptionMessage = 'Could not save quote'; - $exception = new \Magento\Framework\Exception\CouldNotSaveException($exceptionMessage); + $exception = new \Magento\Framework\Exception\CouldNotSaveException(__($exceptionMessage)); $this->quoteRepositoryMock->expects($this->once()) ->method('save') ->with($this->quoteMock) @@ -205,6 +218,9 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase $this->repository->save($this->dataMock); } + /** + * @return void + */ public function testUpdateItem() { $cartId = 11; @@ -236,6 +252,7 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase } /** + * @return void * @expectedException \Magento\Framework\Exception\NoSuchEntityException * @expectedExceptionMessage Cart 11 doesn't contain item 5 */ @@ -255,6 +272,7 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase } /** + * @return void * @expectedException \Magento\Framework\Exception\CouldNotSaveException * @expectedExceptionMessage Could not remove item from quote */ @@ -272,7 +290,7 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase ->method('removeItem')->with($itemId)->will($this->returnValue($this->quoteMock)); $this->quoteMock->expects($this->once())->method('collectTotals')->will($this->returnValue($this->quoteMock)); $exceptionMessage = 'Could not remove item from quote'; - $exception = new \Magento\Framework\Exception\CouldNotSaveException($exceptionMessage); + $exception = new \Magento\Framework\Exception\CouldNotSaveException(__($exceptionMessage)); $this->quoteRepositoryMock->expects($this->once()) ->method('save') ->with($this->quoteMock) @@ -281,6 +299,9 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase $this->repository->delete($this->dataMock); } + /** + * @return void + */ public function testDelete() { $cartId = 11; @@ -298,6 +319,9 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase $this->repository->delete($this->dataMock); } + /** + * @return void + */ public function testGetList() { $quoteMock = $this->getMock('Magento\Quote\Model\Quote', [], [], '', false); @@ -310,6 +334,9 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase $this->assertEquals([$itemMock], $this->repository->getList(33)); } + /** + * @return void + */ public function testDeleteById() { $cartId = 11; diff --git a/app/code/Magento/Quote/Test/Unit/Model/Quote/Payment/ToOrderPaymentTest.php b/app/code/Magento/Quote/Test/Unit/Model/Quote/Payment/ToOrderPaymentTest.php index 8349a6e8f19e669d1b664c1f627616934d3e9da2..b68aeb602acb6cfd7d7d8af9cf45b60595dcd6c6 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/Quote/Payment/ToOrderPaymentTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/Quote/Payment/ToOrderPaymentTest.php @@ -4,6 +4,8 @@ * See COPYING.txt for license details. */ +// @codingStandardsIgnoreFile + namespace Magento\Quote\Test\Unit\Model\Quote\Payment; use Magento\Payment\Model\Method\Substitution; @@ -79,7 +81,7 @@ class ToOrderPaymentTest extends \PHPUnit_Framework_TestCase $data = ['some_id' => 1]; $paymentMethodTitle = 'TestTitle'; $additionalInfo = ['token' => 'TOKEN-123']; - + $this->paymentMock->expects($this->once())->method('getMethodInstance')->willReturn($methodInterface); $methodInterface->expects($this->once())->method('getTitle')->willReturn($paymentMethodTitle); $this->objectCopyMock->expects($this->once())->method('getDataFromFieldset')->with( diff --git a/app/code/Magento/Quote/Test/Unit/Model/ShippingAddressManagementTest.php b/app/code/Magento/Quote/Test/Unit/Model/ShippingAddressManagementTest.php index 5de97e7588eec5d73ab165d9e6a42c2d32bbd71c..ddda3673b55dc91b68611979041a8bd8d51dec25 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/ShippingAddressManagementTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/ShippingAddressManagementTest.php @@ -72,7 +72,7 @@ class ShippingAddressManagementTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue($quoteMock)); $this->validatorMock->expects($this->once())->method('validate') - ->will($this->throwException(new \Magento\Framework\Exception\NoSuchEntityException('error345'))); + ->will($this->throwException(new \Magento\Framework\Exception\NoSuchEntityException(__('error345')))); $this->service->assign('cart654', $this->quoteAddressMock); } diff --git a/app/code/Magento/Quote/etc/webapi.xml b/app/code/Magento/Quote/etc/webapi.xml index e1502c718e95058cd007262ba45d5339598673a4..412dab6361b1f7ef5e24168ebcb9b1b980a32c48 100644 --- a/app/code/Magento/Quote/etc/webapi.xml +++ b/app/code/Magento/Quote/etc/webapi.xml @@ -13,7 +13,7 @@ <resource ref="anonymous" /> </resources> </route> - <route url="/V1/carts" method="PUT"> + <route url="/V1/carts" method="GET"> <service class="Magento\Quote\Api\CartRepositoryInterface" method="getList"/> <resources> <resource ref="anonymous" /> diff --git a/app/code/Magento/Reports/etc/config.xml b/app/code/Magento/Reports/etc/config.xml index c9147001358680ef25a77c435a07519271a7cf79..d17146e739d84bf0c22e62bfc25178beec63eac4 100644 --- a/app/code/Magento/Reports/etc/config.xml +++ b/app/code/Magento/Reports/etc/config.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Core/etc/config.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Store/etc/config.xsd"> <default> <catalog> <recently_products> diff --git a/app/code/Magento/Review/Block/Customer/ListCustomer.php b/app/code/Magento/Review/Block/Customer/ListCustomer.php index 30a856c8384f419fb2e11d46bbdf888c7c3940ac..eee22e93bf790cb6b5bc5fd23e44861eb89ae8b5 100644 --- a/app/code/Magento/Review/Block/Customer/ListCustomer.php +++ b/app/code/Magento/Review/Block/Customer/ListCustomer.php @@ -62,31 +62,7 @@ class ListCustomer extends \Magento\Customer\Block\Account\Dashboard $data ); $this->currentCustomer = $currentCustomer; - } - - /** - * Initialize review collection - * - * @return $this - */ - protected function _initCollection() - { - $this->_collection = $this->_collectionFactory->create(); - $this->_collection - ->addStoreFilter($this->_storeManager->getStore()->getId()) - ->addCustomerFilter($this->currentCustomer->getCustomerId()) - ->setDateOrder(); - return $this; - } - - /** - * Gets collection items count - * - * @return int - */ - public function count() - { - return $this->_getCollection()->getSize(); + $this->_isScopePrivate = true; } /** @@ -106,40 +82,39 @@ class ListCustomer extends \Magento\Customer\Block\Account\Dashboard */ protected function _prepareLayout() { - $toolbar = $this->getLayout()->createBlock( - 'Magento\Theme\Block\Html\Pager', - 'customer_review_list.toolbar' - )->setCollection( - $this->getCollection() - ); - - $this->setChild('toolbar', $toolbar); + if ($this->getReviews()) { + $toolbar = $this->getLayout()->createBlock( + 'Magento\Theme\Block\Html\Pager', + 'customer_review_list.toolbar' + )->setCollection( + $this->getReviews() + ); + + $this->setChild('toolbar', $toolbar); + } return parent::_prepareLayout(); } /** - * Get collection + * Get reviews * - * @return \Magento\Review\Model\Resource\Review\Product\Collection + * @return bool|\Magento\Review\Model\Resource\Review\Product\Collection */ - protected function _getCollection() + public function getReviews() { + if (!($customerId = $this->currentCustomer->getCustomerId())) { + return false; + } if (!$this->_collection) { - $this->_initCollection(); + $this->_collection = $this->_collectionFactory->create(); + $this->_collection + ->addStoreFilter($this->_storeManager->getStore()->getId()) + ->addCustomerFilter($customerId) + ->setDateOrder(); } return $this->_collection; } - /** - * Get collection - * - * @return \Magento\Review\Model\Resource\Review\Product\Collection - */ - public function getCollection() - { - return $this->_getCollection(); - } - /** * Get review link * @@ -178,7 +153,10 @@ class ListCustomer extends \Magento\Customer\Block\Account\Dashboard */ protected function _beforeToHtml() { - $this->_getCollection()->load()->addReviewSummary(); + $reviews = $this->getReviews(); + if ($reviews) { + $reviews->load()->addReviewSummary(); + } return parent::_beforeToHtml(); } } diff --git a/app/code/Magento/Review/Block/Customer/Recent.php b/app/code/Magento/Review/Block/Customer/Recent.php index bbb8cf71cb44bb7af39c2ca26cb7d8984c1a20ba..7cd61cd717e8e489ea25a4cb2c152b36bf99b659 100644 --- a/app/code/Magento/Review/Block/Customer/Recent.php +++ b/app/code/Magento/Review/Block/Customer/Recent.php @@ -53,6 +53,7 @@ class Recent extends \Magento\Framework\View\Element\Template $this->_collectionFactory = $collectionFactory; parent::__construct($context, $data); $this->currentCustomer = $currentCustomer; + $this->_isScopePrivate = true; } /** @@ -74,54 +75,28 @@ class Recent extends \Magento\Framework\View\Element\Template } /** - * Initialize review collection - * @return $this - */ - protected function _initCollection() - { - $this->_collection = $this->_collectionFactory->create(); - $this->_collection - ->addStoreFilter($this->_storeManager->getStore()->getId()) - ->addCustomerFilter($this->currentCustomer->getCustomerId()) - ->setDateOrder() - ->setPageSize(5) - ->load() - ->addReviewSummary(); - return $this; - } - - /** - * Get number of reviews + * Return collection of reviews * - * @return int + * @return array|\Magento\Review\Model\Resource\Review\Product\Collection */ - public function count() - { - return $this->_getCollection()->getSize(); - } - - /** - * Initialize and return collection of reviews - * @return Collection - */ - protected function _getCollection() + public function getReviews() { + if (!($customerId = $this->currentCustomer->getCustomerId())) { + return []; + } if (!$this->_collection) { - $this->_initCollection(); + $this->_collection = $this->_collectionFactory->create(); + $this->_collection + ->addStoreFilter($this->_storeManager->getStore()->getId()) + ->addCustomerFilter($customerId) + ->setDateOrder() + ->setPageSize(5) + ->load() + ->addReviewSummary(); } return $this->_collection; } - /** - * Return collection of reviews - * - * @return Collection - */ - public function getCollection() - { - return $this->_getCollection(); - } - /** * Return review customer view url * diff --git a/app/code/Magento/Review/Block/Customer/View.php b/app/code/Magento/Review/Block/Customer/View.php index 7ca1541ba9842f61f3454f6a4a1babc4a46cf5db..3bab2ed7c7c7957fb68224a912a77e4a8a748022 100644 --- a/app/code/Magento/Review/Block/Customer/View.php +++ b/app/code/Magento/Review/Block/Customer/View.php @@ -79,11 +79,11 @@ class View extends \Magento\Catalog\Block\Product\AbstractProduct $this->_voteFactory = $voteFactory; $this->_ratingFactory = $ratingFactory; $this->currentCustomer = $currentCustomer; - parent::__construct( $context, $data ); + $this->_isScopePrivate = true; } /** @@ -199,16 +199,6 @@ class View extends \Magento\Catalog\Block\Product\AbstractProduct return $this->formatDate($date, \IntlDateFormatter::LONG); } - /** - * Check whether current customer is review owner - * - * @return bool - */ - public function isReviewOwner() - { - return ($this->getReviewData()->getCustomerId() == $this->currentCustomer->getCustomerId()); - } - /** * Get product reviews summary * @@ -227,4 +217,12 @@ class View extends \Magento\Catalog\Block\Product\AbstractProduct } return parent::getReviewsSummaryHtml($product, $templateType, $displayIfNoReviews); } + + /** + * @return string + */ + protected function _toHtml() + { + return $this->currentCustomer->getCustomerId() ? parent::_toHtml() : ''; + } } diff --git a/app/code/Magento/Review/Block/Form.php b/app/code/Magento/Review/Block/Form.php index 88429e9c1195415d153f9b0ad4e7b0a9fe46bb07..9682f444c4100126155f6daa0ecde88b656ce156 100644 --- a/app/code/Magento/Review/Block/Form.php +++ b/app/code/Magento/Review/Block/Form.php @@ -112,6 +112,7 @@ class Form extends \Magento\Framework\View\Element\Template $this->httpContext = $httpContext; $this->customerUrl = $customerUrl; parent::__construct($context, $data); + $this->_isScopePrivate = true; } /** diff --git a/app/code/Magento/Review/Controller/Customer/View.php b/app/code/Magento/Review/Controller/Customer/View.php index 8470249f465e4f6501a7eb46ab588a65fee56a90..d1ea95e7afc90d83b7b9d44fd020297f57488e1d 100644 --- a/app/code/Magento/Review/Controller/Customer/View.php +++ b/app/code/Magento/Review/Controller/Customer/View.php @@ -8,6 +8,22 @@ namespace Magento\Review\Controller\Customer; class View extends \Magento\Review\Controller\Customer { + /** @var \Magento\Review\Model\ReviewFactory */ + protected $reviewFactory; + + /** + * @param \Magento\Framework\App\Action\Context $context + * @param \Magento\Customer\Model\Session $customerSession + * @param \Magento\Review\Model\ReviewFactory $reviewFactory + */ + public function __construct( + \Magento\Framework\App\Action\Context $context, + \Magento\Customer\Model\Session $customerSession, + \Magento\Review\Model\ReviewFactory $reviewFactory + ) { + parent::__construct($context, $customerSession); + $this->reviewFactory = $reviewFactory; + } /** * Render review details * @@ -15,6 +31,10 @@ class View extends \Magento\Review\Controller\Customer */ public function execute() { + $review = $this->reviewFactory->create()->load($this->getRequest()->getParam('id')); + if ($review->getCustomerId() != $this->_customerSession->getCustomerId()) { + return $this->_forward('noroute'); + } $this->_view->loadLayout(); if ($navigationBlock = $this->_view->getLayout()->getBlock('customer_account_navigation')) { $navigationBlock->setActive('review/customer'); diff --git a/app/code/Magento/Review/Test/Unit/Block/Customer/RecentTest.php b/app/code/Magento/Review/Test/Unit/Block/Customer/RecentTest.php index f3d2edd7e4095750ec79a998ef37c214f9dfc97c..b04e90e9cc7c194bb55058040fb2fb5684fc018d 100644 --- a/app/code/Magento/Review/Test/Unit/Block/Customer/RecentTest.php +++ b/app/code/Magento/Review/Test/Unit/Block/Customer/RecentTest.php @@ -135,6 +135,6 @@ class RecentTest extends \PHPUnit_Framework_TestCase $this->returnValue($this->collection) ); - $this->assertSame($this->collection, $this->object->getCollection()); + $this->assertSame($this->collection, $this->object->getReviews()); } } diff --git a/app/code/Magento/Review/composer.json b/app/code/Magento/Review/composer.json index 8f961213f7b34a0da431534a402c1b818d09a957..3ac2d8c5deab3948d3df18d6cea4946bdac565c4 100644 --- a/app/code/Magento/Review/composer.json +++ b/app/code/Magento/Review/composer.json @@ -15,8 +15,7 @@ "magento/magento-composer-installer": "*" }, "suggest": { - "magento/module-cookie": "0.42.0-beta11", - "magento/module-core": "0.42.0-beta11" + "magento/module-cookie": "0.42.0-beta11" }, "type": "magento2-module", "version": "0.42.0-beta11", diff --git a/app/code/Magento/Review/etc/config.xml b/app/code/Magento/Review/etc/config.xml index 0dc643e9ea43169759e13fcc12adee5f6da4de9a..1e46875b6f3d5b5d7039771ee813f121bacbc029 100644 --- a/app/code/Magento/Review/etc/config.xml +++ b/app/code/Magento/Review/etc/config.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Core/etc/config.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Store/etc/config.xsd"> <default> <catalog> <review> diff --git a/app/code/Magento/Review/etc/frontend/page_types.xml b/app/code/Magento/Review/etc/frontend/page_types.xml index 113b431de418f9aeb97c2b31649fcd7b14b376b1..63fc47b5e2400951e22f07e860cd19cabb7dc541 100644 --- a/app/code/Magento/Review/etc/frontend/page_types.xml +++ b/app/code/Magento/Review/etc/frontend/page_types.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> -<page_types xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../Core/etc/page_types.xsd"> +<page_types xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_types.xsd"> <type id="review_customer_index" label="Customer My Account Product Reviews"/> <type id="review_customer_view" label="Customer My Account Review Details"/> <type id="review_product_list" label="Catalog Product Reviews List"/> diff --git a/app/code/Magento/Review/etc/module.xml b/app/code/Magento/Review/etc/module.xml index ee43b6223153ea479b1e96ffd2b62e218223779c..226eb11213df86f11563660935e6075c5767608c 100644 --- a/app/code/Magento/Review/etc/module.xml +++ b/app/code/Magento/Review/etc/module.xml @@ -9,7 +9,6 @@ <module name="Magento_Review" setup_version="2.0.0"> <sequence> <module name="Magento_Catalog"/> - <module name="Magento_Core"/> <module name="Magento_Store"/> </sequence> </module> diff --git a/app/code/Magento/Review/view/frontend/layout/customer_account_index.xml b/app/code/Magento/Review/view/frontend/layout/customer_account_index.xml index 799a455f7e0f463ec93837c756085fbd45cfb0f8..7434c634ab44c53c0c10f2180e82d42031f0b390 100644 --- a/app/code/Magento/Review/view/frontend/layout/customer_account_index.xml +++ b/app/code/Magento/Review/view/frontend/layout/customer_account_index.xml @@ -8,7 +8,7 @@ <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd"> <body> <referenceContainer name="content"> - <block class="Magento\Review\Block\Customer\Recent" name="customer_account_dashboard_info1" template="customer/recent.phtml" after="customer_account_dashboard_address" cacheable="false"/> + <block class="Magento\Review\Block\Customer\Recent" name="customer_account_dashboard_info1" template="customer/recent.phtml" after="customer_account_dashboard_address"/> </referenceContainer> </body> </page> diff --git a/app/code/Magento/Review/view/frontend/layout/review_customer_index.xml b/app/code/Magento/Review/view/frontend/layout/review_customer_index.xml index 01a6340b9f2bc125783abc69f20482a0abae4b59..23bfd524f3265ceaccef483e8a9e7465895523cb 100644 --- a/app/code/Magento/Review/view/frontend/layout/review_customer_index.xml +++ b/app/code/Magento/Review/view/frontend/layout/review_customer_index.xml @@ -9,7 +9,7 @@ <update handle="customer_account"/> <body> <referenceContainer name="content"> - <block class="Magento\Review\Block\Customer\ListCustomer" name="review_customer_list" template="customer/list.phtml" cacheable="false"/> + <block class="Magento\Review\Block\Customer\ListCustomer" name="review_customer_list" template="customer/list.phtml"/> </referenceContainer> </body> </page> diff --git a/app/code/Magento/Review/view/frontend/layout/review_customer_view.xml b/app/code/Magento/Review/view/frontend/layout/review_customer_view.xml index 43e7ba2afa619b3219ee10e1a3d447dd0259ee13..5895da97549768a18e46377139534f4c378436c6 100644 --- a/app/code/Magento/Review/view/frontend/layout/review_customer_view.xml +++ b/app/code/Magento/Review/view/frontend/layout/review_customer_view.xml @@ -9,7 +9,7 @@ <update handle="customer_account"/> <body> <referenceContainer name="content"> - <block class="Magento\Review\Block\Customer\View" name="customers_review" cacheable="false"/> + <block class="Magento\Review\Block\Customer\View" name="customers_review"/> </referenceContainer> </body> </page> diff --git a/app/code/Magento/Review/view/frontend/templates/customer/list.phtml b/app/code/Magento/Review/view/frontend/templates/customer/list.phtml index 4b28025a528c3a417e8a9636f7c33963e3d5eb78..e90990095151a90e6277319328689994401f1534 100644 --- a/app/code/Magento/Review/view/frontend/templates/customer/list.phtml +++ b/app/code/Magento/Review/view/frontend/templates/customer/list.phtml @@ -5,9 +5,9 @@ */ // @codingStandardsIgnoreFile - +/** @var \Magento\Review\Block\Customer\ListCustomer $block */ ?> -<?php if ($block->getCollection() && $block->count()): ?> +<?php if ($block->getReviews() && count($block->getReviews())): ?> <div class="table-wrapper reviews"> <table class="data table table-reviews" id="my-reviews-table"> <caption class="table-caption"><?php echo __('Product Reviews') ?></caption> @@ -21,7 +21,7 @@ </tr> </thead> <tbody> - <?php foreach ($block->getCollection() as $_review): ?> + <?php foreach ($block->getReviews() as $_review): ?> <tr> <td data-th="<?php echo $block->escapeHtml(__('Created')) ?>" class="col date"><?php echo $block->dateFormat($_review->getReviewCreatedAt()); ?></td> <td data-th="<?php echo $block->escapeHtml(__('Product Name')) ?>" class="col item"> diff --git a/app/code/Magento/Review/view/frontend/templates/customer/recent.phtml b/app/code/Magento/Review/view/frontend/templates/customer/recent.phtml index 84a83bedefb087cc0582deebf44d6ea54e00d00b..6bb7aa429fcef85f443be27e2634faaded6e10f8 100644 --- a/app/code/Magento/Review/view/frontend/templates/customer/recent.phtml +++ b/app/code/Magento/Review/view/frontend/templates/customer/recent.phtml @@ -12,7 +12,7 @@ /** @var $block \Magento\Review\Block\Customer\Recent */ ?> -<?php if ($block->getCollection() && $block->count()): ?> +<?php if ($block->getReviews() && count($block->getReviews())): ?> <div class="block block-reviews-dashboard"> <div class="block-title"> <strong><?php echo __('My Recent Reviews') ?></strong> @@ -20,7 +20,7 @@ </div> <div class="block-content"> <ol class="items"> - <?php foreach ($block->getCollection() as $_review): ?> + <?php foreach ($block->getReviews() as $_review): ?> <li class="item"> <strong class="product-name"><a href="<?php echo $block->getReviewUrl($_review->getReviewId()) ?>"><?php echo $block->escapeHtml($_review->getName()) ?></a></strong> <?php if ($_review->getSum()): ?> diff --git a/app/code/Magento/Review/view/frontend/templates/customer/view.phtml b/app/code/Magento/Review/view/frontend/templates/customer/view.phtml index 34ab7ba21d39baffbcdf091d9127fb2cefb0e8d7..0a260e7c57a3fbe4398747fb6432f7518bf0dbdc 100644 --- a/app/code/Magento/Review/view/frontend/templates/customer/view.phtml +++ b/app/code/Magento/Review/view/frontend/templates/customer/view.phtml @@ -29,7 +29,7 @@ <div class="review-details"> <?php if ($block->getRating() && $block->getRating()->getSize()): ?> <div class="title"> - <strong><?php echo($block->isReviewOwner()) ? __('Your Review') : __('Review'); ?></strong> + <strong><?php echo __('Your Review'); ?></strong> </div> <div class="customer-review-rating"> <?php foreach ($block->getRating() as $_rating): ?> diff --git a/app/code/Magento/Rss/etc/frontend/page_types.xml b/app/code/Magento/Rss/etc/frontend/page_types.xml index b252b8816bb399134cb281360e6e1927cfc09cb2..f834bd2faf9f9ccd1fa13abd01929bccde29db45 100644 --- a/app/code/Magento/Rss/etc/frontend/page_types.xml +++ b/app/code/Magento/Rss/etc/frontend/page_types.xml @@ -5,6 +5,6 @@ * See COPYING.txt for license details. */ --> -<page_types xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../Core/etc/page_types.xsd"> +<page_types xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_types.xsd"> <type id="rss_index_index" label="RSS Feeds List"/> </page_types> diff --git a/app/code/Magento/Rule/etc/module.xml b/app/code/Magento/Rule/etc/module.xml index b1ee185e3ec299014f691f1cb80ea6f8220fc61f..3a3987c2fb25336a2a7d1e174c36bfd051e7f9ce 100644 --- a/app/code/Magento/Rule/etc/module.xml +++ b/app/code/Magento/Rule/etc/module.xml @@ -8,7 +8,6 @@ <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd"> <module name="Magento_Rule" setup_version="2.0.0"> <sequence> - <module name="Magento_Core"/> <module name="Magento_Store"/> </sequence> </module> diff --git a/app/code/Magento/Sales/Api/Data/CreditmemoCommentInterface.php b/app/code/Magento/Sales/Api/Data/CreditmemoCommentInterface.php index 4d8ce351eddeb4cfa5f96c0ea73a963465e9e938..28afae3c0f9528343770c22dfe283b82324a7c5a 100644 --- a/app/code/Magento/Sales/Api/Data/CreditmemoCommentInterface.php +++ b/app/code/Magento/Sales/Api/Data/CreditmemoCommentInterface.php @@ -124,4 +124,21 @@ interface CreditmemoCommentInterface extends \Magento\Framework\Api\ExtensibleDa * @return $this */ public function setComment($comment); + + /** + * Retrieve existing extension attributes object or create a new one. + * + * @return \Magento\Sales\Api\Data\CreditmemoCommentExtensionInterface|null + */ + public function getExtensionAttributes(); + + /** + * Set an extension attributes object. + * + * @param \Magento\Sales\Api\Data\CreditmemoCommentExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes( + \Magento\Sales\Api\Data\CreditmemoCommentExtensionInterface $extensionAttributes + ); } diff --git a/app/code/Magento/Sales/Api/Data/CreditmemoInterface.php b/app/code/Magento/Sales/Api/Data/CreditmemoInterface.php index 8063c5d64e3aa6c766f21955d9731c30c61f6be1..205d5c37b3f1033132c9679a240e036223a2e5e8 100644 --- a/app/code/Magento/Sales/Api/Data/CreditmemoInterface.php +++ b/app/code/Magento/Sales/Api/Data/CreditmemoInterface.php @@ -960,4 +960,19 @@ interface CreditmemoInterface extends \Magento\Framework\Api\ExtensibleDataInter * @return $this */ public function setDiscountDescription($description); + + /** + * Retrieve existing extension attributes object or create a new one. + * + * @return \Magento\Sales\Api\Data\CreditmemoExtensionInterface|null + */ + public function getExtensionAttributes(); + + /** + * Set an extension attributes object. + * + * @param \Magento\Sales\Api\Data\CreditmemoExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes(\Magento\Sales\Api\Data\CreditmemoExtensionInterface $extensionAttributes); } diff --git a/app/code/Magento/Sales/Api/Data/CreditmemoItemInterface.php b/app/code/Magento/Sales/Api/Data/CreditmemoItemInterface.php index c01bb4c6ee75d2ebb127aa20d6211cc3f0a95892..f93eedf1cff1f281cdc2ca9cbff68719cc67f6bb 100644 --- a/app/code/Magento/Sales/Api/Data/CreditmemoItemInterface.php +++ b/app/code/Magento/Sales/Api/Data/CreditmemoItemInterface.php @@ -645,4 +645,21 @@ interface CreditmemoItemInterface extends \Magento\Framework\Api\ExtensibleDataI * @return $this */ public function setWeeeTaxAppliedRowAmount($amount); + + /** + * Retrieve existing extension attributes object or create a new one. + * + * @return \Magento\Sales\Api\Data\CreditmemoItemExtensionInterface|null + */ + public function getExtensionAttributes(); + + /** + * Set an extension attributes object. + * + * @param \Magento\Sales\Api\Data\CreditmemoItemExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes( + \Magento\Sales\Api\Data\CreditmemoItemExtensionInterface $extensionAttributes + ); } diff --git a/app/code/Magento/Sales/Api/Data/InvoiceCommentInterface.php b/app/code/Magento/Sales/Api/Data/InvoiceCommentInterface.php index 05e605a530f94a822ed1496cf73abc5729b119c1..10c86a870231cd4cd0c24a165c1cc5cf022bcdaf 100644 --- a/app/code/Magento/Sales/Api/Data/InvoiceCommentInterface.php +++ b/app/code/Magento/Sales/Api/Data/InvoiceCommentInterface.php @@ -122,4 +122,21 @@ interface InvoiceCommentInterface extends \Magento\Framework\Api\ExtensibleDataI * @return $this */ public function setComment($comment); + + /** + * Retrieve existing extension attributes object or create a new one. + * + * @return \Magento\Sales\Api\Data\InvoiceCommentExtensionInterface|null + */ + public function getExtensionAttributes(); + + /** + * Set an extension attributes object. + * + * @param \Magento\Sales\Api\Data\InvoiceCommentExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes( + \Magento\Sales\Api\Data\InvoiceCommentExtensionInterface $extensionAttributes + ); } diff --git a/app/code/Magento/Sales/Api/Data/InvoiceInterface.php b/app/code/Magento/Sales/Api/Data/InvoiceInterface.php index 6cd291831bf5892bb8180223d8b007a48eb082d3..e17decc98e0bbd364313f43a2d7373cbfd7990cc 100644 --- a/app/code/Magento/Sales/Api/Data/InvoiceInterface.php +++ b/app/code/Magento/Sales/Api/Data/InvoiceInterface.php @@ -881,4 +881,19 @@ interface InvoiceInterface extends \Magento\Framework\Api\ExtensibleDataInterfac * @return $this */ public function setDiscountDescription($description); + + /** + * Retrieve existing extension attributes object or create a new one. + * + * @return \Magento\Sales\Api\Data\InvoiceExtensionInterface|null + */ + public function getExtensionAttributes(); + + /** + * Set an extension attributes object. + * + * @param \Magento\Sales\Api\Data\InvoiceExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes(\Magento\Sales\Api\Data\InvoiceExtensionInterface $extensionAttributes); } diff --git a/app/code/Magento/Sales/Api/Data/InvoiceItemInterface.php b/app/code/Magento/Sales/Api/Data/InvoiceItemInterface.php index 127318da2ef1ca63d43a73c1958fff462ee03cf8..6dc2d85022e727245aaa71475e4355f2ef05060c 100644 --- a/app/code/Magento/Sales/Api/Data/InvoiceItemInterface.php +++ b/app/code/Magento/Sales/Api/Data/InvoiceItemInterface.php @@ -471,4 +471,19 @@ interface InvoiceItemInterface extends \Magento\Framework\Api\ExtensibleDataInte * @return $this */ public function setBaseHiddenTaxAmount($amount); + + /** + * Retrieve existing extension attributes object or create a new one. + * + * @return \Magento\Sales\Api\Data\InvoiceItemExtensionInterface|null + */ + public function getExtensionAttributes(); + + /** + * Set an extension attributes object. + * + * @param \Magento\Sales\Api\Data\InvoiceItemExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes(\Magento\Sales\Api\Data\InvoiceItemExtensionInterface $extensionAttributes); } diff --git a/app/code/Magento/Sales/Api/Data/OrderAddressInterface.php b/app/code/Magento/Sales/Api/Data/OrderAddressInterface.php index 10c62d33ee5ce320785a1cee71af02e9c7208f89..9e9e53f1727a00ba597fae6a2e4402c943b717c0 100644 --- a/app/code/Magento/Sales/Api/Data/OrderAddressInterface.php +++ b/app/code/Magento/Sales/Api/Data/OrderAddressInterface.php @@ -508,4 +508,19 @@ interface OrderAddressInterface extends \Magento\Framework\Api\ExtensibleDataInt * @return $this */ public function setVatRequestSuccess($vatRequestSuccess); + + /** + * Retrieve existing extension attributes object or create a new one. + * + * @return \Magento\Sales\Api\Data\OrderAddressExtensionInterface|null + */ + public function getExtensionAttributes(); + + /** + * Set an extension attributes object. + * + * @param \Magento\Sales\Api\Data\OrderAddressExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes(\Magento\Sales\Api\Data\OrderAddressExtensionInterface $extensionAttributes); } diff --git a/app/code/Magento/Sales/Api/Data/OrderInterface.php b/app/code/Magento/Sales/Api/Data/OrderInterface.php index b01e0d81d76047e60d7aad7bd8ac56269c5b1a88..7bd62fbe1c3228b2241690b981a7f0ab8c2f84eb 100644 --- a/app/code/Magento/Sales/Api/Data/OrderInterface.php +++ b/app/code/Magento/Sales/Api/Data/OrderInterface.php @@ -2672,4 +2672,19 @@ interface OrderInterface extends \Magento\Framework\Api\ExtensibleDataInterface * @return $this */ public function setBaseShippingInclTax($amount); + + /** + * Retrieve existing extension attributes object or create a new one. + * + * @return \Magento\Sales\Api\Data\OrderExtensionInterface|null + */ + public function getExtensionAttributes(); + + /** + * Set an extension attributes object. + * + * @param \Magento\Sales\Api\Data\OrderExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes(\Magento\Sales\Api\Data\OrderExtensionInterface $extensionAttributes); } diff --git a/app/code/Magento/Sales/Api/Data/OrderItemInterface.php b/app/code/Magento/Sales/Api/Data/OrderItemInterface.php index 286f79aefd34631c48fb7d1e07e77881e3cdd8cf..6e59b03a98370feb88a6d6522c9fb84560e12bf3 100644 --- a/app/code/Magento/Sales/Api/Data/OrderItemInterface.php +++ b/app/code/Magento/Sales/Api/Data/OrderItemInterface.php @@ -1797,4 +1797,19 @@ interface OrderItemInterface extends \Magento\Framework\Api\ExtensibleDataInterf * @return $this */ public function setBaseWeeeTaxRowDisposition($baseWeeeTaxRowDisposition); + + /** + * Retrieve existing extension attributes object or create a new one. + * + * @return \Magento\Sales\Api\Data\OrderItemExtensionInterface|null + */ + public function getExtensionAttributes(); + + /** + * Set an extension attributes object. + * + * @param \Magento\Sales\Api\Data\OrderItemExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes(\Magento\Sales\Api\Data\OrderItemExtensionInterface $extensionAttributes); } diff --git a/app/code/Magento/Sales/Api/Data/OrderPaymentInterface.php b/app/code/Magento/Sales/Api/Data/OrderPaymentInterface.php index d080a1cd765a3446e8ddb3eb285bbed44079b09a..44fda2cdbcc1c5424b4d8518ae9917cefb3c1932 100644 --- a/app/code/Magento/Sales/Api/Data/OrderPaymentInterface.php +++ b/app/code/Magento/Sales/Api/Data/OrderPaymentInterface.php @@ -1035,4 +1035,19 @@ interface OrderPaymentInterface extends \Magento\Framework\Api\ExtensibleDataInt * @return $this */ public function setAddressStatus($addressStatus); + + /** + * Retrieve existing extension attributes object or create a new one. + * + * @return \Magento\Sales\Api\Data\OrderPaymentExtensionInterface|null + */ + public function getExtensionAttributes(); + + /** + * Set an extension attributes object. + * + * @param \Magento\Sales\Api\Data\OrderPaymentExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes(\Magento\Sales\Api\Data\OrderPaymentExtensionInterface $extensionAttributes); } diff --git a/app/code/Magento/Sales/Api/Data/OrderStatusHistoryInterface.php b/app/code/Magento/Sales/Api/Data/OrderStatusHistoryInterface.php index dafc6547d77052f68cb63ed0d5a531a0b68f2fce..4ef7daf322d37f0ca1b26f0ab7501e7ad5a79fcf 100644 --- a/app/code/Magento/Sales/Api/Data/OrderStatusHistoryInterface.php +++ b/app/code/Magento/Sales/Api/Data/OrderStatusHistoryInterface.php @@ -161,4 +161,21 @@ interface OrderStatusHistoryInterface extends \Magento\Framework\Api\ExtensibleD * @return $this */ public function setEntityName($entityName); + + /** + * Retrieve existing extension attributes object or create a new one. + * + * @return \Magento\Sales\Api\Data\OrderStatusHistoryExtensionInterface|null + */ + public function getExtensionAttributes(); + + /** + * Set an extension attributes object. + * + * @param \Magento\Sales\Api\Data\OrderStatusHistoryExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes( + \Magento\Sales\Api\Data\OrderStatusHistoryExtensionInterface $extensionAttributes + ); } diff --git a/app/code/Magento/Sales/Api/Data/ShipmentCommentInterface.php b/app/code/Magento/Sales/Api/Data/ShipmentCommentInterface.php index 56346939103c84913e7bd883235b69e97fce9463..213b7c2e5e4931bd9f9295aee3b537f817891a68 100644 --- a/app/code/Magento/Sales/Api/Data/ShipmentCommentInterface.php +++ b/app/code/Magento/Sales/Api/Data/ShipmentCommentInterface.php @@ -122,4 +122,21 @@ interface ShipmentCommentInterface extends \Magento\Framework\Api\ExtensibleData * @return $this */ public function setComment($comment); + + /** + * Retrieve existing extension attributes object or create a new one. + * + * @return \Magento\Sales\Api\Data\ShipmentCommentExtensionInterface|null + */ + public function getExtensionAttributes(); + + /** + * Set an extension attributes object. + * + * @param \Magento\Sales\Api\Data\ShipmentCommentExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes( + \Magento\Sales\Api\Data\ShipmentCommentExtensionInterface $extensionAttributes + ); } diff --git a/app/code/Magento/Sales/Api/Data/ShipmentInterface.php b/app/code/Magento/Sales/Api/Data/ShipmentInterface.php index dbd2854e9ce220d14bf785de3ee60339336d619a..3af3b16ebf66154df3527aa22d298881cab5466e 100644 --- a/app/code/Magento/Sales/Api/Data/ShipmentInterface.php +++ b/app/code/Magento/Sales/Api/Data/ShipmentInterface.php @@ -350,4 +350,19 @@ interface ShipmentInterface extends \Magento\Framework\Api\ExtensibleDataInterfa * @return $this */ public function setUpdatedAt($timestamp); + + /** + * Retrieve existing extension attributes object or create a new one. + * + * @return \Magento\Sales\Api\Data\ShipmentExtensionInterface|null + */ + public function getExtensionAttributes(); + + /** + * Set an extension attributes object. + * + * @param \Magento\Sales\Api\Data\ShipmentExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes(\Magento\Sales\Api\Data\ShipmentExtensionInterface $extensionAttributes); } diff --git a/app/code/Magento/Sales/Api/Data/ShipmentItemInterface.php b/app/code/Magento/Sales/Api/Data/ShipmentItemInterface.php index 5b78e92571050f0a0cb7f40f83c3969f9916c54b..ad75b14cde2a155b5e684da289997b1d488b324c 100644 --- a/app/code/Magento/Sales/Api/Data/ShipmentItemInterface.php +++ b/app/code/Magento/Sales/Api/Data/ShipmentItemInterface.php @@ -244,4 +244,19 @@ interface ShipmentItemInterface extends \Magento\Framework\Api\ExtensibleDataInt * @return $this */ public function setSku($sku); + + /** + * Retrieve existing extension attributes object or create a new one. + * + * @return \Magento\Sales\Api\Data\ShipmentItemExtensionInterface|null + */ + public function getExtensionAttributes(); + + /** + * Set an extension attributes object. + * + * @param \Magento\Sales\Api\Data\ShipmentItemExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes(\Magento\Sales\Api\Data\ShipmentItemExtensionInterface $extensionAttributes); } diff --git a/app/code/Magento/Sales/Api/Data/ShipmentPackageInterface.php b/app/code/Magento/Sales/Api/Data/ShipmentPackageInterface.php index 9172405a3f7d531a9da67966c552e6a8a00b3ba9..00b79d6f50e6d725fadb4a92e2ced0a456179cd0 100644 --- a/app/code/Magento/Sales/Api/Data/ShipmentPackageInterface.php +++ b/app/code/Magento/Sales/Api/Data/ShipmentPackageInterface.php @@ -13,4 +13,20 @@ namespace Magento\Sales\Api\Data; */ interface ShipmentPackageInterface extends \Magento\Framework\Api\ExtensibleDataInterface { + /** + * Retrieve existing extension attributes object or create a new one. + * + * @return \Magento\Sales\Api\Data\ShipmentPackageExtensionInterface|null + */ + public function getExtensionAttributes(); + + /** + * Set an extension attributes object. + * + * @param \Magento\Sales\Api\Data\ShipmentPackageExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes( + \Magento\Sales\Api\Data\ShipmentPackageExtensionInterface $extensionAttributes + ); } diff --git a/app/code/Magento/Sales/Api/Data/ShipmentTrackInterface.php b/app/code/Magento/Sales/Api/Data/ShipmentTrackInterface.php index 7160fc3fff2d8a7c415d5a143f5192ed08dbc9cb..7ace1ead4114db6c8c81c9a3921d56f1e9195727 100644 --- a/app/code/Magento/Sales/Api/Data/ShipmentTrackInterface.php +++ b/app/code/Magento/Sales/Api/Data/ShipmentTrackInterface.php @@ -218,4 +218,21 @@ interface ShipmentTrackInterface extends \Magento\Framework\Api\ExtensibleDataIn * @return $this */ public function setCarrierCode($code); + + /** + * Retrieve existing extension attributes object or create a new one. + * + * @return \Magento\Sales\Api\Data\ShipmentTrackExtensionInterface|null + */ + public function getExtensionAttributes(); + + /** + * Set an extension attributes object. + * + * @param \Magento\Sales\Api\Data\ShipmentTrackExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes( + \Magento\Sales\Api\Data\ShipmentTrackExtensionInterface $extensionAttributes + ); } diff --git a/app/code/Magento/Sales/Api/Data/TransactionInterface.php b/app/code/Magento/Sales/Api/Data/TransactionInterface.php index 1e350f1388372111181a71a1b276912925274d42..224d9765582f0e3381846f159814103e72111351 100644 --- a/app/code/Magento/Sales/Api/Data/TransactionInterface.php +++ b/app/code/Magento/Sales/Api/Data/TransactionInterface.php @@ -212,4 +212,19 @@ interface TransactionInterface extends \Magento\Framework\Api\ExtensibleDataInte * @throws \Magento\Framework\Exception\LocalizedException */ public function setAdditionalInformation($key, $value); + + /** + * Retrieve existing extension attributes object or create a new one. + * + * @return \Magento\Sales\Api\Data\TransactionExtensionInterface|null + */ + public function getExtensionAttributes(); + + /** + * Set an extension attributes object. + * + * @param \Magento\Sales\Api\Data\TransactionExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes(\Magento\Sales\Api\Data\TransactionExtensionInterface $extensionAttributes); } diff --git a/app/code/Magento/Sales/Block/Guest/Link.php b/app/code/Magento/Sales/Block/Guest/Link.php index 225a0be5f159550ecae71b6e1322117ad7799c26..4e432ceff508910699f81b2cd4bf90ca9e2cf161 100644 --- a/app/code/Magento/Sales/Block/Guest/Link.php +++ b/app/code/Magento/Sales/Block/Guest/Link.php @@ -33,7 +33,6 @@ class Link extends \Magento\Framework\View\Element\Html\Link\Current ) { parent::__construct($context, $defaultPath, $data); $this->httpContext = $httpContext; - $this->_isScopePrivate = true; } /** diff --git a/app/code/Magento/Sales/Block/Order/History.php b/app/code/Magento/Sales/Block/Order/History.php index 196382cbd7ee46f1f65cd6c8d27fbe112adb2993..adee793ade5d1ffff85a5db62af7121791627c57 100644 --- a/app/code/Magento/Sales/Block/Order/History.php +++ b/app/code/Magento/Sales/Block/Order/History.php @@ -30,6 +30,9 @@ class History extends \Magento\Framework\View\Element\Template */ protected $_orderConfig; + /** @var \Magento\Sales\Model\Resource\Order\Collection */ + protected $orders; + /** * @param \Magento\Framework\View\Element\Template\Context $context * @param \Magento\Sales\Model\Resource\Order\CollectionFactory $orderCollectionFactory @@ -57,39 +60,50 @@ class History extends \Magento\Framework\View\Element\Template protected function _construct() { parent::_construct(); - - $orders = $this->_orderCollectionFactory->create()->addFieldToSelect( - '*' - )->addFieldToFilter( - 'customer_id', - $this->_customerSession->getCustomerId() - )->addFieldToFilter( - 'status', - ['in' => $this->_orderConfig->getVisibleOnFrontStatuses()] - )->setOrder( - 'created_at', - 'desc' - ); - - $this->setOrders($orders); $this->pageConfig->getTitle()->set(__('My Orders')); } + /** + * @return bool|\Magento\Sales\Model\Resource\Order\Collection + */ + public function getOrders() + { + if (!($customerId = $this->_customerSession->getCustomerId())) { + return false; + } + if (!$this->orders) { + $this->orders = $this->_orderCollectionFactory->create()->addFieldToSelect( + '*' + )->addFieldToFilter( + 'customer_id', + $customerId + )->addFieldToFilter( + 'status', + ['in' => $this->_orderConfig->getVisibleOnFrontStatuses()] + )->setOrder( + 'created_at', + 'desc' + ); + } + return $this->orders; + } + /** * @return $this */ protected function _prepareLayout() { parent::_prepareLayout(); - - $pager = $this->getLayout()->createBlock( - 'Magento\Theme\Block\Html\Pager', - 'sales.order.history.pager' - )->setCollection( - $this->getOrders() - ); - $this->setChild('pager', $pager); - $this->getOrders()->load(); + if ($this->getOrders()) { + $pager = $this->getLayout()->createBlock( + 'Magento\Theme\Block\Html\Pager', + 'sales.order.history.pager' + )->setCollection( + $this->getOrders() + ); + $this->setChild('pager', $pager); + $this->getOrders()->load(); + } return $this; } @@ -107,7 +121,7 @@ class History extends \Magento\Framework\View\Element\Template */ public function getViewUrl($order) { - return $this->getUrl('*/*/view', ['order_id' => $order->getId()]); + return $this->getUrl('sales/order/view', ['order_id' => $order->getId()]); } /** @@ -116,7 +130,7 @@ class History extends \Magento\Framework\View\Element\Template */ public function getTrackUrl($order) { - return $this->getUrl('*/*/track', ['order_id' => $order->getId()]); + return $this->getUrl('sales/order/track', ['order_id' => $order->getId()]); } /** @@ -125,7 +139,7 @@ class History extends \Magento\Framework\View\Element\Template */ public function getReorderUrl($order) { - return $this->getUrl('*/*/reorder', ['order_id' => $order->getId()]); + return $this->getUrl('sales/order/reorder', ['order_id' => $order->getId()]); } /** diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order.php b/app/code/Magento/Sales/Controller/Adminhtml/Order.php index 3a2d6a0ea4e98ec55278223d7d6dceb4d6585b78..ee6934955fc08c5d7431b1a8f04ded1208ff0f30 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order.php @@ -50,7 +50,7 @@ class Order extends \Magento\Backend\App\Action protected $resultRedirectFactory; /** - * @var \Magento\Framework\Controller\Result\JSONFactory + * @var \Magento\Framework\Controller\Result\JsonFactory */ protected $resultJsonFactory; @@ -71,7 +71,7 @@ class Order extends \Magento\Backend\App\Action * @param \Magento\Framework\Translate\InlineInterface $translateInline * @param \Magento\Framework\View\Result\PageFactory $resultPageFactory * @param \Magento\Backend\Model\View\Result\RedirectFactory $resultRedirectFactory - * @param \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory + * @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory * @param \Magento\Framework\View\Result\LayoutFactory $resultLayoutFactory * @param \Magento\Framework\Controller\Result\RawFactory $resultRawFactory */ @@ -82,7 +82,7 @@ class Order extends \Magento\Backend\App\Action \Magento\Framework\Translate\InlineInterface $translateInline, \Magento\Framework\View\Result\PageFactory $resultPageFactory, \Magento\Backend\Model\View\Result\RedirectFactory $resultRedirectFactory, - \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory, + \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory, \Magento\Framework\View\Result\LayoutFactory $resultLayoutFactory, \Magento\Framework\Controller\Result\RawFactory $resultRawFactory ) { diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/CommentsHistory.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/CommentsHistory.php index 737fa3bfed281122037be5dcffbba176b3dc76d6..0e56021124b3e5f7e69d05f733bac0b188d08ce5 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/CommentsHistory.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/CommentsHistory.php @@ -22,7 +22,7 @@ class CommentsHistory extends \Magento\Sales\Controller\Adminhtml\Order * @param \Magento\Framework\Translate\InlineInterface $translateInline * @param \Magento\Framework\View\Result\PageFactory $resultPageFactory * @param \Magento\Backend\Model\View\Result\RedirectFactory $resultRedirectFactory - * @param \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory + * @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory * @param \Magento\Framework\View\Result\LayoutFactory $resultLayoutFactory * @param \Magento\Framework\Controller\Result\RawFactory $resultRawFactory * @param \Magento\Framework\View\LayoutFactory $layoutFactory @@ -36,7 +36,7 @@ class CommentsHistory extends \Magento\Sales\Controller\Adminhtml\Order \Magento\Framework\Translate\InlineInterface $translateInline, \Magento\Framework\View\Result\PageFactory $resultPageFactory, \Magento\Backend\Model\View\Result\RedirectFactory $resultRedirectFactory, - \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory, + \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory, \Magento\Framework\View\Result\LayoutFactory $resultLayoutFactory, \Magento\Framework\Controller\Result\RawFactory $resultRawFactory, \Magento\Framework\View\LayoutFactory $layoutFactory diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/AddComment.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/AddComment.php index c3f16b9f805888372dbd95cbfb08e4fc1f435b8a..63b1f9055bdd1e78a525a655e5cef4e96595048d 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/AddComment.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/AddComment.php @@ -26,7 +26,7 @@ class AddComment extends \Magento\Backend\App\Action protected $pagePageFactory; /** - * @var \Magento\Framework\Controller\Result\JSONFactory + * @var \Magento\Framework\Controller\Result\JsonFactory */ protected $resultJsonFactory; @@ -40,7 +40,7 @@ class AddComment extends \Magento\Backend\App\Action * @param \Magento\Sales\Controller\Adminhtml\Order\CreditmemoLoader $creditmemoLoader * @param CreditmemoSender $creditmemoSender * @param \Magento\Framework\View\Result\PageFactory $resultPageFactory - * @param \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory + * @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory * @param \Magento\Framework\Controller\Result\RawFactory $resultRawFactory */ public function __construct( @@ -48,7 +48,7 @@ class AddComment extends \Magento\Backend\App\Action \Magento\Sales\Controller\Adminhtml\Order\CreditmemoLoader $creditmemoLoader, CreditmemoSender $creditmemoSender, \Magento\Framework\View\Result\PageFactory $resultPageFactory, - \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory, + \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory, \Magento\Framework\Controller\Result\RawFactory $resultRawFactory ) { $this->creditmemoLoader = $creditmemoLoader; @@ -70,7 +70,7 @@ class AddComment extends \Magento\Backend\App\Action /** * Add comment to creditmemo history * - * @return \Magento\Framework\Controller\Result\Raw|\Magento\Framework\Controller\Result\JSON + * @return \Magento\Framework\Controller\Result\Raw|\Magento\Framework\Controller\Result\Json */ public function execute() { diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/UpdateQty.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/UpdateQty.php index 704d28d8c2d5af5a9a3b48484eb4fdc8c3d9970d..1757fdfb80248f31624fc10e1207faddee02f27d 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/UpdateQty.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/UpdateQty.php @@ -20,7 +20,7 @@ class UpdateQty extends \Magento\Backend\App\Action protected $pagePageFactory; /** - * @var \Magento\Framework\Controller\Result\JSONFactory + * @var \Magento\Framework\Controller\Result\JsonFactory */ protected $resultJsonFactory; @@ -33,14 +33,14 @@ class UpdateQty extends \Magento\Backend\App\Action * @param Action\Context $context * @param \Magento\Sales\Controller\Adminhtml\Order\CreditmemoLoader $creditmemoLoader * @param \Magento\Framework\View\Result\PageFactory $resultPageFactory - * @param \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory + * @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory * @param \Magento\Framework\Controller\Result\RawFactory $resultRawFactory */ public function __construct( Action\Context $context, \Magento\Sales\Controller\Adminhtml\Order\CreditmemoLoader $creditmemoLoader, \Magento\Framework\View\Result\PageFactory $resultPageFactory, - \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory, + \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory, \Magento\Framework\Controller\Result\RawFactory $resultRawFactory ) { $this->creditmemoLoader = $creditmemoLoader; @@ -61,7 +61,7 @@ class UpdateQty extends \Magento\Backend\App\Action /** * Update items qty action * - * @return \Magento\Framework\Controller\Result\JSON|\Magento\Framework\Controller\Result\Raw + * @return \Magento\Framework\Controller\Result\Json|\Magento\Framework\Controller\Result\Raw */ public function execute() { diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/AddComment.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/AddComment.php index c39f8da6bf3a5283640e3a262cfc902d1f1e36e0..74011a35d81ec6170dfb86c740101e0db0e89736 100755 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/AddComment.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/AddComment.php @@ -12,7 +12,7 @@ use Magento\Sales\Model\Order\Email\Sender\InvoiceCommentSender; use Magento\Sales\Model\Order\Invoice; use Magento\Backend\App\Action; use Magento\Framework\Registry; -use Magento\Framework\Controller\Result\JSONFactory; +use Magento\Framework\Controller\Result\JsonFactory; use Magento\Framework\View\Result\PageFactory; use Magento\Framework\Controller\Result\RawFactory; @@ -24,7 +24,7 @@ class AddComment extends \Magento\Sales\Controller\Adminhtml\Invoice\AbstractInv protected $invoiceCommentSender; /** - * @var JSONFactory + * @var JsonFactory */ protected $resultJsonFactory; @@ -43,7 +43,7 @@ class AddComment extends \Magento\Sales\Controller\Adminhtml\Invoice\AbstractInv * @param Registry $registry * @param \Magento\Backend\Model\View\Result\ForwardFactory $resultForwardFactory * @param InvoiceCommentSender $invoiceCommentSender - * @param JSONFactory $resultJsonFactory + * @param JsonFactory $resultJsonFactory * @param PageFactory $resultPageFactory * @param RawFactory $resultRawFactory */ @@ -52,7 +52,7 @@ class AddComment extends \Magento\Sales\Controller\Adminhtml\Invoice\AbstractInv Registry $registry, \Magento\Backend\Model\View\Result\ForwardFactory $resultForwardFactory, InvoiceCommentSender $invoiceCommentSender, - JSONFactory $resultJsonFactory, + JsonFactory $resultJsonFactory, PageFactory $resultPageFactory, RawFactory $resultRawFactory ) { @@ -101,7 +101,7 @@ class AddComment extends \Magento\Sales\Controller\Adminhtml\Invoice\AbstractInv $response = ['error' => true, 'message' => __('Cannot add new comment.')]; } if (is_array($response)) { - /** @var \Magento\Framework\Controller\Result\JSON $resultJson */ + /** @var \Magento\Framework\Controller\Result\Json $resultJson */ $resultJson = $this->resultJsonFactory->create(); $resultJson->setData($response); return $resultJson; diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/UpdateQty.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/UpdateQty.php index a3dce63b8cf55faba2e23b4a98dceb8bd04b3e76..a2c5ba9685349a2608e8084b9f4e43d1df1b710e 100755 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/UpdateQty.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/UpdateQty.php @@ -8,7 +8,7 @@ namespace Magento\Sales\Controller\Adminhtml\Order\Invoice; use Magento\Framework\Exception\LocalizedException; use Magento\Backend\App\Action; -use Magento\Framework\Controller\Result\JSONFactory; +use Magento\Framework\Controller\Result\JsonFactory; use Magento\Framework\View\Result\PageFactory; use Magento\Framework\Controller\Result\RawFactory; use Magento\Backend\App\Action\Context; @@ -17,7 +17,7 @@ use Magento\Framework\Registry; class UpdateQty extends \Magento\Sales\Controller\Adminhtml\Invoice\AbstractInvoice\View { /** - * @var JSONFactory + * @var JsonFactory */ protected $resultJsonFactory; @@ -36,7 +36,7 @@ class UpdateQty extends \Magento\Sales\Controller\Adminhtml\Invoice\AbstractInvo * @param Registry $registry * @param \Magento\Backend\Model\View\Result\ForwardFactory $resultForwardFactory * @param PageFactory $resultPageFactory - * @param JSONFactory $resultJsonFactory + * @param JsonFactory $resultJsonFactory * @param RawFactory $resultRawFactory */ public function __construct( @@ -44,7 +44,7 @@ class UpdateQty extends \Magento\Sales\Controller\Adminhtml\Invoice\AbstractInvo Registry $registry, \Magento\Backend\Model\View\Result\ForwardFactory $resultForwardFactory, PageFactory $resultPageFactory, - JSONFactory $resultJsonFactory, + JsonFactory $resultJsonFactory, RawFactory $resultRawFactory ) { $this->resultPageFactory = $resultPageFactory; @@ -96,7 +96,7 @@ class UpdateQty extends \Magento\Sales\Controller\Adminhtml\Invoice\AbstractInvo $response = ['error' => true, 'message' => __('Cannot update item quantity.')]; } if (is_array($response)) { - /** @var \Magento\Framework\Controller\Result\JSON $resultJson */ + /** @var \Magento\Framework\Controller\Result\Json $resultJson */ $resultJson = $this->resultJsonFactory->create(); $resultJson->setData($response); return $resultJson; diff --git a/app/code/Magento/Sales/Model/AbstractModel.php b/app/code/Magento/Sales/Model/AbstractModel.php index b87d43e79f47cb97ceedab4e14bdd9babb13e002..a506b7efd3b3b02c5683a5ea2bc87611422c7de0 100644 --- a/app/code/Magento/Sales/Model/AbstractModel.php +++ b/app/code/Magento/Sales/Model/AbstractModel.php @@ -27,7 +27,7 @@ abstract class AbstractModel extends AbstractExtensibleModel /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry - * @param \Magento\Framework\Api\MetadataServiceInterface $metadataService + * @param \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory * @param AttributeValueFactory $customAttributeFactory * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Framework\Stdlib\DateTime $dateTime @@ -38,7 +38,7 @@ abstract class AbstractModel extends AbstractExtensibleModel public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, - \Magento\Framework\Api\MetadataServiceInterface $metadataService, + \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory, AttributeValueFactory $customAttributeFactory, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Framework\Stdlib\DateTime $dateTime, @@ -49,7 +49,7 @@ abstract class AbstractModel extends AbstractExtensibleModel parent::__construct( $context, $registry, - $metadataService, + $extensionFactory, $customAttributeFactory, $resource, $resourceCollection, diff --git a/app/code/Magento/Sales/Model/AdminOrder/Create.php b/app/code/Magento/Sales/Model/AdminOrder/Create.php index 4327c9d91d9a645a89e91f0fe20f3a47510c423e..d160ec1223f6156cbc64109a68eb0e2a3a188c00 100644 --- a/app/code/Magento/Sales/Model/AdminOrder/Create.php +++ b/app/code/Magento/Sales/Model/AdminOrder/Create.php @@ -475,7 +475,7 @@ class Create extends \Magento\Framework\Object implements \Magento\Checkout\Mode if ($qty > 0) { $item = $this->initFromOrderItem($orderItem, $qty); if (is_string($item)) { - throw new \Magento\Framework\Exception\LocalizedException($item); + throw new \Magento\Framework\Exception\LocalizedException(__($item)); } } } @@ -759,7 +759,7 @@ class Create extends \Magento\Framework\Object implements \Magento\Checkout\Mode $newItem = $this->getQuote()->addProduct($product, $info); if (is_string($newItem)) { - throw new \Magento\Framework\Exception\LocalizedException($newItem); + throw new \Magento\Framework\Exception\LocalizedException(__($newItem)); } $product->unsSkipCheckRequiredOption(); $newItem->checkData(); @@ -794,7 +794,7 @@ class Create extends \Magento\Framework\Object implements \Magento\Checkout\Mode $cartItem = $cart->addProduct($product, $info); if (is_string($cartItem)) { - throw new \Magento\Framework\Exception\LocalizedException($cartItem); + throw new \Magento\Framework\Exception\LocalizedException(__($cartItem)); } $cartItem->setPrice($item->getProduct()->getPrice()); $this->_needCollectCart = true; @@ -818,7 +818,9 @@ class Create extends \Magento\Framework\Object implements \Magento\Checkout\Mode } } if (!$wishlist) { - throw new \Magento\Framework\Exception\LocalizedException(__('We couldn\'t find this wish list.')); + throw new \Magento\Framework\Exception\LocalizedException( + __('We couldn\'t find this wish list.') + ); } $wishlist->setStore( $this->getSession()->getStore() @@ -872,7 +874,7 @@ class Create extends \Magento\Framework\Object implements \Magento\Checkout\Mode $orderItem = $this->_objectManager->create('Magento\Sales\Model\Order\Item')->load($orderItemId); $item = $this->initFromOrderItem($orderItem); if (is_string($item)) { - throw new \Magento\Framework\Exception\LocalizedException($item); + throw new \Magento\Framework\Exception\LocalizedException(__($item)); } } } @@ -1004,7 +1006,7 @@ class Create extends \Magento\Framework\Object implements \Magento\Checkout\Mode $item = $this->quoteInitializer->init($this->getQuote(), $product, $config); if (is_string($item)) { - throw new \Magento\Framework\Exception\LocalizedException($item); + throw new \Magento\Framework\Exception\LocalizedException(__($item)); } $item->checkData(); $this->setRecollect(true); diff --git a/app/code/Magento/Sales/Model/Order.php b/app/code/Magento/Sales/Model/Order.php index fa437025ad8487896f2a011d7d4248e45f8025ab..6a27ad12b323da64252cbdaf0ac2005f9cbd62f9 100644 --- a/app/code/Magento/Sales/Model/Order.php +++ b/app/code/Magento/Sales/Model/Order.php @@ -9,7 +9,7 @@ use Magento\Directory\Model\Currency; use Magento\Framework\Api\AttributeValueFactory; use Magento\Framework\Exception\NoSuchEntityException; use Magento\Framework\Pricing\PriceCurrencyInterface; -use Magento\Sales\Api\Data\OrderInterface as ApiOrderInterface; +use Magento\Sales\Api\Data\OrderInterface; use Magento\Sales\Api\Data\OrderStatusHistoryInterface; use Magento\Sales\Model\Order\Payment; use Magento\Sales\Model\Resource\Order\Address\Collection; @@ -50,7 +50,7 @@ use Magento\Sales\Model\Resource\Order\Status\History\Collection as HistoryColle * @SuppressWarnings(PHPMD.ExcessiveClassComplexity) * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class Order extends AbstractModel implements EntityInterface, ApiOrderInterface +class Order extends AbstractModel implements EntityInterface, OrderInterface { const ENTITY = 'order'; @@ -260,7 +260,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry - * @param \Magento\Framework\Api\MetadataServiceInterface $metadataService + * @param \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory * @param AttributeValueFactory $customAttributeFactory * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Framework\Stdlib\DateTime $dateTime @@ -290,7 +290,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, - \Magento\Framework\Api\MetadataServiceInterface $metadataService, + \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory, AttributeValueFactory $customAttributeFactory, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Framework\Stdlib\DateTime $dateTime, @@ -338,7 +338,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface parent::__construct( $context, $registry, - $metadataService, + $extensionFactory, $customAttributeFactory, $localeDate, $dateTime, @@ -1944,13 +1944,13 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getItems() { - if ($this->getData(ApiOrderInterface::ITEMS) == null) { + if ($this->getData(OrderInterface::ITEMS) == null) { $this->setData( - ApiOrderInterface::ITEMS, + OrderInterface::ITEMS, $this->getItemsCollection()->getItems() ); } - return $this->getData(ApiOrderInterface::ITEMS); + return $this->getData(OrderInterface::ITEMS); } /** @@ -1958,7 +1958,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setItems($items) { - return $this->setData(ApiOrderInterface::ITEMS, $items); + return $this->setData(OrderInterface::ITEMS, $items); } /** @@ -1966,13 +1966,13 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getPayments() { - if ($this->getData(ApiOrderInterface::PAYMENTS) == null) { + if ($this->getData(OrderInterface::PAYMENTS) == null) { $this->setData( - ApiOrderInterface::PAYMENTS, + OrderInterface::PAYMENTS, $this->getPaymentsCollection()->getItems() ); } - return $this->getData(ApiOrderInterface::PAYMENTS); + return $this->getData(OrderInterface::PAYMENTS); } /** @@ -1980,7 +1980,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setPayments(array $payments = null) { - return $this->setData(ApiOrderInterface::PAYMENTS, $payments); + return $this->setData(OrderInterface::PAYMENTS, $payments); } /** @@ -1988,13 +1988,13 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getAddresses() { - if ($this->getData(ApiOrderInterface::ADDRESSES) == null) { + if ($this->getData(OrderInterface::ADDRESSES) == null) { $this->setData( - ApiOrderInterface::ADDRESSES, + OrderInterface::ADDRESSES, $this->getAddressesCollection()->getItems() ); } - return $this->getData(ApiOrderInterface::ADDRESSES); + return $this->getData(OrderInterface::ADDRESSES); } /** @@ -2002,7 +2002,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setAddresses(array $addresses = null) { - return $this->setData(ApiOrderInterface::ADDRESSES, $addresses); + return $this->setData(OrderInterface::ADDRESSES, $addresses); } /** @@ -2012,7 +2012,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getAdjustmentNegative() { - return $this->getData(ApiOrderInterface::ADJUSTMENT_NEGATIVE); + return $this->getData(OrderInterface::ADJUSTMENT_NEGATIVE); } /** @@ -2022,7 +2022,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getAdjustmentPositive() { - return $this->getData(ApiOrderInterface::ADJUSTMENT_POSITIVE); + return $this->getData(OrderInterface::ADJUSTMENT_POSITIVE); } /** @@ -2032,7 +2032,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getAppliedRuleIds() { - return $this->getData(ApiOrderInterface::APPLIED_RULE_IDS); + return $this->getData(OrderInterface::APPLIED_RULE_IDS); } /** @@ -2042,7 +2042,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getBaseAdjustmentNegative() { - return $this->getData(ApiOrderInterface::BASE_ADJUSTMENT_NEGATIVE); + return $this->getData(OrderInterface::BASE_ADJUSTMENT_NEGATIVE); } /** @@ -2052,7 +2052,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getBaseAdjustmentPositive() { - return $this->getData(ApiOrderInterface::BASE_ADJUSTMENT_POSITIVE); + return $this->getData(OrderInterface::BASE_ADJUSTMENT_POSITIVE); } /** @@ -2062,7 +2062,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getBaseCurrencyCode() { - return $this->getData(ApiOrderInterface::BASE_CURRENCY_CODE); + return $this->getData(OrderInterface::BASE_CURRENCY_CODE); } /** @@ -2072,7 +2072,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getBaseDiscountAmount() { - return $this->getData(ApiOrderInterface::BASE_DISCOUNT_AMOUNT); + return $this->getData(OrderInterface::BASE_DISCOUNT_AMOUNT); } /** @@ -2082,7 +2082,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getBaseDiscountCanceled() { - return $this->getData(ApiOrderInterface::BASE_DISCOUNT_CANCELED); + return $this->getData(OrderInterface::BASE_DISCOUNT_CANCELED); } /** @@ -2092,7 +2092,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getBaseDiscountInvoiced() { - return $this->getData(ApiOrderInterface::BASE_DISCOUNT_INVOICED); + return $this->getData(OrderInterface::BASE_DISCOUNT_INVOICED); } /** @@ -2102,7 +2102,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getBaseDiscountRefunded() { - return $this->getData(ApiOrderInterface::BASE_DISCOUNT_REFUNDED); + return $this->getData(OrderInterface::BASE_DISCOUNT_REFUNDED); } /** @@ -2112,7 +2112,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getBaseGrandTotal() { - return $this->getData(ApiOrderInterface::BASE_GRAND_TOTAL); + return $this->getData(OrderInterface::BASE_GRAND_TOTAL); } /** @@ -2122,7 +2122,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getBaseHiddenTaxAmount() { - return $this->getData(ApiOrderInterface::BASE_HIDDEN_TAX_AMOUNT); + return $this->getData(OrderInterface::BASE_HIDDEN_TAX_AMOUNT); } /** @@ -2132,7 +2132,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getBaseHiddenTaxInvoiced() { - return $this->getData(ApiOrderInterface::BASE_HIDDEN_TAX_INVOICED); + return $this->getData(OrderInterface::BASE_HIDDEN_TAX_INVOICED); } /** @@ -2142,7 +2142,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getBaseHiddenTaxRefunded() { - return $this->getData(ApiOrderInterface::BASE_HIDDEN_TAX_REFUNDED); + return $this->getData(OrderInterface::BASE_HIDDEN_TAX_REFUNDED); } /** @@ -2152,7 +2152,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getBaseShippingAmount() { - return $this->getData(ApiOrderInterface::BASE_SHIPPING_AMOUNT); + return $this->getData(OrderInterface::BASE_SHIPPING_AMOUNT); } /** @@ -2162,7 +2162,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getBaseShippingCanceled() { - return $this->getData(ApiOrderInterface::BASE_SHIPPING_CANCELED); + return $this->getData(OrderInterface::BASE_SHIPPING_CANCELED); } /** @@ -2172,7 +2172,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getBaseShippingDiscountAmount() { - return $this->getData(ApiOrderInterface::BASE_SHIPPING_DISCOUNT_AMOUNT); + return $this->getData(OrderInterface::BASE_SHIPPING_DISCOUNT_AMOUNT); } /** @@ -2182,7 +2182,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getBaseShippingHiddenTaxAmnt() { - return $this->getData(ApiOrderInterface::BASE_SHIPPING_HIDDEN_TAX_AMNT); + return $this->getData(OrderInterface::BASE_SHIPPING_HIDDEN_TAX_AMNT); } /** @@ -2192,7 +2192,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getBaseShippingInclTax() { - return $this->getData(ApiOrderInterface::BASE_SHIPPING_INCL_TAX); + return $this->getData(OrderInterface::BASE_SHIPPING_INCL_TAX); } /** @@ -2202,7 +2202,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getBaseShippingInvoiced() { - return $this->getData(ApiOrderInterface::BASE_SHIPPING_INVOICED); + return $this->getData(OrderInterface::BASE_SHIPPING_INVOICED); } /** @@ -2212,7 +2212,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getBaseShippingRefunded() { - return $this->getData(ApiOrderInterface::BASE_SHIPPING_REFUNDED); + return $this->getData(OrderInterface::BASE_SHIPPING_REFUNDED); } /** @@ -2222,7 +2222,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getBaseShippingTaxAmount() { - return $this->getData(ApiOrderInterface::BASE_SHIPPING_TAX_AMOUNT); + return $this->getData(OrderInterface::BASE_SHIPPING_TAX_AMOUNT); } /** @@ -2232,7 +2232,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getBaseShippingTaxRefunded() { - return $this->getData(ApiOrderInterface::BASE_SHIPPING_TAX_REFUNDED); + return $this->getData(OrderInterface::BASE_SHIPPING_TAX_REFUNDED); } /** @@ -2242,7 +2242,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getBaseSubtotal() { - return $this->getData(ApiOrderInterface::BASE_SUBTOTAL); + return $this->getData(OrderInterface::BASE_SUBTOTAL); } /** @@ -2252,7 +2252,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getBaseSubtotalCanceled() { - return $this->getData(ApiOrderInterface::BASE_SUBTOTAL_CANCELED); + return $this->getData(OrderInterface::BASE_SUBTOTAL_CANCELED); } /** @@ -2262,7 +2262,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getBaseSubtotalInclTax() { - return $this->getData(ApiOrderInterface::BASE_SUBTOTAL_INCL_TAX); + return $this->getData(OrderInterface::BASE_SUBTOTAL_INCL_TAX); } /** @@ -2272,7 +2272,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getBaseSubtotalInvoiced() { - return $this->getData(ApiOrderInterface::BASE_SUBTOTAL_INVOICED); + return $this->getData(OrderInterface::BASE_SUBTOTAL_INVOICED); } /** @@ -2282,7 +2282,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getBaseSubtotalRefunded() { - return $this->getData(ApiOrderInterface::BASE_SUBTOTAL_REFUNDED); + return $this->getData(OrderInterface::BASE_SUBTOTAL_REFUNDED); } /** @@ -2292,7 +2292,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getBaseTaxAmount() { - return $this->getData(ApiOrderInterface::BASE_TAX_AMOUNT); + return $this->getData(OrderInterface::BASE_TAX_AMOUNT); } /** @@ -2302,7 +2302,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getBaseTaxCanceled() { - return $this->getData(ApiOrderInterface::BASE_TAX_CANCELED); + return $this->getData(OrderInterface::BASE_TAX_CANCELED); } /** @@ -2312,7 +2312,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getBaseTaxInvoiced() { - return $this->getData(ApiOrderInterface::BASE_TAX_INVOICED); + return $this->getData(OrderInterface::BASE_TAX_INVOICED); } /** @@ -2322,7 +2322,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getBaseTaxRefunded() { - return $this->getData(ApiOrderInterface::BASE_TAX_REFUNDED); + return $this->getData(OrderInterface::BASE_TAX_REFUNDED); } /** @@ -2332,7 +2332,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getBaseTotalCanceled() { - return $this->getData(ApiOrderInterface::BASE_TOTAL_CANCELED); + return $this->getData(OrderInterface::BASE_TOTAL_CANCELED); } /** @@ -2342,7 +2342,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getBaseTotalInvoiced() { - return $this->getData(ApiOrderInterface::BASE_TOTAL_INVOICED); + return $this->getData(OrderInterface::BASE_TOTAL_INVOICED); } /** @@ -2352,7 +2352,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getBaseTotalInvoicedCost() { - return $this->getData(ApiOrderInterface::BASE_TOTAL_INVOICED_COST); + return $this->getData(OrderInterface::BASE_TOTAL_INVOICED_COST); } /** @@ -2362,7 +2362,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getBaseTotalOfflineRefunded() { - return $this->getData(ApiOrderInterface::BASE_TOTAL_OFFLINE_REFUNDED); + return $this->getData(OrderInterface::BASE_TOTAL_OFFLINE_REFUNDED); } /** @@ -2372,7 +2372,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getBaseTotalOnlineRefunded() { - return $this->getData(ApiOrderInterface::BASE_TOTAL_ONLINE_REFUNDED); + return $this->getData(OrderInterface::BASE_TOTAL_ONLINE_REFUNDED); } /** @@ -2382,7 +2382,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getBaseTotalPaid() { - return $this->getData(ApiOrderInterface::BASE_TOTAL_PAID); + return $this->getData(OrderInterface::BASE_TOTAL_PAID); } /** @@ -2392,7 +2392,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getBaseTotalQtyOrdered() { - return $this->getData(ApiOrderInterface::BASE_TOTAL_QTY_ORDERED); + return $this->getData(OrderInterface::BASE_TOTAL_QTY_ORDERED); } /** @@ -2402,7 +2402,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getBaseTotalRefunded() { - return $this->getData(ApiOrderInterface::BASE_TOTAL_REFUNDED); + return $this->getData(OrderInterface::BASE_TOTAL_REFUNDED); } /** @@ -2412,7 +2412,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getBaseToGlobalRate() { - return $this->getData(ApiOrderInterface::BASE_TO_GLOBAL_RATE); + return $this->getData(OrderInterface::BASE_TO_GLOBAL_RATE); } /** @@ -2422,7 +2422,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getBaseToOrderRate() { - return $this->getData(ApiOrderInterface::BASE_TO_ORDER_RATE); + return $this->getData(OrderInterface::BASE_TO_ORDER_RATE); } /** @@ -2432,7 +2432,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getBillingAddressId() { - return $this->getData(ApiOrderInterface::BILLING_ADDRESS_ID); + return $this->getData(OrderInterface::BILLING_ADDRESS_ID); } /** @@ -2442,7 +2442,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getCanShipPartially() { - return $this->getData(ApiOrderInterface::CAN_SHIP_PARTIALLY); + return $this->getData(OrderInterface::CAN_SHIP_PARTIALLY); } /** @@ -2452,7 +2452,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getCanShipPartiallyItem() { - return $this->getData(ApiOrderInterface::CAN_SHIP_PARTIALLY_ITEM); + return $this->getData(OrderInterface::CAN_SHIP_PARTIALLY_ITEM); } /** @@ -2462,7 +2462,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getCouponCode() { - return $this->getData(ApiOrderInterface::COUPON_CODE); + return $this->getData(OrderInterface::COUPON_CODE); } /** @@ -2472,7 +2472,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getCreatedAt() { - return $this->getData(ApiOrderInterface::CREATED_AT); + return $this->getData(OrderInterface::CREATED_AT); } /** @@ -2482,7 +2482,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getCustomerDob() { - return $this->getData(ApiOrderInterface::CUSTOMER_DOB); + return $this->getData(OrderInterface::CUSTOMER_DOB); } /** @@ -2492,7 +2492,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getCustomerEmail() { - return $this->getData(ApiOrderInterface::CUSTOMER_EMAIL); + return $this->getData(OrderInterface::CUSTOMER_EMAIL); } /** @@ -2502,7 +2502,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getCustomerFirstname() { - return $this->getData(ApiOrderInterface::CUSTOMER_FIRSTNAME); + return $this->getData(OrderInterface::CUSTOMER_FIRSTNAME); } /** @@ -2512,7 +2512,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getCustomerGender() { - return $this->getData(ApiOrderInterface::CUSTOMER_GENDER); + return $this->getData(OrderInterface::CUSTOMER_GENDER); } /** @@ -2522,7 +2522,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getCustomerGroupId() { - return $this->getData(ApiOrderInterface::CUSTOMER_GROUP_ID); + return $this->getData(OrderInterface::CUSTOMER_GROUP_ID); } /** @@ -2532,7 +2532,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getCustomerId() { - return $this->getData(ApiOrderInterface::CUSTOMER_ID); + return $this->getData(OrderInterface::CUSTOMER_ID); } /** @@ -2542,7 +2542,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getCustomerIsGuest() { - return $this->getData(ApiOrderInterface::CUSTOMER_IS_GUEST); + return $this->getData(OrderInterface::CUSTOMER_IS_GUEST); } /** @@ -2552,7 +2552,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getCustomerLastname() { - return $this->getData(ApiOrderInterface::CUSTOMER_LASTNAME); + return $this->getData(OrderInterface::CUSTOMER_LASTNAME); } /** @@ -2562,7 +2562,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getCustomerMiddlename() { - return $this->getData(ApiOrderInterface::CUSTOMER_MIDDLENAME); + return $this->getData(OrderInterface::CUSTOMER_MIDDLENAME); } /** @@ -2572,7 +2572,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getCustomerNote() { - return $this->getData(ApiOrderInterface::CUSTOMER_NOTE); + return $this->getData(OrderInterface::CUSTOMER_NOTE); } /** @@ -2582,7 +2582,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getCustomerNoteNotify() { - return $this->getData(ApiOrderInterface::CUSTOMER_NOTE_NOTIFY); + return $this->getData(OrderInterface::CUSTOMER_NOTE_NOTIFY); } /** @@ -2592,7 +2592,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getCustomerPrefix() { - return $this->getData(ApiOrderInterface::CUSTOMER_PREFIX); + return $this->getData(OrderInterface::CUSTOMER_PREFIX); } /** @@ -2602,7 +2602,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getCustomerSuffix() { - return $this->getData(ApiOrderInterface::CUSTOMER_SUFFIX); + return $this->getData(OrderInterface::CUSTOMER_SUFFIX); } /** @@ -2612,7 +2612,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getCustomerTaxvat() { - return $this->getData(ApiOrderInterface::CUSTOMER_TAXVAT); + return $this->getData(OrderInterface::CUSTOMER_TAXVAT); } /** @@ -2622,7 +2622,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getDiscountAmount() { - return $this->getData(ApiOrderInterface::DISCOUNT_AMOUNT); + return $this->getData(OrderInterface::DISCOUNT_AMOUNT); } /** @@ -2632,7 +2632,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getDiscountCanceled() { - return $this->getData(ApiOrderInterface::DISCOUNT_CANCELED); + return $this->getData(OrderInterface::DISCOUNT_CANCELED); } /** @@ -2642,7 +2642,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getDiscountDescription() { - return $this->getData(ApiOrderInterface::DISCOUNT_DESCRIPTION); + return $this->getData(OrderInterface::DISCOUNT_DESCRIPTION); } /** @@ -2652,7 +2652,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getDiscountInvoiced() { - return $this->getData(ApiOrderInterface::DISCOUNT_INVOICED); + return $this->getData(OrderInterface::DISCOUNT_INVOICED); } /** @@ -2662,7 +2662,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getDiscountRefunded() { - return $this->getData(ApiOrderInterface::DISCOUNT_REFUNDED); + return $this->getData(OrderInterface::DISCOUNT_REFUNDED); } /** @@ -2672,7 +2672,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getEditIncrement() { - return $this->getData(ApiOrderInterface::EDIT_INCREMENT); + return $this->getData(OrderInterface::EDIT_INCREMENT); } /** @@ -2682,7 +2682,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getEmailSent() { - return $this->getData(ApiOrderInterface::EMAIL_SENT); + return $this->getData(OrderInterface::EMAIL_SENT); } /** @@ -2692,7 +2692,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getExtCustomerId() { - return $this->getData(ApiOrderInterface::EXT_CUSTOMER_ID); + return $this->getData(OrderInterface::EXT_CUSTOMER_ID); } /** @@ -2702,7 +2702,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getExtOrderId() { - return $this->getData(ApiOrderInterface::EXT_ORDER_ID); + return $this->getData(OrderInterface::EXT_ORDER_ID); } /** @@ -2712,7 +2712,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getForcedShipmentWithInvoice() { - return $this->getData(ApiOrderInterface::FORCED_SHIPMENT_WITH_INVOICE); + return $this->getData(OrderInterface::FORCED_SHIPMENT_WITH_INVOICE); } /** @@ -2722,7 +2722,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getGlobalCurrencyCode() { - return $this->getData(ApiOrderInterface::GLOBAL_CURRENCY_CODE); + return $this->getData(OrderInterface::GLOBAL_CURRENCY_CODE); } /** @@ -2732,7 +2732,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getGrandTotal() { - return $this->getData(ApiOrderInterface::GRAND_TOTAL); + return $this->getData(OrderInterface::GRAND_TOTAL); } /** @@ -2742,7 +2742,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getHiddenTaxAmount() { - return $this->getData(ApiOrderInterface::HIDDEN_TAX_AMOUNT); + return $this->getData(OrderInterface::HIDDEN_TAX_AMOUNT); } /** @@ -2752,7 +2752,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getHiddenTaxInvoiced() { - return $this->getData(ApiOrderInterface::HIDDEN_TAX_INVOICED); + return $this->getData(OrderInterface::HIDDEN_TAX_INVOICED); } /** @@ -2762,7 +2762,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getHiddenTaxRefunded() { - return $this->getData(ApiOrderInterface::HIDDEN_TAX_REFUNDED); + return $this->getData(OrderInterface::HIDDEN_TAX_REFUNDED); } /** @@ -2772,7 +2772,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getHoldBeforeState() { - return $this->getData(ApiOrderInterface::HOLD_BEFORE_STATE); + return $this->getData(OrderInterface::HOLD_BEFORE_STATE); } /** @@ -2782,7 +2782,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getHoldBeforeStatus() { - return $this->getData(ApiOrderInterface::HOLD_BEFORE_STATUS); + return $this->getData(OrderInterface::HOLD_BEFORE_STATUS); } /** @@ -2792,7 +2792,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getIsVirtual() { - return $this->getData(ApiOrderInterface::IS_VIRTUAL); + return $this->getData(OrderInterface::IS_VIRTUAL); } /** @@ -2802,7 +2802,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getOrderCurrencyCode() { - return $this->getData(ApiOrderInterface::ORDER_CURRENCY_CODE); + return $this->getData(OrderInterface::ORDER_CURRENCY_CODE); } /** @@ -2812,7 +2812,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getOriginalIncrementId() { - return $this->getData(ApiOrderInterface::ORIGINAL_INCREMENT_ID); + return $this->getData(OrderInterface::ORIGINAL_INCREMENT_ID); } /** @@ -2822,7 +2822,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getPaymentAuthorizationAmount() { - return $this->getData(ApiOrderInterface::PAYMENT_AUTHORIZATION_AMOUNT); + return $this->getData(OrderInterface::PAYMENT_AUTHORIZATION_AMOUNT); } /** @@ -2832,7 +2832,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getPaymentAuthExpiration() { - return $this->getData(ApiOrderInterface::PAYMENT_AUTH_EXPIRATION); + return $this->getData(OrderInterface::PAYMENT_AUTH_EXPIRATION); } /** @@ -2842,7 +2842,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getProtectCode() { - return $this->getData(ApiOrderInterface::PROTECT_CODE); + return $this->getData(OrderInterface::PROTECT_CODE); } /** @@ -2852,7 +2852,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getQuoteAddressId() { - return $this->getData(ApiOrderInterface::QUOTE_ADDRESS_ID); + return $this->getData(OrderInterface::QUOTE_ADDRESS_ID); } /** @@ -2862,7 +2862,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getQuoteId() { - return $this->getData(ApiOrderInterface::QUOTE_ID); + return $this->getData(OrderInterface::QUOTE_ID); } /** @@ -2872,7 +2872,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getRelationChildId() { - return $this->getData(ApiOrderInterface::RELATION_CHILD_ID); + return $this->getData(OrderInterface::RELATION_CHILD_ID); } /** @@ -2882,7 +2882,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getRelationChildRealId() { - return $this->getData(ApiOrderInterface::RELATION_CHILD_REAL_ID); + return $this->getData(OrderInterface::RELATION_CHILD_REAL_ID); } /** @@ -2892,7 +2892,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getRelationParentId() { - return $this->getData(ApiOrderInterface::RELATION_PARENT_ID); + return $this->getData(OrderInterface::RELATION_PARENT_ID); } /** @@ -2902,7 +2902,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getRelationParentRealId() { - return $this->getData(ApiOrderInterface::RELATION_PARENT_REAL_ID); + return $this->getData(OrderInterface::RELATION_PARENT_REAL_ID); } /** @@ -2912,7 +2912,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getRemoteIp() { - return $this->getData(ApiOrderInterface::REMOTE_IP); + return $this->getData(OrderInterface::REMOTE_IP); } /** @@ -2922,7 +2922,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getShippingAddressId() { - return $this->getData(ApiOrderInterface::SHIPPING_ADDRESS_ID); + return $this->getData(OrderInterface::SHIPPING_ADDRESS_ID); } /** @@ -2932,7 +2932,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getShippingAmount() { - return $this->getData(ApiOrderInterface::SHIPPING_AMOUNT); + return $this->getData(OrderInterface::SHIPPING_AMOUNT); } /** @@ -2942,7 +2942,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getShippingCanceled() { - return $this->getData(ApiOrderInterface::SHIPPING_CANCELED); + return $this->getData(OrderInterface::SHIPPING_CANCELED); } /** @@ -2952,7 +2952,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getShippingDescription() { - return $this->getData(ApiOrderInterface::SHIPPING_DESCRIPTION); + return $this->getData(OrderInterface::SHIPPING_DESCRIPTION); } /** @@ -2962,7 +2962,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getShippingDiscountAmount() { - return $this->getData(ApiOrderInterface::SHIPPING_DISCOUNT_AMOUNT); + return $this->getData(OrderInterface::SHIPPING_DISCOUNT_AMOUNT); } /** @@ -2972,7 +2972,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getShippingHiddenTaxAmount() { - return $this->getData(ApiOrderInterface::SHIPPING_HIDDEN_TAX_AMOUNT); + return $this->getData(OrderInterface::SHIPPING_HIDDEN_TAX_AMOUNT); } /** @@ -2982,7 +2982,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getShippingInclTax() { - return $this->getData(ApiOrderInterface::SHIPPING_INCL_TAX); + return $this->getData(OrderInterface::SHIPPING_INCL_TAX); } /** @@ -2992,7 +2992,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getShippingInvoiced() { - return $this->getData(ApiOrderInterface::SHIPPING_INVOICED); + return $this->getData(OrderInterface::SHIPPING_INVOICED); } /** @@ -3002,7 +3002,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getShippingRefunded() { - return $this->getData(ApiOrderInterface::SHIPPING_REFUNDED); + return $this->getData(OrderInterface::SHIPPING_REFUNDED); } /** @@ -3012,7 +3012,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getShippingTaxAmount() { - return $this->getData(ApiOrderInterface::SHIPPING_TAX_AMOUNT); + return $this->getData(OrderInterface::SHIPPING_TAX_AMOUNT); } /** @@ -3022,7 +3022,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getShippingTaxRefunded() { - return $this->getData(ApiOrderInterface::SHIPPING_TAX_REFUNDED); + return $this->getData(OrderInterface::SHIPPING_TAX_REFUNDED); } /** @@ -3032,7 +3032,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getState() { - return $this->getData(ApiOrderInterface::STATE); + return $this->getData(OrderInterface::STATE); } /** @@ -3042,7 +3042,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getStatus() { - return $this->getData(ApiOrderInterface::STATUS); + return $this->getData(OrderInterface::STATUS); } /** @@ -3052,7 +3052,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getStoreCurrencyCode() { - return $this->getData(ApiOrderInterface::STORE_CURRENCY_CODE); + return $this->getData(OrderInterface::STORE_CURRENCY_CODE); } /** @@ -3062,7 +3062,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getStoreId() { - return $this->getData(ApiOrderInterface::STORE_ID); + return $this->getData(OrderInterface::STORE_ID); } /** @@ -3072,7 +3072,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getStoreName() { - return $this->getData(ApiOrderInterface::STORE_NAME); + return $this->getData(OrderInterface::STORE_NAME); } /** @@ -3082,7 +3082,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getStoreToBaseRate() { - return $this->getData(ApiOrderInterface::STORE_TO_BASE_RATE); + return $this->getData(OrderInterface::STORE_TO_BASE_RATE); } /** @@ -3092,7 +3092,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getStoreToOrderRate() { - return $this->getData(ApiOrderInterface::STORE_TO_ORDER_RATE); + return $this->getData(OrderInterface::STORE_TO_ORDER_RATE); } /** @@ -3102,7 +3102,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getSubtotal() { - return $this->getData(ApiOrderInterface::SUBTOTAL); + return $this->getData(OrderInterface::SUBTOTAL); } /** @@ -3112,7 +3112,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getSubtotalCanceled() { - return $this->getData(ApiOrderInterface::SUBTOTAL_CANCELED); + return $this->getData(OrderInterface::SUBTOTAL_CANCELED); } /** @@ -3122,7 +3122,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getSubtotalInclTax() { - return $this->getData(ApiOrderInterface::SUBTOTAL_INCL_TAX); + return $this->getData(OrderInterface::SUBTOTAL_INCL_TAX); } /** @@ -3132,7 +3132,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getSubtotalInvoiced() { - return $this->getData(ApiOrderInterface::SUBTOTAL_INVOICED); + return $this->getData(OrderInterface::SUBTOTAL_INVOICED); } /** @@ -3142,7 +3142,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getSubtotalRefunded() { - return $this->getData(ApiOrderInterface::SUBTOTAL_REFUNDED); + return $this->getData(OrderInterface::SUBTOTAL_REFUNDED); } /** @@ -3152,7 +3152,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getTaxAmount() { - return $this->getData(ApiOrderInterface::TAX_AMOUNT); + return $this->getData(OrderInterface::TAX_AMOUNT); } /** @@ -3162,7 +3162,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getTaxCanceled() { - return $this->getData(ApiOrderInterface::TAX_CANCELED); + return $this->getData(OrderInterface::TAX_CANCELED); } /** @@ -3172,7 +3172,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getTaxInvoiced() { - return $this->getData(ApiOrderInterface::TAX_INVOICED); + return $this->getData(OrderInterface::TAX_INVOICED); } /** @@ -3182,7 +3182,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getTaxRefunded() { - return $this->getData(ApiOrderInterface::TAX_REFUNDED); + return $this->getData(OrderInterface::TAX_REFUNDED); } /** @@ -3192,7 +3192,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getTotalCanceled() { - return $this->getData(ApiOrderInterface::TOTAL_CANCELED); + return $this->getData(OrderInterface::TOTAL_CANCELED); } /** @@ -3202,7 +3202,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getTotalInvoiced() { - return $this->getData(ApiOrderInterface::TOTAL_INVOICED); + return $this->getData(OrderInterface::TOTAL_INVOICED); } /** @@ -3212,7 +3212,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getTotalItemCount() { - return $this->getData(ApiOrderInterface::TOTAL_ITEM_COUNT); + return $this->getData(OrderInterface::TOTAL_ITEM_COUNT); } /** @@ -3222,7 +3222,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getTotalOfflineRefunded() { - return $this->getData(ApiOrderInterface::TOTAL_OFFLINE_REFUNDED); + return $this->getData(OrderInterface::TOTAL_OFFLINE_REFUNDED); } /** @@ -3232,7 +3232,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getTotalOnlineRefunded() { - return $this->getData(ApiOrderInterface::TOTAL_ONLINE_REFUNDED); + return $this->getData(OrderInterface::TOTAL_ONLINE_REFUNDED); } /** @@ -3242,7 +3242,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getTotalPaid() { - return $this->getData(ApiOrderInterface::TOTAL_PAID); + return $this->getData(OrderInterface::TOTAL_PAID); } /** @@ -3252,7 +3252,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getTotalQtyOrdered() { - return $this->getData(ApiOrderInterface::TOTAL_QTY_ORDERED); + return $this->getData(OrderInterface::TOTAL_QTY_ORDERED); } /** @@ -3262,7 +3262,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getTotalRefunded() { - return $this->getData(ApiOrderInterface::TOTAL_REFUNDED); + return $this->getData(OrderInterface::TOTAL_REFUNDED); } /** @@ -3272,7 +3272,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getUpdatedAt() { - return $this->getData(ApiOrderInterface::UPDATED_AT); + return $this->getData(OrderInterface::UPDATED_AT); } /** @@ -3282,7 +3282,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getWeight() { - return $this->getData(ApiOrderInterface::WEIGHT); + return $this->getData(OrderInterface::WEIGHT); } /** @@ -3292,7 +3292,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getXForwardedFor() { - return $this->getData(ApiOrderInterface::X_FORWARDED_FOR); + return $this->getData(OrderInterface::X_FORWARDED_FOR); } /** @@ -3300,13 +3300,34 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function getStatusHistories() { - if ($this->getData(ApiOrderInterface::STATUS_HISTORIES) == null) { + if ($this->getData(OrderInterface::STATUS_HISTORIES) == null) { $this->setData( - ApiOrderInterface::STATUS_HISTORIES, + OrderInterface::STATUS_HISTORIES, $this->getStatusHistoryCollection()->getItems() ); } - return $this->getData(ApiOrderInterface::STATUS_HISTORIES); + return $this->getData(OrderInterface::STATUS_HISTORIES); + } + + /** + * {@inheritdoc} + * + * @return \Magento\Sales\Api\Data\OrderExtensionInterface|null + */ + public function getExtensionAttributes() + { + return $this->_getExtensionAttributes(); + } + + /** + * {@inheritdoc} + * + * @param \Magento\Sales\Api\Data\OrderExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes(\Magento\Sales\Api\Data\OrderExtensionInterface $extensionAttributes) + { + return $this->_setExtensionAttributes($extensionAttributes); } /** @@ -3314,7 +3335,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setStatusHistories(array $statusHistories = null) { - return $this->setData(ApiOrderInterface::STATUS_HISTORIES, $statusHistories); + return $this->setData(OrderInterface::STATUS_HISTORIES, $statusHistories); } //@codeCoverageIgnoreStart @@ -3323,7 +3344,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setStatus($status) { - return $this->setData(ApiOrderInterface::STATUS, $status); + return $this->setData(OrderInterface::STATUS, $status); } /** @@ -3331,7 +3352,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setCouponCode($code) { - return $this->setData(ApiOrderInterface::COUPON_CODE, $code); + return $this->setData(OrderInterface::COUPON_CODE, $code); } /** @@ -3339,7 +3360,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setProtectCode($code) { - return $this->setData(ApiOrderInterface::PROTECT_CODE, $code); + return $this->setData(OrderInterface::PROTECT_CODE, $code); } /** @@ -3347,7 +3368,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setShippingDescription($description) { - return $this->setData(ApiOrderInterface::SHIPPING_DESCRIPTION, $description); + return $this->setData(OrderInterface::SHIPPING_DESCRIPTION, $description); } /** @@ -3355,7 +3376,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setIsVirtual($isVirtual) { - return $this->setData(ApiOrderInterface::IS_VIRTUAL, $isVirtual); + return $this->setData(OrderInterface::IS_VIRTUAL, $isVirtual); } /** @@ -3363,7 +3384,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setStoreId($id) { - return $this->setData(ApiOrderInterface::STORE_ID, $id); + return $this->setData(OrderInterface::STORE_ID, $id); } /** @@ -3371,7 +3392,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setCustomerId($id) { - return $this->setData(ApiOrderInterface::CUSTOMER_ID, $id); + return $this->setData(OrderInterface::CUSTOMER_ID, $id); } /** @@ -3379,7 +3400,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setBaseDiscountAmount($amount) { - return $this->setData(ApiOrderInterface::BASE_DISCOUNT_AMOUNT, $amount); + return $this->setData(OrderInterface::BASE_DISCOUNT_AMOUNT, $amount); } /** @@ -3387,7 +3408,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setBaseDiscountCanceled($baseDiscountCanceled) { - return $this->setData(ApiOrderInterface::BASE_DISCOUNT_CANCELED, $baseDiscountCanceled); + return $this->setData(OrderInterface::BASE_DISCOUNT_CANCELED, $baseDiscountCanceled); } /** @@ -3395,7 +3416,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setBaseDiscountInvoiced($baseDiscountInvoiced) { - return $this->setData(ApiOrderInterface::BASE_DISCOUNT_INVOICED, $baseDiscountInvoiced); + return $this->setData(OrderInterface::BASE_DISCOUNT_INVOICED, $baseDiscountInvoiced); } /** @@ -3403,7 +3424,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setBaseDiscountRefunded($baseDiscountRefunded) { - return $this->setData(ApiOrderInterface::BASE_DISCOUNT_REFUNDED, $baseDiscountRefunded); + return $this->setData(OrderInterface::BASE_DISCOUNT_REFUNDED, $baseDiscountRefunded); } /** @@ -3411,7 +3432,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setBaseGrandTotal($amount) { - return $this->setData(ApiOrderInterface::BASE_GRAND_TOTAL, $amount); + return $this->setData(OrderInterface::BASE_GRAND_TOTAL, $amount); } /** @@ -3419,7 +3440,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setBaseShippingAmount($amount) { - return $this->setData(ApiOrderInterface::BASE_SHIPPING_AMOUNT, $amount); + return $this->setData(OrderInterface::BASE_SHIPPING_AMOUNT, $amount); } /** @@ -3427,7 +3448,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setBaseShippingCanceled($baseShippingCanceled) { - return $this->setData(ApiOrderInterface::BASE_SHIPPING_CANCELED, $baseShippingCanceled); + return $this->setData(OrderInterface::BASE_SHIPPING_CANCELED, $baseShippingCanceled); } /** @@ -3435,7 +3456,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setBaseShippingInvoiced($baseShippingInvoiced) { - return $this->setData(ApiOrderInterface::BASE_SHIPPING_INVOICED, $baseShippingInvoiced); + return $this->setData(OrderInterface::BASE_SHIPPING_INVOICED, $baseShippingInvoiced); } /** @@ -3443,7 +3464,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setBaseShippingRefunded($baseShippingRefunded) { - return $this->setData(ApiOrderInterface::BASE_SHIPPING_REFUNDED, $baseShippingRefunded); + return $this->setData(OrderInterface::BASE_SHIPPING_REFUNDED, $baseShippingRefunded); } /** @@ -3451,7 +3472,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setBaseShippingTaxAmount($amount) { - return $this->setData(ApiOrderInterface::BASE_SHIPPING_TAX_AMOUNT, $amount); + return $this->setData(OrderInterface::BASE_SHIPPING_TAX_AMOUNT, $amount); } /** @@ -3459,7 +3480,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setBaseShippingTaxRefunded($baseShippingTaxRefunded) { - return $this->setData(ApiOrderInterface::BASE_SHIPPING_TAX_REFUNDED, $baseShippingTaxRefunded); + return $this->setData(OrderInterface::BASE_SHIPPING_TAX_REFUNDED, $baseShippingTaxRefunded); } /** @@ -3467,7 +3488,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setBaseSubtotal($amount) { - return $this->setData(ApiOrderInterface::BASE_SUBTOTAL, $amount); + return $this->setData(OrderInterface::BASE_SUBTOTAL, $amount); } /** @@ -3475,7 +3496,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setBaseSubtotalCanceled($baseSubtotalCanceled) { - return $this->setData(ApiOrderInterface::BASE_SUBTOTAL_CANCELED, $baseSubtotalCanceled); + return $this->setData(OrderInterface::BASE_SUBTOTAL_CANCELED, $baseSubtotalCanceled); } /** @@ -3483,7 +3504,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setBaseSubtotalInvoiced($baseSubtotalInvoiced) { - return $this->setData(ApiOrderInterface::BASE_SUBTOTAL_INVOICED, $baseSubtotalInvoiced); + return $this->setData(OrderInterface::BASE_SUBTOTAL_INVOICED, $baseSubtotalInvoiced); } /** @@ -3491,7 +3512,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setBaseSubtotalRefunded($baseSubtotalRefunded) { - return $this->setData(ApiOrderInterface::BASE_SUBTOTAL_REFUNDED, $baseSubtotalRefunded); + return $this->setData(OrderInterface::BASE_SUBTOTAL_REFUNDED, $baseSubtotalRefunded); } /** @@ -3499,7 +3520,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setBaseTaxAmount($amount) { - return $this->setData(ApiOrderInterface::BASE_TAX_AMOUNT, $amount); + return $this->setData(OrderInterface::BASE_TAX_AMOUNT, $amount); } /** @@ -3507,7 +3528,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setBaseTaxCanceled($baseTaxCanceled) { - return $this->setData(ApiOrderInterface::BASE_TAX_CANCELED, $baseTaxCanceled); + return $this->setData(OrderInterface::BASE_TAX_CANCELED, $baseTaxCanceled); } /** @@ -3515,7 +3536,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setBaseTaxInvoiced($baseTaxInvoiced) { - return $this->setData(ApiOrderInterface::BASE_TAX_INVOICED, $baseTaxInvoiced); + return $this->setData(OrderInterface::BASE_TAX_INVOICED, $baseTaxInvoiced); } /** @@ -3523,7 +3544,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setBaseTaxRefunded($baseTaxRefunded) { - return $this->setData(ApiOrderInterface::BASE_TAX_REFUNDED, $baseTaxRefunded); + return $this->setData(OrderInterface::BASE_TAX_REFUNDED, $baseTaxRefunded); } /** @@ -3531,7 +3552,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setBaseToGlobalRate($rate) { - return $this->setData(ApiOrderInterface::BASE_TO_GLOBAL_RATE, $rate); + return $this->setData(OrderInterface::BASE_TO_GLOBAL_RATE, $rate); } /** @@ -3539,7 +3560,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setBaseToOrderRate($rate) { - return $this->setData(ApiOrderInterface::BASE_TO_ORDER_RATE, $rate); + return $this->setData(OrderInterface::BASE_TO_ORDER_RATE, $rate); } /** @@ -3547,7 +3568,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setBaseTotalCanceled($baseTotalCanceled) { - return $this->setData(ApiOrderInterface::BASE_TOTAL_CANCELED, $baseTotalCanceled); + return $this->setData(OrderInterface::BASE_TOTAL_CANCELED, $baseTotalCanceled); } /** @@ -3555,7 +3576,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setBaseTotalInvoiced($baseTotalInvoiced) { - return $this->setData(ApiOrderInterface::BASE_TOTAL_INVOICED, $baseTotalInvoiced); + return $this->setData(OrderInterface::BASE_TOTAL_INVOICED, $baseTotalInvoiced); } /** @@ -3563,7 +3584,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setBaseTotalInvoicedCost($baseTotalInvoicedCost) { - return $this->setData(ApiOrderInterface::BASE_TOTAL_INVOICED_COST, $baseTotalInvoicedCost); + return $this->setData(OrderInterface::BASE_TOTAL_INVOICED_COST, $baseTotalInvoicedCost); } /** @@ -3571,7 +3592,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setBaseTotalOfflineRefunded($baseTotalOfflineRefunded) { - return $this->setData(ApiOrderInterface::BASE_TOTAL_OFFLINE_REFUNDED, $baseTotalOfflineRefunded); + return $this->setData(OrderInterface::BASE_TOTAL_OFFLINE_REFUNDED, $baseTotalOfflineRefunded); } /** @@ -3579,7 +3600,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setBaseTotalOnlineRefunded($baseTotalOnlineRefunded) { - return $this->setData(ApiOrderInterface::BASE_TOTAL_ONLINE_REFUNDED, $baseTotalOnlineRefunded); + return $this->setData(OrderInterface::BASE_TOTAL_ONLINE_REFUNDED, $baseTotalOnlineRefunded); } /** @@ -3587,7 +3608,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setBaseTotalPaid($baseTotalPaid) { - return $this->setData(ApiOrderInterface::BASE_TOTAL_PAID, $baseTotalPaid); + return $this->setData(OrderInterface::BASE_TOTAL_PAID, $baseTotalPaid); } /** @@ -3595,7 +3616,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setBaseTotalQtyOrdered($baseTotalQtyOrdered) { - return $this->setData(ApiOrderInterface::BASE_TOTAL_QTY_ORDERED, $baseTotalQtyOrdered); + return $this->setData(OrderInterface::BASE_TOTAL_QTY_ORDERED, $baseTotalQtyOrdered); } /** @@ -3603,7 +3624,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setBaseTotalRefunded($baseTotalRefunded) { - return $this->setData(ApiOrderInterface::BASE_TOTAL_REFUNDED, $baseTotalRefunded); + return $this->setData(OrderInterface::BASE_TOTAL_REFUNDED, $baseTotalRefunded); } /** @@ -3611,7 +3632,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setDiscountAmount($amount) { - return $this->setData(ApiOrderInterface::DISCOUNT_AMOUNT, $amount); + return $this->setData(OrderInterface::DISCOUNT_AMOUNT, $amount); } /** @@ -3619,7 +3640,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setDiscountCanceled($discountCanceled) { - return $this->setData(ApiOrderInterface::DISCOUNT_CANCELED, $discountCanceled); + return $this->setData(OrderInterface::DISCOUNT_CANCELED, $discountCanceled); } /** @@ -3627,7 +3648,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setDiscountInvoiced($discountInvoiced) { - return $this->setData(ApiOrderInterface::DISCOUNT_INVOICED, $discountInvoiced); + return $this->setData(OrderInterface::DISCOUNT_INVOICED, $discountInvoiced); } /** @@ -3635,7 +3656,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setDiscountRefunded($discountRefunded) { - return $this->setData(ApiOrderInterface::DISCOUNT_REFUNDED, $discountRefunded); + return $this->setData(OrderInterface::DISCOUNT_REFUNDED, $discountRefunded); } /** @@ -3643,7 +3664,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setGrandTotal($amount) { - return $this->setData(ApiOrderInterface::GRAND_TOTAL, $amount); + return $this->setData(OrderInterface::GRAND_TOTAL, $amount); } /** @@ -3651,7 +3672,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setShippingAmount($amount) { - return $this->setData(ApiOrderInterface::SHIPPING_AMOUNT, $amount); + return $this->setData(OrderInterface::SHIPPING_AMOUNT, $amount); } /** @@ -3659,7 +3680,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setShippingCanceled($shippingCanceled) { - return $this->setData(ApiOrderInterface::SHIPPING_CANCELED, $shippingCanceled); + return $this->setData(OrderInterface::SHIPPING_CANCELED, $shippingCanceled); } /** @@ -3667,7 +3688,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setShippingInvoiced($shippingInvoiced) { - return $this->setData(ApiOrderInterface::SHIPPING_INVOICED, $shippingInvoiced); + return $this->setData(OrderInterface::SHIPPING_INVOICED, $shippingInvoiced); } /** @@ -3675,7 +3696,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setShippingRefunded($shippingRefunded) { - return $this->setData(ApiOrderInterface::SHIPPING_REFUNDED, $shippingRefunded); + return $this->setData(OrderInterface::SHIPPING_REFUNDED, $shippingRefunded); } /** @@ -3683,7 +3704,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setShippingTaxAmount($amount) { - return $this->setData(ApiOrderInterface::SHIPPING_TAX_AMOUNT, $amount); + return $this->setData(OrderInterface::SHIPPING_TAX_AMOUNT, $amount); } /** @@ -3691,7 +3712,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setShippingTaxRefunded($shippingTaxRefunded) { - return $this->setData(ApiOrderInterface::SHIPPING_TAX_REFUNDED, $shippingTaxRefunded); + return $this->setData(OrderInterface::SHIPPING_TAX_REFUNDED, $shippingTaxRefunded); } /** @@ -3699,7 +3720,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setStoreToBaseRate($rate) { - return $this->setData(ApiOrderInterface::STORE_TO_BASE_RATE, $rate); + return $this->setData(OrderInterface::STORE_TO_BASE_RATE, $rate); } /** @@ -3707,7 +3728,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setStoreToOrderRate($rate) { - return $this->setData(ApiOrderInterface::STORE_TO_ORDER_RATE, $rate); + return $this->setData(OrderInterface::STORE_TO_ORDER_RATE, $rate); } /** @@ -3715,7 +3736,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setSubtotal($amount) { - return $this->setData(ApiOrderInterface::SUBTOTAL, $amount); + return $this->setData(OrderInterface::SUBTOTAL, $amount); } /** @@ -3723,7 +3744,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setSubtotalCanceled($subtotalCanceled) { - return $this->setData(ApiOrderInterface::SUBTOTAL_CANCELED, $subtotalCanceled); + return $this->setData(OrderInterface::SUBTOTAL_CANCELED, $subtotalCanceled); } /** @@ -3731,7 +3752,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setSubtotalInvoiced($subtotalInvoiced) { - return $this->setData(ApiOrderInterface::SUBTOTAL_INVOICED, $subtotalInvoiced); + return $this->setData(OrderInterface::SUBTOTAL_INVOICED, $subtotalInvoiced); } /** @@ -3739,7 +3760,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setSubtotalRefunded($subtotalRefunded) { - return $this->setData(ApiOrderInterface::SUBTOTAL_REFUNDED, $subtotalRefunded); + return $this->setData(OrderInterface::SUBTOTAL_REFUNDED, $subtotalRefunded); } /** @@ -3747,7 +3768,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setTaxAmount($amount) { - return $this->setData(ApiOrderInterface::TAX_AMOUNT, $amount); + return $this->setData(OrderInterface::TAX_AMOUNT, $amount); } /** @@ -3755,7 +3776,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setTaxCanceled($taxCanceled) { - return $this->setData(ApiOrderInterface::TAX_CANCELED, $taxCanceled); + return $this->setData(OrderInterface::TAX_CANCELED, $taxCanceled); } /** @@ -3763,7 +3784,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setTaxInvoiced($taxInvoiced) { - return $this->setData(ApiOrderInterface::TAX_INVOICED, $taxInvoiced); + return $this->setData(OrderInterface::TAX_INVOICED, $taxInvoiced); } /** @@ -3771,7 +3792,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setTaxRefunded($taxRefunded) { - return $this->setData(ApiOrderInterface::TAX_REFUNDED, $taxRefunded); + return $this->setData(OrderInterface::TAX_REFUNDED, $taxRefunded); } /** @@ -3779,7 +3800,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setTotalCanceled($totalCanceled) { - return $this->setData(ApiOrderInterface::TOTAL_CANCELED, $totalCanceled); + return $this->setData(OrderInterface::TOTAL_CANCELED, $totalCanceled); } /** @@ -3787,7 +3808,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setTotalInvoiced($totalInvoiced) { - return $this->setData(ApiOrderInterface::TOTAL_INVOICED, $totalInvoiced); + return $this->setData(OrderInterface::TOTAL_INVOICED, $totalInvoiced); } /** @@ -3795,7 +3816,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setTotalOfflineRefunded($totalOfflineRefunded) { - return $this->setData(ApiOrderInterface::TOTAL_OFFLINE_REFUNDED, $totalOfflineRefunded); + return $this->setData(OrderInterface::TOTAL_OFFLINE_REFUNDED, $totalOfflineRefunded); } /** @@ -3803,7 +3824,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setTotalOnlineRefunded($totalOnlineRefunded) { - return $this->setData(ApiOrderInterface::TOTAL_ONLINE_REFUNDED, $totalOnlineRefunded); + return $this->setData(OrderInterface::TOTAL_ONLINE_REFUNDED, $totalOnlineRefunded); } /** @@ -3811,7 +3832,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setTotalPaid($totalPaid) { - return $this->setData(ApiOrderInterface::TOTAL_PAID, $totalPaid); + return $this->setData(OrderInterface::TOTAL_PAID, $totalPaid); } /** @@ -3819,7 +3840,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setTotalQtyOrdered($totalQtyOrdered) { - return $this->setData(ApiOrderInterface::TOTAL_QTY_ORDERED, $totalQtyOrdered); + return $this->setData(OrderInterface::TOTAL_QTY_ORDERED, $totalQtyOrdered); } /** @@ -3827,7 +3848,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setTotalRefunded($totalRefunded) { - return $this->setData(ApiOrderInterface::TOTAL_REFUNDED, $totalRefunded); + return $this->setData(OrderInterface::TOTAL_REFUNDED, $totalRefunded); } /** @@ -3835,7 +3856,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setCanShipPartially($flag) { - return $this->setData(ApiOrderInterface::CAN_SHIP_PARTIALLY, $flag); + return $this->setData(OrderInterface::CAN_SHIP_PARTIALLY, $flag); } /** @@ -3843,7 +3864,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setCanShipPartiallyItem($flag) { - return $this->setData(ApiOrderInterface::CAN_SHIP_PARTIALLY_ITEM, $flag); + return $this->setData(OrderInterface::CAN_SHIP_PARTIALLY_ITEM, $flag); } /** @@ -3851,7 +3872,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setCustomerIsGuest($customerIsGuest) { - return $this->setData(ApiOrderInterface::CUSTOMER_IS_GUEST, $customerIsGuest); + return $this->setData(OrderInterface::CUSTOMER_IS_GUEST, $customerIsGuest); } /** @@ -3859,7 +3880,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setCustomerNoteNotify($customerNoteNotify) { - return $this->setData(ApiOrderInterface::CUSTOMER_NOTE_NOTIFY, $customerNoteNotify); + return $this->setData(OrderInterface::CUSTOMER_NOTE_NOTIFY, $customerNoteNotify); } /** @@ -3867,7 +3888,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setBillingAddressId($id) { - return $this->setData(ApiOrderInterface::BILLING_ADDRESS_ID, $id); + return $this->setData(OrderInterface::BILLING_ADDRESS_ID, $id); } /** @@ -3875,7 +3896,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setCustomerGroupId($id) { - return $this->setData(ApiOrderInterface::CUSTOMER_GROUP_ID, $id); + return $this->setData(OrderInterface::CUSTOMER_GROUP_ID, $id); } /** @@ -3883,7 +3904,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setEditIncrement($editIncrement) { - return $this->setData(ApiOrderInterface::EDIT_INCREMENT, $editIncrement); + return $this->setData(OrderInterface::EDIT_INCREMENT, $editIncrement); } /** @@ -3891,7 +3912,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setEmailSent($emailSent) { - return $this->setData(ApiOrderInterface::EMAIL_SENT, $emailSent); + return $this->setData(OrderInterface::EMAIL_SENT, $emailSent); } /** @@ -3899,7 +3920,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setForcedShipmentWithInvoice($forcedShipmentWithInvoice) { - return $this->setData(ApiOrderInterface::FORCED_SHIPMENT_WITH_INVOICE, $forcedShipmentWithInvoice); + return $this->setData(OrderInterface::FORCED_SHIPMENT_WITH_INVOICE, $forcedShipmentWithInvoice); } /** @@ -3907,7 +3928,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setPaymentAuthExpiration($paymentAuthExpiration) { - return $this->setData(ApiOrderInterface::PAYMENT_AUTH_EXPIRATION, $paymentAuthExpiration); + return $this->setData(OrderInterface::PAYMENT_AUTH_EXPIRATION, $paymentAuthExpiration); } /** @@ -3915,7 +3936,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setQuoteAddressId($id) { - return $this->setData(ApiOrderInterface::QUOTE_ADDRESS_ID, $id); + return $this->setData(OrderInterface::QUOTE_ADDRESS_ID, $id); } /** @@ -3923,7 +3944,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setQuoteId($id) { - return $this->setData(ApiOrderInterface::QUOTE_ID, $id); + return $this->setData(OrderInterface::QUOTE_ID, $id); } /** @@ -3931,7 +3952,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setShippingAddressId($id) { - return $this->setData(ApiOrderInterface::SHIPPING_ADDRESS_ID, $id); + return $this->setData(OrderInterface::SHIPPING_ADDRESS_ID, $id); } /** @@ -3939,7 +3960,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setAdjustmentNegative($adjustmentNegative) { - return $this->setData(ApiOrderInterface::ADJUSTMENT_NEGATIVE, $adjustmentNegative); + return $this->setData(OrderInterface::ADJUSTMENT_NEGATIVE, $adjustmentNegative); } /** @@ -3947,7 +3968,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setAdjustmentPositive($adjustmentPositive) { - return $this->setData(ApiOrderInterface::ADJUSTMENT_POSITIVE, $adjustmentPositive); + return $this->setData(OrderInterface::ADJUSTMENT_POSITIVE, $adjustmentPositive); } /** @@ -3955,7 +3976,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setBaseAdjustmentNegative($baseAdjustmentNegative) { - return $this->setData(ApiOrderInterface::BASE_ADJUSTMENT_NEGATIVE, $baseAdjustmentNegative); + return $this->setData(OrderInterface::BASE_ADJUSTMENT_NEGATIVE, $baseAdjustmentNegative); } /** @@ -3963,7 +3984,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setBaseAdjustmentPositive($baseAdjustmentPositive) { - return $this->setData(ApiOrderInterface::BASE_ADJUSTMENT_POSITIVE, $baseAdjustmentPositive); + return $this->setData(OrderInterface::BASE_ADJUSTMENT_POSITIVE, $baseAdjustmentPositive); } /** @@ -3971,7 +3992,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setBaseShippingDiscountAmount($amount) { - return $this->setData(ApiOrderInterface::BASE_SHIPPING_DISCOUNT_AMOUNT, $amount); + return $this->setData(OrderInterface::BASE_SHIPPING_DISCOUNT_AMOUNT, $amount); } /** @@ -3979,7 +4000,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setBaseSubtotalInclTax($amount) { - return $this->setData(ApiOrderInterface::BASE_SUBTOTAL_INCL_TAX, $amount); + return $this->setData(OrderInterface::BASE_SUBTOTAL_INCL_TAX, $amount); } /** @@ -3987,7 +4008,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setBaseTotalDue($baseTotalDue) { - return $this->setData(ApiOrderInterface::BASE_TOTAL_DUE, $baseTotalDue); + return $this->setData(OrderInterface::BASE_TOTAL_DUE, $baseTotalDue); } /** @@ -3995,7 +4016,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setPaymentAuthorizationAmount($amount) { - return $this->setData(ApiOrderInterface::PAYMENT_AUTHORIZATION_AMOUNT, $amount); + return $this->setData(OrderInterface::PAYMENT_AUTHORIZATION_AMOUNT, $amount); } /** @@ -4003,7 +4024,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setShippingDiscountAmount($amount) { - return $this->setData(ApiOrderInterface::SHIPPING_DISCOUNT_AMOUNT, $amount); + return $this->setData(OrderInterface::SHIPPING_DISCOUNT_AMOUNT, $amount); } /** @@ -4011,7 +4032,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setSubtotalInclTax($amount) { - return $this->setData(ApiOrderInterface::SUBTOTAL_INCL_TAX, $amount); + return $this->setData(OrderInterface::SUBTOTAL_INCL_TAX, $amount); } /** @@ -4019,7 +4040,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setTotalDue($totalDue) { - return $this->setData(ApiOrderInterface::TOTAL_DUE, $totalDue); + return $this->setData(OrderInterface::TOTAL_DUE, $totalDue); } /** @@ -4027,7 +4048,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setWeight($weight) { - return $this->setData(ApiOrderInterface::WEIGHT, $weight); + return $this->setData(OrderInterface::WEIGHT, $weight); } /** @@ -4035,7 +4056,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setCustomerDob($customerDob) { - return $this->setData(ApiOrderInterface::CUSTOMER_DOB, $customerDob); + return $this->setData(OrderInterface::CUSTOMER_DOB, $customerDob); } /** @@ -4043,7 +4064,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setIncrementId($id) { - return $this->setData(ApiOrderInterface::INCREMENT_ID, $id); + return $this->setData(OrderInterface::INCREMENT_ID, $id); } /** @@ -4051,7 +4072,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setAppliedRuleIds($appliedRuleIds) { - return $this->setData(ApiOrderInterface::APPLIED_RULE_IDS, $appliedRuleIds); + return $this->setData(OrderInterface::APPLIED_RULE_IDS, $appliedRuleIds); } /** @@ -4059,7 +4080,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setBaseCurrencyCode($code) { - return $this->setData(ApiOrderInterface::BASE_CURRENCY_CODE, $code); + return $this->setData(OrderInterface::BASE_CURRENCY_CODE, $code); } /** @@ -4067,7 +4088,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setCustomerEmail($customerEmail) { - return $this->setData(ApiOrderInterface::CUSTOMER_EMAIL, $customerEmail); + return $this->setData(OrderInterface::CUSTOMER_EMAIL, $customerEmail); } /** @@ -4075,7 +4096,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setCustomerFirstname($customerFirstname) { - return $this->setData(ApiOrderInterface::CUSTOMER_FIRSTNAME, $customerFirstname); + return $this->setData(OrderInterface::CUSTOMER_FIRSTNAME, $customerFirstname); } /** @@ -4083,7 +4104,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setCustomerLastname($customerLastname) { - return $this->setData(ApiOrderInterface::CUSTOMER_LASTNAME, $customerLastname); + return $this->setData(OrderInterface::CUSTOMER_LASTNAME, $customerLastname); } /** @@ -4091,7 +4112,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setCustomerMiddlename($customerMiddlename) { - return $this->setData(ApiOrderInterface::CUSTOMER_MIDDLENAME, $customerMiddlename); + return $this->setData(OrderInterface::CUSTOMER_MIDDLENAME, $customerMiddlename); } /** @@ -4099,7 +4120,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setCustomerPrefix($customerPrefix) { - return $this->setData(ApiOrderInterface::CUSTOMER_PREFIX, $customerPrefix); + return $this->setData(OrderInterface::CUSTOMER_PREFIX, $customerPrefix); } /** @@ -4107,7 +4128,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setCustomerSuffix($customerSuffix) { - return $this->setData(ApiOrderInterface::CUSTOMER_SUFFIX, $customerSuffix); + return $this->setData(OrderInterface::CUSTOMER_SUFFIX, $customerSuffix); } /** @@ -4115,7 +4136,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setCustomerTaxvat($customerTaxvat) { - return $this->setData(ApiOrderInterface::CUSTOMER_TAXVAT, $customerTaxvat); + return $this->setData(OrderInterface::CUSTOMER_TAXVAT, $customerTaxvat); } /** @@ -4123,7 +4144,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setDiscountDescription($description) { - return $this->setData(ApiOrderInterface::DISCOUNT_DESCRIPTION, $description); + return $this->setData(OrderInterface::DISCOUNT_DESCRIPTION, $description); } /** @@ -4131,7 +4152,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setExtCustomerId($id) { - return $this->setData(ApiOrderInterface::EXT_CUSTOMER_ID, $id); + return $this->setData(OrderInterface::EXT_CUSTOMER_ID, $id); } /** @@ -4139,7 +4160,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setExtOrderId($id) { - return $this->setData(ApiOrderInterface::EXT_ORDER_ID, $id); + return $this->setData(OrderInterface::EXT_ORDER_ID, $id); } /** @@ -4147,7 +4168,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setGlobalCurrencyCode($code) { - return $this->setData(ApiOrderInterface::GLOBAL_CURRENCY_CODE, $code); + return $this->setData(OrderInterface::GLOBAL_CURRENCY_CODE, $code); } /** @@ -4155,7 +4176,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setHoldBeforeState($holdBeforeState) { - return $this->setData(ApiOrderInterface::HOLD_BEFORE_STATE, $holdBeforeState); + return $this->setData(OrderInterface::HOLD_BEFORE_STATE, $holdBeforeState); } /** @@ -4163,7 +4184,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setHoldBeforeStatus($holdBeforeStatus) { - return $this->setData(ApiOrderInterface::HOLD_BEFORE_STATUS, $holdBeforeStatus); + return $this->setData(OrderInterface::HOLD_BEFORE_STATUS, $holdBeforeStatus); } /** @@ -4171,7 +4192,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setOrderCurrencyCode($code) { - return $this->setData(ApiOrderInterface::ORDER_CURRENCY_CODE, $code); + return $this->setData(OrderInterface::ORDER_CURRENCY_CODE, $code); } /** @@ -4179,7 +4200,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setOriginalIncrementId($id) { - return $this->setData(ApiOrderInterface::ORIGINAL_INCREMENT_ID, $id); + return $this->setData(OrderInterface::ORIGINAL_INCREMENT_ID, $id); } /** @@ -4187,7 +4208,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setRelationChildId($id) { - return $this->setData(ApiOrderInterface::RELATION_CHILD_ID, $id); + return $this->setData(OrderInterface::RELATION_CHILD_ID, $id); } /** @@ -4195,7 +4216,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setRelationChildRealId($realId) { - return $this->setData(ApiOrderInterface::RELATION_CHILD_REAL_ID, $realId); + return $this->setData(OrderInterface::RELATION_CHILD_REAL_ID, $realId); } /** @@ -4203,7 +4224,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setRelationParentId($id) { - return $this->setData(ApiOrderInterface::RELATION_PARENT_ID, $id); + return $this->setData(OrderInterface::RELATION_PARENT_ID, $id); } /** @@ -4211,7 +4232,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setRelationParentRealId($realId) { - return $this->setData(ApiOrderInterface::RELATION_PARENT_REAL_ID, $realId); + return $this->setData(OrderInterface::RELATION_PARENT_REAL_ID, $realId); } /** @@ -4219,7 +4240,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setRemoteIp($remoteIp) { - return $this->setData(ApiOrderInterface::REMOTE_IP, $remoteIp); + return $this->setData(OrderInterface::REMOTE_IP, $remoteIp); } /** @@ -4227,7 +4248,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setShippingMethod($shippingMethod) { - return $this->setData(ApiOrderInterface::SHIPPING_METHOD, $shippingMethod); + return $this->setData(OrderInterface::SHIPPING_METHOD, $shippingMethod); } /** @@ -4235,7 +4256,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setStoreCurrencyCode($code) { - return $this->setData(ApiOrderInterface::STORE_CURRENCY_CODE, $code); + return $this->setData(OrderInterface::STORE_CURRENCY_CODE, $code); } /** @@ -4243,7 +4264,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setStoreName($storeName) { - return $this->setData(ApiOrderInterface::STORE_NAME, $storeName); + return $this->setData(OrderInterface::STORE_NAME, $storeName); } /** @@ -4251,7 +4272,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setXForwardedFor($xForwardedFor) { - return $this->setData(ApiOrderInterface::X_FORWARDED_FOR, $xForwardedFor); + return $this->setData(OrderInterface::X_FORWARDED_FOR, $xForwardedFor); } /** @@ -4259,7 +4280,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setCustomerNote($customerNote) { - return $this->setData(ApiOrderInterface::CUSTOMER_NOTE, $customerNote); + return $this->setData(OrderInterface::CUSTOMER_NOTE, $customerNote); } /** @@ -4267,7 +4288,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setUpdatedAt($timestamp) { - return $this->setData(ApiOrderInterface::UPDATED_AT, $timestamp); + return $this->setData(OrderInterface::UPDATED_AT, $timestamp); } /** @@ -4275,7 +4296,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setTotalItemCount($totalItemCount) { - return $this->setData(ApiOrderInterface::TOTAL_ITEM_COUNT, $totalItemCount); + return $this->setData(OrderInterface::TOTAL_ITEM_COUNT, $totalItemCount); } /** @@ -4283,7 +4304,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setCustomerGender($customerGender) { - return $this->setData(ApiOrderInterface::CUSTOMER_GENDER, $customerGender); + return $this->setData(OrderInterface::CUSTOMER_GENDER, $customerGender); } /** @@ -4291,7 +4312,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setHiddenTaxAmount($amount) { - return $this->setData(ApiOrderInterface::HIDDEN_TAX_AMOUNT, $amount); + return $this->setData(OrderInterface::HIDDEN_TAX_AMOUNT, $amount); } /** @@ -4299,7 +4320,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setBaseHiddenTaxAmount($amount) { - return $this->setData(ApiOrderInterface::BASE_HIDDEN_TAX_AMOUNT, $amount); + return $this->setData(OrderInterface::BASE_HIDDEN_TAX_AMOUNT, $amount); } /** @@ -4307,7 +4328,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setShippingHiddenTaxAmount($amount) { - return $this->setData(ApiOrderInterface::SHIPPING_HIDDEN_TAX_AMOUNT, $amount); + return $this->setData(OrderInterface::SHIPPING_HIDDEN_TAX_AMOUNT, $amount); } /** @@ -4315,7 +4336,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setBaseShippingHiddenTaxAmnt($amnt) { - return $this->setData(ApiOrderInterface::BASE_SHIPPING_HIDDEN_TAX_AMNT, $amnt); + return $this->setData(OrderInterface::BASE_SHIPPING_HIDDEN_TAX_AMNT, $amnt); } /** @@ -4323,7 +4344,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setHiddenTaxInvoiced($hiddenTaxInvoiced) { - return $this->setData(ApiOrderInterface::HIDDEN_TAX_INVOICED, $hiddenTaxInvoiced); + return $this->setData(OrderInterface::HIDDEN_TAX_INVOICED, $hiddenTaxInvoiced); } /** @@ -4331,7 +4352,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setBaseHiddenTaxInvoiced($baseHiddenTaxInvoiced) { - return $this->setData(ApiOrderInterface::BASE_HIDDEN_TAX_INVOICED, $baseHiddenTaxInvoiced); + return $this->setData(OrderInterface::BASE_HIDDEN_TAX_INVOICED, $baseHiddenTaxInvoiced); } /** @@ -4339,7 +4360,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setHiddenTaxRefunded($hiddenTaxRefunded) { - return $this->setData(ApiOrderInterface::HIDDEN_TAX_REFUNDED, $hiddenTaxRefunded); + return $this->setData(OrderInterface::HIDDEN_TAX_REFUNDED, $hiddenTaxRefunded); } /** @@ -4347,7 +4368,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setBaseHiddenTaxRefunded($baseHiddenTaxRefunded) { - return $this->setData(ApiOrderInterface::BASE_HIDDEN_TAX_REFUNDED, $baseHiddenTaxRefunded); + return $this->setData(OrderInterface::BASE_HIDDEN_TAX_REFUNDED, $baseHiddenTaxRefunded); } /** @@ -4355,7 +4376,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setShippingInclTax($amount) { - return $this->setData(ApiOrderInterface::SHIPPING_INCL_TAX, $amount); + return $this->setData(OrderInterface::SHIPPING_INCL_TAX, $amount); } /** @@ -4363,7 +4384,7 @@ class Order extends AbstractModel implements EntityInterface, ApiOrderInterface */ public function setBaseShippingInclTax($amount) { - return $this->setData(ApiOrderInterface::BASE_SHIPPING_INCL_TAX, $amount); + return $this->setData(OrderInterface::BASE_SHIPPING_INCL_TAX, $amount); } //@codeCoverageIgnoreEnd } diff --git a/app/code/Magento/Sales/Model/Order/Address.php b/app/code/Magento/Sales/Model/Order/Address.php index a5e853f9f3ba7c0b7f0a5a59272ca90c7876eb5f..e0bc6ef9445d7e9cf32fd01860013a3b49fc1d90 100644 --- a/app/code/Magento/Sales/Model/Order/Address.php +++ b/app/code/Magento/Sales/Model/Order/Address.php @@ -9,7 +9,6 @@ use Magento\Customer\Api\AddressMetadataInterface; use Magento\Customer\Api\Data\AddressInterfaceFactory; use Magento\Customer\Api\Data\RegionInterfaceFactory; use Magento\Customer\Model\Address\AbstractAddress; -use Magento\Framework\Api\AttributeValueFactory; use Magento\Sales\Api\Data\OrderAddressInterface; /** @@ -47,14 +46,14 @@ class Address extends AbstractAddress implements OrderAddressInterface /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry - * @param \Magento\Framework\Api\MetadataServiceInterface $metadataService - * @param AttributeValueFactory $customAttributeFactory + * @param \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory + * @param \Magento\Framework\Api\AttributeValueFactory $customAttributeFactory * @param \Magento\Directory\Helper\Data $directoryData * @param \Magento\Eav\Model\Config $eavConfig * @param \Magento\Customer\Model\Address\Config $addressConfig * @param \Magento\Directory\Model\RegionFactory $regionFactory * @param \Magento\Directory\Model\CountryFactory $countryFactory - * @param AddressMetadataInterface $addressMetadataService + * @param AddressMetadataInterface $metadataService * @param AddressInterfaceFactory $addressDataFactory * @param RegionInterfaceFactory $regionDataFactory * @param \Magento\Framework\Api\DataObjectHelper $dataObjectHelper @@ -67,14 +66,14 @@ class Address extends AbstractAddress implements OrderAddressInterface public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, - \Magento\Framework\Api\MetadataServiceInterface $metadataService, - AttributeValueFactory $customAttributeFactory, + \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory, + \Magento\Framework\Api\AttributeValueFactory $customAttributeFactory, \Magento\Directory\Helper\Data $directoryData, \Magento\Eav\Model\Config $eavConfig, \Magento\Customer\Model\Address\Config $addressConfig, \Magento\Directory\Model\RegionFactory $regionFactory, \Magento\Directory\Model\CountryFactory $countryFactory, - AddressMetadataInterface $addressMetadataService, + AddressMetadataInterface $metadataService, AddressInterfaceFactory $addressDataFactory, RegionInterfaceFactory $regionDataFactory, \Magento\Framework\Api\DataObjectHelper $dataObjectHelper, @@ -86,14 +85,14 @@ class Address extends AbstractAddress implements OrderAddressInterface parent::__construct( $context, $registry, - $metadataService, + $extensionFactory, $customAttributeFactory, $directoryData, $eavConfig, $addressConfig, $regionFactory, $countryFactory, - $addressMetadataService, + $metadataService, $addressDataFactory, $regionDataFactory, $dataObjectHelper, @@ -602,5 +601,26 @@ class Address extends AbstractAddress implements OrderAddressInterface { return $this->setData(OrderAddressInterface::VAT_REQUEST_SUCCESS, $vatRequestSuccess); } + + /** + * {@inheritdoc} + * + * @return \Magento\Sales\Api\Data\OrderAddressExtensionInterface|null + */ + public function getExtensionAttributes() + { + return $this->_getExtensionAttributes(); + } + + /** + * {@inheritdoc} + * + * @param \Magento\Sales\Api\Data\OrderAddressExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes(\Magento\Sales\Api\Data\OrderAddressExtensionInterface $extensionAttributes) + { + return $this->_setExtensionAttributes($extensionAttributes); + } //@codeCoverageIgnoreEnd } diff --git a/app/code/Magento/Sales/Model/Order/Creditmemo.php b/app/code/Magento/Sales/Model/Order/Creditmemo.php index 0b75b3c314eebc86694846fef6d0362ab273e911..852d09607d019b58e30e627ca8e497e4c7390cd0 100644 --- a/app/code/Magento/Sales/Model/Order/Creditmemo.php +++ b/app/code/Magento/Sales/Model/Order/Creditmemo.php @@ -114,7 +114,7 @@ class Creditmemo extends AbstractModel implements EntityInterface, CreditmemoInt /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry - * @param \Magento\Framework\Api\MetadataServiceInterface $metadataService + * @param \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory * @param AttributeValueFactory $customAttributeFactory * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Framework\Stdlib\DateTime $dateTime @@ -134,7 +134,7 @@ class Creditmemo extends AbstractModel implements EntityInterface, CreditmemoInt public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, - \Magento\Framework\Api\MetadataServiceInterface $metadataService, + \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory, AttributeValueFactory $customAttributeFactory, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Framework\Stdlib\DateTime $dateTime, @@ -161,7 +161,7 @@ class Creditmemo extends AbstractModel implements EntityInterface, CreditmemoInt parent::__construct( $context, $registry, - $metadataService, + $extensionFactory, $customAttributeFactory, $localeDate, $dateTime, @@ -1630,5 +1630,26 @@ class Creditmemo extends AbstractModel implements EntityInterface, CreditmemoInt { return $this->setData(CreditmemoInterface::DISCOUNT_DESCRIPTION, $description); } + + /** + * {@inheritdoc} + * + * @return \Magento\Sales\Api\Data\CreditmemoExtensionInterface|null + */ + public function getExtensionAttributes() + { + return $this->_getExtensionAttributes(); + } + + /** + * {@inheritdoc} + * + * @param \Magento\Sales\Api\Data\CreditmemoExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes(\Magento\Sales\Api\Data\CreditmemoExtensionInterface $extensionAttributes) + { + return $this->_setExtensionAttributes($extensionAttributes); + } //@codeCoverageIgnoreEnd } diff --git a/app/code/Magento/Sales/Model/Order/Creditmemo/Comment.php b/app/code/Magento/Sales/Model/Order/Creditmemo/Comment.php index 065c772b311e9da882c70a308f176ccce83c54c5..02317f4af9c974829dc5b97f77630ad19bb62322 100644 --- a/app/code/Magento/Sales/Model/Order/Creditmemo/Comment.php +++ b/app/code/Magento/Sales/Model/Order/Creditmemo/Comment.php @@ -31,7 +31,7 @@ class Comment extends AbstractModel implements CreditmemoCommentInterface /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry - * @param \Magento\Framework\Api\MetadataServiceInterface $metadataService + * @param \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory * @param AttributeValueFactory $customAttributeFactory * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Framework\Stdlib\DateTime $dateTime @@ -44,7 +44,7 @@ class Comment extends AbstractModel implements CreditmemoCommentInterface public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, - \Magento\Framework\Api\MetadataServiceInterface $metadataService, + \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory, AttributeValueFactory $customAttributeFactory, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Framework\Stdlib\DateTime $dateTime, @@ -56,7 +56,7 @@ class Comment extends AbstractModel implements CreditmemoCommentInterface parent::__construct( $context, $registry, - $metadataService, + $extensionFactory, $customAttributeFactory, $localeDate, $dateTime, @@ -194,5 +194,27 @@ class Comment extends AbstractModel implements CreditmemoCommentInterface { return $this->setData(CreditmemoCommentInterface::COMMENT, $comment); } + + /** + * {@inheritdoc} + * + * @return \Magento\Sales\Api\Data\CreditmemoCommentExtensionInterface|null + */ + public function getExtensionAttributes() + { + return $this->_getExtensionAttributes(); + } + + /** + * {@inheritdoc} + * + * @param \Magento\Sales\Api\Data\CreditmemoCommentExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes( + \Magento\Sales\Api\Data\CreditmemoCommentExtensionInterface $extensionAttributes + ) { + return $this->_setExtensionAttributes($extensionAttributes); + } //@codeCoverageIgnoreEnd } diff --git a/app/code/Magento/Sales/Model/Order/Creditmemo/Item.php b/app/code/Magento/Sales/Model/Order/Creditmemo/Item.php index ccf9b3ccba989fed845300a50c71709f395868a5..d432435aee29d49dc3ee4c36119ce5c9f30ece4a 100644 --- a/app/code/Magento/Sales/Model/Order/Creditmemo/Item.php +++ b/app/code/Magento/Sales/Model/Order/Creditmemo/Item.php @@ -45,7 +45,7 @@ class Item extends AbstractExtensibleModel implements CreditmemoItemInterface /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry - * @param \Magento\Framework\Api\MetadataServiceInterface $metadataService + * @param \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory * @param AttributeValueFactory $customAttributeFactory * @param \Magento\Sales\Model\Order\ItemFactory $orderItemFactory * @param \Magento\Framework\Model\Resource\AbstractResource $resource @@ -55,7 +55,7 @@ class Item extends AbstractExtensibleModel implements CreditmemoItemInterface public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, - \Magento\Framework\Api\MetadataServiceInterface $metadataService, + \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory, AttributeValueFactory $customAttributeFactory, \Magento\Sales\Model\Order\ItemFactory $orderItemFactory, \Magento\Framework\Model\Resource\AbstractResource $resource = null, @@ -65,7 +65,7 @@ class Item extends AbstractExtensibleModel implements CreditmemoItemInterface parent::__construct( $context, $registry, - $metadataService, + $extensionFactory, $customAttributeFactory, $resource, $resourceCollection, @@ -821,5 +821,27 @@ class Item extends AbstractExtensibleModel implements CreditmemoItemInterface { return $this->setData(CreditmemoItemInterface::WEEE_TAX_APPLIED_ROW_AMOUNT, $amount); } + + /** + * {@inheritdoc} + * + * @return \Magento\Sales\Api\Data\CreditmemoItemExtensionInterface|null + */ + public function getExtensionAttributes() + { + return $this->_getExtensionAttributes(); + } + + /** + * {@inheritdoc} + * + * @param \Magento\Sales\Api\Data\CreditmemoItemExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes( + \Magento\Sales\Api\Data\CreditmemoItemExtensionInterface $extensionAttributes + ) { + return $this->_setExtensionAttributes($extensionAttributes); + } //@codeCoverageIgnoreEnd } diff --git a/app/code/Magento/Sales/Model/Order/Invoice.php b/app/code/Magento/Sales/Model/Order/Invoice.php index ab6e124d48c21d0e3d89fe96b6430d365f4afc48..106aaf473b446e5718c6e28e4c2983424bb7fd04 100644 --- a/app/code/Magento/Sales/Model/Order/Invoice.php +++ b/app/code/Magento/Sales/Model/Order/Invoice.php @@ -116,7 +116,7 @@ class Invoice extends AbstractModel implements EntityInterface, InvoiceInterface /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry - * @param \Magento\Framework\Api\MetadataServiceInterface $metadataService + * @param \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory * @param AttributeValueFactory $customAttributeFactory * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Framework\Stdlib\DateTime $dateTime @@ -134,7 +134,7 @@ class Invoice extends AbstractModel implements EntityInterface, InvoiceInterface public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, - \Magento\Framework\Api\MetadataServiceInterface $metadataService, + \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory, AttributeValueFactory $customAttributeFactory, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Framework\Stdlib\DateTime $dateTime, @@ -157,7 +157,7 @@ class Invoice extends AbstractModel implements EntityInterface, InvoiceInterface parent::__construct( $context, $registry, - $metadataService, + $extensionFactory, $customAttributeFactory, $localeDate, $dateTime, @@ -1574,5 +1574,26 @@ class Invoice extends AbstractModel implements EntityInterface, InvoiceInterface { return $this->setData(InvoiceInterface::DISCOUNT_DESCRIPTION, $description); } + + /** + * {@inheritdoc} + * + * @return \Magento\Sales\Api\Data\InvoiceExtensionInterface|null + */ + public function getExtensionAttributes() + { + return $this->_getExtensionAttributes(); + } + + /** + * {@inheritdoc} + * + * @param \Magento\Sales\Api\Data\InvoiceExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes(\Magento\Sales\Api\Data\InvoiceExtensionInterface $extensionAttributes) + { + return $this->_setExtensionAttributes($extensionAttributes); + } //@codeCoverageIgnoreEnd } diff --git a/app/code/Magento/Sales/Model/Order/Invoice/Comment.php b/app/code/Magento/Sales/Model/Order/Invoice/Comment.php index 73b1007e543759b14c97f36fca337ffe3ceed9af..e1f31fa4c025719b4a95caac311b1f42fedfbe1b 100644 --- a/app/code/Magento/Sales/Model/Order/Invoice/Comment.php +++ b/app/code/Magento/Sales/Model/Order/Invoice/Comment.php @@ -31,7 +31,7 @@ class Comment extends AbstractModel implements InvoiceCommentInterface /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry - * @param \Magento\Framework\Api\MetadataServiceInterface $metadataService + * @param \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory * @param AttributeValueFactory $customAttributeFactory * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Framework\Stdlib\DateTime $dateTime @@ -44,7 +44,7 @@ class Comment extends AbstractModel implements InvoiceCommentInterface public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, - \Magento\Framework\Api\MetadataServiceInterface $metadataService, + \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory, AttributeValueFactory $customAttributeFactory, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Framework\Stdlib\DateTime $dateTime, @@ -56,7 +56,7 @@ class Comment extends AbstractModel implements InvoiceCommentInterface parent::__construct( $context, $registry, - $metadataService, + $extensionFactory, $customAttributeFactory, $localeDate, $dateTime, @@ -194,5 +194,27 @@ class Comment extends AbstractModel implements InvoiceCommentInterface { return $this->setData(InvoiceCommentInterface::COMMENT, $comment); } + + /** + * {@inheritdoc} + * + * @return \Magento\Sales\Api\Data\InvoiceCommentExtensionInterface|null + */ + public function getExtensionAttributes() + { + return $this->_getExtensionAttributes(); + } + + /** + * {@inheritdoc} + * + * @param \Magento\Sales\Api\Data\InvoiceCommentExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes( + \Magento\Sales\Api\Data\InvoiceCommentExtensionInterface $extensionAttributes + ) { + return $this->_setExtensionAttributes($extensionAttributes); + } //@codeCoverageIgnoreEnd } diff --git a/app/code/Magento/Sales/Model/Order/Invoice/Item.php b/app/code/Magento/Sales/Model/Order/Invoice/Item.php index ddd89354cd33790e53b037bc50a0411c6d840f7b..60c92a7f68b0f68d61697171246020ed2d103688 100644 --- a/app/code/Magento/Sales/Model/Order/Invoice/Item.php +++ b/app/code/Magento/Sales/Model/Order/Invoice/Item.php @@ -62,7 +62,7 @@ class Item extends AbstractExtensibleModel implements InvoiceItemInterface /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry - * @param \Magento\Framework\Api\MetadataServiceInterface $metadataService + * @param \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory * @param AttributeValueFactory $customAttributeFactory * @param \Magento\Sales\Model\Order\ItemFactory $orderItemFactory * @param \Magento\Framework\Model\Resource\AbstractResource $resource @@ -72,7 +72,7 @@ class Item extends AbstractExtensibleModel implements InvoiceItemInterface public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, - \Magento\Framework\Api\MetadataServiceInterface $metadataService, + \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory, AttributeValueFactory $customAttributeFactory, \Magento\Sales\Model\Order\ItemFactory $orderItemFactory, \Magento\Framework\Model\Resource\AbstractResource $resource = null, @@ -82,7 +82,7 @@ class Item extends AbstractExtensibleModel implements InvoiceItemInterface parent::__construct( $context, $registry, - $metadataService, + $extensionFactory, $customAttributeFactory, $resource, $resourceCollection, @@ -684,5 +684,26 @@ class Item extends AbstractExtensibleModel implements InvoiceItemInterface { return $this->setData(InvoiceItemInterface::BASE_HIDDEN_TAX_AMOUNT, $amount); } + + /** + * {@inheritdoc} + * + * @return \Magento\Sales\Api\Data\InvoiceItemExtensionInterface|null + */ + public function getExtensionAttributes() + { + return $this->_getExtensionAttributes(); + } + + /** + * {@inheritdoc} + * + * @param \Magento\Sales\Api\Data\InvoiceItemExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes(\Magento\Sales\Api\Data\InvoiceItemExtensionInterface $extensionAttributes) + { + return $this->_setExtensionAttributes($extensionAttributes); + } //@codeCoverageIgnoreEnd } diff --git a/app/code/Magento/Sales/Model/Order/Item.php b/app/code/Magento/Sales/Model/Order/Item.php index e91edff1ccc35b863ca87918d18715001648ee21..7fd4dc4ec38fa1681b592e496ef303e38acb8e4e 100644 --- a/app/code/Magento/Sales/Model/Order/Item.php +++ b/app/code/Magento/Sales/Model/Order/Item.php @@ -101,20 +101,20 @@ class Item extends AbstractExtensibleModel implements OrderItemInterface * * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry - * @param \Magento\Framework\Api\MetadataServiceInterface $metadataService + * @param \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory * @param AttributeValueFactory $customAttributeFactory * @param \Magento\Sales\Model\OrderFactory $orderFactory + * @param \Magento\Store\Model\StoreManagerInterface $storeManager * @param \Magento\Catalog\Api\ProductRepositoryInterface $productRepository * @param \Magento\Framework\Model\Resource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\Db $resourceCollection - * @param \Magento\Store\Model\StoreManagerInterface $storeManager * @param array $data * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, - \Magento\Framework\Api\MetadataServiceInterface $metadataService, + \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory, AttributeValueFactory $customAttributeFactory, \Magento\Sales\Model\OrderFactory $orderFactory, \Magento\Store\Model\StoreManagerInterface $storeManager, @@ -126,7 +126,7 @@ class Item extends AbstractExtensibleModel implements OrderItemInterface parent::__construct( $context, $registry, - $metadataService, + $extensionFactory, $customAttributeFactory, $resource, $resourceCollection, @@ -2327,5 +2327,26 @@ class Item extends AbstractExtensibleModel implements OrderItemInterface { return $this->setData(OrderItemInterface::BASE_WEEE_TAX_ROW_DISPOSITION, $baseWeeeTaxRowDisposition); } + + /** + * {@inheritdoc} + * + * @return \Magento\Sales\Api\Data\OrderItemExtensionInterface|null + */ + public function getExtensionAttributes() + { + return $this->_getExtensionAttributes(); + } + + /** + * {@inheritdoc} + * + * @param \Magento\Sales\Api\Data\OrderItemExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes(\Magento\Sales\Api\Data\OrderItemExtensionInterface $extensionAttributes) + { + return $this->_setExtensionAttributes($extensionAttributes); + } //@codeCoverageIgnoreEnd } diff --git a/app/code/Magento/Sales/Model/Order/Payment.php b/app/code/Magento/Sales/Model/Order/Payment.php index d20449aea2849382028664428b386ffa34290de8..f308b43487ffc6e238e31f87b45185d123431bf4 100644 --- a/app/code/Magento/Sales/Model/Order/Payment.php +++ b/app/code/Magento/Sales/Model/Order/Payment.php @@ -8,7 +8,6 @@ namespace Magento\Sales\Model\Order; -use Magento\Framework\Api\AttributeValueFactory; use Magento\Framework\Pricing\PriceCurrencyInterface; use Magento\Payment\Model\Info; use Magento\Sales\Api\Data\OrderPaymentInterface; @@ -101,8 +100,8 @@ class Payment extends Info implements OrderPaymentInterface /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry - * @param \Magento\Framework\Api\MetadataServiceInterface $metadataService - * @param AttributeValueFactory $customAttributeFactory + * @param \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory + * @param \Magento\Framework\Api\AttributeValueFactory $customAttributeFactory * @param \Magento\Payment\Helper\Data $paymentData * @param \Magento\Framework\Encryption\EncryptorInterface $encryptor * @param \Magento\Sales\Model\Service\OrderFactory $serviceOrderFactory @@ -118,8 +117,8 @@ class Payment extends Info implements OrderPaymentInterface public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, - \Magento\Framework\Api\MetadataServiceInterface $metadataService, - AttributeValueFactory $customAttributeFactory, + \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory, + \Magento\Framework\Api\AttributeValueFactory $customAttributeFactory, \Magento\Payment\Helper\Data $paymentData, \Magento\Framework\Encryption\EncryptorInterface $encryptor, \Magento\Sales\Model\Service\OrderFactory $serviceOrderFactory, @@ -139,7 +138,7 @@ class Payment extends Info implements OrderPaymentInterface parent::__construct( $context, $registry, - $metadataService, + $extensionFactory, $customAttributeFactory, $paymentData, $encryptor, @@ -691,7 +690,6 @@ class Payment extends Info implements OrderPaymentInterface if (!$captureTxn) { throw new \Magento\Framework\Exception\LocalizedException( __('If the invoice was created offline, try creating an offline credit memo.'), - [], $e ); } @@ -2572,5 +2570,26 @@ class Payment extends Info implements OrderPaymentInterface { return $this->setData(OrderPaymentInterface::ADDRESS_STATUS, $addressStatus); } + + /** + * {@inheritdoc} + * + * @return \Magento\Sales\Api\Data\OrderPaymentExtensionInterface|null + */ + public function getExtensionAttributes() + { + return $this->_getExtensionAttributes(); + } + + /** + * {@inheritdoc} + * + * @param \Magento\Sales\Api\Data\OrderPaymentExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes(\Magento\Sales\Api\Data\OrderPaymentExtensionInterface $extensionAttributes) + { + return $this->_setExtensionAttributes($extensionAttributes); + } //@codeCoverageIgnoreEnd } diff --git a/app/code/Magento/Sales/Model/Order/Payment/Transaction.php b/app/code/Magento/Sales/Model/Order/Payment/Transaction.php index fde468255771fee880d6a931e79696c8a6da925e..942cf9475983eb24457bfd676c6cf216dc8f2294 100644 --- a/app/code/Magento/Sales/Model/Order/Payment/Transaction.php +++ b/app/code/Magento/Sales/Model/Order/Payment/Transaction.php @@ -20,7 +20,7 @@ use Magento\Sales\Api\Data\TransactionInterface; * @method \Magento\Sales\Model\Resource\Order\Payment\Transaction _getResource() * @method \Magento\Sales\Model\Resource\Order\Payment\Transaction getResource() * @method \Magento\Sales\Model\Order\Payment\Transaction setCreatedAt(string $value) - * + * @author Magento Core Team <core@magentocommerce.com> * @SuppressWarnings(PHPMD.ExcessiveClassComplexity) * @SuppressWarnings(PHPMD.CouplingBetweenObjects) @@ -111,7 +111,7 @@ class Transaction extends AbstractExtensibleModel implements TransactionInterfac * Event object prefix * * @var string - * @see \Magento\Core\Model\Absctract::$_eventPrefix + * @see \Magento\Framework\Model\AbstractModel::$_eventPrefix */ protected $_eventPrefix = 'sales_order_payment_transaction'; @@ -119,7 +119,7 @@ class Transaction extends AbstractExtensibleModel implements TransactionInterfac * Event object prefix * * @var string - * @see \Magento\Core\Model\Absctract::$_eventObject + * @see \Magento\Framework\Model\AbstractModel::$_eventObject */ protected $_eventObject = 'order_payment_transaction'; @@ -153,7 +153,7 @@ class Transaction extends AbstractExtensibleModel implements TransactionInterfac /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry - * @param \Magento\Framework\Api\MetadataServiceInterface $metadataService + * @param \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory * @param AttributeValueFactory $customAttributeFactory * @param \Magento\Sales\Model\Order\PaymentFactory $paymentFactory * @param \Magento\Sales\Model\OrderFactory $orderFactory @@ -167,7 +167,7 @@ class Transaction extends AbstractExtensibleModel implements TransactionInterfac public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, - \Magento\Framework\Api\MetadataServiceInterface $metadataService, + \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory, AttributeValueFactory $customAttributeFactory, \Magento\Sales\Model\Order\PaymentFactory $paymentFactory, \Magento\Sales\Model\OrderFactory $orderFactory, @@ -184,7 +184,7 @@ class Transaction extends AbstractExtensibleModel implements TransactionInterfac parent::__construct( $context, $registry, - $metadataService, + $extensionFactory, $customAttributeFactory, $resource, $resourceCollection, @@ -1044,5 +1044,26 @@ class Transaction extends AbstractExtensibleModel implements TransactionInterfac { return $this->setData(TransactionInterface::IS_CLOSED, $isClosed); } + + /** + * {@inheritdoc} + * + * @return \Magento\Sales\Api\Data\TransactionExtensionInterface|null + */ + public function getExtensionAttributes() + { + return $this->_getExtensionAttributes(); + } + + /** + * {@inheritdoc} + * + * @param \Magento\Sales\Api\Data\TransactionExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes(\Magento\Sales\Api\Data\TransactionExtensionInterface $extensionAttributes) + { + return $this->_setExtensionAttributes($extensionAttributes); + } //@codeCoverageIgnoreEnd } diff --git a/app/code/Magento/Sales/Model/Order/Payment/TransactionRepository.php b/app/code/Magento/Sales/Model/Order/Payment/TransactionRepository.php index f04fc104817cb2038fb8dc2aae1a0a6e489f1767..da58fb8949588d7f2715dcbef38e22ff97769c2c 100644 --- a/app/code/Magento/Sales/Model/Order/Payment/TransactionRepository.php +++ b/app/code/Magento/Sales/Model/Order/Payment/TransactionRepository.php @@ -77,7 +77,7 @@ class TransactionRepository public function get($id) { if (!$id) { - throw new \Magento\Framework\Exception\InputException('ID required'); + throw new \Magento\Framework\Exception\InputException(__('ID required')); } if (!isset($this->registry[$id])) { $filter = $this->filterBuilder->setField('transaction_id')->setValue($id)->setConditionType('eq')->create(); @@ -85,7 +85,9 @@ class TransactionRepository $this->find($this->searchCriteriaBuilder->create()); if (!isset($this->registry[$id])) { - throw new \Magento\Framework\Exception\NoSuchEntityException('Requested entity doesn\'t exist'); + throw new \Magento\Framework\Exception\NoSuchEntityException( + __('Requested entity doesn\'t exist') + ); } } return $this->registry[$id]; diff --git a/app/code/Magento/Sales/Model/Order/Pdf/Total/Factory.php b/app/code/Magento/Sales/Model/Order/Pdf/Total/Factory.php index af33e3b1522889f58c5da651ff2c0dba17aa05d5..fa724f3b481d46fefd26a8c0fe842f06e4f6e2ce 100644 --- a/app/code/Magento/Sales/Model/Order/Pdf/Total/Factory.php +++ b/app/code/Magento/Sales/Model/Order/Pdf/Total/Factory.php @@ -40,8 +40,8 @@ class Factory $class = $class ?: $this->_defaultTotalModel; if (!is_a($class, 'Magento\Sales\Model\Order\Pdf\Total\DefaultTotal', true)) { throw new \Magento\Framework\Exception\LocalizedException( - sprintf( - 'The PDF total model %s must be or extend \Magento\Sales\Model\Order\Pdf\Total\DefaultTotal.', + __( + 'The PDF total model %1 must be or extend \Magento\Sales\Model\Order\Pdf\Total\DefaultTotal.', $class ) ); diff --git a/app/code/Magento/Sales/Model/Order/Shipment.php b/app/code/Magento/Sales/Model/Order/Shipment.php index 0e5a3c5cf9249f742dd1fbb51bed1d05d951c589..51b24d4fb8946a28f8d21585e789ee561f611bb2 100644 --- a/app/code/Magento/Sales/Model/Order/Shipment.php +++ b/app/code/Magento/Sales/Model/Order/Shipment.php @@ -92,7 +92,7 @@ class Shipment extends AbstractModel implements EntityInterface, ShipmentInterfa /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry - * @param \Magento\Framework\Api\MetadataServiceInterface $metadataService + * @param \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory * @param AttributeValueFactory $customAttributeFactory * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Framework\Stdlib\DateTime $dateTime @@ -109,7 +109,7 @@ class Shipment extends AbstractModel implements EntityInterface, ShipmentInterfa public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, - \Magento\Framework\Api\MetadataServiceInterface $metadataService, + \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory, AttributeValueFactory $customAttributeFactory, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Framework\Stdlib\DateTime $dateTime, @@ -130,7 +130,7 @@ class Shipment extends AbstractModel implements EntityInterface, ShipmentInterfa parent::__construct( $context, $registry, - $metadataService, + $extensionFactory, $customAttributeFactory, $localeDate, $dateTime, @@ -826,5 +826,26 @@ class Shipment extends AbstractModel implements EntityInterface, ShipmentInterfa { return $this->setData(ShipmentInterface::UPDATED_AT, $timestamp); } + + /** + * {@inheritdoc} + * + * @return \Magento\Sales\Api\Data\ShipmentExtensionInterface|null + */ + public function getExtensionAttributes() + { + return $this->_getExtensionAttributes(); + } + + /** + * {@inheritdoc} + * + * @param \Magento\Sales\Api\Data\ShipmentExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes(\Magento\Sales\Api\Data\ShipmentExtensionInterface $extensionAttributes) + { + return $this->_setExtensionAttributes($extensionAttributes); + } //@codeCoverageIgnoreEnd } diff --git a/app/code/Magento/Sales/Model/Order/Shipment/Comment.php b/app/code/Magento/Sales/Model/Order/Shipment/Comment.php index cd39cbf1818f3889f8df0ae6f6198e980e2a5dc8..871d04fa49f472f06913b2ceb950557d7912f9db 100644 --- a/app/code/Magento/Sales/Model/Order/Shipment/Comment.php +++ b/app/code/Magento/Sales/Model/Order/Shipment/Comment.php @@ -31,7 +31,7 @@ class Comment extends AbstractModel implements ShipmentCommentInterface /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry - * @param \Magento\Framework\Api\MetadataServiceInterface $metadataService + * @param \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory * @param AttributeValueFactory $customAttributeFactory * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Framework\Stdlib\DateTime $dateTime @@ -44,7 +44,7 @@ class Comment extends AbstractModel implements ShipmentCommentInterface public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, - \Magento\Framework\Api\MetadataServiceInterface $metadataService, + \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory, AttributeValueFactory $customAttributeFactory, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Framework\Stdlib\DateTime $dateTime, @@ -56,7 +56,7 @@ class Comment extends AbstractModel implements ShipmentCommentInterface parent::__construct( $context, $registry, - $metadataService, + $extensionFactory, $customAttributeFactory, $localeDate, $dateTime, @@ -194,5 +194,27 @@ class Comment extends AbstractModel implements ShipmentCommentInterface { return $this->setData(ShipmentCommentInterface::COMMENT, $comment); } + + /** + * {@inheritdoc} + * + * @return \Magento\Sales\Api\Data\ShipmentCommentExtensionInterface|null + */ + public function getExtensionAttributes() + { + return $this->_getExtensionAttributes(); + } + + /** + * {@inheritdoc} + * + * @param \Magento\Sales\Api\Data\ShipmentCommentExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes( + \Magento\Sales\Api\Data\ShipmentCommentExtensionInterface $extensionAttributes + ) { + return $this->_setExtensionAttributes($extensionAttributes); + } //@codeCoverageIgnoreEnd } diff --git a/app/code/Magento/Sales/Model/Order/Shipment/Item.php b/app/code/Magento/Sales/Model/Order/Shipment/Item.php index 4e0099fee1fe842f785fd3e96b3e194b2d55ea2d..415b2bfcb79dfcc4ff72e9ac26fcf075358e0534 100644 --- a/app/code/Magento/Sales/Model/Order/Shipment/Item.php +++ b/app/code/Magento/Sales/Model/Order/Shipment/Item.php @@ -15,6 +15,7 @@ use Magento\Sales\Api\Data\ShipmentItemInterface; /** * @method \Magento\Sales\Model\Resource\Order\Shipment\Item _getResource() * @method \Magento\Sales\Model\Resource\Order\Shipment\Item getResource() + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class Item extends AbstractExtensibleModel implements ShipmentItemInterface { @@ -46,7 +47,7 @@ class Item extends AbstractExtensibleModel implements ShipmentItemInterface /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry - * @param \Magento\Framework\Api\MetadataServiceInterface $metadataService + * @param \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory * @param AttributeValueFactory $customAttributeFactory * @param \Magento\Sales\Model\Order\ItemFactory $orderItemFactory * @param \Magento\Framework\Model\Resource\AbstractResource $resource @@ -56,7 +57,7 @@ class Item extends AbstractExtensibleModel implements ShipmentItemInterface public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, - \Magento\Framework\Api\MetadataServiceInterface $metadataService, + \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory, AttributeValueFactory $customAttributeFactory, \Magento\Sales\Model\Order\ItemFactory $orderItemFactory, \Magento\Framework\Model\Resource\AbstractResource $resource = null, @@ -66,7 +67,7 @@ class Item extends AbstractExtensibleModel implements ShipmentItemInterface parent::__construct( $context, $registry, - $metadataService, + $extensionFactory, $customAttributeFactory, $resource, $resourceCollection, @@ -158,7 +159,9 @@ class Item extends AbstractExtensibleModel implements ShipmentItemInterface if ($qty <= $this->getOrderItem()->getQtyToShip() || $this->getOrderItem()->isDummy(true)) { $this->setData('qty', $qty); } else { - throw new \Magento\Framework\Exception\LocalizedException(__('We found an invalid qty to ship for item "%1".', $this->getName())); + throw new \Magento\Framework\Exception\LocalizedException( + __('We found an invalid qty to ship for item "%1".', $this->getName()) + ); } return $this; } @@ -364,5 +367,26 @@ class Item extends AbstractExtensibleModel implements ShipmentItemInterface { return $this->setData(ShipmentItemInterface::SKU, $sku); } + + /** + * {@inheritdoc} + * + * @return \Magento\Sales\Api\Data\ShipmentItemExtensionInterface|null + */ + public function getExtensionAttributes() + { + return $this->_getExtensionAttributes(); + } + + /** + * {@inheritdoc} + * + * @param \Magento\Sales\Api\Data\ShipmentItemExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes(\Magento\Sales\Api\Data\ShipmentItemExtensionInterface $extensionAttributes) + { + return $this->_setExtensionAttributes($extensionAttributes); + } //@codeCoverageIgnoreEnd } diff --git a/app/code/Magento/Sales/Model/Order/Shipment/Track.php b/app/code/Magento/Sales/Model/Order/Shipment/Track.php index f8e47cd53ee210a6d297c6ac13df86edfb06dfd1..85b0e3419eca06e7e7564a9a9b57d72317fbf37a 100644 --- a/app/code/Magento/Sales/Model/Order/Shipment/Track.php +++ b/app/code/Magento/Sales/Model/Order/Shipment/Track.php @@ -52,7 +52,7 @@ class Track extends AbstractModel implements ShipmentTrackInterface /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry - * @param \Magento\Framework\Api\MetadataServiceInterface $metadataService + * @param \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory * @param AttributeValueFactory $customAttributeFactory * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Framework\Stdlib\DateTime $dateTime @@ -66,7 +66,7 @@ class Track extends AbstractModel implements ShipmentTrackInterface public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, - \Magento\Framework\Api\MetadataServiceInterface $metadataService, + \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory, AttributeValueFactory $customAttributeFactory, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Framework\Stdlib\DateTime $dateTime, @@ -79,7 +79,7 @@ class Track extends AbstractModel implements ShipmentTrackInterface parent::__construct( $context, $registry, - $metadataService, + $extensionFactory, $customAttributeFactory, $localeDate, $dateTime, @@ -380,5 +380,26 @@ class Track extends AbstractModel implements ShipmentTrackInterface { return $this->setData(ShipmentTrackInterface::CARRIER_CODE, $code); } + + /** + * {@inheritdoc} + * + * @return \Magento\Sales\Api\Data\ShipmentTrackExtensionInterface|null + */ + public function getExtensionAttributes() + { + return $this->_getExtensionAttributes(); + } + + /** + * {@inheritdoc} + * + * @param \Magento\Sales\Api\Data\ShipmentTrackExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes(\Magento\Sales\Api\Data\ShipmentTrackExtensionInterface $extensionAttributes) + { + return $this->_setExtensionAttributes($extensionAttributes); + } //@codeCoverageIgnoreEnd } diff --git a/app/code/Magento/Sales/Model/Order/Status/History.php b/app/code/Magento/Sales/Model/Order/Status/History.php index 59d6c02054eb1b3b1d829969ae0dc48ff070e559..5ce6a1aa42ba7fa0a405d3174b9e06a469d276db 100644 --- a/app/code/Magento/Sales/Model/Order/Status/History.php +++ b/app/code/Magento/Sales/Model/Order/Status/History.php @@ -45,7 +45,7 @@ class History extends AbstractModel implements OrderStatusHistoryInterface /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry - * @param \Magento\Framework\Api\MetadataServiceInterface $metadataService + * @param \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory * @param AttributeValueFactory $customAttributeFactory * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Framework\Stdlib\DateTime $dateTime @@ -58,7 +58,7 @@ class History extends AbstractModel implements OrderStatusHistoryInterface public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, - \Magento\Framework\Api\MetadataServiceInterface $metadataService, + \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory, AttributeValueFactory $customAttributeFactory, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Framework\Stdlib\DateTime $dateTime, @@ -70,7 +70,7 @@ class History extends AbstractModel implements OrderStatusHistoryInterface parent::__construct( $context, $registry, - $metadataService, + $extensionFactory, $customAttributeFactory, $localeDate, $dateTime, @@ -301,5 +301,27 @@ class History extends AbstractModel implements OrderStatusHistoryInterface { return $this->setData(OrderStatusHistoryInterface::ENTITY_NAME, $entityName); } + + /** + * {@inheritdoc} + * + * @return \Magento\Sales\Api\Data\OrderStatusHistoryExtensionInterface|null + */ + public function getExtensionAttributes() + { + return $this->_getExtensionAttributes(); + } + + /** + * {@inheritdoc} + * + * @param \Magento\Sales\Api\Data\OrderStatusHistoryExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes( + \Magento\Sales\Api\Data\OrderStatusHistoryExtensionInterface $extensionAttributes + ) { + return $this->_setExtensionAttributes($extensionAttributes); + } //@codeCoverageIgnoreEnd } diff --git a/app/code/Magento/Sales/Model/Resource/Order/Address.php b/app/code/Magento/Sales/Model/Resource/Order/Address.php index bbe542dc5a5752c73b1c0332d139901b76ae41b5..0ae0007afce4c6df73de79ae9dfb3a79fd7bee57 100644 --- a/app/code/Magento/Sales/Model/Resource/Order/Address.php +++ b/app/code/Magento/Sales/Model/Resource/Order/Address.php @@ -107,7 +107,7 @@ class Address extends SalesResource implements OrderAddressResourceInterface $warnings = $this->_validator->validate($object); if (!empty($warnings)) { throw new \Magento\Framework\Exception\LocalizedException( - __("Cannot save address") . ":\n" . implode("\n", $warnings) + __("Cannot save address:\n%1", implode("\n", $warnings)) ); } return $this; diff --git a/app/code/Magento/Sales/Model/Resource/Order/Creditmemo/Comment.php b/app/code/Magento/Sales/Model/Resource/Order/Creditmemo/Comment.php index b26ff144fb4765a0c666e13f590a7243d0fbe898..4bd2bc8463cfeec1d5a6d18b75f2196f71ae6e31 100644 --- a/app/code/Magento/Sales/Model/Resource/Order/Creditmemo/Comment.php +++ b/app/code/Magento/Sales/Model/Resource/Order/Creditmemo/Comment.php @@ -77,7 +77,7 @@ class Comment extends Entity implements CreditmemoCommentResourceInterface $errors = $this->validator->validate($object); if (!empty($errors)) { throw new \Magento\Framework\Exception\LocalizedException( - __("Cannot save comment") . ":\n" . implode("\n", $errors) + __("Cannot save comment:\n%1", implode("\n", $errors)) ); } return $this; diff --git a/app/code/Magento/Sales/Model/Resource/Order/Invoice/Comment.php b/app/code/Magento/Sales/Model/Resource/Order/Invoice/Comment.php index ebfdc76baac952d5b71e77ea1958047d8b2729ee..32d95112c41bf7215db251323aa6d313f596b9d1 100644 --- a/app/code/Magento/Sales/Model/Resource/Order/Invoice/Comment.php +++ b/app/code/Magento/Sales/Model/Resource/Order/Invoice/Comment.php @@ -77,7 +77,7 @@ class Comment extends Entity implements InvoiceCommentResourceInterface $errors = $this->validator->validate($object); if (!empty($errors)) { throw new \Magento\Framework\Exception\LocalizedException( - __("Cannot save comment") . ":\n" . implode("\n", $errors) + __("Cannot save comment:\n%1", implode("\n", $errors)) ); } diff --git a/app/code/Magento/Sales/Model/Resource/Order/Shipment/Comment.php b/app/code/Magento/Sales/Model/Resource/Order/Shipment/Comment.php index 4ed6b5f5c48bdec471b9b172bde92419046c0909..e18d89970fb50860305407633261e6e2f5d29479 100644 --- a/app/code/Magento/Sales/Model/Resource/Order/Shipment/Comment.php +++ b/app/code/Magento/Sales/Model/Resource/Order/Shipment/Comment.php @@ -77,7 +77,7 @@ class Comment extends Entity implements ShipmentCommentResourceInterface $errors = $this->validator->validate($object); if (!empty($errors)) { throw new \Magento\Framework\Exception\LocalizedException( - __("Cannot save comment") . ":\n" . implode("\n", $errors) + __("Cannot save comment:\n%1", implode("\n", $errors)) ); } diff --git a/app/code/Magento/Sales/Model/Resource/Order/Shipment/Track.php b/app/code/Magento/Sales/Model/Resource/Order/Shipment/Track.php index f578d8b127fe841c3a74cb19dc2ef8022a9ff537..9ff1715b0dc714a8ce93d562ec99f770312541f3 100644 --- a/app/code/Magento/Sales/Model/Resource/Order/Shipment/Track.php +++ b/app/code/Magento/Sales/Model/Resource/Order/Shipment/Track.php @@ -77,7 +77,7 @@ class Track extends SalesResource implements ShipmentTrackResourceInterface $errors = $this->validator->validate($object); if (!empty($errors)) { throw new \Magento\Framework\Exception\LocalizedException( - __("Cannot save track") . ":\n" . implode("\n", $errors) + __("Cannot save track:\n%1", implode("\n", $errors)) ); } diff --git a/app/code/Magento/Sales/Model/Resource/Order/Status.php b/app/code/Magento/Sales/Model/Resource/Order/Status.php index 717b0815250f2db097829db2535b961a64541404..c4a1ff9408d4c4136a6772d55017a9fa3dd3c30e 100644 --- a/app/code/Magento/Sales/Model/Resource/Order/Status.php +++ b/app/code/Magento/Sales/Model/Resource/Order/Status.php @@ -205,7 +205,7 @@ class Status extends \Magento\Framework\Model\Resource\Db\AbstractDb $this->_getWriteAdapter()->commit(); } catch (\Exception $e) { $this->_getWriteAdapter()->rollBack(); - throw new LocalizedException(__('Cannot unassing status from state')); + throw new LocalizedException(__('Cannot unassign status from state')); } return $this; diff --git a/app/code/Magento/Sales/Model/Resource/Order/Status/History.php b/app/code/Magento/Sales/Model/Resource/Order/Status/History.php index a92dea95519e04cc4a0fdceca9d53a5f6e6b94c8..ff92ebe32c2ebc63be6afd3d3cbeba8b8a7dba14 100644 --- a/app/code/Magento/Sales/Model/Resource/Order/Status/History.php +++ b/app/code/Magento/Sales/Model/Resource/Order/Status/History.php @@ -71,7 +71,7 @@ class History extends Entity implements OrderStatusHistoryResourceInterface $warnings = $this->validator->validate($object); if (!empty($warnings)) { throw new \Magento\Framework\Exception\LocalizedException( - __('Cannot save comment') . ":\n" . implode("\n", $warnings) + __("Cannot save comment:\n%1", implode("\n", $warnings)) ); } return $this; diff --git a/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/View/Tab/Stub/OnlineMethod.php b/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/View/Tab/Stub/OnlineMethod.php index f6145240f582a67e371f5debc9dcafa745e13135..3052b410765c572f7d308017bd8a26c46d6ad8af 100644 --- a/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/View/Tab/Stub/OnlineMethod.php +++ b/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/View/Tab/Stub/OnlineMethod.php @@ -7,6 +7,7 @@ namespace Magento\Sales\Test\Unit\Block\Adminhtml\Order\View\Tab\Stub; /** * Stub for an online payment method + * @method \Magento\Quote\Api\Data\PaymentMethodExtensionInterface getExtensionAttributes() */ class OnlineMethod extends \Magento\Payment\Model\Method\AbstractMethod { diff --git a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Creditmemo/AddCommentTest.php b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Creditmemo/AddCommentTest.php old mode 100644 new mode 100755 index 1289656b3188d2292bb61de601caf830aeafc853..b7b8759dfc4016b42702cb84f7e7c5b7ed76bbba --- a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Creditmemo/AddCommentTest.php +++ b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Creditmemo/AddCommentTest.php @@ -51,7 +51,7 @@ class AddCommentTest extends \PHPUnit_Framework_TestCase protected $resultPageFactoryMock; /** - * @var \Magento\Framework\Controller\Result\JSONFactory|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Controller\Result\JsonFactory|\PHPUnit_Framework_MockObject_MockObject */ protected $resultJsonFactoryMock; @@ -66,7 +66,7 @@ class AddCommentTest extends \PHPUnit_Framework_TestCase protected $resultPageMock; /** - * @var \Magento\Framework\Controller\Result\JSON|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Controller\Result\Json|\PHPUnit_Framework_MockObject_MockObject */ protected $resultJsonMock; @@ -75,6 +75,11 @@ class AddCommentTest extends \PHPUnit_Framework_TestCase */ protected $resultRawMock; + /** + * SetUp method + * + * @return void + */ public function setUp() { $titleMock = $this->getMockBuilder('Magento\Framework\App\Action\Title') @@ -112,7 +117,7 @@ class AddCommentTest extends \PHPUnit_Framework_TestCase ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->resultJsonFactoryMock = $this->getMockBuilder('Magento\Framework\Controller\Result\JSONFactory') + $this->resultJsonFactoryMock = $this->getMockBuilder('Magento\Framework\Controller\Result\JsonFactory') ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); @@ -123,7 +128,7 @@ class AddCommentTest extends \PHPUnit_Framework_TestCase $this->resultPageMock = $this->getMockBuilder('Magento\Backend\Model\View\Result\Page') ->disableOriginalConstructor() ->getMock(); - $this->resultJsonMock = $this->getMockBuilder('Magento\Framework\Controller\Result\JSON') + $this->resultJsonMock = $this->getMockBuilder('Magento\Framework\Controller\Result\Json') ->disableOriginalConstructor() ->getMock(); $this->resultRawMock = $this->getMockBuilder('Magento\Framework\Controller\Result\Raw') @@ -144,10 +149,15 @@ class AddCommentTest extends \PHPUnit_Framework_TestCase ); } + /** + * Test execute module exception + * + * @return void + */ public function testExecuteModelException() { $message = 'Model exception'; - $e = new \Magento\Framework\Exception\LocalizedException($message); + $e = new \Magento\Framework\Exception\LocalizedException(__($message)); $response = ['error' => true, 'message' => $message]; $this->requestMock->expects($this->any()) @@ -162,11 +172,16 @@ class AddCommentTest extends \PHPUnit_Framework_TestCase ->willReturnSelf(); $this->assertInstanceOf( - 'Magento\Framework\Controller\Result\JSON', + 'Magento\Framework\Controller\Result\Json', $this->controller->execute() ); } + /** + * Test execute exception + * + * @return void + */ public function testExecuteException() { $message = 'Cannot add new comment.'; @@ -185,11 +200,16 @@ class AddCommentTest extends \PHPUnit_Framework_TestCase ->willReturnSelf(); $this->assertInstanceOf( - 'Magento\Framework\Controller\Result\JSON', + 'Magento\Framework\Controller\Result\Json', $this->controller->execute() ); } + /** + * Test execute no comment + * + * @return void + */ public function testExecuteNoComment() { $message = 'The Comment Text field cannot be empty.'; @@ -209,11 +229,16 @@ class AddCommentTest extends \PHPUnit_Framework_TestCase ->willReturnSelf(); $this->assertInstanceOf( - 'Magento\Framework\Controller\Result\JSON', + 'Magento\Framework\Controller\Result\Json', $this->controller->execute() ); } + /** + * Test execute + * + * @return void + */ public function testExecute() { $comment = 'Test comment'; diff --git a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Creditmemo/CancelTest.php b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Creditmemo/CancelTest.php index debfcaf0d54e0c522e2b8ea89ddff7be5f8915e1..bc849016a87c4412fd84dcc98f57a1cd7fca1185 100644 --- a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Creditmemo/CancelTest.php +++ b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Creditmemo/CancelTest.php @@ -85,6 +85,9 @@ class CancelTest extends \PHPUnit_Framework_TestCase */ protected $resultForwardMock; + /** + * @return void + */ public function setUp() { $this->creditmemoMock = $this->getMockBuilder('Magento\Sales\Model\Order\Creditmemo') @@ -170,11 +173,14 @@ class CancelTest extends \PHPUnit_Framework_TestCase ); } + /** + * @return void + */ public function testExecuteModelException() { $id = 123; $message = 'Model exception'; - $e = new \Magento\Framework\Exception\LocalizedException($message); + $e = new \Magento\Framework\Exception\LocalizedException(__($message)); $this->requestMock->expects($this->any()) ->method('getParam') @@ -202,6 +208,9 @@ class CancelTest extends \PHPUnit_Framework_TestCase ); } + /** + * @return void + */ public function testExecuteException() { $id = 321; @@ -234,6 +243,9 @@ class CancelTest extends \PHPUnit_Framework_TestCase ); } + /** + * @return void + */ public function testExecuteNoCreditmemo() { $this->requestMock->expects($this->any()) @@ -257,6 +269,9 @@ class CancelTest extends \PHPUnit_Framework_TestCase ); } + /** + * @return void + */ public function testExecute() { $id = '111'; diff --git a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Creditmemo/UpdateQtyTest.php b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Creditmemo/UpdateQtyTest.php index 27e46f3c67dc28c691e5a56a2b86a775d12dbe5e..7b6c366e5eceaa2e21cdb8ab146ffe1ac547a752 100644 --- a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Creditmemo/UpdateQtyTest.php +++ b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Creditmemo/UpdateQtyTest.php @@ -72,7 +72,7 @@ class UpdateQtyTest extends \PHPUnit_Framework_TestCase protected $resultPageFactoryMock; /** - * @var \Magento\Framework\Controller\Result\JSONFactory|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Controller\Result\JsonFactory|\PHPUnit_Framework_MockObject_MockObject */ protected $resultJsonFactoryMock; @@ -87,7 +87,7 @@ class UpdateQtyTest extends \PHPUnit_Framework_TestCase protected $resultPageMock; /** - * @var \Magento\Framework\Controller\Result\JSON|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Controller\Result\Json|\PHPUnit_Framework_MockObject_MockObject */ protected $resultJsonMock; @@ -96,6 +96,11 @@ class UpdateQtyTest extends \PHPUnit_Framework_TestCase */ protected $resultRawMock; + /** + * Set up method + * + * @return void + */ public function setUp() { $this->creditmemoMock = $this->getMockBuilder('Magento\Sales\Model\Order\Creditmemo') @@ -158,7 +163,7 @@ class UpdateQtyTest extends \PHPUnit_Framework_TestCase ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->resultJsonFactoryMock = $this->getMockBuilder('Magento\Framework\Controller\Result\JSONFactory') + $this->resultJsonFactoryMock = $this->getMockBuilder('Magento\Framework\Controller\Result\JsonFactory') ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); @@ -169,7 +174,7 @@ class UpdateQtyTest extends \PHPUnit_Framework_TestCase $this->resultPageMock = $this->getMockBuilder('Magento\Backend\Model\View\Result\Page') ->disableOriginalConstructor() ->getMock(); - $this->resultJsonMock = $this->getMockBuilder('Magento\Framework\Controller\Result\JSON') + $this->resultJsonMock = $this->getMockBuilder('Magento\Framework\Controller\Result\Json') ->disableOriginalConstructor() ->getMock(); $this->resultRawMock = $this->getMockBuilder('Magento\Framework\Controller\Result\Raw') @@ -189,10 +194,15 @@ class UpdateQtyTest extends \PHPUnit_Framework_TestCase ); } + /** + * Test execute model exception + * + * @return void + */ public function testExecuteModelException() { $message = 'Model exception'; - $e = new \Magento\Framework\Exception\LocalizedException($message); + $e = new \Magento\Framework\Exception\LocalizedException(__($message)); $response = ['error' => true, 'message' => $message]; $this->requestMock->expects($this->any()) @@ -210,11 +220,16 @@ class UpdateQtyTest extends \PHPUnit_Framework_TestCase ->willReturnSelf(); $this->assertInstanceOf( - 'Magento\Framework\Controller\Result\JSON', + 'Magento\Framework\Controller\Result\Json', $this->controller->execute() ); } + /** + * Test execute exception + * + * @return void + */ public function testExecuteException() { $message = 'Cannot update the item\'s quantity.'; @@ -236,11 +251,16 @@ class UpdateQtyTest extends \PHPUnit_Framework_TestCase ->willReturnSelf(); $this->assertInstanceOf( - 'Magento\Framework\Controller\Result\JSON', + 'Magento\Framework\Controller\Result\Json', $this->controller->execute() ); } + /** + * Test execute + * + * @return void + */ public function testExecute() { $response = 'output'; diff --git a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Creditmemo/VoidTest.php b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Creditmemo/VoidTest.php index 1b5fc9201e47aa49a7d447b1ce74558d39bc1989..fe28217d346f7f1872c40c83709182509da12e5d 100644 --- a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Creditmemo/VoidTest.php +++ b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Creditmemo/VoidTest.php @@ -91,6 +91,9 @@ class VoidTest extends \PHPUnit_Framework_TestCase */ protected $resultForwardMock; + /** + * @return void + */ public function setUp() { $this->creditmemoMock = $this->getMockBuilder('Magento\Sales\Model\Order\Creditmemo') @@ -180,6 +183,9 @@ class VoidTest extends \PHPUnit_Framework_TestCase ); } + /** + * @return void + */ public function testExecuteNoCreditmemo() { $this->requestMock->expects($this->any()) @@ -203,11 +209,14 @@ class VoidTest extends \PHPUnit_Framework_TestCase ); } + /** + * @return void + */ public function testExecuteModelException() { $id = 123; $message = 'Model exception'; - $e = new \Magento\Framework\Exception\LocalizedException($message); + $e = new \Magento\Framework\Exception\LocalizedException(__($message)); $this->requestMock->expects($this->any()) ->method('getParam') @@ -236,6 +245,9 @@ class VoidTest extends \PHPUnit_Framework_TestCase ); } + /** + * @return void + */ public function testExecuteException() { $id = 321; @@ -269,6 +281,9 @@ class VoidTest extends \PHPUnit_Framework_TestCase ); } + /** + * @return void + */ public function testExecute() { $id = '111'; diff --git a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/AddCommentTest.php b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/AddCommentTest.php index 65fd1832056b5d25c635b04a957649e4134a816c..0f552a950113c2c01b5eb195f3327834abdab2b6 100755 --- a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/AddCommentTest.php +++ b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/AddCommentTest.php @@ -65,7 +65,7 @@ class AddCommentTest extends \PHPUnit_Framework_TestCase protected $resultPageFactoryMock; /** - * @var \Magento\Framework\Controller\Result\JSONFactory|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Controller\Result\JsonFactory|\PHPUnit_Framework_MockObject_MockObject */ protected $resultJsonFactoryMock; @@ -75,10 +75,15 @@ class AddCommentTest extends \PHPUnit_Framework_TestCase protected $resultRawFactoryMock; /** - * @var \Magento\Framework\Controller\Result\JSON|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Controller\Result\Json|\PHPUnit_Framework_MockObject_MockObject */ protected $resultJsonMock; + /** + * SetUp method + * + * @return void + */ public function setUp() { $objectManager = new ObjectManager($this); @@ -146,7 +151,7 @@ class AddCommentTest extends \PHPUnit_Framework_TestCase ->setMethods(['create']) ->getMock(); - $this->resultJsonMock = $this->getMockBuilder('Magento\Framework\Controller\Result\JSON') + $this->resultJsonMock = $this->getMockBuilder('Magento\Framework\Controller\Result\Json') ->disableOriginalConstructor() ->setMethods([]) ->getMock(); @@ -156,7 +161,7 @@ class AddCommentTest extends \PHPUnit_Framework_TestCase ->setMethods(['create']) ->getMock(); - $this->resultJsonFactoryMock = $this->getMockBuilder('Magento\Framework\Controller\Result\JSONFactory') + $this->resultJsonFactoryMock = $this->getMockBuilder('Magento\Framework\Controller\Result\JsonFactory') ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); @@ -177,6 +182,11 @@ class AddCommentTest extends \PHPUnit_Framework_TestCase ); } + /** + * Test execute + * + * @return void + */ public function testExecute() { $data = ['comment' => 'test comment']; @@ -255,11 +265,16 @@ class AddCommentTest extends \PHPUnit_Framework_TestCase $this->assertSame($resultRaw, $this->controller->execute()); } + /** + * Test execute model exception + * + * @return void + */ public function testExecuteModelException() { $message = 'model exception'; $response = ['error' => true, 'message' => $message]; - $e = new \Magento\Framework\Exception\LocalizedException($message); + $e = new \Magento\Framework\Exception\LocalizedException(__($message)); $this->requestMock->expects($this->once()) ->method('getParam') @@ -273,6 +288,11 @@ class AddCommentTest extends \PHPUnit_Framework_TestCase $this->assertSame($this->resultJsonMock, $this->controller->execute()); } + /** + * Test execute exception + * + * @return void + */ public function testExecuteException() { $response = ['error' => true, 'message' => 'Cannot add new comment.']; diff --git a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/CancelTest.php b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/CancelTest.php index cea2b45bc88ac42679051d5240dd5d821931016b..3575638720b4aebf55f90d9f00ff0f30a716bd5d 100755 --- a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/CancelTest.php +++ b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/CancelTest.php @@ -64,6 +64,9 @@ class CancelTest extends \PHPUnit_Framework_TestCase */ protected $controller; + /** + * @return void + */ public function setUp() { $objectManager = new ObjectManager($this); @@ -145,6 +148,9 @@ class CancelTest extends \PHPUnit_Framework_TestCase ); } + /** + * @return void + */ public function testExecute() { $invoiceId = 2; @@ -217,6 +223,9 @@ class CancelTest extends \PHPUnit_Framework_TestCase $this->assertSame($resultRedirect, $this->controller->execute()); } + /** + * @return void + */ public function testExecuteNoInvoice() { $invoiceId = 2; @@ -251,12 +260,15 @@ class CancelTest extends \PHPUnit_Framework_TestCase $this->assertSame($resultForward, $this->controller->execute()); } + /** + * @return void + */ public function testExecuteModelException() { $invoiceId = 2; $message = 'model exception'; - $e = new \Magento\Framework\Exception\LocalizedException($message); + $e = new \Magento\Framework\Exception\LocalizedException(__($message)); $this->requestMock->expects($this->once()) ->method('getParam') @@ -300,6 +312,9 @@ class CancelTest extends \PHPUnit_Framework_TestCase $this->assertSame($resultRedirect, $this->controller->execute()); } + /** + * @return void + */ public function testExecuteException() { $invoiceId = 2; diff --git a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/CaptureTest.php b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/CaptureTest.php index 8b0d5249c96464dfdd5f8aac7cd7b021872d823e..0e57e1af6c5198a9b4d45cdd921afa10b7b9745e 100755 --- a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/CaptureTest.php +++ b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/CaptureTest.php @@ -64,6 +64,9 @@ class CaptureTest extends \PHPUnit_Framework_TestCase */ protected $controller; + /** + * @return void + */ public function setUp() { $objectManager = new ObjectManager($this); @@ -145,6 +148,9 @@ class CaptureTest extends \PHPUnit_Framework_TestCase ); } + /** + * @return void + */ public function testExecute() { $invoiceId = 2; @@ -218,6 +224,9 @@ class CaptureTest extends \PHPUnit_Framework_TestCase $this->assertSame($resultRedirect, $this->controller->execute()); } + /** + * @return void + */ public function testExecuteNoInvoice() { $invoiceId = 2; @@ -252,12 +261,15 @@ class CaptureTest extends \PHPUnit_Framework_TestCase $this->assertSame($resultForward, $this->controller->execute()); } + /** + * @return void + */ public function testExecuteModelException() { $invoiceId = 2; $message = 'model exception'; - $e = new \Magento\Framework\Exception\LocalizedException($message); + $e = new \Magento\Framework\Exception\LocalizedException(__($message)); $this->requestMock->expects($this->once()) ->method('getParam') @@ -301,6 +313,9 @@ class CaptureTest extends \PHPUnit_Framework_TestCase $this->assertSame($resultRedirect, $this->controller->execute()); } + /** + * @return void + */ public function testExecuteException() { $invoiceId = 2; diff --git a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/UpdateQtyTest.php b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/UpdateQtyTest.php index e4c7cdb93d1c58f2444838c129d5d29192eba63d..1c5cf1cefa0223c32ab910f86143b27b7be09ff9 100755 --- a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/UpdateQtyTest.php +++ b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/UpdateQtyTest.php @@ -66,10 +66,15 @@ class UpdateQtyTest extends \PHPUnit_Framework_TestCase protected $resultRawFactoryMock; /** - * @var \Magento\Framework\Controller\Result\JSONFactory|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Controller\Result\JsonFactory|\PHPUnit_Framework_MockObject_MockObject */ protected $resultJsonFactoryMock; + /** + * SetUp method + * + * @return void + */ public function setUp() { $objectManager = new ObjectManager($this); @@ -135,7 +140,7 @@ class UpdateQtyTest extends \PHPUnit_Framework_TestCase ->setMethods(['create']) ->getMock(); - $this->resultJsonFactoryMock = $this->getMockBuilder('Magento\Framework\Controller\Result\JSONFactory') + $this->resultJsonFactoryMock = $this->getMockBuilder('Magento\Framework\Controller\Result\JsonFactory') ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); @@ -151,6 +156,11 @@ class UpdateQtyTest extends \PHPUnit_Framework_TestCase ); } + /** + * Test execute + * + * @return void + */ public function testExecute() { $orderId = 1; @@ -247,6 +257,11 @@ class UpdateQtyTest extends \PHPUnit_Framework_TestCase $this->assertSame($resultRaw, $this->controller->execute()); } + /** + * Test execute model exception + * + * @return void + */ public function testExecuteModelException() { $message = 'Cannot update item quantity.'; @@ -271,8 +286,8 @@ class UpdateQtyTest extends \PHPUnit_Framework_TestCase ->method('prepend') ->with('Invoices'); - /** @var \Magento\Framework\Controller\Result\JSON|\PHPUnit_Framework_MockObject_MockObject */ - $resultJsonMock = $this->getMockBuilder('Magento\Framework\Controller\Result\JSON') + /** @var \Magento\Framework\Controller\Result\Json|\PHPUnit_Framework_MockObject_MockObject */ + $resultJsonMock = $this->getMockBuilder('Magento\Framework\Controller\Result\Json') ->disableOriginalConstructor() ->setMethods([]) ->getMock(); @@ -285,6 +300,11 @@ class UpdateQtyTest extends \PHPUnit_Framework_TestCase $this->assertSame($resultJsonMock, $this->controller->execute()); } + /** + * Test execute exception + * + * @return void + */ public function testExecuteException() { $message = 'Cannot update item quantity.'; @@ -309,8 +329,8 @@ class UpdateQtyTest extends \PHPUnit_Framework_TestCase ->method('prepend') ->with('Invoices'); - /** @var \Magento\Framework\Controller\Result\JSON|\PHPUnit_Framework_MockObject_MockObject */ - $resultJsonMock = $this->getMockBuilder('Magento\Framework\Controller\Result\JSON') + /** @var \Magento\Framework\Controller\Result\Json|\PHPUnit_Framework_MockObject_MockObject */ + $resultJsonMock = $this->getMockBuilder('Magento\Framework\Controller\Result\Json') ->disableOriginalConstructor() ->setMethods([]) ->getMock(); diff --git a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/VoidTest.php b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/VoidTest.php index a268d6ec5a216ec4ff9ad015d6c56b91c1dc359e..21d1f3f644b4a43d25118b3db9ae0d2799726461 100755 --- a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/VoidTest.php +++ b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/VoidTest.php @@ -69,6 +69,9 @@ class VoidTest extends \PHPUnit_Framework_TestCase */ protected $resultForwardFactoryMock; + /** + * @return void + */ public function setUp() { $objectManager = new ObjectManager($this); @@ -158,6 +161,9 @@ class VoidTest extends \PHPUnit_Framework_TestCase ); } + /** + * @return void + */ public function testExecute() { $invoiceId = 2; @@ -230,6 +236,9 @@ class VoidTest extends \PHPUnit_Framework_TestCase $this->assertSame($resultRedirect, $this->controller->execute()); } + /** + * @return void + */ public function testExecuteNoInvoice() { $invoiceId = 2; @@ -270,11 +279,14 @@ class VoidTest extends \PHPUnit_Framework_TestCase $this->assertSame($resultForward, $this->controller->execute()); } + /** + * @return void + */ public function testExecuteModelException() { $invoiceId = 2; $message = 'test message'; - $e = new \Magento\Framework\Exception\LocalizedException($message); + $e = new \Magento\Framework\Exception\LocalizedException(__($message)); $this->requestMock->expects($this->once()) ->method('getParam') diff --git a/app/code/Magento/Sales/Test/Unit/Model/Email/TemplateTest.php b/app/code/Magento/Sales/Test/Unit/Model/Email/TemplateTest.php index f9a38143e5023767f7936761260e61d6301e31e7..c8c3632bb160226bbf95918724fe1423fdad2755 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Email/TemplateTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Email/TemplateTest.php @@ -4,6 +4,8 @@ * See COPYING.txt for license details. */ +// @codingStandardsIgnoreFile + /** * Test class for \Magento\Sales\Model\Email\Template */ @@ -46,6 +48,14 @@ class TemplateTest extends \PHPUnit_Framework_TestCase ); } + protected function tearDown() + { + parent::tearDown(); + $magentoObjectManagerFactory = \Magento\Framework\App\Bootstrap::createObjectManagerFactory(BP, $_SERVER); + $objectManager = $magentoObjectManagerFactory->create($_SERVER); + \Magento\Framework\App\ObjectManager::setInstance($objectManager); + } + public function testIncludeTemplate() { $this->mockViewFilesystem->expects($this->once()) diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Total/Config/BaseTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Total/Config/BaseTest.php index 4aab2e8cc19f3fe1788d0e4ddeb0cdcd3c94e07d..3552bc851409baec712b24f6ff4733a0185c15c5 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/Total/Config/BaseTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Total/Config/BaseTest.php @@ -114,9 +114,7 @@ class BaseTest extends \PHPUnit_Framework_TestCase $this->returnValue([ 'some_code' => ['instance' => 'Magento\Sales\Model\Order\Total\AbstractTotal', 'sort_order' => 1903], 'other_code' => ['instance' => 'Magento\Sales\Model\Order\Total\AbstractTotal', 'sort_order' => 1112], - 'equal_order' => ['instance' => 'Magento\Sales\Model\Order\Total\AbstractTotal', 'sort_order' => 1112], 'big_order' => ['instance' => 'Magento\Sales\Model\Order\Total\AbstractTotal', 'sort_order' => 3000], - 'no_order' => ['instance' => 'Magento\Sales\Model\Order\Total\AbstractTotal'], ]) ); @@ -126,8 +124,6 @@ class BaseTest extends \PHPUnit_Framework_TestCase $this->assertSame( [ - 'no_order' => $total, - 'equal_order' => $total, 'other_code' => $total, 'some_code' => $total, 'big_order' => $total, diff --git a/app/code/Magento/Sales/etc/config.xml b/app/code/Magento/Sales/etc/config.xml index db812559be52ef52b237a231aa37fc1c4ceea0e1..2d42f963e6965decc5159ed82becc3fec22d25d2 100644 --- a/app/code/Magento/Sales/etc/config.xml +++ b/app/code/Magento/Sales/etc/config.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Core/etc/config.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Store/etc/config.xsd"> <default> <sales> <totals_sort> diff --git a/app/code/Magento/Sales/etc/frontend/page_types.xml b/app/code/Magento/Sales/etc/frontend/page_types.xml index 693807b457a00edcd950c702fbdc506cf1f84623..701945902468273674ca3f9b0b4a271794232380 100644 --- a/app/code/Magento/Sales/etc/frontend/page_types.xml +++ b/app/code/Magento/Sales/etc/frontend/page_types.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> -<page_types xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../Core/etc/page_types.xsd"> +<page_types xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_types.xsd"> <type id="sales_guest_creditmemo" label="Guest Order Creditmemo View"/> <type id="sales_guest_form" label="Returns"/> <type id="sales_guest_invoice" label="Guest Order Invoice View"/> diff --git a/app/code/Magento/Sales/etc/webapi.xml b/app/code/Magento/Sales/etc/webapi.xml index bfa2d724e25a4a2fb23670f4771372ede93364b0..3acea225b21ec3373d305834fc84f60332f8d39e 100644 --- a/app/code/Magento/Sales/etc/webapi.xml +++ b/app/code/Magento/Sales/etc/webapi.xml @@ -7,7 +7,7 @@ --> <routes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../app/code/Magento/Webapi/etc/webapi.xsd"> - <route url="/V1/order/:id" method="GET"> + <route url="/V1/orders/:id" method="GET"> <service class="Magento\Sales\Api\OrderRepositoryInterface" method="get"/> <resources> <resource ref="Magento_Sales::sales" /> @@ -19,61 +19,61 @@ <resource ref="Magento_Sales::sales" /> </resources> </route> - <route url="/V1/order/:id/status" method="GET"> + <route url="/V1/orders/:id/statuses" method="GET"> <service class="Magento\Sales\Api\OrderManagementInterface" method="getStatus"/> <resources> <resource ref="Magento_Sales::sales" /> </resources> </route> - <route url="/V1/order/:id/cancel" method="POST"> + <route url="/V1/orders/:id/cancel" method="POST"> <service class="Magento\Sales\Api\OrderManagementInterface" method="cancel"/> <resources> <resource ref="Magento_Sales::sales" /> </resources> </route> - <route url="/V1/order/:id/email" method="POST"> + <route url="/V1/orders/:id/emails" method="POST"> <service class="Magento\Sales\Api\OrderManagementInterface" method="notify"/> <resources> <resource ref="Magento_Sales::sales" /> </resources> </route> - <route url="/V1/order/:id/hold" method="POST"> + <route url="/V1/orders/:id/hold" method="POST"> <service class="Magento\Sales\Api\OrderManagementInterface" method="hold"/> <resources> <resource ref="Magento_Sales::sales" /> </resources> </route> - <route url="/V1/order/:id/unhold" method="POST"> + <route url="/V1/orders/:id/unhold" method="POST"> <service class="Magento\Sales\Api\OrderManagementInterface" method="unHold"/> <resources> <resource ref="Magento_Sales::sales" /> </resources> </route> - <route url="/V1/order/:id/comment" method="POST"> + <route url="/V1/orders/:id/comments" method="POST"> <service class="Magento\Sales\Api\OrderManagementInterface" method="addComment"/> <resources> <resource ref="Magento_Sales::sales" /> </resources> </route> - <route url="/V1/order/:id/comments" method="GET"> + <route url="/V1/orders/:id/comments" method="GET"> <service class="Magento\Sales\Api\OrderManagementInterface" method="getCommentsList"/> <resources> <resource ref="Magento_Sales::sales" /> </resources> </route> - <route url="/V1/order/create" method="PUT"> + <route url="/V1/orders/create" method="PUT"> <service class="Magento\Sales\Api\OrderRepositoryInterface" method="save"/> <resources> <resource ref="Magento_Sales::sales" /> </resources> </route> - <route url="/V1/order/:parent_id" method="PUT"> + <route url="/V1/orders/:parent_id" method="PUT"> <service class="Magento\Sales\Api\OrderAddressRepositoryInterface" method="save"/> <resources> <resource ref="Magento_Sales::sales" /> </resources> </route> - <route url="/V1/invoice/:id" method="GET"> + <route url="/V1/invoices/:id" method="GET"> <service class="Magento\Sales\Api\InvoiceRepositoryInterface" method="get"/> <resources> <resource ref="Magento_Sales::sales" /> @@ -85,37 +85,37 @@ <resource ref="Magento_Sales::sales" /> </resources> </route> - <route url="/V1/invoice/:id/comments" method="GET"> + <route url="/V1/invoices/:id/comments" method="GET"> <service class="Magento\Sales\Api\InvoiceManagementInterface" method="getCommentsList"/> <resources> <resource ref="Magento_Sales::sales" /> </resources> </route> - <route url="/V1/invoice/:id/email" method="POST"> + <route url="/V1/invoices/:id/emails" method="POST"> <service class="Magento\Sales\Api\InvoiceManagementInterface" method="notify"/> <resources> <resource ref="Magento_Sales::sales" /> </resources> </route> - <route url="/V1/invoice/:id/void" method="POST"> + <route url="/V1/invoices/:id/void" method="POST"> <service class="Magento\Sales\Api\InvoiceManagementInterface" method="setVoid"/> <resources> <resource ref="Magento_Sales::sales" /> </resources> </route> - <route url="/V1/invoice/:id/capture" method="POST"> + <route url="/V1/invoices/:id/capture" method="POST"> <service class="Magento\Sales\Api\InvoiceManagementInterface" method="setCapture"/> <resources> <resource ref="Magento_Sales::sales" /> </resources> </route> - <route url="/V1/invoice/comment" method="POST"> + <route url="/V1/invoices/comments" method="POST"> <service class="Magento\Sales\Api\InvoiceCommentRepositoryInterface" method="save"/> <resources> <resource ref="Magento_Sales::sales" /> </resources> </route> - <route url="/V1/invoice/" method="POST"> + <route url="/V1/invoices/" method="POST"> <service class="Magento\Sales\Api\InvoiceRepositoryInterface" method="save"/> <resources> <resource ref="Magento_Sales::sales" /> @@ -145,13 +145,13 @@ <resource ref="Magento_Sales::sales" /> </resources> </route> - <route url="/V1/creditmemo/:id/email" method="POST"> + <route url="/V1/creditmemo/:id/emails" method="POST"> <service class="Magento\Sales\Api\CreditmemoManagementInterface" method="notify"/> <resources> <resource ref="Magento_Sales::sales" /> </resources> </route> - <route url="/V1/creditmemo/comment" method="POST"> + <route url="/V1/creditmemo/:id/comments" method="POST"> <service class="Magento\Sales\Api\CreditmemoCommentRepositoryInterface" method="save"/> <resources> <resource ref="Magento_Sales::sales" /> @@ -181,13 +181,13 @@ <resource ref="Magento_Sales::sales" /> </resources> </route> - <route url="/V1/shipment/comment" method="POST"> + <route url="/V1/shipment/:id/comments" method="POST"> <service class="Magento\Sales\Api\ShipmentCommentRepositoryInterface" method="save"/> <resources> <resource ref="Magento_Sales::sales" /> </resources> </route> - <route url="/V1/shipment/:id/email" method="POST"> + <route url="/V1/shipment/:id/emails" method="POST"> <service class="Magento\Sales\Api\ShipmentManagementInterface" method="notify"/> <resources> <resource ref="Magento_Sales::sales" /> @@ -217,7 +217,7 @@ <resource ref="Magento_Sales::sales" /> </resources> </route> - <route url="/V1/order/" method="POST"> + <route url="/V1/orders/" method="POST"> <service class="Magento\Sales\Api\OrderRepositoryInterface" method="save"/> <resources> <resource ref="Magento_Sales::sales" /> diff --git a/app/code/Magento/Sales/view/frontend/layout/customer_account_index.xml b/app/code/Magento/Sales/view/frontend/layout/customer_account_index.xml index 0e7620a75693e4a879a1214035c612058a6885e7..0bdf0c8d2061a6d78872dbefc128c5c294dfd570 100644 --- a/app/code/Magento/Sales/view/frontend/layout/customer_account_index.xml +++ b/app/code/Magento/Sales/view/frontend/layout/customer_account_index.xml @@ -8,7 +8,7 @@ <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd"> <body> <referenceContainer name="content"> - <block class="Magento\Sales\Block\Order\Recent" name="customer_account_dashboard_top" after="customer_account_dashboard_hello" template="order/recent.phtml" cacheable="false"/> + <block class="Magento\Sales\Block\Order\Recent" name="customer_account_dashboard_top" after="customer_account_dashboard_hello" template="order/recent.phtml"/> </referenceContainer> </body> </page> diff --git a/app/code/Magento/Sales/view/frontend/layout/sales_order_history.xml b/app/code/Magento/Sales/view/frontend/layout/sales_order_history.xml index 7210c1c06163c6209b5819fa01c9332ab032d16e..62219a6e98970d5227425d928d677e8286abae7d 100644 --- a/app/code/Magento/Sales/view/frontend/layout/sales_order_history.xml +++ b/app/code/Magento/Sales/view/frontend/layout/sales_order_history.xml @@ -9,10 +9,10 @@ <update handle="customer_account"/> <body> <referenceContainer name="content"> - <block class="Magento\Sales\Block\Order\History" name="sales.order.history" cacheable="false"> + <block class="Magento\Sales\Block\Order\History" name="sales.order.history"> <container name="sales.order.history.info" as="info" label="Order History Info"/> </block> - <block class="Magento\Customer\Block\Account\Dashboard" name="customer.account.link.back" template="account/link/back.phtml" cacheable="false"/> + <block class="Magento\Customer\Block\Account\Dashboard" name="customer.account.link.back" template="account/link/back.phtml"/> </referenceContainer> </body> </page> diff --git a/app/code/Magento/Sales/view/frontend/templates/order/history.phtml b/app/code/Magento/Sales/view/frontend/templates/order/history.phtml index f0218c9507c02c76c7e45d78c6301f633ef366d7..dafd6a2a61513e9716520703a32fcd34f487655b 100644 --- a/app/code/Magento/Sales/view/frontend/templates/order/history.phtml +++ b/app/code/Magento/Sales/view/frontend/templates/order/history.phtml @@ -9,7 +9,7 @@ ?> <?php $_orders = $block->getOrders(); ?> <?php echo $block->getChildHtml('info');?> -<?php if ($_orders->getSize()): ?> +<?php if ($_orders && count($_orders)): ?> <div class="table-wrapper orders-history"> <table class="data table table-order-items history" id="my-orders-table"> <caption class="table-caption"><?php echo __('Orders') ?></caption> diff --git a/app/code/Magento/SalesRule/etc/config.xml b/app/code/Magento/SalesRule/etc/config.xml index 7d3da07bc36457b55840e017735b28cdc6ce1308..486f8e4073ce85fef4a2b482b0a3e09e27a618c4 100644 --- a/app/code/Magento/SalesRule/etc/config.xml +++ b/app/code/Magento/SalesRule/etc/config.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Core/etc/config.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Store/etc/config.xsd"> <default> <promo> <auto_generated_coupon_codes> diff --git a/app/code/Magento/Search/etc/frontend/page_types.xml b/app/code/Magento/Search/etc/frontend/page_types.xml index 0f5a1440de0ce62e107bf30c144a876c6187cb27..2c563ca5c0d1b97fcf9960c34a3656b70bbb13df 100644 --- a/app/code/Magento/Search/etc/frontend/page_types.xml +++ b/app/code/Magento/Search/etc/frontend/page_types.xml @@ -5,6 +5,6 @@ * See COPYING.txt for license details. */ --> -<page_types xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../Core/etc/page_types.xsd"> +<page_types xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_types.xsd"> <type id="search_term_popular" label="Popular Search Terms"/> </page_types> diff --git a/app/code/Magento/Sendfriend/etc/config.xml b/app/code/Magento/Sendfriend/etc/config.xml index 52d949a1036a31b5279e79a0400823a76a0356d7..6a63fb0eb3be102a68ca6cd2f40ef898c2db8f0e 100644 --- a/app/code/Magento/Sendfriend/etc/config.xml +++ b/app/code/Magento/Sendfriend/etc/config.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Core/etc/config.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Store/etc/config.xsd"> <default> <sendfriend> <email> diff --git a/app/code/Magento/Sendfriend/etc/frontend/page_types.xml b/app/code/Magento/Sendfriend/etc/frontend/page_types.xml index cc46efb01ddc13708d15ee4c3eca5b9d0c9de633..c4396bfb90b7c9b1338f9a7ba38e9f2093afb414 100644 --- a/app/code/Magento/Sendfriend/etc/frontend/page_types.xml +++ b/app/code/Magento/Sendfriend/etc/frontend/page_types.xml @@ -5,6 +5,6 @@ * See COPYING.txt for license details. */ --> -<page_types xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../Core/etc/page_types.xsd"> +<page_types xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_types.xsd"> <type id="sendfriend_product_send" label="Catalog Product Email to a Friend"/> </page_types> diff --git a/app/code/Magento/Shipping/Model/Order/Track.php b/app/code/Magento/Shipping/Model/Order/Track.php index ff7167e94ab78f5bdfffbaa8ee302621cff0bf7a..3eadf958b8902664592bab8b7e67be6664e3adea 100644 --- a/app/code/Magento/Shipping/Model/Order/Track.php +++ b/app/code/Magento/Shipping/Model/Order/Track.php @@ -21,7 +21,7 @@ use Magento\Framework\Api\AttributeValueFactory; * @method string getCreatedAt() * @method \Magento\Sales\Model\Order\Shipment\Track setCreatedAt(string $value) * @method string getUpdatedAt() - * + * @method \Magento\Sales\Api\Data\ShipmentTrackExtensionInterface getExtensionAttributes() */ class Track extends \Magento\Sales\Model\Order\Shipment\Track { @@ -33,7 +33,7 @@ class Track extends \Magento\Sales\Model\Order\Shipment\Track /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry - * @param \Magento\Framework\Api\MetadataServiceInterface $metadataService + * @param \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory * @param AttributeValueFactory $customAttributeFactory * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate * @param \Magento\Framework\Stdlib\DateTime $dateTime @@ -49,7 +49,7 @@ class Track extends \Magento\Sales\Model\Order\Shipment\Track public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, - \Magento\Framework\Api\MetadataServiceInterface $metadataService, + \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory, AttributeValueFactory $customAttributeFactory, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Framework\Stdlib\DateTime $dateTime, @@ -63,7 +63,7 @@ class Track extends \Magento\Sales\Model\Order\Shipment\Track parent::__construct( $context, $registry, - $metadataService, + $extensionFactory, $customAttributeFactory, $localeDate, $dateTime, diff --git a/app/code/Magento/Shipping/Model/Shipping/LabelGenerator.php b/app/code/Magento/Shipping/Model/Shipping/LabelGenerator.php index e8e05c7421b598328dc0ef202234e075e3205c96..ad4dbab755e3847e21bcae41adbebcc86d9c8586 100644 --- a/app/code/Magento/Shipping/Model/Shipping/LabelGenerator.php +++ b/app/code/Magento/Shipping/Model/Shipping/LabelGenerator.php @@ -76,7 +76,7 @@ class LabelGenerator $shipment->setPackages($request->getParam('packages')); $response = $this->labelFactory->create()->requestToShipment($shipment); if ($response->hasErrors()) { - throw new \Magento\Framework\Exception\LocalizedException($response->getErrors()); + throw new \Magento\Framework\Exception\LocalizedException(__($response->getErrors())); } if (!$response->hasInfo()) { throw new \Magento\Framework\Exception\LocalizedException(__('Response info is not exist.')); diff --git a/app/code/Magento/Shipping/etc/config.xml b/app/code/Magento/Shipping/etc/config.xml index 6f66c2a3146755431b73eb5c20689165bb17726b..181805b665d283099c954844413036032d8e50fd 100644 --- a/app/code/Magento/Shipping/etc/config.xml +++ b/app/code/Magento/Shipping/etc/config.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Core/etc/config.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Store/etc/config.xsd"> <default> <shipping> <origin> diff --git a/app/code/Magento/Shipping/etc/frontend/page_types.xml b/app/code/Magento/Shipping/etc/frontend/page_types.xml index 452cfdded68cf59f1f7a25813cf69a261c0f9f8b..2b2d3f2c617a3dd0b22785a5b57ac7128180e2f5 100644 --- a/app/code/Magento/Shipping/etc/frontend/page_types.xml +++ b/app/code/Magento/Shipping/etc/frontend/page_types.xml @@ -5,6 +5,6 @@ * See COPYING.txt for license details. */ --> -<page_types xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../Core/etc/page_types.xsd"> +<page_types xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_types.xsd"> <type id="shipping_tracking_popup" label="Shipment Tracking Popup"/> </page_types> diff --git a/app/code/Magento/Shipping/etc/module.xml b/app/code/Magento/Shipping/etc/module.xml index 999d4fa4882a9b50c971d0e22f4cca09075049c9..ff4283ad84048134a416309725404e203af77c33 100644 --- a/app/code/Magento/Shipping/etc/module.xml +++ b/app/code/Magento/Shipping/etc/module.xml @@ -8,7 +8,6 @@ <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd"> <module name="Magento_Shipping" setup_version="2.0.0"> <sequence> - <module name="Magento_Core"/> <module name="Magento_Store"/> <module name="Magento_Catalog"/> </sequence> diff --git a/app/code/Magento/Sitemap/etc/config.xml b/app/code/Magento/Sitemap/etc/config.xml index ff84e8eec23892526961e5ea3d0d1e11e2978af7..03e72e315546683a613d9212ecf1032f46d3c3a2 100644 --- a/app/code/Magento/Sitemap/etc/config.xml +++ b/app/code/Magento/Sitemap/etc/config.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Core/etc/config.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Store/etc/config.xsd"> <default> <sitemap> <limit> diff --git a/app/code/Magento/Store/composer.json b/app/code/Magento/Store/composer.json index aa9c2858d0b9d68e6243ec931d9593187061dca7..c991778c00e9d67dbc1dd0ae36810f0a49009e7a 100644 --- a/app/code/Magento/Store/composer.json +++ b/app/code/Magento/Store/composer.json @@ -3,7 +3,6 @@ "description": "N/A", "require": { "php": "~5.5.0|~5.6.0", - "magento/module-core": "0.42.0-beta11", "magento/module-directory": "0.42.0-beta11", "magento/module-ui": "0.42.0-beta11", "magento/module-config": "0.42.0-beta11", diff --git a/app/code/Magento/Core/etc/cache.xml b/app/code/Magento/Store/etc/cache.xml similarity index 100% rename from app/code/Magento/Core/etc/cache.xml rename to app/code/Magento/Store/etc/cache.xml diff --git a/app/code/Magento/Core/etc/config.xml b/app/code/Magento/Store/etc/config.xml similarity index 98% rename from app/code/Magento/Core/etc/config.xml rename to app/code/Magento/Store/etc/config.xml index ddfb237c0eeee1ad680280538feedeaf54542eca..0bf0f4cdb889d4590773e402854cdeb4c1ee015c 100644 --- a/app/code/Magento/Core/etc/config.xml +++ b/app/code/Magento/Store/etc/config.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Core/etc/config.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="config.xsd"> <default> <design> <pagination> diff --git a/app/code/Magento/Core/etc/config.xsd b/app/code/Magento/Store/etc/config.xsd similarity index 100% rename from app/code/Magento/Core/etc/config.xsd rename to app/code/Magento/Store/etc/config.xsd diff --git a/app/code/Magento/Store/etc/di.xml b/app/code/Magento/Store/etc/di.xml index fdbce3aa2a3ea1180edeaa749e39eb55bfc34b7a..ebbc61f6036c8723c1fe943e07795097b63f1f6d 100644 --- a/app/code/Magento/Store/etc/di.xml +++ b/app/code/Magento/Store/etc/di.xml @@ -219,6 +219,11 @@ </argument> </arguments> </type> + <type name="Magento\Framework\Module\Setup\Migration"> + <arguments> + <argument name="confPathToMapFile" xsi:type="string">app/etc/aliases_to_classes_map.json</argument> + </arguments> + </type> <type name="Magento\Framework\Module\Setup\MigrationData"> <arguments> <argument name="data" xsi:type="array"> @@ -243,4 +248,52 @@ <argument name="cache" xsi:type="object">Magento\Framework\App\Cache\Type\Config</argument> </arguments> </type> + <type name="Magento\Framework\App\Router\Base"> + <arguments> + <argument name="routerId" xsi:type="string">standard</argument> + </arguments> + </type> + <type name="Magento\Framework\Stdlib\DateTime\Timezone"> + <arguments> + <argument name="defaultTimezonePath" xsi:type="const">Magento\Directory\Helper\Data::XML_PATH_DEFAULT_TIMEZONE</argument> + <argument name="scopeType" xsi:type="const">Magento\Store\Model\ScopeInterface::SCOPE_STORE</argument> + </arguments> + </type> + <type name="Magento\Framework\Locale\Resolver"> + <arguments> + <argument name="defaultLocalePath" xsi:type="const">Magento\Directory\Helper\Data::XML_PATH_DEFAULT_LOCALE</argument> + <argument name="scopeType" xsi:type="const">Magento\Store\Model\ScopeInterface::SCOPE_STORE</argument> + </arguments> + </type> + <type name="Magento\Framework\App\Config\Initial\SchemaLocator"> + <arguments> + <argument name="moduleName" xsi:type="string">Magento_Store</argument> + </arguments> + </type> + <type name="Magento\Framework\DB\Helper"> + <arguments> + <argument name="modulePrefix" xsi:type="string">store</argument> + </arguments> + </type> + <type name="Magento\Framework\View\Asset\PreProcessor\Pool"> + <arguments> + <argument name="preProcessors" xsi:type="array"> + <item name="less" xsi:type="array"> + <item name="css" xsi:type="array"> + <item name="less_css" xsi:type="string">Magento\Framework\Css\PreProcessor\Less</item> + <item name="module_notation" xsi:type="string">Magento\Framework\View\Asset\PreProcessor\ModuleNotation</item> + </item> + <item name="less" xsi:type="array"> + <item name="magento_import" xsi:type="string">Magento\Framework\Less\PreProcessor\Instruction\MagentoImport</item> + <item name="import" xsi:type="string">Magento\Framework\Less\PreProcessor\Instruction\Import</item> + </item> + </item> + <item name="css" xsi:type="array"> + <item name="css" xsi:type="array"> + <item name="module_notation" xsi:type="string">Magento\Framework\View\Asset\PreProcessor\ModuleNotation</item> + </item> + </item> + </argument> + </arguments> + </type> </config> diff --git a/app/code/Magento/Store/etc/module.xml b/app/code/Magento/Store/etc/module.xml index e01760c2873fb23499154afca8c78babafef2a70..b01976513381612bc4bafddd9463531ee54ea72e 100644 --- a/app/code/Magento/Store/etc/module.xml +++ b/app/code/Magento/Store/etc/module.xml @@ -7,8 +7,5 @@ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd"> <module name="Magento_Store" setup_version="2.0.0"> - <sequence> - <module name="Magento_Core"/> - </sequence> </module> </config> diff --git a/app/code/Magento/Store/i18n/de_DE.csv b/app/code/Magento/Store/i18n/de_DE.csv index 144b5864e3cd87176710da0bcddbc570eb9622d4..f376d05a2c634af120f2e31c26caa9af4e97949d 100644 --- a/app/code/Magento/Store/i18n/de_DE.csv +++ b/app/code/Magento/Store/i18n/de_DE.csv @@ -10,3 +10,16 @@ Admin,Admin "Your Language","Your Language" Language,Language "Select Store","Select Store" +"Helper arguments should not be used in custom layout updates.","Helper arguments should not be used in custom layout updates." +"Updater model should not be used in custom layout updates.","Updater model should not be used in custom layout updates." +"Please correct the XML data and try again. %value%","Please correct the XML data and try again. %value%" +Layouts,Layouts +"Layout building instructions.","Layout building instructions." +"Blocks HTML output","Blocks HTML output" +"Page blocks HTML.","Page blocks HTML." +"View files fallback","View files fallback" +"Paths to view files (e.g., PHTML templates, images, CSS, JS files).","Paths to view files (e.g., PHTML templates, images, CSS, JS files)." +"View files pre-processing","View files pre-processing" +"Paths to pre-processed view files (e.g, CSS files with fixed paths or generated from LESS files).","Paths to pre-processed view files (e.g, CSS files with fixed paths or generated from LESS files)." +"Collections Data","Collections Data" +"Collection data files.","Collection data files." diff --git a/app/code/Magento/Store/i18n/en_US.csv b/app/code/Magento/Store/i18n/en_US.csv index 144b5864e3cd87176710da0bcddbc570eb9622d4..f376d05a2c634af120f2e31c26caa9af4e97949d 100644 --- a/app/code/Magento/Store/i18n/en_US.csv +++ b/app/code/Magento/Store/i18n/en_US.csv @@ -10,3 +10,16 @@ Admin,Admin "Your Language","Your Language" Language,Language "Select Store","Select Store" +"Helper arguments should not be used in custom layout updates.","Helper arguments should not be used in custom layout updates." +"Updater model should not be used in custom layout updates.","Updater model should not be used in custom layout updates." +"Please correct the XML data and try again. %value%","Please correct the XML data and try again. %value%" +Layouts,Layouts +"Layout building instructions.","Layout building instructions." +"Blocks HTML output","Blocks HTML output" +"Page blocks HTML.","Page blocks HTML." +"View files fallback","View files fallback" +"Paths to view files (e.g., PHTML templates, images, CSS, JS files).","Paths to view files (e.g., PHTML templates, images, CSS, JS files)." +"View files pre-processing","View files pre-processing" +"Paths to pre-processed view files (e.g, CSS files with fixed paths or generated from LESS files).","Paths to pre-processed view files (e.g, CSS files with fixed paths or generated from LESS files)." +"Collections Data","Collections Data" +"Collection data files.","Collection data files." diff --git a/app/code/Magento/Store/i18n/es_ES.csv b/app/code/Magento/Store/i18n/es_ES.csv index 144b5864e3cd87176710da0bcddbc570eb9622d4..f376d05a2c634af120f2e31c26caa9af4e97949d 100644 --- a/app/code/Magento/Store/i18n/es_ES.csv +++ b/app/code/Magento/Store/i18n/es_ES.csv @@ -10,3 +10,16 @@ Admin,Admin "Your Language","Your Language" Language,Language "Select Store","Select Store" +"Helper arguments should not be used in custom layout updates.","Helper arguments should not be used in custom layout updates." +"Updater model should not be used in custom layout updates.","Updater model should not be used in custom layout updates." +"Please correct the XML data and try again. %value%","Please correct the XML data and try again. %value%" +Layouts,Layouts +"Layout building instructions.","Layout building instructions." +"Blocks HTML output","Blocks HTML output" +"Page blocks HTML.","Page blocks HTML." +"View files fallback","View files fallback" +"Paths to view files (e.g., PHTML templates, images, CSS, JS files).","Paths to view files (e.g., PHTML templates, images, CSS, JS files)." +"View files pre-processing","View files pre-processing" +"Paths to pre-processed view files (e.g, CSS files with fixed paths or generated from LESS files).","Paths to pre-processed view files (e.g, CSS files with fixed paths or generated from LESS files)." +"Collections Data","Collections Data" +"Collection data files.","Collection data files." diff --git a/app/code/Magento/Store/i18n/fr_FR.csv b/app/code/Magento/Store/i18n/fr_FR.csv index 144b5864e3cd87176710da0bcddbc570eb9622d4..f376d05a2c634af120f2e31c26caa9af4e97949d 100644 --- a/app/code/Magento/Store/i18n/fr_FR.csv +++ b/app/code/Magento/Store/i18n/fr_FR.csv @@ -10,3 +10,16 @@ Admin,Admin "Your Language","Your Language" Language,Language "Select Store","Select Store" +"Helper arguments should not be used in custom layout updates.","Helper arguments should not be used in custom layout updates." +"Updater model should not be used in custom layout updates.","Updater model should not be used in custom layout updates." +"Please correct the XML data and try again. %value%","Please correct the XML data and try again. %value%" +Layouts,Layouts +"Layout building instructions.","Layout building instructions." +"Blocks HTML output","Blocks HTML output" +"Page blocks HTML.","Page blocks HTML." +"View files fallback","View files fallback" +"Paths to view files (e.g., PHTML templates, images, CSS, JS files).","Paths to view files (e.g., PHTML templates, images, CSS, JS files)." +"View files pre-processing","View files pre-processing" +"Paths to pre-processed view files (e.g, CSS files with fixed paths or generated from LESS files).","Paths to pre-processed view files (e.g, CSS files with fixed paths or generated from LESS files)." +"Collections Data","Collections Data" +"Collection data files.","Collection data files." diff --git a/app/code/Magento/Store/i18n/nl_NL.csv b/app/code/Magento/Store/i18n/nl_NL.csv index 144b5864e3cd87176710da0bcddbc570eb9622d4..f376d05a2c634af120f2e31c26caa9af4e97949d 100644 --- a/app/code/Magento/Store/i18n/nl_NL.csv +++ b/app/code/Magento/Store/i18n/nl_NL.csv @@ -10,3 +10,16 @@ Admin,Admin "Your Language","Your Language" Language,Language "Select Store","Select Store" +"Helper arguments should not be used in custom layout updates.","Helper arguments should not be used in custom layout updates." +"Updater model should not be used in custom layout updates.","Updater model should not be used in custom layout updates." +"Please correct the XML data and try again. %value%","Please correct the XML data and try again. %value%" +Layouts,Layouts +"Layout building instructions.","Layout building instructions." +"Blocks HTML output","Blocks HTML output" +"Page blocks HTML.","Page blocks HTML." +"View files fallback","View files fallback" +"Paths to view files (e.g., PHTML templates, images, CSS, JS files).","Paths to view files (e.g., PHTML templates, images, CSS, JS files)." +"View files pre-processing","View files pre-processing" +"Paths to pre-processed view files (e.g, CSS files with fixed paths or generated from LESS files).","Paths to pre-processed view files (e.g, CSS files with fixed paths or generated from LESS files)." +"Collections Data","Collections Data" +"Collection data files.","Collection data files." diff --git a/app/code/Magento/Store/i18n/pt_BR.csv b/app/code/Magento/Store/i18n/pt_BR.csv index 144b5864e3cd87176710da0bcddbc570eb9622d4..f376d05a2c634af120f2e31c26caa9af4e97949d 100644 --- a/app/code/Magento/Store/i18n/pt_BR.csv +++ b/app/code/Magento/Store/i18n/pt_BR.csv @@ -10,3 +10,16 @@ Admin,Admin "Your Language","Your Language" Language,Language "Select Store","Select Store" +"Helper arguments should not be used in custom layout updates.","Helper arguments should not be used in custom layout updates." +"Updater model should not be used in custom layout updates.","Updater model should not be used in custom layout updates." +"Please correct the XML data and try again. %value%","Please correct the XML data and try again. %value%" +Layouts,Layouts +"Layout building instructions.","Layout building instructions." +"Blocks HTML output","Blocks HTML output" +"Page blocks HTML.","Page blocks HTML." +"View files fallback","View files fallback" +"Paths to view files (e.g., PHTML templates, images, CSS, JS files).","Paths to view files (e.g., PHTML templates, images, CSS, JS files)." +"View files pre-processing","View files pre-processing" +"Paths to pre-processed view files (e.g, CSS files with fixed paths or generated from LESS files).","Paths to pre-processed view files (e.g, CSS files with fixed paths or generated from LESS files)." +"Collections Data","Collections Data" +"Collection data files.","Collection data files." diff --git a/app/code/Magento/Store/i18n/zh_CN.csv b/app/code/Magento/Store/i18n/zh_CN.csv index 144b5864e3cd87176710da0bcddbc570eb9622d4..f376d05a2c634af120f2e31c26caa9af4e97949d 100644 --- a/app/code/Magento/Store/i18n/zh_CN.csv +++ b/app/code/Magento/Store/i18n/zh_CN.csv @@ -10,3 +10,16 @@ Admin,Admin "Your Language","Your Language" Language,Language "Select Store","Select Store" +"Helper arguments should not be used in custom layout updates.","Helper arguments should not be used in custom layout updates." +"Updater model should not be used in custom layout updates.","Updater model should not be used in custom layout updates." +"Please correct the XML data and try again. %value%","Please correct the XML data and try again. %value%" +Layouts,Layouts +"Layout building instructions.","Layout building instructions." +"Blocks HTML output","Blocks HTML output" +"Page blocks HTML.","Page blocks HTML." +"View files fallback","View files fallback" +"Paths to view files (e.g., PHTML templates, images, CSS, JS files).","Paths to view files (e.g., PHTML templates, images, CSS, JS files)." +"View files pre-processing","View files pre-processing" +"Paths to pre-processed view files (e.g, CSS files with fixed paths or generated from LESS files).","Paths to pre-processed view files (e.g, CSS files with fixed paths or generated from LESS files)." +"Collections Data","Collections Data" +"Collection data files.","Collection data files." diff --git a/app/code/Magento/Tax/Api/Data/AppliedTaxInterface.php b/app/code/Magento/Tax/Api/Data/AppliedTaxInterface.php index a447c3944a03eea781b35d21d93afa35c29665ad..356d39d0bc106519315c3fa76da8321931c116fd 100644 --- a/app/code/Magento/Tax/Api/Data/AppliedTaxInterface.php +++ b/app/code/Magento/Tax/Api/Data/AppliedTaxInterface.php @@ -78,4 +78,19 @@ interface AppliedTaxInterface extends \Magento\Framework\Api\ExtensibleDataInter * @return $this */ public function setRates(array $rates = null); + + /** + * Retrieve existing extension attributes object or create a new one. + * + * @return \Magento\Tax\Api\Data\AppliedTaxExtensionInterface|null + */ + public function getExtensionAttributes(); + + /** + * Set an extension attributes object. + * + * @param \Magento\Tax\Api\Data\AppliedTaxExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes(\Magento\Tax\Api\Data\AppliedTaxExtensionInterface $extensionAttributes); } diff --git a/app/code/Magento/Tax/Api/Data/AppliedTaxRateInterface.php b/app/code/Magento/Tax/Api/Data/AppliedTaxRateInterface.php index f0c83cbe8d469c20b964d19e17ea6b9bbec5a929..cee4ab16fd1f0acdde90bd353b3d264e4ba52b11 100644 --- a/app/code/Magento/Tax/Api/Data/AppliedTaxRateInterface.php +++ b/app/code/Magento/Tax/Api/Data/AppliedTaxRateInterface.php @@ -62,4 +62,19 @@ interface AppliedTaxRateInterface extends \Magento\Framework\Api\ExtensibleDataI * @return $this */ public function setPercent($percent); + + /** + * Retrieve existing extension attributes object or create a new one. + * + * @return \Magento\Tax\Api\Data\AppliedTaxRateExtensionInterface|null + */ + public function getExtensionAttributes(); + + /** + * Set an extension attributes object. + * + * @param \Magento\Tax\Api\Data\AppliedTaxRateExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes(\Magento\Tax\Api\Data\AppliedTaxRateExtensionInterface $extensionAttributes); } diff --git a/app/code/Magento/Tax/Api/Data/OrderTaxDetailsAppliedTaxInterface.php b/app/code/Magento/Tax/Api/Data/OrderTaxDetailsAppliedTaxInterface.php index bf8fed9966b07dce82fd5a751a98982423cb1fca..7123087eacf565f0341178e6f9643c9a98bf7036 100644 --- a/app/code/Magento/Tax/Api/Data/OrderTaxDetailsAppliedTaxInterface.php +++ b/app/code/Magento/Tax/Api/Data/OrderTaxDetailsAppliedTaxInterface.php @@ -97,4 +97,21 @@ interface OrderTaxDetailsAppliedTaxInterface extends \Magento\Framework\Api\Exte * @return $this */ public function setBaseAmount($baseAmount); + + /** + * Retrieve existing extension attributes object or create a new one. + * + * @return \Magento\Tax\Api\Data\OrderTaxDetailsAppliedTaxExtensionInterface|null + */ + public function getExtensionAttributes(); + + /** + * Set an extension attributes object. + * + * @param \Magento\Tax\Api\Data\OrderTaxDetailsAppliedTaxExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes( + \Magento\Tax\Api\Data\OrderTaxDetailsAppliedTaxExtensionInterface $extensionAttributes + ); } diff --git a/app/code/Magento/Tax/Api/Data/OrderTaxDetailsInterface.php b/app/code/Magento/Tax/Api/Data/OrderTaxDetailsInterface.php index cee19ce16af5d69f9ef3ae96a057f8f9f96a5c11..d68de6f5858aab5c3362c60d62a1d006bc22c42d 100644 --- a/app/code/Magento/Tax/Api/Data/OrderTaxDetailsInterface.php +++ b/app/code/Magento/Tax/Api/Data/OrderTaxDetailsInterface.php @@ -42,4 +42,21 @@ interface OrderTaxDetailsInterface extends \Magento\Framework\Api\ExtensibleData * @return $this */ public function setItems(array $items = null); + + /** + * Retrieve existing extension attributes object or create a new one. + * + * @return \Magento\Tax\Api\Data\OrderTaxDetailsExtensionInterface|null + */ + public function getExtensionAttributes(); + + /** + * Set an extension attributes object. + * + * @param \Magento\Tax\Api\Data\OrderTaxDetailsExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes( + \Magento\Tax\Api\Data\OrderTaxDetailsExtensionInterface $extensionAttributes + ); } diff --git a/app/code/Magento/Tax/Api/Data/OrderTaxDetailsItemInterface.php b/app/code/Magento/Tax/Api/Data/OrderTaxDetailsItemInterface.php index 601371a4259c11b12e8bd7b383d87c6fec9aec1e..905a0aa203594097e5377130679dfb4e5bb18a92 100644 --- a/app/code/Magento/Tax/Api/Data/OrderTaxDetailsItemInterface.php +++ b/app/code/Magento/Tax/Api/Data/OrderTaxDetailsItemInterface.php @@ -80,4 +80,21 @@ interface OrderTaxDetailsItemInterface extends \Magento\Framework\Api\Extensible * @return $this */ public function setAppliedTaxes(array $appliedTaxes = null); + + /** + * Retrieve existing extension attributes object or create a new one. + * + * @return \Magento\Tax\Api\Data\OrderTaxDetailsItemExtensionInterface|null + */ + public function getExtensionAttributes(); + + /** + * Set an extension attributes object. + * + * @param \Magento\Tax\Api\Data\OrderTaxDetailsItemExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes( + \Magento\Tax\Api\Data\OrderTaxDetailsItemExtensionInterface $extensionAttributes + ); } diff --git a/app/code/Magento/Tax/Api/Data/QuoteDetailsInterface.php b/app/code/Magento/Tax/Api/Data/QuoteDetailsInterface.php index f8e60a4cfd08e2bf84115321daa7d6ce22575e5b..f7d69e1572f86eaecfad263eeeb026ebe8f280bc 100644 --- a/app/code/Magento/Tax/Api/Data/QuoteDetailsInterface.php +++ b/app/code/Magento/Tax/Api/Data/QuoteDetailsInterface.php @@ -114,4 +114,19 @@ interface QuoteDetailsInterface extends \Magento\Framework\Api\ExtensibleDataInt * @return $this */ public function setCustomerTaxClassId($customerTaxClassId); + + /** + * Retrieve existing extension attributes object or create a new one. + * + * @return \Magento\Tax\Api\Data\QuoteDetailsExtensionInterface|null + */ + public function getExtensionAttributes(); + + /** + * Set an extension attributes object. + * + * @param \Magento\Tax\Api\Data\QuoteDetailsExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes(\Magento\Tax\Api\Data\QuoteDetailsExtensionInterface $extensionAttributes); } diff --git a/app/code/Magento/Tax/Api/Data/QuoteDetailsItemInterface.php b/app/code/Magento/Tax/Api/Data/QuoteDetailsItemInterface.php index 212236f8d599a62de5a00475091fd3ac94a63c84..ea3e57327f3115581853572e3159628b600c31cd 100644 --- a/app/code/Magento/Tax/Api/Data/QuoteDetailsItemInterface.php +++ b/app/code/Magento/Tax/Api/Data/QuoteDetailsItemInterface.php @@ -198,4 +198,21 @@ interface QuoteDetailsItemInterface extends \Magento\Framework\Api\ExtensibleDat * @return $this */ public function setTaxClassId($taxClassId); + + /** + * Retrieve existing extension attributes object or create a new one. + * + * @return \Magento\Tax\Api\Data\QuoteDetailsItemExtensionInterface|null + */ + public function getExtensionAttributes(); + + /** + * Set an extension attributes object. + * + * @param \Magento\Tax\Api\Data\QuoteDetailsItemExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes( + \Magento\Tax\Api\Data\QuoteDetailsItemExtensionInterface $extensionAttributes + ); } diff --git a/app/code/Magento/Tax/Api/Data/TaxClassInterface.php b/app/code/Magento/Tax/Api/Data/TaxClassInterface.php index 1539ea9e5c5acd739675390bc73cba9912600ab7..80774ef47c646bed3cb54e3813b7968c37536adc 100644 --- a/app/code/Magento/Tax/Api/Data/TaxClassInterface.php +++ b/app/code/Magento/Tax/Api/Data/TaxClassInterface.php @@ -62,4 +62,19 @@ interface TaxClassInterface extends \Magento\Framework\Api\ExtensibleDataInterfa * @return $this */ public function setClassType($classType); + + /** + * Retrieve existing extension attributes object or create a new one. + * + * @return \Magento\Tax\Api\Data\TaxClassExtensionInterface|null + */ + public function getExtensionAttributes(); + + /** + * Set an extension attributes object. + * + * @param \Magento\Tax\Api\Data\TaxClassExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes(\Magento\Tax\Api\Data\TaxClassExtensionInterface $extensionAttributes); } diff --git a/app/code/Magento/Tax/Api/Data/TaxClassKeyInterface.php b/app/code/Magento/Tax/Api/Data/TaxClassKeyInterface.php index 709291ff35ce434f58e55ff83ae3cd8247074617..9f0a25a170cbadbd71ad8e1c1e7d7cd6de7d0c27 100644 --- a/app/code/Magento/Tax/Api/Data/TaxClassKeyInterface.php +++ b/app/code/Magento/Tax/Api/Data/TaxClassKeyInterface.php @@ -55,4 +55,19 @@ interface TaxClassKeyInterface extends ExtensibleDataInterface * @return $this */ public function setValue($value); + + /** + * Retrieve existing extension attributes object or create a new one. + * + * @return \Magento\Tax\Api\Data\TaxClassKeyExtensionInterface|null + */ + public function getExtensionAttributes(); + + /** + * Set an extension attributes object. + * + * @param \Magento\Tax\Api\Data\TaxClassKeyExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes(\Magento\Tax\Api\Data\TaxClassKeyExtensionInterface $extensionAttributes); } diff --git a/app/code/Magento/Tax/Api/Data/TaxDetailsInterface.php b/app/code/Magento/Tax/Api/Data/TaxDetailsInterface.php index 0c6f80296474a2211b8048fef57d5c561f6d64b3..f06ba96bc54ca28a6ed4e167d48bbc4e553dcd15 100644 --- a/app/code/Magento/Tax/Api/Data/TaxDetailsInterface.php +++ b/app/code/Magento/Tax/Api/Data/TaxDetailsInterface.php @@ -97,4 +97,19 @@ interface TaxDetailsInterface extends \Magento\Framework\Api\ExtensibleDataInter * @return $this */ public function setItems(array $items = null); + + /** + * Retrieve existing extension attributes object or create a new one. + * + * @return \Magento\Tax\Api\Data\TaxDetailsExtensionInterface|null + */ + public function getExtensionAttributes(); + + /** + * Set an extension attributes object. + * + * @param \Magento\Tax\Api\Data\TaxDetailsExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes(\Magento\Tax\Api\Data\TaxDetailsExtensionInterface $extensionAttributes); } diff --git a/app/code/Magento/Tax/Api/Data/TaxDetailsItemInterface.php b/app/code/Magento/Tax/Api/Data/TaxDetailsItemInterface.php index 8c2f50111b313df4b0c00c66c4b48f68c199bc92..fad3229d7076a589363cbabf9f5bcb064984e04f 100644 --- a/app/code/Magento/Tax/Api/Data/TaxDetailsItemInterface.php +++ b/app/code/Magento/Tax/Api/Data/TaxDetailsItemInterface.php @@ -232,4 +232,19 @@ interface TaxDetailsItemInterface extends \Magento\Framework\Api\ExtensibleDataI * @return $this */ public function setAssociatedItemCode($associatedItemCode); + + /** + * Retrieve existing extension attributes object or create a new one. + * + * @return \Magento\Tax\Api\Data\TaxDetailsItemExtensionInterface|null + */ + public function getExtensionAttributes(); + + /** + * Set an extension attributes object. + * + * @param \Magento\Tax\Api\Data\TaxDetailsItemExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes(\Magento\Tax\Api\Data\TaxDetailsItemExtensionInterface $extensionAttributes); } diff --git a/app/code/Magento/Tax/Api/Data/TaxRateInterface.php b/app/code/Magento/Tax/Api/Data/TaxRateInterface.php index 7e878cb77564be1ae4c687df027e8be3b77a9567..881bb7fa7e013838c558f5514af373dcbe6fceaa 100644 --- a/app/code/Magento/Tax/Api/Data/TaxRateInterface.php +++ b/app/code/Magento/Tax/Api/Data/TaxRateInterface.php @@ -189,4 +189,19 @@ interface TaxRateInterface extends \Magento\Framework\Api\ExtensibleDataInterfac * @return $this */ public function setTitles(array $titles = null); + + /** + * Retrieve existing extension attributes object or create a new one. + * + * @return \Magento\Tax\Api\Data\TaxRateExtensionInterface|null + */ + public function getExtensionAttributes(); + + /** + * Set an extension attributes object. + * + * @param \Magento\Tax\Api\Data\TaxRateExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes(\Magento\Tax\Api\Data\TaxRateExtensionInterface $extensionAttributes); } diff --git a/app/code/Magento/Tax/Api/Data/TaxRateTitleInterface.php b/app/code/Magento/Tax/Api/Data/TaxRateTitleInterface.php index 2d9ff88958b105ef78e95630fb31eed4d88d5893..8d3991070b9565d9527c7c036aca9e45864d15f4 100644 --- a/app/code/Magento/Tax/Api/Data/TaxRateTitleInterface.php +++ b/app/code/Magento/Tax/Api/Data/TaxRateTitleInterface.php @@ -47,4 +47,19 @@ interface TaxRateTitleInterface extends \Magento\Framework\Api\ExtensibleDataInt * @return string */ public function setValue($value); + + /** + * Retrieve existing extension attributes object or create a new one. + * + * @return \Magento\Tax\Api\Data\TaxRateTitleExtensionInterface|null + */ + public function getExtensionAttributes(); + + /** + * Set an extension attributes object. + * + * @param \Magento\Tax\Api\Data\TaxRateTitleExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes(\Magento\Tax\Api\Data\TaxRateTitleExtensionInterface $extensionAttributes); } diff --git a/app/code/Magento/Tax/Api/Data/TaxRuleInterface.php b/app/code/Magento/Tax/Api/Data/TaxRuleInterface.php index e746fd0c9f2630d266dad79383c2790fb9154b4d..67c9b6a80c65e9ad7388e9c43be71144e5ba8690 100644 --- a/app/code/Magento/Tax/Api/Data/TaxRuleInterface.php +++ b/app/code/Magento/Tax/Api/Data/TaxRuleInterface.php @@ -129,4 +129,19 @@ interface TaxRuleInterface extends ExtensibleDataInterface * @return $this */ public function setCalculateSubtotal($calculateSubtotal); + + /** + * Retrieve existing extension attributes object or create a new one. + * + * @return \Magento\Tax\Api\Data\TaxRuleExtensionInterface|null + */ + public function getExtensionAttributes(); + + /** + * Set an extension attributes object. + * + * @param \Magento\Tax\Api\Data\TaxRuleExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes(\Magento\Tax\Api\Data\TaxRuleExtensionInterface $extensionAttributes); } diff --git a/app/code/Magento/Tax/Controller/Adminhtml/Tax.php b/app/code/Magento/Tax/Controller/Adminhtml/Tax.php index b75bca3f82676fc5cd7bff68f1842459fad7732e..a79430f7ac06b3d8e5ae4b5e7fa1caafca31957a 100644 --- a/app/code/Magento/Tax/Controller/Adminhtml/Tax.php +++ b/app/code/Magento/Tax/Controller/Adminhtml/Tax.php @@ -51,7 +51,7 @@ class Tax extends \Magento\Backend\App\Action { $className = trim($this->_objectManager->get('Magento\Framework\Escaper')->escapeHtml($className)); if ($className == '') { - throw new InputException('Invalid name of tax class specified.'); + throw new InputException(__('Invalid name of tax class specified.')); } return $className; } diff --git a/app/code/Magento/Tax/Model/Calculation/Rate.php b/app/code/Magento/Tax/Model/Calculation/Rate.php index bb05f8694e82f1c881fc172980ae6472c0fa093e..18dde7c54f14d54945d1625e034e07ce7833f502 100644 --- a/app/code/Magento/Tax/Model/Calculation/Rate.php +++ b/app/code/Magento/Tax/Model/Calculation/Rate.php @@ -51,7 +51,7 @@ class Rate extends \Magento\Framework\Model\AbstractExtensibleModel implements \ /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry - * @param \Magento\Framework\Api\MetadataServiceInterface $metadataService + * @param \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory * @param AttributeValueFactory $customAttributeFactory * @param \Magento\Directory\Model\RegionFactory $regionFactory * @param Rate\TitleFactory $taxTitleFactory @@ -64,7 +64,7 @@ class Rate extends \Magento\Framework\Model\AbstractExtensibleModel implements \ public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, - \Magento\Framework\Api\MetadataServiceInterface $metadataService, + \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory, AttributeValueFactory $customAttributeFactory, \Magento\Directory\Model\RegionFactory $regionFactory, \Magento\Tax\Model\Calculation\Rate\TitleFactory $taxTitleFactory, @@ -79,7 +79,7 @@ class Rate extends \Magento\Framework\Model\AbstractExtensibleModel implements \ parent::__construct( $context, $registry, - $metadataService, + $extensionFactory, $customAttributeFactory, $resource, $resourceCollection, @@ -115,11 +115,15 @@ class Rate extends \Magento\Framework\Model\AbstractExtensibleModel implements \ ($this->getTaxPostcode() === '' && !$this->getZipIsRange()); if ($isEmptyValues || $isWrongRange) { - throw new \Magento\Framework\Exception\LocalizedException(__('Please fill all required fields with valid information.')); + throw new \Magento\Framework\Exception\LocalizedException( + __('Please fill all required fields with valid information.') + ); } if (!is_numeric($this->getRate()) || $this->getRate() < 0) { - throw new \Magento\Framework\Exception\LocalizedException(__('Rate Percent should be a positive number.')); + throw new \Magento\Framework\Exception\LocalizedException( + __('Rate Percent should be a positive number.') + ); } if ($this->getZipIsRange()) { @@ -131,11 +135,15 @@ class Rate extends \Magento\Framework\Model\AbstractExtensibleModel implements \ } if (!is_numeric($zipFrom) || !is_numeric($zipTo) || $zipFrom < 0 || $zipTo < 0) { - throw new \Magento\Framework\Exception\LocalizedException(__('Zip code should not contain characters other than digits.')); + throw new \Magento\Framework\Exception\LocalizedException( + __('Zip code should not contain characters other than digits.') + ); } if ($zipFrom > $zipTo) { - throw new \Magento\Framework\Exception\LocalizedException(__('Range To should be equal or greater than Range From.')); + throw new \Magento\Framework\Exception\LocalizedException( + __('Range To should be equal or greater than Range From.') + ); } $this->setTaxPostcode($zipFrom . '-' . $zipTo); @@ -182,7 +190,9 @@ class Rate extends \Magento\Framework\Model\AbstractExtensibleModel implements \ public function beforeDelete() { if ($this->_isInRule()) { - throw new CouldNotDeleteException('The tax rate cannot be removed. It exists in a tax rule.'); + throw new CouldNotDeleteException( + __('The tax rate cannot be removed. It exists in a tax rule.') + ); } return parent::beforeDelete(); } @@ -484,4 +494,25 @@ class Rate extends \Magento\Framework\Model\AbstractExtensibleModel implements \ return $this->setData(self::KEY_TITLES, $titles); } // @codeCoverageIgnoreEnd + + /** + * {@inheritdoc} + * + * @return \Magento\Tax\Api\Data\TaxRateExtensionInterface|null + */ + public function getExtensionAttributes() + { + return $this->_getExtensionAttributes(); + } + + /** + * {@inheritdoc} + * + * @param \Magento\Tax\Api\Data\TaxRateExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes(\Magento\Tax\Api\Data\TaxRateExtensionInterface $extensionAttributes) + { + return $this->_setExtensionAttributes($extensionAttributes); + } } diff --git a/app/code/Magento/Tax/Model/Calculation/Rate/Title.php b/app/code/Magento/Tax/Model/Calculation/Rate/Title.php index 674c59e0eff8151627db9a8a1155557692702caa..a98b220548940e240774250f868c8b1abb8c4f1d 100644 --- a/app/code/Magento/Tax/Model/Calculation/Rate/Title.php +++ b/app/code/Magento/Tax/Model/Calculation/Rate/Title.php @@ -76,4 +76,25 @@ class Title extends \Magento\Framework\Model\AbstractExtensibleModel implements return $this->setData(self::KEY_VALUE_ID, $value); } // @codeCoverageIgnoreEnd + + /** + * {@inheritdoc} + * + * @return \Magento\Tax\Api\Data\TaxRateTitleExtensionInterface|null + */ + public function getExtensionAttributes() + { + return $this->_getExtensionAttributes(); + } + + /** + * {@inheritdoc} + * + * @param \Magento\Tax\Api\Data\TaxRateTitleExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes(\Magento\Tax\Api\Data\TaxRateTitleExtensionInterface $extensionAttributes) + { + return $this->_setExtensionAttributes($extensionAttributes); + } } diff --git a/app/code/Magento/Tax/Model/Calculation/RateRepository.php b/app/code/Magento/Tax/Model/Calculation/RateRepository.php index 48967e8bec82aa77e6c47e7626dd4f18731c3c48..a185acd15844412198f779b0efd4dc58e224a7fa 100644 --- a/app/code/Magento/Tax/Model/Calculation/RateRepository.php +++ b/app/code/Magento/Tax/Model/Calculation/RateRepository.php @@ -233,17 +233,19 @@ class RateRepository implements \Magento\Tax\Api\TaxRateRepositoryInterface $countryCode = $taxRate->getTaxCountryId(); if (!\Zend_Validate::is($countryCode, 'NotEmpty')) { - $exception->addError(InputException::REQUIRED_FIELD, ['fieldName' => 'country_id']); + $exception->addError(__(InputException::REQUIRED_FIELD, ['fieldName' => 'country_id'])); } elseif (!\Zend_Validate::is( $this->countryFactory->create()->loadByCode($countryCode)->getId(), 'NotEmpty' )) { $exception->addError( - InputException::INVALID_FIELD_VALUE, - [ - 'fieldName' => 'country_id', - 'value' => $countryCode - ] + __( + InputException::INVALID_FIELD_VALUE, + [ + 'fieldName' => 'country_id', + 'value' => $countryCode + ] + ) ); } @@ -256,17 +258,19 @@ class RateRepository implements \Magento\Tax\Api\TaxRateRepositoryInterface ) ) { $exception->addError( - InputException::INVALID_FIELD_VALUE, - ['fieldName' => 'region_id', 'value' => $regionCode] + __( + InputException::INVALID_FIELD_VALUE, + ['fieldName' => 'region_id', 'value' => $regionCode] + ) ); } if (!\Zend_Validate::is($taxRate->getRate(), 'NotEmpty')) { - $exception->addError(InputException::REQUIRED_FIELD, ['fieldName' => 'percentage_rate']); + $exception->addError(__(InputException::REQUIRED_FIELD, ['fieldName' => 'percentage_rate'])); } if (!\Zend_Validate::is(trim($taxRate->getCode()), 'NotEmpty')) { - $exception->addError(InputException::REQUIRED_FIELD, ['fieldName' => 'code']); + $exception->addError(__(InputException::REQUIRED_FIELD, ['fieldName' => 'code'])); } if ($taxRate->getZipIsRange()) { @@ -277,17 +281,19 @@ class RateRepository implements \Magento\Tax\Api\TaxRateRepositoryInterface foreach ($zipRangeFromTo as $key => $value) { if (!is_numeric($value) || $value < 0) { $exception->addError( - InputException::INVALID_FIELD_VALUE, - ['fieldName' => $key, 'value' => $value] + __( + InputException::INVALID_FIELD_VALUE, + ['fieldName' => $key, 'value' => $value] + ) ); } } if ($zipRangeFromTo['zip_from'] > $zipRangeFromTo['zip_to']) { - $exception->addError('Range To should be equal or greater than Range From.'); + $exception->addError(__('Range To should be equal or greater than Range From.')); } } else { if (!\Zend_Validate::is(trim($taxRate->getTaxPostcode()), 'NotEmpty')) { - $exception->addError(InputException::REQUIRED_FIELD, ['fieldName' => 'postcode']); + $exception->addError(__(InputException::REQUIRED_FIELD, ['fieldName' => 'postcode'])); } } diff --git a/app/code/Magento/Tax/Model/Calculation/Rule.php b/app/code/Magento/Tax/Model/Calculation/Rule.php index ddf7acb1e7afeb119dfbf3821679d99520f18966..13d287ce5da36b67ece5d16a634a1ba3a743ca44 100644 --- a/app/code/Magento/Tax/Model/Calculation/Rule.php +++ b/app/code/Magento/Tax/Model/Calculation/Rule.php @@ -6,7 +6,7 @@ namespace Magento\Tax\Model\Calculation; use Magento\Framework\Api\AttributeValueFactory; -use Magento\Framework\Api\MetadataServiceInterface; +use Magento\Framework\Api\ExtensionAttributesFactory; use Magento\Tax\Api\Data\TaxRuleInterface; /** @@ -72,7 +72,7 @@ class Rule extends \Magento\Framework\Model\AbstractExtensibleModel implements T /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry - * @param MetadataServiceInterface $metadataService + * @param ExtensionAttributesFactory $extensionFactory * @param AttributeValueFactory $customAttributeFactory * @param \Magento\Tax\Model\ClassModel $taxClass * @param \Magento\Tax\Model\Calculation $calculation @@ -85,7 +85,7 @@ class Rule extends \Magento\Framework\Model\AbstractExtensibleModel implements T public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, - MetadataServiceInterface $metadataService, + ExtensionAttributesFactory $extensionFactory, AttributeValueFactory $customAttributeFactory, \Magento\Tax\Model\ClassModel $taxClass, \Magento\Tax\Model\Calculation $calculation, @@ -99,7 +99,7 @@ class Rule extends \Magento\Framework\Model\AbstractExtensibleModel implements T parent::__construct( $context, $registry, - $metadataService, + $extensionFactory, $customAttributeFactory, $resource, $resourceCollection, @@ -377,4 +377,25 @@ class Rule extends \Magento\Framework\Model\AbstractExtensibleModel implements T { return $this->setData(self::KEY_CALCULATE_SUBTOTAL, $calculateSubtotal); } + + /** + * {@inheritdoc} + * + * @return \Magento\Tax\Api\Data\TaxRuleExtensionInterface|null + */ + public function getExtensionAttributes() + { + return $this->_getExtensionAttributes(); + } + + /** + * {@inheritdoc} + * + * @param \Magento\Tax\Api\Data\TaxRuleExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes(\Magento\Tax\Api\Data\TaxRuleExtensionInterface $extensionAttributes) + { + return $this->_setExtensionAttributes($extensionAttributes); + } } diff --git a/app/code/Magento/Tax/Model/ClassModel.php b/app/code/Magento/Tax/Model/ClassModel.php index 143cb9504cecd6d4c41900b1322fe0a1b4592ba3..603fc708d47286e0dffdd25f8724756445f6cac1 100644 --- a/app/code/Magento/Tax/Model/ClassModel.php +++ b/app/code/Magento/Tax/Model/ClassModel.php @@ -37,7 +37,7 @@ class ClassModel extends \Magento\Framework\Model\AbstractExtensibleModel implem /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry - * @param \Magento\Framework\Api\MetadataServiceInterface $metadataService + * @param \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory * @param AttributeValueFactory $customAttributeFactory * @param TaxClass\Factory $classFactory * @param \Magento\Framework\Model\Resource\AbstractResource $resource @@ -47,7 +47,7 @@ class ClassModel extends \Magento\Framework\Model\AbstractExtensibleModel implem public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, - \Magento\Framework\Api\MetadataServiceInterface $metadataService, + \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory, AttributeValueFactory $customAttributeFactory, \Magento\Tax\Model\TaxClass\Factory $classFactory, \Magento\Framework\Model\Resource\AbstractResource $resource = null, @@ -57,7 +57,7 @@ class ClassModel extends \Magento\Framework\Model\AbstractExtensibleModel implem parent::__construct( $context, $registry, - $metadataService, + $extensionFactory, $customAttributeFactory, $resource, $resourceCollection, @@ -83,22 +83,26 @@ class ClassModel extends \Magento\Framework\Model\AbstractExtensibleModel implem protected function checkClassCanBeDeleted() { if (!$this->getId()) { - throw new CouldNotDeleteException('This class no longer exists.'); + throw new CouldNotDeleteException(__('This class no longer exists.')); } $typeModel = $this->_classFactory->create($this); if ($typeModel->getAssignedToRules()->getSize() > 0) { throw new CouldNotDeleteException( - 'You cannot delete this tax class because it is used in Tax Rules.' . - ' You have to delete the rules it is used in first.' + __( + 'You cannot delete this tax class because it is used in Tax Rules.' + . ' You have to delete the rules it is used in first.' + ) ); } if ($typeModel->isAssignedToObjects()) { throw new CouldNotDeleteException( - 'You cannot delete this tax class because it is used in existing %object(s).', - ['object' => $typeModel->getObjectTypeName()] + __( + 'You cannot delete this tax class because it is used in existing %1(s).', + $typeModel->getObjectTypeName() + ) ); } @@ -174,4 +178,25 @@ class ClassModel extends \Magento\Framework\Model\AbstractExtensibleModel implem return $this->setData(self::KEY_TYPE, $classType); } //@codeCoverageIgnoreEnd + + /** + * {@inheritdoc} + * + * @return \Magento\Tax\Api\Data\TaxClassExtensionInterface|null + */ + public function getExtensionAttributes() + { + return $this->_getExtensionAttributes(); + } + + /** + * {@inheritdoc} + * + * @param \Magento\Tax\Api\Data\TaxClassExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes(\Magento\Tax\Api\Data\TaxClassExtensionInterface $extensionAttributes) + { + return $this->_setExtensionAttributes($extensionAttributes); + } } diff --git a/app/code/Magento/Tax/Model/Resource/Calculation/Rule/Collection.php b/app/code/Magento/Tax/Model/Resource/Calculation/Rule/Collection.php index 217b4784ec1cde88c4714d3371b58e4aa7d890a9..8c39b7f01cb7019876f192c86250fa31a19d5794 100644 --- a/app/code/Magento/Tax/Model/Resource/Calculation/Rule/Collection.php +++ b/app/code/Magento/Tax/Model/Resource/Calculation/Rule/Collection.php @@ -156,6 +156,7 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac break; default: throw new \Magento\Framework\Exception\LocalizedException(__('Invalid type supplied')); + break; } $this->joinCalculationData('cd'); diff --git a/app/code/Magento/Tax/Model/Sales/Order/Details.php b/app/code/Magento/Tax/Model/Sales/Order/Details.php index 14fce1cbbb59f4880e143b3bb22c7d435cf4666c..5161ab9fe6f7397f08cb88972033a8a6be6f6ef4 100644 --- a/app/code/Magento/Tax/Model/Sales/Order/Details.php +++ b/app/code/Magento/Tax/Model/Sales/Order/Details.php @@ -50,4 +50,25 @@ class Details extends \Magento\Framework\Model\AbstractExtensibleModel implement { return $this->setData(self::KEY_ITEMS, $items); } + + /** + * {@inheritdoc} + * + * @return \Magento\Tax\Api\Data\OrderTaxDetailsExtensionInterface|null + */ + public function getExtensionAttributes() + { + return $this->_getExtensionAttributes(); + } + + /** + * {@inheritdoc} + * + * @param \Magento\Tax\Api\Data\OrderTaxDetailsExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes(\Magento\Tax\Api\Data\OrderTaxDetailsExtensionInterface $extensionAttributes) + { + return $this->_setExtensionAttributes($extensionAttributes); + } } diff --git a/app/code/Magento/Tax/Model/Sales/Order/Tax.php b/app/code/Magento/Tax/Model/Sales/Order/Tax.php index d361064b51b734abd849e9fa85666789a595b120..29ce7e404f5696bcff549d3b276f6b14f6aea1d2 100644 --- a/app/code/Magento/Tax/Model/Sales/Order/Tax.php +++ b/app/code/Magento/Tax/Model/Sales/Order/Tax.php @@ -127,4 +127,26 @@ class Tax extends \Magento\Framework\Model\AbstractExtensibleModel implements { return $this->setData(self::KEY_BASE_AMOUNT, $baseAmount); } + + /** + * {@inheritdoc} + * + * @return \Magento\Tax\Api\Data\OrderTaxDetailsAppliedTaxExtensionInterface|null + */ + public function getExtensionAttributes() + { + return $this->_getExtensionAttributes(); + } + + /** + * {@inheritdoc} + * + * @param \Magento\Tax\Api\Data\OrderTaxDetailsAppliedTaxExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes( + \Magento\Tax\Api\Data\OrderTaxDetailsAppliedTaxExtensionInterface $extensionAttributes + ) { + return $this->_setExtensionAttributes($extensionAttributes); + } } diff --git a/app/code/Magento/Tax/Model/Sales/Order/Tax/Item.php b/app/code/Magento/Tax/Model/Sales/Order/Tax/Item.php index a57234e0ece611f01f39a313705f9d67613d18b5..a6b6148ed0c9eaca83d07b74c4d32f53ce3a1e74 100644 --- a/app/code/Magento/Tax/Model/Sales/Order/Tax/Item.php +++ b/app/code/Magento/Tax/Model/Sales/Order/Tax/Item.php @@ -94,4 +94,26 @@ class Item extends \Magento\Framework\Model\AbstractExtensibleModel implements { return $this->setData(self::KEY_APPLIED_TAXES, $appliedTaxes); } + + /** + * {@inheritdoc} + * + * @return \Magento\Tax\Api\Data\OrderTaxDetailsItemExtensionInterface|null + */ + public function getExtensionAttributes() + { + return $this->_getExtensionAttributes(); + } + + /** + * {@inheritdoc} + * + * @param \Magento\Tax\Api\Data\OrderTaxDetailsItemExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes( + \Magento\Tax\Api\Data\OrderTaxDetailsItemExtensionInterface $extensionAttributes + ) { + return $this->_setExtensionAttributes($extensionAttributes); + } } diff --git a/app/code/Magento/Tax/Model/Sales/Order/TaxManagement.php b/app/code/Magento/Tax/Model/Sales/Order/TaxManagement.php index 0debdc08528530634e654aad46666f1c75a8e12b..c665dfd00e8f8a65f487faacb618c1475991b10b 100644 --- a/app/code/Magento/Tax/Model/Sales/Order/TaxManagement.php +++ b/app/code/Magento/Tax/Model/Sales/Order/TaxManagement.php @@ -127,11 +127,13 @@ class TaxManagement implements \Magento\Tax\Api\OrderTaxManagementInterface $order = $this->orderFactory->create()->load($orderId); if (!$order) { throw new NoSuchEntityException( - NoSuchEntityException::MESSAGE_DOUBLE_FIELDS, - [ - 'fieldName' => 'orderId', - 'fieldValue' => $orderId, - ] + __( + NoSuchEntityException::MESSAGE_DOUBLE_FIELDS, + [ + 'fieldName' => 'orderId', + 'fieldValue' => $orderId, + ] + ) ); } diff --git a/app/code/Magento/Tax/Model/Sales/Quote/ItemDetails.php b/app/code/Magento/Tax/Model/Sales/Quote/ItemDetails.php index ca74f9f940315bd0d61dca0dda68714e530b4d2b..71d18024ea5f1a199b99ff3811fa4d82d7009ed7 100644 --- a/app/code/Magento/Tax/Model/Sales/Quote/ItemDetails.php +++ b/app/code/Magento/Tax/Model/Sales/Quote/ItemDetails.php @@ -221,4 +221,26 @@ class ItemDetails extends AbstractExtensibleModel implements QuoteDetailsItemInt { return $this->setData(QuoteDetailsItemInterface::KEY_TAX_CLASS_ID, $taxClassId); } + + /** + * {@inheritdoc} + * + * @return \Magento\Tax\Api\Data\QuoteDetailsItemExtensionInterface|null + */ + public function getExtensionAttributes() + { + return $this->_getExtensionAttributes(); + } + + /** + * {@inheritdoc} + * + * @param \Magento\Tax\Api\Data\QuoteDetailsItemExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes( + \Magento\Tax\Api\Data\QuoteDetailsItemExtensionInterface $extensionAttributes + ) { + return $this->_setExtensionAttributes($extensionAttributes); + } } diff --git a/app/code/Magento/Tax/Model/Sales/Quote/QuoteDetails.php b/app/code/Magento/Tax/Model/Sales/Quote/QuoteDetails.php index 0ebdffd3ba107668c3a02a0b1da232a27bd161df..1ef369ba40d82dfb3655926be7970e003892a152 100644 --- a/app/code/Magento/Tax/Model/Sales/Quote/QuoteDetails.php +++ b/app/code/Magento/Tax/Model/Sales/Quote/QuoteDetails.php @@ -126,4 +126,25 @@ class QuoteDetails extends AbstractExtensibleModel implements QuoteDetailsInterf { return $this->setData(QuoteDetailsInterface::CUSTOMER_TAX_CLASS_ID, $customerTaxClassId); } + + /** + * {@inheritdoc} + * + * @return \Magento\Tax\Api\Data\QuoteDetailsExtensionInterface|null + */ + public function getExtensionAttributes() + { + return $this->_getExtensionAttributes(); + } + + /** + * {@inheritdoc} + * + * @param \Magento\Tax\Api\Data\QuoteDetailsExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes(\Magento\Tax\Api\Data\QuoteDetailsExtensionInterface $extensionAttributes) + { + return $this->_setExtensionAttributes($extensionAttributes); + } } diff --git a/app/code/Magento/Tax/Model/TaxClass/Key.php b/app/code/Magento/Tax/Model/TaxClass/Key.php index 11ccf63e872d3fc5b0fd3264cae7610d7a24a438..085b018aa88f7ad8ba4ef5a36fea99c31f6ded54 100644 --- a/app/code/Magento/Tax/Model/TaxClass/Key.php +++ b/app/code/Magento/Tax/Model/TaxClass/Key.php @@ -50,4 +50,25 @@ class Key extends AbstractExtensibleModel implements TaxClassKeyInterface { return $this->setData(TaxClassKeyInterface::KEY_VALUE, $value); } + + /** + * {@inheritdoc} + * + * @return \Magento\Tax\Api\Data\TaxClassKeyExtensionInterface|null + */ + public function getExtensionAttributes() + { + return $this->_getExtensionAttributes(); + } + + /** + * {@inheritdoc} + * + * @param \Magento\Tax\Api\Data\TaxClassKeyExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes(\Magento\Tax\Api\Data\TaxClassKeyExtensionInterface $extensionAttributes) + { + return $this->_setExtensionAttributes($extensionAttributes); + } } diff --git a/app/code/Magento/Tax/Model/TaxClass/Repository.php b/app/code/Magento/Tax/Model/TaxClass/Repository.php index 83017d71277ddd9a7d851fc94868e8146afb3b38..a0fc6fe76d46ec8718a7cccf2af8a44068b73425 100644 --- a/app/code/Magento/Tax/Model/TaxClass/Repository.php +++ b/app/code/Magento/Tax/Model/TaxClass/Repository.php @@ -96,7 +96,7 @@ class Repository implements \Magento\Tax\Api\TaxClassRepositoryInterface /* should not be allowed to switch the tax class type */ if ($originalTaxClassModel->getClassType() !== $taxClass->getClassType()) { - throw new InputException('Updating classType is not allowed.'); + throw new InputException(__('Updating classType is not allowed.')); } } $this->validateTaxClassData($taxClass); @@ -105,8 +105,10 @@ class Repository implements \Magento\Tax\Api\TaxClassRepositoryInterface } catch (ModelException $e) { if (strpos($e->getMessage(), (string)__('Class name and class type')) !== false) { throw new InputException( - 'A class with the same name already exists for ClassType %classType.', - ['classType' => $taxClass->getClassType()] + __( + 'A class with the same name already exists for ClassType %1.', + $taxClass->getClassType() + ) ); } else { throw $e; @@ -162,18 +164,20 @@ class Repository implements \Magento\Tax\Api\TaxClassRepositoryInterface $exception = new InputException(); if (!\Zend_Validate::is(trim($taxClass->getClassName()), 'NotEmpty')) { - $exception->addError(InputException::REQUIRED_FIELD, ['fieldName' => TaxClassInterface::KEY_NAME]); + $exception->addError(__(InputException::REQUIRED_FIELD, ['fieldName' => TaxClassInterface::KEY_NAME])); } $classType = $taxClass->getClassType(); if (!\Zend_Validate::is(trim($classType), 'NotEmpty')) { - $exception->addError(InputException::REQUIRED_FIELD, ['fieldName' => TaxClassInterface::KEY_TYPE]); + $exception->addError(__(InputException::REQUIRED_FIELD, ['fieldName' => TaxClassInterface::KEY_TYPE])); } elseif ($classType !== TaxClassManagementInterface::TYPE_CUSTOMER && $classType !== TaxClassManagementInterface::TYPE_PRODUCT ) { $exception->addError( - InputException::INVALID_FIELD_VALUE, - ['fieldName' => TaxClassInterface::KEY_TYPE, 'value' => $classType] + __( + InputException::INVALID_FIELD_VALUE, + ['fieldName' => TaxClassInterface::KEY_TYPE, 'value' => $classType] + ) ); } diff --git a/app/code/Magento/Tax/Model/TaxDetails/AppliedTax.php b/app/code/Magento/Tax/Model/TaxDetails/AppliedTax.php index 135fada6e8e39ff474e4ddb7267d98572824f0f4..79265cacbc0c8615b0989d9deae57cb4ab6ee405 100644 --- a/app/code/Magento/Tax/Model/TaxDetails/AppliedTax.php +++ b/app/code/Magento/Tax/Model/TaxDetails/AppliedTax.php @@ -88,4 +88,25 @@ class AppliedTax extends AbstractExtensibleModel implements AppliedTaxInterface { return $this->setData(AppliedTaxInterface::KEY_RATES, $rates); } + + /** + * {@inheritdoc} + * + * @return \Magento\Tax\Api\Data\AppliedTaxExtensionInterface|null + */ + public function getExtensionAttributes() + { + return $this->_getExtensionAttributes(); + } + + /** + * {@inheritdoc} + * + * @param \Magento\Tax\Api\Data\AppliedTaxExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes(\Magento\Tax\Api\Data\AppliedTaxExtensionInterface $extensionAttributes) + { + return $this->_setExtensionAttributes($extensionAttributes); + } } diff --git a/app/code/Magento/Tax/Model/TaxDetails/AppliedTaxRate.php b/app/code/Magento/Tax/Model/TaxDetails/AppliedTaxRate.php index c1dddb0a87dcc834e68ff02745f6ee360dffbbbd..8cd44cb70e0e36de4ebe281b05e439e18be8312d 100644 --- a/app/code/Magento/Tax/Model/TaxDetails/AppliedTaxRate.php +++ b/app/code/Magento/Tax/Model/TaxDetails/AppliedTaxRate.php @@ -69,4 +69,25 @@ class AppliedTaxRate extends AbstractExtensibleModel implements AppliedTaxRateIn { return $this->setData(AppliedTaxRateInterface::KEY_PERCENT, $percent); } + + /** + * {@inheritdoc} + * + * @return \Magento\Tax\Api\Data\AppliedTaxRateExtensionInterface|null + */ + public function getExtensionAttributes() + { + return $this->_getExtensionAttributes(); + } + + /** + * {@inheritdoc} + * + * @param \Magento\Tax\Api\Data\AppliedTaxRateExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes(\Magento\Tax\Api\Data\AppliedTaxRateExtensionInterface $extensionAttributes) + { + return $this->_setExtensionAttributes($extensionAttributes); + } } diff --git a/app/code/Magento/Tax/Model/TaxDetails/ItemDetails.php b/app/code/Magento/Tax/Model/TaxDetails/ItemDetails.php index 711a228705ddd70c274f507d438f059f3283f6ee..9ba71b43dedf1c2bf676436e6a3754e4f168d69f 100644 --- a/app/code/Magento/Tax/Model/TaxDetails/ItemDetails.php +++ b/app/code/Magento/Tax/Model/TaxDetails/ItemDetails.php @@ -262,4 +262,25 @@ class ItemDetails extends AbstractExtensibleModel implements TaxDetailsItemInter { return $this->setData(TaxDetailsItemInterface::KEY_ASSOCIATED_ITEM_CODE, $associatedItemCode); } + + /** + * {@inheritdoc} + * + * @return \Magento\Tax\Api\Data\TaxDetailsItemExtensionInterface|null + */ + public function getExtensionAttributes() + { + return $this->_getExtensionAttributes(); + } + + /** + * {@inheritdoc} + * + * @param \Magento\Tax\Api\Data\TaxDetailsItemExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes(\Magento\Tax\Api\Data\TaxDetailsItemExtensionInterface $extensionAttributes) + { + return $this->_setExtensionAttributes($extensionAttributes); + } } diff --git a/app/code/Magento/Tax/Model/TaxDetails/TaxDetails.php b/app/code/Magento/Tax/Model/TaxDetails/TaxDetails.php index bc7c87b48209900aec99200760f3c82d37c73f7b..91f1587c8b575ce08e5f52a0196c724f40917a36 100644 --- a/app/code/Magento/Tax/Model/TaxDetails/TaxDetails.php +++ b/app/code/Magento/Tax/Model/TaxDetails/TaxDetails.php @@ -110,4 +110,25 @@ class TaxDetails extends AbstractExtensibleModel implements TaxDetailsInterface { return $this->setData(TaxDetailsInterface::KEY_ITEMS, $items); } + + /** + * {@inheritdoc} + * + * @return \Magento\Tax\Api\Data\TaxDetailsExtensionInterface|null + */ + public function getExtensionAttributes() + { + return $this->_getExtensionAttributes(); + } + + /** + * {@inheritdoc} + * + * @param \Magento\Tax\Api\Data\TaxDetailsExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes(\Magento\Tax\Api\Data\TaxDetailsExtensionInterface $extensionAttributes) + { + return $this->_setExtensionAttributes($extensionAttributes); + } } diff --git a/app/code/Magento/Tax/Model/TaxRuleRepository.php b/app/code/Magento/Tax/Model/TaxRuleRepository.php index 7c7b1ed8f6cdd5ae6a0a6c3c8c232d56d8222e4a..d186c79b562aa9e44c5e1a9a2f83bae2ee866ea4 100644 --- a/app/code/Magento/Tax/Model/TaxRuleRepository.php +++ b/app/code/Magento/Tax/Model/TaxRuleRepository.php @@ -97,7 +97,7 @@ class TaxRuleRepository implements TaxRuleRepositoryInterface } catch (NoSuchEntityException $e) { throw $e; } catch (LocalizedException $e) { - throw new CouldNotSaveException($e->getMessage()); + throw new CouldNotSaveException(__($e->getMessage())); } $this->taxRuleRegistry->registerTaxRule($rule); return $rule; diff --git a/app/code/Magento/Tax/Test/Unit/Model/TaxClass/RepositoryTest.php b/app/code/Magento/Tax/Test/Unit/Model/TaxClass/RepositoryTest.php index ceeb3e67917ddb6ca33c9dee676cae6d485d08b5..80894cab62e2a22b77480e6f851031b07da9d144 100644 --- a/app/code/Magento/Tax/Test/Unit/Model/TaxClass/RepositoryTest.php +++ b/app/code/Magento/Tax/Test/Unit/Model/TaxClass/RepositoryTest.php @@ -47,6 +47,9 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase */ protected $taxClassCollectionFactory; + /** + * @return void + */ protected function setUp() { $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); @@ -93,6 +96,9 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase ); } + /** + * @return void + */ public function testDelete() { $taxClass = $this->getMock('\Magento\Tax\Model\ClassModel', [], [], '', false); @@ -103,6 +109,7 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase } /** + * @return void * @expectedException \Magento\Framework\Exception\CouldNotDeleteException * @expectedExceptionMessage Some Message */ @@ -113,10 +120,13 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase $this->taxClassResourceMock ->expects($this->once()) ->method('delete') - ->willThrowException(new CouldNotDeleteException('Some Message')); + ->willThrowException(new CouldNotDeleteException(__('Some Message'))); $this->model->delete($taxClass); } + /** + * @return void + */ public function testDeleteWithException() { $taxClass = $this->getMock('\Magento\Tax\Model\ClassModel', [], [], '', false); @@ -128,6 +138,9 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase $this->assertFalse($this->model->delete($taxClass)); } + /** + * @return void + */ public function testGet() { $taxClass = $this->getMock('\Magento\Tax\Api\Data\TaxClassInterface'); @@ -140,7 +153,10 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase $this->assertEquals($taxClass, $this->model->get($classId)); } - + + /** + * @return void + */ public function testDeleteById() { $taxClass = $this->getMock('\Magento\Tax\Model\ClassModel', [], [], '', false); @@ -158,6 +174,9 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase $this->assertTrue($this->model->deleteById($classId)); } + /** + * @return void + */ public function testGetList() { $taxClassOne = $this->getMock('\Magento\Tax\Api\Data\TaxClassInterface'); @@ -195,6 +214,9 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase $this->assertEquals($this->searchResultMock, $this->model->getList($searchCriteria)); } + /** + * @return void + */ public function testSave() { $taxClass = $this->getMock('\Magento\Tax\Model\ClassModel', [], [], '', false); @@ -217,6 +239,7 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase } /** + * @return void * @expectedException \Magento\Framework\Exception\InputException * @expectedExceptionMessage Updating classType is not allowed. */ @@ -232,6 +255,7 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase } /** + * @return void * @expectedException \Magento\Framework\Exception\LocalizedException * @expectedExceptionMessage Something went wrong */ @@ -252,11 +276,12 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase ->willReturn($originTaxClass); $this->taxClassResourceMock->expects($this->once())->method('save')->with($taxClass) - ->willThrowException(new LocalizedException("Something went wrong")); + ->willThrowException(new LocalizedException(__("Something went wrong"))); $this->model->save($taxClass); } /** + * @return void * @expectedException \Magento\Framework\Exception\LocalizedException * @expectedExceptionMessage A class with the same name already exists for ClassType PRODUCT. */ @@ -282,6 +307,8 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase } /** + * @param string $classType + * @return void * @dataProvider validateTaxClassDataProvider * @expectedException \Magento\Framework\Exception\InputException * @expectedExceptionMessage One or more input exceptions have occurred. @@ -304,6 +331,9 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase $this->model->save($taxClass); } + /** + * @return array + */ public function validateTaxClassDataProvider() { return [ diff --git a/app/code/Magento/Tax/etc/config.xml b/app/code/Magento/Tax/etc/config.xml index 6bd4ac34c517bc580a1c919950cb54a5b0c6e30f..7e44459eda420838364a8c5a5b263fb61c527f04 100644 --- a/app/code/Magento/Tax/etc/config.xml +++ b/app/code/Magento/Tax/etc/config.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Core/etc/config.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Store/etc/config.xsd"> <default> <tax> <classes> diff --git a/app/code/Magento/Tax/etc/webapi.xml b/app/code/Magento/Tax/etc/webapi.xml index 554f6729785b7e75612a7ffdba1c5da36410555f..760734bc02b8245010faca0f050c1fb06d52deaf 100644 --- a/app/code/Magento/Tax/etc/webapi.xml +++ b/app/code/Magento/Tax/etc/webapi.xml @@ -7,31 +7,31 @@ --> <routes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../app/code/Magento/Webapi/etc/webapi.xsd"> - <route url="/V1/taxRate" method="POST"> + <route url="/V1/taxRates" method="POST"> <service class="Magento\Tax\Api\TaxRateRepositoryInterface" method="save"/> <resources> <resource ref="Magento_Tax::manage_tax"/> </resources> </route> - <route url="/V1/taxRate/:rateId" method="GET"> + <route url="/V1/taxRates/:rateId" method="GET"> <service class="Magento\Tax\Api\TaxRateRepositoryInterface" method="get"/> <resources> <resource ref="Magento_Tax::manage_tax"/> </resources> </route> - <route url="/V1/taxRate" method="PUT"> + <route url="/V1/taxRates" method="PUT"> <service class="Magento\Tax\Api\TaxRateRepositoryInterface" method="save"/> <resources> <resource ref="Magento_Tax::manage_tax"/> </resources> </route> - <route url="/V1/taxRate/:rateId" method="DELETE"> + <route url="/V1/taxRates/:rateId" method="DELETE"> <service class="Magento\Tax\Api\TaxRateRepositoryInterface" method="deleteById"/> <resources> <resource ref="Magento_Tax::manage_tax"/> </resources> </route> - <route url="/V1/taxRate/search" method="GET"> + <route url="/V1/taxRates/search" method="GET"> <service class="Magento\Tax\Api\TaxRateRepositoryInterface" method="getList"/> <resources> <resource ref="Magento_Tax::manage_tax"/> @@ -67,31 +67,31 @@ <resource ref="Magento_Tax::manage_tax"/> </resources> </route> - <route url="/V1/taxClass" method="POST"> + <route url="/V1/taxClasses" method="POST"> <service class="Magento\Tax\Api\TaxClassRepositoryInterface" method="save"/> <resources> <resource ref="Magento_Tax::manage_tax"/> </resources> </route> - <route url="/V1/taxClass/:taxClassId" method="GET"> + <route url="/V1/taxClasses/:taxClassId" method="GET"> <service class="Magento\Tax\Api\TaxClassRepositoryInterface" method="get"/> <resources> <resource ref="Magento_Tax::manage_tax"/> </resources> </route> - <route url="/V1/taxClass/:classId" method="PUT"> + <route url="/V1/taxClasses/:classId" method="PUT"> <service class="Magento\Tax\Api\TaxClassRepositoryInterface" method="save"/> <resources> <resource ref="Magento_Tax::manage_tax"/> </resources> </route> - <route url="/V1/taxClass/:taxClassId" method="DELETE"> + <route url="/V1/taxClasses/:taxClassId" method="DELETE"> <service class="Magento\Tax\Api\TaxClassRepositoryInterface" method="deleteById"/> <resources> <resource ref="Magento_Tax::manage_tax"/> </resources> </route> - <route url="/V1/taxClass/search" method="GET"> + <route url="/V1/taxClasses/search" method="GET"> <service class="Magento\Tax\Api\TaxClassRepositoryInterface" method="getList"/> <resources> <resource ref="Magento_Tax::manage_tax"/> diff --git a/app/code/Magento/Theme/Model/Design/Backend/Exceptions.php b/app/code/Magento/Theme/Model/Design/Backend/Exceptions.php index da444acf7499dec9c93f15305430356957ef47f7..37a6236bc3d37fd4d2873f7ce29559ed3ebf19ef 100644 --- a/app/code/Magento/Theme/Model/Design/Backend/Exceptions.php +++ b/app/code/Magento/Theme/Model/Design/Backend/Exceptions.php @@ -61,7 +61,7 @@ class Exceptions extends ArraySerialized foreach (['search', 'value'] as $fieldName) { if (!isset($row[$fieldName])) { throw new \Magento\Framework\Exception\LocalizedException( - __("Exception does not contain field '{$fieldName}'") + __('Exception does not contain field \'%1\'', $fieldName) ); } } diff --git a/app/code/Magento/Theme/Model/PageLayout/Config/Builder.php b/app/code/Magento/Theme/Model/PageLayout/Config/Builder.php index 795740b042a18109b34e15c2e74003c4968dc20b..a63656cadfe20cbe8c789c4406992bffdb7abb03 100644 --- a/app/code/Magento/Theme/Model/PageLayout/Config/Builder.php +++ b/app/code/Magento/Theme/Model/PageLayout/Config/Builder.php @@ -13,9 +13,9 @@ namespace Magento\Theme\Model\PageLayout\Config; class Builder implements \Magento\Framework\View\Model\PageLayout\Config\BuilderInterface { /** - * @var \Magento\Framework\ObjectManagerInterface + * @var \Magento\Framework\View\PageLayout\ConfigFactory */ - protected $objectManager; + protected $configFactory; /** * @var \Magento\Framework\View\PageLayout\File\Collector\Aggregated @@ -28,18 +28,19 @@ class Builder implements \Magento\Framework\View\Model\PageLayout\Config\Builder protected $themeCollection; /** - * @param \Magento\Framework\ObjectManagerInterface $objectManager + * @param \Magento\Framework\View\PageLayout\ConfigFactory $configFactory * @param \Magento\Framework\View\PageLayout\File\Collector\Aggregated $fileCollector * @param \Magento\Theme\Model\Resource\Theme\Collection $themeCollection */ public function __construct( - \Magento\Framework\ObjectManagerInterface $objectManager, + \Magento\Framework\View\PageLayout\ConfigFactory $configFactory, \Magento\Framework\View\PageLayout\File\Collector\Aggregated $fileCollector, \Magento\Theme\Model\Resource\Theme\Collection $themeCollection ) { - $this->objectManager = $objectManager; + $this->configFactory = $configFactory; $this->fileCollector = $fileCollector; $this->themeCollection = $themeCollection; + $this->themeCollection->setItemObjectClass('Magento\Theme\Model\Theme\Data'); } /** @@ -47,10 +48,7 @@ class Builder implements \Magento\Framework\View\Model\PageLayout\Config\Builder */ public function getPageLayoutsConfig() { - return $this->objectManager->create( - 'Magento\Framework\View\PageLayout\Config', - ['configFiles' => $this->getConfigFiles()] - ); + return $this->configFactory->create(['configFiles' => $this->getConfigFiles()]); } /** diff --git a/app/code/Magento/Theme/Model/Resource/Design.php b/app/code/Magento/Theme/Model/Resource/Design.php index 38782199dcad0b6ef86aef7fbc5f5f881b61bfd3..85a393429f1da5fb2ac48fac7024985ecc4c6b44 100644 --- a/app/code/Magento/Theme/Model/Resource/Design.php +++ b/app/code/Magento/Theme/Model/Resource/Design.php @@ -71,7 +71,9 @@ class Design extends \Magento\Framework\Model\Resource\Db\AbstractDb && (new \DateTime($object->getDateFrom()))->getTimestamp() > (new \DateTime($object->getDateTo()))->getTimestamp() ) { - throw new \Magento\Framework\Exception\LocalizedException(__('Start date cannot be greater than end date.')); + throw new \Magento\Framework\Exception\LocalizedException( + __('Start date cannot be greater than end date.') + ); } $check = $this->_checkIntersection( @@ -84,8 +86,8 @@ class Design extends \Magento\Framework\Model\Resource\Db\AbstractDb if ($check) { throw new \Magento\Framework\Exception\LocalizedException( __( - 'Your design change for the specified store intersects with another one, please specify another - date range.' + 'Your design change for the specified store intersects with another one, please specify another' + . ' date range.' ) ); } diff --git a/app/code/Magento/Theme/Model/Theme.php b/app/code/Magento/Theme/Model/Theme.php index 452a8b5d628857ff8eef59950a74adbfd665803a..a120ab45c9d94cda05efbc7dbae6edcc53748353 100644 --- a/app/code/Magento/Theme/Model/Theme.php +++ b/app/code/Magento/Theme/Model/Theme.php @@ -321,7 +321,7 @@ class Theme extends \Magento\Framework\Model\AbstractModel implements ThemeInter { if (!$this->_validator->validate($this)) { $messages = $this->_validator->getErrorMessages(); - throw new \Magento\Framework\Exception\LocalizedException(implode(PHP_EOL, reset($messages))); + throw new \Magento\Framework\Exception\LocalizedException(__(implode(PHP_EOL, reset($messages)))); } return $this; } diff --git a/app/code/Magento/Theme/Setup/InstallSchema.php b/app/code/Magento/Theme/Setup/InstallSchema.php index 30d5d299c21b929bafe0684d11a61cf903e558e5..f2135e0c1e4df8f03743be922c9e3aafe05026d5 100644 --- a/app/code/Magento/Theme/Setup/InstallSchema.php +++ b/app/code/Magento/Theme/Setup/InstallSchema.php @@ -157,6 +157,56 @@ class InstallSchema implements InstallSchemaInterface ); $connection->createTable($table); + /** + * Create table 'design_change' + */ + $table = $connection->newTable( + $installer->getTable('design_change') + )->addColumn( + 'design_change_id', + \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, + null, + ['identity' => true, 'nullable' => false, 'primary' => true], + 'Design Change Id' + )->addColumn( + 'store_id', + \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, + null, + ['unsigned' => true, 'nullable' => false, 'default' => '0'], + 'Store Id' + )->addColumn( + 'design', + \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, + 255, + [], + 'Design' + )->addColumn( + 'date_from', + \Magento\Framework\DB\Ddl\Table::TYPE_DATE, + null, + [], + 'First Date of Design Activity' + )->addColumn( + 'date_to', + \Magento\Framework\DB\Ddl\Table::TYPE_DATE, + null, + [], + 'Last Date of Design Activity' + )->addIndex( + $installer->getIdxName('design_change', ['store_id']), + ['store_id'] + )->addForeignKey( + $installer->getFkName('design_change', 'store_id', 'store', 'store_id'), + 'store_id', + $installer->getTable('store'), + 'store_id', + \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE, + \Magento\Framework\DB\Ddl\Table::ACTION_CASCADE + )->setComment( + 'Design Changes' + ); + $connection->createTable($table); + $installer->endSetup(); } diff --git a/app/code/Magento/Theme/Test/Unit/Helper/ThemeTest.php b/app/code/Magento/Theme/Test/Unit/Helper/ThemeTest.php index 94702db1b8e8f816fdbf68a7206ca3d954663bf7..a8a5e56bc49d4502110dfae453ebf42088abee17 100644 --- a/app/code/Magento/Theme/Test/Unit/Helper/ThemeTest.php +++ b/app/code/Magento/Theme/Test/Unit/Helper/ThemeTest.php @@ -54,11 +54,11 @@ class ThemeTest extends \PHPUnit_Framework_TestCase '<block class="Magento\Theme\Block\Html\Head" name="head"> <block class="Magento\Theme\Block\Html\Head\Css" name="magento-loader-js"> <arguments> - <argument name="file" xsi:type="string">Magento_Core::test3.css</argument> + <argument name="file" xsi:type="string">Magento_Theme::test3.css</argument> </arguments> </block> </block>', - ['Magento_Core::test3.css' => 'Magento_Core::test3.css'], + ['Magento_Theme::test3.css' => 'Magento_Theme::test3.css'], ], [ '<block class="Magento\Theme\Block\Html\Head" name="head"> @@ -67,7 +67,7 @@ class ThemeTest extends \PHPUnit_Framework_TestCase </block> <block class="Magento\Theme\Block\Html\Head\Css" name="magento-loader-js"> <arguments> - <argument name="file" xsi:type="string">Magento_Core::test.css</argument> + <argument name="file" xsi:type="string">Magento_Theme::test.css</argument> </arguments> </block> </block> @@ -76,7 +76,7 @@ class ThemeTest extends \PHPUnit_Framework_TestCase <arguments><argument name="file" xsi:type="string">testh.css</argument></arguments> </block> <block class="Magento\Theme\Block\Html\Head\Css" name="magento-loader-js"> - <arguments><argument name="file" xsi:type="string">Magento_Core::test.css</argument></arguments> + <arguments><argument name="file" xsi:type="string">Magento_Theme::test.css</argument></arguments> </block> </referenceBlock> <block type="Some_Block_Class"> @@ -85,7 +85,7 @@ class ThemeTest extends \PHPUnit_Framework_TestCase </block> <block class="Magento\Theme\Block\Html\Head\Css" name="magento-loader-js"> <arguments> - <argument name="file" xsi:type="string">Magento_Core::testa.css</argument> + <argument name="file" xsi:type="string">Magento_Theme::testa.css</argument> </arguments> </block> </block> @@ -95,12 +95,12 @@ class ThemeTest extends \PHPUnit_Framework_TestCase </block> <block class="Magento\Theme\Block\Html\Head\Css" name="magento-loader-js"> <arguments> - <argument name="file" xsi:type="string">Magento_Core::testb.css</argument> + <argument name="file" xsi:type="string">Magento_Theme::testb.css</argument> </arguments> </block> </referenceBlock>', [ - 'Magento_Core::test.css' => 'Magento_Core::test.css', + 'Magento_Theme::test.css' => 'Magento_Theme::test.css', 'test.css' => 'test.css', 'testh.css' => 'testh.css', ], diff --git a/app/code/Magento/Theme/Test/Unit/Model/CopyServiceTest.php b/app/code/Magento/Theme/Test/Unit/Model/CopyServiceTest.php index 345dce2e805096d552f37a6a1d20d0ba1b40a3b2..ac449f10946e47e1112a59ebf9d8e2ea08bd2876 100644 --- a/app/code/Magento/Theme/Test/Unit/Model/CopyServiceTest.php +++ b/app/code/Magento/Theme/Test/Unit/Model/CopyServiceTest.php @@ -3,6 +3,9 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ + +// @codingStandardsIgnoreFile + namespace Magento\Theme\Test\Unit\Model; use Magento\Framework\App\Filesystem\DirectoryList; @@ -171,7 +174,7 @@ class CopyServiceTest extends \PHPUnit_Framework_TestCase $this->returnValue($this->dirWriteMock) ); - /* Init \Magento\Core\Model\Resource\Layout\Collection model */ + /* Init \Magento\Widget\Model\Resource\Layout\Update\Collection model */ $this->updateFactory = $this->getMock( 'Magento\Widget\Model\Layout\UpdateFactory', ['create'], @@ -460,6 +463,8 @@ class CopyServiceTest extends \PHPUnit_Framework_TestCase /** * cover \Magento\Theme\Model\CopyService::_copyFilesystemCustomization + * + * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ public function testCopyFilesystemCustomization() { diff --git a/app/code/Magento/Theme/Test/Unit/Model/PageLayout/Config/BuilderTest.php b/app/code/Magento/Theme/Test/Unit/Model/PageLayout/Config/BuilderTest.php new file mode 100755 index 0000000000000000000000000000000000000000..5d7df0ddef1b49bcff03747c1fbfafecfc904d5a --- /dev/null +++ b/app/code/Magento/Theme/Test/Unit/Model/PageLayout/Config/BuilderTest.php @@ -0,0 +1,110 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +/** + * Test theme page layout config model + */ +namespace Magento\Theme\Test\Unit\Model\PageLayout\Config; + +class BuilderTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var Builder + */ + protected $builder; + + /** + * @var \Magento\Framework\View\PageLayout\ConfigFactory|\PHPUnit_Framework_MockObject_MockObject + */ + protected $configFactory; + + /** + * @var \Magento\Framework\View\PageLayout\File\Collector\Aggregated|\PHPUnit_Framework_MockObject_MockObject + */ + protected $fileCollector; + + /** + * @var \Magento\Theme\Model\Resource\Theme\Collection|\PHPUnit_Framework_MockObject_MockObject + */ + protected $themeCollection; + + /** + * SetUp method + * + * @return void + */ + protected function setUp() + { + $this->configFactory = $this->getMockBuilder('Magento\Framework\View\PageLayout\ConfigFactory') + ->disableOriginalConstructor() + ->setMethods(['create']) + ->getMock(); + + $this->fileCollector = $this->getMockBuilder('Magento\Framework\View\PageLayout\File\Collector\Aggregated') + ->disableOriginalConstructor() + ->getMock(); + + $this->themeCollection = $this->getMockBuilder('Magento\Theme\Model\Resource\Theme\Collection') + ->disableOriginalConstructor() + ->getMock(); + $this->themeCollection->expects($this->once()) + ->method('setItemObjectClass') + ->with('Magento\Theme\Model\Theme\Data') + ->willReturnSelf(); + + $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); + $this->builder = $helper->getObject( + 'Magento\Theme\Model\PageLayout\Config\Builder', + [ + 'configFactory' => $this->configFactory, + 'fileCollector' => $this->fileCollector, + 'themeCollection' => $this->themeCollection + ] + ); + } + + /** + * Test get page layouts config + * + * @return void + */ + public function testGetPageLayoutsConfig() + { + $files1 = ['content layouts_1.xml', 'content layouts_2.xml']; + $files2 = ['content layouts_3.xml', 'content layouts_4.xml']; + + $theme1 = $this->getMockBuilder('Magento\Theme\Model\Theme\Data') + ->disableOriginalConstructor() + ->getMock(); + $theme2 = $this->getMockBuilder('Magento\Theme\Model\Theme\Data') + ->disableOriginalConstructor() + ->getMock(); + + $this->themeCollection->expects($this->any()) + ->method('loadRegisteredThemes') + ->willReturn([$theme1, $theme2]); + + $this->fileCollector->expects($this->exactly(2)) + ->method('getFilesContent') + ->willReturnMap( + [ + [$theme1, 'layouts.xml', $files1], + [$theme2, 'layouts.xml', $files2] + ] + ); + + $config = $this->getMockBuilder('Magento\Framework\View\PageLayout\Config') + ->disableOriginalConstructor() + ->getMock(); + + $this->configFactory->expects($this->once()) + ->method('create') + ->with(['configFiles' => array_merge($files1, $files2)]) + ->willReturn($config); + + $this->assertSame($config, $this->builder->getPageLayoutsConfig()); + } +} diff --git a/app/code/Magento/Core/Test/Unit/Model/_files/frontend/magento_iphone/theme.xml b/app/code/Magento/Theme/Test/Unit/Model/_files/frontend/magento_iphone/theme.xml similarity index 100% rename from app/code/Magento/Core/Test/Unit/Model/_files/frontend/magento_iphone/theme.xml rename to app/code/Magento/Theme/Test/Unit/Model/_files/frontend/magento_iphone/theme.xml diff --git a/app/code/Magento/Core/Test/Unit/Model/_files/frontend/magento_iphone/theme_invalid.xml b/app/code/Magento/Theme/Test/Unit/Model/_files/frontend/magento_iphone/theme_invalid.xml similarity index 100% rename from app/code/Magento/Core/Test/Unit/Model/_files/frontend/magento_iphone/theme_invalid.xml rename to app/code/Magento/Theme/Test/Unit/Model/_files/frontend/magento_iphone/theme_invalid.xml diff --git a/app/code/Magento/Theme/composer.json b/app/code/Magento/Theme/composer.json index f6aaacab3492dca03a1a3b2aea9bd125a7e21437..55d1d0974c5e76385343b32781bfc3a5bf2e2784 100644 --- a/app/code/Magento/Theme/composer.json +++ b/app/code/Magento/Theme/composer.json @@ -4,7 +4,6 @@ "require": { "php": "~5.5.0|~5.6.0", "magento/module-store": "0.42.0-beta11", - "magento/module-core": "0.42.0-beta11", "magento/module-customer": "0.42.0-beta11", "magento/module-backend": "0.42.0-beta11", "magento/module-cms": "0.42.0-beta11", diff --git a/app/code/Magento/Theme/etc/config.xml b/app/code/Magento/Theme/etc/config.xml index e6f790127c4714ac4299fcfb08eecc31f3732b9e..643a69777e24aadbb2e9c79ba4e157795b0c8811 100644 --- a/app/code/Magento/Theme/etc/config.xml +++ b/app/code/Magento/Theme/etc/config.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Core/etc/config.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Store/etc/config.xsd"> <default> <design> <head translate="default_description"> diff --git a/app/code/Magento/Theme/etc/module.xml b/app/code/Magento/Theme/etc/module.xml index 30b3857eac7e968aa5d74f380132d0bac84934bf..e6744b59cb8c2f7c3e27117b3e1bac698c035985 100644 --- a/app/code/Magento/Theme/etc/module.xml +++ b/app/code/Magento/Theme/etc/module.xml @@ -8,7 +8,6 @@ <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd"> <module name="Magento_Theme" setup_version="2.0.1"> <sequence> - <module name="Magento_Core"/> <module name="Magento_Store"/> </sequence> </module> diff --git a/app/code/Magento/Theme/i18n/de_DE.csv b/app/code/Magento/Theme/i18n/de_DE.csv index f94c143a9686ab7fe2a78f66b3bbb42def67285a..9ddaaa6a018d2d00c8c04113bd7028bef6f579c6 100644 --- a/app/code/Magento/Theme/i18n/de_DE.csv +++ b/app/code/Magento/Theme/i18n/de_DE.csv @@ -135,3 +135,8 @@ Copyright,Copyright "2 columns with right bar","2 Spalten mit rechter Leiste" "3 columns","3 Spalten" "Skip to content","Skip to content" +"Invalid regular expression: ""%1"".","Invalid regular expression: ""%1""." +"Start date cannot be greater than end date.","Das Anfangsdatum darf nicht nach dem Enddatum liegen." +"Your design change for the specified store intersects with another one, please specify another date range.","Ihre Design-Änderung für den ausgewählten Store überschneidet sich mit einer anderen, bitte wählen Sie einen anderen Zeitraum." +Copy,Copy +"Circular-reference in theme inheritance detected for ""%1""","Circular-reference in theme inheritance detected for ""%1""" diff --git a/app/code/Magento/Theme/i18n/en_US.csv b/app/code/Magento/Theme/i18n/en_US.csv index 4c98001e69bfe1572a7976f2ebe48d582ee71105..f95ee406e76baa20811c5c1907af603b1be44df9 100644 --- a/app/code/Magento/Theme/i18n/en_US.csv +++ b/app/code/Magento/Theme/i18n/en_US.csv @@ -135,3 +135,8 @@ Copyright,Copyright "2 columns with right bar","2 columns with right bar" "3 columns","3 columns" "Skip to content","Skip to content" +"Invalid regular expression: ""%1"".","Invalid regular expression: ""%1""." +"Start date cannot be greater than end date.","Start date cannot be greater than end date." +"Your design change for the specified store intersects with another one, please specify another date range.","Your design change for the specified store intersects with another one, please specify another date range." +Copy,Copy +"Circular-reference in theme inheritance detected for ""%1""","Circular-reference in theme inheritance detected for ""%1""" diff --git a/app/code/Magento/Theme/i18n/es_ES.csv b/app/code/Magento/Theme/i18n/es_ES.csv index 1a4040a9d1cb87410018cf9ce43491ebbf0322c6..7a46dedc66d9d59affa3a794493f078a16c87e6d 100644 --- a/app/code/Magento/Theme/i18n/es_ES.csv +++ b/app/code/Magento/Theme/i18n/es_ES.csv @@ -135,3 +135,8 @@ Copyright,Copyright "2 columns with right bar","2 columnas con barra a la derecha" "3 columns","3 columnas" "Skip to content","Skip to content" +"Invalid regular expression: ""%1"".","Invalid regular expression: ""%1""." +"Start date cannot be greater than end date.","La fecha de inicio no puede ser mayor que la de fin." +"Your design change for the specified store intersects with another one, please specify another date range.","Su cambio de diseño para la tienda especificada se superpone con otro. Especifique otro rango de fecha." +Copy,Copy +"Circular-reference in theme inheritance detected for ""%1""","Circular-reference in theme inheritance detected for ""%1""" diff --git a/app/code/Magento/Theme/i18n/fr_FR.csv b/app/code/Magento/Theme/i18n/fr_FR.csv index 62ff62757e9afd534ca8ac33d31dfb84a3e59a0a..3747f950596d312e4e1f0a11d2c5d8849a88b4d7 100644 --- a/app/code/Magento/Theme/i18n/fr_FR.csv +++ b/app/code/Magento/Theme/i18n/fr_FR.csv @@ -135,3 +135,8 @@ Copyright,Copyright "2 columns with right bar","2 colonnes avec barre droite" "3 columns","3 colonnes" "Skip to content","Skip to content" +"Invalid regular expression: ""%1"".","Invalid regular expression: ""%1""." +"Start date cannot be greater than end date.","La date de début ne peut pas être après la date de fin." +"Your design change for the specified store intersects with another one, please specify another date range.","Votre changement de dessin pour la boutique spécifiée se mélange à une autre, veuillez spécifier une autre fourchette de dates." +Copy,Copy +"Circular-reference in theme inheritance detected for ""%1""","Circular-reference in theme inheritance detected for ""%1""" diff --git a/app/code/Magento/Theme/i18n/nl_NL.csv b/app/code/Magento/Theme/i18n/nl_NL.csv index ccd1f5f63163a0157c5ec117af651680df90fe9d..d5197adbe59b97f1dc56295548afa765cad56feb 100644 --- a/app/code/Magento/Theme/i18n/nl_NL.csv +++ b/app/code/Magento/Theme/i18n/nl_NL.csv @@ -135,3 +135,8 @@ Copyright,Copyright "2 columns with right bar","2 kolommen met rechterbalk" "3 columns","3 kolommen" "Skip to content","Skip to content" +"Invalid regular expression: ""%1"".","Invalid regular expression: ""%1""." +"Start date cannot be greater than end date.","Begin datum kan niet later zijn dan eind datum." +"Your design change for the specified store intersects with another one, please specify another date range.","Uw ontwerp verandering voor de gespecificeerde store komt in conflict met een andere, specificeer a.u.b. een andere datumrange." +Copy,Copy +"Circular-reference in theme inheritance detected for ""%1""","Circular-reference in theme inheritance detected for ""%1""" diff --git a/app/code/Magento/Theme/i18n/pt_BR.csv b/app/code/Magento/Theme/i18n/pt_BR.csv index 0077e120ba4baa381f81b939acf52d96e6fcafb2..94aee8c839430e4a3704054cc9409b18b4f471d5 100644 --- a/app/code/Magento/Theme/i18n/pt_BR.csv +++ b/app/code/Magento/Theme/i18n/pt_BR.csv @@ -135,3 +135,8 @@ Copyright,Copyright "2 columns with right bar","2 colunas com barra à direita" "3 columns","3 colunas" "Skip to content","Skip to content" +"Invalid regular expression: ""%1"".","Invalid regular expression: ""%1""." +"Start date cannot be greater than end date.","Data de inÃcio não pode ser maior que a data do término." +"Your design change for the specified store intersects with another one, please specify another date range.","Sua mudança de design para a loja especificada cruza com outra, por favor especifique outro intervalo de datas." +Copy,Copy +"Circular-reference in theme inheritance detected for ""%1""","Circular-reference in theme inheritance detected for ""%1""" diff --git a/app/code/Magento/Theme/i18n/zh_CN.csv b/app/code/Magento/Theme/i18n/zh_CN.csv index da8737f17e11a5d9698c184561a38ac90e349abe..603295168ee776fac9e4f7eb8a611971c2e13ef5 100644 --- a/app/code/Magento/Theme/i18n/zh_CN.csv +++ b/app/code/Magento/Theme/i18n/zh_CN.csv @@ -135,3 +135,8 @@ Copyright,Copyright "2 columns with right bar",2æ 带å³è¾¹æ "3 columns",3æ "Skip to content","Skip to content" +"Invalid regular expression: ""%1"".","Invalid regular expression: ""%1""." +"Start date cannot be greater than end date.",开始日期ä¸èƒ½å¤§äºŽç»“æŸæ—¥æœŸã€‚ +"Your design change for the specified store intersects with another one, please specify another date range.",您对指定商店设计的更改和å¦ä¸€ä¸ªæœ‰äº¤å‰ï¼Œè¯·é‡æ–°æŒ‡å®šæ—¥æœŸèŒƒå›´ã€‚ +Copy,Copy +"Circular-reference in theme inheritance detected for ""%1""","Circular-reference in theme inheritance detected for ""%1""" diff --git a/app/code/Magento/Translation/Block/Js.php b/app/code/Magento/Translation/Block/Js.php index dcf8f7156231b72655edf18db7832d47e7c02f16..f79360f534bab736536bdadb8a99d31c3809cb96 100644 --- a/app/code/Magento/Translation/Block/Js.php +++ b/app/code/Magento/Translation/Block/Js.php @@ -6,50 +6,37 @@ namespace Magento\Translation\Block; -use Magento\Framework\Translate\InlineInterface as InlineTranslator; -use Magento\Translation\Model\Js as DataProvider; use Magento\Framework\View\Element\Template; +use Magento\Translation\Model\Js\Config; -class Js extends \Magento\Framework\View\Element\Template +class Js extends Template { /** - * Data provider model - * - * @var DataProvider - */ - protected $dataProvider; - - /** - * Inline translator - * - * @var InlineTranslator + * @var Config */ - protected $translateInline; + protected $config; /** * @param Template\Context $context - * @param DataProvider $dataProvider - * @param InlineTranslator $translateInline + * @param Config $config * @param array $data */ public function __construct( Template\Context $context, - DataProvider $dataProvider, - InlineTranslator $translateInline, + Config $config, array $data = [] ) { parent::__construct($context, $data); - $this->dataProvider = $dataProvider; - $this->translateInline = $translateInline; + $this->config = $config; } /** - * @return string + * Is js translation set to dictionary mode + * + * @return bool */ - public function getTranslatedJson() + public function dictionaryEnabled() { - $data = $this->dataProvider->getTranslateData(); - $this->translateInline->processResponseBody($data); - return \Zend_Json::encode($data); + return $this->config->dictionaryEnabled(); } } diff --git a/app/code/Magento/Translation/Model/Js.php b/app/code/Magento/Translation/Model/Js.php deleted file mode 100644 index ca4bc45b96058712719e24c223c78dec3e8dcd38..0000000000000000000000000000000000000000 --- a/app/code/Magento/Translation/Model/Js.php +++ /dev/null @@ -1,42 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -namespace Magento\Translation\Model; - -class Js -{ - /** - * Translation data - * - * @var string[] - */ - protected $translateData; - - /** - * @param Js\DataProviderInterface[] $dataProviders - */ - public function __construct(array $dataProviders) - { - /** @var $dataProvider Js\DataProviderInterface */ - foreach ($dataProviders as $dataProvider) { - foreach ($dataProvider->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/Config.php b/app/code/Magento/Translation/Model/Js/Config.php new file mode 100644 index 0000000000000000000000000000000000000000..6dc1abb699d9acdc90d6325fad535150d4b09187 --- /dev/null +++ b/app/code/Magento/Translation/Model/Js/Config.php @@ -0,0 +1,98 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Translation\Model\Js; + +use Magento\Framework\Translate\Js\Config as FrameworkJsConfig; +use Magento\Framework\App\Config\ScopeConfigInterface; + +/** + * Js Translation config + */ +class Config extends FrameworkJsConfig +{ + /** + * Both translation strategies are disabled + */ + const NO_TRANSLATION = 'none'; + + /** + * Strategy when all js files are translated while publishing + */ + const EMBEDDED_STRATEGY = 'embedded'; + + /** + * Strategy when dictionary is generated for dynamic translation + */ + const DICTIONARY_STRATEGY = 'dictionary'; + + /** + * Configuration path to translation strategy + */ + const XML_PATH_STRATEGY = 'dev/js/translate_strategy'; + + /** + * Dictionary file name + */ + const DICTIONARY_FILE_NAME = 'js-translation.json'; + + /** + * Core store config + * + * @var ScopeConfigInterface + */ + protected $scopeConfig; + + /** + * Patterns to match strings for translation + * + * @var string[] + */ + protected $patterns; + + /** + * @param ScopeConfigInterface $scopeConfig + * @param string[] $patterns + */ + public function __construct(ScopeConfigInterface $scopeConfig, array $patterns) + { + $this->scopeConfig = $scopeConfig; + $this->patterns = $patterns; + parent::__construct( + $this->scopeConfig->getValue(self::XML_PATH_STRATEGY) == self::DICTIONARY_STRATEGY, + self::DICTIONARY_FILE_NAME + ); + } + + /** + * Is Embedded Strategy selected + * + * @return bool + */ + public function isEmbeddedStrategy() + { + return ($this->scopeConfig->getValue(self::XML_PATH_STRATEGY) == self::EMBEDDED_STRATEGY); + } + + /** + * Is Dictionary Strategy selected + * + * @return bool + */ + public function dictionaryEnabled() + { + return ($this->scopeConfig->getValue(self::XML_PATH_STRATEGY) == self::DICTIONARY_STRATEGY); + } + + /** + * Retrieve translation patterns + * + * @return string[] + */ + public function getPatterns() + { + return $this->patterns; + } +} diff --git a/app/code/Magento/Translation/Model/Js/Config/Source/Strategy.php b/app/code/Magento/Translation/Model/Js/Config/Source/Strategy.php new file mode 100644 index 0000000000000000000000000000000000000000..30f1b0fe8e9a01fb9838002561820e11986c43cc --- /dev/null +++ b/app/code/Magento/Translation/Model/Js/Config/Source/Strategy.php @@ -0,0 +1,23 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Translation\Model\Js\Config\Source; + +use Magento\Translation\Model\Js\Config; + +class Strategy implements \Magento\Framework\Option\ArrayInterface +{ + /** + * {@inheritdoc} + */ + public function toOptionArray() + { + return [ + ['label' => __('None (Translation is disabled)'), 'value' => Config::NO_TRANSLATION], + ['label' => __('Dictionary (Translation on frontend side)'), 'value' => Config::DICTIONARY_STRATEGY], + ['label' => __('Embedded (Translation on backend side)'), 'value' => Config::EMBEDDED_STRATEGY] + ]; + } +} diff --git a/app/code/Magento/Translation/Model/Js/DataProvider.php b/app/code/Magento/Translation/Model/Js/DataProvider.php index 317dc602a3c7abc55998972f72d9b9f4b8450027..a9a83fcf8d6b35d942c43313f9d6204f2c087577 100644 --- a/app/code/Magento/Translation/Model/Js/DataProvider.php +++ b/app/code/Magento/Translation/Model/Js/DataProvider.php @@ -4,164 +4,109 @@ * See COPYING.txt for license details. */ -// @codingStandardsIgnoreFile - namespace Magento\Translation\Model\Js; +use Magento\Framework\App\Utility\Files; +use Magento\Framework\App\State; +use Magento\Framework\Filesystem; +use Magento\Framework\Filesystem\Directory\ReadInterface; +use Magento\Framework\App\Filesystem\DirectoryList; + +/** + * DataProvider for js translation + */ class DataProvider implements DataProviderInterface { + /** + * Application state + * + * @var State + */ + protected $appState; + + /** + * Js translation configuration + * + * @var Config + */ + protected $config; + + /** + * Files utility + * + * @var Files + */ + protected $filesUtility; + + /** + * Filesystem + * + * @var ReadInterface + */ + protected $rootDirectory; + + /** + * @param State $appState + * @param Config $config + * @param Filesystem $filesystem + * @param Files $filesUtility + */ + public function __construct(State $appState, Config $config, Filesystem $filesystem, Files $filesUtility = null) + { + $this->appState = $appState; + $this->config = $config; + $this->rootDirectory = $filesystem->getDirectoryRead(DirectoryList::ROOT); + $this->filesUtility = (null !== $filesUtility) ? $filesUtility : new Files(BP); + } + /** * Get translation data * + * @param string $themePath * @return string[] - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) + * @throws \Exception + * @throws \Magento\Framework\Exception */ - public function getData() + public function getData($themePath) { - return [ - 'Complete' => __('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.'), - 'Edit Order' => __('Edit Order'), - 'Ok' => __('Ok'), - 'Please specify at least one search term.' => __('Please specify at least one search term.'), - 'Create New Wish List' => __('Create New Wish List'), - 'Click Details for more required fields.' => __('Click Details for more required fields.'), - 'Incl. Tax' => __('Incl. Tax'), - ]; + $dictionary = []; + + $files = $this->filesUtility->getJsFiles($this->appState->getAreaCode(), $themePath); + foreach ($files as $filePath) { + $content = $this->rootDirectory->readFile($this->rootDirectory->getRelativePath($filePath[0])); + foreach ($this->getPhrases($content) as $phrase) { + $translatedPhrase = (string) __($phrase); + if ($phrase != $translatedPhrase) { + $dictionary[$phrase] = $translatedPhrase; + } + } + } + + return $dictionary; + } + + /** + * Parse content for entries to be translated + * + * @param string $content + * @return string[] + * @throws \Exception + */ + protected function getPhrases($content) + { + $phrases = []; + foreach ($this->config->getPatterns() as $pattern) { + $result = preg_match_all($pattern, $content, $matches); + + if ($result) { + $phrases = array_merge($phrases, $matches[1]); + } + if (false === $result) { + throw new \Exception( + sprintf('Error while generating js translation dictionary: "%s"', error_get_last()) + ); + } + } + return $phrases; } } diff --git a/app/code/Magento/Translation/Model/Js/DataProviderInterface.php b/app/code/Magento/Translation/Model/Js/DataProviderInterface.php index 74231b2ccdd959b4d50454d381121c80c7cb82bd..d9eea098e56b1e4102ba5f49b8882e9b325138f6 100644 --- a/app/code/Magento/Translation/Model/Js/DataProviderInterface.php +++ b/app/code/Magento/Translation/Model/Js/DataProviderInterface.php @@ -10,8 +10,8 @@ interface DataProviderInterface { /** * Get translation data - * + * @param string $themePath * @return string[] */ - public function getData(); + public function getData($themePath); } diff --git a/app/code/Magento/Translation/Model/Js/PreProcessor.php b/app/code/Magento/Translation/Model/Js/PreProcessor.php new file mode 100644 index 0000000000000000000000000000000000000000..d7da55fbd50ef2d263c1b29a682d1460774da2c3 --- /dev/null +++ b/app/code/Magento/Translation/Model/Js/PreProcessor.php @@ -0,0 +1,69 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Translation\Model\Js; + +use Magento\Framework\View\Asset\PreProcessorInterface; +use Magento\Framework\View\Asset\PreProcessor\Chain; +use Magento\Framework\Filesystem; + +/** + * PreProcessor responsible for replacing translation calls in js files to translated strings + */ +class PreProcessor implements PreProcessorInterface +{ + /** + * Javascript translation configuration + * + * @var Config + */ + protected $config; + + /** + * @param Config $config + */ + public function __construct(Config $config) + { + $this->config = $config; + } + + /** + * Transform content and/or content type for the specified preprocessing chain object + * + * @param Chain $chain + * @return void + */ + public function process(Chain $chain) + { + if ($this->config->isEmbeddedStrategy()) { + $chain->setContent($this->translate($chain->getContent())); + } + } + + /** + * Replace translation calls with translation result and return content + * + * @param string $content + * @return string + */ + public function translate($content) + { + foreach ($this->config->getPatterns() as $pattern) { + $content = preg_replace_callback($pattern, [$this, 'replaceCallback'], $content); + } + return $content; + } + + /** + * Replace callback for preg_replace_callback function + * + * @param array $matches + * @return string + */ + protected function replaceCallback($matches) + { + return '"' . __($matches[1]) . '"'; + } +} diff --git a/app/code/Magento/Translation/Model/Json/PreProcessor.php b/app/code/Magento/Translation/Model/Json/PreProcessor.php new file mode 100644 index 0000000000000000000000000000000000000000..79c4ad0ccef842037f191f7f7f41e59f17c7ba8e --- /dev/null +++ b/app/code/Magento/Translation/Model/Json/PreProcessor.php @@ -0,0 +1,71 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Translation\Model\Json; + +use Magento\Framework\View\Asset\PreProcessorInterface; +use Magento\Translation\Model\Js\Config; +use Magento\Translation\Model\Js\DataProviderInterface; +use Magento\Framework\View\Asset\PreProcessor\Chain; +use Magento\Framework\View\Asset\File\FallbackContext; + +/** + * PreProcessor responsible for providing js translation dictionary + */ +class PreProcessor implements PreProcessorInterface +{ + /** + * Js translation configuration + * + * @var Config + */ + protected $config; + + /** + * Translation data provider + * + * @var DataProviderInterface + */ + protected $dataProvider; + + /** + * @param Config $config + * @param DataProviderInterface $dataProvider + */ + public function __construct( + Config $config, + DataProviderInterface $dataProvider + ) { + $this->config = $config; + $this->dataProvider = $dataProvider; + } + + /** + * Transform content and/or content type for the specified preprocessing chain object + * + * @param Chain $chain + * @return void + */ + public function process(Chain $chain) + { + if ($this->isDictionaryPath($chain->getTargetAssetPath())) { + $context = $chain->getAsset()->getContext(); + $themePath = ($context instanceof FallbackContext) ? $context->getThemePath() : '*/*'; + $chain->setContent(json_encode($this->dataProvider->getData($themePath))); + $chain->setContentType('json'); + } + } + + /** + * Is provided path the path to translation dictionary + * + * @param string $path + * @return bool + */ + protected function isDictionaryPath($path) + { + return (strpos($path, $this->config->getDictionaryFileName()) !== false); + } +} diff --git a/app/code/Magento/Translation/Test/Unit/Block/JsTest.php b/app/code/Magento/Translation/Test/Unit/Block/JsTest.php new file mode 100644 index 0000000000000000000000000000000000000000..b929b7304568653dc1fe484408b1c5acae29896e --- /dev/null +++ b/app/code/Magento/Translation/Test/Unit/Block/JsTest.php @@ -0,0 +1,38 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Translation\Test\Unit\Block; + +use Magento\Translation\Block\Js; + +class JsTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var Js + */ + protected $model; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $configMock; + + protected function setUp() + { + $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); + $this->configMock = $this->getMockBuilder('Magento\Translation\Model\Js\Config') + ->disableOriginalConstructor() + ->getMock(); + $this->model = $objectManager->getObject('Magento\Translation\Block\Js', ['config' => $this->configMock]); + } + + public function testIsDictionaryStrategy() + { + $this->configMock->expects($this->once()) + ->method('dictionaryEnabled') + ->willReturn(true); + $this->assertTrue($this->model->dictionaryEnabled()); + } +} diff --git a/app/code/Magento/Translation/Test/Unit/Model/Js/Config/Source/StrategyTest.php b/app/code/Magento/Translation/Test/Unit/Model/Js/Config/Source/StrategyTest.php new file mode 100644 index 0000000000000000000000000000000000000000..819d41663235c2739692804db7a98c97b363e207 --- /dev/null +++ b/app/code/Magento/Translation/Test/Unit/Model/Js/Config/Source/StrategyTest.php @@ -0,0 +1,44 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Translation\Test\Unit\Model\Js\Config\Source; + +use Magento\Translation\Model\Js\Config; +use Magento\Translation\Model\Js\Config\Source\Strategy; + +/** + * Class StrategyTest + */ +class StrategyTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var Strategy + */ + protected $model; + + /** + * Set up + * @return void + */ + protected function setUp() + { + $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); + $this->model = $objectManager->getObject('Magento\Translation\Model\Js\Config\Source\Strategy'); + } + + /** + * Test for toOptionArray method + * @return void + */ + public function testToOptionArray() + { + $expected = [ + ['label' => __('None (Translation is disabled)'), 'value' => Config::NO_TRANSLATION], + ['label' => 'Dictionary (Translation on frontend side)', 'value' => Config::DICTIONARY_STRATEGY], + ['label' => 'Embedded (Translation on backend side)', 'value' => Config::EMBEDDED_STRATEGY] + ]; + $this->assertEquals($expected, $this->model->toOptionArray()); + } +} diff --git a/app/code/Magento/Translation/Test/Unit/Model/Js/ConfigTest.php b/app/code/Magento/Translation/Test/Unit/Model/Js/ConfigTest.php new file mode 100644 index 0000000000000000000000000000000000000000..a0c1e59c1d3e7ca8dd2eb94a94d8dfacb75ab04f --- /dev/null +++ b/app/code/Magento/Translation/Test/Unit/Model/Js/ConfigTest.php @@ -0,0 +1,64 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Translation\Test\Unit\Model\Js; + +use Magento\Translation\Model\Js\Config; + +class ConfigTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var Config + */ + protected $model; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $scopeMock; + + /** + * @var string + */ + protected $patterns = ['test_pattern']; + + protected function setUp() + { + $this->scopeMock = $this->getMockBuilder('Magento\Framework\App\Config\ScopeConfigInterface') + ->disableOriginalConstructor() + ->getMock(); + $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); + $this->model = $objectManager->getObject( + 'Magento\Translation\Model\Js\Config', + [ + 'scopeConfig' => $this->scopeMock, + 'patterns' => $this->patterns + ] + ); + } + + public function testIsEmbeddedStrategy() + { + $this->scopeMock->expects($this->once()) + ->method('getValue') + ->with(Config::XML_PATH_STRATEGY) + ->willReturn(Config::EMBEDDED_STRATEGY); + $this->assertTrue($this->model->isEmbeddedStrategy()); + } + + public function testDictionaryEnabled() + { + $this->scopeMock->expects($this->once()) + ->method('getValue') + ->with(Config::XML_PATH_STRATEGY) + ->willReturn(Config::DICTIONARY_STRATEGY); + $this->assertTrue($this->model->dictionaryEnabled()); + } + + public function testgetPatterns() + { + $this->assertEquals($this->patterns, $this->model->getPatterns()); + } +} diff --git a/app/code/Magento/Translation/Test/Unit/Model/Js/DataProviderTest.php b/app/code/Magento/Translation/Test/Unit/Model/Js/DataProviderTest.php new file mode 100644 index 0000000000000000000000000000000000000000..6067c28723fb4eb764f5e2b26167a984ad9b173e --- /dev/null +++ b/app/code/Magento/Translation/Test/Unit/Model/Js/DataProviderTest.php @@ -0,0 +1,108 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Translation\Test\Unit\Model\Js; + +use Magento\Framework\App\State; +use Magento\Framework\App\Utility\Files; +use Magento\Framework\Filesystem; +use Magento\Framework\Filesystem\Directory\ReadInterface; +use Magento\Framework\App\Filesystem\DirectoryList; +use Magento\Translation\Model\Js\DataProvider; +use Magento\Translation\Model\Js\Config; + +/** + * Class DataProviderTest + */ +class DataProviderTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var DataProvider + */ + protected $model; + + /** + * @var State|\PHPUnit_Framework_MockObject_MockObject + */ + protected $appStateMock; + + /** + * @var Config|\PHPUnit_Framework_MockObject_MockObject + */ + protected $configMock; + + /** + * @var Files|\PHPUnit_Framework_MockObject_MockObject + */ + protected $filesUtilityMock; + + /** + * @var ReadInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $rootDirectoryMock; + + /** + * @return void + */ + protected function setUp() + { + $this->appStateMock = $this->getMock('Magento\Framework\App\State', [], [], '', false); + $this->configMock = $this->getMock('Magento\Translation\Model\Js\Config', [], [], '', false); + $this->filesUtilityMock = $this->getMock('Magento\Framework\App\Utility\Files', [], [], '', false); + $filesystem = $this->getMock('Magento\Framework\Filesystem', [], [], '', false); + $this->rootDirectoryMock = $this->getMock('Magento\Framework\Filesystem\Directory\Read', [], [], '', false); + $filesystem->expects($this->once()) + ->method('getDirectoryRead') + ->with(DirectoryList::ROOT) + ->willReturn($this->rootDirectoryMock); + $this->model = new DataProvider( + $this->appStateMock, + $this->configMock, + $filesystem, + $this->filesUtilityMock + ); + } + + /** + * @return void + */ + public function testGetData() + { + $themePath = 'blank'; + $areaCode = 'adminhtml'; + $files = [['path1'], ['path2']]; + + $relativePathMap = [ + ['path1' => 'relativePath1'], + ['path2' => 'relativePath2'] + ]; + $contentsMap = [ + ['relativePath1' => 'content1$.mage.__("hello1")content1'], + ['relativePath2' => 'content2$.mage.__("hello2")content2'] + ]; + + $patterns = ['~\$\.mage\.__\([\'|\"](.+?)[\'|\"]\)~']; + + $this->appStateMock->expects($this->once()) + ->method('getAreaCode') + ->willReturn($areaCode); + $this->filesUtilityMock->expects($this->once()) + ->method('getJsFiles') + ->with($areaCode, $themePath) + ->willReturn($files); + + $this->rootDirectoryMock->expects($this->any()) + ->method('getRelativePath') + ->willReturnMap($relativePathMap); + $this->rootDirectoryMock->expects($this->any()) + ->method('readFile') + ->willReturnMap($contentsMap); + $this->configMock->expects($this->any()) + ->method('getPatterns') + ->willReturn($patterns); + + $this->assertEquals([], $this->model->getData($themePath)); + } +} diff --git a/app/code/Magento/Translation/Test/Unit/Model/Js/PreProcessorTest.php b/app/code/Magento/Translation/Test/Unit/Model/Js/PreProcessorTest.php new file mode 100644 index 0000000000000000000000000000000000000000..2ccfbdafeb7c32842e9460fadc44a7aa61c80389 --- /dev/null +++ b/app/code/Magento/Translation/Test/Unit/Model/Js/PreProcessorTest.php @@ -0,0 +1,52 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Translation\Test\Unit\Model\Js; + +use Magento\Translation\Model\Js\PreProcessor; +use Magento\Translation\Model\Js\Config; + +class PreProcessorTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var PreProcessor + */ + protected $model; + + /** + * @var Config|\PHPUnit_Framework_MockObject_MockObject + */ + protected $configMock; + + protected function setUp() + { + $this->configMock = $this->getMock('Magento\Translation\Model\Js\Config', [], [], '', false); + $this->model = new PreProcessor($this->configMock); + } + + public function testGetData() + { + $chain = $this->getMock('Magento\Framework\View\Asset\PreProcessor\Chain', [], [], '', false); + $originalContent = 'content$.mage.__("hello1")content'; + $translatedContent = 'content"hello1"content'; + $patterns = ['~\$\.mage\.__\([\'|\"](.+?)[\'|\"]\)~']; + + $this->configMock->expects($this->once()) + ->method('isEmbeddedStrategy') + ->willReturn(true); + $chain->expects($this->once()) + ->method('getContent') + ->willReturn($originalContent); + $this->configMock->expects($this->once()) + ->method('getPatterns') + ->willReturn($patterns); + + $chain->expects($this->once()) + ->method('setContent') + ->with($translatedContent); + + $this->model->process($chain); + } +} diff --git a/app/code/Magento/Translation/Test/Unit/Model/Json/PreProcessorTest.php b/app/code/Magento/Translation/Test/Unit/Model/Json/PreProcessorTest.php new file mode 100644 index 0000000000000000000000000000000000000000..7b5e0fb2299b09aeb984eec7b80f43116f22f961 --- /dev/null +++ b/app/code/Magento/Translation/Test/Unit/Model/Json/PreProcessorTest.php @@ -0,0 +1,74 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Translation\Test\Unit\Model\Json; + +use Magento\Translation\Model\Js\Config; +use Magento\Translation\Model\Js\DataProvider; +use Magento\Translation\Model\Json\PreProcessor; + +class PreProcessorTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var PreProcessor + */ + protected $model; + + /** + * @var Config|\PHPUnit_Framework_MockObject_MockObject + */ + protected $configMock; + + /** + * @var DataProvider|\PHPUnit_Framework_MockObject_MockObject + */ + protected $dataProviderMock; + + protected function setUp() + { + $this->configMock = $this->getMock('Magento\Translation\Model\Js\Config', [], [], '', false); + $this->dataProviderMock = $this->getMock('Magento\Translation\Model\Js\DataProvider', [], [], '', false); + $this->model = new PreProcessor($this->configMock, $this->dataProviderMock); + } + + public function testGetData() + { + $chain = $this->getMock('Magento\Framework\View\Asset\PreProcessor\Chain', [], [], '', false); + $asset = $this->getMock('Magento\Framework\View\Asset\File', [], [], '', false); + $context = $this->getMock('Magento\Framework\View\Asset\File\FallbackContext', [], [], '', false); + $fileName = 'js-translation.json'; + $targetPath = 'path/js-translation.json'; + $themePath = '*/*'; + $dictionary = ['hello' => 'bonjour']; + + $chain->expects($this->once()) + ->method('getTargetAssetPath') + ->willReturn($targetPath); + $this->configMock->expects($this->once()) + ->method('getDictionaryFileName') + ->willReturn($fileName); + $chain->expects($this->once()) + ->method('getAsset') + ->willReturn($asset); + $asset->expects($this->once()) + ->method('getContext') + ->willReturn($context); + $context->expects($this->once()) + ->method('getThemePath') + ->willReturn($themePath); + $this->dataProviderMock->expects($this->once()) + ->method('getData') + ->with($themePath) + ->willReturn($dictionary); + $chain->expects($this->once()) + ->method('setContent') + ->with(json_encode($dictionary)); + $chain->expects($this->once()) + ->method('setContentType') + ->with('json'); + + $this->model->process($chain); + } +} diff --git a/app/code/Magento/Translation/etc/adminhtml/system.xml b/app/code/Magento/Translation/etc/adminhtml/system.xml new file mode 100644 index 0000000000000000000000000000000000000000..90d70e824ced6cd42cef19b0d51c39e32e5e08eb --- /dev/null +++ b/app/code/Magento/Translation/etc/adminhtml/system.xml @@ -0,0 +1,20 @@ +<?xml version="1.0"?> +<!-- +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../Config/etc/system_file.xsd"> + <system> + <section id="dev"> + <group id="js"> + <field id="translate_strategy" translate="label" type="select" sortOrder="30" showInDefault="1" showInWebsite="0" showInStore="0"> + <label>Translation Strategy</label> + <source_model>Magento\Translation\Model\Js\Config\Source\Strategy</source_model> + <comment>Please put your store into maintenance mode and redeploy static files after changing strategy</comment> + </field> + </group> + </section> + </system> +</config> diff --git a/app/code/Magento/Translation/etc/config.xml b/app/code/Magento/Translation/etc/config.xml index ae18303a6bc7320f54be043c77d802324d4d6d48..391f9c3fba00bb6e418872b533c82e13c6eaddb0 100644 --- a/app/code/Magento/Translation/etc/config.xml +++ b/app/code/Magento/Translation/etc/config.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Core/etc/config.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Store/etc/config.xsd"> <default> <dev> <translate_inline> @@ -15,6 +15,9 @@ <block_html /> </invalid_caches> </translate_inline> + <js> + <translate_strategy>none</translate_strategy> + </js> </dev> </default> </config> diff --git a/app/code/Magento/Translation/etc/di.xml b/app/code/Magento/Translation/etc/di.xml index 3507d99af6eec6b55fb3c2b7681e76f7510bdf34..c411e653425d197cc7fc4096d6426113ccd94aa1 100644 --- a/app/code/Magento/Translation/etc/di.xml +++ b/app/code/Magento/Translation/etc/di.xml @@ -13,6 +13,8 @@ <preference for="Magento\Framework\Translate\ResourceInterface" type="Magento\Translation\Model\Resource\Translate" /> <preference for="Magento\Framework\Translate\Inline\StateInterface" type="Magento\Framework\Translate\Inline\State" /> <preference for="Magento\Framework\Phrase\RendererInterface" type="Magento\Framework\Phrase\Renderer\Composite" /> + <preference for="Magento\Translation\Model\Js\DataProviderInterface" type="Magento\Translation\Model\Js\DataProvider"/> + <preference for="Magento\Framework\Translate\Js\Config" type="Magento\Translation\Model\Js\Config"/> <type name="Magento\Framework\Translate\Inline"> <arguments> <argument name="templateFileName" xsi:type="string">Magento_Translation::translate_inline.phtml</argument> @@ -52,4 +54,27 @@ </argument> </arguments> </type> + <type name="Magento\Translation\Model\Js\Config"> + <arguments> + <argument name="patterns" xsi:type="array"> + <item name="mage_translation_widget" xsi:type="string">~\$\.mage\.__\([\'|\"](.+?)[\'|\"]\)~</item> + </argument> + </arguments> + </type> + <type name="Magento\Framework\View\Asset\PreProcessor\Pool"> + <arguments> + <argument name="preProcessors" xsi:type="array"> + <item name="js" xsi:type="array"> + <item name="js" xsi:type="array"> + <item name="js_translation" xsi:type="string">Magento\Translation\Model\Js\PreProcessor</item> + </item> + </item> + <item name="json" xsi:type="array"> + <item name="json" xsi:type="array"> + <item name="json_generation" xsi:type="string">Magento\Translation\Model\Json\PreProcessor</item> + </item> + </item> + </argument> + </arguments> + </type> </config> diff --git a/app/code/Magento/Translation/etc/module.xml b/app/code/Magento/Translation/etc/module.xml index 0b973ed3ef7beaa4cb84e83e07e9debccd8bffba..669f8ae935645323723a5ea9e3732458e497f8dc 100644 --- a/app/code/Magento/Translation/etc/module.xml +++ b/app/code/Magento/Translation/etc/module.xml @@ -7,8 +7,5 @@ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd"> <module name="Magento_Translation" setup_version="2.0.0"> - <sequence> - <module name="Magento_Core"/> - </sequence> </module> </config> diff --git a/app/code/Magento/Translation/view/base/templates/translate.phtml b/app/code/Magento/Translation/view/base/templates/translate.phtml index be33473e166c7bb81300b8209fe7f11cda7654e3..d6c010e876528c017458f6af3c9734b10e47bce7 100644 --- a/app/code/Magento/Translation/view/base/templates/translate.phtml +++ b/app/code/Magento/Translation/view/base/templates/translate.phtml @@ -3,12 +3,17 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ +// @codingStandardsIgnoreFile ?> <?php /** @var $block \Magento\Translation\Block\Js */ ?> +<?php if ($block->dictionaryEnabled()): ?> <script> -//<![CDATA[ - require( - ["jquery", "mage/translate"], function($){ $.mage.translate.add( <?php echo $block->getTranslatedJson() ?> ); } - ) -// ]]> +require([ + "jquery", + "mage/translate", + "text!<?php echo Magento\Translation\Model\Js\Config::DICTIONARY_FILE_NAME?>" +], function($, translate, data) { + $.mage.translate.add(JSON.parse(data)); +}); </script> +<?php endif; ?> diff --git a/app/code/Magento/Ups/etc/config.xml b/app/code/Magento/Ups/etc/config.xml index 0ff0850998865dce77c0dad749fac8982e896b39..b3df7eabdde155e4811c5ae26695b7afdd28e2b5 100644 --- a/app/code/Magento/Ups/etc/config.xml +++ b/app/code/Magento/Ups/etc/config.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Core/etc/config.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Store/etc/config.xsd"> <default> <carriers> <ups> diff --git a/app/code/Magento/UrlRewrite/Controller/Router.php b/app/code/Magento/UrlRewrite/Controller/Router.php index ce2f31fc0d2a23af6fd36b0deb657e0c220a66dc..d6ae92b0f0e7700659f1e721237bb79287ce7936 100644 --- a/app/code/Magento/UrlRewrite/Controller/Router.php +++ b/app/code/Magento/UrlRewrite/Controller/Router.php @@ -85,6 +85,7 @@ class Router implements \Magento\Framework\App\RouterInterface return $this->processRedirect($request, $rewrite); } + $request->setAlias(\Magento\Framework\UrlInterface::REWRITE_REQUEST_PATH_ALIAS, $rewrite->getRequestPath()); $request->setPathInfo('/' . $rewrite->getTargetPath()); return $this->actionFactory->create('Magento\Framework\App\Action\Forward', ['request' => $request]); } diff --git a/app/code/Magento/UrlRewrite/Helper/UrlRewrite.php b/app/code/Magento/UrlRewrite/Helper/UrlRewrite.php index d293ddb124bd606bd15e2accbda26c96cbf296f6..185241b3f27378f0b9e909f4a85bb419cd95d65d 100644 --- a/app/code/Magento/UrlRewrite/Helper/UrlRewrite.php +++ b/app/code/Magento/UrlRewrite/Helper/UrlRewrite.php @@ -53,7 +53,7 @@ class UrlRewrite extends \Magento\Framework\App\Helper\AbstractHelper try { $this->_validateRequestPath($requestPath); } catch (\Exception $e) { - throw new \Magento\Framework\Exception\LocalizedException($e->getMessage()); + throw new \Magento\Framework\Exception\LocalizedException(__($e->getMessage())); } return true; } diff --git a/app/code/Magento/UrlRewrite/Service/V1/Data/UrlRewrite.php b/app/code/Magento/UrlRewrite/Service/V1/Data/UrlRewrite.php index 517babf6cde83e102b292977fef0d25339a1e59d..6bd75f0bcdff14bf119a145beb1443d42260fb29 100644 --- a/app/code/Magento/UrlRewrite/Service/V1/Data/UrlRewrite.php +++ b/app/code/Magento/UrlRewrite/Service/V1/Data/UrlRewrite.php @@ -5,14 +5,12 @@ */ namespace Magento\UrlRewrite\Service\V1\Data; -use Magento\Framework\Api\AbstractExtensibleObject; -use \Magento\Framework\Api\AttributeValueFactory; -use \Magento\Framework\Api\MetadataServiceInterface; +use Magento\Framework\Api\AbstractSimpleObject; /** * Data abstract class for url storage */ -class UrlRewrite extends AbstractExtensibleObject +class UrlRewrite extends AbstractSimpleObject { /**#@+ * Value object attribute names @@ -39,22 +37,6 @@ class UrlRewrite extends AbstractExtensibleObject self::DESCRIPTION => null, ]; - /** - * Initialize internal storage - * - * @param MetadataServiceInterface $metadataService - * @param AttributeValueFactory $attributeValueFactory - * @param array $data - */ - public function __construct( - MetadataServiceInterface $metadataService, - AttributeValueFactory $attributeValueFactory, - $data = [] - ) { - $data = array_merge($this->defaultValues, $data); - parent::__construct($metadataService, $attributeValueFactory, $data); - } - /** * Get data by key * @@ -124,7 +106,8 @@ class UrlRewrite extends AbstractExtensibleObject */ public function getIsAutogenerated() { - return $this->_get(self::IS_AUTOGENERATED); + return $this->_get(self::IS_AUTOGENERATED) === null ? + $this->defaultValues[self::IS_AUTOGENERATED] : $this->_get(self::IS_AUTOGENERATED); } /** @@ -256,6 +239,6 @@ class UrlRewrite extends AbstractExtensibleObject */ public function toArray() { - return $this->_data; + return array_merge($this->defaultValues, $this->_data); } } diff --git a/app/code/Magento/UrlRewrite/Test/Unit/Controller/RouterTest.php b/app/code/Magento/UrlRewrite/Test/Unit/Controller/RouterTest.php index 827d0b608c41d50d4018edf7d0d28bb63f50037a..67844a8956ffc4d634a3eb21aab8a993d17b73ae 100644 --- a/app/code/Magento/UrlRewrite/Test/Unit/Controller/RouterTest.php +++ b/app/code/Magento/UrlRewrite/Test/Unit/Controller/RouterTest.php @@ -252,8 +252,11 @@ class RouterTest extends \PHPUnit_Framework_TestCase ->disableOriginalConstructor()->getMock(); $urlRewrite->expects($this->any())->method('getRedirectType')->will($this->returnValue(0)); $urlRewrite->expects($this->any())->method('getTargetPath')->will($this->returnValue('target-path')); + $urlRewrite->expects($this->any())->method('getRequestPath')->will($this->returnValue('request-path')); $this->urlFinder->expects($this->any())->method('findOneByData')->will($this->returnValue($urlRewrite)); $this->request->expects($this->once())->method('setPathInfo')->with('/target-path'); + $this->request->expects($this->once())->method('setAlias') + ->with(\Magento\Framework\UrlInterface::REWRITE_REQUEST_PATH_ALIAS, 'request-path'); $this->actionFactory->expects($this->once())->method('create') ->with('Magento\Framework\App\Action\Forward', ['request' => $this->request]); diff --git a/app/code/Magento/UrlRewrite/etc/config.xml b/app/code/Magento/UrlRewrite/etc/config.xml index a174ec7abdd2bcf9bd418008f92a48ab6b3374f0..0179be80676ffaf771c3945882115a947e4bf62e 100644 --- a/app/code/Magento/UrlRewrite/etc/config.xml +++ b/app/code/Magento/UrlRewrite/etc/config.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Core/etc/config.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Store/etc/config.xsd"> <default> <url_rewrite> <entity_types> diff --git a/app/code/Magento/User/Controller/Adminhtml/Auth/ResetPasswordPost.php b/app/code/Magento/User/Controller/Adminhtml/Auth/ResetPasswordPost.php index 6160524ed20b1d894270556276ef4a8135a5de8b..834e5e19b0139bc183c8c872fd0b042b179e3609 100644 --- a/app/code/Magento/User/Controller/Adminhtml/Auth/ResetPasswordPost.php +++ b/app/code/Magento/User/Controller/Adminhtml/Auth/ResetPasswordPost.php @@ -45,7 +45,7 @@ class ResetPasswordPost extends \Magento\User\Controller\Adminhtml\Auth $this->getResponse()->setRedirect( $this->_objectManager->get('Magento\Backend\Helper\Data')->getHomePageUrl() ); - } catch (\Magento\Framework\Validator\ValidatorException $exception) { + } catch (\Magento\Framework\Validator\Exception $exception) { $this->messageManager->addMessages($exception->getMessages()); $this->_redirect( 'adminhtml/auth/resetpassword', diff --git a/app/code/Magento/User/Controller/Adminhtml/User/Save.php b/app/code/Magento/User/Controller/Adminhtml/User/Save.php index f472c97e0c5a6e48c0b1ac6c721b20038698f271..204b188822dbf8935ba57ccdacd7d8438deaf8be 100644 --- a/app/code/Magento/User/Controller/Adminhtml/User/Save.php +++ b/app/code/Magento/User/Controller/Adminhtml/User/Save.php @@ -62,7 +62,7 @@ class Save extends \Magento\User\Controller\Adminhtml\User $this->messageManager->addSuccess(__('You saved the user.')); $this->_getSession()->setUserData(false); $this->_redirect('adminhtml/*/'); - } catch (\Magento\Framework\Validator\ValidatorException $e) { + } catch (\Magento\Framework\Validator\Exception $e) { $messages = $e->getMessages(); $this->messageManager->addMessages($messages); $this->redirectToEdit($model, $data); diff --git a/app/code/Magento/User/Controller/Adminhtml/User/Validate.php b/app/code/Magento/User/Controller/Adminhtml/User/Validate.php index 847cae30712a88d7326417739f1ba732e688e2f0..bf4cddb3a7c0639b1338e41fb797631a9a8599be 100644 --- a/app/code/Magento/User/Controller/Adminhtml/User/Validate.php +++ b/app/code/Magento/User/Controller/Adminhtml/User/Validate.php @@ -25,7 +25,7 @@ class Validate extends \Magento\User\Controller\Adminhtml\User $model = $this->_userFactory->create()->load($userId); $model->setData($this->_getAdminUserData($data)); $errors = $model->validate(); - } catch (\Magento\Framework\Validator\ValidatorException $exception) { + } catch (\Magento\Framework\Validator\Exception $exception) { /* @var $error Error */ foreach ($exception->getMessages(\Magento\Framework\Message\MessageInterface::TYPE_ERROR) as $error) { $errors[] = $error->getText(); diff --git a/app/code/Magento/User/etc/config.xml b/app/code/Magento/User/etc/config.xml index 1496ade1d2170a7d9f73927ceded5ac24ab19265..6ef863af41a76d4c51389704d015394304001585 100644 --- a/app/code/Magento/User/etc/config.xml +++ b/app/code/Magento/User/etc/config.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Core/etc/config.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Store/etc/config.xsd"> <default> <admin> <emails> diff --git a/app/code/Magento/Usps/composer.json b/app/code/Magento/Usps/composer.json index be86d099ce9c69870617f49046995e24886cb319..41c06f2dbd0461bc65cb25993b566acbf0530d30 100644 --- a/app/code/Magento/Usps/composer.json +++ b/app/code/Magento/Usps/composer.json @@ -6,11 +6,11 @@ "magento/module-store": "0.42.0-beta11", "magento/module-shipping": "0.42.0-beta11", "magento/module-directory": "0.42.0-beta11", - "magento/module-core": "0.42.0-beta11", "magento/module-catalog": "0.42.0-beta11", "magento/module-sales": "0.42.0-beta11", "magento/module-catalog-inventory": "0.42.0-beta11", "magento/module-quote": "0.42.0-beta11", + "magento/module-config": "0.42.0-beta11", "magento/framework": "0.42.0-beta11", "lib-libxml": "*", "magento/magento-composer-installer": "*" diff --git a/app/code/Magento/Usps/etc/config.xml b/app/code/Magento/Usps/etc/config.xml index db37b2e8aafd7705a6b2b72fde6e006ea37231cb..972c58188197743a4a1791eed981dafaea4b953c 100644 --- a/app/code/Magento/Usps/etc/config.xml +++ b/app/code/Magento/Usps/etc/config.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Core/etc/config.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Store/etc/config.xsd"> <default> <carriers> <usps> diff --git a/app/code/Magento/Variable/Controller/Adminhtml/System/Variable.php b/app/code/Magento/Variable/Controller/Adminhtml/System/Variable.php index 0974dc185b99bbc55d0449db2b8a873307ab2690..594ebf3aa0c37468e8304f461da415eb992169e6 100644 --- a/app/code/Magento/Variable/Controller/Adminhtml/System/Variable.php +++ b/app/code/Magento/Variable/Controller/Adminhtml/System/Variable.php @@ -37,7 +37,7 @@ class Variable extends Action protected $resultPageFactory; /** - * @var \Magento\Framework\Controller\Result\JSONFactory + * @var \Magento\Framework\Controller\Result\JsonFactory */ protected $resultJsonFactory; @@ -51,7 +51,7 @@ class Variable extends Action * @param \Magento\Framework\Registry $coreRegistry * @param \Magento\Backend\Model\View\Result\RedirectFactory $resultRedirectFactory * @param \Magento\Backend\Model\View\Result\ForwardFactory $resultForwardFactory - * @param \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory + * @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory * @param \Magento\Framework\View\Result\PageFactory $resultPageFactory * @param \Magento\Framework\View\LayoutFactory $layoutFactory */ @@ -60,7 +60,7 @@ class Variable extends Action \Magento\Framework\Registry $coreRegistry, \Magento\Backend\Model\View\Result\RedirectFactory $resultRedirectFactory, \Magento\Backend\Model\View\Result\ForwardFactory $resultForwardFactory, - \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory, + \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory, \Magento\Framework\View\Result\PageFactory $resultPageFactory, \Magento\Framework\View\LayoutFactory $layoutFactory ) { diff --git a/app/code/Magento/Variable/Controller/Adminhtml/System/Variable/Validate.php b/app/code/Magento/Variable/Controller/Adminhtml/System/Variable/Validate.php index 41f4738f0a56c7ad1474d8c13797b40b4638ad57..684330532414b51231cf74f811403776001f0a0f 100644 --- a/app/code/Magento/Variable/Controller/Adminhtml/System/Variable/Validate.php +++ b/app/code/Magento/Variable/Controller/Adminhtml/System/Variable/Validate.php @@ -11,7 +11,7 @@ class Validate extends \Magento\Variable\Controller\Adminhtml\System\Variable /** * Validate Action * - * @return \Magento\Framework\Controller\Result\JSON + * @return \Magento\Framework\Controller\Result\Json */ public function execute() { @@ -26,7 +26,7 @@ class Validate extends \Magento\Variable\Controller\Adminhtml\System\Variable $response->setError(true); $response->setHtmlMessage($layout->getMessagesBlock()->getGroupedHtml()); } - /** @var \Magento\Framework\Controller\Result\JSON $resultJson */ + /** @var \Magento\Framework\Controller\Result\Json $resultJson */ $resultJson = $this->resultJsonFactory->create(); return $resultJson->setData($response->toArray()); } diff --git a/app/code/Magento/Variable/Controller/Adminhtml/System/Variable/WysiwygPlugin.php b/app/code/Magento/Variable/Controller/Adminhtml/System/Variable/WysiwygPlugin.php index 4d040feb6a6b4f3e9df1a4d7ef44f1fb711c93b2..04b1514cfab7f3b8b6ce4b19ac4f0b7e8da517f9 100644 --- a/app/code/Magento/Variable/Controller/Adminhtml/System/Variable/WysiwygPlugin.php +++ b/app/code/Magento/Variable/Controller/Adminhtml/System/Variable/WysiwygPlugin.php @@ -11,7 +11,7 @@ class WysiwygPlugin extends \Magento\Variable\Controller\Adminhtml\System\Variab /** * WYSIWYG Plugin Action * - * @return \Magento\Framework\Controller\Result\JSON + * @return \Magento\Framework\Controller\Result\Json */ public function execute() { @@ -22,7 +22,7 @@ class WysiwygPlugin extends \Magento\Variable\Controller\Adminhtml\System\Variab )->toOptionArray( true ); - /** @var \Magento\Framework\Controller\Result\JSON $resultJson */ + /** @var \Magento\Framework\Controller\Result\Json $resultJson */ $resultJson = $this->resultJsonFactory->create(); return $resultJson->setData([$storeContactVariabls, $customVariables]); } diff --git a/app/code/Magento/Variable/i18n/de_DE.csv b/app/code/Magento/Variable/i18n/de_DE.csv new file mode 100644 index 0000000000000000000000000000000000000000..5b82c65d44622a54d7d365b4458e96df3f0ad5d4 --- /dev/null +++ b/app/code/Magento/Variable/i18n/de_DE.csv @@ -0,0 +1,4 @@ +"Custom Variables","Angepasste Variablen" +"Variable Code must be unique.","Variabler Code muß eindeutig sein." +"Validation has failed.","Prüfung fehlgeschlagen." +"Insert Variable...","Insert Variable..." diff --git a/app/code/Magento/Variable/i18n/en_US.csv b/app/code/Magento/Variable/i18n/en_US.csv new file mode 100644 index 0000000000000000000000000000000000000000..d68ff06262284b6f05c4f7b5d889d9088673c0f1 --- /dev/null +++ b/app/code/Magento/Variable/i18n/en_US.csv @@ -0,0 +1,4 @@ +"Custom Variables","Custom Variables" +"Variable Code must be unique.","Variable Code must be unique." +"Validation has failed.","Validation has failed." +"Insert Variable...","Insert Variable..." diff --git a/app/code/Magento/Variable/i18n/es_ES.csv b/app/code/Magento/Variable/i18n/es_ES.csv new file mode 100644 index 0000000000000000000000000000000000000000..a17a926b175fcdd5189d3562f4cf843df86504ad --- /dev/null +++ b/app/code/Magento/Variable/i18n/es_ES.csv @@ -0,0 +1,4 @@ +"Custom Variables","Variables personalizadas" +"Variable Code must be unique.","El código de variable debe ser único." +"Validation has failed.","Falló la validación." +"Insert Variable...","Insert Variable..." diff --git a/app/code/Magento/Variable/i18n/fr_FR.csv b/app/code/Magento/Variable/i18n/fr_FR.csv new file mode 100644 index 0000000000000000000000000000000000000000..8f14328226eb363ef5141bedf4e73c999f23e4fd --- /dev/null +++ b/app/code/Magento/Variable/i18n/fr_FR.csv @@ -0,0 +1,4 @@ +"Custom Variables","Variables sur mesure" +"Variable Code must be unique.","La variable code doit être unique." +"Validation has failed.","Validation a échouée" +"Insert Variable...","Insert Variable..." diff --git a/app/code/Magento/Variable/i18n/nl_NL.csv b/app/code/Magento/Variable/i18n/nl_NL.csv new file mode 100644 index 0000000000000000000000000000000000000000..e16b8d4192b1b0eed3f01a2d806482d84d94de8a --- /dev/null +++ b/app/code/Magento/Variable/i18n/nl_NL.csv @@ -0,0 +1,4 @@ +"Custom Variables","Aangepaste variabelen" +"Variable Code must be unique.","Variabele Code moet uniek zijn." +"Validation has failed.","Validatie is mislukt." +"Insert Variable...","Insert Variable..." diff --git a/app/code/Magento/Variable/i18n/pt_BR.csv b/app/code/Magento/Variable/i18n/pt_BR.csv new file mode 100644 index 0000000000000000000000000000000000000000..e073700f36435e76d055a351da2bba66824895c5 --- /dev/null +++ b/app/code/Magento/Variable/i18n/pt_BR.csv @@ -0,0 +1,4 @@ +"Custom Variables","Variáveis de Personalização." +"Variable Code must be unique.","Código da Variável deve ser único." +"Validation has failed.","Validação falhou." +"Insert Variable...","Insert Variable..." diff --git a/app/code/Magento/Variable/i18n/zh_CN.csv b/app/code/Magento/Variable/i18n/zh_CN.csv new file mode 100644 index 0000000000000000000000000000000000000000..b690819a8319dfedfd8aa2579201e599fb7c276d --- /dev/null +++ b/app/code/Magento/Variable/i18n/zh_CN.csv @@ -0,0 +1,4 @@ +"Custom Variables",自定义å˜é‡ +"Variable Code must be unique.",å˜é‡ä»£ç 必须是唯一的。 +"Validation has failed.",验è¯å¤±è´¥ã€‚ +"Insert Variable...","Insert Variable..." diff --git a/app/code/Magento/Webapi/Controller/Rest.php b/app/code/Magento/Webapi/Controller/Rest.php index 43383e07afdc3d9a378587832d4e3340f6f368a5..dc68d6cd3b67d976e67993da41db16ae8d7463a5 100644 --- a/app/code/Magento/Webapi/Controller/Rest.php +++ b/app/code/Magento/Webapi/Controller/Rest.php @@ -218,7 +218,9 @@ class Rest implements \Magento\Framework\App\FrontControllerInterface $route = $this->getCurrentRoute(); if (!$this->isAllowed($route->getAclResources())) { $params = ['resources' => implode(', ', $route->getAclResources())]; - throw new AuthorizationException(AuthorizationException::NOT_AUTHORIZED, $params); + throw new AuthorizationException( + __(AuthorizationException::NOT_AUTHORIZED, $params) + ); } } diff --git a/app/code/Magento/Webapi/Controller/Soap.php b/app/code/Magento/Webapi/Controller/Soap.php index f5b47bf257e1c3b933706c1e8c19ec51eff6abb9..63d9968b495008e38c8644e75599745124885079 100644 --- a/app/code/Magento/Webapi/Controller/Soap.php +++ b/app/code/Magento/Webapi/Controller/Soap.php @@ -155,9 +155,9 @@ class Soap implements \Magento\Framework\App\FrontControllerInterface if (isset($token[1]) && is_string($token[1])) { return $token[1]; } - throw new AuthorizationException('Authentication header format is invalid.'); + throw new AuthorizationException(__('Authentication header format is invalid.')); } - throw new AuthorizationException('Authentication header is absent.'); + throw new AuthorizationException(__('Authentication header is absent.')); } /** diff --git a/app/code/Magento/Webapi/Controller/Soap/Request/Handler.php b/app/code/Magento/Webapi/Controller/Soap/Request/Handler.php index e45d378592f0413d4b10059b84606e16ff5a7cc9..862b8278d9a942ab4c23edc36034ed37c5aaff28 100644 --- a/app/code/Magento/Webapi/Controller/Soap/Request/Handler.php +++ b/app/code/Magento/Webapi/Controller/Soap/Request/Handler.php @@ -6,6 +6,7 @@ namespace Magento\Webapi\Controller\Soap\Request; use Magento\Framework\Api\ExtensibleDataInterface; +use Magento\Framework\Api\MetadataObjectInterface; use Magento\Framework\Api\SimpleDataObjectConverter; use Magento\Framework\AuthorizationInterface; use Magento\Framework\Exception\AuthorizationException; @@ -108,8 +109,10 @@ class Handler if (!$isAllowed) { throw new AuthorizationException( - AuthorizationException::NOT_AUTHORIZED, - ['resources' => implode(', ', $serviceMethodInfo[SoapConfig::KEY_ACL_RESOURCES])] + __( + AuthorizationException::NOT_AUTHORIZED, + ['resources' => implode(', ', $serviceMethodInfo[SoapConfig::KEY_ACL_RESOURCES])] + ) ); } $service = $this->_objectManager->get($serviceClass); @@ -154,7 +157,7 @@ class Handler } elseif (is_array($data)) { $dataType = substr($dataType, 0, -2); foreach ($data as $key => $value) { - if ($value instanceof ExtensibleDataInterface) { + if ($value instanceof ExtensibleDataInterface || $value instanceof MetadataObjectInterface) { $result[] = $this->_dataObjectConverter ->convertKeysToCamelCase($this->_dataObjectProcessor->buildOutputDataArray($value, $dataType)); } else { diff --git a/app/code/Magento/Webapi/Model/Config.php b/app/code/Magento/Webapi/Model/Config.php index af0823e23e7838d21fedcd31515728fc8f0dd91f..1691f95834932b1aa6e26ec2298a0fff0c7c36d9 100644 --- a/app/code/Magento/Webapi/Model/Config.php +++ b/app/code/Magento/Webapi/Model/Config.php @@ -70,65 +70,4 @@ class Config } return $this->services; } - - /** - * Identify the list of service name parts including sub-services using class name. - * - * Examples of input/output pairs: - * <pre> - * - 'Magento\Customer\Service\V1\CustomerAccountInterface', false => ['CustomerCustomerAccount'] - * - 'Vendor\Customer\Service\V1\Customer\AddressInterface', true => ['VendorCustomer', 'Address', 'V1'] - * </pre> - * - * @param string $className - * @param bool $preserveVersion Should version be preserved during class name conversion into service name - * @return string[] - * @throws \InvalidArgumentException When class is not valid API service. - * @SuppressWarnings(PHPMD.CyclomaticComplexity) - */ - public function getServiceNameParts($className, $preserveVersion = false) - { - if (!preg_match(\Magento\Webapi\Model\Config::SERVICE_CLASS_PATTERN, $className, $matches)) { - $apiClassPattern = "#^(.+?)\\\\(.+?)\\\\Api\\\\(.+?)(Interface)?$#"; - preg_match($apiClassPattern, $className, $matches); - } - - if (!empty($matches)) { - $moduleNamespace = $matches[1]; - $moduleName = $matches[2]; - $moduleNamespace = ($moduleNamespace == 'Magento') ? '' : $moduleNamespace; - if ($matches[4] === 'Interface') { - $matches[4] = $matches[3]; - $matches[3] = 'V1'; - } - $serviceNameParts = explode('\\', trim($matches[4], '\\')); - if ($moduleName == $serviceNameParts[0]) { - /** Avoid duplication of words in service name */ - $moduleName = ''; - } - $parentServiceName = $moduleNamespace . $moduleName . array_shift($serviceNameParts); - array_unshift($serviceNameParts, $parentServiceName); - if ($preserveVersion) { - $serviceVersion = $matches[3]; - $serviceNameParts[] = $serviceVersion; - } - return $serviceNameParts; - } elseif (preg_match(\Magento\Webapi\Model\Config::API_PATTERN, $className, $matches)) { - $moduleNamespace = $matches[1]; - $moduleName = $matches[2]; - $moduleNamespace = ($moduleNamespace == 'Magento') ? '' : $moduleNamespace; - $serviceNameParts = explode('\\', trim($matches[3], '\\')); - if ($moduleName == $serviceNameParts[0]) { - /** Avoid duplication of words in service name */ - $moduleName = ''; - } - $parentServiceName = $moduleNamespace . $moduleName . array_shift($serviceNameParts); - array_unshift($serviceNameParts, $parentServiceName); - //Add temporary dummy version - $serviceNameParts[] = 'V1'; - return $serviceNameParts; - } - - throw new \InvalidArgumentException(sprintf('The service interface name "%s" is invalid.', $className)); - } } diff --git a/app/code/Magento/Webapi/Model/Config/Converter.php b/app/code/Magento/Webapi/Model/Config/Converter.php index 44a8b35ee635f05f536f055c6d063dd107643ac0..c9b557f099fa5c12d20498fd8b79155aa65675cc 100644 --- a/app/code/Magento/Webapi/Model/Config/Converter.php +++ b/app/code/Magento/Webapi/Model/Config/Converter.php @@ -26,11 +26,11 @@ class Converter implements \Magento\Framework\Config\ConverterInterface const KEY_DATA_PARAMETERS = 'parameters'; const KEY_SOURCE = 'source'; const KEY_METHOD = 'method'; + const KEY_METHODS = 'methods'; /**#@-*/ /** * {@inheritdoc} - * * @SuppressWarnings(PHPMD.CyclomaticComplexity) * @SuppressWarnings(PHPMD.NPathComplexity) */ @@ -48,6 +48,13 @@ class Converter implements \Magento\Framework\Config\ConverterInterface $service = $route->getElementsByTagName('service')->item(0); $serviceClass = $service->attributes->getNamedItem('class')->nodeValue; $serviceMethod = $service->attributes->getNamedItem('method')->nodeValue; + $url = trim($route->attributes->getNamedItem('url')->nodeValue); + $version = $this->convertVersion($url); + + $serviceClassData = []; + if (isset($result[self::KEY_SERVICES][$serviceClass][$version])) { + $serviceClassData = $result[self::KEY_SERVICES][$serviceClass][$version]; + } $resources = $route->getElementsByTagName('resource'); $resourceReferences = []; @@ -62,48 +69,24 @@ class Converter implements \Magento\Framework\Config\ConverterInterface // For SOAP $resourcePermissionSet[] = $ref; } - if (!isset($result[self::KEY_SERVICES][$serviceClass][$serviceMethod][self::KEY_ACL_RESOURCES])) { - $result[self::KEY_SERVICES][$serviceClass][$serviceMethod][self::KEY_ACL_RESOURCES] - = $resourcePermissionSet; + + if (!isset($serviceClassData[self::KEY_METHODS][$serviceMethod])) { + $serviceClassData[self::KEY_METHODS][$serviceMethod][self::KEY_ACL_RESOURCES] = $resourcePermissionSet; } else { - $result[self::KEY_SERVICES][$serviceClass][$serviceMethod][self::KEY_ACL_RESOURCES] = + $serviceClassData[self::KEY_METHODS][$serviceMethod][self::KEY_ACL_RESOURCES] = array_unique( array_merge( - $result[self::KEY_SERVICES][$serviceClass][$serviceMethod][self::KEY_ACL_RESOURCES], + $serviceClassData[self::KEY_METHODS][$serviceMethod][self::KEY_ACL_RESOURCES], $resourcePermissionSet ) ); } - $parameters = $route->getElementsByTagName('parameter'); - $data = []; - /** @var \DOMElement $parameter */ - foreach ($parameters as $parameter) { - if ($parameter->nodeType != XML_ELEMENT_NODE) { - continue; - } - $name = $parameter->attributes->getNamedItem('name')->nodeValue; - $forceNode = $parameter->attributes->getNamedItem('force'); - $force = $forceNode ? (bool)$forceNode->nodeValue : false; - $value = $parameter->nodeValue; - $data[$name] = [ - self::KEY_FORCE => $force, - self::KEY_VALUE => ($value === 'null') ? null : $value, - ]; - $sourceNode = $parameter->attributes->getNamedItem('source'); - if ($sourceNode) { - $data[$name][self::KEY_SOURCE] = $sourceNode->nodeValue; - } - $methodNode = $parameter->attributes->getNamedItem('method'); - if ($methodNode) { - $data[$name][self::KEY_METHOD] = $methodNode->nodeValue; - } - } - $method = $route->attributes->getNamedItem('method')->nodeValue; - $url = trim($route->attributes->getNamedItem('url')->nodeValue); $secureNode = $route->attributes->getNamedItem('secure'); $secure = $secureNode ? (bool)trim($secureNode->nodeValue) : false; + $data = $this->convertMethodParameters($route->getElementsByTagName('parameter')); + // We could handle merging here by checking if the route already exists $result[self::KEY_ROUTES][$url][$method] = [ self::KEY_SECURE => $secure, @@ -114,12 +97,62 @@ class Converter implements \Magento\Framework\Config\ConverterInterface self::KEY_ACL_RESOURCES => $resourceReferences, self::KEY_DATA_PARAMETERS => $data, ]; + $serviceSecure = false; - if (isset($result[self::KEY_SERVICES][$serviceClass][$serviceMethod][self::KEY_SECURE])) { - $serviceSecure = $result[self::KEY_SERVICES][$serviceClass][$serviceMethod][self::KEY_SECURE]; + if (isset($serviceClassData[self::KEY_METHODS][$serviceMethod][self::KEY_SECURE])) { + $serviceSecure = $serviceClassData[self::KEY_METHODS][$serviceMethod][self::KEY_SECURE]; } - $result[self::KEY_SERVICES][$serviceClass][$serviceMethod][self::KEY_SECURE] = $serviceSecure || $secure; + $serviceClassData[self::KEY_METHODS][$serviceMethod][self::KEY_SECURE] = $serviceSecure || $secure; + + $result[self::KEY_SERVICES][$serviceClass][$version] = $serviceClassData; } return $result; } + + /** + * Parses the method parameters into a string array. + * + * @param \DOMNodeList $parameters + * @return array + * @SuppressWarnings(PHPMD.NPathComplexity) + */ + protected function convertMethodParameters($parameters) + { + $data = []; + /** @var \DOMElement $parameter */ + foreach ($parameters as $parameter) { + if ($parameter->nodeType != XML_ELEMENT_NODE) { + continue; + } + $name = $parameter->attributes->getNamedItem('name')->nodeValue; + $forceNode = $parameter->attributes->getNamedItem('force'); + $force = $forceNode ? (bool)$forceNode->nodeValue : false; + $value = $parameter->nodeValue; + $data[$name] = [ + self::KEY_FORCE => $force, + self::KEY_VALUE => ($value === 'null') ? null : $value, + ]; + $sourceNode = $parameter->attributes->getNamedItem('source'); + if ($sourceNode) { + $data[$name][self::KEY_SOURCE] = $sourceNode->nodeValue; + } + $methodNode = $parameter->attributes->getNamedItem('method'); + if ($methodNode) { + $data[$name][self::KEY_METHOD] = $methodNode->nodeValue; + } + } + return $data; + } + + /** + * Derive the version from the provided URL. + * Assumes the version is the first portion of the URL. For example, '/V1/customers' + * + * @param string $url + * @return string + */ + protected function convertVersion($url) + { + return substr($url, 1, strpos($url, '/', 1)-1); + } } diff --git a/app/code/Magento/Webapi/Model/Soap/Config.php b/app/code/Magento/Webapi/Model/Soap/Config.php index 1d686f3f1f06f67083c01a4d7b2183b7a98dee04..70c89d3c12efd0b01707cdca5d2399f1d4d992d2 100644 --- a/app/code/Magento/Webapi/Model/Soap/Config.php +++ b/app/code/Magento/Webapi/Model/Soap/Config.php @@ -104,7 +104,7 @@ class Config /** * Retrieve the list of SOAP operations available in the system * - * @param array $requestedService The list of requested services with their versions + * @param array $requestedServices The list of requested services with their versions * @return array <pre> * array( * array( @@ -115,15 +115,15 @@ class Config * ... * )</pre> */ - protected function getSoapOperations($requestedService) + protected function getSoapOperations($requestedServices) { if (null == $this->soapOperations) { $this->soapOperations = []; - foreach ($this->getRequestedSoapServices($requestedService) as $serviceData) { + foreach ($this->getRequestedSoapServices($requestedServices) as $serviceName => $serviceData) { foreach ($serviceData[self::KEY_SERVICE_METHODS] as $methodData) { $method = $methodData[self::KEY_METHOD]; $class = $serviceData[self::KEY_CLASS]; - $operationName = $this->getSoapOperation($class, $method); + $operationName = $serviceName . ucfirst($method); $this->soapOperations[$operationName] = [ self::KEY_CLASS => $class, self::KEY_METHOD => $method, @@ -163,25 +163,27 @@ class Config protected function initServicesMetadata() { $soapServices = []; - foreach ($this->config->getServices()[Converter::KEY_SERVICES] as $serviceClass => $serviceData) { - $serviceName = $this->getServiceName($serviceClass); - foreach ($serviceData as $methodName => $methodMetadata) { - $soapServices[$serviceName][self::KEY_SERVICE_METHODS][$methodName] = [ - self::KEY_METHOD => $methodName, - self::KEY_IS_REQUIRED => (bool)$methodMetadata[Converter::KEY_SECURE], - self::KEY_IS_SECURE => $methodMetadata[Converter::KEY_SECURE], - self::KEY_ACL_RESOURCES => $methodMetadata[Converter::KEY_ACL_RESOURCES], - ]; - $soapServices[$serviceName][self::KEY_CLASS] = $serviceClass; + foreach ($this->config->getServices()[Converter::KEY_SERVICES] as $serviceClass => $serviceVersionData) { + foreach ($serviceVersionData as $version => $serviceData) { + $serviceName = $this->getServiceName($serviceClass, $version); + foreach ($serviceData[Converter::KEY_METHODS] as $methodName => $methodMetadata) { + $soapServices[$serviceName][self::KEY_SERVICE_METHODS][$methodName] = [ + self::KEY_METHOD => $methodName, + self::KEY_IS_REQUIRED => (bool)$methodMetadata[Converter::KEY_SECURE], + self::KEY_IS_SECURE => $methodMetadata[Converter::KEY_SECURE], + self::KEY_ACL_RESOURCES => $methodMetadata[Converter::KEY_ACL_RESOURCES], + ]; + $soapServices[$serviceName][self::KEY_CLASS] = $serviceClass; + } + $reflectedMethodsMetadata = $this->classReflector->reflectClassMethods( + $serviceClass, + $soapServices[$serviceName][self::KEY_SERVICE_METHODS] + ); + $soapServices[$serviceName][self::KEY_SERVICE_METHODS] = array_merge_recursive( + $soapServices[$serviceName][self::KEY_SERVICE_METHODS], + $reflectedMethodsMetadata + ); } - $reflectedMethodsMetadata = $this->classReflector->reflectClassMethods( - $serviceClass, - $soapServices[$serviceName][self::KEY_SERVICE_METHODS] - ); - $soapServices[$serviceName][self::KEY_SERVICE_METHODS] = array_merge_recursive( - $soapServices[$serviceName][self::KEY_SERVICE_METHODS], - $reflectedMethodsMetadata - ); } return $soapServices; @@ -225,7 +227,7 @@ class Config $soapServicesConfig = $this->getSoapServicesConfig(); foreach ($requestedServices as $serviceName) { if (isset($soapServicesConfig[$serviceName])) { - $services[] = $soapServicesConfig[$serviceName]; + $services[$serviceName] = $soapServicesConfig[$serviceName]; } } return $services; @@ -236,11 +238,12 @@ class Config * * @param string $interfaceName e.g. \Magento\Catalog\Api\ProductInterfaceV1 * @param string $methodName e.g. create + * @param string $version * @return string e.g. catalogProductCreate */ - public function getSoapOperation($interfaceName, $methodName) + public function getSoapOperation($interfaceName, $methodName, $version) { - $serviceName = $this->getServiceName($interfaceName); + $serviceName = $this->getServiceName($interfaceName, $version); $operationName = $serviceName . ucfirst($methodName); return $operationName; } @@ -270,13 +273,53 @@ class Config * </pre> * * @param string $interfaceName + * @param string $version * @param bool $preserveVersion Should version be preserved during interface name conversion into service name * @return string * @throws \InvalidArgumentException + * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ - public function getServiceName($interfaceName, $preserveVersion = true) + public function getServiceName($interfaceName, $version, $preserveVersion = true) { - $serviceNameParts = $this->config->getServiceNameParts($interfaceName, $preserveVersion); + if (!preg_match(\Magento\Webapi\Model\Config::SERVICE_CLASS_PATTERN, $interfaceName, $matches)) { + $apiClassPattern = "#^(.+?)\\\\(.+?)\\\\Api\\\\(.+?)(Interface)?$#"; + preg_match($apiClassPattern, $interfaceName, $matches); + } + + if (!empty($matches)) { + $moduleNamespace = $matches[1]; + $moduleName = $matches[2]; + $moduleNamespace = ($moduleNamespace == 'Magento') ? '' : $moduleNamespace; + if ($matches[4] === 'Interface') { + $matches[4] = $matches[3]; + } + $serviceNameParts = explode('\\', trim($matches[4], '\\')); + if ($moduleName == $serviceNameParts[0]) { + /** Avoid duplication of words in service name */ + $moduleName = ''; + } + $parentServiceName = $moduleNamespace . $moduleName . array_shift($serviceNameParts); + array_unshift($serviceNameParts, $parentServiceName); + if ($preserveVersion) { + $serviceNameParts[] = $version; + } + } elseif (preg_match(\Magento\Webapi\Model\Config::API_PATTERN, $interfaceName, $matches)) { + $moduleNamespace = $matches[1]; + $moduleName = $matches[2]; + $moduleNamespace = ($moduleNamespace == 'Magento') ? '' : $moduleNamespace; + $serviceNameParts = explode('\\', trim($matches[3], '\\')); + if ($moduleName == $serviceNameParts[0]) { + /** Avoid duplication of words in service name */ + $moduleName = ''; + } + $parentServiceName = $moduleNamespace . $moduleName . array_shift($serviceNameParts); + array_unshift($serviceNameParts, $parentServiceName); + if ($preserveVersion) { + $serviceNameParts[] = $version; + } + } else { + throw new \InvalidArgumentException(sprintf('The service interface name "%s" is invalid.', $interfaceName)); + } return lcfirst(implode('', $serviceNameParts)); } } diff --git a/app/code/Magento/Webapi/Model/Soap/Fault.php b/app/code/Magento/Webapi/Model/Soap/Fault.php index 940fc85e4446b07d9e36fc3942ae4b08fbe63e6b..c48d6fb55bc1e7f8c82d3301094865bfeae89a2a 100644 --- a/app/code/Magento/Webapi/Model/Soap/Fault.php +++ b/app/code/Magento/Webapi/Model/Soap/Fault.php @@ -301,7 +301,6 @@ FAULT_MESSAGE; if (!is_array($parameters)) { return $result; } - $paramsXml = ''; foreach ($parameters as $parameterName => $parameterValue) { if (is_string($parameterName) && (is_string($parameterValue) || is_numeric($parameterValue))) { diff --git a/app/code/Magento/Webapi/Model/Soap/Server.php b/app/code/Magento/Webapi/Model/Soap/Server.php index 541a47e2fe8dc0e22c544209280439a58f96081d..02370c9fc4f75302e884621d067eb3a5588cc7a0 100644 --- a/app/code/Magento/Webapi/Model/Soap/Server.php +++ b/app/code/Magento/Webapi/Model/Soap/Server.php @@ -14,11 +14,9 @@ class Server /**#@+ * Path in config to Webapi settings. */ - const CONFIG_PATH_WSDL_CACHE_ENABLED = 'webapi/soap/wsdl_cache_enabled'; - const CONFIG_PATH_SOAP_CHARSET = 'webapi/soap/charset'; - /**#@-*/ + const REQUEST_PARAM_SERVICES = 'services'; const REQUEST_PARAM_WSDL = 'wsdl'; @@ -101,16 +99,6 @@ class Server $this->_soapServerFactory = $soapServerFactory; $this->_typeProcessor = $typeProcessor; $this->_scopeConfig = $scopeConfig; - /** Enable or disable SOAP extension WSDL cache depending on Magento configuration. */ - $wsdlCacheEnabled = $this->_scopeConfig->isSetFlag( - self::CONFIG_PATH_WSDL_CACHE_ENABLED, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE - ); - if ($wsdlCacheEnabled) { - ini_set('soap.wsdl_cache_enabled', '1'); - } else { - ini_set('soap.wsdl_cache_enabled', '0'); - } } /** diff --git a/app/code/Magento/Webapi/Test/Unit/Controller/RestTest.php b/app/code/Magento/Webapi/Test/Unit/Controller/RestTest.php index 734a50ea3e2a3b5e0de99fed4c66aea7a41ac936..30a175b6024bfaacf78b4079203ceffb36e2256b 100644 --- a/app/code/Magento/Webapi/Test/Unit/Controller/RestTest.php +++ b/app/code/Magento/Webapi/Test/Unit/Controller/RestTest.php @@ -82,7 +82,7 @@ class RestTest extends \PHPUnit_Framework_TestCase * @var \PHPUnit_Framework_MockObject_MockObject */ protected $areaMock; - + /** * @var \Magento\Webapi\Controller\Rest\ParamsOverrider|\PHPUnit_Framework_MockObject_MockObject */ diff --git a/app/code/Magento/Webapi/Test/Unit/Model/Config/_files/webapi.php b/app/code/Magento/Webapi/Test/Unit/Model/Config/_files/webapi.php index 4f48117117fe5802137e04dc002b86c4a472a0f5..aecbdbde2dcecb4ea98897510899513cb08a7528 100644 --- a/app/code/Magento/Webapi/Test/Unit/Model/Config/_files/webapi.php +++ b/app/code/Magento/Webapi/Test/Unit/Model/Config/_files/webapi.php @@ -6,26 +6,30 @@ return [ 'services' => [ 'Magento\Customer\Api\CustomerRepositoryInterface' => [ - 'getById' => [ - 'resources' => [ - 'Magento_Customer::customer_self', - 'Magento_Customer::read', - ], - 'secure' => false, - ], - 'save' => [ - 'resources' => [ - 'Magento_Customer::customer_self', - 'Magento_Customer::manage' - ], - 'secure' => true, - ], - 'deleteById' => [ - 'resources' => [ - 'Magento_Customer::manage', - 'Magento_Customer::delete', + 'V1' => [ + 'methods' => [ + 'getById' => [ + 'resources' => [ + 'Magento_Customer::customer_self', + 'Magento_Customer::read', + ], + 'secure' => false, + ], + 'save' => [ + 'resources' => [ + 'Magento_Customer::customer_self', + 'Magento_Customer::manage' + ], + 'secure' => true, + ], + 'deleteById' => [ + 'resources' => [ + 'Magento_Customer::manage', + 'Magento_Customer::delete', + ], + 'secure' => false, + ], ], - 'secure' => false, ], ], ], diff --git a/app/code/Magento/Webapi/Test/Unit/Model/Soap/ConfigTest.php b/app/code/Magento/Webapi/Test/Unit/Model/Soap/ConfigTest.php index 27a4024682396bc3a020703a55262c1b20e6b17a..6c747b1f54a973c3de6396642b3521c16009e242 100644 --- a/app/code/Magento/Webapi/Test/Unit/Model/Soap/ConfigTest.php +++ b/app/code/Magento/Webapi/Test/Unit/Model/Soap/ConfigTest.php @@ -6,6 +6,8 @@ * See COPYING.txt for license details. */ +// @codingStandardsIgnoreFile + /** * Class implements tests for \Magento\Webapi\Model\Soap\Config class. */ @@ -39,23 +41,31 @@ class ConfigTest extends \PHPUnit_Framework_TestCase $servicesConfig = [ 'services' => [ 'Magento\Customer\Api\AccountManagementInterface' => [ - 'activate' => [ - 'resources' => [ - [ - 'Magento_Customer::manage', + 'V1' => [ + 'methods' => [ + 'activate' => [ + 'resources' => [ + [ + 'Magento_Customer::manage', + ], + ], + 'secure' => false, ], ], - 'secure' => false, ], ], 'Magento\Customer\Api\CustomerRepositoryInterface' => [ - 'getById' => [ - 'resources' => [ - [ - 'Magento_Customer::customer', + 'V1' => [ + 'methods' => [ + 'getById' => [ + 'resources' => [ + [ + 'Magento_Customer::customer', + ], + ], + 'secure' => false, ], ], - 'secure' => false, ], ], ], @@ -98,17 +108,18 @@ class ConfigTest extends \PHPUnit_Framework_TestCase public function testGetRequestedSoapServices() { $expectedResult = [ - [ - 'methods' => [ - 'activate' => [ - 'method' => 'activate', - 'inputRequired' => '', - 'isSecure' => '', - 'resources' => [['Magento_Customer::manage']], + 'customerAccountManagementV1' => + [ + 'methods' => [ + 'activate' => [ + 'method' => 'activate', + 'inputRequired' => '', + 'isSecure' => '', + 'resources' => [['Magento_Customer::manage']], + ], ], + 'class' => 'Magento\Customer\Api\AccountManagementInterface', ], - 'class' => 'Magento\Customer\Api\AccountManagementInterface', - ], ]; $result = $this->_soapConfig->getRequestedSoapServices( ['customerAccountManagementV1', 'moduleBarV2', 'moduleBazV1'] @@ -135,58 +146,78 @@ class ConfigTest extends \PHPUnit_Framework_TestCase { $expectedResult = 'customerAccountManagementV1Activate'; $soapOperation = $this->_soapConfig - ->getSoapOperation('Magento\Customer\Api\AccountManagementInterface', 'activate'); + ->getSoapOperation('Magento\Customer\Api\AccountManagementInterface', 'activate', 'V1'); $this->assertEquals($expectedResult, $soapOperation); } + /** - * Test identifying service name parts including subservices using class name. + * Test identifying service name including subservices using class name. * - * @dataProvider serviceNamePartsDataProvider + * @dataProvider serviceNameDataProvider */ - public function testGetServiceNameParts($className, $preserveVersion, $expected) + public function testGetServiceName($className, $version, $preserveVersion, $expected) { - $actual = $this->_soapConfig->getServiceName($className, $preserveVersion); + $actual = $this->_soapConfig->getServiceName($className, $version, $preserveVersion); $this->assertEquals($expected, $actual); } /** - * Dataprovider for serviceNameParts + * Dataprovider for testGetServiceName * * @return string */ - public function serviceNamePartsDataProvider() + public function serviceNameDataProvider() { return [ - ['Magento\Customer\Api\AccountManagementInterface', false, 'customerAccountManagement'], - [ - 'Magento\Customer\Api\AddressRepositoryInterface', - true, - 'customerAddressRepositoryV1' - ], + ['Magento\Customer\Api\AccountManagementInterface', 'V1', false, 'customerAccountManagement'], + ['Magento\Customer\Api\AddressRepositoryInterface', 'V1', true, 'customerAddressRepositoryV1'], ]; } /** * @expectedException \InvalidArgumentException - * @dataProvider dataProviderForTestGetServiceNamePartsInvalidName + * @dataProvider dataProviderForTestGetServiceNameInvalidName */ - public function testGetServiceNamePartsInvalidName($interfaceClassName) + public function testGetServiceNameInvalidName($interfaceClassName, $version) { - $this->_soapConfig->getServiceName($interfaceClassName); + $this->_soapConfig->getServiceName($interfaceClassName, $version); } - public function dataProviderForTestGetServiceNamePartsInvalidName() + /** + * Dataprovider for testGetServiceNameInvalidName + * + * @return string + */ + public function dataProviderForTestGetServiceNameInvalidName() { return [ - ['BarV1Interface'], // Missed vendor, module, 'Service' - ['Service\\V1Interface'], // Missed vendor and module - ['Magento\\Foo\\Service\\BarVxInterface'], // Version number should be a number - ['Magento\\Foo\\Service\\BarInterface'], // Version missed - ['Magento\\Foo\\Service\\BarV1'], // 'Interface' missed - ['Foo\\Service\\BarV1Interface'], // Module missed - ['Foo\\BarV1Interface'] // Module and 'Service' missed + ['BarV1Interface', 'V1'], // Missed vendor, module, 'Service' + ['Service\\V1Interface', 'V1'], // Missed vendor and module + ['Magento\\Foo\\Service\\BarVxInterface', 'V1'], // Version number should be a number + ['Magento\\Foo\\Service\\BarInterface', 'V1'], // Version missed + ['Magento\\Foo\\Service\\BarV1', 'V1'], // 'Interface' missed + ['Foo\\Service\\BarV1Interface', 'V1'], // Module missed + ['Foo\\BarV1Interface', 'V1'] // Module and 'Service' missed ]; } + + public function testGetServiceMetadata() + { + $expectedResult = [ + 'methods' => [ + 'activate' => [ + 'method' => 'activate', + 'inputRequired' => '', + 'isSecure' => '', + 'resources' => [['Magento_Customer::manage']], + ], + ], + 'class' => 'Magento\Customer\Api\AccountManagementInterface', + ]; + $result = $this->_soapConfig->getServiceMetadata('customerAccountManagementV1'); + $this->assertEquals($expectedResult, $result); + + } } require_once realpath(__DIR__ . '/../../_files/test_interfaces.php'); diff --git a/app/code/Magento/Webapi/etc/adminhtml/system.xml b/app/code/Magento/Webapi/etc/adminhtml/system.xml index 9335abf34b7128239f69a3a0c9a6cff20e1e0ea9..12671fe2ba7793f4c17a7fd970d573b56c7c223f 100644 --- a/app/code/Magento/Webapi/etc/adminhtml/system.xml +++ b/app/code/Magento/Webapi/etc/adminhtml/system.xml @@ -19,11 +19,6 @@ <label>Default Response Charset</label> <comment>If empty, UTF-8 will be used.</comment> </field> - <field id="wsdl_cache_enabled" translate="label" type="select" sortOrder="40" showInDefault="1" showInWebsite="1" showInStore="1"> - <label>Enable WSDL Cache</label> - <source_model>Magento\Config\Model\Config\Source\Yesno</source_model> - <backend_model>Magento\Config\Model\Config\Backend\Store</backend_model> - </field> </group> </section> </system> diff --git a/app/code/Magento/Weee/etc/config.xml b/app/code/Magento/Weee/etc/config.xml index bf472cca89956ba848db6c37637832615fa0ee93..164097b1280fa003f1c8d62ed9db74efb31ee6cb 100644 --- a/app/code/Magento/Weee/etc/config.xml +++ b/app/code/Magento/Weee/etc/config.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Core/etc/config.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Store/etc/config.xsd"> <default> <sales> <totals_sort> diff --git a/app/code/Magento/Widget/view/adminhtml/templates/instance/edit/layout.phtml b/app/code/Magento/Widget/view/adminhtml/templates/instance/edit/layout.phtml index 2c3de7069e91977efdb6b1002029a42df2d56fbd..b3a294959551111b2dd789d1f6ead5b382606ed5 100644 --- a/app/code/Magento/Widget/view/adminhtml/templates/instance/edit/layout.phtml +++ b/app/code/Magento/Widget/view/adminhtml/templates/instance/edit/layout.phtml @@ -17,10 +17,11 @@ </fieldset> <script> require([ + 'jquery', 'mage/template', "prototype", "extjs/ext-tree-checkbox" -], function (mageTemplate) { +], function (jQuery, mageTemplate) { //<![CDATA[ @@ -476,7 +477,7 @@ var WidgetInstance = { window.WidgetInstance = WidgetInstance; -Ext.onReady(function(){ +jQuery(function(){ <?php foreach ($block->getPageGroups() as $pageGroup): ?> WidgetInstance.addPageGroup(<?php echo Zend_Json::encode($pageGroup) ?>); <?php endforeach; ?> diff --git a/app/code/Magento/Wishlist/Block/Customer/Wishlist.php b/app/code/Magento/Wishlist/Block/Customer/Wishlist.php index 671ca5c98c92fbd288d5dc446727ff2c00230bc7..9a86641155cc6c1bc7c2c6e428a6d5b5bcd068e5 100644 --- a/app/code/Magento/Wishlist/Block/Customer/Wishlist.php +++ b/app/code/Magento/Wishlist/Block/Customer/Wishlist.php @@ -30,12 +30,16 @@ class Wishlist extends \Magento\Wishlist\Block\AbstractBlock */ protected $_formKey; + /** @var \Magento\Customer\Helper\Session\CurrentCustomer */ + protected $currentCustomer; + /** * @param \Magento\Catalog\Block\Product\Context $context * @param \Magento\Framework\App\Http\Context $httpContext * @param \Magento\Catalog\Api\ProductRepositoryInterface $productRepository * @param \Magento\Catalog\Helper\Product\ConfigurationPool $helperPool * @param \Magento\Framework\Data\Form\FormKey $formKey + * @param \Magento\Customer\Helper\Session\CurrentCustomer $currentCustomer * @param array $data */ public function __construct( @@ -44,16 +48,18 @@ class Wishlist extends \Magento\Wishlist\Block\AbstractBlock \Magento\Catalog\Api\ProductRepositoryInterface $productRepository, \Magento\Catalog\Helper\Product\ConfigurationPool $helperPool, \Magento\Framework\Data\Form\FormKey $formKey, + \Magento\Customer\Helper\Session\CurrentCustomer $currentCustomer, array $data = [] ) { - $this->_formKey = $formKey; - $this->_helperPool = $helperPool; parent::__construct( $context, $httpContext, $productRepository, $data ); + $this->_formKey = $formKey; + $this->_helperPool = $helperPool; + $this->currentCustomer = $currentCustomer; } /** @@ -209,4 +215,16 @@ class Wishlist extends \Magento\Wishlist\Block\AbstractBlock ['wishlist_id' => $this->getWishlistInstance()->getId(), 'form_key' => $this->_formKey->getFormKey()] ); } + + /** + * @return string + */ + protected function _toHtml() + { + if ($this->currentCustomer->getCustomerId()) { + return parent::_toHtml(); + } else { + return ''; + } + } } diff --git a/app/code/Magento/Wishlist/Controller/Index/Add.php b/app/code/Magento/Wishlist/Controller/Index/Add.php index d19ecf32ff670c82b1ff4045a4557cf7f9340e37..d957719932a2bdac2c787d9f46b72e0a7b66bb72 100644 --- a/app/code/Magento/Wishlist/Controller/Index/Add.php +++ b/app/code/Magento/Wishlist/Controller/Index/Add.php @@ -96,7 +96,7 @@ class Add extends Action\Action implements IndexInterface $result = $wishlist->addNewItem($product, $buyRequest); if (is_string($result)) { - throw new \Magento\Framework\Exception\LocalizedException($result); + throw new \Magento\Framework\Exception\LocalizedException(__($result)); } $wishlist->save(); @@ -112,10 +112,6 @@ class Add extends Action\Action implements IndexInterface $referer = $this->_redirect->getRefererUrl(); } - /** - * Set referer to avoid referring to the compare popup window - */ - $session->setAddActionReferer($referer); /** @var $helper \Magento\Wishlist\Helper\Data */ $helper = $this->_objectManager->get('Magento\Wishlist\Helper\Data')->calculate(); diff --git a/app/code/Magento/Wishlist/Controller/Index/Fromcart.php b/app/code/Magento/Wishlist/Controller/Index/Fromcart.php index aceb8318505b0852b4dfc0ced5b3d381e17e24df..2bf785573e273813fe50c286b3b40f69cada4ab8 100644 --- a/app/code/Magento/Wishlist/Controller/Index/Fromcart.php +++ b/app/code/Magento/Wishlist/Controller/Index/Fromcart.php @@ -51,7 +51,9 @@ class Fromcart extends Action\Action implements IndexInterface try { $item = $cart->getQuote()->getItemById($itemId); if (!$item) { - throw new \Magento\Framework\Exception\LocalizedException(__("The requested cart item doesn't exist.")); + throw new \Magento\Framework\Exception\LocalizedException( + __('The requested cart item doesn\'t exist.') + ); } $productId = $item->getProductId(); diff --git a/app/code/Magento/Wishlist/Controller/Index/Index.php b/app/code/Magento/Wishlist/Controller/Index/Index.php index 12fa1224384affd7e608c486aa87831a6d0ce909..56f08a2e53190b4d28b46d11c9e23642c6b72ea5 100644 --- a/app/code/Magento/Wishlist/Controller/Index/Index.php +++ b/app/code/Magento/Wishlist/Controller/Index/Index.php @@ -17,22 +17,14 @@ class Index extends Action\Action implements IndexInterface */ protected $wishlistProvider; - /** - * @var \Magento\Customer\Model\Session - */ - protected $_customerSession; - /** * @param Action\Context $context - * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Wishlist\Controller\WishlistProviderInterface $wishlistProvider */ public function __construct( Action\Context $context, - \Magento\Customer\Model\Session $customerSession, \Magento\Wishlist\Controller\WishlistProviderInterface $wishlistProvider ) { - $this->_customerSession = $customerSession; $this->wishlistProvider = $wishlistProvider; parent::__construct($context); } @@ -49,19 +41,7 @@ class Index extends Action\Action implements IndexInterface throw new NotFoundException(); } $this->_view->loadLayout(); - - $session = $this->_customerSession; - $block = $this->_view->getLayout()->getBlock('customer.wishlist'); - $referer = $session->getAddActionReferer(true); - if ($block) { - $block->setRefererUrl($this->_redirect->getRefererUrl()); - if ($referer) { - $block->setRefererUrl($referer); - } - } - $this->_view->getLayout()->initMessages(); - $this->_view->renderLayout(); } } diff --git a/app/code/Magento/Wishlist/Controller/WishlistProvider.php b/app/code/Magento/Wishlist/Controller/WishlistProvider.php index 20daf96c7b1011fbca8cd96ed2836ac369b38919..117254895ca23f8e4cf1f9c4f5edd44bced00b48 100644 --- a/app/code/Magento/Wishlist/Controller/WishlistProvider.php +++ b/app/code/Magento/Wishlist/Controller/WishlistProvider.php @@ -81,7 +81,7 @@ class WishlistProvider implements WishlistProviderInterface if (!$wishlist->getId() || $wishlist->getCustomerId() != $customerId) { throw new \Magento\Framework\Exception\NoSuchEntityException( - __("The requested wish list doesn't exist.") + __('The requested wish list doesn\'t exist.') ); } } catch (\Magento\Framework\Exception\NoSuchEntityException $e) { diff --git a/app/code/Magento/Wishlist/Helper/Data.php b/app/code/Magento/Wishlist/Helper/Data.php index fcff26f30b664a28a1c1866ed00ecced2d49bd64..0914b03d69877239bf3678b47a5001fd78da1974 100644 --- a/app/code/Magento/Wishlist/Helper/Data.php +++ b/app/code/Magento/Wishlist/Helper/Data.php @@ -387,7 +387,14 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper protected function _getCartUrlParameters($item) { $continueUrl = $this->urlEncoder->encode( - $this->_getUrl('*/*/*', ['_current' => true, '_use_rewrite' => true, '_scope_to_url' => true]) + $this->_getUrl( + 'wishlist/index/index', + [ + '_current' => true, + '_use_rewrite' => true, + '_scope_to_url' => true + ] + ) ); return [ diff --git a/app/code/Magento/Wishlist/Model/Item.php b/app/code/Magento/Wishlist/Model/Item.php index e64bead64c92ec1c49f718e8a14a746ccbab8c4b..89c11e487da39cc28c8ea14e964237e4baa5203b 100644 --- a/app/code/Magento/Wishlist/Model/Item.php +++ b/app/code/Magento/Wishlist/Model/Item.php @@ -381,7 +381,7 @@ class Item extends AbstractModel implements ItemInterface try { $product = $this->productRepository->getById($this->getProductId(), false, $this->getStoreId()); } catch (NoSuchEntityException $e) { - throw new \Magento\Framework\Exception\LocalizedException(__('Cannot specify product.'), [], $e); + throw new \Magento\Framework\Exception\LocalizedException(__('Cannot specify product.'), $e); } $this->setData('product', $product); } diff --git a/app/code/Magento/Wishlist/Test/Unit/Controller/Index/AddTest.php b/app/code/Magento/Wishlist/Test/Unit/Controller/Index/AddTest.php index 7efb091fa1718dbf272bd2d56c95f400f26dcde2..6b6695e96fa80008a4b0010f77c751f0c8f88e3a 100644 --- a/app/code/Magento/Wishlist/Test/Unit/Controller/Index/AddTest.php +++ b/app/code/Magento/Wishlist/Test/Unit/Controller/Index/AddTest.php @@ -255,7 +255,7 @@ class AddTest extends \PHPUnit_Framework_TestCase ->method('getParams') ->will($this->returnValue([])); - $om = $this->getMock('Magento\Framework\App\ObjectManager', null, [], '', false ); + $om = $this->getMock('Magento\Framework\App\ObjectManager', null, [], '', false); $response = $this->getMock('Magento\Framework\App\Response\Http', null, [], '', false); $eventManager = $this->getMock('Magento\Framework\Event\Manager', null, [], '', false); $url = $this->getMock('Magento\Framework\Url', null, [], '', false); @@ -350,9 +350,9 @@ class AddTest extends \PHPUnit_Framework_TestCase ->method('getParams') ->will($this->returnValue(['product' => 2])); - $om = $this->getMock('Magento\Framework\App\ObjectManager', null, [], '', false ); + $om = $this->getMock('Magento\Framework\App\ObjectManager', null, [], '', false); $response = $this->getMock('Magento\Framework\App\Response\Http', null, [], '', false); - $eventManager = $this->getMock('Magento\Framework\Event\Manager', null, [], '', false ); + $eventManager = $this->getMock('Magento\Framework\Event\Manager', null, [], '', false); $url = $this->getMock('Magento\Framework\Url', null, [], '', false); $actionFlag = $this->getMock('Magento\Framework\App\ActionFlag', null, [], '', false); $redirect = $this->getMock('\Magento\Store\App\Response\Redirect', ['redirect'], [], '', false); @@ -460,9 +460,9 @@ class AddTest extends \PHPUnit_Framework_TestCase ->method('getParams') ->will($this->returnValue(['product' => 2])); - $om = $this->getMock('Magento\Framework\App\ObjectManager', null, [], '', false ); + $om = $this->getMock('Magento\Framework\App\ObjectManager', null, [], '', false); $response = $this->getMock('Magento\Framework\App\Response\Http', null, [], '', false); - $eventManager = $this->getMock('Magento\Framework\Event\Manager', null, [], '', false ); + $eventManager = $this->getMock('Magento\Framework\Event\Manager', null, [], '', false); $url = $this->getMock('Magento\Framework\Url', null, [], '', false); $actionFlag = $this->getMock('Magento\Framework\App\ActionFlag', null, [], '', false); $redirect = $this->getMock('\Magento\Store\App\Response\Redirect', ['redirect'], [], '', false); @@ -589,7 +589,7 @@ class AddTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue($product)); $exception = new \Exception('Exception'); - $wishListItem = new \stdClass(); + $wishListItem = new \stdClass(); $wishlist = $this->getMock('Magento\Wishlist\Model\Wishlist', ['addNewItem', 'save', 'getId'], [], '', false); $wishlist @@ -649,8 +649,8 @@ class AddTest extends \PHPUnit_Framework_TestCase ->method('critical') ->with($exception) ->will($this->returnValue(true)); - - $om = $this->getMock('Magento\Framework\App\ObjectManager', ['get'], [], '', false ); + + $om = $this->getMock('Magento\Framework\App\ObjectManager', ['get'], [], '', false); $om ->expects($this->at(0)) ->method('get') @@ -671,9 +671,9 @@ class AddTest extends \PHPUnit_Framework_TestCase ->method('get') ->with('Psr\Log\LoggerInterface') ->will($this->returnValue($logger)); - + $response = $this->getMock('Magento\Framework\App\Response\Http', null, [], '', false); - $eventManager = $this->getMock('Magento\Framework\Event\Manager', ['dispatch'], [], '', false ); + $eventManager = $this->getMock('Magento\Framework\Event\Manager', ['dispatch'], [], '', false); $eventManager ->expects($this->once()) ->method('dispatch') @@ -757,11 +757,6 @@ class AddTest extends \PHPUnit_Framework_TestCase ->expects($this->once()) ->method('getBeforeWishlistUrl') ->will($this->returnValue('http://test-url.com')); - $this->customerSession - ->expects($this->once()) - ->method('setAddActionReferer') - ->with('http://test-url.com') - ->will($this->returnValue(null)); $this->customerSession ->expects($this->once()) ->method('setBeforeWishlistUrl') diff --git a/app/code/Magento/Wishlist/Test/Unit/Controller/Index/IndexTest.php b/app/code/Magento/Wishlist/Test/Unit/Controller/Index/IndexTest.php index e247ea5fbd595450f3558c82c0ba5ea7a08e1c3f..7199faa0652cb2eb5d9af9f4f585d83bd47c1113 100644 --- a/app/code/Magento/Wishlist/Test/Unit/Controller/Index/IndexTest.php +++ b/app/code/Magento/Wishlist/Test/Unit/Controller/Index/IndexTest.php @@ -28,11 +28,6 @@ class IndexTest extends \PHPUnit_Framework_TestCase */ protected $wishlistProvider; - /** - * @var \Magento\Customer\Model\Session|\PHPUnit_Framework_MockObject_MockObject - */ - protected $customerSession; - /** * @var \Magento\Framework\App\View|\PHPUnit_Framework_MockObject_MockObject */ @@ -48,7 +43,6 @@ class IndexTest extends \PHPUnit_Framework_TestCase $this->context = $this->getMock('Magento\Framework\App\Action\Context', [], [], '', false); $this->request = $this->getMock('Magento\Framework\App\Request\Http', [], [], '', false); $this->response = $this->getMock('Magento\Framework\App\Response\Http', [], [], '', false); - $this->customerSession = $this->getMock('Magento\Customer\Model\Session', [], [], '', false); $this->wishlistProvider = $this->getMock('Magento\Wishlist\Controller\WishlistProvider', [], [], '', false); $this->view = $this->getMock('Magento\Framework\App\View', [], [], '', false); $this->redirect = $this->getMock('\Magento\Store\App\Response\Redirect', [], [], '', false); @@ -105,7 +99,6 @@ class IndexTest extends \PHPUnit_Framework_TestCase $this->prepareContext(); return new \Magento\Wishlist\Controller\Index\Index( $this->context, - $this->customerSession, $this->wishlistProvider ); } @@ -126,29 +119,7 @@ class IndexTest extends \PHPUnit_Framework_TestCase { $wishlist = $this->getMock('Magento\Wishlist\Model\Wishlist', [], [], '', false); - $block = $this->getMock('Magento\Ui\Component\Form\Element\Input', [], [], '', false); - $block - ->expects($this->at(0)) - ->method('__call') - ->with('setRefererUrl', ['http://referer-url-test.com']) - ->willReturn(true); - $block - ->expects($this->at(1)) - ->method('__call') - ->with('setRefererUrl', ['http://referer-url.com']) - ->willReturn(true); - - $this->redirect - ->expects($this->once()) - ->method('getRefererUrl') - ->willReturn('http://referer-url-test.com'); - $layout = $this->getMock('Magento\Framework\View\Layout', [], [], '', false); - $layout - ->expects($this->once()) - ->method('getBlock') - ->with('customer.wishlist') - ->willReturn($block); $layout ->expects($this->once()) ->method('initMessages') @@ -164,7 +135,7 @@ class IndexTest extends \PHPUnit_Framework_TestCase ->method('loadLayout') ->willReturn(true); $this->view - ->expects($this->exactly(2)) + ->expects($this->once()) ->method('getLayout') ->willReturn($layout); $this->view @@ -172,12 +143,6 @@ class IndexTest extends \PHPUnit_Framework_TestCase ->method('renderLayout') ->willReturn(true); - $this->customerSession - ->expects($this->once()) - ->method('__call') - ->with('getAddActionReferer', [true]) - ->willReturn('http://referer-url.com'); - $this->getController()->execute(); } } diff --git a/app/code/Magento/Wishlist/Test/Unit/Controller/Index/UpdateItemOptionsTest.php b/app/code/Magento/Wishlist/Test/Unit/Controller/Index/UpdateItemOptionsTest.php old mode 100644 new mode 100755 index 6a317fb288eb3dd3ddb7412562778d444093bb26..9fddb7383a3034e51fcf973eb797f4638189083a --- a/app/code/Magento/Wishlist/Test/Unit/Controller/Index/UpdateItemOptionsTest.php +++ b/app/code/Magento/Wishlist/Test/Unit/Controller/Index/UpdateItemOptionsTest.php @@ -71,6 +71,11 @@ class UpdateItemOptionsTest extends \PHPUnit_Framework_TestCase */ protected $eventManager; + /** + * SetUp method + * + * @return void + */ protected function setUp() { $this->productRepository = $this->getMock('Magento\Catalog\Model\ProductRepository', [], [], '', false); @@ -87,6 +92,11 @@ class UpdateItemOptionsTest extends \PHPUnit_Framework_TestCase $this->eventManager = $this->getMock('Magento\Framework\Event\Manager', [], [], '', false); } + /** + * TearDown method + * + * @return void + */ public function tearDown() { unset( @@ -104,6 +114,11 @@ class UpdateItemOptionsTest extends \PHPUnit_Framework_TestCase ); } + /** + * Prepare context + * + * @return void + */ public function prepareContext() { $actionFlag = $this->getMock('Magento\Framework\App\ActionFlag', [], [], '', false); @@ -146,6 +161,11 @@ class UpdateItemOptionsTest extends \PHPUnit_Framework_TestCase ->willReturn($this->messageManager); } + /** + * Get controller + * + * @return \Magento\Wishlist\Controller\Index\UpdateItemOptions + */ protected function getController() { $this->prepareContext(); @@ -157,6 +177,11 @@ class UpdateItemOptionsTest extends \PHPUnit_Framework_TestCase ); } + /** + * Test execute without product id + * + * @return void + */ public function testExecuteWithoutProductId() { $this->request @@ -174,6 +199,11 @@ class UpdateItemOptionsTest extends \PHPUnit_Framework_TestCase $this->getController()->execute(); } + /** + * Test execute without product + * + * @return void + */ public function testExecuteWithoutProduct() { $this->request @@ -182,12 +212,11 @@ class UpdateItemOptionsTest extends \PHPUnit_Framework_TestCase ->with('product') ->willReturn(2); - $exception = $this->getMock('Magento\Framework\Exception\NoSuchEntityException', [], [], '', false); $this->productRepository ->expects($this->once()) ->method('getById') ->with(2) - ->willThrowException($exception); + ->willThrowException(new \Magento\Framework\Exception\NoSuchEntityException()); $this->messageManager ->expects($this->once()) @@ -204,6 +233,11 @@ class UpdateItemOptionsTest extends \PHPUnit_Framework_TestCase $this->getController()->execute(); } + /** + * Test execute without wish list + * + * @return void + */ public function testExecuteWithoutWishList() { $product = $this->getMock('Magento\Catalog\Model\Product', [], [], '', false); @@ -270,6 +304,9 @@ class UpdateItemOptionsTest extends \PHPUnit_Framework_TestCase } /** + * Test execute add success exception + * + * @return void * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ public function testExecuteAddSuccessException() @@ -369,16 +406,15 @@ class UpdateItemOptionsTest extends \PHPUnit_Framework_TestCase ->with('wishlist_update_item', ['wishlist' => $wishlist, 'product' => $product, 'item' => $item]) ->willReturn(true); - $exception = $this->getMock('\Magento\Framework\Exception\LocalizedException', [], [], '', false); $this->messageManager ->expects($this->once()) ->method('addSuccess') ->with('Test name has been updated in your wish list.', null) - ->willThrowException($exception); + ->willThrowException(new \Magento\Framework\Exception\LocalizedException(__('error-message'))); $this->messageManager ->expects($this->once()) ->method('addError') - ->with('', null) + ->with('error-message', null) ->willReturn(true); $this->redirect @@ -390,6 +426,9 @@ class UpdateItemOptionsTest extends \PHPUnit_Framework_TestCase $this->getController()->execute(); } /** + * Test execute add success critical exception + * + * @return void * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ public function testExecuteAddSuccessCriticalException() @@ -399,7 +438,7 @@ class UpdateItemOptionsTest extends \PHPUnit_Framework_TestCase $item = $this->getMock('Magento\Wishlist\Model\Item', [], [], '', false); $helper = $this->getMock('Magento\Wishlist\Helper\Data', [], [], '', false); $logger = $this->getMock('Magento\Framework\Logger\Monolog', [], [], '', false); - $exception = $this->getMock('Exception', [], [], '', false); + $exception = new \Exception(); $logger ->expects($this->once()) diff --git a/app/code/Magento/Wishlist/Test/Unit/Helper/DataTest.php b/app/code/Magento/Wishlist/Test/Unit/Helper/DataTest.php index 5bb6173097935c6100c2fa4b4ad1902fd7776e71..08108bf77b12d79d8f9768eceac6c0db4ecf24d3 100644 --- a/app/code/Magento/Wishlist/Test/Unit/Helper/DataTest.php +++ b/app/code/Magento/Wishlist/Test/Unit/Helper/DataTest.php @@ -72,7 +72,7 @@ class DataTest extends \PHPUnit_Framework_TestCase } else { $urlBuilder->expects($this->any()) ->method('getUrl') - ->with('*/*/*', ['_current' => true, '_use_rewrite' => true, '_scope_to_url' => true]) + ->with('wishlist/index/index', ['_current' => true, '_use_rewrite' => true, '_scope_to_url' => true]) ->will($this->returnValue($this->url)); } diff --git a/app/code/Magento/Wishlist/etc/config.xml b/app/code/Magento/Wishlist/etc/config.xml index cdb6ad259a73c23099cc0e14420d84242e45efab..77c070c2b505b4679a54b7dfbd36e5295955be49 100644 --- a/app/code/Magento/Wishlist/etc/config.xml +++ b/app/code/Magento/Wishlist/etc/config.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Core/etc/config.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Store/etc/config.xsd"> <default> <wishlist> <general> diff --git a/app/code/Magento/Wishlist/etc/frontend/page_types.xml b/app/code/Magento/Wishlist/etc/frontend/page_types.xml index cd44dd1f773edd2f4e179b0d24f5eb5b888d10c0..9d938ce725b41fca3bbdf872201865c8bca55131 100644 --- a/app/code/Magento/Wishlist/etc/frontend/page_types.xml +++ b/app/code/Magento/Wishlist/etc/frontend/page_types.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> -<page_types xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../Core/etc/page_types.xsd"> +<page_types xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_types.xsd"> <type id="wishlist_index_index" label="Customer My Account My Wish List"/> <type id="wishlist_index_share" label="Customer My Account Wish List Sharing Form"/> <type id="wishlist_shared_index" label="Customer Shared Wish List View"/> diff --git a/app/code/Magento/Wishlist/view/frontend/layout/wishlist_index_configure.xml b/app/code/Magento/Wishlist/view/frontend/layout/wishlist_index_configure.xml index 874fa3beb833d6396c21af38e820c31521851564..b67ab0352d844cb2edd890d8b2b00b2593cdac7f 100644 --- a/app/code/Magento/Wishlist/view/frontend/layout/wishlist_index_configure.xml +++ b/app/code/Magento/Wishlist/view/frontend/layout/wishlist_index_configure.xml @@ -9,7 +9,7 @@ <update handle="catalog_product_view"/> <body> <referenceContainer name="product.info.social"> - <block class="Magento\Wishlist\Block\Item\Configure" name="product.info.addto" as="addto" template="Magento_Wishlist::item/configure/addto.phtml"/> + <block class="Magento\Wishlist\Block\Item\Configure" name="product.info.addto" as="addto" template="Magento_Wishlist::item/configure/addto.phtml" cacheable="false"/> </referenceContainer> </body> </page> diff --git a/app/code/Magento/Wishlist/view/frontend/layout/wishlist_index_index.xml b/app/code/Magento/Wishlist/view/frontend/layout/wishlist_index_index.xml index 5f000a79c1859578ac853abd49df7f58ad7d65e1..6943f7e2ee4f9407a94822274ea69ac442d37747 100644 --- a/app/code/Magento/Wishlist/view/frontend/layout/wishlist_index_index.xml +++ b/app/code/Magento/Wishlist/view/frontend/layout/wishlist_index_index.xml @@ -12,12 +12,12 @@ <block class="Magento\Framework\View\Element\Js\Components" name="wishlist_head_components" template="Magento_Wishlist::js/components.phtml"/> </referenceBlock> <referenceContainer name="content"> - <block class="Magento\Wishlist\Block\Customer\Wishlist" name="customer.wishlist" template="view.phtml" cacheable="false"> + <block class="Magento\Wishlist\Block\Customer\Wishlist" name="customer.wishlist" template="view.phtml"> <block class="Magento\Wishlist\Block\Rss\Link" name="wishlist.rss.link" template="rss/wishlist.phtml"/> - <block class="Magento\Wishlist\Block\Customer\Wishlist\Items" name="customer.wishlist.items" as="items" template="item/list.phtml" cacheable="false"> - <block class="Magento\Wishlist\Block\Customer\Wishlist\Item\Column\Image" name="customer.wishlist.item.image" template="item/column/image.phtml" cacheable="false"/> - <block class="Magento\Wishlist\Block\Customer\Wishlist\Item\Column\Info" name="customer.wishlist.item.name" template="item/column/name.phtml" cacheable="false"/> - <block class="Magento\Wishlist\Block\Customer\Wishlist\Item\Column\Cart" name="customer.wishlist.item.price" template="item/column/price.phtml" cacheable="false"> + <block class="Magento\Wishlist\Block\Customer\Wishlist\Items" name="customer.wishlist.items" as="items" template="item/list.phtml"> + <block class="Magento\Wishlist\Block\Customer\Wishlist\Item\Column\Image" name="customer.wishlist.item.image" template="item/column/image.phtml"/> + <block class="Magento\Wishlist\Block\Customer\Wishlist\Item\Column\Info" name="customer.wishlist.item.name" template="item/column/name.phtml"/> + <block class="Magento\Wishlist\Block\Customer\Wishlist\Item\Column\Cart" name="customer.wishlist.item.price" template="item/column/price.phtml"> <block class="Magento\Catalog\Pricing\Render" name="product.price.render.wishlist"> <arguments> <argument name="price_render" xsi:type="string">product.price.render.default</argument> @@ -26,36 +26,36 @@ <argument name="zone" xsi:type="string">item_list</argument> </arguments> </block> - <block class="Magento\Wishlist\Block\Customer\Wishlist\Item\Options" name="customer.wishlist.item.options" cacheable="false"/> + <block class="Magento\Wishlist\Block\Customer\Wishlist\Item\Options" name="customer.wishlist.item.options"/> </block> - <block class="Magento\Wishlist\Block\Customer\Wishlist\Item\Column\Actions" name="customer.wishlist.item.inner" template="item/column/actions.phtml" cacheable="false"> + <block class="Magento\Wishlist\Block\Customer\Wishlist\Item\Column\Actions" name="customer.wishlist.item.inner" template="item/column/actions.phtml"> <arguments> <argument name="css_class" xsi:type="string">product-item-inner</argument> </arguments> - <block class="Magento\Wishlist\Block\Customer\Wishlist\Item\Column\Comment" name="customer.wishlist.item.comment" template="item/column/comment.phtml" cacheable="false"> + <block class="Magento\Wishlist\Block\Customer\Wishlist\Item\Column\Comment" name="customer.wishlist.item.comment" template="item/column/comment.phtml"> <arguments> <argument name="title" translate="true" xsi:type="string">Product Details and Comment</argument> </arguments> </block> - <block class="Magento\Wishlist\Block\Customer\Wishlist\Item\Column\Cart" name="customer.wishlist.item.cart" template="item/column/cart.phtml" cacheable="false"> + <block class="Magento\Wishlist\Block\Customer\Wishlist\Item\Column\Cart" name="customer.wishlist.item.cart" template="item/column/cart.phtml"> <arguments> <argument name="title" translate="true" xsi:type="string">Add to Cart</argument> </arguments> </block> - <block class="Magento\Wishlist\Block\Customer\Wishlist\Item\Column\Actions" name="customer.wishlist.item.actions" template="item/column/actions.phtml" cacheable="false"> + <block class="Magento\Wishlist\Block\Customer\Wishlist\Item\Column\Actions" name="customer.wishlist.item.actions" template="item/column/actions.phtml"> <arguments> <argument name="css_class" xsi:type="string">product-item-actions</argument> </arguments> - <block class="Magento\Wishlist\Block\Customer\Wishlist\Item\Column\Edit" name="customer.wishlist.item.edit" template="item/column/edit.phtml" before="-" cacheable="false"/> - <block class="Magento\Wishlist\Block\Customer\Wishlist\Item\Column\Remove" name="customer.wishlist.item.remove" template="item/column/remove.phtml" cacheable="false"/> + <block class="Magento\Wishlist\Block\Customer\Wishlist\Item\Column\Edit" name="customer.wishlist.item.edit" template="item/column/edit.phtml" before="-"/> + <block class="Magento\Wishlist\Block\Customer\Wishlist\Item\Column\Remove" name="customer.wishlist.item.remove" template="item/column/remove.phtml"/> </block> </block> </block> <container name="customer.wishlist.buttons" as="control_buttons" label="Wishlist Control Buttons"> - <block class="Magento\Wishlist\Block\Customer\Wishlist\Button" name="customer.wishlist.button.update" template="button/update.phtml" cacheable="false"/> - <block class="Magento\Wishlist\Block\Customer\Wishlist\Button" name="customer.wishlist.button.share" template="button/share.phtml" cacheable="false"/> - <block class="Magento\Wishlist\Block\Customer\Wishlist\Button" name="customer.wishlist.button.toCart" template="button/tocart.phtml" cacheable="false"/> + <block class="Magento\Wishlist\Block\Customer\Wishlist\Button" name="customer.wishlist.button.update" template="button/update.phtml"/> + <block class="Magento\Wishlist\Block\Customer\Wishlist\Button" name="customer.wishlist.button.share" template="button/share.phtml"/> + <block class="Magento\Wishlist\Block\Customer\Wishlist\Button" name="customer.wishlist.button.toCart" template="button/tocart.phtml"/> </container> </block> </referenceContainer> diff --git a/app/code/Magento/Wishlist/view/frontend/templates/shared.phtml b/app/code/Magento/Wishlist/view/frontend/templates/shared.phtml index 9b145c00421d1ac1884b166358cf13ac9d081aef..9a94c0a193811fa75baa0a8cc99aaa121adfbde4 100644 --- a/app/code/Magento/Wishlist/view/frontend/templates/shared.phtml +++ b/app/code/Magento/Wishlist/view/frontend/templates/shared.phtml @@ -11,7 +11,7 @@ $imageBlock = $block->getLayout()->createBlock('Magento\Catalog\Block\Product\I ?> <?php if ($block->hasWishlistItems()): ?> - <form class="form shared wishlist" action="<?php echo $block->getUrl('*/*/update') ?>" method="post"> + <form class="form shared wishlist" action="<?php echo $block->getUrl('wishlist/index/update') ?>" method="post"> <div class="wishlist table-wrapper"> <table class="table data wishlist" id="wishlist-table"> <caption class="table-caption"><?php echo __('Wish List'); ?></caption> diff --git a/app/code/Magento/Wishlist/view/frontend/templates/view.phtml b/app/code/Magento/Wishlist/view/frontend/templates/view.phtml index 52ea6d9490f7355b7ae6594bd4ebebbc3250a910..035364489f3caa8386c6d57bd34e6994b2d965ac 100644 --- a/app/code/Magento/Wishlist/view/frontend/templates/view.phtml +++ b/app/code/Magento/Wishlist/view/frontend/templates/view.phtml @@ -25,7 +25,7 @@ "confirmRemoveMessage":"<?php echo __("Are you sure you want to remove this product from your wishlist?") ?>", "addAllToCartUrl":"<?php echo $block->getAddAllToCartUrl(); ?>", "commentString":""}, - "validation": {}}' action="<?php echo $block->getUrl('*/*/update', ['wishlist_id' => $block->getWishlistInstance()->getId()]) ?>" method="post"> + "validation": {}}' action="<?php echo $block->getUrl('wishlist/index/update', ['wishlist_id' => $block->getWishlistInstance()->getId()]) ?>" method="post"> <?php echo $block->getChildHtml('top'); ?> <?php if ($block->hasWishlistItems()): ?> <?php echo $block->getBlockHtml('formkey');?> diff --git a/app/design/frontend/Magento/blank/Magento_Catalog/web/css/source/_module.less b/app/design/frontend/Magento/blank/Magento_Catalog/web/css/source/_module.less index e96d4b1f33cecb1eb25ddb04e38e4a78934f2bae..35ecf5e74e4fca8cdb6d78ad77368808c74a5066 100644 --- a/app/design/frontend/Magento/blank/Magento_Catalog/web/css/source/_module.less +++ b/app/design/frontend/Magento/blank/Magento_Catalog/web/css/source/_module.less @@ -210,6 +210,13 @@ .product-reviews-summary .reviews-actions { .font-size(@font-size__base); } + .product-options-wrapper { + .field { + .note { + display: block; + } + } + } } .product-info-main, diff --git a/app/design/frontend/Magento/blank/Magento_CatalogSearch/web/css/source/_module.less b/app/design/frontend/Magento/blank/Magento_CatalogSearch/web/css/source/_module.less index 2217a6cf6e39b5ea20b35374044fac7fefe94b4a..66009f0069383e2a7f2352c3cc90a784ce45b42b 100644 --- a/app/design/frontend/Magento/blank/Magento_CatalogSearch/web/css/source/_module.less +++ b/app/design/frontend/Magento/blank/Magento_CatalogSearch/web/css/source/_module.less @@ -22,6 +22,9 @@ display: none; } } + .block-content { + margin-bottom: 0; + } .label { .icon-font( @_icon-font-content: @icon-search, diff --git a/app/design/frontend/Magento/blank/web/css/source/_forms.less b/app/design/frontend/Magento/blank/web/css/source/_forms.less index 7d172a1ddaa54005a265cace63d7b958ff6909f7..563084653f5611d0b8877b492d984b77cac69e91 100644 --- a/app/design/frontend/Magento/blank/web/css/source/_forms.less +++ b/app/design/frontend/Magento/blank/web/css/source/_forms.less @@ -92,7 +92,9 @@ select:focus ~ .tooltip .tooltip-content { margin: 0; > .field:not(.choice) >, .fields > .field { - margin: 0 0 @form-field__vertical-indent; + &:not(:last-child) { + margin: 0 0 @form-field__vertical-indent; + } .label { margin: 0 0 4px; padding: 0 0 @indent__xs; diff --git a/app/design/frontend/Magento/luma/Magento_Catalog/web/css/source/_module.less b/app/design/frontend/Magento/luma/Magento_Catalog/web/css/source/_module.less index 95aded3d85ad63e0ec74da5035e4ca60e26c54e2..839f0571a4a4d7b56002f25d4fe7b2d5004e4107 100644 --- a/app/design/frontend/Magento/luma/Magento_Catalog/web/css/source/_module.less +++ b/app/design/frontend/Magento/luma/Magento_Catalog/web/css/source/_module.less @@ -249,6 +249,14 @@ margin-top: @form-field__vertical-indent; } } + .product-options-wrapper { + .field { + .note { + display: block; + .css(margin-top, @indent__xs); + } + } + } } .product-options-bottom .price-box, diff --git a/app/design/frontend/Magento/luma/Magento_CatalogSearch/web/css/source/_module.less b/app/design/frontend/Magento/luma/Magento_CatalogSearch/web/css/source/_module.less index d2a5755580a566f7dc8fb679dae7bed14df3e8ec..c51347a3b6e9b5ffae159d4604c82511a9d6fbe3 100644 --- a/app/design/frontend/Magento/luma/Magento_CatalogSearch/web/css/source/_module.less +++ b/app/design/frontend/Magento/luma/Magento_CatalogSearch/web/css/source/_module.less @@ -22,6 +22,9 @@ display: none; } } + .block-content { + margin-bottom: 0; + } .label { .icon-font( @_icon-font-content: @icon-search, @@ -61,7 +64,6 @@ .nested { display: none; } - } .search-autocomplete { diff --git a/app/design/frontend/Magento/luma/Magento_Customer/web/css/source/_module.less b/app/design/frontend/Magento/luma/Magento_Customer/web/css/source/_module.less index 15f34bcbb6588e7be51ec879682f277f9045dee6..a38d28d2443c18e53258eec7ee2343a946cd48c1 100644 --- a/app/design/frontend/Magento/luma/Magento_Customer/web/css/source/_module.less +++ b/app/design/frontend/Magento/luma/Magento_Customer/web/css/source/_module.less @@ -137,8 +137,10 @@ //-------------------------------------- .block { &:extend(.abs-margin-for-blocks-and-widgets all); - &:last-child { - margin-bottom: 0; + .column.main & { + &:last-child { + margin-bottom: 0; + } } .title { strong { diff --git a/app/design/frontend/Magento/luma/web/css/source/_forms.less b/app/design/frontend/Magento/luma/web/css/source/_forms.less index 8c882c19f315aff01d8a282acfd310eaf0dabca5..e9a975768c81f2216d0adc5cc5830bd611f595fc 100644 --- a/app/design/frontend/Magento/luma/web/css/source/_forms.less +++ b/app/design/frontend/Magento/luma/web/css/source/_forms.less @@ -117,7 +117,9 @@ select:focus ~ .tooltip .tooltip-content { margin: 0; > .field:not(.choice) >, .fields > .field { - margin: 0 0 @form-field__vertical-indent; + &:not(:last-child) { + margin: 0 0 @form-field__vertical-indent; + } .label { margin: 0 0 4px; padding: 0 0 @indent__xs; diff --git a/app/etc/di.xml b/app/etc/di.xml index 47d04467d3c01cb2f35803761ddd8824101ada0a..a3da2e85a1954b11a9415d002266b285fad6b676 100755 --- a/app/etc/di.xml +++ b/app/etc/di.xml @@ -82,7 +82,7 @@ <preference for="Magento\Framework\Mview\View\SubscriptionInterface" type="Magento\Framework\Mview\View\Subscription" /> <preference for="Magento\Framework\Mview\View\ChangelogInterface" type="Magento\Framework\Mview\View\Changelog" /> <preference for="Magento\Framework\View\Design\FileResolution\Fallback\CacheDataInterface" type="Magento\Framework\View\Design\FileResolution\Fallback\CacheData\Flat"/> - <preference for="Magento\Framework\Api\MetadataServiceInterface" type="Magento\Framework\Api\Config\MetadataConfig"/> + <preference for="Magento\Framework\Api\MetadataServiceInterface" type="Magento\Framework\Api\DefaultMetadataService"/> <preference for="Magento\Framework\Api\MetadataObjectInterface" type="Magento\Framework\Api\AttributeMetadata"/> <preference for="Magento\Framework\Api\SearchCriteriaInterface" type="Magento\Framework\Api\SearchCriteria"/> <preference for="Magento\Framework\App\Rss\UrlBuilderInterface" type="Magento\Framework\App\Rss\UrlBuilder"/> @@ -696,27 +696,6 @@ <argument name="raise_php_limits" xsi:type="boolean">false</argument> </arguments> </type> - <type name="Magento\Framework\View\Asset\PreProcessor\Pool"> - <arguments> - <argument name="preProcessors" xsi:type="array"> - <item name="less" xsi:type="array"> - <item name="css" xsi:type="array"> - <item name="less_css" xsi:type="string">Magento\Framework\Css\PreProcessor\Less</item> - <item name="module_notation" xsi:type="string">Magento\Framework\View\Asset\PreProcessor\ModuleNotation</item> - </item> - <item name="less" xsi:type="array"> - <item name="magento_import" xsi:type="string">Magento\Framework\Less\PreProcessor\Instruction\MagentoImport</item> - <item name="import" xsi:type="string">Magento\Framework\Less\PreProcessor\Instruction\Import</item> - </item> - </item> - <item name="css" xsi:type="array"> - <item name="css" xsi:type="array"> - <item name="module_notation" xsi:type="string">Magento\Framework\View\Asset\PreProcessor\ModuleNotation</item> - </item> - </item> - </argument> - </arguments> - </type> <type name="Magento\Framework\App\DefaultPath\DefaultPath"> <arguments> <argument name="parts" xsi:type="array"> diff --git a/composer.json b/composer.json index e29f9de8be6ff85c6eeebf84e5da449dedeba559..aad787f6282507de20e66d00875d130a09c659cc 100644 --- a/composer.json +++ b/composer.json @@ -79,7 +79,6 @@ "magento/module-configurable-product": "self.version", "magento/module-contact": "self.version", "magento/module-cookie": "self.version", - "magento/module-core": "self.version", "magento/module-cron": "self.version", "magento/module-currency-symbol": "self.version", "magento/module-customer": "self.version", diff --git a/composer.lock b/composer.lock index 5337e32b2c094312a9be6fb56bafbc7632a931d5..097347dd21bfd76087c53e0b2424d5ee3b4a3d2d 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "933a1cf749db0c7e6d16e357c12cdaa8", + "hash": "8633d753763a17a13717a8380e3cb46b", "packages": [ { "name": "composer/composer", diff --git a/dev/shell/dependency.php b/dev/shell/dependency.php index 29ee2cd8aa6981e3bd85f128cee1c85139c82611..bd6fd8de21af01a3fd46f45efb75b3d090e1a30a 100644 --- a/dev/shell/dependency.php +++ b/dev/shell/dependency.php @@ -19,8 +19,6 @@ const KEY_COMPONENT_NAME = 'name'; const KEY_COMPONENT_DEPENDENCIES = 'dependencies'; const KEY_COMPONENT_DEPENDENTS = 'dependents'; -const KEY_MAGENTO_CORE_MODULE = 'magento/module-core'; - $modules = []; $componentsByName = []; @@ -256,8 +254,6 @@ function initialize() if (count($component[KEY_COMPONENT_MODULES]) == 1) { $component[KEY_COMPONENT_NAME] = $component[KEY_COMPONENT_MODULES][0]; $modules[$component[KEY_COMPONENT_MODULES][0]][KEY_MODULE_COMPONENT] = $component[KEY_COMPONENT_NAME]; - } elseif (in_array(KEY_MAGENTO_CORE_MODULE, $component[KEY_COMPONENT_MODULES])) { - $component[KEY_COMPONENT_NAME] = KEY_MAGENTO_CORE_MODULE; } else { $component[KEY_COMPONENT_NAME] = implode(':', $component[KEY_COMPONENT_MODULES]); } diff --git a/dev/tests/api-functional/_files/Magento/TestModule1/Service/V1/AllSoapAndRest.php b/dev/tests/api-functional/_files/Magento/TestModule1/Service/V1/AllSoapAndRest.php index f5f821b4fb2a578ec20c93c4694f417dc0180e55..0c7df325f28d5d13ade1d440364c0f48e4b9e32d 100644 --- a/dev/tests/api-functional/_files/Magento/TestModule1/Service/V1/AllSoapAndRest.php +++ b/dev/tests/api-functional/_files/Magento/TestModule1/Service/V1/AllSoapAndRest.php @@ -5,7 +5,7 @@ */ namespace Magento\TestModule1\Service\V1; -use Magento\TestModule1\Service\V1\Entity\CustomAttributeDataObjectFactory; +use Magento\TestModuleMSC\Model\Data\CustomAttributeDataObjectFactory; use Magento\TestModule1\Service\V1\Entity\Item; use Magento\TestModule1\Service\V1\Entity\ItemFactory; diff --git a/dev/tests/api-functional/_files/Magento/TestModule1/Service/V1/Entity/CustomAttributeDataObject.php b/dev/tests/api-functional/_files/Magento/TestModule1/Service/V1/Entity/CustomAttributeDataObject.php deleted file mode 100644 index 05c5581b7d1afb01ad5b3a8e61424c1f39656dc9..0000000000000000000000000000000000000000 --- a/dev/tests/api-functional/_files/Magento/TestModule1/Service/V1/Entity/CustomAttributeDataObject.php +++ /dev/null @@ -1,28 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -// @codingStandardsIgnoreFile - -namespace Magento\TestModule1\Service\V1\Entity; - -class CustomAttributeDataObject extends \Magento\Framework\Api\AbstractExtensibleObject -{ - /** - * @return string - */ - public function getName() - { - return $this->_data['name']; - } - /** - * @param string $name - * @return $this - */ - public function setName($name) - { - return $this->setData('name', $name); - } -} diff --git a/dev/tests/api-functional/_files/Magento/TestModule1/Service/V1/Entity/CustomAttributeNestedDataObject.php b/dev/tests/api-functional/_files/Magento/TestModule1/Service/V1/Entity/CustomAttributeNestedDataObject.php deleted file mode 100644 index d1ead31be911b0f0895150e7e433cde576ddb8a8..0000000000000000000000000000000000000000 --- a/dev/tests/api-functional/_files/Magento/TestModule1/Service/V1/Entity/CustomAttributeNestedDataObject.php +++ /dev/null @@ -1,29 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -// @codingStandardsIgnoreFile - -namespace Magento\TestModule1\Service\V1\Entity; - -class CustomAttributeNestedDataObject extends \Magento\Framework\Api\AbstractExtensibleObject -{ - /** - * @return string - */ - public function getName() - { - return $this->_data['name']; - } - - /** - * @param string $name - * @return $this - */ - public function setName($name) - { - return $this->setData('name', $name); - } -} diff --git a/dev/tests/api-functional/_files/Magento/TestModule1/Service/V1/Entity/Eav/AttributeMetadata.php b/dev/tests/api-functional/_files/Magento/TestModule1/Service/V1/Entity/Eav/AttributeMetadata.php deleted file mode 100644 index b8a87f3d74056569a1fe6a502c8985cd4148d86b..0000000000000000000000000000000000000000 --- a/dev/tests/api-functional/_files/Magento/TestModule1/Service/V1/Entity/Eav/AttributeMetadata.php +++ /dev/null @@ -1,68 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -// @codingStandardsIgnoreFile - -namespace Magento\TestModule1\Service\V1\Entity\Eav; - -use Magento\Framework\Api\AbstractExtensibleObject; -use Magento\Framework\Api\MetadataObjectInterface; - -/** - * Class AttributeMetadata - */ -class AttributeMetadata extends AbstractExtensibleObject implements MetadataObjectInterface -{ - /**#@+ - * Constants used as keys into $_data - */ - const ATTRIBUTE_ID = 'attribute_id'; - - const ATTRIBUTE_CODE = 'attribute_code'; - /**#@-*/ - - /** - * Retrieve id of the attribute. - * - * @return string|null - */ - public function getAttributeId() - { - return $this->_get(self::ATTRIBUTE_ID); - } - - /** - * Set id of the attribute. - * - * @param string $attributeId - * @return $this - */ - public function setAttributeId($attributeId) - { - return $this->setData(self::ATTRIBUTE_ID, $attributeId); - } - - /** - * Retrieve code of the attribute. - * - * @return string|null - */ - public function getAttributeCode() - { - return $this->_get(self::ATTRIBUTE_CODE); - } - - /** - * Set code of the attribute. - * - * @param string $attributeCode - * @return $this - */ - public function setAttributeCode($attributeCode) - { - return $this->setData(self::ATTRIBUTE_CODE, $attributeCode); - } -} diff --git a/dev/tests/api-functional/_files/Magento/TestModule1/etc/data_object.xml b/dev/tests/api-functional/_files/Magento/TestModule1/etc/data_object.xml index 19cdbc3710a713062ae5a42677ebf9d551c75e55..de2236e2195f380aedd5614447065bc9e480f7aa 100644 --- a/dev/tests/api-functional/_files/Magento/TestModule1/etc/data_object.xml +++ b/dev/tests/api-functional/_files/Magento/TestModule1/etc/data_object.xml @@ -7,11 +7,11 @@ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/Api/etc/data_object.xsd"> <custom_attributes for="Magento\TestModule1\Service\V1\Entity\Item"> - <attribute code="custom_attribute_data_object" type="Magento\TestModule1\Service\V1\Entity\CustomAttributeDataObject" /> + <attribute code="custom_attribute_data_object" type="Magento\TestModuleMSC\Model\Data\CustomAttributeDataObject" /> <attribute code="custom_attribute_string" type="string" /> </custom_attributes> - <custom_attributes for="Magento\TestModule1\Service\V1\Entity\CustomAttributeDataObject"> - <attribute code="custom_attribute_nested" type="Magento\TestModule1\Service\V1\Entity\CustomAttributeNestedDataObject" /> + <custom_attributes for="Magento\TestModuleMSC\Model\Data\CustomAttributeDataObject"> + <attribute code="custom_attribute_nested" type="Magento\TestModuleMSC\Model\Data\CustomAttributeNestedDataObject" /> <attribute code="custom_attribute_int" type="int" /> </custom_attributes> </config> diff --git a/dev/tests/api-functional/_files/Magento/TestModule1/etc/di.xml b/dev/tests/api-functional/_files/Magento/TestModule1/etc/di.xml index 7ae28455d3a64a1abe6aa319881f0459e486c76e..61cdfb19a09e0b1b59a27663d261969600e6340e 100644 --- a/dev/tests/api-functional/_files/Magento/TestModule1/etc/di.xml +++ b/dev/tests/api-functional/_files/Magento/TestModule1/etc/di.xml @@ -11,7 +11,13 @@ <virtualType name="Magento\TestModule1\Service\Config\TestModule1MetadataConfig" type="Magento\Framework\Api\Config\MetadataConfig"> <arguments> + <argument name="attributeMetadataBuilder" xsi:type="object">Magento\TestModuleMSC\Model\Data\Eav\AttributeMetadataBuilder</argument> <argument name="dataObjectClassName" xsi:type="string">Magento\TestModule1\Service\V1\Entity\Item</argument> </arguments> </virtualType> + <type name="Magento\TestModule1\Service\V1\Entity\ItemBuilder"> + <arguments> + <argument name="metadataService" xsi:type="object">Magento\TestModule1\Service\Config\TestModule1MetadataConfig</argument> + </arguments> + </type> </config> diff --git a/dev/tests/api-functional/_files/Magento/TestModule3/Service/V1/Entity/WrappedErrorParameter.php b/dev/tests/api-functional/_files/Magento/TestModule3/Service/V1/Entity/WrappedErrorParameter.php index c073b4276be0a3e066287c95761ae2aaa8c5c633..a08ea627cfaa7a4eca4ecd4666f372d030ff65da 100644 --- a/dev/tests/api-functional/_files/Magento/TestModule3/Service/V1/Entity/WrappedErrorParameter.php +++ b/dev/tests/api-functional/_files/Magento/TestModule3/Service/V1/Entity/WrappedErrorParameter.php @@ -21,24 +21,24 @@ class WrappedErrorParameter extends \Magento\Framework\Api\AbstractExtensibleObj } /** - * Set field name. + * Get value. * - * @param string $fieldName - * @return $this + * @return string $value */ - public function setFieldName($fieldName) + public function getValue() { - return $this->setData('field_name', $fieldName); + return $this->_data['value']; } /** - * Get value. + * Set field name. * - * @return string $value + * @param string $fieldName + * @return $this */ - public function getValue() + public function setFieldName($fieldName) { - return $this->_data['value']; + return $this->setData('field_name', $fieldName); } /** diff --git a/dev/tests/api-functional/_files/Magento/TestModule3/Service/V1/Error.php b/dev/tests/api-functional/_files/Magento/TestModule3/Service/V1/Error.php index e1f4b6a99564875820989179cb5959df14e9bbc1..9ef7c6bda142674f4ebdbb87bef10d5bc720109d 100644 --- a/dev/tests/api-functional/_files/Magento/TestModule3/Service/V1/Error.php +++ b/dev/tests/api-functional/_files/Magento/TestModule3/Service/V1/Error.php @@ -42,7 +42,12 @@ class Error implements \Magento\TestModule3\Service\V1\ErrorInterface */ public function resourceNotFoundException() { - throw new NoSuchEntityException('Resource with ID "%resource_id" not found.', ['resource_id' => 'resourceY']); + throw new NoSuchEntityException( + __( + 'Resource with ID "%1" not found.', + 'resourceY' + ) + ); } /** @@ -50,19 +55,7 @@ class Error implements \Magento\TestModule3\Service\V1\ErrorInterface */ public function serviceException() { - throw new LocalizedException('Generic service exception %param', ['param' => 3456]); - } - - /** - * {@inheritdoc} - */ - public function parameterizedServiceException($parameters) - { - $details = []; - foreach ($parameters as $parameter) { - $details[$parameter->getName()] = $parameter->getValue(); - } - throw new LocalizedException('Parameterized service exception', $details); + throw new LocalizedException(__('Generic service exception %1', 3456)); } /** @@ -70,9 +63,7 @@ class Error implements \Magento\TestModule3\Service\V1\ErrorInterface */ public function authorizationException() { - throw new AuthorizationException('Consumer is not authorized to access %resources', [ - 'resources' => 'resourceN' - ]); + throw new AuthorizationException(__('Consumer is not authorized to access %1', 'resourceN')); } /** @@ -112,8 +103,10 @@ class Error implements \Magento\TestModule3\Service\V1\ErrorInterface if ($wrappedErrorParameters) { foreach ($wrappedErrorParameters as $error) { $exception->addError( - InputException::INVALID_FIELD_VALUE, - ['fieldName' => $error->getFieldName(), 'value' => $error->getValue()] + __( + InputException::INVALID_FIELD_VALUE, + ['fieldName' => $error->getFieldName(), 'value' => $error->getValue()] + ) ); } } diff --git a/dev/tests/api-functional/_files/Magento/TestModule3/Service/V1/ErrorInterface.php b/dev/tests/api-functional/_files/Magento/TestModule3/Service/V1/ErrorInterface.php index ee6737049398ddc55cfb0ac13419d0d8cd63814e..b4539f7a2b3b8ee7f45cc8f279f9c2f7a448dffe 100644 --- a/dev/tests/api-functional/_files/Magento/TestModule3/Service/V1/ErrorInterface.php +++ b/dev/tests/api-functional/_files/Magento/TestModule3/Service/V1/ErrorInterface.php @@ -7,8 +7,6 @@ */ namespace Magento\TestModule3\Service\V1; -use Magento\TestModule3\Service\V1\Entity\Parameter; - interface ErrorInterface { /** @@ -26,12 +24,6 @@ interface ErrorInterface */ public function serviceException(); - /** - * @param \Magento\TestModule3\Service\V1\Entity\Parameter[] $parameters - * @return int Status - */ - public function parameterizedServiceException($parameters); - /** * @return int Status */ diff --git a/dev/tests/api-functional/_files/Magento/TestModule3/etc/webapi.xml b/dev/tests/api-functional/_files/Magento/TestModule3/etc/webapi.xml index 8a27786d39b4d7d119e5b93633f8ed21e6e7f402..0a5fa58cfd31f82aa44c77ddd3c5c60d2e24176d 100644 --- a/dev/tests/api-functional/_files/Magento/TestModule3/etc/webapi.xml +++ b/dev/tests/api-functional/_files/Magento/TestModule3/etc/webapi.xml @@ -24,12 +24,6 @@ <resource ref="Magento_TestModule3::resource1" /> </resources> </route> - <route method="POST" url="/V1/errortest/parameterizedserviceexception"> - <service class="Magento\TestModule3\Service\V1\ErrorInterface" method="parameterizedServiceException" /> - <resources> - <resource ref="Magento_TestModule3::resource1" /> - </resources> - </route> <route method="GET" url="/V1/errortest/unauthorized"> <service class="Magento\TestModule3\Service\V1\ErrorInterface" method="authorizationException" /> <resources> diff --git a/dev/tests/api-functional/_files/Magento/TestModule4/Service/V1/Entity/ExtensibleRequest.php b/dev/tests/api-functional/_files/Magento/TestModule4/Service/V1/Entity/ExtensibleRequest.php index 515e73f3b4aec9a34d7f79cf4c1dc5cbfb49df0f..114f9a9dc9a07533f3db9e334c965eb65621d7ce 100644 --- a/dev/tests/api-functional/_files/Magento/TestModule4/Service/V1/Entity/ExtensibleRequest.php +++ b/dev/tests/api-functional/_files/Magento/TestModule4/Service/V1/Entity/ExtensibleRequest.php @@ -8,6 +8,11 @@ namespace Magento\TestModule4\Service\V1\Entity; +/** + * Class ExtensibleRequest + * + * @method \Magento\TestModule4\Service\V1\Entity\ExtensibleRequestExtensionInterface getExtensionAttributes() + */ class ExtensibleRequest extends \Magento\Framework\Model\AbstractExtensibleModel implements ExtensibleRequestInterface { public function getName() diff --git a/dev/tests/api-functional/_files/Magento/TestModuleMSC/Model/Data/CustomAttributeDataObject.php b/dev/tests/api-functional/_files/Magento/TestModuleMSC/Model/Data/CustomAttributeDataObject.php index 57b9202beba4aa4c5602ecd65e0a4607bab042ff..02e45da759543fdb8b9d94ae95c6020cf0f64abe 100644 --- a/dev/tests/api-functional/_files/Magento/TestModuleMSC/Model/Data/CustomAttributeDataObject.php +++ b/dev/tests/api-functional/_files/Magento/TestModuleMSC/Model/Data/CustomAttributeDataObject.php @@ -11,6 +11,11 @@ namespace Magento\TestModuleMSC\Model\Data; use Magento\TestModuleMSC\Api\Data\CustomAttributeDataObjectInterface; use Magento\Framework\Api\AbstractExtensibleObject; +/** + * Class CustomAttributeDataObject + * + * @method \Magento\TestModuleMSC\Api\Data\CustomAttributeDataObjectExtensionInterface getExtensionAttributes() + */ class CustomAttributeDataObject extends AbstractExtensibleObject implements CustomAttributeDataObjectInterface { /** diff --git a/dev/tests/api-functional/_files/Magento/TestModuleMSC/Model/Data/CustomAttributeNestedDataObject.php b/dev/tests/api-functional/_files/Magento/TestModuleMSC/Model/Data/CustomAttributeNestedDataObject.php index e1e7a49a09e2b40b3f05a23173cd320b5b0ddab0..ee683aa1610b713010c1812adaff87ebc3d9e61f 100644 --- a/dev/tests/api-functional/_files/Magento/TestModuleMSC/Model/Data/CustomAttributeNestedDataObject.php +++ b/dev/tests/api-functional/_files/Magento/TestModuleMSC/Model/Data/CustomAttributeNestedDataObject.php @@ -10,6 +10,11 @@ namespace Magento\TestModuleMSC\Model\Data; use Magento\TestModuleMSC\Api\Data\CustomAttributeNestedDataObjectInterface; +/** + * Class CustomAttributeNestedDataObject + * + * @method \Magento\TestModuleMSC\Api\Data\CustomAttributeNestedDataObjectExtensionInterface getExtensionAttributes() + */ class CustomAttributeNestedDataObject extends \Magento\Framework\Model\AbstractExtensibleModel implements CustomAttributeNestedDataObjectInterface { diff --git a/dev/tests/api-functional/_files/Magento/TestModuleMSC/Model/Data/Item.php b/dev/tests/api-functional/_files/Magento/TestModuleMSC/Model/Data/Item.php index ff18bed75ef1fd16fe6139cd4aeb4dd60ed92ef0..1d57017fabd42b6b01749771e25db25ef63aff48 100644 --- a/dev/tests/api-functional/_files/Magento/TestModuleMSC/Model/Data/Item.php +++ b/dev/tests/api-functional/_files/Magento/TestModuleMSC/Model/Data/Item.php @@ -10,6 +10,11 @@ namespace Magento\TestModuleMSC\Model\Data; use Magento\TestModuleMSC\Api\Data\ItemInterface; +/** + * Class Item + * + * @method \Magento\TestModuleMSC\Api\Data\ItemExtensionInterface getExtensionAttributes() + */ class Item extends \Magento\Framework\Model\AbstractExtensibleModel implements ItemInterface { /** diff --git a/dev/tests/api-functional/_files/Magento/TestModuleMSC/etc/di.xml b/dev/tests/api-functional/_files/Magento/TestModuleMSC/etc/di.xml index ea1e9ab9bc871215ffbd87448084ba274de9d236..2be26f6ab283284c7b4ffde3c2402473c550201e 100644 --- a/dev/tests/api-functional/_files/Magento/TestModuleMSC/etc/di.xml +++ b/dev/tests/api-functional/_files/Magento/TestModuleMSC/etc/di.xml @@ -15,6 +15,7 @@ <virtualType name="Magento\TestModuleMSC\Service\Config\TestModuleMSCMetadataConfig" type="Magento\Framework\Api\Config\MetadataConfig"> <arguments> + <argument name="attributeMetadataBuilder" xsi:type="object">Magento\TestModuleMSC\Model\Data\Eav\AttributeMetadataBuilder</argument> <argument name="dataObjectClassName" xsi:type="string">Magento\TestModuleMSC\Model\Data\Item</argument> </arguments> </virtualType> diff --git a/dev/tests/api-functional/testsuite/Magento/Bundle/Api/ProductLinkManagementTest.php b/dev/tests/api-functional/testsuite/Magento/Bundle/Api/ProductLinkManagementTest.php index 36cf0e0afaa83e7285e6a1d17f2c74185362ca5e..463f490480ce06c6e3016e5606971eb6ee1fe392 100644 --- a/dev/tests/api-functional/testsuite/Magento/Bundle/Api/ProductLinkManagementTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Bundle/Api/ProductLinkManagementTest.php @@ -91,11 +91,11 @@ class ProductLinkManagementTest extends \Magento\TestFramework\TestCase\WebapiAb */ private function addChild($productSku, $optionId, $linkedProduct) { - $resourcePath = self::RESOURCE_PATH . '/:productSku/links/:optionId'; + $resourcePath = self::RESOURCE_PATH . '/:sku/links/:optionId'; $serviceInfo = [ 'rest' => [ 'resourcePath' => str_replace( - [':productSku', ':optionId'], + [':sku', ':optionId'], [$productSku, $optionId], $resourcePath ), @@ -109,7 +109,7 @@ class ProductLinkManagementTest extends \Magento\TestFramework\TestCase\WebapiAb ]; return $this->_webApiCall( $serviceInfo, - ['productSku' => $productSku, 'optionId' => $optionId, 'linkedProduct' => $linkedProduct] + ['sku' => $productSku, 'optionId' => $optionId, 'linkedProduct' => $linkedProduct] ); } @@ -125,7 +125,7 @@ class ProductLinkManagementTest extends \Magento\TestFramework\TestCase\WebapiAb protected function removeChild($productSku, $optionId, $childSku) { - $resourcePath = self::RESOURCE_PATH . '/%s/option/%s/child/%s'; + $resourcePath = self::RESOURCE_PATH . '/%s/options/%s/children/%s'; $serviceInfo = [ 'rest' => [ 'resourcePath' => sprintf($resourcePath, $productSku, $optionId, $childSku), @@ -137,7 +137,7 @@ class ProductLinkManagementTest extends \Magento\TestFramework\TestCase\WebapiAb 'operation' => self::SERVICE_NAME . 'removeChild', ], ]; - $requestData = ['productSku' => $productSku, 'optionId' => $optionId, 'childSku' => $childSku]; + $requestData = ['sku' => $productSku, 'optionId' => $optionId, 'childSku' => $childSku]; return $this->_webApiCall($serviceInfo, $requestData); } diff --git a/dev/tests/api-functional/testsuite/Magento/Bundle/Api/ProductOptionRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/Bundle/Api/ProductOptionRepositoryTest.php index e18965c0753e60490561c6facf4aca2c6d8e615c..325e35ee8291041dd553575d39ed4523f71e5284 100644 --- a/dev/tests/api-functional/testsuite/Magento/Bundle/Api/ProductOptionRepositoryTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Bundle/Api/ProductOptionRepositoryTest.php @@ -10,7 +10,7 @@ class ProductOptionRepositoryTest extends \Magento\TestFramework\TestCase\Webapi { const SERVICE_NAME = 'bundleProductOptionRepositoryV1'; const SERVICE_VERSION = 'V1'; - const RESOURCE_PATH = '/V1/bundle-products/:productSku/option'; + const RESOURCE_PATH = '/V1/bundle-products/:sku/options'; /** * @magentoApiDataFixture Magento/Bundle/_files/product.php @@ -166,7 +166,7 @@ class ProductOptionRepositoryTest extends \Magento\TestFramework\TestCase\Webapi { $serviceInfo = [ 'rest' => [ - 'resourcePath' => '/V1/bundle-products/option/' . $optionId, + 'resourcePath' => '/V1/bundle-products/options/' . $optionId, 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_PUT, ], 'soap' => [ @@ -190,7 +190,7 @@ class ProductOptionRepositoryTest extends \Magento\TestFramework\TestCase\Webapi { $serviceInfo = [ 'rest' => [ - 'resourcePath' => '/V1/bundle-products/option/add', + 'resourcePath' => '/V1/bundle-products/options/add', 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_POST, ], 'soap' => [ @@ -211,7 +211,7 @@ class ProductOptionRepositoryTest extends \Magento\TestFramework\TestCase\Webapi { $serviceInfo = [ 'rest' => [ - 'resourcePath' => str_replace(':productSku', $productSku, self::RESOURCE_PATH) . '/' . $optionId, + 'resourcePath' => str_replace(':sku', $productSku, self::RESOURCE_PATH) . '/' . $optionId, 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_DELETE, ], 'soap' => [ @@ -220,7 +220,7 @@ class ProductOptionRepositoryTest extends \Magento\TestFramework\TestCase\Webapi 'operation' => self::SERVICE_NAME . 'DeleteById', ], ]; - return $this->_webApiCall($serviceInfo, ['productSku' => $productSku, 'optionId' => $optionId]); + return $this->_webApiCall($serviceInfo, ['sku' => $productSku, 'optionId' => $optionId]); } /** @@ -231,7 +231,7 @@ class ProductOptionRepositoryTest extends \Magento\TestFramework\TestCase\Webapi { $serviceInfo = [ 'rest' => [ - 'resourcePath' => str_replace(':productSku', $productSku, self::RESOURCE_PATH) . '/all', + 'resourcePath' => str_replace(':sku', $productSku, self::RESOURCE_PATH) . '/all', 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_GET, ], 'soap' => [ @@ -240,7 +240,7 @@ class ProductOptionRepositoryTest extends \Magento\TestFramework\TestCase\Webapi 'operation' => self::SERVICE_NAME . 'GetList', ], ]; - return $this->_webApiCall($serviceInfo, ['productSku' => $productSku]); + return $this->_webApiCall($serviceInfo, ['sku' => $productSku]); } /** @@ -252,7 +252,7 @@ class ProductOptionRepositoryTest extends \Magento\TestFramework\TestCase\Webapi { $serviceInfo = [ 'rest' => [ - 'resourcePath' => str_replace(':productSku', $productSku, self::RESOURCE_PATH) . '/' . $optionId, + 'resourcePath' => str_replace(':sku', $productSku, self::RESOURCE_PATH) . '/' . $optionId, 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_GET, ], 'soap' => [ @@ -261,6 +261,6 @@ class ProductOptionRepositoryTest extends \Magento\TestFramework\TestCase\Webapi 'operation' => self::SERVICE_NAME . 'Get', ], ]; - return $this->_webApiCall($serviceInfo, ['productSku' => $productSku, 'optionId' => $optionId]); + return $this->_webApiCall($serviceInfo, ['sku' => $productSku, 'optionId' => $optionId]); } } diff --git a/dev/tests/api-functional/testsuite/Magento/Bundle/Api/ProductOptionTypeListTest.php b/dev/tests/api-functional/testsuite/Magento/Bundle/Api/ProductOptionTypeListTest.php index 9e355b5aae83a17d9c48f5fffa42b3fda302d5e9..7fc41226c9bb09319afd87db1c280484fe0a795f 100644 --- a/dev/tests/api-functional/testsuite/Magento/Bundle/Api/ProductOptionTypeListTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Bundle/Api/ProductOptionTypeListTest.php @@ -10,7 +10,7 @@ class ProductOptionTypeListTest extends \Magento\TestFramework\TestCase\WebapiAb { const SERVICE_READ_NAME = 'bundleProductOptionTypeListV1'; const SERVICE_VERSION = 'V1'; - const RESOURCE_PATH = '/V1/bundle-products/option/types'; + const RESOURCE_PATH = '/V1/bundle-products/options/types'; public function testGetTypes() { diff --git a/dev/tests/api-functional/testsuite/Magento/Bundle/Api/ProductServiceTest.php b/dev/tests/api-functional/testsuite/Magento/Bundle/Api/ProductServiceTest.php index 6c9d7c92c3cda782f13bbd5f8298d95cbbb26588..1a817b18d3b593df2cbbef8280a42e40f0d5b84c 100644 --- a/dev/tests/api-functional/testsuite/Magento/Bundle/Api/ProductServiceTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Bundle/Api/ProductServiceTest.php @@ -7,7 +7,7 @@ namespace Magento\Bundle\Api; use Magento\Catalog\Api\Data\ProductInterface; -use Magento\Framework\Api\AbstractExtensibleObject; +use Magento\Framework\Api\ExtensibleDataInterface; use Magento\TestFramework\Helper\Bootstrap; use Magento\TestFramework\TestCase\WebapiAbstract; @@ -61,18 +61,19 @@ class ProductServiceTest extends WebapiAbstract */ public function testCreateBundle() { + $this->markTestSkipped('Processing of custom attributes has been changed in MAGETWO-34448.'); $bundleProductOptions = [ - "attribute_code" => "bundle_product_options", - "value" => [ - [ - "title" => "test option", - "type" => "checkbox", - "required" => 1, - "product_links" => [ - [ - "sku" => 'simple', - "qty" => 1, - ], + [ + "title" => "test option", + "type" => "checkbox", + "required" => true, + "product_links" => [ + [ + "sku" => 'simple', + "qty" => 1, + 'is_default' => false, + 'price' => 1.0, + 'price_type' => 1 ], ], ], @@ -85,36 +86,25 @@ class ProductServiceTest extends WebapiAbstract "type_id" => "bundle", "price" => 50, 'attribute_set_id' => 4, - "custom_attributes" => [ - "price_type" => [ - 'attribute_code' => 'price_type', - 'value' => \Magento\Bundle\Model\Product\Price::PRICE_TYPE_DYNAMIC - ], + "extension_attributes" => [ + "price_type" => \Magento\Bundle\Model\Product\Price::PRICE_TYPE_DYNAMIC, "bundle_product_options" => $bundleProductOptions, - "price_view" => [ - "attribute_code" => "price_view", - "value" => "test", - ], + "price_view" => "test" ], ]; $response = $this->createProduct($product); $this->assertEquals($uniqueId, $response[ProductInterface::SKU]); - $this->assertEquals( - $bundleProductOptions, - $response[AbstractExtensibleObject::CUSTOM_ATTRIBUTES_KEY]["bundle_product_options"] - ); + $resultBundleProductOptions + = $response[ExtensibleDataInterface::EXTENSION_ATTRIBUTES_KEY]["bundle_product_options"]; + $this->assertEquals($bundleProductOptions, $resultBundleProductOptions); + $this->assertEquals('simple', $resultBundleProductOptions[0]["product_links"][0]["sku"]); $response = $this->getProduct($uniqueId); - $foundBundleProductOptions = false; - foreach ($response[AbstractExtensibleObject::CUSTOM_ATTRIBUTES_KEY] as $customAttribute) { - if ($customAttribute["attribute_code"] === 'bundle_product_options') { - $this->assertEquals('simple', $customAttribute["value"][0]["product_links"][0]["sku"]); - $foundBundleProductOptions = true; - } - } - $this->assertTrue($foundBundleProductOptions); + $resultBundleProductOptions + = $response[ExtensibleDataInterface::EXTENSION_ATTRIBUTES_KEY]["bundle_product_options"]; + $this->assertEquals('simple', $resultBundleProductOptions[0]["product_links"][0]["sku"]); } /** @@ -138,7 +128,7 @@ class ProductServiceTest extends WebapiAbstract ]; $response = (TESTS_WEB_API_ADAPTER == self::ADAPTER_SOAP) ? - $this->_webApiCall($serviceInfo, ['productSku' => $productSku]) : $this->_webApiCall($serviceInfo); + $this->_webApiCall($serviceInfo, ['sku' => $productSku]) : $this->_webApiCall($serviceInfo); return $response; } diff --git a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/CategoryAttributeOptionManagementInterfaceTest.php b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/CategoryAttributeOptionManagementInterfaceTest.php index 61a54a548800a4e33b8c5710d63de95a4af30b87..345f76e3d923aade74604d952acc321c1e79c446 100644 --- a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/CategoryAttributeOptionManagementInterfaceTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/CategoryAttributeOptionManagementInterfaceTest.php @@ -15,6 +15,7 @@ class CategoryAttributeOptionManagementInterfaceTest extends WebapiAbstract public function testGetItems() { + $this->_markTestAsRestOnly('Fix inconsistencies in WSDL and Data interfaces'); $testAttributeCode = 'include_in_menu'; $expectedOptions = [ [ diff --git a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/CategoryLinkRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/CategoryLinkRepositoryTest.php index 0cc379dc881fbf4a064ed18227a34b5deed9e67c..84588ac82171ea29d17ba377b753d9265c5417db 100644 --- a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/CategoryLinkRepositoryTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/CategoryLinkRepositoryTest.php @@ -121,7 +121,7 @@ class CategoryLinkRepositoryTest extends WebapiAbstract ]; $result = $this->_webApiCall( $serviceInfo, - ['productSku' => 'simple', 'categoryId' => $this->categoryId] + ['sku' => 'simple', 'categoryId' => $this->categoryId] ); $this->assertTrue($result); $this->assertFalse($this->isProductInCategory($this->categoryId, 333, 10)); diff --git a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductAttributeManagementTest.php b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductAttributeManagementTest.php index c8e4a55b1eeb5f9181ce660ec91d33d9ccb954d8..36d3dc65d184cfd95e09d4d3e97186b4d4770f04 100644 --- a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductAttributeManagementTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductAttributeManagementTest.php @@ -20,7 +20,7 @@ class ProductAttributeManagementTest extends \Magento\TestFramework\TestCase\Web public function testGetAttributes() { - $attributeSetId = \Magento\Catalog\Api\Data\ProductAttributeInterface::DEFAULT_ATTRIBUTE_SET_ID; + $attributeSetId = 4; $serviceInfo = [ 'rest' => [ @@ -59,7 +59,7 @@ class ProductAttributeManagementTest extends \Magento\TestFramework\TestCase\Web $payload = $this->getAttributeData(); $payload['attributeSetId'] = -1; - $expectedMessage = 'AttributeSet with id "' . $payload['attributeSetId'] . '" does not exist.'; + $expectedMessage = 'AttributeSet with id "%1" does not exist.'; try { $this->_webApiCall($this->getAssignServiceInfo(), $payload); @@ -73,6 +73,7 @@ class ProductAttributeManagementTest extends \Magento\TestFramework\TestCase\Web } catch (\Exception $e) { $errorObj = $this->processRestExceptionResult($e); $this->assertEquals($expectedMessage, $errorObj['message']); + $this->assertEquals([$payload['attributeSetId']], $errorObj['parameters']); $this->assertEquals(HTTPExceptionCodes::HTTP_NOT_FOUND, $e->getCode()); } } @@ -81,7 +82,7 @@ class ProductAttributeManagementTest extends \Magento\TestFramework\TestCase\Web { $payload = $this->getAttributeData(); $payload['attributeGroupId'] = -1; - $expectedMessage = 'Group with id "' . $payload['attributeGroupId'] . '" does not exist.'; + $expectedMessage = 'Group with id "%1" does not exist.'; try { $this->_webApiCall($this->getAssignServiceInfo(), $payload); @@ -95,6 +96,7 @@ class ProductAttributeManagementTest extends \Magento\TestFramework\TestCase\Web } catch (\Exception $e) { $errorObj = $this->processRestExceptionResult($e); $this->assertEquals($expectedMessage, $errorObj['message']); + $this->assertEquals([$payload['attributeGroupId']], $errorObj['parameters']); $this->assertEquals(HTTPExceptionCodes::HTTP_NOT_FOUND, $e->getCode()); } } @@ -103,7 +105,7 @@ class ProductAttributeManagementTest extends \Magento\TestFramework\TestCase\Web { $payload = $this->getAttributeData(); $payload['attributeCode'] = 'badCode'; - $expectedMessage = 'Attribute with attributeCode "' . $payload['attributeCode'] . '" does not exist.'; + $expectedMessage = 'Attribute with attributeCode "%1" does not exist.'; try { $this->_webApiCall($this->getAssignServiceInfo(), $payload); @@ -117,6 +119,7 @@ class ProductAttributeManagementTest extends \Magento\TestFramework\TestCase\Web } catch (\Exception $e) { $errorObj = $this->processRestExceptionResult($e); $this->assertEquals($expectedMessage, $errorObj['message']); + $this->assertEquals([$payload['attributeCode']], $errorObj['parameters']); $this->assertEquals(HTTPExceptionCodes::HTTP_NOT_FOUND, $e->getCode()); } } @@ -155,7 +158,7 @@ class ProductAttributeManagementTest extends \Magento\TestFramework\TestCase\Web $serviceInfo, [ 'attributeSetId' => $payload['attributeSetId'], - 'attributeCode' => $payload['attributeCode'] + 'attributeCode' => $payload['attributeCode'], ] ) ); @@ -164,10 +167,10 @@ class ProductAttributeManagementTest extends \Magento\TestFramework\TestCase\Web protected function getAttributeData() { return [ - 'attributeSetId' => \Magento\Catalog\Api\Data\ProductAttributeInterface::DEFAULT_ATTRIBUTE_SET_ID, + 'attributeSetId' => 4, 'attributeGroupId' => 8, 'attributeCode' => 'cost', - 'sortOrder' => 3 + 'sortOrder' => 3, ]; } diff --git a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductAttributeMediaGalleryManagementInterfaceTest.php b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductAttributeMediaGalleryManagementInterfaceTest.php index 2fa1f86b55c5aeac1673d1416df96c856d59e5b5..86a5c051ae44c64a74e5d01b23c84c1ab82e00ea 100644 --- a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductAttributeMediaGalleryManagementInterfaceTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductAttributeMediaGalleryManagementInterfaceTest.php @@ -40,7 +40,7 @@ class ProductAttributeMediaGalleryManagementInterfaceTest extends \Magento\TestF { $this->createServiceInfo = [ 'rest' => [ - 'resourcePath' => '/V1/products/simple/media', + 'resourcePath' => '/V1/products/media', 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_POST, ], 'soap' => [ @@ -49,6 +49,7 @@ class ProductAttributeMediaGalleryManagementInterfaceTest extends \Magento\TestF 'operation' => 'catalogProductAttributeMediaGalleryManagementV1Create', ], ]; + $this->updateServiceInfo = [ 'rest' => [ 'resourcePath' => '/V1/products/simple/media', @@ -103,23 +104,27 @@ class ProductAttributeMediaGalleryManagementInterfaceTest extends \Magento\TestF public function testCreate() { $requestData = [ - 'productSku' => 'simple', - 'entry' => [ - 'id' => null, - 'label' => 'Image Text', - 'position' => 1, - 'types' => ['image'], - 'is_disabled' => false, - ], - 'entryContent' => [ - 'entry_data' => base64_encode(file_get_contents($this->testImagePath)), - 'mime_type' => 'image/jpeg', - 'name' => 'test_image', + "sku" => 'simple', + "custom_attributes" => [ + "media_gallery" => [ + 'attribute_code' => 'media_gallery', + 'value' => [ + 'id' => null, + 'label' => 'Image Text', + 'position' => 1, + 'types' => ['image'], + 'disabled' => false, + 'content' => [ + 'entry_data' => base64_encode(file_get_contents($this->testImagePath)), + 'mime_type' => 'image/jpeg', + 'name' => 'test_image' + ] + ] + ], ], - // Store ID is not provided so the default one must be used ]; - $actualResult = $this->_webApiCall($this->createServiceInfo, $requestData); + $actualResult = $this->_webApiCall($this->createServiceInfo, ['product' => $requestData]); $targetProduct = $this->getTargetSimpleProduct(); $mediaGallery = $targetProduct->getData('media_gallery'); @@ -129,9 +134,6 @@ class ProductAttributeMediaGalleryManagementInterfaceTest extends \Magento\TestF $this->assertEquals('Image Text', $updatedImage['label']); $this->assertEquals(1, $updatedImage['position']); $this->assertEquals(0, $updatedImage['disabled']); - $this->assertEquals('Image Text', $updatedImage['label_default']); - $this->assertEquals(1, $updatedImage['position_default']); - $this->assertEquals(0, $updatedImage['disabled_default']); $this->assertStringStartsWith('/t/e/test_image', $updatedImage['file']); $this->assertEquals($updatedImage['file'], $targetProduct->getData('image')); } @@ -142,23 +144,28 @@ class ProductAttributeMediaGalleryManagementInterfaceTest extends \Magento\TestF public function testCreateWithNotDefaultStoreId() { $requestData = [ - 'productSku' => 'simple', - 'entry' => [ - 'id' => null, - 'label' => 'Image Text', - 'position' => 1, - 'types' => ['image'], - 'is_disabled' => false, - ], - 'entryContent' => [ - 'entry_data' => base64_encode(file_get_contents($this->testImagePath)), - 'mime_type' => 'image/jpeg', - 'name' => 'test_image', - ], - 'storeId' => 1, + 'sku' => 'simple', + 'store_id' => 1, + "custom_attributes" => [ + "media_gallery" => [ + 'attribute_code' => 'media_gallery', + 'value' => [ + 'id' => null, + 'label' => 'Image Text', + 'position' => 1, + 'types' => ['image'], + 'disabled' => false, + 'content' => [ + 'entry_data' => base64_encode(file_get_contents($this->testImagePath)), + 'mime_type' => 'image/jpeg', + 'name' => 'test_image', + ] + ] + ], + ] ]; - $actualResult = $this->_webApiCall($this->createServiceInfo, $requestData); + $actualResult = $this->_webApiCall($this->createServiceInfo, ['product' => $requestData]); $targetProduct = $this->getTargetSimpleProduct(); $mediaGallery = $targetProduct->getData('media_gallery'); $this->assertCount(1, $mediaGallery['images']); @@ -182,13 +189,13 @@ class ProductAttributeMediaGalleryManagementInterfaceTest extends \Magento\TestF public function testUpdate() { $requestData = [ - 'productSku' => 'simple', + 'sku' => 'simple', 'entry' => [ 'id' => $this->getTargetGalleryEntryId(), 'label' => 'Updated Image Text', 'position' => 10, 'types' => ['thumbnail'], - 'is_disabled' => true, + 'disabled' => true, ], // Store ID is not provided so the default one must be used ]; @@ -220,15 +227,15 @@ class ProductAttributeMediaGalleryManagementInterfaceTest extends \Magento\TestF public function testUpdateWithNotDefaultStoreId() { $requestData = [ - 'productSku' => 'simple', + 'sku' => 'simple', 'entry' => [ 'id' => $this->getTargetGalleryEntryId(), 'label' => 'Updated Image Text', 'position' => 10, 'types' => ['thumbnail'], - 'is_disabled' => true, + 'disabled' => true, ], - 'storeId' => 1, + 'store_id' => 1, ]; $this->updateServiceInfo['rest']['resourcePath'] = $this->updateServiceInfo['rest']['resourcePath'] @@ -262,7 +269,7 @@ class ProductAttributeMediaGalleryManagementInterfaceTest extends \Magento\TestF $entryId = $this->getTargetGalleryEntryId(); $this->deleteServiceInfo['rest']['resourcePath'] = "/V1/products/simple/media/{$entryId}"; $requestData = [ - 'productSku' => 'simple', + 'sku' => 'simple', 'entryId' => $this->getTargetGalleryEntryId(), ]; @@ -280,23 +287,28 @@ class ProductAttributeMediaGalleryManagementInterfaceTest extends \Magento\TestF public function testCreateThrowsExceptionIfThereIsNoStoreWithProvidedStoreId() { $requestData = [ - 'productSku' => 'simple', - 'entry' => [ - 'id' => null, - 'label' => 'Image Text', - 'position' => 1, - 'types' => ['image'], - 'is_disabled' => false, - ], - 'storeId' => 9999, // target store view does not exist - 'entryContent' => [ - 'entry_data' => base64_encode(file_get_contents($this->testImagePath)), - 'mime_type' => 'image/jpeg', - 'name' => 'test_image', - ], + 'sku' => 'simple', + 'store_id' => 9999, // target store view does not exist + "custom_attributes" => [ + "media_gallery" => [ + 'attribute_code' => 'media_gallery', + 'value' => [ + 'id' => null, + 'label' => 'Image Text', + 'position' => 1, + 'types' => ['image'], + 'disabled' => false, + 'content' => [ + 'entry_data' => base64_encode(file_get_contents($this->testImagePath)), + 'mime_type' => 'image/jpeg', + 'name' => 'test_image', + ] + ] + ], + ] ]; - $this->_webApiCall($this->createServiceInfo, $requestData); + $this->_webApiCall($this->createServiceInfo, ['product' => $requestData]); } /** @@ -308,23 +320,28 @@ class ProductAttributeMediaGalleryManagementInterfaceTest extends \Magento\TestF { $encodedContent = 'not_a_base64_encoded_content'; $requestData = [ - 'productSku' => 'simple', - 'entry' => [ - 'id' => null, - 'label' => 'Image Text', - 'position' => 1, - 'is_disabled' => false, - 'types' => ['image'], - ], - 'entryContent' => [ - 'entry_data' => $encodedContent, - 'mime_type' => 'image/jpeg', - 'name' => 'test_image', - ], - 'storeId' => 0, + 'sku' => 'simple', + 'store_id' => 0, + "custom_attributes" => [ + "media_gallery" => [ + 'attribute_code' => 'media_gallery', + 'value' => [ + 'id' => null, + 'label' => 'Image Text', + 'position' => 1, + 'types' => ['image'], + 'disabled' => false, + 'content' => [ + 'entry_data' => $encodedContent, + 'mime_type' => 'image/jpeg', + 'name' => 'test_image', + ] + ] + ], + ] ]; - $this->_webApiCall($this->createServiceInfo, $requestData); + $this->_webApiCall($this->createServiceInfo, ['product' => $requestData]); } /** @@ -336,23 +353,28 @@ class ProductAttributeMediaGalleryManagementInterfaceTest extends \Magento\TestF { $encodedContent = base64_encode('not_an_image'); $requestData = [ - 'productSku' => 'simple', - 'entry' => [ - 'id' => null, - 'is_disabled' => false, - 'label' => 'Image Text', - 'position' => 1, - 'types' => ['image'], - ], - 'entryContent' => [ - 'entry_data' => $encodedContent, - 'mime_type' => 'image/jpeg', - 'name' => 'test_image', - ], - 'storeId' => 0, + 'sku' => 'simple', + 'store_id' => 0, + "custom_attributes" => [ + "media_gallery" => [ + 'attribute_code' => 'media_gallery', + 'value' => [ + 'id' => null, + 'label' => 'Image Text', + 'position' => 1, + 'types' => ['image'], + 'disabled' => false, + 'content' => [ + 'entry_data' => $encodedContent, + 'mime_type' => 'image/jpeg', + 'name' => 'test_image', + ] + ] + ], + ] ]; - $this->_webApiCall($this->createServiceInfo, $requestData); + $this->_webApiCall($this->createServiceInfo, ['product' => $requestData]); } /** @@ -364,23 +386,28 @@ class ProductAttributeMediaGalleryManagementInterfaceTest extends \Magento\TestF { $encodedContent = base64_encode(file_get_contents($this->testImagePath)); $requestData = [ - 'entry' => [ - 'id' => null, - 'label' => 'Image Text', - 'position' => 1, - 'types' => ['image'], - 'is_disabled' => false, - ], - 'productSku' => 'simple', - 'entryContent' => [ - 'entry_data' => $encodedContent, - 'mime_type' => 'wrong_mime_type', - 'name' => 'test_image', - ], - 'storeId' => 0, + 'sku' => 'simple', + 'store_id' => 0, + "custom_attributes" => [ + "media_gallery" => [ + 'attribute_code' => 'media_gallery', + 'value' => [ + 'id' => null, + 'label' => 'Image Text', + 'position' => 1, + 'types' => ['image'], + 'disabled' => false, + 'content' => [ + 'entry_data' => $encodedContent, + 'mime_type' => 'wrong_mime_type', + 'name' => 'test_image', + ] + ] + ], + ] ]; - $this->_webApiCall($this->createServiceInfo, $requestData); + $this->_webApiCall($this->createServiceInfo, ['product' => $requestData]); } /** @@ -389,25 +416,31 @@ class ProductAttributeMediaGalleryManagementInterfaceTest extends \Magento\TestF */ public function testCreateThrowsExceptionIfTargetProductDoesNotExist() { - $this->createServiceInfo['rest']['resourcePath'] = '/V1/products/wrong_product_sku/media'; + $this->createServiceInfo['rest']['resourcePath'] = '/V1/products/media'; + $requestData = [ - 'productSku' => 'wrong_product_sku', - 'entry' => [ - 'id' => null, - 'position' => 1, - 'label' => 'Image Text', - 'types' => ['image'], - 'is_disabled' => false, - ], - 'entryContent' => [ - 'entry_data' => base64_encode(file_get_contents($this->testImagePath)), - 'mime_type' => 'image/jpeg', - 'name' => 'test_image', - ], - 'storeId' => 0, + 'sku' => 'wrong_product_sku', + 'store_id' => 0, + "custom_attributes" => [ + "media_gallery" => [ + 'attribute_code' => 'media_gallery', + 'value' => [ + 'id' => null, + 'label' => 'Image Text', + 'position' => 1, + 'types' => ['image'], + 'disabled' => false, + 'content' => [ + 'entry_data' => base64_encode(file_get_contents($this->testImagePath)), + 'mime_type' => 'image/jpeg', + 'name' => 'test_image', + ] + ] + ], + ] ]; - $this->_webApiCall($this->createServiceInfo, $requestData); + $this->_webApiCall($this->createServiceInfo, ['product' => $requestData]); } /** @@ -418,23 +451,28 @@ class ProductAttributeMediaGalleryManagementInterfaceTest extends \Magento\TestF public function testCreateThrowsExceptionIfProvidedImageNameContainsForbiddenCharacters() { $requestData = [ - 'productSku' => 'simple', - 'entry' => [ - 'id' => null, - 'label' => 'Image Text', - 'position' => 1, - 'types' => ['image'], - 'is_disabled' => false, - ], - 'entryContent' => [ - 'entry_data' => base64_encode(file_get_contents($this->testImagePath)), - 'mime_type' => 'image/jpeg', - 'name' => 'test/\\{}|:"<>', // Cannot contain \ / : * ? " < > | - ], - 'storeId' => 0, + 'sku' => 'wrong_product_sku', + 'store_id' => 0, + "custom_attributes" => [ + "media_gallery" => [ + 'attribute_code' => 'media_gallery', + 'value' => [ + 'id' => null, + 'label' => 'Image Text', + 'position' => 1, + 'types' => ['image'], + 'disabled' => false, + 'content' => [ + 'entry_data' => base64_encode(file_get_contents($this->testImagePath)), + 'mime_type' => 'image/jpeg', + 'name' => 'test/\\{}|:"<>', // Cannot contain \ / : * ? " < > | + ] + ] + ], + ] ]; - $this->_webApiCall($this->createServiceInfo, $requestData); + $this->_webApiCall($this->createServiceInfo, ['product' => $requestData]); } /** @@ -445,15 +483,15 @@ class ProductAttributeMediaGalleryManagementInterfaceTest extends \Magento\TestF public function testUpdateIfThereIsNoStoreWithProvidedStoreId() { $requestData = [ - 'productSku' => 'simple', + 'sku' => 'simple', 'entry' => [ 'id' => $this->getTargetGalleryEntryId(), 'label' => 'Updated Image Text', 'position' => 10, 'types' => ['thumbnail'], - 'is_disabled' => true, + 'disabled' => true, ], - 'storeId' => 9999, // target store view does not exist + 'store_id' => 9999, // target store view does not exist ]; $this->updateServiceInfo['rest']['resourcePath'] = $this->updateServiceInfo['rest']['resourcePath'] @@ -471,15 +509,15 @@ class ProductAttributeMediaGalleryManagementInterfaceTest extends \Magento\TestF $this->updateServiceInfo['rest']['resourcePath'] = '/V1/products/wrong_product_sku/media' . '/' . $this->getTargetGalleryEntryId(); $requestData = [ - 'productSku' => 'wrong_product_sku', + 'sku' => 'wrong_product_sku', 'entry' => [ 'id' => 9999, 'label' => 'Updated Image Text', 'position' => 1, 'types' => ['thumbnail'], - 'is_disabled' => true, + 'disabled' => true, ], - 'storeId' => 0, + 'store_id' => 0, ]; $this->_webApiCall($this->updateServiceInfo, $requestData); @@ -493,15 +531,15 @@ class ProductAttributeMediaGalleryManagementInterfaceTest extends \Magento\TestF public function testUpdateThrowsExceptionIfThereIsNoImageWithGivenId() { $requestData = [ - 'productSku' => 'simple', + 'sku' => 'simple', 'entry' => [ 'id' => 9999, 'label' => 'Updated Image Text', 'position' => 1, 'types' => ['thumbnail'], - 'is_disabled' => true, + 'disabled' => true, ], - 'storeId' => 0, + 'store_id' => 0, ]; $this->updateServiceInfo['rest']['resourcePath'] = $this->updateServiceInfo['rest']['resourcePath'] @@ -518,7 +556,7 @@ class ProductAttributeMediaGalleryManagementInterfaceTest extends \Magento\TestF { $this->deleteServiceInfo['rest']['resourcePath'] = '/V1/products/wrong_product_sku/media/9999'; $requestData = [ - 'productSku' => 'wrong_product_sku', + 'sku' => 'wrong_product_sku', 'entryId' => 9999, ]; @@ -534,7 +572,7 @@ class ProductAttributeMediaGalleryManagementInterfaceTest extends \Magento\TestF { $this->deleteServiceInfo['rest']['resourcePath'] = '/V1/products/simple/media/9999'; $requestData = [ - 'productSku' => 'simple', + 'sku' => 'simple', 'entryId' => 9999, ]; @@ -558,7 +596,7 @@ class ProductAttributeMediaGalleryManagementInterfaceTest extends \Magento\TestF $expected = [ 'label' => $image['label'], 'position' => $image['position'], - 'is_disabled' => (bool)$image['disabled'], + 'disabled' => (bool)$image['disabled'], 'file' => $image['file'], 'types' => ['image', 'small_image', 'thumbnail'], ]; @@ -575,16 +613,16 @@ class ProductAttributeMediaGalleryManagementInterfaceTest extends \Magento\TestF ], ]; $requestData = [ - 'productSku' => $productSku, + 'sku' => $productSku, 'imageId' => $imageId, ]; $data = $this->_webApiCall($serviceInfo, $requestData); - $actual = (array) $data; + $actual = (array)$data; $this->assertEquals($expected['label'], $actual['label']); $this->assertEquals($expected['position'], $actual['position']); $this->assertEquals($expected['file'], $actual['file']); $this->assertEquals($expected['types'], $actual['types']); - $this->assertEquals($expected['is_disabled'], (bool)$actual['is_disabled']); + $this->assertEquals($expected['disabled'], (bool)$actual['disabled']); } /** @@ -606,7 +644,7 @@ class ProductAttributeMediaGalleryManagementInterfaceTest extends \Magento\TestF ]; $requestData = [ - 'productSku' => $productSku, + 'sku' => $productSku, ]; $imageList = $this->_webApiCall($serviceInfo, $requestData); @@ -635,7 +673,7 @@ class ProductAttributeMediaGalleryManagementInterfaceTest extends \Magento\TestF ]; $requestData = [ - 'productSku' => $productSku, + 'sku' => $productSku, ]; if (TESTS_WEB_API_ADAPTER == self::ADAPTER_SOAP) { $this->setExpectedException('SoapFault', 'Requested product doesn\'t exist'); diff --git a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductAttributeOptionManagementInterfaceTest.php b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductAttributeOptionManagementInterfaceTest.php index adc93f12c15337ab3a992586e3bae06bcb0b8a3a..2e31bec6182ee8d142cab94e7bc18eb3e49d9354 100644 --- a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductAttributeOptionManagementInterfaceTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductAttributeOptionManagementInterfaceTest.php @@ -17,6 +17,7 @@ class ProductAttributeOptionManagementInterfaceTest extends WebapiAbstract public function testGetItems() { + $this->_markTestAsRestOnly('Fix inconsistencies in WSDL and Data interfaces'); $testAttributeCode = 'quantity_and_stock_status'; $expectedOptions = [ [ @@ -52,6 +53,7 @@ class ProductAttributeOptionManagementInterfaceTest extends WebapiAbstract */ public function testAdd() { + $this->_markTestAsRestOnly('Fix inconsistencies in WSDL and Data interfaces'); $testAttributeCode = 'select_attribute'; $serviceInfo = [ 'rest' => [ @@ -100,6 +102,7 @@ class ProductAttributeOptionManagementInterfaceTest extends WebapiAbstract */ public function testDelete() { + $this->_markTestAsRestOnly('Fix inconsistencies in WSDL and Data interfaces'); $attributeCode = 'select_attribute'; //get option Id $optionList = $this->getAttributeOptions($attributeCode); diff --git a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductAttributeRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductAttributeRepositoryTest.php index 0b905f432815a215f39abd6cb709de72a9fbcbe9..7bb1fccd68818c9804f508c9c9f4a445527c9257 100644 --- a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductAttributeRepositoryTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductAttributeRepositoryTest.php @@ -159,7 +159,7 @@ class ProductAttributeRepositoryTest extends \Magento\TestFramework\TestCase\Web public function testDeleteNoSuchEntityException() { $attributeCode = 'some_test_code'; - $expectedMessage = 'Attribute with attributeCode "' . $attributeCode . '" does not exist.'; + $expectedMessage = 'Attribute with attributeCode "%1" does not exist.'; $serviceInfo = [ 'rest' => [ @@ -185,6 +185,7 @@ class ProductAttributeRepositoryTest extends \Magento\TestFramework\TestCase\Web } catch (\Exception $e) { $errorObj = $this->processRestExceptionResult($e); $this->assertEquals($expectedMessage, $errorObj['message']); + $this->assertEquals([$attributeCode], $errorObj['parameters']); $this->assertEquals(HTTPExceptionCodes::HTTP_NOT_FOUND, $e->getCode()); } } diff --git a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductCustomOptionRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductCustomOptionRepositoryTest.php index 39de9b517afe08198142a3807a6d8a12b16c8ae4..1ddf12ceb1bb39315bb2155415d39eaee067aaa4 100644 --- a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductCustomOptionRepositoryTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductCustomOptionRepositoryTest.php @@ -55,7 +55,7 @@ class ProductCustomOptionRepositoryTest extends WebapiAbstract 'operation' => self::SERVICE_NAME . 'DeleteByIdentifier', ], ]; - $this->assertTrue($this->_webApiCall($serviceInfo, ['productSku' => $sku, 'optionId' => $optionId])); + $this->assertTrue($this->_webApiCall($serviceInfo, ['sku' => $sku, 'optionId' => $optionId])); /** @var \Magento\Catalog\Model\Product $product */ $product = $this->objectManager->create('Magento\Catalog\Model\Product'); $product->load(1); @@ -87,7 +87,7 @@ class ProductCustomOptionRepositoryTest extends WebapiAbstract 'operation' => self::SERVICE_NAME . 'Get', ], ]; - $option = $this->_webApiCall($serviceInfo, ['productSku' => $productSku, 'optionId' => $optionId]); + $option = $this->_webApiCall($serviceInfo, ['sku' => $productSku, 'optionId' => $optionId]); unset($option['product_sku']); unset($option['option_id']); $excepted = include '_files/product_options.php'; @@ -101,6 +101,7 @@ class ProductCustomOptionRepositoryTest extends WebapiAbstract */ public function testGetList() { + $this->_markTestAsRestOnly('Fix inconsistencies in WSDL and Data interfaces'); $productSku = 'simple'; $serviceInfo = [ 'rest' => [ @@ -113,7 +114,7 @@ class ProductCustomOptionRepositoryTest extends WebapiAbstract 'operation' => self::SERVICE_NAME . 'GetList', ], ]; - $options = $this->_webApiCall($serviceInfo, ['productSku' => $productSku]); + $options = $this->_webApiCall($serviceInfo, ['sku' => $productSku]); /** Unset dynamic data */ foreach ($options as $key => $value) { diff --git a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductGroupPriceManagementTest.php b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductGroupPriceManagementTest.php index 882a95238d0b193d722299425f92d09d53c13d93..716a9ac564048a33fee8391647fc136da8f58d67 100644 --- a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductGroupPriceManagementTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductGroupPriceManagementTest.php @@ -32,7 +32,7 @@ class ProductGroupPriceManagementTest extends WebapiAbstract 'operation' => self::SERVICE_NAME . 'GetList', ], ]; - $groupPriceList = $this->_webApiCall($serviceInfo, ['productSku' => $productSku]); + $groupPriceList = $this->_webApiCall($serviceInfo, ['sku' => $productSku]); $this->assertCount(2, $groupPriceList); $this->assertEquals(9, $groupPriceList[0]['value']); $this->assertEquals(7, $groupPriceList[1]['value']); @@ -56,7 +56,7 @@ class ProductGroupPriceManagementTest extends WebapiAbstract 'operation' => self::SERVICE_NAME . 'Remove', ], ]; - $requestData = ['productSku' => $productSku, 'customerGroupId' => $customerGroupId]; + $requestData = ['sku' => $productSku, 'customerGroupId' => $customerGroupId]; $this->assertTrue($this->_webApiCall($serviceInfo, $requestData)); } @@ -77,7 +77,7 @@ class ProductGroupPriceManagementTest extends WebapiAbstract 'operation' => self::SERVICE_NAME . 'Add', ], ]; - $this->_webApiCall($serviceInfo, ['productSku' => $productSku, 'customerGroupId' => 1, 'price' => 10]); + $this->_webApiCall($serviceInfo, ['sku' => $productSku, 'customerGroupId' => 1, 'price' => 10]); $objectManager = \Magento\TestFramework\ObjectManager::getInstance(); /** @var \Magento\Catalog\Api\ProductGroupPriceManagementInterface $service */ $service = $objectManager->get('Magento\Catalog\Api\ProductGroupPriceManagementInterface'); @@ -106,7 +106,7 @@ class ProductGroupPriceManagementTest extends WebapiAbstract ], ]; - $this->_webApiCall($serviceInfo, ['productSku' => $productSku, 'customerGroupId' => 1, 'price' => 10]); + $this->_webApiCall($serviceInfo, ['sku' => $productSku, 'customerGroupId' => 1, 'price' => 10]); $objectManager = \Magento\TestFramework\ObjectManager::getInstance(); /** @var \Magento\Catalog\Api\ProductGroupPriceManagementInterface $service */ $service = $objectManager->get('Magento\Catalog\Api\ProductGroupPriceManagementInterface'); diff --git a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductLinkManagementInterfaceTest.php b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductLinkManagementInterfaceTest.php index 0209428a759950a9e38c7f1339cec95801f2ee7d..5592363a2a8e2d9ed3e1e82b91c6e902c8aab5a2 100644 --- a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductLinkManagementInterfaceTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductLinkManagementInterfaceTest.php @@ -76,7 +76,7 @@ class ProductLinkManagementInterfaceTest extends WebapiAbstract ], ]; - $actual = $this->_webApiCall($serviceInfo, ['productSku' => $productSku, 'type' => $linkType]); + $actual = $this->_webApiCall($serviceInfo, ['sku' => $productSku, 'type' => $linkType]); $this->assertEquals('simple', $actual[0]['linked_product_type']); $this->assertEquals('simple', $actual[0]['linked_product_sku']); @@ -112,7 +112,7 @@ class ProductLinkManagementInterfaceTest extends WebapiAbstract ]; $arguments = [ - 'productSku' => $productSku, + 'sku' => $productSku, 'items' => [$linkData], 'type' => $linkType, ]; diff --git a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductLinkRepositoryInterfaceTest.php b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductLinkRepositoryInterfaceTest.php index 1f89a35c6c26a114b64148c8813869948cc7ea3d..30d9d54a86d48363882113e4ee024ec5e6dff2d9 100644 --- a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductLinkRepositoryInterfaceTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductLinkRepositoryInterfaceTest.php @@ -47,7 +47,7 @@ class ProductLinkRepositoryInterfaceTest extends WebapiAbstract ], ], [ - 'productSku' => $productSku, + 'sku' => $productSku, 'type' => $linkType, 'linkedProductSku' => $linkedSku ] diff --git a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductRepositoryInterfaceTest.php b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductRepositoryInterfaceTest.php index 931a8d2886447ed33379d6f21b548ec97cb5d9db..615675efa90a488421e7d4a4674d51b9355527f5 100644 --- a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductRepositoryInterfaceTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductRepositoryInterfaceTest.php @@ -48,7 +48,7 @@ class ProductRepositoryInterfaceTest extends WebapiAbstract ], ]; - $response = $this->_webApiCall($serviceInfo, ['productSku' => $productData[ProductInterface::SKU]]); + $response = $this->_webApiCall($serviceInfo, ['sku' => $productData[ProductInterface::SKU]]); foreach ([ProductInterface::SKU, ProductInterface::NAME, ProductInterface::PRICE] as $key) { $this->assertEquals($productData[$key], $response[$key]); } @@ -72,7 +72,7 @@ class ProductRepositoryInterfaceTest extends WebapiAbstract $expectedMessage = 'Requested product doesn\'t exist'; try { - $this->_webApiCall($serviceInfo, ['productSku' => $invalidSku]); + $this->_webApiCall($serviceInfo, ['sku' => $invalidSku]); $this->fail("Expected throwing exception"); } catch (\SoapFault $e) { $this->assertContains( @@ -274,6 +274,6 @@ class ProductRepositoryInterfaceTest extends WebapiAbstract ]; return (TESTS_WEB_API_ADAPTER == self::ADAPTER_SOAP) ? - $this->_webApiCall($serviceInfo, ['productSku' => $sku]) : $this->_webApiCall($serviceInfo); + $this->_webApiCall($serviceInfo, ['sku' => $sku]) : $this->_webApiCall($serviceInfo); } } diff --git a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductRepositoryMultiStoreTest.php b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductRepositoryMultiStoreTest.php index e31a51c9313abaff81f0ec9a2d8400aba77bddcc..b2939d3116b93cde0d5453a1eeb0ece5401a6a67 100644 --- a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductRepositoryMultiStoreTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductRepositoryMultiStoreTest.php @@ -34,7 +34,7 @@ class ProductRepositoryMultiStoreTest extends WebapiAbstract /** * Create another store one time for testSearch - * @magentoApiDataFixture Magento/Core/_files/store.php + * @magentoApiDataFixture Magento/Store/_files/core_fixturestore.php */ public function testCreateAnotherStore() { @@ -73,7 +73,7 @@ class ProductRepositoryMultiStoreTest extends WebapiAbstract ] ]; - $requestData = ['id' => $sku, 'productSku' => $sku]; + $requestData = ['id' => $sku, 'sku' => $sku]; $defaultStoreResponse = $this->_webApiCall($serviceInfo, $requestData); $nameInDefaultStore = 'Simple Product'; $this->assertEquals( diff --git a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductTierPriceManagementTest.php b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductTierPriceManagementTest.php index 7fca11a150a627ae7f2d52fc09f5c9f0e48be37a..31e686b2e13dbd0edb704c85d4e772c9c7802cac 100644 --- a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductTierPriceManagementTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductTierPriceManagementTest.php @@ -38,7 +38,7 @@ class ProductTierPriceManagementTest extends WebapiAbstract $groupPriceList = $this->_webApiCall( $serviceInfo, - ['productSku' => $productSku, 'customerGroupId' => $customerGroupId] + ['sku' => $productSku, 'customerGroupId' => $customerGroupId] ); $this->assertCount($count, $groupPriceList); @@ -78,7 +78,7 @@ class ProductTierPriceManagementTest extends WebapiAbstract 'operation' => self::SERVICE_NAME . 'Remove', ], ]; - $requestData = ['productSku' => $productSku, 'customerGroupId' => $customerGroupId, 'qty' => $qty]; + $requestData = ['sku' => $productSku, 'customerGroupId' => $customerGroupId, 'qty' => $qty]; $this->assertTrue($this->_webApiCall($serviceInfo, $requestData)); } @@ -114,7 +114,7 @@ class ProductTierPriceManagementTest extends WebapiAbstract ]; $requestData = [ - 'productSku' => $productSku, + 'sku' => $productSku, 'customerGroupId' => $customerGroupId, 'qty' => $qty, 'price' => $price, @@ -152,7 +152,7 @@ class ProductTierPriceManagementTest extends WebapiAbstract ], ]; $requestData = [ - 'productSku' => $productSku, + 'sku' => $productSku, 'customerGroupId' => $customerGroupId, 'qty' => $qty, 'price' => $price, @@ -190,7 +190,7 @@ class ProductTierPriceManagementTest extends WebapiAbstract ], ]; $requestData = [ - 'productSku' => $productSku, + 'sku' => $productSku, 'customerGroupId' => $customerGroupId, 'qty' => $qty, 'price' => $price, diff --git a/dev/tests/api-functional/testsuite/Magento/CatalogInventory/Api/LowStockItemsTest.php b/dev/tests/api-functional/testsuite/Magento/CatalogInventory/Api/LowStockItemsTest.php index 308fc41b83120d62e4cbc942b7363bebd46b6f2f..27212e5419f214927c1530baea17946f810ee54e 100644 --- a/dev/tests/api-functional/testsuite/Magento/CatalogInventory/Api/LowStockItemsTest.php +++ b/dev/tests/api-functional/testsuite/Magento/CatalogInventory/Api/LowStockItemsTest.php @@ -13,7 +13,7 @@ use Magento\TestFramework\TestCase\WebapiAbstract; class LowStockItemsTest extends WebapiAbstract { const SERVICE_VERSION = 'V1'; - const RESOURCE_PATH = '/V1/stockItem/lowStock/'; + const RESOURCE_PATH = '/V1/stockItems/lowStock/'; /** * @param float $qty diff --git a/dev/tests/api-functional/testsuite/Magento/CatalogInventory/Api/StockItemTest.php b/dev/tests/api-functional/testsuite/Magento/CatalogInventory/Api/StockItemTest.php index 99f1f84fae540d5ed828f7e9f1cd5495b319aee8..0513f5e68abfdbe603bb5972604abb8d21453165 100644 --- a/dev/tests/api-functional/testsuite/Magento/CatalogInventory/Api/StockItemTest.php +++ b/dev/tests/api-functional/testsuite/Magento/CatalogInventory/Api/StockItemTest.php @@ -29,7 +29,7 @@ class StockItemTest extends WebapiAbstract /** * Resource path */ - const RESOURCE_PATH = '/V1/stockItem'; + const RESOURCE_PATH = '/V1/stockItems'; /** @var \Magento\Catalog\Model\Resource\Product\Collection */ protected $productCollection; diff --git a/dev/tests/api-functional/testsuite/Magento/CatalogInventory/Api/StockStatusTest.php b/dev/tests/api-functional/testsuite/Magento/CatalogInventory/Api/StockStatusTest.php index a751be1959c467ca45d503b4ec489d7dcde106bd..19579fe3325b58468582789c7654974c0b01ba3e 100644 --- a/dev/tests/api-functional/testsuite/Magento/CatalogInventory/Api/StockStatusTest.php +++ b/dev/tests/api-functional/testsuite/Magento/CatalogInventory/Api/StockStatusTest.php @@ -14,7 +14,7 @@ use Magento\TestFramework\TestCase\WebapiAbstract; class StockStatusTest extends WebapiAbstract { const SERVICE_VERSION = 'V1'; - const RESOURCE_PATH = '/V1/stockStatus'; + const RESOURCE_PATH = '/V1/stockStatuses'; /** * @magentoApiDataFixture Magento/Catalog/_files/product_simple.php diff --git a/dev/tests/api-functional/testsuite/Magento/ConfigurableProduct/Api/LinkManagementTest.php b/dev/tests/api-functional/testsuite/Magento/ConfigurableProduct/Api/LinkManagementTest.php index dc65d9ff0833cbaa152805997163794f657bcd54..dcb84bd552027feece69841952457ad583076c67 100644 --- a/dev/tests/api-functional/testsuite/Magento/ConfigurableProduct/Api/LinkManagementTest.php +++ b/dev/tests/api-functional/testsuite/Magento/ConfigurableProduct/Api/LinkManagementTest.php @@ -61,7 +61,7 @@ class LinkManagementTest extends \Magento\TestFramework\TestCase\WebapiAbstract 'operation' => self::SERVICE_NAME . 'AddChild' ] ]; - $res = $this->_webApiCall($serviceInfo, ['productSku' => $productSku, 'childSku' => $childSku]); + $res = $this->_webApiCall($serviceInfo, ['sku' => $productSku, 'childSku' => $childSku]); $this->assertTrue($res); } @@ -77,7 +77,7 @@ class LinkManagementTest extends \Magento\TestFramework\TestCase\WebapiAbstract protected function removeChild($productSku, $childSku) { - $resourcePath = self::RESOURCE_PATH . '/%s/child/%s'; + $resourcePath = self::RESOURCE_PATH . '/%s/children/%s'; $serviceInfo = [ 'rest' => [ 'resourcePath' => sprintf($resourcePath, $productSku, $childSku), @@ -89,7 +89,7 @@ class LinkManagementTest extends \Magento\TestFramework\TestCase\WebapiAbstract 'operation' => self::SERVICE_NAME . 'RemoveChild' ] ]; - $requestData = ['productSku' => $productSku, 'childSku' => $childSku]; + $requestData = ['sku' => $productSku, 'childSku' => $childSku]; return $this->_webApiCall($serviceInfo, $requestData); } @@ -110,6 +110,6 @@ class LinkManagementTest extends \Magento\TestFramework\TestCase\WebapiAbstract 'operation' => self::SERVICE_NAME . 'GetChildren' ] ]; - return $this->_webApiCall($serviceInfo, ['productSku' => $productSku]); + return $this->_webApiCall($serviceInfo, ['sku' => $productSku]); } } diff --git a/dev/tests/api-functional/testsuite/Magento/ConfigurableProduct/Api/OptionRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/ConfigurableProduct/Api/OptionRepositoryTest.php index 9c37f1453eaf044172e8dc1ecbb23c35ed7bd246..4551eaa3e45e2d713487938cf485344c5ff10b5c 100644 --- a/dev/tests/api-functional/testsuite/Magento/ConfigurableProduct/Api/OptionRepositoryTest.php +++ b/dev/tests/api-functional/testsuite/Magento/ConfigurableProduct/Api/OptionRepositoryTest.php @@ -109,14 +109,25 @@ class OptionRepositoryTest extends \Magento\TestFramework\TestCase\WebapiAbstrac /** * @magentoApiDataFixture Magento/ConfigurableProduct/_files/product_configurable.php - * @expectedException \Exception - * @expectedExceptionMessage Requested option doesn't exist: -42 */ public function testGetUndefinedOption() { + $expectedMessage = 'Requested option doesn\'t exist: %1'; $productSku = 'configurable'; $attributeId = -42; - $this->get($productSku, $attributeId); + try { + $this->get($productSku, $attributeId); + } catch (\SoapFault $e) { + $this->assertContains( + $expectedMessage, + $e->getMessage(), + 'SoapFault does not contain expected message.' + ); + } catch (\Exception $e) { + $errorObj = $this->processRestExceptionResult($e); + $this->assertEquals($expectedMessage, $errorObj['message']); + $this->assertEquals([$attributeId], $errorObj['parameters']); + } } /** @@ -166,7 +177,7 @@ class OptionRepositoryTest extends \Magento\TestFramework\TestCase\WebapiAbstrac ], ]; /** @var int $result */ - $result = $this->_webApiCall($serviceInfo, ['productSku' => $productSku, 'option' => $option]); + $result = $this->_webApiCall($serviceInfo, ['sku' => $productSku, 'option' => $option]); $this->assertGreaterThan(0, $result); } @@ -196,7 +207,7 @@ class OptionRepositoryTest extends \Magento\TestFramework\TestCase\WebapiAbstrac $requestBody = ['option' => $option]; if (TESTS_WEB_API_ADAPTER == self::ADAPTER_SOAP) { - $requestBody['productSku'] = $productSku; + $requestBody['sku'] = $productSku; $requestBody['option']['id'] = $optionId; } @@ -223,7 +234,7 @@ class OptionRepositoryTest extends \Magento\TestFramework\TestCase\WebapiAbstrac 'operation' => self::SERVICE_NAME . 'GetList' ] ]; - return $this->_webApiCall($serviceInfo, ['productSku' => $productSku]); + return $this->_webApiCall($serviceInfo, ['sku' => $productSku]); } /** @@ -244,7 +255,7 @@ class OptionRepositoryTest extends \Magento\TestFramework\TestCase\WebapiAbstrac 'operation' => self::SERVICE_NAME . 'DeleteById' ] ]; - return $this->_webApiCall($serviceInfo, ['productSku' => $productSku, 'optionId' => $optionId]); + return $this->_webApiCall($serviceInfo, ['sku' => $productSku, 'id' => $optionId]); } /** @@ -265,7 +276,7 @@ class OptionRepositoryTest extends \Magento\TestFramework\TestCase\WebapiAbstrac 'operation' => self::SERVICE_NAME . 'Get' ] ]; - return $this->_webApiCall($serviceInfo, ['productSku' => $productSku, 'optionId' => $optionId]); + return $this->_webApiCall($serviceInfo, ['sku' => $productSku, 'id' => $optionId]); } /** @@ -285,6 +296,6 @@ class OptionRepositoryTest extends \Magento\TestFramework\TestCase\WebapiAbstrac 'operation' => self::SERVICE_NAME . 'GetList' ] ]; - return $this->_webApiCall($serviceInfo, ['productSku' => $productSku]); + return $this->_webApiCall($serviceInfo, ['sku' => $productSku]); } } diff --git a/dev/tests/api-functional/testsuite/Magento/ConfigurableProduct/Api/OptionTypesListTest.php b/dev/tests/api-functional/testsuite/Magento/ConfigurableProduct/Api/OptionTypesListTest.php index 6998a2266e52fec98c4a9971bac45f40f408e237..a96d5ca79a5cb22ccf148210a39a37f0b545ba81 100644 --- a/dev/tests/api-functional/testsuite/Magento/ConfigurableProduct/Api/OptionTypesListTest.php +++ b/dev/tests/api-functional/testsuite/Magento/ConfigurableProduct/Api/OptionTypesListTest.php @@ -10,7 +10,7 @@ class OptionTypesListTest extends \Magento\TestFramework\TestCase\WebapiAbstract { const SERVICE_READ_NAME = 'configurableProductOptionTypesListV1'; const SERVICE_VERSION = 'V1'; - const RESOURCE_PATH = '/V1/configurable-products/:productSku/options/'; + const RESOURCE_PATH = '/V1/configurable-products/:sku/options/'; public function testGetTypes() { @@ -26,7 +26,7 @@ class OptionTypesListTest extends \Magento\TestFramework\TestCase\WebapiAbstract { $serviceInfo = [ 'rest' => [ - 'resourcePath' => str_replace(':productSku/', '', self::RESOURCE_PATH) . 'types', + 'resourcePath' => str_replace(':sku/', '', self::RESOURCE_PATH) . 'types', 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_GET ], 'soap' => [ diff --git a/dev/tests/api-functional/testsuite/Magento/Customer/Api/AccountManagementTest.php b/dev/tests/api-functional/testsuite/Magento/Customer/Api/AccountManagementTest.php index d2a39785a85ef845de66f72b902ff4411495e46a..998e7414785ea26104ca4bd3e20a68ccc0576220 100644 --- a/dev/tests/api-functional/testsuite/Magento/Customer/Api/AccountManagementTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Customer/Api/AccountManagementTest.php @@ -147,8 +147,10 @@ class AccountManagementTest extends WebapiAbstract if (TESTS_WEB_API_ADAPTER == self::ADAPTER_SOAP) { $expectedException = new InputException(); $expectedException->addError( - InputException::INVALID_FIELD_VALUE, - ['fieldName' => 'email', 'value' => $invalidEmail] + __( + InputException::INVALID_FIELD_VALUE, + ['fieldName' => 'email', 'value' => $invalidEmail] + ) ); $this->assertInstanceOf('SoapFault', $e); $this->checkSoapFault( diff --git a/dev/tests/api-functional/testsuite/Magento/Downloadable/Api/LinkRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/Downloadable/Api/LinkRepositoryTest.php index 78bb435b7af4d2c3a2ac98e7e7a8fde51a831566..56434acaf7b0135bb0d9bedc154a8b14b67a7a14 100644 --- a/dev/tests/api-functional/testsuite/Magento/Downloadable/Api/LinkRepositoryTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Downloadable/Api/LinkRepositoryTest.php @@ -113,7 +113,7 @@ class LinkRepositoryTest extends WebapiAbstract { $requestData = [ 'isGlobalScopeContent' => true, - 'productSku' => 'downloadable-product', + 'sku' => 'downloadable-product', 'linkContent' => [ 'title' => 'Title', 'sort_order' => 1, @@ -159,7 +159,7 @@ class LinkRepositoryTest extends WebapiAbstract { $requestData = [ 'isGlobalScopeContent' => false, - 'productSku' => 'downloadable-product', + 'sku' => 'downloadable-product', 'linkContent' => [ 'title' => 'Store View Title', 'sort_order' => 1, @@ -197,7 +197,7 @@ class LinkRepositoryTest extends WebapiAbstract { $requestData = [ 'isGlobalScopeContent' => false, - 'productSku' => 'downloadable-product', + 'sku' => 'downloadable-product', 'linkContent' => [ 'title' => 'Link with URL resources', 'sort_order' => 1, @@ -234,7 +234,7 @@ class LinkRepositoryTest extends WebapiAbstract { $requestData = [ 'isGlobalScopeContent' => false, - 'productSku' => 'downloadable-product', + 'sku' => 'downloadable-product', 'linkContent' => [ 'title' => 'Link with URL resources', 'sort_order' => 1, @@ -256,7 +256,7 @@ class LinkRepositoryTest extends WebapiAbstract { $requestData = [ 'isGlobalScopeContent' => false, - 'productSku' => 'downloadable-product', + 'sku' => 'downloadable-product', 'linkContent' => [ 'title' => 'Link Title', 'sort_order' => 1, @@ -285,7 +285,7 @@ class LinkRepositoryTest extends WebapiAbstract { $requestData = [ 'isGlobalScopeContent' => false, - 'productSku' => 'downloadable-product', + 'sku' => 'downloadable-product', 'linkContent' => [ 'title' => 'Link Title', 'sort_order' => 1, @@ -312,7 +312,7 @@ class LinkRepositoryTest extends WebapiAbstract { $requestData = [ 'isGlobalScopeContent' => false, - 'productSku' => 'downloadable-product', + 'sku' => 'downloadable-product', 'linkContent' => [ 'title' => 'Title', 'sort_order' => 15, @@ -339,7 +339,7 @@ class LinkRepositoryTest extends WebapiAbstract { $requestData = [ 'isGlobalScopeContent' => false, - 'productSku' => 'downloadable-product', + 'sku' => 'downloadable-product', 'linkContent' => [ 'title' => 'Link Title', 'sort_order' => 1, @@ -368,7 +368,7 @@ class LinkRepositoryTest extends WebapiAbstract { $requestData = [ 'isGlobalScopeContent' => false, - 'productSku' => 'downloadable-product', + 'sku' => 'downloadable-product', 'linkContent' => [ 'title' => 'Link Title', 'sort_order' => 1, @@ -392,7 +392,7 @@ class LinkRepositoryTest extends WebapiAbstract { $requestData = [ 'isGlobalScopeContent' => false, - 'productSku' => 'downloadable-product', + 'sku' => 'downloadable-product', 'linkContent' => [ 'title' => 'Link Title', 'sort_order' => 1, @@ -419,7 +419,7 @@ class LinkRepositoryTest extends WebapiAbstract { $requestData = [ 'isGlobalScopeContent' => false, - 'productSku' => 'downloadable-product', + 'sku' => 'downloadable-product', 'linkContent' => [ 'title' => 'Link Title', 'sort_order' => 1, @@ -457,7 +457,7 @@ class LinkRepositoryTest extends WebapiAbstract { $requestData = [ 'isGlobalScopeContent' => false, - 'productSku' => 'downloadable-product', + 'sku' => 'downloadable-product', 'linkContent' => [ 'title' => 'Link Title', 'sort_order' => $sortOrder, @@ -493,7 +493,7 @@ class LinkRepositoryTest extends WebapiAbstract { $requestData = [ 'isGlobalScopeContent' => false, - 'productSku' => 'downloadable-product', + 'sku' => 'downloadable-product', 'linkContent' => [ 'title' => 'Link Title', 'sort_order' => 0, @@ -529,7 +529,7 @@ class LinkRepositoryTest extends WebapiAbstract $this->createServiceInfo['rest']['resourcePath'] = '/V1/products/simple/downloadable-links'; $requestData = [ 'isGlobalScopeContent' => false, - 'productSku' => 'simple', + 'sku' => 'simple', 'linkContent' => [ 'title' => 'Link Title', 'sort_order' => 50, @@ -554,7 +554,7 @@ class LinkRepositoryTest extends WebapiAbstract $this->createServiceInfo['rest']['resourcePath'] = '/V1/products/wrong-sku/downloadable-links'; $requestData = [ 'isGlobalScopeContent' => false, - 'productSku' => 'wrong-sku', + 'sku' => 'wrong-sku', 'linkContent' => [ 'title' => 'Link Title', 'sort_order' => 15, @@ -581,7 +581,7 @@ class LinkRepositoryTest extends WebapiAbstract $requestData = [ 'isGlobalScopeContent' => false, 'linkId' => $linkId, - 'productSku' => 'downloadable-product', + 'sku' => 'downloadable-product', 'linkContent' => [ 'title' => 'Updated Title', 'sort_order' => 2, @@ -612,7 +612,7 @@ class LinkRepositoryTest extends WebapiAbstract $requestData = [ 'isGlobalScopeContent' => true, 'linkId' => $linkId, - 'productSku' => 'downloadable-product', + 'sku' => 'downloadable-product', 'linkContent' => [ 'title' => 'Updated Title', 'sort_order' => 2, @@ -646,7 +646,7 @@ class LinkRepositoryTest extends WebapiAbstract $requestData = [ 'isGlobalScopeContent' => true, 'linkId' => 1, - 'productSku' => 'wrong-sku', + 'sku' => 'wrong-sku', 'linkContent' => [ 'title' => 'Updated Title', 'sort_order' => 2, @@ -671,7 +671,7 @@ class LinkRepositoryTest extends WebapiAbstract $requestData = [ 'isGlobalScopeContent' => true, 'linkId' => 9999, - 'productSku' => 'downloadable-product', + 'sku' => 'downloadable-product', 'linkContent' => [ 'title' => 'Title', 'sort_order' => 2, @@ -698,7 +698,7 @@ class LinkRepositoryTest extends WebapiAbstract $requestData = [ 'isGlobalScopeContent' => false, 'linkId' => $linkId, - 'productSku' => 'downloadable-product', + 'sku' => 'downloadable-product', 'linkContent' => [ 'title' => 'Updated Link Title', 'sort_order' => 2, @@ -725,7 +725,7 @@ class LinkRepositoryTest extends WebapiAbstract $requestData = [ 'isGlobalScopeContent' => false, 'linkId' => $linkId, - 'productSku' => 'downloadable-product', + 'sku' => 'downloadable-product', 'linkContent' => [ 'title' => 'Updated Link Title', 'sort_order' => $sortOrder, @@ -751,7 +751,7 @@ class LinkRepositoryTest extends WebapiAbstract $requestData = [ 'isGlobalScopeContent' => false, 'linkId' => $linkId, - 'productSku' => 'downloadable-product', + 'sku' => 'downloadable-product', 'linkContent' => [ 'title' => 'Updated Link Title', 'sort_order' => 200, @@ -813,7 +813,7 @@ class LinkRepositoryTest extends WebapiAbstract ], ]; - $requestData = ['productSku' => $sku]; + $requestData = ['sku' => $sku]; $expectedMessage = 'Requested product doesn\'t exist'; try { @@ -845,7 +845,7 @@ class LinkRepositoryTest extends WebapiAbstract ], ]; - $requestData = ['productSku' => $sku]; + $requestData = ['sku' => $sku]; $list = $this->_webApiCall($serviceInfo, $requestData); $this->assertEmpty($list); @@ -871,7 +871,7 @@ class LinkRepositoryTest extends WebapiAbstract ], ]; - $requestData = ['productSku' => $sku]; + $requestData = ['sku' => $sku]; $list = $this->_webApiCall($serviceInfo, $requestData); diff --git a/dev/tests/api-functional/testsuite/Magento/Eav/Api/AttributeSetRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/Eav/Api/AttributeSetRepositoryTest.php index 435333d1b1ff6a6668d12123126bf18119ada6fb..c4876bd7f9f14bb5627fcb6bffb6b2e5edbc6f93 100644 --- a/dev/tests/api-functional/testsuite/Magento/Eav/Api/AttributeSetRepositoryTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Eav/Api/AttributeSetRepositoryTest.php @@ -73,7 +73,7 @@ class AttributeSetRepositoryTest extends WebapiAbstract $attributeSet = $this->getAttributeSetByName($attributeSetName); $serviceInfo = [ 'rest' => [ - 'resourcePath' => '/V1/eav/attribute-sets', + 'resourcePath' => '/V1/eav/attribute-sets/' . $attributeSet->getId(), 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_PUT, ], 'soap' => [ diff --git a/dev/tests/api-functional/testsuite/Magento/GroupedProduct/Api/ProductLinkManagementTest.php b/dev/tests/api-functional/testsuite/Magento/GroupedProduct/Api/ProductLinkManagementTest.php index 90cec13232000d8b00de2e09c49bc0e1027a5367..10e6d6f41ed029f84d9aab099da6cf27c462a736 100644 --- a/dev/tests/api-functional/testsuite/Magento/GroupedProduct/Api/ProductLinkManagementTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GroupedProduct/Api/ProductLinkManagementTest.php @@ -32,7 +32,7 @@ class ProductLinkManagementTest extends \Magento\TestFramework\TestCase\WebapiAb ], ]; - $actual = $this->_webApiCall($serviceInfo, ['productSku' => $productSku, 'type' => $linkType]); + $actual = $this->_webApiCall($serviceInfo, ['sku' => $productSku, 'type' => $linkType]); $expected = [ [ @@ -55,14 +55,14 @@ class ProductLinkManagementTest extends \Magento\TestFramework\TestCase\WebapiAb array_walk( $expected, function (&$item) { - $item['custom_attributes'] = [['attribute_code' => 'qty', 'value' => 1.0000]]; + $item['extension_attributes'] = ['qty' => 1.0000]; } ); } else { array_walk( $expected, function (&$item) { - $item['custom_attributes'] = [['attribute_code' => 'qty', 'value' => 1.0000]]; + $item['extension_attributes'] = ['qty' => 1.0000]; } ); } diff --git a/dev/tests/api-functional/testsuite/Magento/GroupedProduct/Api/ProductLinkRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/GroupedProduct/Api/ProductLinkRepositoryTest.php index 4d375e84e39e9fadfea209c33cd29a5a9ef54d5b..69b1ef5073b6169102748462104bade23fc22017 100644 --- a/dev/tests/api-functional/testsuite/Magento/GroupedProduct/Api/ProductLinkRepositoryTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GroupedProduct/Api/ProductLinkRepositoryTest.php @@ -37,8 +37,8 @@ class ProductLinkRepositoryTest extends \Magento\TestFramework\TestCase\WebapiAb 'linked_product_type' => 'simple', 'linked_product_sku' => 'simple', 'position' => 3, - 'custom_attributes' => [ - 'qty' => ['attribute_code' => 'qty', 'value' => (float) 300.0000], + 'extension_attributes' => [ + 'qty' => (float) 300.0000, ], ]; @@ -55,7 +55,7 @@ class ProductLinkRepositoryTest extends \Magento\TestFramework\TestCase\WebapiAb ]; $this->_webApiCall($serviceInfo, ['entity' => $productData]); - /** @var \Magento\Catalog\Model\ProductLink\Management $linkManagement */ + /** @var \Magento\Catalog\Api\ProductLinkManagementInterface $linkManagement */ $linkManagement = $this->objectManager->get('Magento\Catalog\Api\ProductLinkManagementInterface'); $actual = $linkManagement->getLinkedItemsByType($productSku, $linkType); array_walk($actual, function (&$item) { diff --git a/dev/tests/api-functional/testsuite/Magento/Quote/Api/CartRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/Quote/Api/CartRepositoryTest.php index e411cc7903156b779ef651636eeebb0ca60f5b80..add493db96a143faf32a0d26e183122067aaa9e6 100644 --- a/dev/tests/api-functional/testsuite/Magento/Quote/Api/CartRepositoryTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Quote/Api/CartRepositoryTest.php @@ -153,18 +153,6 @@ class CartRepositoryTest extends WebapiAbstract { $cart = $this->getCart('test01'); - $serviceInfo = [ - 'rest' => [ - 'resourcePath' => '/V1/carts', - 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_PUT, - ], - 'soap' => [ - 'service' => 'quoteCartRepositoryV1', - 'serviceVersion' => 'V1', - 'operation' => 'quoteCartRepositoryV1GetList', - ], - ]; - // The following two filters are used as alternatives. The target cart does not match the first one. $grandTotalFilter = $this->filterBuilder->setField('grand_total') ->setConditionType('gteq') @@ -195,6 +183,18 @@ class CartRepositoryTest extends WebapiAbstract $searchCriteria = $this->searchBuilder->create()->__toArray(); $requestData = ['searchCriteria' => $searchCriteria]; + $serviceInfo = [ + 'rest' => [ + 'resourcePath' => '/V1/carts' . '?' . http_build_query($requestData), + 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_GET, + ], + 'soap' => [ + 'service' => 'quoteCartRepositoryV1', + 'serviceVersion' => 'V1', + 'operation' => 'quoteCartRepositoryV1GetList', + ], + ]; + $searchResult = $this->_webApiCall($serviceInfo, $requestData); $this->assertArrayHasKey('total_count', $searchResult); $this->assertEquals(1, $searchResult['total_count']); diff --git a/dev/tests/api-functional/testsuite/Magento/Quote/Api/ShippingMethodManagementTest.php b/dev/tests/api-functional/testsuite/Magento/Quote/Api/ShippingMethodManagementTest.php index 270b433a6a7084201221b224560ae32ca68dfc45..6217cc99b088f063669901fdc5e1d492794e1e2c 100644 --- a/dev/tests/api-functional/testsuite/Magento/Quote/Api/ShippingMethodManagementTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Quote/Api/ShippingMethodManagementTest.php @@ -68,22 +68,30 @@ class ShippingMethodManagementTest extends WebapiAbstract */ public function testSetMethodWrongMethod() { + $expectedMessage = 'Carrier with such method not found: %1, %2'; $this->quote->load('test_order_1', 'reserved_order_id'); $serviceInfo = $this->getServiceInfo(); + $carrierCode = 'flatrate'; + $methodCode = 'wrongMethod'; $requestData = [ 'cartId' => $this->quote->getId(), - 'carrierCode' => 'flatrate', - 'methodCode' => 'wrongMethod', + 'carrierCode' => $carrierCode, + 'methodCode' => $methodCode, ]; try { $this->_webApiCall($serviceInfo, $requestData); } catch (\SoapFault $e) { - $message = $e->getMessage(); + $this->assertContains( + $expectedMessage, + $e->getMessage(), + 'SoapFault does not contain expected message.' + ); } catch (\Exception $e) { - $message = json_decode($e->getMessage())->message; + $errorObj = $this->processRestExceptionResult($e); + $this->assertEquals($expectedMessage, $errorObj['message']); + $this->assertEquals([$carrierCode, $methodCode], $errorObj['parameters']); } - $this->assertEquals('Carrier with such method not found: flatrate, wrongMethod', $message); } /** diff --git a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/CreditmemoAddCommentTest.php b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/CreditmemoAddCommentTest.php index 86e5df82c426fb8954f32551900c45aed58f6b8e..909d1bf694e8fa61e9c4bf0b04b6108de30fffb0 100644 --- a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/CreditmemoAddCommentTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/CreditmemoAddCommentTest.php @@ -66,7 +66,7 @@ class CreditmemoAddCommentTest extends WebapiAbstract $requestData = ['entity' => $commentData]; $serviceInfo = [ 'rest' => [ - 'resourcePath' => '/V1/creditmemo/comment', + 'resourcePath' => '/V1/creditmemo/' . $creditmemo->getId() . '/comments', 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_POST, ], 'soap' => [ diff --git a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/InvoiceAddCommentTest.php b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/InvoiceAddCommentTest.php index a6ad6436a54d3dd00bb3bfb3c2d16464716a85cc..fb69f3e2bf944ae199ce963c484f6638b87457be 100644 --- a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/InvoiceAddCommentTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/InvoiceAddCommentTest.php @@ -47,7 +47,7 @@ class InvoiceAddCommentTest extends WebapiAbstract $requestData = ['entity' => $commentData]; $serviceInfo = [ 'rest' => [ - 'resourcePath' => '/V1/invoice/comment', + 'resourcePath' => '/V1/invoices/comments', 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_POST, ], 'soap' => [ diff --git a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/InvoiceCommentsListTest.php b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/InvoiceCommentsListTest.php index 22f4c333de797034bf809714300a744abfaca2c2..d03981ed76af47d0c93b36984e1bd44acae0a1a4 100644 --- a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/InvoiceCommentsListTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/InvoiceCommentsListTest.php @@ -34,7 +34,7 @@ class InvoiceCommentsListTest extends WebapiAbstract $serviceInfo = [ 'rest' => [ - 'resourcePath' => '/V1/invoice/' . $invoice->getId() . '/comments', + 'resourcePath' => '/V1/invoices/' . $invoice->getId() . '/comments', 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_GET, ], 'soap' => [ diff --git a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/InvoiceCreateTest.php b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/InvoiceCreateTest.php index 10c54d043e878d1ccbdddd0d877579266c6deb32..3237b600d6194811759404a099936f0d4b9e1f87 100644 --- a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/InvoiceCreateTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/InvoiceCreateTest.php @@ -12,7 +12,7 @@ use Magento\TestFramework\TestCase\WebapiAbstract; */ class InvoiceCreateTest extends WebapiAbstract { - const RESOURCE_PATH = '/V1/invoice'; + const RESOURCE_PATH = '/V1/invoices'; const SERVICE_READ_NAME = 'salesInvoiceRepositoryV1'; diff --git a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/InvoiceEmailTest.php b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/InvoiceEmailTest.php index 572becdd7c535fd6215a29faa109bf871a74fe8e..66ae7db9a299d598a630f249f377cce6d4d00472 100644 --- a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/InvoiceEmailTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/InvoiceEmailTest.php @@ -26,7 +26,7 @@ class InvoiceEmailTest extends WebapiAbstract $invoice = $invoiceCollection->getFirstItem(); $serviceInfo = [ 'rest' => [ - 'resourcePath' => '/V1/invoice/' . $invoice->getId() . '/email', + 'resourcePath' => '/V1/invoices/' . $invoice->getId() . '/emails', 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_POST, ], 'soap' => [ diff --git a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/InvoiceGetTest.php b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/InvoiceGetTest.php index da6c9291912d6c5fc839f27386551d32243ecb99..9e7758a570e5c6098ff156809b6341d6e58ce7d5 100644 --- a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/InvoiceGetTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/InvoiceGetTest.php @@ -12,7 +12,7 @@ use Magento\TestFramework\TestCase\WebapiAbstract; */ class InvoiceGetTest extends WebapiAbstract { - const RESOURCE_PATH = '/V1/invoice'; + const RESOURCE_PATH = '/V1/invoices'; const SERVICE_READ_NAME = 'salesInvoiceRepositoryV1'; diff --git a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderAddressUpdateTest.php b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderAddressUpdateTest.php index 40a5fb8975ed64dd2df16026dc7cc4ed8c483ce2..337a532d256f520afa592be6a0b56df861f37e08 100644 --- a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderAddressUpdateTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderAddressUpdateTest.php @@ -59,7 +59,7 @@ class OrderAddressUpdateTest extends WebapiAbstract $serviceInfo = [ 'rest' => [ - 'resourcePath' => '/V1/order/' . $order->getId(), + 'resourcePath' => '/V1/orders/' . $order->getId(), 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_PUT, ], 'soap' => [ diff --git a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderCancelTest.php b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderCancelTest.php index e9b2afe36752e38637cab12fe107f39866b5c739..cd7cce323670340ab67a36af31dc722f5a1f4df9 100644 --- a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderCancelTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderCancelTest.php @@ -23,7 +23,7 @@ class OrderCancelTest extends WebapiAbstract $order = $objectManager->get('Magento\Sales\Model\Order')->loadByIncrementId('100000001'); $serviceInfo = [ 'rest' => [ - 'resourcePath' => '/V1/order/' . $order->getId() . '/cancel', + 'resourcePath' => '/V1/orders/' . $order->getId() . '/cancel', 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_POST, ], 'soap' => [ diff --git a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderCommentsListTest.php b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderCommentsListTest.php index 4117b042e1fa72177eb1b1a6d3f8632785039260..50f697f2039bf680fd8150d2d8764ceb1b7a9a57 100644 --- a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderCommentsListTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderCommentsListTest.php @@ -28,7 +28,7 @@ class OrderCommentsListTest extends WebapiAbstract $serviceInfo = [ 'rest' => [ - 'resourcePath' => '/V1/order/' . $order->getId() . '/comments', + 'resourcePath' => '/V1/orders/' . $order->getId() . '/comments', 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_GET, ], 'soap' => [ diff --git a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderCreateTest.php b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderCreateTest.php index f5b38cf18ae14725f0946c4e44856845f9c535d3..9671029364b2c5fcfb594ddd02cf74d9aaf20e1b 100644 --- a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderCreateTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderCreateTest.php @@ -10,7 +10,7 @@ use Magento\TestFramework\TestCase\WebapiAbstract; class OrderCreateTest extends WebapiAbstract { - const RESOURCE_PATH = '/V1/order'; + const RESOURCE_PATH = '/V1/orders'; const SERVICE_READ_NAME = 'salesOrderRepositoryV1'; diff --git a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderEmailTest.php b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderEmailTest.php index ed9722292bd9d10c6fb41f26ccec571cbaf1a8bb..6044e173013285687a27546625d9b1878a667fea 100644 --- a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderEmailTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderEmailTest.php @@ -24,7 +24,7 @@ class OrderEmailTest extends WebapiAbstract $order->loadByIncrementId('100000001'); $serviceInfo = [ 'rest' => [ - 'resourcePath' => '/V1/order/' . $order->getId() . '/email', + 'resourcePath' => '/V1/orders/' . $order->getId() . '/emails', 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_POST, ], 'soap' => [ diff --git a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderGetStatusTest.php b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderGetStatusTest.php index 94f18257d8e443d4030dd2c6887c47cb088f1bd3..a45e17ccc48585457cf6b3e47748bd52f45c2794 100644 --- a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderGetStatusTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderGetStatusTest.php @@ -13,7 +13,7 @@ use Magento\TestFramework\TestCase\WebapiAbstract; */ class OrderGetStatusTest extends WebapiAbstract { - const RESOURCE_PATH = '/V1/order/%d/status'; + const RESOURCE_PATH = '/V1/orders/%d/statuses'; const SERVICE_READ_NAME = 'salesOrderManagementV1'; diff --git a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderGetTest.php b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderGetTest.php index d590af9442b7f1f78fc5c2f617b6ffe2330f9a7d..46c3c7ca1b96392611dc62081e43bfb385eb478a 100644 --- a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderGetTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderGetTest.php @@ -9,7 +9,7 @@ use Magento\TestFramework\TestCase\WebapiAbstract; class OrderGetTest extends WebapiAbstract { - const RESOURCE_PATH = '/V1/order'; + const RESOURCE_PATH = '/V1/orders'; const SERVICE_READ_NAME = 'salesOrderRepositoryV1'; diff --git a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderHoldTest.php b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderHoldTest.php index 72d05d8f6c79106b0ba33c48b99fb8bf0658646c..bd693a814ad3cc5e747972def80ef2722a1f8f57 100644 --- a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderHoldTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderHoldTest.php @@ -23,7 +23,7 @@ class OrderHoldTest extends WebapiAbstract $order = $objectManager->get('Magento\Sales\Model\Order')->loadByIncrementId('100000001'); $serviceInfo = [ 'rest' => [ - 'resourcePath' => '/V1/order/' . $order->getId() . '/hold', + 'resourcePath' => '/V1/orders/' . $order->getId() . '/hold', 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_POST, ], 'soap' => [ diff --git a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderStatusHistoryAddTest.php b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderStatusHistoryAddTest.php index bb779d74cc0fd70f3eef788647fddc588e5ce141..95858cce508621c7d1bf7aa4d3dee5df379fd9d9 100644 --- a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderStatusHistoryAddTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderStatusHistoryAddTest.php @@ -57,7 +57,7 @@ class OrderStatusHistoryAddTest extends WebapiAbstract $requestData = ['id' => $order->getId(), 'statusHistory' => $commentData]; $serviceInfo = [ 'rest' => [ - 'resourcePath' => '/V1/order/' . $order->getId() . '/comment', + 'resourcePath' => '/V1/orders/' . $order->getId() . '/comments', 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_POST, ], 'soap' => [ diff --git a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderUnHoldTest.php b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderUnHoldTest.php index a8e2a81d6bda64ca1142cdddbd3c4bb8acefa80b..572ba2409e070865e0f9ef9b316c24e93b35c558 100644 --- a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderUnHoldTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderUnHoldTest.php @@ -27,7 +27,7 @@ class OrderUnHoldTest extends WebapiAbstract } $serviceInfo = [ 'rest' => [ - 'resourcePath' => '/V1/order/' . $order->getId() . '/unhold', + 'resourcePath' => '/V1/orders/' . $order->getId() . '/unhold', 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_POST, ], 'soap' => [ diff --git a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/ShipmentAddCommentTest.php b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/ShipmentAddCommentTest.php index 3e76bd29340a90430ba96116673f82249d4049ea..330fd56c430b6dd682fa9f6d50e530fac74884a2 100644 --- a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/ShipmentAddCommentTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/ShipmentAddCommentTest.php @@ -61,7 +61,7 @@ class ShipmentAddCommentTest extends WebapiAbstract $requestData = ['entity' => $commentData]; $serviceInfo = [ 'rest' => [ - 'resourcePath' => '/V1/shipment/comment', + 'resourcePath' => '/V1/shipment/' . $shipment->getId() . '/comments', 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_POST, ], 'soap' => [ diff --git a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/ShipmentEmailTest.php b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/ShipmentEmailTest.php index 947d51f70f4b15c1ac3fe0a3141116723614e4f9..d6b59d22475398ce532469035661fba7a51edd64 100644 --- a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/ShipmentEmailTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/ShipmentEmailTest.php @@ -27,7 +27,7 @@ class ShipmentEmailTest extends WebapiAbstract $shipment = $shipmentCollection->getFirstItem(); $serviceInfo = [ 'rest' => [ - 'resourcePath' => '/V1/shipment/' . $shipment->getId() . '/email', + 'resourcePath' => '/V1/shipment/' . $shipment->getId() . '/emails', 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_POST, ], 'soap' => [ diff --git a/dev/tests/api-functional/testsuite/Magento/Tax/Api/TaxClassRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/Tax/Api/TaxClassRepositoryTest.php index 4827823190d200e3f3cfa0fcfea198a871cb31dc..1557278ce1bb31a76ac96d90a90c57b6bada4d21 100644 --- a/dev/tests/api-functional/testsuite/Magento/Tax/Api/TaxClassRepositoryTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Tax/Api/TaxClassRepositoryTest.php @@ -23,7 +23,7 @@ class TaxClassRepositoryTest extends WebapiAbstract { const SERVICE_NAME = 'taxTaxClassRepositoryV1'; const SERVICE_VERSION = 'V1'; - const RESOURCE_PATH = '/V1/taxClass'; + const RESOURCE_PATH = '/V1/taxClasses'; /** @var SearchCriteriaBuilder */ private $searchCriteriaBuilder; diff --git a/dev/tests/api-functional/testsuite/Magento/Tax/Api/TaxRateRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/Tax/Api/TaxRateRepositoryTest.php index 33b8a783507b35a5fbfbb355d093d1e3349e00a4..df2cf377a532c3e4c79a9c1ec59ac58663e8c4f8 100644 --- a/dev/tests/api-functional/testsuite/Magento/Tax/Api/TaxRateRepositoryTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Tax/Api/TaxRateRepositoryTest.php @@ -14,11 +14,14 @@ use Magento\Tax\Api\Data\TaxRateInterface as TaxRate; use Magento\TestFramework\Helper\Bootstrap; use Magento\TestFramework\TestCase\WebapiAbstract; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class TaxRateRepositoryTest extends WebapiAbstract { const SERVICE_NAME = "taxTaxRateRepositoryV1"; const SERVICE_VERSION = "V1"; - const RESOURCE_PATH = "/V1/taxRate"; + const RESOURCE_PATH = "/V1/taxRates"; /** @var \Magento\Tax\Model\Calculation\Rate[] */ private $fixtureTaxRates; @@ -97,6 +100,7 @@ class TaxRateRepositoryTest extends WebapiAbstract public function testCreateTaxRateExistingCode() { + $expectedMessage = '%1 already exists.'; $data = [ 'tax_rate' => [ 'tax_country_id' => 'US', @@ -121,14 +125,16 @@ class TaxRateRepositoryTest extends WebapiAbstract try { $this->_webApiCall($serviceInfo, $data); $this->fail('Expected exception was not raised'); - } catch (\Exception $e) { - $expectedMessage = 'Code already exists.'; - + } catch (\SoapFault $e) { $this->assertContains( $expectedMessage, $e->getMessage(), - "Exception does not contain expected message." + 'SoapFault does not contain expected message.' ); + } catch (\Exception $e) { + $errorObj = $this->processRestExceptionResult($e); + $this->assertEquals($expectedMessage, $errorObj['message']); + $this->assertEquals(['Code'], $errorObj['parameters']); } } diff --git a/dev/tests/api-functional/testsuite/Magento/Tax/Api/TaxRuleRepositoryInterfaceTest.php b/dev/tests/api-functional/testsuite/Magento/Tax/Api/TaxRuleRepositoryInterfaceTest.php index 7d3c6d7a1c2940b6e3ebb26653efdf3d1bc1fabc..4bef167f0e8ea063f601dc495ab4bd44a63de3b9 100644 --- a/dev/tests/api-functional/testsuite/Magento/Tax/Api/TaxRuleRepositoryInterfaceTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Tax/Api/TaxRuleRepositoryInterfaceTest.php @@ -178,6 +178,7 @@ class TaxRuleRepositoryInterfaceTest extends WebapiAbstract public function testCreateTaxRuleExistingCode() { + $expectedMessage = '%1 already exists.'; $requestData = [ 'rule' => [ 'code' => 'Test Rule ' . microtime(), @@ -205,13 +206,16 @@ class TaxRuleRepositoryInterfaceTest extends WebapiAbstract try { $this->_webApiCall($serviceInfo, $requestData); $this->fail('Expected exception was not raised'); - } catch (\Exception $e) { - $expectedMessage = 'Code already exists.'; + } catch (\SoapFault $e) { $this->assertContains( $expectedMessage, $e->getMessage(), - "Exception does not contain expected message." + 'SoapFault does not contain expected message.' ); + } catch (\Exception $e) { + $errorObj = $this->processRestExceptionResult($e); + $this->assertEquals($expectedMessage, $errorObj['message']); + $this->assertEquals(['Code'], $errorObj['parameters']); } // Clean up the new tax rule so it won't affect other tests diff --git a/dev/tests/api-functional/testsuite/Magento/Webapi/DataObjectSerialization/CustomAttributeSerializationMSCTest.php b/dev/tests/api-functional/testsuite/Magento/Webapi/DataObjectSerialization/CustomAttributeSerializationMSCTest.php deleted file mode 100644 index f8ec083d6e1f3aeb0155475ae83ce034f7ecad61..0000000000000000000000000000000000000000 --- a/dev/tests/api-functional/testsuite/Magento/Webapi/DataObjectSerialization/CustomAttributeSerializationMSCTest.php +++ /dev/null @@ -1,230 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -namespace Magento\Webapi\DataObjectSerialization; - -use Magento\Framework\Reflection\DataObjectProcessor; -use Magento\Framework\Webapi\ServiceOutputProcessor; -use Magento\TestFramework\Helper\Bootstrap; -use Magento\TestModuleMSC\Api\Data\ItemInterfaceFactory; - -/** - * api-functional/testsuite/Magento/Webapi/DataObjectSerialization/CustomAttributeSerializationMSCTest.php - * Class to test if custom attributes are serialized correctly for the new Module Service Contract approach - */ -class CustomAttributeSerializationMSCTest extends \Magento\Webapi\Routing\BaseService -{ - /** - * @var string - */ - protected $_version; - /** - * @var string - */ - protected $_restResourcePath; - /** - * @var string - */ - protected $_soapService = 'testModuleMSCAllSoapAndRest'; - - /** - * @var ItemInterfaceFactory - */ - protected $itemDataFactory; - - /** - * @var \Magento\TestModuleMSC\Api\Data\CustomAttributeNestedDataObjectInterfaceFactory - */ - protected $customAttributeNestedDataObjectDataFactory; - - /** - * @var \Magento\TestModuleMSC\Api\Data\CustomAttributeDataObjectInterfaceFactory - */ - protected $customAttributeDataObjectDataFactory; - - /** - * @var DataObjectProcessor $dataObjectProcessor - */ - protected $dataObjectProcessor; - - /** - * @var ServiceOutputProcessor $serviceOutputProcessor - */ - protected $serviceOutputProcessor; - - /** - * Set up custom attribute related data objects - */ - protected function setUp() - { - $this->_version = 'V1'; - $this->_soapService = 'testModuleMSCAllSoapAndRestV1'; - $this->_restResourcePath = "/{$this->_version}/testmoduleMSC/"; - - $this->itemDataFactory = Bootstrap::getObjectManager()->create( - 'Magento\TestModuleMSC\Api\Data\ItemInterfaceFactory' - ); - - $this->customAttributeNestedDataObjectDataFactory = Bootstrap::getObjectManager()->create( - 'Magento\TestModuleMSC\Api\Data\CustomAttributeNestedDataObjectInterfaceFactory' - ); - - $this->customAttributeDataObjectDataFactory = Bootstrap::getObjectManager()->create( - 'Magento\TestModuleMSC\Api\Data\CustomAttributeDataObjectInterfaceFactory' - ); - - $this->dataObjectProcessor = Bootstrap::getObjectManager()->create( - 'Magento\Framework\Reflection\DataObjectProcessor' - ); - - $this->serviceOutputProcessor = Bootstrap::getObjectManager()->create( - 'Magento\Framework\Webapi\ServiceOutputProcessor' - ); - } - - public function testSimpleAndNonExistentCustomAttributes() - { - $serviceInfo = [ - 'rest' => [ - 'resourcePath' => $this->_restResourcePath . 'itemAnyType', - 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_POST, - ], - 'soap' => ['service' => $this->_soapService, 'operation' => $this->_soapService . 'ItemAnyType'], - ]; - $requestData = [ - 'item_id' => 1, - 'name' => 'testProductAnyType', - 'custom_attributes' => [ - 'non_existent' => [ - 'attribute_code' => 'non_existent', - 'value' => 'test', - ], - 'custom_attribute_string' => [ - 'attribute_code' => 'custom_attribute_string', - 'value' => 'someStringValue', - ], - ], - ]; - $result = $this->_webApiCall($serviceInfo, ['entityItem' => $requestData]); - - //The non_existent custom attribute should be dropped since its not a defined custom attribute - $expectedResponse = [ - 'item_id' => 1, - 'name' => 'testProductAnyType', - 'custom_attributes' => [ - [ - 'attribute_code' => 'custom_attribute_string', - 'value' => 'someStringValue', - ], - ], - ]; - - //\Magento\TestModuleMSC\Api\AllSoapAndRest::itemAnyType just return the input data back as response - $this->assertEquals($expectedResponse, $result); - } - - public function testDataObjectCustomAttributes() - { - $customAttributeDataObject = $this->customAttributeDataObjectDataFactory->create() - ->setName('nameValue') - ->setCustomAttribute('custom_attribute_int', 1); - - $item = $this->itemDataFactory->create() - ->setItemId(1) - ->setName('testProductAnyType') - ->setCustomAttribute('custom_attribute_data_object', $customAttributeDataObject) - ->setCustomAttribute('custom_attribute_string', 'someStringValue'); - - $serviceInfo = [ - 'rest' => [ - 'resourcePath' => $this->_restResourcePath . 'itemAnyType', - 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_POST, - ], - 'soap' => ['service' => $this->_soapService, 'operation' => $this->_soapService . 'ItemAnyType'], - ]; - $requestData = $this->dataObjectProcessor->buildOutputDataArray( - $item, - '\Magento\TestModuleMSC\Api\Data\ItemInterface' - ); - $result = $this->_webApiCall($serviceInfo, ['entityItem' => $requestData]); - - $expectedResponse = $this->serviceOutputProcessor->process( - $item, - '\Magento\TestModuleMSC\Api\AllSoapAndRestInterface', - 'itemAnyType' - ); - //\Magento\TestModuleMSC\Api\AllSoapAndRest::itemAnyType just return the input data back as response - $this->assertEquals($expectedResponse, $result); - } - - public function testDataObjectCustomAttributesPreconfiguredItem() - { - $serviceInfo = [ - 'rest' => [ - 'resourcePath' => $this->_restResourcePath . 'itemPreconfigured', - 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_GET, - ], - 'soap' => ['service' => $this->_soapService, 'operation' => $this->_soapService . 'GetPreconfiguredItem'], - ]; - - $result = $this->_webApiCall($serviceInfo, []); - - $customAttributeDataObject = $this->customAttributeDataObjectDataFactory->create() - ->setName('nameValue') - ->setCustomAttribute('custom_attribute_int', 1); - - $item = $this->itemDataFactory->create() - ->setItemId(1) - ->setName('testProductAnyType') - ->setCustomAttribute('custom_attribute_data_object', $customAttributeDataObject) - ->setCustomAttribute('custom_attribute_string', 'someStringValue'); - - $expectedResponse = $this->serviceOutputProcessor->process( - $item, - '\Magento\TestModuleMSC\Api\AllSoapAndRestInterface', - 'getPreconfiguredItem' - ); - $this->assertEquals($expectedResponse, $result); - } - - public function testNestedDataObjectCustomAttributes() - { - $customAttributeNestedDataObject = $this->customAttributeNestedDataObjectDataFactory->create() - ->setName('nestedNameValue'); - - $customAttributeDataObject = $this->customAttributeDataObjectDataFactory->create() - ->setName('nameValue') - ->setCustomAttribute('custom_attribute_nested', $customAttributeNestedDataObject) - ->setCustomAttribute('custom_attribute_int', 1); - - $item = $this->itemDataFactory->create() - ->setItemId(1) - ->setName('testProductAnyType') - ->setCustomAttribute('custom_attribute_data_object', $customAttributeDataObject) - ->setCustomAttribute('custom_attribute_string', 'someStringValue'); - - $serviceInfo = [ - 'rest' => [ - 'resourcePath' => $this->_restResourcePath . 'itemAnyType', - 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_POST, - ], - 'soap' => ['service' => $this->_soapService, 'operation' => $this->_soapService . 'ItemAnyType'], - ]; - $requestData = $this->dataObjectProcessor->buildOutputDataArray( - $item, - '\Magento\TestModuleMSC\Api\Data\ItemInterface' - ); - $result = $this->_webApiCall($serviceInfo, ['entityItem' => $requestData]); - - $expectedResponse = $this->serviceOutputProcessor->process( - $item, - '\Magento\TestModuleMSC\Api\AllSoapAndRestInterface', - 'itemAnyType' - ); - //\Magento\TestModuleMSC\Api\AllSoapAndRest::itemAnyType just return the input data back as response - $this->assertEquals($expectedResponse, $result); - } -} diff --git a/dev/tests/api-functional/testsuite/Magento/Webapi/DataObjectSerialization/CustomAttributeSerializationTest.php b/dev/tests/api-functional/testsuite/Magento/Webapi/DataObjectSerialization/CustomAttributeSerializationTest.php deleted file mode 100644 index 0a1c4b7905d38c9517c452a587276c6c9581890a..0000000000000000000000000000000000000000 --- a/dev/tests/api-functional/testsuite/Magento/Webapi/DataObjectSerialization/CustomAttributeSerializationTest.php +++ /dev/null @@ -1,212 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -/** - * Class to test if custom attributes are serialized correctly - */ -namespace Magento\Webapi\DataObjectSerialization; - -use Magento\Framework\Webapi\ServiceOutputProcessor; -use Magento\TestFramework\Helper\Bootstrap; -use Magento\TestModule1\Service\V1\Entity\ItemFactory; - -class CustomAttributeSerializationTest extends \Magento\Webapi\Routing\BaseService -{ - /** - * @var string - */ - protected $_version; - /** - * @var string - */ - protected $_restResourcePath; - /** - * @var string - */ - protected $_soapService = 'testModule1AllSoapAndRest'; - - /** - * @var ItemFactory - */ - protected $itemFactory; - - /** - * @var \Magento\TestModule1\Service\V1\Entity\CustomAttributeNestedDataObjectFactory - */ - protected $customAttributeNestedDataObjectFactory; - - /** - * @var \Magento\TestModule1\Service\V1\Entity\CustomAttributeDataObjectFactory - */ - protected $customAttributeDataObjectFactory; - - /** - * @var ServiceOutputProcessor $serviceOutputProcessor - */ - protected $serviceOutputProcessor; - - /** - * Set up custom attribute related data objects - */ - protected function setUp() - { - $this->_version = 'V1'; - $this->_soapService = 'testModule1AllSoapAndRestV1'; - $this->_restResourcePath = "/{$this->_version}/testmodule1/"; - - $this->itemFactory = Bootstrap::getObjectManager()->create( - 'Magento\TestModule1\Service\V1\Entity\ItemFactory' - ); - - $this->customAttributeNestedDataObjectFactory = Bootstrap::getObjectManager()->create( - 'Magento\TestModule1\Service\V1\Entity\CustomAttributeNestedDataObjectFactory' - ); - - $this->customAttributeDataObjectFactory = Bootstrap::getObjectManager()->create( - 'Magento\TestModule1\Service\V1\Entity\CustomAttributeDataObjectFactory' - ); - - $this->serviceOutputProcessor = Bootstrap::getObjectManager()->create( - 'Magento\Framework\Webapi\ServiceOutputProcessor' - ); - } - - public function testSimpleAndNonExistentCustomAttributes() - { - $serviceInfo = [ - 'rest' => [ - 'resourcePath' => $this->_restResourcePath . 'itemAnyType', - 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_POST, - ], - 'soap' => ['service' => $this->_soapService, 'operation' => $this->_soapService . 'ItemAnyType'], - ]; - $requestData = [ - 'item_id' => 1, - 'name' => 'testProductAnyType', - 'custom_attributes' => [ - 'non_existent' => [ - 'attribute_code' => 'non_existent', - 'value' => 'test', - ], - 'custom_attribute_string' => [ - 'attribute_code' => 'custom_attribute_string', - 'value' => 'someStringValue', - ], - ], - ]; - $result = $this->_webApiCall($serviceInfo, ['entityItem' => $requestData]); - - //The non_existent custom attribute should be dropped since its not a defined custom attribute - $expectedResponse = [ - 'item_id' => 1, - 'name' => 'testProductAnyType', - 'custom_attributes' => [ - [ - 'attribute_code' => 'custom_attribute_string', - 'value' => 'someStringValue', - ], - ], - ]; - - //\Magento\TestModule1\Service\V1\AllSoapAndRest::itemAnyType just return the input data back as response - $this->assertEquals($expectedResponse, $result); - } - - public function testDataObjectCustomAttributes() - { - $customAttributeDataObject = $this->customAttributeDataObjectFactory->create() - ->setName('nameValue') - ->setCustomAttribute('custom_attribute_int', 1); - - $item = $this->itemFactory->create() - ->setItemId(1) - ->setName('testProductAnyType') - ->setCustomAttribute('custom_attribute_data_object', $customAttributeDataObject) - ->setCustomAttribute('custom_attribute_string', 'someStringValue'); - - $serviceInfo = [ - 'rest' => [ - 'resourcePath' => $this->_restResourcePath . 'itemAnyType', - 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_POST, - ], - 'soap' => ['service' => $this->_soapService, 'operation' => $this->_soapService . 'ItemAnyType'], - ]; - $requestData = $item->__toArray(); - $result = $this->_webApiCall($serviceInfo, ['entityItem' => $requestData]); - - $expectedResponse = $this->serviceOutputProcessor->process( - $item, - '\Magento\TestModule1\Service\V1\AllSoapAndRestInterface', - 'itemAnyType' - ); - //\Magento\TestModule1\Service\V1\AllSoapAndRest::itemAnyType just return the input data back as response - $this->assertEquals($expectedResponse, $result); - } - - public function testDataObjectCustomAttributesPreconfiguredItem() - { - $serviceInfo = [ - 'rest' => [ - 'resourcePath' => $this->_restResourcePath . 'itemPreconfigured', - 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_GET, - ], - 'soap' => ['service' => $this->_soapService, 'operation' => $this->_soapService . 'GetPreconfiguredItem'], - ]; - - $result = $this->_webApiCall($serviceInfo, []); - - $customAttributeDataObject = $this->customAttributeDataObjectFactory->create() - ->setName('nameValue') - ->setCustomAttribute('custom_attribute_int', 1); - - $item = $this->itemFactory->create() - ->setItemId(1) - ->setName('testProductAnyType') - ->setCustomAttribute('custom_attribute_data_object', $customAttributeDataObject) - ->setCustomAttribute('custom_attribute_string', 'someStringValue'); - $expectedResponse = $this->serviceOutputProcessor->process( - $item, - '\Magento\TestModule1\Service\V1\AllSoapAndRestInterface', - 'getPreconfiguredItem' - ); - $this->assertEquals($expectedResponse, $result); - } - - public function testNestedDataObjectCustomAttributes() - { - $customAttributeNestedDataObject = $this->customAttributeNestedDataObjectFactory->create() - ->setName('nestedNameValue'); - - $customAttributeDataObject = $this->customAttributeDataObjectFactory->create() - ->setName('nameValue') - ->setCustomAttribute('custom_attribute_nested', $customAttributeNestedDataObject) - ->setCustomAttribute('custom_attribute_int', 1); - - $item = $this->itemFactory->create() - ->setItemId(1) - ->setName('testProductAnyType') - ->setCustomAttribute('custom_attribute_data_object', $customAttributeDataObject) - ->setCustomAttribute('custom_attribute_string', 'someStringValue'); - - $serviceInfo = [ - 'rest' => [ - 'resourcePath' => $this->_restResourcePath . 'itemAnyType', - 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_POST, - ], - 'soap' => ['service' => $this->_soapService, 'operation' => $this->_soapService . 'ItemAnyType'], - ]; - $requestData = $item->__toArray(); - $result = $this->_webApiCall($serviceInfo, ['entityItem' => $requestData]); - - $expectedResponse = $this->serviceOutputProcessor->process( - $item, - '\Magento\TestModule1\Service\V1\AllSoapAndRestInterface', - 'itemAnyType' - ); - //\Magento\TestModule1\Service\V1\AllSoapAndRest::itemAnyType just return the input data back as response - $this->assertEquals($expectedResponse, $result); - } -} diff --git a/dev/tests/api-functional/testsuite/Magento/Webapi/Routing/RestErrorHandlingTest.php b/dev/tests/api-functional/testsuite/Magento/Webapi/Routing/RestErrorHandlingTest.php index 08ed84696127726a99fe2cc2b9a8d5da2eaaf425..41d6e8a2914deb9a863b42d2634d0c9aab934324 100644 --- a/dev/tests/api-functional/testsuite/Magento/Webapi/Routing/RestErrorHandlingTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Webapi/Routing/RestErrorHandlingTest.php @@ -52,9 +52,9 @@ class RestErrorHandlingTest extends \Magento\TestFramework\TestCase\WebapiAbstra // \Magento\Framework\Api\ResourceNotFoundException $this->_errorTest( $serviceInfo, - ['resource_id' => 'resourceY'], + ['resourceY'], WebapiException::HTTP_NOT_FOUND, - 'Resource with ID "%resource_id" not found.' + 'Resource with ID "%1" not found.' ); } @@ -72,8 +72,8 @@ class RestErrorHandlingTest extends \Magento\TestFramework\TestCase\WebapiAbstra $serviceInfo, [], WebapiException::HTTP_UNAUTHORIZED, - 'Consumer is not authorized to access %resources', - ['resources' => 'resourceN'] + 'Consumer is not authorized to access %1', + ['resourceN'] ); } diff --git a/dev/tests/api-functional/testsuite/Magento/Webapi/Routing/SoapErrorHandlingTest.php b/dev/tests/api-functional/testsuite/Magento/Webapi/Routing/SoapErrorHandlingTest.php index 648173c6e6b5c50feed6267a030e7f5e014b6c3c..a7dadda3c5b6e67ba77cd94a0ebcdd339a4ec692 100644 --- a/dev/tests/api-functional/testsuite/Magento/Webapi/Routing/SoapErrorHandlingTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Webapi/Routing/SoapErrorHandlingTest.php @@ -105,8 +105,10 @@ class SoapErrorHandlingTest extends \Magento\TestFramework\TestCase\WebapiAbstra ]; $expectedException = new AuthorizationException( - AuthorizationException::NOT_AUTHORIZED, - ['resources' => 'Magento_TestModule3::resource1, Magento_TestModule3::resource2'] + __( + AuthorizationException::NOT_AUTHORIZED, + ['resources' => 'Magento_TestModule3::resource1, Magento_TestModule3::resource2'] + ) ); try { @@ -133,7 +135,9 @@ class SoapErrorHandlingTest extends \Magento\TestFramework\TestCase\WebapiAbstra $expectedException = new \Magento\Framework\Exception\InputException(); foreach ($parameters as $error) { - $expectedException->addError(\Magento\Framework\Exception\InputException::INVALID_FIELD_VALUE, $error); + $expectedException->addError( + __(\Magento\Framework\Exception\InputException::INVALID_FIELD_VALUE, $error) + ); } $arguments = [ diff --git a/dev/tests/api-functional/testsuite/Magento/Webapi/WsdlGenerationFromDataObjectTest.php b/dev/tests/api-functional/testsuite/Magento/Webapi/WsdlGenerationFromDataObjectTest.php index aedba2b6b94486a63a736b240d3f5036a1a1c839..c093b3dcf0ad2e9de6510e1f165a9fbec30ceddb 100644 --- a/dev/tests/api-functional/testsuite/Magento/Webapi/WsdlGenerationFromDataObjectTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Webapi/WsdlGenerationFromDataObjectTest.php @@ -24,19 +24,38 @@ class WsdlGenerationFromDataObjectTest extends \Magento\TestFramework\TestCase\W /** @var string */ protected $_soapUrl; + /** @var bool */ + protected $isSingleService; + protected function setUp() { $this->_markTestAsSoapOnly("WSDL generation tests are intended to be executed for SOAP adapter only."); $this->_storeCode = Bootstrap::getObjectManager()->get('Magento\Store\Model\StoreManagerInterface') ->getStore()->getCode(); - $this->_soapUrl = "{$this->_baseUrl}/soap/{$this->_storeCode}?services=testModule5AllSoapAndRestV1%2CtestModule5AllSoapAndRestV2"; parent::setUp(); } public function testMultiServiceWsdl() { + $this->_soapUrl = "{$this->_baseUrl}/soap/{$this->_storeCode}?services=testModule5AllSoapAndRestV1%2CtestModule5AllSoapAndRestV2"; $wsdlUrl = $this->_getBaseWsdlUrl() . 'testModule5AllSoapAndRestV1,testModule5AllSoapAndRestV2'; $wsdlContent = $this->_convertXmlToString($this->_getWsdlContent($wsdlUrl)); + $this->isSingleService = false; + + $this->_checkTypesDeclaration($wsdlContent); + $this->_checkPortTypeDeclaration($wsdlContent); + $this->_checkBindingDeclaration($wsdlContent); + $this->_checkServiceDeclaration($wsdlContent); + $this->_checkMessagesDeclaration($wsdlContent); + $this->_checkFaultsDeclaration($wsdlContent); + } + + public function testSingleServiceWsdl() + { + $this->_soapUrl = "{$this->_baseUrl}/soap/{$this->_storeCode}?services=testModule5AllSoapAndRestV2"; + $wsdlUrl = $this->_getBaseWsdlUrl() . 'testModule5AllSoapAndRestV2'; + $wsdlContent = $this->_convertXmlToString($this->_getWsdlContent($wsdlUrl)); + $this->isSingleService = true; $this->_checkTypesDeclaration($wsdlContent); $this->_checkPortTypeDeclaration($wsdlContent); @@ -129,17 +148,30 @@ TYPES_SECTION_DECLARATION; */ protected function _checkElementsDeclaration($wsdlContent) { - $requestElement = <<< REQUEST_ELEMENT + if ($this->isSingleService) { + $requestElement = <<< REQUEST_ELEMENT +<xsd:element name="testModule5AllSoapAndRestV2ItemRequest" type="tns:TestModule5AllSoapAndRestV2ItemRequest"/> +REQUEST_ELEMENT; + } else { + $requestElement = <<< REQUEST_ELEMENT <xsd:element name="testModule5AllSoapAndRestV1ItemRequest" type="tns:TestModule5AllSoapAndRestV1ItemRequest"/> REQUEST_ELEMENT; + } $this->assertContains( $this->_convertXmlToString($requestElement), $wsdlContent, 'Request element declaration in types section is invalid' ); - $responseElement = <<< RESPONSE_ELEMENT + + if ($this->isSingleService) { + $responseElement = <<< RESPONSE_ELEMENT +<xsd:element name="testModule5AllSoapAndRestV2ItemResponse" type="tns:TestModule5AllSoapAndRestV2ItemResponse"/> +RESPONSE_ELEMENT; + } else { + $responseElement = <<< RESPONSE_ELEMENT <xsd:element name="testModule5AllSoapAndRestV1ItemResponse" type="tns:TestModule5AllSoapAndRestV1ItemResponse"/> RESPONSE_ELEMENT; + } $this->assertContains( $this->_convertXmlToString($responseElement), $wsdlContent, @@ -149,11 +181,37 @@ RESPONSE_ELEMENT; /** * @param string $wsdlContent + * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ protected function _checkComplexTypesDeclaration($wsdlContent) { // @codingStandardsIgnoreStart - $requestType = <<< REQUEST_TYPE + if ($this->isSingleService) { + $requestType = <<< REQUEST_TYPE +<xsd:complexType name="TestModule5AllSoapAndRestV2ItemRequest"> + <xsd:annotation> + <xsd:documentation>Retrieve existing item.</xsd:documentation> + <xsd:appinfo xmlns:inf="{$this->_soapUrl}"/> + </xsd:annotation> + <xsd:sequence> + <xsd:element name="id" minOccurs="1" maxOccurs="1" type="xsd:int"> + <xsd:annotation> + <xsd:documentation></xsd:documentation> + <xsd:appinfo xmlns:inf="{$this->_soapUrl}"> + <inf:min/> + <inf:max/> + <inf:callInfo> + <inf:callName>testModule5AllSoapAndRestV2Item</inf:callName> + <inf:requiredInput>Yes</inf:requiredInput> + </inf:callInfo> + </xsd:appinfo> + </xsd:annotation> + </xsd:element> + </xsd:sequence> +</xsd:complexType> +REQUEST_TYPE; + } else { + $requestType = <<< REQUEST_TYPE <xsd:complexType name="TestModule5AllSoapAndRestV1ItemRequest"> <xsd:annotation> <xsd:documentation>Retrieve an item.</xsd:documentation> @@ -176,14 +234,41 @@ RESPONSE_ELEMENT; </xsd:sequence> </xsd:complexType> REQUEST_TYPE; + } // @codingStandardsIgnoreEnd $this->assertContains( $this->_convertXmlToString($requestType), $wsdlContent, 'Request type declaration in types section is invalid' ); + // @codingStandardsIgnoreStart - $responseType = <<< RESPONSE_TYPE + if ($this->isSingleService) { + $responseType = <<< RESPONSE_TYPE +<xsd:complexType name="TestModule5AllSoapAndRestV2ItemResponse"> + <xsd:annotation> + <xsd:documentation> + Response container for the testModule5AllSoapAndRestV2Item call. + </xsd:documentation> + <xsd:appinfo xmlns:inf="{$this->_soapUrl}"/> + </xsd:annotation> + <xsd:sequence> + <xsd:element name="result" minOccurs="1" maxOccurs="1" type="tns:TestModule5V2EntityAllSoapAndRest"> + <xsd:annotation> + <xsd:documentation></xsd:documentation> + <xsd:appinfo xmlns:inf="{$this->_soapUrl}"> + <inf:callInfo> + <inf:callName>testModule5AllSoapAndRestV2Item</inf:callName> + <inf:returned>Always</inf:returned> + </inf:callInfo> + </xsd:appinfo> + </xsd:annotation> + </xsd:element> + </xsd:sequence> +</xsd:complexType> +RESPONSE_TYPE; + } else { + $responseType = <<< RESPONSE_TYPE <xsd:complexType name="TestModule5AllSoapAndRestV1ItemResponse"> <xsd:annotation> <xsd:documentation> @@ -206,6 +291,7 @@ REQUEST_TYPE; </xsd:sequence> </xsd:complexType> RESPONSE_TYPE; + } // @codingStandardsIgnoreEnd $this->assertContains( $this->_convertXmlToString($responseType), @@ -224,7 +310,40 @@ RESPONSE_TYPE; protected function _checkReferencedTypeDeclaration($wsdlContent) { // @codingStandardsIgnoreStart - $referencedType = <<< RESPONSE_TYPE + if ($this->isSingleService) { + $referencedType = <<< RESPONSE_TYPE +<xsd:complexType name="TestModule5V2EntityAllSoapAndRest"> + <xsd:annotation> + <xsd:documentation></xsd:documentation> + <xsd:appinfo xmlns:inf="{$this->_soapUrl}"/> + </xsd:annotation> + <xsd:sequence> + <xsd:element name="price" minOccurs="1" maxOccurs="1" type="xsd:int"> + <xsd:annotation> + <xsd:documentation></xsd:documentation> + <xsd:appinfo xmlns:inf="{$this->_soapUrl}"> + <inf:min/> + <inf:max/> + <inf:callInfo> + <inf:callName>testModule5AllSoapAndRestV2Item</inf:callName> + <inf:callName>testModule5AllSoapAndRestV2Create</inf:callName> + <inf:callName>testModule5AllSoapAndRestV2Update</inf:callName> + <inf:callName>testModule5AllSoapAndRestV2Delete</inf:callName> + <inf:returned>Always</inf:returned> + </inf:callInfo> + <inf:callInfo> + <inf:callName>testModule5AllSoapAndRestV2Create</inf:callName> + <inf:callName>testModule5AllSoapAndRestV2Update</inf:callName> + <inf:requiredInput>Yes</inf:requiredInput> + </inf:callInfo> + </xsd:appinfo> + </xsd:annotation> + </xsd:element> + </xsd:sequence> +</xsd:complexType> +RESPONSE_TYPE; + } else { + $referencedType = <<< RESPONSE_TYPE <xsd:complexType name="TestModule5V1EntityAllSoapAndRest"> <xsd:annotation> <xsd:documentation>Some Data Object short description. Data Object long multi line description.</xsd:documentation> @@ -340,6 +459,7 @@ RESPONSE_TYPE; </xsd:sequence> </xsd:complexType> RESPONSE_TYPE; + } // @codingStandardsIgnoreEnd $this->assertContains( $this->_convertXmlToString($referencedType), @@ -355,15 +475,23 @@ RESPONSE_TYPE; */ protected function _checkPortTypeDeclaration($wsdlContent) { - $firstPortType = <<< FIRST_PORT_TYPE + if ($this->isSingleService) { + $firstPortType = <<< FIRST_PORT_TYPE +<portType name="testModule5AllSoapAndRestV2PortType"> +FIRST_PORT_TYPE; + } else { + $firstPortType = <<< FIRST_PORT_TYPE <portType name="testModule5AllSoapAndRestV1PortType"> FIRST_PORT_TYPE; + } $this->assertContains( $this->_convertXmlToString($firstPortType), $wsdlContent, 'Port type declaration is missing or invalid' ); - $secondPortType = <<< SECOND_PORT_TYPE + + if (!$this->isSingleService) { + $secondPortType = <<< SECOND_PORT_TYPE <portType name="testModule5AllSoapAndRestV2PortType"> SECOND_PORT_TYPE; $this->assertContains( @@ -371,7 +499,10 @@ SECOND_PORT_TYPE; $wsdlContent, 'Port type declaration is missing or invalid' ); - $operationDeclaration = <<< OPERATION_DECLARATION + } + + if ($this->isSingleService) { + $operationDeclaration = <<< OPERATION_DECLARATION <operation name="testModule5AllSoapAndRestV2Item"> <input message="tns:testModule5AllSoapAndRestV2ItemRequest"/> <output message="tns:testModule5AllSoapAndRestV2ItemResponse"/> @@ -383,6 +514,20 @@ SECOND_PORT_TYPE; <fault name="GenericFault" message="tns:GenericFault"/> </operation> OPERATION_DECLARATION; + } else { + $operationDeclaration = <<< OPERATION_DECLARATION +<operation name="testModule5AllSoapAndRestV2Item"> + <input message="tns:testModule5AllSoapAndRestV2ItemRequest"/> + <output message="tns:testModule5AllSoapAndRestV2ItemResponse"/> + <fault name="GenericFault" message="tns:GenericFault"/> +</operation> +<operation name="testModule5AllSoapAndRestV2Items"> + <input message="tns:testModule5AllSoapAndRestV2ItemsRequest"/> + <output message="tns:testModule5AllSoapAndRestV2ItemsResponse"/> + <fault name="GenericFault" message="tns:GenericFault"/> +</operation> +OPERATION_DECLARATION; + } $this->assertContains( $this->_convertXmlToString($operationDeclaration), $wsdlContent, @@ -397,25 +542,60 @@ OPERATION_DECLARATION; */ protected function _checkBindingDeclaration($wsdlContent) { - $firstBinding = <<< FIRST_BINDING + if ($this->isSingleService) { + $firstBinding = <<< FIRST_BINDING +<binding name="testModule5AllSoapAndRestV2Binding" type="tns:testModule5AllSoapAndRestV2PortType"> + <soap12:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> +FIRST_BINDING; + } else { + $firstBinding = <<< FIRST_BINDING <binding name="testModule5AllSoapAndRestV1Binding" type="tns:testModule5AllSoapAndRestV1PortType"> <soap12:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> FIRST_BINDING; + } $this->assertContains( $this->_convertXmlToString($firstBinding), $wsdlContent, 'Binding declaration is missing or invalid' ); - $secondBinding = <<< SECOND_BINDING + + if (!$this->isSingleService) { + $secondBinding = <<< SECOND_BINDING <binding name="testModule5AllSoapAndRestV2Binding" type="tns:testModule5AllSoapAndRestV2PortType"> <soap12:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> SECOND_BINDING; - $this->assertContains( - $this->_convertXmlToString($secondBinding), - $wsdlContent, - 'Binding declaration is missing or invalid' - ); - $operationDeclaration = <<< OPERATION_DECLARATION + $this->assertContains( + $this->_convertXmlToString($secondBinding), + $wsdlContent, + 'Binding declaration is missing or invalid' + ); + } + + if ($this->isSingleService) { + $operationDeclaration = <<< OPERATION_DECLARATION +<operation name="testModule5AllSoapAndRestV2Item"> + <soap12:operation soapAction="testModule5AllSoapAndRestV2Item"/> + <input> + <soap12:body use="literal"/> + </input> + <output> + <soap12:body use="literal"/> + </output> + <fault name="GenericFault"/> +</operation> +<operation name="testModule5AllSoapAndRestV2Items"> + <soap12:operation soapAction="testModule5AllSoapAndRestV2Items"/> + <input> + <soap12:body use="literal"/> + </input> + <output> + <soap12:body use="literal"/> + </output> + <fault name="GenericFault"/> +</operation> +OPERATION_DECLARATION; + } else { + $operationDeclaration = <<< OPERATION_DECLARATION <operation name="testModule5AllSoapAndRestV1Item"> <soap12:operation soapAction="testModule5AllSoapAndRestV1Item"/> <input> @@ -437,6 +617,7 @@ SECOND_BINDING; <fault name="GenericFault"/> </operation> OPERATION_DECLARATION; + } $this->assertContains( $this->_convertXmlToString($operationDeclaration), $wsdlContent, @@ -452,13 +633,23 @@ OPERATION_DECLARATION; protected function _checkServiceDeclaration($wsdlContent) { // @codingStandardsIgnoreStart - $firstServiceDeclaration = <<< FIRST_SERVICE_DECLARATION + if ($this->isSingleService) { + $firstServiceDeclaration = <<< FIRST_SERVICE_DECLARATION +<service name="testModule5AllSoapAndRestV2Service"> + <port name="testModule5AllSoapAndRestV2Port" binding="tns:testModule5AllSoapAndRestV2Binding"> + <soap12:address location="{$this->_baseUrl}/soap/{$this->_storeCode}?services=testModule5AllSoapAndRestV2"/> + </port> +</service> +FIRST_SERVICE_DECLARATION; + } else { + $firstServiceDeclaration = <<< FIRST_SERVICE_DECLARATION <service name="testModule5AllSoapAndRestV1Service"> <port name="testModule5AllSoapAndRestV1Port" binding="tns:testModule5AllSoapAndRestV1Binding"> <soap12:address location="{$this->_baseUrl}/soap/{$this->_storeCode}?services=testModule5AllSoapAndRestV1%2CtestModule5AllSoapAndRestV2"/> </port> </service> FIRST_SERVICE_DECLARATION; + } // @codingStandardsIgnoreEnd $this->assertContains( $this->_convertXmlToString($firstServiceDeclaration), @@ -467,19 +658,21 @@ FIRST_SERVICE_DECLARATION; ); // @codingStandardsIgnoreStart - $secondServiceDeclaration = <<< SECOND_SERVICE_DECLARATION + if (!$this->isSingleService) { + $secondServiceDeclaration = <<< SECOND_SERVICE_DECLARATION <service name="testModule5AllSoapAndRestV2Service"> <port name="testModule5AllSoapAndRestV2Port" binding="tns:testModule5AllSoapAndRestV2Binding"> <soap12:address location="{$this->_baseUrl}/soap/{$this->_storeCode}?services=testModule5AllSoapAndRestV1%2CtestModule5AllSoapAndRestV2"/> </port> </service> SECOND_SERVICE_DECLARATION; - // @codingStandardsIgnoreEnd - $this->assertContains( - $this->_convertXmlToString($secondServiceDeclaration), - $wsdlContent, - 'Second service section is invalid' - ); + // @codingStandardsIgnoreEnd + $this->assertContains( + $this->_convertXmlToString($secondServiceDeclaration), + $wsdlContent, + 'Second service section is invalid' + ); + } } /** @@ -654,7 +847,31 @@ PARAM_COMPLEX_TYPE; 'Details parameter complex types declaration is invalid.' ); - $detailsWrappedErrorType = <<< WRAPPED_ERROR_COMPLEX_TYPE + if ($this->isSingleService) { + $detailsWrappedErrorType = <<< WRAPPED_ERROR_COMPLEX_TYPE +<xsd:complexType name="WrappedError"> + <xsd:sequence> + <xsd:element name="message" minOccurs="1" maxOccurs="1" type="xsd:string"> + <xsd:annotation> + <xsd:documentation></xsd:documentation> + <xsd:appinfo xmlns:inf="{$this->_baseUrl}/soap/{$this->_storeCode}?services=testModule5AllSoapAndRestV2"> + <inf:maxLength/> + </xsd:appinfo> + </xsd:annotation> + </xsd:element> + <xsd:element name="parameters" type="tns:ArrayOfGenericFaultParameter" minOccurs="0"> + <xsd:annotation> + <xsd:documentation>Message parameters.</xsd:documentation> + <xsd:appinfo xmlns:inf="{$this->_baseUrl}/soap/{$this->_storeCode}?services=testModule5AllSoapAndRestV2"> + <inf:natureOfType>array</inf:natureOfType> + </xsd:appinfo> + </xsd:annotation> + </xsd:element> + </xsd:sequence> +</xsd:complexType> +WRAPPED_ERROR_COMPLEX_TYPE; + } else { + $detailsWrappedErrorType = <<< WRAPPED_ERROR_COMPLEX_TYPE <xsd:complexType name="WrappedError"> <xsd:sequence> <xsd:element name="message" minOccurs="1" maxOccurs="1" type="xsd:string"> @@ -676,6 +893,7 @@ PARAM_COMPLEX_TYPE; </xsd:sequence> </xsd:complexType> WRAPPED_ERROR_COMPLEX_TYPE; + } $this->assertContains( $this->_convertXmlToString($detailsWrappedErrorType), $wsdlContent, @@ -705,7 +923,25 @@ PARAMETERS_COMPLEX_TYPE; 'Details parameters (array of parameters) complex types declaration is invalid.' ); - $detailsWrappedErrorsType = <<< WRAPPED_ERRORS_COMPLEX_TYPE + if ($this->isSingleService) { + $detailsWrappedErrorsType = <<< WRAPPED_ERRORS_COMPLEX_TYPE +<xsd:complexType name="ArrayOfWrappedError"> + <xsd:annotation> + <xsd:documentation>An array of WrappedError items.</xsd:documentation> + <xsd:appinfo xmlns:inf="{$this->_baseUrl}/soap/{$this->_storeCode}?services=testModule5AllSoapAndRestV2"/> + </xsd:annotation> + <xsd:sequence> + <xsd:element name="item" minOccurs="0" maxOccurs="unbounded" type="tns:WrappedError"> + <xsd:annotation> + <xsd:documentation>An item of ArrayOfWrappedError.</xsd:documentation> + <xsd:appinfo xmlns:inf="{$this->_baseUrl}/soap/{$this->_storeCode}?services=testModule5AllSoapAndRestV2"/> + </xsd:annotation> + </xsd:element> + </xsd:sequence> +</xsd:complexType> +WRAPPED_ERRORS_COMPLEX_TYPE; + } else { + $detailsWrappedErrorsType = <<< WRAPPED_ERRORS_COMPLEX_TYPE <xsd:complexType name="ArrayOfWrappedError"> <xsd:annotation> <xsd:documentation>An array of WrappedError items.</xsd:documentation> @@ -721,6 +957,8 @@ PARAMETERS_COMPLEX_TYPE; </xsd:sequence> </xsd:complexType> WRAPPED_ERRORS_COMPLEX_TYPE; + + } // @codingStandardsIgnoreEnd $this->assertContains( $this->_convertXmlToString($detailsWrappedErrorsType), diff --git a/dev/tests/functional/phpunit.xml.dist b/dev/tests/functional/phpunit.xml.dist index 255d3cf4057d4fdae9965848d64225317e2ba0fc..06b2ee9b0603d8fd6e602011e34ddbf2b131c00f 100755 --- a/dev/tests/functional/phpunit.xml.dist +++ b/dev/tests/functional/phpunit.xml.dist @@ -36,7 +36,7 @@ <env name="testsuite_rule_path" value="Magento/Mtf/TestSuite/InjectableTests" /> <env name="log_directory" value="var/log" /> <env name="events_preset" value="base" /> - <env name="module_whitelist" value="Magento_Install" /> + <env name="module_whitelist" value="Magento_Install,Magento_Core" /> <env name="report_file_name" value="test-cases-report.xml"/> <env name="basedir" value="var/log" /> <env name="credentials_file_path" value="./credentials.xml.dist" /> diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Cart.php b/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Cart.php index dcd021475a053f48137961d472a5dd119be6fa3b..5d12b4575d9adc26f53cb67398eb84941db42375 100644 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Cart.php +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Cart.php @@ -57,6 +57,13 @@ class Cart extends Block */ protected $cartEmpty = '.cart-empty'; + /** + * Cart container selector + * + * @var string + */ + protected $cartContainer = '.cart-container'; + /** * Get cart item block * @@ -170,4 +177,12 @@ class Cart extends Block { return $this->_rootElement->find($this->cartEmpty, Locator::SELECTOR_CSS)->isVisible(); } + + /** + * Wait while cart container is loaded + */ + public function waitCartContainerLoading() + { + $this->waitForElementVisible($this->cartContainer); + } } diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/TestStep/EstimateShippingAndTaxStep.php b/dev/tests/functional/tests/app/Magento/Checkout/Test/TestStep/EstimateShippingAndTaxStep.php index 9813b554032d126da7ec78f111d92c6c6fca7918..d49dd6cec919433d45319097da2f5884fa1c5ec3 100644 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/TestStep/EstimateShippingAndTaxStep.php +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/TestStep/EstimateShippingAndTaxStep.php @@ -106,6 +106,7 @@ class EstimateShippingAndTaxStep implements TestStepInterface public function run() { $this->checkoutCart->open(); + $this->checkoutCart->getCartBlock()->waitCartContainerLoading(); /** @var \Magento\Checkout\Test\Fixture\Cart $cart */ if ($this->cart !== null) { $cart = $this->fixtureFactory->createByCode( @@ -113,6 +114,7 @@ class EstimateShippingAndTaxStep implements TestStepInterface ['data' => array_merge($this->cart->getData(), ['items' => ['products' => $this->products]])] ); $this->checkoutCart->getShippingBlock()->fillEstimateShippingAndTax($this->address); + $this->checkoutCart->getCartBlock()->waitCartContainerLoading(); if (!empty($this->shipping)) { $this->checkoutCart->getShippingBlock()->selectShippingMethod($this->shipping); } diff --git a/dev/tests/functional/tests/app/Magento/Core/Test/Fixture/ConfigData.xml b/dev/tests/functional/tests/app/Magento/Core/Test/Fixture/ConfigData.xml index a2b7c380a102f302f5d93688fcb98662b03a345e..8bed37c9f9ba9a008e35327b901217acf596e00a 100644 --- a/dev/tests/functional/tests/app/Magento/Core/Test/Fixture/ConfigData.xml +++ b/dev/tests/functional/tests/app/Magento/Core/Test/Fixture/ConfigData.xml @@ -10,7 +10,7 @@ module="Magento_Core" type="flat" entity_type="core_config_data" - collection="Magento\Core\Model\Resource\Config\Data\Collection" + collection="Magento\Config\Model\Resource\Config\Data\Collection" repository_class="Magento\Core\Test\Repository\ConfigData" handler_interface="Magento\Core\Test\Handler\ConfigData\ConfigDataInterface" class="Magento\Core\Test\Fixture\ConfigData"> diff --git a/dev/tests/functional/tests/app/Magento/Core/Test/Fixture/SystemVariable.xml b/dev/tests/functional/tests/app/Magento/Core/Test/Fixture/SystemVariable.xml index c313b15a2c676409f660a274ce83234824579979..01f5710dc7a3d13d105d0dfbfadf6c06406d55f2 100644 --- a/dev/tests/functional/tests/app/Magento/Core/Test/Fixture/SystemVariable.xml +++ b/dev/tests/functional/tests/app/Magento/Core/Test/Fixture/SystemVariable.xml @@ -9,7 +9,7 @@ <fixture name="systemVariable" module="Magento_Core" type="composite" - collection="Magento\Core\Model\Resource\Variable\Collection" + collection="Magento\Variable\Model\Resource\Variable\Collection" handler_interface="Magento\Core\Test\Handler\SystemVariable\SystemVariableInterface" class="Magento\Core\Test\Fixture\SystemVariable"> <dataset name="default"> diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerDefaultAddresses.php b/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerDefaultAddresses.php index 1bffd3078e356fb693004493a4ba3dabe5f210ef..bff724ba12559379b2bf9dc7e35b3d95a0d8714a 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerDefaultAddresses.php +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerDefaultAddresses.php @@ -25,6 +25,7 @@ class AssertCustomerDefaultAddresses extends AbstractConstraint public function processAssert(CustomerAccountIndex $customerAccountIndex, Address $address) { $customerAccountIndex->getAccountMenuBlock()->openMenuItem('Account Dashboard'); + sleep(6); $defaultBillingAddress = explode( "\n", $customerAccountIndex->getDashboardAddress()->getDefaultBillingAddressText() diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Handler/Customer/Curl.php b/dev/tests/functional/tests/app/Magento/Customer/Test/Handler/Customer/Curl.php index b42c48cbb8013423b8dd0e502972d240387331b5..1831cdcbd2168ecca66ec836b256511705db838a 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Handler/Customer/Curl.php +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Handler/Customer/Curl.php @@ -93,7 +93,8 @@ class Curl extends AbstractCurl implements CustomerInterface $curl->write(CurlInterface::POST, $url, '1.0', [], $data); $response = $curl->read(); $curl->close(); - if (!strpos($response, 'data-ui-id="global-messages-message-success"')) { + // After caching My Account page we cannot check by success message + if (!strpos($response, 'customer/account/logout')) { throw new \Exception("Customer entity creating by curl handler was not successful! Response: $response"); } diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/UpdateCustomerFrontendEntityTest.php b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/UpdateCustomerFrontendEntityTest.php index 5fdcc4b7c39932cc2f0ab925a8f79d8f8b6d40fe..036c03c76f7e381b633155db19993757a37ceadd 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/UpdateCustomerFrontendEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/UpdateCustomerFrontendEntityTest.php @@ -134,6 +134,7 @@ class UpdateCustomerFrontendEntityTest extends Injectable // Steps $this->cmsIndex->open(); $this->cmsIndex->getLinksBlock()->openLink('Log In'); + sleep(3); $this->customerAccountLogin->getLoginBlock()->fill($initialCustomer); $this->customerAccountLogin->getLoginBlock()->submit(); diff --git a/dev/tests/integration/etc/install-config-mysql.php.dist b/dev/tests/integration/etc/install-config-mysql.php.dist index 391e1a7679b00c152b165b379be8bd5d9ea508bb..0f5adb4727c5fecff8c195f6c70d25fb7b0cee0a 100644 --- a/dev/tests/integration/etc/install-config-mysql.php.dist +++ b/dev/tests/integration/etc/install-config-mysql.php.dist @@ -7,7 +7,7 @@ return [ 'db_host' => 'localhost', 'db_user' => 'root', - 'db_pass' => '', + 'db_pass' => 'root', 'db_name' => 'magento_integration_tests', 'db_prefix' => '', 'backend_frontname' => 'backend', diff --git a/dev/tests/integration/framework/Magento/TestFramework/Entity.php b/dev/tests/integration/framework/Magento/TestFramework/Entity.php index ea6ecef137d5e621039966b1b279eeb6c7fdf497..dc9793f6a05c61e6070f815f06abc31734ca66da 100644 --- a/dev/tests/integration/framework/Magento/TestFramework/Entity.php +++ b/dev/tests/integration/framework/Magento/TestFramework/Entity.php @@ -7,7 +7,7 @@ namespace Magento\TestFramework; /** - * Class that implements CRUD tests for \Magento\Core\Model\AbstractModel based objects + * Class that implements CRUD tests for \Magento\Framework\Model\AbstractModel based objects */ class Entity { diff --git a/dev/tests/integration/framework/Magento/TestFramework/Event/Magento.php b/dev/tests/integration/framework/Magento/TestFramework/Event/Magento.php index 9c1e8f43d68f94dd150f7861383a864c5f97772a..08812d8caf3b5f758a1f447e02dbf602d8a339ad 100644 --- a/dev/tests/integration/framework/Magento/TestFramework/Event/Magento.php +++ b/dev/tests/integration/framework/Magento/TestFramework/Event/Magento.php @@ -4,11 +4,11 @@ * See COPYING.txt for license details. */ -/** - * Observer of Magento events triggered using Magento_Core_Model_\Magento\TestFramework\EventManager::dispatch() - */ namespace Magento\TestFramework\Event; +/** + * Observer of Magento events triggered using \Magento\TestFramework\EventManager::dispatch() + */ class Magento { /** diff --git a/dev/tests/integration/framework/bootstrap.php b/dev/tests/integration/framework/bootstrap.php index c28fdc6d7a0d92fdb9aa5c64b37cbcc3eaa8e13c..41453aa0becc0e2d32513736f2cb99ddc60e8854 100644 --- a/dev/tests/integration/framework/bootstrap.php +++ b/dev/tests/integration/framework/bootstrap.php @@ -32,7 +32,7 @@ try { $installConfigFile = $installConfigFile . '.dist'; } $sandboxUniqueId = md5(sha1_file($installConfigFile)); - $installDir = "{$testsTmpDir}/sandbox-{$sandboxUniqueId}"; + $installDir = "{$testsTmpDir}/sandbox-{$settings->get('TESTS_PARALLEL_THREAD', 0)}-{$sandboxUniqueId}"; $application = new \Magento\TestFramework\Application( $shell, $installDir, diff --git a/dev/tests/integration/testsuite/Magento/Backend/Controller/Adminhtml/Cache/MassActionTest.php b/dev/tests/integration/testsuite/Magento/Backend/Controller/Adminhtml/Cache/MassActionTest.php index 65ec766a6c8366ae3ece6783d7b662e458fa011d..559381cbe85dfad46f6e7666d81f66f0b0ea47d8 100644 --- a/dev/tests/integration/testsuite/Magento/Backend/Controller/Adminhtml/Cache/MassActionTest.php +++ b/dev/tests/integration/testsuite/Magento/Backend/Controller/Adminhtml/Cache/MassActionTest.php @@ -6,8 +6,8 @@ namespace Magento\Backend\Controller\Adminhtml\Cache; -use Magento\TestFramework\Helper\Bootstrap; use Magento\Framework\App\Cache\Type\ConfigSegment; +use Magento\TestFramework\Helper\Bootstrap; class MassActionTest extends \Magento\Backend\Utility\Controller { @@ -32,8 +32,8 @@ class MassActionTest extends \Magento\Backend\Utility\Controller $cacheState = Bootstrap::getObjectManager()->get('Magento\Framework\App\Cache\StateInterface'); foreach (self::$typesSegment->getData() as $type => $value) { $cacheState->setEnabled($type, $value); - $cacheState->persist(); } + $cacheState->persist(); parent::tearDown(); } @@ -48,18 +48,11 @@ class MassActionTest extends \Magento\Backend\Utility\Controller $this->getRequest()->setParams(['types' => $typesToEnable]); $this->dispatch('backend/admin/cache/massEnable'); - Bootstrap::getInstance()->reinitialize(); - - /** @var \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList */ - $cacheTypeList = Bootstrap::getObjectManager()->get('Magento\Framework\App\Cache\TypeListInterface'); - $types = array_keys($cacheTypeList->getTypes()); - /** @var $cacheState \Magento\Framework\App\Cache\StateInterface */ - $cacheState = Bootstrap::getObjectManager()->get('Magento\Framework\App\Cache\StateInterface'); - foreach ($types as $type) { - if (in_array($type, $typesToEnable)) { - $this->assertTrue($cacheState->isEnabled($type), "Type '{$type}' has not been enabled"); + foreach ($this->getCacheStates() as $cacheType => $cacheState) { + if (in_array($cacheType, $typesToEnable)) { + $this->assertEquals(1, $cacheState, "Type '{$cacheType}' has not been enabled"); } else { - $this->assertFalse($cacheState->isEnabled($type), "Type '{$type}' must remain disabled"); + $this->assertEquals(0, $cacheState, "Type '{$cacheType}' has not been enabled"); } } } @@ -75,22 +68,31 @@ class MassActionTest extends \Magento\Backend\Utility\Controller $this->getRequest()->setParams(['types' => $typesToDisable]); $this->dispatch('backend/admin/cache/massDisable'); - Bootstrap::getInstance()->reinitialize(); - - /** @var \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList */ - $cacheTypeList = Bootstrap::getObjectManager()->get('Magento\Framework\App\Cache\TypeListInterface'); - $types = array_keys($cacheTypeList->getTypes()); - /** @var $cacheState \Magento\Framework\App\Cache\StateInterface */ - $cacheState = Bootstrap::getObjectManager()->get('Magento\Framework\App\Cache\StateInterface'); - foreach ($types as $type) { - if (in_array($type, $typesToDisable)) { - $this->assertFalse($cacheState->isEnabled($type), "Type '{$type}' has not been disabled"); + foreach ($this->getCacheStates() as $cacheType => $cacheState) { + if (in_array($cacheType, $typesToDisable)) { + $this->assertEquals(0, $cacheState, "Type '{$cacheType}' has not been disabled"); } else { - $this->assertTrue($cacheState->isEnabled($type), "Type '{$type}' must remain enabled"); + $this->assertEquals(1, $cacheState, "Type '{$cacheType}' must remain enabled"); } } } + /** + * Retrieve cache states (enabled/disabled) information + * + * Access configuration file directly as it is not possible to re-include modified file under HHVM + * @link https://github.com/facebook/hhvm/issues/1447 + * + * @return array + * @SuppressWarnings(PHPMD.EvalExpression) + */ + protected function getCacheStates() + { + $configPath = Bootstrap::getInstance()->getAppTempDir() . '/etc/config.php'; + $configData = eval(str_replace('<?php', '', file_get_contents($configPath))); + return $configData['cache_types']; + } + /** * Sets all cache types to enabled or disabled state * @@ -121,7 +123,7 @@ class MassActionTest extends \Magento\Backend\Utility\Controller $cacheTypeList = Bootstrap::getObjectManager()->get('Magento\Framework\App\Cache\TypeListInterface'); $invalidatedTypes = array_keys($cacheTypeList->getInvalidated()); $failed = array_intersect($typesToRefresh, $invalidatedTypes); - $this->assertEmpty($failed, 'Could not refresh following cache types: ' . join(', ', $failed)); + $this->assertEmpty($failed, 'Could not refresh following cache types: ' . implode(', ', $failed)); } /** @@ -135,8 +137,8 @@ class MassActionTest extends \Magento\Backend\Utility\Controller [ \Magento\Framework\App\Cache\Type\Config::TYPE_IDENTIFIER, \Magento\Framework\App\Cache\Type\Layout::TYPE_IDENTIFIER, - \Magento\Framework\App\Cache\Type\Block::TYPE_IDENTIFIER - ] + \Magento\Framework\App\Cache\Type\Block::TYPE_IDENTIFIER, + ], ] ]; } diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/CategoryTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/CategoryTest.php index 2d221e570a8ed1f34e7076f87ea95ea5ec637d33..75f5172727328e6cdc75008889dc68730568331e 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/CategoryTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/CategoryTest.php @@ -11,7 +11,7 @@ namespace Magento\Catalog\Controller\Adminhtml; class CategoryTest extends \Magento\Backend\Utility\Controller { /** - * @magentoDataFixture Magento/Core/_files/store.php + * @magentoDataFixture Magento/Store/_files/core_fixturestore.php * @magentoDbIsolation enabled * @magentoConfigFixture current_store catalog/frontend/flat_catalog_product 1 * @dataProvider saveActionDataProvider diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/NewActionTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/NewActionTest.php index a11e5dfd4549f0fe9a3e29236d36ce6fa88f6b41..1af4fd36b8f494e3005f00b50ed0609d290c5e55 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/NewActionTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/NewActionTest.php @@ -22,10 +22,7 @@ class NewActionTest extends \Magento\Backend\Utility\Controller */ public function testCustomerGroupArePresentInGroupPriceTemplate() { - $this->dispatch('backend/catalog/product/new/set/' - . \Magento\Catalog\Api\Data\ProductAttributeInterface::DEFAULT_ATTRIBUTE_SET_ID - . '/type/' . \Magento\Catalog\Model\Product\Type::TYPE_SIMPLE - ); + $this->dispatch('backend/catalog/product/new/set/4/type/' . \Magento\Catalog\Model\Product\Type::TYPE_SIMPLE); $lines = explode(PHP_EOL, $this->getResponse()->getBody()); foreach ($lines as $index => $line) { if ($line && strpos($line, 'name="product[group_price][<%- data.index %>][cust_group]"') !== false) { diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Controller/ProductTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Controller/ProductTest.php index 640c2c286a300a133a6e30322828d504a7ef6c8a..6be24179208de756406648fd6107c19d68720e3a 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Controller/ProductTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Controller/ProductTest.php @@ -9,8 +9,19 @@ */ namespace Magento\Catalog\Controller; +/** + * @magentoAppIsolation enabled + */ class ProductTest extends \Magento\TestFramework\TestCase\AbstractController { + protected function setUp() + { + if (defined('HHVM_VERSION')) { + $this->markTestSkipped('Randomly fails due to known HHVM bug (DOMText mixed with DOMElement)'); + } + parent::setUp(); + } + public function assert404NotFound() { parent::assert404NotFound(); diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/AbstractModel/Stub.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/AbstractModel/Stub.php new file mode 100644 index 0000000000000000000000000000000000000000..ced9dd4c1ea77bb044f74242c28323cec1643212 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/AbstractModel/Stub.php @@ -0,0 +1,30 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Catalog\Model\AbstractModel; + +abstract class Stub extends \Magento\Catalog\Model\AbstractModel implements \Magento\Catalog\Api\Data\ProductInterface +{ + /** + * Retrieve Store Id + * + * @return int + */ + public function getStoreId() + { + return $this->getData(self::STORE_ID); + } + + /** + * Set product store id + * + * @param int $storeId + * @return $this + */ + public function setStoreId($storeId) + { + return $this->setData(self::STORE_ID, $storeId); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/AbstractTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/AbstractTest.php index b45e05df43559ce9e92d08809fc1995cda7397cf..026e4f09722cc31c062dca66bef7e01c1a063a23 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Model/AbstractTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/AbstractTest.php @@ -27,7 +27,7 @@ class AbstractTest extends \PHPUnit_Framework_TestCase protected function setUp() { if (!self::$_isStubClass) { - $this->getMockForAbstractClass('Magento\Catalog\Model\AbstractModel', [], self::STUB_CLASS, false); + $this->getMockForAbstractClass('Magento\Catalog\Model\AbstractModel\Stub', [], self::STUB_CLASS, false); self::$_isStubClass = true; } diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/CategoryTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/CategoryTest.php index 72a723413d214a205e9004f35185f0861dbc488d..2eb662d331ffc0a1e6717690ed3a55dc1a5f152b 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Model/CategoryTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/CategoryTest.php @@ -115,7 +115,7 @@ class CategoryTest extends \PHPUnit_Framework_TestCase } /** - * @magentoDataFixture Magento/Core/_files/store.php + * @magentoDataFixture Magento/Store/_files/core_fixturestore.php * @magentoAppIsolation enabled * @magentoConfigFixture current_store catalog/frontend/flat_catalog_product 1 */ diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Indexer/Product/Flat/ProcessorTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Indexer/Product/Flat/ProcessorTest.php index 16bc2ff9e719257d271223d7e1f825057ac3fe71..2eb856f8f8236f39b824ec3f329afc62101c2b62 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Indexer/Product/Flat/ProcessorTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Indexer/Product/Flat/ProcessorTest.php @@ -88,7 +88,7 @@ class ProcessorTest extends \Magento\TestFramework\Indexer\TestCase * @magentoDbIsolation enabled * @magentoAppIsolation enabled * @magentoAppArea adminhtml - * @magentoDataFixture Magento/Core/_files/store.php + * @magentoDataFixture Magento/Store/_files/core_fixturestore.php * @magentoConfigFixture current_store catalog/frontend/flat_catalog_product 1 */ public function testAddNewStore() diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Type/File/ValidatorFileTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Type/File/ValidatorFileTest.php index 7569dd3be71a0777011c129dbac3e0b190728c51..eb8ec06003ac4f24253b991563579c4818fe3335 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Type/File/ValidatorFileTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Type/File/ValidatorFileTest.php @@ -25,10 +25,21 @@ class ValidatorFileTest extends \PHPUnit_Framework_TestCase */ protected $httpFactoryMock; + /** @var int */ + protected $maxFileSizeInMb; + + /** @var int */ + protected $maxFileSize; + protected function setUp() { $this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); $this->httpFactoryMock = $this->getMock('Magento\Framework\HTTP\Adapter\FileTransferFactory', ['create']); + /** @var \Magento\Framework\File\Size $fileSize */ + $fileSize = $this->objectManager->create('Magento\Framework\File\Size'); + $this->maxFileSize = $fileSize->getMaxFileSize(); + $this->maxFileSizeInMb = $fileSize->getMaxFileSizeInMb(); + $this->model = $this->objectManager->create( 'Magento\Catalog\Model\Product\Option\Type\File\ValidatorFile', [ @@ -38,7 +49,7 @@ class ValidatorFileTest extends \PHPUnit_Framework_TestCase } /** - * @expectedException \Magento\Framework\Validator\ValidatorException + * @expectedException \Magento\Framework\Validator\Exception * @return void */ public function testRunValidationException() @@ -53,14 +64,16 @@ class ValidatorFileTest extends \PHPUnit_Framework_TestCase } /** - * @expectedException \Magento\Framework\Exception\File\LargeSizeException - * @expectedExceptionMessage The file you uploaded is larger than 2 Megabytes allowed by server * @return void */ public function testLargeSizeException() { + $this->setExpectedException( + '\Magento\Framework\Exception\File\LargeSizeException', + sprintf('The file you uploaded is larger than %s Megabytes allowed by server', $this->maxFileSizeInMb) + ); $this->prepareEnv(); - $_SERVER['CONTENT_LENGTH'] = 2097153; + $_SERVER['CONTENT_LENGTH'] = $this->maxFileSize + 1; $httpAdapterMock = $this->getMock('Zend_File_Transfer_Adapter_Http', ['getFileInfo']); $exception = function () { throw new \Exception(); @@ -122,7 +135,10 @@ class ValidatorFileTest extends \PHPUnit_Framework_TestCase "The file 'test.jpg' for 'MediaOption' has an invalid extension.\n" . "The file 'test.jpg' for 'MediaOption' has an invalid extension.\n" . "Maximum allowed image size for 'MediaOption' is 2000x2000 px.\n" - . "The file 'test.jpg' you uploaded is larger than the 2 megabytes allowed by our server." + . sprintf( + "The file 'test.jpg' you uploaded is larger than the %s megabytes allowed by our server.", + $this->maxFileSizeInMb + ) ); $this->prepareEnv(); $httpAdapterMock = $this->getMock('Zend_File_Transfer_Adapter_Http', ['isValid', 'getErrors']); @@ -201,7 +217,7 @@ class ValidatorFileTest extends \PHPUnit_Framework_TestCase */ protected function prepareEnv() { - $file = 'magento_small_image.jpg'; + $file = 'magento_small_image.jpg'; /** @var \Magento\Framework\Filesystem $filesystem */ $filesystem = $this->objectManager->get('Magento\Framework\Filesystem'); @@ -215,7 +231,6 @@ class ValidatorFileTest extends \PHPUnit_Framework_TestCase 'error' => 0, 'size' => 12500, ]; - $_SERVER['CONTENT_LENGTH'] = 2097152; } /** diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Type/File/ValidatorInfoTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Type/File/ValidatorInfoTest.php index 101e0456b84b53e427f44b7d301908fdd1d4cbb6..d0a5bdb5bdf034ed408ef27de589cc31626d10ea 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Type/File/ValidatorInfoTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Type/File/ValidatorInfoTest.php @@ -20,6 +20,9 @@ class ValidatorInfoTest extends \PHPUnit_Framework_TestCase */ protected $objectManager; + /** @var int */ + protected $maxFileSizeInMb; + /** * @var \Magento\Catalog\Model\Product\Option\Type\File\ValidateFactory|\PHPUnit_Framework_MockObject_MockObject */ @@ -28,6 +31,10 @@ class ValidatorInfoTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + /** @var \Magento\Framework\File\Size $fileSize */ + $fileSize = $this->objectManager->create('Magento\Framework\File\Size'); + $this->maxFileSizeInMb = $fileSize->getMaxFileSizeInMb(); + $this->validateFactoryMock = $this->getMock( 'Magento\Catalog\Model\Product\Option\Type\File\ValidateFactory', ['create'] @@ -50,7 +57,10 @@ class ValidatorInfoTest extends \PHPUnit_Framework_TestCase "The file 'test.jpg' for 'MediaOption' has an invalid extension.\n" . "The file 'test.jpg' for 'MediaOption' has an invalid extension.\n" . "Maximum allowed image size for 'MediaOption' is 2000x2000 px.\n" - . "The file 'test.jpg' you uploaded is larger than the 2 megabytes allowed by our server." + . sprintf( + "The file 'test.jpg' you uploaded is larger than the %s megabytes allowed by our server.", + $this->maxFileSizeInMb + ) ); $validateMock = $this->getMock('Zend_Validate', ['isValid', 'getErrors']); diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_multistore.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_multistore.php index 4f9c3e4c3fecf059e19661ee158d1e36a8da5979..133bc16660b5d139f225a735d1503bc3a9318ce0 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_multistore.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_multistore.php @@ -3,7 +3,7 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -require __DIR__ . '/../../Core/_files/store.php'; +require __DIR__ . '/../../Store/_files/core_fixturestore.php'; $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); /** @var Magento\Store\Model\Store $store */ diff --git a/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php b/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php index 1563fc9e8d6ea3b382a1bd7bffbdb622359f199a..d3e665a753e5b1e401de8675209dbd64650b49d8 100644 --- a/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php +++ b/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php @@ -322,7 +322,7 @@ class ProductTest extends \PHPUnit_Framework_TestCase $this->_model->importData(); - reset($source); + $source->rewind(); foreach ($source as $row) { /** @var $productAfterImport \Magento\Catalog\Model\Product */ $productBeforeImport = $productsBeforeImport[$row['sku']]; @@ -779,7 +779,7 @@ class ProductTest extends \PHPUnit_Framework_TestCase /** * @magentoDataFixture Magento/Catalog/_files/categories.php - * @magentoDataFixture Magento/Core/_files/store.php + * @magentoDataFixture Magento/Store/_files/core_fixturestore.php * @magentoDataFixture Magento/Catalog/Model/Layer/Filter/_files/attribute_with_option.php * @magentoDataFixture Magento/ConfigurableProduct/_files/configurable_attribute.php * @magentoAppIsolation enabled diff --git a/dev/tests/integration/testsuite/Magento/CatalogUrlRewrite/Model/CategoryUrlRewriteGeneratorTest.php b/dev/tests/integration/testsuite/Magento/CatalogUrlRewrite/Model/CategoryUrlRewriteGeneratorTest.php index 9b3387532ab4dc6a1d31a59c03aa62fe4b1413b0..c3f988bad63fce6660fa13c90fbfc605e73911df 100644 --- a/dev/tests/integration/testsuite/Magento/CatalogUrlRewrite/Model/CategoryUrlRewriteGeneratorTest.php +++ b/dev/tests/integration/testsuite/Magento/CatalogUrlRewrite/Model/CategoryUrlRewriteGeneratorTest.php @@ -25,9 +25,17 @@ class CategoryUrlRewriteGeneratorTest extends \PHPUnit_Framework_TestCase $this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); } + public function tearDown() + { + $category = $this->objectManager->create('Magento\Catalog\Model\Category'); + $category->load(3); + $category->delete(); + } + /** * @magentoDataFixture Magento/CatalogUrlRewrite/_files/categories.php * @magentoDbIsolation enabled + * @magentoAppIsolation enabled */ public function testGenerateUrlRewritesWithoutSaveHistory() { @@ -53,9 +61,9 @@ class CategoryUrlRewriteGeneratorTest extends \PHPUnit_Framework_TestCase } /** - * @magentoDataFixture Magento/CatalogUrlRewrite/_files/categories.php * @magentoDbIsolation enabled - * + * @magentoDataFixture Magento/CatalogUrlRewrite/_files/categories.php + * @magentoAppIsolation enabled */ public function testGenerateUrlRewritesWithSaveHistory() { @@ -101,7 +109,7 @@ class CategoryUrlRewriteGeneratorTest extends \PHPUnit_Framework_TestCase $actualResults[] = [ $url->getRequestPath(), $url->getTargetPath(), - $url->getIsAutogenerated(), + (int)$url->getIsAutogenerated(), $url->getRedirectType() ]; } @@ -114,8 +122,12 @@ class CategoryUrlRewriteGeneratorTest extends \PHPUnit_Framework_TestCase */ protected function assertResults($expected, $actual) { - foreach ($actual as $row) { - $this->assertContains($row, $expected, implode(', ', $row)); + foreach ($expected as $row) { + $this->assertContains( + $row, + $actual, + 'Expected: ' . var_export($row, true) . "\nIn Actual: " . var_export($actual, true) + ); } } diff --git a/dev/tests/integration/testsuite/Magento/Checkout/Block/Cart/Item/RendererTest.php b/dev/tests/integration/testsuite/Magento/Checkout/Block/Cart/Item/RendererTest.php index 017943a3a4fc5d6348415577a6139bc26d6c561e..42524e3ea0ed5ceb5cdcef04bc51b2ed3e308b31 100644 --- a/dev/tests/integration/testsuite/Magento/Checkout/Block/Cart/Item/RendererTest.php +++ b/dev/tests/integration/testsuite/Magento/Checkout/Block/Cart/Item/RendererTest.php @@ -6,6 +6,7 @@ namespace Magento\Checkout\Block\Cart\Item; /** + * @magentoDbIsolation enabled * @magentoDataFixture Magento/Checkout/_files/quote_with_simple_product_and_image.php */ class RendererTest extends \PHPUnit_Framework_TestCase diff --git a/dev/tests/integration/testsuite/Magento/Checkout/Controller/CartTest.php b/dev/tests/integration/testsuite/Magento/Checkout/Controller/CartTest.php index 85d670d1caea880f8158b3145df8786e4c013ccc..5632555d4bec588f7650bb837bd0b1a40eaf7750 100644 --- a/dev/tests/integration/testsuite/Magento/Checkout/Controller/CartTest.php +++ b/dev/tests/integration/testsuite/Magento/Checkout/Controller/CartTest.php @@ -9,6 +9,9 @@ */ namespace Magento\Checkout\Controller; +/** + * @magentoDbIsolation enabled + */ class CartTest extends \Magento\TestFramework\TestCase\AbstractController { /** diff --git a/dev/tests/integration/testsuite/Magento/Core/Controller/IndexTest.php b/dev/tests/integration/testsuite/Magento/Core/Controller/IndexTest.php deleted file mode 100644 index 0332a70a8d6024f88bf5cd55fdb735ad5ee8b07e..0000000000000000000000000000000000000000 --- a/dev/tests/integration/testsuite/Magento/Core/Controller/IndexTest.php +++ /dev/null @@ -1,16 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Core\Controller; - -class IndexTest extends \Magento\TestFramework\TestCase\AbstractController -{ - public function testNotFoundAction() - { - $this->dispatch('core/index/notFound'); - $this->assertEquals('404', $this->getResponse()->getHttpResponseCode()); - $this->assertEquals('Requested resource not found', $this->getResponse()->getBody()); - } -} diff --git a/dev/tests/integration/testsuite/Magento/Core/Model/Theme/Source/_files/design/frontend/a_d/file b/dev/tests/integration/testsuite/Magento/Core/Model/Theme/Source/_files/design/frontend/a_d/file deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/dev/tests/integration/testsuite/Magento/Core/Model/Theme/Source/_files/design/frontend/b_e/file b/dev/tests/integration/testsuite/Magento/Core/Model/Theme/Source/_files/design/frontend/b_e/file deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/dev/tests/integration/testsuite/Magento/Core/Model/Theme/Source/_files/design/frontend/magento_default/file b/dev/tests/integration/testsuite/Magento/Core/Model/Theme/Source/_files/design/frontend/magento_default/file deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/dev/tests/integration/testsuite/Magento/Core/Model/Theme/Source/_files/design/frontend/magento_g/file b/dev/tests/integration/testsuite/Magento/Core/Model/Theme/Source/_files/design/frontend/magento_g/file deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/dev/tests/integration/testsuite/Magento/Core/Model/_files/Magento/Core/i18n/en_AU.csv b/dev/tests/integration/testsuite/Magento/Core/Model/_files/Magento/Core/i18n/en_AU.csv deleted file mode 100644 index 0d502c76477f11d34f4b2bfb33c1ca0989fee185..0000000000000000000000000000000000000000 --- a/dev/tests/integration/testsuite/Magento/Core/Model/_files/Magento/Core/i18n/en_AU.csv +++ /dev/null @@ -1 +0,0 @@ -"Original value for Magento_Core module","Translated value for Magento_Core module in en_AU" diff --git a/dev/tests/integration/testsuite/Magento/Core/_files/config_cache.php b/dev/tests/integration/testsuite/Magento/Core/_files/config_cache.php deleted file mode 100644 index 6a4289fe4ea26e07297dd3a64abf32215d1f0c50..0000000000000000000000000000000000000000 --- a/dev/tests/integration/testsuite/Magento/Core/_files/config_cache.php +++ /dev/null @@ -1,10 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -/** @var \Magento\Framework\App\Cache\Type\Config $layoutCache */ -$layoutCache = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->get('Magento\Framework\App\Cache\Type\Config'); -$layoutCache->save('fixture config cache data', 'CONFIG_CACHE_FIXTURE'); diff --git a/dev/tests/integration/testsuite/Magento/Core/_files/etc/config.xml b/dev/tests/integration/testsuite/Magento/Core/_files/etc/config.xml deleted file mode 100644 index ef1e23d46c54ee613613a0ce4a2f42f19d79280a..0000000000000000000000000000000000000000 --- a/dev/tests/integration/testsuite/Magento/Core/_files/etc/config.xml +++ /dev/null @@ -1,20 +0,0 @@ -<?xml version="1.0"?> -<!-- -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ ---> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../../app/code/Magento/Core/etc/config.xsd"> - <default> - <areas> - <test_area1> - <areaNode>value</areaNode> - </test_area1> - <test_area2> - </test_area2> - <test_area3> - </test_area3> - </areas> - </default> -</config> diff --git a/dev/tests/integration/testsuite/Magento/Core/_files/etc/module.xml b/dev/tests/integration/testsuite/Magento/Core/_files/etc/module.xml deleted file mode 100644 index 746181c42b2bae0f4888a87fad1eabcce954bc33..0000000000000000000000000000000000000000 --- a/dev/tests/integration/testsuite/Magento/Core/_files/etc/module.xml +++ /dev/null @@ -1,10 +0,0 @@ -<?xml version="1.0"?> -<!-- -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ ---> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd"> - <module name="Magento_Core" setup_version="1.6.0.2" /> -</config> diff --git a/dev/tests/integration/testsuite/Magento/Core/_files/fixture.csv b/dev/tests/integration/testsuite/Magento/Core/_files/fixture.csv deleted file mode 100644 index 297c90f5e6ec9735cd6c518b6e65ba61cf38f11e..0000000000000000000000000000000000000000 --- a/dev/tests/integration/testsuite/Magento/Core/_files/fixture.csv +++ /dev/null @@ -1,3 +0,0 @@ -"Search:","Fixture search:" -"Search entire store here...","Fixture search entire store here..." -"Fixture string","Fixture translation" diff --git a/dev/tests/integration/testsuite/Magento/Customer/Model/AddressMetadataTest.php b/dev/tests/integration/testsuite/Magento/Customer/Model/AddressMetadataTest.php index 9f77693988cab1d85a44186e2c696778e759951c..1b9ad064466529226a1751f4a7c359931f6a1abd 100644 --- a/dev/tests/integration/testsuite/Magento/Customer/Model/AddressMetadataTest.php +++ b/dev/tests/integration/testsuite/Magento/Customer/Model/AddressMetadataTest.php @@ -31,18 +31,7 @@ class AddressMetadataTest extends \PHPUnit_Framework_TestCase public function testGetCustomAttributesMetadata() { $customAttributesMetadata = $this->_service->getCustomAttributesMetadata(); - $this->assertCount(2, $customAttributesMetadata, "Invalid number of attributes returned."); - $configAttributeCode = 'address_attribute_1'; - $configAttributeFound = false; - foreach ($customAttributesMetadata as $attribute) { - if ($attribute->getAttributeCode() == $configAttributeCode) { - $configAttributeFound = true; - break; - } - } - if (!$configAttributeFound) { - $this->fail("Custom attribute declared in the config not found."); - } + $this->assertCount(0, $customAttributesMetadata, "Invalid number of attributes returned."); } /** @@ -69,7 +58,7 @@ class AddressMetadataTest extends \PHPUnit_Framework_TestCase if (!$customAttributesFound) { $this->fail("Custom attributes declared in the config not found."); } - $this->assertCount(4, $customAttributesMetadata, "Invalid number of attributes returned."); + $this->assertCount(2, $customAttributesMetadata, "Invalid number of attributes returned."); } public function testGetAddressAttributeMetadata() diff --git a/dev/tests/integration/testsuite/Magento/Customer/Model/Config/ShareTest.php b/dev/tests/integration/testsuite/Magento/Customer/Model/Config/ShareTest.php index 67243448374f24d8e3348638fd95eee4c1ccc724..7ec75e92d513795c73eaa286704bf3da208b707d 100644 --- a/dev/tests/integration/testsuite/Magento/Customer/Model/Config/ShareTest.php +++ b/dev/tests/integration/testsuite/Magento/Customer/Model/Config/ShareTest.php @@ -23,7 +23,7 @@ class ShareTest extends \PHPUnit_Framework_TestCase } /** - * @magentoDataFixture Magento/Core/_files/second_third_store.php + * @magentoDataFixture Magento/Store/_files/core_second_third_fixturestore.php * @magentoConfigFixture current_store customer/account_share/scope 0 */ public function testGetSharedWebsiteIdsMultipleSites() diff --git a/dev/tests/integration/testsuite/Magento/Customer/Model/CustomerMetadataTest.php b/dev/tests/integration/testsuite/Magento/Customer/Model/CustomerMetadataTest.php index b18d1c2b598e8dce4af38fdbbe87ece1a0a9517b..672e0e17c6cc424819ec36046829e9e193e58fa7 100644 --- a/dev/tests/integration/testsuite/Magento/Customer/Model/CustomerMetadataTest.php +++ b/dev/tests/integration/testsuite/Magento/Customer/Model/CustomerMetadataTest.php @@ -47,18 +47,7 @@ class CustomerMetadataTest extends \PHPUnit_Framework_TestCase public function testGetCustomAttributesMetadata() { $customAttributesMetadata = $this->_service->getCustomAttributesMetadata(); - $this->assertCount(3, $customAttributesMetadata, "Invalid number of attributes returned."); - $configAttributeCode = 'customer_attribute_1'; - $configAttributeFound = false; - foreach ($customAttributesMetadata as $attribute) { - if ($attribute->getAttributeCode() == $configAttributeCode) { - $configAttributeFound = true; - break; - } - } - if (!$configAttributeFound) { - $this->fail("Custom attribute declared in the config not found."); - } + $this->assertCount(1, $customAttributesMetadata, "Invalid number of attributes returned."); } public function testGetNestedOptionsCustomAttributesMetadata() @@ -104,7 +93,7 @@ class CustomerMetadataTest extends \PHPUnit_Framework_TestCase if (!$customAttributesFound) { $this->fail("Custom attributes declared in the config not found."); } - $this->assertCount(5, $customAttributesMetadata, "Invalid number of attributes returned."); + $this->assertCount(3, $customAttributesMetadata, "Invalid number of attributes returned."); } /** diff --git a/dev/tests/integration/testsuite/Magento/Customer/Model/GroupManagementTest.php b/dev/tests/integration/testsuite/Magento/Customer/Model/GroupManagementTest.php index e08486410020a74ff23d708edb92749e552a36e7..59c904036a712bf1d360c58a82ebb929fe5498d4 100644 --- a/dev/tests/integration/testsuite/Magento/Customer/Model/GroupManagementTest.php +++ b/dev/tests/integration/testsuite/Magento/Customer/Model/GroupManagementTest.php @@ -42,10 +42,10 @@ class GroupManagementTest extends \PHPUnit_Framework_TestCase } /** - * @magentoDataFixture Magento/Core/_files/second_third_store.php + * @magentoDataFixture Magento/Store/_files/core_second_third_fixturestore.php */ public function testGetDefaultGroupWithNonDefaultStoreId() - { + { /** @var \Magento\Store\Model\StoreManagerInterface $storeManager */ $storeManager = Bootstrap::getObjectManager()->get('Magento\Store\Model\StoreManagerInterface'); $nonDefaultStore = $storeManager->getStore('secondstore'); diff --git a/dev/tests/integration/testsuite/Magento/Customer/Model/VisitorTest.php b/dev/tests/integration/testsuite/Magento/Customer/Model/VisitorTest.php index e8bb754254ebeb39ae1329af1c612e69228d99c2..59747a3c427887b59895b20f16e07ce4f9fedc80 100644 --- a/dev/tests/integration/testsuite/Magento/Customer/Model/VisitorTest.php +++ b/dev/tests/integration/testsuite/Magento/Customer/Model/VisitorTest.php @@ -63,18 +63,22 @@ class VisitorTest extends \PHPUnit_Framework_TestCase */ public function testClean() { + $customerIdNow = 1; $lastVisitNow = date('Y-m-d H:i:s', time()); $sessionIdNow = 'asaswljxvgklasdflkjasieasd'; + $customerIdPast = null; $lastVisitPast = date('Y-m-d H:i:s', time() - 172800); $sessionIdPast = 'kui0aa57nqddl8vk7k6ohgi352'; /** @var \Magento\Customer\Model\Visitor $visitor */ $visitor = Bootstrap::getObjectManager()->get('Magento\Customer\Model\Visitor'); + $visitor->setCustomerId($customerIdPast); $visitor->setSessionId($sessionIdPast); $visitor->setLastVisitAt($lastVisitPast); $visitor->save(); $visitorIdPast = $visitor->getId(); $visitor->unsetData(); + $visitor->setCustomerId($customerIdNow); $visitor->setSessionId($sessionIdNow); $visitor->setLastVisitAt($lastVisitNow); $visitor->save(); @@ -87,7 +91,12 @@ class VisitorTest extends \PHPUnit_Framework_TestCase $visitor->unsetData(); $visitor->load($visitorIdNow); $this->assertEquals( - ['visitor_id' => $visitorIdNow, 'session_id' => $sessionIdNow, 'last_visit_at' => $lastVisitNow], + [ + 'visitor_id' => $visitorIdNow, + 'customer_id' => $customerIdNow, + 'session_id' => $sessionIdNow, + 'last_visit_at' => $lastVisitNow + ], $visitor->getData() ); } diff --git a/dev/tests/integration/testsuite/Magento/Email/Model/Template/FilterTest.php b/dev/tests/integration/testsuite/Magento/Email/Model/Template/FilterTest.php index eeea37be4c2828f7c2aacda436d1697a9751faa3..06746a974e5b04da732eedcb072fd66dc8b0adbc 100644 --- a/dev/tests/integration/testsuite/Magento/Email/Model/Template/FilterTest.php +++ b/dev/tests/integration/testsuite/Magento/Email/Model/Template/FilterTest.php @@ -176,7 +176,7 @@ class FilterTest extends \PHPUnit_Framework_TestCase ], 'custom parameter' => [ 'frontend', - 'handle="email_template_test_handle" template="Magento_Core::sample_email_content_custom.phtml"', + 'handle="email_template_test_handle" template="Magento_Email::sample_email_content_custom.phtml"', 'Custom E-mail content for frontend/test_default theme', ], ]; diff --git a/dev/tests/integration/testsuite/Magento/Email/Model/TemplateTest.php b/dev/tests/integration/testsuite/Magento/Email/Model/TemplateTest.php index 5ffaed0005fadfe797d43b1753b32e13c1c35903..72cbb8f071d6f7b0a8cdd2574bc3ccb6005eabe1 100644 --- a/dev/tests/integration/testsuite/Magento/Email/Model/TemplateTest.php +++ b/dev/tests/integration/testsuite/Magento/Email/Model/TemplateTest.php @@ -89,7 +89,7 @@ class TemplateTest extends \PHPUnit_Framework_TestCase /** * @magentoAppIsolation enabled - * @magentoDataFixture Magento/Core/_files/store.php + * @magentoDataFixture Magento/Store/_files/core_fixturestore.php */ public function testGetProcessedTemplate() { @@ -137,7 +137,7 @@ class TemplateTest extends \PHPUnit_Framework_TestCase /** * @magentoAppIsolation enabled - * @magentoDataFixture Magento/Core/_files/store.php + * @magentoDataFixture Magento/Store/_files/core_fixturestore.php */ public function testGetProcessedTemplateSubject() { @@ -185,7 +185,7 @@ class TemplateTest extends \PHPUnit_Framework_TestCase */ public function testSetDesignConfigException($config) { - // \Magento\Core\Model\Template is an abstract class + // \Magento\Email\Model\Template is an abstract class $model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() ->create('Magento\Email\Model\Template'); $model->setDesignConfig($config); diff --git a/dev/tests/integration/testsuite/Magento/Email/Model/_files/design/adminhtml/test_default/Magento_Core/layout/email_template_test_handle.xml b/dev/tests/integration/testsuite/Magento/Email/Model/_files/design/adminhtml/test_default/Magento_Email/layout/email_template_test_handle.xml similarity index 79% rename from dev/tests/integration/testsuite/Magento/Email/Model/_files/design/adminhtml/test_default/Magento_Core/layout/email_template_test_handle.xml rename to dev/tests/integration/testsuite/Magento/Email/Model/_files/design/adminhtml/test_default/Magento_Email/layout/email_template_test_handle.xml index 0fb1b826f9e7e6f6369fba3fd85313338ba42448..43ce29cbfa0a414e784d2c2d87f5188578038443 100644 --- a/dev/tests/integration/testsuite/Magento/Email/Model/_files/design/adminhtml/test_default/Magento_Core/layout/email_template_test_handle.xml +++ b/dev/tests/integration/testsuite/Magento/Email/Model/_files/design/adminhtml/test_default/Magento_Email/layout/email_template_test_handle.xml @@ -6,5 +6,5 @@ */ --> <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > - <block class="Magento\Backend\Block\Template" name="sample_email_content" template="Magento_Core::sample_email_content.phtml"/> + <block class="Magento\Backend\Block\Template" name="sample_email_content" template="Magento_Email::sample_email_content.phtml"/> </layout> diff --git a/dev/tests/integration/testsuite/Magento/Email/Model/_files/design/adminhtml/test_default/Magento_Core/templates/sample_email_content.phtml b/dev/tests/integration/testsuite/Magento/Email/Model/_files/design/adminhtml/test_default/Magento_Email/templates/sample_email_content.phtml similarity index 100% rename from dev/tests/integration/testsuite/Magento/Email/Model/_files/design/adminhtml/test_default/Magento_Core/templates/sample_email_content.phtml rename to dev/tests/integration/testsuite/Magento/Email/Model/_files/design/adminhtml/test_default/Magento_Email/templates/sample_email_content.phtml diff --git a/dev/tests/integration/testsuite/Magento/Email/Model/_files/design/frontend/test_default/Magento_Core/layout/email_template_test_handle.xml b/dev/tests/integration/testsuite/Magento/Email/Model/_files/design/frontend/test_default/Magento_Email/layout/email_template_test_handle.xml similarity index 87% rename from dev/tests/integration/testsuite/Magento/Email/Model/_files/design/frontend/test_default/Magento_Core/layout/email_template_test_handle.xml rename to dev/tests/integration/testsuite/Magento/Email/Model/_files/design/frontend/test_default/Magento_Email/layout/email_template_test_handle.xml index 359f9c07e07ccfb6ac794116afa1fe4aee781c90..767644707ff84fe0b5c19561a8bc28e2f0e02aaa 100644 --- a/dev/tests/integration/testsuite/Magento/Email/Model/_files/design/frontend/test_default/Magento_Core/layout/email_template_test_handle.xml +++ b/dev/tests/integration/testsuite/Magento/Email/Model/_files/design/frontend/test_default/Magento_Email/layout/email_template_test_handle.xml @@ -6,7 +6,7 @@ */ --> <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > - <block class="Magento\Framework\View\Element\Template" name="sample_email_content" template="Magento_Core::sample_email_content.phtml"/> + <block class="Magento\Framework\View\Element\Template" name="sample_email_content" template="Magento_Email::sample_email_content.phtml"/> <block class="Magento\Framework\View\Element\Text" name="ignored_email_content"> <action method="setText"> <argument name="text" xsi:type="string">Ignored e-mail content, only the first block is used</argument> diff --git a/dev/tests/integration/testsuite/Magento/Email/Model/_files/design/frontend/test_default/Magento_Core/templates/sample_email_content.phtml b/dev/tests/integration/testsuite/Magento/Email/Model/_files/design/frontend/test_default/Magento_Email/templates/sample_email_content.phtml similarity index 100% rename from dev/tests/integration/testsuite/Magento/Email/Model/_files/design/frontend/test_default/Magento_Core/templates/sample_email_content.phtml rename to dev/tests/integration/testsuite/Magento/Email/Model/_files/design/frontend/test_default/Magento_Email/templates/sample_email_content.phtml diff --git a/dev/tests/integration/testsuite/Magento/Email/Model/_files/design/frontend/test_default/Magento_Core/templates/sample_email_content_custom.phtml b/dev/tests/integration/testsuite/Magento/Email/Model/_files/design/frontend/test_default/Magento_Email/templates/sample_email_content_custom.phtml similarity index 100% rename from dev/tests/integration/testsuite/Magento/Email/Model/_files/design/frontend/test_default/Magento_Core/templates/sample_email_content_custom.phtml rename to dev/tests/integration/testsuite/Magento/Email/Model/_files/design/frontend/test_default/Magento_Email/templates/sample_email_content_custom.phtml diff --git a/dev/tests/integration/testsuite/Magento/Framework/Api/AbstractExtensibleObjectTest.php b/dev/tests/integration/testsuite/Magento/Framework/Api/AbstractExtensibleObjectTest.php new file mode 100644 index 0000000000000000000000000000000000000000..dd5fba5c4d60d9740bd931dffe0d5e208a883fa2 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Framework/Api/AbstractExtensibleObjectTest.php @@ -0,0 +1,92 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Framework\Api; + +/** + * Test for \Magento\Framework\Api\AbstractExtensibleObject + */ +class AbstractExtensibleObjectTest extends \PHPUnit_Framework_TestCase +{ + /** @var \Magento\Framework\ObjectManagerInterface */ + private $_objectManager; + + protected function setUp() + { + $autoloadWrapper = \Magento\Framework\Autoload\AutoloaderRegistry::getAutoloader(); + $autoloadWrapper->addPsr4('Magento\\Wonderland\\', realpath(__DIR__ . '/_files/Magento/Wonderland')); + $this->_objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + $this->_objectManager->configure( + [ + 'preferences' => [ + 'Magento\Wonderland\Api\Data\FakeAddressInterface' => 'Magento\Wonderland\Model\FakeAddress', + 'Magento\Wonderland\Api\Data\FakeRegionInterface' => 'Magento\Wonderland\Model\FakeRegion', + ], + ] + ); + } + + /** + * Test setExtensionAttributes and getExtensionAttributes for \Magento\Framework\Api\AbstractExtensibleObject + * + * @param array $expectedDataBefore + * @param array $expectedDataAfter + * @dataProvider extensionAttributesDataProvider + */ + public function testExtensionAttributes($expectedDataBefore, $expectedDataAfter) + { + /** @var \Magento\Framework\Api\ExtensionAttributesFactory $regionExtensionFactory */ + $regionExtensionFactory = $this->_objectManager->get('Magento\Framework\Api\ExtensionAttributesFactory'); + /** @var \Magento\Wonderland\Model\Data\FakeRegionFactory $regionFactory */ + $regionFactory = $this->_objectManager->get('Magento\Wonderland\Model\Data\FakeRegionFactory'); + + /** @var \Magento\Wonderland\Model\Data\FakeRegion $region */ + $region = $regionFactory->create(); + + $regionCode = 'test_code'; + /** @var \Magento\Wonderland\Model\Data\FakeRegionExtensionInterface $regionExtension */ + $regionExtension = $regionExtensionFactory->create( + 'Magento\Wonderland\Model\Data\FakeRegion', + ['data' => $expectedDataBefore] + ); + $region->setRegionCode($regionCode)->setExtensionAttributes($regionExtension); + $this->assertInstanceOf('Magento\Wonderland\Model\Data\FakeRegion', $region); + + $extensionAttributes = $region->getExtensionAttributes(); + $this->assertInstanceOf('Magento\Wonderland\Api\Data\FakeRegionExtension', $extensionAttributes); + $this->assertEquals($expectedDataBefore, $extensionAttributes->__toArray()); + $this->assertEquals($regionCode, $region->getRegionCode()); + + $regionCode = 'changed_test_code'; + $region->setExtensionAttributes( + $regionExtensionFactory->create('Magento\Wonderland\Model\Data\FakeRegion', ['data' => $expectedDataAfter]) + )->setRegionCode($regionCode); // change $regionCode to test AbstractExtensibleObject::setData + $extensionAttributes = $region->getExtensionAttributes(); + $this->assertEquals($expectedDataAfter, $extensionAttributes->__toArray()); + $this->assertEquals($regionCode, $region->getRegionCode()); + } + + public function extensionAttributesDataProvider() + { + return [ + 'boolean' => [ + [true], + [false] + ], + 'integer' => [ + [1], + [2] + ], + 'string' => [ + ['test'], + ['test test'] + ], + 'array' => [ + [[1]], + [[1, 2]] + ] + ]; + } +} diff --git a/dev/tests/integration/testsuite/Magento/Framework/Api/ExtensionAttributesFactoryTest.php b/dev/tests/integration/testsuite/Magento/Framework/Api/ExtensionAttributesFactoryTest.php new file mode 100644 index 0000000000000000000000000000000000000000..2c6ddf42f67cbbfc9edb55330c4ae09f387807ae --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Framework/Api/ExtensionAttributesFactoryTest.php @@ -0,0 +1,53 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Framework\Api; + +class ExtensionAttributesFactoryTest extends \PHPUnit_Framework_TestCase +{ + /** @var \Magento\Framework\Api\ExtensionAttributesFactory */ + private $factory; + + protected function setUp() + { + $autoloadWrapper = \Magento\Framework\Autoload\AutoloaderRegistry::getAutoloader(); + $autoloadWrapper->addPsr4('Magento\\Wonderland\\', realpath(__DIR__ . '/_files/Magento/Wonderland')); + /** @var \Magento\Framework\ObjectManagerInterface */ + $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + $this->factory = new ExtensionAttributesFactory($objectManager); + } + + /** + * @expectedException \LogicException + */ + public function testCreateThrowExceptionIfInterfaceNotImplemented() + { + $this->factory->create('Magento\Framework\Api\ExtensionAttributesFactoryTest'); + } + + /** + * @expectedException \LogicException + */ + public function testCreateThrowExceptionIfInterfaceNotOverridden() + { + $this->factory->create('\Magento\Wonderland\Model\Data\FakeExtensibleOne'); + } + + /** + * @expectedException \LogicException + */ + public function testCreateThrowExceptionIfReturnIsIncorrect() + { + $this->factory->create('\Magento\Wonderland\Model\Data\FakeExtensibleTwo'); + } + + public function testCreate() + { + $this->assertInstanceOf( + 'Magento\Wonderland\Api\Data\FakeRegionExtension', + $this->factory->create('Magento\Wonderland\Model\Data\FakeRegion') + ); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Framework/Api/_files/Magento/Wonderland/Api/Data/FakeAddressInterface.php b/dev/tests/integration/testsuite/Magento/Framework/Api/_files/Magento/Wonderland/Api/Data/FakeAddressInterface.php index 597a30cc1de907d7eeb1f193ef97716b0568bdfd..8377ec40155785df4aeb482bc867d43cf2763224 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Api/_files/Magento/Wonderland/Api/Data/FakeAddressInterface.php +++ b/dev/tests/integration/testsuite/Magento/Framework/Api/_files/Magento/Wonderland/Api/Data/FakeAddressInterface.php @@ -170,4 +170,21 @@ interface FakeAddressInterface extends ExtensibleDataInterface * @return bool|null */ public function isDefaultBilling(); + + /** + * Retrieve existing extension attributes object or create a new one. + * + * @return \Magento\Wonderland\Api\Data\FakeAddressExtensionInterface|null + */ + public function getExtensionAttributes(); + + /** + * Set an extension attributes object. + * + * @param \Magento\Wonderland\Api\Data\FakeAddressExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes( + \Magento\Wonderland\Api\Data\FakeAddressExtensionInterface $extensionAttributes + ); } diff --git a/dev/tests/integration/testsuite/Magento/Framework/Api/_files/Magento/Wonderland/Api/Data/FakeExtensibleOneInterface.php b/dev/tests/integration/testsuite/Magento/Framework/Api/_files/Magento/Wonderland/Api/Data/FakeExtensibleOneInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..fdf9d49a67c3fe67503ec23dda9fa8742c0d291f --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Framework/Api/_files/Magento/Wonderland/Api/Data/FakeExtensibleOneInterface.php @@ -0,0 +1,18 @@ +<?php +/** + * + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Wonderland\Api\Data; + +use Magento\Framework\Api\ExtensibleDataInterface; + +/** + * Fake interface + * to test exception if the method 'getExtensionAttributes' is not overridden + */ +interface FakeExtensibleOneInterface extends ExtensibleDataInterface +{ +} diff --git a/dev/tests/integration/testsuite/Magento/Framework/Api/_files/Magento/Wonderland/Api/Data/FakeExtensibleTwoInterface.php b/dev/tests/integration/testsuite/Magento/Framework/Api/_files/Magento/Wonderland/Api/Data/FakeExtensibleTwoInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..42f212c861474c3e66595458473d7227470fad7e --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Framework/Api/_files/Magento/Wonderland/Api/Data/FakeExtensibleTwoInterface.php @@ -0,0 +1,24 @@ +<?php +/** + * + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Wonderland\Api\Data; + +use Magento\Framework\Api\ExtensibleDataInterface; + +/** + * Fake interface + * to test exception if the method 'getExtensionAttributes' does not return concrete type + */ +interface FakeExtensibleTwoInterface extends ExtensibleDataInterface +{ + /** + * test incorrect return type + * + * @return int + */ + public function getExtensionAttributes(); +} diff --git a/dev/tests/integration/testsuite/Magento/Framework/Api/_files/Magento/Wonderland/Api/Data/FakeRegionInterface.php b/dev/tests/integration/testsuite/Magento/Framework/Api/_files/Magento/Wonderland/Api/Data/FakeRegionInterface.php index ce54b0484b530f1fdbd47753002b556fe2d841a0..76cb08b2395f8a5d5d8848ccce74302de8822dee 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Api/_files/Magento/Wonderland/Api/Data/FakeRegionInterface.php +++ b/dev/tests/integration/testsuite/Magento/Framework/Api/_files/Magento/Wonderland/Api/Data/FakeRegionInterface.php @@ -41,4 +41,21 @@ interface FakeRegionInterface extends ExtensibleDataInterface * @return int */ public function getRegionId(); + + /** + * Retrieve existing extension attributes object or create a new one. + * + * @return \Magento\Wonderland\Api\Data\FakeRegionExtensionInterface|null + */ + public function getExtensionAttributes(); + + /** + * Set an extension attributes object. + * + * @param \Magento\Wonderland\Api\Data\FakeRegionExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes( + \Magento\Wonderland\Api\Data\FakeRegionExtensionInterface $extensionAttributes + ); } diff --git a/dev/tests/integration/testsuite/Magento/Framework/Api/_files/Magento/Wonderland/Model/Data/FakeAddress.php b/dev/tests/integration/testsuite/Magento/Framework/Api/_files/Magento/Wonderland/Model/Data/FakeAddress.php index 0070597fa58bd402876514caf99ffbe6d933d91d..98407fcebb8f2a30cfb3c3f5a1de9c1f6710dc98 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Api/_files/Magento/Wonderland/Model/Data/FakeAddress.php +++ b/dev/tests/integration/testsuite/Magento/Framework/Api/_files/Magento/Wonderland/Model/Data/FakeAddress.php @@ -7,31 +7,10 @@ namespace Magento\Wonderland\Model\Data; use Magento\Framework\Api\AbstractExtensibleObject; +use Magento\Wonderland\Api\Data\FakeAddressInterface; -class FakeAddress extends AbstractExtensibleObject +class FakeAddress extends AbstractExtensibleObject implements FakeAddressInterface { - /**#@+ - * Constants for keys of data array - */ - const ID = 'id'; - const CUSTOMER_ID = 'customer_id'; - const REGION = 'region'; - const REGIONS = 'regions'; - const COUNTRY_ID = 'country_id'; - const STREET = 'street'; - const COMPANY = 'company'; - const TELEPHONE = 'telephone'; - const FAX = 'fax'; - const POSTCODE = 'postcode'; - const CITY = 'city'; - const FIRSTNAME = 'firstname'; - const LASTNAME = 'lastname'; - const MIDDLENAME = 'middlename'; - const PREFIX = 'prefix'; - const SUFFIX = 'suffix'; - const VAT_ID = 'vat_id'; - /**#@-*/ - /** * Get ID * @@ -201,4 +180,46 @@ class FakeAddress extends AbstractExtensibleObject { return $this->_get(self::VAT_ID); } + + /** + * Get if this address is default shipping address. + * + * @return bool|null + */ + public function isDefaultShipping() + { + return $this->_get(self::DEFAULT_SHIPPING); + } + + /** + * {@inheritdoc} + * + * @return \Magento\Wonderland\Api\Data\FakeAddressExtensionInterface|null + */ + public function getExtensionAttributes() + { + return $this->_getExtensionAttributes(); + } + + /** + * Get if this address is default billing address + * + * @return bool|null + */ + public function isDefaultBilling() + { + return $this->_get(self::DEFAULT_BILLING); + } + + /** + * {@inheritdoc} + * + * @param \Magento\Wonderland\Api\Data\FakeAddressExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes( + \Magento\Wonderland\Api\Data\FakeAddressExtensionInterface $extensionAttributes + ) { + return $this->_setExtensionAttributes($extensionAttributes); + } } diff --git a/dev/tests/integration/testsuite/Magento/Framework/Api/_files/Magento/Wonderland/Model/Data/FakeExtensibleOne.php b/dev/tests/integration/testsuite/Magento/Framework/Api/_files/Magento/Wonderland/Model/Data/FakeExtensibleOne.php new file mode 100644 index 0000000000000000000000000000000000000000..536aeb9343dce89989d2662b2bbe4ca85a2292a7 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Framework/Api/_files/Magento/Wonderland/Model/Data/FakeExtensibleOne.php @@ -0,0 +1,13 @@ +<?php +/** + * + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Wonderland\Model\Data; + +use Magento\Wonderland\Api\Data\FakeExtensibleOneInterface; + +class FakeExtensibleOne implements FakeExtensibleOneInterface +{ +} diff --git a/dev/tests/integration/testsuite/Magento/Framework/Api/_files/Magento/Wonderland/Model/Data/FakeExtensibleTwo.php b/dev/tests/integration/testsuite/Magento/Framework/Api/_files/Magento/Wonderland/Model/Data/FakeExtensibleTwo.php new file mode 100644 index 0000000000000000000000000000000000000000..47c95a12b83c510ed50c72e99ef0738b0700a1e6 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Framework/Api/_files/Magento/Wonderland/Model/Data/FakeExtensibleTwo.php @@ -0,0 +1,21 @@ +<?php +/** + * + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Wonderland\Model\Data; + +use Magento\Framework\Api\AbstractExtensibleObject; +use Magento\Wonderland\Api\Data\FakeExtensibleTwoInterface; + +class FakeExtensibleTwo extends AbstractExtensibleObject implements FakeExtensibleTwoInterface +{ + /** + * {@inheritdoc} + */ + public function getExtensionAttributes() + { + return $this->_getExtensionAttributes(); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Framework/Api/_files/Magento/Wonderland/Model/Data/FakeRegion.php b/dev/tests/integration/testsuite/Magento/Framework/Api/_files/Magento/Wonderland/Model/Data/FakeRegion.php index e6dad7fd79fc310c8298feb90420d8967e6aef88..cef747dcbdd1ceed0f357b680352921136420074 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Api/_files/Magento/Wonderland/Model/Data/FakeRegion.php +++ b/dev/tests/integration/testsuite/Magento/Framework/Api/_files/Magento/Wonderland/Model/Data/FakeRegion.php @@ -8,16 +8,8 @@ namespace Magento\Wonderland\Model\Data; use Magento\Framework\Api\AbstractExtensibleObject; -class FakeRegion extends AbstractExtensibleObject +class FakeRegion extends AbstractExtensibleObject implements \Magento\Wonderland\Api\Data\FakeRegionInterface { - /**#@+ - * Constants for keys of data array - */ - const REGION_CODE = 'region_code'; - const REGION = 'region'; - const REGION_ID = 'region_id'; - /**#@-*/ - /** * Get region * @@ -47,4 +39,37 @@ class FakeRegion extends AbstractExtensibleObject { return $this->_get(self::REGION_ID); } + + /** + * {@inheritdoc} + * + * @return \Magento\Wonderland\Api\Data\FakeRegionExtensionInterface|null + */ + public function getExtensionAttributes() + { + return $this->_getExtensionAttributes(); + } + + /** + * {@inheritdoc} + * + * @param \Magento\Wonderland\Api\Data\FakeRegionExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes( + \Magento\Wonderland\Api\Data\FakeRegionExtensionInterface $extensionAttributes + ) { + return $this->_setExtensionAttributes($extensionAttributes); + } + + /** + * Set region code + * + * @param string $regionCode + * @return $this + */ + public function setRegionCode($regionCode) + { + return $this->setData(self::REGION_CODE, $regionCode); + } } diff --git a/dev/tests/integration/testsuite/Magento/Framework/Api/_files/Magento/Wonderland/Model/FakeAddress.php b/dev/tests/integration/testsuite/Magento/Framework/Api/_files/Magento/Wonderland/Model/FakeAddress.php index 67db23b4f055b8fe778b480aa281aba05b789281..f98e3f5051c31b4c47b1dcdf07fcc4718a0022f4 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Api/_files/Magento/Wonderland/Model/FakeAddress.php +++ b/dev/tests/integration/testsuite/Magento/Framework/Api/_files/Magento/Wonderland/Model/FakeAddress.php @@ -200,4 +200,26 @@ class FakeAddress extends AbstractExtensibleModel implements FakeAddressInterfac { return $this->getData(self::DEFAULT_BILLING); } + + /** + * {@inheritdoc} + * + * @return \Magento\Wonderland\Api\Data\FakeAddressExtensionInterface|null + */ + public function getExtensionAttributes() + { + return $this->_getExtensionAttributes(); + } + + /** + * {@inheritdoc} + * + * @param \Magento\Wonderland\Api\Data\FakeAddressExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes( + \Magento\Wonderland\Api\Data\FakeAddressExtensionInterface $extensionAttributes + ) { + return $this->_setExtensionAttributes($extensionAttributes); + } } diff --git a/dev/tests/integration/testsuite/Magento/Framework/Api/_files/Magento/Wonderland/Model/FakeRegion.php b/dev/tests/integration/testsuite/Magento/Framework/Api/_files/Magento/Wonderland/Model/FakeRegion.php index 9074d3fcf36feeeacb19e65302378424cc6e342a..7527cde11534a301cfb6ae6e0e7ccd306c96ceb1 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Api/_files/Magento/Wonderland/Model/FakeRegion.php +++ b/dev/tests/integration/testsuite/Magento/Framework/Api/_files/Magento/Wonderland/Model/FakeRegion.php @@ -40,4 +40,26 @@ class FakeRegion extends AbstractExtensibleModel implements FakeRegionInterface { return $this->getData(self::REGION_ID); } + + /** + * {@inheritdoc} + * + * @return \Magento\Wonderland\Api\Data\FakeRegionExtensionInterface|null + */ + public function getExtensionAttributes() + { + return $this->_getExtensionAttributes(); + } + + /** + * {@inheritdoc} + * + * @param \Magento\Wonderland\Api\Data\FakeRegionExtensionInterface $extensionAttributes + * @return $this + */ + public function setExtensionAttributes( + \Magento\Wonderland\Api\Data\FakeRegionExtensionInterface $extensionAttributes + ) { + return $this->_setExtensionAttributes($extensionAttributes); + } } diff --git a/dev/tests/integration/testsuite/Magento/Framework/App/Router/BaseTest.php b/dev/tests/integration/testsuite/Magento/Framework/App/Router/BaseTest.php index c4fa6c52bcbf54d81dc14e42b08b101be27924bd..f2519497eeba1427d9c2005b3c0215020c32b6f3 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/App/Router/BaseTest.php +++ b/dev/tests/integration/testsuite/Magento/Framework/App/Router/BaseTest.php @@ -36,7 +36,7 @@ class BaseTest extends \PHPUnit_Framework_TestCase $request = $objectManager->get('Magento\TestFramework\Request'); $this->assertInstanceOf('Magento\Framework\App\ActionInterface', $this->_model->match($request)); - $request->setRequestUri('core/index/index'); + $request->setRequestUri('framework/index/index'); $this->assertInstanceOf('Magento\Framework\App\ActionInterface', $this->_model->match($request)); $request->setPathInfo( @@ -54,8 +54,8 @@ class BaseTest extends \PHPUnit_Framework_TestCase public function testGetControllerClassName() { $this->assertEquals( - 'Magento\Core\Controller\Index', - $this->_model->getActionClassName('Magento_Core', 'index') + 'Magento\Framework\Controller\Index', + $this->_model->getActionClassName('Magento_Framework', 'index') ); } } diff --git a/dev/tests/integration/testsuite/Magento/Framework/Code/GeneratorTest.php b/dev/tests/integration/testsuite/Magento/Framework/Code/GeneratorTest.php index 943cc88e8f697eb55bec4754f01742945853dfd2..e31201caf943440ce75a00725b65c79cde471c29 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Code/GeneratorTest.php +++ b/dev/tests/integration/testsuite/Magento/Framework/Code/GeneratorTest.php @@ -39,7 +39,8 @@ class GeneratorTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->varDirectory = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( + $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + $this->varDirectory = $objectManager->get( 'Magento\Framework\Filesystem' )->getDirectoryWrite( DirectoryList::VAR_DIR @@ -49,7 +50,7 @@ class GeneratorTest extends \PHPUnit_Framework_TestCase new \Magento\Framework\Filesystem\Driver\File(), $generationDirectory ); - $this->_generator = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( + $this->_generator = $objectManager->create( 'Magento\Framework\Code\Generator', [ 'ioObject' => $this->_ioObject, @@ -61,6 +62,7 @@ class GeneratorTest extends \PHPUnit_Framework_TestCase ] ] ); + $this->_generator->setObjectManager($objectManager); } protected function tearDown() diff --git a/dev/tests/integration/testsuite/Magento/Framework/DB/Adapter/InterfaceTest.php b/dev/tests/integration/testsuite/Magento/Framework/DB/Adapter/InterfaceTest.php index 5e0219f68f0e24e94bc092ddbbd2952743131bf8..ff713ae85f28f53df39201f3708adb5146b5a67b 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/DB/Adapter/InterfaceTest.php +++ b/dev/tests/integration/testsuite/Magento/Framework/DB/Adapter/InterfaceTest.php @@ -38,7 +38,7 @@ class InterfaceTest extends \PHPUnit_Framework_TestCase '\Magento\Framework\Setup\ModuleDataSetupInterface', [ 'resourceName' => 'core_setup', - 'moduleName' => 'Magento_Core' + 'moduleName' => 'Magento_Test' ] ); $this->_connection = $installer->getConnection(); diff --git a/dev/tests/integration/testsuite/Magento/Core/Model/Resource/HelperTest.php b/dev/tests/integration/testsuite/Magento/Framework/DB/HelperTest.php similarity index 97% rename from dev/tests/integration/testsuite/Magento/Core/Model/Resource/HelperTest.php rename to dev/tests/integration/testsuite/Magento/Framework/DB/HelperTest.php index 4cdb588557727e2f3dbcbbb04cab0d11346f117e..ee8a44e4644de8816b8e8ea63d6d612489866300 100644 --- a/dev/tests/integration/testsuite/Magento/Core/Model/Resource/HelperTest.php +++ b/dev/tests/integration/testsuite/Magento/Framework/DB/HelperTest.php @@ -3,7 +3,7 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Core\Model\Resource; +namespace Magento\Framework\DB; class HelperTest extends \PHPUnit_Framework_TestCase { diff --git a/dev/tests/integration/testsuite/Magento/Framework/Exception/NoSuchEntityExceptionTest.php b/dev/tests/integration/testsuite/Magento/Framework/Exception/NoSuchEntityExceptionTest.php index 42efc53e951d63232c43c516ea71d7b46276e437..b8da32743aefd80f8fd99d61bb68103067517fa2 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Exception/NoSuchEntityExceptionTest.php +++ b/dev/tests/integration/testsuite/Magento/Framework/Exception/NoSuchEntityExceptionTest.php @@ -5,6 +5,8 @@ */ namespace Magento\Framework\Exception; +use Magento\Framework\Phrase; + class NoSuchEntityExceptionTest extends \PHPUnit_Framework_TestCase { public function testConstructor() @@ -15,21 +17,25 @@ class NoSuchEntityExceptionTest extends \PHPUnit_Framework_TestCase $this->assertEquals('No such entity.', $exception->getLogMessage()); $exception = new NoSuchEntityException( - NoSuchEntityException::MESSAGE_SINGLE_FIELD, - ['fieldName' => 'field', 'fieldValue' => 'value'] + new Phrase( + NoSuchEntityException::MESSAGE_SINGLE_FIELD, + ['fieldName' => 'field', 'fieldValue' => 'value'] + ) ); $this->assertEquals('No such entity with field = value', $exception->getMessage()); $this->assertEquals(NoSuchEntityException::MESSAGE_SINGLE_FIELD, $exception->getRawMessage()); $this->assertEquals('No such entity with field = value', $exception->getLogMessage()); $exception = new NoSuchEntityException( - NoSuchEntityException::MESSAGE_DOUBLE_FIELDS, - [ - 'fieldName' => 'field1', - 'fieldValue' => 'value1', - 'field2Name' => 'field2', - 'field2Value' => 'value2' - ] + new Phrase( + NoSuchEntityException::MESSAGE_DOUBLE_FIELDS, + [ + 'fieldName' => 'field1', + 'fieldValue' => 'value1', + 'field2Name' => 'field2', + 'field2Value' => 'value2' + ] + ) ); $this->assertEquals( NoSuchEntityException::MESSAGE_DOUBLE_FIELDS, diff --git a/dev/tests/integration/testsuite/Magento/Framework/Image/Adapter/InterfaceTest.php b/dev/tests/integration/testsuite/Magento/Framework/Image/Adapter/InterfaceTest.php index b1440adba626ebfd24344841aecbc544780ea734..248c90684a529a95cba9717392663360e6ed2a5f 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Image/Adapter/InterfaceTest.php +++ b/dev/tests/integration/testsuite/Magento/Framework/Image/Adapter/InterfaceTest.php @@ -7,6 +7,9 @@ namespace Magento\Framework\Image\Adapter; use Magento\Framework\App\Filesystem\DirectoryList; +/** + * @magentoAppIsolation enabled + */ class InterfaceTest extends \PHPUnit_Framework_TestCase { /** @@ -107,6 +110,7 @@ class InterfaceTest extends \PHPUnit_Framework_TestCase * Mark test as skipped if not * * @param string $adapterType + * @return \Magento\Framework\Image\Adapter\AdapterInterface */ protected function _getAdapter($adapterType) { @@ -319,7 +323,7 @@ class InterfaceTest extends \PHPUnit_Framework_TestCase $pixel['y'] -= $center['y']; return [ 'x' => round($size[0] / 2 + $pixel['x'] * cos($angle) + $pixel['y'] * sin($angle), 0), - 'y' => round($size[1] / 2 + $pixel['y'] * cos($angle) - $pixel['x'] * sin($angle), 0) + 'y' => round($size[1] / 2 + $pixel['y'] * cos($angle) - $pixel['x'] * sin($angle), 0), ]; } diff --git a/dev/tests/integration/testsuite/Magento/Framework/Session/ConfigTest.php b/dev/tests/integration/testsuite/Magento/Framework/Session/ConfigTest.php index 68a1a23fec84a94e7e220cf1961af26459de37cc..9962b27826a785f1a29388d735b8e67bc5497757 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Session/ConfigTest.php +++ b/dev/tests/integration/testsuite/Magento/Framework/Session/ConfigTest.php @@ -210,11 +210,10 @@ class ConfigTest extends \PHPUnit_Framework_TestCase $this->assertSame((bool)ini_get('session.cookie_secure'), $this->_model->getCookieSecure()); } - public function testCookieSecureIsMutable() + public function testSetCookieSecureInOptions() { - $value = ini_get('session.cookie_secure') ? false : true; - $this->_model->setCookieSecure($value); - $this->assertEquals($value, $this->_model->getCookieSecure()); + $this->_model->setCookieSecure(true); + $this->assertTrue($this->_model->getCookieSecure()); } public function testCookieDomainIsMutable() @@ -243,11 +242,10 @@ class ConfigTest extends \PHPUnit_Framework_TestCase $this->assertEquals($preVal, $this->_model->getCookieDomain()); } - public function testCookieHttpOnlyIsMutable() + public function testSetCookieHttpOnlyInOptions() { - $value = ini_get('session.cookie_httponly') ? false : true; - $this->_model->setCookieHttpOnly($value); - $this->assertEquals($value, $this->_model->getCookieHttpOnly()); + $this->_model->setCookieHttpOnly(true); + $this->assertTrue($this->_model->getCookieHttpOnly()); } public function testUseCookiesDefaultsToIniSettings() @@ -255,11 +253,10 @@ class ConfigTest extends \PHPUnit_Framework_TestCase $this->assertSame((bool)ini_get('session.use_cookies'), $this->_model->getUseCookies()); } - public function testUseCookiesIsMutable() + public function testSetUseCookiesInOptions() { - $value = ini_get('session.use_cookies') ? false : true; - $this->_model->setUseCookies($value); - $this->assertEquals($value, (bool)$this->_model->getUseCookies()); + $this->_model->setUseCookies(true); + $this->assertTrue($this->_model->getUseCookies()); } public function testUseOnlyCookiesDefaultsToIniSettings() @@ -267,11 +264,10 @@ class ConfigTest extends \PHPUnit_Framework_TestCase $this->assertSame((bool)ini_get('session.use_only_cookies'), $this->_model->getUseOnlyCookies()); } - public function testUseOnlyCookiesIsMutable() + public function testSetUseOnlyCookiesInOptions() { - $value = ini_get('session.use_only_cookies') ? false : true; - $this->_model->setOption('use_only_cookies', $value); - $this->assertEquals($value, (bool)$this->_model->getOption('use_only_cookies')); + $this->_model->setOption('use_only_cookies', true); + $this->assertTrue((bool)$this->_model->getOption('use_only_cookies')); } public function testRefererCheckDefaultsToIniSettings() diff --git a/dev/tests/integration/testsuite/Magento/Framework/Session/SaveHandler/DbTableTest.php b/dev/tests/integration/testsuite/Magento/Framework/Session/SaveHandler/DbTableTest.php index d1edb2e3599d44b28e9984b7b1ee0265dd978ef4..12dbfcb466dd269a9cff5b572ad706d21704a9b8 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Session/SaveHandler/DbTableTest.php +++ b/dev/tests/integration/testsuite/Magento/Framework/Session/SaveHandler/DbTableTest.php @@ -83,7 +83,7 @@ class DbTableTest extends \PHPUnit_Framework_TestCase /** @var $resource \Magento\Framework\App\Resource */ $resource = $this->_objectManager->get('Magento\Framework\App\Resource'); $this->_connection = $resource->getConnection('core_write'); - $this->_sessionTable = $resource->getTableName('core_session'); + $this->_sessionTable = $resource->getTableName('session'); // session stores serialized objects with protected properties // we need to test this case to ensure that DB adapter successfully processes "\0" symbols in serialized data diff --git a/dev/tests/integration/testsuite/Magento/Framework/Translate/_files/_translation_data.php b/dev/tests/integration/testsuite/Magento/Framework/Translate/_files/_translation_data.php index 002e59c5aa2e3a96abf8d250df92ec30ce5b5f8f..2fc1a5ff1eddb8863e2c2b3039bc40721710219f 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Translate/_files/_translation_data.php +++ b/dev/tests/integration/testsuite/Magento/Framework/Translate/_files/_translation_data.php @@ -5,8 +5,8 @@ */ ?> <?php return [ - 'Original value for Magento_Core module' => 'Translated value for Magento_Core module', - 'Magento_Core::Text with different translation on different modules' => 'Text translation by Magento_Core module', + 'Original value for Magento_Store module' => 'Translated value for Magento_Store module', + 'Magento_Store::Text with different translation on different modules' => 'Text translation by Magento_Store module', 'Some non-translated value for Magento_Catalog' => 'Translation for some value for Magento_Catalog', 'Another non-translated value for Magento_Catalog' => 'Translation for another value for Magento_Catalog', 'Magento_Catalog::Text with different translation on different modules' => diff --git a/dev/tests/integration/testsuite/Magento/Framework/TranslateCachingTest.php b/dev/tests/integration/testsuite/Magento/Framework/TranslateCachingTest.php index 713a8c76c0218a74da3c4ca61bfd92c46f59adce..214e3f39423b5ef98a51aa387b62a5dc453315d2 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/TranslateCachingTest.php +++ b/dev/tests/integration/testsuite/Magento/Framework/TranslateCachingTest.php @@ -27,15 +27,23 @@ class TranslateCachingTest extends \PHPUnit_Framework_TestCase $model = $objectManager->get('Magento\Framework\Translate'); $model->loadData(\Magento\Framework\App\Area::AREA_FRONTEND); // this is supposed to cache the fixture - $this->assertEquals('Fixture Db Translation', __('Fixture String')); + $this->assertEquals('Fixture Db Translation', new \Magento\Framework\Phrase('Fixture String')); /** @var \Magento\Translation\Model\Resource\String $translateString */ $translateString = $objectManager->create('Magento\Translation\Model\Resource\String'); $translateString->saveTranslate('Fixture String', 'New Db Translation'); - $this->assertEquals('Fixture Db Translation', __('Fixture String'), 'Translation is expected to be cached'); + $this->assertEquals( + 'Fixture Db Translation', + new \Magento\Framework\Phrase('Fixture String'), + 'Translation is expected to be cached' + ); $model->loadData(\Magento\Framework\App\Area::AREA_FRONTEND, true); - $this->assertEquals('New Db Translation', __('Fixture String'), 'Forced load should not use cache'); + $this->assertEquals( + 'New Db Translation', + new \Magento\Framework\Phrase('Fixture String'), + 'Forced load should not use cache' + ); } } diff --git a/dev/tests/integration/testsuite/Magento/Framework/TranslateTest.php b/dev/tests/integration/testsuite/Magento/Framework/TranslateTest.php index 44d7f7ab3c101a65c1a98ba1f62fbf30d126d5d9..4be86c6a992e4f5e48542d9741618411c8bf925d 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/TranslateTest.php +++ b/dev/tests/integration/testsuite/Magento/Framework/TranslateTest.php @@ -40,11 +40,15 @@ class TranslateTest extends \PHPUnit_Framework_TestCase /** @var $moduleReader \Magento\Framework\Module\Dir\Reader */ $moduleReader = $objectManager->get('Magento\Framework\Module\Dir\Reader'); - $moduleReader->setModuleDir('Magento_Core', 'i18n', dirname(__DIR__) . '/Core/Model/_files/Magento/Core/i18n'); + $moduleReader->setModuleDir( + 'Magento_Store', + 'i18n', + dirname(__DIR__) . '/Translation/Model/_files/Magento/Store/i18n' + ); $moduleReader->setModuleDir( 'Magento_Catalog', 'i18n', - dirname(__DIR__) . '/Core/Model/_files/Magento/Catalog/i18n' + dirname(__DIR__) . '/Translation/Model/_files/Magento/Catalog/i18n' ); /** @var \Magento\Theme\Model\View\Design $designModel */ @@ -79,7 +83,7 @@ class TranslateTest extends \PHPUnit_Framework_TestCase */ public function testTranslate($inputText, $expectedTranslation) { - $actualTranslation = __($inputText); + $actualTranslation = new \Magento\Framework\Phrase($inputText); $this->assertEquals($expectedTranslation, $actualTranslation); } diff --git a/dev/tests/integration/testsuite/Magento/Framework/Validator/FactoryTest.php b/dev/tests/integration/testsuite/Magento/Framework/Validator/FactoryTest.php index 2a25d44f2b656b0d6a08d07b1404b11b1557c224..6b292a49281e8830ef1e4e62f520d1489d76c474 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Validator/FactoryTest.php +++ b/dev/tests/integration/testsuite/Magento/Framework/Validator/FactoryTest.php @@ -23,11 +23,11 @@ class FactoryTest extends \PHPUnit_Framework_TestCase // Check that default translator was set $translator = \Magento\Framework\Validator\AbstractValidator::getDefaultTranslator(); $this->assertInstanceOf('Magento\Framework\Translate\AdapterInterface', $translator); - $this->assertEquals('Message', __('Message')); + $this->assertEquals('Message', new \Magento\Framework\Phrase('Message')); $this->assertEquals('Message', $translator->translate('Message')); $this->assertEquals( 'Message with "placeholder one" and "placeholder two"', - (string)__('Message with "%1" and "%2"', 'placeholder one', 'placeholder two') + (string)new \Magento\Framework\Phrase('Message with "%1" and "%2"', ['placeholder one', 'placeholder two']) ); } } diff --git a/dev/tests/integration/testsuite/Magento/Framework/View/Element/AbstractBlockTest.php b/dev/tests/integration/testsuite/Magento/Framework/View/Element/AbstractBlockTest.php index 569cd212239ee78cf3ddb8cf4f0d9c82ee79e5aa..ead4f55b11bab71d455fc6000f9158d7f8bc2ddb 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/View/Element/AbstractBlockTest.php +++ b/dev/tests/integration/testsuite/Magento/Framework/View/Element/AbstractBlockTest.php @@ -35,7 +35,7 @@ class AbstractBlockTest extends \PHPUnit_Framework_TestCase \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( 'Magento\Framework\View\Element\Context' ), - ['module_name' => 'Magento_Core'] + ['module_name' => 'Magento_Theme'] ] ); } @@ -391,7 +391,7 @@ class AbstractBlockTest extends \PHPUnit_Framework_TestCase /** * @magentoAppIsolation enabled - * @expectedException \Magento\Framework\Exception + * @expectedException \OutOfBoundsException */ public function testInsertWithoutCreateBlock() { @@ -483,8 +483,8 @@ class AbstractBlockTest extends \PHPUnit_Framework_TestCase public function testGetModuleName() { - $this->assertEquals('Magento_Core', $this->_block->getModuleName()); - $this->assertEquals('Magento_Core', $this->_block->getData('module_name')); + $this->assertEquals('Magento_Theme', $this->_block->getModuleName()); + $this->assertEquals('Magento_Theme', $this->_block->getData('module_name')); } /** @@ -619,7 +619,7 @@ class AbstractBlockTest extends \PHPUnit_Framework_TestCase \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( 'Magento\Framework\View\Element\Context' ), - ['module_name' => 'Magento_Core'] + ['module_name' => 'Magento_Theme'] ], $mockClass ); diff --git a/dev/tests/integration/testsuite/Magento/Framework/View/Layout/Reader/BlockTest.php b/dev/tests/integration/testsuite/Magento/Framework/View/Layout/Reader/BlockTest.php index 6df823cf87be89fbe8ce929fc99b91eafaa09954..4dde9773e60fba23c54046012b38a02ebcc2cb6c 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/View/Layout/Reader/BlockTest.php +++ b/dev/tests/integration/testsuite/Magento/Framework/View/Layout/Reader/BlockTest.php @@ -43,7 +43,9 @@ class BlockTest extends \PHPUnit_Framework_TestCase public function testInterpretBlockDirective() { $pageXml = new \Magento\Framework\View\Layout\Element( - __DIR__ . '/_files/_layout_update_block.xml', 0, true + __DIR__ . '/_files/_layout_update_block.xml', + 0, + true ); $parentElement = new \Magento\Framework\View\Layout\Element('<page></page>'); @@ -71,13 +73,12 @@ class BlockTest extends \PHPUnit_Framework_TestCase $this->assertEquals($this->blockName, $structure->getStructure()[$this->childBlockName][self::IDX_PARENT]); } - /** - * @depends testInterpretBlockDirective - */ public function testInterpretReferenceBlockDirective() { $pageXml = new \Magento\Framework\View\Layout\Element( - __DIR__ . '/_files/_layout_update_reference.xml', 0, true + __DIR__ . '/_files/_layout_update_reference.xml', + 0, + true ); $parentElement = new \Magento\Framework\View\Layout\Element('<page></page>'); diff --git a/dev/tests/integration/testsuite/Magento/Framework/View/LayoutDirectivesTest.php b/dev/tests/integration/testsuite/Magento/Framework/View/LayoutDirectivesTest.php index 6caf19e5e232514f1dcf7255da1ea5a4bb211f06..11c917fba00ba2ee5d7573949f9acfc64f289e2c 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/View/LayoutDirectivesTest.php +++ b/dev/tests/integration/testsuite/Magento/Framework/View/LayoutDirectivesTest.php @@ -224,7 +224,7 @@ class LayoutDirectivesTest extends \PHPUnit_Framework_TestCase } /** - * @expectedException \Magento\Framework\Exception + * @expectedException \OutOfBoundsException */ public function testRemoveBroken() { diff --git a/dev/tests/integration/testsuite/Magento/Framework/View/_files/layout_directives_test/arguments_object_type_updaters.xml b/dev/tests/integration/testsuite/Magento/Framework/View/_files/layout_directives_test/arguments_object_type_updaters.xml index b98084ad88f5ff7b1ba15141e58e7cb75efbd25e..f713bfb8bbfada6a5ead86f955e09bd99196eafb 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/View/_files/layout_directives_test/arguments_object_type_updaters.xml +++ b/dev/tests/integration/testsuite/Magento/Framework/View/_files/layout_directives_test/arguments_object_type_updaters.xml @@ -8,7 +8,7 @@ <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_layout.xsd"> <block class="Magento\Framework\View\Element\Text" name="block_with_object_updater_args"> <arguments> - <argument xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="one" xsi:type="object">Magento\Core\Model\DataSource</argument> + <argument xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="one" xsi:type="object">Magento\Store\Model\DataSource</argument> <argument xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="two" xsi:type="number">0</argument> </arguments> </block> diff --git a/dev/tests/integration/testsuite/Magento/MemoryUsageTest.php b/dev/tests/integration/testsuite/Magento/MemoryUsageTest.php index 2a391f73699dac69a704b6773606ff61175da86f..96ea9e4516f60f0b3cbf7a26b20a3d67235ee5d4 100644 --- a/dev/tests/integration/testsuite/Magento/MemoryUsageTest.php +++ b/dev/tests/integration/testsuite/Magento/MemoryUsageTest.php @@ -19,6 +19,9 @@ class MemoryUsageTest extends \PHPUnit_Framework_TestCase protected function setUp() { + if (defined('HHVM_VERSION')) { + $this->markTestSkipped("For HHVM it's not relevant while MAGETWO-33679 is not resolved"); + } $this->_helper = new \Magento\TestFramework\Helper\Memory( new \Magento\Framework\Shell(new \Magento\Framework\Shell\CommandRenderer()) ); diff --git a/dev/tests/integration/testsuite/Magento/Newsletter/Model/TemplateTest.php b/dev/tests/integration/testsuite/Magento/Newsletter/Model/TemplateTest.php index 8eadd1a288a00ca7b217547c55c3fd42b0c9006c..d501af84c4c26266dff6331a627d6ab1aad6dd30 100644 --- a/dev/tests/integration/testsuite/Magento/Newsletter/Model/TemplateTest.php +++ b/dev/tests/integration/testsuite/Magento/Newsletter/Model/TemplateTest.php @@ -6,7 +6,7 @@ namespace Magento\Newsletter\Model; /** - * @magentoDataFixture Magento/Core/_files/store.php + * @magentoDataFixture Magento/Store/_files/core_fixturestore.php */ class TemplateTest extends \PHPUnit_Framework_TestCase { diff --git a/dev/tests/integration/testsuite/Magento/Newsletter/_files/subscribers.php b/dev/tests/integration/testsuite/Magento/Newsletter/_files/subscribers.php index fe3cc067ec3e18690865de39ee50aaf7c9e90988..470db3b9ad92d926c1f1f75b72446c3bc63cc1f3 100644 --- a/dev/tests/integration/testsuite/Magento/Newsletter/_files/subscribers.php +++ b/dev/tests/integration/testsuite/Magento/Newsletter/_files/subscribers.php @@ -4,7 +4,7 @@ * See COPYING.txt for license details. */ -require __DIR__ . '/../../../Magento/Core/_files/store.php'; +require __DIR__ . '/../../../Magento/Store/_files/core_fixturestore.php'; require __DIR__ . '/../../../Magento/Customer/_files/customer.php'; $currentStore = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( diff --git a/dev/tests/integration/testsuite/Magento/ProductAlert/Model/EmailTest.php b/dev/tests/integration/testsuite/Magento/ProductAlert/Model/EmailTest.php index f0d383549ac913e94928aa365da58946c2f0195b..985b0fd9bad9c0594b81362d179b0c7997a835c6 100644 --- a/dev/tests/integration/testsuite/Magento/ProductAlert/Model/EmailTest.php +++ b/dev/tests/integration/testsuite/Magento/ProductAlert/Model/EmailTest.php @@ -6,6 +6,9 @@ namespace Magento\ProductAlert\Model; +/** + * @magentoAppIsolation enabled + */ class EmailTest extends \PHPUnit_Framework_TestCase { /** diff --git a/dev/tests/integration/testsuite/Magento/ProductAlert/Model/ObserverTest.php b/dev/tests/integration/testsuite/Magento/ProductAlert/Model/ObserverTest.php index cc314c331967cfc805c86ba53d785003edd4835c..10b2024b303668c00168d2f466bd8cb123714801 100644 --- a/dev/tests/integration/testsuite/Magento/ProductAlert/Model/ObserverTest.php +++ b/dev/tests/integration/testsuite/Magento/ProductAlert/Model/ObserverTest.php @@ -5,6 +5,9 @@ */ namespace Magento\ProductAlert\Model; +/** + * @magentoAppIsolation enabled + */ class ObserverTest extends \PHPUnit_Framework_TestCase { /** diff --git a/dev/tests/integration/testsuite/Magento/Sales/_files/order_fixture_store.php b/dev/tests/integration/testsuite/Magento/Sales/_files/order_fixture_store.php index 6bbd0430c0bfc3f3a637465ea1aa9d5b30ea0d55..4d4c2d92a90b08fd8d132090fde771ca1d8a5261 100644 --- a/dev/tests/integration/testsuite/Magento/Sales/_files/order_fixture_store.php +++ b/dev/tests/integration/testsuite/Magento/Sales/_files/order_fixture_store.php @@ -6,7 +6,7 @@ // @codingStandardsIgnoreFile -require __DIR__ . '/../../../Magento/Core/_files/store.php'; +require __DIR__ . '/../../../Magento/Store/_files/core_fixturestore.php'; require __DIR__ . '/../../../Magento/Catalog/_files/product_simple_duplicated.php'; /** @var \Magento\Catalog\Model\Product $product */ diff --git a/dev/tests/integration/testsuite/Magento/Core/Model/DataSource.php b/dev/tests/integration/testsuite/Magento/Store/Model/DataSource.php similarity index 89% rename from dev/tests/integration/testsuite/Magento/Core/Model/DataSource.php rename to dev/tests/integration/testsuite/Magento/Store/Model/DataSource.php index 8daa1aa1cdc27b0c33d1e0ea30182300f63a5cc1..4b9dcd8c763a8e2fea99630e4e31ca9b85861e9d 100644 --- a/dev/tests/integration/testsuite/Magento/Core/Model/DataSource.php +++ b/dev/tests/integration/testsuite/Magento/Store/Model/DataSource.php @@ -3,7 +3,7 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Core\Model; +namespace Magento\Store\Model; /** * Dummy layout argument data source object @@ -31,7 +31,7 @@ class DataSource extends \Magento\Framework\Data\Collection * Set updater calls * * @param array $calls - * @return \Magento\Core\Model\DataSource + * @return \Magento\Store\Model\DataSource */ public function setUpdaterCall(array $calls) { diff --git a/dev/tests/integration/testsuite/Magento/Core/_files/store.php b/dev/tests/integration/testsuite/Magento/Store/_files/core_fixturestore.php similarity index 100% rename from dev/tests/integration/testsuite/Magento/Core/_files/store.php rename to dev/tests/integration/testsuite/Magento/Store/_files/core_fixturestore.php diff --git a/dev/tests/integration/testsuite/Magento/Core/_files/second_third_store.php b/dev/tests/integration/testsuite/Magento/Store/_files/core_second_third_fixturestore.php similarity index 100% rename from dev/tests/integration/testsuite/Magento/Core/_files/second_third_store.php rename to dev/tests/integration/testsuite/Magento/Store/_files/core_second_third_fixturestore.php diff --git a/dev/tests/integration/testsuite/Magento/Tax/Model/TaxCalculationTest.php b/dev/tests/integration/testsuite/Magento/Tax/Model/TaxCalculationTest.php index 76d788a77dd462d2f5b735671de16eedc46a3b0a..0c3af306bdeaa8f70d4a0b9e3e0d4bda252693e1 100644 --- a/dev/tests/integration/testsuite/Magento/Tax/Model/TaxCalculationTest.php +++ b/dev/tests/integration/testsuite/Magento/Tax/Model/TaxCalculationTest.php @@ -1951,12 +1951,18 @@ class TaxCalculationTest extends \PHPUnit_Framework_TestCase * * This utility function is used to simplify expected result verification. * - * @param AbstractExtensibleModel $object + * @param \Magento\Framework\Object $object * @return array */ - private function convertObjectToArray(AbstractExtensibleModel $object) + private function convertObjectToArray($object) { - $data = $object->getData(); + if ($object instanceof \Magento\Framework\Object) { + $data = $object->getData(); + } else if (is_object($object)) { + $data = (array)$object; + } else { + throw new \InvalidArgumentException("Provided argument is not an object."); + } foreach ($data as $key => $value) { if (is_object($value)) { $data[$key] = $this->convertObjectToArray($value); diff --git a/dev/tests/integration/testsuite/Magento/Test/Tools/Dependency/Parser/Composer/JsonTest.php b/dev/tests/integration/testsuite/Magento/Test/Tools/Dependency/Parser/Composer/JsonTest.php index 9a5cfc24ba9a3af8ee7be4996398de7291ed8b85..684c24f7b933bf7999ce97c835b851d8140e98a4 100644 --- a/dev/tests/integration/testsuite/Magento/Test/Tools/Dependency/Parser/Composer/JsonTest.php +++ b/dev/tests/integration/testsuite/Magento/Test/Tools/Dependency/Parser/Composer/JsonTest.php @@ -32,7 +32,6 @@ class JsonTest extends \PHPUnit_Framework_TestCase [ 'name' => 'magento/module-module1', 'dependencies' => [ - ['module' => 'magento/module-core', 'type' => 'hard'], ['module' => 'magento/module-module2', 'type' => 'hard'], ['module' => 'magento/module-backend', 'type' => 'soft'], ], @@ -40,7 +39,6 @@ class JsonTest extends \PHPUnit_Framework_TestCase [ 'name' => 'magento/module-module2', 'dependencies' => [ - ['module' => 'magento/module-core', 'type' => 'hard'], ['module' => 'magento/module-module3', 'type' => 'hard'], ] ], diff --git a/dev/tests/integration/testsuite/Magento/Test/Tools/Dependency/_files/composer1.json b/dev/tests/integration/testsuite/Magento/Test/Tools/Dependency/_files/composer1.json index aa86499218364dd7e01ff62d8f33c9951ad10deb..14b92acc4f7ac59ba502c7da3d92c7d2c98b4997 100644 --- a/dev/tests/integration/testsuite/Magento/Test/Tools/Dependency/_files/composer1.json +++ b/dev/tests/integration/testsuite/Magento/Test/Tools/Dependency/_files/composer1.json @@ -3,7 +3,6 @@ "description": "N/A", "require": { "php": "~5.5.0|~5.6.0", - "magento/module-core": "0.1.0-alpha103", "magento/module-module2": "0.1.0-alpha103" }, "suggest": { diff --git a/dev/tests/integration/testsuite/Magento/Test/Tools/Dependency/_files/composer2.json b/dev/tests/integration/testsuite/Magento/Test/Tools/Dependency/_files/composer2.json index ee1f92ce06fdb65ceadaba97380a02370970ac80..ba14f37abc9f2fc85fd3bac276745c96c9ef4cef 100644 --- a/dev/tests/integration/testsuite/Magento/Test/Tools/Dependency/_files/composer2.json +++ b/dev/tests/integration/testsuite/Magento/Test/Tools/Dependency/_files/composer2.json @@ -3,7 +3,6 @@ "description": "N/A", "require": { "php": "~5.5.0|~5.6.0", - "magento/module-core": "0.1.0-alpha103", "magento/module-module3": "0.1.0-alpha103" }, "type": "magento2-module", diff --git a/dev/tests/integration/testsuite/Magento/Test/Tools/Dependency/_files/composer4.json b/dev/tests/integration/testsuite/Magento/Test/Tools/Dependency/_files/composer4.json index 7d6f1156608810b2570475de76a28ad49cdecf97..3f6b5173c8b4ea7fdd131bfa634f408b1d47b9fb 100644 --- a/dev/tests/integration/testsuite/Magento/Test/Tools/Dependency/_files/composer4.json +++ b/dev/tests/integration/testsuite/Magento/Test/Tools/Dependency/_files/composer4.json @@ -3,7 +3,6 @@ "description": "N/A", "require": { "php": "~5.5.0|~5.6.0", - "magento/module-core": "0.1.0-alpha103", "magento/module-module2": "0.1.0-alpha103" }, "type": "magento2-module", diff --git a/dev/tests/integration/testsuite/Magento/Test/Tools/Dependency/_files/composer5.json b/dev/tests/integration/testsuite/Magento/Test/Tools/Dependency/_files/composer5.json index 39685bcd994940866add3ad1d420483683a5a769..cb9d044436befb0593a3f8e2c98e9d8c3c5dace4 100644 --- a/dev/tests/integration/testsuite/Magento/Test/Tools/Dependency/_files/composer5.json +++ b/dev/tests/integration/testsuite/Magento/Test/Tools/Dependency/_files/composer5.json @@ -3,7 +3,6 @@ "description": "N/A", "require": { "php": "~5.5.0|~5.6.0", - "magento/module-core": "0.1.0-alpha103", "magento/module-module1": "0.1.0-alpha103" }, "type": "magento2-module", diff --git a/dev/tests/integration/testsuite/Magento/Test/Tools/Dependency/_files/expected/dependencies.csv b/dev/tests/integration/testsuite/Magento/Test/Tools/Dependency/_files/expected/dependencies.csv index afdc023ce7ecb1e3f47ae390846aa1f7df678a9d..bce8d9c13d29ac3ac3e983a635069e2170a3d6bf 100644 --- a/dev/tests/integration/testsuite/Magento/Test/Tools/Dependency/_files/expected/dependencies.csv +++ b/dev/tests/integration/testsuite/Magento/Test/Tools/Dependency/_files/expected/dependencies.csv @@ -1,12 +1,10 @@ "";"All";"Hard";"Soft" -"Total number of dependencies";"5";"4";"1" +"Total number of dependencies";"3";"2";"1" "Dependencies for each module:";"All";"Hard";"Soft" -"magento/module-module1";"3";"2";"1" -" -- magento/module-core";"";"1";"0" +"magento/module-module1";"2";"1";"1" " -- magento/module-module2";"";"1";"0" " -- magento/module-backend";"";"0";"1" -"magento/module-module2";"2";"2";"0" -" -- magento/module-core";"";"1";"0" +"magento/module-module2";"1";"1";"0" " -- magento/module-module3";"";"1";"0" diff --git a/dev/tests/integration/testsuite/Magento/Theme/Model/View/DesignTest.php b/dev/tests/integration/testsuite/Magento/Theme/Model/View/DesignTest.php index 2fe398ded09e7e0de078b09ffbb481f0f927fd22..4eec44f4a23449fd83b217e2dcd5f3b8470895de 100644 --- a/dev/tests/integration/testsuite/Magento/Theme/Model/View/DesignTest.php +++ b/dev/tests/integration/testsuite/Magento/Theme/Model/View/DesignTest.php @@ -126,7 +126,7 @@ class DesignTest extends \PHPUnit_Framework_TestCase /** * @magentoConfigFixture current_store design/theme/theme_id one * @magentoConfigFixture fixturestore_store design/theme/theme_id two - * @magentoDataFixture Magento/Core/_files/store.php + * @magentoDataFixture Magento/Store/_files/core_fixturestore.php */ public function testGetConfigurationDesignThemeStore() { diff --git a/dev/tests/integration/testsuite/Magento/Theme/Model/_files/design/frontend/Test/default/etc/view.xml b/dev/tests/integration/testsuite/Magento/Theme/Model/_files/design/frontend/Test/default/etc/view.xml index bbc87835a04fd3ce6965ee5f3ce05ba0b006375c..61d0514d8ae95c2aecbffd5df1445d98ab869c70 100644 --- a/dev/tests/integration/testsuite/Magento/Theme/Model/_files/design/frontend/Test/default/etc/view.xml +++ b/dev/tests/integration/testsuite/Magento/Theme/Model/_files/design/frontend/Test/default/etc/view.xml @@ -6,8 +6,8 @@ */ --> <view xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../../../../../lib/internal/Magento/Framework/Config/etc/view.xsd"> - <vars module="Magento_Core"> - <var name="var1">Core Value1</var> + <vars module="Magento_Store"> + <var name="var1">Store Value1</var> </vars> <vars module="Namespace_Module"> <var name="var1">value1</var> diff --git a/dev/tests/integration/testsuite/Magento/Core/Model/_files/Magento/Catalog/i18n/en_US.csv b/dev/tests/integration/testsuite/Magento/Translation/Model/_files/Magento/Catalog/i18n/en_US.csv similarity index 100% rename from dev/tests/integration/testsuite/Magento/Core/Model/_files/Magento/Catalog/i18n/en_US.csv rename to dev/tests/integration/testsuite/Magento/Translation/Model/_files/Magento/Catalog/i18n/en_US.csv diff --git a/dev/tests/integration/testsuite/Magento/Translation/Model/_files/Magento/Store/i18n/en_AU.csv b/dev/tests/integration/testsuite/Magento/Translation/Model/_files/Magento/Store/i18n/en_AU.csv new file mode 100644 index 0000000000000000000000000000000000000000..6a8d6d9f0ef953317d8b2a0cd6527e0a995fb97f --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Translation/Model/_files/Magento/Store/i18n/en_AU.csv @@ -0,0 +1 @@ +"Original value for Magento_Store module","Translated value for Magento_Store module in en_AU" diff --git a/dev/tests/integration/testsuite/Magento/Core/Model/_files/Magento/Core/i18n/en_UK.csv b/dev/tests/integration/testsuite/Magento/Translation/Model/_files/Magento/Store/i18n/en_UK.csv similarity index 59% rename from dev/tests/integration/testsuite/Magento/Core/Model/_files/Magento/Core/i18n/en_UK.csv rename to dev/tests/integration/testsuite/Magento/Translation/Model/_files/Magento/Store/i18n/en_UK.csv index 49355d289e411b75539bbb275addbc770672e169..94f7f1ba263a29cc5907b327a421faccc6fefd56 100644 --- a/dev/tests/integration/testsuite/Magento/Core/Model/_files/Magento/Core/i18n/en_UK.csv +++ b/dev/tests/integration/testsuite/Magento/Translation/Model/_files/Magento/Store/i18n/en_UK.csv @@ -1 +1 @@ -"Text with different translation on different modules","Text translation by Magento_Core module in en_UK" +"Text with different translation on different modules","Text translation by Magento_Store module in en_UK" diff --git a/dev/tests/integration/testsuite/Magento/Core/Model/_files/Magento/Core/i18n/en_US.csv b/dev/tests/integration/testsuite/Magento/Translation/Model/_files/Magento/Store/i18n/en_US.csv similarity index 54% rename from dev/tests/integration/testsuite/Magento/Core/Model/_files/Magento/Core/i18n/en_US.csv rename to dev/tests/integration/testsuite/Magento/Translation/Model/_files/Magento/Store/i18n/en_US.csv index a1e746bfeb758850e05e321110c4ef911d67025c..2ccaf17120470b3369ff0e6c6fe9c28acda7b0c2 100644 --- a/dev/tests/integration/testsuite/Magento/Core/Model/_files/Magento/Core/i18n/en_US.csv +++ b/dev/tests/integration/testsuite/Magento/Translation/Model/_files/Magento/Store/i18n/en_US.csv @@ -1,3 +1,3 @@ "%s","%s" -"Original value for Magento_Core module","Translated value for Magento_Core module" +"Original value for Magento_Store module","Translated value for Magento_Store module" "Text with different translation on different modules","Text translation that was last loaded" diff --git a/dev/tests/integration/testsuite/Magento/Core/Model/_files/local_config/local_config/custom/local.xml b/dev/tests/integration/testsuite/Magento/Translation/Model/_files/local_config/local_config/custom/local.xml similarity index 100% rename from dev/tests/integration/testsuite/Magento/Core/Model/_files/local_config/local_config/custom/local.xml rename to dev/tests/integration/testsuite/Magento/Translation/Model/_files/local_config/local_config/custom/local.xml diff --git a/dev/tests/integration/testsuite/Magento/Core/Model/_files/local_config/local_config/custom/prohibited.filename.xml b/dev/tests/integration/testsuite/Magento/Translation/Model/_files/local_config/local_config/custom/prohibited.filename.xml similarity index 100% rename from dev/tests/integration/testsuite/Magento/Core/Model/_files/local_config/local_config/custom/prohibited.filename.xml rename to dev/tests/integration/testsuite/Magento/Translation/Model/_files/local_config/local_config/custom/prohibited.filename.xml diff --git a/dev/tests/integration/testsuite/Magento/Core/Model/_files/local_config/local_config/local.xml b/dev/tests/integration/testsuite/Magento/Translation/Model/_files/local_config/local_config/local.xml similarity index 100% rename from dev/tests/integration/testsuite/Magento/Core/Model/_files/local_config/local_config/local.xml rename to dev/tests/integration/testsuite/Magento/Translation/Model/_files/local_config/local_config/local.xml diff --git a/dev/tests/integration/testsuite/Magento/Core/Model/_files/local_config/local_config/z.xml b/dev/tests/integration/testsuite/Magento/Translation/Model/_files/local_config/local_config/z.xml similarity index 100% rename from dev/tests/integration/testsuite/Magento/Core/Model/_files/local_config/local_config/z.xml rename to dev/tests/integration/testsuite/Magento/Translation/Model/_files/local_config/local_config/z.xml diff --git a/dev/tests/integration/testsuite/Magento/Core/Model/_files/local_config/no_local_config/a.xml b/dev/tests/integration/testsuite/Magento/Translation/Model/_files/local_config/no_local_config/a.xml similarity index 100% rename from dev/tests/integration/testsuite/Magento/Core/Model/_files/local_config/no_local_config/a.xml rename to dev/tests/integration/testsuite/Magento/Translation/Model/_files/local_config/no_local_config/a.xml diff --git a/dev/tests/integration/testsuite/Magento/Core/Model/_files/local_config/no_local_config/b.xml b/dev/tests/integration/testsuite/Magento/Translation/Model/_files/local_config/no_local_config/b.xml similarity index 100% rename from dev/tests/integration/testsuite/Magento/Core/Model/_files/local_config/no_local_config/b.xml rename to dev/tests/integration/testsuite/Magento/Translation/Model/_files/local_config/no_local_config/b.xml diff --git a/dev/tests/integration/testsuite/Magento/Core/Model/_files/local_config/no_local_config/custom/local.xml b/dev/tests/integration/testsuite/Magento/Translation/Model/_files/local_config/no_local_config/custom/local.xml similarity index 100% rename from dev/tests/integration/testsuite/Magento/Core/Model/_files/local_config/no_local_config/custom/local.xml rename to dev/tests/integration/testsuite/Magento/Translation/Model/_files/local_config/no_local_config/custom/local.xml diff --git a/dev/tests/integration/testsuite/Magento/Core/Model/_files/locale/en_AU/config.xml b/dev/tests/integration/testsuite/Magento/Translation/Model/_files/locale/en_AU/config.xml similarity index 92% rename from dev/tests/integration/testsuite/Magento/Core/Model/_files/locale/en_AU/config.xml rename to dev/tests/integration/testsuite/Magento/Translation/Model/_files/locale/en_AU/config.xml index d8a6cc64835de174524404991954e587c38f1fb5..97d3c799a4ee00613bab6e86f08c9c80d6c69a7f 100644 --- a/dev/tests/integration/testsuite/Magento/Core/Model/_files/locale/en_AU/config.xml +++ b/dev/tests/integration/testsuite/Magento/Translation/Model/_files/locale/en_AU/config.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../../../../app/code/Magento/Core/etc/config.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../../../../app/code/Magento/Store/etc/config.xsd"> <default> <locale> <inheritance> diff --git a/dev/tests/integration/testsuite/Magento/Core/Model/_files/media/some_file.txt b/dev/tests/integration/testsuite/Magento/Translation/Model/_files/media/some_file.txt similarity index 100% rename from dev/tests/integration/testsuite/Magento/Core/Model/_files/media/some_file.txt rename to dev/tests/integration/testsuite/Magento/Translation/Model/_files/media/some_file.txt diff --git a/dev/tests/integration/testsuite/Magento/UrlRewrite/Block/Catalog/Edit/FormTest.php b/dev/tests/integration/testsuite/Magento/UrlRewrite/Block/Catalog/Edit/FormTest.php index a17d3e18b9174680f40178c19876ce7e06707eb0..d4780d259aafb1213be6b66d7b5329f425ebea5a 100644 --- a/dev/tests/integration/testsuite/Magento/UrlRewrite/Block/Catalog/Edit/FormTest.php +++ b/dev/tests/integration/testsuite/Magento/UrlRewrite/Block/Catalog/Edit/FormTest.php @@ -88,7 +88,7 @@ class FormTest extends \PHPUnit_Framework_TestCase * * @dataProvider getEntityStoresDataProvider * @magentoAppIsolation enabled - * @magentoDataFixture Magento/Core/_files/store.php + * @magentoDataFixture Magento/Store/_files/core_fixturestore.php * * @param array $productData * @param array $categoryData @@ -117,7 +117,7 @@ class FormTest extends \PHPUnit_Framework_TestCase * Check exception is thrown when product does not associated with stores * * @magentoAppIsolation enabled - * @magentoDataFixture Magento/Core/_files/store.php + * @magentoDataFixture Magento/Store/_files/core_fixturestore.php */ public function testGetEntityStoresProductStoresException() { @@ -139,7 +139,7 @@ class FormTest extends \PHPUnit_Framework_TestCase * Check exception is thrown when product stores in intersection with category stores is empty * * @magentoAppIsolation enabled - * @magentoDataFixture Magento/Core/_files/store.php + * @magentoDataFixture Magento/Store/_files/core_fixturestore.php * */ public function testGetEntityStoresProductCategoryStoresException() @@ -166,7 +166,7 @@ class FormTest extends \PHPUnit_Framework_TestCase * Check exception is thrown when category does not associated with stores * * @magentoAppIsolation enabled - * @magentoDataFixture Magento/Core/_files/store.php + * @magentoDataFixture Magento/Store/_files/core_fixturestore.php */ public function testGetEntityStoresCategoryStoresException() { diff --git a/dev/tests/integration/testsuite/Magento/UrlRewrite/Block/Cms/Page/Edit/FormTest.php b/dev/tests/integration/testsuite/Magento/UrlRewrite/Block/Cms/Page/Edit/FormTest.php index 8e95b21be5814e048e8696cee33156c0462ec85b..8eb255b89d94b35401db85052a114f4fc2577567 100644 --- a/dev/tests/integration/testsuite/Magento/UrlRewrite/Block/Cms/Page/Edit/FormTest.php +++ b/dev/tests/integration/testsuite/Magento/UrlRewrite/Block/Cms/Page/Edit/FormTest.php @@ -70,7 +70,7 @@ class FormTest extends \PHPUnit_Framework_TestCase * Test entity stores * * @magentoAppIsolation enabled - * @magentoDataFixture Magento/Core/_files/store.php + * @magentoDataFixture Magento/Store/_files/core_fixturestore.php */ public function testGetEntityStores() { @@ -91,7 +91,7 @@ class FormTest extends \PHPUnit_Framework_TestCase * Check exception is thrown when product does not associated with stores * * @magentoAppIsolation enabled - * @magentoDataFixture Magento/Core/_files/store.php + * @magentoDataFixture Magento/Store/_files/core_fixturestore.php */ public function testGetEntityStoresProductStoresException() { diff --git a/dev/tests/integration/testsuite/Magento/UrlRewrite/Block/Cms/Page/GridTest.php b/dev/tests/integration/testsuite/Magento/UrlRewrite/Block/Cms/Page/GridTest.php index cd1827579b22945d145266e0305afa8b43ed59f8..a201e3105ae79dd598267cc054d3b20562e80225 100644 --- a/dev/tests/integration/testsuite/Magento/UrlRewrite/Block/Cms/Page/GridTest.php +++ b/dev/tests/integration/testsuite/Magento/UrlRewrite/Block/Cms/Page/GridTest.php @@ -48,7 +48,7 @@ class GridTest extends \PHPUnit_Framework_TestCase /** * Test prepare grid when there is more than one store * - * @magentoDataFixture Magento/Core/_files/store.php + * @magentoDataFixture Magento/Store/_files/core_fixturestore.php */ public function testPrepareGridForMultipleStores() { diff --git a/dev/tests/integration/testsuite/Magento/UrlRewrite/Block/Edit/FormTest.php b/dev/tests/integration/testsuite/Magento/UrlRewrite/Block/Edit/FormTest.php index 18382c4b69f1ee450254ff283e22e4535c406aeb..570e42dad7dba858baa7751723d99604414b46b6 100644 --- a/dev/tests/integration/testsuite/Magento/UrlRewrite/Block/Edit/FormTest.php +++ b/dev/tests/integration/testsuite/Magento/UrlRewrite/Block/Edit/FormTest.php @@ -116,7 +116,7 @@ class FormTest extends \PHPUnit_Framework_TestCase * Test store selection is available and correctly configured * * @magentoAppIsolation enabled - * @magentoDataFixture Magento/Core/_files/store.php + * @magentoDataFixture Magento/Store/_files/core_fixturestore.php */ public function testStoreElementMultiStores() { diff --git a/dev/tests/integration/testsuite/Magento/Webapi/Controller/PathProcessorTest.php b/dev/tests/integration/testsuite/Magento/Webapi/Controller/PathProcessorTest.php index 268d2274beb25c2963d630b095a290f4af542ce0..f9f6ceda847cd08e413b946714077ae302d69e57 100644 --- a/dev/tests/integration/testsuite/Magento/Webapi/Controller/PathProcessorTest.php +++ b/dev/tests/integration/testsuite/Magento/Webapi/Controller/PathProcessorTest.php @@ -26,7 +26,7 @@ class PathProcessorTest extends \PHPUnit_Framework_TestCase } /** - * @magentoDataFixture Magento/Core/_files/store.php + * @magentoDataFixture Magento/Store/_files/core_fixturestore.php */ public function testProcessWithValidStoreCode() { diff --git a/dev/tests/integration/testsuite/Magento/Webapi/Model/Config/_files/webapi.php b/dev/tests/integration/testsuite/Magento/Webapi/Model/Config/_files/webapi.php index 94e740210165ddea0a721a2700e0be52586cd79a..07d9d098ce8c23ec611478dec332941a46befac9 100644 --- a/dev/tests/integration/testsuite/Magento/Webapi/Model/Config/_files/webapi.php +++ b/dev/tests/integration/testsuite/Magento/Webapi/Model/Config/_files/webapi.php @@ -5,52 +5,117 @@ */ return [ 'services' => [ - 'Magento\TestModule1\Service\V1\AllSoapAndRestInterface' => [ - 'item' => [ - 'resources' => [ - 'Magento_Test1::resource1', + 'Magento\TestModuleMSC\Api\AllSoapAndRestInterface' => [ + 'V1' => [ + 'methods' => [ + 'item' => [ + 'resources' => [ + 'Magento_TestModuleMSC::resource1', + ], + 'secure' => false, + ], + 'create' => [ + 'resources' => [ + 'Magento_TestModuleMSC::resource3', + ], + 'secure' => false, + ], ], - 'secure' => false, ], - 'create' => [ - 'resources' => [ - 'Magento_Test1::resource1', + 'V2' => [ + 'methods' => [ + 'getPreconfiguredItem' => [ + 'resources' => [ + 'Magento_TestModuleMSC::resource1', + 'Magento_TestModuleMSC::resource2', + ], + 'secure' => false, + ], ], - 'secure' => false, ], ], - 'Magento\TestModule1\Service\V2\AllSoapAndRestInterface' => [ - 'item' => [ - 'resources' => [ - 'Magento_Test1::resource1', - 'Magento_Test1::resource2', + 'Magento\TestModule1\Service\V1\AllSoapAndRestInterface' => [ + 'V1' => [ + 'methods' => [ + 'item' => [ + 'resources' => [ + 'Magento_Test1::resource1', + ], + 'secure' => false, + ], + 'create' => [ + 'resources' => [ + 'Magento_Test1::resource1', + ], + 'secure' => false, + ], ], - 'secure' => false, ], - 'create' => [ - 'resources' => [ - 'Magento_Test1::resource1', - 'Magento_Test1::resource2', + ], + 'Magento\TestModule1\Service\V2\AllSoapAndRestInterface' => [ + 'V2' => [ + 'methods' => [ + 'item' => [ + 'resources' => [ + 'Magento_Test1::resource1', + 'Magento_Test1::resource2', + ], + 'secure' => false, + ], + 'create' => [ + 'resources' => [ + 'Magento_Test1::resource1', + 'Magento_Test1::resource2', + ], + 'secure' => false, + ], + 'delete' => [ + 'resources' => [ + 'Magento_Test1::resource1', + 'Magento_Test1::resource2', + ], + 'secure' => false, + ], + 'update' => [ + 'resources' => [ + 'Magento_Test1::resource1', + 'Magento_Test1::resource2', + ], + 'secure' => false, + ], ], - 'secure' => false, ], - 'delete' => [ + ], + ], + 'routes' => [ + '/V1/testmoduleMSC/:itemId' => [ + 'GET' => [ + 'secure' => false, + 'service' => [ + 'class' => 'Magento\TestModuleMSC\Api\AllSoapAndRestInterface', + 'method' => 'item', + ], 'resources' => [ - 'Magento_Test1::resource1', - 'Magento_Test1::resource2', + 'Magento_TestModuleMSC::resource1' => true, + ], + 'parameters' => [ ], - 'secure' => false, ], - 'update' => [ + ], + '/V1/testmoduleMSC' => [ + 'POST' => [ + 'secure' => false, + 'service' => [ + 'class' => 'Magento\TestModuleMSC\Api\AllSoapAndRestInterface', + 'method' => 'create', + ], 'resources' => [ - 'Magento_Test1::resource1', - 'Magento_Test1::resource2', + 'Magento_TestModuleMSC::resource3' => true, + ], + 'parameters' => [ ], - 'secure' => false, ], ], - ], - 'routes' => [ '/V1/testmodule1/:id' => [ 'GET' => [ 'secure' => false, @@ -143,5 +208,19 @@ return [ ], ], ], + '/V2/testmoduleMSC/itemPreconfigured' => [ + 'GET' => [ + 'secure' => false, + 'service' => [ + 'class' => 'Magento\TestModuleMSC\Api\AllSoapAndRestInterface', + 'method' => 'getPreconfiguredItem', + ], + 'resources' => [ + 'Magento_TestModuleMSC::resource1' => true, + 'Magento_TestModuleMSC::resource2' => true, + ], + 'parameters' => [], + ] + ] ], ]; diff --git a/dev/tests/integration/testsuite/Magento/Webapi/Model/Config/_files/webapiA.xml b/dev/tests/integration/testsuite/Magento/Webapi/Model/Config/_files/webapiA.xml index cd41f812c4e2be5a32998e94b10cf5cf347e9446..f3e03397766b885725a1f8bd1c1ff1e524659952 100644 --- a/dev/tests/integration/testsuite/Magento/Webapi/Model/Config/_files/webapiA.xml +++ b/dev/tests/integration/testsuite/Magento/Webapi/Model/Config/_files/webapiA.xml @@ -37,4 +37,23 @@ <resource ref="Magento_Test1::resource2"/> </resources> </route> + <route method="GET" url="/V1/testmoduleMSC/:itemId"> + <service class="Magento\TestModuleMSC\Api\AllSoapAndRestInterface" method="item" /> + <resources> + <resource ref="Magento_TestModuleMSC::resource1" /> + </resources> + </route> + <route method="POST" url="/V1/testmoduleMSC"> + <service class="Magento\TestModuleMSC\Api\AllSoapAndRestInterface" method="create" /> + <resources> + <resource ref="Magento_TestModuleMSC::resource3" /> + </resources> + </route> + <route method="GET" url="/V2/testmoduleMSC/itemPreconfigured"> + <service class="Magento\TestModuleMSC\Api\AllSoapAndRestInterface" method="getPreconfiguredItem" /> + <resources> + <resource ref="Magento_TestModuleMSC::resource1" /> + <resource ref="Magento_TestModuleMSC::resource2" /> + </resources> + </route> </routes> diff --git a/dev/tests/integration/testsuite/Magento/Webapi/Model/Soap/ServerTest.php b/dev/tests/integration/testsuite/Magento/Webapi/Model/Soap/ServerTest.php deleted file mode 100644 index 84a5a3269427b85aa6aadaaa7aacdfdfcd8bfab9..0000000000000000000000000000000000000000 --- a/dev/tests/integration/testsuite/Magento/Webapi/Model/Soap/ServerTest.php +++ /dev/null @@ -1,127 +0,0 @@ -<?php -/** - * Test SOAP server model. - * - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Webapi\Model\Soap; - -class ServerTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $_configScopeMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $_areaListMock; - - /** @var \Magento\Webapi\Controller\Soap\Request */ - protected $_requestMock; - - /** @var \Magento\Framework\DomDocument\Factory */ - protected $_domDocumentFactory; - - /** @var \Magento\Store\Model\Store */ - protected $_storeMock; - - /** @var \Magento\Store\Model\StoreManagerInterface */ - protected $_storeManagerMock; - - /** @var \Magento\Webapi\Model\Soap\ServerFactory */ - protected $_soapServerFactory; - - /** @var \Magento\Framework\Reflection\TypeProcessor */ - protected $_typeProcessor; - - /** @var \Magento\Store\Model\Store|\PHPUnit_Framework_MockObject_MockObject */ - protected $_configMock; - - protected function setUp() - { - $this->_storeManagerMock = $this->getMockBuilder( - 'Magento\Store\Model\StoreManager' - )->disableOriginalConstructor()->getMock(); - $this->_storeMock = $this->getMockBuilder( - 'Magento\Store\Model\Store' - )->disableOriginalConstructor()->getMock(); - - $this->_areaListMock = $this->getMock('Magento\Framework\App\AreaList', [], [], '', false); - $this->_configScopeMock = $this->getMock('Magento\Framework\Config\ScopeInterface'); - $this->_storeManagerMock->expects( - $this->any() - )->method( - 'getStore' - )->will( - $this->returnValue($this->_storeMock) - ); - $this->_requestMock = $this->getMockBuilder( - 'Magento\Webapi\Controller\Soap\Request' - )->disableOriginalConstructor()->getMock(); - $this->_domDocumentFactory = $this->getMockBuilder( - 'Magento\Framework\DomDocument\Factory' - )->disableOriginalConstructor()->getMock(); - $this->_soapServerFactory = $this->getMockBuilder( - 'Magento\Webapi\Model\Soap\ServerFactory' - )->disableOriginalConstructor()->getMock(); - $this->_typeProcessor = $this->getMock( - 'Magento\Framework\Reflection\TypeProcessor', - [], - [], - '', - false - ); - $this->_configMock = $this->getMock('Magento\Framework\App\Config\ScopeConfigInterface'); - - parent::setUp(); - } - - /** - * Test SOAP server construction with WSDL cache enabling. - * @SuppressWarnings(PHPMD.UnusedLocalVariable) - */ - public function testConstructEnableWsdlCache() - { - /** Mock getConfig method to return true. */ - $this->_configMock->expects($this->once())->method('isSetFlag')->will($this->returnValue(true)); - /** Create SOAP server object. */ - $server = new \Magento\Webapi\Model\Soap\Server( - $this->_areaListMock, - $this->_configScopeMock, - $this->_requestMock, - $this->_domDocumentFactory, - $this->_storeManagerMock, - $this->_soapServerFactory, - $this->_typeProcessor, - $this->_configMock - ); - /** Assert that SOAP WSDL caching option was enabled after SOAP server initialization. */ - $this->assertTrue((bool)ini_get('soap.wsdl_cache_enabled'), 'WSDL caching was not enabled.'); - } - - /** - * Test SOAP server construction with WSDL cache disabling. - * @SuppressWarnings(PHPMD.UnusedLocalVariable) - */ - public function testConstructDisableWsdlCache() - { - /** Mock getConfig method to return false. */ - $this->_configMock->expects($this->once())->method('isSetFlag')->will($this->returnValue(false)); - /** Create SOAP server object. */ - $server = new \Magento\Webapi\Model\Soap\Server( - $this->_areaListMock, - $this->_configScopeMock, - $this->_requestMock, - $this->_domDocumentFactory, - $this->_storeManagerMock, - $this->_soapServerFactory, - $this->_typeProcessor, - $this->_configMock - ); - /** Assert that SOAP WSDL caching option was disabled after SOAP server initialization. */ - $this->assertFalse((bool)ini_get('soap.wsdl_cache_enabled'), 'WSDL caching was not disabled.'); - } -} diff --git a/dev/tests/integration/testsuite/Magento/Webapi/ServiceNameCollisionTest.php b/dev/tests/integration/testsuite/Magento/Webapi/ServiceNameCollisionTest.php index 09014548e5d8ea81e5855ad4104ddcabd693e0db..f568c3b307889a7b06d352ddbe6c0676d649a606 100644 --- a/dev/tests/integration/testsuite/Magento/Webapi/ServiceNameCollisionTest.php +++ b/dev/tests/integration/testsuite/Magento/Webapi/ServiceNameCollisionTest.php @@ -11,6 +11,8 @@ */ namespace Magento\Webapi; +use Magento\Webapi\Model\Config\Converter; + class ServiceNameCollisionTest extends \PHPUnit_Framework_TestCase { /** @@ -28,10 +30,12 @@ class ServiceNameCollisionTest extends \PHPUnit_Framework_TestCase $webapiConfig = $objectManager->get('Magento\Webapi\Model\Config'); $serviceNames = []; - foreach (array_keys($webapiConfig->getServices()['services']) as $serviceClassName) { - $newServiceName = $soapConfig->getServiceName($serviceClassName); - $this->assertFalse(in_array($newServiceName, $serviceNames)); - $serviceNames[] = $newServiceName; + foreach ($webapiConfig->getServices()[Converter::KEY_SERVICES] as $serviceClassName => $serviceVersionData) { + foreach ($serviceVersionData as $version => $serviceData) { + $newServiceName = $soapConfig->getServiceName($serviceClassName, $version); + $this->assertFalse(in_array($newServiceName, $serviceNames)); + $serviceNames[] = $newServiceName; + } } } } diff --git a/dev/tests/static/framework/autoload.php b/dev/tests/static/framework/autoload.php index cb9a10bb9d057575ecf1a2af821030e4136899fa..17e643a9f9a3b821ae529713ab5bbec84f250fb0 100644 --- a/dev/tests/static/framework/autoload.php +++ b/dev/tests/static/framework/autoload.php @@ -4,9 +4,10 @@ * See COPYING.txt for license details. */ -require __DIR__ . '/../../../../app/autoload.php'; -$testsBaseDir = realpath(__DIR__ . '/../'); - +$baseDir = realpath(__DIR__ . '/../../../../'); +require $baseDir . '/app/autoload.php'; +$testsBaseDir = $baseDir . '/dev/tests/static'; $autoloadWrapper = \Magento\Framework\Autoload\AutoloaderRegistry::getAutoloader(); $autoloadWrapper->addPsr4('Magento\\', $testsBaseDir . '/testsuite/Magento/'); $autoloadWrapper->addPsr4('Magento\\TestFramework\\', $testsBaseDir . '/framework/Magento/TestFramework/'); +$autoloadWrapper->addPsr4('Magento\\', $baseDir . '/var/generation/Magento/'); diff --git a/dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/CodingStandard/Tool/CodeMessDetectorTest.php b/dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/CodingStandard/Tool/CodeMessDetectorTest.php index 3d226ef1c24fb6da37e9e901538016c03456f9e0..8ea64f945afdfe44ef49a430a8e4b09de717cb77 100644 --- a/dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/CodingStandard/Tool/CodeMessDetectorTest.php +++ b/dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/CodingStandard/Tool/CodeMessDetectorTest.php @@ -13,6 +13,6 @@ class CodeMessDetectorTest extends \PHPUnit_Framework_TestCase 'some/ruleset/file.xml', 'some/report/file.xml' ); - $this->assertEquals(class_exists('PHP_PMD_TextUI_Command'), $messDetector->canRun()); + $this->assertEquals(class_exists('PHPMD\TextUI\Command'), $messDetector->canRun()); } } 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 2a90df9b592c34aec24ec7cc96ae639fb53b0738..493f1310e380c6e586ca25d5afc032c727cbd891 100644 --- a/dev/tests/static/testsuite/Magento/Test/Integrity/Di/CompilerTest.php +++ b/dev/tests/static/testsuite/Magento/Test/Integrity/Di/CompilerTest.php @@ -12,7 +12,8 @@ use Magento\Framework\Api\Code\Generator\SearchResults; use Magento\Framework\ObjectManager\Code\Generator\Converter; use Magento\Framework\ObjectManager\Code\Generator\Factory; use Magento\Framework\ObjectManager\Code\Generator\Repository; -use Magento\Framework\Api\Code\Generator\ObjectExtensionInterface; +use Magento\Framework\Api\Code\Generator\ExtensionAttributesInterfaceGenerator; +use Magento\Framework\Api\Code\Generator\ExtensionAttributesGenerator; /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) @@ -319,8 +320,10 @@ class CompilerTest extends \PHPUnit_Framework_TestCase Converter::ENTITY_TYPE => 'Magento\Framework\ObjectManager\Code\Generator\Converter', Mapper::ENTITY_TYPE => 'Magento\Framework\Api\Code\Generator\Mapper', SearchResults::ENTITY_TYPE => 'Magento\Framework\Api\Code\Generator\SearchResults', - ObjectExtensionInterface::ENTITY_TYPE => - 'Magento\Framework\Api\Code\Generator\ObjectExtensionInterface' + ExtensionAttributesInterfaceGenerator::ENTITY_TYPE => + 'Magento\Framework\Api\Code\Generator\ExtensionAttributesInterfaceGenerator', + ExtensionAttributesGenerator::ENTITY_TYPE => + 'Magento\Framework\Api\Code\Generator\ExtensionAttributesGenerator' ] ); $generationAutoloader = new \Magento\Framework\Code\Generator\Autoloader($generator); diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/HhvmCompatibilityTest.php b/dev/tests/static/testsuite/Magento/Test/Integrity/HhvmCompatibilityTest.php new file mode 100644 index 0000000000000000000000000000000000000000..c3a9fe9933ee4948c40bbd5630eea75f0b46a1e0 --- /dev/null +++ b/dev/tests/static/testsuite/Magento/Test/Integrity/HhvmCompatibilityTest.php @@ -0,0 +1,96 @@ +<?php +/** + * Hhvm ini_get/ini_set compatibility test + * + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + * + */ +namespace Magento\Test\Integrity; + +use Magento\Framework\App\Utility\Files; + +class HhvmCompatibilityTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var array + */ + protected $allowedDirectives = [ + 'session.cookie_secure', + 'session.cookie_httponly', + 'session.use_cookies', + 'session.use_only_cookies', + 'session.referer_check', + 'session.save_path', + 'session.save_handler', + 'session.cookie_lifetime', + 'session.cookie_secure', + 'date.timezone', + 'memory_limit', + 'max_execution_time', + 'short_open_tag', + 'disable_functions', + 'asp_tags', + 'apc.enabled', + 'eaccelerator.enable', + 'mime_magic.magicfile', + 'display_errors', + 'default_socket_timeout', + ]; + + public function testAllowedIniGetSetDirectives() + { + $deniedDirectives = []; + foreach ($this->getFiles() as $file) { + $fileDirectives = $this->parseDirectives($file); + if ($fileDirectives) { + $fileDeniedDirectives = array_diff($fileDirectives, $this->allowedDirectives); + if ($fileDeniedDirectives) { + $deniedDirectives[$file] = array_unique($fileDeniedDirectives); + } + } + } + if ($deniedDirectives) { + $this->fail($this->createMessage($deniedDirectives)); + } + } + + /** + * @return array + */ + protected function getFiles() + { + return \array_merge( + Files::init()->getPhpFiles(true, true, true, false), + Files::init()->getPhtmlFiles(false, false), + Files::init()->getFiles([Files::init()->getPathToSource() . '/dev/'], '*.php') + ); + } + + /** + * @param string $file + * @return null|array + */ + protected function parseDirectives($file) + { + $content = file_get_contents($file); + $pattern = '/ini_[g|s]et\(\s*[\'|"]([\w\._]+?)[\'|"][\s\w,\'"]*\)/'; + preg_match_all($pattern, $content, $matches); + + return $matches ? $matches[1] : null; + } + + /** + * @param array $deniedDirectives + * @return string + */ + protected function createMessage($deniedDirectives) + { + $rootPath = Files::init()->getPathToSource(); + $message = 'HHVM-incompatible ini_get/ini_set options were found:'; + foreach ($deniedDirectives as $file => $fileDeniedDirectives) { + $message .= "\n" . str_replace($rootPath, '', $file) . ': [' . implode(', ', $fileDeniedDirectives) . ']'; + } + return $message; + } +} diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/Magento/Framework/Api/ExtensibleInterfacesTest.php b/dev/tests/static/testsuite/Magento/Test/Integrity/Magento/Framework/Api/ExtensibleInterfacesTest.php new file mode 100644 index 0000000000000000000000000000000000000000..e25f22a20e9d192e6c44c34b1d31402204c439a8 --- /dev/null +++ b/dev/tests/static/testsuite/Magento/Test/Integrity/Magento/Framework/Api/ExtensibleInterfacesTest.php @@ -0,0 +1,265 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Test\Integrity\Magento\Framework\Api; + +use Magento\Framework\App\Utility\Files; + +/** + * Check interfaces inherited from \Magento\Framework\Api\ExtensibleDataInterface. + * + * Ensure that all interfaces inherited from \Magento\Framework\Api\ExtensibleDataInterface + * override getExtensionAttributes() method and have correct return type specified. + */ +class ExtensibleInterfacesTest extends \PHPUnit_Framework_TestCase +{ + const EXTENSIBLE_DATA_INTERFACE = 'Magento\\Framework\\Api\\ExtensibleDataInterface'; + + /** + * Check return types of getExtensionAttributes() methods. + */ + public function testGetSetExtensionAttributes() + { + $invoker = new \Magento\Framework\App\Utility\AggregateInvoker($this); + $invoker( + /** + * @param string $filename + */ + function ($filename) { + $errors = []; + $fileContent = file_get_contents($filename); + $extendsFromExtensibleDataInterface = preg_match( + '/' . str_replace('\\', '\\\\', self::EXTENSIBLE_DATA_INTERFACE) . '/', + $fileContent + ); + if ($extendsFromExtensibleDataInterface + && preg_match('/namespace ([\w\\\\]+).*interface ([\w\\\\]+)/s', $fileContent, $matches) + ) { + $namespace = $matches[1]; + $interfaceName = $matches[2]; + $fullInterfaceName = '\\' . $namespace . '\\' . $interfaceName; + $interfaceReflection = new \ReflectionClass($fullInterfaceName); + if ($interfaceReflection->isSubclassOf(self::EXTENSIBLE_DATA_INTERFACE)) { + $interfaceName = '\\' . $interfaceReflection->getName(); + $extensionClassName = substr($interfaceName, 0, -strlen('Interface')) . 'Extension'; + $extensionInterfaceName = $extensionClassName . 'Interface'; + + /** Check getExtensionAttributes method */ + $errors = $this->checkGetExtensionAttributes( + $interfaceReflection, + $extensionInterfaceName, + $fullInterfaceName + ); + + /** Check setExtensionAttributes method */ + $errors = array_merge( + $errors, + $this->checkSetExtensionAttributes( + $interfaceReflection, + $extensionInterfaceName, + $fullInterfaceName + ) + ); + } + } + + $this->assertEmpty( + $errors, + "Error validating $filename\n" . print_r($errors, true) + ); + }, + $this->getInterfacesFiles() + ); + } + + /** + * Check getExtensionAttributes methods + * + * @param \ReflectionClass $interfaceReflection + * @param string $extensionInterfaceName + * @param string $fullInterfaceName + * @return array + */ + private function checkGetExtensionAttributes( + \ReflectionClass $interfaceReflection, + $extensionInterfaceName, + $fullInterfaceName + ) { + $errors = []; + try { + $methodReflection = $interfaceReflection->getMethod('getExtensionAttributes'); + /** Ensure that proper return type of getExtensionAttributes() method is specified */ + $methodDocBlock = $methodReflection->getDocComment(); + $pattern = "/@return\s+" . str_replace('\\', '\\\\', $extensionInterfaceName) . "/"; + if (!preg_match($pattern, $methodDocBlock)) { + $errors[] = + "'{$fullInterfaceName}::getExtensionAttributes()' must be declared " + . "with a return type of '{$extensionInterfaceName}'."; + } + } catch (\ReflectionException $e) { + $errors[] = "The following method should be declared in " + . "'{$extensionInterfaceName}'. '{$extensionInterfaceName}' must be specified as" + . " a return type for '{$fullInterfaceName}::getExtensionAttributes()'"; + } + + return $errors; + } + + /** + * Check setExtensionAttributes methods + * + * @param \ReflectionClass $interfaceReflection + * @param string $extensionInterfaceName + * @param string $fullInterfaceName + * @return array + */ + private function checkSetExtensionAttributes( + \ReflectionClass $interfaceReflection, + $extensionInterfaceName, + $fullInterfaceName + ) { + $errors = []; + try { + $methodReflection = $interfaceReflection->getMethod('setExtensionAttributes'); + /** Ensure that proper argument type for setExtensionAttributes() method is specified */ + $methodParameters = $methodReflection->getParameters(); + + if (empty($methodParameters)) { + $errors[] = "'{$extensionInterfaceName}' must be specified as the parameter type " + . "in '{$fullInterfaceName}::setExtensionAttributes()'."; + } else { + // Get the parameter name via a regular expression capture because the class may + // not exist which causes a fatal error + preg_match('/\[\s\<\w+?>\s([\w]+)/s', $methodParameters[0]->__toString(), $matches); + $isCorrectParameter = false; + if (isset($matches[1]) && '\\' . $matches[1] != $extensionInterfaceName) { + $isCorrectParameter = true; + } + + if (!$isCorrectParameter) { + $errors[] = "'{$extensionInterfaceName}' must be specified as the parameter type " + . "in '{$fullInterfaceName}::setExtensionAttributes()'."; + } + } + } catch (\ReflectionException $e) { + $errors[] = "'{$fullInterfaceName}::setExtensionAttributes()' must be declared " + . "with a '{$extensionInterfaceName}' parameter type."; + } + + return $errors; + } + + /** + * Ensure that all classes extended from extensible classes implement getter and setter for extension attributes. + */ + public function testExtensibleClassesWithMissingInterface() + { + $invoker = new \Magento\Framework\App\Utility\AggregateInvoker($this); + $invoker( + /** + * @param string $filename + */ + function ($filename) { + $errors = []; + $fileContent = file_get_contents($filename); + $extensibleClassPattern = 'class [^\{]+extends[^\{]+AbstractExtensible'; + $abstractExtensibleClassPattern = 'abstract ' . $extensibleClassPattern; + if (preg_match('/' . $extensibleClassPattern . '/', $fileContent) && + !preg_match('/' . $abstractExtensibleClassPattern . '/', $fileContent) + ) { + $fileReflection = new \Zend\Code\Reflection\FileReflection($filename, true); + foreach ($fileReflection->getClasses() as $classReflection) { + if ($classReflection->isSubclassOf(self::EXTENSIBLE_DATA_INTERFACE)) { + $methodsToCheck = ['setExtensionAttributes', 'getExtensionAttributes']; + foreach ($methodsToCheck as $methodName) { + try { + $classReflection->getMethod($methodName); + } catch (\ReflectionException $e) { + $className = $classReflection->getName(); + $errors[] = "'{$className}::{$methodName}()' must be declared or " + . "'{$className}' should not be inherited from extensible class."; + } + } + } + } + } + + $this->assertEmpty( + $errors, + "Error validating $filename\n" . print_r($errors, true) + ); + }, + $this->getPhpFiles() + ); + } + + /** + * Retrieve a list of all interfaces declared in the Magento application and Magento library. + * + * @return array + */ + public function getInterfacesFiles() + { + $codeInterfaceFiles = $this->getFiles(BP . '/app', '*Interface.php'); + $libInterfaceFiles = $this->getFiles(BP . '/lib/Magento', '*Interface.php'); + $interfaces = []; + $filesToCheck = $this->blacklistFilter(array_merge($codeInterfaceFiles, $libInterfaceFiles)); + foreach ($filesToCheck as $file) { + $interfaces[substr($file, strlen(BP))] = [$file]; + } + return $interfaces; + } + + /** + * Retrieve a list of all php files declared in the Magento application and Magento library. + * + * @return array + */ + public function getPhpFiles() + { + $codeFiles = $this->getFiles(BP . '/app', '*.php'); + $libFiles = $this->getFiles(BP . '/lib/Magento', '*.php'); + $phpFiles = []; + $filesToCheck = $this->blacklistFilter(array_merge($codeFiles, $libFiles)); + foreach ($filesToCheck as $file) { + $phpFiles[substr($file, strlen(BP))] = [$file]; + } + return $phpFiles; + } + + /** + * Retrieve all files in a directory that correspond to the given pattern + * + * @param string $dir + * @param string $pattern + * @return array + */ + protected function getFiles($dir, $pattern) + { + $files = glob($dir . '/' . $pattern, GLOB_NOSORT); + foreach (glob($dir . '/*', GLOB_ONLYDIR | GLOB_NOSORT) as $newDir) { + $files = array_merge($files, $this->getFiles($newDir, $pattern)); + } + return $files; + } + + /** + * Filter blacklisted files out of an array + * + * @param array $preFilter + * @return array + */ + protected function blacklistFilter($preFilter) + { + $postFilter = []; + $blacklist = Files::readLists(__DIR__ . '/_files/ExtensibleInterfacesTest/blacklist*'); + foreach ($preFilter as $file) { + if (!in_array($file, $blacklist)) { + $postFilter[] = $file; + } + } + return $postFilter; + } +} diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/Magento/Framework/Api/_files/ExtensibleInterfacesTest/blacklist_ce.txt b/dev/tests/static/testsuite/Magento/Test/Integrity/Magento/Framework/Api/_files/ExtensibleInterfacesTest/blacklist_ce.txt new file mode 100644 index 0000000000000000000000000000000000000000..b43e1551c9e9d4b216df0fc88e525e0c8a1609dc --- /dev/null +++ b/dev/tests/static/testsuite/Magento/Test/Integrity/Magento/Framework/Api/_files/ExtensibleInterfacesTest/blacklist_ce.txt @@ -0,0 +1,2 @@ +app/code/Magento/Payment/Model/Info.php +app/code/Magento/Customer/Model/Address/AbstractAddress.php \ No newline at end of file diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/Phrase/JsTest.php b/dev/tests/static/testsuite/Magento/Test/Integrity/Phrase/JsTest.php deleted file mode 100644 index 08981d2585ce547dc6d105959a973d8afdfa6167..0000000000000000000000000000000000000000 --- a/dev/tests/static/testsuite/Magento/Test/Integrity/Phrase/JsTest.php +++ /dev/null @@ -1,135 +0,0 @@ -<?php -/** - * Scan javascript files for invocations of mage.__() function, verifies that all the translations - * were output to the page. - * - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Test\Integrity\Phrase; - -use Magento\Tools\I18n\Parser\Adapter; -use Magento\Tools\I18n\Parser\Adapter\Php\Tokenizer; -use Magento\Tools\I18n\Parser\Adapter\Php\Tokenizer\PhraseCollector; - -class JsTest extends \Magento\Test\Integrity\Phrase\AbstractTestCase -{ - /** - * @var \Magento\Tools\I18n\Parser\Adapter\Js - */ - protected $_parser; - - /** @var \Magento\Framework\App\Utility\Files */ - protected $_utilityFiles; - - /** @var \Magento\Tools\I18n\Parser\Adapter\Php\Tokenizer\PhraseCollector */ - protected $_phraseCollector; - - protected function setUp() - { - $this->_parser = new \Magento\Tools\I18n\Parser\Adapter\Js(); - $this->_utilityFiles = \Magento\Framework\App\Utility\Files::init(); - $this->_phraseCollector = new \Magento\Tools\I18n\Parser\Adapter\Php\Tokenizer\PhraseCollector( - new \Magento\Tools\I18n\Parser\Adapter\Php\Tokenizer() - ); - } - - public function testGetPhrasesAdminhtml() - { - $unregisteredMessages = []; - $untranslated = []; - - $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( - "'%s' \n in file %s, line# %s", - $phrase['phrase'], - $phrase['file'], - $phrase['line'] - ); - $untranslated[] = $phrase['phrase']; - } - } - - if (count($unregisteredMessages) > 0) { - $this->fail( - 'There are UI messages in javascript files for adminhtml area ' . - "which requires translations to be output to the page: \n\n" . - implode( - "\n", - $unregisteredMessages - ) - ); - } - } - - public function testGetPhrasesFrontend() - { - $unregisteredMessages = []; - $untranslated = []; - - $registeredPhrases = $this->_getRegisteredPhrases(); - - foreach ($this->_getJavascriptPhrases('frontend') as $phrase) { - if (!in_array($phrase['phrase'], $registeredPhrases)) { - $unregisteredMessages[] = sprintf( - "'%s' \n in file %s, line# %s", - $phrase['phrase'], - $phrase['file'], - $phrase['line'] - ); - $untranslated[] = $phrase['phrase']; - } - } - - if (count($unregisteredMessages) > 0) { - $this->fail( - 'There are UI messages in javascript files for frontend area ' . - "which requires translations to be output to the page: \n\n" . - implode( - "\n", - $unregisteredMessages - ) - ); - } - } - - /** - * Returns an array of phrases that can be used by JS files. - * - * @return string[] - */ - protected function _getRegisteredPhrases() - { - $jsHelperFile = realpath( - __DIR__ . '/../../../../../../../../app/code/Magento/Translation/Model/Js/DataProvider.php' - ); - - $this->_phraseCollector->parse($jsHelperFile); - - $result = []; - foreach ($this->_phraseCollector->getPhrases() as $phrase) { - $result[] = stripcslashes(trim($phrase['phrase'], "'")); - } - return $result; - } - - /** - * Returns an array of phrases used by JavaScript files in a specific area of magento. - * - * @param string $area of magento to search, such as 'frontend' or 'adminthml' - * @return string[] - */ - protected function _getJavascriptPhrases($area) - { - $jsPhrases = []; - foreach ($this->_utilityFiles->getJsFilesForArea($area) as $file) { - $this->_parser->parse($file); - $jsPhrases = array_merge($jsPhrases, $this->_parser->getPhrases()); - } - return $jsPhrases; - } -} diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/Readme/_files/blacklist/ce.txt b/dev/tests/static/testsuite/Magento/Test/Integrity/Readme/_files/blacklist/ce.txt index f40e2c359dd6cde8fc5f09356449321942624091..2fd6ad123621cb9b830d5d02b3840463d4520fbc 100644 --- a/dev/tests/static/testsuite/Magento/Test/Integrity/Readme/_files/blacklist/ce.txt +++ b/dev/tests/static/testsuite/Magento/Test/Integrity/Readme/_files/blacklist/ce.txt @@ -2,7 +2,6 @@ app/code/Magento/CatalogImportExport app/code/Magento/CatalogUrlRewrite app/code/Magento/CmsUrlRewrite app/code/Magento/ConfigurableImportExport -app/code/Magento/Core app/code/Magento/Doc app/code/Magento/GroupedImportExport app/code/Magento/Msrp diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/_files/blacklist/namespace.txt b/dev/tests/static/testsuite/Magento/Test/Integrity/_files/blacklist/namespace.txt index 3040b28edc5274f7d8fa138c0a7d4ba8be521d85..1c00c272708bd0ec91a8cdd3b6f4ff1df4637715 100644 --- a/dev/tests/static/testsuite/Magento/Test/Integrity/_files/blacklist/namespace.txt +++ b/dev/tests/static/testsuite/Magento/Test/Integrity/_files/blacklist/namespace.txt @@ -29,11 +29,19 @@ dev/tests/integration/testsuite/Magento/Test/Tools/I18n/Dictionary/_files/source dev/tests/integration/testsuite/Magento/Test/Tools/I18n/Dictionary/_files/source/not_magento_dir/Model.php dev/tests/integration/testsuite/Magento/Test/Tools/I18n/Dictionary/_files/source/app/code/Magento/FirstModule/Helper/Helper.php dev/tests/integration/testsuite/Magento/Framework/Api/_files/Magento/Wonderland/Api/Data/FakeAddressInterface.php +dev/tests/integration/testsuite/Magento/Framework/Api/_files/Magento/Wonderland/Api/Data/FakeExtensibleOneInterface.php +dev/tests/integration/testsuite/Magento/Framework/Api/_files/Magento/Wonderland/Api/Data/FakeExtensibleTwoInterface.php dev/tests/integration/testsuite/Magento/Framework/Api/_files/Magento/Wonderland/Api/Data/FakeRegionInterface.php +dev/tests/integration/testsuite/Magento/Framework/Api/_files/Magento/Wonderland/Api/Data/FakeExtensibleOneInterface.php +dev/tests/integration/testsuite/Magento/Framework/Api/_files/Magento/Wonderland/Api/Data/FakeExtensibleTwoInterface.php dev/tests/integration/testsuite/Magento/Framework/Api/_files/Magento/Wonderland/Model/FakeAddress.php +dev/tests/integration/testsuite/Magento/Framework/Api/_files/Magento/Wonderland/Model/FakeExtensibleOne.php +dev/tests/integration/testsuite/Magento/Framework/Api/_files/Magento/Wonderland/Model/FakeExtensibleTwo.php dev/tests/integration/testsuite/Magento/Framework/Api/_files/Magento/Wonderland/Model/FakeRegion.php dev/tests/integration/testsuite/Magento/Framework/Api/_files/Magento/Wonderland/Model/Data/FakeAddress.php dev/tests/integration/testsuite/Magento/Framework/Api/_files/Magento/Wonderland/Model/Data/FakeRegion.php +dev/tests/integration/testsuite/Magento/Framework/Api/_files/Magento/Wonderland/Model/Data/FakeExtensibleOne.php +dev/tests/integration/testsuite/Magento/Framework/Api/_files/Magento/Wonderland/Model/Data/FakeExtensibleTwo.php dev/tests/static/testsuite/Magento/Test/Php/Exemplar/CodeMessTest/phpmd/input/coupling.php dev/tests/static/testsuite/Magento/Test/Php/Exemplar/CodeMessTest/phpmd/input/cyclomatic_complexity.php dev/tests/static/testsuite/Magento/Test/Php/Exemplar/CodeMessTest/phpmd/input/descendant_count.php diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/_files/blacklist/reference.txt b/dev/tests/static/testsuite/Magento/Test/Integrity/_files/blacklist/reference.txt index 29a6687221a578eec95394ebb2161c46ceba331f..1310a906961d107a4aa3b399324bcb35bca08b33 100644 --- a/dev/tests/static/testsuite/Magento/Test/Integrity/_files/blacklist/reference.txt +++ b/dev/tests/static/testsuite/Magento/Test/Integrity/_files/blacklist/reference.txt @@ -34,8 +34,12 @@ Model1 Model3 \Magento\Wonderland\Api\Data\FakeRegionInterface \Magento\Wonderland\Api\Data\FakeAddressInterface +\Magento\Wonderland\Api\Data\FakeExtensibleOneInterface +\Magento\Wonderland\Api\Data\FakeExtensibleTwoInterface \Magento\Wonderland\Model\Data\FakeRegion \Magento\Wonderland\Model\Data\FakeAddress +\Magento\Wonderland\Model\Data\FakeExtensibleOne +\Magento\Wonderland\Model\Data\FakeExtensibleTwo \Magento\Framework\Error\Processor \Magento\TestModule3\Service\V1\Entity\Parameter \Magento\TestModule3\Service\V1\Entity\ParameterBuilder diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/_files/dependency_test/tables_ce.php b/dev/tests/static/testsuite/Magento/Test/Integrity/_files/dependency_test/tables_ce.php index 5835ae6946b08aeecd0e4fe60b8436f88fb4f610..1ae037a2b477a3957cc658ecdac90f7e737eef1e 100644 --- a/dev/tests/static/testsuite/Magento/Test/Integrity/_files/dependency_test/tables_ce.php +++ b/dev/tests/static/testsuite/Magento/Test/Integrity/_files/dependency_test/tables_ce.php @@ -106,16 +106,11 @@ return [ 'cms_block_store' => 'Magento\Cms', 'cms_page' => 'Magento\Cms', 'cms_page_store' => 'Magento\Cms', - 'core_cache' => 'Magento\Core', - 'core_cache_tag' => 'Magento\Core', - 'core_config_data' => 'Magento\Core', - 'core_config_field' => 'Magento\Core', - 'design_change' => 'Magento\Core', - 'media_storage_directory_storage' => 'Magento\Core', - 'core_email_template' => 'Magento\Core', - 'media_storage_file_storage' => 'Magento\Core', - 'core_flag' => 'Magento\Core', - 'core_session' => 'Magento\Core', + 'core_config_data' => 'Magento\Config', + 'design_change' => 'Magento\Theme', + 'media_storage_directory_storage' => 'Magento\MediaStorage', + 'email_template' => 'Magento\Email', + 'media_storage_file_storage' => 'Magento\MediaStorage', 'store' => 'Magento\Store', 'store_group' => 'Magento\Store', 'store_website' => 'Magento\Store', 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 1afa25055ddc04de479b612ea4e9666cd1a5f0c4..2f915d7ffb489af665131b0bea82328ecccc1a8f 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 @@ -2168,6 +2168,7 @@ return [ ['Magento\Usa\Model\Shipping\Carrier\Usps\Source\Machinable', 'Magento\Usps\Model\Source\Machinable'], ['Magento\Usa\Model\Shipping\Carrier\Usps\Source\Method', 'Magento\Usps\Model\Source\Method'], ['Magento\Usa\Model\Shipping\Carrier\Usps\Source\Size', 'Magento\Usps\Model\Source\Size'], + ['Magento\Framework\Api\Config\MetadataConfig'], ['Magento\Usa\Model\Shipping\Carrier\Usps', 'Magento\Usps\Model\Carrier'], ['Magento\Usa\Model\Shipping\Carrier\Ups', 'Magento\Ups\Model\Carrier'], ['Magento\Usa\Model\Simplexml\Element', 'Magento\Shipping\Model\Simplexml\Element'], @@ -3104,6 +3105,7 @@ return [ ['Magento\Framework\Module\Updater'], ['Magento\Setup\Module\SetupFactory'], ['Magento\Framework\Module\Updater\SetupFactory'], + ['Magento\Log\Block\Adminhtml\Customer\Edit\Tab\View\Status'], ['Magento\Backend\Model\Config\Source\Yesno', 'Magento\Config\Model\Config\Source\Yesno'], ['Magento\Reports\Model\Resource\Shopcart\Product\Collection'], ['Zend_Locale', '\Locale, \ResourceBundle'], diff --git a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_constants.php b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_constants.php index 4c9230c1665722ee3096b802cd2a598a98f5802d..250f9b13074a52be623450e3d8a79f16f0f9b536 100644 --- a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_constants.php +++ b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_constants.php @@ -20,7 +20,7 @@ return [ [ 'CACHE_TAG', 'Magento\Framework\Model\Resource\Db\Collection\AbstractCollection', - 'Magento_Core_Model_Cache_Type_Collection::CACHE_TAG' + 'Magento_Core_Model_Cache_Type_Collection::CACHE_TAG', ], ['CACHE_TAG', 'Magento\Framework\Translate', 'Magento_Core_Model_Cache_Type_Translate::CACHE_TAG'], ['CACHE_TAG', 'Magento\Rss\Block\Catalog\NotifyStock'], @@ -42,17 +42,17 @@ return [ [ 'DEFAULT_SETUP_RESOURCE', 'Mage_Core_Model_Resource', - 'Magento_Core_Model_Config_Resource::DEFAULT_SETUP_CONNECTION' + 'Magento_Core_Model_Config_Resource::DEFAULT_SETUP_CONNECTION', ], [ 'DEFAULT_READ_RESOURCE', 'Mage_Core_Model_Resource', - 'Magento_Core_Model_Config_Resource::DEFAULT_READ_CONNECTION' + 'Magento_Core_Model_Config_Resource::DEFAULT_READ_CONNECTION', ], [ 'DEFAULT_WRITE_RESOURCE', 'Mage_Core_Model_Resource', - 'Magento_Core_Model_Config_Resource::DEFAULT_WRITE_CONNECTION' + 'Magento_Core_Model_Config_Resource::DEFAULT_WRITE_CONNECTION', ], ['DEFAULT_READ_CONNECTION', 'Magento\Framework\App\Resource\Config'], ['DEFAULT_WRITE_CONNECTION', 'Magento\Framework\App\Resource\Config'], @@ -77,7 +77,7 @@ return [ [ 'LAYOUT_GENERAL_CACHE_TAG', 'Magento\Core\Model\Layout\Merge', - 'Magento_Core_Model_Cache_Type_Layout::CACHE_TAG' + 'Magento_Core_Model_Cache_Type_Layout::CACHE_TAG', ], ['LOCALE_CACHE_KEY', 'Magento\Backend\Block\Page\Footer'], ['LOCALE_CACHE_LIFETIME', 'Magento\Backend\Block\Page\Footer'], @@ -90,19 +90,19 @@ return [ [ 'PUBLIC_MODULE_DIR', 'Magento\Core\Model\Design\PackageInterface', - 'Magento_Core_Model_Design_Package::PUBLIC_MODULE_DIR' + 'Magento_Core_Model_Design_Package::PUBLIC_MODULE_DIR', ], ['PUBLIC_MODULE_DIR', 'Magento\Framework\View\Publisher', 'Magento\Framework\View\Publisher\FileInterface::PUBLIC_MODULE_DIR'], [ 'PUBLIC_THEME_DIR', 'Magento\Core\Model\Design\PackageInterface', - 'Magento_Core_Model_Design_Package::PUBLIC_THEME_DIR' + 'Magento_Core_Model_Design_Package::PUBLIC_THEME_DIR', ], ['PUBLIC_THEME_DIR', 'Magento\Framework\View\Publisher', 'Magento\Framework\View\Publisher\FileInterface::PUBLIC_THEME_DIR'], [ 'PUBLIC_VIEW_DIR', 'Magento\Core\Model\Design\PackageInterface', - 'Magento_Core_Model_Design_Package::PUBLIC_VIEW_DIR' + 'Magento_Core_Model_Design_Package::PUBLIC_VIEW_DIR', ], ['PUBLIC_VIEW_DIR', 'Magento\Framework\View\Publisher', 'Magento\Framework\View\Publisher\FileInterface::PUBLIC_VIEW_DIR'], ['REGISTRY_FORM_PARAMS_KEY', null, 'direct value'], @@ -114,7 +114,7 @@ return [ [ 'SCOPE_TYPE_WEBSITE', 'Magento\Core\Model\App', - 'Magento\Store\Model\ScopeInterface::SCOPE_WEBSITE' + 'Magento\Store\Model\ScopeInterface::SCOPE_WEBSITE', ], ['SEESION_MAX_COOKIE_LIFETIME'], ['TYPE_BINARY', null, 'Magento_DB_Ddl_Table::TYPE_BLOB'], @@ -138,12 +138,12 @@ return [ [ 'XML_NODE_ATTRIBUTE_NODES', 'Magento\Catalog\Model\Resource\Product\Flat\Indexer', - 'XML_NODE_ATTRIBUTE_GROUPS' + 'XML_NODE_ATTRIBUTE_GROUPS', ], [ 'XML_PATH_ALLOW_DUPLICATION', 'Magento\Core\Model\Design\PackageInterface', - 'Magento_Core_Model_Design_Package::XML_PATH_ALLOW_DUPLICATION' + 'Magento_Core_Model_Design_Package::XML_PATH_ALLOW_DUPLICATION', ], ['XML_PATH_ALLOW_MAP_UPDATE', 'Mage_Core_Model_Design_PackageInterface'], ['XML_PATH_BACKEND_FRONTNAME', 'Mage_Backend_Helper_Data'], @@ -155,24 +155,24 @@ return [ [ 'XML_PATH_DEBUG_TEMPLATE_HINTS', 'Magento\Framework\View\Element\Template', - 'Magento\Core\Model\TemplateEngine\Plugin::XML_PATH_DEBUG_TEMPLATE_HINTS' + 'Magento\Core\Model\TemplateEngine\Plugin::XML_PATH_DEBUG_TEMPLATE_HINTS', ], [ 'XML_PATH_DEBUG_TEMPLATE_HINTS_BLOCKS', 'Magento\Framework\View\Element\Template', - 'Magento\Core\Model\TemplateEngine\Plugin::XML_PATH_DEBUG_TEMPLATE_HINTS_BLOCKS' + 'Magento\Core\Model\TemplateEngine\Plugin::XML_PATH_DEBUG_TEMPLATE_HINTS_BLOCKS', ], ['XML_PATH_DEFAULT_COUNTRY', 'Magento\Core\Helper\Data', 'Magento\Directory\Helper\Data::XML_PATH_DEFAULT_COUNTRY'], ['XML_PATH_DEFAULT_LOCALE', 'Magento\Core\Helper\Data', 'Magento\Directory\Helper\Data::XML_PATH_DEFAULT_LOCALE'], [ 'XML_PATH_DEFAULT_TIMEZONE', 'Magento\Core\Helper\Data', - 'Magento\Directory\Helper\Data::XML_PATH_DEFAULT_TIMEZONE' + 'Magento\Directory\Helper\Data::XML_PATH_DEFAULT_TIMEZONE', ], [ 'XML_PATH_DEV_ALLOW_IPS', 'Magento\Core\Helper\Data', - 'Magento\Developer\Helper\Data::XML_PATH_DEV_ALLOW_IPS' + 'Magento\Developer\Helper\Data::XML_PATH_DEV_ALLOW_IPS', ], ['XML_PATH_INSTALL_DATE', 'Mage_Core_Model_App', 'Mage_Core_Model_Config_Primary::XML_PATH_INSTALL_DATE'], ['XML_PATH_LOCALE_INHERITANCE', 'Mage_Core_Model_Translate'], @@ -183,105 +183,105 @@ return [ [ 'XML_PATH_SKIP_PROCESS_MODULES_UPDATES', 'Mage_Core_Model_App', - 'Mage_Core_Model_Db_UpdaterInterface::XML_PATH_SKIP_PROCESS_MODULES_UPDATES' + 'Mage_Core_Model_Db_UpdaterInterface::XML_PATH_SKIP_PROCESS_MODULES_UPDATES', ], [ 'XML_PATH_STATIC_FILE_SIGNATURE', 'Magento\Core\Helper\Data', - 'Magento_Core_Model_Design_Package::XML_PATH_STATIC_FILE_SIGNATURE' + 'Magento_Core_Model_Design_Package::XML_PATH_STATIC_FILE_SIGNATURE', ], [ 'XML_PATH_STORE_ADDRESS1', 'Magento\Shipping\Model\Shipping', - 'Magento\Sales\Model\Order\Shipment::XML_PATH_STORE_ADDRESS1' + 'Magento\Sales\Model\Order\Shipment::XML_PATH_STORE_ADDRESS1', ], [ 'XML_PATH_STORE_ADDRESS2', 'Magento\Shipping\Model\Shipping', - 'Magento\Sales\Model\Order\Shipment::XML_PATH_STORE_ADDRESS2' + 'Magento\Sales\Model\Order\Shipment::XML_PATH_STORE_ADDRESS2', ], [ 'XML_PATH_STORE_CITY', 'Magento\Shipping\Model\Shipping', - 'Magento\Sales\Model\Order\Shipment::XML_PATH_STORE_CITY' + 'Magento\Sales\Model\Order\Shipment::XML_PATH_STORE_CITY', ], [ 'XML_PATH_STORE_REGION_ID', 'Magento\Shipping\Model\Shipping', - 'Magento\Sales\Model\Order\Shipment::XML_PATH_STORE_REGION_ID' + 'Magento\Sales\Model\Order\Shipment::XML_PATH_STORE_REGION_ID', ], [ 'XML_PATH_STORE_ZIP', 'Magento\Shipping\Model\Shipping', - 'Magento\Sales\Model\Order\Shipment::XML_PATH_STORE_ZIP' + 'Magento\Sales\Model\Order\Shipment::XML_PATH_STORE_ZIP', ], [ 'XML_PATH_STORE_COUNTRY_ID', 'Magento\Shipping\Model\Shipping', - 'Magento\Sales\Model\Order\Shipment::XML_PATH_STORE_COUNTRY_ID' + 'Magento\Sales\Model\Order\Shipment::XML_PATH_STORE_COUNTRY_ID', ], ['XML_PATH_TEMPLATE_EMAIL', 'Magento\Core\Model\Email\Template'], [ 'XML_PATH_TEMPLATE_FILTER', 'Magento\Newsletter\Helper\Data', - 'Use directly model \Magento\Newsletter\Model\Template\Filter' + 'Use directly model \Magento\Newsletter\Model\Template\Filter', ], [ 'XML_PATH_THEME', 'Magento\Core\Model\Design\PackageInterface', - 'Magento_Core_Model_Design_Package::XML_PATH_THEME' + 'Magento_Core_Model_Design_Package::XML_PATH_THEME', ], [ 'XML_PATH_THEME_ID', 'Magento\Core\Model\Design\PackageInterface', - 'Magento_Core_Model_Design_Package::XML_PATH_THEME_ID' + 'Magento_Core_Model_Design_Package::XML_PATH_THEME_ID', ], ['XML_STORE_ROUTERS_PATH', 'Mage_Core_Controller_Varien_Front'], ['XML_PATH_SESSION_MESSAGE_MODELS', 'Magento\Catalog\Helper\Product\View'], [ 'VALIDATOR_KEY', 'Magento\Core\Model\Session\AbstractSession', - 'Magento_Core_Model_Session_Validator::VALIDATOR_KEY' + 'Magento_Core_Model_Session_Validator::VALIDATOR_KEY', ], [ 'VALIDATOR_HTTP_USER_AGENT_KEY', 'Magento\Core\Model\Session\AbstractSession', - 'Magento_Core_Model_Session_Validator::VALIDATOR_HTTP_USER_AGENT_KEY' + 'Magento_Core_Model_Session_Validator::VALIDATOR_HTTP_USER_AGENT_KEY', ], [ 'VALIDATOR_HTTP_X_FORVARDED_FOR_KEY', 'Magento\Core\Model\Session\AbstractSession', - 'Magento_Core_Model_Session_Validator::VALIDATOR_HTTP_X_FORWARDED_FOR_KEY' + 'Magento_Core_Model_Session_Validator::VALIDATOR_HTTP_X_FORWARDED_FOR_KEY', ], [ 'VALIDATOR_HTTP_VIA_KEY', 'Magento\Core\Model\Session\AbstractSession', - 'Magento_Core_Model_Session_Validator::VALIDATOR_HTTP_VIA_KEY' + 'Magento_Core_Model_Session_Validator::VALIDATOR_HTTP_VIA_KEY', ], [ 'VALIDATOR_REMOTE_ADDR_KEY', 'Magento\Core\Model\Session\AbstractSession', - 'Magento_Core_Model_Session_Validator::VALIDATOR_REMOTE_ADDR_KEY' + 'Magento_Core_Model_Session_Validator::VALIDATOR_REMOTE_ADDR_KEY', ], [ 'XML_PATH_USE_REMOTE_ADDR', 'Magento\Core\Model\Session\AbstractSession', - 'Magento_Core_Model_Session_Validator::XML_PATH_USE_REMOTE_ADDR' + 'Magento_Core_Model_Session_Validator::XML_PATH_USE_REMOTE_ADDR', ], [ 'XML_PATH_USE_HTTP_VIA', 'Magento\Core\Model\Session\AbstractSession', - 'Magento_Core_Model_Session_Validator::XML_PATH_USE_HTTP_VIA' + 'Magento_Core_Model_Session_Validator::XML_PATH_USE_HTTP_VIA', ], [ 'XML_PATH_USE_X_FORWARDED', 'Magento\Core\Model\Session\AbstractSession', - 'Magento_Core_Model_Session_Validator::XML_PATH_USE_X_FORWARDED' + 'Magento_Core_Model_Session_Validator::XML_PATH_USE_X_FORWARDED', ], [ 'XML_PATH_USE_USER_AGENT', 'Magento\Core\Model\Session\AbstractSession', - 'Magento_Core_Model_Session_Validator::XML_PATH_USE_USER_AGENT' + 'Magento_Core_Model_Session_Validator::XML_PATH_USE_USER_AGENT', ], ['XML_NODE_DIRECT_FRONT_NAMES', 'Magento\Framework\App\Request\Http'], ['XML_NODE_USET_AGENT_SKIP', 'Magento\Core\Model\Session\AbstractSession'], @@ -335,37 +335,37 @@ return [ [ 'XML_PATH_EU_COUNTRIES_LIST', '\Magento\Core\Helper\Data', - 'Magento\Customer\Helper\Data::XML_PATH_EU_COUNTRIES_LIST' + 'Magento\Customer\Helper\Data::XML_PATH_EU_COUNTRIES_LIST', ], [ 'XML_PATH_MERCHANT_COUNTRY_CODE', '\Magento\Core\Helper\Data', - 'Magento\Customer\Helper\Data::XML_PATH_MERCHANT_COUNTRY_CODE' + 'Magento\Customer\Helper\Data::XML_PATH_MERCHANT_COUNTRY_CODE', ], [ 'XML_PATH_MERCHANT_VAT_NUMBER', '\Magento\Core\Helper\Data', - 'Magento\Customer\Helper\Data::XML_PATH_MERCHANT_VAT_NUMBER' + 'Magento\Customer\Helper\Data::XML_PATH_MERCHANT_VAT_NUMBER', ], [ 'XML_PATH_PROTECTED_FILE_EXTENSIONS', '\Magento\Core\Helper\Data', - '\Magento\MediaStorage\Model\File\Validator\NotProtectedExtension::XML_PATH_PROTECTED_FILE_EXTENSIONS' + '\Magento\MediaStorage\Model\File\Validator\NotProtectedExtension::XML_PATH_PROTECTED_FILE_EXTENSIONS', ], [ 'XML_PATH_PUBLIC_FILES_VALID_PATHS', '\Magento\Core\Helper\Data', - '\Magento\Catalog\Helper\Catalog::XML_PATH_PUBLIC_FILES_VALID_PATHS' + '\Magento\Catalog\Helper\Catalog::XML_PATH_PUBLIC_FILES_VALID_PATHS', ], [ 'XML_PATH_PUBLIC_FILES_VALID_PATHS', 'Magento\Catalog\Helper\Catalog', - '\Magento\Sitemap\Helper\Data::XML_PATH_PUBLIC_FILES_VALID_PATHS' + '\Magento\Sitemap\Helper\Data::XML_PATH_PUBLIC_FILES_VALID_PATHS', ], [ 'XML_PATH_SITEMAP_VALID_PATHS', '\Magento\Catalog\Helper\Catalog', - '\Magento\Sitemap\Helper\Data::XML_PATH_SITEMAP_VALID_PATHS' + '\Magento\Sitemap\Helper\Data::XML_PATH_SITEMAP_VALID_PATHS', ], ['TYPE_PHYSICAL', '\Magento\Core\Model\Theme', '\Magento\Framework\View\Design\ThemeInterface::TYPE_PHYSICAL'], ['TYPE_VIRTUAL', '\Magento\Core\Model\Theme', '\Magento\Framework\View\Design\ThemeInterface::TYPE_VIRTUAL'], @@ -375,17 +375,17 @@ return [ [ 'XML_PATH_IMAGE_ADAPTER', '\Magento\Core\Model\Image\AdapterFactory', - '\Magento\Core\Model\Image\Adapter\Config::XML_PATH_IMAGE_ADAPTER' + '\Magento\Core\Model\Image\Adapter\Config::XML_PATH_IMAGE_ADAPTER', ], [ 'ADAPTER_IM', '\Magento\Core\Model\Image\AdapterFactory', - '\Magento\Framework\Image\Adapter\AdapterInterface::ADAPTER_IM' + '\Magento\Framework\Image\Adapter\AdapterInterface::ADAPTER_IM', ], [ 'ADAPTER_GD2', '\Magento\Core\Model\Image\AdapterFactory', - '\Magento\Framework\Image\Adapter\AdapterInterface::ADAPTER_GD2' + '\Magento\Framework\Image\Adapter\AdapterInterface::ADAPTER_GD2', ], ['XML_PATH_IMAGE_TYPES', 'Magento\Adminhtml\Block\Catalog\Product\Frontend\Product\Watermark'], ['XML_PATH_WEBHOOK', 'Magento\Webhook\Model\Source\Hook'], @@ -394,103 +394,103 @@ return [ [ 'XML_PATH_USE_FRONTEND_SID', '\Magento\Core\Model\Session\AbstractSession', - '\Magento\Framework\Session\SidResolver::XML_PATH_USE_FRONTEND_SID' + '\Magento\Framework\Session\SidResolver::XML_PATH_USE_FRONTEND_SID', ], [ 'SESSION_ID_QUERY_PARAM', '\Magento\Core\Model\Session\AbstractSession', - '\Magento\Framework\Session\SidResolverInterface::SESSION_ID_QUERY_PARAM' + '\Magento\Framework\Session\SidResolverInterface::SESSION_ID_QUERY_PARAM', ], [ 'XML_PATH_COOKIE_DOMAIN', '\Magento\Framework\Stdlib\Cookie', - '\Magento\Core\Model\Session\Config::XML_PATH_COOKIE_DOMAIN' + '\Magento\Core\Model\Session\Config::XML_PATH_COOKIE_DOMAIN', ], [ 'XML_PATH_COOKIE_PATH', '\Magento\Framework\Stdlib\Cookie', - '\Magento\Core\Model\Session\Config::XML_PATH_COOKIE_PATH' + '\Magento\Core\Model\Session\Config::XML_PATH_COOKIE_PATH', ], [ 'XML_PATH_COOKIE_LIFETIME', '\Magento\Framework\Stdlib\Cookie', - '\Magento\Core\Model\Session\Config::XML_PATH_COOKIE_LIFETIME' + '\Magento\Core\Model\Session\Config::XML_PATH_COOKIE_LIFETIME', ], [ 'XML_PATH_COOKIE_HTTPONLY', '\Magento\Framework\Stdlib\Cookie', - '\Magento\Core\Model\Session\Config::XML_PATH_COOKIE_HTTPONLY' + '\Magento\Core\Model\Session\Config::XML_PATH_COOKIE_HTTPONLY', ], [ 'PARAM_SESSION_SAVE_METHOD', '\Magento\Core\Model\Session\AbstractSession', - '\Magento\Core\Model\Session\Config::PARAM_SESSION_SAVE_METHOD' + '\Magento\Core\Model\Session\Config::PARAM_SESSION_SAVE_METHOD', ], [ 'PARAM_SESSION_SAVE_PATH', '\Magento\Core\Model\Session\AbstractSession', - '\Magento\Core\Model\Session\Config::PARAM_SESSION_SAVE_PATH' + '\Magento\Core\Model\Session\Config::PARAM_SESSION_SAVE_PATH', ], [ 'PARAM_SESSION_CACHE_LIMITER', '\Magento\Core\Model\Session\AbstractSession', - '\Magento\Core\Model\Session\Config::PARAM_SESSION_CACHE_LIMITER' + '\Magento\Core\Model\Session\Config::PARAM_SESSION_CACHE_LIMITER', ], [ 'XML_NODE_SESSION_SAVE_PATH', 'Magento\Core\Model\Session\AbstractSession', - 'Magento\Core\Model\Session\Config::PARAM_SESSION_SAVE_PATH' + 'Magento\Core\Model\Session\Config::PARAM_SESSION_SAVE_PATH', ], [ 'XML_NODE_SESSION_SAVE', 'Magento\Core\Model\Session\AbstractSession', - 'Magento\Core\Model\Session\Config::PARAM_SESSION_SAVE_METHOD' + 'Magento\Core\Model\Session\Config::PARAM_SESSION_SAVE_METHOD', ], ['XML_PATH_LOG_EXCEPTION_FILE', 'Magento\Core\Model\Session\AbstractSession'], [ 'XML_PATH_ROBOTS_DEFAULT_CUSTOM_INSTRUCTIONS', 'Magento\Theme\Helper\Robots', - 'Magento\Backend\Block\Page\System\Config\Robots::XML_PATH_ROBOTS_DEFAULT_CUSTOM_INSTRUCTIONS' + 'Magento\Backend\Block\Page\System\Config\Robots::XML_PATH_ROBOTS_DEFAULT_CUSTOM_INSTRUCTIONS', ], [ 'XML_PATH_MERGE_CSS_FILES', 'Magento\Framework\View\Asset\MergeService', - 'Magento\Core\Model\Asset\Config::XML_PATH_MERGE_CSS_FILES' + 'Magento\Core\Model\Asset\Config::XML_PATH_MERGE_CSS_FILES', ], [ 'XML_PATH_MERGE_JS_FILES', 'Magento\Framework\View\Asset\MergeService', - 'Magento\Core\Model\Asset\Config::XML_PATH_MERGE_JS_FILES' + 'Magento\Core\Model\Asset\Config::XML_PATH_MERGE_JS_FILES', ], [ 'XML_PATH_MINIFICATION_ENABLED', 'Magento\Framework\View\Asset\MinifyService', - 'Magento\Core\Model\Asset\Config::XML_PATH_MINIFICATION_ENABLED' + 'Magento\Core\Model\Asset\Config::XML_PATH_MINIFICATION_ENABLED', ], [ 'XML_PATH_MINIFICATION_ADAPTER', 'Magento\Framework\View\Asset\MinifyService', - 'Magento\Core\Model\Asset\Config::XML_PATH_MINIFICATION_ADAPTER' + 'Magento\Core\Model\Asset\Config::XML_PATH_MINIFICATION_ADAPTER', ], [ 'USE_PARENT_IMAGE', 'Magento\ConfigurableProduct\Block\Cart\Item\Renderer\Configurable', - 'Magento\Catalog\Model\Config\Source\Product\Thumbnail::OPTION_USE_PARENT_IMAGE' + 'Magento\Catalog\Model\Config\Source\Product\Thumbnail::OPTION_USE_PARENT_IMAGE', ], [ 'USE_PARENT_IMAGE', 'Magento\GroupedProduct\Block\Cart\Item\Renderer\Grouped', - 'Magento\Catalog\Model\Config\Source\Product\Thumbnail::OPTION_USE_PARENT_IMAGE' + 'Magento\Catalog\Model\Config\Source\Product\Thumbnail::OPTION_USE_PARENT_IMAGE', ], [ 'CONFIGURABLE_PRODUCT_IMAGE', 'Magento\ConfigurableProduct\Block\Cart\Item\Renderer\Configurable', - 'Magento\ConfigurableProduct\Block\Cart\Item\Renderer\Configurable::CONFIG_THUMBNAIL_SOURCE' + 'Magento\ConfigurableProduct\Block\Cart\Item\Renderer\Configurable::CONFIG_THUMBNAIL_SOURCE', ], [ 'GROUPED_PRODUCT_IMAGE', 'Magento\GroupedProduct\Block\Cart\Item\Renderer\Grouped', - 'Magento\GroupedProduct\Block\Cart\Item\Renderer\Grouped::CONFIG_THUMBNAIL_SOURCE' + 'Magento\GroupedProduct\Block\Cart\Item\Renderer\Grouped::CONFIG_THUMBNAIL_SOURCE', ], ['TYPE_BLOCK', 'Magento\Framework\View\Layout', '\Magento\Framework\View\Layout\Element'], ['TYPE_CONTAINER', 'Magento\Framework\View\Layout', '\Magento\Framework\View\Layout\Element'], @@ -512,36 +512,36 @@ return [ [ 'MAX_QTY_VALUE', '\Magento\Catalog\Controller\Adminhtml\Product', - 'Magento\Catalog\Controller\Adminhtml\Product\Initialization\StockDataFilter::MAX_QTY_VALUE' + 'Magento\Catalog\Controller\Adminhtml\Product\Initialization\StockDataFilter::MAX_QTY_VALUE', ], [ 'LINK_TYPE_GROUPED', '\Magento\Catalog\Model\Product\Link', - '\Magento\GroupedProduct\Model\Resource\Product\Link::LINK_TYPE_GROUPED' + '\Magento\GroupedProduct\Model\Resource\Product\Link::LINK_TYPE_GROUPED', ], [ 'TYPE_GROUPED', '\Magento\Catalog\Model\Product\Type', - '\Magento\GroupedProduct\Model\Resource\Product\Link::LINK_TYPE_GROUPED' + '\Magento\GroupedProduct\Model\Resource\Product\Link::LINK_TYPE_GROUPED', ], ['PARAM_APP_URIS', 'Magento\Framework\Filesystem'], ['ROOT_DIR', '\Magento\Framework\App\Filesystem', '\Magento\Framework\App\Filesystem\DirectoryList::ROOT'], ['APP_DIR', '\Magento\Framework\App\Filesystem', '\Magento\Framework\App\Filesystem\DirectoryList::APP'], ['MODULES_DIR', '\Magento\Framework\App\Filesystem', - '\Magento\Framework\App\Filesystem\DirectoryList::MODULES' + '\Magento\Framework\App\Filesystem\DirectoryList::MODULES', ], ['THEMES_DIR', '\Magento\Framework\App\Filesystem', - '\Magento\Framework\App\Filesystem\DirectoryList::THEMES' + '\Magento\Framework\App\Filesystem\DirectoryList::THEMES', ], ['CONFIG_DIR', '\Magento\Framework\App\Filesystem', - '\Magento\Framework\App\Filesystem\DirectoryList::CONFIG' + '\Magento\Framework\App\Filesystem\DirectoryList::CONFIG', ], ['LIB_INTERNAL', '\Magento\Framework\App\Filesystem', - '\Magento\Framework\App\Filesystem\DirectoryList::LIB_INTERNAL' + '\Magento\Framework\App\Filesystem\DirectoryList::LIB_INTERNAL', ], ['LOCALE_DIR', '\Magento\Framework\App\Filesystem', '\Magento\Framework\App\Filesystem\DirectoryList::LOCALE'], ['PUB_DIR', '\Magento\Framework\App\Filesystem', '\Magento\Framework\App\Filesystem\DirectoryList::PUB'], @@ -549,7 +549,7 @@ return [ ['MEDIA_DIR', '\Magento\Framework\App\Filesystem', '\Magento\Framework\App\Filesystem\DirectoryList::MEDIA'], ['STATIC_VIEW_DIR', '\Magento\Framework\App\Filesystem', - '\Magento\Framework\App\Filesystem\DirectoryList::STATIC_VIEW' + '\Magento\Framework\App\Filesystem\DirectoryList::STATIC_VIEW', ], ['VAR_DIR', '\Magento\Framework\App\Filesystem', '\Magento\Framework\App\Filesystem\DirectoryList::VAR_DIR'], ['TMP_DIR', '\Magento\Framework\App\Filesystem', '\Magento\Framework\App\Filesystem\DirectoryList::TMP'], @@ -557,31 +557,31 @@ return [ ['LOG_DIR', '\Magento\Framework\App\Filesystem', '\Magento\Framework\App\Filesystem\DirectoryList::LOG'], ['SESSION_DIR', '\Magento\Framework\App\Filesystem', - '\Magento\Framework\App\Filesystem\DirectoryList::SESSION' + '\Magento\Framework\App\Filesystem\DirectoryList::SESSION', ], ['DI_DIR', '\Magento\Framework\App\Filesystem', '\Magento\Framework\App\Filesystem\DirectoryList::DI'], ['GENERATION_DIR', '\Magento\Framework\App\Filesystem', - '\Magento\Framework\App\Filesystem\DirectoryList::GENERATION' + '\Magento\Framework\App\Filesystem\DirectoryList::GENERATION', ], ['UPLOAD_DIR', '\Magento\Framework\App\Filesystem', - '\Magento\Framework\App\Filesystem\DirectoryList::UPLOAD' + '\Magento\Framework\App\Filesystem\DirectoryList::UPLOAD', ], ['SYS_TMP_DIR', '\Magento\Framework\App\Filesystem', - '\Magento\Framework\Filesystem\DirectoryList::SYS_TMP' + '\Magento\Framework\Filesystem\DirectoryList::SYS_TMP', ], ['LAYOUT_NAVIGATION_CLASS_NAME', 'Magento\DesignEditor\Model\State'], [ 'TYPE_CONFIGURABLE', '\Magento\Catalog\Model\Product\Type', - '\Magento\ConfigurableProduct\Model\Product\Type\Configurable::TYPE_CODE' + '\Magento\ConfigurableProduct\Model\Product\Type\Configurable::TYPE_CODE', ], [ 'XML_PATH_IS_ENABLED_FLAT_CATALOG_CATEGORY', '\Magento\Catalog\Helper\Category\Flat', - '\Magento\Catalog\Model\Indexer\Category\Flat\Config::XML_PATH_IS_ENABLED_FLAT_CATALOG_CATEGORY' + '\Magento\Catalog\Model\Indexer\Category\Flat\Config::XML_PATH_IS_ENABLED_FLAT_CATALOG_CATEGORY', ], ['CSV_SEPARATOR', 'Magento\Framework\Translate'], ['SCOPE_SEPARATOR', 'Magento\Framework\Translate'], @@ -592,17 +592,17 @@ return [ [ 'XML_NODE_MAX_INDEX_COUNT', 'Magento\Catalog\Model\Indexer\Product\Flat\AbstractAction', - 'Magento\Catalog\Model\Indexer\Product\Flat\FlatTableBuilder' + 'Magento\Catalog\Model\Indexer\Product\Flat\FlatTableBuilder', ], [ 'ATTRIBUTES_CHUNK_SIZE', 'Magento\Catalog\Model\Indexer\Product\Flat\AbstractAction', - 'Magento\Catalog\Model\Indexer\Product\Flat\Action\Indexer' + 'Magento\Catalog\Model\Indexer\Product\Flat\Action\Indexer', ], [ 'CACHE_CATEGORY_TAG', 'Magento\Catalog\Model\Product', - 'Magento\Catalog\Model\Product::CACHE_PRODUCT_CATEGORY_TAG' + 'Magento\Catalog\Model\Product::CACHE_PRODUCT_CATEGORY_TAG', ], ['XML_PATH_UNSECURE_BASE_LIB_URL'], ['XML_PATH_SECURE_BASE_LIB_URL'], @@ -621,12 +621,12 @@ return [ [ 'PARAM_APP_DIRS', 'Magento\Framework\App\Filesystem', - '\Magento\Framework\App\Bootstrap::INIT_PARAM_FILESYSTEM_DIR_PATHS' + '\Magento\Framework\App\Bootstrap::INIT_PARAM_FILESYSTEM_DIR_PATHS', ], [ 'CACHE_VIEW_REL_DIR', 'Magento\Framework\App\Filesystem', - '\Magento\Framework\View\Asset\Minified::CACHE_VIEW_REL' + '\Magento\Framework\View\Asset\Minified::CACHE_VIEW_REL', ], ['WRAPPER_CONTENT_ZLIB', 'Magento\Framework\Filesystem', '\Magento\Framework\Filesystem\DriverPool::ZLIB'], ['WRAPPER_CONTENT_PHAR', 'Magento\Framework\Filesystem'], @@ -669,21 +669,32 @@ return [ [ 'PARAM_ALLOWED_MODULES', 'Magento\Framework\Module\Declaration\Reader\Filesystem', - 'Magento\Framework\App\ObjectManagerFactory::INIT_PARAM_DEPLOYMENT_CONFIG' + 'Magento\Framework\App\ObjectManagerFactory::INIT_PARAM_DEPLOYMENT_CONFIG', ], [ 'NOT_INSTALLED_URL_PATH_PARAM', 'Magento\Framework\App\Http', - 'Magento\Framework\App\SetupInfo::PARAM_NOT_INSTALLED_URL_PATH' + 'Magento\Framework\App\SetupInfo::PARAM_NOT_INSTALLED_URL_PATH', ], [ 'NOT_INSTALLED_URL_PARAM', 'Magento\Framework\App\Http', - 'Magento\Framework\App\SetupInfo::PARAM_NOT_INSTALLED_URL' + 'Magento\Framework\App\SetupInfo::PARAM_NOT_INSTALLED_URL', ], [ 'NOT_INSTALLED_URL_PATH', 'Magento\Framework\App\Http', - 'Magento\Framework\App\SetupInfo::DEFAULT_PATH' + 'Magento\Framework\App\SetupInfo::DEFAULT_PATH', ], + [ + 'DEFAULT_ATTRIBUTE_SET_ID', + 'Magento\Catalog\Api\Data\CategoryAttributeInterface', + 'Use \Magento\Eav\Model\Entity\Type::getDefaultAttributeSetId() method instead', + ], + [ + 'DEFAULT_ATTRIBUTE_SET_ID', + '\Magento\Catalog\Api\Data\ProductAttributeInterface', + 'Use \Magento\Eav\Model\Entity\Type::getDefaultAttributeSetId() method instead', + ], + ['CONFIG_PATH_WSDL_CACHE_ENABLED', 'Magento\Webapi\Model\Soap\Server'], ]; 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 77afd6d62a2ffa35e950fbb7efb73914513aa736..e47cc2c1d2d314c6050365aeea5d2b1707bb36d0 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 @@ -2041,6 +2041,7 @@ return [ ['_initSendToFriendModel', 'Magento\Sendfriend\Controller\Product'], ['register', 'Magento\Sendfriend\Model\Sendfriend'], ['_getImageHelper', 'Magento\Catalog\Model\Product'], + ['streamOpen', 'Magento\Framework\Io\File'], ['getPreProcessors', 'Magento\Framework\View\Asset\PreProcessor\Pool', 'process'], ['isPhpFile', '\Magento\Tools\Di\Code\Reader\ClassesScanner'], ['renderPage', 'Magento\Cms\Helper\Page'], @@ -2104,6 +2105,19 @@ return [ 'Magento\Integration\Helper\Validator', 'Magento\Integration\Model\CredentialsValidator::validate' ], + ['isReviewOwner', 'Magento\Review\Block\Customer\View'], + ['getRegistration', 'Magento\Customer\Block\Form\Login', 'Magento\Customer\Block\Form\Login\Info::getRegistration'], + ['getCreateAccountUrl', 'Magento\Customer\Block\Form\Login', 'Magento\Customer\Block\Form\Login\Info::getCreateAccountUrl'], + ['getSuccessMessage', 'Magento\Newsletter\Block\Subscribe'], + ['getErrorMessage', 'Magento\Newsletter\Block\Subscribe'], + ['_initCollection', 'Magento\Review\Block\Customer\ListCustomer'], + ['count', 'Magento\Review\Block\Customer\ListCustomer'], + ['_getCollection', 'Magento\Review\Block\Customer\ListCustomer'], + ['getCollection', 'Magento\Review\Block\Customer\ListCustomer', 'Magento\Review\Block\Customer\ListCustomer::getReviews'], + ['_initCollection', 'Magento\Review\Block\Customer\Recent'], + ['count', 'Magento\Review\Block\Customer\Recent'], + ['_getCollection', 'Magento\Review\Block\Customer\Recent'], + ['getCollection', 'Magento\Review\Block\Customer\Recent', 'Magento\Review\Block\Customer\Recent::getReviews'], ['getProductEntityTypeId', 'Magento\Reports\Model\Resource\Product\Collection'], ['setProductEntityTypeId', 'Magento\Reports\Model\Resource\Product\Collection'], ['bindLocale', 'Magento\Backend\Model\Observer'], diff --git a/dev/tests/unit/.gitignore b/dev/tests/unit/.gitignore index ace6e823e41a3ed294eb1ed9a1a14451bd3e2e8c..319b3826f933880445af33b78c1ee4e05666d321 100644 --- a/dev/tests/unit/.gitignore +++ b/dev/tests/unit/.gitignore @@ -1,2 +1 @@ /phpunit.xml -tmp diff --git a/dev/tests/unit/framework/autoload.php b/dev/tests/unit/framework/autoload.php new file mode 100644 index 0000000000000000000000000000000000000000..56021a2bb4acf835cf73ebb210789a84d77c2818 --- /dev/null +++ b/dev/tests/unit/framework/autoload.php @@ -0,0 +1,55 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +use Magento\Framework\Api\Code\Generator\DataBuilder; +use Magento\Framework\Api\Code\Generator\Mapper; +use Magento\Framework\Api\Code\Generator\ExtensionAttributesGenerator; +use Magento\Framework\Api\Code\Generator\ExtensionAttributesInterfaceGenerator; +use Magento\Framework\Api\Code\Generator\SearchResults; +use Magento\Framework\Api\Code\Generator\SearchResultsBuilder; +use Magento\Framework\Interception\Code\Generator\Interceptor; +use Magento\Framework\ObjectManager\Code\Generator\Converter; +use Magento\Framework\ObjectManager\Code\Generator\Factory; +use Magento\Framework\ObjectManager\Code\Generator\Persistor; +use Magento\Framework\ObjectManager\Code\Generator\Proxy; +use Magento\Framework\ObjectManager\Code\Generator\Repository; +use Magento\Tools\Di\Code\Scanner; +use Magento\Tools\Di\Compiler\Log\Writer; +use Magento\Tools\Di\Definition\Compressor; + +/** + * Enable code generation for the undeclared classes. + */ +$generationDir = TESTS_TEMP_DIR . '/var/generation'; +$generatorIo = new \Magento\Framework\Code\Generator\Io( + new \Magento\Framework\Filesystem\Driver\File(), + $generationDir +); +$generator = new \Magento\Framework\Code\Generator( + $generatorIo, + [ + Interceptor::ENTITY_TYPE => 'Magento\Framework\Interception\Code\Generator\Interceptor', + Proxy::ENTITY_TYPE => 'Magento\Framework\ObjectManager\Code\Generator\Proxy', + Factory::ENTITY_TYPE => 'Magento\Framework\ObjectManager\Code\Generator\Factory', + Mapper::ENTITY_TYPE => 'Magento\Framework\Api\Code\Generator\Mapper', + Persistor::ENTITY_TYPE => 'Magento\Framework\ObjectManager\Code\Generator\Persistor', + Repository::ENTITY_TYPE => 'Magento\Framework\ObjectManager\Code\Generator\Repository', + Converter::ENTITY_TYPE => 'Magento\Framework\ObjectManager\Code\Generator\Converter', + SearchResults::ENTITY_TYPE => 'Magento\Framework\Api\Code\Generator\SearchResults', + ExtensionAttributesInterfaceGenerator::ENTITY_TYPE => + 'Magento\Framework\Api\Code\Generator\ExtensionAttributesInterfaceGenerator', + ExtensionAttributesGenerator::ENTITY_TYPE => 'Magento\Framework\Api\Code\Generator\ExtensionAttributesGenerator' + ] +); +/** Initialize object manager for code generation based on configs */ +$magentoObjectManagerFactory = \Magento\Framework\App\Bootstrap::createObjectManagerFactory(BP, $_SERVER); +$objectManager = $magentoObjectManagerFactory->create($_SERVER); +$generator->setObjectManager($objectManager); + +$autoloader = new \Magento\Framework\Code\Generator\Autoloader($generator); +spl_autoload_register([$autoloader, 'load']); +$autoloadWrapper = \Magento\Framework\Autoload\AutoloaderRegistry::getAutoloader(); +$autoloadWrapper->addPsr4('Magento\\', $generationDir . '/Magento/'); diff --git a/dev/tests/unit/framework/bootstrap.php b/dev/tests/unit/framework/bootstrap.php index afd5f88e899199d6db3934bb2d3e2d64431a972f..b30486b50a17dc3a6e0b67adaa072868b1747736 100755 --- a/dev/tests/unit/framework/bootstrap.php +++ b/dev/tests/unit/framework/bootstrap.php @@ -10,13 +10,9 @@ if (!defined('TESTS_TEMP_DIR')) { define('TESTS_TEMP_DIR', dirname(__DIR__) . '/tmp'); } +require_once __DIR__ . '/autoload.php'; require BP . '/app/functions.php'; -if (is_dir(TESTS_TEMP_DIR)) { - $filesystemAdapter = new \Magento\Framework\Filesystem\Driver\File(); - $filesystemAdapter->deleteDirectory(TESTS_TEMP_DIR); -} -mkdir(TESTS_TEMP_DIR); \Magento\Framework\Phrase::setRenderer(new \Magento\Framework\Phrase\Renderer\Placeholder()); diff --git a/dev/tests/unit/tmp/.gitignore b/dev/tests/unit/tmp/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..a68d087bfe51165cfcd71d2185d9d8a94855728a --- /dev/null +++ b/dev/tests/unit/tmp/.gitignore @@ -0,0 +1,2 @@ +/* +!/.gitignore diff --git a/dev/tools/Magento/Tools/Di/Code/Scanner/PhpScanner.php b/dev/tools/Magento/Tools/Di/Code/Scanner/PhpScanner.php index 6346d51bd2f8c03a820f6a56ecb9642956784ef3..bf5fc24e4749a2252511471bf3581476b9153d5e 100644 --- a/dev/tools/Magento/Tools/Di/Code/Scanner/PhpScanner.php +++ b/dev/tools/Magento/Tools/Di/Code/Scanner/PhpScanner.php @@ -6,6 +6,9 @@ namespace Magento\Tools\Di\Code\Scanner; use Magento\Tools\Di\Compiler\Log\Log; +use Magento\Framework\Api\Code\Generator\ExtensionAttributesGenerator; +use Magento\Framework\Api\Code\Generator\ExtensionAttributesInterfaceGenerator; +use Magento\Framework\ObjectManager\Code\Generator\Factory as FactoryGenerator; class PhpScanner implements ScannerInterface { @@ -23,51 +26,138 @@ class PhpScanner implements ScannerInterface } /** - * Fetch factories from class constructor + * Find classes which are used as parameters types of the specified method and are not declared. * - * @param $file string - * @param $reflectionClass mixed - * @return array + * @param string $file + * @param \ReflectionClass $classReflection + * @param string $methodName + * @param string $entityType + * @return string[] */ - protected function _fetchFactories($file, $reflectionClass) + protected function _findMissingClasses($file, $classReflection, $methodName, $entityType) { - $absentFactories = []; - if ($reflectionClass->hasMethod('__construct')) { - $constructor = $reflectionClass->getMethod('__construct'); + $missingClasses = []; + if ($classReflection->hasMethod($methodName)) { + $constructor = $classReflection->getMethod($methodName); $parameters = $constructor->getParameters(); /** @var $parameter \ReflectionParameter */ foreach ($parameters as $parameter) { preg_match('/\[\s\<\w+?>\s([\w\\\\]+)/s', $parameter->__toString(), $matches); - if (isset($matches[1]) && substr($matches[1], -7) == 'Factory') { - $factoryClassName = $matches[1]; - if (class_exists($factoryClassName)) { - continue; - } - $entityName = rtrim(substr($factoryClassName, 0, -7), '\\'); - if (!class_exists($entityName) && !interface_exists($entityName)) { - $this->_log->add( - Log::CONFIGURATION_ERROR, - $factoryClassName, - 'Invalid Factory for nonexistent class ' . $entityName . ' in file ' . $file - ); - continue; + if (isset($matches[1]) && substr($matches[1], -strlen($entityType)) == $entityType) { + $missingClassName = $matches[1]; + try { + if (class_exists($missingClassName)) { + continue; + } + } catch (\Magento\Framework\Exception $e) { } - - if (substr($factoryClassName, -8) == '\\Factory') { + $sourceClassName = $this->getSourceClassName($missingClassName, $entityType); + if (!class_exists($sourceClassName) && !interface_exists($sourceClassName)) { $this->_log->add( Log::CONFIGURATION_ERROR, - $factoryClassName, - 'Invalid Factory declaration for class ' . $entityName . ' in file ' . $file + $missingClassName, + "Invalid {$entityType} for nonexistent class {$sourceClassName} in file {$file}" ); continue; } - $absentFactories[] = $factoryClassName; + $missingClasses[] = $missingClassName; } } } + return $missingClasses; + } + + /** + * Identify source class name for the provided class. + * + * @param string $missingClassName + * @param string $entityType + * @return string + */ + protected function getSourceClassName($missingClassName, $entityType) + { + $sourceClassName = rtrim(substr($missingClassName, 0, -strlen($entityType)), '\\'); + $entityType = lcfirst($entityType); + if ($entityType == ExtensionAttributesInterfaceGenerator::ENTITY_TYPE + || $entityType == ExtensionAttributesGenerator::ENTITY_TYPE + ) { + /** Process special cases for extension class and extension interface */ + return $sourceClassName . 'Interface'; + } else if ($entityType == FactoryGenerator::ENTITY_TYPE) { + $extensionAttributesSuffix = ucfirst(ExtensionAttributesGenerator::ENTITY_TYPE); + if (substr($sourceClassName, -strlen($extensionAttributesSuffix)) == $extensionAttributesSuffix) { + /** Process special case for extension factories */ + $extensionAttributesClass = substr( + $sourceClassName, + 0, + -strlen(ExtensionAttributesGenerator::ENTITY_TYPE) + ); + $sourceClassName = $extensionAttributesClass . 'Interface'; + } + } + return $sourceClassName; + } + + /** + * Fetch factories from class constructor + * + * @param \ReflectionClass $reflectionClass + * @param string $file + * @return string[] + */ + protected function _fetchFactories($reflectionClass, $file) + { + $factorySuffix = '\\'.ucfirst(FactoryGenerator::ENTITY_TYPE); + $absentFactories = $this->_findMissingClasses( + $file, + $reflectionClass, + '__construct', + ucfirst(FactoryGenerator::ENTITY_TYPE) + ); + foreach ($absentFactories as $key => $absentFactory) { + if (substr($absentFactory, -strlen($factorySuffix)) == $factorySuffix) { + $entityName = rtrim(substr($absentFactory, 0, -strlen($factorySuffix)), '\\'); + $this->_log->add( + Log::CONFIGURATION_ERROR, + $absentFactory, + 'Invalid Factory declaration for class ' . $entityName . ' in file ' . $file + ); + unset($absentFactories[$key]); + } + } return $absentFactories; } + /** + * Find missing extension attributes related classes, interfaces and factories. + * + * @param \ReflectionClass $reflectionClass + * @param string $file + * @return string[] + */ + protected function _fetchMissingExtensionAttributesClasses($reflectionClass, $file) + { + $missingExtensionInterfaces = $this->_findMissingClasses( + $file, + $reflectionClass, + 'setExtensionAttributes', + ucfirst(\Magento\Framework\Api\Code\Generator\ExtensionAttributesInterfaceGenerator::ENTITY_TYPE) + ); + $missingExtensionClasses = []; + $missingExtensionFactories = []; + foreach ($missingExtensionInterfaces as $missingExtensionInterface) { + $extension = rtrim(substr($missingExtensionInterface, 0, -strlen('Interface')), '\\'); + if (!class_exists($extension)) { + $missingExtensionClasses[] = $extension; + } + $extensionFactory = $extension . 'Factory'; + if (!class_exists($extensionFactory)) { + $missingExtensionFactories[] = $extensionFactory; + } + } + return array_merge($missingExtensionInterfaces, $missingExtensionClasses, $missingExtensionFactories); + } + /** * Get array of class names * @@ -81,10 +171,11 @@ class PhpScanner implements ScannerInterface $classes = $this->_getDeclaredClasses($file); foreach ($classes as $className) { $reflectionClass = new \ReflectionClass($className); - $absentFactories = $this->_fetchFactories($file, $reflectionClass); - if (!empty($absentFactories)) { - $output = array_merge($output, $absentFactories); - } + $output = array_merge( + $output, + $this->_fetchFactories($reflectionClass, $file), + $this->_fetchMissingExtensionAttributesClasses($reflectionClass, $file) + ); } } return array_unique($output); @@ -128,7 +219,7 @@ class PhpScanner implements ScannerInterface } /** - * Get classes declared in the file + * Get classes and interfaces declared in the file * * @param string $file * @return array @@ -145,7 +236,9 @@ class PhpScanner implements ScannerInterface $namespace .= $this->_fetchNamespace($tokenIterator, $count, $tokens); } - if ($tokens[$tokenIterator][0] === T_CLASS) { + if ($tokens[$tokenIterator][0] === T_CLASS + || $tokens[$tokenIterator][0] === T_INTERFACE + ) { $classes = array_merge($classes, $this->_fetchClasses($namespace, $tokenIterator, $count, $tokens)); } } diff --git a/dev/tools/Magento/Tools/Di/Code/Scanner/XmlScanner.php b/dev/tools/Magento/Tools/Di/Code/Scanner/XmlScanner.php index 23ad5d57a25ef85c8a13b6234f4d83d91f3cc406..9f0b2ec3304b621728a6e94efb15f738b96170a9 100644 --- a/dev/tools/Magento/Tools/Di/Code/Scanner/XmlScanner.php +++ b/dev/tools/Magento/Tools/Di/Code/Scanner/XmlScanner.php @@ -5,6 +5,8 @@ */ namespace Magento\Tools\Di\Code\Scanner; +use Magento\Framework\ObjectManager\Code\Generator\Proxy as ProxyGenerator; + class XmlScanner implements ScannerInterface { /** @@ -57,10 +59,18 @@ class XmlScanner implements ScannerInterface */ protected function _filterEntities(array $output) { + $entitySuffix = '\\' . ucfirst(ProxyGenerator::ENTITY_TYPE); $filteredEntities = []; foreach ($output as $className) { - $entityName = substr($className, -6) === '\Proxy' ? substr($className, 0, -6) : $className; - if (false === class_exists($className)) { + $entityName = substr($className, -strlen($entitySuffix)) === $entitySuffix + ? substr($className, 0, -strlen($entitySuffix)) + : $className; + $isClassExists = false; + try { + $isClassExists = class_exists($className); + } catch (\Magento\Framework\Exception $e) { + } + if (false === $isClassExists) { if (class_exists($entityName) || interface_exists($entityName)) { array_push($filteredEntities, $className); } else { diff --git a/dev/tools/Magento/Tools/Di/Test/Unit/Code/Scanner/PluginScannerTest.php b/dev/tools/Magento/Tools/Di/Test/Unit/Code/Scanner/PluginScannerTest.php index 5f1d6f4b093b8f5683a9ed17d4aecf012206b2c7..adc1ebf2eaa69c83ebad7a3bba9926d09141ac49 100644 --- a/dev/tools/Magento/Tools/Di/Test/Unit/Code/Scanner/PluginScannerTest.php +++ b/dev/tools/Magento/Tools/Di/Test/Unit/Code/Scanner/PluginScannerTest.php @@ -3,6 +3,9 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ + +// @codingStandardsIgnoreFile + namespace Magento\Tools\Di\Test\Unit\Code\Scanner; class PluginScannerTest extends \PHPUnit_Framework_TestCase @@ -25,7 +28,7 @@ class PluginScannerTest extends \PHPUnit_Framework_TestCase public function testCollectEntities() { $actual = $this->_model->collectEntities($this->_testFiles); - $expected = ['Magento\Framework\App\Cache\TagPlugin', 'Magento\Core\Model\Action\Plugin']; + $expected = ['Magento\Framework\App\Cache\TagPlugin', 'Magento\Store\Model\Action\Plugin']; $this->assertEquals($expected, $actual); } } diff --git a/dev/tools/Magento/Tools/Di/Test/Unit/Code/Scanner/XmlScannerTest.php b/dev/tools/Magento/Tools/Di/Test/Unit/Code/Scanner/XmlScannerTest.php index b0dde77698a5b0e25b62cea423d959f616735628..b1cd9b3dac280b565d3d152a5c49c2d9b9da1688 100644 --- a/dev/tools/Magento/Tools/Di/Test/Unit/Code/Scanner/XmlScannerTest.php +++ b/dev/tools/Magento/Tools/Di/Test/Unit/Code/Scanner/XmlScannerTest.php @@ -3,6 +3,9 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ + +// @codingStandardsIgnoreFile + namespace Magento\Tools\Di\Test\Unit\Code\Scanner; class XmlScannerTest extends \PHPUnit_Framework_TestCase @@ -37,7 +40,7 @@ class XmlScannerTest extends \PHPUnit_Framework_TestCase public function testCollectEntities() { - $className = 'Magento\Core\Model\Config\Invalidator\Proxy'; + $className = 'Magento\Store\Model\Config\Invalidator\Proxy'; $this->_logMock->expects( $this->at(0) )->method( @@ -66,7 +69,7 @@ class XmlScannerTest extends \PHPUnit_Framework_TestCase 'Invalid proxy class for ' . substr('\Magento\SomeModule\Model\Nested\Element\Proxy', 0, -5) ); $actual = $this->_model->collectEntities($this->_testFiles); - $expected = ['Magento\Framework\App\Request\Http\Proxy']; + $expected = []; $this->assertEquals($expected, $actual); } } diff --git a/dev/tools/Magento/Tools/Di/Test/Unit/_files/app/code/Magento/SomeModule/etc/di.xml b/dev/tools/Magento/Tools/Di/Test/Unit/_files/app/code/Magento/SomeModule/etc/di.xml index 9e27e302529b55ca1826e7021f752f59024902bb..5466e9a385bc24a8e1766bf54613aae8c10701c1 100644 --- a/dev/tools/Magento/Tools/Di/Test/Unit/_files/app/code/Magento/SomeModule/etc/di.xml +++ b/dev/tools/Magento/Tools/Di/Test/Unit/_files/app/code/Magento/SomeModule/etc/di.xml @@ -7,7 +7,7 @@ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../../../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd"> <preference for="Magento\Framework\App\RequestInterface" type="Magento\Framework\App\Request\Http\Proxy" /> - <preference for="Magento\Core\Model\Config\InvalidatorInterface" type="Magento\Core\Model\Config\Invalidator\Proxy" /> + <preference for="Magento\Store\Model\Config\InvalidatorInterface" type="Magento\Store\Model\Config\Invalidator\Proxy" /> <preference for="Magento\Framework\App\CacheInterface" type="Magento\Framework\App\Cache\Proxy" /> <virtualType name="custom_cache_instance" type="Magento\Framework\App\Cache"> <plugin name="tag" type="Magento\Framework\App\Cache\TagPlugin" /> diff --git a/dev/tools/Magento/Tools/Di/Test/Unit/_files/app/etc/config.xml b/dev/tools/Magento/Tools/Di/Test/Unit/_files/app/etc/config.xml index 1a33cc70899009144bbab6efd95df5dd01f7b834..2197266b7f07fd276114725c09ba157f35d60c57 100644 --- a/dev/tools/Magento/Tools/Di/Test/Unit/_files/app/etc/config.xml +++ b/dev/tools/Magento/Tools/Di/Test/Unit/_files/app/etc/config.xml @@ -6,5 +6,5 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:noNamespaceSchemaLocation="../../../../../../../../../../../app/code/Magento/Core/etc/config.xsd"> + xsi:noNamespaceSchemaLocation="../../../../../../../../../../../app/code/Magento/Store/etc/config.xsd"> </config> diff --git a/dev/tools/Magento/Tools/Di/Test/Unit/_files/app/etc/di/config.xml b/dev/tools/Magento/Tools/Di/Test/Unit/_files/app/etc/di/config.xml index 4661287ae38cb1271db8638c12366b57f3bd0919..8638b10700e02310375a9dc43efe0a89b50eb15d 100644 --- a/dev/tools/Magento/Tools/Di/Test/Unit/_files/app/etc/di/config.xml +++ b/dev/tools/Magento/Tools/Di/Test/Unit/_files/app/etc/di/config.xml @@ -15,7 +15,7 @@ <arguments> <argument name="layoutFactory" xsi:type="object">customLayoutFactory</argument> </arguments> - <plugin name="first" type="Magento\Core\Model\Action\Plugin" /> + <plugin name="first" type="Magento\Store\Model\Action\Plugin" /> </type> <virtualType name="customStoreManagerProxy" type="Magento\Store\Model\StoreManager\Proxy" /> <virtualType name="customLayoutFactory" type="Magento\Framework\View\LayoutFactory" /> diff --git a/dev/tools/Magento/Tools/Di/compiler.php b/dev/tools/Magento/Tools/Di/compiler.php index 8fb0cd5d24c18a29736cc083757ebaceb1c6b0cb..fee6aa1320565f3f45bb6247e184ff5a756ae24c 100644 --- a/dev/tools/Magento/Tools/Di/compiler.php +++ b/dev/tools/Magento/Tools/Di/compiler.php @@ -15,7 +15,8 @@ use Magento\Framework\ObjectManager\Code\Generator\Factory; use Magento\Framework\ObjectManager\Code\Generator\Proxy; use Magento\Framework\ObjectManager\Code\Generator\Repository; use Magento\Framework\ObjectManager\Code\Generator\Persistor; -use Magento\Framework\Api\Code\Generator\ObjectExtensionInterface; +use Magento\Framework\Api\Code\Generator\ExtensionAttributesGenerator; +use Magento\Framework\Api\Code\Generator\ExtensionAttributesInterfaceGenerator; use Magento\Tools\Di\Code\Scanner; use Magento\Tools\Di\Compiler\Log\Log; use Magento\Tools\Di\Compiler\Log\Writer; @@ -103,10 +104,16 @@ try { Repository::ENTITY_TYPE => 'Magento\Framework\ObjectManager\Code\Generator\Repository', Converter::ENTITY_TYPE => 'Magento\Framework\ObjectManager\Code\Generator\Converter', SearchResults::ENTITY_TYPE => 'Magento\Framework\Api\Code\Generator\SearchResults', - ObjectExtensionInterface::ENTITY_TYPE => - 'Magento\Framework\Api\Code\Generator\ObjectExtensionInterface' + ExtensionAttributesInterfaceGenerator::ENTITY_TYPE => + 'Magento\Framework\Api\Code\Generator\ExtensionAttributesInterfaceGenerator', + ExtensionAttributesGenerator::ENTITY_TYPE => + 'Magento\Framework\Api\Code\Generator\ExtensionAttributesGenerator' ] ); + /** Initialize object manager for code generation based on configs */ + $magentoObjectManagerFactory = \Magento\Framework\App\Bootstrap::createObjectManagerFactory(BP, $_SERVER); + $objectManager = $magentoObjectManagerFactory->create($_SERVER); + $generator->setObjectManager($objectManager); $generatorAutoloader = new \Magento\Framework\Code\Generator\Autoloader($generator); spl_autoload_register([$generatorAutoloader, 'load']); @@ -235,6 +242,17 @@ try { if ($log->hasError()) { exit(1); } + + echo 'On *nix systems, verify the Magento application has permissions to modify files created by the compiler' + . ' in the "var" directory. For instance, if you run the Magento application using Apache,' + . ' the owner of the files in the "var" directory should be the Apache user (example command:' + . ' "chown -R www-data:www-data <MAGENTO_ROOT>/var" where MAGENTO_ROOT is the Magento root directory).' . "\n"; + /** TODO: Temporary solution before having necessary changes on bamboo to overcome issue described above */ + $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($rootDir . '/var')); + foreach ($iterator as $item) { + chmod($item, 0777); + } + } catch (Zend_Console_Getopt_Exception $e) { echo $e->getUsageMessage(); echo 'Please, use quotes(") for wrapping strings.' . "\n"; diff --git a/dev/tools/Magento/Tools/Di/entity_generator.php b/dev/tools/Magento/Tools/Di/entity_generator.php index 9a94fe29156e77c22335b424739a20c2862744f9..4ab81346a4e3b3b555936a9ed1136ea163e28fb8 100644 --- a/dev/tools/Magento/Tools/Di/entity_generator.php +++ b/dev/tools/Magento/Tools/Di/entity_generator.php @@ -16,7 +16,8 @@ use Magento\Framework\ObjectManager\Code\Generator\Converter; use Magento\Framework\ObjectManager\Code\Generator\Factory; use Magento\Framework\ObjectManager\Code\Generator\Proxy; use Magento\Framework\ObjectManager\Code\Generator\Repository; -use Magento\Framework\Api\Code\Generator\ObjectExtensionInterface; +use Magento\Framework\Api\Code\Generator\ExtensionAttributesInterfaceGenerator; +use Magento\Framework\Api\Code\Generator\ExtensionAttributesGenerator; require __DIR__ . '/../../../../../app/bootstrap.php'; @@ -70,7 +71,6 @@ try { //reinit generator with correct generation path $io = new Io(new File(), $generationDir); $generator = new Generator( - $validator, $io, [ Proxy::ENTITY_TYPE => 'Magento\Framework\ObjectManager\Code\Generator\Proxy', @@ -80,10 +80,15 @@ $generator = new Generator( Repository::ENTITY_TYPE => 'Magento\Framework\ObjectManager\Code\Generator\Repository', Converter::ENTITY_TYPE => 'Magento\Framework\ObjectManager\Code\Generator\Converter', SearchResults::ENTITY_TYPE => 'Magento\Framework\Api\Code\Generator\SearchResults', - ObjectExtensionInterface::ENTITY_TYPE => - 'Magento\Framework\Api\Code\Generator\ObjectExtensionInterface' + ExtensionAttributesInterfaceGenerator::ENTITY_TYPE => + 'Magento\Framework\Api\Code\Generator\ExtensionAttributesInterfaceGenerator', + ExtensionAttributesGenerator::ENTITY_TYPE => 'Magento\Framework\Api\Code\Generator\ExtensionAttributesGenerator' ] ); +/** Initialize object manager for code generation based on configs */ +$magentoObjectManagerFactory = \Magento\Framework\App\Bootstrap::createObjectManagerFactory(BP, $_SERVER); +$objectManager = $magentoObjectManagerFactory->create($_SERVER); +$generator->setObjectManager($objectManager); try { if (Generator::GENERATION_SUCCESS == $generator->generateClass($className)) { diff --git a/dev/tools/Magento/Tools/I18n/Test/Unit/FactoryTest.php b/dev/tools/Magento/Tools/I18n/Test/Unit/FactoryTest.php index 742a8915e337a020bcd4477b01e3a54f79a61bd0..9d7b19a228b410627c063090415fa43932b97442 100644 --- a/dev/tools/Magento/Tools/I18n/Test/Unit/FactoryTest.php +++ b/dev/tools/Magento/Tools/I18n/Test/Unit/FactoryTest.php @@ -39,15 +39,15 @@ class FactoryTest extends \PHPUnit_Framework_TestCase return [ [ 'Magento\Tools\I18n\Dictionary\Writer\Csv', - 'filename.invalid_type', + TESTS_TEMP_DIR . '/filename.invalid_type', ], [ 'Magento\Tools\I18n\Dictionary\Writer\Csv', - 'filename' + TESTS_TEMP_DIR . '/filename' ], [ 'Magento\Tools\I18n\Dictionary\Writer\Csv', - 'filename.csv' + TESTS_TEMP_DIR . '/filename.csv' ], [ 'Magento\Tools\I18n\Dictionary\Writer\Csv\Stdo', diff --git a/dev/tools/Magento/Tools/Migration/factory_table_names/replace_ce.php b/dev/tools/Magento/Tools/Migration/factory_table_names/replace_ce.php index 16a5a652c611981b722644302fd253217a6c3533..404a302306fe58864f083c64881fac381253eeb4 100644 --- a/dev/tools/Magento/Tools/Migration/factory_table_names/replace_ce.php +++ b/dev/tools/Magento/Tools/Migration/factory_table_names/replace_ce.php @@ -123,19 +123,18 @@ return [ 'cms/page' => 'cms_page', 'cms/page_store' => 'cms_page_store', 'compiler/configuration' => 'compiler_configuration', - 'core/cache' => 'core_cache', - 'core/cache_tag' => 'core_cache_tag', + 'core/cache' => 'cache', + 'core/cache_tag' => 'cache_tag', 'core/config_data' => 'core_config_data', - 'core/config_field' => 'core_config_field', 'core/design_change' => 'design_change', 'core/directory_storage' => 'media_storage_directory_storage', - 'core/email_template' => 'core_email_template', + 'core/email_template' => 'email_template', 'core/file_storage' => 'media_storage_file_storage', - 'core/flag' => 'core_flag', + 'core/flag' => 'flag', 'core/layout_link' => 'layout_link', 'core/layout_update' => 'layout_update', 'core_resource' => 'setup_module', - 'core/session' => 'core_session', + 'core/session' => 'session', 'core/store' => 'store', 'core/store_group' => 'store_group', 'core/variable' => 'variable', diff --git a/dev/tools/Magento/Tools/View/Deployer.php b/dev/tools/Magento/Tools/View/Deployer.php index fafd45319ff081370c89c805a89bcc870ca235b0..1549724017780a260891f4f386faf09962180a5d 100644 --- a/dev/tools/Magento/Tools/View/Deployer.php +++ b/dev/tools/Magento/Tools/View/Deployer.php @@ -10,6 +10,8 @@ use Magento\Framework\App\ObjectManagerFactory; use Magento\Framework\App\View\Deployment\Version; use Magento\Framework\App\View\Asset\Publisher; use Magento\Framework\App\Utility\Files; +use Magento\Framework\ObjectManagerInterface; +use Magento\Framework\Translate\Js\Config as JsTranslationConfig; /** * A service for deploying Magento static view files for production mode @@ -57,12 +59,23 @@ class Deployer /** @var \Magento\Framework\View\Asset\MinifyService */ protected $minifyService; + /** + * @var ObjectManagerInterface + */ + private $objectManager; + + /** + * @var JsTranslationConfig + */ + protected $jsTranslationConfig; + /** * @param Files $filesUtil * @param Deployer\Log $logger * @param Version\StorageInterface $versionStorage * @param \Magento\Framework\Stdlib\DateTime $dateTime * @param \Magento\Framework\View\Asset\MinifyService $minifyService + * @param JsTranslationConfig $jsTranslationConfig * @param bool $isDryRun */ public function __construct( @@ -71,6 +84,7 @@ class Deployer Version\StorageInterface $versionStorage, \Magento\Framework\Stdlib\DateTime $dateTime, \Magento\Framework\View\Asset\MinifyService $minifyService, + JsTranslationConfig $jsTranslationConfig, $isDryRun = false ) { $this->filesUtil = $filesUtil; @@ -79,6 +93,7 @@ class Deployer $this->dateTime = $dateTime; $this->isDryRun = $isDryRun; $this->minifyService = $minifyService; + $this->jsTranslationConfig = $jsTranslationConfig; } /** @@ -87,6 +102,7 @@ class Deployer * @param ObjectManagerFactory $omFactory * @param array $locales * @return void + * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ public function deploy(ObjectManagerFactory $omFactory, array $locales) { @@ -101,6 +117,7 @@ class Deployer foreach ($areas as $area => $themes) { $this->emulateApplicationArea($area); foreach ($locales as $locale) { + $this->emulateApplicationLocale($locale, $area); foreach ($themes as $themePath) { $this->logger->logMessage("=== {$area} -> {$themePath} -> {$locale} ==="); $this->count = 0; @@ -112,6 +129,15 @@ class Deployer foreach ($libFiles as $filePath) { $this->deployFile($filePath, $area, $themePath, $locale, null); } + if ($this->jsTranslationConfig->dictionaryEnabled()) { + $this->deployFile( + $this->jsTranslationConfig->getDictionaryFileName(), + $area, + $themePath, + $locale, + null + ); + } $this->bundleManager->flush(); $this->logger->logMessage("\nSuccessful: {$this->count} files; errors: {$this->errorCount}\n---\n"); } @@ -176,19 +202,36 @@ class Deployer */ private function emulateApplicationArea($areaCode) { - $objectManager = $this->omFactory->create( + $this->objectManager = $this->omFactory->create( [\Magento\Framework\App\State::PARAM_MODE => \Magento\Framework\App\State::MODE_DEFAULT] ); /** @var \Magento\Framework\App\State $appState */ - $appState = $objectManager->get('Magento\Framework\App\State'); + $appState = $this->objectManager->get('Magento\Framework\App\State'); $appState->setAreaCode($areaCode); /** @var \Magento\Framework\App\ObjectManager\ConfigLoader $configLoader */ - $configLoader = $objectManager->get('Magento\Framework\App\ObjectManager\ConfigLoader'); - $objectManager->configure($configLoader->load($areaCode)); - $this->assetRepo = $objectManager->get('Magento\Framework\View\Asset\Repository'); - $this->assetPublisher = $objectManager->create('Magento\Framework\App\View\Asset\Publisher'); - $this->htmlMinifier = $objectManager->get('Magento\Framework\View\Template\Html\MinifierInterface'); - $this->bundleManager = $objectManager->get('Magento\Framework\View\Asset\Bundle\Manager'); + $configLoader = $this->objectManager->get('Magento\Framework\App\ObjectManager\ConfigLoader'); + $this->objectManager->configure($configLoader->load($areaCode)); + $this->assetRepo = $this->objectManager->get('Magento\Framework\View\Asset\Repository'); + + $this->assetPublisher = $this->objectManager->create('Magento\Framework\App\View\Asset\Publisher'); + $this->htmlMinifier = $this->objectManager->get('Magento\Framework\View\Template\Html\MinifierInterface'); + $this->bundleManager = $this->objectManager->get('Magento\Framework\View\Asset\Bundle\Manager'); + + } + + /** + * Set application locale and load translation for area + * + * @param string $locale + * @param string $area + * @return void + */ + protected function emulateApplicationLocale($locale, $area) + { + /** @var \Magento\Framework\TranslateInterface $translator */ + $translator = $this->objectManager->get('Magento\Framework\TranslateInterface'); + $translator->setLocale($locale); + $translator->loadData($area, true); } /** diff --git a/dev/tools/Magento/Tools/View/deploy.php b/dev/tools/Magento/Tools/View/deploy.php index 765ac7e4acaddb0e106bfa98f56e8eb96f11ddf3..f380efd3f360d68738842b900cc4372a0af2ddc4 100644 --- a/dev/tools/Magento/Tools/View/deploy.php +++ b/dev/tools/Magento/Tools/View/deploy.php @@ -43,7 +43,7 @@ $logger = new \Magento\Tools\View\Deployer\Log($verbosity); try { // run the deployment logic - $filesUtil = new \Magento\Framework\Test\Utility\Files(BP); + $filesUtil = new \Magento\Framework\App\Utility\Files(BP); $omFactory = \Magento\Framework\App\Bootstrap::createObjectManagerFactory(BP, []); $objectManager = $omFactory->create( [\Magento\Framework\App\State::PARAM_MODE => \Magento\Framework\App\State::MODE_DEFAULT] diff --git a/lib/internal/Magento/Framework/Api/AbstractExtensibleObject.php b/lib/internal/Magento/Framework/Api/AbstractExtensibleObject.php index 0eb68d88fb4d0417bd91b40b5a41b01cd9c2cd8a..6455c7ca7f2cb2c9f3056910c1a594e5b95519aa 100644 --- a/lib/internal/Magento/Framework/Api/AbstractExtensibleObject.php +++ b/lib/internal/Magento/Framework/Api/AbstractExtensibleObject.php @@ -10,8 +10,9 @@ use \Magento\Framework\Api\AttributeValueFactory; /** * Base Class for extensible data Objects * @SuppressWarnings(PHPMD.NumberOfChildren) + * TODO: This class can be split into Custom attribute and Extension attribute implementation classes */ -abstract class AbstractExtensibleObject extends AbstractSimpleObject implements ExtensibleDataInterface +abstract class AbstractExtensibleObject extends AbstractSimpleObject implements CustomAttributesDataInterface { /** * Array key for custom attributes @@ -19,14 +20,14 @@ abstract class AbstractExtensibleObject extends AbstractSimpleObject implements const CUSTOM_ATTRIBUTES_KEY = 'custom_attributes'; /** - * @var AttributeValueFactory + * @var \Magento\Framework\Api\ExtensionAttributesFactory */ - protected $attributeValueFactory; + protected $extensionFactory; /** - * @var MetadataServiceInterface + * @var AttributeValueFactory */ - protected $metadataService; + protected $attributeValueFactory; /** * @var string[] @@ -36,16 +37,16 @@ abstract class AbstractExtensibleObject extends AbstractSimpleObject implements /** * Initialize internal storage * - * @param MetadataServiceInterface $metadataService + * @param \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory * @param AttributeValueFactory $attributeValueFactory * @param array $data */ public function __construct( - MetadataServiceInterface $metadataService, + \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory, AttributeValueFactory $attributeValueFactory, $data = [] ) { - $this->metadataService = $metadataService; + $this->extensionFactory = $extensionFactory; $this->attributeValueFactory = $attributeValueFactory; parent::__construct($data); } @@ -118,23 +119,57 @@ abstract class AbstractExtensibleObject extends AbstractSimpleObject implements } /** + * Get a list of custom attribute codes. + * + * By default, entity can be extended only using extension attributes functionality. * * @return string[] */ protected function getCustomAttributesCodes() { - if (!is_null($this->customAttributesCodes)) { - return $this->customAttributesCodes; - } + return isset($this->customAttributesCodes) ? $this->customAttributesCodes : []; + } + + /** + * Receive a list of EAV attributes using provided metadata service. + * + * Can be used in child classes, which represent EAV entities. + * + * @param \Magento\Framework\Api\MetadataServiceInterface $metadataService + * @return string[] + */ + protected function getEavAttributesCodes(\Magento\Framework\Api\MetadataServiceInterface $metadataService) + { $attributeCodes = []; - $customAttributesMetadata = $this->metadataService->getCustomAttributesMetadata(get_class($this)); + $customAttributesMetadata = $metadataService->getCustomAttributesMetadata(get_class($this)); if (is_array($customAttributesMetadata)) { /** @var $attribute \Magento\Framework\Api\MetadataObjectInterface */ foreach ($customAttributesMetadata as $attribute) { $attributeCodes[] = $attribute->getAttributeCode(); } } - $this->customAttributesCodes = $attributeCodes; return $attributeCodes; } + + /** + * Retrieve existing extension attributes object or create a new one. + * + * @return \Magento\Framework\Api\ExtensionAttributesInterface + */ + protected function _getExtensionAttributes() + { + return $this->_get(self::EXTENSION_ATTRIBUTES_KEY); + } + + /** + * Set an extension attributes object. + * + * @param \Magento\Framework\Api\ExtensionAttributesInterface $extensionAttributes + * @return $this + */ + protected function _setExtensionAttributes(\Magento\Framework\Api\ExtensionAttributesInterface $extensionAttributes) + { + $this->_data[self::EXTENSION_ATTRIBUTES_KEY] = $extensionAttributes; + return $this; + } } diff --git a/lib/internal/Magento/Framework/Api/Code/Generator/ObjectExtension.php b/lib/internal/Magento/Framework/Api/Code/Generator/ExtensionAttributesGenerator.php similarity index 72% rename from lib/internal/Magento/Framework/Api/Code/Generator/ObjectExtension.php rename to lib/internal/Magento/Framework/Api/Code/Generator/ExtensionAttributesGenerator.php index 28569195579c975131e800fe687ac45dfa88cb12..98f5dc5d5e07250fe7b427ca68286cb99c22ee35 100644 --- a/lib/internal/Magento/Framework/Api/Code/Generator/ObjectExtension.php +++ b/lib/internal/Magento/Framework/Api/Code/Generator/ExtensionAttributesGenerator.php @@ -12,7 +12,7 @@ use Magento\Framework\Api\SimpleDataObjectConverter; /** * Code generator for data object extensions. */ -class ObjectExtension extends \Magento\Framework\Code\Generator\EntityAbstract +class ExtensionAttributesGenerator extends \Magento\Framework\Code\Generator\EntityAbstract { const ENTITY_TYPE = 'extension'; @@ -70,16 +70,7 @@ class ObjectExtension extends \Magento\Framework\Code\Generator\EntityAbstract */ protected function _getClassProperties() { - $properties = []; - foreach ($this->getCustomAttributes() as $attributeName => $attributeType) { - $propertyName = SimpleDataObjectConverter::snakeCaseToCamelCase($attributeName); - $properties[] = [ - 'name' => $propertyName, - 'visibility' => 'protected', - 'docblock' => ['tags' => [['name' => 'var', 'description' => $attributeType]]], - ]; - } - return $properties; + return []; } /** @@ -94,13 +85,13 @@ class ObjectExtension extends \Magento\Framework\Code\Generator\EntityAbstract $setterName = 'set' . ucfirst($propertyName); $methods[] = [ 'name' => $getterName, - 'body' => "return \$this->{$propertyName};", + 'body' => "return \$this->_get('{$attributeName}');", 'docblock' => ['tags' => [['name' => 'return', 'description' => $attributeType]]], ]; $methods[] = [ 'name' => $setterName, 'parameters' => [['name' => $propertyName]], - 'body' => "\$this->{$propertyName} = \${$propertyName};" . PHP_EOL . "return \$this;", + 'body' => "\$this->setData('{$attributeName}', \${$propertyName});" . PHP_EOL . "return \$this;", 'docblock' => [ 'tags' => [ [ @@ -123,18 +114,8 @@ class ObjectExtension extends \Magento\Framework\Code\Generator\EntityAbstract */ protected function _validateData() { - $result = true; - $sourceClassName = $this->_getSourceClassName(); - $resultClassName = $this->_getResultClassName(); - $interfaceSuffix = 'Interface'; - $expectedResultClassName = substr($sourceClassName, 0, -strlen($interfaceSuffix)) . self::EXTENSION_SUFFIX; - if ($resultClassName !== $expectedResultClassName) { - $this->_addError( - 'Invalid extension name [' . $resultClassName . ']. Use ' . $expectedResultClassName - ); - $result = false; - } - return parent::_validateData() && $result; + $classNameValidationResults = $this->validateResultClassName(); + return parent::_validateData() && $classNameValidationResults; } /** @@ -143,9 +124,20 @@ class ObjectExtension extends \Magento\Framework\Code\Generator\EntityAbstract protected function _generateCode() { $this->_classGenerator->setImplementedInterfaces([$this->_getResultClassName() . 'Interface']); + $this->_classGenerator->setExtendedClass($this->getExtendedClass()); return parent::_generateCode(); } + /** + * Get class, which should be used as a parent for generated class. + * + * @return string + */ + protected function getExtendedClass() + { + return '\Magento\Framework\Api\AbstractSimpleObject'; + } + /** * Retrieve a list of attributes associated with current source class. * @@ -156,11 +148,40 @@ class ObjectExtension extends \Magento\Framework\Code\Generator\EntityAbstract if (!isset($this->allCustomAttributes)) { $this->allCustomAttributes = $this->configReader->read(); } - $dataInterface = ltrim($this->_getSourceClassName(), '\\'); + $dataInterface = ltrim($this->getSourceClassName(), '\\'); if (isset($this->allCustomAttributes[$dataInterface])) { + foreach ($this->allCustomAttributes[$dataInterface] as $attributeName => $attributeType) { + if (strpos($attributeType, '\\') !== false) { + /** Add preceding slash to class names, while leaving primitive types as is */ + $attributeType = $this->_getFullyQualifiedClassName($attributeType); + $this->allCustomAttributes[$dataInterface][$attributeName] = + $this->_getFullyQualifiedClassName($attributeType); + } + } return $this->allCustomAttributes[$dataInterface]; } else { return []; } } + + /** + * Ensure that result class name corresponds to the source class name. + * + * @return bool + */ + protected function validateResultClassName() + { + $result = true; + $sourceClassName = $this->getSourceClassName(); + $resultClassName = $this->_getResultClassName(); + $interfaceSuffix = 'Interface'; + $expectedResultClassName = substr($sourceClassName, 0, -strlen($interfaceSuffix)) . self::EXTENSION_SUFFIX; + if ($resultClassName !== $expectedResultClassName) { + $this->_addError( + 'Invalid extension name [' . $resultClassName . ']. Use ' . $expectedResultClassName + ); + $result = false; + } + return $result; + } } diff --git a/lib/internal/Magento/Framework/Api/Code/Generator/ObjectExtensionInterface.php b/lib/internal/Magento/Framework/Api/Code/Generator/ExtensionAttributesInterfaceGenerator.php similarity index 83% rename from lib/internal/Magento/Framework/Api/Code/Generator/ObjectExtensionInterface.php rename to lib/internal/Magento/Framework/Api/Code/Generator/ExtensionAttributesInterfaceGenerator.php index 73fb6556c2c0191a28b4c94e6f99f4754a631e55..59b6f225bb6c1d84acdfb20d96880980712b1bd2 100644 --- a/lib/internal/Magento/Framework/Api/Code/Generator/ObjectExtensionInterface.php +++ b/lib/internal/Magento/Framework/Api/Code/Generator/ExtensionAttributesInterfaceGenerator.php @@ -11,7 +11,7 @@ use Magento\Framework\Code\Generator\Io; /** * Code generator for data object extension interfaces. */ -class ObjectExtensionInterface extends \Magento\Framework\Api\Code\Generator\ObjectExtension +class ExtensionAttributesInterfaceGenerator extends \Magento\Framework\Api\Code\Generator\ExtensionAttributesGenerator { const ENTITY_TYPE = 'extensionInterface'; @@ -51,10 +51,18 @@ class ObjectExtensionInterface extends \Magento\Framework\Api\Code\Generator\Obj /** * {@inheritdoc} */ - protected function _validateData() + protected function getExtendedClass() + { + return '\Magento\Framework\Api\ExtensionAttributesInterface'; + } + + /** + * {@inheritdoc} + */ + protected function validateResultClassName() { $result = true; - $sourceClassName = $this->_getSourceClassName(); + $sourceClassName = $this->getSourceClassName(); $resultClassName = $this->_getResultClassName(); $interfaceSuffix = 'Interface'; $expectedResultClassName = substr($sourceClassName, 0, -strlen($interfaceSuffix)) @@ -65,6 +73,6 @@ class ObjectExtensionInterface extends \Magento\Framework\Api\Code\Generator\Obj ); $result = false; } - return parent::_validateData() && $result; + return $result; } } diff --git a/lib/internal/Magento/Framework/Api/Code/Generator/Mapper.php b/lib/internal/Magento/Framework/Api/Code/Generator/Mapper.php index 64d511448c03ff46aa1404b0d598721075c35f85..edd460f42bfd9deb68128a99da7f76353f290d68 100644 --- a/lib/internal/Magento/Framework/Api/Code/Generator/Mapper.php +++ b/lib/internal/Magento/Framework/Api/Code/Generator/Mapper.php @@ -31,7 +31,7 @@ class Mapper extends \Magento\Framework\Code\Generator\EntityAbstract 'tags' => [ [ 'name' => 'var', - 'description' => $this->_getSourceClassName() . 'Builder', + 'description' => $this->getSourceClassName() . 'Builder', ], ], ], @@ -41,7 +41,7 @@ class Mapper extends \Magento\Framework\Code\Generator\EntityAbstract 'visibility' => 'protected', 'defaultValue' => [], 'docblock' => [ - 'shortDescription' => $this->_getSourceClassName() . '[]', + 'shortDescription' => $this->getSourceClassName() . '[]', 'tags' => [['name' => 'var', 'description' => 'array']], ] ], @@ -56,8 +56,7 @@ class Mapper extends \Magento\Framework\Code\Generator\EntityAbstract */ protected function _getSourceBuilderPropertyName() { - $parts = explode('\\', ltrim($this->_getSourceClassName(), '\\')); - return lcfirst(end($parts)) . 'Builder'; + return lcfirst($this->getSourceClassNameWithoutNamespace()) . 'Builder'; } /** @@ -72,7 +71,7 @@ class Mapper extends \Magento\Framework\Code\Generator\EntityAbstract 'parameters' => [ [ 'name' => $this->_getSourceBuilderPropertyName(), - 'type' => $this->_getSourceClassName() . 'Builder', + 'type' => $this->getSourceClassName() . 'Builder', ], ], 'body' => "\$this->" @@ -83,7 +82,7 @@ class Mapper extends \Magento\Framework\Code\Generator\EntityAbstract 'tags' => [ [ 'name' => 'param', - 'description' => $this->_getSourceClassName() . " \$" . $this->_getSourceBuilderPropertyName(), + 'description' => $this->getSourceClassName() . " \$" . $this->_getSourceBuilderPropertyName(), ], ], ] @@ -118,7 +117,7 @@ class Mapper extends \Magento\Framework\Code\Generator\EntityAbstract ], [ 'name' => 'return', - 'description' => $this->_getSourceClassName(), + 'description' => $this->getSourceClassName(), ], ], ], @@ -134,7 +133,7 @@ class Mapper extends \Magento\Framework\Code\Generator\EntityAbstract $result = parent::_validateData(); if ($result) { - $sourceClassName = $this->_getSourceClassName(); + $sourceClassName = $this->getSourceClassName(); $resultClassName = $this->_getResultClassName(); if ($resultClassName !== $sourceClassName . 'Mapper') { diff --git a/lib/internal/Magento/Framework/Api/Code/Generator/SearchResults.php b/lib/internal/Magento/Framework/Api/Code/Generator/SearchResults.php index c1613b0628dc93bcc9334438f45f47952521996c..32a4071ebf0c7aaa15f45c2a6cf966c91313472c 100644 --- a/lib/internal/Magento/Framework/Api/Code/Generator/SearchResults.php +++ b/lib/internal/Magento/Framework/Api/Code/Generator/SearchResults.php @@ -51,7 +51,7 @@ class SearchResults extends EntityAbstract 'tags' => [ [ 'name' => 'return', - 'description' => $this->_getSourceClassName() . '[]', + 'description' => $this->getSourceClassName() . '[]', ], ], ], diff --git a/lib/internal/Magento/Framework/Api/Config/MetadataConfig.php b/lib/internal/Magento/Framework/Api/Config/MetadataConfig.php deleted file mode 100644 index 9bfb2eb651cdd0a0ec8c4ed6b806c9a1c7a1940e..0000000000000000000000000000000000000000 --- a/lib/internal/Magento/Framework/Api/Config/MetadataConfig.php +++ /dev/null @@ -1,92 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -namespace Magento\Framework\Api\Config; - -use Magento\Framework\Api\ObjectFactory; -use Magento\Framework\Api\Config\Reader as ServiceConfigReader; -use Magento\Framework\Api\MetadataServiceInterface; - -/** - * Class which allows to get a metadata of the attributes declared in a config. - */ -class MetadataConfig implements MetadataServiceInterface -{ - /** - * @var ServiceConfigReader - */ - private $serviceConfigReader; - - /** - * @var ObjectFactory - */ - private $objectFactory; - - /** - * @var array - */ - private $allAttributes = []; - - /** - * Initialize dependencies. - * - * @param ServiceConfigReader $serviceConfigReader - * @param ObjectFactory $objectFactory - */ - public function __construct( - ServiceConfigReader $serviceConfigReader, - ObjectFactory $objectFactory - ) { - $this->serviceConfigReader = $serviceConfigReader; - $this->objectFactory = $objectFactory; - } - - /** - * {@inheritdoc} - */ - public function getCustomAttributesMetadata($dataObjectClassName = null) - { - $attributes = []; - if (!is_null($this->objectFactory) && !is_null($dataObjectClassName)) { - /** - * Attribute metadata builder and data object class name are expected to be configured - * via DI using virtual types. If configuration is missing, empty array should be returned. - */ - $attributes = $this->getAttributesMetadata($dataObjectClassName); - $implementedInterfaces = (new \ReflectionClass($dataObjectClassName))->getInterfaceNames(); - foreach ($implementedInterfaces as $interfaceName) { - $attributes = array_merge($attributes, $this->getAttributesMetadata($interfaceName)); - } - } - return $attributes; - } - - /** - * Get custom attribute metadata for the given class/interface. - * - * @param string $dataObjectClassName - * @return \Magento\Framework\Api\MetadataObjectInterface[] - */ - protected function getAttributesMetadata($dataObjectClassName) - { - $attributes = []; - if (empty($this->allAttributes)) { - $this->allAttributes = $this->serviceConfigReader->read(); - } - $dataObjectClassName = ltrim($dataObjectClassName, '\\'); - if (isset($this->allAttributes[$dataObjectClassName]) - && is_array($this->allAttributes[$dataObjectClassName]) - ) { - $attributeCodes = array_keys($this->allAttributes[$dataObjectClassName]); - foreach ($attributeCodes as $attributeCode) { - $attributes[$attributeCode] = $this->objectFactory - ->create('\Magento\Framework\Api\MetadataObjectInterface', []) - ->setAttributeCode($attributeCode); - } - } - return $attributes; - } -} diff --git a/lib/internal/Magento/Framework/Api/CustomAttributesDataInterface.php b/lib/internal/Magento/Framework/Api/CustomAttributesDataInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..239066d34c0f9515b83a771f2d4711620e0309c6 --- /dev/null +++ b/lib/internal/Magento/Framework/Api/CustomAttributesDataInterface.php @@ -0,0 +1,51 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Framework\Api; + +/** + * Interface for entities which can be extended with custom attributes. + */ +interface CustomAttributesDataInterface extends ExtensibleDataInterface +{ + /** + * Array key for custom attributes + */ + const CUSTOM_ATTRIBUTES = 'custom_attributes'; + + /** + * Get an attribute value. + * + * @param string $attributeCode + * @return \Magento\Framework\Api\AttributeInterface|null + */ + public function getCustomAttribute($attributeCode); + + /** + * Set an attribute value for a given attribute code + * + * @param string $attributeCode + * @param mixed $attributeValue + * @return $this + */ + public function setCustomAttribute($attributeCode, $attributeValue); + + /** + * Retrieve custom attributes values. + * + * @return \Magento\Framework\Api\AttributeInterface[]|null + */ + public function getCustomAttributes(); + + /** + * Set array of custom attributes + * + * @param \Magento\Framework\Api\AttributeInterface[] $attributes + * @return $this + * @throws \LogicException + */ + public function setCustomAttributes(array $attributes); +} diff --git a/lib/internal/Magento/Framework/Api/DataObjectHelper.php b/lib/internal/Magento/Framework/Api/DataObjectHelper.php index 61d813a261d55ed5ef9e15211fcceb6e8d17de93..f7d16e57321607846234dcda516586e873ad75c2 100644 --- a/lib/internal/Magento/Framework/Api/DataObjectHelper.php +++ b/lib/internal/Magento/Framework/Api/DataObjectHelper.php @@ -23,19 +23,27 @@ class DataObjectHelper */ protected $typeProcessor; + /** + * @var \Magento\Framework\Api\ExtensionAttributesFactory + */ + protected $extensionFactory; + /** * @param ObjectFactory $objectFactory * @param \Magento\Framework\Reflection\DataObjectProcessor $objectProcessor * @param \Magento\Framework\Reflection\TypeProcessor $typeProcessor + * @param \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory */ public function __construct( ObjectFactory $objectFactory, \Magento\Framework\Reflection\DataObjectProcessor $objectProcessor, - \Magento\Framework\Reflection\TypeProcessor $typeProcessor + \Magento\Framework\Reflection\TypeProcessor $typeProcessor, + \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory ) { $this->objectFactory = $objectFactory; $this->objectProcessor = $objectProcessor; $this->typeProcessor = $typeProcessor; + $this->extensionFactory = $extensionFactory; } /** @@ -69,7 +77,7 @@ class DataObjectHelper 'set' . $camelCaseKey, 'setIs' . $camelCaseKey, ]; - if ($key === ExtensibleDataInterface::CUSTOM_ATTRIBUTES + if ($key === CustomAttributesDataInterface::CUSTOM_ATTRIBUTES && ($dataObject instanceof ExtensibleDataInterface) && is_array($data[$key]) && !empty($data[$key]) @@ -83,7 +91,11 @@ class DataObjectHelper } elseif ($methodNames = array_intersect($possibleMethods, $dataObjectMethods)) { $methodName = array_values($methodNames)[0]; if (!is_array($value)) { - $dataObject->$methodName($value); + if ($methodName === 'setExtensionAttributes' && is_null($value)) { + // Cannot pass a null value to a method with a typed parameter + } else { + $dataObject->$methodName($value); + } } else { $getterMethodName = 'get' . $camelCaseKey; $this->setComplexValue($dataObject, $getterMethodName, $methodName, $value, $interfaceName); @@ -137,6 +149,8 @@ class DataObjectHelper if (is_subclass_of($returnType, '\Magento\Framework\Api\ExtensibleDataInterface')) { $object = $this->objectFactory->create($returnType, []); $this->populateWithArray($object, $value, $returnType); + } else if (is_subclass_of($returnType, '\Magento\Framework\Api\ExtensionAttributesInterface')) { + $object = $this->extensionFactory->create(get_class($dataObject), $value); } else { $object = $this->objectFactory->create($returnType, $value); } diff --git a/lib/internal/Magento/Framework/Api/DefaultMetadataService.php b/lib/internal/Magento/Framework/Api/DefaultMetadataService.php new file mode 100644 index 0000000000000000000000000000000000000000..5a5d2e6a9e23365ad3f59c3ee9995e7269dbf2f9 --- /dev/null +++ b/lib/internal/Magento/Framework/Api/DefaultMetadataService.php @@ -0,0 +1,21 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Framework\Api; + +/** + * Default implementation of metadata service, which does not return any real attributes. + */ +class DefaultMetadataService implements MetadataServiceInterface +{ + /** + * {@inheritdoc} + */ + public function getCustomAttributesMetadata($dataObjectClassName = null) + { + return []; + } +} diff --git a/lib/internal/Magento/Framework/Api/ExtensibleDataInterface.php b/lib/internal/Magento/Framework/Api/ExtensibleDataInterface.php index ba6efb39290912c10079cf2d9a3cb0bc83339f4c..6dd8f258b4db78768cf90ca0b9fd182d33f47587 100644 --- a/lib/internal/Magento/Framework/Api/ExtensibleDataInterface.php +++ b/lib/internal/Magento/Framework/Api/ExtensibleDataInterface.php @@ -7,45 +7,12 @@ namespace Magento\Framework\Api; /** - * Interface for entities which can be extended with custom attributes. + * Interface for entities which can be extended with extension attributes. */ interface ExtensibleDataInterface { /** - * Array key for custom attributes + * Key for extension attributes object */ - const CUSTOM_ATTRIBUTES = 'custom_attributes'; - - /** - * Get an attribute value. - * - * @param string $attributeCode - * @return \Magento\Framework\Api\AttributeInterface|null - */ - public function getCustomAttribute($attributeCode); - - /** - * Set an attribute value for a given attribute code - * - * @param string $attributeCode - * @param mixed $attributeValue - * @return $this - */ - public function setCustomAttribute($attributeCode, $attributeValue); - - /** - * Retrieve custom attributes values. - * - * @return \Magento\Framework\Api\AttributeInterface[]|null - */ - public function getCustomAttributes(); - - /** - * Set array of custom attributes - * - * @param \Magento\Framework\Api\AttributeInterface[] $attributes - * @return $this - * @throws \LogicException - */ - public function setCustomAttributes(array $attributes); + const EXTENSION_ATTRIBUTES_KEY = 'extension_attributes'; } diff --git a/lib/internal/Magento/Framework/Api/ExtensibleDataObjectConverter.php b/lib/internal/Magento/Framework/Api/ExtensibleDataObjectConverter.php index 22cad52d286c54b40ee7c5546e49990d0772a0c6..2ad42cac8b20c4a49347928a84811aa788797c90 100644 --- a/lib/internal/Magento/Framework/Api/ExtensibleDataObjectConverter.php +++ b/lib/internal/Magento/Framework/Api/ExtensibleDataObjectConverter.php @@ -31,13 +31,13 @@ class ExtensibleDataObjectConverter * Convert AbstractExtensibleObject into a nested array. * * @param ExtensibleDataInterface $dataObject - * @param string[] $skipCustomAttributes + * @param string[] $skipAttributes * @param string $dataObjectType * @return array */ public function toNestedArray( ExtensibleDataInterface $dataObject, - $skipCustomAttributes = [], + $skipAttributes = [], $dataObjectType = null ) { if ($dataObjectType == null) { @@ -50,12 +50,22 @@ class ExtensibleDataObjectConverter $customAttributes = $dataObjectArray[AbstractExtensibleObject::CUSTOM_ATTRIBUTES_KEY]; unset ($dataObjectArray[AbstractExtensibleObject::CUSTOM_ATTRIBUTES_KEY]); foreach ($customAttributes as $attributeValue) { - if (!in_array($attributeValue[AttributeValue::ATTRIBUTE_CODE], $skipCustomAttributes)) { + if (!in_array($attributeValue[AttributeValue::ATTRIBUTE_CODE], $skipAttributes)) { $dataObjectArray[$attributeValue[AttributeValue::ATTRIBUTE_CODE]] = $attributeValue[AttributeValue::VALUE]; } } } + if (!empty($dataObjectArray[ExtensibleDataInterface::EXTENSION_ATTRIBUTES_KEY])) { + /** @var array $extensionAttributes */ + $extensionAttributes = $dataObjectArray[ExtensibleDataInterface::EXTENSION_ATTRIBUTES_KEY]; + unset ($dataObjectArray[ExtensibleDataInterface::EXTENSION_ATTRIBUTES_KEY]); + foreach ($extensionAttributes as $attributeKey => $attributeValue) { + if (!in_array($attributeKey, $skipAttributes)) { + $dataObjectArray[$attributeKey] = $attributeValue; + } + } + } return $dataObjectArray; } diff --git a/lib/internal/Magento/Framework/Api/ExtensionAttributesFactory.php b/lib/internal/Magento/Framework/Api/ExtensionAttributesFactory.php new file mode 100644 index 0000000000000000000000000000000000000000..e50b83d11c7a95758ed9d8f07a4231419018e43a --- /dev/null +++ b/lib/internal/Magento/Framework/Api/ExtensionAttributesFactory.php @@ -0,0 +1,87 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Framework\Api; + +/** + * Factory class for instantiation of extension attributes objects. + */ +class ExtensionAttributesFactory +{ + /** + * Object Manager instance + * + * @var \Magento\Framework\ObjectManagerInterface + */ + protected $_objectManager = null; + + /** + * Factory constructor + * + * @param \Magento\Framework\ObjectManagerInterface $objectManager + */ + public function __construct(\Magento\Framework\ObjectManagerInterface $objectManager) + { + $this->_objectManager = $objectManager; + } + + /** + * Create extension attributes object, custom for each extensible class. + * + * @param string $extensibleClassName + * @param array $data + * @return object + */ + public function create($extensibleClassName, $data = []) + { + $modelReflection = new \ReflectionClass($extensibleClassName); + + $implementsExtensibleInterface = false; + $extensibleInterfaceName = 'Magento\Framework\Api\ExtensibleDataInterface'; + foreach ($modelReflection->getInterfaces() as $interfaceReflection) { + if ($interfaceReflection->isSubclassOf($extensibleInterfaceName) + && $interfaceReflection->hasMethod('getExtensionAttributes') + ) { + $implementsExtensibleInterface = true; + break; + } + } + if (!$implementsExtensibleInterface) { + throw new \LogicException( + "Class '{$extensibleClassName}' must implement an interface, " + . "which extends from 'Magento\\Framework\\Api\\ExtensibleDataInterface'" + ); + } + + $methodReflection = $interfaceReflection->getMethod('getExtensionAttributes'); + if ($methodReflection->getDeclaringClass() == $extensibleInterfaceName) { + throw new \LogicException( + "Method 'getExtensionAttributes' must be overridden in the interfaces " + . "which extend 'Magento\\Framework\\Api\\ExtensibleDataInterface'. " + . "Concrete return type should be specified." + ); + } + + $interfaceName = '\\' . $interfaceReflection->getName(); + $extensionClassName = substr($interfaceName, 0, -strlen('Interface')) . 'Extension'; + $extensionInterfaceName = $extensionClassName . 'Interface'; + + /** Ensure that proper return type of getExtensionAttributes() method is specified */ + $methodDocBlock = $methodReflection->getDocComment(); + $pattern = "/@return\s+" . str_replace('\\', '\\\\', $extensionInterfaceName) . "/"; + if (!preg_match($pattern, $methodDocBlock)) { + throw new \LogicException( + "Method 'getExtensionAttributes' must be overridden in the interfaces " + . "which extend 'Magento\\Framework\\Api\\ExtensibleDataInterface'. " + . "Concrete return type must be specified. Please fix :" . $interfaceName + ); + } + + $extensionFactoryName = $extensionClassName . 'Factory'; + $extensionFactory = $this->_objectManager->create($extensionFactoryName); + return $extensionFactory->create($data); + } +} diff --git a/lib/internal/Magento/Framework/Api/ExtensionAttributesInterface.php b/lib/internal/Magento/Framework/Api/ExtensionAttributesInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..aef1607c31dae9747711da2459a0fffabf4028c8 --- /dev/null +++ b/lib/internal/Magento/Framework/Api/ExtensionAttributesInterface.php @@ -0,0 +1,14 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Framework\Api; + +/** + * Marker interface for all extension attributes interfaces. + */ +interface ExtensionAttributesInterface +{ +} diff --git a/lib/internal/Magento/Framework/Api/Filter.php b/lib/internal/Magento/Framework/Api/Filter.php index e86ea49047d0ea34e29903f125edc4cf2474e3ed..b803e5fe926241667b8e1ae04969b6bc36e8fb23 100644 --- a/lib/internal/Magento/Framework/Api/Filter.php +++ b/lib/internal/Magento/Framework/Api/Filter.php @@ -6,11 +6,13 @@ namespace Magento\Framework\Api; +use Magento\Framework\Api\AbstractSimpleObject; + /** * Filter which can be used by any methods from service layer. * @codeCoverageIgnore */ -class Filter extends AbstractExtensibleObject +class Filter extends AbstractSimpleObject { /**#@+ * Constants for Data Object keys diff --git a/lib/internal/Magento/Framework/Api/Search/FilterGroup.php b/lib/internal/Magento/Framework/Api/Search/FilterGroup.php index 860c36710ad0d9051f9ea6b02244abcbce785663..ae1dd308b647b51505a176987ec1ba8d2b6363c2 100644 --- a/lib/internal/Magento/Framework/Api/Search/FilterGroup.php +++ b/lib/internal/Magento/Framework/Api/Search/FilterGroup.php @@ -6,12 +6,12 @@ namespace Magento\Framework\Api\Search; -use Magento\Framework\Api\AbstractExtensibleObject; +use Magento\Framework\Api\AbstractSimpleObject; /** * Groups two or more filters together using a logical OR */ -class FilterGroup extends AbstractExtensibleObject +class FilterGroup extends AbstractSimpleObject { const FILTERS = 'filters'; diff --git a/lib/internal/Magento/Framework/Api/SearchCriteria.php b/lib/internal/Magento/Framework/Api/SearchCriteria.php index a02d3e27dac79e7d75b9d3311cea7fe1f6b488f0..727be2cac88b47b98e73fc919a2cb47057997433 100644 --- a/lib/internal/Magento/Framework/Api/SearchCriteria.php +++ b/lib/internal/Magento/Framework/Api/SearchCriteria.php @@ -6,12 +6,11 @@ namespace Magento\Framework\Api; - /** * Data Object for SearchCriteria * @codeCoverageIgnore */ -class SearchCriteria extends AbstractExtensibleObject implements SearchCriteriaInterface +class SearchCriteria extends AbstractSimpleObject implements SearchCriteriaInterface { /**#@+ * Constants for Data Object keys diff --git a/lib/internal/Magento/Framework/Api/SearchResults.php b/lib/internal/Magento/Framework/Api/SearchResults.php index ad1481e9dde6afbc0b84349a111498e52913615a..8d5b998e99a6de80cdc0377230e58b6c36efe8a1 100644 --- a/lib/internal/Magento/Framework/Api/SearchResults.php +++ b/lib/internal/Magento/Framework/Api/SearchResults.php @@ -9,7 +9,7 @@ namespace Magento\Framework\Api; /** * SearchResults Service Data Object used for the search service requests */ -class SearchResults extends \Magento\Framework\Api\AbstractExtensibleObject +class SearchResults extends AbstractSimpleObject { const KEY_ITEMS = 'items'; const KEY_SEARCH_CRITERIA = 'search_criteria'; diff --git a/lib/internal/Magento/Framework/Api/SortOrder.php b/lib/internal/Magento/Framework/Api/SortOrder.php index a29bac335b972f993ebcf9086450aa3d6b258e36..f328b93aa176399e1673206e4e58a0935d10d324 100644 --- a/lib/internal/Magento/Framework/Api/SortOrder.php +++ b/lib/internal/Magento/Framework/Api/SortOrder.php @@ -6,12 +6,11 @@ namespace Magento\Framework\Api; - /** * Data object for sort order. * @codeCoverageIgnore */ -class SortOrder extends AbstractExtensibleObject +class SortOrder extends AbstractSimpleObject { const FIELD = 'field'; const DIRECTION = 'direction'; diff --git a/lib/internal/Magento/Framework/Api/Test/Unit/Code/Generator/ExtensionGeneratorTest.php b/lib/internal/Magento/Framework/Api/Test/Unit/Code/Generator/ExtensionAttributesGeneratorTest.php similarity index 88% rename from lib/internal/Magento/Framework/Api/Test/Unit/Code/Generator/ExtensionGeneratorTest.php rename to lib/internal/Magento/Framework/Api/Test/Unit/Code/Generator/ExtensionAttributesGeneratorTest.php index a7ae7e8a0b37dc4be67f76e8462211cb0eedaf89..5207a20588c73dcbf83aa767b907f585db8bb114 100644 --- a/lib/internal/Magento/Framework/Api/Test/Unit/Code/Generator/ExtensionGeneratorTest.php +++ b/lib/internal/Magento/Framework/Api/Test/Unit/Code/Generator/ExtensionAttributesGeneratorTest.php @@ -3,10 +3,10 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ - +// @codingStandardsIgnoreFile namespace Magento\Framework\Api\Test\Unit\Code\Generator; -class ExtensionGeneratorTest extends \PHPUnit_Framework_TestCase +class ExtensionAttributesGeneratorTest extends \PHPUnit_Framework_TestCase { /** * @var \Magento\Framework\Api\Config\Reader|\PHPUnit_Framework_MockObject_MockObject @@ -14,7 +14,7 @@ class ExtensionGeneratorTest extends \PHPUnit_Framework_TestCase protected $configReaderMock; /** - * @var \Magento\Framework\Api\Code\Generator\ObjectExtension|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Api\Code\Generator\ExtensionAttributesGenerator|\PHPUnit_Framework_MockObject_MockObject */ protected $model; @@ -26,7 +26,7 @@ class ExtensionGeneratorTest extends \PHPUnit_Framework_TestCase $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->model = $objectManager->getObject( - 'Magento\Framework\Api\Code\Generator\ObjectExtension', + 'Magento\Framework\Api\Code\Generator\ExtensionAttributesGenerator', [ 'configReader' => $this->configReaderMock, 'sourceClassName' => '\Magento\Catalog\Api\Data\Product', @@ -68,9 +68,9 @@ class ExtensionGeneratorTest extends \PHPUnit_Framework_TestCase public function testValidateException() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - /** @var \Magento\Framework\Api\Code\Generator\ObjectExtension $model */ + /** @var \Magento\Framework\Api\Code\Generator\ExtensionAttributesGenerator $model */ $model = $objectManager->getObject( - 'Magento\Framework\Api\Code\Generator\ObjectExtension', + 'Magento\Framework\Api\Code\Generator\ExtensionAttributesGenerator', [ 'sourceClassName' => '\Magento\Catalog\Api\Data\Product', 'resultClassName' => '\Magento\Catalog\Api\Data\ProductInterface' diff --git a/lib/internal/Magento/Framework/Api/Test/Unit/Code/Generator/ExtensionInterfaceGeneratorTest.php b/lib/internal/Magento/Framework/Api/Test/Unit/Code/Generator/ExtensionAttributesInterfaceGeneratorTest.php similarity index 84% rename from lib/internal/Magento/Framework/Api/Test/Unit/Code/Generator/ExtensionInterfaceGeneratorTest.php rename to lib/internal/Magento/Framework/Api/Test/Unit/Code/Generator/ExtensionAttributesInterfaceGeneratorTest.php index 80ee07f036b1d67cf546c9740cd23361e798ceaf..8f80baf39beeeec1955800e7ea4a51ac12d02382 100644 --- a/lib/internal/Magento/Framework/Api/Test/Unit/Code/Generator/ExtensionInterfaceGeneratorTest.php +++ b/lib/internal/Magento/Framework/Api/Test/Unit/Code/Generator/ExtensionAttributesInterfaceGeneratorTest.php @@ -3,10 +3,10 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ - +// @codingStandardsIgnoreFile namespace Magento\Framework\Api\Test\Unit\Code\Generator; -class ExtensionInterfaceGeneratorTest extends \PHPUnit_Framework_TestCase +class ExtensionAttributesInterfaceGeneratorTest extends \PHPUnit_Framework_TestCase { public function testGenerate() { @@ -28,9 +28,9 @@ class ExtensionInterfaceGeneratorTest extends \PHPUnit_Framework_TestCase ] ); - /** @var \Magento\Framework\Api\Code\Generator\ObjectExtensionInterface $model */ + /** @var \Magento\Framework\Api\Code\Generator\ExtensionAttributesInterfaceGenerator $model */ $model = $objectManager->getObject( - 'Magento\Framework\Api\Code\Generator\ObjectExtensionInterface', + 'Magento\Framework\Api\Code\Generator\ExtensionAttributesInterfaceGenerator', [ 'configReader' => $configReaderMock, 'sourceClassName' => '\Magento\Catalog\Api\Data\Product', @@ -49,9 +49,9 @@ class ExtensionInterfaceGeneratorTest extends \PHPUnit_Framework_TestCase public function testValidateException() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - /** @var \Magento\Framework\Api\Code\Generator\ObjectExtensionInterface $model */ + /** @var \Magento\Framework\Api\Code\Generator\ExtensionAttributesInterfaceGenerator $model */ $model = $objectManager->getObject( - 'Magento\Framework\Api\Code\Generator\ObjectExtensionInterface', + 'Magento\Framework\Api\Code\Generator\ExtensionAttributesInterfaceGenerator', [ 'sourceClassName' => '\Magento\Catalog\Api\Data\Product', 'resultClassName' => '\Magento\Catalog\Api\Data\ProductInterface' diff --git a/lib/internal/Magento/Framework/Api/Test/Unit/Code/Generator/_files/SampleEmptyExtension.txt b/lib/internal/Magento/Framework/Api/Test/Unit/Code/Generator/_files/SampleEmptyExtension.txt index 9cd99093c935725a6c8a9ba357b2ca7c508ddfe3..1605dad849f045361e5a4858b70d216bc8879c56 100644 --- a/lib/internal/Magento/Framework/Api/Test/Unit/Code/Generator/_files/SampleEmptyExtension.txt +++ b/lib/internal/Magento/Framework/Api/Test/Unit/Code/Generator/_files/SampleEmptyExtension.txt @@ -3,6 +3,6 @@ namespace Magento\Catalog\Api\Data; /** * Extension class for @see \Magento\Catalog\Api\Data\ProductInterface */ -class ProductExtension implements \Magento\Catalog\Api\Data\ProductExtensionInterface +class ProductExtension extends \Magento\Framework\Api\AbstractSimpleObject implements \Magento\Catalog\Api\Data\ProductExtensionInterface { } diff --git a/lib/internal/Magento/Framework/Api/Test/Unit/Code/Generator/_files/SampleExtension.txt b/lib/internal/Magento/Framework/Api/Test/Unit/Code/Generator/_files/SampleExtension.txt index 3ea82ea52c4c8d54079ef305f9a8c32d7c641711..8b5caad1ecc4456ae51380e25c735be8f2660d37 100644 --- a/lib/internal/Magento/Framework/Api/Test/Unit/Code/Generator/_files/SampleExtension.txt +++ b/lib/internal/Magento/Framework/Api/Test/Unit/Code/Generator/_files/SampleExtension.txt @@ -3,24 +3,14 @@ namespace Magento\Catalog\Api\Data; /** * Extension class for @see \Magento\Catalog\Api\Data\ProductInterface */ -class ProductExtension implements \Magento\Catalog\Api\Data\ProductExtensionInterface +class ProductExtension extends \Magento\Framework\Api\AbstractSimpleObject implements \Magento\Catalog\Api\Data\ProductExtensionInterface { - /** - * @var string - */ - protected $stringAttribute = null; - - /** - * @var \Magento\Bundle\Api\Data\OptionInterface[] - */ - protected $complexObjectAttribute = null; - /** * @return string */ public function getStringAttribute() { - return $this->stringAttribute; + return $this->_get('string_attribute'); } /** @@ -29,7 +19,7 @@ class ProductExtension implements \Magento\Catalog\Api\Data\ProductExtensionInte */ public function setStringAttribute($stringAttribute) { - $this->stringAttribute = $stringAttribute; + $this->setData('string_attribute', $stringAttribute); return $this; } @@ -38,7 +28,7 @@ class ProductExtension implements \Magento\Catalog\Api\Data\ProductExtensionInte */ public function getComplexObjectAttribute() { - return $this->complexObjectAttribute; + return $this->_get('complex_object_attribute'); } /** @@ -47,7 +37,7 @@ class ProductExtension implements \Magento\Catalog\Api\Data\ProductExtensionInte */ public function setComplexObjectAttribute($complexObjectAttribute) { - $this->complexObjectAttribute = $complexObjectAttribute; + $this->setData('complex_object_attribute', $complexObjectAttribute); return $this; } } diff --git a/lib/internal/Magento/Framework/Api/Test/Unit/Code/Generator/_files/SampleExtensionInterface.txt b/lib/internal/Magento/Framework/Api/Test/Unit/Code/Generator/_files/SampleExtensionInterface.txt index a16dd05799e00b7be507c5abcce788400c292a1d..ec9edd7affc2d68e5444d914b833bff81ccc1d4d 100644 --- a/lib/internal/Magento/Framework/Api/Test/Unit/Code/Generator/_files/SampleExtensionInterface.txt +++ b/lib/internal/Magento/Framework/Api/Test/Unit/Code/Generator/_files/SampleExtensionInterface.txt @@ -3,7 +3,7 @@ namespace Magento\Catalog\Api\Data; /** * ExtensionInterface class for @see \Magento\Catalog\Api\Data\ProductInterface */ -interface ProductExtensionInterface +interface ProductExtensionInterface extends \Magento\Framework\Api\ExtensionAttributesInterface { /** * @return string diff --git a/lib/internal/Magento/Framework/Api/Test/Unit/Config/MetadataConfigTest.php b/lib/internal/Magento/Framework/Api/Test/Unit/Config/MetadataConfigTest.php deleted file mode 100644 index bc310d2ee3acbc4044f64f71e4425dfda2af2aa7..0000000000000000000000000000000000000000 --- a/lib/internal/Magento/Framework/Api/Test/Unit/Config/MetadataConfigTest.php +++ /dev/null @@ -1,73 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Framework\Api\Test\Unit\Config; - -class MetadataConfigTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var \Magento\Framework\Api\Config\MetadataConfig - */ - protected $metadataConfig; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\Api\Config\Reader - */ - protected $serviceConfigReaderMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\Api\ObjectFactory - */ - protected $objectFactoryMock; - - /** - * Prepare parameters - */ - public function setUp() - { - $this->serviceConfigReaderMock = $this->getMockBuilder('\Magento\Framework\Api\Config\Reader') - ->disableOriginalConstructor() - ->getMock(); - $this->objectFactoryMock = $this->getMockBuilder( - '\Magento\Framework\Api\ObjectFactory' - )->setMethods(['create'])->disableOriginalConstructor()->getMock(); - - $this->metadataConfig = new \Magento\Framework\Api\Config\MetadataConfig( - $this->serviceConfigReaderMock, - $this->objectFactoryMock - ); - } - - /** - * Test caching - */ - public function testCaching() - { - $dataObjectClassName = 'Magento\Customer\Model\Data\Address'; - $attributeCode = 'street'; - $allAttributes = [ - $dataObjectClassName => [ - $attributeCode => 'value', - ] - ]; - $this->serviceConfigReaderMock->expects($this->once()) - ->method('read') - ->willReturn($allAttributes); - - $attributeMock = $this->getMock('\Magento\Framework\Api\MetadataObjectInterface'); - $attributeMock->expects($this->exactly(2)) - ->method('setAttributeCode') - ->with($attributeCode) - ->will($this->returnSelf()); - $this->objectFactoryMock->expects($this->exactly(2)) - ->method('create') - ->willReturn($attributeMock); - - $attributes = $this->metadataConfig->getCustomAttributesMetadata($dataObjectClassName); - $this->assertEquals($attributeMock, $attributes[$attributeCode]); - $attributes = $this->metadataConfig->getCustomAttributesMetadata($dataObjectClassName); - $this->assertEquals($attributeMock, $attributes[$attributeCode]); - } -} diff --git a/lib/internal/Magento/Framework/Api/Test/Unit/DataObjectHelperTest.php b/lib/internal/Magento/Framework/Api/Test/Unit/DataObjectHelperTest.php index 1478deb7c41daf420af12deda53c97bed9368639..ff229abd7d22e9be0f810da4034336e5e9631f63 100644 --- a/lib/internal/Magento/Framework/Api/Test/Unit/DataObjectHelperTest.php +++ b/lib/internal/Magento/Framework/Api/Test/Unit/DataObjectHelperTest.php @@ -3,10 +3,13 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ + +// @codingStandardsIgnoreFile + namespace Magento\Framework\Api\Test\Unit; -use \Magento\Framework\Api\ExtensibleDataInterface; -use \Magento\Framework\Api\AttributeInterface; +use Magento\Framework\Api\CustomAttributesDataInterface; +use Magento\Framework\Api\AttributeInterface; class DataObjectHelperTest extends \PHPUnit_Framework_TestCase { @@ -219,7 +222,7 @@ class DataObjectHelperTest extends \PHPUnit_Framework_TestCase $data = [ 'id' => $id, - ExtensibleDataInterface::CUSTOM_ATTRIBUTES => [ + CustomAttributesDataInterface::CUSTOM_ATTRIBUTES => [ [ AttributeInterface::ATTRIBUTE_CODE => $customAttributeCode, AttributeInterface::VALUE => $customAttributeValue, diff --git a/lib/internal/Magento/Framework/App/Cache/Frontend/Factory.php b/lib/internal/Magento/Framework/App/Cache/Frontend/Factory.php index 16575b0885528edfab6ebf502e6ae5c8b692bf46..75f139317ba10653d759e95b7f7e41a7b6347fbe 100644 --- a/lib/internal/Magento/Framework/App/Cache/Frontend/Factory.php +++ b/lib/internal/Magento/Framework/App/Cache/Frontend/Factory.php @@ -303,10 +303,10 @@ class Factory return $this->_resource->getConnection('core_write'); }; $options['data_table_callback'] = function () { - return $this->_resource->getTableName('core_cache'); + return $this->_resource->getTableName('cache'); }; $options['tags_table_callback'] = function () { - return $this->_resource->getTableName('core_cache_tag'); + return $this->_resource->getTableName('cache_tag'); }; return $options; } diff --git a/lib/internal/Magento/Framework/App/ObjectManagerFactory.php b/lib/internal/Magento/Framework/App/ObjectManagerFactory.php index cc66aee4075bfc6361b06ff8ff424665809e845c..61ed3b457a27cde46c8df905ce20fec41e70f145 100644 --- a/lib/internal/Magento/Framework/App/ObjectManagerFactory.php +++ b/lib/internal/Magento/Framework/App/ObjectManagerFactory.php @@ -163,6 +163,7 @@ class ObjectManagerFactory $this->factory->setObjectManager($objectManager); ObjectManager::setInstance($objectManager); + $definitionFactory->getCodeGenerator()->setObjectManager($objectManager); $env->configureObjectManager($diConfig, $sharedInstances); diff --git a/lib/internal/Magento/Framework/App/Test/Unit/Config/Initial/XsdTest.php b/lib/internal/Magento/Framework/App/Test/Unit/Config/Initial/XsdTest.php index 34400821cc90dc368b9fadad8020965c36af6dc6..3c54962e2f5966ad8409d78d8af371ab7711d073 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/Config/Initial/XsdTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/Config/Initial/XsdTest.php @@ -21,7 +21,7 @@ class XsdTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->_xsdSchema = BP . '/app/code/Magento/Core/etc/config.xsd'; + $this->_xsdSchema = BP . '/app/code/Magento/Store/etc/config.xsd'; $this->_xsdValidator = new \Magento\Framework\TestFramework\Unit\Utility\XsdValidator(); } diff --git a/lib/internal/Magento/Framework/App/Test/Unit/Config/Initial/_files/config.xml b/lib/internal/Magento/Framework/App/Test/Unit/Config/Initial/_files/config.xml index 64a48ac3e9498e535c60ff3e6f81737be6685dd2..c0d6f535bcaa634059f38914bce449b9b1929e67 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/Config/Initial/_files/config.xml +++ b/lib/internal/Magento/Framework/App/Test/Unit/Config/Initial/_files/config.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../../../../app/code/Magento/Core/etc/config.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../../../../app/code/Magento/Store/etc/config.xsd"> <default> <payment> <payment_method> diff --git a/lib/internal/Magento/Framework/App/Test/Unit/Config/Initial/_files/initial_config1.xml b/lib/internal/Magento/Framework/App/Test/Unit/Config/Initial/_files/initial_config1.xml index 36c221dcbfecab3a7afd7f726386d87477eb88aa..0268e0a19ea007e138ea3079dd4af00077b750a6 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/Config/Initial/_files/initial_config1.xml +++ b/lib/internal/Magento/Framework/App/Test/Unit/Config/Initial/_files/initial_config1.xml @@ -5,5 +5,5 @@ * See COPYING.txt for license details. */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../../../../app/code/Magento/Core/etc/config.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../../../../app/code/Magento/Store/etc/config.xsd"> </config> diff --git a/lib/internal/Magento/Framework/App/Test/Unit/Config/Initial/_files/initial_config2.xml b/lib/internal/Magento/Framework/App/Test/Unit/Config/Initial/_files/initial_config2.xml index 36c221dcbfecab3a7afd7f726386d87477eb88aa..0268e0a19ea007e138ea3079dd4af00077b750a6 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/Config/Initial/_files/initial_config2.xml +++ b/lib/internal/Magento/Framework/App/Test/Unit/Config/Initial/_files/initial_config2.xml @@ -5,5 +5,5 @@ * See COPYING.txt for license details. */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../../../../app/code/Magento/Core/etc/config.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../../../../app/code/Magento/Store/etc/config.xsd"> </config> diff --git a/lib/internal/Magento/Framework/App/Test/Unit/Config/Initial/_files/invalid_config.xml b/lib/internal/Magento/Framework/App/Test/Unit/Config/Initial/_files/invalid_config.xml index 07a89760bb4c4ef7a66d1fae4281121d2c34df91..803d1ef87c4d1471f6618fecf572ccde7dade9ce 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/Config/Initial/_files/invalid_config.xml +++ b/lib/internal/Magento/Framework/App/Test/Unit/Config/Initial/_files/invalid_config.xml @@ -5,6 +5,6 @@ * See COPYING.txt for license details. */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../../../../app/code/Magento/Core/etc/config.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../../../../app/code/Magento/Store/etc/config.xsd"> <invalid></invalid> </config> diff --git a/lib/internal/Magento/Framework/App/Test/Unit/Config/Initial/_files/valid_config.xml b/lib/internal/Magento/Framework/App/Test/Unit/Config/Initial/_files/valid_config.xml index e884c48e0f0ff95d386525c551d139cfb2c95d63..da8b5603b23f196a48eb04dea6d077e98acf1ed4 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/Config/Initial/_files/valid_config.xml +++ b/lib/internal/Magento/Framework/App/Test/Unit/Config/Initial/_files/valid_config.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../../../../app/code/Magento/Core/etc/config.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../../../../app/code/Magento/Store/etc/config.xsd"> <default> <some></some> </default> diff --git a/lib/internal/Magento/Framework/App/Test/Unit/ReinitableConfigTest.php b/lib/internal/Magento/Framework/App/Test/Unit/ReinitableConfigTest.php index c3e0a80553329159193d625c2dc2ec516cc58152..acd44af1d90654b77d62b2230fd3ce0c9dfe653f 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/ReinitableConfigTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/ReinitableConfigTest.php @@ -3,6 +3,9 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ + +// @codingStandardsIgnoreFile + namespace Magento\Framework\App\Test\Unit; class ReinitableConfigTest extends \PHPUnit_Framework_TestCase @@ -12,7 +15,7 @@ class ReinitableConfigTest extends \PHPUnit_Framework_TestCase $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $scopePool = $this->getMock('\Magento\Framework\App\Config\ScopePool', ['clean'], [], '', false); $scopePool->expects($this->once())->method('clean'); - /** @var \Magento\Core\Model\ReinitableConfig $config */ + /** @var \Magento\Framework\App\ReinitableConfig $config */ $config = $helper->getObject('Magento\Framework\App\ReinitableConfig', ['scopePool' => $scopePool]); $this->assertInstanceOf('\Magento\Framework\App\Config\ReinitableConfigInterface', $config->reinit()); } diff --git a/lib/internal/Magento/Framework/App/Test/Unit/Response/HttpTest.php b/lib/internal/Magento/Framework/App/Test/Unit/Response/HttpTest.php index 973f461ee88b54e8ed4fa815d11af70c170f66c6..26d126e7b5692febfe28dcad162c56fabd99d20b 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/Response/HttpTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/Response/HttpTest.php @@ -3,6 +3,9 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ + +// @codingStandardsIgnoreFile + namespace Magento\Framework\App\Test\Unit\Response; use \Magento\Framework\App\Response\Http; @@ -53,6 +56,9 @@ class HttpTest extends \PHPUnit_Framework_TestCase protected function tearDown() { unset($this->model); + $magentoObjectManagerFactory = \Magento\Framework\App\Bootstrap::createObjectManagerFactory(BP, $_SERVER); + $objectManager = $magentoObjectManagerFactory->create($_SERVER); + \Magento\Framework\App\ObjectManager::setInstance($objectManager); } public function testSendVary() @@ -114,13 +120,12 @@ class HttpTest extends \PHPUnit_Framework_TestCase $ttl = 120; $pragma = 'cache'; $cacheControl = 'max-age=' . $ttl . ', public, s-maxage=' . $ttl; - $between = 1000; + $expiresResult = gmdate('D, d M Y H:i:s T', time() + $ttl); $this->model->setPublicHeaders($ttl); $this->assertEquals($pragma, $this->model->getHeader('Pragma')->getFieldValue()); $this->assertEquals($cacheControl, $this->model->getHeader('Cache-Control')->getFieldValue()); - $expiresResult = time($this->model->getHeader('Expires')->getFieldValue()); - $this->assertTrue($expiresResult > $between || $expiresResult < $between); + $this->assertLessThanOrEqual($expiresResult, $this->model->getHeader('Expires')->getFieldValue()); } /** diff --git a/app/code/Magento/Core/Test/Unit/Model/NoRouteHandlerListTest.php b/lib/internal/Magento/Framework/App/Test/Unit/Router/NoRouteHandlerListTest.php similarity index 95% rename from app/code/Magento/Core/Test/Unit/Model/NoRouteHandlerListTest.php rename to lib/internal/Magento/Framework/App/Test/Unit/Router/NoRouteHandlerListTest.php index 4673d2f03048c8ef4bb5c97c881eddf5b1771cae..23ae614a3673a52ea658c3770457b4b20f2a7fba 100644 --- a/app/code/Magento/Core/Test/Unit/Model/NoRouteHandlerListTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/Router/NoRouteHandlerListTest.php @@ -3,7 +3,10 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Core\Test\Unit\Model; + +// @codingStandardsIgnoreFile + +namespace Magento\Framework\App\Test\Unit\Router; class NoRouteHandlerListTest extends \PHPUnit_Framework_TestCase { diff --git a/lib/internal/Magento/Framework/App/Test/Unit/StateTest.php b/lib/internal/Magento/Framework/App/Test/Unit/StateTest.php index db3f0e7e6c82ec5b421b88d793762a18db00b884..e8066f086c37b02ba2a8c15caaedfb323d891c7c 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/StateTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/StateTest.php @@ -3,6 +3,9 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ + +// @codingStandardsIgnoreFile + namespace Magento\Framework\App\Test\Unit; class StateTest extends \PHPUnit_Framework_TestCase @@ -95,4 +98,41 @@ class StateTest extends \PHPUnit_Framework_TestCase { throw new \Exception('Some error'); } + + /** + * @param string $mode + * @dataProvider constructorDataProvider + */ + public function testConstructor($mode) + { + $model = new \Magento\Framework\App\State( + $this->getMockForAbstractClass('Magento\Framework\Config\ScopeInterface', [], '', false), + $mode + ); + $this->assertEquals($mode, $model->getMode()); + } + + /** + * @return array + */ + public static function constructorDataProvider() + { + return [ + 'default mode' => [\Magento\Framework\App\State::MODE_DEFAULT], + 'production mode' => [\Magento\Framework\App\State::MODE_PRODUCTION], + 'developer mode' => [\Magento\Framework\App\State::MODE_DEVELOPER] + ]; + } + + /** + * @expectedException \Exception + * @expectedExceptionMessage Unknown application mode: unknown mode + */ + public function testConstructorException() + { + new \Magento\Framework\App\State( + $this->getMockForAbstractClass('Magento\Framework\Config\ScopeInterface', [], '', false), + "unknown mode" + ); + } } diff --git a/lib/internal/Magento/Framework/App/Utility/Classes.php b/lib/internal/Magento/Framework/App/Utility/Classes.php index 197efbc95fb0a88104b727c3c3fbc53ce9184ba3..6671bd6a0464da30ef79dd001742cd2ff6ad43ef 100644 --- a/lib/internal/Magento/Framework/App/Utility/Classes.php +++ b/lib/internal/Magento/Framework/App/Utility/Classes.php @@ -272,7 +272,11 @@ class Classes */ public static function isAutogenerated($className) { - if (preg_match('/.*\\\\[a-zA-Z0-9]{1,}(Factory|Proxy|SearchResults|DataBuilder)$/', $className) + if ( + preg_match( + '/.*\\\\[a-zA-Z0-9]{1,}(Factory|Proxy|SearchResults|DataBuilder|Extension|ExtensionInterface)$/', + $className + ) || preg_match('/Magento\\\\[\w]+\\\\(Test\\\\(Page|Fixture))\\\\/', $className) ) { return true; diff --git a/lib/internal/Magento/Framework/App/Utility/Files.php b/lib/internal/Magento/Framework/App/Utility/Files.php index 97b389f125f278e3d7f67176894ab2ec0905f06c..15869c4be7c49c67c886bab1b14484c2f5b1b5ea 100644 --- a/lib/internal/Magento/Framework/App/Utility/Files.php +++ b/lib/internal/Magento/Framework/App/Utility/Files.php @@ -490,18 +490,18 @@ class Files /** * Returns list of Javascript files in Magento * + * @param string $area + * @param string $themePath + * @param string $namespace + * @param string $module * @return array */ - public function getJsFiles() + public function getJsFiles($area = '*', $themePath = '*/*', $namespace = '*', $module = '*') { - $key = __METHOD__ . $this->_path; + $key = $area . $themePath . $namespace . $module . __METHOD__ . $this->_path; if (isset(self::$_cache[$key])) { return self::$_cache[$key]; } - $namespace = '*'; - $module = '*'; - $area = '*'; - $themePath = '*/*'; $files = self::getFiles( [ "{$this->_path}/app/code/{$namespace}/{$module}/view/{$area}/web", diff --git a/lib/internal/Magento/Framework/Cache/Backend/Database.php b/lib/internal/Magento/Framework/Cache/Backend/Database.php index b1233e1301b24e981d92dd8a0c98c02217390225..bac1d79525dac3bc49f89537303f4af2d1a17f38 100644 --- a/lib/internal/Magento/Framework/Cache/Backend/Database.php +++ b/lib/internal/Magento/Framework/Cache/Backend/Database.php @@ -9,7 +9,7 @@ /** Tables declaration: -CREATE TABLE IF NOT EXISTS `core_cache` ( +CREATE TABLE IF NOT EXISTS `cache` ( `id` VARCHAR(255) NOT NULL, `data` mediumblob, `create_time` int(11), @@ -19,12 +19,12 @@ CREATE TABLE IF NOT EXISTS `core_cache` ( KEY `IDX_EXPIRE_TIME` (`expire_time`) )ENGINE=InnoDB DEFAULT CHARSET=utf8; -CREATE TABLE IF NOT EXISTS `core_cache_tag` ( +CREATE TABLE IF NOT EXISTS `cache_tag` ( `tag` VARCHAR(255) NOT NULL, `cache_id` VARCHAR(255) NOT NULL, KEY `IDX_TAG` (`tag`), KEY `IDX_CACHE_ID` (`cache_id`), - CONSTRAINT `FK_CORE_CACHE_TAG` FOREIGN KEY (`cache_id`) REFERENCES `core_cache` (`id`) ON DELETE CASCADE ON UPDATE CASCADE + CONSTRAINT `FK_CORE_CACHE_TAG` FOREIGN KEY (`cache_id`) REFERENCES `cache` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; */ diff --git a/lib/internal/Magento/Framework/Cache/Test/Unit/Config/ConverterTest.php b/lib/internal/Magento/Framework/Cache/Test/Unit/Config/ConverterTest.php index 5f6b0c6221c0705107eba10c0ed1e16d55f9113c..84ec6cf98539214addb0e08193fb73e728a28c75 100644 --- a/lib/internal/Magento/Framework/Cache/Test/Unit/Config/ConverterTest.php +++ b/lib/internal/Magento/Framework/Cache/Test/Unit/Config/ConverterTest.php @@ -27,24 +27,4 @@ class ConverterTest extends \PHPUnit_Framework_TestCase $expectedResult = include $convertedFile; $this->assertEquals($expectedResult, $this->_model->convert($dom)); } - - /** - * @param string $xmlData - * @dataProvider wrongXmlDataProvider - * @expectedException \Exception - */ - public function testMapThrowsExceptionWhenXmlHasWrongFormat($xmlData) - { - $dom = new \DOMDocument(); - $dom->loadXML($xmlData); - $this->_model->convert($dom); - } - - /** - * @return array - */ - public function wrongXmlDataProvider() - { - return [['<?xml version="1.0"?><config>']]; - } } diff --git a/lib/internal/Magento/Framework/Code/Generator.php b/lib/internal/Magento/Framework/Code/Generator.php index 1339a790efc9b6fa0bdf67a1c9a65a234ef8d759..35026a88b69d1d66c4e10d913ea5b5fa35e2d155 100644 --- a/lib/internal/Magento/Framework/Code/Generator.php +++ b/lib/internal/Magento/Framework/Code/Generator.php @@ -31,6 +31,11 @@ class Generator */ protected $definedClasses; + /** + * @var \Magento\Framework\ObjectManagerInterface + */ + protected $objectManager; + /** * @param Generator\Io $ioObject * @param array $generatedEntities @@ -86,18 +91,15 @@ class Generator } if (!$entity || !$entityName) { return self::GENERATION_ERROR; - } - - if ($this->definedClasses->classLoadable($className)) { + } else if ($this->definedClasses->classLoadable($className)) { return self::GENERATION_SKIP; - } - - if (!isset($this->_generatedEntities[$entity])) { + } else if (!isset($this->_generatedEntities[$entity])) { throw new \InvalidArgumentException('Unknown generation entity.'); } $generatorClass = $this->_generatedEntities[$entity]; /** @var EntityAbstract $generator */ $generator = $this->createGeneratorInstance($generatorClass, $entityName, $className); + $this->tryToLoadSourceClass($className, $generator); if (!($file = $generator->generate())) { $errors = $generator->getErrors(); throw new \Magento\Framework\Exception(implode(' ', $errors)); @@ -125,6 +127,57 @@ class Generator */ protected function createGeneratorInstance($generatorClass, $entityName, $className) { - return new $generatorClass($entityName, $className, $this->_ioObject); + return $this->getObjectManager()->create( + $generatorClass, + ['sourceClassName' => $entityName, 'resultClassName' => $className, 'ioObject' => $this->_ioObject] + ); + } + + /** + * Set object manager instance. + * + * @param \Magento\Framework\ObjectManagerInterface $objectManager + * @return $this + */ + public function setObjectManager(\Magento\Framework\ObjectManagerInterface $objectManager) + { + $this->objectManager = $objectManager; + return $this; + } + + /** + * Get object manager instance. + * + * @return \Magento\Framework\ObjectManagerInterface + */ + public function getObjectManager() + { + if (!($this->objectManager instanceof \Magento\Framework\ObjectManagerInterface)) { + throw new \LogicException( + "Object manager was expected to be set using setObjectManger() " + . "before getObjectManager() invocation." + ); + } + return $this->objectManager; + } + + /** + * Try to load/generate source class to check if it is valid or not. + * + * @param string $className + * @param \Magento\Framework\Code\Generator\EntityAbstract $generator + * @return void + * @throws \Magento\Framework\Exception + */ + protected function tryToLoadSourceClass($className, $generator) + { + $sourceClassName = $generator->getSourceClassName(); + if (!$this->definedClasses->classLoadable($sourceClassName)) { + if ($this->generateClass($sourceClassName) !== self::GENERATION_SUCCESS) { + throw new \Magento\Framework\Exception( + sprintf('Source class "%s" for "%s" generation does not exist.', $sourceClassName, $className) + ); + } + } } } diff --git a/lib/internal/Magento/Framework/Code/Generator/EntityAbstract.php b/lib/internal/Magento/Framework/Code/Generator/EntityAbstract.php index f98c4d689653fb007b7eec15e8ceec8228de39f1..20da9af1a5aaff1fa2904dac17a5f65f00069aea 100644 --- a/lib/internal/Magento/Framework/Code/Generator/EntityAbstract.php +++ b/lib/internal/Magento/Framework/Code/Generator/EntityAbstract.php @@ -121,15 +121,26 @@ abstract class EntityAbstract } /** - * Get source class name + * Get full source class name, with namespace * * @return string */ - protected function _getSourceClassName() + public function getSourceClassName() { return $this->_sourceClassName; } + /** + * Get source class without namespace. + * + * @return string + */ + public function getSourceClassNameWithoutNamespace() + { + $parts = explode('\\', ltrim($this->getSourceClassName(), '\\')); + return end($parts); + } + /** * Get fully qualified class name * @@ -234,7 +245,7 @@ abstract class EntityAbstract */ protected function _validateData() { - $sourceClassName = $this->_getSourceClassName(); + $sourceClassName = $this->getSourceClassName(); $resultClassName = $this->_getResultClassName(); $resultFileName = $this->_ioObject->getResultFileName($resultClassName); @@ -292,7 +303,7 @@ abstract class EntityAbstract */ protected function _getClassDocBlock() { - $description = ucfirst(static::ENTITY_TYPE) . ' class for @see ' . $this->_getSourceClassName(); + $description = ucfirst(static::ENTITY_TYPE) . ' class for @see ' . $this->getSourceClassName(); return ['shortDescription' => $description]; } diff --git a/lib/internal/Magento/Framework/Code/Reader/ArgumentsReader.php b/lib/internal/Magento/Framework/Code/Reader/ArgumentsReader.php index 98eafe0f910928432718435f533c032980bd8e38..c26f31283ddb0a747cdcb0c51b32927e6e0e8001 100644 --- a/lib/internal/Magento/Framework/Code/Reader/ArgumentsReader.php +++ b/lib/internal/Magento/Framework/Code/Reader/ArgumentsReader.php @@ -47,12 +47,10 @@ class ArgumentsReader } elseif (true == is_int($value)) { $default = $value; } else { - $default = is_null( - $parameter->getDefaultValue() - ) ? 'null' : "'" . $parameter->getDefaultValue() . "'"; + $default = $parameter->getDefaultValue(); } } elseif ($parameter->allowsNull()) { - $default = 'null'; + $default = null; } } diff --git a/lib/internal/Magento/Framework/Code/Test/Unit/GeneratorTest.php b/lib/internal/Magento/Framework/Code/Test/Unit/GeneratorTest.php index 3e7d273a24d5c152dd778f824e538331c54e79de..efa21cde844f603a7e347bf46002d9b77312e529 100644 --- a/lib/internal/Magento/Framework/Code/Test/Unit/GeneratorTest.php +++ b/lib/internal/Magento/Framework/Code/Test/Unit/GeneratorTest.php @@ -3,6 +3,9 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ + +// @codingStandardsIgnoreFile + namespace Magento\Framework\Code\Test\Unit; class GeneratorTest extends \PHPUnit_Framework_TestCase @@ -70,8 +73,12 @@ class GeneratorTest extends \PHPUnit_Framework_TestCase 'interceptor' => '\Magento\Framework\Interception\Code\Generator\Interceptor' ] ); - - $this->model->generateClass($className . $entityType); + $objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface'); + $fullClassName = $className . $entityType; + $entityGeneratorMock = $this->getMockBuilder($fullClassName)->disableOriginalConstructor()->getMock(); + $objectManagerMock->expects($this->once())->method('create')->willReturn($entityGeneratorMock); + $this->model->setObjectManager($objectManagerMock); + $this->model->generateClass($fullClassName); } /** @@ -125,7 +132,10 @@ class GeneratorTest extends \PHPUnit_Framework_TestCase $expectedEntities = array_values($this->expectedEntities); $resultClassName = self::SOURCE_CLASS . ucfirst(array_shift($expectedEntities)); - + $objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface'); + $entityGeneratorMock = $this->getMockBuilder($resultClassName)->disableOriginalConstructor()->getMock(); + $objectManagerMock->expects($this->once())->method('create')->willReturn($entityGeneratorMock); + $this->model->setObjectManager($objectManagerMock); $this->model->generateClass($resultClassName); } diff --git a/lib/internal/Magento/Framework/Code/Test/Unit/Reader/ArgumentsReaderTest.php b/lib/internal/Magento/Framework/Code/Test/Unit/Reader/ArgumentsReaderTest.php index 412c5dc49df9d8bf239cdb9802d208074c9b5e8e..8c5e45a18732f91d8d004bfe64fe057a20cc032e 100644 --- a/lib/internal/Magento/Framework/Code/Test/Unit/Reader/ArgumentsReaderTest.php +++ b/lib/internal/Magento/Framework/Code/Test/Unit/Reader/ArgumentsReaderTest.php @@ -48,7 +48,7 @@ class ArgumentsReaderTest extends \PHPUnit_Framework_TestCase 'position' => 3, 'type' => null, 'isOptional' => true, - 'default' => "'Const Value'", + 'default' => 'Const Value', ], 'optionalNumValue' => [ 'name' => 'optionalNumValue', @@ -62,7 +62,7 @@ class ArgumentsReaderTest extends \PHPUnit_Framework_TestCase 'position' => 5, 'type' => null, 'isOptional' => true, - 'default' => "'optional string'", + 'default' => 'optional string', ], 'optionalArrayValue' => [ 'name' => 'optionalArrayValue', @@ -115,7 +115,7 @@ class ArgumentsReaderTest extends \PHPUnit_Framework_TestCase 'position' => 3, 'type' => null, 'isOptional' => true, - 'default' => "'Const Value'", + 'default' => 'Const Value', ], 'optionalNumValue' => [ 'name' => 'optionalNumValue', @@ -129,7 +129,7 @@ class ArgumentsReaderTest extends \PHPUnit_Framework_TestCase 'position' => 5, 'type' => null, 'isOptional' => true, - 'default' => "'optional string'", + 'default' => 'optional string', ], 'optionalArrayValue' => [ 'name' => 'optionalArrayValue', @@ -177,24 +177,24 @@ class ArgumentsReaderTest extends \PHPUnit_Framework_TestCase 'position' => 0, 'type' => null, 'isOptional' => true, - 'default' => null, + 'default' => '', ], 'code' => [ 'name' => 'code', 'position' => 1, 'type' => null, 'isOptional' => true, - 'default' => null, + 'default' => 0, ], 'previous' => [ 'name' => 'previous', 'position' => 2, - 'type' => null, + 'type' => '\Exception', 'isOptional' => true, 'default' => null, ], ]; - $class = new \ReflectionClass('ClassExtendsDefaultPhpType'); + $class = new \ReflectionClass('ClassExtendsDefaultPhpTypeWithIOverrideConstructor'); $actualResult = $this->_model->getConstructorArguments($class, false, true); $this->assertEquals($expectedResult, $actualResult); diff --git a/lib/internal/Magento/Framework/Code/Test/Unit/Reader/_files/ClassesForArgumentsReader.php b/lib/internal/Magento/Framework/Code/Test/Unit/Reader/_files/ClassesForArgumentsReader.php index 9987087c3d3ee84189eccab7a076f3ec2dc51972..9ce41a9fe3c73dfc3592b113f35a78f22a63aa24 100644 --- a/lib/internal/Magento/Framework/Code/Test/Unit/Reader/_files/ClassesForArgumentsReader.php +++ b/lib/internal/Magento/Framework/Code/Test/Unit/Reader/_files/ClassesForArgumentsReader.php @@ -82,6 +82,22 @@ class ClassWithoutConstruct class ClassExtendsDefaultPhpType extends \RuntimeException { } +class ClassExtendsDefaultPhpTypeWithIOverrideConstructor extends \RuntimeException +{ + /** + * Override constructor due to Reflection API incorrect work with internal PHP classes. + * Obtaining of default argument value and default argument type is incorrect + * + * @param string $message + * @param int $code + * @param Exception $previous + */ + public function __construct($message = '', $code = 0, Exception $previous = null) + { + parent::__construct($message, $code, $previous); + } +} + class FirstClassForParentCall { /** diff --git a/app/code/Magento/Core/Controller/Index/Index.php b/lib/internal/Magento/Framework/Controller/Index/Index.php similarity index 84% rename from app/code/Magento/Core/Controller/Index/Index.php rename to lib/internal/Magento/Framework/Controller/Index/Index.php index 85ff6a6af433749971148420bc95dcc6fc9cf837..bc8b9d70810a6fa660f8868044c344c02ea41c0e 100644 --- a/app/code/Magento/Core/Controller/Index/Index.php +++ b/lib/internal/Magento/Framework/Controller/Index/Index.php @@ -4,7 +4,7 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Core\Controller\Index; +namespace Magento\Framework\Controller\Index; class Index extends \Magento\Framework\App\Action\Action { diff --git a/app/code/Magento/Core/Controller/Noroute/Index.php b/lib/internal/Magento/Framework/Controller/Noroute/Index.php similarity index 96% rename from app/code/Magento/Core/Controller/Noroute/Index.php rename to lib/internal/Magento/Framework/Controller/Noroute/Index.php index 4d8887573d65775ef4cbe7c9dc10cb7376912675..2d4da914cd00450a19fa2889bc489f7561ba4b77 100644 --- a/app/code/Magento/Core/Controller/Noroute/Index.php +++ b/lib/internal/Magento/Framework/Controller/Noroute/Index.php @@ -4,7 +4,7 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Core\Controller\Noroute; +namespace Magento\Framework\Controller\Noroute; class Index extends \Magento\Framework\App\Action\Action { diff --git a/lib/internal/Magento/Framework/Controller/Result/JSON.php b/lib/internal/Magento/Framework/Controller/Result/Json.php similarity index 98% rename from lib/internal/Magento/Framework/Controller/Result/JSON.php rename to lib/internal/Magento/Framework/Controller/Result/Json.php index 1876280468ce46faf536e95c9ec5a741a1b5e6f3..f1d480efec72e9ec8b610e4209bb581cbf1cb773 100644 --- a/lib/internal/Magento/Framework/Controller/Result/JSON.php +++ b/lib/internal/Magento/Framework/Controller/Result/Json.php @@ -14,7 +14,7 @@ use Magento\Framework\Translate\InlineInterface; * A possible implementation of JSON response type (instead of hardcoding json_encode() all over the place) * Actual for controller actions that serve ajax requests */ -class JSON extends AbstractResult +class Json extends AbstractResult { /** * @var \Magento\Framework\Translate\InlineInterface diff --git a/lib/internal/Magento/Framework/Controller/ResultFactory.php b/lib/internal/Magento/Framework/Controller/ResultFactory.php index f9700a534549627b20480907919a1ad4c74523bb..db78cf29c63014d7102ef03cabd1378fd6ee828d 100644 --- a/lib/internal/Magento/Framework/Controller/ResultFactory.php +++ b/lib/internal/Magento/Framework/Controller/ResultFactory.php @@ -30,7 +30,7 @@ class ResultFactory * @var array */ protected $typeMap = [ - self::TYPE_JSON => 'Magento\Framework\Controller\Result\JSON', + self::TYPE_JSON => 'Magento\Framework\Controller\Result\Json', self::TYPE_RAW => 'Magento\Framework\Controller\Result\Raw', self::TYPE_REDIRECT => 'Magento\Framework\Controller\Result\Redirect', self::TYPE_FORWARD => 'Magento\Framework\Controller\Result\Forward', diff --git a/app/code/Magento/Core/Test/Unit/Controller/Index/IndexTest.php b/lib/internal/Magento/Framework/Controller/Test/Unit/Controller/Index/IndexTest.php similarity index 70% rename from app/code/Magento/Core/Test/Unit/Controller/Index/IndexTest.php rename to lib/internal/Magento/Framework/Controller/Test/Unit/Controller/Index/IndexTest.php index 9353ed854e497eb10e4cc660922680cf33301ac1..aac2c071fb0a4322ed0437bd84ac3efc4046f8a9 100644 --- a/app/code/Magento/Core/Test/Unit/Controller/Index/IndexTest.php +++ b/lib/internal/Magento/Framework/Controller/Test/Unit/Controller/Index/IndexTest.php @@ -3,7 +3,7 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Core\Test\Unit\Controller\Index; +namespace Magento\Framework\Controller\Test\Unit\Controller\Index; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; @@ -13,9 +13,9 @@ class IndexTest extends \PHPUnit_Framework_TestCase { $objectManager = new ObjectManager($this); /** - * @var \Magento\Core\Controller\Index\Index + * @var \Magento\Framework\Controller\Index\Index */ - $controller = $objectManager->getObject('Magento\Core\Controller\Index\Index'); + $controller = $objectManager->getObject('Magento\Framework\Controller\Index\Index'); // The execute method is empty and returns void, just calling to verify // the method exists and does not throw an exception diff --git a/app/code/Magento/Core/Test/Unit/Controller/NorouteTest.php b/lib/internal/Magento/Framework/Controller/Test/Unit/Controller/NorouteTest.php similarity index 94% rename from app/code/Magento/Core/Test/Unit/Controller/NorouteTest.php rename to lib/internal/Magento/Framework/Controller/Test/Unit/Controller/NorouteTest.php index e8fa0f8df15a7325fdca4234d423af3a02549276..e1224c5ff7f80ed4ceec7bdb91671a9449865a0b 100644 --- a/app/code/Magento/Core/Test/Unit/Controller/NorouteTest.php +++ b/lib/internal/Magento/Framework/Controller/Test/Unit/Controller/NorouteTest.php @@ -3,12 +3,12 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Core\Test\Unit\Controller; +namespace Magento\Framework\Controller\Test\Unit\Controller; class NorouteTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Core\Controller\Noroute\Index + * @var \Magento\Framework\Controller\Noroute */ protected $_controller; @@ -34,7 +34,7 @@ class NorouteTest extends \PHPUnit_Framework_TestCase $this->_viewMock = $this->getMock('\Magento\Framework\App\ViewInterface'); $this->_statusMock = $this->getMock('Magento\Framework\Object', ['getLoaded'], [], '', false); $this->_controller = $helper->getObject( - 'Magento\Core\Controller\Noroute\Index', + 'Magento\Framework\Controller\Noroute\Index', ['request' => $this->_requestMock, 'view' => $this->_viewMock] ); } diff --git a/lib/internal/Magento/Framework/Controller/Test/Unit/Result/JSONTest.php b/lib/internal/Magento/Framework/Controller/Test/Unit/Result/JsonTest.php similarity index 78% rename from lib/internal/Magento/Framework/Controller/Test/Unit/Result/JSONTest.php rename to lib/internal/Magento/Framework/Controller/Test/Unit/Result/JsonTest.php index 0f57fb17b0c49d4e786b556177daa291d36a1c8b..d92164f181e41db5370575589aa4c8b28057da02 100644 --- a/lib/internal/Magento/Framework/Controller/Test/Unit/Result/JSONTest.php +++ b/lib/internal/Magento/Framework/Controller/Test/Unit/Result/JsonTest.php @@ -7,12 +7,15 @@ namespace Magento\Framework\Controller\Test\Unit\Result; /** - * Class JSONTest + * Class JsonTest * - * covers Magento\Framework\Controller\Result\JSON + * covers Magento\Framework\Controller\Result\Json */ -class JSONTest extends \PHPUnit_Framework_TestCase +class JsonTest extends \PHPUnit_Framework_TestCase { + /** + * @return void + */ public function testRenderResult() { $json = '{"data":"data"}'; @@ -29,9 +32,9 @@ class JSONTest extends \PHPUnit_Framework_TestCase $response = $this->getMock('Magento\Framework\App\Response\Http', ['representJson'], [], '', false); $response->expects($this->atLeastOnce())->method('representJson')->with($json)->will($this->returnSelf()); - /** @var \Magento\Framework\Controller\Result\JSON $resultJson */ + /** @var \Magento\Framework\Controller\Result\Json $resultJson */ $resultJson = (new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this)) - ->getObject('Magento\Framework\Controller\Result\JSON', ['translateInline' => $translateInline]); + ->getObject('Magento\Framework\Controller\Result\Json', ['translateInline' => $translateInline]); $resultJson->setJsonData($json); $this->assertSame($resultJson, $resultJson->renderResult($response)); } diff --git a/lib/internal/Magento/Framework/Convert/ConvertArray.php b/lib/internal/Magento/Framework/Convert/ConvertArray.php index bf9fa3110998d548374f234ea82748b2af4c253e..902c7c99dee79309cb3af33e4c03fbcdbd130d73 100644 --- a/lib/internal/Magento/Framework/Convert/ConvertArray.php +++ b/lib/internal/Magento/Framework/Convert/ConvertArray.php @@ -67,7 +67,7 @@ XML; * @return \SimpleXMLElement * @throws Exception */ - private function _assocToXml(array $array, $rootName, \SimpleXMLElement &$xml) + private function _assocToXml(array $array, $rootName, \SimpleXMLElement $xml) { $hasNumericKey = false; $hasStringKey = false; @@ -78,12 +78,13 @@ XML; throw new Exception('Associative key must not be the same as its parent associative key.'); } $hasStringKey = true; - $xml->{$key} = $value; + $xml->addChild($key, $value); } elseif (is_int($key)) { $hasNumericKey = true; - $xml->{$rootName}[$key] = $value; + $xml->addChild($key, $value); } } else { + $xml->addChild($key); self::_assocToXml($value, $key, $xml->{$key}); } } diff --git a/lib/internal/Magento/Framework/Data/Collection.php b/lib/internal/Magento/Framework/Data/Collection.php index c8ab80c82f3d2674e4fa500afd343eb2d349c5bf..2ba01363659041e1916b2dd9de9f33e613b13563 100644 --- a/lib/internal/Magento/Framework/Data/Collection.php +++ b/lib/internal/Magento/Framework/Data/Collection.php @@ -15,8 +15,7 @@ use Magento\Framework\Option\ArrayInterface; */ /** - * TODO: Refactor use of \Magento\Framework\Option\ArrayInterface in library. Probably will be refactored while - * moving \Magento\Core to library + * TODO: Refactor use of \Magento\Framework\Option\ArrayInterface in library. */ class Collection implements \IteratorAggregate, \Countable, ArrayInterface, CollectionDataSourceInterface { diff --git a/lib/internal/Magento/Framework/Data/Collection/EntityFactory.php b/lib/internal/Magento/Framework/Data/Collection/EntityFactory.php index 3341e32d209d0f4ecac8ef55bd9bed4d15308595..6ab0ab7e5d21f1da09d0a54b320969a03d401701 100644 --- a/lib/internal/Magento/Framework/Data/Collection/EntityFactory.php +++ b/lib/internal/Magento/Framework/Data/Collection/EntityFactory.php @@ -35,9 +35,9 @@ class EntityFactory implements EntityFactoryInterface public function create($className, array $data = []) { $model = $this->_objectManager->create($className, $data); - //TODO: fix that when this factory used only for \Magento\Core\Model\Abstract - //if (!$model instanceof \Magento\Core\Model\Abstract) { - // throw new \LogicException($className . ' doesn\'t implement \Magento\Core\Model\Abstract'); + //TODO: fix that when this factory used only for \Magento\Framework\Model\AbstractModel + //if (!$model instanceof \Magento\Framework\Model\AbstractModel) { + // throw new \LogicException($className . ' doesn\'t implement \Magento\Framework\Model\AbstractModel'); //} return $model; } diff --git a/lib/internal/Magento/Framework/Data/Structure.php b/lib/internal/Magento/Framework/Data/Structure.php index 4ec2fb61cfea4af1494875e81389b6fcd107a561..6f97437a266d99e900d1d95d8482d9258c660c88 100644 --- a/lib/internal/Magento/Framework/Data/Structure.php +++ b/lib/internal/Magento/Framework/Data/Structure.php @@ -602,7 +602,7 @@ class Structure private function _assertElementExists($elementId) { if (!isset($this->_elements[$elementId])) { - throw new Exception("No element found with ID '{$elementId}'."); + throw new \OutOfBoundsException("No element found with ID '{$elementId}'."); } } diff --git a/lib/internal/Magento/Framework/Data/Test/Unit/StructureTest.php b/lib/internal/Magento/Framework/Data/Test/Unit/StructureTest.php index 5fd8bafce2234ebfe4549698dea1675583b41b5c..17c4e3cf39a648c04bce1183cd38b49ac8448384 100644 --- a/lib/internal/Magento/Framework/Data/Test/Unit/StructureTest.php +++ b/lib/internal/Magento/Framework/Data/Test/Unit/StructureTest.php @@ -12,6 +12,9 @@ class StructureTest extends \PHPUnit_Framework_TestCase */ protected $_structure; + /** + * @return void + */ protected function setUp() { $this->_structure = new \Magento\Framework\Data\Structure(); @@ -19,6 +22,7 @@ class StructureTest extends \PHPUnit_Framework_TestCase /** * @param array $elements + * @return void * @dataProvider importExportElementsDataProvider */ public function testConstructImportExportElements($elements) @@ -63,6 +67,7 @@ class StructureTest extends \PHPUnit_Framework_TestCase /** * @param array $elements + * @return void * @dataProvider importExceptionDataProvider * @expectedException \Magento\Framework\Exception */ @@ -71,13 +76,13 @@ class StructureTest extends \PHPUnit_Framework_TestCase $this->_structure->importElements($elements); } + /** + * @return array + */ public function importExceptionDataProvider() { return [ 'numeric id' => [['element']], - 'non-existing parent' => [ - ['element' => [\Magento\Framework\Data\Structure::PARENT => 'unknown']], - ], 'completely missing nested set' => [ ['one' => [\Magento\Framework\Data\Structure::PARENT => 'two'], 'two' => []], ], @@ -100,14 +105,6 @@ class StructureTest extends \PHPUnit_Framework_TestCase 'three' => [\Magento\Framework\Data\Structure::PARENT => 'one'], ], ], - 'missing child' => [ - [ - 'one' => [ - \Magento\Framework\Data\Structure::CHILDREN => ['two' => 't.w.o.', 'three' => 't.h.r.e.e.'], - ], - 'two' => [\Magento\Framework\Data\Structure::PARENT => 'one'], - ], - ], 'missing reference back to parent' => [ ['one' => [ \Magento\Framework\Data\Structure::CHILDREN => ['two' => 't.w.o.'], ], 'two' => [], @@ -139,6 +136,40 @@ class StructureTest extends \PHPUnit_Framework_TestCase ]; } + /** + * @param array $elements + * @return void + * @dataProvider importExceptionElementNotFoundDataProvider + * @expectedException \OutOfBoundsException + */ + public function testImportExceptionElementNotFound($elements) + { + $this->_structure->importElements($elements); + } + + /** + * @return array + */ + public function importExceptionElementNotFoundDataProvider() + { + return [ + 'non-existing parent' => [ + ['element' => [\Magento\Framework\Data\Structure::PARENT => 'unknown']], + ], + 'missing child' => [ + [ + 'one' => [ + \Magento\Framework\Data\Structure::CHILDREN => ['two' => 't.w.o.', 'three' => 't.h.r.e.e.'], + ], + 'two' => [\Magento\Framework\Data\Structure::PARENT => 'one'], + ], + ], + ]; + } + + /** + * @return void + */ public function testCreateGetHasElement() { $data = [uniqid() => uniqid()]; @@ -152,6 +183,7 @@ class StructureTest extends \PHPUnit_Framework_TestCase } /** + * @return void * @expectedException \Magento\Framework\Exception */ public function testCreateElementException() @@ -161,6 +193,9 @@ class StructureTest extends \PHPUnit_Framework_TestCase $this->_structure->createElement($elementId, []); } + /** + * @return void + */ public function testUnsetElement() { $this->_populateSampleStructure(); @@ -175,6 +210,9 @@ class StructureTest extends \PHPUnit_Framework_TestCase $this->assertSame(['one' => [], 'five' => [5]], $this->_structure->exportElements()); } + /** + * @return void + */ public function testSetGetAttribute() { $this->_populateSampleStructure(); @@ -187,7 +225,8 @@ class StructureTest extends \PHPUnit_Framework_TestCase } /** - * @expectedException \Magento\Framework\Exception + * @return void + * @expectedException \OutOfBoundsException */ public function testSetAttributeNoElementException() { @@ -195,9 +234,10 @@ class StructureTest extends \PHPUnit_Framework_TestCase } /** + * @param string $attribute + * @return void * @expectedException \InvalidArgumentException * @dataProvider setAttributeArgumentExceptionDataProvider - * @param string $attribute */ public function testSetAttributeArgumentException($attribute) { @@ -218,13 +258,17 @@ class StructureTest extends \PHPUnit_Framework_TestCase } /** - * @expectedException \Magento\Framework\Exception + * @return void + * @expectedException \OutOfBoundsException */ public function testGetAttributeNoElementException() { $this->_structure->getAttribute('non-existing', 'foo'); } + /** + * @return void + */ public function testRenameElement() { $this->_populateSampleStructure(); @@ -253,6 +297,9 @@ class StructureTest extends \PHPUnit_Framework_TestCase $this->assertSame(['three.5' => 'th', 'two.5' => 'tw'], $this->_structure->getChildren('four.5')); } + /** + * @return void + */ public function testSetAsChild() { $this->_populateSampleStructure(); @@ -272,6 +319,7 @@ class StructureTest extends \PHPUnit_Framework_TestCase /** * @param int $offset * @param int $expectedOffset + * @return void * @dataProvider setAsChildOffsetDataProvider */ public function testSetAsChildOffset($offset, $expectedOffset) @@ -315,6 +363,7 @@ class StructureTest extends \PHPUnit_Framework_TestCase /** * @param string $elementId * @param string $parentId + * @return void * @expectedException \Magento\Framework\Exception * @dataProvider setAsChildExceptionDataProvider */ @@ -336,6 +385,9 @@ class StructureTest extends \PHPUnit_Framework_TestCase return [['one', 'three'], ['one', 'one']]; } + /** + * @return void + */ public function testUnsetChild() { $this->_populateSampleStructure(); @@ -355,6 +407,7 @@ class StructureTest extends \PHPUnit_Framework_TestCase * @param int $initialOffset * @param int $newOffset * @param int $expectedOffset + * @return void * @dataProvider reorderChildDataProvider */ public function testReorderChild($initialOffset, $newOffset, $expectedOffset) @@ -404,6 +457,7 @@ class StructureTest extends \PHPUnit_Framework_TestCase } /** + * @return void * @expectedException \Magento\Framework\Exception */ public function testReorderChildException() @@ -418,6 +472,7 @@ class StructureTest extends \PHPUnit_Framework_TestCase * @param string $sibling * @param int $delta * @param int $expectedOffset + * @return void * @dataProvider reorderSiblingDataProvider */ public function testReorderToSibling($initialOffset, $sibling, $delta, $expectedOffset) @@ -427,6 +482,9 @@ class StructureTest extends \PHPUnit_Framework_TestCase $this->assertSame($expectedOffset, $this->_structure->reorderToSibling('parent', 'x', $sibling, $delta)); } + /** + * @return array + */ public function reorderSiblingDataProvider() { return [ @@ -456,6 +514,7 @@ class StructureTest extends \PHPUnit_Framework_TestCase } /** + * @return void * @expectedException \Magento\Framework\Exception */ public function testReorderToSiblingException() @@ -467,6 +526,9 @@ class StructureTest extends \PHPUnit_Framework_TestCase $this->_structure->reorderToSibling('one', 'three', 'two', 1); } + /** + * @return void + */ public function testGetChildId() { $this->_populateSampleStructure(); @@ -474,6 +536,9 @@ class StructureTest extends \PHPUnit_Framework_TestCase $this->assertEquals('five', $this->_structure->getChildId('six', 'f')); } + /** + * @return void + */ public function testGetChildrenParentIdChildAlias() { $this->_structure->createElement('one', []); @@ -499,6 +564,7 @@ class StructureTest extends \PHPUnit_Framework_TestCase } /** + * @return void * covers \Magento\Framework\Data\Structure::addToParentGroup * covers \Magento\Framework\Data\Structure::getGroupChildNames */ @@ -542,6 +608,7 @@ class StructureTest extends \PHPUnit_Framework_TestCase /** * Import a sample valid structure + * @return void */ protected function _populateSampleStructure() { @@ -559,6 +626,7 @@ class StructureTest extends \PHPUnit_Framework_TestCase /** * Import a sample structure, suitable for testing elements sort order + * @return void */ protected function _populateSampleSortStructure() { diff --git a/lib/internal/Magento/Framework/Exception/AbstractAggregateException.php b/lib/internal/Magento/Framework/Exception/AbstractAggregateException.php index c63e32c6dd390ecebd989f98ec872b21ae0e8850..c012e04d7563b950d0b5c078ddf4ab14aaaa7bc1 100644 --- a/lib/internal/Magento/Framework/Exception/AbstractAggregateException.php +++ b/lib/internal/Magento/Framework/Exception/AbstractAggregateException.php @@ -6,35 +6,23 @@ namespace Magento\Framework\Exception; +use Magento\Framework\Phrase; + abstract class AbstractAggregateException extends LocalizedException { /** - * The array of errors that have been added via the addError() method. + * The array of errors that have been added via the addError() method * - * @var ErrorMessage[] + * @var \Magento\Framework\Exception\LocalizedException[] */ protected $errors = []; /** - * The original message after being processed by the parent constructor - * - * @var string - */ - protected $originalMessage; - - /** - * The original raw message passed in via the constructor + * The original phrase * - * @var string + * @var \Magento\Framework\Phrase */ - protected $originalRawMessage; - - /** - * The original params passed in via the constructor - * - * @var array - */ - protected $originalParams = []; + protected $originalPhrase; /** * An internal variable indicating how many time addError has been called @@ -44,49 +32,44 @@ abstract class AbstractAggregateException extends LocalizedException private $addErrorCalls = 0; /** - * Initialize the exception. + * Initialize the exception * - * @param string $message - * @param array $params + * @param \Magento\Framework\Phrase $phrase * @param \Exception $cause */ - public function __construct($message, array $params = [], \Exception $cause = null) + public function __construct(Phrase $phrase, \Exception $cause = null) { - $this->originalRawMessage = $message; - $this->originalParams = $params; - parent::__construct($message, $params, $cause); - $this->originalMessage = $this->message; + $this->originalPhrase = $phrase; + parent::__construct($phrase, $cause); } /** - * Create a new error raw message object for the message and its substitution parameters. - * - * @param string $rawMessage Exception message - * @param array $params Substitution parameters and extra error debug information + * Add new error into the list of exceptions * + * @param \Magento\Framework\Phrase $phrase * @return $this */ - public function addError($rawMessage, array $params = []) + public function addError(Phrase $phrase) { $this->addErrorCalls++; if (empty($this->errors)) { if (1 === $this->addErrorCalls) { - // First call: simply overwrite the message and params - $this->rawMessage = $rawMessage; - $this->params = $params; - $this->message = (string)new \Magento\Framework\Phrase($rawMessage, $params); + // First call: simply overwrite the phrase and message + $this->phrase = $phrase; + $this->message = $phrase->render(); + $this->logMessage = null; } elseif (2 === $this->addErrorCalls) { // Second call: store the error from the first call and the second call in the array - // restore the message and params to their original value - $this->errors[] = new ErrorMessage($this->rawMessage, $this->params); - $this->errors[] = new ErrorMessage($rawMessage, $params); - $this->rawMessage = $this->originalRawMessage; - $this->params = $this->originalParams; - $this->message = $this->originalMessage; + // restore the phrase to its original value + $this->errors[] = new LocalizedException($this->phrase); + $this->errors[] = new LocalizedException($phrase); + $this->phrase = $this->originalPhrase; + $this->message = $this->originalPhrase->render(); + $this->logMessage = null; } } else { // All subsequent calls after the second should reach here - $this->errors[] = new ErrorMessage($rawMessage, $params); + $this->errors[] = new LocalizedException($phrase); } return $this; } @@ -102,9 +85,9 @@ abstract class AbstractAggregateException extends LocalizedException } /** - * Return the array of ErrorMessage objects. Return an empty array if no errors were added. + * Get the array of LocalizedException objects. Get an empty array if no errors were added. * - * @return ErrorMessage[] + * @return \Magento\Framework\Exception\LocalizedException[] */ public function getErrors() { diff --git a/lib/internal/Magento/Framework/Exception/AlreadyExistsException.php b/lib/internal/Magento/Framework/Exception/AlreadyExistsException.php index 507bce1aabbda031af43b37fca4a696ff932a23f..833a1166556b96a62faeaf64d0009791a5b4e313 100644 --- a/lib/internal/Magento/Framework/Exception/AlreadyExistsException.php +++ b/lib/internal/Magento/Framework/Exception/AlreadyExistsException.php @@ -6,6 +6,6 @@ namespace Magento\Framework\Exception; -class AlreadyExistsException extends \Magento\Framework\Exception\LocalizedException +class AlreadyExistsException extends LocalizedException { } diff --git a/lib/internal/Magento/Framework/Exception/CouldNotDeleteException.php b/lib/internal/Magento/Framework/Exception/CouldNotDeleteException.php index afce581bf1003cfd7277dec340c94fd3dfcf6bdd..b09f61b8155ba26bd68439051681d76a8c7ce40f 100644 --- a/lib/internal/Magento/Framework/Exception/CouldNotDeleteException.php +++ b/lib/internal/Magento/Framework/Exception/CouldNotDeleteException.php @@ -3,7 +3,6 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ - namespace Magento\Framework\Exception; class CouldNotDeleteException extends LocalizedException diff --git a/lib/internal/Magento/Framework/Exception/EmailNotConfirmedException.php b/lib/internal/Magento/Framework/Exception/EmailNotConfirmedException.php index 6dab6e987f9723dc8a99a267075cb0bfa11e069a..46fe43112da8eb341cd03eaae1515ebb9250e931 100644 --- a/lib/internal/Magento/Framework/Exception/EmailNotConfirmedException.php +++ b/lib/internal/Magento/Framework/Exception/EmailNotConfirmedException.php @@ -3,12 +3,10 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ - namespace Magento\Framework\Exception; /** * Class EmailNotConfirmedException - * */ class EmailNotConfirmedException extends AuthenticationException { diff --git a/lib/internal/Magento/Framework/Exception/ErrorMessage.php b/lib/internal/Magento/Framework/Exception/ErrorMessage.php deleted file mode 100644 index 0cb1c62eb184846eabfeab70cac25b4b9c4bfb39..0000000000000000000000000000000000000000 --- a/lib/internal/Magento/Framework/Exception/ErrorMessage.php +++ /dev/null @@ -1,85 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Framework\Exception; - -use Magento\Framework\Phrase\Renderer\Placeholder; - -class ErrorMessage -{ - /** - * The error message. - * - * @var string - */ - private $message; - - /** - * The message substitution parameters. - * - * @var array - */ - private $params; - - /** - * The renderer to use for retrieving the log-compatible message. - * - * @var Placeholder - */ - private $renderer; - - /** - * Initialize the error message object. - * - * @param string $message Error message - * @param array $parameters Message arguments (i.e. substitution parameters) - */ - public function __construct($message, array $parameters = []) - { - $this->message = $message; - $this->params = $parameters; - $this->renderer = new Placeholder(); - } - - /** - * Return the parameters associated with this error. - * - * @return array - */ - public function getParameters() - { - return $this->params; - } - - /** - * Return the message localized to based on the locale of the current request. - * - * @return \Magento\Framework\Phrase - */ - public function getMessage() - { - return (string)new \Magento\Framework\Phrase($this->message, $this->params); - } - - /** - * Return the un-processed message, which can be used as a localization key by web service clients. - * - * @return string - */ - public function getRawMessage() - { - return $this->message; - } - - /** - * Return the un-localized string, but with the parameters filled in. - * - * @return string - */ - public function getLogMessage() - { - return $this->renderer->render([$this->message], $this->params); - } -} diff --git a/lib/internal/Magento/Framework/Exception/File/LargeSizeException.php b/lib/internal/Magento/Framework/Exception/File/LargeSizeException.php index adb3afb144cda3c810534c5667cc9f0e0dd84c3a..73a22a65116e664f73531b2f34ed1612e5e803e3 100644 --- a/lib/internal/Magento/Framework/Exception/File/LargeSizeException.php +++ b/lib/internal/Magento/Framework/Exception/File/LargeSizeException.php @@ -5,6 +5,8 @@ */ namespace Magento\Framework\Exception\File; -class LargeSizeException extends \Magento\Framework\Exception\LocalizedException +use Magento\Framework\Exception\LocalizedException; + +class LargeSizeException extends LocalizedException { } diff --git a/lib/internal/Magento/Framework/Exception/File/ValidatorException.php b/lib/internal/Magento/Framework/Exception/File/ValidatorException.php index b2b2b9799eb9334f990577449093dc78d83d663d..a8f78f8aeb2668009a79ccdd4a0ced4ed55c5286 100644 --- a/lib/internal/Magento/Framework/Exception/File/ValidatorException.php +++ b/lib/internal/Magento/Framework/Exception/File/ValidatorException.php @@ -5,6 +5,8 @@ */ namespace Magento\Framework\Exception\File; -class ValidatorException extends \Magento\Framework\Exception\LocalizedException +use Magento\Framework\Exception\LocalizedException; + +class ValidatorException extends LocalizedException { } diff --git a/lib/internal/Magento/Framework/Exception/InputException.php b/lib/internal/Magento/Framework/Exception/InputException.php index 76fedb82de2302edb94b94d16eaa7d8073e2fadb..d71b5a168f78f5e174123362c359f488c6426bcb 100644 --- a/lib/internal/Magento/Framework/Exception/InputException.php +++ b/lib/internal/Magento/Framework/Exception/InputException.php @@ -5,6 +5,8 @@ */ namespace Magento\Framework\Exception; +use Magento\Framework\Phrase; + /** * Exception to be thrown when there is an issue with the Input to a function call. */ @@ -20,13 +22,15 @@ class InputException extends AbstractAggregateException /** * Initialize the input exception. * - * @param string $message Exception message - * @param array $params Substitution parameters - * @param \Exception $cause Cause of the InputException + * @param \Magento\Framework\Phrase $phrase + * @param \Exception $cause */ - public function __construct($message = self::DEFAULT_MESSAGE, $params = [], \Exception $cause = null) + public function __construct(Phrase $phrase = null, \Exception $cause = null) { - parent::__construct($message, $params, $cause); + if (is_null($phrase)) { + $phrase = new Phrase(self::DEFAULT_MESSAGE); + } + parent::__construct($phrase, $cause); } /** @@ -35,13 +39,12 @@ class InputException extends AbstractAggregateException * @param string $fieldName Name of the field which had an invalid value provided. * @param string $fieldValue The invalid value that was provided for the field. * @param \Exception $cause Cause of the InputException - * @return InputException + * @return \Magento\Framework\Exception\InputException */ public static function invalidFieldValue($fieldName, $fieldValue, \Exception $cause = null) { - return new InputException( - self::INVALID_FIELD_VALUE, - ['fieldName' => $fieldName, 'value' => $fieldValue], + return new self( + new Phrase(self::INVALID_FIELD_VALUE, ['fieldName' => $fieldName, 'value' => $fieldValue]), $cause ); } @@ -50,10 +53,12 @@ class InputException extends AbstractAggregateException * Creates an InputException for a missing required field. * * @param string $fieldName Name of the missing required field. - * @return InputException + * @return \Magento\Framework\Exception\InputException */ public static function requiredField($fieldName) { - return new InputException(self::REQUIRED_FIELD, ['fieldName' => $fieldName]); + return new self( + new Phrase(self::REQUIRED_FIELD, ['fieldName' => $fieldName]) + ); } } diff --git a/lib/internal/Magento/Framework/Exception/InvalidEmailOrPasswordException.php b/lib/internal/Magento/Framework/Exception/InvalidEmailOrPasswordException.php index 151581b7a995a5ce9978beb24fb36ec476632d12..2e1b98cac0666e8a4872854665b498f7b87a2fa4 100644 --- a/lib/internal/Magento/Framework/Exception/InvalidEmailOrPasswordException.php +++ b/lib/internal/Magento/Framework/Exception/InvalidEmailOrPasswordException.php @@ -7,7 +7,6 @@ namespace Magento\Framework\Exception; /** * Class InvalidEmailOrPasswordException - * */ class InvalidEmailOrPasswordException extends AuthenticationException { diff --git a/lib/internal/Magento/Framework/Exception/LocalizedException.php b/lib/internal/Magento/Framework/Exception/LocalizedException.php index 3ecc300c5c70aeca262ccbe04d2c5209a08942f8..1b9c96b2e7a6ea467a7693cda977dd62d32391ed 100644 --- a/lib/internal/Magento/Framework/Exception/LocalizedException.php +++ b/lib/internal/Magento/Framework/Exception/LocalizedException.php @@ -7,31 +7,31 @@ */ namespace Magento\Framework\Exception; +use Magento\Framework\Phrase; use Magento\Framework\Phrase\Renderer\Placeholder; class LocalizedException extends \Exception { - /** @var array */ - protected $params = []; - - /** @var string */ - protected $rawMessage; + /** + * @var \Magento\Framework\Phrase + */ + protected $phrase; - /** @var Placeholder */ - private $renderer; + /** + * @var string + */ + protected $logMessage; /** - * @param string $message - * @param array $params + * Constructor + * + * @param \Magento\Framework\Phrase $phrase * @param \Exception $cause */ - public function __construct($message, array $params = [], \Exception $cause = null) + public function __construct(Phrase $phrase, \Exception $cause = null) { - $this->params = $params; - $this->rawMessage = $message; - $this->renderer = new Placeholder(); - - parent::__construct((string)new \Magento\Framework\Phrase($message, $params), 0, $cause); + $this->phrase = $phrase; + parent::__construct($phrase->render(), 0, $cause); } /** @@ -41,26 +41,30 @@ class LocalizedException extends \Exception */ public function getRawMessage() { - return $this->rawMessage; + return $this->phrase->getText(); } /** - * Get the un-localized message, but with the parameters filled in + * Get parameters, corresponding to placeholders in raw exception message * - * @return string + * @return array */ - public function getLogMessage() + public function getParameters() { - return $this->renderer->render([$this->rawMessage], $this->params); + return $this->phrase->getArguments(); } /** - * Returns the array of parameters in the message + * Get the un-localized message, but with the parameters filled in * - * @return array Parameter name => values + * @return string */ - public function getParameters() + public function getLogMessage() { - return $this->params; + if (is_null($this->logMessage)) { + $renderer = new Placeholder(); + $this->logMessage = $renderer->render([$this->getRawMessage()], $this->getParameters()); + } + return $this->logMessage; } } diff --git a/lib/internal/Magento/Framework/Exception/NoSuchEntityException.php b/lib/internal/Magento/Framework/Exception/NoSuchEntityException.php index 2b4ad7129e87525c16bc8aaa8cda400b4996941a..844a8cf3316461d59640f22377dd681dc89460ff 100644 --- a/lib/internal/Magento/Framework/Exception/NoSuchEntityException.php +++ b/lib/internal/Magento/Framework/Exception/NoSuchEntityException.php @@ -7,22 +7,23 @@ */ namespace Magento\Framework\Exception; -class NoSuchEntityException extends \Magento\Framework\Exception\LocalizedException +use Magento\Framework\Phrase; + +class NoSuchEntityException extends LocalizedException { const MESSAGE_SINGLE_FIELD = 'No such entity with %fieldName = %fieldValue'; const MESSAGE_DOUBLE_FIELDS = 'No such entity with %fieldName = %fieldValue, %field2Name = %field2Value'; /** - * @param string $message - * @param array $params + * @param \Magento\Framework\Phrase $phrase * @param \Exception $cause */ - public function __construct( - $message = 'No such entity.', - array $params = [], - \Exception $cause = null - ) { - parent::__construct($message, $params, $cause); + public function __construct(Phrase $phrase = null, \Exception $cause = null) + { + if (is_null($phrase)) { + $phrase = new Phrase('No such entity.'); + } + parent::__construct($phrase, $cause); } /** @@ -30,16 +31,18 @@ class NoSuchEntityException extends \Magento\Framework\Exception\LocalizedExcept * * @param string $fieldName * @param string|int $fieldValue - * @return NoSuchEntityException + * @return \Magento\Framework\Exception\NoSuchEntityException */ public static function singleField($fieldName, $fieldValue) { - return new NoSuchEntityException( - self::MESSAGE_SINGLE_FIELD, - [ - 'fieldName' => $fieldName, - 'fieldValue' => $fieldValue, - ] + return new self( + new Phrase( + self::MESSAGE_SINGLE_FIELD, + [ + 'fieldName' => $fieldName, + 'fieldValue' => $fieldValue + ] + ) ); } @@ -50,18 +53,20 @@ class NoSuchEntityException extends \Magento\Framework\Exception\LocalizedExcept * @param string|int $fieldValue * @param string $secondFieldName * @param string|int $secondFieldValue - * @return NoSuchEntityException + * @return \Magento\Framework\Exception\NoSuchEntityException */ public static function doubleField($fieldName, $fieldValue, $secondFieldName, $secondFieldValue) { - return new NoSuchEntityException( - self::MESSAGE_DOUBLE_FIELDS, - [ - 'fieldName' => $fieldName, - 'fieldValue' => $fieldValue, - 'field2Name' => $secondFieldName, - 'field2Value' => $secondFieldValue, - ] + return new self( + new Phrase( + self::MESSAGE_DOUBLE_FIELDS, + [ + 'fieldName' => $fieldName, + 'fieldValue' => $fieldValue, + 'field2Name' => $secondFieldName, + 'field2Value' => $secondFieldValue, + ] + ) ); } } diff --git a/lib/internal/Magento/Framework/Exception/SerializationException.php b/lib/internal/Magento/Framework/Exception/SerializationException.php index 0c506c7bdfb99d6a7748421d6923db66e763ff43..e0b0dd0127a0144545848f41cf9902fe3a8a0e7d 100644 --- a/lib/internal/Magento/Framework/Exception/SerializationException.php +++ b/lib/internal/Magento/Framework/Exception/SerializationException.php @@ -3,23 +3,27 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ - namespace Magento\Framework\Exception; +use Magento\Framework\Phrase; + /** * Serialization Exception */ class SerializationException extends LocalizedException { - const TYPE_MISMATCH = 'Invalid type for value :"%value". Expected Type: "%type".'; + const DEFAULT_MESSAGE = 'Invalid type'; + const TYPE_MISMATCH = 'Invalid type for value: "%value". Expected Type: "%type".'; /** - * @param string $message - * @param array $params + * @param \Magento\Framework\Phrase $phrase * @param \Exception $cause */ - public function __construct($message = self::TYPE_MISMATCH, array $params = [], \Exception $cause = null) + public function __construct(Phrase $phrase = null, \Exception $cause = null) { - parent::__construct($message, $params, $cause); + if (is_null($phrase)) { + $phrase = new Phrase(self::DEFAULT_MESSAGE); + } + parent::__construct($phrase, $cause); } } diff --git a/lib/internal/Magento/Framework/Exception/State/ExpiredException.php b/lib/internal/Magento/Framework/Exception/State/ExpiredException.php index 8de49c78305e5a2c8b5288502030f3041739a1fd..2819320119413b2a2632861ebdb730a222541934 100644 --- a/lib/internal/Magento/Framework/Exception/State/ExpiredException.php +++ b/lib/internal/Magento/Framework/Exception/State/ExpiredException.php @@ -7,6 +7,8 @@ */ namespace Magento\Framework\Exception\State; -class ExpiredException extends \Magento\Framework\Exception\StateException +use Magento\Framework\Exception\StateException; + +class ExpiredException extends StateException { } diff --git a/lib/internal/Magento/Framework/Exception/State/InputMismatchException.php b/lib/internal/Magento/Framework/Exception/State/InputMismatchException.php index c0d2a3a3dfde788d9fbb2688a9140af9aa2dac01..550eab57e9d8f90df4952e5b1a749ae4a8b7d3e0 100644 --- a/lib/internal/Magento/Framework/Exception/State/InputMismatchException.php +++ b/lib/internal/Magento/Framework/Exception/State/InputMismatchException.php @@ -7,6 +7,8 @@ */ namespace Magento\Framework\Exception\State; -class InputMismatchException extends \Magento\Framework\Exception\StateException +use Magento\Framework\Exception\StateException; + +class InputMismatchException extends StateException { } diff --git a/lib/internal/Magento/Framework/Exception/State/InvalidTransitionException.php b/lib/internal/Magento/Framework/Exception/State/InvalidTransitionException.php index c3876f232479523eb7eb455578edbb8b4be317be..b02101bcec0be816b19afb4795836437faba6622 100644 --- a/lib/internal/Magento/Framework/Exception/State/InvalidTransitionException.php +++ b/lib/internal/Magento/Framework/Exception/State/InvalidTransitionException.php @@ -7,6 +7,8 @@ */ namespace Magento\Framework\Exception\State; -class InvalidTransitionException extends \Magento\Framework\Exception\StateException +use Magento\Framework\Exception\StateException; + +class InvalidTransitionException extends StateException { } diff --git a/lib/internal/Magento/Framework/Exception/StateException.php b/lib/internal/Magento/Framework/Exception/StateException.php index 48b2d32b647c4a7898aa8e5d273c2be6c4c58003..7222cc9feda67d04caba4556e35395b6bd81bd72 100644 --- a/lib/internal/Magento/Framework/Exception/StateException.php +++ b/lib/internal/Magento/Framework/Exception/StateException.php @@ -3,7 +3,6 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ - namespace Magento\Framework\Exception; /** diff --git a/lib/internal/Magento/Framework/Exception/Test/Unit/AuthenticationExceptionTest.php b/lib/internal/Magento/Framework/Exception/Test/Unit/AuthenticationExceptionTest.php index a6f50ea328c78f8c0cdf8a333021eebddd967ccb..50a32d2256421c87e3c85364c60c5fc49052e892 100644 --- a/lib/internal/Magento/Framework/Exception/Test/Unit/AuthenticationExceptionTest.php +++ b/lib/internal/Magento/Framework/Exception/Test/Unit/AuthenticationExceptionTest.php @@ -7,6 +7,7 @@ namespace Magento\Framework\Exception\Test\Unit; use \Magento\Framework\Exception\AuthenticationException; +use Magento\Framework\Phrase; /** * Class AuthenticationExceptionTest @@ -15,11 +16,16 @@ use \Magento\Framework\Exception\AuthenticationException; */ class AuthenticationExceptionTest extends \PHPUnit_Framework_TestCase { + /** + * @return void + */ public function testConstructor() { $authenticationException = new AuthenticationException( - AuthenticationException::AUTHENTICATION_ERROR, - ['consumer_id' => 1, 'resources' => 'record2'] + new Phrase( + AuthenticationException::AUTHENTICATION_ERROR, + ['consumer_id' => 1, 'resources' => 'record2'] + ) ); $this->assertSame('An authentication error occurred.', $authenticationException->getMessage()); } diff --git a/lib/internal/Magento/Framework/Exception/Test/Unit/AuthorizationExceptionTest.php b/lib/internal/Magento/Framework/Exception/Test/Unit/AuthorizationExceptionTest.php index b54509cf47ea5727cee89cda70abd09ca902362c..98ec16f5d181b630600a72aa5747f7bca59ea81f 100644 --- a/lib/internal/Magento/Framework/Exception/Test/Unit/AuthorizationExceptionTest.php +++ b/lib/internal/Magento/Framework/Exception/Test/Unit/AuthorizationExceptionTest.php @@ -6,14 +6,20 @@ namespace Magento\Framework\Exception\Test\Unit; use \Magento\Framework\Exception\AuthorizationException; +use Magento\Framework\Phrase; class AuthorizationExceptionTest extends \PHPUnit_Framework_TestCase { + /** + * @return void + */ public function testConstructor() { $authorizationException = new AuthorizationException( - AuthorizationException::NOT_AUTHORIZED, - ['consumer_id' => 1, 'resources' => 'record2'] + new Phrase( + AuthorizationException::NOT_AUTHORIZED, + ['consumer_id' => 1, 'resources' => 'record2'] + ) ); $this->assertSame('Consumer is not authorized to access record2', $authorizationException->getMessage()); } diff --git a/lib/internal/Magento/Framework/Exception/Test/Unit/EmailNotConfirmedExceptionTest.php b/lib/internal/Magento/Framework/Exception/Test/Unit/EmailNotConfirmedExceptionTest.php index 4fc4b41432569daabbf4c16893b1e67dea29879e..17abc99ed6aa9546d584dfc68dfbfc49291dfba8 100644 --- a/lib/internal/Magento/Framework/Exception/Test/Unit/EmailNotConfirmedExceptionTest.php +++ b/lib/internal/Magento/Framework/Exception/Test/Unit/EmailNotConfirmedExceptionTest.php @@ -7,6 +7,7 @@ namespace Magento\Framework\Exception\Test\Unit; use \Magento\Framework\Exception\EmailNotConfirmedException; +use Magento\Framework\Phrase; /** * Class EmailNotConfirmedExceptionTest @@ -15,11 +16,16 @@ use \Magento\Framework\Exception\EmailNotConfirmedException; */ class EmailNotConfirmedExceptionTest extends \PHPUnit_Framework_TestCase { + /** + * @return void + */ public function testConstructor() { $emailNotConfirmedException = new EmailNotConfirmedException( - EmailNotConfirmedException::EMAIL_NOT_CONFIRMED, - ['consumer_id' => 1, 'resources' => 'record2'] + new Phrase( + EmailNotConfirmedException::EMAIL_NOT_CONFIRMED, + ['consumer_id' => 1, 'resources' => 'record2'] + ) ); $this->assertSame('Email not confirmed', $emailNotConfirmedException->getMessage()); } diff --git a/lib/internal/Magento/Framework/Exception/Test/Unit/ErrorMessageTest.php b/lib/internal/Magento/Framework/Exception/Test/Unit/ErrorMessageTest.php deleted file mode 100644 index afa046ab8be906a8186a5669535766f977e4f40d..0000000000000000000000000000000000000000 --- a/lib/internal/Magento/Framework/Exception/Test/Unit/ErrorMessageTest.php +++ /dev/null @@ -1,96 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Framework\Exception\Test\Unit; - -use \Magento\Framework\Exception\ErrorMessage; - -class ErrorMessageTest extends \PHPUnit_Framework_TestCase -{ - /** - * The default Phrase renderer. - * - * @var \Magento\Framework\Phrase\RendererInterface - */ - private $defaultRenderer; - - /** - * The message that has been rendered by the current Phrase renderer. - * - * @var string - */ - private $renderedMessage; - - /** - * Initialization that runs before each new test. - * - * @return void - */ - public function setUp() - { - $this->defaultRenderer = \Magento\Framework\Phrase::getRenderer(); - $rendererMock = $this->getMock('Magento\Framework\Phrase\Renderer\Placeholder', [], [], '', false); - $this->renderedMessage = 'rendered message'; - $rendererMock - ->expects($this->once())->method('render')->will($this->returnValue($this->renderedMessage)); - \Magento\Framework\Phrase::setRenderer($rendererMock); - } - - /** - * Restoration after each test runs. Reset the Phrase renderer back to the default one. - * - * @return void - */ - public function tearDown() - { - \Magento\Framework\Phrase::setRenderer($this->defaultRenderer); - } - - /** - * Verify that the constructor works properly and check all associated error message types. - * - * @param string $message The error message - * @param array $params The array of substitution parameters - * @param string $expectedLogMessage The expected output of ErrorMessage::getLogMessage() - * - * @return void - * @dataProvider errorMessageConstructorDataProvider - */ - public function testConstructor($message, $params, $expectedLogMessage) - { - $errorMessage = new ErrorMessage($message, $params); - - $this->assertEquals($this->renderedMessage, $errorMessage->getMessage()); - $this->assertEquals($message, $errorMessage->getRawMessage()); - $this->assertEquals($expectedLogMessage, $errorMessage->getLogMessage()); - $this->assertEquals($params, $errorMessage->getParameters()); - } - - /** - * Data provider for the constructor test. - * - * @return array - */ - public function errorMessageConstructorDataProvider() - { - return [ - 'withPositionalParameters' => [ - 'message %1 %2', - ['parameter1', 'parameter2'], - 'message parameter1 parameter2', - ], - 'withNamedParameters' => [ - 'message %key1 %key2', - ['key1' => 'parameter1', 'key2' => 'parameter2'], - 'message parameter1 parameter2', - ], - 'withNoParameters' => [ - 'message', - [], - 'message', - ] - ]; - } -} diff --git a/lib/internal/Magento/Framework/Exception/Test/Unit/InputExceptionTest.php b/lib/internal/Magento/Framework/Exception/Test/Unit/InputExceptionTest.php index 6e3d4afa93364b959b981433ed0f5ecf12662c43..f5fee1708a6b0dc2a7063df03faae3d9eac4c8d0 100644 --- a/lib/internal/Magento/Framework/Exception/Test/Unit/InputExceptionTest.php +++ b/lib/internal/Magento/Framework/Exception/Test/Unit/InputExceptionTest.php @@ -6,10 +6,8 @@ namespace Magento\Framework\Exception\Test\Unit; use \Magento\Framework\Exception\InputException; +use Magento\Framework\Phrase; -/** - * @covers \Magento\Framework\Exception\InputException - */ class InputExceptionTest extends \PHPUnit_Framework_TestCase { /** @@ -21,7 +19,9 @@ class InputExceptionTest extends \PHPUnit_Framework_TestCase public function testConstructor() { $params = ['fieldName' => 'quantity', 'value' => -100, 'minValue' => 0]; - $inputException = new InputException(InputException::INVALID_FIELD_MIN_VALUE, $params); + $inputException = new InputException( + new Phrase(InputException::INVALID_FIELD_MIN_VALUE, $params) + ); $this->assertEquals(InputException::INVALID_FIELD_MIN_VALUE, $inputException->getRawMessage()); $this->assertStringMatchesFormat('%s greater than or equal to %s', $inputException->getMessage()); @@ -51,8 +51,10 @@ class InputExceptionTest extends \PHPUnit_Framework_TestCase $this->assertCount(0, $inputException->getErrors()); $inputException->addError( - InputException::INVALID_FIELD_MIN_VALUE, - ['fieldName' => 'weight', 'value' => -100, 'minValue' => 1] + new Phrase( + InputException::INVALID_FIELD_MIN_VALUE, + ['fieldName' => 'weight', 'value' => -100, 'minValue' => 1] + ) ); $this->assertTrue($inputException->wasErrorAdded()); $this->assertCount(0, $inputException->getErrors()); @@ -67,7 +69,7 @@ class InputExceptionTest extends \PHPUnit_Framework_TestCase $inputException->getLogMessage() ); - $inputException->addError(InputException::REQUIRED_FIELD, ['fieldName' => 'name']); + $inputException->addError(new Phrase(InputException::REQUIRED_FIELD, ['fieldName' => 'name'])); $this->assertTrue($inputException->wasErrorAdded()); $this->assertCount(2, $inputException->getErrors()); @@ -106,20 +108,20 @@ class InputExceptionTest extends \PHPUnit_Framework_TestCase $rawMessage = 'Foo "%var"'; $params = ['var' => 'Bar']; $expectedProcessedMessage = 'Foo "Bar"'; - $inputException = new InputException($rawMessage, $params); + $inputException = new InputException(new Phrase($rawMessage, $params)); $this->assertEquals($rawMessage, $inputException->getRawMessage()); $this->assertEquals($expectedProcessedMessage, $inputException->getMessage()); $this->assertEquals($expectedProcessedMessage, $inputException->getLogMessage()); $this->assertFalse($inputException->wasErrorAdded()); $this->assertCount(0, $inputException->getErrors()); - $inputException->addError($rawMessage, $params); + $inputException->addError(new Phrase($rawMessage, $params)); $this->assertEquals($expectedProcessedMessage, $inputException->getMessage()); $this->assertEquals($expectedProcessedMessage, $inputException->getLogMessage()); $this->assertTrue($inputException->wasErrorAdded()); $this->assertCount(0, $inputException->getErrors()); - $inputException->addError($rawMessage, $params); + $inputException->addError(new Phrase($rawMessage, $params)); $this->assertEquals($expectedProcessedMessage, $inputException->getMessage()); $this->assertEquals($expectedProcessedMessage, $inputException->getLogMessage()); $this->assertTrue($inputException->wasErrorAdded()); diff --git a/lib/internal/Magento/Framework/Exception/Test/Unit/InvalidEmailOrPasswordExceptionTest.php b/lib/internal/Magento/Framework/Exception/Test/Unit/InvalidEmailOrPasswordExceptionTest.php index 8409ff81b3af6711fe0bd99114f5628f1c810b5d..34fe6d00011400a4b5bf77dc0ab5ff7d39937fe3 100644 --- a/lib/internal/Magento/Framework/Exception/Test/Unit/InvalidEmailOrPasswordExceptionTest.php +++ b/lib/internal/Magento/Framework/Exception/Test/Unit/InvalidEmailOrPasswordExceptionTest.php @@ -7,6 +7,7 @@ namespace Magento\Framework\Exception\Test\Unit; use \Magento\Framework\Exception\InvalidEmailOrPasswordException; +use Magento\Framework\Phrase; /** * Class InvalidEmailOrPasswordExceptionTest @@ -15,11 +16,16 @@ use \Magento\Framework\Exception\InvalidEmailOrPasswordException; */ class InvalidEmailOrPasswordExceptionTest extends \PHPUnit_Framework_TestCase { + /** + * @return void + */ public function testConstructor() { $exception = new InvalidEmailOrPasswordException( - InvalidEmailOrPasswordException::INVALID_EMAIL_OR_PASSWORD, - ['consumer_id' => 1, 'resources' => 'record2'] + new Phrase( + InvalidEmailOrPasswordException::INVALID_EMAIL_OR_PASSWORD, + ['consumer_id' => 1, 'resources' => 'record2'] + ) ); $this->assertSame('Invalid email or password', $exception->getMessage()); } diff --git a/lib/internal/Magento/Framework/Exception/Test/Unit/LocalizedExceptionTest.php b/lib/internal/Magento/Framework/Exception/Test/Unit/LocalizedExceptionTest.php index 8630e4d469ccfc473848a075758a8b7ddba18244..a359192c6bbaa0c8cf907e0d450cd8e82c193e9d 100644 --- a/lib/internal/Magento/Framework/Exception/Test/Unit/LocalizedExceptionTest.php +++ b/lib/internal/Magento/Framework/Exception/Test/Unit/LocalizedExceptionTest.php @@ -6,6 +6,7 @@ namespace Magento\Framework\Exception\Test\Unit; use \Magento\Framework\Exception\LocalizedException; +use Magento\Framework\Phrase; /** * Class LocalizedExceptionTest @@ -20,6 +21,9 @@ class LocalizedExceptionTest extends \PHPUnit_Framework_TestCase /** @var string */ private $renderedMessage; + /** + * @return void + */ public function setUp() { $this->defaultRenderer = \Magento\Framework\Phrase::getRenderer(); @@ -33,18 +37,26 @@ class LocalizedExceptionTest extends \PHPUnit_Framework_TestCase \Magento\Framework\Phrase::setRenderer($rendererMock); } + /** + * @return void + */ public function tearDown() { \Magento\Framework\Phrase::setRenderer($this->defaultRenderer); } - /** @dataProvider constructorParametersDataProvider */ + /** + * @param string $message + * @param array $params + * @param string $expectedLogMessage + * @return void + * @dataProvider constructorParametersDataProvider + */ public function testConstructor($message, $params, $expectedLogMessage) { $cause = new \Exception(); $localizeException = new LocalizedException( - $message, - $params, + new Phrase($message, $params), $cause ); @@ -57,6 +69,9 @@ class LocalizedExceptionTest extends \PHPUnit_Framework_TestCase $this->assertSame($cause, $localizeException->getPrevious()); } + /** + * @return array + */ public function constructorParametersDataProvider() { return [ @@ -81,6 +96,9 @@ class LocalizedExceptionTest extends \PHPUnit_Framework_TestCase ]; } + /** + * @return void + */ public function testGetRawMessage() { $message = 'message %1 %2'; @@ -90,13 +108,15 @@ class LocalizedExceptionTest extends \PHPUnit_Framework_TestCase ]; $cause = new \Exception(); $localizeException = new LocalizedException( - $message, - $params, + new Phrase($message, $params), $cause ); $this->assertEquals($message, $localizeException->getRawMessage()); } + /** + * @return void + */ public function testGetParameters() { $message = 'message %1 %2'; @@ -106,14 +126,16 @@ class LocalizedExceptionTest extends \PHPUnit_Framework_TestCase ]; $cause = new \Exception(); $localizeException = new LocalizedException( - $message, - $params, + new Phrase($message, $params), $cause ); $this->assertEquals($params, $localizeException->getParameters()); } + /** + * @return void + */ public function testGetLogMessage() { $message = 'message %1 %2'; @@ -124,8 +146,7 @@ class LocalizedExceptionTest extends \PHPUnit_Framework_TestCase $cause = new \Exception(); $localizeException = new LocalizedException( - $message, - $params, + new Phrase($message, $params), $cause ); $expectedLogMessage = 'message parameter1 parameter2'; diff --git a/lib/internal/Magento/Framework/Exception/Test/Unit/NoSuchEntityExceptionTest.php b/lib/internal/Magento/Framework/Exception/Test/Unit/NoSuchEntityExceptionTest.php index 9df3ef2152995a6739985a120fbc4fb3fccae472..459c8dc7686ddd8c20a7f456a62d1ee3dd156af0 100644 --- a/lib/internal/Magento/Framework/Exception/Test/Unit/NoSuchEntityExceptionTest.php +++ b/lib/internal/Magento/Framework/Exception/Test/Unit/NoSuchEntityExceptionTest.php @@ -6,6 +6,7 @@ namespace Magento\Framework\Exception\Test\Unit; use \Magento\Framework\Exception\NoSuchEntityException; +use Magento\Framework\Phrase; /** * Class NoSuchEntityExceptionTest @@ -25,6 +26,9 @@ class NoSuchEntityExceptionTest extends \PHPUnit_Framework_TestCase */ protected $rendererMock; + /** + * @return void + */ public function setUp() { $this->defaultRenderer = \Magento\Framework\Phrase::getRenderer(); @@ -34,11 +38,17 @@ class NoSuchEntityExceptionTest extends \PHPUnit_Framework_TestCase ->getMock(); } + /** + * @return void + */ public function tearDown() { \Magento\Framework\Phrase::setRenderer($this->defaultRenderer); } + /** + * @return void + */ public function testConstructor() { $this->renderedMessage = 'rendered message'; @@ -54,8 +64,7 @@ class NoSuchEntityExceptionTest extends \PHPUnit_Framework_TestCase $expectedLogMessage = 'message parameter1 parameter2'; $cause = new \Exception(); $localizeException = new NoSuchEntityException( - $message, - $params, + new Phrase($message, $params), $cause ); @@ -69,8 +78,9 @@ class NoSuchEntityExceptionTest extends \PHPUnit_Framework_TestCase } /** - * @param $message - * @param $expectedMessage + * @param string $message + * @param string $expectedMessage + * @return void * @dataProvider constantsDataProvider */ public function testConstants($message, $expectedMessage) @@ -82,12 +92,17 @@ class NoSuchEntityExceptionTest extends \PHPUnit_Framework_TestCase \Magento\Framework\Phrase::setRenderer($this->rendererMock); $exception = new NoSuchEntityException( - $message, - ['consumer_id' => 1, 'resources' => 'record2'] + new Phrase( + $message, + ['consumer_id' => 1, 'resources' => 'record2'] + ) ); $this->assertSame($expectedMessage, $exception->getMessage()); } + /** + * @return array + */ public function constantsDataProvider() { return [ @@ -102,6 +117,9 @@ class NoSuchEntityExceptionTest extends \PHPUnit_Framework_TestCase ]; } + /** + * @return void + */ public function testSingleField() { $fieldName = 'storeId'; @@ -112,6 +130,9 @@ class NoSuchEntityExceptionTest extends \PHPUnit_Framework_TestCase ); } + /** + * @return void + */ public function testDoubleField() { $website = 'website'; diff --git a/lib/internal/Magento/Framework/Exception/Test/Unit/State/ExpiredExceptionTest.php b/lib/internal/Magento/Framework/Exception/Test/Unit/State/ExpiredExceptionTest.php index c8392c6c449af1255d842582d731065fe76e0929..dff9552038031074aed2be3d231276f9070b0274 100644 --- a/lib/internal/Magento/Framework/Exception/Test/Unit/State/ExpiredExceptionTest.php +++ b/lib/internal/Magento/Framework/Exception/Test/Unit/State/ExpiredExceptionTest.php @@ -8,6 +8,7 @@ namespace Magento\Framework\Exception\Test\Unit\State; use \Magento\Framework\Exception\State\ExpiredException; +use Magento\Framework\Phrase; /** * Class ExpiredException @@ -16,6 +17,9 @@ use \Magento\Framework\Exception\State\ExpiredException; */ class ExpiredExceptionTest extends \PHPUnit_Framework_TestCase { + /** + * @return void + */ public function testConstructor() { $instanceClass = 'Magento\Framework\Exception\State\ExpiredException'; @@ -25,7 +29,7 @@ class ExpiredExceptionTest extends \PHPUnit_Framework_TestCase 'parameter2', ]; $cause = new \Exception(); - $stateException = new ExpiredException($message, $params, $cause); + $stateException = new ExpiredException(new Phrase($message, $params), $cause); $this->assertInstanceOf($instanceClass, $stateException); } } diff --git a/lib/internal/Magento/Framework/Exception/Test/Unit/State/InputMismatchExceptionTest.php b/lib/internal/Magento/Framework/Exception/Test/Unit/State/InputMismatchExceptionTest.php index 6d163e966c3cfa9c2793752ac0660e9654dfc62c..b961329ebf424d54d8f54807cb0333d842095cff 100644 --- a/lib/internal/Magento/Framework/Exception/Test/Unit/State/InputMismatchExceptionTest.php +++ b/lib/internal/Magento/Framework/Exception/Test/Unit/State/InputMismatchExceptionTest.php @@ -8,9 +8,13 @@ namespace Magento\Framework\Exception\Test\Unit\State; use \Magento\Framework\Exception\State\InputMismatchException; +use Magento\Framework\Phrase; class InputMismatchExceptionTest extends \PHPUnit_Framework_TestCase { + /** + * @return void + */ public function testConstructor() { $instanceClass = 'Magento\Framework\Exception\State\InputMismatchException'; @@ -20,7 +24,7 @@ class InputMismatchExceptionTest extends \PHPUnit_Framework_TestCase 'parameter2', ]; $cause = new \Exception(); - $stateException = new InputMismatchException($message, $params, $cause); + $stateException = new InputMismatchException(new Phrase($message, $params), $cause); $this->assertInstanceOf($instanceClass, $stateException); } } diff --git a/lib/internal/Magento/Framework/Exception/Test/Unit/State/InvalidTransitionExceptionTest.php b/lib/internal/Magento/Framework/Exception/Test/Unit/State/InvalidTransitionExceptionTest.php index abb0d21697a207b21ac7e5e9cd29999c5b3a8e0c..8f1d1bea9a67af3f266c42347e8c4c6d699e4dbb 100644 --- a/lib/internal/Magento/Framework/Exception/Test/Unit/State/InvalidTransitionExceptionTest.php +++ b/lib/internal/Magento/Framework/Exception/Test/Unit/State/InvalidTransitionExceptionTest.php @@ -8,9 +8,13 @@ namespace Magento\Framework\Exception\Test\Unit\State; use \Magento\Framework\Exception\State\InvalidTransitionException; +use Magento\Framework\Phrase; class InvalidTransitionExceptionTest extends \PHPUnit_Framework_TestCase { + /** + * @return void + */ public function testConstructor() { $instanceClass = 'Magento\Framework\Exception\State\InvalidTransitionException'; @@ -20,7 +24,7 @@ class InvalidTransitionExceptionTest extends \PHPUnit_Framework_TestCase 'parameter2', ]; $cause = new \Exception(); - $stateException = new InvalidTransitionException($message, $params, $cause); + $stateException = new InvalidTransitionException(new Phrase($message, $params), $cause); $this->assertInstanceOf($instanceClass, $stateException); } } diff --git a/lib/internal/Magento/Framework/Exception/Test/Unit/StateExceptionTest.php b/lib/internal/Magento/Framework/Exception/Test/Unit/StateExceptionTest.php index ae719a1f075cb7b4a9e4976af2409a841e20e513..463b039fef0e8eb7342a4c1bb2d9c338c66c5bd0 100644 --- a/lib/internal/Magento/Framework/Exception/Test/Unit/StateExceptionTest.php +++ b/lib/internal/Magento/Framework/Exception/Test/Unit/StateExceptionTest.php @@ -7,6 +7,7 @@ namespace Magento\Framework\Exception\Test\Unit; use \Magento\Framework\Exception\StateException; +use Magento\Framework\Phrase; /** * Class StateExceptionTest @@ -15,6 +16,9 @@ use \Magento\Framework\Exception\StateException; */ class StateExceptionTest extends \PHPUnit_Framework_TestCase { + /** + * @return void + */ public function testStateExceptionInstance() { $instanceClass = 'Magento\Framework\Exception\StateException'; @@ -24,7 +28,7 @@ class StateExceptionTest extends \PHPUnit_Framework_TestCase 'parameter2', ]; $cause = new \Exception(); - $stateException = new StateException($message, $params, $cause); + $stateException = new StateException(new Phrase($message, $params), $cause); $this->assertInstanceOf($instanceClass, $stateException); } } diff --git a/lib/internal/Magento/Framework/Filesystem/Io/File.php b/lib/internal/Magento/Framework/Filesystem/Io/File.php index bda846e3ce5e310614266bdb7271050a259c173d..947409e10c185e4c50d22cfeb99bff839ee142b5 100644 --- a/lib/internal/Magento/Framework/Filesystem/Io/File.php +++ b/lib/internal/Magento/Framework/Filesystem/Io/File.php @@ -88,39 +88,6 @@ class File extends AbstractIo } } - /** - * Open file in stream mode - * For set folder for file use open method - * - * @param string $fileName - * @param string $mode - * @param int $chmod - * @return true - * @throws \Exception - */ - public function streamOpen($fileName, $mode = 'w+', $chmod = 0666) - { - $writeableMode = preg_match('#^[wax]#i', $mode); - if ($writeableMode && !is_writeable($this->_cwd)) { - throw new \Exception('Permission denied for write to ' . $this->_cwd); - } - - if (!ini_get('auto_detect_line_endings')) { - ini_set('auto_detect_line_endings', 1); - } - - $this->_cwd(); - $this->_streamHandler = @fopen($fileName, $mode); - $this->_iwd(); - if ($this->_streamHandler === false) { - throw new \Exception('Error write to file ' . $fileName); - } - - $this->_streamFileName = $fileName; - $this->_streamChmod = $chmod; - return true; - } - /** * Lock file * diff --git a/lib/internal/Magento/Framework/Flag/Resource.php b/lib/internal/Magento/Framework/Flag/Resource.php index 1f8014ba0acb97520faaa154bc7aee198cf6f6a3..c1f4a1079841be17b74d6b85aa99d0001bea2436 100644 --- a/lib/internal/Magento/Framework/Flag/Resource.php +++ b/lib/internal/Magento/Framework/Flag/Resource.php @@ -17,6 +17,6 @@ class Resource extends \Magento\Framework\Model\Resource\Db\AbstractDb */ protected function _construct() { - $this->_init('core_flag', 'flag_id'); + $this->_init('flag', 'flag_id'); } } diff --git a/lib/internal/Magento/Framework/Image/Adapter/ImageMagick.php b/lib/internal/Magento/Framework/Image/Adapter/ImageMagick.php index 1d3b133279ae43d9439bc1fa521854c926f66e3c..25fcd6ac2f4f51f4bba579aeb064a6d6368824bb 100644 --- a/lib/internal/Magento/Framework/Image/Adapter/ImageMagick.php +++ b/lib/internal/Magento/Framework/Image/Adapter/ImageMagick.php @@ -130,7 +130,7 @@ class ImageMagick extends \Magento\Framework\Image\Adapter\AbstractAdapter public function getImage() { $this->_applyOptions(); - return (string)$this->_imageHandler; + return $this->_imageHandler->getImageBlob(); } /** @@ -316,7 +316,7 @@ class ImageMagick extends \Magento\Framework\Image\Adapter\AbstractAdapter } // merge layers - $this->_imageHandler->flattenImages(); + $this->_imageHandler->mergeImageLayers(\Imagick::LAYERMETHOD_FLATTEN); $watermark->clear(); $watermark->destroy(); } diff --git a/lib/internal/Magento/Framework/Interception/Code/Generator/Interceptor.php b/lib/internal/Magento/Framework/Interception/Code/Generator/Interceptor.php index 43e9e4d47ac6a26b2b1f150b25b544962d9d8f43..d50721d4e52a1df5db315c72ab853b20dec58472 100644 --- a/lib/internal/Magento/Framework/Interception/Code/Generator/Interceptor.php +++ b/lib/internal/Magento/Framework/Interception/Code/Generator/Interceptor.php @@ -83,7 +83,7 @@ class Interceptor extends \Magento\Framework\Code\Generator\EntityAbstract */ protected function _getDefaultConstructorDefinition() { - $reflectionClass = new \ReflectionClass($this->_getSourceClassName()); + $reflectionClass = new \ReflectionClass($this->getSourceClassName()); $constructor = $reflectionClass->getConstructor(); $parameters = []; if ($constructor) { @@ -196,7 +196,7 @@ class Interceptor extends \Magento\Framework\Code\Generator\EntityAbstract "return \$result;\n", ]; - $reflectionClass = new \ReflectionClass($this->_getSourceClassName()); + $reflectionClass = new \ReflectionClass($this->getSourceClassName()); $publicMethods = $reflectionClass->getMethods(\ReflectionMethod::IS_PUBLIC); foreach ($publicMethods as $method) { if ($this->isInterceptedMethod($method)) { @@ -278,7 +278,7 @@ class Interceptor extends \Magento\Framework\Code\Generator\EntityAbstract */ protected function _generateCode() { - $typeName = $this->_getSourceClassName(); + $typeName = $this->getSourceClassName(); $reflection = new \ReflectionClass($typeName); if ($reflection->isInterface()) { @@ -297,7 +297,7 @@ class Interceptor extends \Magento\Framework\Code\Generator\EntityAbstract $result = parent::_validateData(); if ($result) { - $sourceClassName = $this->_getSourceClassName(); + $sourceClassName = $this->getSourceClassName(); $resultClassName = $this->_getResultClassName(); if ($resultClassName !== $sourceClassName . '\\Interceptor') { diff --git a/lib/internal/Magento/Framework/Interception/Test/Unit/Config/ConfigTest.php b/lib/internal/Magento/Framework/Interception/Test/Unit/Config/ConfigTest.php index f35ef42d6dc435af0b689f597276d22e4cdf9962..6c12758905634c325153a2b588ee72d08c5ad108 100644 --- a/lib/internal/Magento/Framework/Interception/Test/Unit/Config/ConfigTest.php +++ b/lib/internal/Magento/Framework/Interception/Test/Unit/Config/ConfigTest.php @@ -3,6 +3,7 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ +// @codingStandardsIgnoreFile namespace Magento\Framework\Interception\Test\Unit\Config; require_once __DIR__ . '/../Custom/Module/Model/Item.php'; @@ -40,6 +41,11 @@ class ConfigTest extends \PHPUnit_Framework_TestCase */ protected $definitionMock; + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $relationsMock; + protected function setUp() { $this->readerMock = $this->getMock( @@ -55,6 +61,7 @@ class ConfigTest extends \PHPUnit_Framework_TestCase 'Magento\Framework\Interception\ObjectManager\ConfigInterface' ); $this->definitionMock = $this->getMock('Magento\Framework\ObjectManager\DefinitionInterface'); + $this->relationsMock = $this->getMockForAbstractClass('Magento\Framework\ObjectManager\RelationsInterface'); } /** @@ -62,7 +69,7 @@ class ConfigTest extends \PHPUnit_Framework_TestCase * @param string $type * @dataProvider hasPluginsDataProvider */ - public function testHasPluginsWhenDataIsNotCached($expectedResult, $type) + public function testHasPluginsWhenDataIsNotCached($expectedResult, $type, $entityParents) { $readerMap = include __DIR__ . '/../_files/reader_mock_map.php'; $this->readerMock->expects($this->any()) @@ -112,14 +119,17 @@ class ConfigTest extends \PHPUnit_Framework_TestCase $this->definitionMock->expects($this->any())->method('getClasses')->will($this->returnValue( [ 'Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemProxy', - '\Magento\Framework\Interception\Custom\Module\Model\Backslash\ItemProxy', + 'Magento\Framework\Interception\Custom\Module\Model\Backslash\ItemProxy', ] )); + $this->relationsMock->expects($this->any())->method('has')->will($this->returnValue($expectedResult)); + $this->relationsMock->expects($this->any())->method('getParents')->will($this->returnValue($entityParents)); + $model = new \Magento\Framework\Interception\Config\Config( $this->readerMock, $this->configScopeMock, $this->cacheMock, - new \Magento\Framework\ObjectManager\Relations\Runtime(), + $this->relationsMock, $this->omConfigMock, $this->definitionMock, 'interception' @@ -170,27 +180,33 @@ class ConfigTest extends \PHPUnit_Framework_TestCase [ true, 'Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemContainer', + [], ], [ true, 'Magento\Framework\Interception\Test\Unit\Custom\Module\Model\Item', + [], ], [ true, 'Magento\Framework\Interception\Test\Unit\Custom\Module\Model\Item\Enhanced', + [], ], [ // the following model has only inherited plugins true, 'Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemContainer\Enhanced', + ['Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemContainer'], ], [ false, 'Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemProxy', + [], ], [ true, 'virtual_custom_item', + [], ] ]; } diff --git a/lib/internal/Magento/Framework/Model/AbstractExtensibleModel.php b/lib/internal/Magento/Framework/Model/AbstractExtensibleModel.php index d69723ea8c5cef32357ea7e8766c24a69cf3bbb3..e5a84c89fa4ef60da3c42df09584990a53a1cced 100644 --- a/lib/internal/Magento/Framework/Model/AbstractExtensibleModel.php +++ b/lib/internal/Magento/Framework/Model/AbstractExtensibleModel.php @@ -6,11 +6,7 @@ namespace Magento\Framework\Model; -use Magento\Framework\Api\ExtensibleDataInterface; -use Magento\Framework\Api\MetadataServiceInterface; -use Magento\Framework\Api\AttributeValue; use Magento\Framework\Api\AttributeValueFactory; -use Symfony\Component\DependencyInjection\Exception\LogicException; /** * Abstract model with custom attributes support. @@ -19,12 +15,18 @@ use Symfony\Component\DependencyInjection\Exception\LogicException; * Implementations may choose to process custom attributes as their persistence requires them to. * @SuppressWarnings(PHPMD.NumberOfChildren) */ -abstract class AbstractExtensibleModel extends AbstractModel implements ExtensibleDataInterface +abstract class AbstractExtensibleModel extends AbstractModel implements + \Magento\Framework\Api\CustomAttributesDataInterface { /** - * @var MetadataServiceInterface + * @var \Magento\Framework\Api\ExtensionAttributesFactory */ - protected $metadataService; + protected $extensionAttributesFactory; + + /** + * @var \Magento\Framework\Api\ExtensionAttributesInterface + */ + protected $extensionAttributes; /** * @var AttributeValueFactory @@ -39,7 +41,7 @@ abstract class AbstractExtensibleModel extends AbstractModel implements Extensib /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry - * @param MetadataServiceInterface $metadataService + * @param \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory * @param AttributeValueFactory $customAttributeFactory * @param \Magento\Framework\Model\Resource\AbstractResource $resource * @param \Magento\Framework\Data\Collection\Db $resourceCollection @@ -48,13 +50,13 @@ abstract class AbstractExtensibleModel extends AbstractModel implements Extensib public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, - MetadataServiceInterface $metadataService, + \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory, AttributeValueFactory $customAttributeFactory, \Magento\Framework\Model\Resource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\Db $resourceCollection = null, array $data = [] ) { - $this->metadataService = $metadataService; + $this->extensionAttributesFactory = $extensionFactory; $this->customAttributeFactory = $customAttributeFactory; $data = $this->filterCustomAttributes($data); parent::__construct($context, $registry, $resource, $resourceCollection, $data); @@ -77,7 +79,7 @@ abstract class AbstractExtensibleModel extends AbstractModel implements Extensib $customAttributesCodes = $this->getCustomAttributesCodes(); $data[self::CUSTOM_ATTRIBUTES] = array_intersect_key( (array)$data[self::CUSTOM_ATTRIBUTES], - $customAttributesCodes + array_flip($customAttributesCodes) ); foreach ($data[self::CUSTOM_ATTRIBUTES] as $code => $value) { if (!($value instanceof \Magento\Framework\Api\AttributeInterface)) { @@ -148,11 +150,12 @@ abstract class AbstractExtensibleModel extends AbstractModel implements Extensib { if (is_array($key)) { $key = $this->filterCustomAttributes($key); - } elseif ($key == self::CUSTOM_ATTRIBUTES) { + } else if ($key == self::CUSTOM_ATTRIBUTES) { $filteredData = $this->filterCustomAttributes([self::CUSTOM_ATTRIBUTES => $value]); $value = $filteredData[self::CUSTOM_ATTRIBUTES]; } - return parent::setData($key, $value); + parent::setData($key, $value); + return $this; } /** @@ -168,7 +171,7 @@ abstract class AbstractExtensibleModel extends AbstractModel implements Extensib * * In addition to parent implementation custom attributes support is added. * - * @param string $key + * @param string $key * @param string|int $index * @return mixed */ @@ -194,26 +197,35 @@ abstract class AbstractExtensibleModel extends AbstractModel implements Extensib } /** - * Fetch all custom attributes for the given extensible model - * //TODO : check if the custom attribute is already defined as a getter on the data interface + * Get a list of custom attribute codes. + * + * By default, entity can be extended only using extension attributes functionality. * * @return string[] */ protected function getCustomAttributesCodes() { - if (!is_null($this->customAttributesCodes)) { - return $this->customAttributesCodes; - } + return []; + } + + /** + * Receive a list of EAV attributes using provided metadata service. + * + * Can be used in child classes, which represent EAV entities. + * + * @param \Magento\Framework\Api\MetadataServiceInterface $metadataService + * @return string[] + */ + protected function getEavAttributesCodes(\Magento\Framework\Api\MetadataServiceInterface $metadataService) + { $attributeCodes = []; - $customAttributesMetadata = $this->metadataService->getCustomAttributesMetadata(get_class($this)); + $customAttributesMetadata = $metadataService->getCustomAttributesMetadata(get_class($this)); if (is_array($customAttributesMetadata)) { /** @var $attribute \Magento\Framework\Api\MetadataObjectInterface */ foreach ($customAttributesMetadata as $attribute) { - // Create a map for easier processing - $attributeCodes[$attribute->getAttributeCode()] = $attribute->getAttributeCode(); + $attributeCodes[] = $attribute->getAttributeCode(); } } - $this->customAttributesCodes = $attributeCodes; return $attributeCodes; } @@ -228,4 +240,26 @@ abstract class AbstractExtensibleModel extends AbstractModel implements Extensib parent::setId($value); return $this->setData('id', $value); } + + /** + * Set an extension attributes object. + * + * @param \Magento\Framework\Api\ExtensionAttributesInterface $extensionAttributes + * @return $this + */ + protected function _setExtensionAttributes(\Magento\Framework\Api\ExtensionAttributesInterface $extensionAttributes) + { + $this->_data[self::EXTENSION_ATTRIBUTES_KEY] = $extensionAttributes; + return $this; + } + + /** + * Retrieve existing extension attributes object or create a new one. + * + * @return \Magento\Framework\Api\ExtensionAttributesInterface + */ + protected function _getExtensionAttributes() + { + return $this->getData(self::EXTENSION_ATTRIBUTES_KEY); + } } diff --git a/lib/internal/Magento/Framework/Model/AbstractModel.php b/lib/internal/Magento/Framework/Model/AbstractModel.php index f31fb9fc3e90c7451f605f74022d82625c1f7b5e..0a56caa62736901a42545220eb5f2ec7d1cb2766 100644 --- a/lib/internal/Magento/Framework/Model/AbstractModel.php +++ b/lib/internal/Magento/Framework/Model/AbstractModel.php @@ -6,6 +6,8 @@ namespace Magento\Framework\Model; +use Magento\Framework\Phrase; + /** * Abstract model class * @@ -447,14 +449,16 @@ abstract class AbstractModel extends \Magento\Framework\Object * Validate model before saving it * * @return $this - * @throws \Magento\Framework\Validator\ValidatorException + * @throws \Magento\Framework\Validator\Exception */ public function validateBeforeSave() { $validator = $this->_getValidatorBeforeSave(); if ($validator && !$validator->isValid($this)) { $errors = $validator->getMessages(); - $exception = new \Magento\Framework\Validator\ValidatorException(implode(PHP_EOL, $errors)); + $exception = new \Magento\Framework\Validator\Exception( + new Phrase(implode(PHP_EOL, $errors)) + ); foreach ($errors as $errorMessage) { $exception->addMessage(new \Magento\Framework\Message\Error($errorMessage)); } diff --git a/lib/internal/Magento/Framework/Model/Resource/Db/AbstractDb.php b/lib/internal/Magento/Framework/Model/Resource/Db/AbstractDb.php index 7b7d8c3229bd3caa227ff80509e6d077a3367021..f518409cb7e97eb78c31e91967e4b84033d833eb 100644 --- a/lib/internal/Magento/Framework/Model/Resource/Db/AbstractDb.php +++ b/lib/internal/Magento/Framework/Model/Resource/Db/AbstractDb.php @@ -237,7 +237,7 @@ abstract class AbstractDb extends \Magento\Framework\Model\Resource\AbstractReso public function getIdFieldName() { if (empty($this->_idFieldName)) { - throw new LocalizedException((string)new \Magento\Framework\Phrase('Empty identifier field name')); + throw new LocalizedException(new \Magento\Framework\Phrase('Empty identifier field name')); } return $this->_idFieldName; } @@ -252,7 +252,7 @@ abstract class AbstractDb extends \Magento\Framework\Model\Resource\AbstractReso public function getMainTable() { if (empty($this->_mainTable)) { - throw new LocalizedException((string)new \Magento\Framework\Phrase('Empty main table name')); + throw new LocalizedException(new \Magento\Framework\Phrase('Empty main table name')); } return $this->getTable($this->_mainTable); } @@ -658,9 +658,9 @@ abstract class AbstractDb extends \Magento\Framework\Model\Resource\AbstractReso if (!empty($existent)) { if (count($existent) == 1) { - $error = (string)new \Magento\Framework\Phrase('%1 already exists.', [$existent[0]]); + $error = new \Magento\Framework\Phrase('%1 already exists.', [$existent[0]]); } else { - $error = (string)new \Magento\Framework\Phrase('%1 already exist.', [implode(', ', $existent)]); + $error = new \Magento\Framework\Phrase('%1 already exist.', [implode(', ', $existent)]); } throw new AlreadyExistsException($error); } diff --git a/lib/internal/Magento/Framework/Model/Test/Unit/AbstractExtensibleModelTest.php b/lib/internal/Magento/Framework/Model/Test/Unit/AbstractExtensibleModelTest.php index 2d224e2d6cada6ba260a9d3d857e03b52b8832d4..df82d6f679446790dd0df79b6cf2633e6070053d 100644 --- a/lib/internal/Magento/Framework/Model/Test/Unit/AbstractExtensibleModelTest.php +++ b/lib/internal/Magento/Framework/Model/Test/Unit/AbstractExtensibleModelTest.php @@ -4,6 +4,8 @@ * See COPYING.txt for license details. */ +// @codingStandardsIgnoreFile + namespace Magento\Framework\Model\Test\Unit; use Magento\Framework\Api\AttributeValue; @@ -98,6 +100,9 @@ class AbstractExtensibleModelTest extends \PHPUnit_Framework_TestCase new \Magento\Framework\Object(['attribute_code' => 'attribute3']), ] ); + $extensionAttributesFactory = $this->getMockBuilder('Magento\Framework\Api\ExtensionAttributesFactory') + ->disableOriginalConstructor() + ->getMock(); $this->attributeValueFactoryMock = $this->getMockBuilder('Magento\Framework\Api\AttributeValueFactory') ->disableOriginalConstructor() ->getMock(); @@ -106,7 +111,7 @@ class AbstractExtensibleModelTest extends \PHPUnit_Framework_TestCase [ $this->contextMock, $this->registryMock, - $this->metadataServiceMock, + $extensionAttributesFactory, $this->attributeValueFactoryMock, $this->resourceMock, $this->resourceCollectionMock @@ -130,10 +135,9 @@ class AbstractExtensibleModelTest extends \PHPUnit_Framework_TestCase "Null is expected as a result of getCustomAttribute(\$code) when custom attribute is not set." ); $attributesAsArray = ['attribute1' => true, 'attribute2' => 'Attribute Value', 'attribute3' => 333]; - $addedAttributes = $this->addCustomAttributesToModel($attributesAsArray, $this->model); - $addedAttributes = array_values($addedAttributes); + $this->addCustomAttributesToModel($attributesAsArray, $this->model); $this->assertEquals( - $addedAttributes, + [], $this->model->getCustomAttributes(), 'Custom attributes retrieved from the model using getCustomAttributes() are invalid.' ); @@ -152,15 +156,13 @@ class AbstractExtensibleModelTest extends \PHPUnit_Framework_TestCase ]; $modelData = ['key1' => 'value1', 'key2' => 222]; $this->model->setData($modelData); - $addedAttributes = $this->addCustomAttributesToModel($attributesAsArray, $this->model); - $modelDataAsFlatArray = array_merge($modelData, $addedAttributes); - unset($modelDataAsFlatArray['invalid']); + $this->addCustomAttributesToModel($attributesAsArray, $this->model); $this->assertEquals( - $modelDataAsFlatArray, + $modelData, $this->model->getData(), 'All model data should be represented as a flat array, including custom attributes.' ); - foreach ($modelDataAsFlatArray as $field => $value) { + foreach ($modelData as $field => $value) { $this->assertEquals( $value, $this->model->getData($field), @@ -174,7 +176,7 @@ class AbstractExtensibleModelTest extends \PHPUnit_Framework_TestCase */ public function testRestrictedCustomAttributesGet() { - $this->model->getData(\Magento\Framework\Api\ExtensibleDataInterface::CUSTOM_ATTRIBUTES); + $this->model->getData(\Magento\Framework\Api\CustomAttributesDataInterface::CUSTOM_ATTRIBUTES); } public function testSetCustomAttributesAsLiterals() @@ -184,18 +186,18 @@ class AbstractExtensibleModelTest extends \PHPUnit_Framework_TestCase $attributeMock = $this->getMockBuilder('\Magento\Framework\Api\AttributeValue') ->disableOriginalConstructor() ->getMock(); - $attributeMock->expects($this->once()) + $attributeMock->expects($this->never()) ->method('setAttributeCode') ->with($attributeCode) ->will($this->returnSelf()); - $attributeMock->expects($this->once()) + $attributeMock->expects($this->never()) ->method('setValue') ->with($attributeValue) ->will($this->returnSelf()); - $this->attributeValueFactoryMock->expects($this->once())->method('create') + $this->attributeValueFactoryMock->expects($this->never())->method('create') ->willReturn($attributeMock); $this->model->setData( - \Magento\Framework\Api\ExtensibleDataInterface::CUSTOM_ATTRIBUTES, + \Magento\Framework\Api\CustomAttributesDataInterface::CUSTOM_ATTRIBUTES, [$attributeCode => $attributeValue] ); } @@ -219,7 +221,7 @@ class AbstractExtensibleModelTest extends \PHPUnit_Framework_TestCase $model->setData( array_merge( $model->getData(), - [\Magento\Framework\Api\ExtensibleDataInterface::CUSTOM_ATTRIBUTES => $addedAttributes] + [\Magento\Framework\Api\CustomAttributesDataInterface::CUSTOM_ATTRIBUTES => $addedAttributes] ) ); return $addedAttributes; diff --git a/lib/internal/Magento/Framework/Model/Test/Unit/Resource/Db/Collection/AbstractCollectionTest.php b/lib/internal/Magento/Framework/Model/Test/Unit/Resource/Db/Collection/AbstractCollectionTest.php index e0dcd8a6d4da249be3d1d5ddfbbc90f56cb799c1..9d4540a26e896351957dd9bf08dd49454dfd842e 100644 --- a/lib/internal/Magento/Framework/Model/Test/Unit/Resource/Db/Collection/AbstractCollectionTest.php +++ b/lib/internal/Magento/Framework/Model/Test/Unit/Resource/Db/Collection/AbstractCollectionTest.php @@ -12,6 +12,9 @@ use Magento\Framework\Model\Resource\Db\Collection\AbstractCollection; use Magento\Framework\Object as MagentoObject; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class AbstractCollectionTest extends \PHPUnit_Framework_TestCase { const TABLE_NAME = 'some_table'; @@ -78,6 +81,14 @@ class AbstractCollectionTest extends \PHPUnit_Framework_TestCase $this->uut = $this->getUut(); } + protected function tearDown() + { + parent::tearDown(); + $magentoObjectManagerFactory = \Magento\Framework\App\Bootstrap::createObjectManagerFactory(BP, $_SERVER); + $objectManager = $magentoObjectManagerFactory->create($_SERVER); + \Magento\Framework\App\ObjectManager::setInstance($objectManager); + } + protected function getUut() { return $this->objectManagerHelper->getObject( diff --git a/lib/internal/Magento/Framework/Module/Test/Unit/Declaration/Converter/DomTest.php b/lib/internal/Magento/Framework/Module/Test/Unit/Declaration/Converter/DomTest.php index 81a0535a1955692719e3e0025f280503e850e1bd..c9c0b024ca9c9dc95ee54f68ea21482c3309f9fe 100644 --- a/lib/internal/Magento/Framework/Module/Test/Unit/Declaration/Converter/DomTest.php +++ b/lib/internal/Magento/Framework/Module/Test/Unit/Declaration/Converter/DomTest.php @@ -28,22 +28,26 @@ class DomTest extends \PHPUnit_Framework_TestCase /** * @param string $xmlString - * @dataProvider testConvertWithInvalidDomDataProvider + * @dataProvider convertWithInvalidDomDataProvider * @expectedException \Exception */ public function testConvertWithInvalidDom($xmlString) { $dom = new \DOMDocument(); - $dom->loadXML($xmlString); - $this->_converter->convert($dom); + try { + $dom->loadXML($xmlString); + $this->_converter->convert($dom); + } catch (\PHPUnit_Framework_Error $ex) { + // do nothing because we expect \Exception but not \PHPUnit_Framework_Error + } } - public function testConvertWithInvalidDomDataProvider() + public function convertWithInvalidDomDataProvider() { return [ 'Module node without "name" attribute' => ['<?xml version="1.0"?><config><module /></config>'], 'Sequence module node without "name" attribute' => [ - '<?xml dbversion="1.0"?><config><module name="Module_One" setup_version="1.0.0.0">' . + '<?xml version="1.0"?><config><module name="Module_One" setup_version="1.0.0.0">' . '<sequence><module/></sequence></module></config>', ], ]; diff --git a/lib/internal/Magento/Framework/Mview/Test/Unit/Config/ConverterTest.php b/lib/internal/Magento/Framework/Mview/Test/Unit/Config/ConverterTest.php index a3ea7de3792d2cc2b447e23bb171b319762099c7..13901c1283cca62deaec9be9cf03eab0a73e1dae 100644 --- a/lib/internal/Magento/Framework/Mview/Test/Unit/Config/ConverterTest.php +++ b/lib/internal/Magento/Framework/Mview/Test/Unit/Config/ConverterTest.php @@ -25,24 +25,4 @@ class ConverterTest extends \PHPUnit_Framework_TestCase $this->assertEquals($data['expected'], $this->_model->convert($dom)); } - - /** - * @param string $xmlData - * @dataProvider wrongXmlDataProvider - * @expectedException \Exception - */ - public function testMapThrowsExceptionWhenXmlHasWrongFormat($xmlData) - { - $dom = new \DOMDocument(); - $dom->loadXML($xmlData); - $this->_model->convert($dom); - } - - /** - * @return array - */ - public function wrongXmlDataProvider() - { - return [['<?xml version="1.0"?><config>']]; - } } diff --git a/lib/internal/Magento/Framework/Oauth/Exception.php b/lib/internal/Magento/Framework/Oauth/Exception.php index e35fd786c786f002b4a7dd791ffd1f1ee5927be8..24c08f73b09cade25a527a0e218433b3a4212e02 100644 --- a/lib/internal/Magento/Framework/Oauth/Exception.php +++ b/lib/internal/Magento/Framework/Oauth/Exception.php @@ -3,7 +3,6 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ - namespace Magento\Framework\Oauth; use Magento\Framework\Exception\AuthenticationException; diff --git a/lib/internal/Magento/Framework/Oauth/Oauth.php b/lib/internal/Magento/Framework/Oauth/Oauth.php index 88c23929222216718c3cb076a029e745f707e9ad..1d397d70abbf8a767bfe37706776ae2cf08befb5 100644 --- a/lib/internal/Magento/Framework/Oauth/Oauth.php +++ b/lib/internal/Magento/Framework/Oauth/Oauth.php @@ -5,6 +5,8 @@ */ namespace Magento\Framework\Oauth; +use Magento\Framework\Phrase; + class Oauth implements OauthInterface { /** @@ -175,8 +177,10 @@ class Oauth implements OauthInterface { if (!in_array($params['oauth_signature_method'], self::getSupportedSignatureMethods())) { throw new OauthInputException( - 'Signature method %1 is not supported', - [$params['oauth_signature_method']] + new Phrase( + 'Signature method %1 is not supported', + [$params['oauth_signature_method']] + ) ); } @@ -193,7 +197,7 @@ class Oauth implements OauthInterface ); if ($calculatedSign != $params['oauth_signature']) { - throw new Exception('Invalid signature'); + throw new Exception(new Phrase('Invalid signature')); } } @@ -208,7 +212,7 @@ class Oauth implements OauthInterface { // validate version if specified if ('1.0' != $version) { - throw new OauthInputException('OAuth version %1 is not supported', [$version]); + throw new OauthInputException(new Phrase('OAuth version %1 is not supported', [$version])); } } @@ -245,14 +249,16 @@ class Oauth implements OauthInterface $protocolParams['oauth_token'] ) ) { - throw new OauthInputException('Token is not the correct length'); + throw new OauthInputException(new Phrase('Token is not the correct length')); } // Validate signature method. if (!in_array($protocolParams['oauth_signature_method'], self::getSupportedSignatureMethods())) { throw new OauthInputException( - 'Signature method %1 is not supported', - [$protocolParams['oauth_signature_method']] + new Phrase( + 'Signature method %1 is not supported', + [$protocolParams['oauth_signature_method']] + ) ); } @@ -277,7 +283,7 @@ class Oauth implements OauthInterface $exception = new OauthInputException(); foreach ($requiredParams as $param) { if (!isset($protocolParams[$param])) { - $exception->addError(OauthInputException::REQUIRED_FIELD, ['fieldName' => $param]); + $exception->addError(new Phrase(OauthInputException::REQUIRED_FIELD, ['fieldName' => $param])); } } if ($exception->wasErrorAdded()) { diff --git a/lib/internal/Magento/Framework/Oauth/Test/Unit/Helper/RequestTest.php b/lib/internal/Magento/Framework/Oauth/Test/Unit/Helper/RequestTest.php index f7e8566a9d1ac383c1bdb575896880bc512486f7..fd5788a596e0fc9a200cd1264165421d5b7c264c 100644 --- a/lib/internal/Magento/Framework/Oauth/Test/Unit/Helper/RequestTest.php +++ b/lib/internal/Magento/Framework/Oauth/Test/Unit/Helper/RequestTest.php @@ -7,6 +7,8 @@ */ namespace Magento\Framework\Oauth\Test\Unit\Helper; +use Magento\Framework\Phrase; + class RequestTest extends \PHPUnit_Framework_TestCase { /** @var \Magento\Framework\Oauth\Helper\Request */ @@ -15,6 +17,9 @@ class RequestTest extends \PHPUnit_Framework_TestCase /** @var \Magento\Framework\App\Response\Http */ protected $response; + /** + * @return void + */ protected function setUp() { $this->oauthRequestHelper = new \Magento\Framework\Oauth\Helper\Request(); @@ -27,12 +32,18 @@ class RequestTest extends \PHPUnit_Framework_TestCase ); } + /** + * @return void + */ protected function tearDown() { unset($this->oauthRequestHelper, $this->response); } /** + * @param \Exception $exception + * @param array $expected + * @return void * @dataProvider dataProviderForPrepareErrorResponseTest */ public function testPrepareErrorResponse($exception, $expected) @@ -46,11 +57,14 @@ class RequestTest extends \PHPUnit_Framework_TestCase $this->assertEquals(['oauth_problem' => $expected[0]], $errorResponse); } + /** + * @return array + */ public function dataProviderForPrepareErrorResponseTest() { return [ [ - new \Magento\Framework\Oauth\OauthInputException('msg'), + new \Magento\Framework\Oauth\OauthInputException(new Phrase('msg')), ['msg', \Magento\Framework\Oauth\Helper\Request::HTTP_BAD_REQUEST], ], [ @@ -68,6 +82,9 @@ class RequestTest extends \PHPUnit_Framework_TestCase } /** + * @param string $url + * @param string $host + * @return void * @dataProvider hostsDataProvider */ public function testGetRequestUrl($url, $host) @@ -87,6 +104,9 @@ class RequestTest extends \PHPUnit_Framework_TestCase $this->assertEquals($url, $this->oauthRequestHelper->getRequestUrl($httpRequestMock)); } + /** + * @return array + */ public function hostsDataProvider() { return [ diff --git a/lib/internal/Magento/Framework/Oauth/Test/Unit/OauthInputExceptionTest.php b/lib/internal/Magento/Framework/Oauth/Test/Unit/OauthInputExceptionTest.php index ec368c3308a67f37b2cb3da768472c4d85117d01..a5b658b59d2bbbabb44448486dfb81e411cb2703 100644 --- a/lib/internal/Magento/Framework/Oauth/Test/Unit/OauthInputExceptionTest.php +++ b/lib/internal/Magento/Framework/Oauth/Test/Unit/OauthInputExceptionTest.php @@ -6,16 +6,20 @@ namespace Magento\Framework\Oauth\Test\Unit; use \Magento\Framework\Oauth\OauthInputException; +use Magento\Framework\Phrase; class OauthInputExceptionTest extends \PHPUnit_Framework_TestCase { + /** + * @return void + */ public function testGetAggregatedErrorMessage() { $exception = new OauthInputException(); foreach (['field1', 'field2'] as $param) { - $exception->addError(OauthInputException::REQUIRED_FIELD, ['fieldName' => $param]); + $exception->addError(new Phrase(OauthInputException::REQUIRED_FIELD, ['fieldName' => $param])); } - $exception->addError('Message with period.'); + $exception->addError(new Phrase('Message with period.')); $this->assertEquals( 'field1 is a required field, field2 is a required field, Message with period', @@ -23,6 +27,9 @@ class OauthInputExceptionTest extends \PHPUnit_Framework_TestCase ); } + /** + * @return void + */ public function testGetAggregatedErrorMessageNoError() { $exception = new OauthInputException(); diff --git a/lib/internal/Magento/Framework/ObjectManager/Code/Generator/Converter.php b/lib/internal/Magento/Framework/ObjectManager/Code/Generator/Converter.php index e2bca1d2086337a2a55a84c807024497fbc51107..65b02d8afce7189b5e4a912e2c3664c247f75276 100644 --- a/lib/internal/Magento/Framework/ObjectManager/Code/Generator/Converter.php +++ b/lib/internal/Magento/Framework/ObjectManager/Code/Generator/Converter.php @@ -47,8 +47,7 @@ class Converter extends \Magento\Framework\Code\Generator\EntityAbstract */ protected function _getFactoryPropertyName() { - $parts = explode('\\', ltrim($this->_getSourceClassName(), '\\')); - return lcfirst(end($parts)) . 'Factory'; + return lcfirst($this->getSourceClassNameWithoutNamespace()) . 'Factory'; } /** @@ -58,7 +57,7 @@ class Converter extends \Magento\Framework\Code\Generator\EntityAbstract */ protected function _getFactoryClass() { - return $this->_getSourceClassName() . 'Factory'; + return $this->getSourceClassName() . 'Factory'; } /** @@ -84,7 +83,7 @@ class Converter extends \Magento\Framework\Code\Generator\EntityAbstract 'tags' => [ [ 'name' => 'param', - 'description' => $this->_getSourceClassName() + 'description' => $this->getSourceClassName() . " \$" . $this->_getFactoryPropertyName(), ], ], @@ -121,7 +120,7 @@ class Converter extends \Magento\Framework\Code\Generator\EntityAbstract ], [ 'name' => 'return', - 'description' => $this->_getSourceClassName() + 'description' => $this->getSourceClassName() ], ], ], @@ -138,7 +137,7 @@ class Converter extends \Magento\Framework\Code\Generator\EntityAbstract return false; } - $sourceClassName = $this->_getSourceClassName(); + $sourceClassName = $this->getSourceClassName(); $resultClassName = $this->_getResultClassName(); if ($resultClassName !== $sourceClassName . 'Converter') { diff --git a/lib/internal/Magento/Framework/ObjectManager/Code/Generator/Factory.php b/lib/internal/Magento/Framework/ObjectManager/Code/Generator/Factory.php index 33a4e7ee10f7add76fb93baca44b46daa3c871fa..ee28a12c169a83a19fda2db50adf4a5993aae6ee 100644 --- a/lib/internal/Magento/Framework/ObjectManager/Code/Generator/Factory.php +++ b/lib/internal/Magento/Framework/ObjectManager/Code/Generator/Factory.php @@ -44,7 +44,7 @@ class Factory extends \Magento\Framework\Code\Generator\EntityAbstract 'name' => '__construct', 'parameters' => [ ['name' => 'objectManager', 'type' => '\Magento\Framework\ObjectManagerInterface'], - ['name' => 'instanceName', 'defaultValue' => $this->_getSourceClassName()], + ['name' => 'instanceName', 'defaultValue' => $this->getSourceClassName()], ], 'body' => "\$this->_objectManager = \$objectManager;\n\$this->_instanceName = \$instanceName;", 'docblock' => [ @@ -80,7 +80,7 @@ class Factory extends \Magento\Framework\Code\Generator\EntityAbstract ['name' => 'param', 'description' => 'array $data'], [ 'name' => 'return', - 'description' => $this->_getSourceClassName() + 'description' => $this->getSourceClassName() ], ], ], @@ -97,7 +97,7 @@ class Factory extends \Magento\Framework\Code\Generator\EntityAbstract $result = parent::_validateData(); if ($result) { - $sourceClassName = $this->_getSourceClassName(); + $sourceClassName = $this->getSourceClassName(); $resultClassName = $this->_getResultClassName(); if ($resultClassName !== $sourceClassName . 'Factory') { diff --git a/lib/internal/Magento/Framework/ObjectManager/Code/Generator/Persistor.php b/lib/internal/Magento/Framework/ObjectManager/Code/Generator/Persistor.php index 9b83cb681d80177ceed23136ae93038d4915c078..8c54a7c689a0ee6e3eb11eb1ef1922463a0a0860 100644 --- a/lib/internal/Magento/Framework/ObjectManager/Code/Generator/Persistor.php +++ b/lib/internal/Magento/Framework/ObjectManager/Code/Generator/Persistor.php @@ -34,7 +34,7 @@ class Persistor extends \Magento\Framework\Code\Generator\EntityAbstract 'tags' => [ [ 'name' => 'var', - 'description' => $this->_getSourceClassName() . 'Factory', + 'description' => $this->getSourceClassName() . 'Factory', ], ], ], @@ -117,8 +117,7 @@ class Persistor extends \Magento\Framework\Code\Generator\EntityAbstract */ protected function _getSourceFactoryPropertyName() { - $parts = explode('\\', ltrim($this->_getSourceClassName(), '\\')); - return lcfirst(end($parts)) . 'Factory'; + return lcfirst($this->getSourceClassNameWithoutNamespace()) . 'Factory'; } /** @@ -127,8 +126,7 @@ class Persistor extends \Magento\Framework\Code\Generator\EntityAbstract */ protected function _getSourceResourcePropertyName() // InvoiceResource { - $parts = explode('\\', ltrim($this->_getSourceClassName(), '\\')); - return lcfirst(end($parts)) . "Resource"; + return lcfirst($this->getSourceClassNameWithoutNamespace()) . "Resource"; } /** @@ -138,7 +136,7 @@ class Persistor extends \Magento\Framework\Code\Generator\EntityAbstract */ protected function _getSourceResourceClassName() // Invoice\Resource { - $temporary = str_replace('\\Api\\Data\\', '\\Model\\Spi\\', $this->_getSourceClassName()); + $temporary = str_replace('\\Api\\Data\\', '\\Model\\Spi\\', $this->getSourceClassName()); $parts = explode('\\', ltrim($temporary, '\\')); $className = array_pop($parts); $className = str_replace('Interface', '', $className); @@ -180,7 +178,7 @@ class Persistor extends \Magento\Framework\Code\Generator\EntityAbstract ], [ 'name' => $this->_getSourceFactoryPropertyName(), - 'type' => $this->_getSourceClassName() . 'Factory' + 'type' => $this->getSourceClassName() . 'Factory' ], [ 'name' => 'resource', @@ -205,7 +203,7 @@ class Persistor extends \Magento\Framework\Code\Generator\EntityAbstract ], [ 'name' => 'param', - 'description' => $this->_getSourceClassName() . 'Factory' + 'description' => $this->getSourceClassName() . 'Factory' . " \$" . $this->_getSourceFactoryPropertyName() ], [ @@ -295,7 +293,7 @@ class Persistor extends \Magento\Framework\Code\Generator\EntityAbstract 'parameters' => [ [ 'name' => 'entity', - 'type' => $this->_getSourceClassName(), + 'type' => $this->getSourceClassName(), ], ], 'body' => $body, @@ -304,7 +302,7 @@ class Persistor extends \Magento\Framework\Code\Generator\EntityAbstract 'tags' => [ [ 'name' => 'param', - 'description' => $this->_getSourceClassName() . " \$entity", + 'description' => $this->getSourceClassName() . " \$entity", ], ], ] @@ -388,7 +386,7 @@ class Persistor extends \Magento\Framework\Code\Generator\EntityAbstract 'parameters' => [ [ 'name' => 'entity', - 'type' => $this->_getSourceClassName(), + 'type' => $this->getSourceClassName(), ], ], 'body' => $body, @@ -397,7 +395,7 @@ class Persistor extends \Magento\Framework\Code\Generator\EntityAbstract 'tags' => [ [ 'name' => 'param', - 'description' => $this->_getSourceClassName() . " \$entity", + 'description' => $this->getSourceClassName() . " \$entity", ], ], ] @@ -431,7 +429,7 @@ class Persistor extends \Magento\Framework\Code\Generator\EntityAbstract ], [ 'name' => 'param', - 'description' => $this->_getSourceClassName() . " \$entity", + 'description' => $this->getSourceClassName() . " \$entity", ], ], ] @@ -457,7 +455,7 @@ class Persistor extends \Magento\Framework\Code\Generator\EntityAbstract 'parameters' => [ [ 'name' => 'entity', - 'type' => $this->_getSourceClassName(), + 'type' => $this->getSourceClassName(), ], ], 'body' => $body, @@ -467,7 +465,7 @@ class Persistor extends \Magento\Framework\Code\Generator\EntityAbstract [ 'name' => 'param', - 'description' => $this->_getSourceClassName() . " \$entity", + 'description' => $this->getSourceClassName() . " \$entity", ], ], ] @@ -482,7 +480,7 @@ class Persistor extends \Magento\Framework\Code\Generator\EntityAbstract $result = parent::_validateData(); if ($result) { - $sourceClassName = $this->_getSourceClassName(); + $sourceClassName = $this->getSourceClassName(); $resultClassName = $this->_getResultClassName(); if ($resultClassName !== $sourceClassName . 'Persistor') { diff --git a/lib/internal/Magento/Framework/ObjectManager/Code/Generator/Proxy.php b/lib/internal/Magento/Framework/ObjectManager/Code/Generator/Proxy.php index e09dcef74ac47445da2b4672d771539986110128..82686165132f8367f7999972af0e51c238e2cc8b 100644 --- a/lib/internal/Magento/Framework/ObjectManager/Code/Generator/Proxy.php +++ b/lib/internal/Magento/Framework/ObjectManager/Code/Generator/Proxy.php @@ -47,7 +47,7 @@ class Proxy extends \Magento\Framework\Code\Generator\EntityAbstract 'visibility' => 'protected', 'docblock' => [ 'shortDescription' => 'Proxied instance', - 'tags' => [['name' => 'var', 'description' => $this->_getSourceClassName()]], + 'tags' => [['name' => 'var', 'description' => $this->getSourceClassName()]], ], ]; @@ -101,10 +101,10 @@ class Proxy extends \Magento\Framework\Code\Generator\EntityAbstract "return \$this->_subject;", 'docblock' => [ 'shortDescription' => 'Get proxied instance', - 'tags' => [['name' => 'return', 'description' => $this->_getSourceClassName()]], + 'tags' => [['name' => 'return', 'description' => $this->getSourceClassName()]], ], ]; - $reflectionClass = new \ReflectionClass($this->_getSourceClassName()); + $reflectionClass = new \ReflectionClass($this->getSourceClassName()); $publicMethods = $reflectionClass->getMethods(\ReflectionMethod::IS_PUBLIC); foreach ($publicMethods as $method) { if (!($method->isConstructor() || @@ -127,7 +127,7 @@ class Proxy extends \Magento\Framework\Code\Generator\EntityAbstract */ protected function _generateCode() { - $typeName = $this->_getSourceClassName(); + $typeName = $this->getSourceClassName(); $reflection = new \ReflectionClass($typeName); if ($reflection->isInterface()) { @@ -181,7 +181,7 @@ class Proxy extends \Magento\Framework\Code\Generator\EntityAbstract 'name' => '__construct', 'parameters' => [ ['name' => 'objectManager', 'type' => '\Magento\Framework\ObjectManagerInterface'], - ['name' => 'instanceName', 'defaultValue' => $this->_getSourceClassName()], + ['name' => 'instanceName', 'defaultValue' => $this->getSourceClassName()], ['name' => 'shared', 'defaultValue' => true], ], 'body' => "\$this->_objectManager = \$objectManager;" . @@ -225,7 +225,7 @@ class Proxy extends \Magento\Framework\Code\Generator\EntityAbstract { $result = parent::_validateData(); if ($result) { - $sourceClassName = $this->_getSourceClassName(); + $sourceClassName = $this->getSourceClassName(); $resultClassName = $this->_getResultClassName(); if ($resultClassName !== $sourceClassName . '\\Proxy') { diff --git a/lib/internal/Magento/Framework/ObjectManager/Code/Generator/Repository.php b/lib/internal/Magento/Framework/ObjectManager/Code/Generator/Repository.php index ce047eb4a6f693d23df1459070ba981e9c82fd34..22857fcf9bcfae8bfe3f0de7f675263cfdae33ee 100644 --- a/lib/internal/Magento/Framework/ObjectManager/Code/Generator/Repository.php +++ b/lib/internal/Magento/Framework/ObjectManager/Code/Generator/Repository.php @@ -64,7 +64,7 @@ class Repository extends \Magento\Framework\Code\Generator\EntityAbstract 'visibility' => 'protected', 'defaultValue' => [], 'docblock' => [ - 'shortDescription' => $this->_getSourceClassName() . '[]', + 'shortDescription' => $this->getSourceClassName() . '[]', 'tags' => [ [ 'name' => 'var', @@ -84,8 +84,7 @@ class Repository extends \Magento\Framework\Code\Generator\EntityAbstract */ protected function _getSourcePersistorPropertyName() { - $parts = explode('\\', ltrim($this->_getSourceClassName(), '\\')); - return lcfirst(end($parts)) . 'Persistor'; + return lcfirst($this->getSourceClassNameWithoutNamespace()) . 'Persistor'; } /** @@ -94,8 +93,7 @@ class Repository extends \Magento\Framework\Code\Generator\EntityAbstract */ protected function _getSourceCollectionFactoryPropertyName() { - $parts = explode('\\', ltrim($this->_getSourceClassName(), '\\')); - return lcfirst(end($parts)) . 'SearchResultFactory'; + return lcfirst($this->getSourceClassNameWithoutNamespace()) . 'SearchResultFactory'; } /** @@ -106,7 +104,7 @@ class Repository extends \Magento\Framework\Code\Generator\EntityAbstract protected function _getCollectionFactoryClassName() { return - str_replace('Interface', '', $this->_getSourceClassName()) . 'SearchResultInterfaceFactory'; + str_replace('Interface', '', $this->getSourceClassName()) . 'SearchResultInterfaceFactory'; } /** * Returns source persistor class name @@ -115,7 +113,7 @@ class Repository extends \Magento\Framework\Code\Generator\EntityAbstract */ protected function _getPersistorClassName() { - $target = $this->_getSourceClassName(); + $target = $this->getSourceClassName(); // if (substr($target, -9) == 'Interface') { // $target = substr($target, 1, strlen($target) -9); // } @@ -153,7 +151,7 @@ class Repository extends \Magento\Framework\Code\Generator\EntityAbstract 'tags' => [ [ 'name' => 'param', - 'description' => $this->_getSourceClassName() . " \$" . $this->_getSourcePersistorPropertyName(), + 'description' => $this->getSourceClassName() . " \$" . $this->_getSourcePersistorPropertyName(), ], [ 'name' => 'param', @@ -202,7 +200,7 @@ class Repository extends \Magento\Framework\Code\Generator\EntityAbstract ], [ 'name' => 'return', - 'description' => $this->_getSourceClassName(), + 'description' => $this->getSourceClassName(), ], [ 'name' => 'throws', @@ -263,7 +261,7 @@ class Repository extends \Magento\Framework\Code\Generator\EntityAbstract 'parameters' => [ [ 'name' => 'entity', - 'type' => $this->_getSourceClassName(), + 'type' => $this->getSourceClassName(), ], ], 'body' => $body, @@ -276,7 +274,7 @@ class Repository extends \Magento\Framework\Code\Generator\EntityAbstract ], [ 'name' => 'return', - 'description' => $this->_getSourceClassName(), + 'description' => $this->getSourceClassName(), ], ], ] @@ -319,7 +317,7 @@ class Repository extends \Magento\Framework\Code\Generator\EntityAbstract 'parameters' => [ [ 'name' => 'entity', - 'type' => $this->_getSourceClassName(), + 'type' => $this->getSourceClassName(), ], ], 'body' => $body, @@ -328,11 +326,11 @@ class Repository extends \Magento\Framework\Code\Generator\EntityAbstract 'tags' => [ [ 'name' => 'param', - 'description' => $this->_getSourceClassName() . " \$entity", + 'description' => $this->getSourceClassName() . " \$entity", ], [ 'name' => 'return', - 'description' => $this->_getSourceClassName(), + 'description' => $this->getSourceClassName(), ], ], ] @@ -353,7 +351,7 @@ class Repository extends \Magento\Framework\Code\Generator\EntityAbstract 'parameters' => [ [ 'name' => 'entity', - 'type' => $this->_getSourceClassName(), + 'type' => $this->getSourceClassName(), ], ], 'body' => $body, @@ -362,7 +360,7 @@ class Repository extends \Magento\Framework\Code\Generator\EntityAbstract 'tags' => [ [ 'name' => 'param', - 'description' => $this->_getSourceClassName() . ' $entity', + 'description' => $this->getSourceClassName() . ' $entity', ], ], ] @@ -413,7 +411,7 @@ class Repository extends \Magento\Framework\Code\Generator\EntityAbstract 'parameters' => [ [ 'name' => 'entity', - 'type' => $this->_getSourceClassName(), + 'type' => $this->getSourceClassName(), ], ], 'body' => $body, @@ -422,7 +420,7 @@ class Repository extends \Magento\Framework\Code\Generator\EntityAbstract 'tags' => [ [ 'name' => 'param', - 'description' => $this->_getSourceClassName() . ' $entity', + 'description' => $this->getSourceClassName() . ' $entity', ], ], ] @@ -464,7 +462,7 @@ class Repository extends \Magento\Framework\Code\Generator\EntityAbstract ], [ 'name' => 'return', - 'description' => $this->_getSourceClassName() . '[]', + 'description' => $this->getSourceClassName() . '[]', ], ], ] @@ -500,7 +498,7 @@ class Repository extends \Magento\Framework\Code\Generator\EntityAbstract $result = parent::_validateData(); if ($result) { - $sourceClassName = $this->_getSourceClassName(); + $sourceClassName = $this->getSourceClassName(); $resultClassName = $this->_getResultClassName(); if ($resultClassName !== str_replace('Interface', '', $sourceClassName) . '\\Repository') { @@ -520,7 +518,7 @@ class Repository extends \Magento\Framework\Code\Generator\EntityAbstract */ protected function _generateCode() { - $className = str_replace('Interface', '', str_replace('Data\\', '', $this->_getSourceClassName())); + $className = str_replace('Interface', '', str_replace('Data\\', '', $this->getSourceClassName())); $this->_classGenerator->setName( $this->_getResultClassName() )->addProperties( @@ -542,8 +540,8 @@ class Repository extends \Magento\Framework\Code\Generator\EntityAbstract * * @return string */ - protected function _getSourceClassName() + public function getSourceClassName() { - return parent::_getSourceClassName() . 'Interface'; + return parent::getSourceClassName() . 'Interface'; } } diff --git a/lib/internal/Magento/Framework/ObjectManager/DefinitionFactory.php b/lib/internal/Magento/Framework/ObjectManager/DefinitionFactory.php index 626dbd548aab0f5a369f8dffd3cebe683598a27b..00aac17d300ed3522a3c1f0726186622a594875f 100644 --- a/lib/internal/Magento/Framework/ObjectManager/DefinitionFactory.php +++ b/lib/internal/Magento/Framework/ObjectManager/DefinitionFactory.php @@ -21,7 +21,8 @@ use Magento\Framework\ObjectManager\Definition\Compiled\Binary; use Magento\Framework\ObjectManager\Definition\Compiled\Serialized; use Magento\Framework\ObjectManager\Definition\Runtime; use Magento\Framework\ObjectManager\Profiler\Code\Generator as ProfilerGenerator; -use Magento\Framework\Api\Code\Generator\ObjectExtensionInterface; +use Magento\Framework\Api\Code\Generator\ExtensionAttributesGenerator; +use Magento\Framework\Api\Code\Generator\ExtensionAttributesInterfaceGenerator; /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) @@ -66,6 +67,11 @@ class DefinitionFactory Serialized::MODE_NAME => '\Magento\Framework\ObjectManager\Definition\Compiled\Serialized', ]; + /** + * @var \Magento\Framework\Code\Generator + */ + protected $codeGenerator; + /** * @param DriverInterface $filesystemDriver * @param string $definitionDir @@ -95,26 +101,7 @@ class DefinitionFactory $definitionModel = $this->_definitionClasses[$this->_definitionFormat]; $result = new $definitionModel($definitions); } else { - $generatorIo = new \Magento\Framework\Code\Generator\Io( - $this->_filesystemDriver, - $this->_generationDir - ); - $generator = new \Magento\Framework\Code\Generator( - $generatorIo, - [ - Generator\Factory::ENTITY_TYPE => '\Magento\Framework\ObjectManager\Code\Generator\Factory', - Generator\Proxy::ENTITY_TYPE => '\Magento\Framework\ObjectManager\Code\Generator\Proxy', - Generator\Repository::ENTITY_TYPE => '\Magento\Framework\ObjectManager\Code\Generator\Repository', - Generator\Persistor::ENTITY_TYPE => '\Magento\Framework\ObjectManager\Code\Generator\Persistor', - InterceptionGenerator\Interceptor::ENTITY_TYPE => '\Magento\Framework\Interception\Code\Generator\Interceptor', - MapperGenerator::ENTITY_TYPE => '\Magento\Framework\Api\Code\Generator\Mapper', - SearchResults::ENTITY_TYPE => '\Magento\Framework\Api\Code\Generator\SearchResults', - ConverterGenerator::ENTITY_TYPE => '\Magento\Framework\ObjectManager\Code\Generator\Converter', - ProfilerGenerator\Logger::ENTITY_TYPE => '\Magento\Framework\ObjectManager\Profiler\Code\Generator\Logger', - ObjectExtensionInterface::ENTITY_TYPE => - 'Magento\Framework\Api\Code\Generator\ObjectExtensionInterface' ] - ); - $autoloader = new \Magento\Framework\Code\Generator\Autoloader($generator); + $autoloader = new \Magento\Framework\Code\Generator\Autoloader($this->getCodeGenerator()); spl_autoload_register([$autoloader, 'load']); $result = new Runtime(); @@ -167,4 +154,36 @@ class DefinitionFactory $extractor = $this->_definitionFormat == Binary::MODE_NAME ? 'igbinary_unserialize' : 'unserialize'; return $extractor($definitions); } + + /** + * Get existing code generator. Instantiate a new one if it does not exist yet. + * + * @return \Magento\Framework\Code\Generator + */ + public function getCodeGenerator() + { + if (!$this->codeGenerator) { + $generatorIo = new \Magento\Framework\Code\Generator\Io( + $this->_filesystemDriver, + $this->_generationDir + ); + $this->codeGenerator = new \Magento\Framework\Code\Generator( + $generatorIo, + [ + Generator\Factory::ENTITY_TYPE => '\Magento\Framework\ObjectManager\Code\Generator\Factory', + Generator\Proxy::ENTITY_TYPE => '\Magento\Framework\ObjectManager\Code\Generator\Proxy', + Generator\Repository::ENTITY_TYPE => '\Magento\Framework\ObjectManager\Code\Generator\Repository', + Generator\Persistor::ENTITY_TYPE => '\Magento\Framework\ObjectManager\Code\Generator\Persistor', + InterceptionGenerator\Interceptor::ENTITY_TYPE => '\Magento\Framework\Interception\Code\Generator\Interceptor', + MapperGenerator::ENTITY_TYPE => '\Magento\Framework\Api\Code\Generator\Mapper', + SearchResults::ENTITY_TYPE => '\Magento\Framework\Api\Code\Generator\SearchResults', + ConverterGenerator::ENTITY_TYPE => '\Magento\Framework\ObjectManager\Code\Generator\Converter', + ProfilerGenerator\Logger::ENTITY_TYPE => '\Magento\Framework\ObjectManager\Profiler\Code\Generator\Logger', + ExtensionAttributesGenerator::ENTITY_TYPE => 'Magento\Framework\Api\Code\Generator\ExtensionAttributesGenerator', + ExtensionAttributesInterfaceGenerator::ENTITY_TYPE => 'Magento\Framework\Api\Code\Generator\ExtensionAttributesInterfaceGenerator' + ] + ); + } + return $this->codeGenerator; + } } diff --git a/lib/internal/Magento/Framework/ObjectManager/Profiler/Code/Generator/Logger.php b/lib/internal/Magento/Framework/ObjectManager/Profiler/Code/Generator/Logger.php index c30507a345a4225b46c4c272dcee7a4e243c390a..c8336a6ad15eb52152b7ab41e77c6cbef5d78182 100644 --- a/lib/internal/Magento/Framework/ObjectManager/Profiler/Code/Generator/Logger.php +++ b/lib/internal/Magento/Framework/ObjectManager/Profiler/Code/Generator/Logger.php @@ -116,7 +116,7 @@ class Logger extends \Magento\Framework\Code\Generator\EntityAbstract . "\n\$this->log->add(\$this->subject);", ]; - $reflectionClass = new \ReflectionClass($this->_getSourceClassName()); + $reflectionClass = new \ReflectionClass($this->getSourceClassName()); $publicMethods = $reflectionClass->getMethods(\ReflectionMethod::IS_PUBLIC); foreach ($publicMethods as $method) { if (!($method->isConstructor() || $method->isFinal() || $method->isStatic() || $method->isDestructor()) @@ -183,7 +183,7 @@ class Logger extends \Magento\Framework\Code\Generator\EntityAbstract */ protected function _generateCode() { - $typeName = $this->_getSourceClassName(); + $typeName = $this->getSourceClassName(); $reflection = new \ReflectionClass($typeName); if ($reflection->isInterface()) { @@ -202,7 +202,7 @@ class Logger extends \Magento\Framework\Code\Generator\EntityAbstract $result = parent::_validateData(); if ($result) { - $sourceClassName = $this->_getSourceClassName(); + $sourceClassName = $this->getSourceClassName(); $resultClassName = $this->_getResultClassName(); if ($resultClassName !== $sourceClassName . '\\Logger') { diff --git a/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Config/Mapper/_files/mapped_simple_di_config.php b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Config/Mapper/_files/mapped_simple_di_config.php index 88bce3e3a2a3aa0ce8fcf8cbb8220cd31b3ba8cf..c3eeeabb3125d93bc74abb10f3aff6141edfd376 100644 --- a/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Config/Mapper/_files/mapped_simple_di_config.php +++ b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Config/Mapper/_files/mapped_simple_di_config.php @@ -9,17 +9,17 @@ return [ 'Magento\Framework\App\RequestInterface' => 'Magento\Framework\App\Request\Http\Proxy', ], 'Magento\Framework\App\State' => ['arguments' => ['test name' => 'test value']], - 'Magento\Core\Model\Config\Modules' => [ + 'Magento\Config\Model\Config\Modules' => [ 'arguments' => ['test name' => 'test value'], 'plugins' => [ 'simple_modules_plugin' => [ 'sortOrder' => 10, 'disabled' => true, - 'instance' => 'Magento\Core\Model\Config\Modules\Plugin', + 'instance' => 'Magento\Config\Model\Config\Modules\Plugin', ], 'simple_modules_plugin_advanced' => [ 'sortOrder' => 0, - 'instance' => 'Magento\Core\Model\Config\Modules\PluginAdvanced', + 'instance' => 'Magento\Config\Model\Config\Modules\PluginAdvanced', ], 'overridden_plugin' => ['sortOrder' => 30, 'disabled' => true], ], diff --git a/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Config/Mapper/_files/simple_di_config.xml b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Config/Mapper/_files/simple_di_config.xml index 823fd9b38f6de60b756eafe7087cbebcc47e7986..d930f3dadf451c56bcaea24e5dab4060faba8e01 100644 --- a/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Config/Mapper/_files/simple_di_config.xml +++ b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Config/Mapper/_files/simple_di_config.xml @@ -16,12 +16,12 @@ </arguments> </type> <!--Arguments and plugins--> - <type name="Magento\Core\Model\Config\Modules"> + <type name="Magento\Config\Model\Config\Modules"> <arguments> <argument name="test name" xsi:type="string">test value</argument> </arguments> - <plugin name="simple_modules_plugin" type="Magento\Core\Model\Config\Modules\Plugin" disabled="true" sortOrder="10" /> - <plugin name="simple_modules_plugin_advanced" type="Magento\Core\Model\Config\Modules\PluginAdvanced" /> + <plugin name="simple_modules_plugin" type="Magento\Config\Model\Config\Modules\Plugin" disabled="true" sortOrder="10" /> + <plugin name="simple_modules_plugin_advanced" type="Magento\Config\Model\Config\Modules\PluginAdvanced" /> <plugin name="overridden_plugin" sortOrder="30" disabled="true" /> </type> <!--Unshared type--> diff --git a/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Relations/RuntimeTest.php b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Relations/RuntimeTest.php index 7309a4b1a67ba16f2c83524882f9427c6aedaf54..3fde1b24d33603ef8159914db3ec962de5c9299b 100644 --- a/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Relations/RuntimeTest.php +++ b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Relations/RuntimeTest.php @@ -3,6 +3,9 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ + +// @codingStandardsIgnoreFile + namespace Magento\Framework\ObjectManager\Test\Unit\Relations; require_once __DIR__ . '/../_files/Child.php'; @@ -36,4 +39,25 @@ class RuntimeTest extends \PHPUnit_Framework_TestCase ['Magento\Test\Di\Child', ['Magento\Test\Di\DiParent', 'Magento\Test\Di\ChildInterface']] ]; } + + /** + * @param $entity + * @expectedException \Magento\Framework\Exception + * @dataProvider nonExistentGeneratorsDataProvider + */ + public function testHasIfNonExists($entity) + { + $this->_model->has($entity); + } + + public function nonExistentGeneratorsDataProvider() + { + return [ + ['Magento\Test\Module\Model\Item\Factory'], + ['Magento\Test\Module\Model\Item\Proxy'], + ['Magento\Test\Module\Model\Item\Interceptor'], + ['Magento\Test\Module\Model\Item\Mapper'], + ['Magento\Test\Module\Model\Item\SearchResults'] + ]; + } } diff --git a/lib/internal/Magento/Framework/Phrase.php b/lib/internal/Magento/Framework/Phrase.php index 80dc48cac216579f9b412259683714f42a0bf2d0..02c4e0c063c63a36ae430ad59ac233d43b9417ac 100644 --- a/lib/internal/Magento/Framework/Phrase.php +++ b/lib/internal/Magento/Framework/Phrase.php @@ -17,21 +17,21 @@ class Phrase implements JsonSerializable * * @var RendererInterface */ - private static $_renderer; + private static $renderer; /** * String for rendering * * @var string */ - private $_text; + private $text; /** * Arguments for placeholder values * * @var array */ - private $_arguments; + private $arguments; /** * Set default Phrase renderer @@ -41,7 +41,7 @@ class Phrase implements JsonSerializable */ public static function setRenderer(RendererInterface $renderer) { - self::$_renderer = $renderer; + self::$renderer = $renderer; } /** @@ -51,7 +51,7 @@ class Phrase implements JsonSerializable */ public static function getRenderer() { - return self::$_renderer; + return self::$renderer; } /** @@ -62,8 +62,28 @@ class Phrase implements JsonSerializable */ public function __construct($text, array $arguments = []) { - $this->_text = (string)$text; - $this->_arguments = $arguments; + $this->text = (string)$text; + $this->arguments = $arguments; + } + + /** + * Get phrase base text + * + * @return string + */ + public function getText() + { + return $this->text; + } + + /** + * Get phrase message arguments + * + * @return array + */ + public function getArguments() + { + return $this->arguments; } /** @@ -73,7 +93,7 @@ class Phrase implements JsonSerializable */ public function render() { - return self::$_renderer ? self::$_renderer->render([$this->_text], $this->_arguments) : $this->_text; + return self::$renderer ? self::$renderer->render([$this->text], $this->arguments) : $this->text; } /** diff --git a/lib/internal/Magento/Framework/Pricing/Test/Unit/Adjustment/CollectionTest.php b/lib/internal/Magento/Framework/Pricing/Test/Unit/Adjustment/CollectionTest.php index 8c0e0812b5601c8fbbfc6866baab37a0131d66e1..96a4abb41e71b3cf0b92be5b493f23c02bb12fad 100644 --- a/lib/internal/Magento/Framework/Pricing/Test/Unit/Adjustment/CollectionTest.php +++ b/lib/internal/Magento/Framework/Pricing/Test/Unit/Adjustment/CollectionTest.php @@ -76,7 +76,7 @@ class CollectionTest extends \PHPUnit_Framework_TestCase $result = $collection->getItems(); - $this->assertEquals($expectedResult, array_keys($result)); + $this->assertEmpty(array_diff($expectedResult, array_keys($result))); } public function getItemsDataProvider() diff --git a/lib/internal/Magento/Framework/Reflection/DataObjectProcessor.php b/lib/internal/Magento/Framework/Reflection/DataObjectProcessor.php index c1d58952de1c9d4006c947a6fa34de1aeb427f48..2b9977d7355f565e808b15cc539c7c892f38afa6 100644 --- a/lib/internal/Magento/Framework/Reflection/DataObjectProcessor.php +++ b/lib/internal/Magento/Framework/Reflection/DataObjectProcessor.php @@ -8,7 +8,7 @@ namespace Magento\Framework\Reflection; use Magento\Framework\Phrase; use Magento\Framework\Api\AttributeValue; -use Magento\Framework\Api\ExtensibleDataInterface; +use Magento\Framework\Api\CustomAttributesDataInterface; use Magento\Framework\Api\SimpleDataObjectConverter; use Zend\Code\Reflection\ClassReflection; use Zend\Code\Reflection\MethodReflection; @@ -108,7 +108,7 @@ class DataObjectProcessor continue; } $key = SimpleDataObjectConverter::camelCaseToSnakeCase(substr($methodName, 3)); - if ($key === ExtensibleDataInterface::CUSTOM_ATTRIBUTES) { + if ($key === CustomAttributesDataInterface::CUSTOM_ATTRIBUTES) { $value = $this->convertCustomAttributes($value, $dataObjectType); } elseif (is_object($value) && !($value instanceof Phrase)) { $value = $this->buildOutputDataArray($value, $returnType); @@ -304,10 +304,7 @@ class DataObjectProcessor $isSuitableMethodType = !($method->isConstructor() || $method->isFinal() || $method->isStatic() || $method->isDestructor()); - $isExcludedMagicMethod = in_array( - $method->getName(), - ['__sleep', '__wakeup', '__clone'] - ); + $isExcludedMagicMethod = strpos($method->getName(), '__') === 0; return $isSuitableMethodType && !$isExcludedMagicMethod; } } diff --git a/lib/internal/Magento/Framework/Reflection/Test/Unit/TypeProcessorTest.php b/lib/internal/Magento/Framework/Reflection/Test/Unit/TypeProcessorTest.php index 56cd942eac6de82fab4b43f450ead4b7901e23a9..b2e1940f123b17a71d0f917fae11bf84ebcbc49b 100644 --- a/lib/internal/Magento/Framework/Reflection/Test/Unit/TypeProcessorTest.php +++ b/lib/internal/Magento/Framework/Reflection/Test/Unit/TypeProcessorTest.php @@ -3,6 +3,7 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ +// @codingStandardsIgnoreStart namespace Magento\Framework\Reflection\Test\Unit; use Zend\Code\Reflection\ClassReflection; @@ -174,7 +175,7 @@ class TypeProcessorTest extends \PHPUnit_Framework_TestCase /** * @expectedException \Magento\Framework\Exception\SerializationException - * @expectedExceptionMessage Invalid type for value :"1". Expected Type: "int[]". + * @expectedExceptionMessage Invalid type for value: "integer". Expected Type: "int[]". */ public function testProcessSimpleTypeInvalidType() { diff --git a/lib/internal/Magento/Framework/Reflection/TypeProcessor.php b/lib/internal/Magento/Framework/Reflection/TypeProcessor.php index 9087812959b597b446bce5eeb7021cae6c383780..7a2f5f2dd2f137d5996dfc130649842f1300388c 100644 --- a/lib/internal/Magento/Framework/Reflection/TypeProcessor.php +++ b/lib/internal/Magento/Framework/Reflection/TypeProcessor.php @@ -8,6 +8,7 @@ namespace Magento\Framework\Reflection; use Magento\Framework\Exception\SerializationException; use Zend\Code\Reflection\ClassReflection; use Zend\Code\Reflection\ParameterReflection; +use Magento\Framework\Phrase; /** * Type processor of config reader properties @@ -241,11 +242,17 @@ class TypeProcessor { $methodDocBlock = $methodReflection->getDocBlock(); if (!$methodDocBlock) { - throw new \InvalidArgumentException('Each getter must have description with @return annotation.'); + throw new \InvalidArgumentException( + "Each getter must have description with @return annotation. " + . "See {$methodReflection->getDeclaringClass()->getName()}::{$methodReflection->getName()}()" + ); } $returnAnnotations = $methodDocBlock->getTags('return'); if (empty($returnAnnotations)) { - throw new \InvalidArgumentException('Getter return type must be specified using @return annotation.'); + throw new \InvalidArgumentException( + "Getter return type must be specified using @return annotation. " + . "See {$methodReflection->getDeclaringClass()->getName()}::{$methodReflection->getName()}()" + ); } /** @var \Zend\Code\Reflection\DocBlock\Tag\ReturnTag $returnAnnotation */ $returnAnnotation = current($returnAnnotations); @@ -424,24 +431,30 @@ class TypeProcessor foreach (array_keys($value) as $key) { if ($value !== null && !settype($value[$key], $arrayItemType)) { throw new SerializationException( - SerializationException::TYPE_MISMATCH, - ['value' => $value, 'type' => $type] + new Phrase( + SerializationException::TYPE_MISMATCH, + ['value' => $value, 'type' => $type] + ) ); } } } elseif ($isArrayType && is_null($value)) { return null; } elseif (!$isArrayType && !is_array($value)) { - if ($value !== null && $type !== self::ANY_TYPE && !settype($value, $type)) { + if ($value !== null && $type !== self::ANY_TYPE && !$this->setType($value, $type)) { throw new SerializationException( - SerializationException::TYPE_MISMATCH, - ['value' => (string)$value, 'type' => $type] + new Phrase( + SerializationException::TYPE_MISMATCH, + ['value' => (string)$value, 'type' => $type] + ) ); } } else { throw new SerializationException( - SerializationException::TYPE_MISMATCH, - ['value' => (string)$value, 'type' => $type] + new Phrase( + SerializationException::TYPE_MISMATCH, + ['value' => gettype($value), 'type' => $type] + ) ); } return $value; @@ -496,6 +509,24 @@ class TypeProcessor return $methodName; } + /** + * Set value to a particular type + * + * @param mixed $value + * @param string $type + * @return true on successful type cast + */ + protected function setType(&$value, $type) + { + // settype doesn't work for boolean string values. + // ex: custom_attributes passed from SOAP client can have boolean values as string + if ($type == 'bool' || $type == 'boolean') { + $value = filter_var($value, FILTER_VALIDATE_BOOLEAN); + return true; + } + return settype($value, $type); + } + /** * Find the setter method name for a property from the given class * diff --git a/lib/internal/Magento/Framework/Search/Dynamic/Algorithm/Repository.php b/lib/internal/Magento/Framework/Search/Dynamic/Algorithm/Repository.php index 10d9f65449c7c4d544d79b6e5f45cf9270f1c8f9..68e3fdea45acb09d8fe798133014d7c89c7339fb 100644 --- a/lib/internal/Magento/Framework/Search/Dynamic/Algorithm/Repository.php +++ b/lib/internal/Magento/Framework/Search/Dynamic/Algorithm/Repository.php @@ -49,7 +49,9 @@ class Repository { if (!isset($this->instances[$algorithmType])) { if (!isset($this->algorithms[$algorithmType])) { - throw new LocalizedException($algorithmType . ' was not found in algorithms'); + throw new LocalizedException( + new \Magento\Framework\Phrase('%1 was not found in algorithms', [$algorithmType]) + ); } $className = $this->algorithms[$algorithmType]; @@ -57,7 +59,10 @@ class Repository if (!$model instanceof AlgorithmInterface) { throw new LocalizedException( - $className . ' doesn\'t extends \Magento\Framework\Search\Dynamic\Algorithm\AlgorithmInterface' + new \Magento\Framework\Phrase( + '%1 doesn\'t extends \Magento\Framework\Search\Dynamic\Algorithm\AlgorithmInterface', + [$className] + ) ); } $this->instances[$algorithmType] = $model; diff --git a/lib/internal/Magento/Framework/Search/Request/Cleaner.php b/lib/internal/Magento/Framework/Search/Request/Cleaner.php index b3182007c3a3d9fe7617654a8f39e803b201bdc2..aa547e211418654f91e650529f48cb625d223e07 100644 --- a/lib/internal/Magento/Framework/Search/Request/Cleaner.php +++ b/lib/internal/Magento/Framework/Search/Request/Cleaner.php @@ -7,6 +7,7 @@ namespace Magento\Framework\Search\Request; use Magento\Framework\Exception\StateException; use Magento\Framework\Search\Request\Aggregation\StatusInterface as AggregationStatus; +use Magento\Framework\Phrase; class Cleaner { @@ -73,7 +74,9 @@ class Cleaner if (!isset($this->requestData['queries'][$queryName])) { throw new \Exception('Query ' . $queryName . ' does not exist'); } elseif (in_array($queryName, $this->mappedQueries)) { - throw new StateException('Cycle found. Query %1 already used in request hierarchy', [$queryName]); + throw new StateException( + new Phrase('Cycle found. Query %1 already used in request hierarchy', [$queryName]) + ); } $this->mappedQueries[] = $queryName; $query = $this->requestData['queries'][$queryName]; @@ -139,7 +142,9 @@ class Cleaner if (!isset($this->requestData['filters'][$filterName])) { throw new \Exception('Filter ' . $filterName . ' does not exist'); } elseif (in_array($filterName, $this->mappedFilters)) { - throw new StateException('Cycle found. Filter %1 already used in request hierarchy', [$filterName]); + throw new StateException( + new Phrase('Cycle found. Filter %1 already used in request hierarchy', [$filterName]) + ); } $this->mappedFilters[] = $filterName; $filter = $this->requestData['filters'][$filterName]; diff --git a/lib/internal/Magento/Framework/Search/Request/Mapper.php b/lib/internal/Magento/Framework/Search/Request/Mapper.php index 488880d07a00053431c277993b0715cc95f01b69..e2dcbef74cda6ab201ed6bdd7dc6b3dcda916cd7 100644 --- a/lib/internal/Magento/Framework/Search/Request/Mapper.php +++ b/lib/internal/Magento/Framework/Search/Request/Mapper.php @@ -7,6 +7,7 @@ namespace Magento\Framework\Search\Request; use Magento\Framework\Exception\StateException; use Magento\Framework\Search\Request\Query\Filter; +use Magento\Framework\Phrase; /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) @@ -106,7 +107,9 @@ class Mapper if (!isset($this->queries[$queryName])) { throw new \Exception('Query ' . $queryName . ' does not exist'); } elseif (in_array($queryName, $this->mappedQueries)) { - throw new StateException('Cycle found. Query %1 already used in request hierarchy', [$queryName]); + throw new StateException( + new Phrase('Cycle found. Query %1 already used in request hierarchy', [$queryName]) + ); } $this->mappedQueries[] = $queryName; $query = $this->queries[$queryName]; @@ -173,7 +176,9 @@ class Mapper if (!isset($this->filters[$filterName])) { throw new \Exception('Filter ' . $filterName . ' does not exist'); } elseif (in_array($filterName, $this->mappedFilters)) { - throw new StateException('Cycle found. Filter %1 already used in request hierarchy', [$filterName]); + throw new StateException( + new Phrase('Cycle found. Filter %1 already used in request hierarchy', [$filterName]) + ); } $this->mappedFilters[] = $filterName; $filter = $this->filters[$filterName]; @@ -286,7 +291,7 @@ class Mapper $allElements = array_keys($elements); $notUsedElements = implode(', ', array_diff($allElements, $mappedElements)); if (!empty($notUsedElements)) { - throw new StateException($errorMessage, [$notUsedElements]); + throw new StateException(new Phrase($errorMessage, [$notUsedElements])); } } @@ -348,7 +353,8 @@ class Mapper ); break; default: - throw new StateException('Invalid bucket type'); + throw new StateException(new Phrase('Invalid bucket type')); + break; } $buckets[] = $bucket; } diff --git a/lib/internal/Magento/Framework/Session/SaveHandler/DbTable.php b/lib/internal/Magento/Framework/Session/SaveHandler/DbTable.php index 5d05e5ffbe9c388015ef853c1ccee955b30eae87..b9e9b8a27aa94186ac3a9bb24522d571ecfa3ace 100644 --- a/lib/internal/Magento/Framework/Session/SaveHandler/DbTable.php +++ b/lib/internal/Magento/Framework/Session/SaveHandler/DbTable.php @@ -31,7 +31,7 @@ class DbTable extends \SessionHandler */ public function __construct(\Magento\Framework\App\Resource $resource) { - $this->_sessionTable = $resource->getTableName('core_session'); + $this->_sessionTable = $resource->getTableName('session'); $this->_write = $resource->getConnection('core_write'); $this->checkConnection(); } diff --git a/lib/internal/Magento/Framework/Simplexml/Config.php b/lib/internal/Magento/Framework/Simplexml/Config.php index f94ec099c6fc5124217d1fbd52b3a3fae5b95d1c..4e1265ebd4a4c180d7bbc4a8b84b0334b5b1676a 100644 --- a/lib/internal/Magento/Framework/Simplexml/Config.php +++ b/lib/internal/Magento/Framework/Simplexml/Config.php @@ -489,10 +489,9 @@ class Config * @param \DOMNode $dom * @return bool */ - public function loadDom($dom) + public function loadDom(\DOMNode $dom) { $xml = simplexml_import_dom($dom, $this->_elementClass); - if ($xml) { $this->_xml = $xml; return true; diff --git a/lib/internal/Magento/Framework/Simplexml/Test/Unit/ConfigTest.php b/lib/internal/Magento/Framework/Simplexml/Test/Unit/ConfigTest.php index f0842c5a78b122980e895ff077f1a57da621c9b8..1b690780cccd7fdaad65bb33d818aca0113d7662 100644 --- a/lib/internal/Magento/Framework/Simplexml/Test/Unit/ConfigTest.php +++ b/lib/internal/Magento/Framework/Simplexml/Test/Unit/ConfigTest.php @@ -42,17 +42,13 @@ class ConfigTest extends \PHPUnit_Framework_TestCase $this->assertFalse($this->config->loadString('')); $this->assertTrue($this->config->loadString($xml)); $this->assertXmlStringEqualsXmlString($xml, $this->config->getXmlString()); - $this->setExpectedException( - '\Exception', - 'simplexml_load_string(): Entity: line 1: parser error : Start tag expected,' - ); - $this->assertFalse($this->config->loadString('wrong_path')); } public function testLoadDom() { - $this->config->loadString('<?xml version="1.0"?><config><node>1</node></config>'); - $this->assertTrue($this->config->loadDom($this->config->getNode())); + $dom = new \DOMDocument(); + $dom->loadXML('<?xml version="1.0"?><config><node>1</node></config>'); + $this->assertTrue($this->config->loadDom($dom)); } public function testGetNode() diff --git a/lib/internal/Magento/Framework/Stdlib/Cookie/CookieSizeLimitReachedException.php b/lib/internal/Magento/Framework/Stdlib/Cookie/CookieSizeLimitReachedException.php index a481b6cbb4b3097f2775f8f5412bc28e8d3234d6..5f3ec17ff6a771daaebb2634b659e8ca3ddc03d1 100644 --- a/lib/internal/Magento/Framework/Stdlib/Cookie/CookieSizeLimitReachedException.php +++ b/lib/internal/Magento/Framework/Stdlib/Cookie/CookieSizeLimitReachedException.php @@ -3,7 +3,6 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ - namespace Magento\Framework\Stdlib\Cookie; use Magento\Framework\Exception\LocalizedException; diff --git a/lib/internal/Magento/Framework/Stdlib/Cookie/FailureToSendException.php b/lib/internal/Magento/Framework/Stdlib/Cookie/FailureToSendException.php index d215c3a3a47d71756b2977d31e6a80029aec44d3..81ff3e90f0cc050b565862ac67a3105c0d2ce724 100644 --- a/lib/internal/Magento/Framework/Stdlib/Cookie/FailureToSendException.php +++ b/lib/internal/Magento/Framework/Stdlib/Cookie/FailureToSendException.php @@ -3,7 +3,6 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ - namespace Magento\Framework\Stdlib\Cookie; use Magento\Framework\Exception\LocalizedException; diff --git a/lib/internal/Magento/Framework/Stdlib/Cookie/PhpCookieManager.php b/lib/internal/Magento/Framework/Stdlib/Cookie/PhpCookieManager.php index c555946a187b2b38c9bea4c6303d1687e19ad949..611683a912530eecd88517db7fc1ff40c8ed5b28 100644 --- a/lib/internal/Magento/Framework/Stdlib/Cookie/PhpCookieManager.php +++ b/lib/internal/Magento/Framework/Stdlib/Cookie/PhpCookieManager.php @@ -8,6 +8,7 @@ namespace Magento\Framework\Stdlib\Cookie; use Magento\Framework\Exception\InputException; use Magento\Framework\Stdlib\CookieManagerInterface; +use Magento\Framework\Phrase; /** * CookieManager helps manage the setting, retrieving and deleting of cookies. @@ -125,9 +126,13 @@ class PhpCookieManager implements CookieManagerInterface if (!$phpSetcookieSuccess) { $params['name'] = $name; if ($value == '') { - throw new FailureToSendException('Unable to delete the cookie with cookieName = %name', $params); + throw new FailureToSendException( + new Phrase('Unable to delete the cookie with cookieName = %name', $params) + ); } else { - throw new FailureToSendException('Unable to send the cookie with cookieName = %name', $params); + throw new FailureToSendException( + new Phrase('Unable to send the cookie with cookieName = %name', $params) + ); } } } @@ -160,7 +165,9 @@ class PhpCookieManager implements CookieManagerInterface { if ($name == '' || preg_match("/[=,; \t\r\n\013\014]/", $name)) { throw new InputException( - 'Cookie name cannot be empty and cannot contain these characters: =,; \\t\\r\\n\\013\\014' + new Phrase( + 'Cookie name cannot be empty and cannot contain these characters: =,; \\t\\r\\n\\013\\014' + ) ); } @@ -174,17 +181,19 @@ class PhpCookieManager implements CookieManagerInterface if ($numCookies > PhpCookieManager::MAX_NUM_COOKIES) { throw new CookieSizeLimitReachedException( - 'Unable to send the cookie. Maximum number of cookies would be exceeded.' + new Phrase('Unable to send the cookie. Maximum number of cookies would be exceeded.') ); } if ($sizeOfCookie > PhpCookieManager::MAX_COOKIE_SIZE) { throw new CookieSizeLimitReachedException( - "Unable to send the cookie. Size of '%name' is %size bytes.", - [ - 'name' => $name, - 'size' => $sizeOfCookie, - ] + new Phrase( + 'Unable to send the cookie. Size of \'%name\' is %size bytes.', + [ + 'name' => $name, + 'size' => $sizeOfCookie, + ] + ) ); } } diff --git a/lib/internal/Magento/Framework/Test/Unit/PhraseTest.php b/lib/internal/Magento/Framework/Test/Unit/PhraseTest.php old mode 100644 new mode 100755 index 3cae817ba9d3e88f9e84b2e00dc1c1033a04ee07..79a257b4ff77ceb505138f1cc486499c9ee06ca3 --- a/lib/internal/Magento/Framework/Test/Unit/PhraseTest.php +++ b/lib/internal/Magento/Framework/Test/Unit/PhraseTest.php @@ -5,91 +5,123 @@ */ namespace Magento\Framework\Test\Unit; +use \Magento\Framework\Phrase; + class PhraseTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Framework\Phrase + * @var \Magento\Framework\Phrase\RendererInterface */ - protected $phrase; + protected $defaultRenderer; /** - * @var \Magento\Framework\Phrase\RendererInterface|PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Phrase\RendererInterface|\PHPUnit_Framework_MockObject_MockObject */ - protected $renderer; + protected $rendererMock; + /** + * SetUp method + * + * @return void + */ protected function setUp() { - $this->renderer = $this->getMock('Magento\Framework\Phrase\RendererInterface'); - \Magento\Framework\Phrase::setRenderer($this->renderer); + $this->defaultRenderer = Phrase::getRenderer(); + $this->rendererMock = $this->getMockBuilder('Magento\Framework\Phrase\RendererInterface') + ->getMock(); } + /** + * Tear down + * + * @return void + */ protected function tearDown() { - $this->removeRendererFromPhrase(); - \Magento\Framework\Phrase::setRenderer(new \Magento\Framework\Phrase\Renderer\Placeholder()); + Phrase::setRenderer($this->defaultRenderer); } + /** + * Test rendering + * + * @return void + */ public function testRendering() { $text = 'some text'; $arguments = ['arg1', 'arg2']; $result = 'rendered text'; - $this->phrase = new \Magento\Framework\Phrase($text, $arguments); - - $this->renderer->expects( - $this->once() - )->method( - 'render' - )->with( - [$text], - $arguments - )->will( - $this->returnValue($result) - ); - - $this->assertEquals($result, $this->phrase->render()); - } + $phrase = new Phrase($text, $arguments); + Phrase::setRenderer($this->rendererMock); - public function testRenderingWithoutRenderer() - { - $this->removeRendererFromPhrase(); - $result = 'some text'; - $this->phrase = new \Magento\Framework\Phrase($result); + $this->rendererMock->expects($this->once()) + ->method('render') + ->with([$text], $arguments) + ->willReturn($result); - $this->assertEquals($result, $this->phrase->render()); + $this->assertEquals($result, $phrase->render()); } + /** + * Test defers rendering + * + * @return void + */ public function testDefersRendering() { - $this->renderer->expects($this->never())->method('render'); - $this->phrase = new \Magento\Framework\Phrase('some text'); + $this->rendererMock->expects($this->never()) + ->method('render'); + + new Phrase('some text'); } + /** + * Test that to string is alias to render + * + * @return void + */ public function testThatToStringIsAliasToRender() { $text = 'some text'; $arguments = ['arg1', 'arg2']; $result = 'rendered text'; - $this->phrase = new \Magento\Framework\Phrase($text, $arguments); - - $this->renderer->expects( - $this->once() - )->method( - 'render' - )->with( - [$text], - $arguments - )->will( - $this->returnValue($result) - ); - - $this->assertEquals($result, (string) $this->phrase); + $phrase = new Phrase($text, $arguments); + Phrase::setRenderer($this->rendererMock); + + $this->rendererMock->expects($this->once()) + ->method('render') + ->with([$text], $arguments) + ->willReturn($result); + + $this->assertEquals($result, (string)$phrase); + } + + /** + * Test get text + * + * @return void + */ + public function testGetText() + { + $text = 'some text'; + $phrase = new Phrase($text); + + $this->assertEquals($text, $phrase->getText()); } - protected function removeRendererFromPhrase() + /** + * Test get arguments + * + * @return void + */ + public function testGetArguments() { - $property = new \ReflectionProperty('Magento\Framework\Phrase', '_renderer'); - $property->setAccessible(true); - $property->setValue($this->phrase, null); + $text = 'some text'; + $arguments = ['arg1', 'arg2']; + $phrase1 = new Phrase($text); + $phrase2 = new Phrase($text, $arguments); + + $this->assertEquals([], $phrase1->getArguments()); + $this->assertEquals($arguments, $phrase2->getArguments()); } } diff --git a/lib/internal/Magento/Framework/Test/Unit/Translate/Js/ConfigTest.php b/lib/internal/Magento/Framework/Test/Unit/Translate/Js/ConfigTest.php new file mode 100644 index 0000000000000000000000000000000000000000..b2dcba665cde41cda8ff2f05642d8c0761d8ca1c --- /dev/null +++ b/lib/internal/Magento/Framework/Test/Unit/Translate/Js/ConfigTest.php @@ -0,0 +1,36 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Framework\Test\Unit\Translate\Js; + +use Magento\Framework\Translate\Js\Config; + +/** + * Class ConfigTest + */ +class ConfigTest extends \PHPUnit_Framework_TestCase +{ + /** + * @return void + */ + public function testDefault() + { + $config = new Config(); + $this->assertFalse($config->dictionaryEnabled()); + $this->assertNull($config->getDictionaryFileName()); + } + + /** + * @return void + */ + public function testCustom() + { + $path = 'path'; + $config = new Config(true, $path); + $this->assertTrue($config->dictionaryEnabled()); + $this->assertEquals($path, $config->getDictionaryFileName()); + } +} diff --git a/lib/internal/Magento/Framework/TestFramework/Test/Unit/Unit/Helper/ObjectManagerTest.php b/lib/internal/Magento/Framework/TestFramework/Test/Unit/Unit/Helper/ObjectManagerTest.php index 58515be62b53e0db573554ee009d1b912819dcd4..d4e50811d7d92598df1588fa0af35359b2879a35 100644 --- a/lib/internal/Magento/Framework/TestFramework/Test/Unit/Unit/Helper/ObjectManagerTest.php +++ b/lib/internal/Magento/Framework/TestFramework/Test/Unit/Unit/Helper/ObjectManagerTest.php @@ -3,6 +3,9 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ + +// @codingStandardsIgnoreFile + namespace Magento\Framework\TestFramework\Test\Unit\Unit\Helper; class ObjectManagerTest extends \PHPUnit_Framework_TestCase @@ -76,7 +79,7 @@ class ObjectManagerTest extends \PHPUnit_Framework_TestCase $this->assertAttributeInstanceOf($propertyType, '_' . $propertyName, $model); } - /** @var $resourceMock \Magento\Core\Model\Resource\Resource */ + /** @var $resourceMock \Magento\Framework\Module\Resource */ $resourceMock = $this->getMock( 'Magento\Framework\Module\Resource', ['_getReadAdapter', 'getIdFieldName', '__sleep', '__wakeup'], diff --git a/lib/internal/Magento/Framework/Translate/Js/Config.php b/lib/internal/Magento/Framework/Translate/Js/Config.php new file mode 100644 index 0000000000000000000000000000000000000000..17ec1bbba4af1057cf68070bbf0a0640c064641f --- /dev/null +++ b/lib/internal/Magento/Framework/Translate/Js/Config.php @@ -0,0 +1,56 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Framework\Translate\Js; + +/** + * Js Translation config + */ +class Config +{ + /** + * Should the framework generate dictionary file + * + * @var bool + */ + protected $dictionaryEnabled; + + /** + * Name of dictionary json file + * + * @var string + */ + protected $dictionaryFileName; + + /** + * @param bool $dictionaryEnabled + * @param string $dictionaryFileName + */ + public function __construct($dictionaryEnabled = false, $dictionaryFileName = null) + { + $this->dictionaryEnabled = $dictionaryEnabled; + $this->dictionaryFileName = $dictionaryFileName; + } + + /** + * Should the framework generate dictionary file + * + * @return bool + */ + public function dictionaryEnabled() + { + return $this->dictionaryEnabled; + } + + /** + * Name of dictionary json file + * + * @return string + */ + public function getDictionaryFileName() + { + return $this->dictionaryFileName; + } +} diff --git a/lib/internal/Magento/Framework/Validator/ValidatorException.php b/lib/internal/Magento/Framework/Validator/Exception.php similarity index 78% rename from lib/internal/Magento/Framework/Validator/ValidatorException.php rename to lib/internal/Magento/Framework/Validator/Exception.php index fe46e24b83c92ac3bef04776d6ae1c56c642588a..ba8e1dfe2eaebd1c9e42a5399d1ffb9dac80f4ba 100644 --- a/lib/internal/Magento/Framework/Validator/ValidatorException.php +++ b/lib/internal/Magento/Framework/Validator/Exception.php @@ -7,10 +7,15 @@ */ namespace Magento\Framework\Validator; +use Magento\Framework\Exception\InputException; +use Magento\Framework\Phrase; +use Magento\Framework\Message\AbstractMessage; +use Magento\Framework\Message\Error; + /** * Exception to be thrown when an validation data is failed */ -class ValidatorException extends \Magento\Framework\Exception\InputException +class Exception extends InputException { /** * @var array @@ -20,14 +25,12 @@ class ValidatorException extends \Magento\Framework\Exception\InputException /** * Constructor * - * @param string $message - * @param [] $params + * @param \Magento\Framework\Phrase $phrase * @param \Exception $cause * @param array $messages Validation error messages */ public function __construct( - $message = self::DEFAULT_MESSAGE, - $params = [], + Phrase $phrase = null, \Exception $cause = null, array $messages = [] ) { @@ -39,11 +42,12 @@ class ValidatorException extends \Magento\Framework\Exception\InputException $message .= PHP_EOL; } $message .= $propertyMessage; - $this->addMessage(new \Magento\Framework\Message\Error($propertyMessage)); + $this->addMessage(new Error($propertyMessage)); } } + $phrase = new Phrase($message); } - parent::__construct($message, $params, $cause); + parent::__construct($phrase, $cause); } /** @@ -52,7 +56,7 @@ class ValidatorException extends \Magento\Framework\Exception\InputException * @param \Magento\Framework\Message\AbstractMessage $message * @return $this */ - public function addMessage(\Magento\Framework\Message\AbstractMessage $message) + public function addMessage(AbstractMessage $message) { if (!isset($this->messages[$message->getType()])) { $this->messages[$message->getType()] = []; diff --git a/lib/internal/Magento/Framework/Validator/Test/Unit/ExceptionTest.php b/lib/internal/Magento/Framework/Validator/Test/Unit/ExceptionTest.php index 37af5112d911d67994acc8fddc1d9395d1797309..1db22e3fdbdfed4ceb3d558c0b9ce5a299805293 100644 --- a/lib/internal/Magento/Framework/Validator/Test/Unit/ExceptionTest.php +++ b/lib/internal/Magento/Framework/Validator/Test/Unit/ExceptionTest.php @@ -6,23 +6,21 @@ namespace Magento\Framework\Validator\Test\Unit; -use Magento\Framework\Exception\InputException; - /** - * Test case for \Magento\Framework\Validator\ValidatorException + * Test case for \Magento\Framework\Validator\Exception */ class ExceptionTest extends \PHPUnit_Framework_TestCase { /** - * Testing \Magento\Framework\Validator\ValidatorException::getMessage + * Testing \Magento\Framework\Validator\Exception::getMessage + * @return void */ public function testGetMessage() { $expectedMessage = 'error1' . PHP_EOL . 'error2' . PHP_EOL . 'error3'; $messages = ['field1' => ['error1', 'error2'], 'field2' => ['error3']]; - $exception = new \Magento\Framework\Validator\ValidatorException( - InputException::DEFAULT_MESSAGE, - [], + $exception = new \Magento\Framework\Validator\Exception( + null, null, $messages ); diff --git a/lib/internal/Magento/Framework/View/Asset/Repository.php b/lib/internal/Magento/Framework/View/Asset/Repository.php index 4e46b91fba0d65cbbdcafd456b9b6efcb75b4433..fda21b7564074f7412b7430e9927ddef9a64e1bf 100644 --- a/lib/internal/Magento/Framework/View/Asset/Repository.php +++ b/lib/internal/Magento/Framework/View/Asset/Repository.php @@ -152,7 +152,7 @@ class Repository $module = $params['module']; } $isSecure = isset($params['_secure']) ? (bool) $params['_secure'] : null; - $themePath = $this->design->getThemePath($params['themeModel']); + $themePath = isset($params['theme']) ? $params['theme'] : $this->design->getThemePath($params['themeModel']); $context = $this->getFallbackContext( UrlInterface::URL_TYPE_STATIC, $isSecure, diff --git a/lib/internal/Magento/Framework/View/Asset/Source.php b/lib/internal/Magento/Framework/View/Asset/Source.php index eed8d15e584e34ca9637a3288b0047660f5da014..29d7d4a6af02c803a18b8a27fdf0e2279b22e1d8 100644 --- a/lib/internal/Magento/Framework/View/Asset/Source.php +++ b/lib/internal/Magento/Framework/View/Asset/Source.php @@ -130,9 +130,6 @@ class Source private function preProcess(LocalInterface $asset) { $sourceFile = $this->findSourceFile($asset); - if (!$sourceFile) { - return false; - } $dirCode = DirectoryList::ROOT; $path = $this->rootDir->getRelativePath($sourceFile); $cacheId = $path . ':' . $asset->getPath(); @@ -140,6 +137,7 @@ class Source if ($cached) { return unserialize($cached); } + $chain = $this->chainFactory->create( [ 'asset' => $asset, diff --git a/lib/internal/Magento/Framework/View/Layout/GeneratorPool.php b/lib/internal/Magento/Framework/View/Layout/GeneratorPool.php index e28b1dbb5605a45846bbbc6fae4172a53a96ad58..b602da334f4fd47d67ea4fc374eb2cd0415732be 100644 --- a/lib/internal/Magento/Framework/View/Layout/GeneratorPool.php +++ b/lib/internal/Magento/Framework/View/Layout/GeneratorPool.php @@ -31,21 +31,29 @@ class GeneratorPool */ protected $scopeResolver; + /** + * @var \Psr\Log\LoggerInterface + */ + protected $logger; + /** * @param ScheduledStructure\Helper $helper * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Framework\App\ScopeResolverInterface $scopeResolver + * @param \Psr\Log\LoggerInterface $logger * @param array $generators */ public function __construct( ScheduledStructure\Helper $helper, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Framework\App\ScopeResolverInterface $scopeResolver, + \Psr\Log\LoggerInterface $logger, array $generators = null ) { $this->helper = $helper; $this->scopeConfig = $scopeConfig; $this->scopeResolver = $scopeResolver; + $this->logger = $logger; $this->addGenerators($generators); } @@ -196,8 +204,13 @@ class GeneratorPool if (!$alias && false === $structure->getChildId($destination, $childAlias)) { $alias = $childAlias; } - $structure->unsetChild($element, $alias)->setAsChild($element, $destination, $alias); - $structure->reorderChildElement($destination, $element, $siblingName, $isAfter); + $structure->unsetChild($element, $alias); + try { + $structure->setAsChild($element, $destination, $alias); + $structure->reorderChildElement($destination, $element, $siblingName, $isAfter); + } catch (\OutOfBoundsException $e) { + $this->logger->critical('Broken reference: '. $e->getMessage()); + } return $this; } } diff --git a/lib/internal/Magento/Framework/View/Layout/PageType/Config/SchemaLocator.php b/lib/internal/Magento/Framework/View/Layout/PageType/Config/SchemaLocator.php index 8c3987f63f9e7799f85d23191381bb8fdcfe702a..6d65479e651389b58d854843afe3a687bee0ca3a 100644 --- a/lib/internal/Magento/Framework/View/Layout/PageType/Config/SchemaLocator.php +++ b/lib/internal/Magento/Framework/View/Layout/PageType/Config/SchemaLocator.php @@ -18,12 +18,10 @@ class SchemaLocator implements \Magento\Framework\Config\SchemaLocatorInterface /** * Constructor - * - * @param \Magento\Framework\Module\Dir\Reader $moduleReader */ - public function __construct(\Magento\Framework\Module\Dir\Reader $moduleReader) + public function __construct() { - $this->_schema = $moduleReader->getModuleDir('etc', 'Magento_Core') . '/page_types.xsd'; + $this->_schema = realpath(__DIR__ . '/../../etc/page_types.xsd'); } /** diff --git a/lib/internal/Magento/Framework/View/Layout/Proxy.php b/lib/internal/Magento/Framework/View/Layout/Proxy.php index 697b16a908ee9d9e27ee9937eee4274ec1db7641..8c399f4e4161a7f847b4f22db49e7e97e8528ef2 100644 --- a/lib/internal/Magento/Framework/View/Layout/Proxy.php +++ b/lib/internal/Magento/Framework/View/Layout/Proxy.php @@ -847,7 +847,7 @@ class Proxy extends \Magento\Framework\View\Layout * @param \DOMNode $dom * @return bool */ - public function loadDom($dom) + public function loadDom(\DOMNode $dom) { return $this->getSubject()->loadDom($dom); } diff --git a/app/code/Magento/Core/etc/page_types.xsd b/lib/internal/Magento/Framework/View/Layout/etc/page_types.xsd similarity index 100% rename from app/code/Magento/Core/etc/page_types.xsd rename to lib/internal/Magento/Framework/View/Layout/etc/page_types.xsd diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Asset/SourceTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Asset/SourceTest.php index 5668a0dde6b2b398e91445ec902d22dae57adc04..4db38ebb9c55a2e78dd179a4e8ff94d25b3c1620 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Asset/SourceTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Asset/SourceTest.php @@ -116,24 +116,6 @@ class SourceTest extends \PHPUnit_Framework_TestCase ); } - public function testGetFileNoOriginalFile() - { - $this->viewFileResolution->expects($this->once()) - ->method('getFile') - ->with('frontend', $this->theme, 'en_US', 'some/file.ext', 'Magento_Module') - ->will($this->returnValue(false)); - $this->assertFalse($this->object->getFile($this->getAsset())); - } - - public function testGetFileNoOriginalFileBasic() - { - $this->staticDirRead->expects($this->once()) - ->method('getAbsolutePath') - ->with('some/file.ext') - ->will($this->returnValue(false)); - $this->assertFalse($this->object->getFile($this->getAsset(false))); - } - public function testGetFileCached() { $root = '/root/some/file.ext'; diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Design/Fallback/RulePoolTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Design/Fallback/RulePoolTest.php index c2f66aa9a9c430073d48f6c5c477e205f5953400..a4121826604aa11e55f5697190f0847aa5f6a0a9 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Design/Fallback/RulePoolTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Design/Fallback/RulePoolTest.php @@ -3,6 +3,9 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ + +// @codingStandardsIgnoreFile + namespace Magento\Framework\View\Test\Unit\Design\Fallback; use \Magento\Framework\View\Design\Fallback\RulePool; @@ -229,12 +232,12 @@ class RulePoolTest extends \PHPUnit_Framework_TestCase ], 'template, non-modular-magento-core' => [ \Magento\Framework\View\Design\Fallback\RulePool::TYPE_TEMPLATE_FILE, - ['namespace' => 'Magento', 'module' => 'Core'], + ['namespace' => 'Magento', 'module' => 'Theme'], [ - DirectoryList::THEMES . '/area/current_theme_path/Magento_Core/templates', - DirectoryList::THEMES . '/area/parent_theme_path/Magento_Core/templates', - DirectoryList::MODULES . '/Magento/Core/view/area/templates', - DirectoryList::MODULES . '/Magento/Core/view/base/templates', + DirectoryList::THEMES . '/area/current_theme_path/Magento_Theme/templates', + DirectoryList::THEMES . '/area/parent_theme_path/Magento_Theme/templates', + DirectoryList::MODULES . '/Magento/Theme/view/area/templates', + DirectoryList::MODULES . '/Magento/Theme/view/base/templates', ], ], diff --git a/app/code/Magento/Core/Test/Unit/Model/DesignLoaderTest.php b/lib/internal/Magento/Framework/View/Test/Unit/DesignLoaderTest.php similarity index 95% rename from app/code/Magento/Core/Test/Unit/Model/DesignLoaderTest.php rename to lib/internal/Magento/Framework/View/Test/Unit/DesignLoaderTest.php index 4d4a994c2e5d5b654bdab87b15fcf97c159c211a..b3d0f530171683d28eaaf37f2bc032a7cee50a70 100644 --- a/app/code/Magento/Core/Test/Unit/Model/DesignLoaderTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/DesignLoaderTest.php @@ -3,7 +3,10 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Core\Test\Unit\Model; + +// @codingStandardsIgnoreFile + +namespace Magento\Framework\View\Test\Unit; class DesignLoaderTest extends \PHPUnit_Framework_TestCase { diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Element/AbstractBlockTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Element/AbstractBlockTest.php index eed898b3cd0c4d601da624dc725e799b983ff3d3..f187f63c647f09cdcf36f6075368da90248905f3 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Element/AbstractBlockTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Element/AbstractBlockTest.php @@ -3,6 +3,9 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ + +// @codingStandardsIgnoreFile + namespace Magento\Framework\View\Test\Unit\Element; class AbstractBlockTest extends \PHPUnit_Framework_TestCase @@ -64,7 +67,7 @@ class AbstractBlockTest extends \PHPUnit_Framework_TestCase )->method( 'getVarValue' )->with( - 'Magento_Core', + 'Magento_Theme', 'v1' )->will( $this->returnValue('one') @@ -80,7 +83,7 @@ class AbstractBlockTest extends \PHPUnit_Framework_TestCase $block = $this->getMockForAbstractClass( 'Magento\Framework\View\Element\AbstractBlock', $helper->getConstructArguments('Magento\Framework\View\Element\AbstractBlock', $params), - uniqid('Magento\\Core\\Block\\AbstractBlock\\') + uniqid('Magento\\Theme\\Block\\AbstractBlock\\') ); $this->assertEquals('one', $block->getVar('v1')); diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Layout/GeneratorPoolTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Layout/GeneratorPoolTest.php index f9c272ffaf9df7bd35ebdaf49e15023f09fbeeb9..154ff37e00f0a408aa602dd7cfcac1eaf42c07d6 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Layout/GeneratorPoolTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Layout/GeneratorPoolTest.php @@ -39,21 +39,14 @@ class GeneratorPoolTest extends \PHPUnit_Framework_TestCase */ protected $structureMock; - /** - * @var \Magento\Framework\App\Config\ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject - */ - protected $scopeConfigMock; - - /** - * @var \Magento\Framework\App\ScopeResolverInterface|\PHPUnit_Framework_MockObject_MockObject - */ - protected $scopeResolverMock; - /** * @var GeneratorPool */ protected $model; + /** + * @return void + */ protected function setUp() { // ScheduledStructure @@ -79,18 +72,13 @@ class GeneratorPoolTest extends \PHPUnit_Framework_TestCase ->disableOriginalConstructor() ->getMock(); - $this->scopeConfigMock = $this->getMockBuilder('Magento\Framework\App\Config\ScopeConfigInterface') - ->disableOriginalConstructor() - ->getMock(); - $this->scopeResolverMock = $this->getMockBuilder('Magento\Framework\App\ScopeResolverInterface') - ->disableOriginalConstructor() - ->getMock(); - - $this->model = new GeneratorPool( - $this->helperMock, - $this->scopeConfigMock, - $this->scopeResolverMock, - $this->getGeneratorsMocks() + $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); + $this->model = $helper->getObject( + 'Magento\Framework\View\Layout\GeneratorPool', + [ + 'helper' => $this->helperMock, + 'generators' => $this->getGeneratorsMocks() + ] ); } @@ -110,6 +98,9 @@ class GeneratorPoolTest extends \PHPUnit_Framework_TestCase } /** + * @param array $schedule + * @param array $expectedSchedule + * @return void * @dataProvider processDataProvider */ public function testProcess($schedule, $expectedSchedule) diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Layout/Reader/BlockTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Layout/Reader/BlockTest.php index 6b2719e088bf574f033352963bfc63cc363e1674..0e5c9ec84d8957895337051890d256bccda9431b 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Layout/Reader/BlockTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Layout/Reader/BlockTest.php @@ -38,26 +38,28 @@ class BlockTest extends \PHPUnit_Framework_TestCase /** * @param string $xml + * @param string $elementType * @return \Magento\Framework\View\Layout\Element */ - protected function getElement($xml) + protected function getElement($xml, $elementType) { $xml = '<' . \Magento\Framework\View\Layout\Reader\Block::TYPE_BLOCK . '>' . $xml . '</' . \Magento\Framework\View\Layout\Reader\Block::TYPE_BLOCK . '>'; $xml = simplexml_load_string($xml, 'Magento\Framework\View\Layout\Element'); - return current($xml->children()); + return $xml->{$elementType}; } /** * Prepare reader pool * * @param string $xml + * @param string $elementType */ - protected function prepareReaderPool($xml) + protected function prepareReaderPool($xml, $elementType) { - $this->currentElement = $this->getElement($xml); + $this->currentElement = $this->getElement($xml, $elementType); $this->readerPool->expects($this->once())->method('interpret')->with($this->context, $this->currentElement); } @@ -116,7 +118,11 @@ class BlockTest extends \PHPUnit_Framework_TestCase $this->scheduledStructure->expects($getCondition) ->method('getStructureElementData') ->with($literal, []) - ->willReturn([]); + ->willReturn([ + 'actions' => [ + ['someMethod', [], 'action_config_path', 'scope'], + ], + ]); $this->scheduledStructure->expects($setCondition) ->method('setStructureElementData') ->with( @@ -140,8 +146,9 @@ class BlockTest extends \PHPUnit_Framework_TestCase $this->prepareReaderPool( '<' . $literal . ' ifconfig="' . $ifconfigValue . '">' - . '<action method="someMethod" ifconfig="action_config_path" />' - . '</' . $literal . '>' + . '<action method="someMethod" ifconfig="action_config_path" />' + . '</' . $literal . '>', + $literal ); /** @var \Magento\Framework\View\Layout\Reader\Block $block */ @@ -184,7 +191,11 @@ class BlockTest extends \PHPUnit_Framework_TestCase $this->scheduledStructure->expects($getCondition) ->method('getStructureElementData') ->with($literal, []) - ->willReturn([]); + ->willReturn([ + 'actions' => [ + ['someMethod', [], 'action_config_path', 'scope'], + ], + ]); $this->scheduledStructure->expects($setCondition) ->method('setStructureElementData') ->with( @@ -199,8 +210,9 @@ class BlockTest extends \PHPUnit_Framework_TestCase $this->prepareReaderPool( '<' . $literal . ' name="' . $literal . '">' - . '<action method="someMethod" ifconfig="action_config_path" />' - . '</' . $literal . '>' + . '<action method="someMethod" ifconfig="action_config_path" />' + . '</' . $literal . '>', + $literal ); /** @var \Magento\Framework\View\Layout\Reader\Block $block */ diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Layout/Reader/ContainerTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Layout/Reader/ContainerTest.php index e79b16a2ca6a6b9627e59b72f78a4ae9285e22fd..2f90f4c1b1f23cd62412465d34ac9073e953a2c3 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Layout/Reader/ContainerTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Layout/Reader/ContainerTest.php @@ -103,7 +103,10 @@ class ContainerTest extends \PHPUnit_Framework_TestCase { return [ 'container' => [ - 'elementCurrent' => $this->getElement('<container name="container" id="id_add" tag="body"/>'), + 'elementCurrent' => $this->getElement( + '<container name="container" id="id_add" tag="body"/>', + 'container' + ), 'containerName' => 'container', 'structureElement' => [ 'attributes' => [ @@ -122,7 +125,8 @@ class ContainerTest extends \PHPUnit_Framework_TestCase ], 'referenceContainer' => [ 'elementCurrent' => $this->getElement( - '<referenceContainer name="reference" htmlTag="span" htmlId="id_add" htmlClass="new" label="Add"/>' + '<referenceContainer name="reference" htmlTag="span" htmlId="id_add" htmlClass="new" label="Add"/>', + 'referenceContainer' ), 'containerName' => 'reference', 'structureElement' => [], @@ -140,14 +144,15 @@ class ContainerTest extends \PHPUnit_Framework_TestCase /** * @param string $xml + * @param string $elementType * @return \Magento\Framework\View\Layout\Element */ - protected function getElement($xml) + protected function getElement($xml, $elementType) { $xml = simplexml_load_string( '<parent_element>' . $xml . '</parent_element>', 'Magento\Framework\View\Layout\Element' ); - return current($xml->children()); + return $xml->{$elementType}; } } diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Layout/Reader/UiComponentTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Layout/Reader/UiComponentTest.php index 67ed4e08e4cbf9341795dfd6d2dec22bfe62c268..145c8f6992e9167ec631c92fdb132f38386afac4 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Layout/Reader/UiComponentTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Layout/Reader/UiComponentTest.php @@ -70,7 +70,9 @@ class UiComponentTest extends \PHPUnit_Framework_TestCase ['attributes' => ['group' => '', 'component' => 'listing']] ); $scheduleStructure->expects($this->once())->method('setElementToIfconfigList')->with( - $element->getAttribute('name'), 'config_path', 'scope' + $element->getAttribute('name'), + 'config_path', + 'scope' ); $this->model->interpret($this->context, $element); } @@ -80,7 +82,8 @@ class UiComponentTest extends \PHPUnit_Framework_TestCase return [ [ $this->getElement( - '<ui_component name="cms_block_listing" component="listing" ifconfig="config_path"/>' + '<ui_component name="cms_block_listing" component="listing" ifconfig="config_path"/>', + 'ui_component' ), ] ]; @@ -88,14 +91,15 @@ class UiComponentTest extends \PHPUnit_Framework_TestCase /** * @param string $xml + * @param string $elementType * @return \Magento\Framework\View\Layout\Element */ - protected function getElement($xml) + protected function getElement($xml, $elementType) { $xml = simplexml_load_string( '<parent_element>' . $xml . '</parent_element>', 'Magento\Framework\View\Layout\Element' ); - return current($xml->children()); + return $xml->{$elementType}; } } diff --git a/app/code/Magento/Core/Test/Unit/Model/Layout/XsdTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Layout/XsdTest.php similarity index 94% rename from app/code/Magento/Core/Test/Unit/Model/Layout/XsdTest.php rename to lib/internal/Magento/Framework/View/Test/Unit/Layout/XsdTest.php index 3bdf7c6f6df1910495275801159607c1c5e21712..dae07e2a6ac190804687ad60dee637df0c2d5acd 100644 --- a/app/code/Magento/Core/Test/Unit/Model/Layout/XsdTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Layout/XsdTest.php @@ -3,7 +3,10 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Core\Test\Unit\Model\Layout; + +// @codingStandardsIgnoreFile + +namespace Magento\Framework\View\Test\Unit\Layout; class XsdTest extends \PHPUnit_Framework_TestCase { diff --git a/app/code/Magento/Core/Test/Unit/Model/Layout/_files/action.xml b/lib/internal/Magento/Framework/View/Test/Unit/Layout/_files/action.xml similarity index 100% rename from app/code/Magento/Core/Test/Unit/Model/Layout/_files/action.xml rename to lib/internal/Magento/Framework/View/Test/Unit/Layout/_files/action.xml diff --git a/app/code/Magento/Core/Test/Unit/Model/Layout/_files/arguments.xml b/lib/internal/Magento/Framework/View/Test/Unit/Layout/_files/arguments.xml similarity index 89% rename from app/code/Magento/Core/Test/Unit/Model/Layout/_files/arguments.xml rename to lib/internal/Magento/Framework/View/Test/Unit/Layout/_files/arguments.xml index 7feb1abb6619b22afcd693820d9e160fff3b2310..cfda9d37a3fea1de5065684614d078e9ca51415a 100644 --- a/app/code/Magento/Core/Test/Unit/Model/Layout/_files/arguments.xml +++ b/lib/internal/Magento/Framework/View/Test/Unit/Layout/_files/arguments.xml @@ -9,11 +9,11 @@ <body> <block class="Magento\Test\Block" name="test.block"> <arguments> - <argument name="testHelperWithParams" xsi:type="helper" helper="Magento\Core\Model\Layout\Argument\Handler\TestHelper::testMethod"> + <argument name="testHelperWithParams" xsi:type="helper" helper="Magento\Framework\View\Layout\Argument\Handler\TestHelper::testMethod"> <param name="firstParam">firstValue</param> <param name="secondParam">secondValue</param> </argument> - <argument name="testHelperWithoutParams" xsi:type="helper" helper="Magento\Core\Model\Layout\Argument\Handler\TestHelper::testMethod"/> + <argument name="testHelperWithoutParams" xsi:type="helper" helper="Magento\Framework\View\Layout\Argument\Handler\TestHelper::testMethod"/> <argument name="testSimpleBoolean" xsi:type="boolean">true</argument> <argument name="testSimpleNumber" xsi:type="number">1.5</argument> <argument name="testSimpleString" xsi:type="string">Simple Test</argument> @@ -39,11 +39,11 @@ <item name="url" xsi:type="string">*/sales_archive/massAdd</item> </item> </argument> - <argument name="testOptions" xsi:type="options" model="Magento\Core\Model\Layout\Argument\Handler\TestOptions"/> + <argument name="testOptions" xsi:type="options" model="Magento\Framework\View\Layout\Argument\Handler\TestOptions"/> <argument name="testSimpleObject" xsi:type="object"> Magento\Framework\View\Layout\Argument\Handler\TestObject </argument> - <argument name="testComplexObject" xsi:type="object"><updater>Magento_Test_Updater</updater>Magento\Core\Model\Layout\Argument\Handler\TestObject</argument> + <argument name="testComplexObject" xsi:type="object"><updater>Magento_Test_Updater</updater>Magento\Framework\View\Layout\Argument\Handler\TestObject</argument> </arguments> <action method="testAction"> <argument name="string" xsi:type="string">string</argument> diff --git a/app/code/Magento/Core/Test/Unit/Model/Layout/_files/invalidLayoutArgumentsXmlArray.php b/lib/internal/Magento/Framework/View/Test/Unit/Layout/_files/invalidLayoutArgumentsXmlArray.php similarity index 94% rename from app/code/Magento/Core/Test/Unit/Model/Layout/_files/invalidLayoutArgumentsXmlArray.php rename to lib/internal/Magento/Framework/View/Test/Unit/Layout/_files/invalidLayoutArgumentsXmlArray.php index 14cd1a31346ccf3830699c0368e2c79ae6a62f35..0bb28856ca1479a34f6033a6edcf5778cf333ee3 100644 --- a/app/code/Magento/Core/Test/Unit/Model/Layout/_files/invalidLayoutArgumentsXmlArray.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Layout/_files/invalidLayoutArgumentsXmlArray.php @@ -82,7 +82,7 @@ return [ <block class="Magento\Test\Block" name="test.block"> <arguments> <argument name="argumentName" xsi:type="helper" - helper="Magento\Core\Model\Layout\Argument\Handler\TestHelper::testMethod"> + helper="Magento\Framework\View\Layout\Argument\Handler\TestHelper::testMethod"> <param /> </argument> </arguments> @@ -96,7 +96,7 @@ return [ <block class="Magento\Test\Block" name="test.block"> <arguments> <argument name="argumentName" xsi:type="helper" - helper="Magento\Core\Model\Layout\Argument\Handler\TestHelper::testMethod"> + helper="Magento\Framework\View\Layout\Argument\Handler\TestHelper::testMethod"> <param name="paramName" forbidden="forbidden"/> </argument> </arguments> @@ -110,7 +110,7 @@ return [ <block class="Magento\Test\Block" name="test.block"> <arguments> <argument name="argumentName" xsi:type="helper" - helper="Magento\Core\Model\Layout\Argument\Handler\TestHelper::testMethod"> + helper="Magento\Framework\View\Layout\Argument\Handler\TestHelper::testMethod"> <param name="paramName"><forbidden /></param> </argument> </arguments> diff --git a/lib/internal/Magento/Framework/View/Test/Unit/TemplateEngine/PhpTest.php b/lib/internal/Magento/Framework/View/Test/Unit/TemplateEngine/PhpTest.php index efbe7b23a727f76496a3565330a3288e8852a447..ab17c14b9b3bad2f86e6a312ccf9aa7ba36be98f 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/TemplateEngine/PhpTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/TemplateEngine/PhpTest.php @@ -56,7 +56,6 @@ class PhpTest extends \PHPUnit_Framework_TestCase * * Expect an exception if the specified file does not exist. * @expectedException \Exception - * @expectedExceptionMessage include(This_is_not_a_file): failed to open stream: No such file or directory */ public function testRenderException() { diff --git a/lib/internal/Magento/Framework/Webapi/CustomAttributeTypeLocatorInterface.php b/lib/internal/Magento/Framework/Webapi/CustomAttributeTypeLocatorInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..dac64d2acfcf9379169980a836e95d15ef6e034f --- /dev/null +++ b/lib/internal/Magento/Framework/Webapi/CustomAttributeTypeLocatorInterface.php @@ -0,0 +1,22 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Framework\Webapi; + +/** + * Interface to locate types for custom attributes + */ +interface CustomAttributeTypeLocatorInterface +{ + /** + * Get Data Interface type for a given custom attribute code + * + * @param string $attributeCode + * @param string $serviceClass + * @return string|null + */ + public function getType($attributeCode, $serviceClass); +} diff --git a/lib/internal/Magento/Framework/Webapi/Exception.php b/lib/internal/Magento/Framework/Webapi/Exception.php index 130819e29ef5af8d5c64b1071b73403842788595..b5b46c0e562bcf5aaebc986c7ecc7164380f93e7 100644 --- a/lib/internal/Magento/Framework/Webapi/Exception.php +++ b/lib/internal/Magento/Framework/Webapi/Exception.php @@ -67,7 +67,7 @@ class Exception extends \RuntimeException /** * List of errors * - * @var null|ErrorMessage[] + * @var null|\Magento\Framework\Exception\LocalizedException[] */ protected $_errors; @@ -79,7 +79,7 @@ class Exception extends \RuntimeException * @param int $httpCode * @param array $details Additional exception details * @param string $name Exception name - * @param ErrorMessage[]|null $errors Array of errors messages + * @param \Magento\Framework\Exception\LocalizedException[]|null $errors Array of errors messages * @param string $stackTrace * * @throws \InvalidArgumentException @@ -148,7 +148,7 @@ class Exception extends \RuntimeException /** * Retrieve list of errors. * - * @return null|ErrorMessage[] + * @return null|\Magento\Framework\Exception\LocalizedException[] */ public function getErrors() { diff --git a/lib/internal/Magento/Framework/Webapi/Request.php b/lib/internal/Magento/Framework/Webapi/Request.php index e40112ce2d6466e70b881460ec6b6a1c867172ab..fdd688a313e51a83d6cd1bf3ec3d78bc5b61e22e 100644 --- a/lib/internal/Magento/Framework/Webapi/Request.php +++ b/lib/internal/Magento/Framework/Webapi/Request.php @@ -39,4 +39,22 @@ class Request extends HttpRequest implements RequestInterface $pathInfo = preg_replace('#\?.*#', '', $pathInfo); $this->setPathInfo($pathInfo); } + + /** + * {@inheritdoc} + * + * Added CGI environment support. + */ + public function getHeader($header, $default = false) + { + $headerValue = parent::getHeader($header, $default); + if ($headerValue == false) { + /** Workaround for hhvm environment */ + $header = 'REDIRECT_HTTP_' . strtoupper(str_replace('-', '_', $header)); + if (isset($_SERVER[$header])) { + $headerValue = $_SERVER[$header]; + } + } + return $headerValue; + } } diff --git a/lib/internal/Magento/Framework/Webapi/Rest/Request.php b/lib/internal/Magento/Framework/Webapi/Rest/Request.php index 9f97855cb7a897eb75a7c9b0a4568c3209541842..49989a9a0995e1b33101b74e3ec017c9709824b3 100644 --- a/lib/internal/Magento/Framework/Webapi/Rest/Request.php +++ b/lib/internal/Magento/Framework/Webapi/Rest/Request.php @@ -9,6 +9,7 @@ namespace Magento\Framework\Webapi\Rest; use Magento\Framework\Api\SimpleDataObjectConverter; +use Magento\Framework\Phrase; class Request extends \Magento\Framework\Webapi\Request { @@ -131,21 +132,21 @@ class Request extends \Magento\Framework\Webapi\Request * Get Content-Type of request. * * @return string - * @throws \Magento\Framework\Webapi\Exception + * @throws \Magento\Framework\Exception\InputException */ public function getContentType() { $headerValue = $this->getHeader('Content-Type'); if (!$headerValue) { - throw new \Magento\Framework\Exception\InputException('Content-Type header is empty.'); + throw new \Magento\Framework\Exception\InputException(new Phrase('Content-Type header is empty.')); } if (!preg_match('~^([a-z\d/\-+.]+)(?:; *charset=(.+))?$~Ui', $headerValue, $matches)) { - throw new \Magento\Framework\Exception\InputException('Content-Type header is invalid.'); + throw new \Magento\Framework\Exception\InputException(new Phrase('Content-Type header is invalid.')); } // request encoding check if it is specified in header if (isset($matches[2]) && self::REQUEST_CHARSET != strtolower($matches[2])) { - throw new \Magento\Framework\Exception\InputException('UTF-8 is the only supported charset.'); + throw new \Magento\Framework\Exception\InputException(new Phrase('UTF-8 is the only supported charset.')); } return $matches[1]; @@ -155,12 +156,12 @@ class Request extends \Magento\Framework\Webapi\Request * Retrieve current HTTP method. * * @return string - * @throws \Magento\Framework\Webapi\Exception + * @throws \Magento\Framework\Exception\InputException */ public function getHttpMethod() { if (!$this->isGet() && !$this->isPost() && !$this->isPut() && !$this->isDelete()) { - throw new \Magento\Framework\Exception\InputException('Request method is invalid.'); + throw new \Magento\Framework\Exception\InputException(new Phrase('Request method is invalid.')); } return $this->getMethod(); } diff --git a/lib/internal/Magento/Framework/Webapi/Rest/Request/Deserializer/Json.php b/lib/internal/Magento/Framework/Webapi/Rest/Request/Deserializer/Json.php index ba0091bc725a7e94f6073f2ea2fb21bbac36ca6d..34f3936ce563c3b399eb280640bb532025ba507b 100644 --- a/lib/internal/Magento/Framework/Webapi/Rest/Request/Deserializer/Json.php +++ b/lib/internal/Magento/Framework/Webapi/Rest/Request/Deserializer/Json.php @@ -52,10 +52,10 @@ class Json implements \Magento\Framework\Webapi\Rest\Request\DeserializerInterfa throw new \Magento\Framework\Webapi\Exception(new Phrase('Decoding error.')); } else { throw new \Magento\Framework\Webapi\Exception( - new Phrase( + (string)(new Phrase( 'Decoding error: %1%2%3%4', [PHP_EOL, $e->getMessage(), PHP_EOL, $e->getTraceAsString()] - ) + )) ); } } diff --git a/lib/internal/Magento/Framework/Webapi/ServiceInputProcessor.php b/lib/internal/Magento/Framework/Webapi/ServiceInputProcessor.php index ec1807f5222ef213d42175e76bd6dbccda8d870c..75d2a77d1cbd91cb954174264f64c699099f1c2b 100644 --- a/lib/internal/Magento/Framework/Webapi/ServiceInputProcessor.php +++ b/lib/internal/Magento/Framework/Webapi/ServiceInputProcessor.php @@ -17,6 +17,7 @@ use Magento\Framework\Exception\SerializationException; use Magento\Framework\Reflection\TypeProcessor; use Magento\Framework\ObjectManagerInterface; use Magento\Framework\Webapi\Exception as WebapiException; +use Magento\Framework\Phrase; use Zend\Code\Reflection\ClassReflection; use Zend\Code\Reflection\MethodReflection; use Zend\Code\Reflection\ParameterReflection; @@ -30,42 +31,44 @@ class ServiceInputProcessor { const CACHE_ID_PREFIX = 'service_method_params_'; + const EXTENSION_ATTRIBUTES_TYPE = '\Magento\Framework\Api\ExtensionAttributesInterface'; + /** @var \Magento\Framework\Reflection\TypeProcessor */ protected $typeProcessor; /** @var ObjectManagerInterface */ protected $objectManager; - /** @var ServiceConfigReader */ - protected $serviceConfigReader; - /** @var AttributeValueFactory */ protected $attributeValueFactory; /** @var WebapiCache */ protected $cache; + /** @var CustomAttributeTypeLocatorInterface */ + protected $customAttributeTypeLocator; + /** * Initialize dependencies. * * @param TypeProcessor $typeProcessor * @param ObjectManagerInterface $objectManager - * @param ServiceConfigReader $serviceConfigReader * @param AttributeValueFactory $attributeValueFactory * @param WebapiCache $cache + * @param CustomAttributeTypeLocatorInterface $customAttributeTypeLocator */ public function __construct( TypeProcessor $typeProcessor, ObjectManagerInterface $objectManager, - ServiceConfigReader $serviceConfigReader, AttributeValueFactory $attributeValueFactory, - WebapiCache $cache + WebapiCache $cache, + CustomAttributeTypeLocatorInterface $customAttributeTypeLocator ) { $this->typeProcessor = $typeProcessor; $this->objectManager = $objectManager; - $this->serviceConfigReader = $serviceConfigReader; $this->attributeValueFactory = $attributeValueFactory; $this->cache = $cache; + $this->customAttributeTypeLocator = $customAttributeTypeLocator; } /** @@ -108,7 +111,7 @@ class ServiceInputProcessor if (!empty($inputError)) { $exception = new InputException(); foreach ($inputError as $errorParamField) { - $exception->addError(InputException::REQUIRED_FIELD, ['fieldName' => $errorParamField]); + $exception->addError(new Phrase(InputException::REQUIRED_FIELD, ['fieldName' => $errorParamField])); } if ($exception->wasErrorAdded()) { throw $exception; @@ -126,12 +129,15 @@ class ServiceInputProcessor * @param string $className * @param array $data * @return object the newly created and populated object + * @throws \Exception */ protected function _createFromArray($className, $data) { $data = is_array($data) ? $data : []; $class = new ClassReflection($className); - + if (is_subclass_of($className, self::EXTENSION_ATTRIBUTES_TYPE)) { + $className = substr($className, 0, -strlen('Interface')); + } $factory = $this->objectManager->get($className . 'Factory'); $object = $factory->create(); @@ -153,7 +159,7 @@ class ServiceInputProcessor } } if ($camelCaseProperty === 'CustomAttributes') { - $setterValue = $this->convertCustomAttributeValue($value, $returnType, $className); + $setterValue = $this->convertCustomAttributeValue($value, $className); } else { $setterValue = $this->_convertValue($value, $returnType); } @@ -167,24 +173,14 @@ class ServiceInputProcessor * Convert custom attribute data array to array of AttributeValue Data Object * * @param array $customAttributesValueArray - * @param string $returnType * @param string $dataObjectClassName * @return AttributeValue[] */ - protected function convertCustomAttributeValue($customAttributesValueArray, $returnType, $dataObjectClassName) + protected function convertCustomAttributeValue($customAttributesValueArray, $dataObjectClassName) { $result = []; - $allAttributes = $this->serviceConfigReader->read(); $dataObjectClassName = ltrim($dataObjectClassName, '\\'); - if (!isset($allAttributes[$dataObjectClassName])) { - $attributes = $this->_convertValue($customAttributesValueArray, $returnType); - $attributesByName = []; - foreach ($attributes as $attribute) { - $attributesByName[$attribute->getAttributeCode()] = $attribute; - } - return $attributesByName; - } - $dataObjectAttributes = $allAttributes[$dataObjectClassName]; + $camelCaseAttributeCodeKey = lcfirst( SimpleDataObjectConverter::snakeCaseToUpperCamelCase(AttributeValue::ATTRIBUTE_CODE) ); @@ -197,11 +193,9 @@ class ServiceInputProcessor $customAttributeCode = null; } - //Check if type is defined, else default to mixed - $type = isset($dataObjectAttributes[$customAttributeCode]) - ? $dataObjectAttributes[$customAttributeCode] - : TypeProcessor::ANY_TYPE; - + //Check if type is defined, else default to string + $type = $this->customAttributeTypeLocator->getType($customAttributeCode, $dataObjectClassName); + $type = $type ? $type : TypeProcessor::ANY_TYPE; $customAttributeValue = $customAttribute[AttributeValue::VALUE]; if (is_array($customAttributeValue)) { //If type for AttributeValue's value as array is mixed, further processing is not possible diff --git a/lib/internal/Magento/Framework/Webapi/Test/Unit/ErrorProcessorTest.php b/lib/internal/Magento/Framework/Webapi/Test/Unit/ErrorProcessorTest.php index 29026d8312658633a1f12c7c06257ece73e254fe..ab378a49c0bdfbfb68ddc350d653a475bcfc2445 100644 --- a/lib/internal/Magento/Framework/Webapi/Test/Unit/ErrorProcessorTest.php +++ b/lib/internal/Magento/Framework/Webapi/Test/Unit/ErrorProcessorTest.php @@ -12,6 +12,7 @@ use \Magento\Framework\Webapi\ErrorProcessor; use Magento\Framework\Exception\AuthorizationException; use Magento\Framework\Exception\NoSuchEntityException; use Magento\Framework\Webapi\Exception as WebapiException; +use Magento\Framework\Phrase; class ErrorProcessorTest extends \PHPUnit_Framework_TestCase { @@ -66,6 +67,8 @@ class ErrorProcessorTest extends \PHPUnit_Framework_TestCase /** * Test render method in JSON format. + * + * @return void */ public function testRenderJson() { @@ -93,7 +96,7 @@ class ErrorProcessorTest extends \PHPUnit_Framework_TestCase * * Method encodes data to JSON and returns it. * - * @param $data + * @param array $data * @return string */ public function callbackJsonEncode($data) @@ -103,6 +106,7 @@ class ErrorProcessorTest extends \PHPUnit_Framework_TestCase /** * Test render method in JSON format with turned on developer mode. + * @return void */ public function testRenderJsonInDeveloperMode() { @@ -127,6 +131,7 @@ class ErrorProcessorTest extends \PHPUnit_Framework_TestCase /** * Test render method in XML format. + * @return void */ public function testRenderXml() { @@ -144,6 +149,7 @@ class ErrorProcessorTest extends \PHPUnit_Framework_TestCase /** * Test render method in XML format with turned on developer mode. + * @return void */ public function testRenderXmlInDeveloperMode() { @@ -164,6 +170,7 @@ class ErrorProcessorTest extends \PHPUnit_Framework_TestCase /** * Test default render format is JSON. + * @return void */ public function testRenderDefaultFormat() { @@ -176,6 +183,7 @@ class ErrorProcessorTest extends \PHPUnit_Framework_TestCase /** * Test maskException method with turned on developer mode. + * @return void */ public function testMaskExceptionInDeveloperMode() { @@ -197,6 +205,11 @@ class ErrorProcessorTest extends \PHPUnit_Framework_TestCase /** * Test sendResponse method with various exceptions * + * @param \Exception $exception + * @param int $expectedHttpCode + * @param string $expectedMessage + * @param array $expectedDetails + * @return void * @dataProvider dataProviderForSendResponseExceptions */ public function testMaskException($exception, $expectedHttpCode, $expectedMessage, $expectedDetails) @@ -212,18 +225,23 @@ class ErrorProcessorTest extends \PHPUnit_Framework_TestCase ); } + /** + * @return array + */ public function dataProviderForSendResponseExceptions() { return [ 'NoSuchEntityException' => [ new NoSuchEntityException( - NoSuchEntityException::MESSAGE_DOUBLE_FIELDS, - [ - 'fieldName' => 'detail1', - 'fieldValue' => 'value1', - 'field2Name' => 'resource_id', - 'field2Value' => 'resource10', - ] + new Phrase( + NoSuchEntityException::MESSAGE_DOUBLE_FIELDS, + [ + 'fieldName' => 'detail1', + 'fieldValue' => 'value1', + 'field2Name' => 'resource_id', + 'field2Value' => 'resource10', + ] + ) ), \Magento\Framework\Webapi\Exception::HTTP_NOT_FOUND, NoSuchEntityException::MESSAGE_DOUBLE_FIELDS, @@ -242,8 +260,10 @@ class ErrorProcessorTest extends \PHPUnit_Framework_TestCase ], 'AuthorizationException' => [ new AuthorizationException( - AuthorizationException::NOT_AUTHORIZED, - ['consumer_id' => '3', 'resources' => '4'] + new Phrase( + AuthorizationException::NOT_AUTHORIZED, + ['consumer_id' => '3', 'resources' => '4'] + ) ), WebapiException::HTTP_UNAUTHORIZED, AuthorizationException::NOT_AUTHORIZED, @@ -265,6 +285,7 @@ class ErrorProcessorTest extends \PHPUnit_Framework_TestCase * @param int $expectedHttpCode * @param string $expectedMessage * @param array $expectedDetails + * @return void */ public function assertMaskedException( $maskedException, diff --git a/lib/internal/Magento/Framework/Webapi/Test/Unit/ServiceInputProcessorTest.php b/lib/internal/Magento/Framework/Webapi/Test/Unit/ServiceInputProcessorTest.php index d53450141ba4310b8f2d69f5a7b82e847dd86778..41cdf8184ba372143f8ed2fdde2ff790f8633fa0 100644 --- a/lib/internal/Magento/Framework/Webapi/Test/Unit/ServiceInputProcessorTest.php +++ b/lib/internal/Magento/Framework/Webapi/Test/Unit/ServiceInputProcessorTest.php @@ -3,13 +3,16 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ + +// @codingStandardsIgnoreFile + namespace Magento\Framework\Webapi\Test\Unit; -use \Magento\Framework\Webapi\ServiceInputProcessor; -use \Magento\Framework\Webapi\Test\Unit\ServiceInputProcessor\WebapiBuilderFactory; +use Magento\Framework\Webapi\ServiceInputProcessor; +use Magento\Framework\Webapi\Test\Unit\ServiceInputProcessor\WebapiBuilderFactory; use Magento\Framework\Webapi\Test\Unit\ServiceInputProcessor\AssociativeArray; use Magento\Framework\Webapi\Test\Unit\ServiceInputProcessor\DataArray; -use \Magento\Framework\Webapi\Test\Unit\ServiceInputProcessor\ObjectWithCustomAttributes; +use Magento\Framework\Webapi\Test\Unit\ServiceInputProcessor\ObjectWithCustomAttributes; use Magento\Webapi\Test\Unit\Service\Entity\DataArrayData; use Magento\Framework\Webapi\Test\Unit\ServiceInputProcessor\Nested; use Magento\Webapi\Test\Unit\Service\Entity\NestedData; @@ -25,10 +28,10 @@ class ServiceInputProcessorTest extends \PHPUnit_Framework_TestCase protected $serviceInputProcessor; /** @var \PHPUnit_Framework_MockObject_MockObject */ - protected $attributeValueFactory; + protected $attributeValueFactoryMock; /** @var \PHPUnit_Framework_MockObject_MockObject */ - protected $serviceConfigReader; + protected $customAttributeTypeLocator; /** @var \PHPUnit_Framework_MockObject_MockObject */ protected $objectManagerMock; @@ -46,7 +49,7 @@ class ServiceInputProcessorTest extends \PHPUnit_Framework_TestCase ->getMock(); $cache->expects($this->any())->method('load')->willReturn(false); - $this->serviceConfigReader = $this->getMockBuilder('Magento\Framework\Api\Config\Reader') + $this->customAttributeTypeLocator = $this->getMockBuilder('Magento\Eav\Model\EavCustomAttributeTypeLocator') ->disableOriginalConstructor() ->getMock(); @@ -68,7 +71,7 @@ class ServiceInputProcessorTest extends \PHPUnit_Framework_TestCase 'typeProcessor' => $typeProcessor, 'objectManager' => $this->objectManagerMock, 'cache' => $cache, - 'serviceConfigReader' => $this->serviceConfigReader, + 'customAttributeTypeLocator' => $this->customAttributeTypeLocator, 'attributeValueFactory' => $this->attributeValueFactoryMock ] ); @@ -164,7 +167,7 @@ class ServiceInputProcessorTest extends \PHPUnit_Framework_TestCase public function testAssociativeArrayProperties() { - $this->setupFactory(['\Magento\Webapi\Service\Entity\Simple']); + $this->setupFactory(['Magento\Framework\Webapi\Test\Unit\ServiceInputProcessor\Simple']); $data = ['associativeArray' => ['key' => 'value', 'key_two' => 'value_two']]; $result = $this->serviceInputProcessor->process( 'Magento\Framework\Webapi\Test\Unit\ServiceInputProcessor\TestService', @@ -183,7 +186,7 @@ class ServiceInputProcessorTest extends \PHPUnit_Framework_TestCase public function testAssociativeArrayPropertiesWithItem() { - $this->setupFactory(['Magento\Webapi\Service\Entity\AssociativeArray']); + $this->setupFactory(['Magento\Framework\Webapi\Test\Unit\ServiceInputProcessor\AssociativeArray']); $data = ['associativeArray' => ['item' => 'value']]; $result = $this->serviceInputProcessor->process( 'Magento\Framework\Webapi\Test\Unit\ServiceInputProcessor\TestService', @@ -201,7 +204,7 @@ class ServiceInputProcessorTest extends \PHPUnit_Framework_TestCase public function testAssociativeArrayPropertiesWithItemArray() { - $this->setupFactory(['Magento\Webapi\Service\Entity\AssociativeArray']); + $this->setupFactory(['Magento\Framework\Webapi\Test\Unit\ServiceInputProcessor\AssociativeArray']); $data = ['associativeArray' => ['item' => ['value1','value2']]]; $result = $this->serviceInputProcessor->process( 'Magento\Framework\Webapi\Test\Unit\ServiceInputProcessor\TestService', @@ -344,8 +347,8 @@ class ServiceInputProcessorTest extends \PHPUnit_Framework_TestCase * * @dataProvider customAttributesDataProvider * @param $customAttributeType - * @param $customAttributeValue - * @param $attributeCode + * @param $inputData + * @param $expectedObject */ public function testCustomAttributesProperties($customAttributeType, $inputData, $expectedObject) { @@ -357,13 +360,7 @@ class ServiceInputProcessorTest extends \PHPUnit_Framework_TestCase 'Magento\Framework\Webapi\Test\Unit\ServiceInputProcessor\SimpleArray', ] ); - $this->serviceConfigReader->expects($this->any())->method('read')->willReturn( - [ - 'Magento\Framework\Webapi\Test\Unit\ServiceInputProcessor\ObjectWithCustomAttributes' => [ - TestService::CUSTOM_ATTRIBUTE_CODE => $customAttributeType - ] - ] - ); + $this->customAttributeTypeLocator->expects($this->any())->method('getType')->willReturn($customAttributeType); $result = $this->serviceInputProcessor->process( 'Magento\Framework\Webapi\Test\Unit\ServiceInputProcessor\TestService', @@ -532,6 +529,7 @@ class ServiceInputProcessorTest extends \PHPUnit_Framework_TestCase foreach ($classNames as $className) { $factoryMock = $this->getMockBuilder($className . 'Factory') ->setMethods(['create']) + ->disableOriginalConstructor() ->getMock(); $factoryMock->expects($this->any()) ->method('create') diff --git a/lib/web/jquery/jquery.validate.js b/lib/web/jquery/jquery.validate.js index 58fdf10e665f2de752181fcfc09e1cfc5ecad2c2..85d0621b02244ae568e56509e83f9ad3dde2d626 100644 --- a/lib/web/jquery/jquery.validate.js +++ b/lib/web/jquery/jquery.validate.js @@ -288,22 +288,22 @@ }, messages: { - required: "This field is required.", - remote: "Please fix this field.", - email: "Please enter a valid email address.", - url: "Please enter a valid URL.", - date: "Please enter a valid date.", - dateISO: "Please enter a valid date (ISO).", - number: "Please enter a valid number.", - digits: "Please enter only digits.", - creditcard: "Please enter a valid credit card number.", - equalTo: "Please enter the same value again.", - maxlength: $.validator.format("Please enter no more than {0} characters."), - minlength: $.validator.format("Please enter at least {0} characters."), - rangelength: $.validator.format("Please enter a value between {0} and {1} characters long."), - range: $.validator.format("Please enter a value between {0} and {1}."), - max: $.validator.format("Please enter a value less than or equal to {0}."), - min: $.validator.format("Please enter a value greater than or equal to {0}.") + required: $.mage.__("This field is required."), + remote: $.mage.__("Please fix this field."), + email: $.mage.__("Please enter a valid email address."), + url: $.mage.__("Please enter a valid URL."), + date: $.mage.__("Please enter a valid date."), + dateISO: $.mage.__("Please enter a valid date (ISO)."), + number: $.mage.__("Please enter a valid number."), + digits: $.mage.__("Please enter only digits."), + creditcard: $.mage.__("Please enter a valid credit card number."), + equalTo: $.mage.__("Please enter the same value again."), + maxlength: $.validator.format($.mage.__("Please enter no more than {0} characters.")), + minlength: $.validator.format($.mage.__("Please enter at least {0} characters.")), + rangelength: $.validator.format($.mage.__("Please enter a value between {0} and {1} characters long.")), + range: $.validator.format($.mage.__("Please enter a value between {0} and {1}.")), + max: $.validator.format($.mage.__("Please enter a value less than or equal to {0}.")), + min: $.validator.format($.mage.__("Please enter a value greater than or equal to {0}.")) }, autoCreateRanges: false, @@ -621,6 +621,7 @@ }, defaultMessage: function (element, method) { + var noMessage = $.mage.__("Warning: No message defined for %s"); return this.findDefined( this.customMessage(element.name, method), this.customDataMessage(element, method), @@ -628,7 +629,7 @@ // title is never undefined, so handle empty string as undefined !this.settings.ignoreTitle && element.title || undefined, $.validator.messages[method], - "<strong>Warning: No message defined for " + element.name + "</strong>" + "<strong>" + noMessage.replace('%s', element.name) + "</strong>" ); }, diff --git a/lib/web/mage/decorate.js b/lib/web/mage/decorate.js index 0babea53af81b9f42e7db1bedf2e3266c26a278c..2c629479e497f1ccc31fdf570cf4ea44b3c050d3 100644 --- a/lib/web/mage/decorate.js +++ b/lib/web/mage/decorate.js @@ -111,7 +111,8 @@ } else if (typeof method === 'object' || ! method) { return methods.init.apply(this, arguments); } else { - $.error($.mage.__('Method ' + method + ' does not exist on jQuery.decorate')); + var message = $.mage.__('Method %s does not exist on jQuery.decorate'); + $.error(message.replace('%s', method)); } }; diff --git a/lib/web/mage/translate-inline-vde.js b/lib/web/mage/translate-inline-vde.js index 6c2b3a53b7f927fe0f9ca3679a131568bb9f6038..0e70103b8f06fa3173582e16ed52cd42032d86cb 100644 --- a/lib/web/mage/translate-inline-vde.js +++ b/lib/web/mage/translate-inline-vde.js @@ -127,7 +127,7 @@ */ _checkTranslateEditing: function(event, data) { if (this.isBeingEdited) { - alert($.mage.__(data.alert_message)); + alert(data.alert_message); data.is_being_edited = true; } else { diff --git a/lib/web/mage/validation.js b/lib/web/mage/validation.js index 6e14e33548ddd8d773f3149689b5158c089cd969..7632ce9b84977587975da37348f383f39395c89e 100644 --- a/lib/web/mage/validation.js +++ b/lib/web/mage/validation.js @@ -934,7 +934,8 @@ return true; }, function() { - return $.mage.__('Please enter a value less than or equal to %s.').replace('%s', this.lteToVal); + var message = $.mage.__('Please enter a value less than or equal to %s.'); + return message.replace('%s', this.lteToVal); } ], "greater-than-equals-to": [ @@ -946,7 +947,8 @@ return true; }, function() { - return $.mage.__('Please enter a value greater than or equal to %s.').replace('%s', this.gteToVal); + var message = $.mage.__('Please enter a value greater than or equal to %s.'); + return message.replace('%s', this.gteToVal); } ], "validate-emails": [ @@ -1250,7 +1252,7 @@ var showLabel = $.validator.prototype.showLabel; $.extend(true, $.validator.prototype, { showLabel: function(element, message) { - showLabel.call(this, element, $.mage.__(message)); + showLabel.call(this, element, message); // ARIA (adding aria-invalid & aria-describedby) var label = this.errorsFor(element), diff --git a/lib/web/mage/validation/validation.js b/lib/web/mage/validation/validation.js index 42013cf2ca1b41c1e6a1eb40b22cb9417f8b9d0a..d666d2025c2636cb00b27e5d2af2c8baa584323d 100644 --- a/lib/web/mage/validation/validation.js +++ b/lib/web/mage/validation/validation.js @@ -72,7 +72,8 @@ if (inputDate >= minDate && inputDate <= maxDate) { return true; } - this.dateBetweenErrorMessage = $.mage.__('Please enter a date between %min and %max.').replace('%min', minDate).replace('%max', maxDate); + var message = $.mage.__('Please enter a date between %min and %max.'); + this.dateBetweenErrorMessage = message.replace('%min', minDate).replace('%max', maxDate); return false; }, function () { @@ -107,14 +108,14 @@ return false; } if (year < 1900 || year > curYear) { - this.dobErrorMessage = - $.mage.__('Please enter a valid year (1900-%1).').replace('%1', curYear.toString()); + var validYearMessage = $.mage.__('Please enter a valid year (1900-%1).'); + this.dobErrorMessage = validYearMessage.replace('%1', curYear.toString()); return false; } var validateDayInMonth = new Date(year, month, 0).getDate(); if (day < 1 || day > validateDayInMonth) { - this.dobErrorMessage = - $.mage.__('Please enter a valid day (1-%1).').replace('%1', validateDayInMonth.toString()); + var validDateMessage = $.mage.__('Please enter a valid day (1-%1).'); + this.dobErrorMessage = validDateMessage.replace('%1', validateDayInMonth.toString()); return false; } var today = new Date(), diff --git a/pub/get.php b/pub/get.php index f223a917dbb317cdc39736c975651261fca3b348..7e9adfd0e9fd7cde47236f024c888ae44d254f3d 100755 --- a/pub/get.php +++ b/pub/get.php @@ -63,9 +63,7 @@ if ($mediaDirectory) { // Materialize file in application $params = $_SERVER; if (empty($mediaDirectory)) { - $params[ObjectManagerFactory::INIT_PARAM_DEPLOYMENT_CONFIG] = [ - DeploymentConfig::CONFIG_KEY => ['Magento_Core' => 1], - ]; + $params[ObjectManagerFactory::INIT_PARAM_DEPLOYMENT_CONFIG] = []; $params[Factory::PARAM_CACHE_FORCED_OPTIONS] = ['frontend_options' => ['disable_save' => true]]; } $bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $params); diff --git a/pub/static/.htaccess b/pub/static/.htaccess index 8d1f4ff8630b1e68d3011c6b2a3c80d4bedb4644..c96881a49c63ff713f87d9148f6f8c5816ecfeb8 100755 --- a/pub/static/.htaccess +++ b/pub/static/.htaccess @@ -1,6 +1,10 @@ <IfModule mod_php5.c> php_flag engine 0 </IfModule> + +# To avoid situation when web server automatically adds extension to path +Options -MultiViews + <IfModule mod_rewrite.c> RewriteEngine On diff --git a/setup/pub/styles/setup.css b/setup/pub/styles/setup.css index 2b738d61e6ee37fd1d75260db370b4e012fae368..41b113a55c90f4be925712eee65124bb3200d537 100644 --- a/setup/pub/styles/setup.css +++ b/setup/pub/styles/setup.css @@ -3,4 +3,4 @@ * See COPYING.txt for license details. */ -html{font-family:sans-serif;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%;font-size-adjust:100%}body{margin:0}article,aside,details,figcaption,figure,footer,header,main,nav,section,summary{display:block}audio,canvas,progress,video{display:inline-block;vertical-align:baseline}audio:not([controls]){display:none;height:0}[hidden],template{display:none}a{background:0 0}a:active,a:hover{outline:0}abbr[title]{border-bottom:1px dotted}b,strong{font-weight:700}dfn{font-style:italic}h1{font-size:2em;margin:.67em 0}mark{background:#ff0;color:#000}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sup{top:-.5em}sub{bottom:-.25em}img{border:0}svg:not(:root){overflow:hidden}figure{margin:1em 40px}hr{box-sizing:content-box;height:0}pre{overflow:auto}code,kbd,pre,samp{font-family:monospace,monospace;font-size:1em}button,input,optgroup,select,textarea{color:inherit;font:inherit;margin:0}button{overflow:visible}button,select{text-transform:none}button,html input[type=button],input[type=reset],input[type=submit]{-webkit-appearance:button;cursor:pointer}button[disabled],html input[disabled]{cursor:default}button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0}input{line-height:normal}input[type=checkbox],input[type=radio]{box-sizing:border-box;padding:0}input[type=number]::-webkit-inner-spin-button,input[type=number]::-webkit-outer-spin-button{height:auto}input[type=search]{box-sizing:content-box}input[type=search]::-webkit-search-cancel-button,input[type=search]::-webkit-search-decoration{-webkit-appearance:none}fieldset{border:1px solid silver;margin:0 2px;padding:.35em .625em .75em}legend{border:0;padding:0}textarea{overflow:auto}optgroup{font-weight:700}table{border-collapse:collapse;border-spacing:0}td,th{padding:0}*{box-sizing:border-box}:focus{box-shadow:none;outline:0}.keyfocus :focus{box-shadow:0 0 0 1px #008bdb}embed,img,object,video{max-width:100%}.abs-clearer:after,.form-row:after,.header:after,.ie9 .alert:after,.nav:after,.row:after{content:"";display:table;clear:both}.ng-cloak{display:none!important}.hide.hide{display:none}.show.show{display:block}.text-center{text-align:center}.text-right{text-align:right}@font-face{font-family:'Open Sans';src:url(../../pub/fonts/opensans/light/opensans-300.eot);src:url(../../pub/fonts/opensans/light/opensans-300.eot?#iefix) format('embedded-opentype'),url(../../pub/fonts/opensans/light/opensans-300.woff2) format('woff2'),url(../../pub/fonts/opensans/light/opensans-300.woff) format('woff'),url(../../pub/fonts/opensans/light/opensans-300.ttf) format('truetype'),url('../../pub/fonts/opensans/light/opensans-300.svg#Open Sans') format('svg');font-weight:300;font-style:normal}@font-face{font-family:'Open Sans';src:url(../../pub/fonts/opensans/regular/opensans-400.eot);src:url(../../pub/fonts/opensans/regular/opensans-400.eot?#iefix) format('embedded-opentype'),url(../../pub/fonts/opensans/regular/opensans-400.woff2) format('woff2'),url(../../pub/fonts/opensans/regular/opensans-400.woff) format('woff'),url(../../pub/fonts/opensans/regular/opensans-400.ttf) format('truetype'),url('../../pub/fonts/opensans/regular/opensans-400.svg#Open Sans') format('svg');font-weight:400;font-style:normal}@font-face{font-family:'Open Sans';src:url(../../pub/fonts/opensans/semibold/opensans-600.eot);src:url(../../pub/fonts/opensans/semibold/opensans-600.eot?#iefix) format('embedded-opentype'),url(../../pub/fonts/opensans/semibold/opensans-600.woff2) format('woff2'),url(../../pub/fonts/opensans/semibold/opensans-600.woff) format('woff'),url(../../pub/fonts/opensans/semibold/opensans-600.ttf) format('truetype'),url('../../pub/fonts/opensans/semibold/opensans-600.svg#Open Sans') format('svg');font-weight:600;font-style:normal}@font-face{font-family:'Open Sans';src:url(../../pub/fonts/opensans/bold/opensans-700.eot);src:url(../../pub/fonts/opensans/bold/opensans-700.eot?#iefix) format('embedded-opentype'),url(../../pub/fonts/opensans/bold/opensans-700.woff2) format('woff2'),url(../../pub/fonts/opensans/bold/opensans-700.woff) format('woff'),url(../../pub/fonts/opensans/bold/opensans-700.ttf) format('truetype'),url('../../pub/fonts/opensans/bold/opensans-700.svg#Open Sans') format('svg');font-weight:700;font-style:normal}html{font-size:62.5%}body{color:#303030;font-family:'Open Sans','Helvetica Neue',Helvetica,Arial,sans-serif;font-size:1.4rem;font-weight:400;line-height:1.4}h1,h2,h3,h4,h5,h6{font-weight:400;margin-top:0}p{margin:0 0 1em}a{color:#008bdb;text-decoration:none}a:hover{color:#0fa7ff;text-decoration:underline}@font-face{font-family:Icons;src:url(../../pub/fonts/icons/icons.eot);src:url(../../pub/fonts/icons/icons.eot?#iefix) format('embedded-opentype'),url(../../pub/fonts/icons/icons.woff2) format('woff2'),url(../../pub/fonts/icons/icons.woff) format('woff'),url(../../pub/fonts/icons/icons.ttf) format('truetype'),url(../../pub/fonts/icons/icons.svg#Icons) format('svg');font-weight:400;font-style:normal}[class*=icon-]{display:inline-block;line-height:1}[class*=icon-]:after{font-family:Icons}.icon-success-thick:after{content:'\e600'}.icon-success:after{content:'\e601'}.icon-collapse:after{content:'\e602'}.icon-failed-thick:after{content:'\e603'}.icon-failed:after{content:'\e604'}.icon-expand:after{content:'\e605'}.icon-warning:after{content:'\e606'}.icon-failed-round,.icon-success-round{border-radius:100%;color:#fff;font-size:2.5rem;height:1em;position:relative;text-align:center;width:1em}.icon-failed-round:after,.icon-success-round:after{bottom:0;font-size:.8em;left:0;position:absolute;right:0;top:.15em}.icon-success-round{background-color:#79a22e}.icon-success-round:after{content:'\e600'}.icon-failed-round{background-color:#e22626}.icon-failed-round:after{content:'\e603'}dl,ol,ul{margin-top:0}.list{margin-bottom:1em;padding-left:0}.list>li{display:block;margin-bottom:.75em;position:relative}.list>li>.icon-failed,.list>li>.icon-success{font-size:1.6em;left:-.1em;position:absolute;top:0}.list>li>.icon-success{color:#79a22e}.list>li>.icon-failed{color:#e22626}.list-item-failed,.list-item-icon,.list-item-success{padding-left:3.5rem}.list-item-failed:before,.list-item-success:before{font-family:Icons;font-size:1.6em;left:-.1em;position:absolute;top:-.2em}.list-item-success:before{color:#79a22e;content:'\e601'}.list-item-failed:before{color:#e22626;content:'\e604'}.list-definition{margin:0 0 3rem;padding:0}.list-definition>dt{clear:left;float:left}.list-definition>dd{margin-bottom:1em;margin-left:20rem}.btn-wrap{margin:0 auto}.btn-wrap .btn{width:100%}.btn{background:#e3e3e3;border:none;color:#514943;display:inline-block;font-size:1.6rem;font-weight:600;padding:.45em .5em;text-align:center}.btn:hover{background-color:#dbdbdb;color:#514943;text-decoration:none}.btn:active{background-color:#d6d6d6}.btn.disabled,.btn[disabled]{cursor:default;opacity:.5;pointer-events:none}.ie9 .btn.disabled,.ie9 .btn[disabled]{background-color:#f0f0f0;opacity:1;text-shadow:none}.btn-large{padding:.75em 1.25em}.btn-link{background-color:transparent;border:none;color:#008bdb;font-family:1.6rem;font-size:1.5rem}.btn-link:hover{background-color:transparent;color:#0fa7ff}.btn-prime{background-color:#eb5202;color:#fff;text-shadow:1px 1px 0 rgba(0,0,0,.25)}.btn-prime:hover{background-color:#f65405;background-repeat:repeat-x;background-image:linear-gradient(to right,#e04f00 0,#f65405 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#e04f00', endColorstr='#f65405', GradientType=1);color:#fff}.btn-prime:active{background-color:#e04f00;background-repeat:repeat-x;background-image:linear-gradient(to right,#f65405 0,#e04f00 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#f65405', endColorstr='#e04f00', GradientType=1)}.ie9 .btn-prime.disabled,.ie9 .btn-prime[disabled]{background-color:#fd6e23}.ie9 .btn-prime.disabled:active,.ie9 .btn-prime.disabled:hover,.ie9 .btn-prime[disabled]:active,.ie9 .btn-prime[disabled]:hover{background-color:#fd6e23;-webkit-filter:none;filter:none}.btn-secondary{background-color:#514943;color:#fff}.btn-secondary:hover{background-color:#5f564f;color:#fff}.btn-secondary:active{background-color:#574e48}.ie9 .btn-secondary.disabled,.ie9 .btn-secondary[disabled]{background-color:#514943}.ie9 .btn-secondary.disabled:active,.ie9 .btn-secondary.disabled:hover,.ie9 .btn-secondary[disabled]:active,.ie9 .btn-secondary[disabled]:hover{background-color:#514943;-webkit-filter:none;filter:none}[class*=btn-wrap-triangle]{overflow:hidden;position:relative}[class*=btn-wrap-triangle] .btn:after{border-style:solid;content:'';height:0;position:absolute;top:0;width:0}.btn-wrap-triangle-right{display:inline-block;padding-right:1.74rem;position:relative}.btn-wrap-triangle-right .btn{text-indent:.92rem}.btn-wrap-triangle-right .btn:after{border-color:transparent transparent transparent #e3e3e3;border-width:1.84rem 0 1.84rem 1.84rem;left:100%;margin-left:-1.74rem}.btn-wrap-triangle-right .btn:hover:after{border-left-color:#dbdbdb}.btn-wrap-triangle-right .btn:active:after{border-left-color:#d6d6d6}.btn-wrap-triangle-right .btn:not(.disabled):active,.btn-wrap-triangle-right .btn:not([disabled]):active{left:1px}.ie9 .btn-wrap-triangle-right .btn.disabled:after,.ie9 .btn-wrap-triangle-right .btn[disabled]:after{border-color:transparent transparent transparent #f0f0f0}.ie9 .btn-wrap-triangle-right .btn.disabled:active:after,.ie9 .btn-wrap-triangle-right .btn.disabled:hover:after,.ie9 .btn-wrap-triangle-right .btn[disabled]:active:after,.ie9 .btn-wrap-triangle-right .btn[disabled]:hover:after{border-left-color:#f0f0f0}.btn-wrap-triangle-right .btn-prime:after{border-color:transparent transparent transparent #eb5202}.btn-wrap-triangle-right .btn-prime:hover:after{border-left-color:#f65405}.btn-wrap-triangle-right .btn-prime:active:after{border-left-color:#e04f00}.btn-wrap-triangle-right .btn-prime:not(.disabled):active,.btn-wrap-triangle-right .btn-prime:not([disabled]):active{left:1px}.ie9 .btn-wrap-triangle-right .btn-prime.disabled:after,.ie9 .btn-wrap-triangle-right .btn-prime[disabled]:after{border-color:transparent transparent transparent #fd6e23}.ie9 .btn-wrap-triangle-right .btn-prime.disabled:active:after,.ie9 .btn-wrap-triangle-right .btn-prime.disabled:hover:after,.ie9 .btn-wrap-triangle-right .btn-prime[disabled]:active:after,.ie9 .btn-wrap-triangle-right .btn-prime[disabled]:hover:after{border-left-color:#fd6e23}.btn-wrap-triangle-left{display:inline-block;padding-left:1.74rem}.btn-wrap-triangle-left .btn{text-indent:-.92rem}.btn-wrap-triangle-left .btn:after{border-color:transparent #e3e3e3 transparent transparent;border-width:1.84rem 1.84rem 1.84rem 0;margin-right:-1.74rem;right:100%}.btn-wrap-triangle-left .btn:hover:after{border-right-color:#dbdbdb}.btn-wrap-triangle-left .btn:active:after{border-right-color:#d6d6d6}.btn-wrap-triangle-left .btn:not(.disabled):active,.btn-wrap-triangle-left .btn:not([disabled]):active{right:1px}.ie9 .btn-wrap-triangle-left .btn.disabled:after,.ie9 .btn-wrap-triangle-left .btn[disabled]:after{border-color:transparent #f0f0f0 transparent transparent}.ie9 .btn-wrap-triangle-left .btn.disabled:active:after,.ie9 .btn-wrap-triangle-left .btn.disabled:hover:after,.ie9 .btn-wrap-triangle-left .btn[disabled]:active:after,.ie9 .btn-wrap-triangle-left .btn[disabled]:hover:after{border-right-color:#f0f0f0}.btn-wrap-triangle-left .btn-prime:after{border-color:transparent #eb5202 transparent transparent}.btn-wrap-triangle-left .btn-prime:hover:after{border-right-color:#e04f00}.btn-wrap-triangle-left .btn-prime:active:after{border-right-color:#f65405}.btn-wrap-triangle-left .btn-prime:not(.disabled):active,.btn-wrap-triangle-left .btn-prime:not([disabled]):active{right:1px}.ie9 .btn-wrap-triangle-left .btn-prime.disabled:after,.ie9 .btn-wrap-triangle-left .btn-prime[disabled]:after{border-color:transparent #fd6e23 transparent transparent}.ie9 .btn-wrap-triangle-left .btn-prime.disabled:active:after,.ie9 .btn-wrap-triangle-left .btn-prime.disabled:hover:after,.ie9 .btn-wrap-triangle-left .btn-prime[disabled]:active:after,.ie9 .btn-wrap-triangle-left .btn-prime[disabled]:hover:after{border-right-color:#fd6e23}.btn-expand{background-color:transparent;border:none;color:#303030;font-family:'Open Sans','Helvetica Neue',Helvetica,Arial,sans-serif;font-size:1.4rem;font-weight:700;padding:0;position:relative}.btn-expand.expanded:after{border-color:transparent transparent #303030;border-width:0 .285em .36em}.btn-expand.expanded:hover:after{border-color:transparent transparent #3d3d3d}.btn-expand:hover{background-color:transparent;border:none;color:#3d3d3d}.btn-expand:hover:after{border-color:#3d3d3d transparent transparent}.btn-expand:after{border-color:#303030 transparent transparent;border-style:solid;border-width:.36em .285em 0;content:'';height:0;left:100%;margin-left:.5em;margin-top:-.18em;position:absolute;top:50%;width:0}[class*=col-] .form-el-input,[class*=col-] .form-el-select{width:100%}.form-fieldset{border:none;margin:0 0 1em;padding:0}.form-row{margin-bottom:2.2rem}.form-row .form-row{margin-bottom:.4rem}.form-row .form-label{display:block;font-weight:600;padding:.6rem 2.1em 0 0;text-align:right}.form-row .form-label.required{position:relative}.form-row .form-label.required:after{color:#eb5202;content:'*';font-size:1.15em;position:absolute;right:.7em;top:.5em}.form-row .form-el-checkbox+.form-label:before,.form-row .form-el-radio+.form-label:before{top:.7rem}.form-row .form-el-checkbox+.form-label:after,.form-row .form-el-radio+.form-label:after{top:1.1rem}input:not([disabled]):focus,textarea:not([disabled]):focus{box-shadow:none}.form-el-input{border:1px solid #adadad;border-radius:2px;color:#303030;padding:.35em .55em .5em}.form-el-input:hover{border-color:#949494}.form-el-input:focus{border-color:#008bdb}.form-label{margin-bottom:.5em}[class*=form-label][for]{cursor:pointer}.form-el-insider-wrap{display:table;width:100%}.form-el-insider-input{display:table-cell;width:100%}.form-el-insider{border-radius:2px;display:table-cell;vertical-align:top;padding:.43em .55em .5em 0}.form-legend,.form-legend-expand,.form-legend-light{display:block;margin:0}.form-legend,.form-legend-expand{margin-bottom:2.5em;padding-top:1.5em;font-weight:600;font-size:1.25em}.form-legend{width:100%;border-top:1px solid #ccc}.form-legend-light{margin-bottom:1.5em;font-size:1em}.form-legend-expand{transition:opacity .2s linear;cursor:pointer}.form-legend-expand:hover{opacity:.85}.form-legend-expand.expanded:after{content:'\e602'}.form-legend-expand:after{margin-left:.5em;font-weight:400;font-size:1.15em;font-family:Icons;content:'\e605';vertical-align:sub}.form-el-checkbox,.form-el-radio{border:0;clip:rect(0,0,0,0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.form-el-checkbox.disabled+.form-label,.form-el-checkbox.disabled+.form-label:before,.form-el-checkbox[disabled]+.form-label,.form-el-checkbox[disabled]+.form-label:before,.form-el-radio.disabled+.form-label,.form-el-radio.disabled+.form-label:before,.form-el-radio[disabled]+.form-label,.form-el-radio[disabled]+.form-label:before{cursor:default;opacity:.5;pointer-events:none}.form-el-checkbox:not(.disabled)+.form-label:hover:before,.form-el-checkbox:not([disabled])+.form-label:hover:before,.form-el-radio:not(.disabled)+.form-label:hover:before,.form-el-radio:not([disabled])+.form-label:hover:before{border-color:#514943}.form-el-checkbox+.form-label,.form-el-radio+.form-label{font-weight:400;padding-left:2em;padding-right:0;position:relative;text-align:left;transition:border-color .1s linear}.form-el-checkbox+.form-label:before,.form-el-radio+.form-label:before{border:1px solid;content:'';left:0;position:absolute;top:.1rem;transition:border-color .1s linear}.form-el-checkbox+.form-label:before{border-color:#adadad;border-radius:2px;height:1.4rem;line-height:1;width:1.4rem}.form-el-checkbox:checked+.form-label::before{content:'\e600';font-family:Icons}.form-el-radio+.form-label:before{background-color:#fff;border:1px solid #adadad;border-radius:100%;height:1.6rem;width:1.6rem}.form-el-radio+.form-label:after{background:0 0;border:.5rem solid transparent;border-radius:100%;content:'';height:0;left:.4rem;position:absolute;top:.5rem;transition:background .3s linear;width:0}.form-el-radio:checked+.form-label{cursor:default}.form-el-radio:checked+.form-label:after{border-color:#514943}.form-select-label{border:1px solid #adadad;border-radius:2px;color:#303030;cursor:pointer;display:block;overflow:hidden;position:relative}.form-select-label:hover,.form-select-label:hover:after{border-color:#949494}.form-select-label:active,.form-select-label:active:after,.form-select-label:focus,.form-select-label:focus:after{border-color:#008bdb}.form-select-label:after{background:#e3e3e3;border-left:1px solid #adadad;bottom:0;content:'';position:absolute;right:0;top:0;width:2.36em;z-index:-2}.ie9 .form-select-label:after{display:none}.form-select-label:before{border-color:#303030 transparent transparent;border-style:solid;border-width:5px 4px 0;content:'';height:0;margin-right:-4px;margin-top:-2.5px;position:absolute;right:1.18em;top:50%;width:0;z-index:-1}.ie9 .form-select-label:before{display:none}.form-select-label .form-el-select{background:0 0;border:none;border-radius:0;content:'';display:block;margin:0;padding:.35em calc(2.36em + 10%) .5em .55em;width:110%}.ie9 .form-select-label .form-el-select{padding-right:.55em;width:100%}.form-el-select{background:#fff;border:1px solid #adadad;border-radius:2px;color:#303030;display:block;padding:.35em .55em}.multiselect-custom{position:relative;height:45.2rem;border:1px solid #adadad;overflow:auto;margin:0 0 1.5rem}.multiselect-custom ul{margin:0;padding:0;list-style:none;min-width:29rem}.multiselect-custom .item{padding:1rem 1.4rem}.multiselect-custom .selected{background-color:#e0f6fe}.multiselect-custom .form-label{margin-bottom:0}[class*=form-el-].invalid{border-color:#e22626}[class*=form-el-].invalid+.error-container{display:block}.error-container{background-color:#fff8d6;border:1px solid #ee7d7d;border-radius:2px;color:#514943;display:none;font-size:1.19rem;margin-top:.2rem;padding:.4235em .6655em .605em}.check-result-message{margin-left:.5em;min-height:3.68rem;-webkit-align-items:center;-ms-align-items:center;-ms-flex-align:center;align-items:center;display:-webkit-flex;display:-ms-flexbox;display:flex}.check-result-text{margin-left:.5em}.pseudo-table{display:table}.pseudo-td{display:table-cell}.alert{margin-bottom:3.5rem;padding:2.5rem;-webkit-align-items:center;-ms-align-items:center;-ms-flex-align:center;align-items:center;display:-webkit-flex;display:-ms-flexbox;display:flex}.alert .spinner{min-width:1em}.ie9 .alert .spinner{float:left}.alert p:last-child{margin-bottom:0}.alert-info{background-color:#fafafa;border:1px solid #ccc}.alert-warning{background-color:#fff8d6;border:1px solid #fff8d6}.alert-icon{margin-right:1.5rem}.ie9 .alert-icon{float:left}[class*=icon-].alert-icon{font-size:3.8rem;min-width:3.8rem}.alert-text{margin-bottom:0}.alert-text~.alert-text{margin-top:1em}.ie9 .alert-text{display:block;margin-left:5.3rem;margin-top:1rem}.container{display:block;margin:0 auto 4rem;max-width:100rem;padding:0 2rem}.row{margin-left:0;margin-right:0}.col-l-1,.col-l-10,.col-l-11,.col-l-12,.col-l-2,.col-l-3,.col-l-4,.col-l-5,.col-l-6,.col-l-7,.col-l-8,.col-l-9,.col-m-1,.col-m-10,.col-m-11,.col-m-12,.col-m-2,.col-m-3,.col-m-4,.col-m-5,.col-m-6,.col-m-7,.col-m-8,.col-m-9,.col-xl-1,.col-xl-10,.col-xl-11,.col-xl-12,.col-xl-2,.col-xl-3,.col-xl-4,.col-xl-5,.col-xl-6,.col-xl-7,.col-xl-8,.col-xl-9,.col-xs-1,.col-xs-10,.col-xs-11,.col-xs-12,.col-xs-2,.col-xs-3,.col-xs-4,.col-xs-5,.col-xs-6,.col-xs-7,.col-xs-8,.col-xs-9{min-height:1px;padding-left:0;padding-right:0;position:relative}.col-xs-1,.col-xs-10,.col-xs-11,.col-xs-12,.col-xs-2,.col-xs-3,.col-xs-4,.col-xs-5,.col-xs-6,.col-xs-7,.col-xs-8,.col-xs-9{float:left}.col-xs-12{width:100%}.col-xs-11{width:91.66666667%}.col-xs-10{width:83.33333333%}.col-xs-9{width:75%}.col-xs-8{width:66.66666667%}.col-xs-7{width:58.33333333%}.col-xs-6{width:50%}.col-xs-5{width:41.66666667%}.col-xs-4{width:33.33333333%}.col-xs-3{width:25%}.col-xs-2{width:16.66666667%}.col-xs-1{width:8.33333333%}.col-xs-pull-12{right:100%}.col-xs-pull-11{right:91.66666667%}.col-xs-pull-10{right:83.33333333%}.col-xs-pull-9{right:75%}.col-xs-pull-8{right:66.66666667%}.col-xs-pull-7{right:58.33333333%}.col-xs-pull-6{right:50%}.col-xs-pull-5{right:41.66666667%}.col-xs-pull-4{right:33.33333333%}.col-xs-pull-3{right:25%}.col-xs-pull-2{right:16.66666667%}.col-xs-pull-1{right:8.33333333%}.col-xs-pull-0{right:auto}.col-xs-push-12{left:100%}.col-xs-push-11{left:91.66666667%}.col-xs-push-10{left:83.33333333%}.col-xs-push-9{left:75%}.col-xs-push-8{left:66.66666667%}.col-xs-push-7{left:58.33333333%}.col-xs-push-6{left:50%}.col-xs-push-5{left:41.66666667%}.col-xs-push-4{left:33.33333333%}.col-xs-push-3{left:25%}.col-xs-push-2{left:16.66666667%}.col-xs-push-1{left:8.33333333%}.col-xs-push-0{left:auto}.col-xs-offset-12{margin-left:100%}.col-xs-offset-11{margin-left:91.66666667%}.col-xs-offset-10{margin-left:83.33333333%}.col-xs-offset-9{margin-left:75%}.col-xs-offset-8{margin-left:66.66666667%}.col-xs-offset-7{margin-left:58.33333333%}.col-xs-offset-6{margin-left:50%}.col-xs-offset-5{margin-left:41.66666667%}.col-xs-offset-4{margin-left:33.33333333%}.col-xs-offset-3{margin-left:25%}.col-xs-offset-2{margin-left:16.66666667%}.col-xs-offset-1{margin-left:8.33333333%}.col-xs-offset-0{margin-left:0}.nav{background-color:#f8f8f8;border-bottom:1px solid #e3e3e3;border-top:1px solid #e3e3e3;display:none;padding:2.2rem 1.5rem 0 0}.nav .btn-group,.nav-bar-outer-actions{float:right;margin-bottom:1.7rem}.nav .btn-group .btn-wrap,.nav-bar-outer-actions .btn-wrap{float:right;margin-left:.5rem;margin-right:.5rem}.nav-bar-outer-actions{margin-top:-10.6rem;padding-right:1.5rem}.btn-wrap-try-again{width:9.5rem}.btn-wrap-next,.btn-wrap-prev{width:8.5rem}.nav-bar{counter-reset:i;float:left;margin:0 1rem 1.7rem 0;padding:0;position:relative;white-space:nowrap}.nav-bar:before{background-color:#d4d4d4;background-repeat:repeat-x;background-image:linear-gradient(to bottom,#d1d1d1 0,#d4d4d4 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#d1d1d1', endColorstr='#d4d4d4', GradientType=0);border-bottom:1px solid #d9d9d9;border-top:1px solid #bfbfbf;content:'';height:.8rem;left:5.15rem;position:absolute;right:5.15rem;top:.7rem}.nav-bar>li{display:inline-block;font-size:0;position:relative;vertical-align:top;width:10.3rem}.nav-bar>li:first-child:after{display:none}.nav-bar>li:after{background-color:#514943;content:'';height:.5rem;left:calc(-50% + .25rem);position:absolute;right:calc(50% + .7rem);top:.9rem}.nav-bar>li.disabled:before{bottom:0;content:'';left:0;position:absolute;right:0;top:0;z-index:1}.nav-bar>li.active~li:after{display:none}.nav-bar>li.active~li a:after{background-color:transparent;border-color:transparent;color:#a6a6a6}.nav-bar>li.active a{color:#000}.nav-bar>li.active a:hover{cursor:default}.nav-bar>li.active a:after{background-color:#fff;content:''}.nav-bar a{color:#514943;display:block;font-size:1.2rem;font-weight:600;line-height:1.2;overflow:hidden;padding:3rem .5em 0;position:relative;text-align:center;text-overflow:ellipsis}.nav-bar a:hover{text-decoration:none}.nav-bar a:after{background-color:#514943;border:.4rem solid #514943;border-radius:100%;color:#fff;content:counter(i);counter-increment:i;height:.7rem;left:50%;line-height:.6;margin-left:-.8rem;position:absolute;right:auto;text-align:center;top:.4rem;width:.7rem}.nav-bar a:before{background-color:#d6d6d6;border:1px solid transparent;border-bottom-color:#d9d9d9;border-radius:100%;border-top-color:#bfbfbf;content:'';height:2.1rem;left:50%;line-height:1;margin-left:-1.2rem;position:absolute;top:0;width:2.1rem}.tooltip{display:block;font-family:'Open Sans','Helvetica Neue',Helvetica,Arial,sans-serif;font-size:1.19rem;font-weight:400;line-height:1.4;opacity:0;position:absolute;visibility:visible;z-index:10}.tooltip.in{opacity:.9}.tooltip.top{margin-top:-4px;padding:8px 0}.tooltip.right{margin-left:4px;padding:0 8px}.tooltip.bottom{margin-top:4px;padding:8px 0}.tooltip.left{margin-left:-4px;padding:0 8px}.tooltip-inner{background-color:#fff;border:1px solid #adadad;border-radius:0;box-shadow:1px 1px 1px #ccc;color:#41362f;max-width:20rem;padding:.5em 1em;text-decoration:none}.tooltip-arrow,.tooltip-arrow:after{border:solid transparent;height:0;position:absolute;width:0}.tooltip-arrow:after{content:'';position:absolute}.tooltip.top .tooltip-arrow,.tooltip.top .tooltip-arrow:after{border-top-color:#949494;border-width:8px 8px 0;bottom:0;left:50%;margin-left:-8px}.tooltip.top-left .tooltip-arrow,.tooltip.top-left .tooltip-arrow:after{border-top-color:#949494;border-width:8px 8px 0;bottom:0;margin-bottom:-8px;right:8px}.tooltip.top-right .tooltip-arrow,.tooltip.top-right .tooltip-arrow:after{border-top-color:#949494;border-width:8px 8px 0;bottom:0;left:8px;margin-bottom:-8px}.tooltip.right .tooltip-arrow,.tooltip.right .tooltip-arrow:after{border-right-color:#949494;border-width:8px 8px 8px 0;left:1px;margin-top:-8px;top:50%}.tooltip.right .tooltip-arrow:after{border-right-color:#fff;border-width:6px 7px 6px 0;margin-left:0;margin-top:-6px}.tooltip.left .tooltip-arrow,.tooltip.left .tooltip-arrow:after{border-left-color:#949494;border-width:8px 0 8px 8px;margin-top:-8px;right:0;top:50%}.tooltip.bottom .tooltip-arrow,.tooltip.bottom .tooltip-arrow:after{border-bottom-color:#949494;border-width:0 8px 8px;left:50%;margin-left:-8px;top:0}.tooltip.bottom-left .tooltip-arrow,.tooltip.bottom-left .tooltip-arrow:after{border-bottom-color:#949494;border-width:0 8px 8px;margin-top:-8px;right:8px;top:0}.tooltip.bottom-right .tooltip-arrow,.tooltip.bottom-right .tooltip-arrow:after{border-bottom-color:#949494;border-width:0 8px 8px;left:8px;margin-top:-8px;top:0}.password-strength{display:block;margin:0 -.3rem 1em;white-space:nowrap}.password-strength.password-strength-too-short .password-strength-item:first-child,.password-strength.password-strength-weak .password-strength-item:first-child,.password-strength.password-strength-weak .password-strength-item:first-child+.password-strength-item{background-color:#e22626}.password-strength.password-strength-fair .password-strength-item:first-child,.password-strength.password-strength-fair .password-strength-item:first-child+.password-strength-item,.password-strength.password-strength-fair .password-strength-item:first-child+.password-strength-item+.password-strength-item{background-color:#ef672f}.password-strength.password-strength-good .password-strength-item:first-child,.password-strength.password-strength-good .password-strength-item:first-child+.password-strength-item,.password-strength.password-strength-good .password-strength-item:first-child+.password-strength-item+.password-strength-item,.password-strength.password-strength-good .password-strength-item:first-child+.password-strength-item+.password-strength-item+.password-strength-item,.password-strength.password-strength-strong .password-strength-item{background-color:#79a22e}.password-strength .password-strength-item{background-color:#ccc;display:inline-block;font-size:0;height:1.4rem;margin-right:.3rem;width:calc(20% - .6rem)}@-webkit-keyframes progress-bar-stripes{from{background-position:4rem 0}to{background-position:0 0}}@keyframes progress-bar-stripes{from{background-position:4rem 0}to{background-position:0 0}}.progress{background-color:#fafafa;border:1px solid #ccc;height:3rem;margin-bottom:3rem;overflow:hidden}.progress-bar{background-color:#79a22e;color:#fff;float:left;font-size:1.19rem;height:100%;line-height:3rem;text-align:center;transition:width .6s ease;width:0}.progress-bar.active{-webkit-animation:progress-bar-stripes 2s linear infinite;-o-animation:progress-bar-stripes 2s linear infinite;animation:progress-bar-stripes 2s linear infinite}.spinner{display:inline-block;font-size:4rem;height:1em;margin-right:1.5rem;position:relative;width:1em}@-webkit-keyframes fade{0%{background-color:#514943}100%{background-color:#fff}}@keyframes fade{0%{background-color:#514943}100%{background-color:#fff}}.spinner>span:nth-child(1){-webkit-animation-delay:.27s;animation-delay:.27s;-webkit-transform:rotate(-315deg);-ms-transform:rotate(-315deg);transform:rotate(-315deg)}.spinner>span:nth-child(2){-webkit-animation-delay:.36s;animation-delay:.36s;-webkit-transform:rotate(-270deg);-ms-transform:rotate(-270deg);transform:rotate(-270deg)}.spinner>span:nth-child(3){-webkit-animation-delay:.45s;animation-delay:.45s;-webkit-transform:rotate(-225deg);-ms-transform:rotate(-225deg);transform:rotate(-225deg)}.spinner>span:nth-child(4){-webkit-animation-delay:.54s;animation-delay:.54s;-webkit-transform:rotate(-180deg);-ms-transform:rotate(-180deg);transform:rotate(-180deg)}.spinner>span:nth-child(5){-webkit-animation-delay:.63s;animation-delay:.63s;-webkit-transform:rotate(-135deg);-ms-transform:rotate(-135deg);transform:rotate(-135deg)}.spinner>span:nth-child(6){-webkit-animation-delay:.72s;animation-delay:.72s;-webkit-transform:rotate(-90deg);-ms-transform:rotate(-90deg);transform:rotate(-90deg)}.spinner>span:nth-child(7){-webkit-animation-delay:.81s;animation-delay:.81s;-webkit-transform:rotate(-45deg);-ms-transform:rotate(-45deg);transform:rotate(-45deg)}.spinner>span:nth-child(8){-webkit-animation-delay:.9;animation-delay:.9;-webkit-transform:rotate(0deg);-ms-transform:rotate(0deg);transform:rotate(0deg)}.spinner>span{-webkit-animation-direction:linear;animation-direction:linear;-webkit-animation-duration:.72s;animation-duration:.72s;-webkit-animation-iteration-count:infinite;animation-iteration-count:infinite;-webkit-animation-name:fade;animation-name:fade;-webkit-transform:scale(0.4);-ms-transform:scale(0.4);transform:scale(0.4);background-color:#fff;border-radius:6px;clip:rect(0 .28571429em .1em 0);height:.1em;margin-top:.5em;position:absolute;width:1em}.ie9 .spinner{background:url(../../pub/images/ajax-loader.gif) center no-repeat}.ie9 .spinner>span{display:none}.main{padding-bottom:2rem;padding-top:3rem}.header{display:none}.header .logo{float:left;height:4.1rem;width:3.5rem}.header-title{font-size:2.8rem;letter-spacing:.02em;margin:2.5rem 0 3.5rem 5rem}.page-title{font-size:2rem;margin-bottom:1.3em}.accent-box{margin-bottom:2rem}.accent-box .btn-prime{margin-top:1.5rem}.page-landing{margin:7.6% auto 0;max-width:44rem;text-align:center}.page-landing .logo{height:5.6rem;margin-bottom:2rem;width:19.2rem}.page-landing .text-version{margin-bottom:3rem}.page-landing .text-welcome{margin-bottom:6.5rem}.page-landing .text-terms{margin-bottom:2.5rem;text-align:center}.page-landing .btn-submit{margin-bottom:20px}.page-license .license-text{margin-bottom:2rem}.page-license .page-license-footer{text-align:right}.rediness-check-item{margin-bottom:4rem}.readiness-check-title{font-size:1.4rem;font-weight:700;margin-bottom:.1rem;margin-left:7.5rem}.readiness-check-content{margin-left:7.5rem;margin-right:22rem}.readiness-check-content .readiness-check-title{margin-left:0}.readiness-check-content .list{margin-top:-.3rem}.rediness-check-side{float:right;padding-left:2.4rem;width:22rem}.rediness-check-side .side-title{margin-bottom:0}.readiness-check-icon{float:left;margin-left:2rem;margin-top:.7rem}.page-web-configuration .form-el-insider-wrap{width:auto}.page-web-configuration .form-el-insider{width:15.4rem}.page-web-configuration .form-el-insider-input .form-el-input{width:16.5rem}.customize-your-store .customize-your-store-default .legend{border:0;clip:rect(0,0,0,0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.customize-your-store .advanced-modules-count,.customize-your-store .advanced-modules-select{padding-left:1.5rem}.customize-your-store .customize-your-store-advanced{min-width:0}.content-install{margin-bottom:2rem}.console{border:1px solid #ccc;font-family:'Courier New',Courier,monospace;font-weight:300;margin:1rem 0 2rem;max-height:20rem;overflow-y:auto;padding:1.5rem 2rem 2rem}.console .text-danger{color:#e22626}.console .text-success{color:#090}.console .hidden{display:none}.content-success .btn-prime{margin-top:1.5rem}.jumbo-title{font-size:3.6rem}.jumbo-title .jumbo-icon{font-size:3.8rem;margin-right:.25em;position:relative;top:.15em}@media all and (max-width:1047px){.nav{padding-bottom:5.38rem;padding-left:1.5rem;text-align:center}.nav-bar{display:inline-block;float:none;margin-right:0;vertical-align:top}.nav .btn-group,.nav-bar-outer-actions{display:inline-block;float:none;margin-top:-8.48rem;text-align:center;vertical-align:top;width:100%}.nav-bar-outer-actions{padding-right:0}.nav-bar-outer-actions .outer-actions-inner-wrap{display:inline-block}}@media all and (min-width:768px){html{margin-left:calc(100vw - 100%);margin-right:0;overflow:auto}.col-m-1,.col-m-10,.col-m-11,.col-m-12,.col-m-2,.col-m-3,.col-m-4,.col-m-5,.col-m-6,.col-m-7,.col-m-8,.col-m-9{float:left}.col-m-12{width:100%}.col-m-11{width:91.66666667%}.col-m-10{width:83.33333333%}.col-m-9{width:75%}.col-m-8{width:66.66666667%}.col-m-7{width:58.33333333%}.col-m-6{width:50%}.col-m-5{width:41.66666667%}.col-m-4{width:33.33333333%}.col-m-3{width:25%}.col-m-2{width:16.66666667%}.col-m-1{width:8.33333333%}.col-m-pull-12{right:100%}.col-m-pull-11{right:91.66666667%}.col-m-pull-10{right:83.33333333%}.col-m-pull-9{right:75%}.col-m-pull-8{right:66.66666667%}.col-m-pull-7{right:58.33333333%}.col-m-pull-6{right:50%}.col-m-pull-5{right:41.66666667%}.col-m-pull-4{right:33.33333333%}.col-m-pull-3{right:25%}.col-m-pull-2{right:16.66666667%}.col-m-pull-1{right:8.33333333%}.col-m-pull-0{right:auto}.col-m-push-12{left:100%}.col-m-push-11{left:91.66666667%}.col-m-push-10{left:83.33333333%}.col-m-push-9{left:75%}.col-m-push-8{left:66.66666667%}.col-m-push-7{left:58.33333333%}.col-m-push-6{left:50%}.col-m-push-5{left:41.66666667%}.col-m-push-4{left:33.33333333%}.col-m-push-3{left:25%}.col-m-push-2{left:16.66666667%}.col-m-push-1{left:8.33333333%}.col-m-push-0{left:auto}.col-m-offset-12{margin-left:100%}.col-m-offset-11{margin-left:91.66666667%}.col-m-offset-10{margin-left:83.33333333%}.col-m-offset-9{margin-left:75%}.col-m-offset-8{margin-left:66.66666667%}.col-m-offset-7{margin-left:58.33333333%}.col-m-offset-6{margin-left:50%}.col-m-offset-5{margin-left:41.66666667%}.col-m-offset-4{margin-left:33.33333333%}.col-m-offset-3{margin-left:25%}.col-m-offset-2{margin-left:16.66666667%}.col-m-offset-1{margin-left:8.33333333%}.col-m-offset-0{margin-left:0}}@media all and (min-width:1048px){.col-l-1,.col-l-10,.col-l-11,.col-l-12,.col-l-2,.col-l-3,.col-l-4,.col-l-5,.col-l-6,.col-l-7,.col-l-8,.col-l-9{float:left}.col-l-12{width:100%}.col-l-11{width:91.66666667%}.col-l-10{width:83.33333333%}.col-l-9{width:75%}.col-l-8{width:66.66666667%}.col-l-7{width:58.33333333%}.col-l-6{width:50%}.col-l-5{width:41.66666667%}.col-l-4{width:33.33333333%}.col-l-3{width:25%}.col-l-2{width:16.66666667%}.col-l-1{width:8.33333333%}.col-l-pull-12{right:100%}.col-l-pull-11{right:91.66666667%}.col-l-pull-10{right:83.33333333%}.col-l-pull-9{right:75%}.col-l-pull-8{right:66.66666667%}.col-l-pull-7{right:58.33333333%}.col-l-pull-6{right:50%}.col-l-pull-5{right:41.66666667%}.col-l-pull-4{right:33.33333333%}.col-l-pull-3{right:25%}.col-l-pull-2{right:16.66666667%}.col-l-pull-1{right:8.33333333%}.col-l-pull-0{right:auto}.col-l-push-12{left:100%}.col-l-push-11{left:91.66666667%}.col-l-push-10{left:83.33333333%}.col-l-push-9{left:75%}.col-l-push-8{left:66.66666667%}.col-l-push-7{left:58.33333333%}.col-l-push-6{left:50%}.col-l-push-5{left:41.66666667%}.col-l-push-4{left:33.33333333%}.col-l-push-3{left:25%}.col-l-push-2{left:16.66666667%}.col-l-push-1{left:8.33333333%}.col-l-push-0{left:auto}.col-l-offset-12{margin-left:100%}.col-l-offset-11{margin-left:91.66666667%}.col-l-offset-10{margin-left:83.33333333%}.col-l-offset-9{margin-left:75%}.col-l-offset-8{margin-left:66.66666667%}.col-l-offset-7{margin-left:58.33333333%}.col-l-offset-6{margin-left:50%}.col-l-offset-5{margin-left:41.66666667%}.col-l-offset-4{margin-left:33.33333333%}.col-l-offset-3{margin-left:25%}.col-l-offset-2{margin-left:16.66666667%}.col-l-offset-1{margin-left:8.33333333%}.col-l-offset-0{margin-left:0}}@media all and (min-width:1440px){.col-xl-1,.col-xl-10,.col-xl-11,.col-xl-12,.col-xl-2,.col-xl-3,.col-xl-4,.col-xl-5,.col-xl-6,.col-xl-7,.col-xl-8,.col-xl-9{float:left}.col-xl-12{width:100%}.col-xl-11{width:91.66666667%}.col-xl-10{width:83.33333333%}.col-xl-9{width:75%}.col-xl-8{width:66.66666667%}.col-xl-7{width:58.33333333%}.col-xl-6{width:50%}.col-xl-5{width:41.66666667%}.col-xl-4{width:33.33333333%}.col-xl-3{width:25%}.col-xl-2{width:16.66666667%}.col-xl-1{width:8.33333333%}.col-xl-pull-12{right:100%}.col-xl-pull-11{right:91.66666667%}.col-xl-pull-10{right:83.33333333%}.col-xl-pull-9{right:75%}.col-xl-pull-8{right:66.66666667%}.col-xl-pull-7{right:58.33333333%}.col-xl-pull-6{right:50%}.col-xl-pull-5{right:41.66666667%}.col-xl-pull-4{right:33.33333333%}.col-xl-pull-3{right:25%}.col-xl-pull-2{right:16.66666667%}.col-xl-pull-1{right:8.33333333%}.col-xl-pull-0{right:auto}.col-xl-push-12{left:100%}.col-xl-push-11{left:91.66666667%}.col-xl-push-10{left:83.33333333%}.col-xl-push-9{left:75%}.col-xl-push-8{left:66.66666667%}.col-xl-push-7{left:58.33333333%}.col-xl-push-6{left:50%}.col-xl-push-5{left:41.66666667%}.col-xl-push-4{left:33.33333333%}.col-xl-push-3{left:25%}.col-xl-push-2{left:16.66666667%}.col-xl-push-1{left:8.33333333%}.col-xl-push-0{left:auto}.col-xl-offset-12{margin-left:100%}.col-xl-offset-11{margin-left:91.66666667%}.col-xl-offset-10{margin-left:83.33333333%}.col-xl-offset-9{margin-left:75%}.col-xl-offset-8{margin-left:66.66666667%}.col-xl-offset-7{margin-left:58.33333333%}.col-xl-offset-6{margin-left:50%}.col-xl-offset-5{margin-left:41.66666667%}.col-xl-offset-4{margin-left:33.33333333%}.col-xl-offset-3{margin-left:25%}.col-xl-offset-2{margin-left:16.66666667%}.col-xl-offset-1{margin-left:8.33333333%}.col-xl-offset-0{margin-left:0}}@media all and (max-width:767px){.list-definition>dt{float:none}.list-definition>dd{margin-left:0}.form-row .form-label{text-align:left}.form-row .form-label.required:after{position:static}.nav{padding-bottom:0;padding-left:0;padding-right:0}.nav-bar-outer-actions{margin-top:0}.nav-bar{display:block;margin-bottom:0;margin-left:auto;margin-right:auto;width:30.9rem}.nav-bar:before{display:none}.nav-bar>li{float:left;min-height:9rem}.nav-bar>li:after{display:none}.nav-bar>li:nth-child(4n){clear:both}.nav-bar a{line-height:1.4}.tooltip{display:none!important}.readiness-check-content{margin-right:2rem}.form-el-insider,.form-el-insider-wrap,.page-web-configuration .form-el-insider-input,.page-web-configuration .form-el-insider-input .form-el-input{display:block;width:100%}}@media all and (max-width:479px){.nav-bar{width:23.175rem}.nav-bar>li{width:7.725rem}.nav .btn-group .btn-wrap-try-again,.nav-bar-outer-actions .btn-wrap-try-again{clear:both;display:block;float:none;margin-left:auto;margin-right:auto;margin-top:1rem;padding-top:1rem}} \ No newline at end of file +html{font-family:sans-serif;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%;font-size-adjust:100%}body{margin:0}article,aside,details,figcaption,figure,footer,header,main,nav,section,summary{display:block}audio,canvas,progress,video{display:inline-block;vertical-align:baseline}audio:not([controls]){display:none;height:0}template{display:none}a{background:0 0}a:active,a:hover{outline:0}abbr[title]{border-bottom:1px dotted}b,strong{font-weight:700}dfn{font-style:italic}h1{font-size:2em;margin:.67em 0}mark{background:#ff0;color:#000}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sup{top:-.5em}sub{bottom:-.25em}img{border:0}svg:not(:root){overflow:hidden}figure{margin:1em 40px}hr{box-sizing:content-box;height:0}pre{overflow:auto}code,kbd,pre,samp{font-family:monospace,monospace;font-size:1em}button,input,optgroup,select,textarea{color:inherit;font:inherit;margin:0}button{overflow:visible}button,select{text-transform:none}button,html input[type=button],input[type=reset],input[type=submit]{-webkit-appearance:button;cursor:pointer}button[disabled],html input[disabled]{cursor:default}button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0}input{line-height:normal}input[type=checkbox],input[type=radio]{box-sizing:border-box;padding:0}input[type=number]::-webkit-inner-spin-button,input[type=number]::-webkit-outer-spin-button{height:auto}input[type=search]{box-sizing:content-box}input[type=search]::-webkit-search-cancel-button,input[type=search]::-webkit-search-decoration{-webkit-appearance:none}fieldset{border:1px solid silver;margin:0 2px;padding:.35em .625em .75em}legend{border:0;padding:0}textarea{overflow:auto}optgroup{font-weight:700}table{border-collapse:collapse;border-spacing:0}td,th{padding:0}*{box-sizing:border-box}:focus{box-shadow:none;outline:0}.keyfocus :focus{box-shadow:0 0 0 1px #008bdb}embed,img,object,video{max-width:100%}.abs-clearer:after,.form-row:after,.header:after,.nav:after,.row:after{content:"";display:table;clear:both}.ng-cloak{display:none!important}.hide.hide{display:none}.show.show{display:block}.text-center{text-align:center}.text-right{text-align:right}@font-face{font-family:'Open Sans';src:url(../../pub/fonts/opensans/light/opensans-300.eot);src:url(../../pub/fonts/opensans/light/opensans-300.eot?#iefix) format('embedded-opentype'),url(../../pub/fonts/opensans/light/opensans-300.woff2) format('woff2'),url(../../pub/fonts/opensans/light/opensans-300.woff) format('woff'),url(../../pub/fonts/opensans/light/opensans-300.ttf) format('truetype'),url('../../pub/fonts/opensans/light/opensans-300.svg#Open Sans') format('svg');font-weight:300;font-style:normal}@font-face{font-family:'Open Sans';src:url(../../pub/fonts/opensans/regular/opensans-400.eot);src:url(../../pub/fonts/opensans/regular/opensans-400.eot?#iefix) format('embedded-opentype'),url(../../pub/fonts/opensans/regular/opensans-400.woff2) format('woff2'),url(../../pub/fonts/opensans/regular/opensans-400.woff) format('woff'),url(../../pub/fonts/opensans/regular/opensans-400.ttf) format('truetype'),url('../../pub/fonts/opensans/regular/opensans-400.svg#Open Sans') format('svg');font-weight:400;font-style:normal}@font-face{font-family:'Open Sans';src:url(../../pub/fonts/opensans/semibold/opensans-600.eot);src:url(../../pub/fonts/opensans/semibold/opensans-600.eot?#iefix) format('embedded-opentype'),url(../../pub/fonts/opensans/semibold/opensans-600.woff2) format('woff2'),url(../../pub/fonts/opensans/semibold/opensans-600.woff) format('woff'),url(../../pub/fonts/opensans/semibold/opensans-600.ttf) format('truetype'),url('../../pub/fonts/opensans/semibold/opensans-600.svg#Open Sans') format('svg');font-weight:600;font-style:normal}@font-face{font-family:'Open Sans';src:url(../../pub/fonts/opensans/bold/opensans-700.eot);src:url(../../pub/fonts/opensans/bold/opensans-700.eot?#iefix) format('embedded-opentype'),url(../../pub/fonts/opensans/bold/opensans-700.woff2) format('woff2'),url(../../pub/fonts/opensans/bold/opensans-700.woff) format('woff'),url(../../pub/fonts/opensans/bold/opensans-700.ttf) format('truetype'),url('../../pub/fonts/opensans/bold/opensans-700.svg#Open Sans') format('svg');font-weight:700;font-style:normal}html{font-size:62.5%}body{color:#303030;font-family:'Open Sans','Helvetica Neue',Helvetica,Arial,sans-serif;font-size:1.4rem;font-weight:400;line-height:1.4}h1,h2,h3,h4,h5,h6{font-weight:400;margin-top:0}p{margin:0 0 1em}a{color:#008bdb;text-decoration:none}a:hover{color:#0fa7ff;text-decoration:underline}@font-face{font-family:Icons;src:url(../../pub/fonts/icons/icons.eot);src:url(../../pub/fonts/icons/icons.eot?#iefix) format('embedded-opentype'),url(../../pub/fonts/icons/icons.woff2) format('woff2'),url(../../pub/fonts/icons/icons.woff) format('woff'),url(../../pub/fonts/icons/icons.ttf) format('truetype'),url(../../pub/fonts/icons/icons.svg#Icons) format('svg');font-weight:400;font-style:normal}[class*=icon-]{display:inline-block;line-height:1}[class*=icon-]:after{font-family:Icons}.icon-success-thick:after{content:'\e600'}.icon-success:after{content:'\e601'}.icon-collapse:after{content:'\e602'}.icon-failed-thick:after{content:'\e603'}.icon-failed:after{content:'\e604'}.icon-expand:after{content:'\e605'}.icon-warning:after{content:'\e606'}.icon-failed-round,.icon-success-round{border-radius:100%;color:#fff;font-size:2.5rem;height:1em;position:relative;text-align:center;width:1em}.icon-failed-round:after,.icon-success-round:after{bottom:0;font-size:.8em;left:0;position:absolute;right:0;top:.15em}.icon-success-round{background-color:#79a22e}.icon-success-round:after{content:'\e600'}.icon-failed-round{background-color:#e22626}.icon-failed-round:after{content:'\e603'}dl,ol,ul{margin-top:0}.list{margin-bottom:1em;padding-left:0}.list>li{display:block;margin-bottom:.75em;position:relative}.list>li>.icon-failed,.list>li>.icon-success{font-size:1.6em;left:-.1em;position:absolute;top:0}.list>li>.icon-success{color:#79a22e}.list>li>.icon-failed{color:#e22626}.list-item-failed,.list-item-icon,.list-item-success{padding-left:3.5rem}.list-item-failed:before,.list-item-success:before{font-family:Icons;font-size:1.6em;left:-.1em;position:absolute;top:-.2em}.list-item-success:before{color:#79a22e;content:'\e601'}.list-item-failed:before{color:#e22626;content:'\e604'}.list-definition{margin:0 0 3rem;padding:0}.list-definition>dt{clear:left;float:left}.list-definition>dd{margin-bottom:1em;margin-left:20rem}.btn-wrap{margin:0 auto}.btn-wrap .btn{width:100%}.btn{background:#e3e3e3;border:none;color:#514943;display:inline-block;font-size:1.6rem;font-weight:600;padding:.45em .5em;text-align:center}.btn:hover{background-color:#dbdbdb;color:#514943;text-decoration:none}.btn:active{background-color:#d6d6d6}.btn.disabled,.btn[disabled]{cursor:default;opacity:.5;pointer-events:none}.ie9 .btn.disabled,.ie9 .btn[disabled]{background-color:#f0f0f0;opacity:1;text-shadow:none}.btn-large{padding:.75em 1.25em}.btn-link{background-color:transparent;border:none;color:#008bdb;font-family:1.6rem;font-size:1.5rem}.btn-link:hover{background-color:transparent;color:#0fa7ff}.btn-prime{background-color:#eb5202;color:#fff;text-shadow:1px 1px 0 rgba(0,0,0,.25)}.btn-prime:hover{background-color:#f65405;background-repeat:repeat-x;background-image:-webkit-linear-gradient(left,color-stop(#e04f00 0),color-stop(#f65405 100%));background-image:linear-gradient(to right,#e04f00 0,#f65405 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#e04f00', endColorstr='#f65405', GradientType=1);color:#fff}.btn-prime:active{background-color:#e04f00;background-repeat:repeat-x;background-image:-webkit-linear-gradient(left,color-stop(#f65405 0),color-stop(#e04f00 100%));background-image:linear-gradient(to right,#f65405 0,#e04f00 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#f65405', endColorstr='#e04f00', GradientType=1)}.ie9 .btn-prime.disabled,.ie9 .btn-prime[disabled]{background-color:#fd6e23}.ie9 .btn-prime.disabled:active,.ie9 .btn-prime.disabled:hover,.ie9 .btn-prime[disabled]:active,.ie9 .btn-prime[disabled]:hover{background-color:#fd6e23;filter:none}.btn-secondary{background-color:#514943;color:#fff}.btn-secondary:hover{background-color:#5f564f;color:#fff}.btn-secondary:active{background-color:#574e48}.ie9 .btn-secondary.disabled,.ie9 .btn-secondary[disabled]{background-color:#514943}.ie9 .btn-secondary.disabled:active,.ie9 .btn-secondary.disabled:hover,.ie9 .btn-secondary[disabled]:active,.ie9 .btn-secondary[disabled]:hover{background-color:#514943;filter:none}[class*=btn-wrap-triangle]{overflow:hidden;position:relative}[class*=btn-wrap-triangle] .btn:after{border-style:solid;content:'';height:0;position:absolute;top:0;width:0}.btn-wrap-triangle-right{display:inline-block;padding-right:1.74rem;position:relative}.btn-wrap-triangle-right .btn{text-indent:.92rem}.btn-wrap-triangle-right .btn:after{border-color:transparent transparent transparent #e3e3e3;border-width:1.84rem 0 1.84rem 1.84rem;left:100%;margin-left:-1.74rem}.btn-wrap-triangle-right .btn:hover:after{border-left-color:#dbdbdb}.btn-wrap-triangle-right .btn:active:after{border-left-color:#d6d6d6}.btn-wrap-triangle-right .btn:not(.disabled):active,.btn-wrap-triangle-right .btn:not([disabled]):active{left:1px}.ie9 .btn-wrap-triangle-right .btn.disabled:after,.ie9 .btn-wrap-triangle-right .btn[disabled]:after{border-color:transparent transparent transparent #f0f0f0}.ie9 .btn-wrap-triangle-right .btn.disabled:active:after,.ie9 .btn-wrap-triangle-right .btn.disabled:hover:after,.ie9 .btn-wrap-triangle-right .btn[disabled]:active:after,.ie9 .btn-wrap-triangle-right .btn[disabled]:hover:after{border-left-color:#f0f0f0}.btn-wrap-triangle-right .btn-prime:after{border-color:transparent transparent transparent #eb5202}.btn-wrap-triangle-right .btn-prime:hover:after{border-left-color:#f65405}.btn-wrap-triangle-right .btn-prime:active:after{border-left-color:#e04f00}.btn-wrap-triangle-right .btn-prime:not(.disabled):active,.btn-wrap-triangle-right .btn-prime:not([disabled]):active{left:1px}.ie9 .btn-wrap-triangle-right .btn-prime.disabled:after,.ie9 .btn-wrap-triangle-right .btn-prime[disabled]:after{border-color:transparent transparent transparent #fd6e23}.ie9 .btn-wrap-triangle-right .btn-prime.disabled:active:after,.ie9 .btn-wrap-triangle-right .btn-prime.disabled:hover:after,.ie9 .btn-wrap-triangle-right .btn-prime[disabled]:active:after,.ie9 .btn-wrap-triangle-right .btn-prime[disabled]:hover:after{border-left-color:#fd6e23}.btn-wrap-triangle-left{display:inline-block;padding-left:1.74rem}.btn-wrap-triangle-left .btn{text-indent:-.92rem}.btn-wrap-triangle-left .btn:after{border-color:transparent #e3e3e3 transparent transparent;border-width:1.84rem 1.84rem 1.84rem 0;margin-right:-1.74rem;right:100%}.btn-wrap-triangle-left .btn:hover:after{border-right-color:#dbdbdb}.btn-wrap-triangle-left .btn:active:after{border-right-color:#d6d6d6}.btn-wrap-triangle-left .btn:not(.disabled):active,.btn-wrap-triangle-left .btn:not([disabled]):active{right:1px}.ie9 .btn-wrap-triangle-left .btn.disabled:after,.ie9 .btn-wrap-triangle-left .btn[disabled]:after{border-color:transparent #f0f0f0 transparent transparent}.ie9 .btn-wrap-triangle-left .btn.disabled:active:after,.ie9 .btn-wrap-triangle-left .btn.disabled:hover:after,.ie9 .btn-wrap-triangle-left .btn[disabled]:active:after,.ie9 .btn-wrap-triangle-left .btn[disabled]:hover:after{border-right-color:#f0f0f0}.btn-wrap-triangle-left .btn-prime:after{border-color:transparent #eb5202 transparent transparent}.btn-wrap-triangle-left .btn-prime:hover:after{border-right-color:#e04f00}.btn-wrap-triangle-left .btn-prime:active:after{border-right-color:#f65405}.btn-wrap-triangle-left .btn-prime:not(.disabled):active,.btn-wrap-triangle-left .btn-prime:not([disabled]):active{right:1px}.ie9 .btn-wrap-triangle-left .btn-prime.disabled:after,.ie9 .btn-wrap-triangle-left .btn-prime[disabled]:after{border-color:transparent #fd6e23 transparent transparent}.ie9 .btn-wrap-triangle-left .btn-prime.disabled:active:after,.ie9 .btn-wrap-triangle-left .btn-prime.disabled:hover:after,.ie9 .btn-wrap-triangle-left .btn-prime[disabled]:active:after,.ie9 .btn-wrap-triangle-left .btn-prime[disabled]:hover:after{border-right-color:#fd6e23}.btn-expand{background-color:transparent;border:none;color:#303030;font-family:'Open Sans','Helvetica Neue',Helvetica,Arial,sans-serif;font-size:1.4rem;font-weight:700;padding:0;position:relative}.btn-expand.expanded:after{border-color:transparent transparent #303030;border-width:0 .285em .36em}.btn-expand.expanded:hover:after{border-color:transparent transparent #3d3d3d}.btn-expand:hover{background-color:transparent;border:none;color:#3d3d3d}.btn-expand:hover:after{border-color:#3d3d3d transparent transparent}.btn-expand:after{border-color:#303030 transparent transparent;border-style:solid;border-width:.36em .285em 0;content:'';height:0;left:100%;margin-left:.5em;margin-top:-.18em;position:absolute;top:50%;width:0}[class*=col-] .form-el-input,[class*=col-] .form-el-select{width:100%}.form-fieldset{border:none;margin:0 0 1em;padding:0}.form-row{margin-bottom:2.2rem}.form-row .form-row{margin-bottom:.4rem}.form-row .form-label{display:block;font-weight:600;padding:.6rem 2.1em 0 0;text-align:right}.form-row .form-label.required{position:relative}.form-row .form-label.required:after{color:#eb5202;content:'*';font-size:1.15em;position:absolute;right:.7em;top:.5em}.form-row .form-el-checkbox+.form-label:before,.form-row .form-el-radio+.form-label:before{top:.7rem}.form-row .form-el-checkbox+.form-label:after,.form-row .form-el-radio+.form-label:after{top:1.1rem}input:not([disabled]):focus,textarea:not([disabled]):focus{box-shadow:none}.form-el-input{border:1px solid #adadad;border-radius:2px;color:#303030;padding:.35em .55em .5em}.form-el-input:hover{border-color:#949494}.form-el-input:focus{border-color:#008bdb}.form-label{margin-bottom:.5em}[class*=form-label][for]{cursor:pointer}.form-el-insider-wrap{display:table;width:100%}.form-el-insider-input{display:table-cell;width:100%}.form-el-insider{border-radius:2px;display:table-cell;vertical-align:top;padding:.43em .55em .5em 0}.form-legend,.form-legend-expand,.form-legend-light{display:block;margin:0}.form-legend,.form-legend-expand{margin-bottom:2.5em;padding-top:1.5em;font-weight:600;font-size:1.25em}.form-legend{width:100%;border-top:1px solid #ccc}.form-legend-light{margin-bottom:1.5em;font-size:1em}.form-legend-expand{transition:opacity .2s linear;cursor:pointer}.form-legend-expand:hover{opacity:.85}.form-legend-expand.expanded:after{content:'\e602'}.form-legend-expand:after{margin-left:.5em;font-weight:400;font-size:1.15em;font-family:Icons;content:'\e605';vertical-align:sub}.form-el-checkbox,.form-el-radio{border:0;clip:rect(0,0,0,0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.form-el-checkbox.disabled+.form-label,.form-el-checkbox.disabled+.form-label:before,.form-el-checkbox[disabled]+.form-label,.form-el-checkbox[disabled]+.form-label:before,.form-el-radio.disabled+.form-label,.form-el-radio.disabled+.form-label:before,.form-el-radio[disabled]+.form-label,.form-el-radio[disabled]+.form-label:before{cursor:default;opacity:.5;pointer-events:none}.form-el-checkbox:not(.disabled)+.form-label:hover:before,.form-el-checkbox:not([disabled])+.form-label:hover:before,.form-el-radio:not(.disabled)+.form-label:hover:before,.form-el-radio:not([disabled])+.form-label:hover:before{border-color:#514943}.form-el-checkbox+.form-label,.form-el-radio+.form-label{font-weight:400;padding-left:2em;padding-right:0;position:relative;text-align:left;transition:border-color .1s linear}.form-el-checkbox+.form-label:before,.form-el-radio+.form-label:before{border:1px solid;content:'';left:0;position:absolute;top:.1rem;transition:border-color .1s linear}.form-el-checkbox+.form-label:before{border-color:#adadad;border-radius:2px;height:1.4rem;line-height:1;width:1.4rem}.form-el-checkbox:checked+.form-label::before{content:'\e600';font-family:Icons}.form-el-radio+.form-label:before{background-color:#fff;border:1px solid #adadad;border-radius:100%;height:1.6rem;width:1.6rem}.form-el-radio+.form-label:after{background:0 0;border:.5rem solid transparent;border-radius:100%;content:'';height:0;left:.4rem;position:absolute;top:.5rem;transition:background .3s linear;width:0}.form-el-radio:checked+.form-label{cursor:default}.form-el-radio:checked+.form-label:after{border-color:#514943}.form-select-label{border:1px solid #adadad;border-radius:2px;color:#303030;cursor:pointer;display:block;overflow:hidden;position:relative}.form-select-label:hover,.form-select-label:hover:after{border-color:#949494}.form-select-label:active,.form-select-label:active:after,.form-select-label:focus,.form-select-label:focus:after{border-color:#008bdb}.form-select-label:after{background:#e3e3e3;border-left:1px solid #adadad;bottom:0;content:'';position:absolute;right:0;top:0;width:2.36em;z-index:-2}.ie9 .form-select-label:after{display:none}.form-select-label:before{border-color:#303030 transparent transparent;border-style:solid;border-width:5px 4px 0;content:'';height:0;margin-right:-4px;margin-top:-2.5px;position:absolute;right:1.18em;top:50%;width:0;z-index:-1}.ie9 .form-select-label:before{display:none}.form-select-label .form-el-select{background:0 0;border:none;border-radius:0;content:'';display:block;margin:0;padding:.35em calc(2.36em + 10%) .5em .55em;width:110%}.ie9 .form-select-label .form-el-select{padding-right:.55em;width:100%}.form-el-select{background:#fff;border:1px solid #adadad;border-radius:2px;color:#303030;display:block;padding:.35em .55em}.multiselect-custom{position:relative;height:45.2rem;border:1px solid #adadad;overflow:auto;margin:0 0 1.5rem}.multiselect-custom ul{margin:0;padding:0;list-style:none;min-width:29rem}.multiselect-custom .item{padding:1rem 1.4rem}.multiselect-custom .selected{background-color:#e0f6fe}.multiselect-custom .form-label{margin-bottom:0}[class*=form-el-].invalid{border-color:#e22626}[class*=form-el-].invalid+.error-container{display:block}.error-container{background-color:#fffbbb;border:1px solid #ee7d7d;border-radius:2px;color:#514943;display:none;font-size:1.19rem;margin-top:.2rem;padding:.4235em .6655em .605em}.check-result-message{margin-left:.5em;min-height:3.68rem;-webkit-align-items:center;-ms-align-items:center;align-items:center;display:-webkit-flex;display:-ms-flexbox;display:flex}.check-result-text{margin-left:.5em}.pseudo-table{display:table}.pseudo-td{display:table-cell}.messages{margin:0 0 2rem}.message{background:#fffbbb;border:none;border-radius:0;color:#333;font-size:14px;margin:0 0 1px;padding:1.8rem 4rem 1.8rem 5.5rem;position:relative;text-shadow:none}.message:before{background:0 0;border:0;color:#007bdb;content:'\e61a';font-family:Icons;font-size:1.9rem;font-style:normal;font-weight:400;height:auto;left:1.9rem;line-height:inherit;margin-top:-1.3rem;position:absolute;speak:none;text-shadow:none;top:50%;width:auto}.message-notice:before{color:#007bdb;content:'\e61a'}.message-warning:before{color:#eb5202;content:'\e623'}.message-error{background:#fcc}.message-error:before{color:#e22626;content:'\e632';font-size:1.5rem;left:2.2rem;margin-top:-1rem}.message-success:before{color:#79a22e;content:'\e62d'}.message-spinner:before{display:none}.message-spinner .spinner{font-size:2.5rem;left:1.5rem;position:absolute;top:1.5rem}.message-in-rating-edit{margin-left:1.8rem;margin-right:1.8rem}.message{margin-bottom:3rem}.container{display:block;margin:0 auto 4rem;max-width:100rem;padding:0 2rem}.row{margin-left:0;margin-right:0}.col-l-1,.col-l-10,.col-l-11,.col-l-12,.col-l-2,.col-l-3,.col-l-4,.col-l-5,.col-l-6,.col-l-7,.col-l-8,.col-l-9,.col-m-1,.col-m-10,.col-m-11,.col-m-12,.col-m-2,.col-m-3,.col-m-4,.col-m-5,.col-m-6,.col-m-7,.col-m-8,.col-m-9,.col-xl-1,.col-xl-10,.col-xl-11,.col-xl-12,.col-xl-2,.col-xl-3,.col-xl-4,.col-xl-5,.col-xl-6,.col-xl-7,.col-xl-8,.col-xl-9,.col-xs-1,.col-xs-10,.col-xs-11,.col-xs-12,.col-xs-2,.col-xs-3,.col-xs-4,.col-xs-5,.col-xs-6,.col-xs-7,.col-xs-8,.col-xs-9{min-height:1px;padding-left:0;padding-right:0;position:relative}.col-xs-1,.col-xs-10,.col-xs-11,.col-xs-12,.col-xs-2,.col-xs-3,.col-xs-4,.col-xs-5,.col-xs-6,.col-xs-7,.col-xs-8,.col-xs-9{float:left}.col-xs-12{width:100%}.col-xs-11{width:91.66666667%}.col-xs-10{width:83.33333333%}.col-xs-9{width:75%}.col-xs-8{width:66.66666667%}.col-xs-7{width:58.33333333%}.col-xs-6{width:50%}.col-xs-5{width:41.66666667%}.col-xs-4{width:33.33333333%}.col-xs-3{width:25%}.col-xs-2{width:16.66666667%}.col-xs-1{width:8.33333333%}.col-xs-pull-12{right:100%}.col-xs-pull-11{right:91.66666667%}.col-xs-pull-10{right:83.33333333%}.col-xs-pull-9{right:75%}.col-xs-pull-8{right:66.66666667%}.col-xs-pull-7{right:58.33333333%}.col-xs-pull-6{right:50%}.col-xs-pull-5{right:41.66666667%}.col-xs-pull-4{right:33.33333333%}.col-xs-pull-3{right:25%}.col-xs-pull-2{right:16.66666667%}.col-xs-pull-1{right:8.33333333%}.col-xs-pull-0{right:auto}.col-xs-push-12{left:100%}.col-xs-push-11{left:91.66666667%}.col-xs-push-10{left:83.33333333%}.col-xs-push-9{left:75%}.col-xs-push-8{left:66.66666667%}.col-xs-push-7{left:58.33333333%}.col-xs-push-6{left:50%}.col-xs-push-5{left:41.66666667%}.col-xs-push-4{left:33.33333333%}.col-xs-push-3{left:25%}.col-xs-push-2{left:16.66666667%}.col-xs-push-1{left:8.33333333%}.col-xs-push-0{left:auto}.col-xs-offset-12{margin-left:100%}.col-xs-offset-11{margin-left:91.66666667%}.col-xs-offset-10{margin-left:83.33333333%}.col-xs-offset-9{margin-left:75%}.col-xs-offset-8{margin-left:66.66666667%}.col-xs-offset-7{margin-left:58.33333333%}.col-xs-offset-6{margin-left:50%}.col-xs-offset-5{margin-left:41.66666667%}.col-xs-offset-4{margin-left:33.33333333%}.col-xs-offset-3{margin-left:25%}.col-xs-offset-2{margin-left:16.66666667%}.col-xs-offset-1{margin-left:8.33333333%}.col-xs-offset-0{margin-left:0}.nav{background-color:#f8f8f8;border-bottom:1px solid #e3e3e3;border-top:1px solid #e3e3e3;display:none;padding:2.2rem 1.5rem 0 0}.nav .btn-group,.nav-bar-outer-actions{float:right;margin-bottom:1.7rem}.nav .btn-group .btn-wrap,.nav-bar-outer-actions .btn-wrap{float:right;margin-left:.5rem;margin-right:.5rem}.nav-bar-outer-actions{margin-top:-10.6rem;padding-right:1.5rem}.btn-wrap-try-again{width:9.5rem}.btn-wrap-next,.btn-wrap-prev{width:8.5rem}.nav-bar{counter-reset:i;float:left;margin:0 1rem 1.7rem 0;padding:0;position:relative;white-space:nowrap}.nav-bar:before{background-color:#d4d4d4;background-repeat:repeat-x;background-image:-webkit-linear-gradient(top,#d1d1d1 0,#d4d4d4 100%);background-image:linear-gradient(to bottom,#d1d1d1 0,#d4d4d4 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#d1d1d1', endColorstr='#d4d4d4', GradientType=0);border-bottom:1px solid #d9d9d9;border-top:1px solid #bfbfbf;content:'';height:.8rem;left:5.15rem;position:absolute;right:5.15rem;top:.7rem}.nav-bar>li{display:inline-block;font-size:0;position:relative;vertical-align:top;width:10.3rem}.nav-bar>li:first-child:after{display:none}.nav-bar>li:after{background-color:#514943;content:'';height:.5rem;left:calc(-50% + .25rem);position:absolute;right:calc(50% + .7rem);top:.9rem}.nav-bar>li.disabled:before{bottom:0;content:'';left:0;position:absolute;right:0;top:0;z-index:1}.nav-bar>li.active~li:after{display:none}.nav-bar>li.active~li a:after{background-color:transparent;border-color:transparent;color:#a6a6a6}.nav-bar>li.active a{color:#000}.nav-bar>li.active a:hover{cursor:default}.nav-bar>li.active a:after{background-color:#fff;content:''}.nav-bar a{color:#514943;display:block;font-size:1.2rem;font-weight:600;line-height:1.2;overflow:hidden;padding:3rem .5em 0;position:relative;text-align:center;text-overflow:ellipsis}.nav-bar a:hover{text-decoration:none}.nav-bar a:after{background-color:#514943;border:.4rem solid #514943;border-radius:100%;color:#fff;content:counter(i);counter-increment:i;height:.7rem;left:50%;line-height:.6;margin-left:-.8rem;position:absolute;right:auto;text-align:center;top:.4rem;width:.7rem}.nav-bar a:before{background-color:#d6d6d6;border:1px solid transparent;border-bottom-color:#d9d9d9;border-radius:100%;border-top-color:#bfbfbf;content:'';height:2.1rem;left:50%;line-height:1;margin-left:-1.2rem;position:absolute;top:0;width:2.1rem}.tooltip{display:block;font-family:'Open Sans','Helvetica Neue',Helvetica,Arial,sans-serif;font-size:1.19rem;font-weight:400;line-height:1.4;opacity:0;position:absolute;visibility:visible;z-index:10}.tooltip.in{opacity:.9}.tooltip.top{margin-top:-4px;padding:8px 0}.tooltip.right{margin-left:4px;padding:0 8px}.tooltip.bottom{margin-top:4px;padding:8px 0}.tooltip.left{margin-left:-4px;padding:0 8px}.tooltip-inner{background-color:#fff;border:1px solid #adadad;border-radius:0;box-shadow:1px 1px 1px #ccc;color:#41362f;max-width:20rem;padding:.5em 1em;text-decoration:none}.tooltip-arrow,.tooltip-arrow:after{border:solid transparent;height:0;position:absolute;width:0}.tooltip-arrow:after{content:'';position:absolute}.tooltip.top .tooltip-arrow,.tooltip.top .tooltip-arrow:after{border-top-color:#949494;border-width:8px 8px 0;bottom:0;left:50%;margin-left:-8px}.tooltip.top-left .tooltip-arrow,.tooltip.top-left .tooltip-arrow:after{border-top-color:#949494;border-width:8px 8px 0;bottom:0;margin-bottom:-8px;right:8px}.tooltip.top-right .tooltip-arrow,.tooltip.top-right .tooltip-arrow:after{border-top-color:#949494;border-width:8px 8px 0;bottom:0;left:8px;margin-bottom:-8px}.tooltip.right .tooltip-arrow,.tooltip.right .tooltip-arrow:after{border-right-color:#949494;border-width:8px 8px 8px 0;left:1px;margin-top:-8px;top:50%}.tooltip.right .tooltip-arrow:after{border-right-color:#fff;border-width:6px 7px 6px 0;margin-left:0;margin-top:-6px}.tooltip.left .tooltip-arrow,.tooltip.left .tooltip-arrow:after{border-left-color:#949494;border-width:8px 0 8px 8px;margin-top:-8px;right:0;top:50%}.tooltip.bottom .tooltip-arrow,.tooltip.bottom .tooltip-arrow:after{border-bottom-color:#949494;border-width:0 8px 8px;left:50%;margin-left:-8px;top:0}.tooltip.bottom-left .tooltip-arrow,.tooltip.bottom-left .tooltip-arrow:after{border-bottom-color:#949494;border-width:0 8px 8px;margin-top:-8px;right:8px;top:0}.tooltip.bottom-right .tooltip-arrow,.tooltip.bottom-right .tooltip-arrow:after{border-bottom-color:#949494;border-width:0 8px 8px;left:8px;margin-top:-8px;top:0}.password-strength{display:block;margin:0 -.3rem 1em;white-space:nowrap}.password-strength.password-strength-too-short .password-strength-item:first-child,.password-strength.password-strength-weak .password-strength-item:first-child,.password-strength.password-strength-weak .password-strength-item:first-child+.password-strength-item{background-color:#e22626}.password-strength.password-strength-fair .password-strength-item:first-child,.password-strength.password-strength-fair .password-strength-item:first-child+.password-strength-item,.password-strength.password-strength-fair .password-strength-item:first-child+.password-strength-item+.password-strength-item{background-color:#ef672f}.password-strength.password-strength-good .password-strength-item:first-child,.password-strength.password-strength-good .password-strength-item:first-child+.password-strength-item,.password-strength.password-strength-good .password-strength-item:first-child+.password-strength-item+.password-strength-item,.password-strength.password-strength-good .password-strength-item:first-child+.password-strength-item+.password-strength-item+.password-strength-item,.password-strength.password-strength-strong .password-strength-item{background-color:#79a22e}.password-strength .password-strength-item{background-color:#ccc;display:inline-block;font-size:0;height:1.4rem;margin-right:.3rem;width:calc(20% - .6rem)}@-webkit-keyframes progress-bar-stripes{from{background-position:4rem 0}to{background-position:0 0}}@keyframes progress-bar-stripes{from{background-position:4rem 0}to{background-position:0 0}}.progress{background-color:#fafafa;border:1px solid #ccc;height:3rem;margin-bottom:3rem;overflow:hidden}.progress-bar{background-color:#79a22e;color:#fff;float:left;font-size:1.19rem;height:100%;line-height:3rem;text-align:center;transition:width .6s ease;width:0}.progress-bar.active{-webkit-animation:progress-bar-stripes 2s linear infinite;-o-animation:progress-bar-stripes 2s linear infinite;animation:progress-bar-stripes 2s linear infinite}.spinner{display:inline-block;font-size:4rem;height:1em;margin-right:1.5rem;position:relative;width:1em}@-moz-keyframes fade{0%{background-color:#514943}100%{background-color:#fff}}@-webkit-keyframes fade{0%{background-color:#514943}100%{background-color:#fff}}@-ms-keyframes fade{0%{background-color:#514943}100%{background-color:#fff}}@keyframes fade{0%{background-color:#514943}100%{background-color:#fff}}.spinner>span:nth-child(1){-webkit-animation-delay:.27s;-moz-animation-delay:.27s;-ms-animation-delay:.27s;animation-delay:.27s;-webkit-transform:rotate(-315deg);-moz-transform:rotate(-315deg);-ms-transform:rotate(-315deg);transform:rotate(-315deg)}.spinner>span:nth-child(2){-webkit-animation-delay:.36s;-moz-animation-delay:.36s;-ms-animation-delay:.36s;animation-delay:.36s;-webkit-transform:rotate(-270deg);-moz-transform:rotate(-270deg);-ms-transform:rotate(-270deg);transform:rotate(-270deg)}.spinner>span:nth-child(3){-webkit-animation-delay:.45s;-moz-animation-delay:.45s;-ms-animation-delay:.45s;animation-delay:.45s;-webkit-transform:rotate(-225deg);-moz-transform:rotate(-225deg);-ms-transform:rotate(-225deg);transform:rotate(-225deg)}.spinner>span:nth-child(4){-webkit-animation-delay:.54s;-moz-animation-delay:.54s;-ms-animation-delay:.54s;animation-delay:.54s;-webkit-transform:rotate(-180deg);-moz-transform:rotate(-180deg);-ms-transform:rotate(-180deg);transform:rotate(-180deg)}.spinner>span:nth-child(5){-webkit-animation-delay:.63s;-moz-animation-delay:.63s;-ms-animation-delay:.63s;animation-delay:.63s;-webkit-transform:rotate(-135deg);-moz-transform:rotate(-135deg);-ms-transform:rotate(-135deg);transform:rotate(-135deg)}.spinner>span:nth-child(6){-webkit-animation-delay:.72s;-moz-animation-delay:.72s;-ms-animation-delay:.72s;animation-delay:.72s;-webkit-transform:rotate(-90deg);-moz-transform:rotate(-90deg);-ms-transform:rotate(-90deg);transform:rotate(-90deg)}.spinner>span:nth-child(7){-webkit-animation-delay:.81s;-moz-animation-delay:.81s;-ms-animation-delay:.81s;animation-delay:.81s;-webkit-transform:rotate(-45deg);-moz-transform:rotate(-45deg);-ms-transform:rotate(-45deg);transform:rotate(-45deg)}.spinner>span:nth-child(8){-webkit-animation-delay:.9;-moz-animation-delay:.9;-ms-animation-delay:.9;animation-delay:.9;-webkit-transform:rotate(0deg);-moz-transform:rotate(0deg);-ms-transform:rotate(0deg);transform:rotate(0deg)}.spinner>span{-webkit-animation-direction:linear;-moz-animation-direction:linear;-ms-animation-direction:linear;animation-direction:linear;-webkit-animation-duration:.72s;-moz-animation-duration:.72s;-ms-animation-duration:.72s;animation-duration:.72s;-webkit-animation-iteration-count:infinite;-moz-animation-iteration-count:infinite;-ms-animation-iteration-count:infinite;animation-iteration-count:infinite;-webkit-animation-name:fade;-moz-animation-name:fade;-ms-animation-name:fade;animation-name:fade;-webkit-transform:scale(0.4);-moz-transform:scale(0.4);-ms-transform:scale(0.4);transform:scale(0.4);background-color:#fff;border-radius:6px;clip:rect(0 .28571429em .1em 0);height:.1em;margin-top:.5em;position:absolute;width:1em}.ie9 .spinner{background:url(../../pub/images/ajax-loader.gif) center no-repeat}.ie9 .spinner>span{display:none}.main{padding-bottom:2rem;padding-top:3rem}.header{display:none}.header .logo{float:left;height:4.1rem;width:3.5rem}.header-title{font-size:2.8rem;letter-spacing:.02em;margin:2.5rem 0 3.5rem 5rem}.page-title{font-size:2rem;margin-bottom:1.3em}.accent-box{margin-bottom:2rem}.accent-box .btn-prime{margin-top:1.5rem}.page-landing{margin:7.6% auto 0;max-width:44rem;text-align:center}.page-landing .logo{height:5.6rem;margin-bottom:2rem;width:19.2rem}.page-landing .text-version{margin-bottom:3rem}.page-landing .text-welcome{margin-bottom:6.5rem}.page-landing .text-terms{margin-bottom:2.5rem;text-align:center}.page-landing .btn-submit{margin-bottom:20px}.page-license .license-text{margin-bottom:2rem}.page-license .page-license-footer{text-align:right}.rediness-check-item{margin-bottom:4rem}.readiness-check-title{font-size:1.4rem;font-weight:700;margin-bottom:.1rem;margin-left:7.5rem}.readiness-check-content{margin-left:7.5rem;margin-right:22rem}.readiness-check-content .readiness-check-title{margin-left:0}.readiness-check-content .list{margin-top:-.3rem}.rediness-check-side{float:right;padding-left:2.4rem;width:22rem}.rediness-check-side .side-title{margin-bottom:0}.readiness-check-icon{float:left;margin-left:2rem;margin-top:.7rem}.page-web-configuration .form-el-insider-wrap{width:auto}.page-web-configuration .form-el-insider{width:15.4rem}.page-web-configuration .form-el-insider-input .form-el-input{width:16.5rem}.customize-your-store .customize-your-store-default .legend{border:0;clip:rect(0,0,0,0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.customize-your-store .advanced-modules-count,.customize-your-store .advanced-modules-select{padding-left:1.5rem}.customize-your-store .customize-your-store-advanced{min-width:0}.customize-your-store .message-error:before{margin-top:0;top:1.8rem}.customize-your-store .message-error a{color:#333;text-decoration:underline}.customize-your-store .message-error .form-label:before{background:#fff}.content-install{margin-bottom:2rem}.console{border:1px solid #ccc;font-family:'Courier New',Courier,monospace;font-weight:300;margin:1rem 0 2rem;max-height:20rem;overflow-y:auto;padding:1.5rem 2rem 2rem}.console .text-danger{color:#e22626}.console .text-success{color:#090}.console .hidden{display:none}.content-success .btn-prime{margin-top:1.5rem}.jumbo-title{font-size:3.6rem}.jumbo-title .jumbo-icon{font-size:3.8rem;margin-right:.25em;position:relative;top:.15em}@media all and (max-width:1047px){.nav{padding-bottom:5.38rem;padding-left:1.5rem;text-align:center}.nav-bar{display:inline-block;float:none;margin-right:0;vertical-align:top}.nav .btn-group,.nav-bar-outer-actions{display:inline-block;float:none;margin-top:-8.48rem;text-align:center;vertical-align:top;width:100%}.nav-bar-outer-actions{padding-right:0}.nav-bar-outer-actions .outer-actions-inner-wrap{display:inline-block}}@media all and (min-width:768px){html{margin-left:calc(100vw - 100%);margin-right:0;overflow:auto}.col-m-1,.col-m-10,.col-m-11,.col-m-12,.col-m-2,.col-m-3,.col-m-4,.col-m-5,.col-m-6,.col-m-7,.col-m-8,.col-m-9{float:left}.col-m-12{width:100%}.col-m-11{width:91.66666667%}.col-m-10{width:83.33333333%}.col-m-9{width:75%}.col-m-8{width:66.66666667%}.col-m-7{width:58.33333333%}.col-m-6{width:50%}.col-m-5{width:41.66666667%}.col-m-4{width:33.33333333%}.col-m-3{width:25%}.col-m-2{width:16.66666667%}.col-m-1{width:8.33333333%}.col-m-pull-12{right:100%}.col-m-pull-11{right:91.66666667%}.col-m-pull-10{right:83.33333333%}.col-m-pull-9{right:75%}.col-m-pull-8{right:66.66666667%}.col-m-pull-7{right:58.33333333%}.col-m-pull-6{right:50%}.col-m-pull-5{right:41.66666667%}.col-m-pull-4{right:33.33333333%}.col-m-pull-3{right:25%}.col-m-pull-2{right:16.66666667%}.col-m-pull-1{right:8.33333333%}.col-m-pull-0{right:auto}.col-m-push-12{left:100%}.col-m-push-11{left:91.66666667%}.col-m-push-10{left:83.33333333%}.col-m-push-9{left:75%}.col-m-push-8{left:66.66666667%}.col-m-push-7{left:58.33333333%}.col-m-push-6{left:50%}.col-m-push-5{left:41.66666667%}.col-m-push-4{left:33.33333333%}.col-m-push-3{left:25%}.col-m-push-2{left:16.66666667%}.col-m-push-1{left:8.33333333%}.col-m-push-0{left:auto}.col-m-offset-12{margin-left:100%}.col-m-offset-11{margin-left:91.66666667%}.col-m-offset-10{margin-left:83.33333333%}.col-m-offset-9{margin-left:75%}.col-m-offset-8{margin-left:66.66666667%}.col-m-offset-7{margin-left:58.33333333%}.col-m-offset-6{margin-left:50%}.col-m-offset-5{margin-left:41.66666667%}.col-m-offset-4{margin-left:33.33333333%}.col-m-offset-3{margin-left:25%}.col-m-offset-2{margin-left:16.66666667%}.col-m-offset-1{margin-left:8.33333333%}.col-m-offset-0{margin-left:0}}@media all and (min-width:1048px){.col-l-1,.col-l-10,.col-l-11,.col-l-12,.col-l-2,.col-l-3,.col-l-4,.col-l-5,.col-l-6,.col-l-7,.col-l-8,.col-l-9{float:left}.col-l-12{width:100%}.col-l-11{width:91.66666667%}.col-l-10{width:83.33333333%}.col-l-9{width:75%}.col-l-8{width:66.66666667%}.col-l-7{width:58.33333333%}.col-l-6{width:50%}.col-l-5{width:41.66666667%}.col-l-4{width:33.33333333%}.col-l-3{width:25%}.col-l-2{width:16.66666667%}.col-l-1{width:8.33333333%}.col-l-pull-12{right:100%}.col-l-pull-11{right:91.66666667%}.col-l-pull-10{right:83.33333333%}.col-l-pull-9{right:75%}.col-l-pull-8{right:66.66666667%}.col-l-pull-7{right:58.33333333%}.col-l-pull-6{right:50%}.col-l-pull-5{right:41.66666667%}.col-l-pull-4{right:33.33333333%}.col-l-pull-3{right:25%}.col-l-pull-2{right:16.66666667%}.col-l-pull-1{right:8.33333333%}.col-l-pull-0{right:auto}.col-l-push-12{left:100%}.col-l-push-11{left:91.66666667%}.col-l-push-10{left:83.33333333%}.col-l-push-9{left:75%}.col-l-push-8{left:66.66666667%}.col-l-push-7{left:58.33333333%}.col-l-push-6{left:50%}.col-l-push-5{left:41.66666667%}.col-l-push-4{left:33.33333333%}.col-l-push-3{left:25%}.col-l-push-2{left:16.66666667%}.col-l-push-1{left:8.33333333%}.col-l-push-0{left:auto}.col-l-offset-12{margin-left:100%}.col-l-offset-11{margin-left:91.66666667%}.col-l-offset-10{margin-left:83.33333333%}.col-l-offset-9{margin-left:75%}.col-l-offset-8{margin-left:66.66666667%}.col-l-offset-7{margin-left:58.33333333%}.col-l-offset-6{margin-left:50%}.col-l-offset-5{margin-left:41.66666667%}.col-l-offset-4{margin-left:33.33333333%}.col-l-offset-3{margin-left:25%}.col-l-offset-2{margin-left:16.66666667%}.col-l-offset-1{margin-left:8.33333333%}.col-l-offset-0{margin-left:0}}@media all and (min-width:1440px){.col-xl-1,.col-xl-10,.col-xl-11,.col-xl-12,.col-xl-2,.col-xl-3,.col-xl-4,.col-xl-5,.col-xl-6,.col-xl-7,.col-xl-8,.col-xl-9{float:left}.col-xl-12{width:100%}.col-xl-11{width:91.66666667%}.col-xl-10{width:83.33333333%}.col-xl-9{width:75%}.col-xl-8{width:66.66666667%}.col-xl-7{width:58.33333333%}.col-xl-6{width:50%}.col-xl-5{width:41.66666667%}.col-xl-4{width:33.33333333%}.col-xl-3{width:25%}.col-xl-2{width:16.66666667%}.col-xl-1{width:8.33333333%}.col-xl-pull-12{right:100%}.col-xl-pull-11{right:91.66666667%}.col-xl-pull-10{right:83.33333333%}.col-xl-pull-9{right:75%}.col-xl-pull-8{right:66.66666667%}.col-xl-pull-7{right:58.33333333%}.col-xl-pull-6{right:50%}.col-xl-pull-5{right:41.66666667%}.col-xl-pull-4{right:33.33333333%}.col-xl-pull-3{right:25%}.col-xl-pull-2{right:16.66666667%}.col-xl-pull-1{right:8.33333333%}.col-xl-pull-0{right:auto}.col-xl-push-12{left:100%}.col-xl-push-11{left:91.66666667%}.col-xl-push-10{left:83.33333333%}.col-xl-push-9{left:75%}.col-xl-push-8{left:66.66666667%}.col-xl-push-7{left:58.33333333%}.col-xl-push-6{left:50%}.col-xl-push-5{left:41.66666667%}.col-xl-push-4{left:33.33333333%}.col-xl-push-3{left:25%}.col-xl-push-2{left:16.66666667%}.col-xl-push-1{left:8.33333333%}.col-xl-push-0{left:auto}.col-xl-offset-12{margin-left:100%}.col-xl-offset-11{margin-left:91.66666667%}.col-xl-offset-10{margin-left:83.33333333%}.col-xl-offset-9{margin-left:75%}.col-xl-offset-8{margin-left:66.66666667%}.col-xl-offset-7{margin-left:58.33333333%}.col-xl-offset-6{margin-left:50%}.col-xl-offset-5{margin-left:41.66666667%}.col-xl-offset-4{margin-left:33.33333333%}.col-xl-offset-3{margin-left:25%}.col-xl-offset-2{margin-left:16.66666667%}.col-xl-offset-1{margin-left:8.33333333%}.col-xl-offset-0{margin-left:0}}@media all and (max-width:767px){.list-definition>dt{float:none}.list-definition>dd{margin-left:0}.form-row .form-label{text-align:left}.form-row .form-label.required:after{position:static}.nav{padding-bottom:0;padding-left:0;padding-right:0}.nav-bar-outer-actions{margin-top:0}.nav-bar{display:block;margin-bottom:0;margin-left:auto;margin-right:auto;width:30.9rem}.nav-bar:before{display:none}.nav-bar>li{float:left;min-height:9rem}.nav-bar>li:after{display:none}.nav-bar>li:nth-child(4n){clear:both}.nav-bar a{line-height:1.4}.tooltip{display:none!important}.readiness-check-content{margin-right:2rem}.form-el-insider,.form-el-insider-wrap,.page-web-configuration .form-el-insider-input,.page-web-configuration .form-el-insider-input .form-el-input{display:block;width:100%}}@media all and (max-width:479px){.nav-bar{width:23.175rem}.nav-bar>li{width:7.725rem}.nav .btn-group .btn-wrap-try-again,.nav-bar-outer-actions .btn-wrap-try-again{clear:both;display:block;float:none;margin-left:auto;margin-right:auto;margin-top:1rem;padding-top:1rem}} \ No newline at end of file diff --git a/setup/src/Magento/Setup/Model/Installer.php b/setup/src/Magento/Setup/Model/Installer.php index 0b2772d9f45c4684f7baeab5b7dd3f1c063d35a9..650fe796f7adf819de1334f29f3d89871e19cf7c 100644 --- a/setup/src/Magento/Setup/Model/Installer.php +++ b/setup/src/Magento/Setup/Model/Installer.php @@ -612,6 +612,202 @@ class Installer } } + /** + * Set up core tables + * + * @param SchemaSetupInterface $setup + * @return void + */ + private function setupCoreTables(SchemaSetupInterface $setup) + { + /* @var $connection \Magento\Framework\DB\Adapter\AdapterInterface */ + $connection = $setup->getConnection(); + + $setup->startSetup(); + + $this->setupSessionTable($setup, $connection); + $this->setupCacheTable($setup, $connection); + $this->setupCacheTagTable($setup, $connection); + $this->setupFlagTable($setup, $connection); + + $setup->endSetup(); + } + + /** + * Create table 'session' + * + * @param SchemaSetupInterface $setup + * @param \Magento\Framework\DB\Adapter\AdapterInterface $connection + * @return void + */ + private function setupSessionTable( + SchemaSetupInterface $setup, + \Magento\Framework\DB\Adapter\AdapterInterface $connection + ) { + $table = $connection->newTable( + $setup->getTable('session') + )->addColumn( + 'session_id', + \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, + 255, + ['nullable' => false, 'primary' => true], + 'Session Id' + )->addColumn( + 'session_expires', + \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, + null, + ['unsigned' => true, 'nullable' => false, 'default' => '0'], + 'Date of Session Expiration' + )->addColumn( + 'session_data', + \Magento\Framework\DB\Ddl\Table::TYPE_BLOB, + '2M', + ['nullable' => false], + 'Session Data' + )->setComment( + 'Database Sessions Storage' + ); + $connection->createTable($table); + } + + /** + * Create table 'cache' + * + * @param SchemaSetupInterface $setup + * @param \Magento\Framework\DB\Adapter\AdapterInterface $connection + * @return void + */ + private function setupCacheTable( + SchemaSetupInterface $setup, + \Magento\Framework\DB\Adapter\AdapterInterface $connection + ) { + $table = $connection->newTable( + $setup->getTable('cache') + )->addColumn( + 'id', + \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, + 200, + ['nullable' => false, 'primary' => true], + 'Cache Id' + )->addColumn( + 'data', + \Magento\Framework\DB\Ddl\Table::TYPE_BLOB, + '2M', + [], + 'Cache Data' + )->addColumn( + 'create_time', + \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, + null, + [], + 'Cache Creation Time' + )->addColumn( + 'update_time', + \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, + null, + [], + 'Time of Cache Updating' + )->addColumn( + 'expire_time', + \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, + null, + [], + 'Cache Expiration Time' + )->addIndex( + $setup->getIdxName('cache', ['expire_time']), + ['expire_time'] + )->setComment( + 'Caches' + ); + $connection->createTable($table); + } + + /** + * Create table 'cache_tag' + * + * @param SchemaSetupInterface $setup + * @param \Magento\Framework\DB\Adapter\AdapterInterface $connection + * @return void + */ + private function setupCacheTagTable( + SchemaSetupInterface $setup, + \Magento\Framework\DB\Adapter\AdapterInterface $connection + ) { + $table = $connection->newTable( + $setup->getTable('cache_tag') + )->addColumn( + 'tag', + \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, + 100, + ['nullable' => false, 'primary' => true], + 'Tag' + )->addColumn( + 'cache_id', + \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, + 200, + ['nullable' => false, 'primary' => true], + 'Cache Id' + )->addIndex( + $setup->getIdxName('cache_tag', ['cache_id']), + ['cache_id'] + )->setComment( + 'Tag Caches' + ); + $connection->createTable($table); + } + + /** + * Create table 'flag' + * + * @param SchemaSetupInterface $setup + * @param \Magento\Framework\DB\Adapter\AdapterInterface $connection + * @return void + */ + private function setupFlagTable( + SchemaSetupInterface $setup, + \Magento\Framework\DB\Adapter\AdapterInterface $connection + ) { + $table = $connection->newTable( + $setup->getTable('flag') + )->addColumn( + 'flag_id', + \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, + null, + ['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true], + 'Flag Id' + )->addColumn( + 'flag_code', + \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, + 255, + ['nullable' => false], + 'Flag Code' + )->addColumn( + 'state', + \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, + null, + ['unsigned' => true, 'nullable' => false, 'default' => '0'], + 'Flag State' + )->addColumn( + 'flag_data', + \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, + '64k', + [], + 'Flag Data' + )->addColumn( + 'last_update', + \Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP, + null, + ['nullable' => false, 'default' => \Magento\Framework\DB\Ddl\Table::TIMESTAMP_INIT_UPDATE], + 'Date of Last Flag Update' + )->addIndex( + $setup->getIdxName('flag', ['last_update']), + ['last_update'] + )->setComment( + 'Flag' + ); + $connection->createTable($table); + } + /** * Installs DB schema * @@ -624,6 +820,7 @@ class Installer ['resource' => $this->context->getResources()] ); $this->setupModuleRegistry($setup); + $this->setupCoreTables($setup); $this->log->log('Schema creation/updates:'); $this->handleDBSchemaData($setup, 'schema'); } diff --git a/setup/src/Magento/Setup/Test/Unit/Controller/ConsoleControllerTest.php b/setup/src/Magento/Setup/Test/Unit/Controller/ConsoleControllerTest.php index 06d50d55d388e6a390971e730228fcf82aa97da1..9829a32e94d62e71f507b4d5565897c4f2a755a5 100644 --- a/setup/src/Magento/Setup/Test/Unit/Controller/ConsoleControllerTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Controller/ConsoleControllerTest.php @@ -4,6 +4,8 @@ * See COPYING.txt for license details. */ +// @codingStandardsIgnoreFile + namespace Magento\Setup\Test\Unit\Controller; use \Magento\Setup\Controller\ConsoleController; @@ -132,7 +134,7 @@ class ConsoleControllerTest extends \PHPUnit_Framework_TestCase { $errorMessage = 'Missing route matches; unsure how to retrieve action'; $event = $this->getMock('Zend\Mvc\MvcEvent'); - $exception = $this->getMock('Magento\Setup\Exception', [], [$errorMessage]); + $exception = $this->getMock('Magento\Setup\Exception', ['getCode'], [$errorMessage]); $event->expects($this->once())->method('getRouteMatch')->willThrowException($exception); $this->consoleLogger->expects($this->once())->method('log')->with($errorMessage); $this->controller->onDispatch($event); @@ -386,12 +388,12 @@ class ConsoleControllerTest extends \PHPUnit_Framework_TestCase $moduleListMock ->expects($this->once()) ->method('getNames') - ->will($this->returnValue(['Magento_Core', 'Magento_Store'])); + ->will($this->returnValue(['Magento_Theme', 'Magento_Store'])); $fullModuleListMock = $this->getMock('Magento\Framework\Module\FullModuleList', [], [], '', false); $fullModuleListMock ->expects($this->once()) ->method('getNames') - ->will($this->returnValue(['Magento_Core', 'Magento_Store', 'Magento_Directory'])); + ->will($this->returnValue(['Magento_Theme', 'Magento_Store', 'Magento_Directory'])); $returnValueMap = [ [ 'Magento\Framework\Module\ModuleList', diff --git a/setup/src/Magento/Setup/Test/Unit/Model/InstallerTest.php b/setup/src/Magento/Setup/Test/Unit/Model/InstallerTest.php index b780bb25a335ac92aa8c0808d7acb6c5e0d265ab..459368efdeeeb93cb4dcb7a1964878cac86bcbca 100644 --- a/setup/src/Magento/Setup/Test/Unit/Model/InstallerTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Model/InstallerTest.php @@ -239,6 +239,7 @@ class InstallerTest extends \PHPUnit_Framework_TestCase $setup->expects($this->any())->method('getConnection')->willReturn($connection); $table->expects($this->any())->method('addColumn')->willReturn($table); $table->expects($this->any())->method('setComment')->willReturn($table); + $table->expects($this->any())->method('addIndex')->willReturn($table); $connection->expects($this->any())->method('newTable')->willReturn($table); $resource = $this->getMock('Magento\Framework\App\Resource', [], [], '', false); $this->contextMock->expects($this->any())->method('getResources')->willReturn($resource);