本文整理汇总了PHP中Magento\Framework\Indexer\IndexerRegistry::expects方法的典型用法代码示例。如果您正苦于以下问题:PHP IndexerRegistry::expects方法的具体用法?PHP IndexerRegistry::expects怎么用?PHP IndexerRegistry::expects使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\Indexer\IndexerRegistry
的用法示例。
在下文中一共展示了IndexerRegistry::expects方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testAfterImportSource
/**
* Test AfterImportSource()
*/
public function testAfterImportSource()
{
$this->_indexerMock->expects($this->once())->method('invalidate');
$this->indexerRegistryMock->expects($this->any())->method('get')->with(\Magento\Catalog\Model\Indexer\Product\Price\Processor::INDEXER_ID)->will($this->returnValue($this->_indexerMock));
$this->_indexerMock->expects($this->any())->method('isScheduled')->will($this->returnValue(false));
$importMock = $this->getMock('Magento\\ImportExport\\Model\\Import', [], [], '', false);
$this->assertEquals('return_value', $this->_model->afterImportSource($importMock, 'return_value'));
}
示例2: testIsAvailable
/**
* @param $isAvailable
* @param $isFlatEnabled
* @param $isValid
* @param $result
* @dataProvider isAvailableDataProvider
*/
public function testIsAvailable($isAvailable, $isFlatEnabled, $isValid, $result)
{
$this->flatIndexerMock->expects($this->any())->method('load')->with('catalog_category_flat');
$this->flatIndexerMock->expects($this->any())->method('isValid')->will($this->returnValue($isValid));
$this->indexerRegistryMock->expects($this->any())->method('get')->with(\Magento\Catalog\Model\Indexer\Category\Flat\State::INDEXER_ID)->will($this->returnValue($this->flatIndexerMock));
$this->scopeConfigMock->expects($this->any())->method('isSetFlag')->with('catalog/frontend/flat_catalog_category')->will($this->returnValue($isFlatEnabled));
$this->model = new \Magento\Catalog\Model\Indexer\Category\Flat\State($this->scopeConfigMock, $this->indexerRegistryMock, $isAvailable);
$this->assertEquals($result, $this->model->isAvailable());
}
示例3: testAroundSave
public function testAroundSave()
{
$this->stateMock->expects($this->once())->method('isFlatEnabled')->will($this->returnValue(true));
$this->indexerMock->expects($this->once())->method('invalidate');
$this->indexerRegistryMock->expects($this->once())->method('get')->with(\Magento\Catalog\Model\Indexer\Category\Flat\State::INDEXER_ID)->will($this->returnValue($this->indexerMock));
$this->groupMock->expects($this->once())->method('dataHasChangedFor')->with('root_category_id')->will($this->returnValue(true));
$this->groupMock->expects($this->once())->method('isObjectNew')->will($this->returnValue(false));
$this->assertFalse($this->model->aroundSave($this->subjectMock, $this->closureMock, $this->groupMock));
}
示例4: testDelete
public function testDelete()
{
$this->designConfig->expects($this->exactly(2))->method('getExtensionAttributes')->willReturn($this->designExtension);
$this->designExtension->expects($this->once())->method('getDesignConfigData')->willReturn([$this->designConfigData]);
$this->configStorage->expects($this->once())->method('delete')->with($this->designConfig);
$this->reinitableConfig->expects($this->once())->method('reinit');
$this->indexerRegistry->expects($this->once())->method('get')->with(Config::DESIGN_CONFIG_GRID_INDEXER_ID)->willReturn($this->indexer);
$this->indexer->expects($this->once())->method('reindexAll');
$this->assertSame($this->designConfig, $this->repository->delete($this->designConfig));
}
示例5: setUp
public function setUp()
{
$this->_objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
$this->_subjectMock = $this->getMock('\\Magento\\Customer\\Api\\GroupRepositoryInterface', [], [], '', false);
$indexerMock = $this->getMock('Magento\\Indexer\\Model\\Indexer', ['getId', 'invalidate'], [], '', false);
$indexerMock->expects($this->once())->method('invalidate');
$this->indexerRegistryMock = $this->getMock('Magento\\Framework\\Indexer\\IndexerRegistry', ['get'], [], '', false);
$this->indexerRegistryMock->expects($this->once())->method('get')->with(\Magento\Catalog\Model\Indexer\Product\Price\Processor::INDEXER_ID)->will($this->returnValue($indexerMock));
$this->_model = $this->_objectManager->getObject('Magento\\Catalog\\Model\\Indexer\\Product\\Price\\Plugin\\CustomerGroup', ['indexerRegistry' => $this->indexerRegistryMock]);
}
示例6: testAfterDelete
public function testAfterDelete()
{
/** @var \Magento\Store\Model\Group|\PHPUnit_Framework_MockObject_MockObject $subjectMock */
$subjectMock = $this->getMockBuilder('Magento\\Store\\Model\\Group')->disableOriginalConstructor()->getMock();
/** @var IndexerInterface|\PHPUnit_Framework_MockObject_MockObject $indexerMock */
$indexerMock = $this->getMockBuilder('Magento\\Framework\\Indexer\\IndexerInterface')->getMockForAbstractClass();
$indexerMock->expects($this->once())->method('invalidate');
$this->indexerRegistryMock->expects($this->once())->method('get')->with(Config::DESIGN_CONFIG_GRID_INDEXER_ID)->willReturn($indexerMock);
$this->assertEquals($subjectMock, $this->model->afterDelete($subjectMock, $subjectMock));
}
示例7: testFilter
public function testFilter()
{
$attributeCode = 'attribute-code';
$attributeCodeTwo = 'attribute-code2';
$tableName = 'customer_grid_flat';
$attributes = [$attributeCode => [AttributeMetadataInterface::ATTRIBUTE_CODE => $attributeCode, AttributeMetadataInterface::FRONTEND_INPUT => 'input', AttributeMetadataInterface::FRONTEND_LABEL => 'Frontend label', AttributeMetadataInterface::BACKEND_TYPE => 'static', AttributeMetadataInterface::OPTIONS => [], AttributeMetadataInterface::IS_USED_IN_GRID => true, AttributeMetadataInterface::IS_VISIBLE_IN_GRID => true, AttributeMetadataInterface::IS_FILTERABLE_IN_GRID => true, AttributeMetadataInterface::IS_SEARCHABLE_IN_GRID => true], $attributeCodeTwo => [AttributeMetadataInterface::ATTRIBUTE_CODE => $attributeCodeTwo, AttributeMetadataInterface::FRONTEND_INPUT => 'input', AttributeMetadataInterface::FRONTEND_LABEL => 'Frontend label two', AttributeMetadataInterface::BACKEND_TYPE => 'static', AttributeMetadataInterface::OPTIONS => [], AttributeMetadataInterface::IS_USED_IN_GRID => false, AttributeMetadataInterface::IS_VISIBLE_IN_GRID => false, AttributeMetadataInterface::IS_FILTERABLE_IN_GRID => false, AttributeMetadataInterface::IS_SEARCHABLE_IN_GRID => false]];
$this->indexerRegistry->expects($this->once())->method('get')->with(\Magento\Customer\Model\Customer::CUSTOMER_GRID_INDEXER_ID)->willReturn($this->indexer);
$this->indexer->expects($this->once())->method('getState')->willReturn($this->indexerState);
$this->indexerState->expects($this->once())->method('getStatus')->willReturn(\Magento\Framework\Indexer\StateInterface::STATUS_INVALID);
$this->flatScopeResolver->expects($this->once())->method('resolve')->with(\Magento\Customer\Model\Customer::CUSTOMER_GRID_INDEXER_ID, [])->willReturn($tableName);
$this->resource->expects($this->once())->method('getConnection')->willReturn($this->connection);
$this->connection->expects($this->once())->method('describeTable')->with($tableName)->willReturn(['attribute-code' => ['Attribute data']]);
$this->assertArrayNotHasKey($attributeCodeTwo, $this->model->filter($attributes));
}
示例8: prepareIndexer
protected function prepareIndexer()
{
$this->indexerRegistryMock->expects($this->once())
->method('get')
->with(\Magento\CatalogSearch\Model\Indexer\Fulltext::INDEXER_ID)
->will($this->returnValue($this->indexerMock));
}
示例9: testExecute
/**
* @param array $indexerIds
* @param \Exception $exception
* @param array $expectsExceptionValues
* @dataProvider executeDataProvider
*/
public function testExecute($indexerIds, $exception, $expectsExceptionValues)
{
$this->model = new \Magento\Indexer\Controller\Adminhtml\Indexer\MassChangelog($this->contextMock);
$this->request->expects($this->any())->method('getParam')->with('indexer_ids')->will($this->returnValue($indexerIds));
if (!is_array($indexerIds)) {
$this->messageManager->expects($this->once())->method('addError')->with(__('Please select indexers.'))->will($this->returnValue(1));
} else {
$this->objectManager->expects($this->any())->method('get')->with('Magento\\Framework\\Indexer\\IndexerRegistry')->will($this->returnValue($this->indexReg));
$indexerInterface = $this->getMockForAbstractClass('Magento\\Framework\\Indexer\\IndexerInterface', ['setScheduled'], '', false);
$this->indexReg->expects($this->any())->method('get')->with(1)->will($this->returnValue($indexerInterface));
if ($exception !== null) {
$indexerInterface->expects($this->any())->method('setScheduled')->with(true)->will($this->throwException($exception));
} else {
$indexerInterface->expects($this->any())->method('setScheduled')->with(true)->will($this->returnValue(1));
}
$this->messageManager->expects($this->any())->method('addSuccess')->will($this->returnValue(1));
if ($exception !== null) {
$this->messageManager->expects($this->exactly($expectsExceptionValues[2]))->method('addError')->with($exception->getMessage());
$this->messageManager->expects($this->exactly($expectsExceptionValues[1]))->method('addException')->with($exception, "We couldn't change indexer(s)' mode because of an error.");
}
}
$this->helper->expects($this->any())->method("getUrl")->willReturn("magento.com");
$this->response->expects($this->any())->method("setRedirect")->willReturn(1);
$this->model->executeInternal();
}
示例10: testReindexListForce
public function testReindexListForce()
{
$ids = [1];
$this->_stateMock->expects($this->once())->method('isFlatEnabled')->willReturn(true);
$indexerMock = $this->getMockBuilder('Magento\\Indexer\\Model\\Indexer')->disableOriginalConstructor()->getMock();
$this->indexerRegistryMock->expects($this->any())->method('get')->with(Processor::INDEXER_ID)->willReturn($indexerMock);
$indexerMock->expects($this->any())->method('isScheduled')->willReturn(true);
$indexerMock->expects($this->any())->method('reindexList')->with($ids)->willReturnSelf();
$this->_model->reindexList($ids, true);
}
示例11: testSyncCustomerGrid
public function testSyncCustomerGrid()
{
$gridTable = 'customer_grid_flat';
$customerLogTable = 'customer_log';
$this->indexerRegistry->expects($this->once())->method('get')->with(\Magento\Customer\Model\Customer::CUSTOMER_GRID_INDEXER_ID)->willReturn($this->indexer);
$this->resource->expects($this->once())->method('getConnection')->willReturn($this->connection);
$this->flatScopeResolver->expects($this->once())->method('resolve')->with(\Magento\Customer\Model\Customer::CUSTOMER_GRID_INDEXER_ID, [])->willReturn($gridTable);
$this->resource->expects($this->exactly(2))->method('getTableName')->willReturnMap([[$gridTable], [$customerLogTable]]);
$this->connection->expects($this->exactly(2))->method('select')->willReturn($this->select);
$this->select->expects($this->exactly(2))->method('from')->willReturnSelf();
$this->select->expects($this->once())->method('order')->with('last_visit_at DESC')->willReturnSelf();
$this->select->expects($this->once())->method('limit')->with(1)->willReturnSelf();
$this->connection->expects($this->atLeastOnce())->method('query')->with($this->select)->willReturn($this->queryResult);
$this->queryResult->expects($this->once())->method('fetchColumn')->willReturn('2015-08-13 10:36:44');
$this->select->expects($this->once())->method('where')->with('last_login_at > ?', '2015-08-13 10:36:44')->willReturnSelf();
$this->queryResult->expects($this->once())->method('fetchAll')->willReturn([['customer_id' => 23], ['customer_id' => 65]]);
$this->indexer->expects($this->once())->method('reindexList')->with(['23', '65']);
$this->observer->syncCustomerGrid();
}
示例12: testProcessValueOff
/**
* @param string $oldValue
* @param string $value
* @dataProvider dataProviderProcessValueOff
*/
public function testProcessValueOff($oldValue, $value)
{
$this->configMock->expects($this->once())->method('getValue')->with(null, 'default')->will($this->returnValue($oldValue));
$this->model->setValue($value);
$this->indexerStateMock->expects($this->never())->method('loadByIndexer');
$this->indexerStateMock->expects($this->never())->method('setStatus');
$this->indexerStateMock->expects($this->never())->method('save');
$this->indexerRegistry->expects($this->once())->method('get')->with('catalog_category_flat')->willReturn($this->flatIndexer);
$this->flatIndexer->expects($this->once())->method('setScheduled')->with(false);
$this->model->processValue();
}
示例13: testReindexFlatDisabled
/**
* @param $productScheduled
* @param $expectedProductReindexCall
*
* @dataProvider reindexFlatDisabledTestDataProvider
*/
public function testReindexFlatDisabled($productScheduled, $expectedProductReindexCall)
{
$affectedProductIds = ["1", "2"];
$this->category->setAffectedProductIds($affectedProductIds);
$pathIds = ['path/1/2', 'path/2/3'];
$this->category->setData('path_ids', $pathIds);
$this->category->setId('123');
$this->flatState->expects($this->any())->method('isFlatEnabled')->will($this->returnValue(false));
$this->productIndexer->expects($this->exactly(1))->method('isScheduled')->will($this->returnValue($productScheduled));
$this->productIndexer->expects($this->exactly($expectedProductReindexCall))->method('reindexList')->with($pathIds);
$this->indexerRegistry->expects($this->at(0))->method('get')->with(Indexer\Category\Product::INDEXER_ID)->will($this->returnValue($this->productIndexer));
$this->category->reindex();
}
示例14: prepareIndexer
protected function prepareIndexer()
{
$this->indexerRegistryMock->expects($this->once())->method('get')->with(\Magento\Catalog\Model\Indexer\Product\Category::INDEXER_ID)->will($this->returnValue($this->categoryIndexer));
}
示例15: mockIndexerMethods
protected function mockIndexerMethods()
{
$this->indexerMock->expects($this->once())->method('invalidate');
$this->indexerRegistryMock->expects($this->once())->method('get')->with(\Magento\Catalog\Model\Indexer\Category\Product::INDEXER_ID)->will($this->returnValue($this->indexerMock));
}