本文整理汇总了PHP中Magento\Framework\App\Resource::expects方法的典型用法代码示例。如果您正苦于以下问题:PHP Resource::expects方法的具体用法?PHP Resource::expects怎么用?PHP Resource::expects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\App\Resource
的用法示例。
在下文中一共展示了Resource::expects方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testPurge
/**
* Test purge method
*/
public function testPurge()
{
$this->appResourceMock->expects($this->once())->method('getConnection')->will($this->returnValue($this->adapterMock));
$this->appResourceMock->expects($this->once())->method('getTableName')->will($this->returnValue('sales_flat_invoice_grid'));
$this->adapterMock->expects($this->once())->method('delete')->with('sales_flat_invoice_grid', ['fi.field = ?' => 1])->will($this->returnValue(1));
$this->assertEquals(1, $this->grid->purge(1, 'fi.field'));
}
示例2: setUp
/**
* {@inheritDoc}
*/
protected function setUp()
{
$this->resourceMock = $this->getMockBuilder('Magento\\Framework\\App\\Resource')->disableOriginalConstructor()->getMock();
$this->connectionMock = $this->getMockBuilder('Magento\\Framework\\DB\\Adapter\\AdapterInterface')->getMock();
$this->resourceMock->expects($this->any())->method('getConnection')->willReturn($this->connectionMock);
$this->helper = new Helper($this->resourceMock);
}
示例3: setUp
protected function setUp()
{
$this->entityModel = $this->getMock('Magento\\CatalogImportExport\\Model\\Import\\Product', ['getBehavior', 'getNewSku', 'getNextBunch', 'isRowAllowedToImport', 'getRowScope', 'getConnection'], [], '', false);
$this->connection = $this->getMock('Magento\\Framework\\DB\\Adapter\\Pdo\\Mysql', ['select', 'fetchAll', 'fetchPairs', 'joinLeft', 'insertOnDuplicate', 'delete', 'quoteInto', 'fetchAssoc'], [], '', false);
$select = $this->getMock('Magento\\Framework\\DB\\Select', [], [], '', false);
$select->expects($this->any())->method('from')->will($this->returnSelf());
$select->expects($this->any())->method('where')->will($this->returnSelf());
$select->expects($this->any())->method('joinLeft')->will($this->returnSelf());
$adapter = $this->getMock('Magento\\Framework\\DB\\Adapter\\Pdo\\Mysql', [], [], '', false);
$adapter->expects($this->any())->method('quoteInto')->will($this->returnValue('query'));
$select->expects($this->any())->method('getAdapter')->willReturn($adapter);
$this->connection->expects($this->any())->method('select')->will($this->returnValue($select));
$this->connection->expects($this->any())->method('fetchPairs')->will($this->returnValue(['1' => '1', '2' => '2']));
$this->connection->expects($this->any())->method('insertOnDuplicate')->willReturnSelf();
$this->connection->expects($this->any())->method('delete')->willReturnSelf();
$this->connection->expects($this->any())->method('quoteInto')->willReturn('');
$this->resource = $this->getMock('Magento\\Framework\\App\\Resource', ['getConnection', 'getTableName'], [], '', false);
$this->resource->expects($this->any())->method('getConnection')->will($this->returnValue($this->connection));
$this->resource->expects($this->any())->method('getTableName')->will($this->returnValue('tableName'));
$this->attrSetColFac = $this->getMock('Magento\\Eav\\Model\\Resource\\Entity\\Attribute\\Set\\CollectionFactory', ['create'], [], '', false);
$this->setCollection = $this->getMock('Magento\\Eav\\Model\\Resource\\Entity\\Attribute\\Set\\Collection', ['setEntityTypeFilter'], [], '', false);
$this->attrSetColFac->expects($this->any())->method('create')->will($this->returnValue($this->setCollection));
$this->setCollection->expects($this->any())->method('setEntityTypeFilter')->will($this->returnValue([]));
$this->prodAttrColFac = $this->getMock('Magento\\Catalog\\Model\\Resource\\Product\\Attribute\\CollectionFactory', ['create'], [], '', false);
$attrCollection = $this->getMock('\\Magento\\Catalog\\Model\\Resource\\Product\\Attribute\\Collection', [], [], '', false);
$attrCollection->expects($this->any())->method('addFieldToFilter')->willReturn([]);
$this->prodAttrColFac->expects($this->any())->method('create')->will($this->returnValue($attrCollection));
$this->params = [0 => $this->entityModel, 1 => 'bundle'];
$this->objectManagerHelper = new ObjectManagerHelper($this);
$this->bundle = $this->objectManagerHelper->getObject('Magento\\BundleImportExport\\Model\\Import\\Product\\Type\\Bundle', ['attrSetColFac' => $this->attrSetColFac, 'prodAttrColFac' => $this->prodAttrColFac, 'resource' => $this->resource, 'params' => $this->params]);
}
示例4: setUp
public function setUp()
{
$this->coreEntityFactoryMock = $this->getMock('Magento\\Framework\\Data\\Collection\\EntityFactory', [], [], '', false);
$this->loggerMock = $this->getMock('Psr\\Log\\LoggerInterface');
$this->fetchStrategyMock = $this->getMock('Magento\\Framework\\Data\\Collection\\Db\\FetchStrategyInterface', [], [], '', false);
$this->eventManagerMock = $this->getMock('Magento\\Framework\\Event\\ManagerInterface', [], [], '', false);
$this->configMock = $this->getMock('Magento\\Eav\\Model\\Config', [], [], '', false);
$this->coreResourceMock = $this->getMock('Magento\\Framework\\App\\Resource', [], [], '', false);
$this->resourceHelperMock = $this->getMock('Magento\\Eav\\Model\\Resource\\Helper', [], [], '', false);
$this->validatorFactoryMock = $this->getMock('Magento\\Framework\\Validator\\UniversalFactory', [], [], '', false);
$this->entityFactoryMock = $this->getMock('Magento\\Eav\\Model\\EntityFactory', [], [], '', false);
/** @var \Magento\Framework\DB\Adapter\Pdo\Mysql|\PHPUnit_Framework_MockObject_MockObject */
$connectionMock = $this->getMock('Magento\\Framework\\DB\\Adapter\\Pdo\\Mysql', [], [], '', false);
$this->statementMock = $this->getMock('Magento\\Framework\\DB\\Statement\\Pdo\\Mysql', ['fetch'], [], '', false);
/** @var $selectMock \Zend_Db_Select|\PHPUnit_Framework_MockObject_MockObject */
$selectMock = $this->getMock('Zend_Db_Select', [], [], '', false);
$this->coreEntityFactoryMock->expects($this->any())->method('create')->will($this->returnCallback([$this, 'getMagentoObject']));
$connectionMock->expects($this->any())->method('select')->will($this->returnValue($selectMock));
$connectionMock->expects($this->any())->method('query')->willReturn($this->statementMock);
$this->coreResourceMock->expects($this->any())->method('getConnection')->will($this->returnValue($connectionMock));
$entityMock = $this->getMock('Magento\\Eav\\Model\\Entity\\AbstractEntity', [], [], '', false);
$entityMock->expects($this->any())->method('getReadConnection')->will($this->returnValue($connectionMock));
$entityMock->expects($this->any())->method('getDefaultAttributes')->will($this->returnValue([]));
$this->validatorFactoryMock->expects($this->any())->method('create')->with('test_entity_model')->will($this->returnValue($entityMock));
$this->model = new AbstractCollectionStub($this->coreEntityFactoryMock, $this->loggerMock, $this->fetchStrategyMock, $this->eventManagerMock, $this->configMock, $this->coreResourceMock, $this->entityFactoryMock, $this->resourceHelperMock, $this->validatorFactoryMock, null);
}
示例5: setUp
protected function setUp()
{
$this->_adapterMock = $this->getMock('Magento\\Framework\\DB\\Adapter\\AdapterInterface');
$this->_resourceMock = $this->getMock('Magento\\Framework\\App\\Resource', [], [], '', false);
$this->_resourceMock->expects($this->any())->method('getConnection')->with('prefix_read')->will($this->returnValue($this->_adapterMock));
$this->_model = $this->getMockForAbstractClass('Magento\\Framework\\DB\\Helper\\AbstractHelper', [$this->_resourceMock, 'prefix'], '', true, true, true, ['addLikeEscape']);
}
示例6: testResetSearchResult
public function testResetSearchResult()
{
$this->resource->expects($this->once())->method('getTableName')->with('search_query', 'core_read')->willReturn('table_name_search_query');
$this->adapter->expects($this->once())->method('update')->with('table_name_search_query', ['is_processed' => 0], ['is_processed != 0'])->willReturn(10);
$result = $this->target->resetSearchResults();
$this->assertEquals($this->target, $result);
}
示例7: setUp
protected function setUp()
{
$helper = new ObjectManager($this);
$this->select = $this->getMockBuilder('Magento\\Framework\\DB\\Select')->setMethods(['group', 'limit', 'where', 'columns', 'from', 'join'])->disableOriginalConstructor()->getMock();
$this->select->expects($this->any())->method('from')->willReturnSelf();
$connectionAdapter = $this->getMockBuilder('Magento\\Framework\\DB\\Adapter\\AdapterInterface')->setMethods(['select'])->disableOriginalConstructor()->getMockForAbstractClass();
$connectionAdapter->expects($this->any())->method('select')->will($this->returnValue($this->select));
$this->resource = $this->getMockBuilder('Magento\\Framework\\App\\Resource')->disableOriginalConstructor()->getMock();
$this->resource->expects($this->any())->method('getConnection')->with(Resource::DEFAULT_READ_RESOURCE)->will($this->returnValue($connectionAdapter));
$this->scoreBuilder = $this->getMockBuilder('Magento\\Framework\\Search\\Adapter\\Mysql\\ScoreBuilder')->setMethods(['clear'])->disableOriginalConstructor()->getMock();
$this->scoreBuilderFactory = $this->getMockBuilder('Magento\\Framework\\Search\\Adapter\\Mysql\\ScoreBuilderFactory')->setMethods(['create'])->disableOriginalConstructor()->getMock();
$this->scoreBuilderFactory->expects($this->any())->method('create')->will($this->returnValue($this->scoreBuilder));
$this->request = $this->getMockBuilder('Magento\\Framework\\Search\\RequestInterface')->setMethods(['getQuery', 'getIndex', 'getSize'])->disableOriginalConstructor()->getMockForAbstractClass();
$this->queryContainer = $this->getMockBuilder('Magento\\Framework\\Search\\Adapter\\Mysql\\Query\\QueryContainer')->setMethods(['addMatchQuery', 'getDerivedQueries'])->disableOriginalConstructor()->getMock();
$this->queryContainer->expects($this->any())->method('addMatchQuery')->willReturnArgument(0);
$queryContainerFactory = $this->getMockBuilder('Magento\\Framework\\Search\\Adapter\\Mysql\\Query\\QueryContainerFactory')->setMethods(['create'])->disableOriginalConstructor()->getMock();
$queryContainerFactory->expects($this->any())->method('create')->willReturn($this->queryContainer);
$this->filterBuilder = $this->getMockBuilder('Magento\\Framework\\Search\\Adapter\\Mysql\\Filter\\Builder')->setMethods(['build'])->disableOriginalConstructor()->getMock();
$this->matchBuilder = $this->getMockBuilder('\\Magento\\Framework\\Search\\Adapter\\Mysql\\Query\\Builder\\Match')->setMethods(['build'])->disableOriginalConstructor()->getMock();
$this->matchBuilder->expects($this->any())->method('build')->willReturnArgument(1);
/** @var MockObject|\Magento\Framework\Search\Adapter\Mysql\IndexBuilderInterface $indexBuilder */
$indexBuilder = $this->getMockBuilder('\\Magento\\Framework\\Search\\Adapter\\Mysql\\IndexBuilderInterface')->disableOriginalConstructor()->setMethods(['build'])->getMockForAbstractClass();
$indexBuilder->expects($this->any())->method('build')->will($this->returnValue($this->select));
$index = self::INDEX_NAME;
$this->request->expects($this->exactly(2))->method('getIndex')->will($this->returnValue($index));
$this->mapper = $helper->getObject('Magento\\Framework\\Search\\Adapter\\Mysql\\Mapper', ['resource' => $this->resource, 'scoreBuilderFactory' => $this->scoreBuilderFactory, 'queryContainerFactory' => $queryContainerFactory, 'filterBuilder' => $this->filterBuilder, 'matchBuilder' => $this->matchBuilder, 'indexProviders' => [$index => $indexBuilder]]);
}
示例8: testCreate
public function testCreate()
{
$triggerName = 'trigger_name';
$this->resourceMock->expects($this->atLeastOnce())->method('getTriggerName')->willReturn($triggerName);
$triggerMock = $this->getMockBuilder('Magento\\Framework\\DB\\Ddl\\Trigger')->disableOriginalConstructor()->getMock();
$triggerMock->expects($this->exactly(3))->method('setName')->with($triggerName)->will($this->returnSelf());
$triggerMock->expects($this->exactly(3))->method('getName')->will($this->returnValue('triggerName'));
$triggerMock->expects($this->exactly(3))->method('setTime')->with(\Magento\Framework\DB\Ddl\Trigger::TIME_AFTER)->will($this->returnSelf());
$triggerMock->expects($this->exactly(3))->method('setEvent')->will($this->returnSelf());
$triggerMock->expects($this->exactly(3))->method('setTable')->with($this->tableName)->will($this->returnSelf());
$triggerMock->expects($this->exactly(6))->method('addStatement')->will($this->returnSelf());
$changelogMock = $this->getMockForAbstractClass('Magento\\Framework\\Mview\\View\\ChangelogInterface', [], '', false, false, true, []);
$changelogMock->expects($this->exactly(3))->method('getName')->will($this->returnValue('test_view_cl'));
$changelogMock->expects($this->exactly(3))->method('getColumnName')->will($this->returnValue('entity_id'));
$this->viewMock->expects($this->exactly(3))->method('getChangelog')->will($this->returnValue($changelogMock));
$this->triggerFactoryMock->expects($this->exactly(3))->method('create')->will($this->returnValue($triggerMock));
$otherChangelogMock = $this->getMockForAbstractClass('Magento\\Framework\\Mview\\View\\ChangelogInterface', [], '', false, false, true, []);
$otherChangelogMock->expects($this->exactly(3))->method('getName')->will($this->returnValue('other_test_view_cl'));
$otherChangelogMock->expects($this->exactly(3))->method('getColumnName')->will($this->returnValue('entity_id'));
$otherViewMock = $this->getMockForAbstractClass('Magento\\Framework\\Mview\\ViewInterface', [], '', false, false, true, []);
$otherViewMock->expects($this->exactly(1))->method('getId')->will($this->returnValue('other_id'));
$otherViewMock->expects($this->exactly(1))->method('getSubscriptions')->will($this->returnValue([['name' => $this->tableName], ['name' => 'otherTableName']]));
$otherViewMock->expects($this->exactly(3))->method('getChangelog')->will($this->returnValue($otherChangelogMock));
$this->viewMock->expects($this->exactly(3))->method('getId')->will($this->returnValue('this_id'));
$this->viewMock->expects($this->never())->method('getSubscriptions');
$this->viewCollectionMock->expects($this->exactly(1))->method('getViewsByStateMode')->with(\Magento\Framework\Mview\View\StateInterface::MODE_ENABLED)->will($this->returnValue([$this->viewMock, $otherViewMock]));
$this->connectionMock->expects($this->exactly(3))->method('dropTrigger')->with('triggerName')->will($this->returnValue(true));
$this->connectionMock->expects($this->exactly(3))->method('createTrigger')->with($triggerMock);
$this->model->create();
}
示例9: testGetTable
public function testGetTable()
{
$tableName = 'table';
$expectedTableName = 'expected_table';
$this->resourceModel->expects($this->once())->method('getTableName')->with($tableName)->will($this->returnValue($expectedTableName));
$this->assertSame($expectedTableName, $this->object->getTable($tableName));
// Check that table name is cached
$this->assertSame($expectedTableName, $this->object->getTable($tableName));
}
示例10: setUp
/**
* Initialization
*/
protected function setUp()
{
$this->adapterMock = $this->getMock('Magento\\Framework\\DB\\Adapter\\Pdo\\Mysql', [], [], '', false);
$this->appResourceMock = $this->getMock('Magento\\Framework\\App\\Resource', [], [], '', false);
$this->appResourceMock->expects($this->any())->method('getConnection')->will($this->returnValue($this->adapterMock));
$this->appResourceMock->expects($this->any())->method('getTableName')->willReturnArgument(0);
$objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
$this->taxItem = $objectManager->getObject('Magento\\Sales\\Model\\Resource\\Order\\Tax\\Item', ['resource' => $this->appResourceMock]);
}
示例11: setUp
public function setUp()
{
$this->adapterMock = $this->getMock('Magento\\Framework\\DB\\Adapter\\Pdo\\Mysql', [], [], '', false);
$this->resourceMock = $this->getMock('Magento\\Framework\\App\\Resource', [], [], '', false);
$this->resourceMock->expects($this->any())->method('getConnection')->willReturn($this->adapterMock);
$contextMock = $this->getMock('\\Magento\\Framework\\Model\\Resource\\Db\\Context', [], [], '', false);
$contextMock->expects($this->once())->method('getResources')->willReturn($this->resourceMock);
$this->nonceResource = new \Magento\Integration\Model\Resource\Oauth\Nonce($contextMock);
}
示例12: setUp
/**
* Set Up
*/
protected function setUp()
{
$objectManager = new ObjectManager($this);
$this->requestFilter = $this->getMockBuilder('Magento\\Framework\\Search\\Request\\Filter\\Range')->setMethods(['getField', 'getFrom', 'getTo'])->disableOriginalConstructor()->getMock();
$this->adapter = $this->getMockBuilder('\\Magento\\Framework\\DB\\Adapter\\AdapterInterface')->setMethods(['quote'])->getMockForAbstractClass();
$this->resource = $this->getMockBuilder('Magento\\Framework\\App\\Resource')->setMethods(['getConnection'])->disableOriginalConstructor()->getMock();
$this->resource->expects($this->once())->method('getConnection')->with(\Magento\Framework\App\Resource::DEFAULT_READ_RESOURCE)->will($this->returnValue($this->adapter));
$this->filter = $objectManager->getObject('Magento\\Framework\\Search\\Adapter\\Mysql\\Filter\\Builder\\Range', ['resource' => $this->resource]);
}
示例13: setUp
protected function setUp()
{
$adapter = $this->getMockBuilder('\\Magento\\Framework\\DB\\Adapter\\AdapterInterface')->getMock();
$this->resource = $this->getMock('Magento\\Framework\\App\\Resource', [], [], '', false);
$this->resource->expects($this->any())->method('getConnection')->will($this->returnValue($adapter));
$this->relation = $this->getMock('Magento\\Catalog\\Model\\Resource\\Product\\Relation', [], [], '', false);
$this->objectManagerHelper = new ObjectManagerHelper($this);
$this->configurable = $this->objectManagerHelper->getObject('Magento\\ConfigurableProduct\\Model\\Resource\\Product\\Type\\Configurable', ['resource' => $this->resource, 'catalogProductRelation' => $this->relation]);
}
示例14: setUp
protected function setUp()
{
$this->adapter = $this->getMockBuilder('\\Magento\\Framework\\DB\\Adapter\\AdapterInterface')->disableOriginalConstructor()->getMockForAbstractClass();
$this->resource = $this->getMockBuilder('\\Magento\\Framework\\App\\Resource')->setMethods(['getConnection'])->disableOriginalConstructor()->getMock();
$this->resource->expects($this->atLeastOnce())->method('getConnection')->with('write')->willReturn($this->adapter);
$this->indexScopeResolver = $this->getMockBuilder('\\Magento\\Indexer\\Model\\ScopeResolver\\IndexScopeResolver')->setMethods(['resolve'])->disableOriginalConstructor()->getMock();
$this->flatScopeResolver = $this->getMockBuilder('\\Magento\\Indexer\\Model\\ScopeResolver\\FlatScopeResolver')->setMethods(['resolve'])->disableOriginalConstructor()->getMock();
$objectManager = new ObjectManager($this);
$this->target = $objectManager->getObject('\\Magento\\Indexer\\Model\\IndexStructure', ['resource' => $this->resource, 'indexScopeResolver' => $this->indexScopeResolver, 'flatScopeResolver' => $this->flatScopeResolver]);
}
示例15: setUp
public function setUp()
{
$this->consumerMock = $this->getMock('Magento\\Integration\\Model\\Oauth\\Consumer', ['setUpdatedAt', 'getId'], [], '', false);
$this->adapterMock = $this->getMock('Magento\\Framework\\DB\\Adapter\\Pdo\\Mysql', [], [], '', false);
$this->resourceMock = $this->getMock('Magento\\Framework\\App\\Resource', [], [], '', false);
$this->resourceMock->expects($this->any())->method('getConnection')->willReturn($this->adapterMock);
$contextMock = $this->getMock('Magento\\Framework\\Model\\Resource\\Db\\Context', [], [], '', false);
$contextMock->expects($this->once())->method('getResources')->willReturn($this->resourceMock);
$this->consumerResource = new \Magento\Integration\Model\Resource\Oauth\Consumer($contextMock, new \Magento\Framework\Stdlib\DateTime());
}