diff --git a/app/code/Magento/Bundle/Model/Plugin/BundleLoadOptions.php b/app/code/Magento/Bundle/Model/Plugin/BundleLoadOptions.php index acbf28dd74d38916626a63e980cf36546e8c70ee..7e7294d98bc1e766709bb8ed2cf668e50076de1e 100644 --- a/app/code/Magento/Bundle/Model/Plugin/BundleLoadOptions.php +++ b/app/code/Magento/Bundle/Model/Plugin/BundleLoadOptions.php @@ -15,20 +15,20 @@ class BundleLoadOptions protected $productOptionList; /** - * @var \Magento\Framework\Api\AttributeDataBuilder + * @var \Magento\Framework\Api\AttributeValueFactory */ - protected $customAttributeBuilder; + protected $customAttributeFactory; /** * @param \Magento\Bundle\Model\Product\OptionList $productOptionList - * @param \Magento\Framework\Api\AttributeDataBuilder $customAttributeBuilder + * @param \Magento\Framework\Api\AttributeValueFactory $customAttributeFactory */ public function __construct( \Magento\Bundle\Model\Product\OptionList $productOptionList, - \Magento\Framework\Api\AttributeDataBuilder $customAttributeBuilder + \Magento\Framework\Api\AttributeValueFactory $customAttributeFactory ) { $this->productOptionList = $productOptionList; - $this->customAttributeBuilder = $customAttributeBuilder; + $this->customAttributeFactory = $customAttributeFactory; } /** @@ -50,10 +50,9 @@ class BundleLoadOptions if ($product->getTypeId() != \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE) { return $product; } - $customAttribute = $this->customAttributeBuilder + $customAttribute = $this->customAttributeFactory->create() ->setAttributeCode('bundle_product_options') - ->setValue($this->productOptionList->getItems($product)) - ->create(); + ->setValue($this->productOptionList->getItems($product)); $attributes = array_merge($product->getCustomAttributes(), ['bundle_product_options' => $customAttribute]); $product->setData('custom_attributes', $attributes); return $product; diff --git a/app/code/Magento/Bundle/Test/Unit/Model/OptionRepositoryTest.php b/app/code/Magento/Bundle/Test/Unit/Model/OptionRepositoryTest.php index 623d647cf5b623530a2fba9e6b45030ad0e5737c..2ed7bdb1b29e5864135cfa067f78a7022c28ec7a 100644 --- a/app/code/Magento/Bundle/Test/Unit/Model/OptionRepositoryTest.php +++ b/app/code/Magento/Bundle/Test/Unit/Model/OptionRepositoryTest.php @@ -69,6 +69,7 @@ class OptionRepositoryTest extends \PHPUnit_Framework_TestCase $this->productRepositoryMock = $this->getMock('\Magento\Catalog\Api\ProductRepositoryInterface'); $this->typeMock = $this->getMock('\Magento\Bundle\Model\Product\Type', [], [], '', false); $this->optionFactoryMock = $this->getMockBuilder('\Magento\Bundle\Api\Data\OptionInterfaceFactory') + ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); $this->dataObjectHelperMock = $this->getMockBuilder('\Magento\Framework\Api\DataObjectHelper') 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 fb57b32683eed7c035619ee234f6d9d0bd2bea56..0618065c4e80bacd68fe211d7a433209636aa97a 100644 --- a/app/code/Magento/Bundle/Test/Unit/Model/Plugin/BundleLoadOptionsTest.php +++ b/app/code/Magento/Bundle/Test/Unit/Model/Plugin/BundleLoadOptionsTest.php @@ -21,15 +21,15 @@ class BundleLoadOptionsTest extends \PHPUnit_Framework_TestCase /** * @var \PHPUnit_Framework_MockObject_MockObject */ - protected $attributeBuilderMock; + protected $attributeFactoryMock; protected function setUp() { $this->optionListMock = $this->getMock('\Magento\Bundle\Model\Product\OptionList', [], [], '', false); - $this->attributeBuilderMock = $this->getMock('\Magento\Framework\Api\AttributeDataBuilder', [], [], '', false); + $this->attributeFactoryMock = $this->getMock('\Magento\Framework\Api\AttributeValueFactory', [], [], '', false); $this->model = new \Magento\Bundle\Model\Plugin\BundleLoadOptions( $this->optionListMock, - $this->attributeBuilderMock + $this->attributeFactoryMock ); } @@ -69,16 +69,16 @@ class BundleLoadOptionsTest extends \PHPUnit_Framework_TestCase ->method('getItems') ->with($productMock) ->willReturn([$optionMock]); - $this->attributeBuilderMock->expects($this->once()) + $customAttributeMock = $this->getMock('\Magento\Framework\Api\AttributeValue', [], [], '', false); + $customAttributeMock->expects($this->once()) ->method('setAttributeCode') ->with('bundle_product_options') ->willReturnSelf(); - $this->attributeBuilderMock->expects($this->once()) + $customAttributeMock->expects($this->once()) ->method('setValue') ->with([$optionMock]) ->willReturnSelf(); - $customAttributeMock = $this->getMock('\Magento\Framework\Api\AttributeValue', [], [], '', false); - $this->attributeBuilderMock->expects($this->once())->method('create')->willReturn($customAttributeMock); + $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]); diff --git a/app/code/Magento/Catalog/Api/Data/CategoryAttributeSearchResultsInterface.php b/app/code/Magento/Catalog/Api/Data/CategoryAttributeSearchResultsInterface.php index 980b3c2ae8c09d96438a8ec12737f4a1f26344fb..aec790eefd288e5d642c4859e267e7cf866e9ce2 100644 --- a/app/code/Magento/Catalog/Api/Data/CategoryAttributeSearchResultsInterface.php +++ b/app/code/Magento/Catalog/Api/Data/CategoryAttributeSearchResultsInterface.php @@ -14,4 +14,12 @@ interface CategoryAttributeSearchResultsInterface extends \Magento\Framework\Api * @return \Magento\Catalog\Api\Data\CategoryAttributeInterface[] */ public function getItems(); + + /** + * Set attributes list. + * + * @param \Magento\Catalog\Api\Data\CategoryAttributeInterface[] $items + * @return $this + */ + public function setItems(array $items = null); } diff --git a/app/code/Magento/Catalog/Api/Data/ProductAttributeDataBuilder.php b/app/code/Magento/Catalog/Api/Data/ProductAttributeDataBuilder.php deleted file mode 100644 index c921729a91e0b5cc33de9d6ce3edc6915c8ac8d9..0000000000000000000000000000000000000000 --- a/app/code/Magento/Catalog/Api/Data/ProductAttributeDataBuilder.php +++ /dev/null @@ -1,382 +0,0 @@ -<?php -/** - * - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -namespace Magento\Catalog\Api\Data; - -use Magento\Framework\Api\MetadataServiceInterface; -use Magento\Framework\Api\ObjectFactory; - -/** - * DataBuilder class for \Magento\Catalog\Api\Data\ProductAttributeInterface - * @codeCoverageIgnore - */ -class ProductAttributeDataBuilder extends \Magento\Framework\Api\Builder -{ - /** - * @param ObjectFactory $objectFactory - * @param MetadataServiceInterface $metadataService - * @param \Magento\Framework\Api\AttributeValueFactory $attributeValueFactory - * @param \Magento\Framework\Reflection\DataObjectProcessor $objectProcessor - * @param \Magento\Framework\Reflection\TypeProcessor $typeProcessor - * @param \Magento\Framework\Serialization\DataBuilderFactory $dataBuilderFactory - * @param \Magento\Framework\ObjectManager\ConfigInterface $objectManagerConfig - * @param string $modelClassInterface - */ - public function __construct( - ObjectFactory $objectFactory, - MetadataServiceInterface $metadataService, - \Magento\Framework\Api\AttributeValueFactory $attributeValueFactory, - \Magento\Framework\Reflection\DataObjectProcessor $objectProcessor, - \Magento\Framework\Reflection\TypeProcessor $typeProcessor, - \Magento\Framework\Serialization\DataBuilderFactory $dataBuilderFactory, - \Magento\Framework\ObjectManager\ConfigInterface $objectManagerConfig, - $modelClassInterface = 'Magento\Catalog\Api\Data\ProductAttributeInterface' - ) { - parent::__construct( - $objectFactory, - $metadataService, - $attributeValueFactory, - $objectProcessor, - $typeProcessor, - $dataBuilderFactory, - $objectManagerConfig, - $modelClassInterface - ); - } - - /** - * @param bool|null $isWysiwygEnabled - * @return $this - */ - public function setIsWysiwygEnabled($isWysiwygEnabled) - { - $this->_set('is_wysiwyg_enabled', $isWysiwygEnabled); - return $this; - } - - /** - * @param bool|null $isHtmlAllowedOnFront - * @return $this - */ - public function setIsHtmlAllowedOnFront($isHtmlAllowedOnFront) - { - $this->_set('is_html_allowed_on_front', $isHtmlAllowedOnFront); - return $this; - } - - /** - * @param bool|null $usedForSortBy - * @return $this - */ - public function setUsedForSortBy($usedForSortBy) - { - $this->_set('used_for_sort_by', $usedForSortBy); - return $this; - } - - /** - * @param bool|null $isFilterable - * @return $this - */ - public function setIsFilterable($isFilterable) - { - $this->_set('is_filterable', $isFilterable); - return $this; - } - - /** - * @param bool|null $isFilterableInSearch - * @return $this - */ - public function setIsFilterableInSearch($isFilterableInSearch) - { - $this->_set('is_filterable_in_search', $isFilterableInSearch); - return $this; - } - - /** - * @param int|null $position - * @return $this - */ - public function setPosition($position) - { - $this->_set('position', $position); - return $this; - } - - /** - * @param string $applyTo - * @return $this - */ - public function setApplyTo($applyTo) - { - $this->_set('apply_to', $applyTo); - return $this; - } - - /** - * @param string|null $isSearchable - * @return $this - */ - public function setIsSearchable($isSearchable) - { - $this->_set('is_searchable', $isSearchable); - return $this; - } - - /** - * @param string|null $isVisibleInAdvancedSearch - * @return $this - */ - public function setIsVisibleInAdvancedSearch($isVisibleInAdvancedSearch) - { - $this->_set('is_visible_in_advanced_search', $isVisibleInAdvancedSearch); - return $this; - } - - /** - * @param string|null $isComparable - * @return $this - */ - public function setIsComparable($isComparable) - { - $this->_set('is_comparable', $isComparable); - return $this; - } - - /** - * @param string|null $isUsedForPromoRules - * @return $this - */ - public function setIsUsedForPromoRules($isUsedForPromoRules) - { - $this->_set('is_used_for_promo_rules', $isUsedForPromoRules); - return $this; - } - - /** - * @param string|null $isVisibleOnFront - * @return $this - */ - public function setIsVisibleOnFront($isVisibleOnFront) - { - $this->_set('is_visible_on_front', $isVisibleOnFront); - return $this; - } - - /** - * @param string|null $usedInProductListing - * @return $this - */ - public function setUsedInProductListing($usedInProductListing) - { - $this->_set('used_in_product_listing', $usedInProductListing); - return $this; - } - - /** - * @param bool|null $isVisible - * @return $this - */ - public function setIsVisible($isVisible) - { - $this->_set('is_visible', $isVisible); - return $this; - } - - /** - * @param string|null $scope - * @return $this - */ - public function setScope($scope) - { - $this->_set('scope', $scope); - return $this; - } - - /** - * @param int|null $attributeId - * @return $this - */ - public function setAttributeId($attributeId) - { - $this->_set('attribute_id', $attributeId); - return $this; - } - - /** - * @param string $attributeCode - * @return $this - */ - public function setAttributeCode($attributeCode) - { - $this->_set('attribute_code', $attributeCode); - return $this; - } - - /** - * @param string $frontendInput - * @return $this - */ - public function setFrontendInput($frontendInput) - { - $this->_set('frontend_input', $frontendInput); - return $this; - } - - /** - * @param string|null $entityTypeId - * @return $this - */ - public function setEntityTypeId($entityTypeId) - { - $this->_set('entity_type_id', $entityTypeId); - return $this; - } - - /** - * @param bool $isRequired - * @return $this - */ - public function setIsRequired($isRequired) - { - $this->_set('is_required', $isRequired); - return $this; - } - - /** - * @param \Magento\Eav\Api\Data\AttributeOptionInterface $options - * @return $this - */ - public function setOptions($options) - { - $this->_set('options', $options); - return $this; - } - - /** - * @param bool|null $isUserDefined - * @return $this - */ - public function setIsUserDefined($isUserDefined) - { - $this->_set('is_user_defined', $isUserDefined); - return $this; - } - - /** - * @param string $frontendLabel - * @return $this - */ - public function setDefaultFrontendLabel($frontendLabel) - { - $this->_set('frontend_label', $frontendLabel); - return $this; - } - - /** - * @param \Magento\Eav\Api\Data\AttributeFrontendLabelInterface[] - * $storeFrontendLabels - * @return $this - */ - public function setFrontendLabels($storeFrontendLabels) - { - $this->_set('frontend_labels', $storeFrontendLabels); - return $this; - } - - /** - * @param string|null $note - * @return $this - */ - public function setNote($note) - { - $this->_set('note', $note); - return $this; - } - - /** - * @param string|null $backendType - * @return $this - */ - public function setBackendType($backendType) - { - $this->_set('backend_type', $backendType); - return $this; - } - - /** - * @param string|null $backendModel - * @return $this - */ - public function setBackendModel($backendModel) - { - $this->_set('backend_model', $backendModel); - return $this; - } - - /** - * @param string|null $sourceModel - * @return $this - */ - public function setSourceModel($sourceModel) - { - $this->_set('source_model', $sourceModel); - return $this; - } - - /** - * @param string|null $defaultValue - * @return $this - */ - public function setDefaultValue($defaultValue) - { - $this->_set('default_value', $defaultValue); - return $this; - } - - /** - * @param string|null $isUnique - * @return $this - */ - public function setIsUnique($isUnique) - { - $this->_set('is_unique', $isUnique); - return $this; - } - - /** - * @param string|null $frontendClass - * @return $this - */ - public function setFrontendClass($frontendClass) - { - $this->_set('frontend_class', $frontendClass); - return $this; - } - - /** - * @param \Magento\Eav\Api\Data\AttributeValidationRuleInterface $validationRules - * @return $this - */ - public function setValidationRules($validationRules) - { - $this->_set('validation_rules', $validationRules); - return $this; - } - - /** - * {@inheritdoc} - */ - public function create() - { - /** TODO: temporary fix while problem with hasDataChanges flag not solved. MAGETWO-30324 */ - $object = parent::create(); - $object->setDataChanges(true); - return $object; - } -} diff --git a/app/code/Magento/Catalog/Api/Data/ProductAttributeSearchResultsInterface.php b/app/code/Magento/Catalog/Api/Data/ProductAttributeSearchResultsInterface.php index ab76e76994740fd51f91ab15818f6a029a37ab9f..0f1424a7c489536614597e1471ba315d09f7a17d 100644 --- a/app/code/Magento/Catalog/Api/Data/ProductAttributeSearchResultsInterface.php +++ b/app/code/Magento/Catalog/Api/Data/ProductAttributeSearchResultsInterface.php @@ -14,4 +14,12 @@ interface ProductAttributeSearchResultsInterface extends \Magento\Framework\Api\ * @return \Magento\Catalog\Api\Data\ProductAttributeInterface[] */ public function getItems(); + + /** + * Set attributes list. + * + * @param \Magento\Catalog\Api\Data\ProductAttributeInterface[] $items + * @return $this + */ + public function setItems(array $items = null); } diff --git a/app/code/Magento/Catalog/Api/Data/ProductLinkSearchResults.php b/app/code/Magento/Catalog/Api/Data/ProductLinkSearchResults.php deleted file mode 100644 index bfd0f7689c7ac31702543634b62c2a06542266b6..0000000000000000000000000000000000000000 --- a/app/code/Magento/Catalog/Api/Data/ProductLinkSearchResults.php +++ /dev/null @@ -1,23 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -namespace Magento\Catalog\Api\Data; - -/** - * @codeCoverageIgnore - */ -class ProductLinkSearchResults extends \Magento\Framework\Api\SearchResults -{ - /** - * Get items - * - * @return \Magento\Catalog\Api\Data\ProductLinkInterface[] - */ - public function getItems() - { - return parent::getItems(); - } -} diff --git a/app/code/Magento/Catalog/Api/Data/ProductSearchResultsInterface.php b/app/code/Magento/Catalog/Api/Data/ProductSearchResultsInterface.php index d3ef0bec79d055b584fd5fc211e6f627da677d9b..7349ab87124cf7e9c1a33e38814e24b0a79d4fff 100644 --- a/app/code/Magento/Catalog/Api/Data/ProductSearchResultsInterface.php +++ b/app/code/Magento/Catalog/Api/Data/ProductSearchResultsInterface.php @@ -14,4 +14,12 @@ interface ProductSearchResultsInterface extends \Magento\Framework\Api\SearchRes * @return \Magento\Catalog\Api\Data\ProductInterface[] */ public function getItems(); + + /** + * Set attributes list. + * + * @param \Magento\Catalog\Api\Data\ProductInterface[] $items + * @return $this + */ + public function setItems(array $items = null); } diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Price/Group/AbstractGroup.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Price/Group/AbstractGroup.php index 5bca99812e4c5afc4d71c7a25df3cd9aa62d11ac..859fd53ef081612b52e3f05bd99c7d83da33c254 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Price/Group/AbstractGroup.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Price/Group/AbstractGroup.php @@ -66,9 +66,9 @@ abstract class AbstractGroup extends Widget implements RendererInterface protected $_groupManagement; /** - * @var \Magento\Framework\Api\SearchCriteriaDataBuilder + * @var \Magento\Framework\Api\SearchCriteriaBuilder */ - protected $_searchCriteriaDataBuilder; + protected $_searchCriteriaBuilder; /** * @param \Magento\Backend\Block\Template\Context $context @@ -77,7 +77,7 @@ abstract class AbstractGroup extends Widget implements RendererInterface * @param \Magento\Framework\Module\Manager $moduleManager * @param \Magento\Framework\Registry $registry * @param GroupManagementInterface $groupManagement - * @param \Magento\Framework\Api\SearchCriteriaDataBuilder $searchCriteriaDataBuilder + * @param \Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder * @param array $data */ public function __construct( @@ -87,7 +87,7 @@ abstract class AbstractGroup extends Widget implements RendererInterface \Magento\Framework\Module\Manager $moduleManager, \Magento\Framework\Registry $registry, GroupManagementInterface $groupManagement, - \Magento\Framework\Api\SearchCriteriaDataBuilder $searchCriteriaDataBuilder, + \Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder, array $data = [] ) { $this->_groupRepository = $groupRepository; @@ -95,7 +95,7 @@ abstract class AbstractGroup extends Widget implements RendererInterface $this->moduleManager = $moduleManager; $this->_coreRegistry = $registry; $this->_groupManagement = $groupManagement; - $this->_searchCriteriaDataBuilder = $searchCriteriaDataBuilder; + $this->_searchCriteriaBuilder = $searchCriteriaBuilder; parent::__construct($context, $data); } @@ -191,7 +191,7 @@ abstract class AbstractGroup extends Widget implements RendererInterface } $this->_customerGroups = $this->_getInitialCustomerGroups(); /** @var \Magento\Customer\Api\Data\GroupInterface[] $groups */ - $groups = $this->_groupRepository->getList($this->_searchCriteriaDataBuilder->create()); + $groups = $this->_groupRepository->getList($this->_searchCriteriaBuilder->create()); foreach ($groups->getItems() as $group) { $this->_customerGroups[$group->getId()] = $group->getCode(); } diff --git a/app/code/Magento/Catalog/Model/Category/AttributeRepository.php b/app/code/Magento/Catalog/Model/Category/AttributeRepository.php index 98060255af1b49a195a08c39839bceb72c54c68f..bf52fc7acb6dc2c02ae364cc603460edb96c2d58 100644 --- a/app/code/Magento/Catalog/Model/Category/AttributeRepository.php +++ b/app/code/Magento/Catalog/Model/Category/AttributeRepository.php @@ -10,7 +10,7 @@ use Magento\Catalog\Api\CategoryAttributeRepositoryInterface; class AttributeRepository implements CategoryAttributeRepositoryInterface { /** - * @var \Magento\Framework\Api\SearchCriteriaDataBuilder + * @var \Magento\Framework\Api\SearchCriteriaBuilder */ protected $searchCriteriaBuilder; @@ -26,13 +26,13 @@ class AttributeRepository implements CategoryAttributeRepositoryInterface /** * @param \Magento\Framework\Api\Config\MetadataConfig $metadataConfig - * @param \Magento\Framework\Api\SearchCriteriaDataBuilder $searchCriteriaBuilder + * @param \Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder * @param \Magento\Framework\Api\FilterBuilder $filterBuilder * @param \Magento\Eav\Api\AttributeRepositoryInterface $eavAttributeRepository */ public function __construct( \Magento\Framework\Api\Config\MetadataConfig $metadataConfig, - \Magento\Framework\Api\SearchCriteriaDataBuilder $searchCriteriaBuilder, + \Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder, \Magento\Framework\Api\FilterBuilder $filterBuilder, \Magento\Eav\Api\AttributeRepositoryInterface $eavAttributeRepository ) { diff --git a/app/code/Magento/Catalog/Model/Product/Attribute/Repository.php b/app/code/Magento/Catalog/Model/Product/Attribute/Repository.php index 0d9e8f96d0b832186e47791ac9e9ba38f645d35b..6bbae5a2350c1005e73cbb8abf46f7ae87ef6159 100644 --- a/app/code/Magento/Catalog/Model/Product/Attribute/Repository.php +++ b/app/code/Magento/Catalog/Model/Product/Attribute/Repository.php @@ -50,7 +50,7 @@ class Repository implements \Magento\Catalog\Api\ProductAttributeRepositoryInter protected $metadataConfig; /** - * @var \Magento\Framework\Api\SearchCriteriaDataBuilder + * @var \Magento\Framework\Api\SearchCriteriaBuilder */ protected $searchCriteriaBuilder; @@ -67,7 +67,7 @@ class Repository implements \Magento\Catalog\Api\ProductAttributeRepositoryInter * @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\SearchCriteriaDataBuilder $searchCriteriaBuilder + * @param \Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder * @param \Magento\Framework\Api\FilterBuilder $filterBuilder * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ @@ -79,7 +79,7 @@ class Repository implements \Magento\Catalog\Api\ProductAttributeRepositoryInter \Magento\Eav\Model\Config $eavConfig, \Magento\Eav\Model\Adminhtml\System\Config\Source\Inputtype\ValidatorFactory $validatorFactory, \Magento\Framework\Api\Config\MetadataConfig $metadataConfig, - \Magento\Framework\Api\SearchCriteriaDataBuilder $searchCriteriaBuilder, + \Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder, \Magento\Framework\Api\FilterBuilder $filterBuilder ) { $this->attributeResource = $attributeResource; diff --git a/app/code/Magento/Catalog/Model/Product/Attribute/SetRepository.php b/app/code/Magento/Catalog/Model/Product/Attribute/SetRepository.php index 356dfbaeeb86bdbd3dfbf593b2bb5ef892dce1c7..372cda91ef3bc9f08f5a297888b98d51fcca04a5 100644 --- a/app/code/Magento/Catalog/Model/Product/Attribute/SetRepository.php +++ b/app/code/Magento/Catalog/Model/Product/Attribute/SetRepository.php @@ -16,7 +16,7 @@ class SetRepository implements \Magento\Catalog\Api\AttributeSetRepositoryInterf protected $attributeSetRepository; /** - * @var \Magento\Framework\Api\SearchCriteriaDataBuilder + * @var \Magento\Framework\Api\SearchCriteriaBuilder */ protected $searchCriteriaBuilder; @@ -32,13 +32,13 @@ class SetRepository implements \Magento\Catalog\Api\AttributeSetRepositoryInterf /** * @param \Magento\Eav\Api\AttributeSetRepositoryInterface $attributeSetRepository - * @param \Magento\Framework\Api\SearchCriteriaDataBuilder $searchCriteriaBuilder + * @param \Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder * @param \Magento\Framework\Api\FilterBuilder $filterBuilder * @param \Magento\Eav\Model\Config $eavConfig */ public function __construct( \Magento\Eav\Api\AttributeSetRepositoryInterface $attributeSetRepository, - \Magento\Framework\Api\SearchCriteriaDataBuilder $searchCriteriaBuilder, + \Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder, \Magento\Framework\Api\FilterBuilder $filterBuilder, \Magento\Eav\Model\Config $eavConfig ) { diff --git a/app/code/Magento/Catalog/Model/Product/Option/Converter.php b/app/code/Magento/Catalog/Model/Product/Option/Converter.php index 010348d3097dbecbb134746214352aa2cc3e3678..ac59498ccb58c323e6ce629bb0e2639b8e33b6db 100644 --- a/app/code/Magento/Catalog/Model/Product/Option/Converter.php +++ b/app/code/Magento/Catalog/Model/Product/Option/Converter.php @@ -31,7 +31,7 @@ class Converter public function toArray(\Magento\Catalog\Api\Data\ProductCustomOptionInterface $option) { $optionData = $option->getData(); - $values = $option->getData('values'); + $values = $option->getValues(); $valuesData = []; if (!empty($values)) { foreach ($values as $key => $value) { diff --git a/app/code/Magento/Catalog/Model/ProductRepository.php b/app/code/Magento/Catalog/Model/ProductRepository.php index 4a205ae8920f5a00fb1e0a3aad9de3dc09ff5151..a42e163a2b0b6ee5d0f3c037c9efc102e4c3917e 100644 --- a/app/code/Magento/Catalog/Model/ProductRepository.php +++ b/app/code/Magento/Catalog/Model/ProductRepository.php @@ -37,12 +37,12 @@ class ProductRepository implements \Magento\Catalog\Api\ProductRepositoryInterfa protected $initializationHelper; /** - * @var \Magento\Catalog\Api\Data\ProductSearchResultsDataBuilder + * @var \Magento\Catalog\Api\Data\ProductSearchResultsInterfaceFactory */ - protected $searchResultsBuilder; + protected $searchResultsFactory; /** - * @var \Magento\Framework\Api\SearchCriteriaDataBuilder + * @var \Magento\Framework\Api\SearchCriteriaBuilder */ protected $searchCriteriaBuilder; @@ -74,9 +74,9 @@ class ProductRepository implements \Magento\Catalog\Api\ProductRepositoryInterfa /** * @param ProductFactory $productFactory * @param \Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper $initializationHelper - * @param \Magento\Catalog\Api\Data\ProductSearchResultsDataBuilder $searchResultsBuilder + * @param \Magento\Catalog\Api\Data\ProductSearchResultsInterfaceFactory $searchResultsFactory * @param Resource\Product\CollectionFactory $collectionFactory - * @param \Magento\Framework\Api\SearchCriteriaDataBuilder $searchCriteriaBuilder + * @param \Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder * @param \Magento\Catalog\Api\ProductAttributeRepositoryInterface $attributeRepository * @param Resource\Product $resourceModel * @param \Magento\Framework\Api\FilterBuilder $filterBuilder @@ -85,9 +85,9 @@ class ProductRepository implements \Magento\Catalog\Api\ProductRepositoryInterfa public function __construct( ProductFactory $productFactory, \Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper $initializationHelper, - \Magento\Catalog\Api\Data\ProductSearchResultsDataBuilder $searchResultsBuilder, + \Magento\Catalog\Api\Data\ProductSearchResultsInterfaceFactory $searchResultsFactory, \Magento\Catalog\Model\Resource\Product\CollectionFactory $collectionFactory, - \Magento\Framework\Api\SearchCriteriaDataBuilder $searchCriteriaBuilder, + \Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder, \Magento\Catalog\Api\ProductAttributeRepositoryInterface $attributeRepository, \Magento\Catalog\Model\Resource\Product $resourceModel, \Magento\Framework\Api\FilterBuilder $filterBuilder, @@ -96,7 +96,7 @@ class ProductRepository implements \Magento\Catalog\Api\ProductRepositoryInterfa $this->productFactory = $productFactory; $this->collectionFactory = $collectionFactory; $this->initializationHelper = $initializationHelper; - $this->searchResultsBuilder = $searchResultsBuilder; + $this->searchResultsFactory = $searchResultsFactory; $this->searchCriteriaBuilder = $searchCriteriaBuilder; $this->resourceModel = $resourceModel; $this->attributeRepository = $attributeRepository; @@ -293,10 +293,11 @@ class ProductRepository implements \Magento\Catalog\Api\ProductRepositoryInterfa $collection->setPageSize($searchCriteria->getPageSize()); $collection->load(); - $this->searchResultsBuilder->setSearchCriteria($searchCriteria); - $this->searchResultsBuilder->setItems($collection->getItems()); - $this->searchResultsBuilder->setTotalCount($collection->getSize()); - return $this->searchResultsBuilder->create(); + $searchResult = $this->searchResultsFactory->create(); + $searchResult->setSearchCriteria($searchCriteria); + $searchResult->setItems($collection->getItems()); + $searchResult->setTotalCount($collection->getSize()); + return $searchResult; } /** 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 94c23c96eaf9c0775c504a7180e1ee7827829fbe..e5948f941ab03c593376010814923b26705c193b 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Category/AttributeRepositoryTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Category/AttributeRepositoryTest.php @@ -46,7 +46,7 @@ class AttributeRepositoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->searchBuilderMock = - $this->getMock('Magento\Framework\Api\SearchCriteriaDataBuilder', [], [], '', false); + $this->getMock('Magento\Framework\Api\SearchCriteriaBuilder', [], [], '', false); $this->filterBuilderMock = $this->getMock('Magento\Framework\Api\FilterBuilder', [], [], '', false); $this->attributeRepositoryMock = @@ -60,6 +60,9 @@ class AttributeRepositoryTest extends \PHPUnit_Framework_TestCase 'getItems', 'getSearchCriteria', 'getTotalCount', + 'setItems', + 'setSearchCriteria', + 'setTotalCount', '__wakeup' ], [], 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 198953711d6087eb6627848b2d6abc8c0abd77f9..e738b7e96bfeee4c68abcb87a6f07cfeffdf56fe 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 @@ -88,7 +88,7 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase $this->metadataConfigMock = $this->getMock('Magento\Framework\Api\Config\MetadataConfig', [], [], '', false); $this->searchCriteriaBuilderMock = - $this->getMock('Magento\Framework\Api\SearchCriteriaDataBuilder', [], [], '', false); + $this->getMock('Magento\Framework\Api\SearchCriteriaBuilder', [], [], '', false); $this->filterBuilderMock = $this->getMock('Magento\Framework\Api\FilterBuilder', [], [], '', false); $this->searchResultMock = @@ -98,6 +98,9 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase 'getItems', 'getSearchCriteria', 'getTotalCount', + 'setItems', + 'setSearchCriteria', + 'setTotalCount', '__wakeup' ], [], diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/SetRepositoryTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/SetRepositoryTest.php index c4717b0f781730e62ab7fb204c5f9d243d9cc261..70ba8feab8dac3e42fa185581ef583a60b784acd 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/SetRepositoryTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/SetRepositoryTest.php @@ -37,7 +37,7 @@ class SetRepositoryTest extends \PHPUnit_Framework_TestCase { $this->attrSetRepositoryMock = $this->getMock('\Magento\Eav\Api\AttributeSetRepositoryInterface'); $this->searchCriteriaBuilderMock = $this->getMock( - '\Magento\Framework\Api\SearchCriteriaDataBuilder', + '\Magento\Framework\Api\SearchCriteriaBuilder', [], [], '', diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ProductRepositoryTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ProductRepositoryTest.php index 6ac9a5530e2fb31c53f4c3dd758a85cf17851e19..33e3305cefa18a734566e56cfb55cd3d2985949e 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/ProductRepositoryTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/ProductRepositoryTest.php @@ -58,7 +58,7 @@ class ProductRepositoryTest extends \PHPUnit_Framework_TestCase /** * @var \PHPUnit_Framework_MockObject_MockObject */ - protected $searchResultsBuilderMock; + protected $searchResultsFactoryMock; /** * @var array data to create product @@ -93,7 +93,7 @@ class ProductRepositoryTest extends \PHPUnit_Framework_TestCase false ); $this->searchCriteriaBuilderMock = $this->getMock( - '\Magento\Framework\Api\SearchCriteriaDataBuilder', + '\Magento\Framework\Api\SearchCriteriaBuilder', [], [], '', @@ -106,9 +106,9 @@ class ProductRepositoryTest extends \PHPUnit_Framework_TestCase '', false ); - $this->searchResultsBuilderMock = $this->getMock( - '\Magento\Catalog\Api\Data\ProductSearchResultsDataBuilder', - ['setSearchCriteria', 'setItems', 'setTotalCount', 'create'], + $this->searchResultsFactoryMock = $this->getMock( + '\Magento\Catalog\Api\Data\ProductSearchResultsInterfaceFactory', + ['create'], [], '', false @@ -126,7 +126,7 @@ class ProductRepositoryTest extends \PHPUnit_Framework_TestCase 'collectionFactory' => $this->collectionFactoryMock, 'searchCriteriaBuilder' => $this->searchCriteriaBuilderMock, 'metadataServiceInterface' => $this->metadataServiceMock, - 'searchResultsBuilder' => $this->searchResultsBuilderMock + 'searchResultsFactory' => $this->searchResultsFactoryMock ] ); } @@ -424,13 +424,19 @@ class ProductRepositoryTest extends \PHPUnit_Framework_TestCase $searchCriteriaMock->expects($this->once())->method('getPageSize')->willReturn(42); $collectionMock->expects($this->once())->method('setPageSize')->with(42); $collectionMock->expects($this->once())->method('load'); - $this->searchResultsBuilderMock->expects($this->once())->method('setSearchCriteria')->with($searchCriteriaMock); $collectionMock->expects($this->once())->method('getItems')->willReturn([$itemsMock]); - $this->searchResultsBuilderMock->expects($this->once())->method('setItems')->with([$itemsMock]); $collectionMock->expects($this->once())->method('getSize')->willReturn(128); - $this->searchResultsBuilderMock->expects($this->once())->method('setTotalCount')->with(128); - $this->searchResultsBuilderMock->expects($this->once())->method('create')->willReturnSelf(); - $this->assertEquals($this->searchResultsBuilderMock, $this->model->getList($searchCriteriaMock)); + $searchResultsMock = $this->getMock( + '\Magento\Catalog\Api\Data\ProductSearchResultsInterface', + [], + [], + '', + false + ); + $searchResultsMock->expects($this->once())->method('setSearchCriteria')->with($searchCriteriaMock); + $searchResultsMock->expects($this->once())->method('setItems')->with([$itemsMock]); + $this->searchResultsFactoryMock->expects($this->once())->method('create')->willReturn($searchResultsMock); + $this->assertEquals($searchResultsMock, $this->model->getList($searchCriteriaMock)); } /** diff --git a/app/code/Magento/Catalog/etc/di.xml b/app/code/Magento/Catalog/etc/di.xml index d446005fc57a5f10d15c0d32f7b71920f9e81562..971bebcac3226849a1af0c88b08925230ea83246 100644 --- a/app/code/Magento/Catalog/etc/di.xml +++ b/app/code/Magento/Catalog/etc/di.xml @@ -442,16 +442,6 @@ <type name="Magento\Catalog\Model\Resource\Config"> <plugin name="productListingAttributesCaching" type="Magento\Catalog\Plugin\Model\Resource\Config" /> </type> - <type name="Magento\Catalog\Api\Data\CategoryDataBuilder"> - <arguments> - <argument name="metadataService" xsi:type="object">Magento\Catalog\Model\Category\AttributeRepository\Proxy</argument> - </arguments> - </type> - <type name="Magento\Catalog\Api\Data\ProductDataBuilder"> - <arguments> - <argument name="metadataService" xsi:type="object">Magento\Catalog\Model\Product\Attribute\Repository\Proxy</argument> - </arguments> - </type> <preference for="Magento\Catalog\Api\ProductLinkTypeListInterface" type="Magento\Catalog\Model\Product\LinkTypeProvider" /> <preference for="Magento\Catalog\Api\Data\ProductLinkAttributeInterface" type="\Magento\Catalog\Model\ProductLink\Attribute" /> <preference for="Magento\Catalog\Api\Data\ProductLinkTypeInterface" type="Magento\Catalog\Model\ProductLink\Type" /> diff --git a/app/code/Magento/Catalog/view/base/templates/product/price/amount/default.phtml b/app/code/Magento/Catalog/view/base/templates/product/price/amount/default.phtml index ac875f187c97a24a4ef4ee3bb10c57ed3e429fc5..c14759cdc910ec6f5c14762f917359f872a5fa86 100644 --- a/app/code/Magento/Catalog/view/base/templates/product/price/amount/default.phtml +++ b/app/code/Magento/Catalog/view/base/templates/product/price/amount/default.phtml @@ -17,7 +17,7 @@ <?php endif; ?> <span<?php if ($block->getPriceId()): ?> id="<?php echo $block->getPriceId() ?>"<?php endif;?> <?php echo($block->getPriceDisplayLabel()) ? 'data-label="' . $block->getPriceDisplayLabel() . $block->getPriceDisplayInclExclTaxes() . '"' : '' ?> - data-price-amount="<?php echo $block->getAmount()->getValue(); ?>" + data-price-amount="<?php echo $block->getDisplayValue(); ?>" data-price-type="<?php echo $block->getPriceType(); ?>" class="price-wrapper <?php echo $block->getPriceWrapperCss(); ?>" <?php echo $block->getSchema() ? ' itemprop="price"' : '' ?>> diff --git a/app/code/Magento/CatalogInventory/Api/Data/StockCollectionInterface.php b/app/code/Magento/CatalogInventory/Api/Data/StockCollectionInterface.php index d97ac8660c3ea9fbb16f885f5b3f665e36502c3e..8f5bdc39025cb7437b649c78ab94c1d46228dfa8 100644 --- a/app/code/Magento/CatalogInventory/Api/Data/StockCollectionInterface.php +++ b/app/code/Magento/CatalogInventory/Api/Data/StockCollectionInterface.php @@ -22,4 +22,12 @@ interface StockCollectionInterface extends SearchResultsInterface * @return \Magento\CatalogInventory\Api\Data\StockInterface[] */ public function getItems(); + + /** + * Set items + * + * @param \Magento\CatalogInventory\Api\Data\StockInterface[] $items + * @return $this + */ + public function setItems(array $items = null); } diff --git a/app/code/Magento/CatalogInventory/Api/Data/StockItemCollectionInterface.php b/app/code/Magento/CatalogInventory/Api/Data/StockItemCollectionInterface.php index 9052026d81fa46d84726a756b484a9ca463bba78..fad64f575cc0005a2f6b713b74564cde3dc5353e 100644 --- a/app/code/Magento/CatalogInventory/Api/Data/StockItemCollectionInterface.php +++ b/app/code/Magento/CatalogInventory/Api/Data/StockItemCollectionInterface.php @@ -24,6 +24,14 @@ interface StockItemCollectionInterface extends SearchResultsInterface */ public function getItems(); + /** + * Set items + * + * @param \Magento\CatalogInventory\Api\Data\StockItemInterface[] $items + * @return $this + */ + public function setItems(array $items = null); + /** * Get search criteria. * diff --git a/app/code/Magento/CatalogInventory/Api/Data/StockStatusCollectionInterface.php b/app/code/Magento/CatalogInventory/Api/Data/StockStatusCollectionInterface.php index 13e661dc22c25bfc5126b8617ff097d12b37d415..c20852455ee36de0c0ae97532556f9b1cf6d97d8 100644 --- a/app/code/Magento/CatalogInventory/Api/Data/StockStatusCollectionInterface.php +++ b/app/code/Magento/CatalogInventory/Api/Data/StockStatusCollectionInterface.php @@ -19,6 +19,15 @@ interface StockStatusCollectionInterface extends SearchResultsInterface */ public function getItems(); + + /** + * Sets items + * + * @param \Magento\CatalogInventory\Api\Data\StockStatusInterface[] $items + * @return $this + */ + public function setItems(array $items = null); + /** * Get search criteria. * diff --git a/app/code/Magento/CatalogUrlRewrite/Model/Category/CanonicalUrlRewriteGenerator.php b/app/code/Magento/CatalogUrlRewrite/Model/Category/CanonicalUrlRewriteGenerator.php index f4e65e37189f0e21b5260ad0ff006e919ba390ab..749b746ca8e8e2853b8c29f7732753adf257dde0 100644 --- a/app/code/Magento/CatalogUrlRewrite/Model/Category/CanonicalUrlRewriteGenerator.php +++ b/app/code/Magento/CatalogUrlRewrite/Model/Category/CanonicalUrlRewriteGenerator.php @@ -8,26 +8,26 @@ namespace Magento\CatalogUrlRewrite\Model\Category; use Magento\Catalog\Model\Category; use Magento\CatalogUrlRewrite\Model\CategoryUrlPathGenerator; use Magento\CatalogUrlRewrite\Model\CategoryUrlRewriteGenerator; -use Magento\UrlRewrite\Service\V1\Data\UrlRewriteBuilder; +use Magento\UrlRewrite\Service\V1\Data\UrlRewriteFactory; class CanonicalUrlRewriteGenerator { /** @var \Magento\CatalogUrlRewrite\Model\CategoryUrlPathGenerator */ protected $categoryUrlPathGenerator; - /** @var \Magento\UrlRewrite\Service\V1\Data\UrlRewriteBuilder */ - protected $urlRewriteBuilder; + /** @var \Magento\UrlRewrite\Service\V1\Data\UrlRewriteFactory */ + protected $urlRewriteFactory; /** * @param \Magento\CatalogUrlRewrite\Model\CategoryUrlPathGenerator $categoryUrlPathGenerator - * @param \Magento\UrlRewrite\Service\V1\Data\UrlRewriteBuilder $urlRewriteBuilder + * @param \Magento\UrlRewrite\Service\V1\Data\UrlRewriteFactory $urlRewriteFactory */ public function __construct( CategoryUrlPathGenerator $categoryUrlPathGenerator, - UrlRewriteBuilder $urlRewriteBuilder + UrlRewriteFactory $urlRewriteFactory ) { $this->categoryUrlPathGenerator = $categoryUrlPathGenerator; - $this->urlRewriteBuilder = $urlRewriteBuilder; + $this->urlRewriteFactory = $urlRewriteFactory; } /** @@ -40,12 +40,11 @@ class CanonicalUrlRewriteGenerator public function generate($storeId, Category $category) { return [ - $this->urlRewriteBuilder->setStoreId($storeId) + $this->urlRewriteFactory->create()->setStoreId($storeId) ->setEntityType(CategoryUrlRewriteGenerator::ENTITY_TYPE) ->setEntityId($category->getId()) ->setRequestPath($this->categoryUrlPathGenerator->getUrlPathWithSuffix($category, $storeId)) ->setTargetPath($this->categoryUrlPathGenerator->getCanonicalUrlPath($category)) - ->create() ]; } } diff --git a/app/code/Magento/CatalogUrlRewrite/Model/Category/CurrentUrlRewritesRegenerator.php b/app/code/Magento/CatalogUrlRewrite/Model/Category/CurrentUrlRewritesRegenerator.php index f4f81c95acee54853ccfd571d1bc991069292fee..fc7107801aca1499d67eb3ec16e6dbd385f7a588 100644 --- a/app/code/Magento/CatalogUrlRewrite/Model/Category/CurrentUrlRewritesRegenerator.php +++ b/app/code/Magento/CatalogUrlRewrite/Model/Category/CurrentUrlRewritesRegenerator.php @@ -11,15 +11,15 @@ use Magento\CatalogUrlRewrite\Model\CategoryUrlRewriteGenerator; use Magento\UrlRewrite\Model\OptionProvider; use Magento\UrlRewrite\Model\UrlFinderInterface; use Magento\UrlRewrite\Service\V1\Data\UrlRewrite; -use Magento\UrlRewrite\Service\V1\Data\UrlRewriteBuilder; +use Magento\UrlRewrite\Service\V1\Data\UrlRewriteFactory; class CurrentUrlRewritesRegenerator { /** @var \Magento\CatalogUrlRewrite\Model\CategoryUrlPathGenerator */ protected $categoryUrlPathGenerator; - /** @var \Magento\UrlRewrite\Service\V1\Data\UrlRewriteBuilder */ - protected $urlRewriteBuilder; + /** @var \Magento\UrlRewrite\Service\V1\Data\UrlRewriteFactory */ + protected $urlRewriteFactory; /** @var UrlFinderInterface */ protected $urlFinder; @@ -29,16 +29,16 @@ class CurrentUrlRewritesRegenerator /** * @param \Magento\CatalogUrlRewrite\Model\CategoryUrlPathGenerator $categoryUrlPathGenerator - * @param \Magento\UrlRewrite\Service\V1\Data\UrlRewriteBuilder $urlRewriteBuilder + * @param \Magento\UrlRewrite\Service\V1\Data\UrlRewriteFactory $urlRewriteFactory * @param UrlFinderInterface $urlFinder */ public function __construct( CategoryUrlPathGenerator $categoryUrlPathGenerator, - UrlRewriteBuilder $urlRewriteBuilder, + UrlRewriteFactory $urlRewriteFactory, UrlFinderInterface $urlFinder ) { $this->categoryUrlPathGenerator = $categoryUrlPathGenerator; - $this->urlRewriteBuilder = $urlRewriteBuilder; + $this->urlRewriteFactory = $urlRewriteFactory; $this->urlFinder = $urlFinder; } @@ -83,15 +83,14 @@ class CurrentUrlRewritesRegenerator if ($this->category->getData('save_rewrites_history')) { $targetPath = $this->categoryUrlPathGenerator->getUrlPathWithSuffix($this->category, $storeId); if ($url->getRequestPath() !== $targetPath) { - $urls[] = $this->urlRewriteBuilder + $urls[] = $this->urlRewriteFactory->create() ->setEntityType(CategoryUrlRewriteGenerator::ENTITY_TYPE) ->setEntityId($this->category->getId()) ->setRequestPath($url->getRequestPath()) ->setTargetPath($targetPath) ->setRedirectType(OptionProvider::PERMANENT) ->setStoreId($storeId) - ->setIsAutogenerated(0) - ->create(); + ->setIsAutogenerated(0); } } return $urls; @@ -109,7 +108,7 @@ class CurrentUrlRewritesRegenerator ? $url->getTargetPath() : $this->categoryUrlPathGenerator->getUrlPathWithSuffix($this->category, $storeId); if ($url->getRequestPath() !== $targetPath) { - $urls[] = $this->urlRewriteBuilder + $urls[] = $this->urlRewriteFactory->create() ->setEntityType(CategoryUrlRewriteGenerator::ENTITY_TYPE) ->setEntityId($this->category->getId()) ->setRequestPath($url->getRequestPath()) @@ -118,8 +117,7 @@ class CurrentUrlRewritesRegenerator ->setStoreId($storeId) ->setDescription($url->getDescription()) ->setIsAutogenerated(0) - ->setMetadata($url->getMetadata()) - ->create(); + ->setMetadata($url->getMetadata()); } return $urls; } diff --git a/app/code/Magento/CatalogUrlRewrite/Model/Product/CanonicalUrlRewriteGenerator.php b/app/code/Magento/CatalogUrlRewrite/Model/Product/CanonicalUrlRewriteGenerator.php index cea457ef62b3c129f3958f3c1db06fea3e3065b1..ba76c1451c50802f5d85ab19e880a69bec77eb4f 100644 --- a/app/code/Magento/CatalogUrlRewrite/Model/Product/CanonicalUrlRewriteGenerator.php +++ b/app/code/Magento/CatalogUrlRewrite/Model/Product/CanonicalUrlRewriteGenerator.php @@ -9,24 +9,24 @@ use Magento\Catalog\Model\Product; use Magento\CatalogUrlRewrite\Model\ProductUrlPathGenerator; use Magento\CatalogUrlRewrite\Model\ProductUrlRewriteGenerator; use Magento\UrlRewrite\Service\V1\Data\UrlRewrite; -use Magento\UrlRewrite\Service\V1\Data\UrlRewriteBuilder; +use Magento\UrlRewrite\Service\V1\Data\UrlRewriteFactory; class CanonicalUrlRewriteGenerator { /** @var ProductUrlPathGenerator */ protected $productUrlPathGenerator; - /** @var UrlRewriteBuilder */ - protected $urlRewriteBuilder; + /** @var UrlRewriteFactory */ + protected $urlRewriteFactory; /** * @param ProductUrlPathGenerator $productUrlPathGenerator - * @param UrlRewriteBuilder $urlRewriteBuilder + * @param UrlRewriteFactory $urlRewriteFactory */ - public function __construct(ProductUrlPathGenerator $productUrlPathGenerator, UrlRewriteBuilder $urlRewriteBuilder) + public function __construct(ProductUrlPathGenerator $productUrlPathGenerator, UrlRewriteFactory $urlRewriteFactory) { $this->productUrlPathGenerator = $productUrlPathGenerator; - $this->urlRewriteBuilder = $urlRewriteBuilder; + $this->urlRewriteFactory = $urlRewriteFactory; } /** @@ -39,13 +39,12 @@ class CanonicalUrlRewriteGenerator public function generate($storeId, Product $product) { return [ - $this->urlRewriteBuilder + $this->urlRewriteFactory->create() ->setEntityType(ProductUrlRewriteGenerator::ENTITY_TYPE) ->setEntityId($product->getId()) ->setRequestPath($this->productUrlPathGenerator->getUrlPathWithSuffix($product, $storeId)) ->setTargetPath($this->productUrlPathGenerator->getCanonicalUrlPath($product)) ->setStoreId($storeId) - ->create() ]; } } diff --git a/app/code/Magento/CatalogUrlRewrite/Model/Product/CategoriesUrlRewriteGenerator.php b/app/code/Magento/CatalogUrlRewrite/Model/Product/CategoriesUrlRewriteGenerator.php index cd0296aca6580fb03dd08e80c1c15e37a9e0fba9..872c94b1c4bc96384fda494525aacc27be005dbf 100644 --- a/app/code/Magento/CatalogUrlRewrite/Model/Product/CategoriesUrlRewriteGenerator.php +++ b/app/code/Magento/CatalogUrlRewrite/Model/Product/CategoriesUrlRewriteGenerator.php @@ -10,24 +10,24 @@ use Magento\CatalogUrlRewrite\Model\ObjectRegistry; use Magento\CatalogUrlRewrite\Model\ProductUrlPathGenerator; use Magento\CatalogUrlRewrite\Model\ProductUrlRewriteGenerator; use Magento\UrlRewrite\Service\V1\Data\UrlRewrite; -use Magento\UrlRewrite\Service\V1\Data\UrlRewriteBuilder; +use Magento\UrlRewrite\Service\V1\Data\UrlRewriteFactory; class CategoriesUrlRewriteGenerator { /** @var ProductUrlPathGenerator */ protected $productUrlPathGenerator; - /** @var UrlRewriteBuilder */ - protected $urlRewriteBuilder; + /** @var UrlRewriteFactory */ + protected $urlRewriteFactory; /** * @param ProductUrlPathGenerator $productUrlPathGenerator - * @param UrlRewriteBuilder $urlRewriteBuilder + * @param UrlRewriteFactory $urlRewriteFactory */ - public function __construct(ProductUrlPathGenerator $productUrlPathGenerator, UrlRewriteBuilder $urlRewriteBuilder) + public function __construct(ProductUrlPathGenerator $productUrlPathGenerator, UrlRewriteFactory $urlRewriteFactory) { $this->productUrlPathGenerator = $productUrlPathGenerator; - $this->urlRewriteBuilder = $urlRewriteBuilder; + $this->urlRewriteFactory = $urlRewriteFactory; } /** @@ -42,14 +42,13 @@ class CategoriesUrlRewriteGenerator { $urls = []; foreach ($productCategories->getList() as $category) { - $urls[] = $this->urlRewriteBuilder + $urls[] = $this->urlRewriteFactory->create() ->setEntityType(ProductUrlRewriteGenerator::ENTITY_TYPE) ->setEntityId($product->getId()) ->setRequestPath($this->productUrlPathGenerator->getUrlPathWithSuffix($product, $storeId, $category)) ->setTargetPath($this->productUrlPathGenerator->getCanonicalUrlPath($product, $category)) ->setStoreId($storeId) - ->setMetadata(['category_id' => $category->getId()]) - ->create(); + ->setMetadata(['category_id' => $category->getId()]); } return $urls; } diff --git a/app/code/Magento/CatalogUrlRewrite/Model/Product/CurrentUrlRewritesRegenerator.php b/app/code/Magento/CatalogUrlRewrite/Model/Product/CurrentUrlRewritesRegenerator.php index 1e6fac93ed6fdb3b16c89fd2b09980300518bbdb..bc62a07c63a3c8a485bb4fd4ad57e98e51f8fd78 100644 --- a/app/code/Magento/CatalogUrlRewrite/Model/Product/CurrentUrlRewritesRegenerator.php +++ b/app/code/Magento/CatalogUrlRewrite/Model/Product/CurrentUrlRewritesRegenerator.php @@ -13,7 +13,7 @@ use Magento\CatalogUrlRewrite\Model\ObjectRegistry; use Magento\UrlRewrite\Model\UrlFinderInterface; use Magento\CatalogUrlRewrite\Model\ProductUrlRewriteGenerator; use Magento\CatalogUrlRewrite\Model\ProductUrlPathGenerator; -use Magento\UrlRewrite\Service\V1\Data\UrlRewriteBuilder; +use Magento\UrlRewrite\Service\V1\Data\UrlRewriteFactory; use Magento\Store\Model\StoreManagerInterface; /** @@ -33,22 +33,22 @@ class CurrentUrlRewritesRegenerator /** @var ProductUrlPathGenerator */ protected $productUrlPathGenerator; - /** @var UrlRewriteBuilder */ - protected $urlRewriteBuilder; + /** @var UrlRewriteFactory */ + protected $urlRewriteFactory; /** * @param UrlFinderInterface $urlFinder * @param ProductUrlPathGenerator $productUrlPathGenerator - * @param UrlRewriteBuilder $urlRewriteBuilder + * @param UrlRewriteFactory $urlRewriteFactory */ public function __construct( UrlFinderInterface $urlFinder, ProductUrlPathGenerator $productUrlPathGenerator, - UrlRewriteBuilder $urlRewriteBuilder + UrlRewriteFactory $urlRewriteFactory ) { $this->urlFinder = $urlFinder; $this->productUrlPathGenerator = $productUrlPathGenerator; - $this->urlRewriteBuilder = $urlRewriteBuilder; + $this->urlRewriteFactory = $urlRewriteFactory; } /** @@ -105,7 +105,7 @@ class CurrentUrlRewritesRegenerator return []; } return [ - $this->urlRewriteBuilder + $this->urlRewriteFactory->create() ->setEntityType(ProductUrlRewriteGenerator::ENTITY_TYPE) ->setEntityId($this->product->getId()) ->setRequestPath($url->getRequestPath()) @@ -115,7 +115,6 @@ class CurrentUrlRewritesRegenerator ->setDescription($url->getDescription()) ->setIsAutogenerated(0) ->setMetadata($url->getMetadata()) - ->create() ]; } @@ -134,7 +133,7 @@ class CurrentUrlRewritesRegenerator return []; } return [ - $this->urlRewriteBuilder + $this->urlRewriteFactory->create() ->setEntityType(ProductUrlRewriteGenerator::ENTITY_TYPE) ->setEntityId($this->product->getId()) ->setRequestPath($url->getRequestPath()) @@ -144,7 +143,6 @@ class CurrentUrlRewritesRegenerator ->setDescription($url->getDescription()) ->setIsAutogenerated(0) ->setMetadata($url->getMetadata()) - ->create() ]; } 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 768bfcdea8afe02a66da3093d7252a0077cd8844..93a09f24ea8ac466b08ac4d8c2ce0d0771476a81 100644 --- a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Category/CanonicalUrlRewriteGeneratorTest.php +++ b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Category/CanonicalUrlRewriteGeneratorTest.php @@ -19,15 +19,16 @@ class CanonicalUrlRewriteGeneratorTest extends \PHPUnit_Framework_TestCase /** @var \Magento\Catalog\Model\Category|\PHPUnit_Framework_MockObject_MockObject */ protected $category; - /** @var \Magento\UrlRewrite\Service\V1\Data\UrlRewriteBuilder|\PHPUnit_Framework_MockObject_MockObject */ - protected $urlRewriteBuilder; + /** @var \Magento\UrlRewrite\Service\V1\Data\UrlRewriteFactory|\PHPUnit_Framework_MockObject_MockObject */ + protected $urlRewriteFactory; /** @var \Magento\UrlRewrite\Service\V1\Data\UrlRewrite|\PHPUnit_Framework_MockObject_MockObject */ protected $urlRewrite; protected function setUp() { - $this->urlRewriteBuilder = $this->getMockBuilder('Magento\UrlRewrite\Service\V1\Data\UrlRewriteBuilder') + $this->urlRewriteFactory = $this->getMockBuilder('Magento\UrlRewrite\Service\V1\Data\UrlRewriteFactory') + ->setMethods(['create']) ->disableOriginalConstructor()->getMock(); $this->urlRewrite = $this->getMockBuilder('Magento\UrlRewrite\Service\V1\Data\UrlRewrite') ->disableOriginalConstructor()->getMock(); @@ -40,7 +41,7 @@ class CanonicalUrlRewriteGeneratorTest extends \PHPUnit_Framework_TestCase 'Magento\CatalogUrlRewrite\Model\Category\CanonicalUrlRewriteGenerator', [ 'categoryUrlPathGenerator' => $this->categoryUrlPathGenerator, - 'urlRewriteBuilder' => $this->urlRewriteBuilder + 'urlRewriteFactory' => $this->urlRewriteFactory ] ); } @@ -57,17 +58,17 @@ class CanonicalUrlRewriteGeneratorTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue($requestPath)); $this->categoryUrlPathGenerator->expects($this->any())->method('getCanonicalUrlPath') ->will($this->returnValue($targetPath)); - $this->urlRewriteBuilder->expects($this->any())->method('setStoreId')->with($storeId) + $this->urlRewrite->expects($this->any())->method('setStoreId')->with($storeId) ->will($this->returnSelf()); - $this->urlRewriteBuilder->expects($this->any())->method('setEntityId')->with($categoryId) + $this->urlRewrite->expects($this->any())->method('setEntityId')->with($categoryId) ->will($this->returnSelf()); - $this->urlRewriteBuilder->expects($this->any())->method('setEntityType') + $this->urlRewrite->expects($this->any())->method('setEntityType') ->with(CategoryUrlRewriteGenerator::ENTITY_TYPE)->will($this->returnSelf()); - $this->urlRewriteBuilder->expects($this->any())->method('setRequestPath')->with($requestPath) + $this->urlRewrite->expects($this->any())->method('setRequestPath')->with($requestPath) ->will($this->returnSelf()); - $this->urlRewriteBuilder->expects($this->any())->method('setTargetPath')->with($targetPath) + $this->urlRewrite->expects($this->any())->method('setTargetPath')->with($targetPath) ->will($this->returnSelf()); - $this->urlRewriteBuilder->expects($this->any())->method('create')->will($this->returnValue($this->urlRewrite)); + $this->urlRewriteFactory->expects($this->any())->method('create')->will($this->returnValue($this->urlRewrite)); $this->assertEquals( [$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 284d67132535fd70fe866f71a898a766c888fb14..db8545333579635b506339ead620e789fd8551de 100644 --- a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Category/CurrentUrlRewritesRegeneratorTest.php +++ b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Category/CurrentUrlRewritesRegeneratorTest.php @@ -27,15 +27,16 @@ class CurrentUrlRewritesRegeneratorTest extends \PHPUnit_Framework_TestCase /** @var \Magento\Catalog\Model\Category|\PHPUnit_Framework_MockObject_MockObject */ protected $category; - /** @var \Magento\UrlRewrite\Service\V1\Data\UrlRewriteBuilder|\PHPUnit_Framework_MockObject_MockObject */ - protected $urlRewriteBuilder; + /** @var \Magento\UrlRewrite\Service\V1\Data\UrlRewriteFactory|\PHPUnit_Framework_MockObject_MockObject */ + protected $urlRewriteFactory; /** @var \Magento\UrlRewrite\Service\V1\Data\UrlRewrite|\PHPUnit_Framework_MockObject_MockObject */ protected $urlRewrite; protected function setUp() { - $this->urlRewriteBuilder = $this->getMockBuilder('Magento\UrlRewrite\Service\V1\Data\UrlRewriteBuilder') + $this->urlRewriteFactory = $this->getMockBuilder('Magento\UrlRewrite\Service\V1\Data\UrlRewriteFactory') + ->setMethods(['create']) ->disableOriginalConstructor()->getMock(); $this->urlRewrite = $this->getMockBuilder('Magento\UrlRewrite\Service\V1\Data\UrlRewrite') ->disableOriginalConstructor()->getMock(); @@ -55,7 +56,7 @@ class CurrentUrlRewritesRegeneratorTest extends \PHPUnit_Framework_TestCase [ 'urlFinder' => $this->urlFinder, 'categoryUrlPathGenerator' => $this->categoryUrlPathGenerator, - 'urlRewriteBuilder' => $this->urlRewriteBuilder + 'urlRewriteFactory' => $this->urlRewriteFactory ] ); } @@ -183,8 +184,10 @@ class CurrentUrlRewritesRegeneratorTest extends \PHPUnit_Framework_TestCase ); $this->categoryUrlPathGenerator->expects($this->never())->method('getUrlPathWithSuffix'); $this->category->expects($this->any())->method('getId')->will($this->returnValue($categoryId)); - $this->urlRewriteBuilder->expects($this->once())->method('setDescription')->with($description) + $this->urlRewrite->expects($this->once())->method('setDescription')->with($description) ->will($this->returnSelf()); + $this->urlRewriteFactory->expects($this->once())->method('create') + ->willReturn($this->urlRewrite); $this->prepareUrlRewriteMock($storeId, $categoryId, $requestPath, $targetPath, 0); $this->assertEquals( @@ -220,8 +223,10 @@ class CurrentUrlRewritesRegeneratorTest extends \PHPUnit_Framework_TestCase $this->categoryUrlPathGenerator->expects($this->any())->method('getUrlPathWithSuffix') ->will($this->returnValue($targetPath)); $this->category->expects($this->any())->method('getId')->will($this->returnValue($categoryId)); - $this->urlRewriteBuilder->expects($this->once())->method('setDescription')->with($description) + $this->urlRewrite->expects($this->once())->method('setDescription')->with($description) ->will($this->returnSelf()); + $this->urlRewriteFactory->expects($this->once())->method('create') + ->willReturn($this->urlRewrite); $this->prepareUrlRewriteMock($storeId, $categoryId, $requestPath, $targetPath, 'code'); $this->assertEquals( @@ -260,21 +265,21 @@ class CurrentUrlRewritesRegeneratorTest extends \PHPUnit_Framework_TestCase */ protected function prepareUrlRewriteMock($storeId, $categoryId, $requestPath, $targetPath, $redirectType) { - $this->urlRewriteBuilder->expects($this->any())->method('setStoreId')->with($storeId) + $this->urlRewrite->expects($this->any())->method('setStoreId')->with($storeId) ->will($this->returnSelf()); - $this->urlRewriteBuilder->expects($this->any())->method('setEntityId')->with($categoryId) + $this->urlRewrite->expects($this->any())->method('setEntityId')->with($categoryId) ->will($this->returnSelf()); - $this->urlRewriteBuilder->expects($this->any())->method('setEntityType') + $this->urlRewrite->expects($this->any())->method('setEntityType') ->with(CategoryUrlRewriteGenerator::ENTITY_TYPE)->will($this->returnSelf()); - $this->urlRewriteBuilder->expects($this->any())->method('setRequestPath')->with($requestPath) + $this->urlRewrite->expects($this->any())->method('setRequestPath')->with($requestPath) ->will($this->returnSelf()); - $this->urlRewriteBuilder->expects($this->any())->method('setTargetPath')->with($targetPath) + $this->urlRewrite->expects($this->any())->method('setTargetPath')->with($targetPath) ->will($this->returnSelf()); - $this->urlRewriteBuilder->expects($this->any())->method('setIsAutogenerated')->with(0) + $this->urlRewrite->expects($this->any())->method('setIsAutogenerated')->with(0) ->will($this->returnSelf()); - $this->urlRewriteBuilder->expects($this->any())->method('setRedirectType')->with($redirectType) + $this->urlRewrite->expects($this->any())->method('setRedirectType')->with($redirectType) ->will($this->returnSelf()); - $this->urlRewriteBuilder->expects($this->any())->method('setMetadata')->with([])->will($this->returnSelf()); - $this->urlRewriteBuilder->expects($this->any())->method('create')->will($this->returnValue($this->urlRewrite)); + $this->urlRewrite->expects($this->any())->method('setMetadata')->with([])->will($this->returnSelf()); + $this->urlRewriteFactory->expects($this->any())->method('create')->will($this->returnValue($this->urlRewrite)); } } diff --git a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Product/CanonicalUrlRewriteGeneratorTest.php b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Product/CanonicalUrlRewriteGeneratorTest.php index 6bf7b9b3753e41498e904f338270cec294cfaad4..eda2ea617c63a220b087f9fd0657fde94301f541 100644 --- a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Product/CanonicalUrlRewriteGeneratorTest.php +++ b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Product/CanonicalUrlRewriteGeneratorTest.php @@ -22,15 +22,16 @@ class CanonicalUrlRewriteGeneratorTest extends \PHPUnit_Framework_TestCase /** @var \Magento\CatalogUrlRewrite\Model\ObjectRegistry|\PHPUnit_Framework_MockObject_MockObject */ protected $categoryRegistry; - /** @var \Magento\UrlRewrite\Service\V1\Data\UrlRewriteBuilder|\PHPUnit_Framework_MockObject_MockObject */ - protected $urlRewriteBuilder; + /** @var \Magento\UrlRewrite\Service\V1\Data\UrlRewriteFactory|\PHPUnit_Framework_MockObject_MockObject */ + protected $urlRewriteFactory; /** @var \Magento\UrlRewrite\Service\V1\Data\UrlRewrite|\PHPUnit_Framework_MockObject_MockObject */ protected $urlRewrite; protected function setUp() { - $this->urlRewriteBuilder = $this->getMockBuilder('Magento\UrlRewrite\Service\V1\Data\UrlRewriteBuilder') + $this->urlRewriteFactory = $this->getMockBuilder('Magento\UrlRewrite\Service\V1\Data\UrlRewriteFactory') + ->setMethods(['create']) ->disableOriginalConstructor()->getMock(); $this->urlRewrite = $this->getMockBuilder('Magento\UrlRewrite\Service\V1\Data\UrlRewrite') ->disableOriginalConstructor()->getMock(); @@ -45,7 +46,7 @@ class CanonicalUrlRewriteGeneratorTest extends \PHPUnit_Framework_TestCase 'Magento\CatalogUrlRewrite\Model\Product\CanonicalUrlRewriteGenerator', [ 'productUrlPathGenerator' => $this->productUrlPathGenerator, - 'urlRewriteBuilder' => $this->urlRewriteBuilder + 'urlRewriteFactory' => $this->urlRewriteFactory ] ); } @@ -64,17 +65,17 @@ class CanonicalUrlRewriteGeneratorTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue($targetPath)); $this->categoryRegistry->expects($this->any())->method('getList')->will($this->returnValue([])); - $this->urlRewriteBuilder->expects($this->any())->method('setStoreId')->with($storeId) + $this->urlRewrite->expects($this->any())->method('setStoreId')->with($storeId) ->will($this->returnSelf()); - $this->urlRewriteBuilder->expects($this->any())->method('setEntityId')->with($productId) + $this->urlRewrite->expects($this->any())->method('setEntityId')->with($productId) ->will($this->returnSelf()); - $this->urlRewriteBuilder->expects($this->any())->method('setEntityType') + $this->urlRewrite->expects($this->any())->method('setEntityType') ->with(ProductUrlRewriteGenerator::ENTITY_TYPE)->will($this->returnSelf()); - $this->urlRewriteBuilder->expects($this->any())->method('setRequestPath')->with($requestPath) + $this->urlRewrite->expects($this->any())->method('setRequestPath')->with($requestPath) ->will($this->returnSelf()); - $this->urlRewriteBuilder->expects($this->any())->method('setTargetPath')->with($targetPath) + $this->urlRewrite->expects($this->any())->method('setTargetPath')->with($targetPath) ->will($this->returnSelf()); - $this->urlRewriteBuilder->expects($this->any())->method('create')->will($this->returnValue($this->urlRewrite)); + $this->urlRewriteFactory->expects($this->any())->method('create')->will($this->returnValue($this->urlRewrite)); $this->assertEquals( [ $this->urlRewrite, diff --git a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Product/CategoriesUrlRewriteGeneratorTest.php b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Product/CategoriesUrlRewriteGeneratorTest.php index 04597a4e37b792d43652d0f1bda0c53d8e509ded..b72f47d04d06468e71b905d60b320ccfc0daac79 100644 --- a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Product/CategoriesUrlRewriteGeneratorTest.php +++ b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Product/CategoriesUrlRewriteGeneratorTest.php @@ -23,15 +23,16 @@ class CategoriesUrlRewriteGeneratorTest extends \PHPUnit_Framework_TestCase /** @var \Magento\CatalogUrlRewrite\Model\ObjectRegistry|\PHPUnit_Framework_MockObject_MockObject */ protected $categoryRegistry; - /** @var \Magento\UrlRewrite\Service\V1\Data\UrlRewriteBuilder|\PHPUnit_Framework_MockObject_MockObject */ - protected $urlRewriteBuilder; + /** @var \Magento\UrlRewrite\Service\V1\Data\UrlRewriteFactory|\PHPUnit_Framework_MockObject_MockObject */ + protected $urlRewriteFactory; /** @var \Magento\UrlRewrite\Service\V1\Data\UrlRewrite|\PHPUnit_Framework_MockObject_MockObject */ protected $urlRewrite; protected function setUp() { - $this->urlRewriteBuilder = $this->getMockBuilder('Magento\UrlRewrite\Service\V1\Data\UrlRewriteBuilder') + $this->urlRewriteFactory = $this->getMockBuilder('Magento\UrlRewrite\Service\V1\Data\UrlRewriteFactory') + ->setMethods(['create']) ->disableOriginalConstructor()->getMock(); $this->urlRewrite = $this->getMockBuilder('Magento\UrlRewrite\Service\V1\Data\UrlRewrite') ->disableOriginalConstructor()->getMock(); @@ -46,7 +47,7 @@ class CategoriesUrlRewriteGeneratorTest extends \PHPUnit_Framework_TestCase 'Magento\CatalogUrlRewrite\Model\Product\CategoriesUrlRewriteGenerator', [ 'productUrlPathGenerator' => $this->productUrlPathGenerator, - 'urlRewriteBuilder' => $this->urlRewriteBuilder + 'urlRewriteFactory' => $this->urlRewriteFactory ] ); } @@ -79,19 +80,19 @@ class CategoriesUrlRewriteGeneratorTest extends \PHPUnit_Framework_TestCase $this->categoryRegistry->expects($this->any())->method('getList') ->will($this->returnValue([$category])); - $this->urlRewriteBuilder->expects($this->any())->method('setStoreId')->with($storeId) + $this->urlRewrite->expects($this->any())->method('setStoreId')->with($storeId) ->will($this->returnSelf()); - $this->urlRewriteBuilder->expects($this->any())->method('setEntityId')->with($productId) + $this->urlRewrite->expects($this->any())->method('setEntityId')->with($productId) ->will($this->returnSelf()); - $this->urlRewriteBuilder->expects($this->any())->method('setEntityType') + $this->urlRewrite->expects($this->any())->method('setEntityType') ->with(ProductUrlRewriteGenerator::ENTITY_TYPE)->will($this->returnSelf()); - $this->urlRewriteBuilder->expects($this->any())->method('setRequestPath')->with($urlPathWithCategory) + $this->urlRewrite->expects($this->any())->method('setRequestPath')->with($urlPathWithCategory) ->will($this->returnSelf()); - $this->urlRewriteBuilder->expects($this->any())->method('setTargetPath')->with($canonicalUrlPathWithCategory) + $this->urlRewrite->expects($this->any())->method('setTargetPath')->with($canonicalUrlPathWithCategory) ->will($this->returnSelf()); - $this->urlRewriteBuilder->expects($this->any())->method('setMetadata') + $this->urlRewrite->expects($this->any())->method('setMetadata') ->with(['category_id' => $categoryId])->will($this->returnSelf()); - $this->urlRewriteBuilder->expects($this->any())->method('create')->will($this->returnValue($this->urlRewrite)); + $this->urlRewriteFactory->expects($this->any())->method('create')->will($this->returnValue($this->urlRewrite)); $this->assertEquals( [ diff --git a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Product/CurrentUrlRewritesRegeneratorTest.php b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Product/CurrentUrlRewritesRegeneratorTest.php index b40de1acbb26822fa7bb2ed7c4e1ff56c2ad7e1d..05f28533c92c05062d690aa41a5fcfd7517185d0 100644 --- a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Product/CurrentUrlRewritesRegeneratorTest.php +++ b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Product/CurrentUrlRewritesRegeneratorTest.php @@ -33,15 +33,16 @@ class CurrentUrlRewritesRegeneratorTest extends \PHPUnit_Framework_TestCase /** @var \Magento\CatalogUrlRewrite\Model\ObjectRegistry|\PHPUnit_Framework_MockObject_MockObject */ protected $objectRegistry; - /** @var \Magento\UrlRewrite\Service\V1\Data\UrlRewriteBuilder|\PHPUnit_Framework_MockObject_MockObject */ - protected $urlRewriteBuilder; + /** @var \Magento\UrlRewrite\Service\V1\Data\UrlRewriteFactory|\PHPUnit_Framework_MockObject_MockObject */ + protected $urlRewriteFactory; /** @var \Magento\UrlRewrite\Service\V1\Data\UrlRewrite|\PHPUnit_Framework_MockObject_MockObject */ protected $urlRewrite; protected function setUp() { - $this->urlRewriteBuilder = $this->getMockBuilder('Magento\UrlRewrite\Service\V1\Data\UrlRewriteBuilder') + $this->urlRewriteFactory = $this->getMockBuilder('Magento\UrlRewrite\Service\V1\Data\UrlRewriteFactory') + ->setMethods(['create']) ->disableOriginalConstructor()->getMock(); $this->urlRewrite = $this->getMockBuilder('Magento\UrlRewrite\Service\V1\Data\UrlRewrite') ->disableOriginalConstructor()->getMock(); @@ -65,7 +66,7 @@ class CurrentUrlRewritesRegeneratorTest extends \PHPUnit_Framework_TestCase [ 'urlFinder' => $this->urlFinder, 'productUrlPathGenerator' => $this->productUrlPathGenerator, - 'urlRewriteBuilder' => $this->urlRewriteBuilder + 'urlRewriteFactory' => $this->urlRewriteFactory ] ); } @@ -296,24 +297,24 @@ class CurrentUrlRewritesRegeneratorTest extends \PHPUnit_Framework_TestCase $metadata, $description ) { - $this->urlRewriteBuilder->expects($this->any())->method('setStoreId')->with($storeId) + $this->urlRewrite->expects($this->any())->method('setStoreId')->with($storeId) ->will($this->returnSelf()); - $this->urlRewriteBuilder->expects($this->any())->method('setEntityId')->with($productId) + $this->urlRewrite->expects($this->any())->method('setEntityId')->with($productId) ->will($this->returnSelf()); - $this->urlRewriteBuilder->expects($this->any())->method('setEntityType') + $this->urlRewrite->expects($this->any())->method('setEntityType') ->with(ProductUrlRewriteGenerator::ENTITY_TYPE)->will($this->returnSelf()); - $this->urlRewriteBuilder->expects($this->any())->method('setRequestPath')->with($requestPath) + $this->urlRewrite->expects($this->any())->method('setRequestPath')->with($requestPath) ->will($this->returnSelf()); - $this->urlRewriteBuilder->expects($this->any())->method('setTargetPath')->with($targetPath) + $this->urlRewrite->expects($this->any())->method('setTargetPath')->with($targetPath) ->will($this->returnSelf()); - $this->urlRewriteBuilder->expects($this->any())->method('setIsAutogenerated')->with(0) + $this->urlRewrite->expects($this->any())->method('setIsAutogenerated')->with(0) ->will($this->returnSelf()); - $this->urlRewriteBuilder->expects($this->any())->method('setRedirectType')->with($redirectType) + $this->urlRewrite->expects($this->any())->method('setRedirectType')->with($redirectType) ->will($this->returnSelf()); - $this->urlRewriteBuilder->expects($this->any())->method('setMetadata')->with($metadata) + $this->urlRewrite->expects($this->any())->method('setMetadata')->with($metadata) ->will($this->returnSelf()); - $this->urlRewriteBuilder->expects($this->any())->method('create')->will($this->returnValue($this->urlRewrite)); - $this->urlRewriteBuilder->expects($this->once())->method('setDescription')->with($description) + $this->urlRewriteFactory->expects($this->any())->method('create')->will($this->returnValue($this->urlRewrite)); + $this->urlRewrite->expects($this->once())->method('setDescription')->with($description) ->will($this->returnSelf()); } } diff --git a/app/code/Magento/Checkout/Model/Type/Onepage.php b/app/code/Magento/Checkout/Model/Type/Onepage.php index f828cd023312f9933c72a4ae1a51ae20b67f6b02..3e746159a8dd0d041bc71f14326cb0a2fee9e810 100644 --- a/app/code/Magento/Checkout/Model/Type/Onepage.php +++ b/app/code/Magento/Checkout/Model/Type/Onepage.php @@ -585,7 +585,11 @@ class Onepage } $customer = $this->customerDataFactory->create(); - $this->dataObjectHelper->populateWithArray($customer, $customerData); + $this->dataObjectHelper->populateWithArray( + $customer, + $customerData, + '\Magento\Customer\Api\Data\CustomerInterface' + ); if ($quote->getCheckoutMethod() == self::METHOD_REGISTER) { // We always have $customerRequest here, otherwise we would have been kicked off the function several @@ -816,7 +820,11 @@ class Onepage $customer = $quote->getCustomer(); $customerBillingData = $billing->exportCustomerAddress(); $dataArray = $this->_objectCopyService->getDataFromFieldset('checkout_onepage_quote', 'to_customer', $quote); - $this->dataObjectHelper->populateWithArray($customer, $dataArray); + $this->dataObjectHelper->populateWithArray( + $customer, + $dataArray, + '\Magento\Customer\Api\Data\CustomerInterface' + ); $quote->setCustomer($customer)->setCustomerId(true); $customerBillingData->setIsDefaultBilling(true); diff --git a/app/code/Magento/CmsUrlRewrite/Model/CmsPageUrlRewriteGenerator.php b/app/code/Magento/CmsUrlRewrite/Model/CmsPageUrlRewriteGenerator.php index 41fd268b4dd686430c602dfb8fe65c00cfd13b76..11d78b2722eab6742c65f7c0dc27dcd9cba12c58 100644 --- a/app/code/Magento/CmsUrlRewrite/Model/CmsPageUrlRewriteGenerator.php +++ b/app/code/Magento/CmsUrlRewrite/Model/CmsPageUrlRewriteGenerator.php @@ -6,7 +6,7 @@ namespace Magento\CmsUrlRewrite\Model; use Magento\Store\Model\StoreManagerInterface; -use Magento\UrlRewrite\Service\V1\Data\UrlRewriteBuilder; +use Magento\UrlRewrite\Service\V1\Data\UrlRewriteFactory; class CmsPageUrlRewriteGenerator { @@ -15,8 +15,8 @@ class CmsPageUrlRewriteGenerator */ const ENTITY_TYPE = 'cms-page'; - /** @var \Magento\UrlRewrite\Service\V1\Data\UrlRewriteBuilder */ - protected $urlRewriteBuilder; + /** @var \Magento\UrlRewrite\Service\V1\Data\UrlRewriteFactory */ + protected $urlRewriteFactory; /** @var \Magento\CmsUrlRewrite\Model\CmsPageUrlPathGenerator */ protected $cmsPageUrlPathGenerator; @@ -34,16 +34,16 @@ class CmsPageUrlRewriteGenerator protected $cmsPage; /** - * @param \Magento\UrlRewrite\Service\V1\Data\UrlRewriteBuilder $urlRewriteBuilder + * @param \Magento\UrlRewrite\Service\V1\Data\UrlRewriteFactory $urlRewriteFactory * @param \Magento\CmsUrlRewrite\Model\CmsPageUrlPathGenerator $cmsPageUrlPathGenerator * @param StoreManagerInterface $storeManager */ public function __construct( - UrlRewriteBuilder $urlRewriteBuilder, + UrlRewriteFactory $urlRewriteFactory, CmsPageUrlPathGenerator $cmsPageUrlPathGenerator, StoreManagerInterface $storeManager ) { - $this->urlRewriteBuilder = $urlRewriteBuilder; + $this->urlRewriteFactory = $urlRewriteFactory; $this->storeManager = $storeManager; $this->cmsPageUrlPathGenerator = $cmsPageUrlPathGenerator; } @@ -104,13 +104,12 @@ class CmsPageUrlRewriteGenerator */ protected function createUrlRewrite($storeId, $redirectType = 0) { - return $this->urlRewriteBuilder->setStoreId($storeId) + return $this->urlRewriteFactory->create()->setStoreId($storeId) ->setEntityType(self::ENTITY_TYPE) ->setEntityId($this->cmsPage->getId()) ->setRequestPath($this->cmsPage->getIdentifier()) ->setTargetPath($this->cmsPageUrlPathGenerator->getCanonicalUrlPath($this->cmsPage)) ->setIsAutogenerated(1) - ->setRedirectType($redirectType) - ->create(); + ->setRedirectType($redirectType); } } diff --git a/app/code/Magento/ConfigurableProduct/Model/ProductVariationsBuilder.php b/app/code/Magento/ConfigurableProduct/Model/ProductVariationsBuilder.php index 7c67a9ed644a1d0c3f0a5dc8159756758d6454f1..2227d9c97b2cb11c42cda8d739a48ccf33ca3afa 100644 --- a/app/code/Magento/ConfigurableProduct/Model/ProductVariationsBuilder.php +++ b/app/code/Magento/ConfigurableProduct/Model/ProductVariationsBuilder.php @@ -9,9 +9,9 @@ namespace Magento\ConfigurableProduct\Model; class ProductVariationsBuilder { /** - * @var \Magento\Framework\Api\AttributeDataBuilder + * @var \Magento\Framework\Api\AttributeValueFactory */ - private $customAttributeBuilder; + private $customAttributeFactory; /** * @var \Magento\Catalog\Model\ProductFactory @@ -25,16 +25,16 @@ class ProductVariationsBuilder /** * @param \Magento\Catalog\Model\ProductFactory $productFactory - * @param \Magento\Framework\Api\AttributeDataBuilder $customAttributeBuilder + * @param \Magento\Framework\Api\AttributeValueFactory $customAttributeFactory * @param Product\Type\VariationMatrix $variationMatrix */ public function __construct( \Magento\Catalog\Model\ProductFactory $productFactory, - \Magento\Framework\Api\AttributeDataBuilder $customAttributeBuilder, + \Magento\Framework\Api\AttributeValueFactory $customAttributeFactory, \Magento\ConfigurableProduct\Model\Product\Type\VariationMatrix $variationMatrix ) { $this->productFactory = $productFactory; - $this->customAttributeBuilder = $customAttributeBuilder; + $this->customAttributeFactory = $customAttributeFactory; $this->variationMatrix = $variationMatrix; } @@ -58,10 +58,9 @@ class ProductVariationsBuilder $suffix = ''; foreach ($variation as $attributeId => $valueInfo) { $suffix .= '-' . $valueInfo['value']; - $customAttribute = $this->customAttributeBuilder + $customAttribute = $this->customAttributeFactory->create() ->setAttributeCode($attributes[$attributeId]['attribute_code']) - ->setValue($valueInfo['value']) - ->create(); + ->setValue($valueInfo['value']); $customAttributes = array_merge( $item->getCustomAttributes(), [ diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/ProductVariationsBuilderTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/ProductVariationsBuilderTest.php index 49d42a1000cc9f1f6f1c4d0aca3c053713bb173b..e67edfb8a0347d843ba354db1f69976030d9ede0 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/ProductVariationsBuilderTest.php +++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/ProductVariationsBuilderTest.php @@ -17,7 +17,7 @@ class ProductVariationsBuilderTest extends \PHPUnit_Framework_TestCase /** * @var \PHPUnit_Framework_MockObject_MockObject */ - private $customAttributeBuilder; + private $customAttributeFactory; /** * @var \PHPUnit_Framework_MockObject_MockObject @@ -36,8 +36,8 @@ class ProductVariationsBuilderTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->customAttributeBuilder = $this->getMock( - '\Magento\Framework\Api\AttributeDataBuilder', + $this->customAttributeFactory = $this->getMock( + '\Magento\Framework\Api\AttributeValueFactory', [], [], '', @@ -64,7 +64,7 @@ class ProductVariationsBuilderTest extends \PHPUnit_Framework_TestCase $this->model = new \Magento\ConfigurableProduct\Model\ProductVariationsBuilder( $this->productFactory, - $this->customAttributeBuilder, + $this->customAttributeFactory, $this->variationMatrix ); } @@ -96,17 +96,17 @@ class ProductVariationsBuilderTest extends \PHPUnit_Framework_TestCase $output->expects($this->at(0))->method('setData')->with($productData); $attribute = $this->getMock('\Magento\Framework\Api\AttributeInterface'); - $this->customAttributeBuilder->expects($this->once()) + $attribute->expects($this->once()) ->method('setAttributeCode') ->with('sort_order') ->willReturnSelf(); - $this->customAttributeBuilder->expects($this->once()) + $attribute->expects($this->once()) ->method('setValue') ->with(15) ->willReturnSelf(); - $this->customAttributeBuilder->expects($this->once()) + $this->customAttributeFactory->expects($this->once()) ->method('create') ->willReturn($attribute); diff --git a/app/code/Magento/Customer/Api/Data/AddressSearchResultsInterface.php b/app/code/Magento/Customer/Api/Data/AddressSearchResultsInterface.php index f7275b87eb5126801215915906bd3873c66a4729..ab08ea9e87b298b8641bd714742834da1976efe0 100644 --- a/app/code/Magento/Customer/Api/Data/AddressSearchResultsInterface.php +++ b/app/code/Magento/Customer/Api/Data/AddressSearchResultsInterface.php @@ -17,4 +17,12 @@ interface AddressSearchResultsInterface extends \Magento\Framework\Api\SearchRes * @return \Magento\Customer\Api\Data\AddressInterface[] */ public function getItems(); + + /** + * Set customer addresses list. + * + * @param \Magento\Customer\Api\Data\AddressInterface[] $items + * @return $this + */ + public function setItems(array $items = null); } diff --git a/app/code/Magento/Customer/Api/Data/CustomerSearchResultsInterface.php b/app/code/Magento/Customer/Api/Data/CustomerSearchResultsInterface.php index c5721cb56fe6d3c36bfda6f1906f0682cab42678..2a020f9deeb09503817655494eaa0d2a57208dee 100644 --- a/app/code/Magento/Customer/Api/Data/CustomerSearchResultsInterface.php +++ b/app/code/Magento/Customer/Api/Data/CustomerSearchResultsInterface.php @@ -17,4 +17,12 @@ interface CustomerSearchResultsInterface extends \Magento\Framework\Api\SearchRe * @return \Magento\Customer\Api\Data\CustomerInterface[] */ public function getItems(); + + /** + * Set customers list. + * + * @param \Magento\Customer\Api\Data\CustomerInterface[] $items + * @return $this + */ + public function setItems(array $items = null); } diff --git a/app/code/Magento/Customer/Api/Data/GroupSearchResultsInterface.php b/app/code/Magento/Customer/Api/Data/GroupSearchResultsInterface.php index bf5d9dacab210d47ff10bdbdaa05dbb1f8b3f191..953c2f2381498b6534652defd89065e69c71cdf0 100644 --- a/app/code/Magento/Customer/Api/Data/GroupSearchResultsInterface.php +++ b/app/code/Magento/Customer/Api/Data/GroupSearchResultsInterface.php @@ -17,4 +17,12 @@ interface GroupSearchResultsInterface extends \Magento\Framework\Api\SearchResul * @return \Magento\Customer\Api\Data\GroupInterface[] */ public function getItems(); + + /** + * Set customer groups list. + * + * @param \Magento\Customer\Api\Data\GroupInterface[] $items + * @return $this + */ + public function setItems(array $items = null); } diff --git a/app/code/Magento/Customer/Block/Address/Edit.php b/app/code/Magento/Customer/Block/Address/Edit.php index d66cd086e5590ff5174a4ef1fbb48366246e9d38..cd0076a93ebfeb9638f4ba990505f83fee885795 100644 --- a/app/code/Magento/Customer/Block/Address/Edit.php +++ b/app/code/Magento/Customer/Block/Address/Edit.php @@ -135,7 +135,11 @@ class Edit extends \Magento\Directory\Block\Data 'region' => $postedData['region'], ]; } - $this->dataObjectHelper->populateWithArray($this->_address, $postedData); + $this->dataObjectHelper->populateWithArray( + $this->_address, + $postedData, + '\Magento\Customer\Api\Data\AddressInterface' + ); } return $this; diff --git a/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Account.php b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Account.php index 090b8d358e0cec305e55c81c1003dfa396259e4c..c7d7bafa60bb60e9c77e6a181e73b8ea23df14d5 100644 --- a/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Account.php +++ b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Account.php @@ -245,7 +245,11 @@ class Account extends GenericMetadata $customerData = $this->_backendSession->getCustomerData(); $accountData = isset($customerData['account']) ? $customerData['account'] : []; $this->_customerDataObject = $this->customerDataFactory->create(); - $this->dataObjectHelper->populateWithArray($this->_customerDataObject, $accountData); + $this->dataObjectHelper->populateWithArray( + $this->_customerDataObject, + $accountData, + '\Magento\Customer\Api\Data\CustomerInterface' + ); } return $this->_customerDataObject; } diff --git a/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Addresses.php b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Addresses.php index ecbb711a685f0db625e97e14b9ec5fb3794d4114..d44d33db5673dd215f48ff0f8349243efc55aa23 100644 --- a/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Addresses.php +++ b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Addresses.php @@ -317,12 +317,20 @@ class Addresses extends GenericMetadata } $customerDataObject = $this->customerDataFactory->create(); - $this->dataObjectHelper->populateWithArray($customerDataObject, $account); + $this->dataObjectHelper->populateWithArray( + $customerDataObject, + $account, + '\Magento\Customer\Api\Data\CustomerInterface' + ); $this->assign('customer', $customerDataObject); $addressCollection = []; foreach ($customerData['address'] as $key => $addressData) { $addressDataObject = $this->addressDataFactory->create(); - $this->dataObjectHelper->populateWithArray($addressDataObject, $addressData); + $this->dataObjectHelper->populateWithArray( + $addressDataObject, + $addressData, + '\Magento\Customer\Api\Data\AddressInterface' + ); $addressCollection[$key] = $addressDataObject; } $this->assign('addressCollection', $addressCollection); diff --git a/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Carts.php b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Carts.php index 1d02cf14c5600c204d6fcc9a7cdca5fc87443480..092fe5c4c487e3bd5690bd533445e7ffd9b7658c 100644 --- a/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Carts.php +++ b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/Carts.php @@ -87,7 +87,8 @@ class Carts extends \Magento\Backend\Block\Template $customerDataObject = $this->customerDataFactory->create(); $this->dataObjectHelper->populateWithArray( $customerDataObject, - $this->_backendSession->getCustomerData()['account'] + $this->_backendSession->getCustomerData()['account'], + '\Magento\Customer\Api\Data\CustomerInterface' ); return $customerDataObject; } 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 891ba0e5fcad0cfd8153c0600ed705583a5b92a6..7520b9d412947e3b731941d1b43f31547d8c3096 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 @@ -110,7 +110,8 @@ class PersonalInfo extends \Magento\Backend\Block\Template $this->customer = $this->customerDataFactory->create(); $this->dataObjectHelper->populateWithArray( $this->customer, - $this->_backendSession->getCustomerData()['account'] + $this->_backendSession->getCustomerData()['account'], + '\Magento\Customer\Api\Data\CustomerInterface' ); } return $this->customer; diff --git a/app/code/Magento/Customer/Controller/Account/CreatePost.php b/app/code/Magento/Customer/Controller/Account/CreatePost.php index f9eb6b26b800301e93ff364ded353a685eb2e4cc..55d7bf4c4a11535abe6f9220af2a3f69e68b3b6e 100644 --- a/app/code/Magento/Customer/Controller/Account/CreatePost.php +++ b/app/code/Magento/Customer/Controller/Account/CreatePost.php @@ -179,7 +179,11 @@ class CreatePost extends \Magento\Customer\Controller\Account } } $addressDataObject = $this->addressDataFactory->create(); - $this->dataObjectHelper->populateWithArray($addressDataObject, $addressData); + $this->dataObjectHelper->populateWithArray( + $addressDataObject, + $addressData, + '\Magento\Customer\Api\Data\AddressInterface' + ); $addressDataObject->setRegion($regionDataObject); $addressDataObject->setIsDefaultBilling( diff --git a/app/code/Magento/Customer/Controller/Account/Edit.php b/app/code/Magento/Customer/Controller/Account/Edit.php index ca761f1b11ec4e24519f1ebc98588e5ae9ac10ee..b4de05f17140b8be1acb91b7fc070fe38400c0e7 100644 --- a/app/code/Magento/Customer/Controller/Account/Edit.php +++ b/app/code/Magento/Customer/Controller/Account/Edit.php @@ -62,7 +62,11 @@ class Edit extends \Magento\Customer\Controller\Account $customerId = $this->_getSession()->getCustomerId(); $customerDataObject = $this->customerRepository->getById($customerId); if (!empty($data)) { - $this->dataObjectHelper->populateWithArray($customerDataObject, $data); + $this->dataObjectHelper->populateWithArray( + $customerDataObject, + $data, + '\Magento\Customer\Api\Data\CustomerInterface' + ); } $this->_getSession()->setCustomerData($customerDataObject); $this->_getSession()->setChangePassword($this->getRequest()->getParam('changepass') == 1); diff --git a/app/code/Magento/Customer/Controller/Address/FormPost.php b/app/code/Magento/Customer/Controller/Address/FormPost.php index 7e2c46aa164c083cb39cd960130c029e0d89d099..86af07c52935b87ffde0dbac2cf428896b9c693b 100644 --- a/app/code/Magento/Customer/Controller/Address/FormPost.php +++ b/app/code/Magento/Customer/Controller/Address/FormPost.php @@ -46,7 +46,11 @@ class FormPost extends \Magento\Customer\Controller\Address ]; $region = $this->regionDataFactory->create(); - $this->dataObjectHelper->populateWithArray($region, $regionData); + $this->dataObjectHelper->populateWithArray( + $region, + $regionData, + '\Magento\Customer\Api\Data\RegionInterface' + ); unset($attributeValues['region'], $attributeValues['region_id']); $attributeValues['region'] = $region; @@ -54,7 +58,8 @@ class FormPost extends \Magento\Customer\Controller\Address $addressDataObject = $this->addressDataFactory->create(); $this->dataObjectHelper->populateWithArray( $addressDataObject, - array_merge($existingAddressData, $attributeValues) + array_merge($existingAddressData, $attributeValues), + '\Magento\Customer\Api\Data\AddressInterface' ); $addressDataObject->setCustomerId($this->_getSession()->getCustomerId()) ->setRegion($region) diff --git a/app/code/Magento/Customer/Controller/Adminhtml/Index/Edit.php b/app/code/Magento/Customer/Controller/Adminhtml/Index/Edit.php index 2949af84dbcc902bbb8999a9130715ba4f62c791..cc024c507011aa41f6258ff83748fd9e06840e61 100644 --- a/app/code/Magento/Customer/Controller/Adminhtml/Index/Edit.php +++ b/app/code/Magento/Customer/Controller/Adminhtml/Index/Edit.php @@ -73,7 +73,11 @@ class Edit extends \Magento\Customer\Controller\Adminhtml\Index $formData = $customerForm->extractData($request, 'account'); $customerData['account'] = $customerForm->restoreData($formData); $customer = $this->customerDataFactory->create(); - $this->dataObjectHelper->populateWithArray($customer, $customerData['account']); + $this->dataObjectHelper->populateWithArray( + $customer, + $customerData['account'], + '\Magento\Customer\Api\Data\CustomerInterface' + ); } if (isset($data['address']) && is_array($data['address'])) { diff --git a/app/code/Magento/Customer/Controller/Adminhtml/Index/Save.php b/app/code/Magento/Customer/Controller/Adminhtml/Index/Save.php index 269c29e076bf6d546ea10474d18fd7c3b09e86d7..3c2b02d7a7f06dd356600bb33420202d3792fec6 100644 --- a/app/code/Magento/Customer/Controller/Adminhtml/Index/Save.php +++ b/app/code/Magento/Customer/Controller/Adminhtml/Index/Save.php @@ -196,7 +196,11 @@ class Save extends \Magento\Customer\Controller\Adminhtml\Index $customerData['id'] = $customerId; } - $this->dataObjectHelper->populateWithArray($customer, $customerData); + $this->dataObjectHelper->populateWithArray( + $customer, + $customerData, + '\Magento\Customer\Api\Data\CustomerInterface' + ); $addresses = []; foreach ($addressesData as $addressData) { $region = isset($addressData['region']) ? $addressData['region'] : null; @@ -206,7 +210,11 @@ class Save extends \Magento\Customer\Controller\Adminhtml\Index 'region_id' => $regionId, ]; $addressDataObject = $this->addressDataFactory->create(); - $this->dataObjectHelper->populateWithArray($addressDataObject, $addressData); + $this->dataObjectHelper->populateWithArray( + $addressDataObject, + $addressData, + '\Magento\Customer\Api\Data\AddressInterface' + ); $addresses[] = $addressDataObject; } diff --git a/app/code/Magento/Customer/Controller/Adminhtml/Index/Validate.php b/app/code/Magento/Customer/Controller/Adminhtml/Index/Validate.php index a053e798ece1008e7b2ce15519c6effcd81ac25a..3f925ba579e8f9c72a271b03677ee49d7fd2626f 100644 --- a/app/code/Magento/Customer/Controller/Adminhtml/Index/Validate.php +++ b/app/code/Magento/Customer/Controller/Adminhtml/Index/Validate.php @@ -43,7 +43,11 @@ class Validate extends \Magento\Customer\Controller\Adminhtml\Index unset($data['website_id']); } - $this->dataObjectHelper->populateWithArray($customer, $data); + $this->dataObjectHelper->populateWithArray( + $customer, + $data, + '\Magento\Customer\Api\Data\CustomerInterface' + ); $errors = $this->customerAccountManagement->validate($customer); } catch (\Magento\Framework\Validator\ValidatorException $exception) { /* @var $error Error */ diff --git a/app/code/Magento/Customer/Model/Address/AbstractAddress.php b/app/code/Magento/Customer/Model/Address/AbstractAddress.php index 8b11022ba92c115e052f3ca0b99ddb28337fa0a0..65c9db82bf0ee887255c4c05c774f8071fe7a61a 100644 --- a/app/code/Magento/Customer/Model/Address/AbstractAddress.php +++ b/app/code/Magento/Customer/Model/Address/AbstractAddress.php @@ -510,7 +510,11 @@ class AbstractAddress extends \Magento\Framework\Model\AbstractExtensibleModel $addressData[AddressData::REGION] = $region; $addressDataObject = $this->addressDataFactory->create(); - $this->dataObjectHelper->populateWithArray($addressDataObject, $addressData); + $this->dataObjectHelper->populateWithArray( + $addressDataObject, + $addressData, + '\Magento\Customer\Api\Data\AddressInterface' + ); if ($addressId) { $addressDataObject->setId($addressId); } diff --git a/app/code/Magento/Customer/Model/AttributeMetadataConverter.php b/app/code/Magento/Customer/Model/AttributeMetadataConverter.php index d27f4657c1c1745735dbdbb2c39ec51625bee2b3..a9fc1eb30fd224344967d1f18245ef37a3d14116 100644 --- a/app/code/Magento/Customer/Model/AttributeMetadataConverter.php +++ b/app/code/Magento/Customer/Model/AttributeMetadataConverter.php @@ -71,7 +71,11 @@ class AttributeMetadataConverter $optionArray = []; foreach ($option['value'] as $optionArrayValues) { $optionObject = $this->optionFactory->create(); - $this->dataObjectHelper->populateWithArray($optionObject, $optionArrayValues); + $this->dataObjectHelper->populateWithArray( + $optionObject, + $optionArrayValues, + '\Magento\Customer\Api\Data\OptionInterface' + ); $optionArray[] = $optionObject; } $optionDataObject->setOptions($optionArray); diff --git a/app/code/Magento/Customer/Model/AttributeMetadataDataBuilder.php b/app/code/Magento/Customer/Model/AttributeMetadataDataBuilder.php deleted file mode 100644 index cf08de198532abb741be9c6fa8f79f59cb1c4ee2..0000000000000000000000000000000000000000 --- a/app/code/Magento/Customer/Model/AttributeMetadataDataBuilder.php +++ /dev/null @@ -1,220 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -namespace Magento\Customer\Model; - -use Magento\Framework\Api\AttributeMetadataBuilderInterface; - -/** - * DataBuilder class for \Magento\Customer\Api\Data\AttributeMetadataInterface - */ -class AttributeMetadataDataBuilder extends \Magento\Framework\Api\Builder implements AttributeMetadataBuilderInterface -{ - /** - * @param string $attributeCode - * @return $this - */ - public function setAttributeCode($attributeCode) - { - $this->_set('attribute_code', $attributeCode); - return $this; - } - - /** - * @param string $frontendInput - * @return $this - */ - public function setFrontendInput($frontendInput) - { - $this->_set('frontend_input', $frontendInput); - return $this; - } - - /** - * @param string $inputFilter - * @return $this - */ - public function setInputFilter($inputFilter) - { - $this->_set('input_filter', $inputFilter); - return $this; - } - - /** - * @param string $storeLabel - * @return $this - */ - public function setStoreLabel($storeLabel) - { - $this->_set('store_label', $storeLabel); - return $this; - } - - /** - * @param \Magento\Customer\Api\Data\ValidationRuleInterface[] $validationRules - * @return $this - */ - public function setValidationRules($validationRules) - { - $this->_set('validation_rules', $validationRules); - return $this; - } - - /** - * @param int $multilineCount - * @return $this - */ - public function setMultilineCount($multilineCount) - { - $this->_set('multiline_count', $multilineCount); - return $this; - } - - /** - * @param bool $visible - * @return $this - */ - public function setVisible($visible) - { - $this->_set('visible', $visible); - return $this; - } - - /** - * @param bool $required - * @return $this - */ - public function setRequired($required) - { - $this->_set('required', $required); - return $this; - } - - /** - * @param string $dataModel - * @return $this - */ - public function setDataModel($dataModel) - { - $this->_set('data_model', $dataModel); - return $this; - } - - /** - * @param \Magento\Customer\Api\Data\OptionInterface[] $options - * @return $this - */ - public function setOptions($options) - { - $this->_set('options', $options); - return $this; - } - - /** - * @param string $frontendClass - * @return $this - */ - public function setFrontendClass($frontendClass) - { - $this->_set('frontend_class', $frontendClass); - return $this; - } - - /** - * @param bool $userDefined - * @return $this - */ - public function setUserDefined($userDefined) - { - $this->_set('user_defined', $userDefined); - return $this; - } - - /** - * @param int $sortOrder - * @return $this - */ - public function setSortOrder($sortOrder) - { - $this->_set('sort_order', $sortOrder); - return $this; - } - - /** - * @param string $frontendLabel - * @return $this - */ - public function setFrontendLabel($frontendLabel) - { - $this->_set('frontend_label', $frontendLabel); - return $this; - } - - /** - * @param string $note - * @return $this - */ - public function setNote($note) - { - $this->_set('note', $note); - return $this; - } - - /** - * @param bool $system - * @return $this - */ - public function setSystem($system) - { - $this->_set('system', $system); - return $this; - } - - /** - * @param string $backendType - * @return $this - */ - public function setBackendType($backendType) - { - $this->_set('backend_type', $backendType); - return $this; - } - - /** - * Initialize the builder - * - * @param \Magento\Framework\Api\ObjectFactory $objectFactory - * @param \Magento\Framework\Api\MetadataServiceInterface $metadataService - * @param \Magento\Framework\Api\AttributeValueFactory $attributeValueFactory - * @param \Magento\Framework\Reflection\DataObjectProcessor $objectProcessor - * @param \Magento\Framework\Reflection\TypeProcessor $typeProcessor - * @param \Magento\Framework\Serialization\DataBuilderFactory $dataBuilderFactory - * @param \Magento\Framework\ObjectManager\ConfigInterface $objectManagerConfig - * @param string|null $modelClassInterface - * @SuppressWarnings(PHPMD.UnusedFormalParameter) - */ - public function __construct( - \Magento\Framework\Api\ObjectFactory $objectFactory, - \Magento\Framework\Api\MetadataServiceInterface $metadataService, - \Magento\Framework\Api\AttributeValueFactory $attributeValueFactory, - \Magento\Framework\Reflection\DataObjectProcessor $objectProcessor, - \Magento\Framework\Reflection\TypeProcessor $typeProcessor, - \Magento\Framework\Serialization\DataBuilderFactory $dataBuilderFactory, - \Magento\Framework\ObjectManager\ConfigInterface $objectManagerConfig, - $modelClassInterface = null - ) { - parent::__construct( - $objectFactory, - $metadataService, - $attributeValueFactory, - $objectProcessor, - $typeProcessor, - $dataBuilderFactory, - $objectManagerConfig, - 'Magento\Customer\Api\Data\AttributeMetadataInterface' - ); - } -} diff --git a/app/code/Magento/Customer/Model/Customer.php b/app/code/Magento/Customer/Model/Customer.php index 49917e246c52a0f90991a8d4e5c27897a9ee9f04..c4d6a3e6c360e3f38740f0710839ab483de8dca5 100644 --- a/app/code/Magento/Customer/Model/Customer.php +++ b/app/code/Magento/Customer/Model/Customer.php @@ -288,7 +288,11 @@ class Customer extends \Magento\Framework\Model\AbstractExtensibleModel $addressesData[] = $address->getDataModel(); } $customerDataObject = $this->customerDataFactory->create(); - $this->dataObjectHelper->populateWithArray($customerDataObject, $customerData); + $this->dataObjectHelper->populateWithArray( + $customerDataObject, + $customerData, + '\Magento\Customer\Api\Data\CustomerInterface' + ); $customerDataObject->setAddresses($addressesData) ->setId($this->getId()); return $customerDataObject; @@ -414,11 +418,19 @@ class Customer extends \Magento\Framework\Model\AbstractExtensibleModel $customerData = (array)$this->getData(); $customerData[CustomerData::ID] = $this->getId(); $dataObject = $this->customerDataFactory->create(); - $this->dataObjectHelper->populateWithArray($dataObject, $customerData); + $this->dataObjectHelper->populateWithArray( + $dataObject, + $customerData, + '\Magento\Customer\Api\Data\CustomerInterface' + ); $customerOrigData = (array)$this->getOrigData(); $customerOrigData[CustomerData::ID] = $this->getId(); $origDataObject = $this->customerDataFactory->create(); - $this->dataObjectHelper->populateWithArray($origDataObject, $customerOrigData); + $this->dataObjectHelper->populateWithArray( + $origDataObject, + $customerOrigData, + '\Magento\Customer\Api\Data\CustomerInterface' + ); $this->_eventManager->dispatch( 'customer_save_after_data_object', ['customer_data_object' => $dataObject, 'orig_customer_data_object' => $origDataObject] diff --git a/app/code/Magento/Customer/Model/CustomerExtractor.php b/app/code/Magento/Customer/Model/CustomerExtractor.php index 7e16f8359a27992368d06f8a4c8a7ebc7951e464..bc2880babd4cdf2302956a90fa8126c7971d0854 100644 --- a/app/code/Magento/Customer/Model/CustomerExtractor.php +++ b/app/code/Magento/Customer/Model/CustomerExtractor.php @@ -77,7 +77,11 @@ class CustomerExtractor $customerData[$attributeCode] = $request->getParam($attributeCode); } $customerDataObject = $this->customerFactory->create(); - $this->dataObjectHelper->populateWithArray($customerDataObject, $customerData); + $this->dataObjectHelper->populateWithArray( + $customerDataObject, + $customerData, + '\Magento\Customer\Api\Data\CustomerInterface' + ); $store = $this->storeManager->getStore(); if ($isGroupIdEmpty) { $customerDataObject->setGroupId( diff --git a/app/code/Magento/Customer/Model/Resource/AddressRepository.php b/app/code/Magento/Customer/Model/Resource/AddressRepository.php index c83617ec411201db71c248516418cd1a5d25691e..ce60b52c51c20722c26ab4bbf8c23dfcb8c521e2 100644 --- a/app/code/Magento/Customer/Model/Resource/AddressRepository.php +++ b/app/code/Magento/Customer/Model/Resource/AddressRepository.php @@ -47,9 +47,9 @@ class AddressRepository implements \Magento\Customer\Api\AddressRepositoryInterf protected $addressResourceModel; /** - * @var \Magento\Customer\Api\Data\AddressSearchResultsDataBuilder + * @var \Magento\Customer\Api\Data\AddressSearchResultsInterfaceFactory */ - protected $addressSearchResultsBuilder; + protected $addressSearchResultsFactory; /** * @var \Magento\Customer\Model\Resource\Address\CollectionFactory @@ -62,7 +62,7 @@ class AddressRepository implements \Magento\Customer\Api\AddressRepositoryInterf * @param \Magento\Customer\Model\CustomerRegistry $customerRegistry * @param \Magento\Customer\Model\Resource\Address $addressResourceModel * @param \Magento\Directory\Helper\Data $directoryData - * @param \Magento\Customer\Api\Data\AddressSearchResultsDataBuilder $addressSearchResultsBuilder + * @param \Magento\Customer\Api\Data\AddressSearchResultsInterfaceFactory $addressSearchResultsFactory * @param \Magento\Customer\Model\Resource\Address\CollectionFactory $addressCollectionFactory */ public function __construct( @@ -71,7 +71,7 @@ class AddressRepository implements \Magento\Customer\Api\AddressRepositoryInterf \Magento\Customer\Model\CustomerRegistry $customerRegistry, \Magento\Customer\Model\Resource\Address $addressResourceModel, \Magento\Directory\Helper\Data $directoryData, - \Magento\Customer\Api\Data\AddressSearchResultsDataBuilder $addressSearchResultsBuilder, + \Magento\Customer\Api\Data\AddressSearchResultsInterfaceFactory $addressSearchResultsFactory, \Magento\Customer\Model\Resource\Address\CollectionFactory $addressCollectionFactory ) { $this->addressFactory = $addressFactory; @@ -79,7 +79,7 @@ class AddressRepository implements \Magento\Customer\Api\AddressRepositoryInterf $this->customerRegistry = $customerRegistry; $this->addressResource = $addressResourceModel; $this->directoryData = $directoryData; - $this->addressSearchResultsBuilder = $addressSearchResultsBuilder; + $this->addressSearchResultsFactory = $addressSearchResultsFactory; $this->addressCollectionFactory = $addressCollectionFactory; } @@ -142,7 +142,7 @@ class AddressRepository implements \Magento\Customer\Api\AddressRepositoryInterf */ public function getList(SearchCriteriaInterface $searchCriteria) { - $this->addressSearchResultsBuilder->setSearchCriteria($searchCriteria); + $searchResults = $this->addressSearchResultsFactory->create(); /** @var Collection $collection */ $collection = $this->addressCollectionFactory->create(); @@ -150,7 +150,7 @@ class AddressRepository implements \Magento\Customer\Api\AddressRepositoryInterf foreach ($searchCriteria->getFilterGroups() as $group) { $this->addFilterGroupToCollection($group, $collection); } - $this->addressSearchResultsBuilder->setTotalCount($collection->getSize()); + $searchResults->setTotalCount($collection->getSize()); /** @var SortOrder $sortOrder */ foreach ((array)$searchCriteria->getSortOrders() as $sortOrder) { $field = $sortOrder->getField(); @@ -168,9 +168,9 @@ class AddressRepository implements \Magento\Customer\Api\AddressRepositoryInterf foreach ($collection->getItems() as $address) { $addresses[] = $this->getById($address->getId()); } - $this->addressSearchResultsBuilder->setItems($addresses); - $this->addressSearchResultsBuilder->setSearchCriteria($searchCriteria); - return $this->addressSearchResultsBuilder->create(); + $searchResults->setItems($addresses); + $searchResults->setSearchCriteria($searchCriteria); + return $searchResults; } /** diff --git a/app/code/Magento/Customer/Model/Resource/CustomerRepository.php b/app/code/Magento/Customer/Model/Resource/CustomerRepository.php index 610870d48f195e1e3f7059ad730a2e0df12cdb62..757ef49198d792f77de17761bd01f7d30e67e8b4 100644 --- a/app/code/Magento/Customer/Model/Resource/CustomerRepository.php +++ b/app/code/Magento/Customer/Model/Resource/CustomerRepository.php @@ -48,9 +48,9 @@ class CustomerRepository implements \Magento\Customer\Api\CustomerRepositoryInte protected $customerMetadata; /** - * @var \Magento\Customer\Api\Data\CustomerSearchResultsDataBuilder + * @var \Magento\Customer\Api\Data\CustomerSearchResultsInterfaceFactory */ - protected $searchResultsBuilder; + protected $searchResultsFactory; /** * @var \Magento\Framework\Event\ManagerInterface @@ -74,7 +74,7 @@ class CustomerRepository implements \Magento\Customer\Api\CustomerRepositoryInte * @param \Magento\Customer\Model\Resource\AddressRepository $addressRepository * @param \Magento\Customer\Model\Resource\Customer $customerResourceModel * @param \Magento\Customer\Api\CustomerMetadataInterface $customerMetadata - * @param \Magento\Customer\Api\Data\CustomerSearchResultsDataBuilder $searchResultsDataBuilder + * @param \Magento\Customer\Api\Data\CustomerSearchResultsInterfaceFactory $searchResultsFactory * @param \Magento\Framework\Event\ManagerInterface $eventManager * @param \Magento\Store\Model\StoreManagerInterface $storeManager * @param \Magento\Framework\Api\ExtensibleDataObjectConverter $extensibleDataObjectConverter @@ -87,7 +87,7 @@ class CustomerRepository implements \Magento\Customer\Api\CustomerRepositoryInte \Magento\Customer\Model\Resource\AddressRepository $addressRepository, \Magento\Customer\Model\Resource\Customer $customerResourceModel, \Magento\Customer\Api\CustomerMetadataInterface $customerMetadata, - \Magento\Customer\Api\Data\CustomerSearchResultsDataBuilder $searchResultsDataBuilder, + \Magento\Customer\Api\Data\CustomerSearchResultsInterfaceFactory $searchResultsFactory, \Magento\Framework\Event\ManagerInterface $eventManager, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Framework\Api\ExtensibleDataObjectConverter $extensibleDataObjectConverter @@ -98,7 +98,7 @@ class CustomerRepository implements \Magento\Customer\Api\CustomerRepositoryInte $this->addressRepository = $addressRepository; $this->customerResourceModel = $customerResourceModel; $this->customerMetadata = $customerMetadata; - $this->searchResultsBuilder = $searchResultsDataBuilder; + $this->searchResultsFactory = $searchResultsFactory; $this->eventManager = $eventManager; $this->storeManager = $storeManager; $this->extensibleDataObjectConverter = $extensibleDataObjectConverter; @@ -209,7 +209,8 @@ class CustomerRepository implements \Magento\Customer\Api\CustomerRepositoryInte */ public function getList(SearchCriteriaInterface $searchCriteria) { - $this->searchResultsBuilder->setSearchCriteria($searchCriteria); + $searchResults = $this->searchResultsFactory->create(); + $searchResults->setSearchCriteria($searchCriteria); /** @var \Magento\Customer\Model\Resource\Customer\Collection $collection */ $collection = $this->customerFactory->create()->getCollection(); // This is needed to make sure all the attributes are properly loaded @@ -229,7 +230,7 @@ class CustomerRepository implements \Magento\Customer\Api\CustomerRepositoryInte foreach ($searchCriteria->getFilterGroups() as $group) { $this->addFilterGroupToCollection($group, $collection); } - $this->searchResultsBuilder->setTotalCount($collection->getSize()); + $searchResults->setTotalCount($collection->getSize()); $sortOrders = $searchCriteria->getSortOrders(); if ($sortOrders) { foreach ($searchCriteria->getSortOrders() as $sortOrder) { @@ -246,8 +247,8 @@ class CustomerRepository implements \Magento\Customer\Api\CustomerRepositoryInte foreach ($collection as $customerModel) { $customers[] = $customerModel->getDataModel(); } - $this->searchResultsBuilder->setItems($customers); - return $this->searchResultsBuilder->create(); + $searchResults->setItems($customers); + return $searchResults; } /** diff --git a/app/code/Magento/Customer/Model/Resource/GroupRepository.php b/app/code/Magento/Customer/Model/Resource/GroupRepository.php index 1b7a04ca76cea601b057a49bbc7a79d127fb83ba..74f227df9ebf71c99d6b4765cd41530dda28d63f 100644 --- a/app/code/Magento/Customer/Model/Resource/GroupRepository.php +++ b/app/code/Magento/Customer/Model/Resource/GroupRepository.php @@ -53,9 +53,9 @@ class GroupRepository implements \Magento\Customer\Api\GroupRepositoryInterface protected $dataObjectProcessor; /** - * @var \Magento\Customer\Api\Data\GroupSearchResultsDataBuilder + * @var \Magento\Customer\Api\Data\GroupSearchResultsInterfaceFactory */ - protected $searchResultsBuilder; + protected $searchResultsFactory; /** * @var \Magento\Tax\Api\TaxClassRepositoryInterface @@ -68,7 +68,7 @@ class GroupRepository implements \Magento\Customer\Api\GroupRepositoryInterface * @param \Magento\Customer\Api\Data\GroupInterfaceFactory $groupDataFactory * @param \Magento\Customer\Model\Resource\Group $groupResourceModel * @param \Magento\Framework\Reflection\DataObjectProcessor $dataObjectProcessor - * @param \Magento\Customer\Api\Data\GroupSearchResultsDataBuilder $searchResultsBuilder + * @param \Magento\Customer\Api\Data\GroupSearchResultsInterfaceFactory $searchResultsFactory * @param \Magento\Tax\Api\TaxClassRepositoryInterface $taxClassRepositoryInterface */ public function __construct( @@ -77,7 +77,7 @@ class GroupRepository implements \Magento\Customer\Api\GroupRepositoryInterface \Magento\Customer\Api\Data\GroupInterfaceFactory $groupDataFactory, \Magento\Customer\Model\Resource\Group $groupResourceModel, \Magento\Framework\Reflection\DataObjectProcessor $dataObjectProcessor, - \Magento\Customer\Api\Data\GroupSearchResultsDataBuilder $searchResultsBuilder, + \Magento\Customer\Api\Data\GroupSearchResultsInterfaceFactory $searchResultsFactory, \Magento\Tax\Api\TaxClassRepositoryInterface $taxClassRepositoryInterface ) { $this->groupRegistry = $groupRegistry; @@ -85,7 +85,7 @@ class GroupRepository implements \Magento\Customer\Api\GroupRepositoryInterface $this->groupDataFactory = $groupDataFactory; $this->groupResourceModel = $groupResourceModel; $this->dataObjectProcessor = $dataObjectProcessor; - $this->searchResultsBuilder = $searchResultsBuilder; + $this->searchResultsFactory = $searchResultsFactory; $this->taxClassRepository = $taxClassRepositoryInterface; } @@ -159,7 +159,8 @@ class GroupRepository implements \Magento\Customer\Api\GroupRepositoryInterface */ public function getList(SearchCriteriaInterface $searchCriteria) { - $this->searchResultsBuilder->setSearchCriteria($searchCriteria); + $searchResults = $this->searchResultsFactory->create(); + $searchResults->setSearchCriteria($searchCriteria); /** @var \Magento\Customer\Model\Resource\Group\Collection $collection */ $collection = $this->groupFactory->create()->getCollection(); @@ -169,7 +170,7 @@ class GroupRepository implements \Magento\Customer\Api\GroupRepositoryInterface foreach ($searchCriteria->getFilterGroups() as $group) { $this->addFilterGroupToCollection($group, $collection); } - $this->searchResultsBuilder->setTotalCount($collection->getSize()); + $searchResults->setTotalCount($collection->getSize()); $sortOrders = $searchCriteria->getSortOrders(); /** @var \Magento\Framework\Api\SortOrder $sortOrder */ if ($sortOrders) { @@ -195,7 +196,7 @@ class GroupRepository implements \Magento\Customer\Api\GroupRepositoryInterface ->setTaxClassName($group->getTaxClassName()); $groups[] = $groupDataObject; } - return $this->searchResultsBuilder->setItems($groups)->create(); + return $searchResults->setItems($groups); } /** diff --git a/app/code/Magento/Customer/Test/Unit/Model/Resource/Group/Grid/ServiceCollectionTest.php b/app/code/Magento/Customer/Test/Unit/Model/Resource/Group/Grid/ServiceCollectionTest.php index 96dfa00d94649984fd84913aba701ba72bae0589..5d9f67f24e56e09a51f142380ce5e27363b064ca 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Resource/Group/Grid/ServiceCollectionTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Resource/Group/Grid/ServiceCollectionTest.php @@ -72,6 +72,7 @@ class ServiceCollectionTest extends \PHPUnit_Framework_TestCase 'filterBuilder' => $this->filterBuilder, 'searchCriteriaBuilder' => $this->searchCriteriaBuilder, 'groupRepository' => $this->groupRepositoryMock, + 'sortOrderBuilder' => $this->sortOrderBuilder, ] ); } diff --git a/app/code/Magento/Customer/etc/di.xml b/app/code/Magento/Customer/etc/di.xml index 5ea705d5687f45e48baf39832f4ef733abaaa7d3..fb07378f191ad35ad2f3ff3e6c0105e381570bd8 100644 --- a/app/code/Magento/Customer/etc/di.xml +++ b/app/code/Magento/Customer/etc/di.xml @@ -37,8 +37,6 @@ type="Magento\Customer\Model\Metadata\CustomerCachedMetadata" /> <preference for="Magento\Customer\Api\AddressMetadataInterface" type="Magento\Customer\Model\Metadata\AddressCachedMetadata" /> - <preference for="Magento\Customer\Api\Data\AttributeMetadataDataBuilder" - type="Magento\Customer\Model\AttributeMetadataDataBuilder" /> <type name="Magento\Customer\Model\Session"> <arguments> <argument name="configShare" xsi:type="object">Magento\Customer\Model\Config\Share\Proxy</argument> @@ -48,16 +46,6 @@ <argument name="customerRepository" xsi:type="object">Magento\Customer\Api\CustomerRepositoryInterface\Proxy</argument> </arguments> </type> - <type name="Magento\Customer\Api\Data\CustomerDataBuilder" shared="false"> - <arguments> - <argument name="metadataService" xsi:type="object">\Magento\Customer\Api\CustomerMetadataInterface</argument> - </arguments> - </type> - <type name="Magento\Customer\Api\Data\AddressDataBuilder" shared="false"> - <arguments> - <argument name="metadataService" xsi:type="object">\Magento\Customer\Api\AddressMetadataInterface</argument> - </arguments> - </type> <type name="Magento\Customer\Helper\Address"> <arguments> <argument name="addressConfig" xsi:type="object">Magento\Customer\Model\Address\Config\Proxy</argument> @@ -68,7 +56,6 @@ <argument name="customerResource" xsi:type="object">Magento\Customer\Model\Resource\Customer\Proxy</argument> </arguments> </type> - <type name="Magento\Customer\Api\Data\OptionDataBuilder" shared="false" /> <type name="Magento\Eav\Model\Entity\Setup\PropertyMapper\Composite"> <arguments> <argument name="propertyMappers" xsi:type="array"> @@ -77,9 +64,6 @@ </arguments> </type> <virtualType name="Magento\Customer\Api\Config\CustomerMetadataConfig" type="Magento\Framework\Api\Config\MetadataConfig"> - <arguments> - <argument name="attributeMetadataBuilder" xsi:type="object">Magento\Customer\Model\AttributeMetadataDataBuilder</argument> - </arguments> </virtualType> <type name="Magento\Customer\Model\Metadata\CustomerMetadata"> <arguments> @@ -87,9 +71,6 @@ </arguments> </type> <virtualType name="Magento\Customer\Api\Config\AddressMetadataConfig" type="Magento\Framework\Api\Config\MetadataConfig"> - <arguments> - <argument name="attributeMetadataBuilder" xsi:type="object">Magento\Customer\Model\AttributeMetadataDataBuilder</argument> - </arguments> </virtualType> <type name="Magento\Customer\Model\Metadata\AddressMetadata"> <arguments> diff --git a/app/code/Magento/Downloadable/Model/Link.php b/app/code/Magento/Downloadable/Model/Link.php index 8bd4c56a3148efd24a471da136de198037f5f76d..776e2983fdac58a8d627c637cac8237363b81f03 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\AttributeDataBuilder; use Magento\Framework\Api\MetadataServiceInterface; use Magento\Downloadable\Model\Resource\Link as Resource; @@ -56,11 +55,6 @@ class Link extends \Magento\Framework\Model\AbstractExtensibleModel implements C */ protected $metadataService; - /** - * @var AttributeDataBuilder - */ - protected $customAttributeBuilder; - /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry diff --git a/app/code/Magento/Eav/Api/Data/AttributeGroupDataBuilder.php b/app/code/Magento/Eav/Api/Data/AttributeGroupDataBuilder.php deleted file mode 100644 index 66ef5afef6e29eea7e61048ee7ee48f95d5e716e..0000000000000000000000000000000000000000 --- a/app/code/Magento/Eav/Api/Data/AttributeGroupDataBuilder.php +++ /dev/null @@ -1,91 +0,0 @@ -<?php -/** - * - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -namespace Magento\Eav\Api\Data; - -use Magento\Framework\Api\MetadataServiceInterface; -use Magento\Framework\Api\ObjectFactory; - -/** - * DataBuilder class for \Magento\Eav\Api\Data\AttributeGroupInterface - * @codeCoverageIgnore - */ -class AttributeGroupDataBuilder extends \Magento\Framework\Api\Builder -{ - /** - * @param ObjectFactory $objectFactory - * @param MetadataServiceInterface $metadataService - * @param \Magento\Framework\Api\AttributeValueFactory $attributeValueFactory - * @param \Magento\Framework\Reflection\DataObjectProcessor $objectProcessor - * @param \Magento\Framework\Reflection\TypeProcessor $typeProcessor - * @param \Magento\Framework\Serialization\DataBuilderFactory $dataBuilderFactory - * @param \Magento\Framework\ObjectManager\ConfigInterface $objectManagerConfig - * @param string $modelClassInterface - */ - public function __construct( - ObjectFactory $objectFactory, - MetadataServiceInterface $metadataService, - \Magento\Framework\Api\AttributeValueFactory $attributeValueFactory, - \Magento\Framework\Reflection\DataObjectProcessor $objectProcessor, - \Magento\Framework\Reflection\TypeProcessor $typeProcessor, - \Magento\Framework\Serialization\DataBuilderFactory $dataBuilderFactory, - \Magento\Framework\ObjectManager\ConfigInterface $objectManagerConfig, - $modelClassInterface = 'Magento\Eav\Api\Data\AttributeGroupInterface' - ) { - parent::__construct( - $objectFactory, - $metadataService, - $attributeValueFactory, - $objectProcessor, - $typeProcessor, - $dataBuilderFactory, - $objectManagerConfig, - $modelClassInterface - ); - } - - /** - * {@inheritdoc} - */ - public function create() - { - /** TODO: temporary fix while problem with hasDataChanges flag not solved. MAGETWO-30324 */ - $object = parent::create(); - $object->setDataChanges(true); - return $object; - } - - /** - * @param string|null $attributeGroupName - * @return $this - */ - public function setAttributeGroupName($attributeGroupName) - { - $this->_set('attribute_group_name', $attributeGroupName); - return $this; - } - - /** - * @param string|null $attributeGroupId - * @return $this - */ - public function setAttributeGroupId($attributeGroupId) - { - $this->_set('attribute_group_id', $attributeGroupId); - return $this; - } - - /** - * @param int|null $attributeSetId - * @return $this - */ - public function setAttributeSetId($attributeSetId) - { - $this->_set('attribute_set_id', $attributeSetId); - return $this; - } -} diff --git a/app/code/Magento/Eav/Api/Data/AttributeGroupSearchResultsInterface.php b/app/code/Magento/Eav/Api/Data/AttributeGroupSearchResultsInterface.php index 14a78abf17a5c9806d271b42e58ddf1870f956e2..fd9a4416c42cac6310c62febf27afc114a6c3a74 100644 --- a/app/code/Magento/Eav/Api/Data/AttributeGroupSearchResultsInterface.php +++ b/app/code/Magento/Eav/Api/Data/AttributeGroupSearchResultsInterface.php @@ -14,4 +14,12 @@ interface AttributeGroupSearchResultsInterface extends \Magento\Framework\Api\Se * @return \Magento\Eav\Api\Data\AttributeGroupInterface[] */ public function getItems(); + + /** + * Set attribute sets list. + * + * @param \Magento\Eav\Api\Data\AttributeGroupInterface[] $items + * @return $this + */ + public function setItems(array $items = null); } diff --git a/app/code/Magento/Eav/Api/Data/AttributeSearchResultsInterface.php b/app/code/Magento/Eav/Api/Data/AttributeSearchResultsInterface.php index 2b419e95236e24625652ece84a4a5d083ad99a84..ccf026345d871471491ab633ed878ecf5f452b42 100644 --- a/app/code/Magento/Eav/Api/Data/AttributeSearchResultsInterface.php +++ b/app/code/Magento/Eav/Api/Data/AttributeSearchResultsInterface.php @@ -14,4 +14,12 @@ interface AttributeSearchResultsInterface extends \Magento\Framework\Api\SearchR * @return \Magento\Eav\Api\Data\AttributeInterface[] */ public function getItems(); + + /** + * Set attributes list. + * + * @param \Magento\Eav\Api\Data\AttributeInterface[] $items + * @return $this + */ + public function setItems(array $items = null); } diff --git a/app/code/Magento/Eav/Api/Data/AttributeSetDataBuilder.php b/app/code/Magento/Eav/Api/Data/AttributeSetDataBuilder.php deleted file mode 100644 index 4383ee100029be8d4c34a6bbf9d9c5bf71a5c9cb..0000000000000000000000000000000000000000 --- a/app/code/Magento/Eav/Api/Data/AttributeSetDataBuilder.php +++ /dev/null @@ -1,101 +0,0 @@ -<?php -/** - * - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -namespace Magento\Eav\Api\Data; - -use Magento\Framework\Api\MetadataServiceInterface; -use Magento\Framework\Api\ObjectFactory; - -/** - * DataBuilder class for \Magento\Eav\Api\Data\AttributeSetInterface - * @codeCoverageIgnore - */ -class AttributeSetDataBuilder extends \Magento\Framework\Api\Builder -{ - /** - * @param ObjectFactory $objectFactory - * @param MetadataServiceInterface $metadataService - * @param \Magento\Framework\Api\AttributeValueFactory $attributeValueFactory - * @param \Magento\Framework\Reflection\DataObjectProcessor $objectProcessor - * @param \Magento\Framework\Reflection\TypeProcessor $typeProcessor - * @param \Magento\Framework\Serialization\DataBuilderFactory $dataBuilderFactory - * @param \Magento\Framework\ObjectManager\ConfigInterface $objectManagerConfig - * @param string $modelClassInterface - */ - public function __construct( - ObjectFactory $objectFactory, - MetadataServiceInterface $metadataService, - \Magento\Framework\Api\AttributeValueFactory $attributeValueFactory, - \Magento\Framework\Reflection\DataObjectProcessor $objectProcessor, - \Magento\Framework\Reflection\TypeProcessor $typeProcessor, - \Magento\Framework\Serialization\DataBuilderFactory $dataBuilderFactory, - \Magento\Framework\ObjectManager\ConfigInterface $objectManagerConfig, - $modelClassInterface = 'Magento\Eav\Api\Data\AttributeSetInterface' - ) { - parent::__construct( - $objectFactory, - $metadataService, - $attributeValueFactory, - $objectProcessor, - $typeProcessor, - $dataBuilderFactory, - $objectManagerConfig, - $modelClassInterface - ); - } - - /** - * @param string $attributeSetName - * @return $this - */ - public function setAttributeSetName($attributeSetName) - { - $this->_set('attribute_set_name', $attributeSetName); - return $this; - } - - /** - * @param int|null $attributeSetId - * @return $this - */ - public function setAttributeSetId($attributeSetId) - { - $this->_set('attribute_set_id', $attributeSetId); - return $this; - } - - /** - * @param int $sortOrder - * @return $this - */ - public function setSortOrder($sortOrder) - { - $this->_set('sort_order', $sortOrder); - return $this; - } - - /** - * @param int|null $entityTypeId - * @return $this - */ - public function setEntityTypeId($entityTypeId) - { - $this->_set('entity_type_id', $entityTypeId); - return $this; - } - - /** - * {@inheritdoc} - */ - public function create() - { - /** TODO: temporary fix while problem with hasDataChanges flag not solved. MAGETWO-30324 */ - $object = parent::create(); - $object->setDataChanges(true); - return $object; - } -} diff --git a/app/code/Magento/Eav/Api/Data/AttributeSetSearchResultsInterface.php b/app/code/Magento/Eav/Api/Data/AttributeSetSearchResultsInterface.php index 7621e60c2b07d67c7afac4f6bdd7b02302880dcd..ef0d07da39cd28adf9353b0a37355835863f26f9 100644 --- a/app/code/Magento/Eav/Api/Data/AttributeSetSearchResultsInterface.php +++ b/app/code/Magento/Eav/Api/Data/AttributeSetSearchResultsInterface.php @@ -14,4 +14,12 @@ interface AttributeSetSearchResultsInterface extends \Magento\Framework\Api\Sear * @return \Magento\Eav\Api\Data\AttributeSetInterface[] */ public function getItems(); + + /** + * Set attribute sets list. + * + * @param \Magento\Eav\Api\Data\AttributeSetInterface[] $items + * @return $this + */ + public function setItems(array $items = null); } diff --git a/app/code/Magento/Eav/Model/Attribute/GroupRepository.php b/app/code/Magento/Eav/Model/Attribute/GroupRepository.php index 3ac1073b7cbf59f2bb4803865d4931b61fd2b130..558964315f315229a58605dbc3adf0698fb86629 100644 --- a/app/code/Magento/Eav/Model/Attribute/GroupRepository.php +++ b/app/code/Magento/Eav/Model/Attribute/GroupRepository.php @@ -33,29 +33,29 @@ class GroupRepository implements \Magento\Eav\Api\AttributeGroupRepositoryInterf protected $groupListFactory; /** - * @var \Magento\Eav\Api\Data\AttributeGroupSearchResultsDataBuilder + * @var \Magento\Eav\Api\Data\AttributeGroupSearchResultsInterfaceFactory */ - protected $searchResultsBuilder; + protected $searchResultsFactory; /** * @param \Magento\Eav\Model\Resource\Entity\Attribute\Group $groupResource * @param \Magento\Eav\Model\Resource\Entity\Attribute\Group\CollectionFactory $groupListFactory * @param \Magento\Eav\Model\Entity\Attribute\GroupFactory $groupFactory * @param \Magento\Eav\Api\AttributeSetRepositoryInterface $setRepository - * @param \Magento\Eav\Api\Data\AttributeGroupSearchResultsDataBuilder $searchResultsBuilder + * @param \Magento\Eav\Api\Data\AttributeGroupSearchResultsInterfaceFactory $searchResultsFactory */ public function __construct( \Magento\Eav\Model\Resource\Entity\Attribute\Group $groupResource, \Magento\Eav\Model\Resource\Entity\Attribute\Group\CollectionFactory $groupListFactory, \Magento\Eav\Model\Entity\Attribute\GroupFactory $groupFactory, \Magento\Eav\Api\AttributeSetRepositoryInterface $setRepository, - \Magento\Eav\Api\Data\AttributeGroupSearchResultsDataBuilder $searchResultsBuilder + \Magento\Eav\Api\Data\AttributeGroupSearchResultsInterfaceFactory $searchResultsFactory ) { $this->groupResource = $groupResource; $this->groupListFactory = $groupListFactory; $this->groupFactory = $groupFactory; $this->setRepository = $setRepository; - $this->searchResultsBuilder = $searchResultsBuilder; + $this->searchResultsFactory = $searchResultsFactory; } /** @@ -109,10 +109,11 @@ class GroupRepository implements \Magento\Eav\Api\AttributeGroupRepositoryInterf $collection->setAttributeSetFilter($attributeSetId); $collection->setSortOrder(); - $this->searchResultsBuilder->setSearchCriteria($searchCriteria); - $this->searchResultsBuilder->setItems($collection->getItems()); - $this->searchResultsBuilder->setTotalCount($collection->getSize()); - return $this->searchResultsBuilder->create(); + $searchResult = $this->searchResultsFactory->create(); + $searchResult->setSearchCriteria($searchCriteria); + $searchResult->setItems($collection->getItems()); + $searchResult->setTotalCount($collection->getSize()); + return $searchResult; } /** diff --git a/app/code/Magento/Eav/Model/AttributeRepository.php b/app/code/Magento/Eav/Model/AttributeRepository.php index 86437cdbf3d48452e55aaefa5b6c2c0702c643a1..b3dfb59a88829a072cf65e6dc7fb4c9336459a10 100644 --- a/app/code/Magento/Eav/Model/AttributeRepository.php +++ b/app/code/Magento/Eav/Model/AttributeRepository.php @@ -33,9 +33,9 @@ class AttributeRepository implements \Magento\Eav\Api\AttributeRepositoryInterfa protected $attributeCollectionFactory; /** - * @var \Magento\Eav\Api\Data\AttributeSearchResultsDataBuilder + * @var \Magento\Eav\Api\Data\AttributeSearchResultsInterfaceFactory */ - protected $searchResultsBuilder; + protected $searchResultsFactory; /** * @var Entity\AttributeFactory @@ -46,20 +46,20 @@ class AttributeRepository implements \Magento\Eav\Api\AttributeRepositoryInterfa * @param Config $eavConfig * @param Resource\Entity\Attribute $eavResource * @param Resource\Entity\Attribute\CollectionFactory $attributeCollectionFactory - * @param \Magento\Eav\Api\Data\AttributeSearchResultsDataBuilder $searchResultsBuilder + * @param \Magento\Eav\Api\Data\AttributeSearchResultsInterfaceFactory $searchResultsFactory * @param Entity\AttributeFactory $attributeFactory */ public function __construct( \Magento\Eav\Model\Config $eavConfig, \Magento\Eav\Model\Resource\Entity\Attribute $eavResource, \Magento\Eav\Model\Resource\Entity\Attribute\CollectionFactory $attributeCollectionFactory, - \Magento\Eav\Api\Data\AttributeSearchResultsDataBuilder $searchResultsBuilder, + \Magento\Eav\Api\Data\AttributeSearchResultsInterfaceFactory $searchResultsFactory, \Magento\Eav\Model\Entity\AttributeFactory $attributeFactory ) { $this->eavConfig = $eavConfig; $this->eavResource = $eavResource; $this->attributeCollectionFactory = $attributeCollectionFactory; - $this->searchResultsBuilder = $searchResultsBuilder; + $this->searchResultsFactory = $searchResultsFactory; $this->attributeFactory = $attributeFactory; } @@ -127,10 +127,11 @@ class AttributeRepository implements \Magento\Eav\Api\AttributeRepositoryInterfa foreach ($attributeCollection as $attribute) { $attributes[] = $this->get($entityTypeCode, $attribute->getAttributeCode()); } - $this->searchResultsBuilder->setSearchCriteria($searchCriteria); - $this->searchResultsBuilder->setItems($attributes); - $this->searchResultsBuilder->setTotalCount($totalCount); - return $this->searchResultsBuilder->create(); + $searchResults = $this->searchResultsFactory->create(); + $searchResults->setSearchCriteria($searchCriteria); + $searchResults->setItems($attributes); + $searchResults->setTotalCount($totalCount); + return $searchResults; } /** diff --git a/app/code/Magento/Eav/Model/AttributeSetRepository.php b/app/code/Magento/Eav/Model/AttributeSetRepository.php index 29cfc020a170711c6f2560f924faf45870866aa8..dc989a741f09d3dc6a825b156da200cfabf42dea 100644 --- a/app/code/Magento/Eav/Model/AttributeSetRepository.php +++ b/app/code/Magento/Eav/Model/AttributeSetRepository.php @@ -42,29 +42,29 @@ class AttributeSetRepository implements AttributeSetRepositoryInterface private $eavConfig; /** - * @var \Magento\Eav\Api\Data\AttributeSetSearchResultsDataBuilder + * @var \Magento\Eav\Api\Data\AttributeSetSearchResultsInterfaceFactory */ - private $searchResultsBuilder; + private $searchResultsFactory; /** * @param AttributeSetResource $attributeSetResource * @param AttributeSetFactory $attributeSetFactory * @param CollectionFactory $collectionFactory * @param Config $eavConfig - * @param \Magento\Eav\Api\Data\AttributeSetSearchResultsDataBuilder $searchResultBuilder + * @param \Magento\Eav\Api\Data\AttributeSetSearchResultsInterfaceFactory $searchResultFactory */ public function __construct( AttributeSetResource $attributeSetResource, AttributeSetFactory $attributeSetFactory, CollectionFactory $collectionFactory, EavConfig $eavConfig, - \Magento\Eav\Api\Data\AttributeSetSearchResultsDataBuilder $searchResultBuilder + \Magento\Eav\Api\Data\AttributeSetSearchResultsInterfaceFactory $searchResultFactory ) { $this->attributeSetResource = $attributeSetResource; $this->attributeSetFactory = $attributeSetFactory; $this->collectionFactory = $collectionFactory; $this->eavConfig = $eavConfig; - $this->searchResultsBuilder = $searchResultBuilder; + $this->searchResultsFactory = $searchResultFactory; } /** @@ -98,10 +98,11 @@ class AttributeSetRepository implements AttributeSetRepositoryInterface $collection->setCurPage($searchCriteria->getCurrentPage()); $collection->setPageSize($searchCriteria->getPageSize()); - $this->searchResultsBuilder->setSearchCriteria($searchCriteria); - $this->searchResultsBuilder->setItems($collection->getItems()); - $this->searchResultsBuilder->setTotalCount($collection->getSize()); - return $this->searchResultsBuilder->create(); + $searchResults = $this->searchResultsFactory->create(); + $searchResults->setSearchCriteria($searchCriteria); + $searchResults->setItems($collection->getItems()); + $searchResults->setTotalCount($collection->getSize()); + return $searchResults; } /** 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 394be4fc0d26047bece3d5c36ae4248562918b3e..377aa2277184687d8ad6f6c20ef2d9166c0466c2 100644 --- a/app/code/Magento/Eav/Test/Unit/Model/Attribute/GroupRepositoryTest.php +++ b/app/code/Magento/Eav/Test/Unit/Model/Attribute/GroupRepositoryTest.php @@ -30,7 +30,7 @@ class GroupRepositoryTest extends \PHPUnit_Framework_TestCase /** * @var \PHPUnit_Framework_MockObject_MockObject */ - protected $searchResultsBuilderMock; + protected $searchResultsFactoryMock; /** * @var \PHPUnit_Framework_MockObject_MockObject @@ -54,9 +54,9 @@ class GroupRepositoryTest extends \PHPUnit_Framework_TestCase false ); $this->setRepositoryMock = $this->getMock('\Magento\Eav\Api\AttributeSetRepositoryInterface'); - $this->searchResultsBuilderMock = $this->getMock( - '\Magento\Eav\Api\Data\AttributeGroupSearchResultsDataBuilder', - ['setSearchCriteria', 'setItems', 'setTotalCount', 'create'], + $this->searchResultsFactoryMock = $this->getMock( + '\Magento\Eav\Api\Data\AttributeGroupSearchResultsInterfaceFactory', + ['create'], [], '', false @@ -77,7 +77,7 @@ class GroupRepositoryTest extends \PHPUnit_Framework_TestCase 'groupListFactory' => $this->groupListFactoryMock, 'groupFactory' => $this->groupFactoryMock, 'setRepository' => $this->setRepositoryMock, - 'searchResultsBuilder' => $this->searchResultsBuilderMock + 'searchResultsFactory' => $this->searchResultsFactoryMock ] ); } @@ -246,11 +246,18 @@ class GroupRepositoryTest extends \PHPUnit_Framework_TestCase $groupCollectionMock->expects($this->once())->method('setSortOrder'); $groupCollectionMock->expects($this->once())->method('getSize')->willReturn(1); - $this->searchResultsBuilderMock->expects($this->once())->method('setSearchCriteria')->with($searchCriteriaMock); - $this->searchResultsBuilderMock->expects($this->once())->method('setItems')->with([$groupMock]); - $this->searchResultsBuilderMock->expects($this->once())->method('setTotalCount')->with(1); - $this->searchResultsBuilderMock->expects($this->once())->method('create')->willReturnSelf(); - $this->assertEquals($this->searchResultsBuilderMock, $this->model->getList($searchCriteriaMock)); + $searchResultsMock = $this->getMock( + '\Magento\Eav\Api\Data\AttributeGroupSearchResultsInterface', + [], + [], + '', + false + ); + $searchResultsMock->expects($this->once())->method('setSearchCriteria')->with($searchCriteriaMock); + $searchResultsMock->expects($this->once())->method('setItems')->with([$groupMock]); + $searchResultsMock->expects($this->once())->method('setTotalCount')->with(1); + $this->searchResultsFactoryMock->expects($this->once())->method('create')->willReturn($searchResultsMock); + $this->assertEquals($searchResultsMock, $this->model->getList($searchCriteriaMock)); } /** diff --git a/app/code/Magento/Eav/Test/Unit/Model/AttributeSetRepositoryTest.php b/app/code/Magento/Eav/Test/Unit/Model/AttributeSetRepositoryTest.php index 77ecf73968d47018b8d280658ea140be22a261ea..2b710da0cfab25d5cda2f9c97db05aeff4b91124 100644 --- a/app/code/Magento/Eav/Test/Unit/Model/AttributeSetRepositoryTest.php +++ b/app/code/Magento/Eav/Test/Unit/Model/AttributeSetRepositoryTest.php @@ -40,7 +40,7 @@ class AttributeSetRepositoryTest extends \PHPUnit_Framework_TestCase /** * @var \PHPUnit_Framework_MockObject_MockObject */ - private $resultBuilderMock; + private $resultFactoryMock; protected function setUp() { @@ -66,9 +66,9 @@ class AttributeSetRepositoryTest extends \PHPUnit_Framework_TestCase false ); $this->eavConfigMock = $this->getMock('Magento\Eav\Model\Config', ['getEntityType'], [], '', false); - $this->resultBuilderMock = $this->getMock( - '\Magento\Eav\Api\Data\AttributeSetSearchResultsDataBuilder', - ['setSearchCriteria', 'setItems', 'setTotalCount', 'create', '__wakeup'], + $this->resultFactoryMock = $this->getMock( + '\Magento\Eav\Api\Data\AttributeSetSearchResultsInterfaceFactory', + ['create'], [], '', false @@ -78,7 +78,7 @@ class AttributeSetRepositoryTest extends \PHPUnit_Framework_TestCase $this->setFactoryMock, $this->collectionFactoryMock, $this->eavConfigMock, - $this->resultBuilderMock + $this->resultFactoryMock ); } @@ -216,18 +216,18 @@ class AttributeSetRepositoryTest extends \PHPUnit_Framework_TestCase $collectionMock->expects($this->once())->method('getItems')->willReturn([$attributeSetMock]); $collectionMock->expects($this->once())->method('getSize')->willReturn(1); - $this->resultBuilderMock->expects($this->once()) + $resultMock = $this->getMock('\Magento\Eav\Api\Data\AttributeSetSearchResultsInterface', [], [], '', false); + $resultMock->expects($this->once()) ->method('setSearchCriteria') ->with($searchCriteriaMock) ->willReturnSelf(); - $this->resultBuilderMock->expects($this->once()) + $resultMock->expects($this->once()) ->method('setItems') ->with([$attributeSetMock]) ->willReturnSelf(); - $this->resultBuilderMock->expects($this->once())->method('setTotalCount')->with(1)->willReturnSelf(); + $resultMock->expects($this->once())->method('setTotalCount')->with(1)->willReturnSelf(); - $resultMock = $this->getMock('\Magento\Eav\Api\Data\AttributeSetSearchResultsInterface', [], [], '', false); - $this->resultBuilderMock->expects($this->once())->method('create')->willReturn($resultMock); + $this->resultFactoryMock->expects($this->once())->method('create')->willReturn($resultMock); $this->model->getList($searchCriteriaMock); } 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 index 0a6d8f2b1c8255a3db0b538695d7b25d6ba2adb5..c95e4ba9827f3facf32bf1257a2c4081a48e3a18 100644 --- 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 @@ -87,7 +87,11 @@ class Status extends \Magento\Backend\Block\Template if (!$this->customer) { $this->customer = $this->customerFactory->create(); $this->dataObjectHelper - ->populateWithArray($this->customer, $this->_backendSession->getCustomerData()['account']); + ->populateWithArray( + $this->customer, + $this->_backendSession->getCustomerData()['account'], + '\Magento\Customer\Api\Data\CustomerInterface' + ); } return $this->customer; } diff --git a/app/code/Magento/OfflineShipping/etc/fieldset.xml b/app/code/Magento/OfflineShipping/etc/fieldset.xml index a76ae34d59ef26a6c9218af3661e1e3f6f0a1250..17c6cfaa6d403c3194d476162e148ac331c0f2c7 100644 --- a/app/code/Magento/OfflineShipping/etc/fieldset.xml +++ b/app/code/Magento/OfflineShipping/etc/fieldset.xml @@ -8,7 +8,7 @@ <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Object/etc/fieldset.xsd"> <scope id="global"> - <fieldset id="sales_convert_quote_item"> + <fieldset id="quote_convert_item"> <field name="free_shipping"> <aspect name="to_order_item" /> </field> diff --git a/app/code/Magento/PageCache/Controller/Block/Render.php b/app/code/Magento/PageCache/Controller/Block/Render.php index 2758db3f574214ca247997de092f4cc580c990e3..8afaeb27e5c3a552d83e8a72d1a940ddab4434ba 100644 --- a/app/code/Magento/PageCache/Controller/Block/Render.php +++ b/app/code/Magento/PageCache/Controller/Block/Render.php @@ -19,7 +19,8 @@ class Render extends \Magento\PageCache\Controller\Block $this->_forward('noroute'); return; } - + // disable profiling during private content handling AJAX call + \Magento\Framework\Profiler::reset(); $blocks = $this->_getBlocks(); $data = []; foreach ($blocks as $blockName => $blockInstance) { diff --git a/app/code/Magento/Quote/Api/Data/CartSearchResultsInterface.php b/app/code/Magento/Quote/Api/Data/CartSearchResultsInterface.php index bfad641fd0a04d326c6ccb6312c26ac0580fde42..f3683415e7580eed924e5270f6676da8fcc73ff7 100644 --- a/app/code/Magento/Quote/Api/Data/CartSearchResultsInterface.php +++ b/app/code/Magento/Quote/Api/Data/CartSearchResultsInterface.php @@ -46,7 +46,7 @@ interface CartSearchResultsInterface extends \Magento\Framework\Api\SearchResult * @param \Magento\Framework\Api\SearchCriteriaInterface $searchCriteria * @return $this */ - public function setSearchCriteria(\Magento\Framework\Api\SearchCriteriaInterface $searchCriteria); + public function setSearchCriteria(\Magento\Framework\Api\SearchCriteriaInterface $searchCriteria = null); /** * Get total count. diff --git a/app/code/Magento/Quote/Model/Quote/Address.php b/app/code/Magento/Quote/Model/Quote/Address.php index 69a06b6c03312beac1f1f57e27a49f98a25e0929..01b4582cea36f116cddf6fba40e123c25c1c91d4 100644 --- a/app/code/Magento/Quote/Model/Quote/Address.php +++ b/app/code/Magento/Quote/Model/Quote/Address.php @@ -513,7 +513,11 @@ class Address extends \Magento\Customer\Model\Address\AbstractAddress implements $customerAddressData = array_merge($customerAddressData, $customerAddressDataWithRegion); $addressDataObject = $this->addressDataFactory->create(); - $this->dataObjectHelper->populateWithArray($addressDataObject, $customerAddressData); + $this->dataObjectHelper->populateWithArray( + $addressDataObject, + $customerAddressData, + '\Magento\Customer\Api\Data\AddressInterface' + ); return $addressDataObject; } diff --git a/app/code/Magento/Sales/Api/Data/CreditmemoCommentInterface.php b/app/code/Magento/Sales/Api/Data/CreditmemoCommentInterface.php index 0e0e7160582e7cc10aa401a35b4891bb22fa998a..4d8ce351eddeb4cfa5f96c0ea73a963465e9e938 100644 --- a/app/code/Magento/Sales/Api/Data/CreditmemoCommentInterface.php +++ b/app/code/Magento/Sales/Api/Data/CreditmemoCommentInterface.php @@ -64,6 +64,14 @@ interface CreditmemoCommentInterface extends \Magento\Framework\Api\ExtensibleDa */ public function getEntityId(); + /** + * Sets entity ID. + * + * @param int $entityId + * @return $this + */ + public function setEntityId($entityId); + /** * Gets the is-customer-notified flag value for the credit memo. * diff --git a/app/code/Magento/Sales/Api/Data/CreditmemoCommentSearchResultInterface.php b/app/code/Magento/Sales/Api/Data/CreditmemoCommentSearchResultInterface.php index 962865788bf5ee8f256011624f9a0e30f28221ae..71ad928a2a8b87fa0e0bba5180529a2b18ce896a 100644 --- a/app/code/Magento/Sales/Api/Data/CreditmemoCommentSearchResultInterface.php +++ b/app/code/Magento/Sales/Api/Data/CreditmemoCommentSearchResultInterface.php @@ -21,4 +21,12 @@ interface CreditmemoCommentSearchResultInterface extends \Magento\Framework\Api\ * @return \Magento\Sales\Api\Data\CreditmemoCommentInterface[] Array of collection items. */ public function getItems(); + + /** + * Sets collection items. + * + * @param \Magento\Sales\Api\Data\CreditmemoCommentInterface[] $items + * @return $this + */ + public function setItems(array $items = null); } diff --git a/app/code/Magento/Sales/Api/Data/CreditmemoInterface.php b/app/code/Magento/Sales/Api/Data/CreditmemoInterface.php index 8c0e875ead18eda66304c5ec6af3a65f73c9b998..8063c5d64e3aa6c766f21955d9731c30c61f6be1 100644 --- a/app/code/Magento/Sales/Api/Data/CreditmemoInterface.php +++ b/app/code/Magento/Sales/Api/Data/CreditmemoInterface.php @@ -256,6 +256,14 @@ interface CreditmemoInterface extends \Magento\Framework\Api\ExtensibleDataInter */ public function getBaseAdjustmentNegative(); + /** + * Sets the credit memo negative base adjustment. + * + * @param float $baseAdjustmentNegative + * @return $this + */ + public function setBaseAdjustmentNegative($baseAdjustmentNegative); + /** * Gets the credit memo positive base adjustment. * @@ -263,6 +271,14 @@ interface CreditmemoInterface extends \Magento\Framework\Api\ExtensibleDataInter */ public function getBaseAdjustmentPositive(); + /** + * Sets the credit memo positive base adjustment. + * + * @param float $baseAdjustmentPositive + * @return $this + */ + public function setBaseAdjustmentPositive($baseAdjustmentPositive); + /** * Gets the credit memo base currency code. * @@ -401,6 +417,15 @@ interface CreditmemoInterface extends \Magento\Framework\Api\ExtensibleDataInter * @return int Credit memo ID. */ public function getEntityId(); + + /** + * Sets entity ID. + * + * @param int $entityId + * @return $this + */ + public function setEntityId($entityId); + /** * Gets the credit memo global currency code. * @@ -547,6 +572,14 @@ interface CreditmemoInterface extends \Magento\Framework\Api\ExtensibleDataInter */ public function getTransactionId(); + /** + * Sets the credit memo transaction ID. + * + * @param string $transactionId + * @return $this + */ + public function setTransactionId($transactionId); + /** * Gets the credit memo updated-at timestamp. * diff --git a/app/code/Magento/Sales/Api/Data/CreditmemoItemInterface.php b/app/code/Magento/Sales/Api/Data/CreditmemoItemInterface.php index 41eace4abdad8299142f514a4202fc74339efa4d..c01bb4c6ee75d2ebb127aa20d6211cc3f0a95892 100644 --- a/app/code/Magento/Sales/Api/Data/CreditmemoItemInterface.php +++ b/app/code/Magento/Sales/Api/Data/CreditmemoItemInterface.php @@ -263,6 +263,14 @@ interface CreditmemoItemInterface extends \Magento\Framework\Api\ExtensibleDataI */ public function getEntityId(); + /** + * Sets entity ID. + * + * @param int $entityId + * @return $this + */ + public function setEntityId($entityId); + /** * Gets the hidden tax amount for a credit memo item. * diff --git a/app/code/Magento/Sales/Api/Data/CreditmemoItemSearchResultInterface.php b/app/code/Magento/Sales/Api/Data/CreditmemoItemSearchResultInterface.php index b9edf60f8f17c2958c737a8878678059679da448..5379dd74e78be5eaeff7e00c268327bafadf22a0 100644 --- a/app/code/Magento/Sales/Api/Data/CreditmemoItemSearchResultInterface.php +++ b/app/code/Magento/Sales/Api/Data/CreditmemoItemSearchResultInterface.php @@ -21,4 +21,12 @@ interface CreditmemoItemSearchResultInterface extends \Magento\Framework\Api\Sea * @return \Magento\Sales\Api\Data\CreditmemoItemInterface[] Array of collection items. */ public function getItems(); + + /** + * Set collection items. + * + * @param \Magento\Sales\Api\Data\CreditmemoItemInterface[] $items + * @return $this + */ + public function setItems(array $items = null); } diff --git a/app/code/Magento/Sales/Api/Data/CreditmemoSearchResultInterface.php b/app/code/Magento/Sales/Api/Data/CreditmemoSearchResultInterface.php index adc3e1131be9edd9cf801eb1746d048abb8c5929..2e3456b6b11c30e83e38fb86a26db6c223948b15 100644 --- a/app/code/Magento/Sales/Api/Data/CreditmemoSearchResultInterface.php +++ b/app/code/Magento/Sales/Api/Data/CreditmemoSearchResultInterface.php @@ -20,4 +20,12 @@ interface CreditmemoSearchResultInterface extends \Magento\Framework\Api\SearchR * @return \Magento\Sales\Api\Data\CreditmemoInterface[] Array of collection items. */ public function getItems(); + + /** + * Set collection items. + * + * @param \Magento\Sales\Api\Data\CreditmemoInterface[] $items + * @return $this + */ + public function setItems(array $items = null); } diff --git a/app/code/Magento/Sales/Api/Data/InvoiceCommentInterface.php b/app/code/Magento/Sales/Api/Data/InvoiceCommentInterface.php index ddeff7a15307a6f4b19476a89c433f4fe5c73080..05e605a530f94a822ed1496cf73abc5729b119c1 100644 --- a/app/code/Magento/Sales/Api/Data/InvoiceCommentInterface.php +++ b/app/code/Magento/Sales/Api/Data/InvoiceCommentInterface.php @@ -62,6 +62,14 @@ interface InvoiceCommentInterface extends \Magento\Framework\Api\ExtensibleDataI */ public function getEntityId(); + /** + * Sets entity ID. + * + * @param int $entityId + * @return $this + */ + public function setEntityId($entityId); + /** * Gets the is-customer-notified flag value for the invoice. * diff --git a/app/code/Magento/Sales/Api/Data/InvoiceCommentSearchResultInterface.php b/app/code/Magento/Sales/Api/Data/InvoiceCommentSearchResultInterface.php index fc95adf84d6ed5054b372bca22ab136d16bd5719..4ba898bfedc012e4bfae657a1c15337148431012 100644 --- a/app/code/Magento/Sales/Api/Data/InvoiceCommentSearchResultInterface.php +++ b/app/code/Magento/Sales/Api/Data/InvoiceCommentSearchResultInterface.php @@ -19,4 +19,12 @@ interface InvoiceCommentSearchResultInterface extends \Magento\Framework\Api\Sea * @return \Magento\Sales\Api\Data\InvoiceCommentInterface[] Array of collection items. */ public function getItems(); + + /** + * Sets collection items. + * + * @param \Magento\Sales\Api\Data\InvoiceCommentInterface[] $items + * @return $this + */ + public function setItems(array $items = null); } diff --git a/app/code/Magento/Sales/Api/Data/InvoiceInterface.php b/app/code/Magento/Sales/Api/Data/InvoiceInterface.php index 736c490639094b4ef4b94a948022e743039e4446..6cd291831bf5892bb8180223d8b007a48eb082d3 100644 --- a/app/code/Magento/Sales/Api/Data/InvoiceInterface.php +++ b/app/code/Magento/Sales/Api/Data/InvoiceInterface.php @@ -347,6 +347,14 @@ interface InvoiceInterface extends \Magento\Framework\Api\ExtensibleDataInterfac */ public function getEntityId(); + /** + * Sets entity ID. + * + * @param int $entityId + * @return $this + */ + public function setEntityId($entityId); + /** * Gets the global currency code for the invoice. * @@ -501,6 +509,14 @@ interface InvoiceInterface extends \Magento\Framework\Api\ExtensibleDataInterfac */ public function getTransactionId(); + /** + * Sets the transaction ID for the invoice. + * + * @param string $transactionId + * @return $this + */ + public function setTransactionId($transactionId); + /** * Gets the updated-at timestamp for the invoice. * diff --git a/app/code/Magento/Sales/Api/Data/InvoiceItemInterface.php b/app/code/Magento/Sales/Api/Data/InvoiceItemInterface.php index 68f3628b4a36453c6d4daca17319caa8f5b53066..127318da2ef1ca63d43a73c1958fff462ee03cf8 100644 --- a/app/code/Magento/Sales/Api/Data/InvoiceItemInterface.php +++ b/app/code/Magento/Sales/Api/Data/InvoiceItemInterface.php @@ -196,6 +196,14 @@ interface InvoiceItemInterface extends \Magento\Framework\Api\ExtensibleDataInte */ public function getEntityId(); + /** + * Sets entity ID. + * + * @param int $entityId + * @return $this + */ + public function setEntityId($entityId); + /** * Gets the hidden tax amount for the invoice item. * diff --git a/app/code/Magento/Sales/Api/Data/InvoiceItemSearchResultInterface.php b/app/code/Magento/Sales/Api/Data/InvoiceItemSearchResultInterface.php index 904f89fb8b362e8edbd2cd563bf888c0e159f03d..6472290a10f7b98384862cdbda2c8738254b501b 100644 --- a/app/code/Magento/Sales/Api/Data/InvoiceItemSearchResultInterface.php +++ b/app/code/Magento/Sales/Api/Data/InvoiceItemSearchResultInterface.php @@ -18,4 +18,12 @@ interface InvoiceItemSearchResultInterface extends \Magento\Framework\Api\Search * @return \Magento\Sales\Api\Data\InvoiceItemInterface[] Array of collection items. */ public function getItems(); + + /** + * Sets collection items. + * + * @param \Magento\Sales\Api\Data\InvoiceItemInterface[] $items + * @return $this + */ + public function setItems(array $items = null); } diff --git a/app/code/Magento/Sales/Api/Data/InvoiceSearchResultInterface.php b/app/code/Magento/Sales/Api/Data/InvoiceSearchResultInterface.php index 8421fff2884ca4de3e3f551338107fabb3111572..01fcf9d051d7fbba114abd6fe7d7b54a6046af35 100644 --- a/app/code/Magento/Sales/Api/Data/InvoiceSearchResultInterface.php +++ b/app/code/Magento/Sales/Api/Data/InvoiceSearchResultInterface.php @@ -18,4 +18,12 @@ interface InvoiceSearchResultInterface extends \Magento\Framework\Api\SearchResu * @return \Magento\Sales\Api\Data\InvoiceInterface[] Array of collection items. */ public function getItems(); + + /** + * Sets collection items. + * + * @param \Magento\Sales\Api\Data\InvoiceInterface[] $items + * @return $this + */ + public function setItems(array $items = null); } diff --git a/app/code/Magento/Sales/Api/Data/OrderAddressInterface.php b/app/code/Magento/Sales/Api/Data/OrderAddressInterface.php index 39c71fe74410db0e6e874b97d76630888ef5ee48..10c62d33ee5ce320785a1cee71af02e9c7208f89 100644 --- a/app/code/Magento/Sales/Api/Data/OrderAddressInterface.php +++ b/app/code/Magento/Sales/Api/Data/OrderAddressInterface.php @@ -175,6 +175,14 @@ interface OrderAddressInterface extends \Magento\Framework\Api\ExtensibleDataInt */ public function getEntityId(); + /** + * Sets the ID for the order address. + * + * @param int $entityId + * @return $this + */ + public function setEntityId($entityId); + /** * Gets the fax number for the order address. * diff --git a/app/code/Magento/Sales/Api/Data/OrderAddressSearchResultInterface.php b/app/code/Magento/Sales/Api/Data/OrderAddressSearchResultInterface.php index 88cba66995a5f807521cca4dacd288466daa413d..1008f41c2095e83a52888548786aaf0a919fe13a 100644 --- a/app/code/Magento/Sales/Api/Data/OrderAddressSearchResultInterface.php +++ b/app/code/Magento/Sales/Api/Data/OrderAddressSearchResultInterface.php @@ -20,4 +20,12 @@ interface OrderAddressSearchResultInterface extends \Magento\Framework\Api\Searc * @return \Magento\Sales\Api\Data\OrderAddressInterface[] Array of collection items. */ public function getItems(); + + /** + * Set collection items. + * + * @param \Magento\Sales\Api\Data\OrderAddressInterface[] $items + * @return $this + */ + public function setItems(array $items = null); } diff --git a/app/code/Magento/Sales/Api/Data/OrderInterface.php b/app/code/Magento/Sales/Api/Data/OrderInterface.php index a2e0b7f5b2ce5574961c80988dda1d8d1b15be1e..b01e0d81d76047e60d7aad7bd8ac56269c5b1a88 100644 --- a/app/code/Magento/Sales/Api/Data/OrderInterface.php +++ b/app/code/Magento/Sales/Api/Data/OrderInterface.php @@ -1068,6 +1068,14 @@ interface OrderInterface extends \Magento\Framework\Api\ExtensibleDataInterface */ public function getEntityId(); + /** + * Sets entity ID. + * + * @param int $entityId + * @return $this + */ + public function setEntityId($entityId); + /** * Gets the external customer ID for the order. * diff --git a/app/code/Magento/Sales/Api/Data/OrderItemSearchResultInterface.php b/app/code/Magento/Sales/Api/Data/OrderItemSearchResultInterface.php index de76ac119af8e751fcf455ded73cb98fb2b5057b..d380b316080c10f678e10c53db1ba75a2224169b 100644 --- a/app/code/Magento/Sales/Api/Data/OrderItemSearchResultInterface.php +++ b/app/code/Magento/Sales/Api/Data/OrderItemSearchResultInterface.php @@ -20,4 +20,12 @@ interface OrderItemSearchResultInterface extends \Magento\Framework\Api\SearchRe * @return \Magento\Sales\Api\Data\OrderItemInterface[] Array of collection items. */ public function getItems(); + + /** + * Set collection items. + * + * @param \Magento\Sales\Api\Data\OrderItemInterface[] $items + * @return $this + */ + public function setItems(array $items = null); } diff --git a/app/code/Magento/Sales/Api/Data/OrderPaymentInterface.php b/app/code/Magento/Sales/Api/Data/OrderPaymentInterface.php index 9ea389c850ca297c57ee2ab1e58b0c9e589bf961..d080a1cd765a3446e8ddb3eb285bbed44079b09a 100644 --- a/app/code/Magento/Sales/Api/Data/OrderPaymentInterface.php +++ b/app/code/Magento/Sales/Api/Data/OrderPaymentInterface.php @@ -549,6 +549,14 @@ interface OrderPaymentInterface extends \Magento\Framework\Api\ExtensibleDataInt */ public function getEntityId(); + /** + * Sets entity ID. + * + * @param int $entityId + * @return $this + */ + public function setEntityId($entityId); + /** * Gets the last transaction ID for the order payment. * diff --git a/app/code/Magento/Sales/Api/Data/OrderPaymentSearchResultInterface.php b/app/code/Magento/Sales/Api/Data/OrderPaymentSearchResultInterface.php index 13999f243c23800f22f18d3da9b00b2f2216ea28..2e0d8d19cc8866cdb50287f5c6c3f4adf38be689 100644 --- a/app/code/Magento/Sales/Api/Data/OrderPaymentSearchResultInterface.php +++ b/app/code/Magento/Sales/Api/Data/OrderPaymentSearchResultInterface.php @@ -20,4 +20,12 @@ interface OrderPaymentSearchResultInterface extends \Magento\Framework\Api\Searc * @return \Magento\Sales\Api\Data\OrderPaymentInterface[] Array of collection items. */ public function getItems(); + + /** + * Set collection items. + * + * @param \Magento\Sales\Api\Data\OrderPaymentInterface[] $items + * @return $this + */ + public function setItems(array $items = null); } diff --git a/app/code/Magento/Sales/Api/Data/OrderStatusHistoryInterface.php b/app/code/Magento/Sales/Api/Data/OrderStatusHistoryInterface.php index 5d88187dc4ebe1a964d3249da4279f768455750c..dafc6547d77052f68cb63ed0d5a531a0b68f2fce 100644 --- a/app/code/Magento/Sales/Api/Data/OrderStatusHistoryInterface.php +++ b/app/code/Magento/Sales/Api/Data/OrderStatusHistoryInterface.php @@ -71,6 +71,14 @@ interface OrderStatusHistoryInterface extends \Magento\Framework\Api\ExtensibleD */ public function getEntityId(); + /** + * Sets entity ID. + * + * @param int $entityId + * @return $this + */ + public function setEntityId($entityId); + /** * Gets the entity name for the order status history. * diff --git a/app/code/Magento/Sales/Api/Data/OrderStatusHistorySearchResultInterface.php b/app/code/Magento/Sales/Api/Data/OrderStatusHistorySearchResultInterface.php index aef58312b999db2e2aff4494dc4a744e539ad9e3..01b15f1bf39ab7585ce6fb772de30fc5f11a5bfa 100644 --- a/app/code/Magento/Sales/Api/Data/OrderStatusHistorySearchResultInterface.php +++ b/app/code/Magento/Sales/Api/Data/OrderStatusHistorySearchResultInterface.php @@ -20,4 +20,12 @@ interface OrderStatusHistorySearchResultInterface extends \Magento\Framework\Api * @return \Magento\Sales\Api\Data\OrderStatusHistoryInterface[] Array of collection items. */ public function getItems(); + + /** + * Set collection items. + * + * @param \Magento\Sales\Api\Data\OrderStatusHistoryInterface[] $items + * @return $this + */ + public function setItems(array $items = null); } diff --git a/app/code/Magento/Sales/Api/Data/ShipmentCommentInterface.php b/app/code/Magento/Sales/Api/Data/ShipmentCommentInterface.php index 6b7e09789811e2dad13093642e0fffe0723fe769..56346939103c84913e7bd883235b69e97fce9463 100644 --- a/app/code/Magento/Sales/Api/Data/ShipmentCommentInterface.php +++ b/app/code/Magento/Sales/Api/Data/ShipmentCommentInterface.php @@ -62,6 +62,14 @@ interface ShipmentCommentInterface extends \Magento\Framework\Api\ExtensibleData */ public function getEntityId(); + /** + * Sets entity ID. + * + * @param int $entityId + * @return $this + */ + public function setEntityId($entityId); + /** * Gets the is-customer-notified flag value for the shipment comment. * diff --git a/app/code/Magento/Sales/Api/Data/ShipmentCommentSearchResultInterface.php b/app/code/Magento/Sales/Api/Data/ShipmentCommentSearchResultInterface.php index 92be1196ff41458e1bd3ca85c2c2d5a94b60fbe8..6fa9ff5b0f5dbe8fb23d26f0ca928b130a168a1a 100644 --- a/app/code/Magento/Sales/Api/Data/ShipmentCommentSearchResultInterface.php +++ b/app/code/Magento/Sales/Api/Data/ShipmentCommentSearchResultInterface.php @@ -19,4 +19,12 @@ interface ShipmentCommentSearchResultInterface extends \Magento\Framework\Api\Se * @return \Magento\Sales\Api\Data\ShipmentCommentInterface[] Array of collection items. */ public function getItems(); + + /** + * Set collection items. + * + * @param \Magento\Sales\Api\Data\ShipmentCommentInterface[] $items + * @return $this + */ + public function setItems(array $items = null); } diff --git a/app/code/Magento/Sales/Api/Data/ShipmentInterface.php b/app/code/Magento/Sales/Api/Data/ShipmentInterface.php index 4f4b3e4d637a7407281767366c8b437cc7aa6162..dbd2854e9ce220d14bf785de3ee60339336d619a 100644 --- a/app/code/Magento/Sales/Api/Data/ShipmentInterface.php +++ b/app/code/Magento/Sales/Api/Data/ShipmentInterface.php @@ -124,6 +124,14 @@ interface ShipmentInterface extends \Magento\Framework\Api\ExtensibleDataInterfa */ public function getEntityId(); + /** + * Sets entity ID. + * + * @param int $entityId + * @return $this + */ + public function setEntityId($entityId); + /** * Gets the increment ID for the shipment. * @@ -209,6 +217,14 @@ interface ShipmentInterface extends \Magento\Framework\Api\ExtensibleDataInterfa */ public function getItems(); + /** + * Sets the items for the shipment. + * + * @param \Magento\Sales\Api\Data\ShipmentItemInterface[] $items + * @return $this + */ + public function setItems($items); + /** * Gets the tracks for the shipment. * @@ -216,6 +232,14 @@ interface ShipmentInterface extends \Magento\Framework\Api\ExtensibleDataInterfa */ public function getTracks(); + /** + * Sets the tracks for the shipment. + * + * @param \Magento\Sales\Api\Data\ShipmentTrackInterface[] $tracks + * @return $this + */ + public function setTracks($tracks); + /** * Gets the comments for the shipment. * @@ -223,6 +247,14 @@ interface ShipmentInterface extends \Magento\Framework\Api\ExtensibleDataInterfa */ public function getComments(); + /** + * Sets the comments for the shipment. + * + * @param \Magento\Sales\Api\Data\ShipmentCommentInterface[] $comments + * @return $this + */ + public function setComments(array $comments = null); + /** * Sets the store ID for the shipment. * diff --git a/app/code/Magento/Sales/Api/Data/ShipmentItemInterface.php b/app/code/Magento/Sales/Api/Data/ShipmentItemInterface.php index fe4d8b7bf8b9ea9a60064a6032fe394138ac9ded..5b78e92571050f0a0cb7f40f83c3969f9916c54b 100644 --- a/app/code/Magento/Sales/Api/Data/ShipmentItemInterface.php +++ b/app/code/Magento/Sales/Api/Data/ShipmentItemInterface.php @@ -86,6 +86,14 @@ interface ShipmentItemInterface extends \Magento\Framework\Api\ExtensibleDataInt */ public function getEntityId(); + /** + * Sets entity ID. + * + * @param int $entityId + * @return $this + */ + public function setEntityId($entityId); + /** * Gets the name for the shipment item. * diff --git a/app/code/Magento/Sales/Api/Data/ShipmentItemSearchResultInterface.php b/app/code/Magento/Sales/Api/Data/ShipmentItemSearchResultInterface.php index a0a9d4e012965df4d1e52115b8b63b67db02446c..f709fe623aa57a499825e509e813748f75f63c68 100644 --- a/app/code/Magento/Sales/Api/Data/ShipmentItemSearchResultInterface.php +++ b/app/code/Magento/Sales/Api/Data/ShipmentItemSearchResultInterface.php @@ -19,4 +19,12 @@ interface ShipmentItemSearchResultInterface extends \Magento\Framework\Api\Searc * @return \Magento\Sales\Api\Data\ShipmentItemInterface[] Array of collection items. */ public function getItems(); + + /** + * Set collection items. + * + * @param \Magento\Sales\Api\Data\ShipmentItemInterface[] $items + * @return $this + */ + public function setItems(array $items = null); } diff --git a/app/code/Magento/Sales/Api/Data/ShipmentSearchResultInterface.php b/app/code/Magento/Sales/Api/Data/ShipmentSearchResultInterface.php index e6efad7c0495076dc612274dd9ab22fbd3cff6c1..828de5d7be7b406fb7efe7900d2315645e2f6238 100644 --- a/app/code/Magento/Sales/Api/Data/ShipmentSearchResultInterface.php +++ b/app/code/Magento/Sales/Api/Data/ShipmentSearchResultInterface.php @@ -21,4 +21,12 @@ interface ShipmentSearchResultInterface extends SearchResultsInterface * @return \Magento\Sales\Api\Data\ShipmentInterface[] Array of collection items. */ public function getItems(); + + /** + * Set collection items. + * + * @param \Magento\Sales\Api\Data\ShipmentInterface[] $items + * @return $this + */ + public function setItems(array $items = null); } diff --git a/app/code/Magento/Sales/Api/Data/ShipmentTrackInterface.php b/app/code/Magento/Sales/Api/Data/ShipmentTrackInterface.php index c19abc6ed0d8263ddc4fb8308a0ff6a3a5bc045a..7160fc3fff2d8a7c415d5a143f5192ed08dbc9cb 100644 --- a/app/code/Magento/Sales/Api/Data/ShipmentTrackInterface.php +++ b/app/code/Magento/Sales/Api/Data/ShipmentTrackInterface.php @@ -90,6 +90,14 @@ interface ShipmentTrackInterface extends \Magento\Framework\Api\ExtensibleDataIn */ public function getEntityId(); + /** + * Sets entity ID. + * + * @param int $entityId + * @return $this + */ + public function setEntityId($entityId); + /** * Gets the order_id for the shipment package. * diff --git a/app/code/Magento/Sales/Api/Data/ShipmentTrackSearchResultInterface.php b/app/code/Magento/Sales/Api/Data/ShipmentTrackSearchResultInterface.php index fe70e4c91a5ca04c0d1c6ff3d9b7b66cf9b78b32..26187c86ce99d7d11b69db5a13ea245c8624434b 100644 --- a/app/code/Magento/Sales/Api/Data/ShipmentTrackSearchResultInterface.php +++ b/app/code/Magento/Sales/Api/Data/ShipmentTrackSearchResultInterface.php @@ -20,4 +20,12 @@ interface ShipmentTrackSearchResultInterface extends \Magento\Framework\Api\Sear * @return \Magento\Sales\Api\Data\ShipmentTrackInterface[] Array of collection items. */ public function getItems(); + + /** + * Set collection items. + * + * @param \Magento\Sales\Api\Data\ShipmentTrackInterface[] $items + * @return $this + */ + public function setItems(array $items = null); } diff --git a/app/code/Magento/Sales/Api/Data/TransactionSearchResultInterface.php b/app/code/Magento/Sales/Api/Data/TransactionSearchResultInterface.php index 6a7f7380ef3b0e60c85ec27d46454e3caa6f3930..414b5d05d27d0592b88c24b77d836c3242036e90 100644 --- a/app/code/Magento/Sales/Api/Data/TransactionSearchResultInterface.php +++ b/app/code/Magento/Sales/Api/Data/TransactionSearchResultInterface.php @@ -18,4 +18,12 @@ interface TransactionSearchResultInterface extends \Magento\Framework\Api\Search * @return \Magento\Sales\Api\Data\TransactionInterface[] Array of collection items. */ public function getItems(); + + /** + * Set collection items. + * + * @param \Magento\Sales\Api\Data\TransactionInterface[] $items + * @return $this + */ + public function setItems(array $items = null); } diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Items/Grid.php b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Items/Grid.php index 9feb4b05070fac34847483a29932b4c70c118cc9..5fd71bba8d3b26dac8e2e04da72d3b45bdab6f35 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Items/Grid.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Items/Grid.php @@ -286,9 +286,12 @@ class Grid extends \Magento\Sales\Block\Adminhtml\Order\Create\AbstractCreate { $address = $this->getQuoteAddress(); if ($this->displayTotalsIncludeTax()) { - return $address->getSubtotal() + $address->getTaxAmount() + $this->getDiscountAmount(); + return $address->getSubtotal() + + $address->getTaxAmount() + + $address->getDiscountAmount() + + $address->getHiddenTaxAmount(); } else { - return $address->getSubtotal() + $this->getDiscountAmount(); + return $address->getSubtotal() + $address->getDiscountAmount(); } } diff --git a/app/code/Magento/Sales/Model/AdminOrder/Create.php b/app/code/Magento/Sales/Model/AdminOrder/Create.php index 5194db0369e315e2608b3ace3fc17e5d3c0a862f..4327c9d91d9a645a89e91f0fe20f3a47510c423e 100644 --- a/app/code/Magento/Sales/Model/AdminOrder/Create.php +++ b/app/code/Magento/Sales/Model/AdminOrder/Create.php @@ -1548,7 +1548,11 @@ class Create extends \Magento\Framework\Object implements \Magento\Checkout\Mode $data = $form->extractData($request); $data = $form->restoreData($data); $customer = $this->customerFactory->create(); - $this->dataObjectHelper->populateWithArray($customer, $data); + $this->dataObjectHelper->populateWithArray( + $customer, + $data, + '\Magento\Customer\Api\Data\CustomerInterface' + ); $this->getQuote()->updateCustomerData($customer); $data = []; @@ -1666,7 +1670,11 @@ class Create extends \Magento\Framework\Object implements \Magento\Checkout\Mode } } - $this->dataObjectHelper->populateWithArray($customer, $data); + $this->dataObjectHelper->populateWithArray( + $customer, + $data, + '\Magento\Customer\Api\Data\CustomerInterface' + ); return $customer; } diff --git a/app/code/Magento/Sales/Model/Order/Address.php b/app/code/Magento/Sales/Model/Order/Address.php index 971183c49f58fff688e133cae97a7d8074fb02ba..a5e853f9f3ba7c0b7f0a5a59272ca90c7876eb5f 100644 --- a/app/code/Magento/Sales/Model/Order/Address.php +++ b/app/code/Magento/Sales/Model/Order/Address.php @@ -219,6 +219,17 @@ class Address extends AbstractAddress implements OrderAddressInterface return $this->getData(OrderAddressInterface::ENTITY_ID); } + /** + * Sets the ID for the order address. + * + * @param int $entityId + * @return $this + */ + public function setEntityId($entityId) + { + return $this->setData(OrderAddressInterface::ENTITY_ID, $entityId); + } + /** * Returns fax * diff --git a/app/code/Magento/Sales/Model/Order/Creditmemo.php b/app/code/Magento/Sales/Model/Order/Creditmemo.php index ec25b06e53aed9ee4d9d1bc35dcdb771cbf182bb..0b75b3c314eebc86694846fef6d0362ab273e911 100644 --- a/app/code/Magento/Sales/Model/Order/Creditmemo.php +++ b/app/code/Magento/Sales/Model/Order/Creditmemo.php @@ -20,9 +20,6 @@ use Magento\Sales\Model\EntityInterface; * * @method \Magento\Sales\Model\Resource\Order\Creditmemo _getResource() * @method \Magento\Sales\Model\Resource\Order\Creditmemo getResource() - * @method \Magento\Sales\Model\Order\Creditmemo setBaseAdjustmentNegative(float $value) - * @method \Magento\Sales\Model\Order\Creditmemo setBaseAdjustmentPositive(float $value) - * @method \Magento\Sales\Model\Order\Creditmemo setTransactionId(string $value) * @method \Magento\Sales\Model\Order\Creditmemo setCreatedAt(string $value) * @SuppressWarnings(PHPMD.ExcessivePublicCount) * @SuppressWarnings(PHPMD.ExcessiveClassComplexity) @@ -856,6 +853,17 @@ class Creditmemo extends AbstractModel implements EntityInterface, CreditmemoInt return $this->getData(CreditmemoInterface::BASE_ADJUSTMENT_NEGATIVE); } + /** + * Set base_adjustment_negative + * + * @param float $baseAdjustmentNegative + * @return $this + */ + public function setBaseAdjustmentNegative($baseAdjustmentNegative) + { + return $this->setData(CreditmemoInterface::BASE_ADJUSTMENT_NEGATIVE, $baseAdjustmentNegative); + } + /** * Returns base_adjustment_positive * @@ -866,6 +874,17 @@ class Creditmemo extends AbstractModel implements EntityInterface, CreditmemoInt return $this->getData(CreditmemoInterface::BASE_ADJUSTMENT_POSITIVE); } + /** + * Set base_adjustment_positive + * + * @param float $baseAdjustmentPositive + * @return $this + */ + public function setBaseAdjustmentPositive($baseAdjustmentPositive) + { + return $this->setData(CreditmemoInterface::BASE_ADJUSTMENT_POSITIVE, $baseAdjustmentPositive); + } + /** * Returns base_currency_code * @@ -1246,6 +1265,17 @@ class Creditmemo extends AbstractModel implements EntityInterface, CreditmemoInt return $this->getData(CreditmemoInterface::TRANSACTION_ID); } + /** + * Sets the credit memo transaction ID. + * + * @param string $transactionId + * @return $this + */ + public function setTransactionId($transactionId) + { + return $this->setData(CreditmemoInterface::TRANSACTION_ID, $transactionId); + } + /** * Returns updated_at * diff --git a/app/code/Magento/Sales/Model/Order/Creditmemo/Total/Shipping.php b/app/code/Magento/Sales/Model/Order/Creditmemo/Total/Shipping.php index 36b6ddd66fb1f49dcaf169bb51d87ca9b65ee04d..a5cbd3431b33765263d3fd6e5b9bee27ea9b42ea 100644 --- a/app/code/Magento/Sales/Model/Order/Creditmemo/Total/Shipping.php +++ b/app/code/Magento/Sales/Model/Order/Creditmemo/Total/Shipping.php @@ -12,37 +12,21 @@ use Magento\Framework\Pricing\PriceCurrencyInterface; */ class Shipping extends AbstractTotal { - /** - * @var \Magento\Store\Model\StoreManagerInterface - */ - protected $_storeManager; - - /** - * @var \Magento\Tax\Model\Config - */ - protected $_taxConfig; - /** * @var PriceCurrencyInterface */ protected $priceCurrency; /** - * @param \Magento\Store\Model\StoreManagerInterface $storeManager - * @param \Magento\Tax\Model\Config $taxConfig * @param PriceCurrencyInterface $priceCurrency * @param array $data */ public function __construct( - \Magento\Store\Model\StoreManagerInterface $storeManager, - \Magento\Tax\Model\Config $taxConfig, PriceCurrencyInterface $priceCurrency, array $data = [] ) { parent::__construct($data); $this->priceCurrency = $priceCurrency; - $this->_storeManager = $storeManager; - $this->_taxConfig = $taxConfig; } /** @@ -56,12 +40,12 @@ class Shipping extends AbstractTotal $allowedAmount = $order->getShippingAmount() - $order->getShippingRefunded(); $baseAllowedAmount = $order->getBaseShippingAmount() - $order->getBaseShippingRefunded(); - $shipping = $order->getShippingAmount(); - $baseShipping = $order->getBaseShippingAmount(); - $shippingInclTax = $order->getShippingInclTax(); - $baseShippingInclTax = $order->getBaseShippingInclTax(); + $orderShippingAmount = $order->getShippingAmount(); + $orderBaseShippingAmount = $order->getBaseShippingAmount(); + $orderShippingInclTax = $order->getShippingInclTax(); + $orderBaseShippingInclTax = $order->getBaseShippingInclTax(); - $isShippingInclTax = $this->_taxConfig->displaySalesShippingInclTax($order->getStoreId()); + $shippingAmount = $baseShippingAmount = $shippingInclTax = $baseShippingInclTax = 0; /** * Check if shipping amount was specified (from invoice or another source). @@ -69,33 +53,29 @@ class Shipping extends AbstractTotal */ if ($creditmemo->hasBaseShippingAmount()) { $baseShippingAmount = $this->priceCurrency->round($creditmemo->getBaseShippingAmount()); - if ($isShippingInclTax && $baseShippingInclTax != 0) { - $part = $baseShippingAmount / $baseShippingInclTax; - $shippingInclTax = $this->priceCurrency->round($shippingInclTax * $part); - $baseShippingInclTax = $baseShippingAmount; - $baseShippingAmount = $this->priceCurrency->round($baseShipping * $part); - } /* * Rounded allowed shipping refund amount is the highest acceptable shipping refund amount. * Shipping refund amount shouldn't cause errors, if it doesn't exceed that limit. * Note: ($x < $y + 0.0001) means ($x <= $y) for floats */ if ($baseShippingAmount < $this->priceCurrency->round($baseAllowedAmount) + 0.0001) { + $ratio = 0; + if ($orderBaseShippingAmount > 0) { + $ratio = $baseShippingAmount / $orderBaseShippingAmount; + } /* * Shipping refund amount should be equated to allowed refund amount, * if it exceeds that limit. * Note: ($x > $y - 0.0001) means ($x >= $y) for floats */ if ($baseShippingAmount > $baseAllowedAmount - 0.0001) { - $shipping = $allowedAmount; - $baseShipping = $baseAllowedAmount; + $shippingAmount = $allowedAmount; + $baseShippingAmount = $baseAllowedAmount; } else { - if ($baseShipping != 0) { - $shipping = $shipping * $baseShippingAmount / $baseShipping; - } - $shipping = $this->priceCurrency->round($shipping); - $baseShipping = $baseShippingAmount; + $shippingAmount = $this->priceCurrency->round($orderShippingAmount * $ratio); } + $shippingInclTax = $this->priceCurrency->round($orderShippingInclTax * $ratio); + $baseShippingInclTax = $this->priceCurrency->round($orderBaseShippingInclTax * $ratio); } else { $baseAllowedAmount = $order->getBaseCurrency()->format($baseAllowedAmount, null, false); throw new \Magento\Framework\Exception\LocalizedException( @@ -103,26 +83,25 @@ class Shipping extends AbstractTotal ); } } else { - if ($baseShipping != 0) { - $allowedTaxAmount = $order->getShippingTaxAmount() - $order->getShippingTaxRefunded(); - $baseAllowedTaxAmount = $order->getBaseShippingTaxAmount() - $order->getBaseShippingTaxRefunded(); + $shippingAmount = $allowedAmount; + $baseShippingAmount = $baseAllowedAmount; - $shippingInclTax = $this->priceCurrency->round($allowedAmount + $allowedTaxAmount); - $baseShippingInclTax = $this->priceCurrency->round( - $baseAllowedAmount + $baseAllowedTaxAmount - ); - } - $shipping = $allowedAmount; - $baseShipping = $baseAllowedAmount; + $allowedTaxAmount = $order->getShippingTaxAmount() - $order->getShippingTaxRefunded(); + $baseAllowedTaxAmount = $order->getBaseShippingTaxAmount() - $order->getBaseShippingTaxRefunded(); + + $shippingInclTax = $this->priceCurrency->round($allowedAmount + $allowedTaxAmount); + $baseShippingInclTax = $this->priceCurrency->round( + $baseAllowedAmount + $baseAllowedTaxAmount + ); } - $creditmemo->setShippingAmount($shipping); - $creditmemo->setBaseShippingAmount($baseShipping); + $creditmemo->setShippingAmount($shippingAmount); + $creditmemo->setBaseShippingAmount($baseShippingAmount); $creditmemo->setShippingInclTax($shippingInclTax); $creditmemo->setBaseShippingInclTax($baseShippingInclTax); - $creditmemo->setGrandTotal($creditmemo->getGrandTotal() + $shipping); - $creditmemo->setBaseGrandTotal($creditmemo->getBaseGrandTotal() + $baseShipping); + $creditmemo->setGrandTotal($creditmemo->getGrandTotal() + $shippingAmount); + $creditmemo->setBaseGrandTotal($creditmemo->getBaseGrandTotal() + $baseShippingAmount); return $this; } } diff --git a/app/code/Magento/Sales/Model/Order/Creditmemo/Total/Tax.php b/app/code/Magento/Sales/Model/Order/Creditmemo/Total/Tax.php index b3a9ecaab603c5c7f563607fce082e2db9e4e329..3502252f9cad1d1112c56b606f1f76295c4ecb41 100644 --- a/app/code/Magento/Sales/Model/Order/Creditmemo/Total/Tax.php +++ b/app/code/Magento/Sales/Model/Order/Creditmemo/Total/Tax.php @@ -11,6 +11,7 @@ class Tax extends AbstractTotal * @param \Magento\Sales\Model\Order\Creditmemo $creditmemo * @return $this * + * @SuppressWarnings(PHPMD.NPathComplexity) * @SuppressWarnings(PHPMD.CyclomaticComplexity) * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ @@ -64,6 +65,7 @@ class Tax extends AbstractTotal } } + $isPartialShippingRefunded = false; if ($invoice = $creditmemo->getInvoice()) { //recalculate tax amounts in case if refund shipping value was changed if ($order->getBaseShippingAmount() && $creditmemo->getBaseShippingAmount()) { @@ -80,6 +82,9 @@ class Tax extends AbstractTotal $baseTotalHiddenTax = $creditmemo->roundPrice($baseTotalHiddenTax, 'base'); $shippingHiddenTaxAmount = $creditmemo->roundPrice($shippingHiddenTaxAmount); $baseShippingHiddenTaxAmount = $creditmemo->roundPrice($baseShippingHiddenTaxAmount, 'base'); + if ($taxFactor < 1 && $invoice->getShippingTaxAmount() > 0) { + $isPartialShippingRefunded = true; + } $totalTax += $shippingTaxAmount; $baseTotalTax += $baseShippingTaxAmount; } @@ -107,6 +112,9 @@ class Tax extends AbstractTotal $baseShippingTaxAmount = $creditmemo->roundPrice($baseShippingTaxAmount, 'base'); $shippingHiddenTaxAmount = $creditmemo->roundPrice($shippingHiddenTaxAmount); $baseShippingHiddenTaxAmount = $creditmemo->roundPrice($baseShippingHiddenTaxAmount, 'base'); + if ($part < 1 && $order->getShippingTaxAmount() > 0) { + $isPartialShippingRefunded = true; + } } elseif ($shippingDelta == $creditmemo->getBaseShippingAmount()) { $shippingTaxAmount = $order->getShippingTaxAmount() - $order->getShippingTaxRefunded(); $baseShippingTaxAmount = $order->getBaseShippingTaxAmount() - $order->getBaseShippingTaxRefunded(); @@ -136,7 +144,7 @@ class Tax extends AbstractTotal $creditmemo->getBaseShippingHiddenTaxAmnt() - $creditmemo->getBaseHiddenTaxAmount(); - if ($creditmemo->isLast()) { + if ($creditmemo->isLast() && !$isPartialShippingRefunded) { $totalTax = $allowedTax; $baseTotalTax = $allowedBaseTax; $totalHiddenTax = $allowedHiddenTax; diff --git a/app/code/Magento/Sales/Model/Order/Invoice.php b/app/code/Magento/Sales/Model/Order/Invoice.php index 32729252dea4a42147af1de830a84135a0004aed..ab6e124d48c21d0e3d89fe96b6430d365f4afc48 100644 --- a/app/code/Magento/Sales/Model/Order/Invoice.php +++ b/app/code/Magento/Sales/Model/Order/Invoice.php @@ -11,7 +11,6 @@ use Magento\Sales\Model\AbstractModel; use Magento\Sales\Model\EntityInterface; /** - * @method \Magento\Sales\Model\Order\Invoice setTransactionId(string $value) * @method \Magento\Sales\Model\Order\Invoice setCreatedAt(string $value) * @SuppressWarnings(PHPMD.ExcessivePublicCount) * @SuppressWarnings(PHPMD.ExcessiveClassComplexity) @@ -1201,6 +1200,17 @@ class Invoice extends AbstractModel implements EntityInterface, InvoiceInterface return $this->getData(InvoiceInterface::TRANSACTION_ID); } + /** + * Sets transaction_id + * + * @param string $transactionId + * @return $this + */ + public function setTransactionId($transactionId) + { + return $this->setData(InvoiceInterface::TRANSACTION_ID, $transactionId); + } + /** * Returns updated_at * diff --git a/app/code/Magento/Sales/Model/Order/Shipment.php b/app/code/Magento/Sales/Model/Order/Shipment.php index 4091779a2d5a30a73b484629b9f389e47738bd9e..0e5a3c5cf9249f742dd1fbb51bed1d05d951c589 100644 --- a/app/code/Magento/Sales/Model/Order/Shipment.php +++ b/app/code/Magento/Sales/Model/Order/Shipment.php @@ -566,6 +566,17 @@ class Shipment extends AbstractModel implements EntityInterface, ShipmentInterfa return $this->getData(ShipmentInterface::ITEMS); } + /** + * Sets items + * + * @param mixed $items + * @return $this + */ + public function setItems($items) + { + return $this->setData(ShipmentInterface::ITEMS, $items); + } + /** * Returns tracks * @@ -585,6 +596,17 @@ class Shipment extends AbstractModel implements EntityInterface, ShipmentInterfa return $this->getData(ShipmentInterface::TRACKS); } + /** + * Returns tracks + * + * @param \Magento\Sales\Api\Data\ShipmentTrackInterface[] $tracks + * @return $this + */ + public function setTracks($tracks) + { + return $this->setData(ShipmentInterface::TRACKS, $tracks); + } + /** * Returns billing_address_id * @@ -705,6 +727,17 @@ class Shipment extends AbstractModel implements EntityInterface, ShipmentInterfa return $this->getData(ShipmentInterface::COMMENTS); } + /** + * Sets comments + * + * @param \Magento\Sales\Api\Data\ShipmentCommentInterface[] $comments + * @return $this + */ + public function setComments(array $comments = null) + { + return $this->setData(ShipmentInterface::COMMENTS, $comments); + } + //@codeCoverageIgnoreStart /** * {@inheritdoc} diff --git a/app/code/Magento/Sales/Model/Resource/Collection/AbstractCollection.php b/app/code/Magento/Sales/Model/Resource/Collection/AbstractCollection.php index 7fbc7bef512eae5ed527a9893b487ef71ef552be..c2419e03710bf69921a5d74d346a1917369ad3c7 100644 --- a/app/code/Magento/Sales/Model/Resource/Collection/AbstractCollection.php +++ b/app/code/Magento/Sales/Model/Resource/Collection/AbstractCollection.php @@ -180,6 +180,18 @@ abstract class AbstractCollection extends \Magento\Framework\Model\Resource\Db\C return null; } + /** + * Set search criteria. + * + * @param \Magento\Framework\Api\SearchCriteriaInterface $searchCriteria + * @return $this + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function setSearchCriteria(\Magento\Framework\Api\SearchCriteriaInterface $searchCriteria = null) + { + return $this; + } + /** * Get total count. * @@ -189,4 +201,28 @@ abstract class AbstractCollection extends \Magento\Framework\Model\Resource\Db\C { return $this->getSize(); } + + /** + * Set total count. + * + * @param int $totalCount + * @return $this + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function setTotalCount($totalCount) + { + return $this; + } + + /** + * Set items list. + * + * @param \Magento\Framework\Api\ExtensibleDataInterface[] $items + * @return $this + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function setItems(array $items = null) + { + return $this; + } } diff --git a/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/Create/Items/GridTest.php b/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/Create/Items/GridTest.php index eab1ad0f086d745ef77b2a96870761371c910af1..0c948763c81bafcea06f1b8e2acd9679aa6f05e5 100644 --- a/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/Create/Items/GridTest.php +++ b/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/Create/Items/GridTest.php @@ -339,6 +339,7 @@ class GridTest extends \PHPUnit_Framework_TestCase $this->assertEquals($html, $grid->getItemRowTotalHtml($this->itemMock)); } + public function testGetItemRowTotalWithDiscountHtml() { $html = '$34.28'; @@ -360,4 +361,81 @@ class GridTest extends \PHPUnit_Framework_TestCase $this->assertEquals($html, $grid->getItemRowTotalWithDiscountHtml($this->itemMock)); } + + /** + * @param array $orderData + * @param bool $displayTotalsIncludeTax + * @param float $expected + * @dataProvider getSubtotalWithDiscountDataProvider + */ + public function testGetSubtotalWithDiscount($orderData, $displayTotalsIncludeTax, $expected) + { + $quoteAddressMock = $this->getMock( + '\Magento\Quote\Model\Quote\Address', + ['getSubtotal', 'getTaxAmount','getHiddenTaxAmount','getDiscountAmount'], + [], + '', + false + ); + $gridMock = $this->getMock( + 'Magento\Sales\Block\Adminhtml\Order\Create\Items\Grid', + ['getQuoteAddress','displayTotalsIncludeTax'], + [], + '', + false + ); + + $gridMock->expects($this->any())->method('getQuoteAddress') + ->will($this->returnValue($quoteAddressMock)); + $gridMock->expects($this->any())->method('displayTotalsIncludeTax') + ->will($this->returnValue($displayTotalsIncludeTax)); + + $quoteAddressMock->expects($this->once()) + ->method('getSubtotal') + ->will($this->returnValue($orderData['subTotal'])); + + $quoteAddressMock->expects($this->any()) + ->method('getTaxAmount') + ->will($this->returnValue($orderData['taxAmount'])); + + $quoteAddressMock->expects($this->any()) + ->method('getHiddenTaxAmount') + ->will($this->returnValue($orderData['hiddenTaxAmount'])); + + $quoteAddressMock->expects($this->once()) + ->method('getDiscountAmount') + ->will($this->returnValue($orderData['discountAmount'])); + + $this->assertEquals($expected, $gridMock->getSubtotalWithDiscount()); + } + + /** + * @return array + */ + public function getSubtotalWithDiscountDataProvider() + { + $result = []; + $result['displayTotalsIncludeTaxTrue'] = [ + 'orderData' => [ + 'subTotal' => 32.59, + 'taxAmount' => 8.2, + 'hiddenTaxAmount' => 1.72, + 'discountAmount' => -10.24 + ], + 'displayTotalsIncludeTax'=> true, + 'expected' => 32.27 + ]; + $result['displayTotalsIncludeTaxFalse'] = [ + 'orderData' => [ + 'subTotal' => 66.67, + 'taxAmount' => 20, + 'hiddenTaxAmount' => 8, + 'discountAmount' => -34.67 + ], + 'displayTotalsIncludeTax'=> false, + 'expected' => 32 + ]; + return $result; + } + } diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Creditmemo/Total/ShippingTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Creditmemo/Total/ShippingTest.php new file mode 100644 index 0000000000000000000000000000000000000000..6017ebc09a0c24e788cd7bb2fe3cc8c7905cef54 --- /dev/null +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Creditmemo/Total/ShippingTest.php @@ -0,0 +1,277 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +// @codingStandardsIgnoreFile + +namespace Magento\Sales\Test\Unit\Model\Order\Creditmemo\Total; + +class ShippingTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $creditmemoMock; + + /** + * @var \Magento\Sales\Model\Order\Creditmemo\Total\Shipping + */ + protected $shippingCollector; + + public function setUp() + { + $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); + + $this->creditmemoMock = $this->getMockBuilder('Magento\Sales\Model\Order\Creditmemo') + ->disableOriginalConstructor() + ->setMethods( + [ + 'getOrder', + 'hasBaseShippingAmount', + 'getBaseShippingAmount', + 'setShippingAmount', + 'setBaseShippingAmount', + 'setShippingInclTax', + 'setBaseShippingInclTax', + 'setGrandTotal', + 'setBaseGrandTotal', + 'getGrandTotal', + 'getBaseGrandTotal', + ] + )->getMock(); + + $priceCurrencyMock = $this->getMock('Magento\Framework\Pricing\PriceCurrencyInterface'); + $priceCurrencyMock->expects($this->any()) + ->method('round') + ->willReturnCallback( + function ($amount) { + return round($amount, 2); + } + ); + + $this->shippingCollector = $objectManager->getObject( + 'Magento\Sales\Model\Order\Creditmemo\Total\Shipping', + [ + 'priceCurrency' => $priceCurrencyMock, + ] + ); + } + + /** + * Test the case where shipping amount specified is greater than shipping amount allowed + * + * @expectedException \Magento\Framework\Exception\LocalizedException + * @expectedExceptionMessage Maximum shipping amount allowed to refund is: 5 + */ + public function testCollectException() + { + $orderShippingAmount = 10; + $orderShippingRefunded = 5; + $allowedShippingAmount = $orderShippingAmount - $orderShippingRefunded; + $creditmemoShippingAmount = 6; + $currencyMock = $this->getMockBuilder('Magento\Directory\Model\Currency') + ->disableOriginalConstructor() + ->getMock(); + $currencyMock->expects($this->once()) + ->method('format') + ->with($allowedShippingAmount, null, false) + ->willReturn($allowedShippingAmount); + $order = new \Magento\Framework\Object( + [ + 'base_shipping_amount' => $orderShippingAmount, + 'base_shipping_refunded' => $orderShippingRefunded, + 'base_currency' => $currencyMock, + ] + ); + + $this->creditmemoMock->expects($this->once()) + ->method('getOrder') + ->willReturn($order); + + $this->creditmemoMock->expects($this->once()) + ->method('hasBaseShippingAmount') + ->willReturn(true); + $this->creditmemoMock->expects($this->once()) + ->method('getBaseShippingAmount') + ->willReturn($creditmemoShippingAmount); + + + $this->shippingCollector->collect($this->creditmemoMock); + } + + public function testCollectNoSpecifiedShippingAmount() + { + $orderShippingAmount = 10; + $orderShippingRefunded = 5; + $allowedShippingAmount = $orderShippingAmount - $orderShippingRefunded; + $baseOrderShippingAmount = 20; + $baseOrderShippingRefunded = 10; + $baseAllowedShippingAmount = $baseOrderShippingAmount - $baseOrderShippingRefunded; + $shippingTaxAmount = 2; + $shippingTaxAmountRefunded = 1; + $baseShippingTaxAmount = 4; + $baseShippingTaxAmountRefunded = 2; + + $expectedShippingAmountInclTax = $allowedShippingAmount + $shippingTaxAmount - $shippingTaxAmountRefunded; + $expectedBaseShippingAmountInclTax = + $baseAllowedShippingAmount + $baseShippingTaxAmount - $baseShippingTaxAmountRefunded; + $grandTotalBefore = 100; + $baseGrandTotalBefore = 200; + $expectedGrandTotal = $grandTotalBefore + $allowedShippingAmount; + $expectedBaseGrandTtoal = $baseGrandTotalBefore + $baseAllowedShippingAmount; + + $order = new \Magento\Framework\Object( + [ + 'shipping_amount' => $orderShippingAmount, + 'shipping_refunded' => $orderShippingRefunded, + 'base_shipping_amount' => $baseOrderShippingAmount, + 'base_shipping_refunded' => $baseOrderShippingRefunded, + 'shipping_incl_tax' => $orderShippingAmount + $shippingTaxAmount, + 'base_shipping_incl_tax' => $baseOrderShippingAmount + $baseShippingTaxAmount, + 'shipping_tax_amount' => $shippingTaxAmount, + 'shipping_tax_refunded' => $shippingTaxAmountRefunded, + 'base_shipping_tax_amount' => $baseShippingTaxAmount, + 'base_shipping_tax_refunded' => $baseShippingTaxAmountRefunded, + ] + ); + + $this->creditmemoMock->expects($this->once()) + ->method('getOrder') + ->willReturn($order); + + $this->creditmemoMock->expects($this->once()) + ->method('hasBaseShippingAmount') + ->willReturn(false); + + $this->creditmemoMock->expects($this->once()) + ->method('getGrandTotal') + ->willReturn($grandTotalBefore); + $this->creditmemoMock->expects($this->once()) + ->method('getBaseGrandTotal') + ->willReturn($baseGrandTotalBefore); + + //verify + $this->creditmemoMock->expects($this->once()) + ->method('setShippingAmount') + ->with($allowedShippingAmount) + ->willReturnSelf(); + $this->creditmemoMock->expects($this->once()) + ->method('setBaseShippingAmount') + ->with($baseAllowedShippingAmount) + ->willReturnSelf(); + $this->creditmemoMock->expects($this->once()) + ->method('setShippingInclTax') + ->with($expectedShippingAmountInclTax) + ->willReturnSelf(); + $this->creditmemoMock->expects($this->once()) + ->method('setBaseShippingInclTax') + ->with($expectedBaseShippingAmountInclTax) + ->willReturnSelf(); + $this->creditmemoMock->expects($this->once()) + ->method('setGrandTotal') + ->with($expectedGrandTotal) + ->willReturnSelf(); + $this->creditmemoMock->expects($this->once()) + ->method('setBaseGrandTotal') + ->with($expectedBaseGrandTtoal) + ->willReturnSelf(); + + $this->shippingCollector->collect($this->creditmemoMock); + } + + /** + * @param float $ratio + * @dataProvider collectWithSpecifiedShippingAmountDataProvider + */ + public function testCollectWithSpecifiedShippingAmount($ratio) + { + $orderShippingAmount = 10; + $orderShippingAmountRefunded = 5; + $baseOrderShippingAmount = 20; + $baseOrderShippingAmountRefunded = 10; + $shippingTaxAmount = 2; + $baseShippingTaxAmount = 4; + $orderShippingInclTax = $orderShippingAmount + $shippingTaxAmount; + $baseOrderShippingInclTax = $baseOrderShippingAmount + $baseShippingTaxAmount; + + //refund half + $creditmemoBaseShippingAmount = $ratio * $baseOrderShippingAmount; + + $expectedShippingAmount = $orderShippingAmount * $ratio; + $expectedShippingAmountInclTax = $orderShippingInclTax * $ratio; + $expectedBaseShippingAmount = $baseOrderShippingAmount * $ratio; + $expectedBaseShippingAmountInclTax = $baseOrderShippingInclTax * $ratio; + + $grandTotalBefore = 100; + $baseGrandTotalBefore = 200; + $expectedGrandTotal = $grandTotalBefore + $expectedShippingAmount; + $expectedBaseGrandTtoal = $baseGrandTotalBefore + $expectedBaseShippingAmount; + + $order = new \Magento\Framework\Object( + [ + 'shipping_amount' => $orderShippingAmount, + 'shipping_refunded' => $orderShippingAmountRefunded, + 'base_shipping_amount' => $baseOrderShippingAmount, + 'base_shipping_refunded' => $baseOrderShippingAmountRefunded, + 'shipping_incl_tax' => $orderShippingInclTax, + 'base_shipping_incl_tax' => $baseOrderShippingInclTax, + ] + ); + + $this->creditmemoMock->expects($this->once()) + ->method('getOrder') + ->willReturn($order); + + $this->creditmemoMock->expects($this->once()) + ->method('hasBaseShippingAmount') + ->willReturn(true); + $this->creditmemoMock->expects($this->once()) + ->method('getBaseShippingAmount') + ->willReturn($creditmemoBaseShippingAmount); + + $this->creditmemoMock->expects($this->once()) + ->method('getGrandTotal') + ->willReturn($grandTotalBefore); + $this->creditmemoMock->expects($this->once()) + ->method('getBaseGrandTotal') + ->willReturn($baseGrandTotalBefore); + + //verify + $this->creditmemoMock->expects($this->once()) + ->method('setShippingAmount') + ->with($expectedShippingAmount) + ->willReturnSelf(); + $this->creditmemoMock->expects($this->once()) + ->method('setBaseShippingAmount') + ->with($expectedBaseShippingAmount) + ->willReturnSelf(); + $this->creditmemoMock->expects($this->once()) + ->method('setShippingInclTax') + ->with($expectedShippingAmountInclTax) + ->willReturnSelf(); + $this->creditmemoMock->expects($this->once()) + ->method('setBaseShippingInclTax') + ->with($expectedBaseShippingAmountInclTax) + ->willReturnSelf(); + $this->creditmemoMock->expects($this->once()) + ->method('setGrandTotal') + ->with($expectedGrandTotal) + ->willReturnSelf(); + $this->creditmemoMock->expects($this->once()) + ->method('setBaseGrandTotal') + ->with($expectedBaseGrandTtoal) + ->willReturnSelf(); + + $this->shippingCollector->collect($this->creditmemoMock); + } + + public function collectWithSpecifiedShippingAmountDataProvider() + { + return [ + 'half' => [0.5], //This will test the case where specified amount equals maximum allowed amount + 'quarter' => [0.25], + ]; + } +} diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Creditmemo/Total/TaxTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Creditmemo/Total/TaxTest.php index c52603c44591bbd804c8a2ebeed1ad939f517958..cf4124f653cfa2080e3b6f81e51f5fc63e44cabf 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/Creditmemo/Total/TaxTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Creditmemo/Total/TaxTest.php @@ -457,6 +457,81 @@ class TaxTest extends \PHPUnit_Framework_TestCase ], ], ]; + + // scenario 5: 3 items, 3 invoiced, rowtotal of 150 with 8.25 tax rate + // shipping is partially returned + $result['last_partial_creditmemo_with_partial_shipping_refund'] = [ + 'order_data' => [ + 'data_fields' => [ + 'shipping_tax_amount' => 1.24, + 'base_shipping_tax_amount' => 1.24, + 'shipping_tax_refunded' => 0, + 'base_shipping_tax_refunded' => 0, + 'shipping_hidden_tax_amount' => 0, + 'base_shipping_hidden_tax_amount' => 0, + 'tax_amount' => 16.09, + 'base_tax_amount' => 16.09, + 'tax_invoiced' => 16.09, + 'base_tax_invoiced' => 16.09, + 'tax_refunded' => 9.9, + 'base_tax_refunded' => 9.9, + 'shipping_amount' => 15, + 'shipping_amount_refunded' => 0, + 'base_shipping_amount' => 15, + 'base_shipping_amount_refunded' => 0, + ], + ], + 'creditmemo_data' => [ + 'items' => [ + 'item_1' => [ + 'order_item' => [ + 'qty_invoiced' => 3, + 'tax_invoiced' => 12.38, + 'tax_refunded' => 8.26, + 'base_tax_invoiced' => 12.38, + 'base_tax_refunded' => 8.26, + 'hidden_tax_amount' => 0, + 'base_hidden_tax_amount' => 0, + 'qty_refunded' => 2, + ], + 'is_last' => true, + 'qty' => 1, + ], + ], + 'is_last' => true, + 'data_fields' => [ + 'shipping_amount' => 7.5, + 'base_shipping_amount' => 7.5, + 'grand_total' => 60.82, + 'base_grand_total' => 60.82, + 'tax_amount' => 0.82, + 'base_tax_amount' => 0.82, + 'invoice' => new MagentoObject( + [ + 'shipping_tax_amount' => 1.24, + 'base_shipping_tax_amount' => 1.24, + 'shipping_hidden_tax_amount' => 0, + 'base_shipping_hidden_tax_amount' => 0, + ] + ), + ], + ], + 'expected_results' => [ + 'creditmemo_items' => [ + 'item_1' => [ + 'tax_amount' => 4.12, + 'base_tax_amount' => 4.12, + ], + ], + 'creditmemo_data' => [ + 'grand_total' => 65.56, + 'base_grand_total' => 65.56, + 'tax_amount' => 5.56, + 'base_tax_amount' => 5.56, + ], + ], + ]; + return $result; } diff --git a/app/code/Magento/Sales/etc/fieldset.xml b/app/code/Magento/Sales/etc/fieldset.xml index 0c2601c754313d90b67a0e9fad0ee0598f3ebc41..519416dc4ca31179f491d29beb22dab760e664cc 100644 --- a/app/code/Magento/Sales/etc/fieldset.xml +++ b/app/code/Magento/Sales/etc/fieldset.xml @@ -391,95 +391,6 @@ <aspect name="to_order_payment" /> </field> </fieldset> - <fieldset id="sales_convert_quote_item"> - <field name="sku"> - <aspect name="to_order_item" /> - </field> - <field name="name"> - <aspect name="to_order_item" /> - </field> - <field name="description"> - <aspect name="to_order_item" /> - </field> - <field name="weight"> - <aspect name="to_order_item" /> - </field> - <field name="is_qty_decimal"> - <aspect name="to_order_item" /> - </field> - <field name="qty"> - <aspect name="to_order_item" targetField="qty_ordered" /> - </field> - <field name="is_virtual"> - <aspect name="to_order_item" /> - </field> - <field name="original_price"> - <aspect name="to_order_item" /> - </field> - <field name="applied_rule_ids"> - <aspect name="to_order_item" /> - </field> - <field name="additional_data"> - <aspect name="to_order_item" /> - </field> - <field name="calculation_price"> - <aspect name="to_order_item" targetField="price" /> - </field> - <field name="base_calculation_price"> - <aspect name="to_order_item" targetField="base_price" /> - </field> - <field name="tax_percent"> - <aspect name="to_order_item" /> - </field> - <field name="tax_amount"> - <aspect name="to_order_item" /> - </field> - <field name="tax_before_discount"> - <aspect name="to_order_item" /> - </field> - <field name="base_tax_before_discount"> - <aspect name="to_order_item" /> - </field> - <field name="tax_string"> - <aspect name="to_order_item" /> - </field> - <field name="row_weight"> - <aspect name="to_order_item" /> - </field> - <field name="row_total"> - <aspect name="to_order_item" /> - </field> - <field name="base_original_price"> - <aspect name="to_order_item" /> - </field> - <field name="base_tax_amount"> - <aspect name="to_order_item" /> - </field> - <field name="base_row_total"> - <aspect name="to_order_item" /> - </field> - <field name="discount_percent"> - <aspect name="to_order_item_discount" /> - </field> - <field name="discount_amount"> - <aspect name="to_order_item_discount" /> - </field> - <field name="base_discount_amount"> - <aspect name="to_order_item_discount" /> - </field> - <field name="base_cost"> - <aspect name="to_order_item" /> - </field> - <field name="store_id"> - <aspect name="to_order_item" /> - </field> - <field name="hidden_tax_amount"> - <aspect name="to_order_item" /> - </field> - <field name="base_hidden_tax_amount"> - <aspect name="to_order_item" /> - </field> - </fieldset> <fieldset id="sales_convert_order"> <field name="customer_id"> <aspect name="to_quote" /> diff --git a/app/code/Magento/Sales/view/adminhtml/templates/order/create/items/grid.phtml b/app/code/Magento/Sales/view/adminhtml/templates/order/create/items/grid.phtml index ab99f595ec4efd3e2271438d139819a4dd07879a..80cf6765da7a5284cfec1a78a7dcb690c5c35a13 100644 --- a/app/code/Magento/Sales/view/adminhtml/templates/order/create/items/grid.phtml +++ b/app/code/Magento/Sales/view/adminhtml/templates/order/create/items/grid.phtml @@ -64,7 +64,7 @@ <td class="col-price"><strong><?php echo $block->formatPrice($block->getDiscountAmount()) ?></strong></td> <td class="col-price"><strong> <?php - echo $block->formatPrice($block->getSubtotal() + $block->getDiscountAmount()); + echo $block->formatPrice($block->getSubtotalWithDiscount()); ?></strong></td> <td colspan="2"> </td> </tr> diff --git a/app/code/Magento/Tax/Api/Data/TaxClassDataBuilder.php b/app/code/Magento/Tax/Api/Data/TaxClassDataBuilder.php deleted file mode 100644 index 4b8a3a4876204ebfb08f2bd42486a3bae3dbf3ec..0000000000000000000000000000000000000000 --- a/app/code/Magento/Tax/Api/Data/TaxClassDataBuilder.php +++ /dev/null @@ -1,88 +0,0 @@ -<?php -/** - * - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Tax\Api\Data; - -/** - * DataBuilder class for \Magento\Tax\Api\Data\TaxClassInterface - * @codeCoverageIgnore - */ -class TaxClassDataBuilder extends \Magento\Framework\Api\Builder -{ - /** - * Initialize the builder - * - * @param \Magento\Framework\Api\ObjectFactory $objectFactory - * @param \Magento\Framework\Api\MetadataServiceInterface $metadataService - * @param \Magento\Framework\Api\AttributeValueFactory $attributeValueFactory - * @param \Magento\Framework\Reflection\DataObjectProcessor $objectProcessor - * @param \Magento\Framework\Reflection\TypeProcessor $typeProcessor - * @param \Magento\Framework\Serialization\DataBuilderFactory $dataBuilderFactory - * @param \Magento\Framework\ObjectManager\ConfigInterface $objectManagerConfig - * @param string|null $modelClassInterface - */ - public function __construct( - \Magento\Framework\Api\ObjectFactory $objectFactory, - \Magento\Framework\Api\MetadataServiceInterface $metadataService, - \Magento\Framework\Api\AttributeValueFactory $attributeValueFactory, - \Magento\Framework\Reflection\DataObjectProcessor $objectProcessor, - \Magento\Framework\Reflection\TypeProcessor $typeProcessor, - \Magento\Framework\Serialization\DataBuilderFactory $dataBuilderFactory, - \Magento\Framework\ObjectManager\ConfigInterface $objectManagerConfig, - $modelClassInterface = null - ) { - parent::__construct( - $objectFactory, - $metadataService, - $attributeValueFactory, - $objectProcessor, - $typeProcessor, - $dataBuilderFactory, - $objectManagerConfig, - 'Magento\Tax\Api\Data\TaxClassInterface' - ); - } - - /** - * @param int|null $classId - * @return $this - */ - public function setClassId($classId) - { - $this->_set('class_id', $classId); - return $this; - } - - /** - * @param string $className - * @return $this - */ - public function setClassName($className) - { - $this->_set('class_name', $className); - return $this; - } - - /** - * @param string $classType - * @return $this - */ - public function setClassType($classType) - { - $this->_set('class_type', $classType); - return $this; - } - - /** - * {@inheritdoc} - */ - public function create() - { - $object = parent::create(); - $object->setDataChanges(true); - return $object; - } -} diff --git a/app/code/Magento/Tax/Api/Data/TaxClassSearchResultsInterface.php b/app/code/Magento/Tax/Api/Data/TaxClassSearchResultsInterface.php index fbcf859e1975d9be513f72a9f0c687d1c6d0c5de..e81bb366a4d7e346aa390cf315b66af7459c5af3 100644 --- a/app/code/Magento/Tax/Api/Data/TaxClassSearchResultsInterface.php +++ b/app/code/Magento/Tax/Api/Data/TaxClassSearchResultsInterface.php @@ -14,4 +14,12 @@ interface TaxClassSearchResultsInterface extends \Magento\Framework\Api\SearchRe * @return \Magento\Tax\Api\Data\TaxClassInterface[] */ public function getItems(); + + /** + * Set items. + * + * @param \Magento\Tax\Api\Data\TaxClassInterface[] $items + * @return $this + */ + public function setItems(array $items = null); } diff --git a/app/code/Magento/Tax/Api/Data/TaxRateDataBuilder.php b/app/code/Magento/Tax/Api/Data/TaxRateDataBuilder.php deleted file mode 100644 index b079864bb964e3f888d22af277946414b43bdbaa..0000000000000000000000000000000000000000 --- a/app/code/Magento/Tax/Api/Data/TaxRateDataBuilder.php +++ /dev/null @@ -1,166 +0,0 @@ -<?php -/** - * - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Tax\Api\Data; - -/** - * DataBuilder class for \Magento\Tax\Api\Data\TaxRateInterface - * @codeCoverageIgnore - */ -class TaxRateDataBuilder extends \Magento\Framework\Api\Builder -{ - /** - * @param \Magento\Framework\Api\ObjectFactory $objectFactory - * @param \Magento\Framework\Api\MetadataServiceInterface $metadataService - * @param \Magento\Framework\Api\AttributeValueFactory $attributeValueFactory - * @param \Magento\Framework\Reflection\DataObjectProcessor $objectProcessor - * @param \Magento\Framework\Reflection\TypeProcessor $typeProcessor - * @param \Magento\Framework\Serialization\DataBuilderFactory $dataBuilderFactory - * @param \Magento\Framework\ObjectManager\ConfigInterface $objectManagerConfig - * @param string|null $modelClassInterface - */ - public function __construct( - \Magento\Framework\Api\ObjectFactory $objectFactory, - \Magento\Framework\Api\MetadataServiceInterface $metadataService, - \Magento\Framework\Api\AttributeValueFactory $attributeValueFactory, - \Magento\Framework\Reflection\DataObjectProcessor $objectProcessor, - \Magento\Framework\Reflection\TypeProcessor $typeProcessor, - \Magento\Framework\Serialization\DataBuilderFactory $dataBuilderFactory, - \Magento\Framework\ObjectManager\ConfigInterface $objectManagerConfig, - $modelClassInterface = null - ) { - parent::__construct( - $objectFactory, - $metadataService, - $attributeValueFactory, - $objectProcessor, - $typeProcessor, - $dataBuilderFactory, - $objectManagerConfig, - 'Magento\Tax\Api\Data\TaxRateInterface' - ); - } - - /** - * @param int|null $id - * @return $this - */ - public function setId($id) - { - $this->_set('id', $id); - return $this; - } - - /** - * @param string $taxCountryId - * @return $this - */ - public function setTaxCountryId($taxCountryId) - { - $this->_set('tax_country_id', $taxCountryId); - return $this; - } - - /** - * @param int|null $taxRegionId - * @return $this - */ - public function setTaxRegionId($taxRegionId) - { - $this->_set('tax_region_id', $taxRegionId); - return $this; - } - - /** - * @param string|null $regionName - * @return $this - */ - public function setRegionName($regionName) - { - $this->_set('region_name', $regionName); - return $this; - } - - /** - * @param string|null $taxPostcode - * @return $this - */ - public function setTaxPostcode($taxPostcode) - { - $this->_set('tax_postcode', $taxPostcode); - return $this; - } - - /** - * @param int|null $zipFrom - * @return $this - */ - public function setZipFrom($zipFrom) - { - $this->_set('zip_from', $zipFrom); - return $this; - } - - /** - * @param int|null $zipTo - * @return $this - */ - public function setZipTo($zipTo) - { - $this->_set('zip_to', $zipTo); - return $this; - } - - /** - * @param float $rate - * @return $this - */ - public function setRate($rate) - { - $this->_set('rate', $rate); - return $this; - } - - /** - * @param string $code - * @return $this - */ - public function setCode($code) - { - $this->_set('code', $code); - return $this; - } - - /** - * @param \Magento\Tax\Api\Data\TaxRateTitleInterface $titles - * @return $this - */ - public function setTitles($titles) - { - $this->_set('titles', $titles); - return $this; - } - - /** - * @param int|null $zipIsRange - * @return $this - */ - public function setZipIsRange($zipIsRange) - { - $this->_set('zip_is_range', $zipIsRange); - return $this; - } - /** - * {@inheritdoc} - */ - public function create() - { - /** TODO: temporary fix while problem with hasDataChanges flag not solved. MAGETWO-30324 */ - $object = parent::create(); - $object->setDataChanges(true); - return $object; - } -} diff --git a/app/code/Magento/Tax/Api/Data/TaxRateSearchResultsInterface.php b/app/code/Magento/Tax/Api/Data/TaxRateSearchResultsInterface.php index 9f834184255f86bd5c818bcb04e88574a415fd01..5d4bd3769db16b7376ff1c450c1e2b2693a3c40e 100644 --- a/app/code/Magento/Tax/Api/Data/TaxRateSearchResultsInterface.php +++ b/app/code/Magento/Tax/Api/Data/TaxRateSearchResultsInterface.php @@ -17,4 +17,12 @@ interface TaxRateSearchResultsInterface extends SearchResultsInterface * @return \Magento\Tax\Api\Data\TaxRateInterface[] */ public function getItems(); + + /** + * Set items + * + * @param \Magento\Tax\Api\Data\TaxRateInterface[] $items + * @return $this + */ + public function setItems(array $items = null); } diff --git a/app/code/Magento/Tax/Api/Data/TaxRateTitleDataBuilder.php b/app/code/Magento/Tax/Api/Data/TaxRateTitleDataBuilder.php deleted file mode 100644 index dd6340ceed838a16a0da66f44d1422021d67347a..0000000000000000000000000000000000000000 --- a/app/code/Magento/Tax/Api/Data/TaxRateTitleDataBuilder.php +++ /dev/null @@ -1,78 +0,0 @@ -<?php -/** - * - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Tax\Api\Data; - -/** - * DataBuilder class for \Magento\Tax\Api\Data\TaxRateTitleInterface - * @codeCoverageIgnore - */ -class TaxRateTitleDataBuilder extends \Magento\Framework\Api\Builder -{ - /** - * Initialize the builder - * - * @param \Magento\Framework\Api\ObjectFactory $objectFactory - * @param \Magento\Framework\Api\MetadataServiceInterface $metadataService - * @param \Magento\Framework\Api\AttributeValueFactory $attributeValueFactory - * @param \Magento\Framework\Reflection\DataObjectProcessor $objectProcessor - * @param \Magento\Framework\Reflection\TypeProcessor $typeProcessor - * @param \Magento\Framework\Serialization\DataBuilderFactory $dataBuilderFactory - * @param \Magento\Framework\ObjectManager\ConfigInterface $objectManagerConfig - * @param string|null $modelClassInterface - */ - public function __construct( - \Magento\Framework\Api\ObjectFactory $objectFactory, - \Magento\Framework\Api\MetadataServiceInterface $metadataService, - \Magento\Framework\Api\AttributeValueFactory $attributeValueFactory, - \Magento\Framework\Reflection\DataObjectProcessor $objectProcessor, - \Magento\Framework\Reflection\TypeProcessor $typeProcessor, - \Magento\Framework\Serialization\DataBuilderFactory $dataBuilderFactory, - \Magento\Framework\ObjectManager\ConfigInterface $objectManagerConfig, - $modelClassInterface = null - ) { - parent::__construct( - $objectFactory, - $metadataService, - $attributeValueFactory, - $objectProcessor, - $typeProcessor, - $dataBuilderFactory, - $objectManagerConfig, - 'Magento\Tax\Api\Data\TaxRateTitleInterface' - ); - } - - /** - * @param string $storeId - * @return $this - */ - public function setStoreId($storeId) - { - $this->_set('store_id', $storeId); - return $this; - } - - /** - * @param string $value - * @return $this - */ - public function setValue($value) - { - $this->_set('value', $value); - return $this; - } - - /** - * {@inheritdoc} - */ - public function create() - { - $object = parent::create(); - $object->setDataChanges(true); - return $object; - } -} diff --git a/app/code/Magento/Tax/Api/Data/TaxRuleDataBuilder.php b/app/code/Magento/Tax/Api/Data/TaxRuleDataBuilder.php deleted file mode 100644 index 31908d5f58ffebf320dee99a4f97f68339f167d4..0000000000000000000000000000000000000000 --- a/app/code/Magento/Tax/Api/Data/TaxRuleDataBuilder.php +++ /dev/null @@ -1,138 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -namespace Magento\Tax\Api\Data; - -/** - * DataBuilder class for \Magento\Tax\Api\Data\TaxRuleInterface - * @codeCoverageIgnore - */ -class TaxRuleDataBuilder extends \Magento\Framework\Api\Builder -{ - /** - * Initialize the builder - * - * @param \Magento\Framework\Api\ObjectFactory $objectFactory - * @param \Magento\Framework\Api\MetadataServiceInterface $metadataService - * @param \Magento\Framework\Api\AttributeValueFactory $attributeValueFactory - * @param \Magento\Framework\Reflection\DataObjectProcessor $objectProcessor - * @param \Magento\Framework\Reflection\TypeProcessor $typeProcessor - * @param \Magento\Framework\Serialization\DataBuilderFactory $dataBuilderFactory - * @param \Magento\Framework\ObjectManager\ConfigInterface $objectManagerConfig - * @param string|null $modelClassInterface - */ - public function __construct( - \Magento\Framework\Api\ObjectFactory $objectFactory, - \Magento\Framework\Api\MetadataServiceInterface $metadataService, - \Magento\Framework\Api\AttributeValueFactory $attributeValueFactory, - \Magento\Framework\Reflection\DataObjectProcessor $objectProcessor, - \Magento\Framework\Reflection\TypeProcessor $typeProcessor, - \Magento\Framework\Serialization\DataBuilderFactory $dataBuilderFactory, - \Magento\Framework\ObjectManager\ConfigInterface $objectManagerConfig, - $modelClassInterface = null - ) { - parent::__construct( - $objectFactory, - $metadataService, - $attributeValueFactory, - $objectProcessor, - $typeProcessor, - $dataBuilderFactory, - $objectManagerConfig, - 'Magento\Tax\Api\Data\TaxRuleInterface' - ); - } - - /** - * @param int|null $id - * @return $this - */ - public function setId($id) - { - $this->_set('id', $id); - return $this; - } - - /** - * @param string $code - * @return $this - */ - public function setCode($code) - { - $this->_set('code', $code); - return $this; - } - - /** - * @param int $priority - * @return $this - */ - public function setPriority($priority) - { - $this->_set('priority', $priority); - return $this; - } - - /** - * @param int $position - * @return $this - */ - public function setPosition($position) - { - $this->_set('position', $position); - return $this; - } - - /** - * @param int $customerTaxClassIds - * @return $this - */ - public function setCustomerTaxClassIds($customerTaxClassIds) - { - $this->_set('customer_tax_class_ids', $customerTaxClassIds); - return $this; - } - - /** - * @param int $productTaxClassIds - * @return $this - */ - public function setProductTaxClassIds($productTaxClassIds) - { - $this->_set('product_tax_class_ids', $productTaxClassIds); - return $this; - } - - /** - * @param int $taxRateIds - * @return $this - */ - public function setTaxRateIds($taxRateIds) - { - $this->_set('tax_rate_ids', $taxRateIds); - return $this; - } - - /** - * @param bool|null $calculateSubtotal - * @return $this - */ - public function setCalculateSubtotal($calculateSubtotal) - { - $this->_set('calculate_subtotal', $calculateSubtotal); - return $this; - } - - /** - * {@inheritdoc} - */ - public function create() - { - $object = parent::create(); - $object->setDataChanges(true); - return $object; - } -} diff --git a/app/code/Magento/Tax/Api/Data/TaxRuleSearchResultsInterface.php b/app/code/Magento/Tax/Api/Data/TaxRuleSearchResultsInterface.php index 423b714f6348874472efa0f4e78d48fac414549c..de3735efa25f49ca35ab8c7c89f417529d4d9109 100644 --- a/app/code/Magento/Tax/Api/Data/TaxRuleSearchResultsInterface.php +++ b/app/code/Magento/Tax/Api/Data/TaxRuleSearchResultsInterface.php @@ -14,4 +14,12 @@ interface TaxRuleSearchResultsInterface extends \Magento\Framework\Api\SearchRes * @return \Magento\Tax\Api\Data\TaxRuleInterface[] */ public function getItems(); + + /** + * Set items + * + * @param \Magento\Tax\Api\Data\TaxRuleInterface[] $items + * @return $this + */ + public function setItems(array $items = null); } diff --git a/app/code/Magento/Tax/Model/Calculation/RateRepository.php b/app/code/Magento/Tax/Model/Calculation/RateRepository.php index be0dd027c72a4b7b76e09ebf31aa04d510cc005b..48967e8bec82aa77e6c47e7626dd4f18731c3c48 100644 --- a/app/code/Magento/Tax/Model/Calculation/RateRepository.php +++ b/app/code/Magento/Tax/Model/Calculation/RateRepository.php @@ -41,9 +41,9 @@ class RateRepository implements \Magento\Tax\Api\TaxRateRepositoryInterface protected $rateRegistry; /** - * @var \Magento\Tax\Api\Data\TaxRuleSearchResultsDataBuilder + * @var \Magento\Tax\Api\Data\TaxRuleSearchResultsInterfaceFactory */ - private $taxRateSearchResultsBuilder; + private $taxRateSearchResultsFactory; /** * @var RateFactory @@ -68,7 +68,7 @@ class RateRepository implements \Magento\Tax\Api\TaxRateRepositoryInterface /** * @param Converter $converter * @param RateRegistry $rateRegistry - * @param \Magento\Tax\Api\Data\TaxRuleSearchResultsDataBuilder $taxRateSearchResultsBuilder + * @param \Magento\Tax\Api\Data\TaxRuleSearchResultsInterfaceFactory $taxRateSearchResultsFactory * @param RateFactory $rateFactory * @param CountryFactory $countryFactory * @param RegionFactory $regionFactory @@ -77,7 +77,7 @@ class RateRepository implements \Magento\Tax\Api\TaxRateRepositoryInterface public function __construct( Converter $converter, RateRegistry $rateRegistry, - \Magento\Tax\Api\Data\TaxRuleSearchResultsDataBuilder $taxRateSearchResultsBuilder, + \Magento\Tax\Api\Data\TaxRuleSearchResultsInterfaceFactory $taxRateSearchResultsFactory, RateFactory $rateFactory, CountryFactory $countryFactory, RegionFactory $regionFactory, @@ -85,7 +85,7 @@ class RateRepository implements \Magento\Tax\Api\TaxRateRepositoryInterface ) { $this->converter = $converter; $this->rateRegistry = $rateRegistry; - $this->taxRateSearchResultsBuilder = $taxRateSearchResultsBuilder; + $this->taxRateSearchResultsFactory = $taxRateSearchResultsFactory; $this->rateFactory = $rateFactory; $this->countryFactory = $countryFactory; $this->regionFactory = $regionFactory; @@ -173,11 +173,10 @@ class RateRepository implements \Magento\Tax\Api\TaxRateRepositoryInterface $taxRate[] = $taxRateModel; } - return $this->taxRateSearchResultsBuilder + return $this->taxRateSearchResultsFactory->create() ->setItems($taxRate) ->setTotalCount($collection->getSize()) - ->setSearchCriteria($searchCriteria) - ->create(); + ->setSearchCriteria($searchCriteria); } /** diff --git a/app/code/Magento/Tax/Model/Observer.php b/app/code/Magento/Tax/Model/Observer.php index 70767d87251dd70aa4a189d9aeecc57d95aef0ae..b83a599cd0680764604722dd2d71370c67d3159d 100644 --- a/app/code/Magento/Tax/Model/Observer.php +++ b/app/code/Magento/Tax/Model/Observer.php @@ -311,11 +311,18 @@ class Observer if ($this->_taxData->displayBothPrices()) { $options['optionTemplate'] = sprintf( '<%%= data.label %%>' - . '<%% if(data.finalPrice.value) { %%>' + . '<%% if (data.finalPrice.value) { %%>' . ' <%%= data.finalPrice.formatted %%> (%1$s <%%= data.basePrice.formatted %%>)' . '<%% } %%>', __('Excl. tax:') ); + } elseif ($this->_taxData->priceIncludesTax() && $this->_taxData->displayPriceExcludingTax()) { + $options['optionTemplate'] = sprintf( + '<%%= data.label %%>' + . '<%% if (data.basePrice.value) { %%>' + . ' <%%= data.basePrice.formatted %%>' + . '<%% } %%>' + ); } $response->setAdditionalOptions($options); diff --git a/app/code/Magento/Tax/Model/TaxClass/Repository.php b/app/code/Magento/Tax/Model/TaxClass/Repository.php index acfd524f939eb0f22556f59939bfdecb29221758..83017d71277ddd9a7d851fc94868e8146afb3b38 100644 --- a/app/code/Magento/Tax/Model/TaxClass/Repository.php +++ b/app/code/Magento/Tax/Model/TaxClass/Repository.php @@ -32,9 +32,9 @@ class Repository implements \Magento\Tax\Api\TaxClassRepositoryInterface protected $taxClassCollectionFactory; /** - * @var \Magento\Tax\Api\Data\TaxClassSearchResultsDataBuilder + * @var \Magento\Tax\Api\Data\TaxClassSearchResultsInterfaceFactory */ - protected $searchResultsBuilder; + protected $searchResultsFactory; /** * @var ClassModelRegistry @@ -66,7 +66,7 @@ class Repository implements \Magento\Tax\Api\TaxClassRepositoryInterface * @param SearchCriteriaBuilder $searchCriteriaBuilder * @param FilterBuilder $filterBuilder * @param TaxClassCollectionFactory $taxClassCollectionFactory - * @param \Magento\Tax\Api\Data\TaxClassSearchResultsDataBuilder $searchResultsBuilder + * @param \Magento\Tax\Api\Data\TaxClassSearchResultsInterfaceFactory $searchResultsFactory * @param ClassModelRegistry $classModelRegistry * @param \Magento\Tax\Model\Resource\TaxClass $taxClassResource */ @@ -74,14 +74,14 @@ class Repository implements \Magento\Tax\Api\TaxClassRepositoryInterface SearchCriteriaBuilder $searchCriteriaBuilder, FilterBuilder $filterBuilder, TaxClassCollectionFactory $taxClassCollectionFactory, - \Magento\Tax\Api\Data\TaxClassSearchResultsDataBuilder $searchResultsBuilder, + \Magento\Tax\Api\Data\TaxClassSearchResultsInterfaceFactory $searchResultsFactory, ClassModelRegistry $classModelRegistry, \Magento\Tax\Model\Resource\TaxClass $taxClassResource ) { $this->searchCriteriaBuilder = $searchCriteriaBuilder; $this->filterBuilder = $filterBuilder; $this->taxClassCollectionFactory = $taxClassCollectionFactory; - $this->searchResultsBuilder = $searchResultsBuilder; + $this->searchResultsFactory = $searchResultsFactory; $this->classModelRegistry = $classModelRegistry; $this->taxClassResource = $taxClassResource; } @@ -187,13 +187,14 @@ class Repository implements \Magento\Tax\Api\TaxClassRepositoryInterface */ public function getList(\Magento\Framework\Api\SearchCriteriaInterface $searchCriteria) { - $this->searchResultsBuilder->setSearchCriteria($searchCriteria); + $searchResults = $this->searchResultsFactory->create(); + $searchResults->setSearchCriteria($searchCriteria); /** @var TaxClassCollection $collection */ $collection = $this->taxClassCollectionFactory->create(); foreach ($searchCriteria->getFilterGroups() as $group) { $this->addFilterGroupToCollection($group, $collection); } - $this->searchResultsBuilder->setTotalCount($collection->getSize()); + $searchResults->setTotalCount($collection->getSize()); $sortOrders = $searchCriteria->getSortOrders(); /** @var SortOrder $sortOrder */ if ($sortOrders) { @@ -206,8 +207,8 @@ class Repository implements \Magento\Tax\Api\TaxClassRepositoryInterface } $collection->setCurPage($searchCriteria->getCurrentPage()); $collection->setPageSize($searchCriteria->getPageSize()); - $this->searchResultsBuilder->setItems($collection->getItems()); - return $this->searchResultsBuilder->create(); + $searchResults->setItems($collection->getItems()); + return $searchResults; } /** diff --git a/app/code/Magento/Tax/Model/TaxRuleRepository.php b/app/code/Magento/Tax/Model/TaxRuleRepository.php index 46884bc439f8be855271188da1525d6e92346ac4..7c7b1ed8f6cdd5ae6a0a6c3c8c232d56d8222e4a 100644 --- a/app/code/Magento/Tax/Model/TaxRuleRepository.php +++ b/app/code/Magento/Tax/Model/TaxRuleRepository.php @@ -15,7 +15,7 @@ use Magento\Framework\Exception\NoSuchEntityException; use Magento\Framework\Exception\AlreadyExistsException; use Magento\Tax\Api\Data\TaxRuleInterface; use Magento\Tax\Api\TaxRuleRepositoryInterface; -use Magento\Tax\Api\Data\TaxRuleSearchResultsDataBuilder; +use Magento\Tax\Api\Data\TaxRuleSearchResultsInterfaceFactory; use Magento\Tax\Model\Calculation\RuleFactory; use Magento\Tax\Model\Calculation\TaxRuleRegistry; use Magento\Tax\Model\Resource\Calculation\Rule as Resource; @@ -33,9 +33,9 @@ class TaxRuleRepository implements TaxRuleRepositoryInterface protected $taxRuleRegistry; /** - * @var TaxRuleSearchResultsDataBuilder + * @var TaxRuleSearchResultsInterfaceFactory */ - protected $taxRuleSearchResultsBuilder; + protected $taxRuleSearchResultsFactory; /** * @var RuleFactory @@ -54,20 +54,20 @@ class TaxRuleRepository implements TaxRuleRepositoryInterface /** * @param TaxRuleRegistry $taxRuleRegistry - * @param TaxRuleSearchResultsDataBuilder $searchResultsBuilder + * @param TaxRuleSearchResultsInterfaceFactory $searchResultsFactory * @param RuleFactory $ruleFactory * @param CollectionFactory $collectionFactory * @param Resource $resource */ public function __construct( TaxRuleRegistry $taxRuleRegistry, - TaxRuleSearchResultsDataBuilder $searchResultsBuilder, + TaxRuleSearchResultsInterfaceFactory $searchResultsFactory, RuleFactory $ruleFactory, CollectionFactory $collectionFactory, Resource $resource ) { $this->taxRuleRegistry = $taxRuleRegistry; - $this->taxRuleSearchResultsBuilder = $searchResultsBuilder; + $this->taxRuleSearchResultsFactory = $searchResultsFactory; $this->taxRuleModelFactory = $ruleFactory; $this->collectionFactory = $collectionFactory; $this->resource = $resource; @@ -128,7 +128,8 @@ class TaxRuleRepository implements TaxRuleRepositoryInterface */ public function getList(\Magento\Framework\Api\SearchCriteria $searchCriteria) { - $this->taxRuleSearchResultsBuilder->setSearchCriteria($searchCriteria); + $searchResults = $this->taxRuleSearchResultsFactory->create(); + $searchResults->setSearchCriteria($searchCriteria); $fields = []; $collection = $this->collectionFactory->create(); @@ -146,7 +147,7 @@ class TaxRuleRepository implements TaxRuleRepositoryInterface } } - $this->taxRuleSearchResultsBuilder->setTotalCount($collection->getSize()); + $searchResults->setTotalCount($collection->getSize()); $sortOrders = $searchCriteria->getSortOrders(); /** @var SortOrder $sortOrder */ if ($sortOrders) { @@ -160,8 +161,8 @@ class TaxRuleRepository implements TaxRuleRepositoryInterface $collection->setCurPage($searchCriteria->getCurrentPage()); $collection->setPageSize($searchCriteria->getPageSize()); - $this->taxRuleSearchResultsBuilder->setItems($collection->getItems()); - return $this->taxRuleSearchResultsBuilder->create(); + $searchResults->setItems($collection->getItems()); + return $searchResults; } /** diff --git a/app/code/Magento/Tax/Pricing/Render/Adjustment.php b/app/code/Magento/Tax/Pricing/Render/Adjustment.php index b3776fdc7fb3b656eebbeb1f50622224f4645a7a..db800ac1c16346d8e5fd7148cb89f6ad91908a86 100644 --- a/app/code/Magento/Tax/Pricing/Render/Adjustment.php +++ b/app/code/Magento/Tax/Pricing/Render/Adjustment.php @@ -54,6 +54,10 @@ class Adjustment extends AbstractAdjustment $this->amountRender->setDisplayValue( $this->amountRender->getAmount()->getValue($this->getAdjustmentCode()) ); + if ($this->taxHelper->priceIncludesTax()) { + // for dynamic calculations of prices with any options, use the base price amount + $this->amountRender->setPriceType('basePrice'); + } } return $this->toHtml(); } diff --git a/app/code/Magento/Tax/Test/Unit/Model/Calculation/RateRepositoryTest.php b/app/code/Magento/Tax/Test/Unit/Model/Calculation/RateRepositoryTest.php index f07198363a36082263c877259c482b068bf7cbbf..7feff54990150d92bc3806f1399109e9410d4145 100644 --- a/app/code/Magento/Tax/Test/Unit/Model/Calculation/RateRepositoryTest.php +++ b/app/code/Magento/Tax/Test/Unit/Model/Calculation/RateRepositoryTest.php @@ -32,7 +32,12 @@ class RateRepositoryTest extends \PHPUnit_Framework_TestCase /** * @var \PHPUnit_Framework_MockObject_MockObject */ - private $searchResultBuilder; + private $searchResultFactory; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + private $searchResultMock; /** * @var \PHPUnit_Framework_MockObject_MockObject @@ -70,9 +75,16 @@ class RateRepositoryTest extends \PHPUnit_Framework_TestCase '', false ); - $this->searchResultBuilder = $this->getMock( - 'Magento\Tax\Api\Data\TaxRuleSearchResultsDataBuilder', - ['setItems', 'setSearchCriteria', 'setTotalCount', 'create'], + $this->searchResultFactory = $this->getMock( + 'Magento\Tax\Api\Data\TaxRuleSearchResultsInterfaceFactory', + ['create'], + [], + '', + false + ); + $this->searchResultMock = $this->getMock( + 'Magento\Tax\Api\Data\TaxRuleSearchResultsInterface', + [], [], '', false @@ -108,7 +120,7 @@ class RateRepositoryTest extends \PHPUnit_Framework_TestCase $this->model = new RateRepository( $this->rateConverterMock, $this->rateRegistryMock, - $this->searchResultBuilder, + $this->searchResultFactory, $this->rateFactoryMock, $this->countryFactoryMock, $this->regionFactoryMock, @@ -237,12 +249,12 @@ class RateRepositoryTest extends \PHPUnit_Framework_TestCase $this->rateFactoryMock->expects($this->once())->method('create')->will($this->returnValue($rateMock)); $rateMock->expects($this->any())->method('getCollection')->will($this->returnValue($collectionMock)); - $this->searchResultBuilder->expects($this->once())->method('setItems')->with($items)->willReturnSelf(); - $this->searchResultBuilder->expects($this->once())->method('setTotalCount')->with(count($items)) + $this->searchResultMock->expects($this->once())->method('setItems')->with($items)->willReturnSelf(); + $this->searchResultMock->expects($this->once())->method('setTotalCount')->with(count($items)) ->willReturnSelf(); - $this->searchResultBuilder->expects($this->once())->method('setSearchCriteria')->with($searchCriteriaMock) + $this->searchResultMock->expects($this->once())->method('setSearchCriteria')->with($searchCriteriaMock) ->willReturnSelf(); - $this->searchResultBuilder->expects($this->once())->method('create'); + $this->searchResultFactory->expects($this->once())->method('create')->willReturn($this->searchResultMock); $this->model->getList($searchCriteriaMock); } @@ -383,12 +395,12 @@ class RateRepositoryTest extends \PHPUnit_Framework_TestCase - $this->searchResultBuilder->expects($this->once())->method('setItems')->with($items)->willReturnSelf(); - $this->searchResultBuilder->expects($this->once())->method('setTotalCount')->with(count($items)) + $this->searchResultMock->expects($this->once())->method('setItems')->with($items)->willReturnSelf(); + $this->searchResultMock->expects($this->once())->method('setTotalCount')->with(count($items)) ->willReturnSelf(); - $this->searchResultBuilder->expects($this->once())->method('setSearchCriteria')->with($searchCriteriaMock) + $this->searchResultMock->expects($this->once())->method('setSearchCriteria')->with($searchCriteriaMock) ->willReturnSelf(); - $this->searchResultBuilder->expects($this->once())->method('create'); + $this->searchResultFactory->expects($this->once())->method('create')->willReturn($this->searchResultMock); $this->model->getList($searchCriteriaMock); } 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 f7c4cf1865adfed1f40c3bb361f6deb4097dda99..ceeb3e67917ddb6ca33c9dee676cae6d485d08b5 100644 --- a/app/code/Magento/Tax/Test/Unit/Model/TaxClass/RepositoryTest.php +++ b/app/code/Magento/Tax/Test/Unit/Model/TaxClass/RepositoryTest.php @@ -20,7 +20,12 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase /** * @var \PHPUnit_Framework_MockObject_MockObject */ - protected $searchResultBuilder; + protected $searchResultFactory; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $searchResultMock; /** * @var \PHPUnit_Framework_MockObject_MockObject @@ -45,11 +50,16 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->searchResultBuilder = $this->getMock( - '\Magento\Tax\Api\Data\TaxClassSearchResultsDataBuilder', - [ - 'setSearchCriteria', 'setTotalCount', 'setItems', 'create' - ], + $this->searchResultFactory = $this->getMock( + '\Magento\Tax\Api\Data\TaxClassSearchResultsInterfaceFactory', + ['create'], + [], + '', + false + ); + $this->searchResultMock = $this->getMock( + '\Magento\Tax\Api\Data\TaxClassSearchResultsInterface', + [], [], '', false @@ -77,7 +87,7 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase [ 'classModelRegistry' => $this->classModelRegistryMock, 'taxClassResource' => $this->taxClassResourceMock, - 'searchResultsBuilder' => $this->searchResultBuilder, + 'searchResultsFactory' => $this->searchResultFactory, 'taxClassCollectionFactory' => $this->taxClassCollectionFactory ] ); @@ -172,18 +182,17 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase $searchCriteria->expects($this->once())->method('getPageSize')->willReturn(20); $searchCriteria->expects($this->once())->method('getCurrentPage')->willReturn(0); - $result = $this->getMock('\Magento\Tax\Api\Data\TaxRateSearchResultsInterface'); $collection->expects($this->any())->method('getSize')->willReturn(2); $collection->expects($this->any())->method('setItems')->with([$taxClassOne, $taxClassTwo]); $collection->expects($this->once())->method('setCurPage')->with(0); $collection->expects($this->once())->method('setPageSize')->with(20); - $this->searchResultBuilder->expects($this->once())->method('setSearchCriteria')->with($searchCriteria); - $this->searchResultBuilder->expects($this->once())->method('setTotalCount')->with(2); - $this->searchResultBuilder->expects($this->once())->method('create')->willReturn($result); + $this->searchResultMock->expects($this->once())->method('setSearchCriteria')->with($searchCriteria); + $this->searchResultMock->expects($this->once())->method('setTotalCount')->with(2); + $this->searchResultFactory->expects($this->once())->method('create')->willReturn($this->searchResultMock); $this->taxClassCollectionFactory->expects($this->once())->method('create')->willReturn($collection); - $this->assertEquals($result, $this->model->getList($searchCriteria)); + $this->assertEquals($this->searchResultMock, $this->model->getList($searchCriteria)); } public function testSave() diff --git a/app/code/Magento/Tax/Test/Unit/Model/TaxRuleRepositoryTest.php b/app/code/Magento/Tax/Test/Unit/Model/TaxRuleRepositoryTest.php index 8120f87150ace57ff612e1c3f032787c86980abd..435fa82bbe9e41c33f6fc7779bdca58eb418eb89 100644 --- a/app/code/Magento/Tax/Test/Unit/Model/TaxRuleRepositoryTest.php +++ b/app/code/Magento/Tax/Test/Unit/Model/TaxRuleRepositoryTest.php @@ -24,7 +24,12 @@ class TaxRuleRepositoryTest extends \PHPUnit_Framework_TestCase /** * @var \PHPUnit_Framework_MockObject_MockObject */ - protected $searchResultBuilder; + protected $searchResultFactory; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $searchResultsMock; /** * @var \PHPUnit_Framework_MockObject_MockObject @@ -50,9 +55,16 @@ class TaxRuleRepositoryTest extends \PHPUnit_Framework_TestCase { $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->taxRuleRegistry = $this->getMock('\Magento\Tax\Model\Calculation\TaxRuleRegistry', [], [], '', false); - $this->searchResultBuilder = $this->getMock( - '\Magento\Tax\Api\Data\TaxRuleSearchResultsDataBuilder', - ['setSearchCriteria', 'setTotalCount', 'setItems', 'create'], + $this->searchResultFactory = $this->getMock( + '\Magento\Tax\Api\Data\TaxRuleSearchResultsInterfaceFactory', + ['create'], + [], + '', + false + ); + $this->searchResultsMock = $this->getMock( + '\Magento\Tax\Api\Data\TaxRuleSearchResultsInterface', + [], [], '', false @@ -69,7 +81,7 @@ class TaxRuleRepositoryTest extends \PHPUnit_Framework_TestCase $this->model = new TaxRuleRepository( $this->taxRuleRegistry, - $this->searchResultBuilder, + $this->searchResultFactory, $this->ruleFactory, $this->collectionFactory, $this->resource @@ -169,7 +181,7 @@ class TaxRuleRepositoryTest extends \PHPUnit_Framework_TestCase $filterMock = $this->getMock('\Magento\Framework\Api\Filter', [], [], '', false); $sortOrderMock = $this->getMock('\Magento\Framework\Api\SortOrder', [], [], '', false); - $this->searchResultBuilder->expects($this->once())->method('setSearchCriteria')->with($searchCriteriaMock); + $this->searchResultsMock->expects($this->once())->method('setSearchCriteria')->with($searchCriteriaMock); $this->collectionFactory->expects($this->once())->method('create')->willReturn($collectionMock); $searchCriteriaMock->expects($this->once())->method('getFilterGroups')->willReturn([$filterGroupMock]); $filterGroupMock->expects($this->exactly(2))->method('getFilters')->willReturn([$filterMock]); @@ -183,7 +195,7 @@ class TaxRuleRepositoryTest extends \PHPUnit_Framework_TestCase $collectionMock->expects($this->once())->method('addFieldToFilter') ->with([0 => 'rate.tax_calculation_rate_id'], [0 => ['eq' => 'value']]); $collectionMock->expects($this->once())->method('getSize')->willReturn($collectionSize); - $this->searchResultBuilder->expects($this->once())->method('setTotalCount')->with($collectionSize); + $this->searchResultsMock->expects($this->once())->method('setTotalCount')->with($collectionSize); $searchCriteriaMock->expects($this->once())->method('getSortOrders')->willReturn([$sortOrderMock]); $sortOrderMock->expects($this->once())->method('getField')->willReturn('sort_order'); $sortOrderMock->expects($this->once())->method('getDirection')->willReturn(SearchCriteria::SORT_ASC); @@ -193,8 +205,8 @@ class TaxRuleRepositoryTest extends \PHPUnit_Framework_TestCase $searchCriteriaMock->expects($this->once())->method('getPageSize')->willReturn($pageSize); $collectionMock->expects($this->once())->method('setPageSize')->with($pageSize); $collectionMock->expects($this->once())->method('getItems')->willReturn([]); - $this->searchResultBuilder->expects($this->once())->method('setItems')->with([]); - $this->searchResultBuilder->expects($this->once())->method('create')->willReturnSelf(); - $this->assertEquals($this->searchResultBuilder, $this->model->getList($searchCriteriaMock)); + $this->searchResultsMock->expects($this->once())->method('setItems')->with([]); + $this->searchResultFactory->expects($this->once())->method('create')->willReturn($this->searchResultsMock); + $this->assertEquals($this->searchResultsMock, $this->model->getList($searchCriteriaMock)); } } diff --git a/app/code/Magento/Tax/view/adminhtml/templates/order/create/items/price/total.phtml b/app/code/Magento/Tax/view/adminhtml/templates/order/create/items/price/total.phtml index da2cdfb0ee54362d0798811ca06831937a787b7a..28b22c6a4b9ff8634a216cc29ea9ecd30c533c36 100644 --- a/app/code/Magento/Tax/view/adminhtml/templates/order/create/items/price/total.phtml +++ b/app/code/Magento/Tax/view/adminhtml/templates/order/create/items/price/total.phtml @@ -26,6 +26,6 @@ $_item = $block->getItem(); <?php if ($block->displayBothPrices($block->getStore())): ?> <br /><span class="label"><?php echo __('Incl. Tax'); ?>:</span> <?php endif; ?> - <?php $_incl = $_item->getPriceInclTax() * $_item->getQty() - $_item->getTotalDiscountAmount(); ?> + <?php $_incl = $block->getTotalAmount($_item); ?> <?php echo $block->formatPrice($_incl) ?> <?php endif; ?> diff --git a/app/code/Magento/UrlRewrite/Model/Storage/AbstractStorage.php b/app/code/Magento/UrlRewrite/Model/Storage/AbstractStorage.php index 7cf653bda3e020ca92cdcbed615d29ea23a00da2..4664dd4b7e721371c05b41952df26f45865bcc75 100644 --- a/app/code/Magento/UrlRewrite/Model/Storage/AbstractStorage.php +++ b/app/code/Magento/UrlRewrite/Model/Storage/AbstractStorage.php @@ -6,22 +6,28 @@ namespace Magento\UrlRewrite\Model\Storage; use Magento\UrlRewrite\Model\StorageInterface; -use Magento\UrlRewrite\Service\V1\Data\UrlRewriteBuilder; +use Magento\UrlRewrite\Service\V1\Data\UrlRewriteFactory; +use Magento\Framework\Api\DataObjectHelper; /** * Abstract db storage */ abstract class AbstractStorage implements StorageInterface { - /** @var UrlRewriteBuilder */ - protected $urlRewriteBuilder; + /** @var UrlRewriteFactory */ + protected $urlRewriteFactory; + + /** @var DataObjectHelper */ + protected $dataObjectHelper; /** - * @param UrlRewriteBuilder $urlRewriteBuilder + * @param UrlRewriteFactory $urlRewriteFactory + * @param DataObjectHelper $dataObjectHelper */ - public function __construct(UrlRewriteBuilder $urlRewriteBuilder) + public function __construct(UrlRewriteFactory $urlRewriteFactory, DataObjectHelper $dataObjectHelper) { - $this->urlRewriteBuilder = $urlRewriteBuilder; + $this->urlRewriteFactory = $urlRewriteFactory; + $this->dataObjectHelper = $dataObjectHelper; } /** @@ -97,6 +103,12 @@ abstract class AbstractStorage implements StorageInterface */ protected function createUrlRewrite($data) { - return $this->urlRewriteBuilder->populateWithArray($data)->create(); + $dataObject = $this->urlRewriteFactory->create(); + $this->dataObjectHelper->populateWithArray( + $dataObject, + $data, + '\Magento\UrlRewrite\Service\V1\Data\UrlRewrite' + ); + return $dataObject; } } diff --git a/app/code/Magento/UrlRewrite/Model/Storage/DbStorage.php b/app/code/Magento/UrlRewrite/Model/Storage/DbStorage.php index 75d935565122d24c304fd96e91e5dd614adbf2ab..519ac3fc6cfc0696c59f3f6288d4bad20ace3f8f 100644 --- a/app/code/Magento/UrlRewrite/Model/Storage/DbStorage.php +++ b/app/code/Magento/UrlRewrite/Model/Storage/DbStorage.php @@ -7,7 +7,8 @@ namespace Magento\UrlRewrite\Model\Storage; use Magento\Framework\App\Resource; use Magento\UrlRewrite\Service\V1\Data\UrlRewrite; -use Magento\UrlRewrite\Service\V1\Data\UrlRewriteBuilder; +use Magento\UrlRewrite\Service\V1\Data\UrlRewriteFactory; +use Magento\Framework\Api\DataObjectHelper; class DbStorage extends AbstractStorage { @@ -32,15 +33,19 @@ class DbStorage extends AbstractStorage protected $resource; /** - * @param \Magento\UrlRewrite\Service\V1\Data\UrlRewriteBuilder $urlRewriteBuilder + * @param \Magento\UrlRewrite\Service\V1\Data\UrlRewriteFactory $urlRewriteFactory + * @param DataObjectHelper $dataObjectHelper * @param \Magento\Framework\App\Resource $resource */ - public function __construct(UrlRewriteBuilder $urlRewriteBuilder, Resource $resource) - { + public function __construct( + UrlRewriteFactory $urlRewriteFactory, + DataObjectHelper $dataObjectHelper, + Resource $resource + ) { $this->connection = $resource->getConnection(Resource::DEFAULT_WRITE_RESOURCE); $this->resource = $resource; - parent::__construct($urlRewriteBuilder); + parent::__construct($urlRewriteFactory, $dataObjectHelper); } /** diff --git a/app/code/Magento/UrlRewrite/Service/V1/Data/UrlRewrite.php b/app/code/Magento/UrlRewrite/Service/V1/Data/UrlRewrite.php index d37fa216be9534dd7465118bd4f108e2828ffaa8..517babf6cde83e102b292977fef0d25339a1e59d 100644 --- a/app/code/Magento/UrlRewrite/Service/V1/Data/UrlRewrite.php +++ b/app/code/Magento/UrlRewrite/Service/V1/Data/UrlRewrite.php @@ -6,6 +6,8 @@ namespace Magento\UrlRewrite\Service\V1\Data; use Magento\Framework\Api\AbstractExtensibleObject; +use \Magento\Framework\Api\AttributeValueFactory; +use \Magento\Framework\Api\MetadataServiceInterface; /** * Data abstract class for url storage @@ -27,6 +29,32 @@ class UrlRewrite extends AbstractExtensibleObject const METADATA = 'metadata'; /**#@-*/ + /** + * @var array + */ + protected $defaultValues = [ + self::REDIRECT_TYPE => 0, + self::IS_AUTOGENERATED => 1, + self::METADATA => null, + 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 * @@ -46,6 +74,15 @@ class UrlRewrite extends AbstractExtensibleObject return $this->_get(self::URL_REWRITE_ID); } + /** + * @param int $urlRewriteId + * @return int + */ + public function setUrlRewriteId($urlRewriteId) + { + return $this->setData(self::URL_REWRITE_ID, $urlRewriteId); + } + /** * @return int */ @@ -54,6 +91,16 @@ class UrlRewrite extends AbstractExtensibleObject return $this->_get(self::ENTITY_ID); } + /** + * @param int $entityId + * + * @return $this + */ + public function setEntityId($entityId) + { + return $this->setData(self::ENTITY_ID, $entityId); + } + /** * @return string */ @@ -62,6 +109,16 @@ class UrlRewrite extends AbstractExtensibleObject return $this->_get(self::ENTITY_TYPE); } + /** + * @param string $entityType + * + * @return $this + */ + public function setEntityType($entityType) + { + return $this->setData(self::ENTITY_TYPE, $entityType); + } + /** * @return int */ @@ -70,6 +127,16 @@ class UrlRewrite extends AbstractExtensibleObject return $this->_get(self::IS_AUTOGENERATED); } + /** + * @param int $isAutogenerated + * + * @return $this + */ + public function setIsAutogenerated($isAutogenerated) + { + return $this->setData(self::IS_AUTOGENERATED, $isAutogenerated); + } + /** * @return string */ @@ -78,6 +145,16 @@ class UrlRewrite extends AbstractExtensibleObject return $this->_get(self::REQUEST_PATH); } + /** + * @param string $requestPath + * + * @return $this + */ + public function setRequestPath($requestPath) + { + return $this->setData(self::REQUEST_PATH, $requestPath); + } + /** * @return string */ @@ -86,6 +163,16 @@ class UrlRewrite extends AbstractExtensibleObject return $this->_get(self::TARGET_PATH); } + /** + * @param string $targetPath + * + * @return $this + */ + public function setTargetPath($targetPath) + { + return $this->setData(self::TARGET_PATH, $targetPath); + } + /** * @return int */ @@ -94,6 +181,16 @@ class UrlRewrite extends AbstractExtensibleObject return $this->_get(self::STORE_ID); } + /** + * @param int $storeId + * + * @return $this + */ + public function setStoreId($storeId) + { + return $this->setData(self::STORE_ID, $storeId); + } + /** * @return int */ @@ -102,6 +199,16 @@ class UrlRewrite extends AbstractExtensibleObject return (int)$this->_get(self::REDIRECT_TYPE); } + /** + * @param int $redirectCode + * + * @return $this + */ + public function setRedirectType($redirectCode) + { + return $this->setData(self::REDIRECT_TYPE, $redirectCode); + } + /** * @return string */ @@ -110,6 +217,16 @@ class UrlRewrite extends AbstractExtensibleObject return $this->_get(self::DESCRIPTION); } + /** + * @param string $description + * + * @return $this + */ + public function setDescription($description) + { + return $this->setData(self::DESCRIPTION, $description); + } + /** * @return array */ @@ -119,6 +236,19 @@ class UrlRewrite extends AbstractExtensibleObject return !empty($metadata) ? unserialize($metadata) : []; } + /** + * @param array|string $metadata + * + * @return $this + */ + public function setMetadata($metadata) + { + if (is_array($metadata)) { + $metadata = serialize($metadata); + } + return $this->setData(UrlRewrite::METADATA, $metadata); + } + /** * Convert UrlRewrite to array * diff --git a/app/code/Magento/UrlRewrite/Service/V1/Data/UrlRewriteBuilder.php b/app/code/Magento/UrlRewrite/Service/V1/Data/UrlRewriteBuilder.php deleted file mode 100644 index eab6658155fb2e7d070d33597b5fbd045156569a..0000000000000000000000000000000000000000 --- a/app/code/Magento/UrlRewrite/Service/V1/Data/UrlRewriteBuilder.php +++ /dev/null @@ -1,123 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\UrlRewrite\Service\V1\Data; - -use Magento\Framework\Api\ExtensibleObjectBuilder; - -/** - * Data builder class for url rewrite - */ -class UrlRewriteBuilder extends ExtensibleObjectBuilder -{ - /** - * @var array - */ - protected $defaultValues = [ - UrlRewrite::REDIRECT_TYPE => 0, - UrlRewrite::IS_AUTOGENERATED => 1, - UrlRewrite::METADATA => null, - UrlRewrite::DESCRIPTION => null, - ]; - - /** - * {@inheritdoc} - */ - public function getData() - { - return array_merge($this->defaultValues, $this->data); - } - - /** - * @param int $entityId - * - * @return $this - */ - public function setEntityId($entityId) - { - return $this->_set(UrlRewrite::ENTITY_ID, $entityId); - } - - /** - * @param string $entityType - * - * @return $this - */ - public function setEntityType($entityType) - { - return $this->_set(UrlRewrite::ENTITY_TYPE, $entityType); - } - - /** - * @param int $isAutogenerated - * - * @return $this - */ - public function setIsAutogenerated($isAutogenerated) - { - return $this->_set(UrlRewrite::IS_AUTOGENERATED, $isAutogenerated); - } - - /** - * @param string $requestPath - * - * @return $this - */ - public function setRequestPath($requestPath) - { - return $this->_set(UrlRewrite::REQUEST_PATH, $requestPath); - } - - /** - * @param string $targetPath - * - * @return $this - */ - public function setTargetPath($targetPath) - { - return $this->_set(UrlRewrite::TARGET_PATH, $targetPath); - } - - /** - * @param int $storeId - * - * @return $this - */ - public function setStoreId($storeId) - { - return $this->_set(UrlRewrite::STORE_ID, $storeId); - } - - /** - * @param int $redirectCode - * - * @return $this - */ - public function setRedirectType($redirectCode) - { - return $this->_set(UrlRewrite::REDIRECT_TYPE, $redirectCode); - } - - /** - * @param string $description - * - * @return $this - */ - public function setDescription($description) - { - return $this->_set(UrlRewrite::DESCRIPTION, $description); - } - - /** - * @param array $metadata - * - * @return $this - */ - public function setMetadata(array $metadata) - { - $metadata = $metadata ? serialize($metadata) : null; - return $this->_set(UrlRewrite::METADATA, $metadata); - } -} diff --git a/app/code/Magento/UrlRewrite/Test/Unit/Model/Storage/AbstractStorageTest.php b/app/code/Magento/UrlRewrite/Test/Unit/Model/Storage/AbstractStorageTest.php index 8028689b81ee3675e67b49bef979ae315b7f3999..cf4623f3ac12ba59c82f1216da4f5ae33323eaf4 100644 --- a/app/code/Magento/UrlRewrite/Test/Unit/Model/Storage/AbstractStorageTest.php +++ b/app/code/Magento/UrlRewrite/Test/Unit/Model/Storage/AbstractStorageTest.php @@ -10,9 +10,14 @@ use Magento\UrlRewrite\Model\Storage\DuplicateEntryException; class AbstractStorageTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\UrlRewrite\Service\V1\Data\UrlRewriteBuilder|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\UrlRewrite\Service\V1\Data\UrlRewriteFactory|\PHPUnit_Framework_MockObject_MockObject */ - protected $urlRewriteBuilder; + protected $urlRewriteFactory; + + /** + * @var \Magento\Framework\Api\DataObjectHelper|\PHPUnit_Framework_MockObject_MockObject + */ + protected $dataObjectHelper; /** * @var \Magento\UrlRewrite\Model\Storage\AbstractStorage|\PHPUnit_Framework_MockObject_MockObject @@ -21,12 +26,15 @@ class AbstractStorageTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->urlRewriteBuilder = $this->getMockBuilder('Magento\UrlRewrite\Service\V1\Data\UrlRewriteBuilder') + $this->urlRewriteFactory = $this->getMockBuilder('Magento\UrlRewrite\Service\V1\Data\UrlRewriteFactory') + ->setMethods(['create']) + ->disableOriginalConstructor()->getMock(); + $this->dataObjectHelper = $this->getMockBuilder('Magento\Framework\Api\DataObjectHelper') ->disableOriginalConstructor()->getMock(); $this->storage = $this->getMockForAbstractClass( 'Magento\UrlRewrite\Model\Storage\AbstractStorage', - [$this->urlRewriteBuilder], + [$this->urlRewriteFactory, $this->dataObjectHelper], '', true, true, @@ -45,21 +53,21 @@ class AbstractStorageTest extends \PHPUnit_Framework_TestCase ->with($data) ->will($this->returnValue($rows)); - $this->urlRewriteBuilder->expects($this->at(0)) + $this->dataObjectHelper->expects($this->at(0)) ->method('populateWithArray') - ->with($rows[0]) + ->with($urlRewrites[0], $rows[0], '\Magento\UrlRewrite\Service\V1\Data\UrlRewrite') ->will($this->returnSelf()); - $this->urlRewriteBuilder->expects($this->at(1)) + $this->urlRewriteFactory->expects($this->at(0)) ->method('create') ->will($this->returnValue($urlRewrites[0])); - $this->urlRewriteBuilder->expects($this->at(2)) + $this->dataObjectHelper->expects($this->at(1)) ->method('populateWithArray') - ->with($rows[1]) + ->with($urlRewrites[1], $rows[1], '\Magento\UrlRewrite\Service\V1\Data\UrlRewrite') ->will($this->returnSelf()); - $this->urlRewriteBuilder->expects($this->at(3)) + $this->urlRewriteFactory->expects($this->at(1)) ->method('create') ->will($this->returnValue($urlRewrites[1])); @@ -89,12 +97,12 @@ class AbstractStorageTest extends \PHPUnit_Framework_TestCase ->with($data) ->will($this->returnValue($row)); - $this->urlRewriteBuilder->expects($this->once()) + $this->dataObjectHelper->expects($this->once()) ->method('populateWithArray') - ->with($row) + ->with($urlRewrite, $row, '\Magento\UrlRewrite\Service\V1\Data\UrlRewrite') ->will($this->returnSelf()); - $this->urlRewriteBuilder->expects($this->any()) + $this->urlRewriteFactory->expects($this->any()) ->method('create') ->will($this->returnValue($urlRewrite)); diff --git a/app/code/Magento/UrlRewrite/Test/Unit/Model/Storage/DbStorageTest.php b/app/code/Magento/UrlRewrite/Test/Unit/Model/Storage/DbStorageTest.php index a550deddf6eb978ed63c653b670b6aa89b9f25e9..8931b9531802b40a45302d8990e9ea38ae796e46 100644 --- a/app/code/Magento/UrlRewrite/Test/Unit/Model/Storage/DbStorageTest.php +++ b/app/code/Magento/UrlRewrite/Test/Unit/Model/Storage/DbStorageTest.php @@ -17,9 +17,14 @@ use Magento\UrlRewrite\Service\V1\Data\UrlRewrite; class DbStorageTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\UrlRewrite\Service\V1\Data\UrlRewriteBuilder|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\UrlRewrite\Service\V1\Data\UrlRewriteFactory|\PHPUnit_Framework_MockObject_MockObject */ - protected $urlRewriteBuilder; + protected $urlRewriteFactory; + + /** + * @var \Magento\Framework\Api\DataObjectHelper|\PHPUnit_Framework_MockObject_MockObject + */ + protected $dataObjectHelper; /** * @var \Magento\Framework\DB\Adapter\AdapterInterface|\PHPUnit_Framework_MockObject_MockObject @@ -43,7 +48,10 @@ class DbStorageTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->urlRewriteBuilder = $this->getMock('Magento\UrlRewrite\Service\V1\Data\UrlRewriteBuilder', [], [], '', + $this->urlRewriteFactory = $this->getMockBuilder('Magento\UrlRewrite\Service\V1\Data\UrlRewriteFactory') + ->setMethods(['create']) + ->disableOriginalConstructor()->getMock(); + $this->dataObjectHelper = $this->getMock('Magento\Framework\Api\DataObjectHelper', [], [], '', false); $this->adapter = $this->getMock('Magento\Framework\DB\Adapter\AdapterInterface'); $this->select = $this->getMock('Magento\Framework\DB\Select', ['from', 'where', 'deleteFromSelect'], [], '', @@ -61,7 +69,8 @@ class DbStorageTest extends \PHPUnit_Framework_TestCase $this->storage = (new ObjectManager($this))->getObject( 'Magento\UrlRewrite\Model\Storage\DbStorage', [ - 'urlRewriteBuilder' => $this->urlRewriteBuilder, + 'urlRewriteFactory' => $this->urlRewriteFactory, + 'dataObjectHelper' => $this->dataObjectHelper, 'resource' => $this->resource, ] ); @@ -88,21 +97,21 @@ class DbStorageTest extends \PHPUnit_Framework_TestCase ->with($this->select) ->will($this->returnValue([['row1'], ['row2']])); - $this->urlRewriteBuilder->expects($this->at(0)) + $this->dataObjectHelper->expects($this->at(0)) ->method('populateWithArray') - ->with(['row1']) + ->with(['urlRewrite1'], ['row1'], '\Magento\UrlRewrite\Service\V1\Data\UrlRewrite') ->will($this->returnSelf()); - $this->urlRewriteBuilder->expects($this->at(1)) + $this->urlRewriteFactory->expects($this->at(0)) ->method('create') ->will($this->returnValue(['urlRewrite1'])); - $this->urlRewriteBuilder->expects($this->at(2)) + $this->dataObjectHelper->expects($this->at(1)) ->method('populateWithArray') - ->with(['row2']) + ->with(['urlRewrite2'], ['row2'], '\Magento\UrlRewrite\Service\V1\Data\UrlRewrite') ->will($this->returnSelf()); - $this->urlRewriteBuilder->expects($this->at(3)) + $this->urlRewriteFactory->expects($this->at(1)) ->method('create') ->will($this->returnValue(['urlRewrite2'])); @@ -130,12 +139,12 @@ class DbStorageTest extends \PHPUnit_Framework_TestCase ->with($this->select) ->will($this->returnValue(['row1'])); - $this->urlRewriteBuilder->expects($this->at(0)) + $this->dataObjectHelper->expects($this->at(0)) ->method('populateWithArray') - ->with(['row1']) + ->with(['urlRewrite1'], ['row1'], '\Magento\UrlRewrite\Service\V1\Data\UrlRewrite') ->will($this->returnSelf()); - $this->urlRewriteBuilder->expects($this->at(1)) + $this->urlRewriteFactory->expects($this->at(0)) ->method('create') ->will($this->returnValue(['urlRewrite1'])); diff --git a/app/code/Magento/Weee/Model/Attribute/Backend/Weee/Tax.php b/app/code/Magento/Weee/Model/Attribute/Backend/Weee/Tax.php index 5475b7dd14632855e9adc3b8f377d2cd49f67079..aafe267ef947396a24fe9390d52d9dd4a2e67c52 100644 --- a/app/code/Magento/Weee/Model/Attribute/Backend/Weee/Tax.php +++ b/app/code/Magento/Weee/Model/Attribute/Backend/Weee/Tax.php @@ -74,7 +74,7 @@ class Tax extends \Magento\Catalog\Model\Product\Attribute\Backend\Price continue; } - $state = isset($tax['state']) ? $tax['state'] : '*'; + $state = isset($tax['state']) ? $tax['state'] : '0'; $key1 = implode('-', [$tax['website_id'], $tax['country'], $state]); if (!empty($dup[$key1])) { @@ -139,11 +139,7 @@ class Tax extends \Magento\Catalog\Model\Product\Attribute\Backend\Price continue; } - if (isset($tax['state']) && $tax['state']) { - $state = $tax['state']; - } else { - $state = '0'; - } + $state = isset($tax['state']) ? $tax['state'] : '0'; $data = []; $data['website_id'] = $tax['website_id']; diff --git a/app/code/Magento/Weee/Model/Tax.php b/app/code/Magento/Weee/Model/Tax.php index 7eab12df0722dbead3edf7667a66d52aab10a2c8..63c3f17d0147922da91d0d1a7534ca448968300d 100644 --- a/app/code/Magento/Weee/Model/Tax.php +++ b/app/code/Magento/Weee/Model/Tax.php @@ -263,7 +263,7 @@ class Tax extends \Magento\Framework\Model\AbstractModel $rateRequest->getCountryId() )->where( 'state IN(?)', - [$rateRequest->getRegionId(), '*'] + [$rateRequest->getRegionId(), 0] )->where( 'entity_id = ?', (int)$product->getId() diff --git a/app/code/Magento/Weee/Model/Total/Creditmemo/Weee.php b/app/code/Magento/Weee/Model/Total/Creditmemo/Weee.php index 4107c5d55a44174261641944f63fb4e983910f82..d45eab656ca2a5eaf6c41e5f17125b87dc6b2f8b 100644 --- a/app/code/Magento/Weee/Model/Total/Creditmemo/Weee.php +++ b/app/code/Magento/Weee/Model/Total/Creditmemo/Weee.php @@ -80,8 +80,6 @@ class Weee extends \Magento\Sales\Model\Order\Creditmemo\Total\AbstractTotal 'base' ); - $orderItemTaxAmount = $orderItemWeeeAmountInclTax - $orderItemWeeeAmountExclTax; - $orderItemBaseTaxAmount = $orderItemBaseWeeeAmountInclTax - $baseWeeeAmountInclTax; $itemTaxAmount = $weeeAmountInclTax - $weeeAmountExclTax; $itemBaseTaxAmount = $baseWeeeAmountInclTax - $baseWeeeAmountExclTax; @@ -117,6 +115,7 @@ class Weee extends \Magento\Sales\Model\Order\Creditmemo\Total\AbstractTotal //Set the ratio of the tax amount in invoice item compared to tax amount in order item //This information is needed to calculate tax per tax rate later + $orderItemTaxAmount = $orderItemWeeeAmountInclTax - $orderItemWeeeAmountExclTax; if ($orderItemTaxAmount != 0) { $taxRatio = []; if ($item->getTaxRatio()) { @@ -132,7 +131,7 @@ class Weee extends \Magento\Sales\Model\Order\Creditmemo\Total\AbstractTotal $newApplied = []; $applied = $this->_weeeData->getApplied($orderItem); foreach ($applied as $one) { - $title = $one['title']; + $title = (string)$one['title']; $one['base_row_amount'] = $creditmemo->roundPrice($one['base_row_amount'] * $ratio, $title.'_base'); $one['row_amount'] = $creditmemo->roundPrice($one['row_amount'] * $ratio, $title); $one['base_row_amount_incl_tax'] = $creditmemo->roundPrice( diff --git a/app/code/Magento/Weee/Model/Total/Invoice/Weee.php b/app/code/Magento/Weee/Model/Total/Invoice/Weee.php index b89362baf000fa84ca1d9aa4d89441e4a5f3925d..457a08ccd86691eac2615dcbffcc5571bc8eaf6e 100644 --- a/app/code/Magento/Weee/Model/Total/Invoice/Weee.php +++ b/app/code/Magento/Weee/Model/Total/Invoice/Weee.php @@ -104,7 +104,7 @@ class Weee extends \Magento\Sales\Model\Order\Invoice\Total\AbstractTotal $newApplied = []; $applied = $this->_weeeData->getApplied($orderItem); foreach ($applied as $one) { - $title = $one['title']; + $title = (string)$one['title']; $one['base_row_amount'] = $invoice->roundPrice($one['base_row_amount'] * $ratio, $title.'_base'); $one['row_amount'] = $invoice->roundPrice($one['row_amount'] * $ratio, $title); $one['base_row_amount_incl_tax'] = $invoice->roundPrice( diff --git a/app/code/Magento/Weee/Setup/InstallSchema.php b/app/code/Magento/Weee/Setup/InstallSchema.php index a5e6d0ff2351f501d8f39065edf82d06dd3ca8ef..c304dd40f5a099ea51e588c7fd3c35fca3adb148 100644 --- a/app/code/Magento/Weee/Setup/InstallSchema.php +++ b/app/code/Magento/Weee/Setup/InstallSchema.php @@ -59,9 +59,9 @@ class InstallSchema implements InstallSchemaInterface 'Value' )->addColumn( 'state', - \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, - 255, - ['nullable' => false, 'default' => '*'], + \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, + null, + ['nullable' => false, 'default' => '0'], 'State' )->addColumn( 'attribute_id', @@ -69,12 +69,6 @@ class InstallSchema implements InstallSchemaInterface null, ['unsigned' => true, 'nullable' => false], 'Attribute Id' - )->addColumn( - 'entity_type_id', - \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, - null, - ['unsigned' => true, 'nullable' => false], - 'Entity Type Id' )->addIndex( $setup->getIdxName('weee_tax', ['website_id']), ['website_id'] diff --git a/app/code/Magento/Weee/Setup/UpgradeSchema.php b/app/code/Magento/Weee/Setup/UpgradeSchema.php deleted file mode 100644 index 2b025a60d0905185fc7e5d56d8a9dc7dbbc5c163..0000000000000000000000000000000000000000 --- a/app/code/Magento/Weee/Setup/UpgradeSchema.php +++ /dev/null @@ -1,33 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -namespace Magento\Weee\Setup; - -use Magento\Framework\Setup\UpgradeSchemaInterface; -use Magento\Framework\Setup\ModuleContextInterface; -use Magento\Framework\Setup\SchemaSetupInterface; - -/** - * @codeCoverageIgnore - */ -class UpgradeSchema implements UpgradeSchemaInterface -{ - /** - * {@inheritdoc} - */ - public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $context) - { - if (version_compare($context->getVersion(), '2.0.0.1') < 0) { - $setup->startSetup(); - $connection = $setup->getConnection(); - - //Drop entity_type_id column for wee tax table - $connection->dropColumn($setup->getTable('weee_tax'), 'entity_type_id'); - - $setup->endSetup(); - } - } -} diff --git a/app/code/Magento/Weee/Test/Unit/Model/Attribute/Backend/Weee/TaxTest.php b/app/code/Magento/Weee/Test/Unit/Model/Attribute/Backend/Weee/TaxTest.php index 4d77625dea7b38e98c43a1cc84b52c16a9e1bf33..982ab25d288565668c73243dcff2165ceeb821ad 100644 --- a/app/code/Magento/Weee/Test/Unit/Model/Attribute/Backend/Weee/TaxTest.php +++ b/app/code/Magento/Weee/Test/Unit/Model/Attribute/Backend/Weee/TaxTest.php @@ -51,7 +51,7 @@ class TaxTest extends \PHPUnit_Framework_TestCase ->method('getAttribute') ->will($this->returnValue($attributeMock)); - $taxes = [['state' => 'Texas', 'country' => 'US', 'website_id' => '1']]; + $taxes = [['state' => 12, 'country' => 'US', 'website_id' => '1']]; $productMock = $this->getMockBuilder('Magento\Catalog\Model\Product') ->setMethods(['getData']) ->disableOriginalConstructor() @@ -64,8 +64,8 @@ class TaxTest extends \PHPUnit_Framework_TestCase // No exception $modelMock->validate($productMock); - $taxes = [['state' => 'Texas', 'country' => 'US', 'website_id' => '1'], - ['state' => 'Texas', 'country' => 'US', 'website_id' => '1']]; + $taxes = [['state' => 12, 'country' => 'US', 'website_id' => '1'], + ['state' => 12, 'country' => 'US', 'website_id' => '1']]; $productMock = $this->getMockBuilder('Magento\Catalog\Model\Product') ->setMethods(['getData']) ->disableOriginalConstructor() @@ -188,14 +188,14 @@ class TaxTest extends \PHPUnit_Framework_TestCase { return [ 'withRegion' => [ - 'origData' => [['state' => 'TX', 'country' => 'US', 'website_id' => '1']], - 'currentData' => [['state' => 'TX', 'country' => 'US', 'website_id' => '2', 'price' => 100]], - 'expectedData' => ['state' => 'TX', 'country' => 'US', 'website_id' => '2', 'value' => 100, + 'origData' => [['state' => 12, 'country' => 'US', 'website_id' => '1']], + 'currentData' => [['state' => 12, 'country' => 'US', 'website_id' => '2', 'price' => 100]], + 'expectedData' => ['state' => 12, 'country' => 'US', 'website_id' => '2', 'value' => 100, 'attribute_id' => 1]], 'withNoRegion' => [ - 'origData' => [['state' => '0', 'country' => 'US', 'website_id' => '1']], - 'currentData' => [['state' => '0', 'country' => 'US', 'website_id' => '2', 'price' => 100]], - 'expectedData' => ['state' => '0', 'country' => 'US', 'website_id' => '2', 'value' => 100, + 'origData' => [['country' => 'US', 'website_id' => '1']], + 'currentData' => [['country' => 'US', 'website_id' => '2', 'price' => 100]], + 'expectedData' => ['state' => 0, 'country' => 'US', 'website_id' => '2', 'value' => 100, 'attribute_id' => 1]] ]; } diff --git a/app/code/Magento/Weee/etc/fieldset.xml b/app/code/Magento/Weee/etc/fieldset.xml index 0583276631dee52c0ceecafbc8cfe6e13950694d..3412772efede312f50cc76c38eca88fc53da726d 100644 --- a/app/code/Magento/Weee/etc/fieldset.xml +++ b/app/code/Magento/Weee/etc/fieldset.xml @@ -8,7 +8,7 @@ <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Object/etc/fieldset.xsd"> <scope id="global"> - <fieldset id="sales_convert_quote_item"> + <fieldset id="quote_convert_item"> <field name="weee_tax_applied"> <aspect name="to_order_item" /> </field> @@ -37,6 +37,35 @@ <aspect name="to_order_item" /> </field> </fieldset> + <fieldset id="sales_convert_quote"> + <field name="weee_tax_applied"> + <aspect name="to_order" /> + </field> + <field name="weee_tax_applied_amount"> + <aspect name="to_order" /> + </field> + <field name="weee_tax_applied_row_amount"> + <aspect name="to_order" /> + </field> + <field name="base_weee_tax_applied_amount"> + <aspect name="to_order" /> + </field> + <field name="base_weee_tax_applied_row_amnt"> + <aspect name="to_order" /> + </field> + <field name="weee_tax_disposition"> + <aspect name="to_order" /> + </field> + <field name="base_weee_tax_disposition"> + <aspect name="to_order" /> + </field> + <field name="weee_tax_row_disposition"> + <aspect name="to_order" /> + </field> + <field name="base_weee_tax_row_disposition"> + <aspect name="to_order" /> + </field> + </fieldset> <fieldset id="sales_convert_order_item"> <field name="weee_tax_applied"> <aspect name="to_cm_item" /> diff --git a/app/code/Magento/Weee/view/adminhtml/templates/order/create/items/price/total.phtml b/app/code/Magento/Weee/view/adminhtml/templates/order/create/items/price/total.phtml index 2604efdebb3905f5530cbbcb01a677bdbd39534f..c244c34fcd635225bca5de9e01951e13ad4d1b65 100644 --- a/app/code/Magento/Weee/view/adminhtml/templates/order/create/items/price/total.phtml +++ b/app/code/Magento/Weee/view/adminhtml/templates/order/create/items/price/total.phtml @@ -46,7 +46,7 @@ $_item = $block->getItem(); <?php if ($block->displayBothPrices()): ?> <br /><span class="label"><?php echo __('Incl. Tax'); ?>:</span> <?php endif; ?> - <?php $_incl = $block->getRowDisplayPriceInclTax() - $_item->getTotalDiscountAmount(); ?> + <?php $_incl = $block->getTotalAmount($_item); ?> <?php echo $block->formatPrice(max(0, $_incl)) ?> <?php if ($this->helper('Magento\Weee\Helper\Data')->getApplied($_item)): ?> <br /> diff --git a/app/etc/di.xml b/app/etc/di.xml index 6ae1eaa1529f5d0f392f41de92ef6248fa7d94f0..48402892228cc368b5457502ed828f9a27e4655d 100755 --- a/app/etc/di.xml +++ b/app/etc/di.xml @@ -82,8 +82,8 @@ <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\AttributeMetadataBuilderInterface" type="Magento\Framework\Api\AttributeMetadataBuilder"/> <preference for="Magento\Framework\Api\MetadataServiceInterface" type="Magento\Framework\Api\Config\MetadataConfig"/> + <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"/> <preference for="Magento\Framework\DB\LoggerInterface" type="Magento\Framework\DB\Logger\Null"/> diff --git a/app/etc/vendor_path.php b/app/etc/vendor_path.php index bd9482bb36ae0879f2f38c9747b28b05f99413e0..b6af03ef32fa48938f0a80ce7194f177a56e1177 100755 --- a/app/etc/vendor_path.php +++ b/app/etc/vendor_path.php @@ -1,10 +1,5 @@ <?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - /** * Path to Composer vendor directory */ -return 'vendor'; +return './vendor'; diff --git a/composer.json b/composer.json index f22f996c07214bdff779c678a7c4615c1f0f02a8..e29f9de8be6ff85c6eeebf84e5da449dedeba559 100644 --- a/composer.json +++ b/composer.json @@ -32,7 +32,8 @@ "magento/zendframework1": "1.12.10", "composer/composer": "1.0.0-alpha8", "monolog/monolog": "1.11.0", - "tubalmartin/cssmin": "2.4.8-p4" + "tubalmartin/cssmin": "2.4.8-p4", + "magento/magento-composer-installer": "*" }, "require-dev": { "phpunit/phpunit": "4.1.0", @@ -194,7 +195,8 @@ }, "autoload": { "psr-4": { - "Magento\\Framework\\": "lib/internal/Magento/Framework/" + "Magento\\Framework\\": "lib/internal/Magento/Framework/", + "Magento\\Setup\\": "setup/src/Magento/Setup/" } }, "autoload-dev": { @@ -204,8 +206,7 @@ "Magento\\Tools\\Sanity\\": "dev/build/publication/sanity/Magento/Tools/Sanity/", "Magento\\TestFramework\\Inspection\\": "dev/tests/static/framework/Magento/TestFramework/Inspection/", "Magento\\TestFramework\\Utility\\": "dev/tests/static/framework/Magento/TestFramework/Utility/", - "Magento\\ToolkitFramework\\": "dev/tools/performance-toolkit/framework/Magento/ToolkitFramework/", - "Magento\\Setup\\": "setup/src/Magento/Setup/" + "Magento\\ToolkitFramework\\": "dev/tools/performance-toolkit/framework/Magento/ToolkitFramework/" } } } diff --git a/composer.lock b/composer.lock index 02b43c39d185181e4bb80017a35c3dcb4b364d35..5337e32b2c094312a9be6fb56bafbc7632a931d5 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": "498056a32c33c43d23e5d2ee37362a2d", + "hash": "933a1cf749db0c7e6d16e357c12cdaa8", "packages": [ { "name": "composer/composer", @@ -131,6 +131,82 @@ ], "time": "2012-01-03 00:33:17" }, + { + "name": "magento/magento-composer-installer", + "version": "0.1.4", + "source": { + "type": "git", + "url": "https://github.com/magento/magento-composer-installer.git", + "reference": "7f03451f71e55d52c2bb07325d56a4e6df322f30" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/magento/magento-composer-installer/zipball/7f03451f71e55d52c2bb07325d56a4e6df322f30", + "reference": "7f03451f71e55d52c2bb07325d56a4e6df322f30", + "shasum": "" + }, + "require": { + "composer-plugin-api": "1.0.0" + }, + "require-dev": { + "composer/composer": "*@dev", + "firegento/phpcs": "dev-patch-1", + "mikey179/vfsstream": "*", + "phpunit/phpunit": "*", + "phpunit/phpunit-mock-objects": "dev-master", + "squizlabs/php_codesniffer": "1.4.7", + "symfony/process": "*" + }, + "type": "composer-plugin", + "extra": { + "composer-command-registry": [ + "MagentoHackathon\\Composer\\Magento\\Command\\DeployCommand" + ], + "class": "MagentoHackathon\\Composer\\Magento\\Plugin" + }, + "autoload": { + "psr-0": { + "MagentoHackathon\\Composer\\Magento": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "OSL-3.0" + ], + "authors": [ + { + "name": "Vinai Kopp", + "email": "vinai@netzarbeiter.com" + }, + { + "name": "Daniel Fahlke aka Flyingmana", + "email": "flyingmana@googlemail.com" + }, + { + "name": "Jörg Weller", + "email": "weller@flagbit.de" + }, + { + "name": "Karl Spies", + "email": "karl.spies@gmx.net" + }, + { + "name": "Tobias Vogt", + "email": "tobi@webguys.de" + }, + { + "name": "David Fuhr", + "email": "fuhr@flagbit.de" + } + ], + "description": "Composer installer for Magento modules", + "homepage": "https://github.com/magento/magento-composer-installer", + "keywords": [ + "composer-installer", + "magento" + ], + "time": "2015-03-05 21:40:30" + }, { "name": "magento/zendframework1", "version": "1.12.10", 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 8975db0fa437fa639d6a685694cafdb36c826ad7..f5f821b4fb2a578ec20c93c4694f417dc0180e55 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,32 +5,32 @@ */ namespace Magento\TestModule1\Service\V1; -use Magento\TestModule1\Service\V1\Entity\CustomAttributeDataObjectBuilder; +use Magento\TestModule1\Service\V1\Entity\CustomAttributeDataObjectFactory; use Magento\TestModule1\Service\V1\Entity\Item; -use Magento\TestModule1\Service\V1\Entity\ItemBuilder; +use Magento\TestModule1\Service\V1\Entity\ItemFactory; class AllSoapAndRest implements \Magento\TestModule1\Service\V1\AllSoapAndRestInterface { /** - * @var ItemBuilder + * @var ItemFactory */ - protected $itemBuilder; + protected $itemFactory; /** - * @var CustomAttributeDataObjectBuilder + * @var CustomAttributeDataObjectFactory */ - protected $customAttributeDataObjectBuilder; + protected $customAttributeDataObjectFactory; /** - * @param ItemBuilder $itemBuilder - * @param CustomAttributeDataObjectBuilder $customAttributeNestedDataObjectBuilder + * @param ItemFactory $itemFactory + * @param CustomAttributeDataObjectFactory $customAttributeNestedDataObjectFactory */ public function __construct( - ItemBuilder $itemBuilder, - CustomAttributeDataObjectBuilder $customAttributeNestedDataObjectBuilder + ItemFactory $itemFactory, + CustomAttributeDataObjectFactory $customAttributeNestedDataObjectFactory ) { - $this->itemBuilder = $itemBuilder; - $this->customAttributeDataObjectBuilder = $customAttributeNestedDataObjectBuilder; + $this->itemFactory = $itemFactory; + $this->customAttributeDataObjectFactory = $customAttributeNestedDataObjectFactory; } /** @@ -38,7 +38,7 @@ class AllSoapAndRest implements \Magento\TestModule1\Service\V1\AllSoapAndRestIn */ public function item($itemId) { - return $this->itemBuilder->setItemId($itemId)->setName('testProduct1')->create(); + return $this->itemFactory->create()->setItemId($itemId)->setName('testProduct1'); } /** @@ -46,8 +46,8 @@ class AllSoapAndRest implements \Magento\TestModule1\Service\V1\AllSoapAndRestIn */ public function items() { - $result1 = $this->itemBuilder->setItemId(1)->setName('testProduct1')->create(); - $result2 = $this->itemBuilder->setItemId(2)->setName('testProduct2')->create(); + $result1 = $this->itemFactory->create()->setItemId(1)->setName('testProduct1'); + $result2 = $this->itemFactory->create()->setItemId(2)->setName('testProduct2'); return [$result1, $result2]; } @@ -57,7 +57,7 @@ class AllSoapAndRest implements \Magento\TestModule1\Service\V1\AllSoapAndRestIn */ public function create($name) { - return $this->itemBuilder->setItemId(rand())->setName($name)->create(); + return $this->itemFactory->create()->setItemId(rand())->setName($name); } /** @@ -65,17 +65,16 @@ class AllSoapAndRest implements \Magento\TestModule1\Service\V1\AllSoapAndRestIn */ public function update(Item $entityItem) { - return $this->itemBuilder->setItemId($entityItem->getItemId()) - ->setName('Updated' . $entityItem->getName()) - ->create(); + return $this->itemFactory->create()->setItemId($entityItem->getItemId()) + ->setName('Updated' . $entityItem->getName()); } public function testOptionalParam($name = null) { if (is_null($name)) { - return $this->itemBuilder->setItemId(3)->setName('No Name')->create(); + return $this->itemFactory->create()->setItemId(3)->setName('No Name'); } else { - return $this->itemBuilder->setItemId(3)->setName($name)->create(); + return $this->itemFactory->create()->setItemId(3)->setName($name); } } @@ -92,17 +91,15 @@ class AllSoapAndRest implements \Magento\TestModule1\Service\V1\AllSoapAndRestIn */ public function getPreconfiguredItem() { - $customAttributeDataObject = $this->customAttributeDataObjectBuilder + $customAttributeDataObject = $this->customAttributeDataObjectFactory->create() ->setName('nameValue') - ->setCustomAttribute('custom_attribute_int', 1) - ->create(); + ->setCustomAttribute('custom_attribute_int', 1); - $item = $this->itemBuilder + $item = $this->itemFactory->create() ->setItemId(1) ->setName('testProductAnyType') ->setCustomAttribute('custom_attribute_data_object', $customAttributeDataObject) - ->setCustomAttribute('custom_attribute_string', 'someStringValue') - ->create(); + ->setCustomAttribute('custom_attribute_string', 'someStringValue'); return $item; } 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 index c902c5ad8d9877c416e1546b522f3b4c5371dde1..05c5581b7d1afb01ad5b3a8e61424c1f39656dc9 100644 --- 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 @@ -3,6 +3,9 @@ * 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 @@ -14,4 +17,12 @@ class CustomAttributeDataObject extends \Magento\Framework\Api\AbstractExtensibl { 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/CustomAttributeDataObjectBuilder.php b/dev/tests/api-functional/_files/Magento/TestModule1/Service/V1/Entity/CustomAttributeDataObjectBuilder.php deleted file mode 100644 index b66f00c0f4a1bc29bf18254f57ea1e09c836c7dd..0000000000000000000000000000000000000000 --- a/dev/tests/api-functional/_files/Magento/TestModule1/Service/V1/Entity/CustomAttributeDataObjectBuilder.php +++ /dev/null @@ -1,21 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -namespace Magento\TestModule1\Service\V1\Entity; - -class CustomAttributeDataObjectBuilder extends \Magento\Framework\Api\ExtensibleObjectBuilder -{ - /** - * @param string $name - * - * @return $this - */ - public function setName($name) - { - $this->data['name'] = $name; - return $this; - } -} 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 index a794774c3f7f314e95d9a01ce0a56860341331cc..d1ead31be911b0f0895150e7e433cde576ddb8a8 100644 --- 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 @@ -3,6 +3,9 @@ * 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 @@ -14,4 +17,13 @@ class CustomAttributeNestedDataObject extends \Magento\Framework\Api\AbstractExt { 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/CustomAttributeNestedDataObjectBuilder.php b/dev/tests/api-functional/_files/Magento/TestModule1/Service/V1/Entity/CustomAttributeNestedDataObjectBuilder.php deleted file mode 100644 index 84ec340dc087fd3274e2ac6ac2b5a5089d0f891c..0000000000000000000000000000000000000000 --- a/dev/tests/api-functional/_files/Magento/TestModule1/Service/V1/Entity/CustomAttributeNestedDataObjectBuilder.php +++ /dev/null @@ -1,21 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -namespace Magento\TestModule1\Service\V1\Entity; - -class CustomAttributeNestedDataObjectBuilder extends \Magento\Framework\Api\ExtensibleObjectBuilder -{ - /** - * @param string $name - * - * @return $this - */ - public function setName($name) - { - $this->data['name'] = $name; - return $this; - } -} 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 index 0541cefb3e8ffe665c087a93b033e1ae43a96cb8..b8a87f3d74056569a1fe6a502c8985cd4148d86b 100644 --- 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 @@ -3,6 +3,9 @@ * 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; @@ -31,6 +34,17 @@ class AttributeMetadata extends AbstractExtensibleObject implements MetadataObje 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. * @@ -40,4 +54,15 @@ class AttributeMetadata extends AbstractExtensibleObject implements MetadataObje { 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/Service/V1/Entity/Eav/AttributeMetadataBuilder.php b/dev/tests/api-functional/_files/Magento/TestModule1/Service/V1/Entity/Eav/AttributeMetadataBuilder.php deleted file mode 100644 index 84a3d9cb0f4207e5f4703bbaa302928b1ace35a1..0000000000000000000000000000000000000000 --- a/dev/tests/api-functional/_files/Magento/TestModule1/Service/V1/Entity/Eav/AttributeMetadataBuilder.php +++ /dev/null @@ -1,37 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\TestModule1\Service\V1\Entity\Eav; - -use Magento\Framework\Api\AttributeMetadataBuilderInterface; -use Magento\Framework\Api\ExtensibleObjectBuilder; - -/** - * Class AttributeMetadataBuilder - */ -class AttributeMetadataBuilder extends ExtensibleObjectBuilder implements AttributeMetadataBuilderInterface -{ - /** - * Set attribute id - * - * @param int $attributeId - * @return $this - */ - public function setAttributeId($attributeId) - { - return $this->_set(AttributeMetadata::ATTRIBUTE_ID, $attributeId); - } - - /** - * Set attribute code - * - * @param string $attributeCode - * @return $this - */ - public function setAttributeCode($attributeCode) - { - return $this->_set(AttributeMetadata::ATTRIBUTE_CODE, $attributeCode); - } -} diff --git a/dev/tests/api-functional/_files/Magento/TestModule1/Service/V1/Entity/Item.php b/dev/tests/api-functional/_files/Magento/TestModule1/Service/V1/Entity/Item.php index 80ec81c542d9a4e52a4260256781d9e8cbd4ea2b..3abf3f7134834175768cd408f1e8e0df48a0e578 100644 --- a/dev/tests/api-functional/_files/Magento/TestModule1/Service/V1/Entity/Item.php +++ b/dev/tests/api-functional/_files/Magento/TestModule1/Service/V1/Entity/Item.php @@ -7,6 +7,14 @@ namespace Magento\TestModule1\Service\V1\Entity; class Item extends \Magento\Framework\Api\AbstractExtensibleObject { + /**#@+ + * Custom attribute code constants + */ + const CUSTOM_ATTRIBUTE_1 = 'custom_attribute1'; + const CUSTOM_ATTRIBUTE_2 = 'custom_attribute2'; + const CUSTOM_ATTRIBUTE_3 = 'custom_attribute3'; + /**#@-*/ + /** * @return int */ @@ -15,6 +23,15 @@ class Item extends \Magento\Framework\Api\AbstractExtensibleObject return $this->_data['item_id']; } + /** + * @param int $itemId + * @return $this + */ + public function setItemId($itemId) + { + return $this->setData('item_id', $itemId); + } + /** * @return string */ @@ -22,4 +39,26 @@ class Item extends \Magento\Framework\Api\AbstractExtensibleObject { return $this->_data['name']; } + + /** + * @param string $name + * @return $this + */ + public function setName($name) + { + return $this->setData('name', $name); + } + + /** + * Template method used to configure the attribute codes for the custom attributes + * + * @return string[] + */ + protected function getCustomAttributesCodes() + { + return array_merge( + parent::getCustomAttributesCodes(), + [self::CUSTOM_ATTRIBUTE_1, self::CUSTOM_ATTRIBUTE_2, self::CUSTOM_ATTRIBUTE_3] + ); + } } diff --git a/dev/tests/api-functional/_files/Magento/TestModule1/Service/V1/Entity/ItemBuilder.php b/dev/tests/api-functional/_files/Magento/TestModule1/Service/V1/Entity/ItemBuilder.php deleted file mode 100644 index 5da49d73bba44d8306061118c31f1a5546e28f97..0000000000000000000000000000000000000000 --- a/dev/tests/api-functional/_files/Magento/TestModule1/Service/V1/Entity/ItemBuilder.php +++ /dev/null @@ -1,52 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\TestModule1\Service\V1\Entity; - -class ItemBuilder extends \Magento\Framework\Api\ExtensibleObjectBuilder -{ - /**#@+ - * Custom attribute code constants - */ - const CUSTOM_ATTRIBUTE_1 = 'custom_attribute1'; - const CUSTOM_ATTRIBUTE_2 = 'custom_attribute2'; - const CUSTOM_ATTRIBUTE_3 = 'custom_attribute3'; - /**#@-*/ - - /** - * @param int $itemId - * - * @return \Magento\TestModule1\Service\V1\Entity\ItemBuilder - */ - public function setItemId($itemId) - { - $this->data['item_id'] = $itemId; - return $this; - } - - /** - * @param string $name - * - * @return \Magento\TestModule1\Service\V1\Entity\ItemBuilder - */ - public function setName($name) - { - $this->data['name'] = $name; - return $this; - } - - /** - * Template method used to configure the attribute codes for the custom attributes - * - * @return string[] - */ - public function getCustomAttributesCodes() - { - return array_merge( - parent::getCustomAttributesCodes(), - [self::CUSTOM_ATTRIBUTE_1, self::CUSTOM_ATTRIBUTE_2, self::CUSTOM_ATTRIBUTE_3] - ); - } -} diff --git a/dev/tests/api-functional/_files/Magento/TestModule1/Service/V2/AllSoapAndRest.php b/dev/tests/api-functional/_files/Magento/TestModule1/Service/V2/AllSoapAndRest.php index 407086eacee8989460d982407f276df4a4f76e77..de633fa9a193b6ce5810c576da21f6a5bbef8887 100644 --- a/dev/tests/api-functional/_files/Magento/TestModule1/Service/V2/AllSoapAndRest.php +++ b/dev/tests/api-functional/_files/Magento/TestModule1/Service/V2/AllSoapAndRest.php @@ -6,21 +6,21 @@ namespace Magento\TestModule1\Service\V2; use Magento\TestModule1\Service\V2\Entity\Item; -use Magento\TestModule1\Service\V2\Entity\ItemBuilder; +use Magento\TestModule1\Service\V2\Entity\ItemFactory; class AllSoapAndRest implements \Magento\TestModule1\Service\V2\AllSoapAndRestInterface { /** - * @var ItemBuilder + * @var ItemFactory */ - protected $itemBuilder; + protected $itemFactory; /** - * @param ItemBuilder $itemBuilder + * @param ItemFactory $itemFactory */ - public function __construct(ItemBuilder $itemBuilder) + public function __construct(ItemFactory $itemFactory) { - $this->itemBuilder = $itemBuilder; + $this->itemFactory = $itemFactory; } /** @@ -28,7 +28,7 @@ class AllSoapAndRest implements \Magento\TestModule1\Service\V2\AllSoapAndRestIn */ public function item($id) { - return $this->itemBuilder->setId($id)->setName('testProduct1')->setPrice('1')->create(); + return $this->itemFactory->create()->setId($id)->setName('testProduct1')->setPrice('1'); } /** @@ -37,8 +37,8 @@ class AllSoapAndRest implements \Magento\TestModule1\Service\V2\AllSoapAndRestIn public function items($filters = [], $sortOrder = 'ASC') { $result = []; - $firstItem = $this->itemBuilder->setId(1)->setName('testProduct1')->setPrice('1')->create(); - $secondItem = $this->itemBuilder->setId(2)->setName('testProduct2')->setPrice('2')->create(); + $firstItem = $this->itemFactory->create()->setId(1)->setName('testProduct1')->setPrice('1'); + $secondItem = $this->itemFactory->create()->setId(2)->setName('testProduct2')->setPrice('2'); /** Simple filtration implementation */ if (!empty($filters)) { @@ -62,7 +62,7 @@ class AllSoapAndRest implements \Magento\TestModule1\Service\V2\AllSoapAndRestIn */ public function create($name) { - return $this->itemBuilder->setId(rand())->setName($name)->setPrice('10')->create(); + return $this->itemFactory->create()->setId(rand())->setName($name)->setPrice('10'); } /** @@ -70,10 +70,10 @@ class AllSoapAndRest implements \Magento\TestModule1\Service\V2\AllSoapAndRestIn */ public function update(Item $entityItem) { - return $this->itemBuilder + return $this->itemFactory->create() ->setId($entityItem->getId()) ->setName('Updated' . $entityItem->getName()) - ->setPrice('5')->create(); + ->setPrice('5'); } /** @@ -81,6 +81,6 @@ class AllSoapAndRest implements \Magento\TestModule1\Service\V2\AllSoapAndRestIn */ public function delete($id) { - return $this->itemBuilder->setId($id)->setName('testProduct1')->setPrice('1')->create(); + return $this->itemFactory->create()->setId($id)->setName('testProduct1')->setPrice('1'); } } diff --git a/dev/tests/api-functional/_files/Magento/TestModule1/Service/V2/Entity/Item.php b/dev/tests/api-functional/_files/Magento/TestModule1/Service/V2/Entity/Item.php index 9d3f4b857e3ab95523185331d20510871e5debee..891ff49d1cffc949d3302c200e87e93586fa437b 100644 --- a/dev/tests/api-functional/_files/Magento/TestModule1/Service/V2/Entity/Item.php +++ b/dev/tests/api-functional/_files/Magento/TestModule1/Service/V2/Entity/Item.php @@ -15,6 +15,15 @@ class Item extends \Magento\Framework\Api\AbstractExtensibleObject return $this->_data['id']; } + /** + * @param int $id + * @return $this + */ + public function setId($id) + { + return $this->setData('id', $id); + } + /** * @return string */ @@ -23,6 +32,15 @@ class Item extends \Magento\Framework\Api\AbstractExtensibleObject return $this->_data['name']; } + /** + * @param string $name + * @return $this + */ + public function setName($name) + { + return $this->setData('name', $name); + } + /** * @return string */ @@ -30,4 +48,13 @@ class Item extends \Magento\Framework\Api\AbstractExtensibleObject { return $this->_data['price']; } + + /** + * @param string $price + * @return $this + */ + public function setPrice($price) + { + return $this->setData('price', $price); + } } diff --git a/dev/tests/api-functional/_files/Magento/TestModule1/Service/V2/Entity/ItemBuilder.php b/dev/tests/api-functional/_files/Magento/TestModule1/Service/V2/Entity/ItemBuilder.php deleted file mode 100644 index 44cc72e7ce63fcf2b1fa3ec95b7cf72d95d8a17f..0000000000000000000000000000000000000000 --- a/dev/tests/api-functional/_files/Magento/TestModule1/Service/V2/Entity/ItemBuilder.php +++ /dev/null @@ -1,42 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\TestModule1\Service\V2\Entity; - -class ItemBuilder extends \Magento\Framework\Api\ExtensibleObjectBuilder -{ - /** - * @param int $id - * - * @return \Magento\TestModule1\Service\V2\Entity\ItemBuilder - */ - public function setId($id) - { - $this->data['id'] = $id; - return $this; - } - - /** - * @param string $name - * - * @return \Magento\TestModule1\Service\V2\Entity\ItemBuilder - */ - public function setName($name) - { - $this->data['name'] = $name; - return $this; - } - - /** - * @param string $price - * - * @return \Magento\TestModule1\Service\V2\Entity\ItemBuilder - */ - public function setPrice($price) - { - $this->data['price'] = $price; - return $this; - } -} 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 254ba3ba70abcbd81992dd06649eb4ecd48f774d..7ae28455d3a64a1abe6aa319881f0459e486c76e 100644 --- a/dev/tests/api-functional/_files/Magento/TestModule1/etc/di.xml +++ b/dev/tests/api-functional/_files/Magento/TestModule1/etc/di.xml @@ -11,13 +11,7 @@ <virtualType name="Magento\TestModule1\Service\Config\TestModule1MetadataConfig" type="Magento\Framework\Api\Config\MetadataConfig"> <arguments> - <argument name="attributeMetadataBuilder" xsi:type="object">Magento\TestModule1\Service\V1\Entity\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/TestModule2/Service/V1/Entity/Item.php b/dev/tests/api-functional/_files/Magento/TestModule2/Service/V1/Entity/Item.php index 4781959355d4f152d466f3a054b3e358eeadc580..677ea39860129e85c6f705a0d0bf001b366d8b09 100644 --- a/dev/tests/api-functional/_files/Magento/TestModule2/Service/V1/Entity/Item.php +++ b/dev/tests/api-functional/_files/Magento/TestModule2/Service/V1/Entity/Item.php @@ -15,6 +15,16 @@ class Item extends \Magento\Framework\Api\AbstractExtensibleObject return $this->_data['id']; } + /** + * @param int $id + * @return $this + */ + public function setId($id) + { + return $this->setData('id', $id); + } + + /** * @return string */ @@ -22,4 +32,12 @@ class Item extends \Magento\Framework\Api\AbstractExtensibleObject { 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/TestModule2/Service/V1/Entity/ItemBuilder.php b/dev/tests/api-functional/_files/Magento/TestModule2/Service/V1/Entity/ItemBuilder.php deleted file mode 100644 index d53919e16d7736aa61a9584467de296687d0d4d1..0000000000000000000000000000000000000000 --- a/dev/tests/api-functional/_files/Magento/TestModule2/Service/V1/Entity/ItemBuilder.php +++ /dev/null @@ -1,29 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\TestModule2\Service\V1\Entity; - -class ItemBuilder extends \Magento\Framework\Api\ExtensibleObjectBuilder -{ - /** - * @param int $id - * @return \Magento\TestModule2\Service\V1\Entity\ItemBuilder - */ - public function setId($id) - { - $this->data['id'] = $id; - return $this; - } - - /** - * @param string $name - * @return \Magento\TestModule2\Service\V1\Entity\ItemBuilder - */ - public function setName($name) - { - $this->data['name'] = $name; - return $this; - } -} diff --git a/dev/tests/api-functional/_files/Magento/TestModule2/Service/V1/NoWebApiXml.php b/dev/tests/api-functional/_files/Magento/TestModule2/Service/V1/NoWebApiXml.php index b4983e6ed8ade4de16e61ff44542fe89273eed65..b7d8143b9864249e32656a86f1308b7bd04e4614 100644 --- a/dev/tests/api-functional/_files/Magento/TestModule2/Service/V1/NoWebApiXml.php +++ b/dev/tests/api-functional/_files/Magento/TestModule2/Service/V1/NoWebApiXml.php @@ -6,21 +6,21 @@ namespace Magento\TestModule2\Service\V1; use Magento\TestModule2\Service\V1\Entity\Item; -use Magento\TestModule2\Service\V1\Entity\ItemBuilder; +use Magento\TestModule2\Service\V1\Entity\ItemFactory; class NoWebApiXml implements \Magento\TestModule2\Service\V1\NoWebApiXmlInterface { /** - * @var ItemBuilder + * @var ItemFactory */ - protected $itemBuilder; + protected $itemFactory; /** - * @param ItemBuilder $itemBuilder + * @param ItemFactory $itemFactory */ - public function __construct(ItemBuilder $itemBuilder) + public function __construct(ItemFactory $itemFactory) { - $this->itemBuilder = $itemBuilder; + $this->itemFactory = $itemFactory; } /** @@ -28,7 +28,7 @@ class NoWebApiXml implements \Magento\TestModule2\Service\V1\NoWebApiXmlInterfac */ public function item($id) { - return $this->itemBuilder->setId($id)->setName('testProduct1')->create(); + return $this->itemFactory->create()->setId($id)->setName('testProduct1'); } /** @@ -36,9 +36,9 @@ class NoWebApiXml implements \Magento\TestModule2\Service\V1\NoWebApiXmlInterfac */ public function items() { - $result1 = $this->itemBuilder->setId(1)->setName('testProduct1')->create(); + $result1 = $this->itemFactory->create()->setId(1)->setName('testProduct1'); - $result2 = $this->itemBuilder->setId(2)->setName('testProduct2')->create(); + $result2 = $this->itemFactory->create()->setId(2)->setName('testProduct2'); return [$result1, $result2]; } @@ -48,7 +48,7 @@ class NoWebApiXml implements \Magento\TestModule2\Service\V1\NoWebApiXmlInterfac */ public function create($name) { - return $this->itemBuilder->setId(rand())->setName($name)->create(); + return $this->itemFactory->create()->setId(rand())->setName($name); } /** @@ -56,6 +56,6 @@ class NoWebApiXml implements \Magento\TestModule2\Service\V1\NoWebApiXmlInterfac */ public function update(Item $item) { - return $this->itemBuilder->setId($item->getId())->setName('Updated' . $item->getName())->create(); + return $this->itemFactory->create()->setId($item->getId())->setName('Updated' . $item->getName()); } } diff --git a/dev/tests/api-functional/_files/Magento/TestModule2/Service/V1/SubsetRest.php b/dev/tests/api-functional/_files/Magento/TestModule2/Service/V1/SubsetRest.php index cbf9d7e2da58e7b543b51f32c1c3379cec30dad8..afd604a46d49215edb35e2a8c02b92bf174c99b1 100644 --- a/dev/tests/api-functional/_files/Magento/TestModule2/Service/V1/SubsetRest.php +++ b/dev/tests/api-functional/_files/Magento/TestModule2/Service/V1/SubsetRest.php @@ -6,21 +6,21 @@ namespace Magento\TestModule2\Service\V1; use Magento\TestModule2\Service\V1\Entity\Item; -use Magento\TestModule2\Service\V1\Entity\ItemBuilder; +use Magento\TestModule2\Service\V1\Entity\ItemFactory; class SubsetRest implements \Magento\TestModule2\Service\V1\SubsetRestInterface { /** - * @var ItemBuilder + * @var ItemFactory */ - protected $itemBuilder; + protected $itemFactory; /** - * @param ItemBuilder $itemBuilder + * @param ItemFactory $itemFactory */ - public function __construct(ItemBuilder $itemBuilder) + public function __construct(ItemFactory $itemFactory) { - $this->itemBuilder = $itemBuilder; + $this->itemFactory = $itemFactory; } /** @@ -28,7 +28,7 @@ class SubsetRest implements \Magento\TestModule2\Service\V1\SubsetRestInterface */ public function item($id) { - return $this->itemBuilder->setId($id)->setName('testItem' . $id)->create(); + return $this->itemFactory->create()->setId($id)->setName('testItem' . $id); } /** @@ -36,9 +36,9 @@ class SubsetRest implements \Magento\TestModule2\Service\V1\SubsetRestInterface */ public function items() { - $result1 = $this->itemBuilder->setId(1)->setName('testItem1')->create(); + $result1 = $this->itemFactory->create()->setId(1)->setName('testItem1'); - $result2 = $this->itemBuilder->setId(2)->setName('testItem2')->create(); + $result2 = $this->itemFactory->create()->setId(2)->setName('testItem2'); return [$result1, $result2]; } @@ -48,7 +48,7 @@ class SubsetRest implements \Magento\TestModule2\Service\V1\SubsetRestInterface */ public function create($name) { - return $this->itemBuilder->setId(rand())->setName($name)->create(); + return $this->itemFactory->create()->setId(rand())->setName($name); } /** @@ -56,7 +56,7 @@ class SubsetRest implements \Magento\TestModule2\Service\V1\SubsetRestInterface */ public function update(Item $item) { - return $this->itemBuilder->setId($item->getId())->setName('Updated' . $item->getName())->create(); + return $this->itemFactory->create()->setId($item->getId())->setName('Updated' . $item->getName()); } /** @@ -64,6 +64,6 @@ class SubsetRest implements \Magento\TestModule2\Service\V1\SubsetRestInterface */ public function remove($id) { - return $this->itemBuilder->setId(1)->create(); + return $this->itemFactory->create()->setId(1); } } diff --git a/dev/tests/api-functional/_files/Magento/TestModule3/Service/V1/Entity/Parameter.php b/dev/tests/api-functional/_files/Magento/TestModule3/Service/V1/Entity/Parameter.php index 44f22d3fb830c493019e2ee6bfae1900c9c71479..59e4c84ac24f0b1988eccb1a73ae07db43d1bcee 100644 --- a/dev/tests/api-functional/_files/Magento/TestModule3/Service/V1/Entity/Parameter.php +++ b/dev/tests/api-functional/_files/Magento/TestModule3/Service/V1/Entity/Parameter.php @@ -3,6 +3,9 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ + +// @codingStandardsIgnoreFile + namespace Magento\TestModule3\Service\V1\Entity; class Parameter extends \Magento\Framework\Api\AbstractExtensibleObject @@ -17,6 +20,17 @@ class Parameter extends \Magento\Framework\Api\AbstractExtensibleObject return $this->_data['name']; } + /** + * Set Name. + * + * @param string $name + * @return $this + */ + public function setName($name) + { + return $this->setData('name', $name); + } + /** * Get value. * @@ -26,4 +40,15 @@ class Parameter extends \Magento\Framework\Api\AbstractExtensibleObject { return $this->_data['value']; } + + /** + * Set value. + * + * @param string $value + * @return $this + */ + public function setValue($value) + { + return $this->setData('value', $value); + } } diff --git a/dev/tests/api-functional/_files/Magento/TestModule3/Service/V1/Entity/ParameterBuilder.php b/dev/tests/api-functional/_files/Magento/TestModule3/Service/V1/Entity/ParameterBuilder.php deleted file mode 100644 index faad247d90deeb017b09fa1b4f3bcfdb2daffbba..0000000000000000000000000000000000000000 --- a/dev/tests/api-functional/_files/Magento/TestModule3/Service/V1/Entity/ParameterBuilder.php +++ /dev/null @@ -1,33 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\TestModule3\Service\V1\Entity; - -class ParameterBuilder extends \Magento\Framework\Api\ExtensibleObjectBuilder -{ - /** - * Set Name. - * - * @param string $name - * @return \Magento\TestModule3\Service\V1\Entity\ParameterBuilder - */ - public function setName($name) - { - $this->data['name'] = $name; - return $this; - } - - /** - * Set value. - * - * @param string $value - * @return \Magento\TestModule3\Service\V1\Entity\ParameterBuilder - */ - public function setValue($value) - { - $this->data['value'] = $value; - return $this; - } -} 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 5308640833578aca09c156bf43e0d5903cdc6d7a..c073b4276be0a3e066287c95761ae2aaa8c5c633 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 @@ -4,6 +4,8 @@ * See COPYING.txt for license details. */ +// @codingStandardsIgnoreFile + namespace Magento\TestModule3\Service\V1\Entity; class WrappedErrorParameter extends \Magento\Framework\Api\AbstractExtensibleObject @@ -18,6 +20,17 @@ class WrappedErrorParameter extends \Magento\Framework\Api\AbstractExtensibleObj return $this->_data['field_name']; } + /** + * Set field name. + * + * @param string $fieldName + * @return $this + */ + public function setFieldName($fieldName) + { + return $this->setData('field_name', $fieldName); + } + /** * Get value. * @@ -27,4 +40,15 @@ class WrappedErrorParameter extends \Magento\Framework\Api\AbstractExtensibleObj { return $this->_data['value']; } + + /** + * Set value. + * + * @param string $value + * @return $this + */ + public function setValue($value) + { + return $this->setData('value', $value); + } } diff --git a/dev/tests/api-functional/_files/Magento/TestModule3/Service/V1/Entity/WrappedErrorParameterBuilder.php b/dev/tests/api-functional/_files/Magento/TestModule3/Service/V1/Entity/WrappedErrorParameterBuilder.php deleted file mode 100644 index ff7df239f39135e29b2b2514251238c8f76a6226..0000000000000000000000000000000000000000 --- a/dev/tests/api-functional/_files/Magento/TestModule3/Service/V1/Entity/WrappedErrorParameterBuilder.php +++ /dev/null @@ -1,34 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -namespace Magento\TestModule3\Service\V1\Entity; - -class WrappedErrorParameterBuilder extends \Magento\Framework\Api\ExtensibleObjectBuilder -{ - /** - * Set field name. - * - * @param string $fieldName - * @return $this - */ - public function setFieldName($fieldName) - { - $this->data['field_name'] = $fieldName; - return $this; - } - - /** - * Set value. - * - * @param string $value - * @return $this - */ - public function setValue($value) - { - $this->data['value'] = $value; - return $this; - } -} 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 8306194ceee0617c1ad7fd88920a55cd2e8c1ce6..e1f4b6a99564875820989179cb5959df14e9bbc1 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 @@ -12,21 +12,21 @@ use Magento\Framework\Exception\InputException; use Magento\Framework\Exception\LocalizedException; use Magento\Framework\Exception\NoSuchEntityException; use Magento\TestModule3\Service\V1\Entity\Parameter; -use Magento\TestModule3\Service\V1\Entity\ParameterBuilder; +use Magento\TestModule3\Service\V1\Entity\ParameterFactory; class Error implements \Magento\TestModule3\Service\V1\ErrorInterface { /** - * @var ParameterBuilder + * @var ParameterFactory */ - protected $parameterBuilder; + protected $parameterFactory; /** - * @param ParameterBuilder $parameterBuilder + * @param ParameterFactory $parameterFactory */ - public function __construct(ParameterBuilder $parameterBuilder) + public function __construct(ParameterFactory $parameterFactory) { - $this->parameterBuilder = $parameterBuilder; + $this->parameterFactory = $parameterFactory; } /** @@ -34,7 +34,7 @@ class Error implements \Magento\TestModule3\Service\V1\ErrorInterface */ public function success() { - return $this->parameterBuilder->setName('id')->setValue('a good id')->create(); + return $this->parameterFactory->create()->setName('id')->setValue('a good id'); } /** diff --git a/dev/tests/api-functional/_files/Magento/TestModule4/Service/V1/DataObjectService.php b/dev/tests/api-functional/_files/Magento/TestModule4/Service/V1/DataObjectService.php index 04ad6935cd37907acf0ea930bdd106f0a4e50fd3..c988c6a1821c66ab89504d5b557c3a4bebda0e3e 100644 --- a/dev/tests/api-functional/_files/Magento/TestModule4/Service/V1/DataObjectService.php +++ b/dev/tests/api-functional/_files/Magento/TestModule4/Service/V1/DataObjectService.php @@ -6,23 +6,23 @@ namespace Magento\TestModule4\Service\V1; use Magento\TestModule4\Service\V1\Entity\DataObjectRequest; -use Magento\TestModule4\Service\V1\Entity\DataObjectResponseBuilder; +use Magento\TestModule4\Service\V1\Entity\DataObjectResponseFactory; use Magento\TestModule4\Service\V1\Entity\ExtensibleRequestInterface; use Magento\TestModule4\Service\V1\Entity\NestedDataObjectRequest; class DataObjectService implements \Magento\TestModule4\Service\V1\DataObjectServiceInterface { /** - * @var DataObjectResponseBuilder + * @var DataObjectResponseFactory */ - protected $responseBuilder; + protected $responseFactory; /** - * @param DataObjectResponseBuilder $responseBuilder + * @param DataObjectResponseFactory $responseFactory */ - public function __construct(DataObjectResponseBuilder $responseBuilder) + public function __construct(DataObjectResponseFactory $responseFactory) { - $this->responseBuilder = $responseBuilder; + $this->responseFactory = $responseFactory; } /** @@ -30,7 +30,7 @@ class DataObjectService implements \Magento\TestModule4\Service\V1\DataObjectSer */ public function getData($id) { - return $this->responseBuilder->setEntityId($id)->setName("Test")->create(); + return $this->responseFactory->create()->setEntityId($id)->setName("Test"); } /** @@ -38,7 +38,7 @@ class DataObjectService implements \Magento\TestModule4\Service\V1\DataObjectSer */ public function updateData($id, DataObjectRequest $request) { - return $this->responseBuilder->setEntityId($id)->setName($request->getName())->create(); + return $this->responseFactory->create()->setEntityId($id)->setName($request->getName()); } /** @@ -46,7 +46,7 @@ class DataObjectService implements \Magento\TestModule4\Service\V1\DataObjectSer */ public function nestedData($id, NestedDataObjectRequest $request) { - return $this->responseBuilder->setEntityId($id)->setName($request->getDetails()->getName())->create(); + return $this->responseFactory->create()->setEntityId($id)->setName($request->getDetails()->getName()); } /** @@ -65,6 +65,6 @@ class DataObjectService implements \Magento\TestModule4\Service\V1\DataObjectSer */ public function extensibleDataObject($id, ExtensibleRequestInterface $request) { - return $this->responseBuilder->setEntityId($id)->setName($request->getName())->create(); + return $this->responseFactory->create()->setEntityId($id)->setName($request->getName()); } } diff --git a/dev/tests/api-functional/_files/Magento/TestModule4/Service/V1/Entity/DataObjectRequest.php b/dev/tests/api-functional/_files/Magento/TestModule4/Service/V1/Entity/DataObjectRequest.php index b14e85d1a5b0096737cccb40ab8fd1b82accc060..5de8dafbba3d55a92126665d35b37db5efadecb6 100644 --- a/dev/tests/api-functional/_files/Magento/TestModule4/Service/V1/Entity/DataObjectRequest.php +++ b/dev/tests/api-functional/_files/Magento/TestModule4/Service/V1/Entity/DataObjectRequest.php @@ -15,6 +15,15 @@ class DataObjectRequest extends \Magento\Framework\Api\AbstractExtensibleObject return $this->_get('name'); } + /** + * @param string $name + * @return $this + */ + public function setName($name) + { + return $this->setData('name', $name); + } + /** * @return int|null */ @@ -22,4 +31,13 @@ class DataObjectRequest extends \Magento\Framework\Api\AbstractExtensibleObject { return $this->_get('entity_id'); } + + /** + * @param int $entityId + * @return $this + */ + public function setEntityId($entityId) + { + return $this->setData('entity_id', $entityId); + } } diff --git a/dev/tests/api-functional/_files/Magento/TestModule4/Service/V1/Entity/DataObjectRequestBuilder.php b/dev/tests/api-functional/_files/Magento/TestModule4/Service/V1/Entity/DataObjectRequestBuilder.php deleted file mode 100644 index 47d1c1966922fda5f0cd0e750b4cb21fd8c908cb..0000000000000000000000000000000000000000 --- a/dev/tests/api-functional/_files/Magento/TestModule4/Service/V1/Entity/DataObjectRequestBuilder.php +++ /dev/null @@ -1,27 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\TestModule4\Service\V1\Entity; - -class DataObjectRequestBuilder extends \Magento\Framework\Api\ExtensibleObjectBuilder -{ - /** - * @param string $name - * @return DataObjectRequest - */ - public function setName($name) - { - return $this->_set('name', $name); - } - - /** - * @param int $entityId - * @return DataObjectRequest - */ - public function setEntityId($entityId) - { - return $this->_set('entity_id', $entityId); - } -} diff --git a/dev/tests/api-functional/_files/Magento/TestModule4/Service/V1/Entity/DataObjectResponse.php b/dev/tests/api-functional/_files/Magento/TestModule4/Service/V1/Entity/DataObjectResponse.php index 0d69fd2c777e27166f0e37f9a0db897c8c7b48f4..f66ebab1ecee90efa699a5c7c59d3fbd178ed7fe 100644 --- a/dev/tests/api-functional/_files/Magento/TestModule4/Service/V1/Entity/DataObjectResponse.php +++ b/dev/tests/api-functional/_files/Magento/TestModule4/Service/V1/Entity/DataObjectResponse.php @@ -15,6 +15,15 @@ class DataObjectResponse extends \Magento\Framework\Api\AbstractExtensibleObject return $this->_get('entity_id'); } + /** + * @param int $entityId + * @return $this + */ + public function setEntityId($entityId) + { + return $this->setData('entity_id', $entityId); + } + /** * @return string */ @@ -22,4 +31,13 @@ class DataObjectResponse extends \Magento\Framework\Api\AbstractExtensibleObject { return $this->_get('name'); } + + /** + * @param string $name + * @return $this + */ + public function setName($name) + { + return $this->setData('name', $name); + } } diff --git a/dev/tests/api-functional/_files/Magento/TestModule4/Service/V1/Entity/DataObjectResponseBuilder.php b/dev/tests/api-functional/_files/Magento/TestModule4/Service/V1/Entity/DataObjectResponseBuilder.php deleted file mode 100644 index 22a3b1b58ad489982b6fd16871c91f2d78f58534..0000000000000000000000000000000000000000 --- a/dev/tests/api-functional/_files/Magento/TestModule4/Service/V1/Entity/DataObjectResponseBuilder.php +++ /dev/null @@ -1,27 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\TestModule4\Service\V1\Entity; - -class DataObjectResponseBuilder extends \Magento\Framework\Api\ExtensibleObjectBuilder -{ - /** - * @param int $entityId - * @return DataObjectResponseBuilder - */ - public function setEntityId($entityId) - { - return $this->_set('entity_id', $entityId); - } - - /** - * @param string $name - * @return DataObjectResponseBuilder - */ - public function setName($name) - { - return $this->_set('name', $name); - } -} 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 d96ca365fbd34fa3d1efa4fb02efa4267243ccfa..515e73f3b4aec9a34d7f79cf4c1dc5cbfb49df0f 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 @@ -14,4 +14,22 @@ class ExtensibleRequest extends \Magento\Framework\Model\AbstractExtensibleModel { return $this->getData("name"); } + + /** + * @param string $name + * @return $this + */ + public function setName($name) + { + return $this->setData("name", $name); + } + + /** + * @param int $entityId + * @return $this + */ + public function setEntityId($entityId) + { + return $this->setData("entity_id", $entityId); + } } diff --git a/dev/tests/api-functional/_files/Magento/TestModule4/Service/V1/Entity/ExtensibleRequestInterface.php b/dev/tests/api-functional/_files/Magento/TestModule4/Service/V1/Entity/ExtensibleRequestInterface.php index 4b6c422a3447ecc31a24564b50efa19db57f4eac..cd0f2902c5c3a5d729c60ebd6ae0cf48dfeae146 100644 --- a/dev/tests/api-functional/_files/Magento/TestModule4/Service/V1/Entity/ExtensibleRequestInterface.php +++ b/dev/tests/api-functional/_files/Magento/TestModule4/Service/V1/Entity/ExtensibleRequestInterface.php @@ -12,8 +12,20 @@ interface ExtensibleRequestInterface extends \Magento\Framework\Api\ExtensibleDa */ public function getName(); + /** + * @param string $name + * @return $this + */ + public function setName($name); + /** * @return int|null */ public function getEntityId(); + + /** + * @param int $entityId + * @return $this + */ + public function setEntityId($entityId); } diff --git a/dev/tests/api-functional/_files/Magento/TestModule4/Service/V1/Entity/NestedDataObjectRequest.php b/dev/tests/api-functional/_files/Magento/TestModule4/Service/V1/Entity/NestedDataObjectRequest.php index 5af1942295499f25ccb9fcdd4059a5712c771aa9..47b38e59a6f26c07ad040ddd4ecdfba390bf3b6d 100644 --- a/dev/tests/api-functional/_files/Magento/TestModule4/Service/V1/Entity/NestedDataObjectRequest.php +++ b/dev/tests/api-functional/_files/Magento/TestModule4/Service/V1/Entity/NestedDataObjectRequest.php @@ -14,4 +14,13 @@ class NestedDataObjectRequest extends \Magento\Framework\Api\AbstractExtensibleO { return $this->_get('details'); } + + /** + * @param \Magento\TestModule4\Service\V1\Entity\DataObjectRequest $details + * @return $this + */ + public function setDetails(\Magento\TestModule4\Service\V1\Entity\DataObjectRequest $details = null) + { + return $this->setData('details', $details); + } } diff --git a/dev/tests/api-functional/_files/Magento/TestModule4/Service/V1/Entity/NestedDataObjectRequestBuilder.php b/dev/tests/api-functional/_files/Magento/TestModule4/Service/V1/Entity/NestedDataObjectRequestBuilder.php deleted file mode 100644 index 7b24d19b4e26696b40531342acd7b7d0a3d2ee24..0000000000000000000000000000000000000000 --- a/dev/tests/api-functional/_files/Magento/TestModule4/Service/V1/Entity/NestedDataObjectRequestBuilder.php +++ /dev/null @@ -1,18 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\TestModule4\Service\V1\Entity; - -class NestedDataObjectRequestBuilder extends \Magento\Framework\Api\ExtensibleObjectBuilder -{ - /** - * @param \Magento\TestModule4\Service\V1\Entity\DataObjectRequest $details - * @return \Magento\TestModule4\Service\V1\Entity\DataObjectRequest - */ - public function setDetails(DataObjectRequest $details) - { - return $this->_set('details', $details); - } -} diff --git a/dev/tests/api-functional/_files/Magento/TestModule5/Service/V1/AllSoapAndRest.php b/dev/tests/api-functional/_files/Magento/TestModule5/Service/V1/AllSoapAndRest.php index 2d8376547315d07a6d66b03a8d9107efd2359d2b..bbcc323d6cd67bd7f5b18d55dcfc90a4c886281c 100644 --- a/dev/tests/api-functional/_files/Magento/TestModule5/Service/V1/AllSoapAndRest.php +++ b/dev/tests/api-functional/_files/Magento/TestModule5/Service/V1/AllSoapAndRest.php @@ -5,21 +5,21 @@ */ namespace Magento\TestModule5\Service\V1; -use Magento\TestModule5\Service\V1\Entity\AllSoapAndRestBuilder; +use Magento\TestModule5\Service\V1\Entity\AllSoapAndRestFactory; class AllSoapAndRest implements \Magento\TestModule5\Service\V1\AllSoapAndRestInterface { /** - * @var AllSoapAndRestBuilder + * @var AllSoapAndRestFactory */ - protected $builder; + protected $factory; /** - * @param AllSoapAndRestBuilder $builder + * @param AllSoapAndRestFactory $factory */ - public function __construct(AllSoapAndRestBuilder $builder) + public function __construct(AllSoapAndRestFactory $factory) { - $this->builder = $builder; + $this->factory = $factory; } /** @@ -27,12 +27,11 @@ class AllSoapAndRest implements \Magento\TestModule5\Service\V1\AllSoapAndRestIn */ public function item($entityId) { - return $this->builder + return $this->factory->create() ->setEntityId($entityId) ->setName('testItemName') ->setIsEnabled(true) - ->setHasOrders(true) - ->create(); + ->setHasOrders(true); } /** @@ -40,8 +39,8 @@ class AllSoapAndRest implements \Magento\TestModule5\Service\V1\AllSoapAndRestIn */ public function items() { - $allSoapAndRest1 = $this->builder->setEntityId(1)->setName('testProduct1')->create(); - $allSoapAndRest2 = $this->builder->setEntityId(2)->setName('testProduct2')->create(); + $allSoapAndRest1 = $this->factory->create()->setEntityId(1)->setName('testProduct1'); + $allSoapAndRest2 = $this->factory->create()->setEntityId(2)->setName('testProduct2'); return [$allSoapAndRest1, $allSoapAndRest2]; } @@ -50,7 +49,11 @@ class AllSoapAndRest implements \Magento\TestModule5\Service\V1\AllSoapAndRestIn */ public function create(\Magento\TestModule5\Service\V1\Entity\AllSoapAndRest $item) { - return $this->builder->populate($item)->create(); + return $this->factory->create() + ->setEntityId($item->getEntityId()) + ->setName($item->getName()) + ->setIsEnabled($item->isEnabled()) + ->setHasOrders($item->hasOrders()); } /** diff --git a/dev/tests/api-functional/_files/Magento/TestModule5/Service/V1/Entity/AllSoapAndRest.php b/dev/tests/api-functional/_files/Magento/TestModule5/Service/V1/Entity/AllSoapAndRest.php index b777d90ded0e486eeed942312a49d542c73a431a..bcbb0e2a2c0bf456d12cb7718b23c019019c6a94 100644 --- a/dev/tests/api-functional/_files/Magento/TestModule5/Service/V1/Entity/AllSoapAndRest.php +++ b/dev/tests/api-functional/_files/Magento/TestModule5/Service/V1/Entity/AllSoapAndRest.php @@ -28,6 +28,17 @@ class AllSoapAndRest extends \Magento\Framework\Api\AbstractExtensibleObject return $this->_get(self::ID); } + /** + * Set item ID. + * + * @param int $entityId + * @return $this + */ + public function setEntityId($entityId) + { + return $this->setData(self::ID, $entityId); + } + /** * Retrieve item Name. * @@ -38,6 +49,17 @@ class AllSoapAndRest extends \Magento\Framework\Api\AbstractExtensibleObject return $this->_get(self::NAME); } + /** + * Set item Name. + * + * @param string $name + * @return $this + */ + public function setName($name) + { + return $this->setData(self::NAME, $name); + } + /** * Check if entity is enabled * @@ -48,6 +70,17 @@ class AllSoapAndRest extends \Magento\Framework\Api\AbstractExtensibleObject return $this->_get(self::ENABLED); } + /** + * Set if entity is enabled + * + * @param bool $isEnabled + * @return bool + */ + public function setIsEnabled($isEnabled) + { + return $this->setData(self::ENABLED, $isEnabled); + } + /** * Check if current entity has a property defined * @@ -58,6 +91,17 @@ class AllSoapAndRest extends \Magento\Framework\Api\AbstractExtensibleObject return $this->_get(self::HAS_ORDERS); } + /** + * Set whether current entity has a property defined + * + * @param bool $setHasOrders + * @return $this + */ + public function setHasOrders($hasOrders) + { + return $this->setData(self::HAS_ORDERS, $hasOrders); + } + /** * Method which will not be used when adding complex type field to WSDL. * diff --git a/dev/tests/api-functional/_files/Magento/TestModule5/Service/V1/Entity/AllSoapAndRestBuilder.php b/dev/tests/api-functional/_files/Magento/TestModule5/Service/V1/Entity/AllSoapAndRestBuilder.php deleted file mode 100644 index 46dd6dd72de5eae31ce168c67d74f304ee69d6ee..0000000000000000000000000000000000000000 --- a/dev/tests/api-functional/_files/Magento/TestModule5/Service/V1/Entity/AllSoapAndRestBuilder.php +++ /dev/null @@ -1,57 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\TestModule5\Service\V1\Entity; - -use Magento\Framework\Api\AbstractSimpleObjectBuilder; - -/** - * Some Data Object short description. - * - * Data Object long - * multi line description. - */ -class AllSoapAndRestBuilder extends AbstractSimpleObjectBuilder -{ - /** - * @param int $id - * @return AllSoapAndRestBuilder - */ - public function setEntityId($id) - { - return $this->_set(AllSoapAndRest::ID, $id); - } - - /** - * @param string $name - * @return AllSoapAndRestBuilder - */ - public function setName($name) - { - return $this->_set(AllSoapAndRest::NAME, $name); - } - - /** - * Set flag if entity is enabled - * - * @param bool $isEnabled - * @return AllSoapAndRestBuilder - */ - public function setIsEnabled($isEnabled) - { - return $this->_set(AllSoapAndRest::ENABLED, $isEnabled); - } - - /** - * Set flag if entity has orders - * - * @param bool $hasOrders - * @return AllSoapAndRestBuilder - */ - public function setHasOrders($hasOrders) - { - return $this->_set(AllSoapAndRest::HAS_ORDERS, $hasOrders); - } -} diff --git a/dev/tests/api-functional/_files/Magento/TestModule5/Service/V1/OverrideService.php b/dev/tests/api-functional/_files/Magento/TestModule5/Service/V1/OverrideService.php index 1e174932cbcc67a95c95c9a765c8bcb60cf68593..4e8653a17741d7a1933c22082d13075664b48901 100644 --- a/dev/tests/api-functional/_files/Magento/TestModule5/Service/V1/OverrideService.php +++ b/dev/tests/api-functional/_files/Magento/TestModule5/Service/V1/OverrideService.php @@ -6,31 +6,30 @@ namespace Magento\TestModule5\Service\V1; -use Magento\TestModule5\Service\V1\Entity\AllSoapAndRestBuilder; +use Magento\TestModule5\Service\V1\Entity\AllSoapAndRestFactory; class OverrideService implements OverrideServiceInterface { /** - * @var AllSoapAndRestBuilder + * @var AllSoapAndRestFactory */ - protected $builder; + protected $factory; /** - * @param AllSoapAndRestBuilder $builder + * @param AllSoapAndRestFactory $factory */ - public function __construct(AllSoapAndRestBuilder $builder) + public function __construct(AllSoapAndRestFactory $factory) { - $this->builder = $builder; + $this->factory = $factory; } /** * {@inheritdoc} */ public function scalarUpdate($entityId, $name, $hasOrders) { - return $this->builder + return $this->factory->create() ->setEntityId($entityId) ->setName($name) - ->setHasOrders($hasOrders) - ->create(); + ->setHasOrders($hasOrders); } } diff --git a/dev/tests/api-functional/_files/Magento/TestModule5/Service/V2/AllSoapAndRest.php b/dev/tests/api-functional/_files/Magento/TestModule5/Service/V2/AllSoapAndRest.php index b5b6044a9bfca7caa6ce29d11fffc987e6a10e2e..b02a14ce675403f04d093864eb186e68c3dddba2 100644 --- a/dev/tests/api-functional/_files/Magento/TestModule5/Service/V2/AllSoapAndRest.php +++ b/dev/tests/api-functional/_files/Magento/TestModule5/Service/V2/AllSoapAndRest.php @@ -6,21 +6,21 @@ namespace Magento\TestModule5\Service\V2; use Magento\TestModule5\Service\V2\Entity\AllSoapAndRest as AllSoapAndRestEntity; -use Magento\TestModule5\Service\V2\Entity\AllSoapAndRestBuilder; +use Magento\TestModule5\Service\V2\Entity\AllSoapAndRestFactory; class AllSoapAndRest implements AllSoapAndRestInterface { /** - * @var AllSoapAndRestBuilder + * @var AllSoapAndRestFactory */ - protected $builder; + protected $factory; /** - * @param AllSoapAndRestBuilder $builder + * @param AllSoapAndRestFactory $factory */ - public function __construct(AllSoapAndRestBuilder $builder) + public function __construct(AllSoapAndRestFactory $factory) { - $this->builder = $builder; + $this->factory = $factory; } /** @@ -28,7 +28,7 @@ class AllSoapAndRest implements AllSoapAndRestInterface */ public function item($id) { - return $this->builder->setPrice(1)->setId($id)->setName('testItemName')->create(); + return $this->factory->create()->setPrice(1)->setId($id)->setName('testItemName'); } /** @@ -36,8 +36,8 @@ class AllSoapAndRest implements AllSoapAndRestInterface */ public function items() { - $allSoapAndRest1 = $this->builder->setPrice(1)->setId(1)->setName('testProduct1')->create(); - $allSoapAndRest2 = $this->builder->setPrice(1)->setId(2)->setName('testProduct2')->create(); + $allSoapAndRest1 = $this->factory->create()->setPrice(1)->setId(1)->setName('testProduct1'); + $allSoapAndRest2 = $this->factory->create()->setPrice(1)->setId(2)->setName('testProduct2'); return [$allSoapAndRest1, $allSoapAndRest2]; } @@ -46,7 +46,7 @@ class AllSoapAndRest implements AllSoapAndRestInterface */ public function create(\Magento\TestModule5\Service\V2\Entity\AllSoapAndRest $item) { - return $this->builder->populate($item)->create(); + return $this->factory->create()->setPrice($item->getPrice()); } /** @@ -55,7 +55,7 @@ class AllSoapAndRest implements AllSoapAndRestInterface public function update(\Magento\TestModule5\Service\V2\Entity\AllSoapAndRest $item) { $item->setName('Updated' . $item->getName()); - return $this->builder->populate($item)->create(); + return $item; } /** @@ -65,6 +65,6 @@ class AllSoapAndRest implements AllSoapAndRestInterface */ public function delete($id) { - return $this->builder->setPrice(1)->setId($id)->setName('testItemName')->create(); + return $this->factory->create()->setPrice(1)->setId($id)->setName('testItemName'); } } diff --git a/dev/tests/api-functional/_files/Magento/TestModule5/Service/V2/Entity/AllSoapAndRestBuilder.php b/dev/tests/api-functional/_files/Magento/TestModule5/Service/V2/Entity/AllSoapAndRestBuilder.php deleted file mode 100644 index 996b4c8760c086567720f0dd1b1a8d765499b8af..0000000000000000000000000000000000000000 --- a/dev/tests/api-functional/_files/Magento/TestModule5/Service/V2/Entity/AllSoapAndRestBuilder.php +++ /dev/null @@ -1,22 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\TestModule5\Service\V2\Entity; - -use Magento\TestModule5\Service\V1\Entity; - -class AllSoapAndRestBuilder extends \Magento\TestModule5\Service\V1\Entity\AllSoapAndRestBuilder -{ - const PRICE = 'price'; - - /** - * @param int $price - * @return \Magento\TestModule5\Service\V2\Entity\AllSoapAndRestBuilder - */ - public function setPrice($price) - { - return $this->_set(self::PRICE, $price); - } -} diff --git a/dev/tests/api-functional/_files/Magento/TestModuleMSC/Api/Data/CustomAttributeDataObjectInterface.php b/dev/tests/api-functional/_files/Magento/TestModuleMSC/Api/Data/CustomAttributeDataObjectInterface.php index 8bc01d6b0747a294dde62dc8c38ab7a2d8dfb995..405595033957432ca56c442db93f82ba25eef5d4 100644 --- a/dev/tests/api-functional/_files/Magento/TestModuleMSC/Api/Data/CustomAttributeDataObjectInterface.php +++ b/dev/tests/api-functional/_files/Magento/TestModuleMSC/Api/Data/CustomAttributeDataObjectInterface.php @@ -13,4 +13,10 @@ interface CustomAttributeDataObjectInterface extends \Magento\Framework\Api\Exte * @return string */ public function getName(); + + /** + * @param string $name + * @return $this + */ + public function setName($name); } diff --git a/dev/tests/api-functional/_files/Magento/TestModuleMSC/Api/Data/CustomAttributeNestedDataObjectInterface.php b/dev/tests/api-functional/_files/Magento/TestModuleMSC/Api/Data/CustomAttributeNestedDataObjectInterface.php index 2392f27f39df89ead9d4210dc68e3b6d0193080c..86053d02c6df5c0f42ed25a37b1429f3b066e553 100644 --- a/dev/tests/api-functional/_files/Magento/TestModuleMSC/Api/Data/CustomAttributeNestedDataObjectInterface.php +++ b/dev/tests/api-functional/_files/Magento/TestModuleMSC/Api/Data/CustomAttributeNestedDataObjectInterface.php @@ -11,4 +11,10 @@ interface CustomAttributeNestedDataObjectInterface extends \Magento\Framework\Ap * @return string */ public function getName(); + + /** + * @param string $name + * @return $this + */ + public function setName($name); } diff --git a/dev/tests/api-functional/_files/Magento/TestModuleMSC/Api/Data/ItemInterface.php b/dev/tests/api-functional/_files/Magento/TestModuleMSC/Api/Data/ItemInterface.php index ab84970f9d1f476d283fd215c89c9ad3737c6dda..3a3f81cf1b0b53fc657f6774a435f00d723c0e8f 100644 --- a/dev/tests/api-functional/_files/Magento/TestModuleMSC/Api/Data/ItemInterface.php +++ b/dev/tests/api-functional/_files/Magento/TestModuleMSC/Api/Data/ItemInterface.php @@ -12,8 +12,20 @@ interface ItemInterface extends \Magento\Framework\Api\ExtensibleDataInterface */ public function getItemId(); + /** + * @param int $itemId + * @return $this + */ + public function setItemId($itemId); + /** * @return string */ public function getName(); + + /** + * @param string $name + * @return $this + */ + public function setName($name); } diff --git a/dev/tests/api-functional/_files/Magento/TestModuleMSC/Model/AllSoapAndRest.php b/dev/tests/api-functional/_files/Magento/TestModuleMSC/Model/AllSoapAndRest.php index 3d42fc29470579a942b29c16fcf26d6796dc7c60..12f56f0bc4775839281f3d46076eaefb78b20832 100644 --- a/dev/tests/api-functional/_files/Magento/TestModuleMSC/Model/AllSoapAndRest.php +++ b/dev/tests/api-functional/_files/Magento/TestModuleMSC/Model/AllSoapAndRest.php @@ -5,31 +5,31 @@ */ namespace Magento\TestModuleMSC\Model; -use Magento\TestModuleMSC\Api\Data\CustomAttributeDataObjectDataBuilder; -use Magento\TestModuleMSC\Api\Data\ItemDataBuilder; +use Magento\TestModuleMSC\Api\Data\CustomAttributeDataObjectInterfaceFactory; +use Magento\TestModuleMSC\Api\Data\ItemInterfaceFactory; class AllSoapAndRest implements \Magento\TestModuleMSC\Api\AllSoapAndRestInterface { /** - * @var ItemDataBuilder + * @var ItemInterfaceFactory */ - protected $itemDataBuilder; + protected $itemDataFactory; /** - * @var CustomAttributeDataObjectDataBuilder + * @var CustomAttributeDataObjectInterfaceFactory */ - protected $customAttributeDataObjectDataBuilder; + protected $customAttributeDataObjectDataFactory; /** - * @param ItemDataBuilder $itemDataBuilder - * @param CustomAttributeDataObjectDataBuilder $customAttributeNestedDataObjectBuilder + * @param ItemInterfaceFactory $itemDataFactory + * @param CustomAttributeDataObjectInterfaceFactory $customAttributeNestedDataObjectFactory */ public function __construct( - ItemDataBuilder $itemDataBuilder, - CustomAttributeDataObjectDataBuilder $customAttributeNestedDataObjectBuilder + ItemInterfaceFactory $itemDataFactory, + CustomAttributeDataObjectInterfaceFactory $customAttributeNestedDataObjectFactory ) { - $this->itemDataBuilder = $itemDataBuilder; - $this->customAttributeDataObjectDataBuilder = $customAttributeNestedDataObjectBuilder; + $this->itemDataFactory = $itemDataFactory; + $this->customAttributeDataObjectDataFactory = $customAttributeNestedDataObjectFactory; } /** @@ -37,7 +37,7 @@ class AllSoapAndRest implements \Magento\TestModuleMSC\Api\AllSoapAndRestInterfa */ public function item($itemId) { - return $this->itemDataBuilder->setItemId($itemId)->setName('testProduct1')->create(); + return $this->itemDataFactory->create()->setItemId($itemId)->setName('testProduct1'); } /** @@ -45,8 +45,8 @@ class AllSoapAndRest implements \Magento\TestModuleMSC\Api\AllSoapAndRestInterfa */ public function items() { - $result1 = $this->itemDataBuilder->setItemId(1)->setName('testProduct1')->create(); - $result2 = $this->itemDataBuilder->setItemId(2)->setName('testProduct2')->create(); + $result1 = $this->itemDataFactory->create()->setItemId(1)->setName('testProduct1'); + $result2 = $this->itemDataFactory->create()->setItemId(2)->setName('testProduct2'); return [$result1, $result2]; } @@ -56,7 +56,7 @@ class AllSoapAndRest implements \Magento\TestModuleMSC\Api\AllSoapAndRestInterfa */ public function create($name) { - return $this->itemDataBuilder->setItemId(rand())->setName($name)->create(); + return $this->itemDataFactory->create()->setItemId(rand())->setName($name); } /** @@ -64,17 +64,16 @@ class AllSoapAndRest implements \Magento\TestModuleMSC\Api\AllSoapAndRestInterfa */ public function update(\Magento\TestModuleMSC\Api\Data\ItemInterface $entityItem) { - return $this->itemDataBuilder->setItemId($entityItem->getItemId()) - ->setName('Updated' . $entityItem->getName()) - ->create(); + return $this->itemDataFactory->create()->setItemId($entityItem->getItemId()) + ->setName('Updated' . $entityItem->getName()); } public function testOptionalParam($name = null) { if (is_null($name)) { - return $this->itemDataBuilder->setItemId(3)->setName('No Name')->create(); + return $this->itemDataFactory->create()->setItemId(3)->setName('No Name'); } else { - return $this->itemDataBuilder->setItemId(3)->setName($name)->create(); + return $this->itemDataFactory->create()->setItemId(3)->setName($name); } } @@ -91,17 +90,15 @@ class AllSoapAndRest implements \Magento\TestModuleMSC\Api\AllSoapAndRestInterfa */ public function getPreconfiguredItem() { - $customAttributeDataObject = $this->customAttributeDataObjectDataBuilder + $customAttributeDataObject = $this->customAttributeDataObjectDataFactory->create() ->setName('nameValue') - ->setCustomAttribute('custom_attribute_int', 1) - ->create(); + ->setCustomAttribute('custom_attribute_int', 1); - $item = $this->itemDataBuilder + $item = $this->itemDataFactory->create() ->setItemId(1) ->setName('testProductAnyType') ->setCustomAttribute('custom_attribute_data_object', $customAttributeDataObject) - ->setCustomAttribute('custom_attribute_string', 'someStringValue') - ->create(); + ->setCustomAttribute('custom_attribute_string', 'someStringValue'); return $item; } 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 54dbbdffc5accd97a9fe58f133001127574f8bf2..57b9202beba4aa4c5602ecd65e0a4607bab042ff 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 @@ -20,4 +20,13 @@ class CustomAttributeDataObject extends AbstractExtensibleObject implements Cust { 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/TestModuleMSC/Model/Data/CustomAttributeNestedDataObject.php b/dev/tests/api-functional/_files/Magento/TestModuleMSC/Model/Data/CustomAttributeNestedDataObject.php index 24937c7ecae46870cb3af65c34e1cad80daf9310..e1e7a49a09e2b40b3f05a23173cd320b5b0ddab0 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 @@ -20,4 +20,13 @@ class CustomAttributeNestedDataObject extends \Magento\Framework\Model\AbstractE { 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/TestModuleMSC/Model/Data/Eav/AttributeMetadata.php b/dev/tests/api-functional/_files/Magento/TestModuleMSC/Model/Data/Eav/AttributeMetadata.php index b8cca857d3c044e13448fb5a165377988eee1911..6d243943177acee07873ecf99bbfbaea58b48e93 100644 --- a/dev/tests/api-functional/_files/Magento/TestModuleMSC/Model/Data/Eav/AttributeMetadata.php +++ b/dev/tests/api-functional/_files/Magento/TestModuleMSC/Model/Data/Eav/AttributeMetadata.php @@ -3,6 +3,9 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ + +// @codingStandardsIgnoreFile + namespace Magento\TestModuleMSC\Model\Data\Eav; use Magento\Framework\Api\AbstractExtensibleObject; @@ -31,6 +34,17 @@ class AttributeMetadata extends AbstractExtensibleObject implements MetadataObje 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. * @@ -40,4 +54,15 @@ class AttributeMetadata extends AbstractExtensibleObject implements MetadataObje { 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/TestModuleMSC/Model/Data/Eav/AttributeMetadataBuilder.php b/dev/tests/api-functional/_files/Magento/TestModuleMSC/Model/Data/Eav/AttributeMetadataBuilder.php deleted file mode 100644 index 64ceb50d1395acac795546d8ae2134d63fb62002..0000000000000000000000000000000000000000 --- a/dev/tests/api-functional/_files/Magento/TestModuleMSC/Model/Data/Eav/AttributeMetadataBuilder.php +++ /dev/null @@ -1,37 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\TestModuleMSC\Model\Data\Eav; - -use Magento\Framework\Api\AttributeMetadataBuilderInterface; -use Magento\Framework\Api\ExtensibleObjectBuilder; - -/** - * Class AttributeMetadataBuilder - */ -class AttributeMetadataBuilder extends ExtensibleObjectBuilder implements AttributeMetadataBuilderInterface -{ - /** - * Set attribute id - * - * @param int $attributeId - * @return $this - */ - public function setAttributeId($attributeId) - { - return $this->_set(AttributeMetadata::ATTRIBUTE_ID, $attributeId); - } - - /** - * Set attribute code - * - * @param string $attributeCode - * @return $this - */ - public function setAttributeCode($attributeCode) - { - return $this->_set(AttributeMetadata::ATTRIBUTE_CODE, $attributeCode); - } -} 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 c35147c0e7745c3829215f1c93ba772894a9f0f5..ff18bed75ef1fd16fe6139cd4aeb4dd60ed92ef0 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 @@ -20,6 +20,15 @@ class Item extends \Magento\Framework\Model\AbstractExtensibleModel implements I return $this->_data['item_id']; } + /** + * @param int $itemId + * @return $this + */ + public function setItemId($itemId) + { + return $this->setData('item_id', $itemId); + } + /** * @return string */ @@ -27,4 +36,13 @@ class Item extends \Magento\Framework\Model\AbstractExtensibleModel implements I { 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/TestModuleMSC/etc/di.xml b/dev/tests/api-functional/_files/Magento/TestModuleMSC/etc/di.xml index 2be26f6ab283284c7b4ffde3c2402473c550201e..ea1e9ab9bc871215ffbd87448084ba274de9d236 100644 --- a/dev/tests/api-functional/_files/Magento/TestModuleMSC/etc/di.xml +++ b/dev/tests/api-functional/_files/Magento/TestModuleMSC/etc/di.xml @@ -15,7 +15,6 @@ <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/framework/Magento/TestFramework/Helper/Customer.php b/dev/tests/api-functional/framework/Magento/TestFramework/Helper/Customer.php index 3e23b454e67df29659f9896c4ca97535093925a7..746bea41561c61ea1fc80233fabdee38b698bd40 100644 --- a/dev/tests/api-functional/framework/Magento/TestFramework/Helper/Customer.php +++ b/dev/tests/api-functional/framework/Magento/TestFramework/Helper/Customer.php @@ -176,7 +176,11 @@ class Customer extends WebapiAbstract ], ]; $customer = $this->customerDataFactory->create(); - $this->dataObjectHelper->populateWithArray($customer, $customerData); + $this->dataObjectHelper->populateWithArray( + $customer, + $customerData, + '\Magento\Customer\Api\Data\CustomerInterface' + ); return $customer; } } diff --git a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/CategoryRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/CategoryRepositoryTest.php index 9cf88f3b541a85659aa4780f336b9178688bb100..6a61347d6d211ad498aabff70b382545b3550748 100644 --- a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/CategoryRepositoryTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/CategoryRepositoryTest.php @@ -166,13 +166,13 @@ class CategoryRepositoryTest extends WebapiAbstract 'name' => isset($categoryData['name']) ? $categoryData['name'] : uniqid('Category-', true), 'is_active' => '1', + 'include_in_menu' => "1", 'custom_attributes' => [ ['attribute_code' => 'url_key', 'value' => ''], ['attribute_code' => 'description', 'value' => 'Custom description'], ['attribute_code' => 'meta_title', 'value' => ''], ['attribute_code' => 'meta_keywords', 'value' => ''], ['attribute_code' => 'meta_description', 'value' => ''], - ['attribute_code' => 'include_in_menu', 'value' => '1'], ['attribute_code' => 'display_mode', 'value' => 'PRODUCTS'], ['attribute_code' => 'landing_page', 'value' => ''], ['attribute_code' => 'is_anchor', 'value' => '0'], @@ -250,6 +250,8 @@ class CategoryRepositoryTest extends WebapiAbstract $data['id'] = $id; return $this->_webApiCall($serviceInfo, ['id' => $id, 'category' => $data]); } else { + $data['id'] = $id; + return $this->_webApiCall($serviceInfo, ['id' => $id, 'category' => $data]); return $this->_webApiCall($serviceInfo, ['category' => $data]); } } diff --git a/dev/tests/api-functional/testsuite/Magento/Customer/Api/CustomerRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/Customer/Api/CustomerRepositoryTest.php index 91b10316172d00186756c1acd8a67892662507c7..f7e988d062bbba12ccc7b951b6e18ddb3fb32c20 100644 --- a/dev/tests/api-functional/testsuite/Magento/Customer/Api/CustomerRepositoryTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Customer/Api/CustomerRepositoryTest.php @@ -213,7 +213,11 @@ class CustomerRepositoryTest extends WebapiAbstract $lastName = $existingCustomerDataObject->getLastname(); $customerData[Customer::LASTNAME] = $lastName . 'Updated'; $newCustomerDataObject = $this->customerDataFactory->create(); - $this->dataObjectHelper->populateWithArray($newCustomerDataObject, $customerData); + $this->dataObjectHelper->populateWithArray( + $newCustomerDataObject, + $customerData, + '\Magento\Customer\Api\Data\CustomerInterface' + ); $serviceInfo = [ 'rest' => [ @@ -249,7 +253,11 @@ class CustomerRepositoryTest extends WebapiAbstract $lastName = $existingCustomerDataObject->getLastname(); $customerData[Customer::LASTNAME] = $lastName . 'Updated'; $newCustomerDataObject = $this->customerDataFactory->create(); - $this->dataObjectHelper->populateWithArray($newCustomerDataObject, $customerData); + $this->dataObjectHelper->populateWithArray( + $newCustomerDataObject, + $customerData, + '\Magento\Customer\Api\Data\CustomerInterface' + ); $serviceInfo = [ 'rest' => [ @@ -296,7 +304,11 @@ class CustomerRepositoryTest extends WebapiAbstract $customerData[Customer::LASTNAME] = $lastName . 'Updated'; $customerData[Customer::ID] = -1; $newCustomerDataObject = $this->customerDataFactory->create(); - $this->dataObjectHelper->populateWithArray($newCustomerDataObject, $customerData); + $this->dataObjectHelper->populateWithArray( + $newCustomerDataObject, + $customerData, + '\Magento\Customer\Api\Data\CustomerInterface' + ); $serviceInfo = [ 'rest' => [ diff --git a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/CreditmemoCreateTest.php b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/CreditmemoCreateTest.php index 5eb537e8fe78b44709fe801499ccc492bd38fe6a..1f3e32bcd3441fdde3cc3e07918bf2000b3a2746 100644 --- a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/CreditmemoCreateTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/CreditmemoCreateTest.php @@ -44,7 +44,7 @@ class CreditmemoCreateTest extends WebapiAbstract /** @var \Magento\Sales\Model\Order\Item $orderItem */ $orderItem = current($order->getAllItems()); $items = [ - $orderItem->getId() => ['qty' => $orderItem->getQtyInvoiced(), 'order_item_id' => $orderItem->getId()], + $orderItem->getId() => ['order_item_id' => $orderItem->getId(), 'qty' => $orderItem->getQtyInvoiced()], ]; $serviceInfo = [ 'rest' => [ 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 d3bb09f340db73f6839c74e741fd89a1aca37fd7..f5b38cf18ae14725f0946c4e44856845f9c535d3 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 @@ -32,11 +32,11 @@ class OrderCreateTest extends WebapiAbstract { /** @var \Magento\Sales\Model\Order $orderBuilder */ $orderFactory = $this->objectManager->get('Magento\Sales\Model\OrderFactory'); - /** @var \Magento\Sales\Service\V1\Data\OrderItemBuilder $orderItemBuilder */ + /** @var \Magento\Sales\Api\Data\OrderItemFactory $orderItemFactory */ $orderItemFactory = $this->objectManager->get('Magento\Sales\Model\Order\ItemFactory'); - /** @var \Magento\Sales\Service\V1\Data\OrderPaymentBuilder $orderPaymentBuilder */ + /** @var \Magento\Sales\Api\Data\OrderPaymentFactory $orderPaymentFactory */ $orderPaymentFactory = $this->objectManager->get('Magento\Sales\Model\Order\PaymentFactory'); - /** @var \Magento\Sales\Service\V1\Data\OrderAddressBuilder $orderAddressBuilder */ + /** @var \Magento\Sales\Api\Data\OrderAddressFactory $orderAddressFactory */ $orderAddressFactory = $this->objectManager->get('Magento\Sales\Model\Order\AddressFactory'); $order = $orderFactory->create( diff --git a/dev/tests/api-functional/testsuite/Magento/Webapi/DataObjectSerialization/CustomAttributeSerializationMSCTest.php b/dev/tests/api-functional/testsuite/Magento/Webapi/DataObjectSerialization/CustomAttributeSerializationMSCTest.php index 98f09fbe0795185b8614a36633af680685d2ec23..f8ec083d6e1f3aeb0155475ae83ce034f7ecad61 100644 --- a/dev/tests/api-functional/testsuite/Magento/Webapi/DataObjectSerialization/CustomAttributeSerializationMSCTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Webapi/DataObjectSerialization/CustomAttributeSerializationMSCTest.php @@ -9,7 +9,7 @@ namespace Magento\Webapi\DataObjectSerialization; use Magento\Framework\Reflection\DataObjectProcessor; use Magento\Framework\Webapi\ServiceOutputProcessor; use Magento\TestFramework\Helper\Bootstrap; -use Magento\TestModuleMSC\Api\Data\ItemDataBuilder; +use Magento\TestModuleMSC\Api\Data\ItemInterfaceFactory; /** * api-functional/testsuite/Magento/Webapi/DataObjectSerialization/CustomAttributeSerializationMSCTest.php @@ -31,19 +31,19 @@ class CustomAttributeSerializationMSCTest extends \Magento\Webapi\Routing\BaseSe protected $_soapService = 'testModuleMSCAllSoapAndRest'; /** - * @var ItemDataBuilder + * @var ItemInterfaceFactory */ - protected $itemDataBuilder; + protected $itemDataFactory; /** - * @var \Magento\TestModuleMSC\Api\Data\CustomAttributeNestedDataObjectDataBuilder + * @var \Magento\TestModuleMSC\Api\Data\CustomAttributeNestedDataObjectInterfaceFactory */ - protected $customAttributeNestedDataObjectDataBuilder; + protected $customAttributeNestedDataObjectDataFactory; /** - * @var \Magento\TestModuleMSC\Api\Data\CustomAttributeDataObjectDataBuilder + * @var \Magento\TestModuleMSC\Api\Data\CustomAttributeDataObjectInterfaceFactory */ - protected $customAttributeDataObjectDataBuilder; + protected $customAttributeDataObjectDataFactory; /** * @var DataObjectProcessor $dataObjectProcessor @@ -64,16 +64,16 @@ class CustomAttributeSerializationMSCTest extends \Magento\Webapi\Routing\BaseSe $this->_soapService = 'testModuleMSCAllSoapAndRestV1'; $this->_restResourcePath = "/{$this->_version}/testmoduleMSC/"; - $this->itemDataBuilder = Bootstrap::getObjectManager()->create( - 'Magento\TestModuleMSC\Api\Data\ItemDataBuilder' + $this->itemDataFactory = Bootstrap::getObjectManager()->create( + 'Magento\TestModuleMSC\Api\Data\ItemInterfaceFactory' ); - $this->customAttributeNestedDataObjectDataBuilder = Bootstrap::getObjectManager()->create( - 'Magento\TestModuleMSC\Api\Data\CustomAttributeNestedDataObjectDataBuilder' + $this->customAttributeNestedDataObjectDataFactory = Bootstrap::getObjectManager()->create( + 'Magento\TestModuleMSC\Api\Data\CustomAttributeNestedDataObjectInterfaceFactory' ); - $this->customAttributeDataObjectDataBuilder = Bootstrap::getObjectManager()->create( - 'Magento\TestModuleMSC\Api\Data\CustomAttributeDataObjectDataBuilder' + $this->customAttributeDataObjectDataFactory = Bootstrap::getObjectManager()->create( + 'Magento\TestModuleMSC\Api\Data\CustomAttributeDataObjectInterfaceFactory' ); $this->dataObjectProcessor = Bootstrap::getObjectManager()->create( @@ -128,17 +128,15 @@ class CustomAttributeSerializationMSCTest extends \Magento\Webapi\Routing\BaseSe public function testDataObjectCustomAttributes() { - $customAttributeDataObject = $this->customAttributeDataObjectDataBuilder + $customAttributeDataObject = $this->customAttributeDataObjectDataFactory->create() ->setName('nameValue') - ->setCustomAttribute('custom_attribute_int', 1) - ->create(); + ->setCustomAttribute('custom_attribute_int', 1); - $item = $this->itemDataBuilder + $item = $this->itemDataFactory->create() ->setItemId(1) ->setName('testProductAnyType') ->setCustomAttribute('custom_attribute_data_object', $customAttributeDataObject) - ->setCustomAttribute('custom_attribute_string', 'someStringValue') - ->create(); + ->setCustomAttribute('custom_attribute_string', 'someStringValue'); $serviceInfo = [ 'rest' => [ @@ -174,17 +172,15 @@ class CustomAttributeSerializationMSCTest extends \Magento\Webapi\Routing\BaseSe $result = $this->_webApiCall($serviceInfo, []); - $customAttributeDataObject = $this->customAttributeDataObjectDataBuilder + $customAttributeDataObject = $this->customAttributeDataObjectDataFactory->create() ->setName('nameValue') - ->setCustomAttribute('custom_attribute_int', 1) - ->create(); + ->setCustomAttribute('custom_attribute_int', 1); - $item = $this->itemDataBuilder + $item = $this->itemDataFactory->create() ->setItemId(1) ->setName('testProductAnyType') ->setCustomAttribute('custom_attribute_data_object', $customAttributeDataObject) - ->setCustomAttribute('custom_attribute_string', 'someStringValue') - ->create(); + ->setCustomAttribute('custom_attribute_string', 'someStringValue'); $expectedResponse = $this->serviceOutputProcessor->process( $item, @@ -196,22 +192,19 @@ class CustomAttributeSerializationMSCTest extends \Magento\Webapi\Routing\BaseSe public function testNestedDataObjectCustomAttributes() { - $customAttributeNestedDataObject = $this->customAttributeNestedDataObjectDataBuilder - ->setName('nestedNameValue') - ->create(); + $customAttributeNestedDataObject = $this->customAttributeNestedDataObjectDataFactory->create() + ->setName('nestedNameValue'); - $customAttributeDataObject = $this->customAttributeDataObjectDataBuilder + $customAttributeDataObject = $this->customAttributeDataObjectDataFactory->create() ->setName('nameValue') ->setCustomAttribute('custom_attribute_nested', $customAttributeNestedDataObject) - ->setCustomAttribute('custom_attribute_int', 1) - ->create(); + ->setCustomAttribute('custom_attribute_int', 1); - $item = $this->itemDataBuilder + $item = $this->itemDataFactory->create() ->setItemId(1) ->setName('testProductAnyType') ->setCustomAttribute('custom_attribute_data_object', $customAttributeDataObject) - ->setCustomAttribute('custom_attribute_string', 'someStringValue') - ->create(); + ->setCustomAttribute('custom_attribute_string', 'someStringValue'); $serviceInfo = [ 'rest' => [ diff --git a/dev/tests/api-functional/testsuite/Magento/Webapi/DataObjectSerialization/CustomAttributeSerializationTest.php b/dev/tests/api-functional/testsuite/Magento/Webapi/DataObjectSerialization/CustomAttributeSerializationTest.php index c135e8e0adc2889f855cc7a7cefc1e397a5d5099..0a1c4b7905d38c9517c452a587276c6c9581890a 100644 --- a/dev/tests/api-functional/testsuite/Magento/Webapi/DataObjectSerialization/CustomAttributeSerializationTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Webapi/DataObjectSerialization/CustomAttributeSerializationTest.php @@ -11,7 +11,7 @@ namespace Magento\Webapi\DataObjectSerialization; use Magento\Framework\Webapi\ServiceOutputProcessor; use Magento\TestFramework\Helper\Bootstrap; -use Magento\TestModule1\Service\V1\Entity\ItemBuilder; +use Magento\TestModule1\Service\V1\Entity\ItemFactory; class CustomAttributeSerializationTest extends \Magento\Webapi\Routing\BaseService { @@ -29,19 +29,19 @@ class CustomAttributeSerializationTest extends \Magento\Webapi\Routing\BaseServi protected $_soapService = 'testModule1AllSoapAndRest'; /** - * @var ItemBuilder + * @var ItemFactory */ - protected $itemBuilder; + protected $itemFactory; /** - * @var \Magento\TestModule1\Service\V1\Entity\CustomAttributeNestedDataObjectBuilder + * @var \Magento\TestModule1\Service\V1\Entity\CustomAttributeNestedDataObjectFactory */ - protected $customAttributeNestedDataObjectBuilder; + protected $customAttributeNestedDataObjectFactory; /** - * @var \Magento\TestModule1\Service\V1\Entity\CustomAttributeDataObjectBuilder + * @var \Magento\TestModule1\Service\V1\Entity\CustomAttributeDataObjectFactory */ - protected $customAttributeDataObjectBuilder; + protected $customAttributeDataObjectFactory; /** * @var ServiceOutputProcessor $serviceOutputProcessor @@ -57,16 +57,16 @@ class CustomAttributeSerializationTest extends \Magento\Webapi\Routing\BaseServi $this->_soapService = 'testModule1AllSoapAndRestV1'; $this->_restResourcePath = "/{$this->_version}/testmodule1/"; - $this->itemBuilder = Bootstrap::getObjectManager()->create( - 'Magento\TestModule1\Service\V1\Entity\ItemBuilder' + $this->itemFactory = Bootstrap::getObjectManager()->create( + 'Magento\TestModule1\Service\V1\Entity\ItemFactory' ); - $this->customAttributeNestedDataObjectBuilder = Bootstrap::getObjectManager()->create( - 'Magento\TestModule1\Service\V1\Entity\CustomAttributeNestedDataObjectBuilder' + $this->customAttributeNestedDataObjectFactory = Bootstrap::getObjectManager()->create( + 'Magento\TestModule1\Service\V1\Entity\CustomAttributeNestedDataObjectFactory' ); - $this->customAttributeDataObjectBuilder = Bootstrap::getObjectManager()->create( - 'Magento\TestModule1\Service\V1\Entity\CustomAttributeDataObjectBuilder' + $this->customAttributeDataObjectFactory = Bootstrap::getObjectManager()->create( + 'Magento\TestModule1\Service\V1\Entity\CustomAttributeDataObjectFactory' ); $this->serviceOutputProcessor = Bootstrap::getObjectManager()->create( @@ -117,17 +117,15 @@ class CustomAttributeSerializationTest extends \Magento\Webapi\Routing\BaseServi public function testDataObjectCustomAttributes() { - $customAttributeDataObject = $this->customAttributeDataObjectBuilder + $customAttributeDataObject = $this->customAttributeDataObjectFactory->create() ->setName('nameValue') - ->setCustomAttribute('custom_attribute_int', 1) - ->create(); + ->setCustomAttribute('custom_attribute_int', 1); - $item = $this->itemBuilder + $item = $this->itemFactory->create() ->setItemId(1) ->setName('testProductAnyType') ->setCustomAttribute('custom_attribute_data_object', $customAttributeDataObject) - ->setCustomAttribute('custom_attribute_string', 'someStringValue') - ->create(); + ->setCustomAttribute('custom_attribute_string', 'someStringValue'); $serviceInfo = [ 'rest' => [ @@ -160,17 +158,15 @@ class CustomAttributeSerializationTest extends \Magento\Webapi\Routing\BaseServi $result = $this->_webApiCall($serviceInfo, []); - $customAttributeDataObject = $this->customAttributeDataObjectBuilder + $customAttributeDataObject = $this->customAttributeDataObjectFactory->create() ->setName('nameValue') - ->setCustomAttribute('custom_attribute_int', 1) - ->create(); + ->setCustomAttribute('custom_attribute_int', 1); - $item = $this->itemBuilder + $item = $this->itemFactory->create() ->setItemId(1) ->setName('testProductAnyType') ->setCustomAttribute('custom_attribute_data_object', $customAttributeDataObject) - ->setCustomAttribute('custom_attribute_string', 'someStringValue') - ->create(); + ->setCustomAttribute('custom_attribute_string', 'someStringValue'); $expectedResponse = $this->serviceOutputProcessor->process( $item, '\Magento\TestModule1\Service\V1\AllSoapAndRestInterface', @@ -181,22 +177,19 @@ class CustomAttributeSerializationTest extends \Magento\Webapi\Routing\BaseServi public function testNestedDataObjectCustomAttributes() { - $customAttributeNestedDataObject = $this->customAttributeNestedDataObjectBuilder - ->setName('nestedNameValue') - ->create(); + $customAttributeNestedDataObject = $this->customAttributeNestedDataObjectFactory->create() + ->setName('nestedNameValue'); - $customAttributeDataObject = $this->customAttributeDataObjectBuilder + $customAttributeDataObject = $this->customAttributeDataObjectFactory->create() ->setName('nameValue') ->setCustomAttribute('custom_attribute_nested', $customAttributeNestedDataObject) - ->setCustomAttribute('custom_attribute_int', 1) - ->create(); + ->setCustomAttribute('custom_attribute_int', 1); - $item = $this->itemBuilder + $item = $this->itemFactory->create() ->setItemId(1) ->setName('testProductAnyType') ->setCustomAttribute('custom_attribute_data_object', $customAttributeDataObject) - ->setCustomAttribute('custom_attribute_string', 'someStringValue') - ->create(); + ->setCustomAttribute('custom_attribute_string', 'someStringValue'); $serviceInfo = [ 'rest' => [ diff --git a/dev/tests/api-functional/testsuite/Magento/Webapi/Routing/RequestIdOverrideTest.php b/dev/tests/api-functional/testsuite/Magento/Webapi/Routing/RequestIdOverrideTest.php index f53fee3189db52c68b39ebefa24f1470f60c7bea..67eb179b9171f312c246898c27d636cec7bf88a5 100644 --- a/dev/tests/api-functional/testsuite/Magento/Webapi/Routing/RequestIdOverrideTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Webapi/Routing/RequestIdOverrideTest.php @@ -26,9 +26,9 @@ class RequestIdOverrideTest extends \Magento\Webapi\Routing\BaseService protected $_restResourcePath; /** - * @var \Magento\TestModule5\Service\V1\Entity\AllSoapAndRestBuilder + * @var \Magento\TestModule5\Service\V1\Entity\AllSoapAndRestFactory */ - protected $itemBuilder; + protected $itemFactory; /** * @var string @@ -40,8 +40,8 @@ class RequestIdOverrideTest extends \Magento\Webapi\Routing\BaseService $this->_markTestAsRestOnly('Request Id overriding is a REST based feature.'); $this->_version = 'V1'; $this->_restResourcePath = "/{$this->_version}/TestModule5/"; - $this->itemBuilder = Bootstrap::getObjectManager() - ->create('Magento\TestModule5\Service\V1\Entity\AllSoapAndRestBuilder'); + $this->itemFactory = Bootstrap::getObjectManager() + ->create('Magento\TestModule5\Service\V1\Entity\AllSoapAndRestFactory'); } public function testOverride() @@ -54,10 +54,9 @@ class RequestIdOverrideTest extends \Magento\Webapi\Routing\BaseService 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_PUT, ], ]; - $item = $this->itemBuilder + $item = $this->itemFactory->create() ->setEntityId($incorrectItemId) - ->setName('test') - ->create(); + ->setName('test'); $requestData = ['entityItem' => $item->__toArray()]; $item = $this->_webApiCall($serviceInfo, $requestData); $this->assertEquals( @@ -78,10 +77,9 @@ class RequestIdOverrideTest extends \Magento\Webapi\Routing\BaseService 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_PUT, ], ]; - $item = $this->itemBuilder + $item = $this->itemFactory->create() ->setEntityId($incorrectItemId) - ->setName('test') - ->create(); + ->setName('test'); $requestData = ['entityItem' => $item->__toArray()]; $item = $this->_webApiCall($serviceInfo, $requestData); $this->assertEquals( @@ -100,9 +98,8 @@ class RequestIdOverrideTest extends \Magento\Webapi\Routing\BaseService 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_PUT, ], ]; - $item = $this->itemBuilder - ->setName('test') - ->create(); + $item = $this->itemFactory->create() + ->setName('test'); $requestData = ['entityItem' => $item->__toArray()]; $item = $this->_webApiCall($serviceInfo, $requestData); $this->assertEquals( diff --git a/dev/tests/api-functional/testsuite/Magento/Webapi/Routing/ServiceVersionV1Test.php b/dev/tests/api-functional/testsuite/Magento/Webapi/Routing/ServiceVersionV1Test.php index e2aa1d4098488e7bf5b7af4e4e899332fbde93a3..588c0e095d2760459f71e27e4d25c9d4143ae1e4 100644 --- a/dev/tests/api-functional/testsuite/Magento/Webapi/Routing/ServiceVersionV1Test.php +++ b/dev/tests/api-functional/testsuite/Magento/Webapi/Routing/ServiceVersionV1Test.php @@ -12,7 +12,8 @@ namespace Magento\Webapi\Routing; use Magento\Framework\Api\AttributeValue; use Magento\TestFramework\Authentication\OauthHelper; use Magento\TestFramework\Helper\Bootstrap; -use Magento\TestModule1\Service\V1\Entity\ItemBuilder; +use Magento\TestModule1\Service\V1\Entity\Item; +use Magento\TestModule1\Service\V1\Entity\ItemFactory; class ServiceVersionV1Test extends \Magento\Webapi\Routing\BaseService { @@ -29,11 +30,11 @@ class ServiceVersionV1Test extends \Magento\Webapi\Routing\BaseService */ protected $_soapService = 'testModule1AllSoapAndRest'; - /** @var \Magento\Framework\Api\AttributeDataBuilder */ - protected $valueBuilder; + /** @var \Magento\Framework\Api\AttributeValueFactory */ + protected $valueFactory; - /** @var ItemBuilder */ - protected $itemBuilder; + /** @var ItemFactory */ + protected $itemFactory; protected function setUp() { @@ -41,12 +42,12 @@ class ServiceVersionV1Test extends \Magento\Webapi\Routing\BaseService $this->_soapService = 'testModule1AllSoapAndRestV1'; $this->_restResourcePath = "/{$this->_version}/testmodule1/"; - $this->valueBuilder = Bootstrap::getObjectManager()->create( - 'Magento\Framework\Api\AttributeDataBuilder' + $this->valueFactory = Bootstrap::getObjectManager()->create( + 'Magento\Framework\Api\AttributeValueFactory' ); - $this->itemBuilder = Bootstrap::getObjectManager()->create( - 'Magento\TestModule1\Service\V1\Entity\ItemBuilder' + $this->itemFactory = Bootstrap::getObjectManager()->create( + 'Magento\TestModule1\Service\V1\Entity\ItemFactory' ); } @@ -76,38 +77,34 @@ class ServiceVersionV1Test extends \Magento\Webapi\Routing\BaseService { $this->_markTestAsRestOnly('Test will fail for SOAP because attribute values get converted to strings.'); $customerAttributes = [ - ItemBuilder::CUSTOM_ATTRIBUTE_1 => [ - AttributeValue::ATTRIBUTE_CODE => ItemBuilder::CUSTOM_ATTRIBUTE_1, + Item::CUSTOM_ATTRIBUTE_1 => [ + AttributeValue::ATTRIBUTE_CODE => Item::CUSTOM_ATTRIBUTE_1, AttributeValue::VALUE => '12345', ], - ItemBuilder::CUSTOM_ATTRIBUTE_2 => [ - AttributeValue::ATTRIBUTE_CODE => ItemBuilder::CUSTOM_ATTRIBUTE_2, + Item::CUSTOM_ATTRIBUTE_2 => [ + AttributeValue::ATTRIBUTE_CODE => Item::CUSTOM_ATTRIBUTE_2, AttributeValue::VALUE => 12345, ], - ItemBuilder::CUSTOM_ATTRIBUTE_3 => [ - AttributeValue::ATTRIBUTE_CODE => ItemBuilder::CUSTOM_ATTRIBUTE_3, + Item::CUSTOM_ATTRIBUTE_3 => [ + AttributeValue::ATTRIBUTE_CODE => Item::CUSTOM_ATTRIBUTE_3, AttributeValue::VALUE => true, ], ]; - $attributeValue1 = $this->valueBuilder - ->setAttributeCode(ItemBuilder::CUSTOM_ATTRIBUTE_1) - ->setValue('12345') - ->create(); - $attributeValue2 = $this->valueBuilder - ->setAttributeCode(ItemBuilder::CUSTOM_ATTRIBUTE_2) - ->setValue(12345) - ->create(); - $attributeValue3 = $this->valueBuilder - ->setAttributeCode(ItemBuilder::CUSTOM_ATTRIBUTE_3) - ->setValue(true) - ->create(); + $attributeValue1 = $this->valueFactory->create() + ->setAttributeCode(Item::CUSTOM_ATTRIBUTE_1) + ->setValue('12345'); + $attributeValue2 = $this->valueFactory->create() + ->setAttributeCode(Item::CUSTOM_ATTRIBUTE_2) + ->setValue(12345); + $attributeValue3 = $this->valueFactory->create() + ->setAttributeCode(Item::CUSTOM_ATTRIBUTE_3) + ->setValue(true); - $item = $this->itemBuilder + $item = $this->itemFactory->create() ->setItemId(1) ->setName('testProductAnyType') - ->setCustomAttributes([$attributeValue1, $attributeValue2, $attributeValue3]) - ->create(); + ->setCustomAttributes([$attributeValue1, $attributeValue2, $attributeValue3]); $serviceInfo = [ 'rest' => [ diff --git a/dev/tests/integration/testsuite/Magento/Customer/Model/AccountManagementTest.php b/dev/tests/integration/testsuite/Magento/Customer/Model/AccountManagementTest.php index 0fdb5939928cfe40230052e9d3ce483166a1417d..7c5c490fc594672a29274872150bc4d22a76fee6 100755 --- a/dev/tests/integration/testsuite/Magento/Customer/Model/AccountManagementTest.php +++ b/dev/tests/integration/testsuite/Magento/Customer/Model/AccountManagementTest.php @@ -590,7 +590,11 @@ class AccountManagementTest extends \PHPUnit_Framework_TestCase ] ); $customerEntity = $this->customerFactory->create(); - $this->dataObjectHelper->populateWithArray($customerEntity, $customerData); + $this->dataObjectHelper->populateWithArray( + $customerEntity, + $customerData, + '\Magento\Customer\Api\Data\CustomerInterface' + ); $customerAfter = $this->accountManagement->createAccount($customerEntity, 'aPassword'); $this->assertGreaterThan(0, $customerAfter->getId()); diff --git a/dev/tests/integration/testsuite/Magento/Customer/Model/Resource/CustomerRepositoryTest.php b/dev/tests/integration/testsuite/Magento/Customer/Model/Resource/CustomerRepositoryTest.php index 92fc0f516f8e8c2633794d206460226a72c6b355..da8f3084e644a6c34069c4259209b65bd32cf311 100644 --- a/dev/tests/integration/testsuite/Magento/Customer/Model/Resource/CustomerRepositoryTest.php +++ b/dev/tests/integration/testsuite/Magento/Customer/Model/Resource/CustomerRepositoryTest.php @@ -146,7 +146,11 @@ class CustomerRepositoryTest extends \PHPUnit_Framework_TestCase 'default_shipping' => $defaultShipping ]); $customerDetails = $this->customerFactory->create(); - $this->dataObjectHelper->populateWithArray($customerDetails, $customerData); + $this->dataObjectHelper->populateWithArray( + $customerDetails, + $customerData, + '\Magento\Customer\Api\Data\CustomerInterface' + ); $this->customerRepository->save($customerDetails); $customerAfter = $this->customerRepository->getById($existingCustomerId); $this->assertEquals($email, $customerAfter->getEmail()); @@ -208,10 +212,18 @@ class CustomerRepositoryTest extends \PHPUnit_Framework_TestCase $addressId = $addresses[0]->getId(); $newAddress = array_merge($addresses[0]->__toArray(), ['city' => $city]); $newAddressDataObject = $this->addressFactory->create(); - $this->dataObjectHelper->populateWithArray($newAddressDataObject, $newAddress); + $this->dataObjectHelper->populateWithArray( + $newAddressDataObject, + $newAddress, + '\Magento\Customer\Api\Data\AddressInterface' + ); $newAddressDataObject->setRegion($addresses[0]->getRegion()); $newCustomerEntity = $this->customerFactory->create(); - $this->dataObjectHelper->populateWithArray($newCustomerEntity, $customerDetails); + $this->dataObjectHelper->populateWithArray( + $newCustomerEntity, + $customerDetails, + '\Magento\Customer\Api\Data\CustomerInterface' + ); $newCustomerEntity->setId($customerId) ->setAddresses([$newAddressDataObject, $addresses[1]]); $this->customerRepository->save($newCustomerEntity); @@ -236,7 +248,11 @@ class CustomerRepositoryTest extends \PHPUnit_Framework_TestCase $customer = $this->customerRepository->getById($customerId); $customerDetails = $customer->__toArray(); $newCustomerEntity = $this->customerFactory->create(); - $this->dataObjectHelper->populateWithArray($newCustomerEntity, $customerDetails); + $this->dataObjectHelper->populateWithArray( + $newCustomerEntity, + $customerDetails, + '\Magento\Customer\Api\Data\CustomerInterface' + ); $newCustomerEntity->setId($customer->getId()) ->setAddresses(null); $this->customerRepository->save($newCustomerEntity); @@ -257,7 +273,11 @@ class CustomerRepositoryTest extends \PHPUnit_Framework_TestCase $customer = $this->customerRepository->getById($customerId); $customerDetails = $customer->__toArray(); $newCustomerEntity = $this->customerFactory->create(); - $this->dataObjectHelper->populateWithArray($newCustomerEntity, $customerDetails); + $this->dataObjectHelper->populateWithArray( + $newCustomerEntity, + $customerDetails, + '\Magento\Customer\Api\Data\CustomerInterface' + ); $newCustomerEntity->setId($customer->getId()) ->setAddresses([]); $this->customerRepository->save($newCustomerEntity); @@ -279,9 +299,9 @@ class CustomerRepositoryTest extends \PHPUnit_Framework_TestCase */ public function testSearchCustomers($filters, $filterGroup, $expectedResult) { - /** @var \Magento\Framework\Api\SearchCriteriaDataBuilder $searchBuilder */ + /** @var \Magento\Framework\Api\SearchCriteriBuilder $searchBuilder */ $searchBuilder = Bootstrap::getObjectManager() - ->create('Magento\Framework\Api\SearchCriteriaDataBuilder'); + ->create('Magento\Framework\Api\SearchCriteriaBuilder'); foreach ($filters as $filter) { $searchBuilder->addFilter([$filter]); } @@ -308,9 +328,9 @@ class CustomerRepositoryTest extends \PHPUnit_Framework_TestCase */ public function testSearchCustomersOrder() { - /** @var \Magento\Framework\Api\SearchCriteriaDataBuilder $searchBuilder */ + /** @var \Magento\Framework\Api\SearchCriteriaBuilder $searchBuilder */ $objectManager = Bootstrap::getObjectManager(); - $searchBuilder = $objectManager->create('Magento\Framework\Api\SearchCriteriaDataBuilder'); + $searchBuilder = $objectManager->create('Magento\Framework\Api\SearchCriteriaBuilder'); // Filter for 'firstname' like 'First' $filterBuilder = $objectManager->create('Magento\Framework\Api\FilterBuilder'); diff --git a/dev/tests/integration/testsuite/Magento/Customer/Model/Resource/GroupRepositoryTest.php b/dev/tests/integration/testsuite/Magento/Customer/Model/Resource/GroupRepositoryTest.php index c9971f4b1f581d61ed1094d17ea75726fc75c172..e6b402a6c7e80df1611c57033d69cb20e6ce53fa 100644 --- a/dev/tests/integration/testsuite/Magento/Customer/Model/Resource/GroupRepositoryTest.php +++ b/dev/tests/integration/testsuite/Magento/Customer/Model/Resource/GroupRepositoryTest.php @@ -25,7 +25,7 @@ class GroupRepositoryTest extends \PHPUnit_Framework_TestCase /** @var \Magento\Customer\Model\Data\GroupInterfaceFactory */ private $groupFactory; - /** @var \Magento\Framework\Api\SearchCriteriaDataBuilder */ + /** @var \Magento\Framework\Api\SearchCriteriaBuilder */ private $searchCriteriaBuilder; protected function setUp() @@ -33,7 +33,7 @@ class GroupRepositoryTest extends \PHPUnit_Framework_TestCase $this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); $this->groupRepository = $this->objectManager->create('Magento\Customer\Api\GroupRepositoryInterface'); $this->groupFactory = $this->objectManager->create('Magento\Customer\Api\Data\GroupInterfaceFactory'); - $this->searchCriteriaBuilder = $this->objectManager->create('Magento\Framework\Api\SearchCriteriaDataBuilder'); + $this->searchCriteriaBuilder = $this->objectManager->create('Magento\Framework\Api\SearchCriteriaBuilder'); } /** diff --git a/dev/tests/integration/testsuite/Magento/Framework/Api/Code/Generator/DataBuilderTest.php b/dev/tests/integration/testsuite/Magento/Framework/Api/Code/Generator/DataBuilderTest.php deleted file mode 100644 index 3f164c9d5312577ca04f70532db1c2d2b787a4e8..0000000000000000000000000000000000000000 --- a/dev/tests/integration/testsuite/Magento/Framework/Api/Code/Generator/DataBuilderTest.php +++ /dev/null @@ -1,160 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Framework\Api\Code\Generator; - -use Magento\Wonderland\Api\Data\FakeAddressInterface; -use Magento\Wonderland\Api\Data\FakeRegionInterface; -use Magento\Wonderland\Model\Data\FakeAddress; -use Magento\Wonderland\Model\Data\FakeRegion; - -class DataBuilderTest 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', - ], - ] - ); - } - - /** - * @dataProvider getBuildersToTest - */ - public function testBuilders($builderType) - { - $builder = $this->_objectManager->create($builderType); - $this->assertInstanceOf($builderType, $builder); - } - - public function getBuildersToTest() - { - return [ - ['Magento\Catalog\Api\Data\ProductDataBuilder'], - ]; - } - - public function testDataObjectBuilder() - { - $regionBuilder = $this->_objectManager->create('Magento\Wonderland\Model\Data\FakeRegionBuilder'); - $this->assertInstanceOf('\Magento\Wonderland\Model\Data\FakeRegionBuilder', $regionBuilder); - $region = $regionBuilder->setRegion('test') - ->setRegionCode('test_code') - ->setRegionId('test_id') - ->create(); - $this->assertInstanceOf('\Magento\Wonderland\Model\Data\FakeRegion', $region); - $this->assertEquals('test', $region->getRegion()); - } - - public function testDataObjectPopulateWithArray() - { - $data = $this->getAddressArray(); - - /** @var \Magento\Wonderland\Model\Data\FakeAddressBuilder $addressBuilder */ - $addressBuilder = $this->_objectManager->create('Magento\Wonderland\Model\Data\FakeAddressBuilder'); - /** @var \Magento\Wonderland\Api\Data\FakeAddressInterface $address */ - $address = $addressBuilder->populateWithArray($data) - ->create(); - $this->assertInstanceOf('\Magento\Wonderland\Model\Data\FakeAddress', $address); - $this->assertEquals('Johnes', $address->getLastname()); - $this->assertNull($address->getCustomAttribute('test')); - $this->assertEmpty($address->getCustomAttributes()); - $this->assertInstanceOf('\Magento\Wonderland\Model\Data\FakeRegion', $address->getRegion()); - $this->assertInstanceOf('\Magento\Wonderland\Model\Data\FakeRegion', $address->getRegions()[0]); - $this->assertInstanceOf('\Magento\Wonderland\Model\Data\FakeRegion', $address->getRegions()[1]); - } - - public function testDataObjectPopulate() - { - $data = $this->getAddressArray(); - - /** @var \Magento\Wonderland\Model\Data\FakeAddressBuilder $addressBuilder */ - $addressBuilder = $this->_objectManager->create('Magento\Wonderland\Model\Data\FakeAddressBuilder'); - /** @var \Magento\Wonderland\Api\Data\FakeAddressInterface $address */ - $address = $addressBuilder->populateWithArray($data) - ->create(); - - $addressUpdated = $addressBuilder->populate($address) - ->setCompany('RocketScience') - ->create(); - - $this->assertInstanceOf('\Magento\Wonderland\Model\Data\FakeAddress', $addressUpdated); - $this->assertEquals('RocketScience', $addressUpdated->getCompany()); - - $this->assertEmpty($address->getCustomAttributes()); - $this->assertInstanceOf('\Magento\Wonderland\Model\Data\FakeRegion', $address->getRegion()); - $this->assertInstanceOf('\Magento\Wonderland\Model\Data\FakeRegion', $address->getRegions()[0]); - $this->assertInstanceOf('\Magento\Wonderland\Model\Data\FakeRegion', $address->getRegions()[1]); - } - - public function testModelPopulateWithArray() - { - $data = $this->getAddressArray(); - - /** @var \Magento\Wonderland\Api\Data\FakeAddressDataBuilder $addressBuilder */ - $addressBuilder = $this->_objectManager->create('Magento\Wonderland\Api\Data\FakeAddressDataBuilder'); - /** @var \Magento\Wonderland\Api\Data\FakeAddressInterface $address */ - $address = $addressBuilder->populateWithArray($data) - ->create(); - $this->assertInstanceOf('\Magento\Wonderland\Api\Data\FakeAddressInterface', $address); - $this->assertEquals('Johnes', $address->getLastname()); - $this->assertEquals(true, $address->isDefaultShipping()); - $this->assertEquals(false, $address->isDefaultBilling()); - $this->assertNull($address->getCustomAttribute('test')); - $this->assertInstanceOf('\Magento\Wonderland\Api\Data\FakeRegionInterface', $address->getRegion()); - $this->assertInstanceOf('\Magento\Wonderland\Api\Data\FakeRegionInterface', $address->getRegions()[0]); - $this->assertInstanceOf('\Magento\Wonderland\Api\Data\FakeRegionInterface', $address->getRegions()[1]); - } - - public function getAddressArray() - { - return [ - FakeAddressInterface::ID => 1, - FakeAddressInterface::CITY => 'Kiev', - FakeAddressInterface::REGION => [ - FakeRegionInterface::REGION => 'US', - FakeRegionInterface::REGION_CODE => 'TX', - FakeRegionInterface::REGION_ID => '1', - ], - FakeAddressInterface::REGIONS => [ - [ - FakeRegionInterface::REGION => 'US', - FakeRegionInterface::REGION_CODE => 'TX', - FakeRegionInterface::REGION_ID => '1', - ], [ - FakeRegionInterface::REGION => 'US', - FakeRegionInterface::REGION_CODE => 'TX', - FakeRegionInterface::REGION_ID => '2', - ], - ], - FakeAddressInterface::COMPANY => 'Magento', - FakeAddressInterface::COUNTRY_ID => 'US', - FakeAddressInterface::CUSTOMER_ID => '1', - FakeAddressInterface::FAX => '222', - FakeAddressInterface::FIRSTNAME => 'John', - FakeAddressInterface::MIDDLENAME => 'Dow', - FakeAddressInterface::LASTNAME => 'Johnes', - FakeAddressInterface::SUFFIX => 'Jr.', - FakeAddressInterface::POSTCODE => '78757', - FakeAddressInterface::PREFIX => 'Mr.', - FakeAddressInterface::STREET => 'Oak rd.', - FakeAddressInterface::TELEPHONE => '1234567', - FakeAddressInterface::VAT_ID => '1', - 'test' => 'xxx', - FakeAddressInterface::DEFAULT_BILLING => false, - FakeAddressInterface::DEFAULT_SHIPPING => true, - ]; - } -} diff --git a/dev/tests/integration/testsuite/Magento/Framework/Object/Copy/Config/ReaderTest.php b/dev/tests/integration/testsuite/Magento/Framework/Object/Copy/Config/ReaderTest.php index 5bb93561c8d4a4dc42daab08ef75b9cddf482e08..3e043b22fa3faf9bdbc795c72227922ab9dd68b9 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Object/Copy/Config/ReaderTest.php +++ b/dev/tests/integration/testsuite/Magento/Framework/Object/Copy/Config/ReaderTest.php @@ -53,10 +53,10 @@ class ReaderTest extends \PHPUnit_Framework_TestCase ->willReturn($fileList); $expected = [ 'global' => [ - 'sales_convert_quote_item' => [ + 'quote_convert_item' => [ 'event_id' => ['to_order_item' => "*"], 'event_name' => ['to_order_item' => "*"], - 'event_description' => ['to_order_item' => "complexDesciption"], + 'event_description' => ['to_order_item' => "complexDescription"], ], ], ]; diff --git a/dev/tests/integration/testsuite/Magento/Framework/Object/Copy/Config/_files/partialFieldsetFirst.xml b/dev/tests/integration/testsuite/Magento/Framework/Object/Copy/Config/_files/partialFieldsetFirst.xml index 233ceaee8a79e28ce8f673a0fa35da861e91dcdf..6074e4f38f44796afd9e074b35cdeb09fc366d72 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Object/Copy/Config/_files/partialFieldsetFirst.xml +++ b/dev/tests/integration/testsuite/Magento/Framework/Object/Copy/Config/_files/partialFieldsetFirst.xml @@ -8,13 +8,13 @@ <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../../../../lib/internal/Magento/Framework/Object/etc/fieldset.xsd"> <scope id="global"> - <fieldset id="sales_convert_quote_item"> + <fieldset id="quote_convert_item"> <field name="event_id"> </field> <field name="event_name"> </field> <field name="event_description"> - <aspect name="to_order_item" targetField="complexDesciption" /> + <aspect name="to_order_item" targetField="complexDescription" /> </field> </fieldset> </scope> diff --git a/dev/tests/integration/testsuite/Magento/Framework/Object/Copy/Config/_files/partialFieldsetSecond.xml b/dev/tests/integration/testsuite/Magento/Framework/Object/Copy/Config/_files/partialFieldsetSecond.xml index 04d98120d2a747b704b50435c4ef9b6206fbdc5e..5e6a7144b6260bea88151d2fa073745826c684cd 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Object/Copy/Config/_files/partialFieldsetSecond.xml +++ b/dev/tests/integration/testsuite/Magento/Framework/Object/Copy/Config/_files/partialFieldsetSecond.xml @@ -8,7 +8,7 @@ <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../../../../lib/internal/Magento/Framework/Object/etc/fieldset_file.xsd"> <scope id="global"> - <fieldset id="sales_convert_quote_item"> + <fieldset id="quote_convert_item"> <field name="event_id"> <aspect name="to_order_item" /> </field> diff --git a/dev/tests/integration/testsuite/Magento/Indexer/Controller/Adminhtml/IndexerTest.php b/dev/tests/integration/testsuite/Magento/Indexer/Controller/Adminhtml/IndexerTest.php index 26fe450bc09707af9b4288f1bac4c82b8a3ac593..827606d2109cc98040774d98805329fe5ca57594 100644 --- a/dev/tests/integration/testsuite/Magento/Indexer/Controller/Adminhtml/IndexerTest.php +++ b/dev/tests/integration/testsuite/Magento/Indexer/Controller/Adminhtml/IndexerTest.php @@ -19,7 +19,7 @@ class IndexerTest extends \Magento\Backend\Utility\Controller { $this->dispatch('backend/indexer/indexer/list/'); $body = $this->getResponse()->getBody(); - $this->assertContains('<h1 class="title">Index Management</h1>', $body); + $this->assertContains('<h1 class="page-title">Index Management</h1>', $body); $this->assertSelectCount('#gridIndexer_massaction-select', 1, $body, 'Mode selector is not found'); $this->assertContains('option value="change_mode_onthefly"', $body); $this->assertContains('option value="change_mode_changelog"', $body); diff --git a/dev/tests/integration/testsuite/Magento/Quote/Model/QuoteTest.php b/dev/tests/integration/testsuite/Magento/Quote/Model/QuoteTest.php index 655f6ea9d006c50f4afcdd14a9758aa842f52b62..92fc68dbe396734fa7d87b5803f7ecbb8c830e1c 100644 --- a/dev/tests/integration/testsuite/Magento/Quote/Model/QuoteTest.php +++ b/dev/tests/integration/testsuite/Magento/Quote/Model/QuoteTest.php @@ -46,7 +46,11 @@ class QuoteTest extends \PHPUnit_Framework_TestCase $dataObjectHelper = Bootstrap::getObjectManager()->create('Magento\Framework\Api\DataObjectHelper'); $expected = $this->_getCustomerDataArray(); $customer = $customerFactory->create(); - $dataObjectHelper->populateWithArray($customer, $expected); + $dataObjectHelper->populateWithArray( + $customer, + $expected, + '\Magento\Customer\Api\Data\CustomerInterface' + ); $this->assertEquals($expected, $this->convertToArray($customer)); @@ -68,7 +72,11 @@ class QuoteTest extends \PHPUnit_Framework_TestCase //For save in repository $expected = $this->removeIdFromCustomerData($expected); $customerDataSet = $customerFactory->create(); - $dataObjectHelper->populateWithArray($customerDataSet, $expected); + $dataObjectHelper->populateWithArray( + $customerDataSet, + $expected, + '\Magento\Customer\Api\Data\CustomerInterface' + ); $this->assertEquals($expected, $this->convertToArray($customerDataSet)); /** * @var \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository @@ -80,7 +88,11 @@ class QuoteTest extends \PHPUnit_Framework_TestCase $expected = $this->_getCustomerDataArray(); $expected = $this->changeEmailInCustomerData('test@example.com', $expected); $customerDataUpdated = $customerFactory->create(); - $dataObjectHelper->populateWithArray($customerDataUpdated, $expected); + $dataObjectHelper->populateWithArray( + $customerDataUpdated, + $expected, + '\Magento\Customer\Api\Data\CustomerInterface' + ); $quote->updateCustomerData($customerDataUpdated); $customer = $quote->getCustomer(); $expected = $this->changeEmailInCustomerData('test@example.com', $expected); diff --git a/dev/tests/integration/testsuite/Magento/Webapi/Service/Entity/AssociativeArrayBuilder.php b/dev/tests/integration/testsuite/Magento/Webapi/Service/Entity/AssociativeArrayBuilder.php deleted file mode 100644 index e5d4037bf903b60af6d50808f0e35fa2c92588d5..0000000000000000000000000000000000000000 --- a/dev/tests/integration/testsuite/Magento/Webapi/Service/Entity/AssociativeArrayBuilder.php +++ /dev/null @@ -1,17 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Webapi\Service\Entity; - -class AssociativeArrayBuilder extends \Magento\Framework\Api\ExtensibleObjectBuilder -{ - /** - * @param string[] $associativeArray - */ - public function setAssociativeArray(array $associativeArray) - { - $this->data['associativeArray'] = $associativeArray; - } -} diff --git a/dev/tests/integration/testsuite/Magento/Webapi/Service/Entity/DataObjectArrayBuilder.php b/dev/tests/integration/testsuite/Magento/Webapi/Service/Entity/DataObjectArrayBuilder.php deleted file mode 100644 index 4abff8fedc1b030d160bf132905d7a379a319110..0000000000000000000000000000000000000000 --- a/dev/tests/integration/testsuite/Magento/Webapi/Service/Entity/DataObjectArrayBuilder.php +++ /dev/null @@ -1,17 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Webapi\Service\Entity; - -class DataObjectArrayBuilder extends \Magento\Framework\Api\ExtensibleObjectBuilder -{ - /** - * @param \Magento\Webapi\Service\Entity\SimpleDataObject[] $items - */ - public function setItems(array $items) - { - $this->data['items'] = $items; - } -} diff --git a/dev/tests/integration/testsuite/Magento/Webapi/Service/Entity/NestedBuilder.php b/dev/tests/integration/testsuite/Magento/Webapi/Service/Entity/NestedBuilder.php deleted file mode 100644 index ccac8cbd49be0a3310c28dd7a31a3d3188e9263c..0000000000000000000000000000000000000000 --- a/dev/tests/integration/testsuite/Magento/Webapi/Service/Entity/NestedBuilder.php +++ /dev/null @@ -1,17 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Webapi\Service\Entity; - -class NestedBuilder extends \Magento\Framework\Api\ExtensibleObjectBuilder -{ - /** - * @param \Magento\Webapi\Service\Entity\SimpleDataObject $details - */ - public function setDetails($details) - { - $this->data['details'] = $details; - } -} diff --git a/dev/tests/integration/testsuite/Magento/Webapi/Service/Entity/SimpleArrayBuilder.php b/dev/tests/integration/testsuite/Magento/Webapi/Service/Entity/SimpleArrayBuilder.php deleted file mode 100644 index 852a82291ad0ba6b81b388207aebcc5c7bef1d4e..0000000000000000000000000000000000000000 --- a/dev/tests/integration/testsuite/Magento/Webapi/Service/Entity/SimpleArrayBuilder.php +++ /dev/null @@ -1,17 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Webapi\Service\Entity; - -class SimpleArrayBuilder extends \Magento\Framework\Api\ExtensibleObjectBuilder -{ - /** - * @param int[] $ids - */ - public function setIds(array $ids) - { - $this->data['ids'] = $ids; - } -} diff --git a/dev/tests/integration/testsuite/Magento/Webapi/Service/Entity/SimpleBuilder.php b/dev/tests/integration/testsuite/Magento/Webapi/Service/Entity/SimpleBuilder.php deleted file mode 100644 index dbe4047089ca615df59be24c9c6889a5c90f7826..0000000000000000000000000000000000000000 --- a/dev/tests/integration/testsuite/Magento/Webapi/Service/Entity/SimpleBuilder.php +++ /dev/null @@ -1,25 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Webapi\Service\Entity; - -class SimpleBuilder extends \Magento\Framework\Api\ExtensibleObjectBuilder -{ - /** - * @param int $entityId - */ - public function setEntityId($entityId) - { - $this->data['entityId'] = $entityId; - } - - /** - * @param string $name - */ - public function setName($name) - { - $this->data['name'] = $name; - } -} diff --git a/dev/tests/integration/testsuite/Magento/Weee/Model/TaxTest.php b/dev/tests/integration/testsuite/Magento/Weee/Model/TaxTest.php index 03819211a74ecb9c997a21214fd073eae8eca57c..8b1d329150edc4b0e5219f54efdd70a4c49e6106 100644 --- a/dev/tests/integration/testsuite/Magento/Weee/Model/TaxTest.php +++ b/dev/tests/integration/testsuite/Magento/Weee/Model/TaxTest.php @@ -65,7 +65,11 @@ class TaxTest extends \PHPUnit_Framework_TestCase $customerRepository->getById(1), [], '\Magento\Customer\Api\Data\CustomerInterface' ); $customerDataSet = $customerFactory->create(); - $dataObjectHelper->populateWithArray($customerDataSet, $expected); + $dataObjectHelper->populateWithArray( + $customerDataSet, + $expected, + '\Magento\Customer\Api\Data\CustomerInterface' + ); $fixtureGroupCode = 'custom_group'; $fixtureTaxClassId = 3; /** @var \Magento\Customer\Model\Group $group */ 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 df8f052ccc25ec33229b0205a299a9b866685c64..2a90df9b592c34aec24ec7cc96ae639fb53b0738 100644 --- a/dev/tests/static/testsuite/Magento/Test/Integrity/Di/CompilerTest.php +++ b/dev/tests/static/testsuite/Magento/Test/Integrity/Di/CompilerTest.php @@ -7,10 +7,8 @@ */ namespace Magento\Test\Integrity\Di; -use Magento\Framework\Api\Code\Generator\DataBuilder; use Magento\Framework\Api\Code\Generator\Mapper; use Magento\Framework\Api\Code\Generator\SearchResults; -use Magento\Framework\Api\Code\Generator\SearchResultsBuilder; use Magento\Framework\ObjectManager\Code\Generator\Converter; use Magento\Framework\ObjectManager\Code\Generator\Factory; use Magento\Framework\ObjectManager\Code\Generator\Repository; @@ -316,9 +314,6 @@ class CompilerTest extends \PHPUnit_Framework_TestCase $generator = new \Magento\Framework\Code\Generator( $generatorIo, [ - DataBuilder::ENTITY_TYPE => 'Magento\Framework\Api\Code\Generator\DataBuilder', - SearchResultsBuilder::ENTITY_TYPE => 'Magento\Framework\Api\Code\Generator\SearchResultsBuilder', - DataBuilder::ENTITY_TYPE_BUILDER => 'Magento\Framework\Api\Code\Generator\DataBuilder', Factory::ENTITY_TYPE => 'Magento\Framework\ObjectManager\Code\Generator\Factory', Repository::ENTITY_TYPE => 'Magento\Framework\ObjectManager\Code\Generator\Repository', Converter::ENTITY_TYPE => 'Magento\Framework\ObjectManager\Code\Generator\Converter', diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/Magento/Core/Model/Fieldset/_files/fieldset.xml b/dev/tests/static/testsuite/Magento/Test/Integrity/Magento/Core/Model/Fieldset/_files/fieldset.xml index 120bafba36ad6d5385bb753e7571338a8e06c3d2..f6b412aa67c33d3e29d45368951034a2294d5602 100644 --- a/dev/tests/static/testsuite/Magento/Test/Integrity/Magento/Core/Model/Fieldset/_files/fieldset.xml +++ b/dev/tests/static/testsuite/Magento/Test/Integrity/Magento/Core/Model/Fieldset/_files/fieldset.xml @@ -391,7 +391,7 @@ <aspect name="to_order_payment" /> </field> </fieldset> - <fieldset id="sales_convert_quote_item"> + <fieldset id="quote_convert_item"> <field name="sku"> <aspect name="to_order_item" /> </field> 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 6dbca32165dd5ef56301be9883101668b13f018d..77afd6d62a2ffa35e950fbb7efb73914513aa736 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 @@ -2037,7 +2037,6 @@ return [ ['getResourceCollection', 'Magento\CatalogSearch\Model\Resource\EngineInterface'], ['getResultCollection', 'Magento\CatalogSearch\Model\Resource\EngineInterface'], ['getAdvancedResultCollection', 'Magento\CatalogSearch\Model\Resource\EngineInterface'], - ['setIsConfigurable', 'Magento\Catalog\Api\Data\ProductAttributeDataBuilder'], ['_getSendfriendModel', 'Magento\Sendfriend\Block\Send'], ['_initSendToFriendModel', 'Magento\Sendfriend\Controller\Product'], ['register', 'Magento\Sendfriend\Model\Sendfriend'], diff --git a/dev/tests/static/testsuite/Magento/Test/Php/_files/phpcpd/blacklist/common.txt b/dev/tests/static/testsuite/Magento/Test/Php/_files/phpcpd/blacklist/common.txt index b85b6a5737da9fc8acca9aaf00edb545c36e515b..3b24b6214aa2026bbebee8fc505c49b1ef228535 100644 --- a/dev/tests/static/testsuite/Magento/Test/Php/_files/phpcpd/blacklist/common.txt +++ b/dev/tests/static/testsuite/Magento/Test/Php/_files/phpcpd/blacklist/common.txt @@ -132,6 +132,10 @@ Magento/Shipping/Model Magento/Ui Magento/Sales/Service/V1 Magento/Sales/Api +Magento/Eav/Api/Data +Magento/Customer/Api/Data +Magento/Quote/Api/Data +Magento/Catalog/Api/Data Magento/Sales/Spi Magento/Shipping/Controller/Adminhtml/Order/Shipment vendor diff --git a/dev/tools/Magento/Tools/Di/Code/Scanner/PhpScanner.php b/dev/tools/Magento/Tools/Di/Code/Scanner/PhpScanner.php index 9f08a02568b5f6c771bd537799d3313719ec046c..6346d51bd2f8c03a820f6a56ecb9642956784ef3 100644 --- a/dev/tools/Magento/Tools/Di/Code/Scanner/PhpScanner.php +++ b/dev/tools/Magento/Tools/Di/Code/Scanner/PhpScanner.php @@ -68,43 +68,6 @@ class PhpScanner implements ScannerInterface return $absentFactories; } - /** - * Fetch factories from class constructor - * - * @param $file string - * @param $reflectionClass mixed - * @return array - */ - protected function _fetchDataBuilders($file, $reflectionClass) - { - $absentDataBuilders = []; - if ($reflectionClass->hasMethod('__construct')) { - $constructor = $reflectionClass->getMethod('__construct'); - $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], -11) == 'DataBuilder') { - $factoryClassName = $matches[1]; - if (class_exists($factoryClassName)) { - continue; - } - $entityName = rtrim(substr($factoryClassName, 0, -11), '\\'); - if (!class_exists($entityName) && !interface_exists($entityName . 'Interface')) { - $this->_log->add( - Log::CONFIGURATION_ERROR, - $factoryClassName, - 'Invalid DataBuilder for nonexistent class ' . $entityName . ' in file ' . $file - ); - continue; - } - $absentDataBuilders[] = $factoryClassName; - } - } - } - return $absentDataBuilders; - } - /** * Get array of class names * @@ -119,9 +82,8 @@ class PhpScanner implements ScannerInterface foreach ($classes as $className) { $reflectionClass = new \ReflectionClass($className); $absentFactories = $this->_fetchFactories($file, $reflectionClass); - $absentDataBuilders = $this->_fetchDataBuilders($file, $reflectionClass); if (!empty($absentFactories)) { - $output = array_merge($output, $absentFactories, $absentDataBuilders); + $output = array_merge($output, $absentFactories); } } } diff --git a/dev/tools/Magento/Tools/Di/Code/Scanner/RepositoryScanner.php b/dev/tools/Magento/Tools/Di/Code/Scanner/RepositoryScanner.php index 9eb25fc1c50049ca0e8c5463205655df229bc5bd..9261e8d65022956c9aa1989f4a40f4ecfe8066fa 100644 --- a/dev/tools/Magento/Tools/Di/Code/Scanner/RepositoryScanner.php +++ b/dev/tools/Magento/Tools/Di/Code/Scanner/RepositoryScanner.php @@ -40,12 +40,10 @@ class RepositoryScanner implements ScannerInterface if (!class_exists($replacementType->nodeValue, $this->useAutoload)) { $persistor = str_replace('\\Repository', 'InterfacePersistor', $replacementType->nodeValue); $factory = str_replace('\\Repository', 'InterfaceFactory', $replacementType->nodeValue); - $dataBuilder = str_replace('\\Repository', 'DataBuilder', $replacementType->nodeValue); $searchResultFactory = str_replace('\\Repository', 'SearchResultInterfaceFactory', $replacementType->nodeValue); $repositoryClassNames[$persistor] = $persistor; $repositoryClassNames[$factory] = $factory; - $repositoryClassNames[$dataBuilder] = $dataBuilder; $repositoryClassNames[$searchResultFactory] = $searchResultFactory; $repositoryClassNames[$replacementType->nodeValue] = $replacementType->nodeValue; } diff --git a/dev/tools/Magento/Tools/Di/compiler.php b/dev/tools/Magento/Tools/Di/compiler.php index ccd484037efb1af292d05a6d28b5f3d4561571ac..8fb0cd5d24c18a29736cc083757ebaceb1c6b0cb 100644 --- a/dev/tools/Magento/Tools/Di/compiler.php +++ b/dev/tools/Magento/Tools/Di/compiler.php @@ -6,10 +6,8 @@ require __DIR__ . '/../../../bootstrap.php'; $rootDir = realpath(__DIR__ . '/../../../../../'); -use Magento\Framework\Api\Code\Generator\DataBuilder; use Magento\Framework\Api\Code\Generator\Mapper; use Magento\Framework\Api\Code\Generator\SearchResults; -use Magento\Framework\Api\Code\Generator\SearchResultsBuilder; use Magento\Framework\Autoload\AutoloaderRegistry; use Magento\Framework\Interception\Code\Generator\Interceptor; use Magento\Framework\ObjectManager\Code\Generator\Converter; @@ -97,10 +95,7 @@ try { $generator = new \Magento\Framework\Code\Generator( $generatorIo, [ - DataBuilder::ENTITY_TYPE => 'Magento\Framework\Api\Code\Generator\DataBuilder', Interceptor::ENTITY_TYPE => 'Magento\Framework\Interception\Code\Generator\Interceptor', - SearchResultsBuilder::ENTITY_TYPE => 'Magento\Framework\Api\Code\Generator\SearchResultsBuilder', - DataBuilder::ENTITY_TYPE_BUILDER => 'Magento\Framework\Api\Code\Generator\DataBuilder', 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', diff --git a/dev/tools/Magento/Tools/Di/entity_generator.php b/dev/tools/Magento/Tools/Di/entity_generator.php index 52594160c06f7432c38e92fad24e224798667d3a..9a94fe29156e77c22335b424739a20c2862744f9 100644 --- a/dev/tools/Magento/Tools/Di/entity_generator.php +++ b/dev/tools/Magento/Tools/Di/entity_generator.php @@ -4,10 +4,8 @@ * 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\SearchResults; -use Magento\Framework\Api\Code\Generator\SearchResultsBuilder; use Magento\Framework\Autoload\AutoloaderRegistry; use Magento\Framework\Code\Generator; use Magento\Framework\Code\Generator\Io; @@ -75,9 +73,6 @@ $generator = new Generator( $validator, $io, [ - DataBuilder::ENTITY_TYPE => 'Magento\Framework\Api\Code\Generator\DataBuilder', - SearchResultsBuilder::ENTITY_TYPE => 'Magento\Framework\Api\Code\Generator\SearchResultsBuilder', - DataBuilder::ENTITY_TYPE_BUILDER => 'Magento\Framework\Api\Code\Generator\DataBuilder', Proxy::ENTITY_TYPE => 'Magento\Framework\ObjectManager\Code\Generator\Proxy', Factory::ENTITY_TYPE => 'Magento\Framework\ObjectManager\Code\Generator\Factory', Interceptor::ENTITY_TYPE => 'Magento\Framework\Interception\Code\Generator\Interceptor', diff --git a/dev/tools/Magento/Tools/View/deploy.php b/dev/tools/Magento/Tools/View/deploy.php index a68a977243964261d716a16e629bb126f5f8aadb..765ac7e4acaddb0e106bfa98f56e8eb96f11ddf3 100644 --- a/dev/tools/Magento/Tools/View/deploy.php +++ b/dev/tools/Magento/Tools/View/deploy.php @@ -16,10 +16,7 @@ $options = getopt('', ['langs::', 'dry-run', 'verbose::', 'help']); define('USAGE', "USAGE:\n\tphp -f {$baseName} -- [--langs=en_US,de_DE,...] [--verbose=0|1] [--dry-run] [--help]\n"); require __DIR__ . '/../../../../../app/bootstrap.php'; -AutoloaderRegistry::getAutoloader()->addPsr4( - 'Magento\\', - [BP . '/dev/tests/static/framework/Magento/', realpath(__DIR__ . '/../../../Magento/')] -); +AutoloaderRegistry::getAutoloader()->addPsr4('Magento\\', [BP . '/tools/Magento/']); // parse all options if (isset($options['help'])) { @@ -42,26 +39,31 @@ if (isset($options['verbose'])) { $verbosity = 0 === (int)$options['verbose'] ? \Magento\Tools\View\Deployer\Log::SILENT : \Magento\Tools\View\Deployer\Log::ERROR | \Magento\Tools\View\Deployer\Log::DEBUG; } +$logger = new \Magento\Tools\View\Deployer\Log($verbosity); -// run the deployment logic -$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] -); +try { + // run the deployment logic + $filesUtil = new \Magento\Framework\Test\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] + ); -/** @var \Magento\Framework\App\DeploymentConfig $deploymentConfig */ -$deploymentConfig = $objectManager->get('Magento\Framework\App\DeploymentConfig'); -$isAppInstalled = $deploymentConfig->isAvailable(); -if (!$isAppInstalled) { - throw new \Exception('Please install the Magento application before running this process.'); -} + /** @var \Magento\Framework\App\DeploymentConfig $deploymentConfig */ + $deploymentConfig = $objectManager->get('Magento\Framework\App\DeploymentConfig'); + $isAppInstalled = $deploymentConfig->isAvailable(); + if (!$isAppInstalled) { + throw new \Exception('You need to install the Magento application before running this utility.'); + } -$logger = new \Magento\Tools\View\Deployer\Log($verbosity); -/** @var \Magento\Tools\View\Deployer $deployer */ -$deployer = $objectManager->create( - 'Magento\Tools\View\Deployer', - ['filesUtil' => $filesUtil, 'logger' => $logger, 'isDryRun' => $isDryRun] -); -$deployer->deploy($omFactory, $langs); -exit(0); + /** @var \Magento\Tools\View\Deployer $deployer */ + $deployer = $objectManager->create( + 'Magento\Tools\View\Deployer', + ['filesUtil' => $filesUtil, 'logger' => $logger, 'isDryRun' => $isDryRun] + ); + $deployer->deploy($omFactory, $langs); +} catch (\Exception $e) { + $logger->logError($e->getMessage()); + $logger->logDebug($e->getTraceAsString()); + exit(1); +} diff --git a/lib/internal/Magento/Framework/Api/AbstractSearchResultsBuilder.php b/lib/internal/Magento/Framework/Api/AbstractSearchResultsBuilder.php deleted file mode 100644 index e26b83ab6ad04bbcf5eb4705a9f81e0bd3b4c4ac..0000000000000000000000000000000000000000 --- a/lib/internal/Magento/Framework/Api/AbstractSearchResultsBuilder.php +++ /dev/null @@ -1,102 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -namespace Magento\Framework\Api; - -/** - * Builder for the SearchResults Service Data Object - * - * @method SearchResults create() - */ -abstract class AbstractSearchResultsBuilder extends ExtensibleObjectBuilder -{ - /** - * Search criteria builder - * - * @var SearchCriteriaBuilder - */ - protected $searchCriteriaBuilder; - - /** - * Item data object builder - * - * @var BuilderInterface $itemObjectBuilder - */ - protected $itemObjectBuilder; - - /** - * Constructor - * - * @param ObjectFactory $objectFactory - * @param AttributeValueFactory $valueFactory - * @param MetadataServiceInterface $metadataService - * @param SearchCriteriaBuilder $searchCriteriaBuilder - * @param BuilderInterface $itemObjectBuilder - */ - public function __construct( - ObjectFactory $objectFactory, - AttributeValueFactory $valueFactory, - MetadataServiceInterface $metadataService, - SearchCriteriaBuilder $searchCriteriaBuilder, - BuilderInterface $itemObjectBuilder - ) { - parent::__construct($objectFactory, $valueFactory, $metadataService); - $this->searchCriteriaBuilder = $searchCriteriaBuilder; - $this->itemObjectBuilder = $itemObjectBuilder; - } - - /** - * Set search criteria - * - * @param SearchCriteria $searchCriteria - * @return $this - */ - public function setSearchCriteria(SearchCriteria $searchCriteria) - { - return $this->_set(SearchResults::KEY_SEARCH_CRITERIA, $searchCriteria); - } - - /** - * Set total count - * - * @param int $totalCount - * @return $this - */ - public function setTotalCount($totalCount) - { - return $this->_set(SearchResults::KEY_TOTAL_COUNT, $totalCount); - } - - /** - * Set items - * - * @param \Magento\Framework\Api\AbstractExtensibleObject[] $items - * @return $this - */ - public function setItems($items) - { - return $this->_set(SearchResults::KEY_ITEMS, $items); - } - - /** - * {@inheritdoc} - */ - protected function _setDataValues(array $data) - { - if (array_key_exists(SearchResults::KEY_SEARCH_CRITERIA, $data)) { - $data[SearchResults::KEY_SEARCH_CRITERIA] = - $this->searchCriteriaBuilder->populateWithArray($data[SearchResults::KEY_SEARCH_CRITERIA])->create(); - } - if (array_key_exists(SearchResults::KEY_ITEMS, $data)) { - $items = []; - foreach ($data[SearchResults::KEY_ITEMS] as $itemArray) { - $items[] = $this->itemObjectBuilder->populateWithArray($itemArray)->create(); - } - $data[SearchResults::KEY_ITEMS] = $items; - } - return parent::_setDataValues($data); - } -} diff --git a/lib/internal/Magento/Framework/Api/AbstractSimpleObjectBuilder.php b/lib/internal/Magento/Framework/Api/AbstractSimpleObjectBuilder.php index d59c4461b3e3c8f263069802d3e6333e137babc3..3c511a75937082524aaf74544b3ba88dd4c436d8 100644 --- a/lib/internal/Magento/Framework/Api/AbstractSimpleObjectBuilder.php +++ b/lib/internal/Magento/Framework/Api/AbstractSimpleObjectBuilder.php @@ -30,28 +30,6 @@ abstract class AbstractSimpleObjectBuilder implements SimpleBuilderInterface $this->objectFactory = $objectFactory; } - /** - * Initializes Data Object with the data from array - * - * @param array $data - * @return $this - */ - protected function _setDataValues(array $data) - { - $dataObjectMethods = get_class_methods($this->_getDataObjectType()); - foreach ($data as $key => $value) { - /* First, verify is there any getter for the key on the Service Data Object */ - $possibleMethods = [ - 'get' . \Magento\Framework\Api\SimpleDataObjectConverter::snakeCaseToUpperCamelCase($key), - 'is' . \Magento\Framework\Api\SimpleDataObjectConverter::snakeCaseToUpperCamelCase($key), - ]; - if (array_intersect($possibleMethods, $dataObjectMethods)) { - $this->data[$key] = $value; - } - } - return $this; - } - /** * Builds the Data Object * @@ -85,13 +63,8 @@ abstract class AbstractSimpleObjectBuilder implements SimpleBuilderInterface protected function _getDataObjectType() { $currentClass = get_class($this); - $dataBuilderSuffix = 'DataBuilder'; - if (substr($currentClass, -strlen($dataBuilderSuffix)) === $dataBuilderSuffix) { - $dataObjectType = substr($currentClass, 0, -strlen($dataBuilderSuffix)) . 'Interface'; - } else { - $builderSuffix = 'Builder'; - $dataObjectType = substr($currentClass, 0, -strlen($builderSuffix)); - } + $builderSuffix = 'Builder'; + $dataObjectType = substr($currentClass, 0, -strlen($builderSuffix)); return $dataObjectType; } diff --git a/lib/internal/Magento/Framework/Api/AttributeDataBuilder.php b/lib/internal/Magento/Framework/Api/AttributeDataBuilder.php deleted file mode 100644 index b45520fbc8c70f7069627528bfaeb6f4ed37d7a1..0000000000000000000000000000000000000000 --- a/lib/internal/Magento/Framework/Api/AttributeDataBuilder.php +++ /dev/null @@ -1,44 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Framework\Api; - -/** - * Custom Attribute Data object builder - */ -class AttributeDataBuilder extends AbstractSimpleObjectBuilder -{ - /** - * Set attribute code - * - * @param string $attributeCode - * @return $this - */ - public function setAttributeCode($attributeCode) - { - return $this->_set(AttributeValue::ATTRIBUTE_CODE, $attributeCode); - } - - /** - * Set attribute value - * - * @param string $value - * @return $this - */ - public function setValue($value) - { - return $this->_set(AttributeValue::VALUE, $value); - } - - /** - * Return the Data type class name - * - * @return string - */ - protected function _getDataObjectType() - { - return '\Magento\Framework\Api\AttributeValue'; - } -} diff --git a/lib/internal/Magento/Framework/Api/AttributeMetadata.php b/lib/internal/Magento/Framework/Api/AttributeMetadata.php index 8420b663b255b8770b93fda560abd9cabee3a9a4..ba8723230de9e423a04b7702b5f9b108518ed8b8 100644 --- a/lib/internal/Magento/Framework/Api/AttributeMetadata.php +++ b/lib/internal/Magento/Framework/Api/AttributeMetadata.php @@ -22,4 +22,15 @@ class AttributeMetadata extends AbstractSimpleObject implements MetadataObjectIn { 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/lib/internal/Magento/Framework/Api/AttributeMetadataBuilder.php b/lib/internal/Magento/Framework/Api/AttributeMetadataBuilder.php deleted file mode 100644 index dd765d1f1adc58f2cce43d6f4a69f4f79e0092ea..0000000000000000000000000000000000000000 --- a/lib/internal/Magento/Framework/Api/AttributeMetadataBuilder.php +++ /dev/null @@ -1,26 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -namespace Magento\Framework\Api; - -/** - * Default implementation of the AttributeMetadataBuilderInterface - */ -class AttributeMetadataBuilder extends AbstractSimpleObjectBuilder implements AttributeMetadataBuilderInterface -{ - const ATTRIBUTE_CODE = 'attribute_code'; - - /** - * Set attribute code - * - * @param string $attributeCode - * @return $this - */ - public function setAttributeCode($attributeCode) - { - return $this->_set(self::ATTRIBUTE_CODE, $attributeCode); - } -} diff --git a/lib/internal/Magento/Framework/Api/AttributeMetadataBuilderInterface.php b/lib/internal/Magento/Framework/Api/AttributeMetadataBuilderInterface.php deleted file mode 100644 index fef5d8e1e7d32b43b71c418c5cd82fdb522e434e..0000000000000000000000000000000000000000 --- a/lib/internal/Magento/Framework/Api/AttributeMetadataBuilderInterface.php +++ /dev/null @@ -1,28 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -namespace Magento\Framework\Api; - -/** - * Attribute metadata object builder interface. - */ -interface AttributeMetadataBuilderInterface -{ - /** - * Set code of the attribute. - * - * @param string $attributeCode - * @return $this - */ - public function setAttributeCode($attributeCode); - - /** - * Build the attribute data object. - * - * @return AbstractSimpleObject - */ - public function create(); -} diff --git a/lib/internal/Magento/Framework/Api/Builder.php b/lib/internal/Magento/Framework/Api/Builder.php deleted file mode 100644 index 9b7338a54e2788624477f5131966860e36b4b845..0000000000000000000000000000000000000000 --- a/lib/internal/Magento/Framework/Api/Builder.php +++ /dev/null @@ -1,406 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -namespace Magento\Framework\Api; - -/** - * @SuppressWarnings(PHPMD.CouplingBetweenObjects) - */ -class Builder implements BuilderInterface -{ - /**#@+ - * Constant which defines if builder is created for building data objects or data models. - */ - const TYPE_DATA_OBJECT = 'data_object'; - const TYPE_EXTENSIBLE_DATA_OBJECT = 'extensible_data_object'; - const TYPE_DATA_MODEL = 'data_model'; - /**#@-*/ - - /** - * @var string - */ - protected $modelClassInterface; - - /** - * @var array - */ - protected $data; - - /** - * @var ObjectFactory - */ - protected $objectFactory; - - /** - * @var MetadataServiceInterface - */ - protected $metadataService; - - /** - * @var string[] - */ - protected $customAttributesCodes = null; - - /** - * @var \Magento\Framework\Api\AttributeValueFactory - */ - protected $attributeValueFactory; - - /** - * @var \Magento\Framework\Reflection\DataObjectProcessor - */ - protected $objectProcessor; - - /** - * @var array - */ - protected $interfaceMethodsDescription; - - /** - * @var \Magento\Framework\Reflection\TypeProcessor - */ - protected $typeProcessor; - - /** - * @var \Magento\Framework\Serialization\DataBuilderFactory - */ - protected $dataBuilderFactory; - - /** - * @var \Magento\Framework\ObjectManager\ConfigInterface - */ - protected $objectManagerConfig; - - /** - * @param ObjectFactory $objectFactory - * @param MetadataServiceInterface $metadataService - * @param AttributeValueFactory $attributeValueFactory - * @param \Magento\Framework\Reflection\DataObjectProcessor $objectProcessor - * @param \Magento\Framework\Reflection\TypeProcessor $typeProcessor - * @param \Magento\Framework\Serialization\DataBuilderFactory $dataBuilderFactory - * @param \Magento\Framework\ObjectManager\ConfigInterface $objectManagerConfig - * @param string $modelClassInterface - */ - public function __construct( - ObjectFactory $objectFactory, - MetadataServiceInterface $metadataService, - \Magento\Framework\Api\AttributeValueFactory $attributeValueFactory, - \Magento\Framework\Reflection\DataObjectProcessor $objectProcessor, - \Magento\Framework\Reflection\TypeProcessor $typeProcessor, - \Magento\Framework\Serialization\DataBuilderFactory $dataBuilderFactory, - \Magento\Framework\ObjectManager\ConfigInterface $objectManagerConfig, - $modelClassInterface = null - ) { - $this->objectFactory = $objectFactory; - $this->metadataService = $metadataService; - $this->modelClassInterface = $modelClassInterface; - $this->objectProcessor = $objectProcessor; - $this->attributeValueFactory = $attributeValueFactory; - $this->typeProcessor = $typeProcessor; - $this->dataBuilderFactory = $dataBuilderFactory; - $this->objectManagerConfig = $objectManagerConfig; - $this->data = []; - } - - /** - * {@inheritdoc} - */ - public function setCustomAttribute($attributeCode, $attributeValue) - { - $customAttributesCodes = $this->getCustomAttributesCodes(); - if (in_array($attributeCode, $customAttributesCodes)) { - $attribute = $this->attributeValueFactory->create() - ->setAttributeCode($attributeCode) - ->setValue($attributeValue); - //Stores as an associative array for easier lookup and processing - $this->data[ExtensibleDataInterface::CUSTOM_ATTRIBUTES][$attributeCode] = $attribute; - } - return $this; - } - - /** - * {@inheritdoc} - */ - public function setCustomAttributes(array $attributes) - { - $customAttributesCodes = $this->getCustomAttributesCodes(); - /** @var \Magento\Framework\Api\AttributeInterface $attribute */ - foreach ($attributes as $attribute) { - if (!$attribute instanceof AttributeValue) { - throw new \LogicException('Custom Attribute array elements can only be type of AttributeValue'); - } - $attributeCode = $attribute->getAttributeCode(); - if (in_array($attributeCode, $customAttributesCodes)) { - $this->data[AbstractExtensibleObject::CUSTOM_ATTRIBUTES_KEY][$attributeCode] = $attribute; - } - } - return $this; - } - - /** - * {@inheritdoc} - */ - public function create() - { - $dataType = $this->getDataType(); - if ($dataType == self::TYPE_DATA_MODEL) { - /** @var \Magento\Framework\Model\AbstractExtensibleModel $dataObject */ - $dataObject = $this->objectFactory->create( - $this->_getDataObjectType(), - ['data' => $this->data] - ); - $dataObject->setDataChanges(true); - } elseif ($dataType == self::TYPE_EXTENSIBLE_DATA_OBJECT) { - $dataObjectType = $this->_getDataObjectType(); - $dataObject = $this->objectFactory->create( - $dataObjectType, - ['attributeValueFactory' => $this->attributeValueFactory, 'data' => $this->data] - ); - } else { - $dataObjectType = $this->_getDataObjectType(); - $dataObject = $this->objectFactory->create( - $dataObjectType, - ['data' => $this->data] - ); - } - if ($dataObject instanceof \Magento\Framework\Object) { - $dataObject->setDataChanges(true); - } - $this->data = []; - return $dataObject; - } - - /** - * {@inheritdoc} - */ - public function populateWithArray(array $data) - { - $this->data = []; - $this->_setDataValues($data); - return $this; - } - - /** - * {@inheritdoc} - */ - public function populate(ExtensibleDataInterface $prototype) - { - $objectType = $this->_getDataObjectType(); - if (!($prototype instanceof $objectType)) { - throw new \LogicException('Wrong prototype object given. It can only be of "' . $objectType . '" type.'); - } - $prototypeArray = $this->objectProcessor->buildOutputDataArray($prototype, $objectType); - return $this->populateWithArray($prototypeArray); - } - - /** - * {@inheritdoc} - */ - public function mergeDataObjects( - ExtensibleDataInterface $firstDataObject, - ExtensibleDataInterface $secondDataObject - ) { - $objectType = $this->_getDataObjectType(); - if (!$firstDataObject instanceof $objectType || !$secondDataObject instanceof $objectType) { - throw new \LogicException('Wrong prototype object given. It can only be of "' . $objectType . '" type.'); - } - $firstObjectArray = $this->objectProcessor->buildOutputDataArray($firstDataObject, $objectType); - $secondObjectArray = $this->objectProcessor->buildOutputDataArray($secondDataObject, $objectType); - $this->_setDataValues($firstObjectArray); - $this->_setDataValues($secondObjectArray); - return $this; - } - - /** - * {@inheritdoc} - */ - public function mergeDataObjectWithArray(ExtensibleDataInterface $dataObject, array $data) - { - $objectType = $this->_getDataObjectType(); - if (!($dataObject instanceof $objectType)) { - throw new \LogicException('Wrong prototype object given. It can only be of "' . $objectType . '" type.'); - } - $dataArray = $this->objectProcessor->buildOutputDataArray($dataObject, $objectType); - $this->_setDataValues($dataArray); - $this->_setDataValues($data); - return $this; - } - - /** - * {@inheritdoc} - */ - public function getData() - { - return $this->data; - } - - /** - * @param string $key - * @param mixed $value - * - * @return $this - */ - protected function _set($key, $value) - { - $this->data[$key] = $value; - return $this; - } - - /** - * Identify type of objects which should be built with generated builder. Value can be one of self::TYPE_DATA_*. - * - * @return string - * @throws \LogicException - */ - protected function getDataType() - { - $dataType = $this->_getDataObjectType(); - if (is_subclass_of($dataType, '\Magento\Framework\Api\AbstractExtensibleObject')) { - return self::TYPE_EXTENSIBLE_DATA_OBJECT; - } elseif (is_subclass_of($dataType, '\Magento\Framework\Api\AbstractSimpleObject')) { - return self::TYPE_DATA_OBJECT; - } elseif (is_subclass_of($dataType, '\Magento\Framework\Model\AbstractExtensibleModel')) { - return self::TYPE_DATA_MODEL; - } - $dataType = ltrim($dataType, '\\'); - $sourceClassPreference = $this->objectManagerConfig->getPreference($dataType); - if (empty($sourceClassPreference)) { - throw new \LogicException( - "Preference for {$this->_getDataObjectType()} is not defined." - ); - } - - if (is_subclass_of($dataType, '\Magento\Framework\Api\AbstractExtensibleObject')) { - return self::TYPE_EXTENSIBLE_DATA_OBJECT; - } elseif (is_subclass_of($sourceClassPreference, '\Magento\Framework\Api\AbstractSimpleObject')) { - return self::TYPE_DATA_OBJECT; - } elseif (is_subclass_of($sourceClassPreference, '\Magento\Framework\Model\AbstractExtensibleModel')) { - return self::TYPE_DATA_MODEL; - } else { - throw new \LogicException( - 'Preference of ' . $this->_getDataObjectType() - . ' must extend from AbstractSimpleObject or AbstractExtensibleModel' - ); - } - } - - /** - * Template method used to configure the attribute codes for the custom attributes - * - * @return string[] - */ - protected function getCustomAttributesCodes() - { - if (!is_null($this->customAttributesCodes)) { - return $this->customAttributesCodes; - } - $attributeCodes = []; - /** @var \Magento\Framework\Api\MetadataObjectInterface[] $customAttributesMetadata */ - $customAttributesMetadata = $this->metadataService - ->getCustomAttributesMetadata($this->_getDataObjectType()); - if (is_array($customAttributesMetadata)) { - foreach ($customAttributesMetadata as $attribute) { - $attributeCodes[] = $attribute->getAttributeCode(); - } - } - $this->customAttributesCodes = $attributeCodes; - return $attributeCodes; - } - - /** - * Initializes Data Object with the data from array - * - * @param array $data - * @return $this - */ - protected function _setDataValues(array $data) - { - $dataObjectMethods = get_class_methods($this->_getDataObjectType()); - foreach ($data as $key => $value) { - /* First, verify is there any getter for the key on the Service Data Object */ - $camelCaseKey = \Magento\Framework\Api\SimpleDataObjectConverter::snakeCaseToUpperCamelCase($key); - $possibleMethods = [ - 'get' . $camelCaseKey, - 'is' . $camelCaseKey, - ]; - if ($key === ExtensibleDataInterface::CUSTOM_ATTRIBUTES - && is_array($data[$key]) - && !empty($data[$key]) - ) { - foreach ($data[$key] as $customAttribute) { - $this->setCustomAttribute( - $customAttribute[AttributeInterface::ATTRIBUTE_CODE], - $customAttribute[AttributeInterface::VALUE] - ); - } - } elseif ($methodName = array_intersect($possibleMethods, $dataObjectMethods)) { - if (!is_array($value)) { - $this->data[$key] = $value; - } else { - $this->setComplexValue($methodName[0], $key, $value); - } - } elseif (in_array($key, $this->getCustomAttributesCodes())) { - $this->setCustomAttribute($key, $value); - } - } - - return $this; - } - - /** - * @param string $methodName - * @param string $key - * @param array $value - * @return $this - */ - protected function setComplexValue($methodName, $key, array $value) - { - $returnType = $this->objectProcessor->getMethodReturnType($this->_getDataObjectType(), $methodName); - if ($this->typeProcessor->isTypeSimple($returnType)) { - $this->data[$key] = $value; - return $this; - } - - if ($this->typeProcessor->isArrayType($returnType)) { - $type = $this->typeProcessor->getArrayItemType($returnType); - $dataBuilder = $this->dataBuilderFactory->getDataBuilder($type); - $objects = []; - foreach ($value as $arrayElementData) { - $objects[] = $dataBuilder->populateWithArray($arrayElementData) - ->create(); - } - $this->data[$key] = $objects; - return $this; - } - - $dataBuilder = $this->dataBuilderFactory->getDataBuilder($returnType); - $object = $dataBuilder->populateWithArray($value) - ->create(); - $this->data[$key] = $object; - return $this; - } - - /** - * Get data object type based on suffix - * - * @return string - */ - protected function _getDataObjectType() - { - if ($this->modelClassInterface) { - return $this->modelClassInterface; - } - $currentClass = get_class($this); - $dataBuilderSuffix = 'DataBuilder'; - if (substr($currentClass, -strlen($dataBuilderSuffix)) === $dataBuilderSuffix) { - $dataObjectType = substr($currentClass, 0, -strlen($dataBuilderSuffix)) . 'Interface'; - } else { - $builderSuffix = 'Builder'; - $dataObjectType = substr($currentClass, 0, -strlen($builderSuffix)); - } - return $dataObjectType; - } -} diff --git a/lib/internal/Magento/Framework/Api/BuilderInterface.php b/lib/internal/Magento/Framework/Api/BuilderInterface.php deleted file mode 100644 index 1b89995f51af90a3a4154b1e75b9e3b8f510d807..0000000000000000000000000000000000000000 --- a/lib/internal/Magento/Framework/Api/BuilderInterface.php +++ /dev/null @@ -1,77 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -namespace Magento\Framework\Api; - -interface BuilderInterface extends SimpleBuilderInterface -{ - /** - * Set custom attribute value. - * - * @param string $attributeCode - * @param mixed $attributeValue - * @return $this - */ - public function setCustomAttribute($attributeCode, $attributeValue); - - /** - * Set array of custom attributes - * - * @param \Magento\Framework\Api\AttributeInterface[] $attributes - * @return $this - * @throws \LogicException If array elements are not of AttributeValue type - */ - public function setCustomAttributes(array $attributes); - - /** - * Return created ExtensibleDataInterface object - * - * @return \Magento\Framework\Api\ExtensibleDataInterface - */ - public function create(); - - /** - * Populates the fields with data from the array. - * - * Keys for the map are snake_case attribute/field names. - * - * @param array $data - * @return $this - */ - public function populateWithArray(array $data); - - /** - * Populates the fields with an existing entity. - * - * @param ExtensibleDataInterface $prototype the prototype to base on - * @return $this - * @throws \LogicException If $prototype object class is not the same type as object that is constructed - */ - public function populate(ExtensibleDataInterface $prototype); - - /** - * Populate builder with the two data interfaces, merging them - * - * @param ExtensibleDataInterface $firstDataObject - * @param ExtensibleDataInterface $secondDataObject - * @return $this - * @throws \LogicException - */ - public function mergeDataObjects( - ExtensibleDataInterface $firstDataObject, - ExtensibleDataInterface $secondDataObject - ); - - /** - * Populate builder with the data interface and array, merging them - * - * @param ExtensibleDataInterface $dataObject - * @param array $data - * @return $this - * @throws \LogicException - */ - public function mergeDataObjectWithArray(ExtensibleDataInterface $dataObject, array $data); -} diff --git a/lib/internal/Magento/Framework/Api/Code/Generator/DataBuilder.php b/lib/internal/Magento/Framework/Api/Code/Generator/DataBuilder.php deleted file mode 100644 index 4dbbd72d071c8b061b53aae9c14af62e49c4165c..0000000000000000000000000000000000000000 --- a/lib/internal/Magento/Framework/Api/Code/Generator/DataBuilder.php +++ /dev/null @@ -1,287 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -namespace Magento\Framework\Api\Code\Generator; - -use Magento\Framework\Code\Generator\EntityAbstract; -use Magento\Framework\Code\Generator\Io; -use Zend\Code\Reflection\ClassReflection; - -/** - * Class Builder - */ -class DataBuilder extends EntityAbstract -{ - /** - * Builder Entity, used for a builders built based on Data Objects - */ - const ENTITY_TYPE = 'dataBuilder'; - - /** - * Builder Entity, used for a builders built based on API interfaces - */ - const ENTITY_TYPE_BUILDER = 'builder'; - - /** - * Data Model property name - */ - const DATA_PROPERTY_NAME = 'data'; - - /**#@+ - * Constant which defines if builder is created for building data objects or data models. - */ - const TYPE_DATA_OBJECT = 'data_object'; - const TYPE_DATA_MODEL = 'data_model'; - /**#@-*/ - - /** @var string */ - protected $currentDataType; - - /** @var string[] */ - protected $extensibleInterfaceMethods; - - /** - * @var \Magento\Framework\Reflection\TypeProcessor - */ - protected $typeProcessor = null; - - /** - * Initialize dependencies. - * - * @param string|null $sourceClassName - * @param string|null $resultClassName - * @param Io|null $ioObject - * @param \Magento\Framework\Code\Generator\CodeGeneratorInterface|null $classGenerator - * @param \Magento\Framework\Code\Generator\DefinedClasses|null $definedClasses - */ - public function __construct( - $sourceClassName = null, - $resultClassName = null, - Io $ioObject = null, - \Magento\Framework\Code\Generator\CodeGeneratorInterface $classGenerator = null, - \Magento\Framework\Code\Generator\DefinedClasses $definedClasses = null - ) { - $this->typeProcessor = new \Magento\Framework\Reflection\TypeProcessor(); - parent::__construct( - $sourceClassName, - $resultClassName, - $ioObject, - $classGenerator, - $definedClasses - ); - } - - /** - * Retrieve class properties - * - * @return array - */ - protected function _getClassProperties() - { - return []; - } - - /** - * Get default constructor definition for generated class - * - * @return array - */ - protected function _getDefaultConstructorDefinition() - { - $constructorDefinition = [ - 'name' => '__construct', - 'parameters' => [ - ['name' => 'objectFactory', 'type' => '\Magento\Framework\Api\ObjectFactory'], - ['name' => 'metadataService', 'type' => '\Magento\Framework\Api\MetadataServiceInterface'], - ['name' => 'attributeValueFactory', 'type' => '\Magento\Framework\Api\AttributeValueFactory'], - ['name' => 'objectProcessor', 'type' => '\Magento\Framework\Reflection\DataObjectProcessor'], - ['name' => 'typeProcessor', 'type' => '\Magento\Framework\Reflection\TypeProcessor'], - ['name' => 'dataBuilderFactory', 'type' => '\Magento\Framework\Serialization\DataBuilderFactory'], - ['name' => 'objectManagerConfig', 'type' => '\Magento\Framework\ObjectManager\ConfigInterface'], - [ - 'name' => 'modelClassInterface', - 'type' => 'string', - 'defaultValue' => $this->_getNullDefaultValue() - ], - ], - 'docblock' => [ - 'shortDescription' => 'Initialize the builder', - 'tags' => [ - [ - 'name' => 'param', - 'description' => '\Magento\Framework\Api\ObjectFactory $objectFactory', - ], - [ - 'name' => 'param', - 'description' => '\Magento\Framework\Api\MetadataServiceInterface $metadataService' - ], - [ - 'name' => 'param', - 'description' => '\Magento\Framework\Api\AttributeValueFactory $attributeValueFactory' - ], - [ - 'name' => 'param', - 'description' => '\Magento\Framework\Reflection\DataObjectProcessor $objectProcessor' - ], - [ - 'name' => 'param', - 'description' => '\Magento\Framework\Reflection\TypeProcessor $typeProcessor' - ], - [ - 'name' => 'param', - 'description' => '\Magento\Framework\Serialization\DataBuilderFactory $dataBuilderFactory' - ], - [ - 'name' => 'param', - 'description' => '\Magento\Framework\ObjectManager\ConfigInterface $objectManagerConfig' - ], - [ - 'name' => 'param', - 'description' => 'string|null $modelClassInterface' - ], - ], - ], - 'body' => "parent::__construct(\$objectFactory, \$metadataService, \$attributeValueFactory, " - . "\$objectProcessor, \$typeProcessor, \$dataBuilderFactory, \$objectManagerConfig, " - . "'{$this->_getSourceClassName()}');", - ]; - return $constructorDefinition; - } - - /** - * Return a list of methods for class generator - * - * @return array - */ - protected function _getClassMethods() - { - $methods = []; - $className = $this->_getSourceClassName(); - $reflectionClass = new \ReflectionClass($className); - $publicMethods = $reflectionClass->getMethods(\ReflectionMethod::IS_PUBLIC); - foreach ($publicMethods as $method) { - if ($this->canUseMethodForGeneration($method)) { - $methods[] = $this->_getMethodInfo($method); - } - } - $defaultConstructorDefinition = $this->_getDefaultConstructorDefinition(); - if (!empty($defaultConstructorDefinition)) { - $methods[] = $defaultConstructorDefinition; - } - return $methods; - } - - /** - * Check if the specified method should be used during generation builder generation. - * - * @param \ReflectionMethod $method - * @return bool - */ - protected function canUseMethodForGeneration($method) - { - $isGetter = substr($method->getName(), 0, 3) == 'get' || substr($method->getName(), 0, 2) == 'is'; - $isSuitableMethodType = !($method->isConstructor() || $method->isFinal() - || $method->isStatic() || $method->isDestructor()); - $isMagicMethod = in_array($method->getName(), ['__sleep', '__wakeup', '__clone']); - $isPartOfExtensibleInterface = in_array($method->getName(), $this->getExtensibleInterfaceMethods()); - return $isGetter && $isSuitableMethodType && !$isMagicMethod && !$isPartOfExtensibleInterface; - } - - /** - * Retrieve method info - * - * @param \ReflectionMethod $method - * @return array - */ - protected function _getMethodInfo(\ReflectionMethod $method) - { - if (substr($method->getName(), 0, 2) == 'is') { - $propertyName = substr($method->getName(), 2); - } else { - $propertyName = substr($method->getName(), 3); - } - $returnType = $this->typeProcessor->getGetterReturnType( - (new ClassReflection($this->_getSourceClassName())) - ->getMethod($method->getName()) - ); - $fieldName = strtolower(preg_replace('/(.)([A-Z])/', "$1_$2", $propertyName)); - $methodInfo = [ - 'name' => 'set' . $propertyName, - 'parameters' => [ - ['name' => lcfirst($propertyName)], - ], - 'body' => "\$this->_set('{$fieldName}', \$" . lcfirst($propertyName) . ");" - . PHP_EOL . "return \$this;", - 'docblock' => [ - 'tags' => [ - ['name' => 'param', 'description' => $returnType['type'] . " \$" . lcfirst($propertyName)], - ['name' => 'return', 'description' => '$this'], - ], - ], - ]; - return $methodInfo; - } - - /** - * Generate code - * - * @return string - */ - protected function _generateCode() - { - $this->_classGenerator - ->setName($this->_getResultClassName()) - ->addProperties($this->_getClassProperties()) - ->addMethods($this->_getClassMethods()) - ->setClassDocBlock($this->_getClassDocBlock()) - ->setExtendedClass('\Magento\Framework\Api\Builder'); - return $this->_getGeneratedCode(); - } - - /** - * {@inheritdoc} - */ - protected function _getSourceClassName() - { - return $this->_getDataObjectType(); - } - - /** - * Get data object type based on suffix - * - * @return string - */ - protected function _getDataObjectType() - { - $currentBuilderClass = $this->_getResultClassName(); - $dataBuilderSuffix = 'DataBuilder'; - if (substr($currentBuilderClass, -strlen($dataBuilderSuffix)) === $dataBuilderSuffix) { - $dataObjectType = substr($currentBuilderClass, 0, -strlen($dataBuilderSuffix)) . 'Interface'; - } else { - $builderSuffix = 'Builder'; - $dataObjectType = substr($currentBuilderClass, 0, -strlen($builderSuffix)); - } - return $dataObjectType; - } - - /** - * Get a list of methods declared on extensible data interface. - * - * @return string[] - */ - protected function getExtensibleInterfaceMethods() - { - if ($this->extensibleInterfaceMethods === null) { - $interfaceReflection = new ClassReflection('Magento\Framework\Api\ExtensibleDataInterface'); - $methodsReflection = $interfaceReflection->getMethods(); - $this->extensibleInterfaceMethods = []; - foreach ($methodsReflection as $methodReflection) { - $this->extensibleInterfaceMethods[] = $methodReflection->getName(); - } - } - return $this->extensibleInterfaceMethods; - } -} diff --git a/lib/internal/Magento/Framework/Api/Code/Generator/SearchResultsBuilder.php b/lib/internal/Magento/Framework/Api/Code/Generator/SearchResultsBuilder.php deleted file mode 100644 index 0e7d054a9840339ce017a772c95c63cb171e4ef8..0000000000000000000000000000000000000000 --- a/lib/internal/Magento/Framework/Api/Code/Generator/SearchResultsBuilder.php +++ /dev/null @@ -1,130 +0,0 @@ -<?php -/** - * @category Magento - * @package Magento_Code - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Framework\Api\Code\Generator; - -use Magento\Framework\Code\Generator\EntityAbstract; - -/** - * Class Builder - */ -class SearchResultsBuilder extends EntityAbstract -{ - /** - * Entity type - */ - const ENTITY_TYPE = 'searchResultsBuilder'; - - /** - * Search result builder abstract class - */ - const SEARCH_RESULT_BUILDER = '\\Magento\Framework\Api\AbstractSearchResultsBuilder'; - - /** - * Retrieve class properties - * - * @return array - */ - protected function _getClassProperties() - { - return []; - } - - /** - * Get default constructor definition for generated class - * - * @return array - */ - protected function _getDefaultConstructorDefinition() - { - return [ - 'name' => '__construct', - 'parameters' => [ - [ - 'name' => 'objectFactory', - 'type' => '\\Magento\Framework\Api\ObjectFactory', - ], - [ - 'name' => 'valueFactory', - 'type' => '\\Magento\Framework\Api\AttributeValueFactory' - ], - [ - 'name' => 'metadataService', - 'type' => '\\Magento\Framework\Api\Config\MetadataConfig' - ], - [ - 'name' => 'searchCriteriaBuilder', - 'type' => '\\Magento\Framework\Api\SearchCriteriaBuilder' - ], - [ - 'name' => 'itemObjectBuilder', - 'type' => $this->_getSourceClassName() . 'Builder' - ], - ], - 'body' => "parent::__construct(\$objectFactory, \$valueFactory, \$metadataService, " . - "\$searchCriteriaBuilder, \$itemObjectBuilder);", - 'docblock' => [ - 'shortDescription' => ucfirst(static::ENTITY_TYPE) . ' constructor', - 'tags' => [ - [ - 'name' => 'param', - 'description' => '', - ], - ], - ] - ]; - } - - /** - * Returns list of methods for class generator - * - * @return array - */ - protected function _getClassMethods() - { - return [$this->_getDefaultConstructorDefinition()]; - } - - /** - * {@inheritdoc} - */ - protected function _validateData() - { - $result = parent::_validateData(); - - if ($result) { - $sourceClassName = $this->_getSourceClassName(); - $resultClassName = $this->_getResultClassName(); - - if ($resultClassName !== $sourceClassName . 'SearchResultsBuilder') { - $this->_addError( - 'Invalid Result class name [' . $resultClassName . ']. Use ' - . $sourceClassName . 'SearchResultsBuilder' - ); - $result = false; - } - } - return $result; - } - - /** - * Generate code - * - * @return string - */ - protected function _generateCode() - { - $this->_classGenerator->setName( - $this->_getResultClassName() - )->addMethods( - $this->_getClassMethods() - )->setClassDocBlock( - $this->_getClassDocBlock() - )->setExtendedClass(self::SEARCH_RESULT_BUILDER); - return $this->_getGeneratedCode(); - } -} diff --git a/lib/internal/Magento/Framework/Api/Config/MetadataConfig.php b/lib/internal/Magento/Framework/Api/Config/MetadataConfig.php index 59f39f342cae672126b81a222788d4ea309b1092..9bfb2eb651cdd0a0ec8c4ed6b806c9a1c7a1940e 100644 --- a/lib/internal/Magento/Framework/Api/Config/MetadataConfig.php +++ b/lib/internal/Magento/Framework/Api/Config/MetadataConfig.php @@ -6,7 +6,7 @@ namespace Magento\Framework\Api\Config; -use Magento\Framework\Api\AttributeMetadataBuilderInterface; +use Magento\Framework\Api\ObjectFactory; use Magento\Framework\Api\Config\Reader as ServiceConfigReader; use Magento\Framework\Api\MetadataServiceInterface; @@ -21,9 +21,9 @@ class MetadataConfig implements MetadataServiceInterface private $serviceConfigReader; /** - * @var AttributeMetadataBuilderInterface + * @var ObjectFactory */ - private $attributeMetadataBuilder; + private $objectFactory; /** * @var array @@ -34,14 +34,14 @@ class MetadataConfig implements MetadataServiceInterface * Initialize dependencies. * * @param ServiceConfigReader $serviceConfigReader - * @param AttributeMetadataBuilderInterface $attributeMetadataBuilder + * @param ObjectFactory $objectFactory */ public function __construct( ServiceConfigReader $serviceConfigReader, - AttributeMetadataBuilderInterface $attributeMetadataBuilder + ObjectFactory $objectFactory ) { $this->serviceConfigReader = $serviceConfigReader; - $this->attributeMetadataBuilder = $attributeMetadataBuilder; + $this->objectFactory = $objectFactory; } /** @@ -50,7 +50,7 @@ class MetadataConfig implements MetadataServiceInterface public function getCustomAttributesMetadata($dataObjectClassName = null) { $attributes = []; - if (!is_null($this->attributeMetadataBuilder) && !is_null($dataObjectClassName)) { + 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. @@ -82,8 +82,9 @@ class MetadataConfig implements MetadataServiceInterface ) { $attributeCodes = array_keys($this->allAttributes[$dataObjectClassName]); foreach ($attributeCodes as $attributeCode) { - $this->attributeMetadataBuilder->setAttributeCode($attributeCode); - $attributes[$attributeCode] = $this->attributeMetadataBuilder->create(); + $attributes[$attributeCode] = $this->objectFactory + ->create('\Magento\Framework\Api\MetadataObjectInterface', []) + ->setAttributeCode($attributeCode); } } return $attributes; diff --git a/lib/internal/Magento/Framework/Api/DataObjectHelper.php b/lib/internal/Magento/Framework/Api/DataObjectHelper.php index 371b610c59c23972694d5b96d711d51ac7aa8a68..61d813a261d55ed5ef9e15211fcceb6e8d17de93 100644 --- a/lib/internal/Magento/Framework/Api/DataObjectHelper.php +++ b/lib/internal/Magento/Framework/Api/DataObjectHelper.php @@ -44,7 +44,7 @@ class DataObjectHelper * @param string $interfaceName * @return $this */ - public function populateWithArray($dataObject, array $data, $interfaceName = null) + public function populateWithArray($dataObject, array $data, $interfaceName) { $this->_setDataValues($dataObject, $data, $interfaceName); return $this; diff --git a/lib/internal/Magento/Framework/Api/ExtensibleObjectBuilder.php b/lib/internal/Magento/Framework/Api/ExtensibleObjectBuilder.php deleted file mode 100644 index fcd13b96d9e437c35d465a35d49929a0e0fab604..0000000000000000000000000000000000000000 --- a/lib/internal/Magento/Framework/Api/ExtensibleObjectBuilder.php +++ /dev/null @@ -1,239 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -namespace Magento\Framework\Api; - -/** - * Base Builder Class for extensible data Objects - * @SuppressWarnings(PHPMD.NumberOfChildren) - */ -class ExtensibleObjectBuilder extends AbstractSimpleObjectBuilder implements BuilderInterface -{ - /** - * @var \Magento\Framework\Api\AttributeValueFactory - */ - protected $attributeValueFactory; - - /** - * @var MetadataServiceInterface - */ - protected $metadataService; - - /** - * @var string[] - */ - protected $customAttributesCodes = null; - - /** - * @var string - */ - protected $modelClassInterface; - - /** - * @param \Magento\Framework\Api\ObjectFactory $objectFactory - * @param \Magento\Framework\Api\AttributeValueFactory $valueFactory - * @param MetadataServiceInterface $metadataService - * @param string|null $modelClassInterface - */ - public function __construct( - \Magento\Framework\Api\ObjectFactory $objectFactory, - \Magento\Framework\Api\AttributeValueFactory $valueFactory, - MetadataServiceInterface $metadataService, - $modelClassInterface = null - ) { - $this->attributeValueFactory = $valueFactory; - $this->metadataService = $metadataService; - $this->modelClassInterface = $modelClassInterface; - parent::__construct($objectFactory); - } - - /** - * Builds the Data Object - * - * @return AbstractExtensibleObject - */ - public function create() - { - $dataObjectType = $this->_getDataObjectType(); - $dataObject = $this->objectFactory->create( - $dataObjectType, - ['attributeValueFactory' => $this->attributeValueFactory, 'data' => $this->getData()] - ); - $this->data = []; - return $dataObject; - } - - /** - * {@inheritdoc} - */ - public function setCustomAttributes(array $attributes) - { - $customAttributesCodes = $this->getCustomAttributesCodes(); - foreach ($attributes as $attribute) { - if (!$attribute instanceof AttributeValue) { - throw new \LogicException('Custom Attribute array elements can only be type of AttributeValue'); - } - $attributeCode = $attribute->getAttributeCode(); - if (in_array($attributeCode, $customAttributesCodes)) { - $this->data[AbstractExtensibleObject::CUSTOM_ATTRIBUTES_KEY][$attributeCode] = $attribute; - } - } - return $this; - } - - /** - * {@inheritdoc} - */ - public function setCustomAttribute($attributeCode, $attributeValue) - { - $customAttributesCodes = $this->getCustomAttributesCodes(); - /* If key corresponds to custom attribute code, populate custom attributes */ - if (in_array($attributeCode, $customAttributesCodes)) { - $attribute = $this->attributeValueFactory->create() - ->setAttributeCode($attributeCode) - ->setValue($attributeValue); - $this->data[AbstractExtensibleObject::CUSTOM_ATTRIBUTES_KEY][$attributeCode] = $attribute; - } - return $this; - } - - /** - * Populates the fields with an existing entity. - * - * @param ExtensibleDataInterface $prototype the prototype to base on - * @return $this - * @throws \LogicException If $prototype object class is not the same type as object that is constructed - */ - public function populate(ExtensibleDataInterface $prototype) - { - $objectType = $this->_getDataObjectType(); - if (!($prototype instanceof $objectType)) { - throw new \LogicException('Wrong prototype object given. It can only be of "' . $objectType . '" type.'); - } - return $this->populateWithArray($prototype->__toArray()); - } - - /** - * Populates the fields with data from the array. - * - * Keys for the map are snake_case attribute/field names. - * - * @param array $data - * @return $this - */ - public function populateWithArray(array $data) - { - $this->data = []; - $this->_setDataValues($data); - return $this; - } - - /** - * Merge second Data Object data with first Data Object data and create new Data Object object based on merge - * result. - * - * @param ExtensibleDataInterface $firstDataObject - * @param ExtensibleDataInterface $secondDataObject - * @return $this - * @throws \LogicException - */ - public function mergeDataObjects( - ExtensibleDataInterface $firstDataObject, - ExtensibleDataInterface $secondDataObject - ) { - $objectType = $this->_getDataObjectType(); - if (get_class($firstDataObject) != $objectType || get_class($secondDataObject) != $objectType) { - throw new \LogicException('Wrong prototype object given. It can only be of "' . $objectType . '" type.'); - } - $this->_setDataValues($firstDataObject->__toArray()); - $this->_setDataValues($secondDataObject->__toArray()); - return $this; - } - - /** - * Merged data provided in array format with Data Object data and create new Data Object object based on merge - * result. - * - * @param ExtensibleDataInterface $dataObject - * @param array $data - * @return $this - * @throws \LogicException - */ - public function mergeDataObjectWithArray(ExtensibleDataInterface $dataObject, array $data) - { - $objectType = $this->_getDataObjectType(); - if (!($dataObject instanceof $objectType)) { - throw new \LogicException('Wrong prototype object given. It can only be of "' . $objectType . '" type.'); - } - $this->_setDataValues($dataObject->__toArray()); - $this->_setDataValues($data); - return $this; - } - - /** - * Template method used to configure the attribute codes for the custom attributes - * - * @return string[] - */ - protected function getCustomAttributesCodes() - { - if (!is_null($this->customAttributesCodes)) { - return $this->customAttributesCodes; - } - $attributeCodes = []; - $customAttributesMetadata = $this->metadataService->getCustomAttributesMetadata($this->_getDataObjectType()); - if (is_array($customAttributesMetadata)) { - foreach ($customAttributesMetadata as $attribute) { - $attributeCodes[] = $attribute->getAttributeCode(); - } - } - $this->customAttributesCodes = $attributeCodes; - return $attributeCodes; - } - - /** - * Initializes Data Object with the data from array - * - * @param array $data - * @return $this - */ - protected function _setDataValues(array $data) - { - $dataObjectMethods = get_class_methods($this->_getDataObjectType()); - foreach ($data as $key => $value) { - /* First, verify is there any getter for the key on the Service Data Object */ - $camelCaseKey = \Magento\Framework\Api\SimpleDataObjectConverter::snakeCaseToUpperCamelCase($key); - $possibleMethods = [ - 'get' . $camelCaseKey, - 'is' . $camelCaseKey, - ]; - if ($key == AbstractExtensibleObject::CUSTOM_ATTRIBUTES_KEY - && is_array($data[$key]) - && !empty($data[$key]) - ) { - foreach ($data[$key] as $customAttribute) { - $this->setCustomAttribute( - $customAttribute[AttributeValue::ATTRIBUTE_CODE], - $customAttribute[AttributeValue::VALUE] - ); - } - } elseif (array_intersect($possibleMethods, $dataObjectMethods)) { - $this->data[$key] = $value; - } else { - $this->setCustomAttribute($key, $value); - } - } - return $this; - } - - /** - * {@inheritdoc} - */ - protected function _getDataObjectType() - { - return $this->modelClassInterface ?: parent::_getDataObjectType(); - } -} diff --git a/lib/internal/Magento/Framework/Api/Filter.php b/lib/internal/Magento/Framework/Api/Filter.php index df982867020c24d045d823b44184cacbb5d666c3..e86ea49047d0ea34e29903f125edc4cf2474e3ed 100644 --- a/lib/internal/Magento/Framework/Api/Filter.php +++ b/lib/internal/Magento/Framework/Api/Filter.php @@ -8,9 +8,17 @@ namespace Magento\Framework\Api; /** * Filter which can be used by any methods from service layer. + * @codeCoverageIgnore */ class Filter extends AbstractExtensibleObject { + /**#@+ + * Constants for Data Object keys + */ + const KEY_FIELD = 'field'; + const KEY_VALUE = 'value'; + const KEY_CONDITION_TYPE = 'condition_type'; + /** * Get field * @@ -18,7 +26,18 @@ class Filter extends AbstractExtensibleObject */ public function getField() { - return $this->_get('field'); + return $this->_get(self::KEY_FIELD); + } + + /** + * Set field + * + * @param string $field + * @return $this + */ + public function setField($field) + { + return $this->setData(self::KEY_FIELD, $field); } /** @@ -28,7 +47,18 @@ class Filter extends AbstractExtensibleObject */ public function getValue() { - return $this->_get('value'); + return $this->_get(self::KEY_VALUE); + } + + /** + * Set value + * + * @param string $value + * @return $this + */ + public function setValue($value) + { + return $this->setData(self::KEY_VALUE, $value); } /** @@ -38,6 +68,17 @@ class Filter extends AbstractExtensibleObject */ public function getConditionType() { - return $this->_get('condition_type'); + return $this->_get(self::KEY_CONDITION_TYPE); + } + + /** + * Set condition type + * + * @param string $conditionType + * @return $this + */ + public function setConditionType($conditionType) + { + return $this->setData(self::KEY_CONDITION_TYPE, $conditionType); } } diff --git a/lib/internal/Magento/Framework/Api/FilterBuilder.php b/lib/internal/Magento/Framework/Api/FilterBuilder.php index 598e9c48315fd479087639c93eda6d6e3f25bf3a..7bd8ceba85a89ae9119b508353b319f8437dfd5a 100644 --- a/lib/internal/Magento/Framework/Api/FilterBuilder.php +++ b/lib/internal/Magento/Framework/Api/FilterBuilder.php @@ -11,7 +11,7 @@ namespace Magento\Framework\Api; * * @method Filter create() */ -class FilterBuilder extends \Magento\Framework\Api\Builder +class FilterBuilder extends AbstractSimpleObjectBuilder { /** * Set field diff --git a/lib/internal/Magento/Framework/Api/MetadataObjectInterface.php b/lib/internal/Magento/Framework/Api/MetadataObjectInterface.php index 8a333df1e6729791118889225468f53f27c02728..3d752ed3e558ca03b3d80a2d52f2033cce358a68 100644 --- a/lib/internal/Magento/Framework/Api/MetadataObjectInterface.php +++ b/lib/internal/Magento/Framework/Api/MetadataObjectInterface.php @@ -14,4 +14,12 @@ interface MetadataObjectInterface * @return string */ public function getAttributeCode(); + + /** + * Set code of the attribute. + * + * @param string $attributeCode + * @return $this + */ + public function setAttributeCode($attributeCode); } diff --git a/lib/internal/Magento/Framework/Api/Search/FilterGroup.php b/lib/internal/Magento/Framework/Api/Search/FilterGroup.php index d48e11851fb5bab51b7d94daa50d6f1302acd34b..860c36710ad0d9051f9ea6b02244abcbce785663 100644 --- a/lib/internal/Magento/Framework/Api/Search/FilterGroup.php +++ b/lib/internal/Magento/Framework/Api/Search/FilterGroup.php @@ -25,4 +25,16 @@ class FilterGroup extends AbstractExtensibleObject $filters = $this->_get(self::FILTERS); return is_null($filters) ? [] : $filters; } + + /** + * Set filters + * + * @param \Magento\Framework\Api\Filter[] $filters + * @return $this + * @codeCoverageIgnore + */ + public function setFilters(array $filters = null) + { + return $this->setData(self::FILTERS, $filters); + } } diff --git a/lib/internal/Magento/Framework/Api/Search/FilterGroupBuilder.php b/lib/internal/Magento/Framework/Api/Search/FilterGroupBuilder.php index a9c68bf8dd2622c6b18895d00700c880c6ec9c34..afc1dca15ffbfb7b4451be38939aa6c6ea9326be 100644 --- a/lib/internal/Magento/Framework/Api/Search/FilterGroupBuilder.php +++ b/lib/internal/Magento/Framework/Api/Search/FilterGroupBuilder.php @@ -6,15 +6,14 @@ namespace Magento\Framework\Api\Search; -use Magento\Framework\Api\Builder; +use Magento\Framework\Api\AbstractSimpleObjectBuilder; use Magento\Framework\Api\FilterBuilder; -use Magento\Framework\Api\MetadataServiceInterface; use Magento\Framework\Api\ObjectFactory; /** * Builder for FilterGroup Data. */ -class FilterGroupBuilder extends Builder +class FilterGroupBuilder extends AbstractSimpleObjectBuilder { /** * @var FilterBuilder @@ -23,35 +22,14 @@ class FilterGroupBuilder extends Builder /** * @param ObjectFactory $objectFactory - * @param MetadataServiceInterface $metadataService - * @param \Magento\Framework\Api\AttributeValueFactory $attributeValueFactory - * @param \Magento\Framework\Reflection\DataObjectProcessor $objectProcessor - * @param \Magento\Framework\Reflection\TypeProcessor $typeProcessor - * @param \Magento\Framework\Serialization\DataBuilderFactory $dataBuilderFactory - * @param \Magento\Framework\ObjectManager\ConfigInterface $objectManagerConfig * @param FilterBuilder $filterBuilder - * @param string|null $modelClassInterface */ public function __construct( ObjectFactory $objectFactory, - MetadataServiceInterface $metadataService, - \Magento\Framework\Api\AttributeValueFactory $attributeValueFactory, - \Magento\Framework\Reflection\DataObjectProcessor $objectProcessor, - \Magento\Framework\Reflection\TypeProcessor $typeProcessor, - \Magento\Framework\Serialization\DataBuilderFactory $dataBuilderFactory, - \Magento\Framework\ObjectManager\ConfigInterface $objectManagerConfig, - FilterBuilder $filterBuilder, - $modelClassInterface = null + FilterBuilder $filterBuilder ) { parent::__construct( - $objectFactory, - $metadataService, - $attributeValueFactory, - $objectProcessor, - $typeProcessor, - $dataBuilderFactory, - $objectManagerConfig, - $modelClassInterface + $objectFactory ); $this->_filterBuilder = $filterBuilder; } @@ -78,19 +56,4 @@ class FilterGroupBuilder extends Builder { return $this->_set(FilterGroup::FILTERS, $filters); } - - /** - * {@inheritdoc} - */ - protected function _setDataValues(array $data) - { - if (isset($data[FilterGroup::FILTERS])) { - $filters = []; - foreach ($data[FilterGroup::FILTERS] as $filter) { - $filters[] = $this->_filterBuilder->populateWithArray($filter)->create(); - } - $data[FilterGroup::FILTERS] = $filters; - } - return parent::_setDataValues($data); - } } diff --git a/lib/internal/Magento/Framework/Api/SearchCriteria.php b/lib/internal/Magento/Framework/Api/SearchCriteria.php index 0a704699494bc84bb6df3ac15b8fd6d7142f5c36..a02d3e27dac79e7d75b9d3311cea7fe1f6b488f0 100644 --- a/lib/internal/Magento/Framework/Api/SearchCriteria.php +++ b/lib/internal/Magento/Framework/Api/SearchCriteria.php @@ -9,6 +9,7 @@ namespace Magento\Framework\Api; /** * Data Object for SearchCriteria + * @codeCoverageIgnore */ class SearchCriteria extends AbstractExtensibleObject implements SearchCriteriaInterface { @@ -59,4 +60,48 @@ class SearchCriteria extends AbstractExtensibleObject implements SearchCriteriaI { return $this->_get(self::CURRENT_PAGE); } + + /** + * Set a list of filter groups. + * + * @param \Magento\Framework\Api\Search\FilterGroup[] $filterGroups + * @return $this + */ + public function setFilterGroups(array $filterGroups = null) + { + return $this->setData(self::FILTER_GROUPS, $filterGroups); + } + + /** + * Set sort order. + * + * @param \Magento\Framework\Api\SortOrder[] $sortOrders + * @return $this + */ + public function setSortOrders(array $sortOrders = null) + { + return $this->setData(self::SORT_ORDERS, $sortOrders); + } + + /** + * Set page size. + * + * @param int $pageSize + * @return $this + */ + public function setPageSize($pageSize) + { + return $this->setData(self::PAGE_SIZE, $pageSize); + } + + /** + * Set current page. + * + * @param int $currentPage + * @return $this + */ + public function setCurrentPage($currentPage) + { + return $this->setData(self::CURRENT_PAGE, $currentPage); + } } diff --git a/lib/internal/Magento/Framework/Api/SearchCriteriaBuilder.php b/lib/internal/Magento/Framework/Api/SearchCriteriaBuilder.php index 84edfa1a2f3205fd3d71de20e4dd240e36489d20..faec4510efc5c8c0a0f77bef7929fe387b4ec60a 100644 --- a/lib/internal/Magento/Framework/Api/SearchCriteriaBuilder.php +++ b/lib/internal/Magento/Framework/Api/SearchCriteriaBuilder.php @@ -11,7 +11,7 @@ use Magento\Framework\Api\Search\FilterGroupBuilder; /** * Builder for SearchCriteria Service Data Object */ -class SearchCriteriaBuilder extends Builder +class SearchCriteriaBuilder extends AbstractSimpleObjectBuilder { /** * @var FilterGroupBuilder @@ -20,35 +20,14 @@ class SearchCriteriaBuilder extends Builder /** * @param ObjectFactory $objectFactory - * @param MetadataServiceInterface $metadataService - * @param AttributeValueFactory $attributeValueFactory - * @param \Magento\Framework\Reflection\DataObjectProcessor $objectProcessor - * @param \Magento\Framework\Reflection\TypeProcessor $typeProcessor - * @param \Magento\Framework\Serialization\DataBuilderFactory $dataBuilderFactory - * @param \Magento\Framework\ObjectManager\ConfigInterface $objectManagerConfig * @param FilterGroupBuilder $filterGroupBuilder - * @param string|null $modelClassInterface */ public function __construct( ObjectFactory $objectFactory, - MetadataServiceInterface $metadataService, - AttributeValueFactory $attributeValueFactory, - \Magento\Framework\Reflection\DataObjectProcessor $objectProcessor, - \Magento\Framework\Reflection\TypeProcessor $typeProcessor, - \Magento\Framework\Serialization\DataBuilderFactory $dataBuilderFactory, - \Magento\Framework\ObjectManager\ConfigInterface $objectManagerConfig, - FilterGroupBuilder $filterGroupBuilder, - $modelClassInterface = null + FilterGroupBuilder $filterGroupBuilder ) { parent::__construct( - $objectFactory, - $metadataService, - $attributeValueFactory, - $objectProcessor, - $typeProcessor, - $dataBuilderFactory, - $objectManagerConfig, - $modelClassInterface + $objectFactory ); $this->_filterGroupBuilder = $filterGroupBuilder; } diff --git a/lib/internal/Magento/Framework/Api/SearchCriteriaDataBuilder.php b/lib/internal/Magento/Framework/Api/SearchCriteriaDataBuilder.php deleted file mode 100644 index bbd5f434dc6d202330e806cd13ae3f4ea8b70e5c..0000000000000000000000000000000000000000 --- a/lib/internal/Magento/Framework/Api/SearchCriteriaDataBuilder.php +++ /dev/null @@ -1,14 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -namespace Magento\Framework\Api; - -/** - * TODO: Temporary search criteria builder builder - */ -class SearchCriteriaDataBuilder extends \Magento\Framework\Api\SearchCriteriaBuilder -{ -} diff --git a/lib/internal/Magento/Framework/Api/SearchCriteriaInterface.php b/lib/internal/Magento/Framework/Api/SearchCriteriaInterface.php index 87e57f53aa35034c2f1c40d6eb7b433ade582343..96535d03e30d512a41edc60638e398fc3b8dacc7 100644 --- a/lib/internal/Magento/Framework/Api/SearchCriteriaInterface.php +++ b/lib/internal/Magento/Framework/Api/SearchCriteriaInterface.php @@ -21,6 +21,14 @@ interface SearchCriteriaInterface */ public function getFilterGroups(); + /** + * Set a list of filter groups. + * + * @param \Magento\Framework\Api\Search\FilterGroup[] $filterGroups + * @return $this + */ + public function setFilterGroups(array $filterGroups = null); + /** * Get sort order. * @@ -28,6 +36,14 @@ interface SearchCriteriaInterface */ public function getSortOrders(); + /** + * Set sort order. + * + * @param \Magento\Framework\Api\SortOrder[] $sortOrders + * @return $this + */ + public function setSortOrders(array $sortOrders = null); + /** * Get page size. * @@ -35,10 +51,26 @@ interface SearchCriteriaInterface */ public function getPageSize(); + /** + * Set page size. + * + * @param int $pageSize + * @return $this + */ + public function setPageSize($pageSize); + /** * Get current page. * * @return int|null */ public function getCurrentPage(); + + /** + * Set current page. + * + * @param int $currentPage + * @return $this + */ + public function setCurrentPage($currentPage); } diff --git a/lib/internal/Magento/Framework/Api/SearchResultsInterface.php b/lib/internal/Magento/Framework/Api/SearchResultsInterface.php index 03806a89948c07e219729ada16996ee4c97aa9c4..fdf4bce22dc9f5ba200bf4e0628ccf27501681e1 100644 --- a/lib/internal/Magento/Framework/Api/SearchResultsInterface.php +++ b/lib/internal/Magento/Framework/Api/SearchResultsInterface.php @@ -18,6 +18,14 @@ interface SearchResultsInterface */ public function getItems(); + /** + * Set items list. + * + * @param \Magento\Framework\Api\ExtensibleDataInterface[] $items + * @return $this + */ + public function setItems(array $items = null); + /** * Get search criteria. * @@ -25,10 +33,26 @@ interface SearchResultsInterface */ public function getSearchCriteria(); + /** + * Set search criteria. + * + * @param \Magento\Framework\Api\SearchCriteriaInterface $searchCriteria + * @return $this + */ + public function setSearchCriteria(\Magento\Framework\Api\SearchCriteriaInterface $searchCriteria = null); + /** * Get total count. * * @return int */ public function getTotalCount(); + + /** + * Set total count. + * + * @param int $totalCount + * @return $this + */ + public function setTotalCount($totalCount); } diff --git a/lib/internal/Magento/Framework/Api/SortOrder.php b/lib/internal/Magento/Framework/Api/SortOrder.php index aae092060225f9d1fbf0cccba5ba204b2ba9678d..a29bac335b972f993ebcf9086450aa3d6b258e36 100644 --- a/lib/internal/Magento/Framework/Api/SortOrder.php +++ b/lib/internal/Magento/Framework/Api/SortOrder.php @@ -9,6 +9,7 @@ namespace Magento\Framework\Api; /** * Data object for sort order. + * @codeCoverageIgnore */ class SortOrder extends AbstractExtensibleObject { @@ -25,6 +26,17 @@ class SortOrder extends AbstractExtensibleObject return $this->_get(SortOrder::FIELD); } + /** + * Set sorting field. + * + * @param string $field + * @return $this + */ + public function setField($field) + { + return $this->setData(SortOrder::FIELD, $field); + } + /** * Get sorting direction. * @@ -34,4 +46,15 @@ class SortOrder extends AbstractExtensibleObject { return $this->_get(SortOrder::DIRECTION); } + + /** + * Set sorting direction. + * + * @param string $direction + * @return $this + */ + public function setDirection($direction) + { + return $this->setData(SortOrder::DIRECTION, $direction); + } } diff --git a/lib/internal/Magento/Framework/Api/SortOrderBuilder.php b/lib/internal/Magento/Framework/Api/SortOrderBuilder.php index 59653270ee57d5147fe523c47aec772501c34b12..2f02c1c129a3b8c5f330b4e1739194f005f5ca47 100644 --- a/lib/internal/Magento/Framework/Api/SortOrderBuilder.php +++ b/lib/internal/Magento/Framework/Api/SortOrderBuilder.php @@ -10,9 +10,8 @@ namespace Magento\Framework\Api; /** * Builder for sort order data object. * - * @method SortOrder create() */ -class SortOrderBuilder extends ExtensibleObjectBuilder +class SortOrderBuilder extends AbstractSimpleObjectBuilder { /** * Set sorting field. diff --git a/lib/internal/Magento/Framework/Api/Test/Unit/Code/Generator/GenerateSearchResultsBuilderTest.php b/lib/internal/Magento/Framework/Api/Test/Unit/Code/Generator/GenerateSearchResultsBuilderTest.php deleted file mode 100644 index eba4aa8c768f6b3a7a35e70c5225099c95bc1399..0000000000000000000000000000000000000000 --- a/lib/internal/Magento/Framework/Api/Test/Unit/Code/Generator/GenerateSearchResultsBuilderTest.php +++ /dev/null @@ -1,68 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Framework\Api\Test\Unit\Code\Generator; - - -/** - * Class SearchResultBuilderTest - */ -class GenerateSearchResultsBuilderTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $ioObjectMock; - - /** - * Create mock for class \Magento\Framework\Code\Generator\Io - */ - protected function setUp() - { - $this->ioObjectMock = $this->getMock( - '\Magento\Framework\Code\Generator\Io', - [], - [], - '', - false - ); - } - - /** - * generate SearchResultBuilder class - */ - public function testGenerate() - { - require_once __DIR__ . '/Sample.php'; - /** @var \Magento\Framework\Api\Code\Generator\SearchResultsBuilder $model */ - $model = $this->getMock( - 'Magento\Framework\Api\Code\Generator\SearchResultsBuilder', - [ - '_validateData' - ], - [ - '\Magento\Framework\Api\Code\Generator\Sample', - null, - $this->ioObjectMock, - null, - null, - $this->getMock('Magento\Framework\Filesystem\FileResolver') - ] - ); - $sampleSearchResultBuilderCode = file_get_contents(__DIR__ . '/_files/SampleSearchResultsBuilder.txt'); - $this->ioObjectMock->expects($this->once()) - ->method('getResultFileName') - ->with('\Magento\Framework\Api\Code\Generator\SampleSearchResultsBuilder') - ->will($this->returnValue('SampleSearchResultsBuilder.php')); - $this->ioObjectMock->expects($this->once()) - ->method('writeResultFile') - ->with('SampleSearchResultsBuilder.php', $sampleSearchResultBuilderCode); - - $model->expects($this->once()) - ->method('_validateData') - ->will($this->returnValue(true)); - $this->assertEquals('SampleSearchResultsBuilder.php', $model->generate(), implode("\n", $model->getErrors())); - } -} diff --git a/lib/internal/Magento/Framework/Api/Test/Unit/Code/Generator/_files/ExtensibleSampleDataBuilder.txt b/lib/internal/Magento/Framework/Api/Test/Unit/Code/Generator/_files/ExtensibleSampleDataBuilder.txt deleted file mode 100644 index f1150ba27db5dafe5b6e0c5ea36c9a6021df480b..0000000000000000000000000000000000000000 --- a/lib/internal/Magento/Framework/Api/Test/Unit/Code/Generator/_files/ExtensibleSampleDataBuilder.txt +++ /dev/null @@ -1,65 +0,0 @@ -namespace Magento\Framework\Api\Code\Generator; - -/** - * DataBuilder class for - * \Magento\Framework\Api\Code\Generator\ExtensibleSampleInterface - */ -class ExtensibleSampleDataBuilder extends \Magento\Framework\Api\Builder -{ - /** - * @param array $items - * @return $this - */ - public function setItems($items) - { - $this->_set('items', $items); - return $this; - } - - /** - * @param string $name - * @return $this - */ - public function setName($name) - { - $this->_set('name', $name); - return $this; - } - - /** - * @param int $count - * @return $this - */ - public function setCount($count) - { - $this->_set('count', $count); - return $this; - } - - /** - * @param int $createdAt - * @return $this - */ - public function setCreatedAt($createdAt) - { - $this->_set('created_at', $createdAt); - return $this; - } - - /** - * Initialize the builder - * - * @param \Magento\Framework\Api\ObjectFactory $objectFactory - * @param \Magento\Framework\Api\MetadataServiceInterface $metadataService - * @param \Magento\Framework\Api\AttributeDataBuilder $attributeValueBuilder - * @param \Magento\Framework\Reflection\DataObjectProcessor $objectProcessor - * @param \Magento\Framework\Reflection\TypeProcessor $typeProcessor - * @param \Magento\Framework\Serialization\DataBuilderFactory $dataBuilderFactory - * @param \Magento\Framework\ObjectManager\ConfigInterface $objectManagerConfig - * @param string|null $modelClassInterface - */ - public function __construct(\Magento\Framework\Api\ObjectFactory $objectFactory, \Magento\Framework\Api\MetadataServiceInterface $metadataService, \Magento\Framework\Api\AttributeDataBuilder $attributeValueBuilder, \Magento\Framework\Reflection\DataObjectProcessor $objectProcessor, \Magento\Framework\Reflection\TypeProcessor $typeProcessor, \Magento\Framework\Serialization\DataBuilderFactory $dataBuilderFactory, \Magento\Framework\ObjectManager\ConfigInterface $objectManagerConfig, $modelClassInterface = null) - { - parent::__construct($objectFactory, $metadataService, $attributeValueBuilder, $objectProcessor, $typeProcessor, $dataBuilderFactory, $objectManagerConfig, 'Magento\Framework\Api\Code\Generator\ExtensibleSampleInterface'); - } -} diff --git a/lib/internal/Magento/Framework/Api/Test/Unit/Code/Generator/_files/SampleBuilder.txt b/lib/internal/Magento/Framework/Api/Test/Unit/Code/Generator/_files/SampleBuilder.txt deleted file mode 100644 index cfc1250701c346a9f514b7a6214edd9e276b3320..0000000000000000000000000000000000000000 --- a/lib/internal/Magento/Framework/Api/Test/Unit/Code/Generator/_files/SampleBuilder.txt +++ /dev/null @@ -1,15 +0,0 @@ -namespace Magento\Framework\Api\Code\Generator; - -/** - * Builder class for @see \Magento\Framework\Api\Code\Generator\Sample - */ -class SampleBuilder extends \Magento\Framework\Api\ExtensibleObjectBuilder -{ - /** - * {@inheritdoc} - */ - public function setMessages($messages) - { - return $this->_set(\Magento\Framework\Api\Code\Generator\Sample::MESSAGES, $messages); - } -} diff --git a/lib/internal/Magento/Framework/Api/Test/Unit/Code/Generator/_files/SampleSearchResultsBuilder.txt b/lib/internal/Magento/Framework/Api/Test/Unit/Code/Generator/_files/SampleSearchResultsBuilder.txt deleted file mode 100644 index 209dd9b054922d9736e7ea47f794ec1f00482052..0000000000000000000000000000000000000000 --- a/lib/internal/Magento/Framework/Api/Test/Unit/Code/Generator/_files/SampleSearchResultsBuilder.txt +++ /dev/null @@ -1,17 +0,0 @@ -namespace Magento\Framework\Api\Code\Generator; - -/** - * SearchResultsBuilder class for @see \Magento\Framework\Api\Code\Generator\Sample - */ -class SampleSearchResultsBuilder extends \Magento\Framework\Api\AbstractSearchResultsBuilder -{ - /** - * SearchResultsBuilder constructor - * - * @param - */ - public function __construct(\Magento\Framework\Api\ObjectFactory $objectFactory, \Magento\Framework\Api\AttributeValueFactory $valueFactory, \Magento\Framework\Api\Config\MetadataConfig $metadataService, \Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder, \Magento\Framework\Api\Code\Generator\SampleBuilder $itemObjectBuilder) - { - parent::__construct($objectFactory, $valueFactory, $metadataService, $searchCriteriaBuilder, $itemObjectBuilder); - } -} diff --git a/lib/internal/Magento/Framework/Api/Test/Unit/Config/MetadataConfigTest.php b/lib/internal/Magento/Framework/Api/Test/Unit/Config/MetadataConfigTest.php index d98b9db25a87c6bb0f556b672e4c280280ecf1ad..bc310d2ee3acbc4044f64f71e4425dfda2af2aa7 100644 --- a/lib/internal/Magento/Framework/Api/Test/Unit/Config/MetadataConfigTest.php +++ b/lib/internal/Magento/Framework/Api/Test/Unit/Config/MetadataConfigTest.php @@ -18,9 +18,9 @@ class MetadataConfigTest extends \PHPUnit_Framework_TestCase protected $serviceConfigReaderMock; /** - * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\Api\AttributeMetadataBuilderInterface + * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\Api\ObjectFactory */ - protected $attributeMetadataBuilderMock; + protected $objectFactoryMock; /** * Prepare parameters @@ -30,13 +30,13 @@ class MetadataConfigTest extends \PHPUnit_Framework_TestCase $this->serviceConfigReaderMock = $this->getMockBuilder('\Magento\Framework\Api\Config\Reader') ->disableOriginalConstructor() ->getMock(); - $this->attributeMetadataBuilderMock = $this->getMockBuilder( - '\Magento\Framework\Api\AttributeMetadataBuilderInterface' - )->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->attributeMetadataBuilderMock + $this->objectFactoryMock ); } @@ -57,10 +57,11 @@ class MetadataConfigTest extends \PHPUnit_Framework_TestCase ->willReturn($allAttributes); $attributeMock = $this->getMock('\Magento\Framework\Api\MetadataObjectInterface'); - $this->attributeMetadataBuilderMock->expects($this->exactly(2)) + $attributeMock->expects($this->exactly(2)) ->method('setAttributeCode') - ->with($attributeCode); - $this->attributeMetadataBuilderMock->expects($this->exactly(2)) + ->with($attributeCode) + ->will($this->returnSelf()); + $this->objectFactoryMock->expects($this->exactly(2)) ->method('create') ->willReturn($attributeMock); diff --git a/lib/internal/Magento/Framework/Api/Test/Unit/Data/AttributeValueTest.php b/lib/internal/Magento/Framework/Api/Test/Unit/Data/AttributeValueTest.php index 2437d84880bce65045045b303dbea41f15b74b37..be70bc717d963e8d1b1e2035288dc44c48eb5e38 100644 --- a/lib/internal/Magento/Framework/Api/Test/Unit/Data/AttributeValueTest.php +++ b/lib/internal/Magento/Framework/Api/Test/Unit/Data/AttributeValueTest.php @@ -21,12 +21,12 @@ class AttributeValueTest extends \PHPUnit_Framework_TestCase public function testConstructorAndGettersWithString() { - $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - /** @var \Magento\Framework\Api\AttributeDataBuilder $attributeBuilder */ - $attributeBuilder = $helper->getObject('Magento\Framework\Api\AttributeDataBuilder') - ->setAttributeCode(self::ATTRIBUTE_CODE) - ->setValue(self::STRING_VALUE); - $attribute = new AttributeValue($attributeBuilder->getData()); + $attribute = new AttributeValue( + [ + AttributeValue::ATTRIBUTE_CODE => self::ATTRIBUTE_CODE, + AttributeValue::VALUE => self::STRING_VALUE + ] + ); $this->assertSame(self::ATTRIBUTE_CODE, $attribute->getAttributeCode()); $this->assertSame(self::STRING_VALUE, $attribute->getValue()); @@ -34,12 +34,12 @@ class AttributeValueTest extends \PHPUnit_Framework_TestCase public function testConstructorAndGettersWithInteger() { - $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - /** @var \Magento\Framework\Api\AttributeDataBuilder $attributeBuilder */ - $attributeBuilder = $helper->getObject('Magento\Framework\Api\AttributeDataBuilder') - ->setAttributeCode(self::ATTRIBUTE_CODE) - ->setValue(self::INTEGER_VALUE); - $attribute = new AttributeValue($attributeBuilder->getData()); + $attribute = new AttributeValue( + [ + AttributeValue::ATTRIBUTE_CODE => self::ATTRIBUTE_CODE, + AttributeValue::VALUE => self::INTEGER_VALUE + ] + ); $this->assertSame(self::ATTRIBUTE_CODE, $attribute->getAttributeCode()); $this->assertSame(self::INTEGER_VALUE, $attribute->getValue()); @@ -47,12 +47,12 @@ class AttributeValueTest extends \PHPUnit_Framework_TestCase public function testConstructorAndGettersWithFloat() { - $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - /** @var \Magento\Framework\Api\AttributeDataBuilder $attributeBuilder */ - $attributeBuilder = $helper->getObject('Magento\Framework\Api\AttributeDataBuilder') - ->setAttributeCode(self::ATTRIBUTE_CODE) - ->setValue(self::FLOAT_VALUE); - $attribute = new AttributeValue($attributeBuilder->getData()); + $attribute = new AttributeValue( + [ + AttributeValue::ATTRIBUTE_CODE => self::ATTRIBUTE_CODE, + AttributeValue::VALUE => self::FLOAT_VALUE + ] + ); $this->assertSame(self::ATTRIBUTE_CODE, $attribute->getAttributeCode()); $this->assertSame(self::FLOAT_VALUE, $attribute->getValue()); @@ -60,12 +60,12 @@ class AttributeValueTest extends \PHPUnit_Framework_TestCase public function testConstructorAndGettersWithBoolean() { - $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - /** @var \Magento\Framework\Api\AttributeDataBuilder $attributeBuilder */ - $attributeBuilder = $helper->getObject('Magento\Framework\Api\AttributeDataBuilder') - ->setAttributeCode(self::ATTRIBUTE_CODE) - ->setValue(self::BOOLEAN_VALUE); - $attribute = new AttributeValue($attributeBuilder->getData()); + $attribute = new AttributeValue( + [ + AttributeValue::ATTRIBUTE_CODE => self::ATTRIBUTE_CODE, + AttributeValue::VALUE => self::BOOLEAN_VALUE + ] + ); $this->assertSame(self::ATTRIBUTE_CODE, $attribute->getAttributeCode()); $this->assertSame(self::BOOLEAN_VALUE, $attribute->getValue()); diff --git a/lib/internal/Magento/Framework/Api/Test/Unit/DataObjectHelperTest.php b/lib/internal/Magento/Framework/Api/Test/Unit/DataObjectHelperTest.php index 30afec4acdccafb21a94fe796924e86a2e91ec79..1478deb7c41daf420af12deda53c97bed9368639 100644 --- a/lib/internal/Magento/Framework/Api/Test/Unit/DataObjectHelperTest.php +++ b/lib/internal/Magento/Framework/Api/Test/Unit/DataObjectHelperTest.php @@ -102,18 +102,22 @@ class DataObjectHelperTest extends \PHPUnit_Framework_TestCase $this->objectProcessorMock->expects($this->at(0)) ->method('getMethodReturnType') - ->with('Magento\Customer\Model\Data\Address', 'getStreet') + ->with('\Magento\Customer\Api\Data\AddressInterface', 'getStreet') ->willReturn('string[]'); $this->objectProcessorMock->expects($this->at(1)) ->method('getMethodReturnType') - ->with('Magento\Customer\Model\Data\Address', 'getRegion') + ->with('\Magento\Customer\Api\Data\AddressInterface', 'getRegion') ->willReturn('\Magento\Customer\Api\Data\RegionInterface'); $this->objectFactoryMock->expects($this->once()) ->method('create') ->with('\Magento\Customer\Api\Data\RegionInterface', []) ->willReturn($regionDataObject); - $this->dataObjectHelper->populateWithArray($addressDataObject, $data); + $this->dataObjectHelper->populateWithArray( + $addressDataObject, + $data, + '\Magento\Customer\Api\Data\AddressInterface' + ); $this->assertEquals($id, $addressDataObject->getId()); $this->assertEquals($countryId, $addressDataObject->getCountryId()); @@ -164,7 +168,11 @@ class DataObjectHelperTest extends \PHPUnit_Framework_TestCase $this->attributeValueFactoryMock->expects($this->once()) ->method('create') ->willReturn($customAttribute); - $this->dataObjectHelper->populateWithArray($addressDataObject, $data); + $this->dataObjectHelper->populateWithArray( + $addressDataObject, + $data, + '\Magento\Customer\Api\Data\AddressInterface' + ); $this->assertEquals($id, $addressDataObject->getId()); $this->assertEquals( @@ -223,7 +231,11 @@ class DataObjectHelperTest extends \PHPUnit_Framework_TestCase $this->attributeValueFactoryMock->expects($this->once()) ->method('create') ->willReturn($customAttribute); - $this->dataObjectHelper->populateWithArray($addressDataObject, $data); + $this->dataObjectHelper->populateWithArray( + $addressDataObject, + $data, + '\Magento\Customer\Api\Data\AddressInterface' + ); $this->assertEquals($id, $addressDataObject->getId()); $this->assertEquals( diff --git a/lib/internal/Magento/Framework/Api/Test/Unit/StubAbstractSimpleObjectBuilder.php b/lib/internal/Magento/Framework/Api/Test/Unit/StubAbstractSimpleObjectBuilder.php deleted file mode 100644 index c387049951dc8f41a25154e1abc5ae256e84d7c7..0000000000000000000000000000000000000000 --- a/lib/internal/Magento/Framework/Api/Test/Unit/StubAbstractSimpleObjectBuilder.php +++ /dev/null @@ -1,15 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Framework\Api\Test\Unit; - -use Magento\Framework\Api\AbstractSimpleObjectBuilder; - -/** - * Class Stub for testing AbstractSimpleObjectBuilder class - */ -class StubAbstractSimpleObjectBuilder extends AbstractSimpleObjectBuilder -{ -} diff --git a/lib/internal/Magento/Framework/App/StaticResource.php b/lib/internal/Magento/Framework/App/StaticResource.php index 45fe01dac839dc28c47816a70c27a085eb53fd86..a4df94fc2eafdf67458801a82ac574f721a7f3c9 100644 --- a/lib/internal/Magento/Framework/App/StaticResource.php +++ b/lib/internal/Magento/Framework/App/StaticResource.php @@ -99,6 +99,8 @@ class StaticResource implements \Magento\Framework\AppInterface */ public function launch() { + // disabling profiling when retrieving static resource + \Magento\Framework\Profiler::reset(); $appMode = $this->state->getMode(); if ($appMode == \Magento\Framework\App\State::MODE_PRODUCTION) { $this->response->setHttpResponseCode(404); diff --git a/lib/internal/Magento/Framework/Data/AbstractSearchResult.php b/lib/internal/Magento/Framework/Data/AbstractSearchResult.php index 5b23d07bc05c3c2d82e5baca6486b5d600cffca2..994b3a2c25f9c8b2cf378f55d7ef9367ff474a5f 100644 --- a/lib/internal/Magento/Framework/Data/AbstractSearchResult.php +++ b/lib/internal/Magento/Framework/Data/AbstractSearchResult.php @@ -103,6 +103,16 @@ abstract class AbstractSearchResult extends AbstractDataObject implements Search return $this->data['items']; } + /** + * @param \Magento\Framework\Object[] $items + * @return $this + */ + public function setItems(array $items = null) + { + $this->data['items'] = $items; + return $this; + } + /** * @return int */ @@ -114,6 +124,16 @@ abstract class AbstractSearchResult extends AbstractDataObject implements Search return $this->data['total_count']; } + /** + * @param int $totalCount + * @return $this + */ + public function setTotalCount($totalCount) + { + $this->data['total_count'] = $totalCount; + return $this; + } + /** * @return \Magento\Framework\Api\CriteriaInterface */ @@ -125,6 +145,16 @@ abstract class AbstractSearchResult extends AbstractDataObject implements Search return $this->data['search_criteria']; } + /** + * @param \Magento\Framework\Api\SearchCriteriaInterface $searchCriteria + * @return $this + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function setSearchCriteria(\Magento\Framework\Api\SearchCriteriaInterface $searchCriteria = null) + { + return $this; + } + /** * @return \Magento\Framework\Data\SearchResultIterator */ diff --git a/lib/internal/Magento/Framework/Model/AbstractModel.php b/lib/internal/Magento/Framework/Model/AbstractModel.php index 5c5985ee70e0946722a440c0733ffa048e3dddc6..f31fb9fc3e90c7451f605f74022d82625c1f7b5e 100644 --- a/lib/internal/Magento/Framework/Model/AbstractModel.php +++ b/lib/internal/Magento/Framework/Model/AbstractModel.php @@ -642,6 +642,17 @@ abstract class AbstractModel extends \Magento\Framework\Object return $this->_getData('entity_id'); } + /** + * Set entity id + * + * @param int $entityId + * @return $this + */ + public function setEntityId($entityId) + { + return $this->setData('entity_id', $entityId); + } + /** * Clearing object for correct deleting by garbage collector * diff --git a/lib/internal/Magento/Framework/Model/Test/Unit/AbstractExtensibleModelTest.php b/lib/internal/Magento/Framework/Model/Test/Unit/AbstractExtensibleModelTest.php index 13bffdd695ea7eda4fe7d1fa0335cf35f3197631..2d224e2d6cada6ba260a9d3d857e03b52b8832d4 100644 --- a/lib/internal/Magento/Framework/Model/Test/Unit/AbstractExtensibleModelTest.php +++ b/lib/internal/Magento/Framework/Model/Test/Unit/AbstractExtensibleModelTest.php @@ -6,6 +6,7 @@ namespace Magento\Framework\Model\Test\Unit; +use Magento\Framework\Api\AttributeValue; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; class AbstractExtensibleModelTest extends \PHPUnit_Framework_TestCase @@ -206,15 +207,14 @@ class AbstractExtensibleModelTest extends \PHPUnit_Framework_TestCase */ protected function addCustomAttributesToModel($attributesAsArray, $model) { - $objectManager = new ObjectManagerHelper($this); - /** @var \Magento\Framework\Api\AttributeDataBuilder $attributeValueBuilder */ - $attributeValueBuilder = $objectManager->getObject('Magento\Framework\Api\AttributeDataBuilder'); $addedAttributes = []; foreach ($attributesAsArray as $attributeCode => $attributeValue) { - $addedAttributes[$attributeCode] = $attributeValueBuilder - ->setAttributeCode($attributeCode) - ->setValue($attributeValue) - ->create(); + $addedAttributes[$attributeCode] = new AttributeValue( + [ + AttributeValue::ATTRIBUTE_CODE => $attributeCode, + AttributeValue::VALUE => $attributeValue, + ] + ); } $model->setData( array_merge( diff --git a/lib/internal/Magento/Framework/Module/ModuleList/DeploymentConfigFactory.php b/lib/internal/Magento/Framework/Module/ModuleList/DeploymentConfigFactory.php new file mode 100644 index 0000000000000000000000000000000000000000..c7b92525fa6a2f25c77f2343aac8219bcfc14cf3 --- /dev/null +++ b/lib/internal/Magento/Framework/Module/ModuleList/DeploymentConfigFactory.php @@ -0,0 +1,24 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Framework\Module\ModuleList; + +/** + * Factory for Deployment configuration segment for modules + */ +class DeploymentConfigFactory +{ + /** + * Factory method for Deployment Config object + * + * @param array $data + * @return DeploymentConfig + */ + public function create(array $data) + { + return new DeploymentConfig($data); + } +} diff --git a/lib/internal/Magento/Framework/Module/Status.php b/lib/internal/Magento/Framework/Module/Status.php index 3fca3995780ab3a1fc4bb27e26cd306a2bdf478e..d71a48fc3c6680fc69a414f1c8512ae592597f5c 100644 --- a/lib/internal/Magento/Framework/Module/Status.php +++ b/lib/internal/Magento/Framework/Module/Status.php @@ -7,10 +7,13 @@ namespace Magento\Framework\Module; use Magento\Framework\App\DeploymentConfig\Writer; +use Magento\Framework\Module\ModuleList\DeploymentConfigFactory; use Magento\Framework\App\State\Cleanup; /** * A service for controlling module status + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class Status { @@ -56,6 +59,13 @@ class Status */ private $conflictChecker; + /** + * Factory to create module deployment config object + * + * @var DeploymentConfigFactory + */ + private $deploymentConfigFactory; + /** * Constructor * @@ -65,6 +75,7 @@ class Status * @param Cleanup $cleanup * @param ConflictChecker $conflictChecker * @param DependencyChecker $dependencyChecker + * @param DeploymentConfigFactory $deploymentConfigFactory */ public function __construct( ModuleList\Loader $loader, @@ -72,7 +83,8 @@ class Status Writer $writer, Cleanup $cleanup, ConflictChecker $conflictChecker, - DependencyChecker $dependencyChecker + DependencyChecker $dependencyChecker, + DeploymentConfigFactory $deploymentConfigFactory ) { $this->loader = $loader; $this->list = $list; @@ -80,6 +92,7 @@ class Status $this->cleanup = $cleanup; $this->conflictChecker = $conflictChecker; $this->dependencyChecker = $dependencyChecker; + $this->deploymentConfigFactory = $deploymentConfigFactory; } /** @@ -159,7 +172,7 @@ class Status $result[$name] = $currentStatus; } } - $segment = new ModuleList\DeploymentConfig($result); + $segment = $this->deploymentConfigFactory->create($result); $this->writer->update($segment); $this->cleanup->clearCaches(); $this->cleanup->clearCodeGeneratedFiles(); diff --git a/lib/internal/Magento/Framework/Module/Test/Unit/ModuleList/DeploymentConfigFactoryTest.php b/lib/internal/Magento/Framework/Module/Test/Unit/ModuleList/DeploymentConfigFactoryTest.php new file mode 100644 index 0000000000000000000000000000000000000000..fc07edc800666e6451e67cdf88893055dcc1e9e7 --- /dev/null +++ b/lib/internal/Magento/Framework/Module/Test/Unit/ModuleList/DeploymentConfigFactoryTest.php @@ -0,0 +1,26 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Framework\Module\Test\Unit\ModuleList; + +use Magento\Framework\Module\ModuleList\DeploymentConfigFactory; + +class DeploymentConfigFactoryTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var DeploymentConfigFactory + */ + protected $object; + + public function testCreate() + { + $this->object = new DeploymentConfigFactory(); + $this->assertInstanceOf( + 'Magento\Framework\Module\ModuleList\DeploymentConfig', + $this->object->create(['Module_One' => 0, 'Module_Two' =>1]) + ); + } +} diff --git a/lib/internal/Magento/Framework/Module/Test/Unit/StatusTest.php b/lib/internal/Magento/Framework/Module/Test/Unit/StatusTest.php index 36ae599d5f570cf9caaa35b9e84edb5c06cd509d..f469783e91b5811c417b3d06b6c22754e3647a7e 100644 --- a/lib/internal/Magento/Framework/Module/Test/Unit/StatusTest.php +++ b/lib/internal/Magento/Framework/Module/Test/Unit/StatusTest.php @@ -40,6 +40,11 @@ class StatusTest extends \PHPUnit_Framework_TestCase */ private $dependencyChecker; + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + private $deploymentConfigFactory; + /** * @var Status */ @@ -53,13 +58,21 @@ class StatusTest extends \PHPUnit_Framework_TestCase $this->cleanup = $this->getMock('Magento\Framework\App\State\Cleanup', [], [], '', false); $this->conflictChecker = $this->getMock('Magento\Framework\Module\ConflictChecker', [], [], '', false); $this->dependencyChecker = $this->getMock('Magento\Framework\Module\DependencyChecker', [], [], '', false); + $this->deploymentConfigFactory = $this->getMock( + 'Magento\Framework\Module\ModuleList\DeploymentConfigFactory', + [], + [], + '', + false + ); $this->object = new Status( $this->loader, $this->moduleList, $this->writer, $this->cleanup, $this->conflictChecker, - $this->dependencyChecker + $this->dependencyChecker, + $this->deploymentConfigFactory ); } @@ -167,10 +180,11 @@ class StatusTest extends \PHPUnit_Framework_TestCase $this->moduleList->expects($this->at(0))->method('has')->with('Module_Foo')->willReturn(false); $this->moduleList->expects($this->at(1))->method('has')->with('Module_Bar')->willReturn(false); $this->moduleList->expects($this->at(2))->method('has')->with('Module_Baz')->willReturn(false); - $constraint = new \PHPUnit_Framework_Constraint_IsInstanceOf( - 'Magento\Framework\Module\ModuleList\DeploymentConfig' - ); - $this->writer->expects($this->once())->method('update')->with($constraint); + $deploymentConfig = $this->getMock('Magento\Framework\Module\ModuleList\DeploymentConfig', [], [], '', false); + $expectedModules = ['Module_Foo' => 1, 'Module_Bar' => 1, 'Module_Baz' => 0]; + $this->deploymentConfigFactory->expects($this->once())->method('create')->with($expectedModules) + ->willReturn($deploymentConfig); + $this->writer->expects($this->once())->method('update')->with($deploymentConfig); $this->cleanup->expects($this->once())->method('clearCaches'); $this->cleanup->expects($this->once())->method('clearCodeGeneratedFiles'); $this->object->setIsEnabled(true, ['Module_Foo', 'Module_Bar']); diff --git a/lib/internal/Magento/Framework/ObjectManager/DefinitionFactory.php b/lib/internal/Magento/Framework/ObjectManager/DefinitionFactory.php index bb9f7e00b4ca9e187707100883bf279521229f75..626dbd548aab0f5a369f8dffd3cebe683598a27b 100644 --- a/lib/internal/Magento/Framework/ObjectManager/DefinitionFactory.php +++ b/lib/internal/Magento/Framework/ObjectManager/DefinitionFactory.php @@ -11,10 +11,8 @@ namespace Magento\Framework\ObjectManager; -use Magento\Framework\Api\Code\Generator\DataBuilder as DataBuilderGenerator; use Magento\Framework\Api\Code\Generator\Mapper as MapperGenerator; use Magento\Framework\Api\Code\Generator\SearchResults; -use Magento\Framework\Api\Code\Generator\SearchResultsBuilder; use Magento\Framework\Filesystem\DriverInterface; use Magento\Framework\Interception\Code\Generator as InterceptionGenerator; use Magento\Framework\ObjectManager\Code\Generator; @@ -104,14 +102,11 @@ class DefinitionFactory $generator = new \Magento\Framework\Code\Generator( $generatorIo, [ - SearchResultsBuilder::ENTITY_TYPE => '\Magento\Framework\Api\Code\Generator\SearchResultsBuilder', 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', - DataBuilderGenerator::ENTITY_TYPE => '\Magento\Framework\Api\Code\Generator\DataBuilder', - DataBuilderGenerator::ENTITY_TYPE_BUILDER => 'Magento\Framework\Api\Code\Generator\DataBuilder', 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', diff --git a/lib/internal/Magento/Framework/Reflection/Test/Unit/DataObject.php b/lib/internal/Magento/Framework/Reflection/Test/Unit/DataObject.php new file mode 100644 index 0000000000000000000000000000000000000000..501ac376fe70d8e1945ffdc73ecee3d6e66176ba --- /dev/null +++ b/lib/internal/Magento/Framework/Reflection/Test/Unit/DataObject.php @@ -0,0 +1,58 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Framework\Reflection\Test\Unit; + +/** + * Dummy data object to be used by TypeProcessorTest + */ +class DataObject +{ + /** + * @var string + */ + protected $attrName; + + /** + * @var bool + */ + protected $isActive; + + /** + * @return string + */ + public function getAttrName() + { + return $this->attrName; + } + + /** + * @param string $attrName + * @return $this + */ + public function setAttrName($attrName) + { + $this->attrName = $attrName; + return $this; + } + + /** + * @return bool + */ + public function isActive() + { + return $this->isActive; + } + + /** + * @param bool $isActive + * @return $this + */ + public function setIsActive($isActive) + { + $this->isActive = $isActive; + return $this; + } +} diff --git a/lib/internal/Magento/Framework/Reflection/Test/Unit/TypeProcessorTest.php b/lib/internal/Magento/Framework/Reflection/Test/Unit/TypeProcessorTest.php index 7dd1bf8f36f78018db1d4888a3f3e1df05fe6f6b..56cd942eac6de82fab4b43f450ead4b7901e23a9 100644 --- a/lib/internal/Magento/Framework/Reflection/Test/Unit/TypeProcessorTest.php +++ b/lib/internal/Magento/Framework/Reflection/Test/Unit/TypeProcessorTest.php @@ -5,6 +5,8 @@ */ namespace Magento\Framework\Reflection\Test\Unit; +use Zend\Code\Reflection\ClassReflection; + /** * Type processor Test */ @@ -180,4 +182,24 @@ class TypeProcessorTest extends \PHPUnit_Framework_TestCase $type = 'int[]'; $this->_typeProcessor->processSimpleAndAnyType($value, $type); } + + public function testFindSetterMethodName() + { + $class = new ClassReflection("\\Magento\\Framework\\Reflection\\Test\\Unit\\DataObject"); + $setterName = $this->_typeProcessor->findSetterMethodName($class, 'AttrName'); + $this->assertEquals("setAttrName", $setterName); + + $booleanSetterName = $this->_typeProcessor->findSetterMethodName($class, 'Active'); + $this->assertEquals("setIsActive", $booleanSetterName); + } + + /** + * @expectedException \Exception + * @expectedExceptionMessageRegExp /Property :"InvalidAttribute" does not exist in the provided class: \w+/ + */ + public function testFindSetterMethodNameInvalidAttribute() + { + $class = new ClassReflection("\\Magento\\Framework\\Reflection\\Test\\Unit\\DataObject"); + $this->_typeProcessor->findSetterMethodName($class, 'InvalidAttribute'); + } } diff --git a/lib/internal/Magento/Framework/Reflection/TypeProcessor.php b/lib/internal/Magento/Framework/Reflection/TypeProcessor.php index ad2ea51bdaa51e13a6db466f43064499357fc7c2..9087812959b597b446bce5eeb7021cae6c383780 100644 --- a/lib/internal/Magento/Framework/Reflection/TypeProcessor.php +++ b/lib/internal/Magento/Framework/Reflection/TypeProcessor.php @@ -495,4 +495,32 @@ class TypeProcessor } return $methodName; } + + /** + * Find the setter method name for a property from the given class + * + * @param ClassReflection $class + * @param string $camelCaseProperty + * @return string processed method name + * @throws \Exception If $camelCaseProperty has no corresponding setter method + */ + public function findSetterMethodName(ClassReflection $class, $camelCaseProperty) + { + $setterName = 'set' . $camelCaseProperty; + $boolSetterName = 'setIs' . $camelCaseProperty; + if ($class->hasMethod($setterName)) { + $methodName = $setterName; + } elseif ($class->hasMethod($boolSetterName)) { + $methodName = $boolSetterName; + } else { + throw new \Exception( + sprintf( + 'Property :"%s" does not exist in the provided class: "%s".', + $camelCaseProperty, + $class->getName() + ) + ); + } + return $methodName; + } } diff --git a/lib/internal/Magento/Framework/Serialization/DataBuilderFactory.php b/lib/internal/Magento/Framework/Serialization/DataBuilderFactory.php deleted file mode 100644 index a64670910d253dac667c3a7288bd5c4daa7e27f4..0000000000000000000000000000000000000000 --- a/lib/internal/Magento/Framework/Serialization/DataBuilderFactory.php +++ /dev/null @@ -1,72 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -namespace Magento\Framework\Serialization; - -use Magento\Framework\ObjectManagerInterface; - -/** - * Factory used to construct Data Builder based on interface name - */ -class DataBuilderFactory -{ - /** - * @var ObjectManagerInterface - */ - protected $objectManager; - - /** - * @param ObjectManagerInterface $objectManager - */ - public function __construct(ObjectManagerInterface $objectManager) - { - $this->objectManager = $objectManager; - } - - /** - * Returns a builder for a given class name. - * - * @param string $className - * @return \Magento\Framework\Api\BuilderInterface Builder Instance - */ - public function getDataBuilder($className) - { - $builderClassName = $this->getBuilderClassName($className); - return $this->createObject($builderClassName); - } - - /** - * Returns builder class name - * - * @param string $className - * @return string - */ - protected function getBuilderClassName($className) - { - $interfaceSuffix = 'Interface'; - if (substr($className, -strlen($interfaceSuffix)) === $interfaceSuffix) { - /** If class name ends with Interface, replace it with Data suffix */ - $builderClassName = substr($className, 0, -strlen($interfaceSuffix)) . 'Data'; - } else { - $builderClassName = $className; - } - $builderClassName .= 'Builder'; - - $builderClassName = ltrim($builderClassName, '\\'); - return $builderClassName; - } - - /** - * Creates builder object - * - * @param string $builderClassName - * @return \Magento\Framework\Api\BuilderInterface Builder Instance - */ - protected function createObject($builderClassName) - { - return $this->objectManager->create($builderClassName); - } -} diff --git a/lib/internal/Magento/Framework/Serialization/Test/Unit/DataBuilderFactoryTest.php b/lib/internal/Magento/Framework/Serialization/Test/Unit/DataBuilderFactoryTest.php deleted file mode 100644 index 13487b6520acdec46695b92104b1b453c7352f3b..0000000000000000000000000000000000000000 --- a/lib/internal/Magento/Framework/Serialization/Test/Unit/DataBuilderFactoryTest.php +++ /dev/null @@ -1,59 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -namespace Magento\Framework\Serialization\Test\Unit; - -use \Magento\Framework\Serialization\DataBuilderFactory; - -use Magento\Framework\ObjectManagerInterface; - -class DataBuilderFactoryTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var ObjectManagerInterface | \PHPUnit_Framework_MockObject_MockObject - */ - private $objectManager; - - /** - * @var DataBuilderFactory - */ - private $dataBuilderFactory; - - public function setUp() - { - $this->objectManager = $this->getMockBuilder('Magento\Framework\ObjectManagerInterface') - ->setMethods([]) - ->getMock(); - - $this->dataBuilderFactory = new DataBuilderFactory($this->objectManager); - } - - /** - * @param string $className - * @param string $expectedBuilderName - * @dataProvider classNamesDataProvider - */ - public function testGetBuilderClassName($className, $expectedBuilderName) - { - $this->objectManager->expects($this->once()) - ->method('create') - ->with($expectedBuilderName) - ->willReturn(new \StdClass); - - $this->assertInstanceOf('StdClass', $this->dataBuilderFactory->getDataBuilder($className)); - } - - /** - * @return array - */ - public function classNamesDataProvider() - { - return [ - ['\\TypeInterface', 'TypeDataBuilder'], - ['\\Type', 'TypeBuilder'] - ]; - } -} diff --git a/lib/internal/Magento/Framework/Webapi/ServiceInputProcessor.php b/lib/internal/Magento/Framework/Webapi/ServiceInputProcessor.php index 59bebdb9439fe8e217a42d22e79bd4ac9f15b4f2..ec1807f5222ef213d42175e76bd6dbccda8d870c 100644 --- a/lib/internal/Magento/Framework/Webapi/ServiceInputProcessor.php +++ b/lib/internal/Magento/Framework/Webapi/ServiceInputProcessor.php @@ -7,7 +7,7 @@ */ namespace Magento\Framework\Webapi; -use Magento\Framework\Api\AttributeDataBuilder; +use Magento\Framework\Api\AttributeValueFactory; use Magento\Framework\Api\AttributeValue; use Magento\Framework\Api\Config\Reader as ServiceConfigReader; use Magento\Framework\Api\SimpleDataObjectConverter; @@ -15,7 +15,7 @@ use Magento\Framework\App\Cache\Type\Webapi as WebapiCache; use Magento\Framework\Exception\InputException; use Magento\Framework\Exception\SerializationException; use Magento\Framework\Reflection\TypeProcessor; -use Magento\Framework\Serialization\DataBuilderFactory; +use Magento\Framework\ObjectManagerInterface; use Magento\Framework\Webapi\Exception as WebapiException; use Zend\Code\Reflection\ClassReflection; use Zend\Code\Reflection\MethodReflection; @@ -33,14 +33,14 @@ class ServiceInputProcessor /** @var \Magento\Framework\Reflection\TypeProcessor */ protected $typeProcessor; - /** @var DataBuilderFactory */ - protected $builderFactory; + /** @var ObjectManagerInterface */ + protected $objectManager; /** @var ServiceConfigReader */ protected $serviceConfigReader; - /** @var AttributeDataBuilder */ - protected $attributeValueBuilder; + /** @var AttributeValueFactory */ + protected $attributeValueFactory; /** @var WebapiCache */ protected $cache; @@ -49,22 +49,22 @@ class ServiceInputProcessor * Initialize dependencies. * * @param TypeProcessor $typeProcessor - * @param DataBuilderFactory $builderFactory + * @param ObjectManagerInterface $objectManager * @param ServiceConfigReader $serviceConfigReader - * @param AttributeDataBuilder $attributeValueBuilder + * @param AttributeValueFactory $attributeValueFactory * @param WebapiCache $cache */ public function __construct( TypeProcessor $typeProcessor, - DataBuilderFactory $builderFactory, + ObjectManagerInterface $objectManager, ServiceConfigReader $serviceConfigReader, - AttributeDataBuilder $attributeValueBuilder, + AttributeValueFactory $attributeValueFactory, WebapiCache $cache ) { $this->typeProcessor = $typeProcessor; - $this->builderFactory = $builderFactory; + $this->objectManager = $objectManager; $this->serviceConfigReader = $serviceConfigReader; - $this->attributeValueBuilder = $attributeValueBuilder; + $this->attributeValueFactory = $attributeValueFactory; $this->cache = $cache; } @@ -132,7 +132,8 @@ class ServiceInputProcessor $data = is_array($data) ? $data : []; $class = new ClassReflection($className); - $builder = $this->builderFactory->getDataBuilder($className); + $factory = $this->objectManager->get($className . 'Factory'); + $object = $factory->create(); foreach ($data as $propertyName => $value) { // Converts snake_case to uppercase CamelCase to help form getter/setter method names @@ -142,16 +143,24 @@ class ServiceInputProcessor $methodReflection = $class->getMethod($methodName); if ($methodReflection->isPublic()) { $returnType = $this->typeProcessor->getGetterReturnType($methodReflection)['type']; - $setterName = 'set' . $camelCaseProperty; + try { + $setterName = $this->typeProcessor->findSetterMethodName($class, $camelCaseProperty); + } catch (\Exception $e) { + if (empty($value)) { + continue; + } else { + throw $e; + } + } if ($camelCaseProperty === 'CustomAttributes') { $setterValue = $this->convertCustomAttributeValue($value, $returnType, $className); } else { $setterValue = $this->_convertValue($value, $returnType); } - $builder->{$setterName}($setterValue); + $object->{$setterName}($setterValue); } } - return $builder->create(); + return $object; } /** @@ -168,7 +177,12 @@ class ServiceInputProcessor $allAttributes = $this->serviceConfigReader->read(); $dataObjectClassName = ltrim($dataObjectClassName, '\\'); if (!isset($allAttributes[$dataObjectClassName])) { - return $this->_convertValue($customAttributesValueArray, $returnType); + $attributes = $this->_convertValue($customAttributesValueArray, $returnType); + $attributesByName = []; + foreach ($attributes as $attribute) { + $attributesByName[$attribute->getAttributeCode()] = $attribute; + } + return $attributesByName; } $dataObjectAttributes = $allAttributes[$dataObjectClassName]; $camelCaseAttributeCodeKey = lcfirst( @@ -200,10 +214,9 @@ class ServiceInputProcessor $attributeValue = $this->_convertValue($customAttributeValue, $type); } //Populate the attribute value data object once the value for custom attribute is derived based on type - $result[] = $this->attributeValueBuilder + $result[$customAttributeCode] = $this->attributeValueFactory->create() ->setAttributeCode($customAttributeCode) - ->setValue($attributeValue) - ->create(); + ->setValue($attributeValue); } return $result; diff --git a/lib/internal/Magento/Framework/Webapi/Test/Unit/ServiceInputProcessor/AssociativeArray.php b/lib/internal/Magento/Framework/Webapi/Test/Unit/ServiceInputProcessor/AssociativeArray.php index 4c0081fd3d438f5b7f0691a9d6cde094f0973ed5..132947d5d040e1cd8a79ab0a62606e74f7972a33 100644 --- a/lib/internal/Magento/Framework/Webapi/Test/Unit/ServiceInputProcessor/AssociativeArray.php +++ b/lib/internal/Magento/Framework/Webapi/Test/Unit/ServiceInputProcessor/AssociativeArray.php @@ -16,4 +16,13 @@ class AssociativeArray extends AbstractExtensibleObject { return $this->_get('associativeArray'); } + + /** + * @param string[] $associativeArray + * @return $this + */ + public function setAssociativeArray(array $associativeArray = []) + { + return $this->setData('associativeArray', $associativeArray); + } } diff --git a/lib/internal/Magento/Framework/Webapi/Test/Unit/ServiceInputProcessor/AssociativeArrayBuilder.php b/lib/internal/Magento/Framework/Webapi/Test/Unit/ServiceInputProcessor/AssociativeArrayBuilder.php deleted file mode 100644 index 1b563204225ed704d84c5d2e1c97ac35d62cfd97..0000000000000000000000000000000000000000 --- a/lib/internal/Magento/Framework/Webapi/Test/Unit/ServiceInputProcessor/AssociativeArrayBuilder.php +++ /dev/null @@ -1,21 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Framework\Webapi\Test\Unit\ServiceInputProcessor; - -use Magento\Framework\Api\ExtensibleObjectBuilder; - -class AssociativeArrayBuilder extends ExtensibleObjectBuilder -{ - /** - * @param string[] $associativeArray - * @return $this - */ - public function setAssociativeArray($associativeArray) - { - $this->data['associativeArray'] = $associativeArray; - return $this; - } -} diff --git a/lib/internal/Magento/Framework/Webapi/Test/Unit/ServiceInputProcessor/DataArray.php b/lib/internal/Magento/Framework/Webapi/Test/Unit/ServiceInputProcessor/DataArray.php index b1eed520ea63adcdf99672a8ed99816dcd0bca81..d620fad15b96b4a00b22864276d4b7d022272b10 100644 --- a/lib/internal/Magento/Framework/Webapi/Test/Unit/ServiceInputProcessor/DataArray.php +++ b/lib/internal/Magento/Framework/Webapi/Test/Unit/ServiceInputProcessor/DataArray.php @@ -16,4 +16,13 @@ class DataArray extends AbstractExtensibleObject { return $this->_get('items'); } + + /** + * @param \Magento\Webapi\Service\Entity\Simple[] $items + * @return $this + */ + public function setItems(array $items = null) + { + return $this->setData('items', $items); + } } diff --git a/lib/internal/Magento/Framework/Webapi/Test/Unit/ServiceInputProcessor/DataArrayBuilder.php b/lib/internal/Magento/Framework/Webapi/Test/Unit/ServiceInputProcessor/DataArrayBuilder.php deleted file mode 100644 index a6f3b8720780ec36858d1373aaec7f1ce5e63479..0000000000000000000000000000000000000000 --- a/lib/internal/Magento/Framework/Webapi/Test/Unit/ServiceInputProcessor/DataArrayBuilder.php +++ /dev/null @@ -1,21 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Framework\Webapi\Test\Unit\ServiceInputProcessor; - -use Magento\Framework\Api\ExtensibleObjectBuilder; - -class DataArrayBuilder extends ExtensibleObjectBuilder -{ - /** - * @param \Magento\Framework\Webapi\Test\Unit\ServiceInputProcessor\Simple[] $items - * @return $this - */ - public function setItems($items) - { - $this->data['items'] = $items; - return $this; - } -} diff --git a/lib/internal/Magento/Framework/Webapi/Test/Unit/ServiceInputProcessor/Nested.php b/lib/internal/Magento/Framework/Webapi/Test/Unit/ServiceInputProcessor/Nested.php index 05f7cda59849595b876a9a02d344bf399186e985..d69482352272d1c798643ce804fb497c515967f9 100644 --- a/lib/internal/Magento/Framework/Webapi/Test/Unit/ServiceInputProcessor/Nested.php +++ b/lib/internal/Magento/Framework/Webapi/Test/Unit/ServiceInputProcessor/Nested.php @@ -16,4 +16,13 @@ class Nested extends AbstractExtensibleObject { return $this->_get('details'); } + + /** + * @param \Magento\Webapi\Service\Entity\Simple $details + * @return $this + */ + public function setDetails($details) + { + return $this->setData('details', $details); + } } diff --git a/lib/internal/Magento/Framework/Webapi/Test/Unit/ServiceInputProcessor/NestedBuilder.php b/lib/internal/Magento/Framework/Webapi/Test/Unit/ServiceInputProcessor/NestedBuilder.php deleted file mode 100644 index aec2af54d8e96b536e1975e78dd1e3f1b54ecd4b..0000000000000000000000000000000000000000 --- a/lib/internal/Magento/Framework/Webapi/Test/Unit/ServiceInputProcessor/NestedBuilder.php +++ /dev/null @@ -1,21 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Framework\Webapi\Test\Unit\ServiceInputProcessor; - -use Magento\Framework\Api\ExtensibleObjectBuilder; - -class NestedBuilder extends ExtensibleObjectBuilder -{ - /** - * @param string $details - * @return $this - */ - public function setDetails($details) - { - $this->data['details'] = $details; - return $this; - } -} diff --git a/lib/internal/Magento/Framework/Webapi/Test/Unit/ServiceInputProcessor/ObjectWithCustomAttributes.php b/lib/internal/Magento/Framework/Webapi/Test/Unit/ServiceInputProcessor/ObjectWithCustomAttributes.php index 4f4532ece362e7dea3009e9e1cea1796793eeff0..36ee49d4e9055fee51760eb96130d2bfb2985309 100644 --- a/lib/internal/Magento/Framework/Webapi/Test/Unit/ServiceInputProcessor/ObjectWithCustomAttributes.php +++ b/lib/internal/Magento/Framework/Webapi/Test/Unit/ServiceInputProcessor/ObjectWithCustomAttributes.php @@ -9,4 +9,8 @@ use Magento\Framework\Api\AbstractExtensibleObject; class ObjectWithCustomAttributes extends AbstractExtensibleObject { + /** + * @var string[] + */ + protected $customAttributesCodes = [TestService::CUSTOM_ATTRIBUTE_CODE]; } diff --git a/lib/internal/Magento/Framework/Webapi/Test/Unit/ServiceInputProcessor/ObjectWithCustomAttributesBuilder.php b/lib/internal/Magento/Framework/Webapi/Test/Unit/ServiceInputProcessor/ObjectWithCustomAttributesBuilder.php deleted file mode 100644 index a080a40d8ca0d0e942d4af3fb1fb5bfe49c31dbd..0000000000000000000000000000000000000000 --- a/lib/internal/Magento/Framework/Webapi/Test/Unit/ServiceInputProcessor/ObjectWithCustomAttributesBuilder.php +++ /dev/null @@ -1,16 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Framework\Webapi\Test\Unit\ServiceInputProcessor; - -use Magento\Framework\Api\ExtensibleObjectBuilder; - -class ObjectWithCustomAttributesBuilder extends ExtensibleObjectBuilder -{ - /** - * @var string[] - */ - protected $customAttributesCodes = [TestService::CUSTOM_ATTRIBUTE_CODE]; -} diff --git a/lib/internal/Magento/Framework/Webapi/Test/Unit/ServiceInputProcessor/Simple.php b/lib/internal/Magento/Framework/Webapi/Test/Unit/ServiceInputProcessor/Simple.php index 9cd6d0d190d22f53fb497da81b76fc07960c61bd..14537dbdfb761153367a8c9cbbde6100e3af5b09 100644 --- a/lib/internal/Magento/Framework/Webapi/Test/Unit/ServiceInputProcessor/Simple.php +++ b/lib/internal/Magento/Framework/Webapi/Test/Unit/ServiceInputProcessor/Simple.php @@ -17,6 +17,15 @@ class Simple extends AbstractExtensibleObject return $this->_get('entityId'); } + /** + * @param int $entityId + * @return $this + */ + public function setEntityId($entityId) + { + return $this->setData('entityId', $entityId); + } + /** * @return string|null */ @@ -24,4 +33,13 @@ class Simple extends AbstractExtensibleObject { return $this->_get('name'); } + + /** + * @param string $name + * @return $this + */ + public function setName($name) + { + return $this->setData('name', $name); + } } diff --git a/lib/internal/Magento/Framework/Webapi/Test/Unit/ServiceInputProcessor/SimpleArray.php b/lib/internal/Magento/Framework/Webapi/Test/Unit/ServiceInputProcessor/SimpleArray.php index b09582c2a6d4cd20b57b14883e97911ee00365de..0fc83797db44b5f19ff36556a7e9f66368dafb22 100644 --- a/lib/internal/Magento/Framework/Webapi/Test/Unit/ServiceInputProcessor/SimpleArray.php +++ b/lib/internal/Magento/Framework/Webapi/Test/Unit/ServiceInputProcessor/SimpleArray.php @@ -16,4 +16,13 @@ class SimpleArray extends AbstractExtensibleObject { return $this->_get('ids'); } + + /** + * @param int[] $ids + * @return $this + */ + public function setIds(array $ids = null) + { + return $this->setData('ids', $ids); + } } diff --git a/lib/internal/Magento/Framework/Webapi/Test/Unit/ServiceInputProcessor/SimpleArrayBuilder.php b/lib/internal/Magento/Framework/Webapi/Test/Unit/ServiceInputProcessor/SimpleArrayBuilder.php deleted file mode 100644 index f979b7481dca348de7932d13160ee29aed20b8ae..0000000000000000000000000000000000000000 --- a/lib/internal/Magento/Framework/Webapi/Test/Unit/ServiceInputProcessor/SimpleArrayBuilder.php +++ /dev/null @@ -1,21 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Framework\Webapi\Test\Unit\ServiceInputProcessor; - -use Magento\Framework\Api\ExtensibleObjectBuilder; - -class SimpleArrayBuilder extends ExtensibleObjectBuilder -{ - /** - * @param array $ids - * @return $this - */ - public function setIds($ids) - { - $this->data['ids'] = $ids; - return $this; - } -} diff --git a/lib/internal/Magento/Framework/Webapi/Test/Unit/ServiceInputProcessor/SimpleBuilder.php b/lib/internal/Magento/Framework/Webapi/Test/Unit/ServiceInputProcessor/SimpleBuilder.php deleted file mode 100644 index b10e117f8c68db0655d42a7cbb8fcf45eb310c09..0000000000000000000000000000000000000000 --- a/lib/internal/Magento/Framework/Webapi/Test/Unit/ServiceInputProcessor/SimpleBuilder.php +++ /dev/null @@ -1,31 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Framework\Webapi\Test\Unit\ServiceInputProcessor; - -use Magento\Framework\Api\ExtensibleObjectBuilder; - -class SimpleBuilder extends ExtensibleObjectBuilder -{ - /** - * @param int $id - * @return $this - */ - public function setEntityId($id) - { - $this->data['entityId'] = $id; - return $this; - } - - /** - * @param string $name - * @return $this - */ - public function setName($name) - { - $this->data['name'] = $name; - return $this; - } -} diff --git a/lib/internal/Magento/Framework/Webapi/Test/Unit/ServiceInputProcessor/WebapiBuilderFactory.php b/lib/internal/Magento/Framework/Webapi/Test/Unit/ServiceInputProcessor/WebapiBuilderFactory.php deleted file mode 100644 index 13fa96edf76143e472ccd72441cddf1423a4e8b2..0000000000000000000000000000000000000000 --- a/lib/internal/Magento/Framework/Webapi/Test/Unit/ServiceInputProcessor/WebapiBuilderFactory.php +++ /dev/null @@ -1,28 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Framework\Webapi\Test\Unit\ServiceInputProcessor; - -class WebapiBuilderFactory extends \Magento\Framework\Serialization\DataBuilderFactory -{ - /** - * @param \Magento\Framework\TestFramework\Unit\Helper\ObjectManager $objectManager - */ - public function __construct(\Magento\Framework\TestFramework\Unit\Helper\ObjectManager $objectManager) - { - $this->objectManager = $objectManager; - } - - /** - * Creates builder object - * - * @param $builderClassName - * @return \Magento\Framework\Api\BuilderInterface Builder Instance - */ - protected function createObject($builderClassName) - { - return $this->objectManager->getObject($builderClassName); - } -} diff --git a/lib/internal/Magento/Framework/Webapi/Test/Unit/ServiceInputProcessorTest.php b/lib/internal/Magento/Framework/Webapi/Test/Unit/ServiceInputProcessorTest.php index 0eb9af208ca32fde7757b5f85a4a11929e5b6a00..d53450141ba4310b8f2d69f5a7b82e847dd86778 100644 --- a/lib/internal/Magento/Framework/Webapi/Test/Unit/ServiceInputProcessorTest.php +++ b/lib/internal/Magento/Framework/Webapi/Test/Unit/ServiceInputProcessorTest.php @@ -25,15 +25,20 @@ class ServiceInputProcessorTest extends \PHPUnit_Framework_TestCase protected $serviceInputProcessor; /** @var \PHPUnit_Framework_MockObject_MockObject */ - protected $attributeValueBuilder; + protected $attributeValueFactory; /** @var \PHPUnit_Framework_MockObject_MockObject */ protected $serviceConfigReader; + /** @var \PHPUnit_Framework_MockObject_MockObject */ + protected $objectManagerMock; + public function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $objectFactory = new WebapiBuilderFactory($objectManager); + $this->objectManagerMock = $this->getMockBuilder('\Magento\Framework\ObjectManagerInterface') + ->disableOriginalConstructor() + ->getMock(); /** @var \Magento\Framework\Reflection\TypeProcessor $typeProcessor */ $typeProcessor = $objectManager->getObject('Magento\Framework\Reflection\TypeProcessor'); $cache = $this->getMockBuilder('Magento\Framework\App\Cache\Type\Webapi') @@ -46,16 +51,25 @@ class ServiceInputProcessorTest extends \PHPUnit_Framework_TestCase ->getMock(); /** @var \Magento\Framework\Api\AttributeDataBuilder */ - $this->attributeValueBuilder = $objectManager->getObject('Magento\Framework\Api\AttributeDataBuilder'); + $this->attributeValueFactoryMock = $this->getMockBuilder('Magento\Framework\Api\AttributeValueFactory') + ->disableOriginalConstructor() + ->getMock(); + $this->attributeValueFactoryMock->expects($this->any()) + ->method('create') + ->willReturnCallback( + function () use ($objectManager) { + return $objectManager->getObject('Magento\Framework\Api\AttributeValue'); + } + ); $this->serviceInputProcessor = $objectManager->getObject( 'Magento\Framework\Webapi\ServiceInputProcessor', [ 'typeProcessor' => $typeProcessor, - 'builderFactory' => $objectFactory, + 'objectManager' => $this->objectManagerMock, 'cache' => $cache, 'serviceConfigReader' => $this->serviceConfigReader, - 'attributeValueBuilder' => $this->attributeValueBuilder + 'attributeValueFactory' => $this->attributeValueFactoryMock ] ); } @@ -102,6 +116,12 @@ class ServiceInputProcessorTest extends \PHPUnit_Framework_TestCase public function testNestedDataProperties() { + $this->setupFactory( + [ + 'Magento\Framework\Webapi\Test\Unit\ServiceInputProcessor\Nested', + '\Magento\Framework\Webapi\Test\Unit\ServiceInputProcessor\Simple', + ] + ); $data = ['nested' => ['details' => ['entityId' => 15, 'name' => 'Test']]]; $result = $this->serviceInputProcessor->process( 'Magento\Framework\Webapi\Test\Unit\ServiceInputProcessor\TestService', @@ -144,6 +164,7 @@ class ServiceInputProcessorTest extends \PHPUnit_Framework_TestCase public function testAssociativeArrayProperties() { + $this->setupFactory(['\Magento\Webapi\Service\Entity\Simple']); $data = ['associativeArray' => ['key' => 'value', 'key_two' => 'value_two']]; $result = $this->serviceInputProcessor->process( 'Magento\Framework\Webapi\Test\Unit\ServiceInputProcessor\TestService', @@ -162,6 +183,7 @@ class ServiceInputProcessorTest extends \PHPUnit_Framework_TestCase public function testAssociativeArrayPropertiesWithItem() { + $this->setupFactory(['Magento\Webapi\Service\Entity\AssociativeArray']); $data = ['associativeArray' => ['item' => 'value']]; $result = $this->serviceInputProcessor->process( 'Magento\Framework\Webapi\Test\Unit\ServiceInputProcessor\TestService', @@ -179,6 +201,7 @@ class ServiceInputProcessorTest extends \PHPUnit_Framework_TestCase public function testAssociativeArrayPropertiesWithItemArray() { + $this->setupFactory(['Magento\Webapi\Service\Entity\AssociativeArray']); $data = ['associativeArray' => ['item' => ['value1','value2']]]; $result = $this->serviceInputProcessor->process( 'Magento\Framework\Webapi\Test\Unit\ServiceInputProcessor\TestService', @@ -197,6 +220,11 @@ class ServiceInputProcessorTest extends \PHPUnit_Framework_TestCase public function testArrayOfDataObjectProperties() { + $this->setupFactory( + [ + '\Magento\Framework\Webapi\Test\Unit\ServiceInputProcessor\Simple' + ] + ); $data = [ 'dataObjects' => [ ['entityId' => 14, 'name' => 'First'], @@ -228,6 +256,7 @@ class ServiceInputProcessorTest extends \PHPUnit_Framework_TestCase public function testNestedSimpleArrayProperties() { + $this->setupFactory(['Magento\Framework\Webapi\Test\Unit\ServiceInputProcessor\SimpleArray']); $data = ['arrayData' => ['ids' => [1, 2, 3, 4]]]; $result = $this->serviceInputProcessor->process( 'Magento\Framework\Webapi\Test\Unit\ServiceInputProcessor\TestService', @@ -249,6 +278,7 @@ class ServiceInputProcessorTest extends \PHPUnit_Framework_TestCase public function testNestedAssociativeArrayProperties() { + $this->setupFactory(['Magento\Framework\Webapi\Test\Unit\ServiceInputProcessor\AssociativeArray']); $data = [ 'associativeArrayData' => ['associativeArray' => ['key' => 'value', 'key2' => 'value2']], ]; @@ -272,6 +302,12 @@ class ServiceInputProcessorTest extends \PHPUnit_Framework_TestCase public function testNestedArrayOfDataObjectProperties() { + $this->setupFactory( + [ + 'Magento\Framework\Webapi\Test\Unit\ServiceInputProcessor\DataArray', + '\Magento\Framework\Webapi\Test\Unit\ServiceInputProcessor\Simple', + ] + ); $data = [ 'dataObjects' => [ 'items' => [['entityId' => 1, 'name' => 'First'], ['entityId' => 2, 'name' => 'Second']], @@ -313,6 +349,14 @@ class ServiceInputProcessorTest extends \PHPUnit_Framework_TestCase */ public function testCustomAttributesProperties($customAttributeType, $inputData, $expectedObject) { + $this->setupFactory( + [ + 'Magento\Framework\Webapi\Test\Unit\ServiceInputProcessor\ObjectWithCustomAttributes', + '\Magento\Framework\Webapi\Test\Unit\ServiceInputProcessor\Simple', + 'Magento\Framework\Webapi\Test\Unit\ServiceInputProcessor\Simple', + 'Magento\Framework\Webapi\Test\Unit\ServiceInputProcessor\SimpleArray', + ] + ); $this->serviceConfigReader->expects($this->any())->method('read')->willReturn( [ 'Magento\Framework\Webapi\Test\Unit\ServiceInputProcessor\ObjectWithCustomAttributes' => [ @@ -480,4 +524,26 @@ class ServiceInputProcessorTest extends \PHPUnit_Framework_TestCase ]] ); } + protected function setupFactory(array $classNames) + { + $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); + + $returnValueMap = []; + foreach ($classNames as $className) { + $factoryMock = $this->getMockBuilder($className . 'Factory') + ->setMethods(['create']) + ->getMock(); + $factoryMock->expects($this->any()) + ->method('create') + ->willReturnCallback( + function () use ($objectManager, $className) { + return $objectManager->getObject($className); + } + ); + $returnValueMap[] = [$className . 'Factory', $factoryMock]; + } + $this->objectManagerMock->expects($this->any()) + ->method('get') + ->will($this->returnValueMap($returnValueMap)); + } } diff --git a/setup/pub/magento/setup/add-database.js b/setup/pub/magento/setup/add-database.js index b6dde9b8caf56179eb66b6c1cbab057e13bb5e60..af4e87b7680d3443883e569c3518ba96b1d0d3f9 100644 --- a/setup/pub/magento/setup/add-database.js +++ b/setup/pub/magento/setup/add-database.js @@ -22,9 +22,12 @@ angular.module('add-database', ['ngStorage']) $http.post('index.php/database-check', $scope.db) .success(function (data) { $scope.testConnection.result = data; - if (!(($scope.testConnection.result !== undefined) && (!$scope.testConnection.result.success))) { + if ($scope.testConnection.result.success) { $scope.nextState(); } + }) + .error(function (data) { + $scope.testConnection.failed = data; }); }; diff --git a/setup/pub/magento/setup/readiness-check.js b/setup/pub/magento/setup/readiness-check.js index 2c46b35064292264e2a117a23a22d0e4bda4b4f5..d7c0eb243e2fccce768b7eec41e4b5b414ca7584 100644 --- a/setup/pub/magento/setup/readiness-check.js +++ b/setup/pub/magento/setup/readiness-check.js @@ -32,6 +32,11 @@ angular.module('readiness-check', []) processed: false, expanded: false }; + $scope.rawpost = { + visible: false, + processed: false, + expanded: false + }; $scope.extensions = { visible: false, processed: false, @@ -57,6 +62,19 @@ angular.module('readiness-check', []) $scope.stopProgress(); } }, + 'php-rawpost': { + url:'index.php/environment/php-rawpost', + show: function() { + $scope.startProgress(); + $scope.rawpost.visible = true; + }, + process: function(data) { + $scope.rawpost.processed = true; + angular.extend($scope.rawpost, data); + $scope.updateOnProcessed($scope.rawpost.responseType); + $scope.stopProgress(); + } + }, 'php-extensions': { url:'index.php/environment/php-extensions', show: function() { diff --git a/setup/src/Magento/Setup/Controller/ConsoleController.php b/setup/src/Magento/Setup/Controller/ConsoleController.php index 1e59a5e9db82533a6f3c37c0dc8e38003ef265da..58bf6d31f91660d2b24cb931f7dbd809adf7ca2c 100644 --- a/setup/src/Magento/Setup/Controller/ConsoleController.php +++ b/setup/src/Magento/Setup/Controller/ConsoleController.php @@ -317,6 +317,8 @@ class ConsoleController extends AbstractActionController $this->installer = $installerFactory->create($consoleLogger); $this->maintenanceMode = $maintenanceMode; $this->objectManagerProvider = $objectManagerProvider; + // By default we use our customized error handler, but for CLI we want to display all errors + restore_error_handler(); } /** @@ -405,6 +407,7 @@ class ConsoleController extends AbstractActionController */ public function updateAction() { + $this->installer->updateModulesSequence(); $this->installer->installSchema(); $this->installer->installDataFixtures(); } diff --git a/setup/src/Magento/Setup/Controller/Environment.php b/setup/src/Magento/Setup/Controller/Environment.php index 07dc89aff7db5eec32e2e8ae73f7bffc7f089f2c..8b93843046fb95d46f2abc1558a43f586fac0e47 100644 --- a/setup/src/Magento/Setup/Controller/Environment.php +++ b/setup/src/Magento/Setup/Controller/Environment.php @@ -87,6 +87,29 @@ class Environment extends AbstractActionController return new JsonModel($data); } + /** + * Checks if PHP version >= 5.6.0 and always_populate_raw_post_data is set + * + * @return JsonModel + */ + public function phpRawpostAction() + { + $iniSetting = ini_get('always_populate_raw_post_data'); + $responseType = ResponseTypeInterface::RESPONSE_TYPE_SUCCESS; + if (version_compare(PHP_VERSION, '5.6.0') >= 0 && (int)$iniSetting > -1) { + $responseType = ResponseTypeInterface::RESPONSE_TYPE_ERROR; + } + $data = [ + 'responseType' => $responseType, + 'data' => [ + 'version' => PHP_VERSION, + 'ini' => ini_get('always_populate_raw_post_data') + ] + ]; + + return new JsonModel($data); + } + /** * Verifies php verifications * diff --git a/setup/src/Magento/Setup/Model/Installer.php b/setup/src/Magento/Setup/Model/Installer.php index aaac7d81ac2e8f9fd85973faaa53170d317df449..0b2772d9f45c4684f7baeab5b7dd3f1c063d35a9 100644 --- a/setup/src/Magento/Setup/Model/Installer.php +++ b/setup/src/Magento/Setup/Model/Installer.php @@ -13,12 +13,14 @@ use Magento\Framework\App\DeploymentConfig\InstallConfig; use Magento\Framework\App\DeploymentConfig\ResourceConfig; use Magento\Framework\App\DeploymentConfig\SessionConfig; use Magento\Framework\App\DeploymentConfig\Writer; +use Magento\Framework\App\DeploymentConfig\Reader; use Magento\Framework\App\Filesystem\DirectoryList; use Magento\Framework\App\MaintenanceMode; use Magento\Framework\Filesystem; use Magento\Framework\Filesystem\FilesystemException; use Magento\Framework\Math\Random; use Magento\Framework\Module\ModuleList\DeploymentConfig; +use Magento\Framework\Module\ModuleList\DeploymentConfigFactory; use Magento\Framework\Module\ModuleList\Loader as ModuleLoader; use Magento\Framework\Module\ModuleListInterface; use Magento\Framework\Shell; @@ -102,6 +104,13 @@ class Installer */ private $deploymentConfigWriter; + /** + * Deployment configuration reader + * + * @var Writer + */ + private $deploymentConfigReader; + /** * Module list * @@ -109,6 +118,13 @@ class Installer */ private $moduleList; + /** + * Factory for module deployment config + * + * @var DeploymentConfigFactory + */ + private $deploymentConfigFactory; + /** * Module list loader * @@ -211,7 +227,9 @@ class Installer * * @param FilePermissions $filePermissions * @param Writer $deploymentConfigWriter + * @param Reader $deploymentConfigReader * @param \Magento\Framework\App\DeploymentConfig $deploymentConfig + * @param DeploymentConfigFactory $deploymentConfigFactory * @param ModuleListInterface $moduleList * @param ModuleLoader $moduleLoader * @param DirectoryList $directoryList @@ -230,7 +248,9 @@ class Installer public function __construct( FilePermissions $filePermissions, Writer $deploymentConfigWriter, + Reader $deploymentConfigReader, \Magento\Framework\App\DeploymentConfig $deploymentConfig, + DeploymentConfigFactory $deploymentConfigFactory, ModuleListInterface $moduleList, ModuleLoader $moduleLoader, DirectoryList $directoryList, @@ -246,6 +266,8 @@ class Installer ) { $this->filePermissions = $filePermissions; $this->deploymentConfigWriter = $deploymentConfigWriter; + $this->deploymentConfigReader = $deploymentConfigReader; + $this->deploymentConfigFactory = $deploymentConfigFactory; $this->moduleList = $moduleList; $this->moduleLoader = $moduleLoader; $this->directoryList = $directoryList; @@ -336,7 +358,7 @@ class Installer $key = array_search($module, $toEnable); $result[$module] = false !== $key; } - return new DeploymentConfig($result); + return $this->deploymentConfigFactory->create($result); } /** @@ -786,6 +808,33 @@ class Installer $adminAccount->save(); } + /** + * Updates modules in deployment configuration + * + * @return void + */ + public function updateModulesSequence() + { + $this->assertDeploymentConfigExists(); + $this->log->log('File system cleanup:'); + $this->deleteDirContents(DirectoryList::GENERATION); + $this->deleteDirContents(DirectoryList::CACHE); + $this->log->log('Updating modules:'); + $allModules = array_keys($this->moduleLoader->load()); + $deploymentConfig = $this->deploymentConfigReader->load(); + $currentModules = isset($deploymentConfig['modules']) ? $deploymentConfig['modules'] : [] ; + $result = []; + foreach ($allModules as $module) { + if (isset($currentModules[$module]) && !$currentModules[$module]) { + $result[$module] = 0; + } else { + $result[$module] = 1; + } + } + $segment = $this->deploymentConfigFactory->create($result); + $this->deploymentConfigWriter->update($segment); + } + /** * Uninstall Magento application * diff --git a/setup/src/Magento/Setup/Model/InstallerFactory.php b/setup/src/Magento/Setup/Model/InstallerFactory.php index 826c37a97841d6d417b959e1cab2298e0f933d84..6ed7fbb8d3019080ed16fa3404780f1fbc14947b 100644 --- a/setup/src/Magento/Setup/Model/InstallerFactory.php +++ b/setup/src/Magento/Setup/Model/InstallerFactory.php @@ -8,6 +8,7 @@ namespace Magento\Setup\Model; use Zend\ServiceManager\ServiceLocatorInterface; use Magento\Setup\Module\ResourceFactory; +use Magento\Framework\App\ErrorHandler; class InstallerFactory { @@ -33,6 +34,9 @@ class InstallerFactory { $this->serviceLocator = $serviceLocator; $this->resourceFactory = $resourceFactory; + // For Setup Wizard we are using our customized error handler + $handler = new ErrorHandler(); + set_error_handler([$handler, 'handler']); } /** @@ -46,7 +50,9 @@ class InstallerFactory return new Installer( $this->serviceLocator->get('Magento\Setup\Model\FilePermissions'), $this->serviceLocator->get('Magento\Framework\App\DeploymentConfig\Writer'), + $this->serviceLocator->get('Magento\Framework\App\DeploymentConfig\Reader'), $this->serviceLocator->get('Magento\Framework\App\DeploymentConfig'), + $this->serviceLocator->get('Magento\Framework\Module\ModuleList\DeploymentConfigFactory'), $this->serviceLocator->get('Magento\Framework\Module\ModuleList'), $this->serviceLocator->get('Magento\Framework\Module\ModuleList\Loader'), $this->serviceLocator->get('Magento\Framework\App\Filesystem\DirectoryList'), diff --git a/setup/src/Magento/Setup/Test/Unit/Controller/ConsoleControllerTest.php b/setup/src/Magento/Setup/Test/Unit/Controller/ConsoleControllerTest.php index 098be45fdb17f73af2168e26981f8a0f825905b0..06d50d55d388e6a390971e730228fcf82aa97da1 100644 --- a/setup/src/Magento/Setup/Test/Unit/Controller/ConsoleControllerTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Controller/ConsoleControllerTest.php @@ -165,8 +165,9 @@ class ConsoleControllerTest extends \PHPUnit_Framework_TestCase public function testUpdateAction() { - $this->installer->expects($this->once())->method('installSchema'); - $this->installer->expects($this->once())->method('installDataFixtures'); + $this->installer->expects($this->at(0))->method('updateModulesSequence'); + $this->installer->expects($this->at(1))->method('installSchema'); + $this->installer->expects($this->at(2))->method('installDataFixtures'); $this->controller->updateAction(); } diff --git a/setup/src/Magento/Setup/Test/Unit/Model/InstallerFactoryTest.php b/setup/src/Magento/Setup/Test/Unit/Model/InstallerFactoryTest.php index 19746c6b5d179a20d4de2eee695158caa001134d..bde3f74878cf367016ef7884bb1356f491079e37 100644 --- a/setup/src/Magento/Setup/Test/Unit/Model/InstallerFactoryTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Model/InstallerFactoryTest.php @@ -21,6 +21,10 @@ class InstallerFactoryTest extends \PHPUnit_Framework_TestCase 'Magento\Framework\App\DeploymentConfig\Writer', $this->getMock('Magento\Framework\App\DeploymentConfig\Writer', [], [], '', false), ], + [ + 'Magento\Framework\App\DeploymentConfig\Reader', + $this->getMock('Magento\Framework\App\DeploymentConfig\Reader', [], [], '', false), + ], [ 'Magento\Framework\App\DeploymentConfig', $this->getMock('Magento\Framework\App\DeploymentConfig', [], [], '', false), @@ -29,6 +33,10 @@ class InstallerFactoryTest extends \PHPUnit_Framework_TestCase 'Magento\Setup\Module\Setup', $this->getMock('Magento\Setup\Module\Setup', [], [], '', false), ], + [ + 'Magento\Framework\Module\ModuleList\DeploymentConfigFactory', + $this->getMock('Magento\Framework\Module\ModuleList\DeploymentConfigFactory', [], [], '', false), + ], [ 'Magento\Framework\Module\ModuleList', $this->getMock('Magento\Framework\Module\ModuleList', [], [], '', false), diff --git a/setup/src/Magento/Setup/Test/Unit/Model/InstallerTest.php b/setup/src/Magento/Setup/Test/Unit/Model/InstallerTest.php index 1343dc2151c7b4afd1b7af5d9113b4673d7d0c42..b780bb25a335ac92aa8c0808d7acb6c5e0d265ab 100644 --- a/setup/src/Magento/Setup/Test/Unit/Model/InstallerTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Model/InstallerTest.php @@ -35,6 +35,11 @@ class InstallerTest extends \PHPUnit_Framework_TestCase */ private $configWriter; + /** + * @var \Magento\Framework\App\DeploymentConfig\Reader|\PHPUnit_Framework_MockObject_MockObject + */ + private $configReader; + /** * @var \Magento\Framework\App\DeploymentConfig|\PHPUnit_Framework_MockObject_MockObject */ @@ -50,6 +55,16 @@ class InstallerTest extends \PHPUnit_Framework_TestCase */ private $moduleLoader; + /** + * @var \Magento\Framework\Module\ModuleList\DeploymentConfigFactory|\PHPUnit_Framework_MockObject_MockObject + */ + private $deploymentConfigFactory; + + /** + * @var \Magento\Framework\Module\ModuleList\DeploymentConfig|\PHPUnit_Framework_MockObject_MockObject + */ + private $deploymentConfig; + /** * @var \Magento\Framework\App\Filesystem\DirectoryList|\PHPUnit_Framework_MockObject_MockObject */ @@ -121,6 +136,7 @@ class InstallerTest extends \PHPUnit_Framework_TestCase { $this->filePermissions = $this->getMock('Magento\Setup\Model\FilePermissions', [], [], '', false); $this->configWriter = $this->getMock('Magento\Framework\App\DeploymentConfig\Writer', [], [], '', false); + $this->configReader = $this->getMock('Magento\Framework\App\DeploymentConfig\Reader', [], [], '', false); $this->config = $this->getMock('Magento\Framework\App\DeploymentConfig', [], [], '', false); $this->moduleList = $this->getMockForAbstractClass('Magento\Framework\Module\ModuleListInterface'); @@ -131,11 +147,20 @@ class InstallerTest extends \PHPUnit_Framework_TestCase ['Foo_One', 'Bar_Two'] ); $this->moduleLoader = $this->getMock('Magento\Framework\Module\ModuleList\Loader', [], [], '', false); - $allModules = [ - 'Foo_One' => [], - 'Bar_Two' => [], - ]; - $this->moduleLoader->expects($this->any())->method('load')->willReturn($allModules); + $this->deploymentConfigFactory = $this->getMock( + 'Magento\Framework\Module\ModuleList\DeploymentConfigFactory', + [], + [], + '', + false + ); + $this->deploymentConfig = $this->getMock( + 'Magento\Framework\Module\ModuleList\DeploymentConfig', + [], + [], + '', + false + ); $this->directoryList = $this->getMock('Magento\Framework\App\Filesystem\DirectoryList', [], [], '', false); $this->adminFactory = $this->getMock('Magento\Setup\Model\AdminAccountFactory', [], [], '', false); $this->logger = $this->getMockForAbstractClass('Magento\Setup\Model\LoggerInterface'); @@ -166,10 +191,13 @@ class InstallerTest extends \PHPUnit_Framework_TestCase $objectManagerProvider = $this->getMock('Magento\Setup\Model\ObjectManagerProvider', [], [], '', false); $objectManagerProvider->expects($this->any())->method('get')->willReturn($this->objectManager); } + return new Installer( $this->filePermissions, $this->configWriter, + $this->configReader, $this->config, + $this->deploymentConfigFactory, $this->moduleList, $this->moduleLoader, $this->directoryList, @@ -199,7 +227,12 @@ class InstallerTest extends \PHPUnit_Framework_TestCase [DbConfig::CONFIG_KEY, self::$dbConfig], [EncryptConfig::CONFIG_KEY, [EncryptConfig::KEY_ENCRYPTION_KEY => 'encryption_key']] ])); - + $allModules = ['Foo_One' => [], 'Bar_Two' => []]; + $this->moduleLoader->expects($this->any())->method('load')->willReturn($allModules); + $modules = ['Foo_One' => 1, 'Bar_Two' => 1 ]; + $this->deploymentConfig->expects($this->any())->method('getData')->willReturn($modules); + $this->deploymentConfigFactory->expects($this->any())->method('create')->with($modules) + ->willReturn($this->deploymentConfig); $setup = $this->getMock('Magento\Setup\Module\Setup', [], [], '', false); $table = $this->getMock('Magento\Framework\DB\Ddl\Table', [], [], '', false); $connection = $this->getMockForAbstractClass('Magento\Framework\DB\Adapter\AdapterInterface'); @@ -285,6 +318,43 @@ class InstallerTest extends \PHPUnit_Framework_TestCase $this->assertSame(['message' => [$expectedMessage]], $this->object->getInstallInfo()); } + public function testUpdateModulesSequence() + { + $varDir = $this->getMockForAbstractClass('Magento\Framework\Filesystem\Directory\WriteInterface'); + $varDir->expects($this->exactly(2))->method('getAbsolutePath')->willReturn('/var'); + $this->filesystem + ->expects($this->exactly(2)) + ->method('getDirectoryWrite') + ->willReturn($varDir); + + $allModules = [ + 'Foo_One' => [], + 'Bar_Two' => [], + 'New_Module' => [], + ]; + $this->moduleLoader->expects($this->once())->method('load')->willReturn($allModules); + + $expectedModules = [ + 'Bar_Two' => 0, + 'Foo_One' => 1, + 'New_Module' => 1 + ]; + + $this->config->expects($this->atLeastOnce())->method('isAvailable')->willReturn(true); + $this->deploymentConfigFactory->expects($this->once())->method('create')->with($expectedModules) + ->willReturn($this->deploymentConfig); + + $newObject = $this->createObject(false, false); + $this->configReader->expects($this->once())->method('load') + ->willReturn(['modules' => ['Bar_Two' => 0, 'Foo_One' => 1, 'Old_Module' => 0] ]); + $this->configWriter->expects($this->once())->method('update')->with($this->deploymentConfig); + $this->logger->expects($this->at(0))->method('log')->with('File system cleanup:'); + $this->logger->expects($this->at(1))->method('log') + ->with('The directory \'/var\' doesn\'t exist - skipping cleanup'); + $this->logger->expects($this->at(3))->method('log')->with('Updating modules:'); + $newObject->updateModulesSequence(); + } + public function testUninstall() { $this->config->expects($this->once())->method('isAvailable')->willReturn(false); diff --git a/setup/view/magento/setup/add-database.phtml b/setup/view/magento/setup/add-database.phtml index 89606123cdf98a39f0c62580a489ba9f1ab2b68a..7f3091734e0db60c20ff7f1b4cfc21b3ba0623bd 100644 --- a/setup/view/magento/setup/add-database.phtml +++ b/setup/view/magento/setup/add-database.phtml @@ -42,9 +42,9 @@ </div> <div class="message message-error" - ng-show="testConnection.result.success === undefined && testConnection.result !== undefined" + ng-show="testConnection.failed !== undefined" > - <span class="message-text">Unknown Database Server Host.</span> + <span class="message-text">{{testConnection.failed}}</span> </div> <form diff --git a/setup/view/magento/setup/readiness-check/progress.phtml b/setup/view/magento/setup/readiness-check/progress.phtml index 34ee9207b59a00ace2ddbf7b9eb55a62b12ba49e..275d677b1c8795c019e4122da50dd8274a775de2 100644 --- a/setup/view/magento/setup/readiness-check/progress.phtml +++ b/setup/view/magento/setup/readiness-check/progress.phtml @@ -86,6 +86,58 @@ </div> +<div id="php-rawpost" class="rediness-check-item" ng-show="rawpost.visible"> + + <h3 class="readiness-check-title" ng-hide="version.processed"> + Checking PHP Settings... + </h3> + + <div ng-show="rawpost.processed" ng-switch="rawpost.responseType"> + + <div ng-switch-when="success" ng-init="updateOnSuccess(rawpost)"> + + <span class="readiness-check-icon icon-success-round"></span> + + <div class="readiness-check-content"> + <h3 class="readiness-check-title">PHP Settings Check</h3> + <p> + Your PHP setting is correct. + </p> + </div> + + </div> + + <div class="readiness-check-item" ng-switch-default ng-init="updateOnError(rawpost)"> + + <div class="rediness-check-side"> + <p class="side-title">Need Help?</p> + <a href="http://php.net/manual/en/ini.core.php#ini.always-populate-raw-post-data" target="_blank">PHP Documentation</a> + </div> + + <span class="readiness-check-icon icon-failed-round"></span> + + <div class="readiness-check-content"> + <h3 class="readiness-check-title">PHP Settings Check</h3> + <p> + Your PHP Version is {{rawpost.data.version}}, but always_populate_raw_post_data = {{rawpost.data.ini}}. + <a href="#php-rawpost" ng-click="updateOnExpand(rawpost)"> + <span ng-hide="rawpost.expanded">Show detail</span> + <span ng-show="rawpost.expanded">Hide detail</span> + </a> + </p> + <p ng-show="rawpost.expanded"> + $HTTP_RAW_POST_DATA is deprecated from PHP 5.6 onwards and will stop the installer from running. + Please open your php.ini file and set always_populate_raw_post_data to -1. + </p> + <p ng-show="rawpost.expanded">If you need more help please call your hosting provider.</p> + </div> + + </div> + + </div> + +</div> + <div id="php-extensions" class="rediness-check-item" ng-show="extensions.visible"> <h3 ng-hide="extensions.processed" class="readiness-check-title">