当前位置: 首页>>代码示例>>PHP>>正文


PHP Config::expects方法代码示例

本文整理汇总了PHP中Magento\Eav\Model\Config::expects方法的典型用法代码示例。如果您正苦于以下问题:PHP Config::expects方法的具体用法?PHP Config::expects怎么用?PHP Config::expects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Magento\Eav\Model\Config的用法示例。


在下文中一共展示了Config::expects方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testLike

 /**
  * Test a search using 'like' condition
  */
 public function testLike()
 {
     $attributeCode = 'description';
     $attributeCodeId = 42;
     $attribute = $this->getMock('Magento\\Catalog\\Model\\ResourceModel\\Eav\\Attribute', [], [], '', false);
     $attribute->expects($this->once())->method('getAttributeCode')->willReturn($attributeCode);
     $this->eavConfig->expects($this->once())->method('getAttribute')->with(Product::ENTITY, $attributeCodeId)->willReturn($attribute);
     $filtersData = ['catalog_product_entity_text' => [$attributeCodeId => ['like' => 'search text']]];
     $this->filterBuilder->expects($this->once())->method('setField')->with($attributeCode)->willReturn($this->filterBuilder);
     $this->filterBuilder->expects($this->once())->method('setValue')->with('search text')->willReturn($this->filterBuilder);
     $filter = $this->getMock('Magento\\Framework\\Api\\Filter');
     $this->filterBuilder->expects($this->once())->method('create')->willReturn($filter);
     $criteria = $this->getMock('Magento\\Framework\\Api\\Search\\SearchCriteria', [], [], '', false);
     $this->criteriaBuilder->expects($this->once())->method('create')->willReturn($criteria);
     $criteria->expects($this->once())->method('setRequestName')->with('advanced_search_container');
     $tempTable = $this->getMock('Magento\\Framework\\DB\\Ddl\\Table', [], [], '', false);
     $temporaryStorage = $this->getMock('Magento\\Framework\\Search\\Adapter\\Mysql\\TemporaryStorage', [], [], '', false);
     $temporaryStorage->expects($this->once())->method('storeApiDocuments')->willReturn($tempTable);
     $this->temporaryStorageFactory->expects($this->once())->method('create')->willReturn($temporaryStorage);
     $searchResult = $this->getMock('Magento\\Framework\\Api\\Search\\SearchResultInterface', [], [], '', false);
     $this->search->expects($this->once())->method('search')->willReturn($searchResult);
     // addFieldsToFilter will load filters,
     //   then loadWithFilter will trigger _renderFiltersBefore code in Advanced/Collection
     $this->assertSame($this->advancedCollection, $this->advancedCollection->addFieldsToFilter($filtersData)->loadWithFilter());
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:28,代码来源:CollectionTest.php

示例2: testAfterSave

 public function testAfterSave()
 {
     $value = true;
     $attributeMock = $this->getMockBuilder('Magento\\Eav\\Model\\Entity\\Attribute\\AbstractAttribute')->setMethods(['save', 'setData'])->disableOriginalConstructor()->getMockForAbstractClass();
     $this->eavConfigMock->expects($this->once())->method('getAttribute')->with('customer', 'disable_auto_group_change')->willReturn($attributeMock);
     $attributeMock->expects($this->once())->method('setData')->with('default_value', $value);
     $attributeMock->expects($this->once())->method('save');
     $this->model->setValue($value);
     $this->assertEquals($this->model, $this->model->afterSave());
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:10,代码来源:DisableAutoGroupAssignDefaultTest.php

示例3: setUp

 protected function setUp()
 {
     $this->searchBuilderMock = $this->getMock('Magento\\Framework\\Api\\SearchCriteriaBuilder', [], [], '', false);
     $this->filterBuilderMock = $this->getMock('Magento\\Framework\\Api\\FilterBuilder', [], [], '', false);
     $this->attributeRepositoryMock = $this->getMock('Magento\\Eav\\Api\\AttributeRepositoryInterface', [], [], '', false);
     $this->searchResultMock = $this->getMock('Magento\\Framework\\Api\\SearchResultsInterface', ['getItems', 'getSearchCriteria', 'getTotalCount', 'setItems', 'setSearchCriteria', 'setTotalCount', '__wakeup'], [], '', false);
     $this->eavConfigMock = $this->getMock('Magento\\Eav\\Model\\Config', [], [], '', false);
     $this->eavConfigMock->expects($this->any())->method('getEntityType')->willReturn(new \Magento\Framework\DataObject(['default_attribute_set_id' => 3]));
     $this->model = (new ObjectManager($this))->getObject('Magento\\Catalog\\Model\\Category\\AttributeRepository', ['searchCriteriaBuilder' => $this->searchBuilderMock, 'filterBuilder' => $this->filterBuilderMock, 'eavAttributeRepository' => $this->attributeRepositoryMock, 'eavConfig' => $this->eavConfigMock]);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:10,代码来源:AttributeRepositoryTest.php

示例4: testAfterGetUsedProductCollection

 public function testAfterGetUsedProductCollection()
 {
     $subject = $this->getMock('\\Magento\\ConfigurableProduct\\Model\\Product\\Type\\Configurable', [], [], '', false);
     $result = $this->getMock('\\Magento\\ConfigurableProduct\\Model\\ResourceModel\\Product\\Type\\Configurable\\Product\\Collection', ['getEntity', 'addAttributeToSelect'], [], '', false);
     $collectionEntity = $this->getMock('\\Magento\\Eav\\Model\\Entity\\Collection\\AbstractCollection', ['getType'], [], '', false);
     $collectionEntity->expects($this->once())->method('getType')->willReturn('catalog');
     $result->expects($this->once())->method('getEntity')->willReturn($collectionEntity);
     $attribute = $this->getMock('\\Magento\\Catalog\\Model\\ResourceModel\\Eav\\Attribute', [], [], '', false);
     $this->eavConfig->expects($this->once())->method('getEntityAttributeCodes')->with('catalog')->willReturn(['size', 'color', 'swatch1']);
     $this->eavConfig->expects($this->exactly(3))->method('getAttribute')->willReturn($attribute);
     $this->swatchHelper->expects($this->exactly(3))->method('isVisualSwatch')->with($attribute)->willReturn(true);
     $result->expects($this->once())->method('addAttributeToSelect')->with($this->identicalTo(['image', 'size', 'color', 'swatch1']))->willReturn($result);
     $result = $this->pluginModel->afterGetUsedProductCollection($subject, $result);
     $this->assertInstanceOf('\\Magento\\ConfigurableProduct\\Model\\ResourceModel\\Product\\Type\\Configurable\\Product\\Collection', $result);
 }
开发者ID:rafaelstz,项目名称:magento2,代码行数:15,代码来源:ConfigurableTest.php

示例5: testAddDynamicDataWithStaticAndFilterable

 /**
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 public function testAddDynamicDataWithStaticAndFilterable()
 {
     $existentName = 'field';
     $existentField = ['name' => $existentName, 'handler' => 'handler', 'origin' => $existentName, 'type' => 'type', 'filters' => ['filter'], 'dataType' => 'data_type'];
     $data = ['fields' => [$existentName => $existentField], 'references' => ['customer' => ['to' => 'to_field']]];
     $attrName = $existentName;
     $attrBackendType = 'varchar';
     $attrFrontendInput = 'text';
     /** @var \Magento\Eav\Model\Entity\Type|\PHPUnit_Framework_MockObject_MockObject $collectionMock $entityType */
     $entityType = $this->getMockBuilder('Magento\\Eav\\Model\\Entity\\Type')->disableOriginalConstructor()->getMock();
     /** @var Collection|\PHPUnit_Framework_MockObject_MockObject $collectionMock */
     $collectionMock = $this->getMockBuilder('Magento\\Eav\\Model\\ResourceModel\\Entity\\Attribute\\Collection')->disableOriginalConstructor()->getMock();
     /** @var \Magento\Customer\Model\ResourceModel\Customer|\PHPUnit_Framework_MockObject_MockObject $entity */
     $entity = $this->getMockBuilder('Magento\\Customer\\Model\\ResourceModel\\Customer')->disableOriginalConstructor()->getMock();
     /** @var \Magento\Customer\Model\Attribute|\PHPUnit_Framework_MockObject_MockObject $attribute */
     $attribute = $this->getMockBuilder('Magento\\Customer\\Model\\Attribute')->disableOriginalConstructor()->setMethods(['setEntity', 'getName', 'getFrontendInput', 'getBackendType', 'canBeSearchableInGrid', 'canBeFilterableInGrid', 'getData'])->getMock();
     $this->eavConfig->expects($this->once())->method('getEntityType')->with(Customer::ENTITY)->willReturn($entityType);
     $entityType->expects($this->once())->method('getAttributeCollection')->willReturn($collectionMock);
     $collectionMock->expects($this->once())->method('getItems')->willReturn([$attribute]);
     $entityType->expects($this->once())->method('getEntity')->willReturn($entity);
     $attribute->expects($this->once())->method('setEntity')->with($entity)->willReturnSelf();
     $attribute->expects($this->exactly(3))->method('getName')->willReturn($attrName);
     $attribute->expects($this->any())->method('getFrontendInput')->willReturn($attrFrontendInput);
     $attribute->expects($this->any())->method('getBackendType')->willReturn($attrBackendType);
     $attribute->expects($this->any())->method('canBeSearchableInGrid')->willReturn(false);
     $attribute->expects($this->any())->method('canBeFilterableInGrid')->willReturn(true);
     $attribute->expects($this->any())->method('getData')->willReturnMap([['is_used_in_grid', null, true]]);
     $this->assertEquals(['fields' => [$attrName => ['name' => $attrName, 'handler' => 'Magento\\Framework\\Indexer\\Handler\\AttributeHandler', 'origin' => $attrName, 'type' => 'filterable', 'filters' => [], 'dataType' => 'varchar', 'entity' => Customer::ENTITY, 'bind' => 'to_field']], 'references' => ['customer' => ['to' => 'to_field']]], $this->object->addDynamicData($data));
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:32,代码来源:AttributeProviderTest.php

示例6: setUp

 protected function setUp()
 {
     parent::setUp();
     $this->eavConfigMock = $this->getMockBuilder(Config::class)->disableOriginalConstructor()->getMock();
     $this->eavValidationRulesMock = $this->getMockBuilder(EavValidationRules::class)->disableOriginalConstructor()->getMock();
     $this->requestMock = $this->getMockBuilder(RequestInterface::class)->getMockForAbstractClass();
     $this->groupCollectionFactoryMock = $this->getMockBuilder(GroupCollectionFactory::class)->disableOriginalConstructor()->setMethods(['create'])->getMock();
     $this->groupCollectionMock = $this->getMockBuilder(GroupCollection::class)->disableOriginalConstructor()->getMock();
     $this->attributeMock = $this->getMockBuilder(EavAttribute::class)->disableOriginalConstructor()->getMock();
     $this->groupMock = $this->getMockBuilder(Group::class)->disableOriginalConstructor()->setMethods(['getAttributeGroupCode'])->getMock();
     $this->entityTypeMock = $this->getMockBuilder(EntityType::class)->disableOriginalConstructor()->getMock();
     $this->attributeCollectionMock = $this->getMockBuilder(AttributeCollection::class)->disableOriginalConstructor()->getMock();
     $this->storeManagerMock = $this->getMockBuilder(StoreManagerInterface::class)->getMockForAbstractClass();
     $this->formElementMapperMock = $this->getMockBuilder(FormElementMapper::class)->disableOriginalConstructor()->getMock();
     $this->metaPropertiesMapperMock = $this->getMockBuilder(MetaPropertiesMapper::class)->disableOriginalConstructor()->getMock();
     $this->groupCollectionFactoryMock->expects($this->any())->method('create')->willReturn($this->groupCollectionMock);
     $this->groupCollectionMock->expects($this->any())->method('setAttributeSetFilter')->willReturnSelf();
     $this->groupCollectionMock->expects($this->any())->method('setSortOrder')->willReturnSelf();
     $this->groupCollectionMock->expects($this->any())->method('load')->willReturnSelf();
     $this->groupCollectionMock->expects($this->any())->method('getIterator')->willReturn(new \ArrayIterator([$this->groupMock]));
     $this->attributeCollectionMock->expects($this->any())->method('addFieldToSelect')->willReturnSelf();
     $this->attributeCollectionMock->expects($this->any())->method('load')->willReturnSelf();
     $this->eavConfigMock->expects($this->any())->method('getEntityType')->willReturn($this->entityTypeMock);
     $this->entityTypeMock->expects($this->any())->method('getAttributeCollection')->willReturn($this->attributeCollectionMock);
     $this->productMock->expects($this->any())->method('getAttributes')->willReturn([$this->attributeMock]);
 }
开发者ID:BlackIkeEagle,项目名称:magento2-continuousphp,代码行数:26,代码来源:EavTest.php

示例7: setUp

 /**
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 protected function setUp()
 {
     $this->productFactoryMock = $this->getMock('Magento\\Catalog\\Model\\ProductFactory', ['create'], [], '', false);
     $this->productMock = $this->getMock('Magento\\Catalog\\Model\\Product', [], [], '', false);
     $this->initializedProductMock = $this->getMock('Magento\\Catalog\\Model\\Product', ['setProductOptions', 'load', 'getOptions', 'getSku', 'getGalleryAttributeBackend', 'getMediaConfig', 'getMediaAttributes', 'getProductLinks', 'setProductLinks'], [], '', false);
     $this->filterBuilderMock = $this->getMock('\\Magento\\Framework\\Api\\FilterBuilder', [], [], '', false);
     $this->initializationHelperMock = $this->getMock('\\Magento\\Catalog\\Controller\\Adminhtml\\Product\\Initialization\\Helper', [], [], '', false);
     $this->collectionFactoryMock = $this->getMock('\\Magento\\Catalog\\Model\\Resource\\Product\\CollectionFactory', ['create'], [], '', false);
     $this->searchCriteriaBuilderMock = $this->getMock('\\Magento\\Framework\\Api\\SearchCriteriaBuilder', [], [], '', false);
     $this->metadataServiceMock = $this->getMock('\\Magento\\Catalog\\Api\\ProductAttributeRepositoryInterface', [], [], '', false);
     $this->searchResultsFactoryMock = $this->getMock('\\Magento\\Catalog\\Api\\Data\\ProductSearchResultsInterfaceFactory', ['create'], [], '', false);
     $this->resourceModelMock = $this->getMock('\\Magento\\Catalog\\Model\\Resource\\Product', [], [], '', false);
     $this->eavConfigMock = $this->getMock('Magento\\Eav\\Model\\Config', [], [], '', false);
     $this->eavConfigMock->expects($this->any())->method('getEntityType')->willReturn(new \Magento\Framework\Object(['default_attribute_set_id' => 4]));
     $this->objectManager = new ObjectManager($this);
     $this->extensibleDataObjectConverterMock = $this->getMockBuilder('\\Magento\\Framework\\Api\\ExtensibleDataObjectConverter')->setMethods(['toNestedArray'])->disableOriginalConstructor()->getMock();
     $this->fileSystemMock = $this->getMockBuilder('\\Magento\\Framework\\Filesystem')->disableOriginalConstructor()->getMock();
     $this->mimeTypeExtensionMapMock = $this->getMockBuilder('Magento\\Catalog\\Model\\Product\\Gallery\\MimeTypeExtensionMap')->getMock();
     $this->contentFactoryMock = $this->getMock('Magento\\Framework\\Api\\Data\\ImageContentInterfaceFactory', ['create'], [], '', false);
     $this->contentValidatorMock = $this->getMockBuilder('Magento\\Framework\\Api\\ImageContentValidatorInterface')->disableOriginalConstructor()->getMock();
     $optionConverter = $this->objectManager->getObject('Magento\\Catalog\\Model\\Product\\Option\\Converter');
     $this->linkTypeProviderMock = $this->getMock('Magento\\Catalog\\Model\\Product\\LinkTypeProvider', ['getLinkTypes'], [], '', false);
     $this->imageProcessorMock = $this->getMock('Magento\\Framework\\Api\\ImageProcessorInterface', [], [], '', false);
     $this->model = $this->objectManager->getObject('Magento\\Catalog\\Model\\ProductRepository', ['productFactory' => $this->productFactoryMock, 'initializationHelper' => $this->initializationHelperMock, 'resourceModel' => $this->resourceModelMock, 'filterBuilder' => $this->filterBuilderMock, 'collectionFactory' => $this->collectionFactoryMock, 'searchCriteriaBuilder' => $this->searchCriteriaBuilderMock, 'metadataServiceInterface' => $this->metadataServiceMock, 'searchResultsFactory' => $this->searchResultsFactoryMock, 'extensibleDataObjectConverter' => $this->extensibleDataObjectConverterMock, 'optionConverter' => $optionConverter, 'eavConfig' => $this->eavConfigMock, 'contentValidator' => $this->contentValidatorMock, 'fileSystem' => $this->fileSystemMock, 'contentFactory' => $this->contentFactoryMock, 'mimeTypeExtensionMap' => $this->mimeTypeExtensionMapMock, 'linkTypeProvider' => $this->linkTypeProviderMock, 'imageProcessor' => $this->imageProcessorMock]);
 }
开发者ID:niranjanssiet,项目名称:magento2,代码行数:28,代码来源:ProductRepositoryTest.php

示例8: testRefreshSpecialPrices

 public function testRefreshSpecialPrices()
 {
     $idsToProcess = [1, 2, 3];
     $this->metadataPool->expects($this->atLeastOnce())->method('getMetadata')->willReturn($this->metadataMock);
     $this->metadataMock->expects($this->atLeastOnce())->method('getLinkField')->willReturn('row_id');
     $this->metadataMock->expects($this->atLeastOnce())->method('getIdentifierField')->willReturn('entity_id');
     $selectMock = $this->getMock('Magento\\Framework\\DB\\Select', [], [], '', false);
     $selectMock->expects($this->any())->method('from')->will($this->returnSelf());
     $selectMock->expects($this->any())->method('joinLeft')->will($this->returnSelf());
     $selectMock->expects($this->any())->method('where')->will($this->returnSelf());
     $connectionMock = $this->getMock('Magento\\Framework\\DB\\Adapter\\AdapterInterface', [], [], '', false);
     $connectionMock->expects($this->any())->method('select')->will($this->returnValue($selectMock));
     $connectionMock->expects($this->any())->method('fetchCol')->will($this->returnValue($idsToProcess));
     $this->_resourceMock->expects($this->once())->method('getConnection')->will($this->returnValue($connectionMock));
     $this->_resourceMock->expects($this->any())->method('getTableName')->will($this->returnValue('category'));
     $storeMock = $this->getMock('\\Magento\\Store\\Model\\Store', [], [], '', false);
     $storeMock->expects($this->any())->method('getId')->will($this->returnValue(1));
     $this->_storeManagerMock->expects($this->once())->method('getStores')->with(true)->will($this->returnValue([$storeMock]));
     $this->_localeDateMock->expects($this->once())->method('scopeTimeStamp')->with($storeMock)->will($this->returnValue(32000));
     $indexerMock = $this->getMock('Magento\\Indexer\\Model\\Indexer', [], [], '', false);
     $indexerMock->expects($this->exactly(2))->method('reindexList');
     $this->_priceProcessorMock->expects($this->exactly(2))->method('getIndexer')->will($this->returnValue($indexerMock));
     $attributeMock = $this->getMockForAbstractClass('Magento\\Eav\\Model\\Entity\\Attribute\\AbstractAttribute', [], '', false, true, true, ['__wakeup', 'getAttributeId']);
     $attributeMock->expects($this->any())->method('getAttributeId')->will($this->returnValue(1));
     $this->_eavConfigMock->expects($this->any())->method('getAttribute')->will($this->returnValue($attributeMock));
     $this->_model->execute();
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:27,代码来源:RefreshSpecialPricesTest.php

示例9: setUp

 /**
  * Set Up
  */
 protected function setUp()
 {
     $this->localeDate = $this->getMock('Magento\\Framework\\Stdlib\\DateTime\\Timezone', [], [], '', false);
     $this->config = $this->getMock('Magento\\Eav\\Model\\Config', ['getEntityType'], [], '', false);
     $type = $this->getMock('\\Magento\\Eav\\Model\\Entity\\Type', [], [], '', false);
     $this->config->expects($this->once())->method('getEntityType')->willReturn($type);
     $this->resource = $this->getMock('Magento\\Framework\\App\\Resource', [], [], '', false);
     $this->storeManager = $this->getMock('Magento\\Store\\Model\\StoreManager', [], [], '', false);
     $this->logger = $this->getMock('Magento\\Framework\\Logger\\Monolog', [], [], '', false);
     $this->collection = $this->getMock('\\Magento\\Catalog\\Model\\Resource\\Product\\CollectionFactory', [], [], '', false);
     $this->abstractCollection = $this->getMockForAbstractClass('\\Magento\\Eav\\Model\\Entity\\Collection\\AbstractCollection', [], '', false, true, true, ['count', 'setOrder', 'setStoreId', 'getCurPage', 'getLastPageNumber']);
     $this->exportConfig = $this->getMock('Magento\\ImportExport\\Model\\Export\\Config', [], [], '', false);
     $this->productFactory = $this->getMock('Magento\\Catalog\\Model\\Resource\\ProductFactory', ['create', 'getTypeId'], [], '', false);
     $this->attrSetColFactory = $this->getMock('Magento\\Eav\\Model\\Resource\\Entity\\Attribute\\Set\\CollectionFactory', ['create', 'setEntityTypeFilter'], [], '', false);
     $this->categoryColFactory = $this->getMock('Magento\\Catalog\\Model\\Resource\\Category\\CollectionFactory', ['create', 'addNameToResult'], [], '', false);
     $this->itemFactory = $this->getMock('Magento\\CatalogInventory\\Model\\Resource\\Stock\\ItemFactory', [], [], '', false);
     $this->optionColFactory = $this->getMock('Magento\\Catalog\\Model\\Resource\\Product\\Option\\CollectionFactory', [], [], '', false);
     $this->attributeColFactory = $this->getMock('Magento\\Catalog\\Model\\Resource\\Product\\Attribute\\CollectionFactory', [], [], '', false);
     $this->typeFactory = $this->getMock('Magento\\CatalogImportExport\\Model\\Export\\Product\\Type\\Factory', [], [], '', false);
     $this->linkTypeProvider = $this->getMock('Magento\\Catalog\\Model\\Product\\LinkTypeProvider', [], [], '', false);
     $this->rowCustomizer = $this->getMock('Magento\\CatalogImportExport\\Model\\Export\\RowCustomizer\\Composite', [], [], '', false);
     $this->storeResolver = $this->getMock('\\Magento\\CatalogImportExport\\Model\\Import\\Product\\StoreResolver', [], [], '', false);
     $this->groupRepository = $this->getMock('\\Magento\\Customer\\Api\\GroupRepositoryInterface', [], [], '', false);
     $this->writer = $this->getMock('Magento\\ImportExport\\Model\\Export\\Adapter\\AbstractAdapter', ['setHeaderCols', 'writeRow', 'getContents'], [], '', false);
     $constructorMethods = ['initTypeModels', 'initAttributes', '_initStores', 'initAttributeSets', 'initWebsites', 'initCategories'];
     $mockMethods = array_merge($constructorMethods, ['_customHeadersMapping', '_prepareEntityCollection', '_getEntityCollection', 'getWriter', 'getExportData', '_headerColumns', '_customFieldsMapping', 'getItemsPerPage', 'paginateCollection', '_getHeaderColumns']);
     $this->advancedPricing = $this->getMock('Magento\\AdvancedPricingImportExport\\Model\\Export\\AdvancedPricing', $mockMethods, [], '', false);
     foreach ($constructorMethods as $method) {
         $this->advancedPricing->expects($this->once())->method($method)->will($this->returnSelf());
     }
     $this->advancedPricing->__construct($this->localeDate, $this->config, $this->resource, $this->storeManager, $this->logger, $this->collection, $this->exportConfig, $this->productFactory, $this->attrSetColFactory, $this->categoryColFactory, $this->itemFactory, $this->optionColFactory, $this->attributeColFactory, $this->typeFactory, $this->linkTypeProvider, $this->rowCustomizer, $this->storeResolver, $this->groupRepository);
 }
开发者ID:nja78,项目名称:magento2,代码行数:35,代码来源:AdvancedPricingTest.php

示例10: testGetPrefixes

 public function testGetPrefixes()
 {
     $entityTypeId = 3;
     /** @var \Magento\Eav\Model\Entity\Type|\PHPUnit_Framework_MockObject_MockObject $entityType */
     $entityType = $this->getMockBuilder('Magento\\Eav\\Model\\Entity\\Type')->disableOriginalConstructor()->getMock();
     $entityType->expects($this->once())->method('getId')->will($this->returnValue($entityTypeId));
     /** @var AbstractFrontend|\PHPUnit_Framework_MockObject_MockObject $frontend */
     $frontend = $this->getMockBuilder('Magento\\Eav\\Model\\Entity\\Attribute\\Frontend\\AbstractFrontend')->setMethods(['getLabel'])->disableOriginalConstructor()->getMockForAbstractClass();
     $frontend->expects($this->once())->method('getLabel')->will($this->returnValue('testLabel'));
     $this->attributeCollection->expects($this->once())->method('setEntityTypeFilter')->with($this->equalTo($entityTypeId));
     $this->attributeCollection->expects($this->once())->method('setFrontendInputTypeFilter')->with($this->equalTo('media_image'));
     $this->attribute->expects($this->once())->method('getAttributeCode')->will($this->returnValue('attributeCode'));
     $this->attribute->expects($this->once())->method('getFrontend')->will($this->returnValue($frontend));
     $this->attributeCollection->expects($this->any())->method('getIterator')->will($this->returnValue(new \ArrayIterator([$this->attribute])));
     $this->eavConfig->expects($this->any())->method('getEntityType')->with($this->equalTo(Product::ENTITY))->will($this->returnValue($entityType));
     $this->assertEquals([['field' => 'attributeCode_', 'label' => 'testLabel']], $this->model->getPrefixes());
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:17,代码来源:ImageTest.php

示例11: testUpdateAttributes

 public function testUpdateAttributes()
 {
     $productIds = [1, 2, 2, 4];
     $productIdsUnique = [0 => 1, 1 => 2, 3 => 4];
     $attrData = [1];
     $storeId = 1;
     $this->resource->expects($this->any())->method('updateAttributes')->with($productIds, $attrData, $storeId)->will($this->returnSelf());
     $this->categoryIndexer->expects($this->any())->method('isScheduled')->will($this->returnValue(false));
     $this->categoryIndexer->expects($this->any())->method('reindexList')->will($this->returnValue($productIds));
     $this->prepareIndexer();
     $this->eavConfig->expects($this->any())->method('getAttribute')->will($this->returnValue($this->eavAttribute));
     $this->eavAttribute->expects($this->any())->method('isIndexable')->will($this->returnValue(false));
     $this->assertEquals($this->model, $this->model->updateAttributes($productIds, $attrData, $storeId));
     $this->assertEquals($this->model->getDataByKey('product_ids'), $productIdsUnique);
     $this->assertEquals($this->model->getDataByKey('attributes_data'), $attrData);
     $this->assertEquals($this->model->getDataByKey('store_id'), $storeId);
 }
开发者ID:whoople,项目名称:magento2-testing,代码行数:17,代码来源:ActionTest.php

示例12: setUp

 protected function setUp()
 {
     $this->productFactoryMock = $this->getMock('Magento\\Catalog\\Model\\ProductFactory', ['create'], [], '', false);
     $this->productMock = $this->getMock('Magento\\Catalog\\Model\\Product', [], [], '', false);
     $this->filterBuilderMock = $this->getMock('\\Magento\\Framework\\Api\\FilterBuilder', [], [], '', false);
     $this->initializationHelperMock = $this->getMock('\\Magento\\Catalog\\Controller\\Adminhtml\\Product\\Initialization\\Helper', [], [], '', false);
     $this->collectionFactoryMock = $this->getMock('\\Magento\\Catalog\\Model\\Resource\\Product\\CollectionFactory', ['create'], [], '', false);
     $this->searchCriteriaBuilderMock = $this->getMock('\\Magento\\Framework\\Api\\SearchCriteriaBuilder', [], [], '', false);
     $this->metadataServiceMock = $this->getMock('\\Magento\\Catalog\\Api\\ProductAttributeRepositoryInterface', [], [], '', false);
     $this->searchResultsFactoryMock = $this->getMock('\\Magento\\Catalog\\Api\\Data\\ProductSearchResultsInterfaceFactory', ['create'], [], '', false);
     $this->resourceModelMock = $this->getMock('\\Magento\\Catalog\\Model\\Resource\\Product', [], [], '', false);
     $this->eavConfigMock = $this->getMock('Magento\\Eav\\Model\\Config', [], [], '', false);
     $this->eavConfigMock->expects($this->any())->method('getEntityType')->willReturn(new \Magento\Framework\Object(['default_attribute_set_id' => 4]));
     $this->objectManager = new ObjectManager($this);
     $this->extensibleDataObjectConverterMock = $this->getMockBuilder('\\Magento\\Framework\\Api\\ExtensibleDataObjectConverter')->setMethods(['toNestedArray'])->disableOriginalConstructor()->getMock();
     $this->model = $this->objectManager->getObject('Magento\\Catalog\\Model\\ProductRepository', ['productFactory' => $this->productFactoryMock, 'initializationHelper' => $this->initializationHelperMock, 'resourceModel' => $this->resourceModelMock, 'filterBuilder' => $this->filterBuilderMock, 'collectionFactory' => $this->collectionFactoryMock, 'searchCriteriaBuilder' => $this->searchCriteriaBuilderMock, 'metadataServiceInterface' => $this->metadataServiceMock, 'searchResultsFactory' => $this->searchResultsFactoryMock, 'extensibleDataObjectConverter' => $this->extensibleDataObjectConverterMock, 'eavConfig' => $this->eavConfigMock]);
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:17,代码来源:ProductRepositoryTest.php

示例13: testValidateWithDatetimeValue

 /**
  * @dataProvider validateDataProvider
  *
  * @param string $attributeValue
  * @param string|array $parsedValue
  * @param string $newValue
  * @param string $operator
  * @param array $input
  */
 public function testValidateWithDatetimeValue($attributeValue, $parsedValue, $newValue, $operator, $input)
 {
     $this->product->setData('attribute', 'attribute_key');
     $this->product->setData('value_parsed', $parsedValue);
     $this->product->setData('operator', $operator);
     $this->config->expects($this->any())->method('getAttribute')->will($this->returnValue($this->eavAttributeResource));
     $this->eavAttributeResource->expects($this->any())->method('isScopeGlobal')->will($this->returnValue(false));
     $this->eavAttributeResource->expects($this->any())->method($input['method'])->will($this->returnValue($input['type']));
     $this->productModel->expects($this->any())->method('hasData')->will($this->returnValue(true));
     $this->productModel->expects($this->at(0))->method('getData')->will($this->returnValue(['1' => ['1' => $attributeValue]]));
     $this->productModel->expects($this->any())->method('getData')->will($this->returnValue($newValue));
     $this->productModel->expects($this->any())->method('getId')->will($this->returnValue('1'));
     $this->productModel->expects($this->once())->method('getStoreId')->will($this->returnValue('1'));
     $this->productModel->expects($this->any())->method('getResource')->will($this->returnValue($this->productResource));
     $this->productResource->expects($this->any())->method('getAttribute')->will($this->returnValue($this->eavAttributeResource));
     $this->product->collectValidatedAttributes($this->productModel);
     $this->assertTrue($this->product->validate($this->productModel));
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:27,代码来源:ProductTest.php

示例14: _parentObjectConstructor

 /**
  * @return $this
  */
 protected function _parentObjectConstructor()
 {
     $type = $this->getMockBuilder('Magento\\Eav\\Model\\Entity\\Type')->disableOriginalConstructor()->getMock();
     $type->expects($this->any())->method('getEntityTypeId')->will($this->returnValue(self::ENTITY_TYPE_ID));
     $this->config->expects($this->any())->method('getEntityType')->with(self::ENTITY_TYPE_CODE)->willReturn($type);
     $this->_connection = $this->getMock('\\Magento\\Framework\\DB\\Adapter\\AdapterInterface');
     $this->resource->expects($this->any())->method('getConnection')->willReturn($this->_connection);
     return $this;
 }
开发者ID:vv-team,项目名称:foodo,代码行数:12,代码来源:ProductTest.php

示例15: testSendNewAccountEmailWithoutStoreId

 public function testSendNewAccountEmailWithoutStoreId()
 {
     $store = $this->getMock('Magento\\Store\\Model\\Store', [], [], '', false);
     $website = $this->getMock('Magento\\Store\\Model\\Website', [], [], '', false);
     $website->expects($this->once())->method('getStoreIds')->will($this->returnValue([1, 2, 3, 4]));
     $this->_storeManager->expects($this->once())->method('getWebsite')->with(1)->will($this->returnValue($website));
     $this->_storeManager->expects($this->once())->method('getStore')->with(1)->will($this->returnValue($store));
     $this->_config->expects($this->exactly(3))->method('getAttribute')->will($this->returnValue($this->_attribute));
     $this->_attribute->expects($this->exactly(3))->method('getIsVisible')->will($this->returnValue(true));
     $methods = ['setTemplateIdentifier', 'setTemplateOptions', 'setTemplateVars', 'setFrom', 'addTo'];
     foreach ($methods as $method) {
         $this->_transportBuilderMock->expects($this->once())->method($method)->will($this->returnSelf());
     }
     $transportMock = $this->getMock('Magento\\Framework\\Mail\\TransportInterface', [], [], '', false);
     $transportMock->expects($this->once())->method('sendMessage')->will($this->returnSelf());
     $this->_transportBuilderMock->expects($this->once())->method('getTransport')->will($this->returnValue($transportMock));
     $this->_model->setData(['website_id' => 1, 'store_id' => 1, 'email' => 'email@example.com', 'firstname' => 'FirstName', 'lastname' => 'LastName', 'middlename' => 'MiddleName', 'prefix' => 'Prefix']);
     $this->_model->sendNewAccountEmail('registered');
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:19,代码来源:CustomerTest.php


注:本文中的Magento\Eav\Model\Config::expects方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。