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


PHP Resource::expects方法代码示例

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


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

示例1: 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

示例2: testResetSearchResult

 public function testResetSearchResult()
 {
     $this->resource->expects($this->once())->method('getTableName')->with('search_query', ResourceConnection::DEFAULT_CONNECTION)->willReturn('table_name_search_query');
     $this->connection->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);
 }
开发者ID:whoople,项目名称:magento2-testing,代码行数:7,代码来源:FulltextTest.php

示例3: testMove

 /**
  * @param string $flatTable
  * @param bool $isFlatTableExists
  * @param string $flatDropName
  * @param string $temporaryFlatTableName
  * @param array $expectedRenameTablesArgument
  * @dataProvider moveDataProvider
  */
 public function testMove($flatTable, $isFlatTableExists, $flatDropName, $temporaryFlatTableName, $expectedRenameTablesArgument)
 {
     $this->_connectionMock->expects($this->exactly(2))->method('dropTable')->with($flatDropName);
     $this->_connectionMock->expects($this->once())->method('isTableExists')->with($flatTable)->will($this->returnValue($isFlatTableExists));
     $this->_connectionMock->expects($this->once())->method('renameTablesBatch')->with($expectedRenameTablesArgument);
     $this->_resourceMock->expects($this->any())->method('getConnection')->will($this->returnValue($this->_connectionMock));
     $model = $this->_objectManager->getObject('Magento\\Catalog\\Model\\Indexer\\Product\\Flat\\TableData', ['resource' => $this->_resourceMock]);
     $model->move($flatTable, $flatDropName, $temporaryFlatTableName);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:17,代码来源:TableDataTest.php

示例4: testProcessPrice

 public function testProcessPrice()
 {
     $expectedResult = 'search_index.product_id IN (select entity_id from (TEST QUERY PART) as filter)';
     $scopeId = 0;
     $isNegation = false;
     $query = 'SELECT table.price FROM catalog_product_entity';
     $this->scope->expects($this->once())->method('getId')->will($this->returnValue($scopeId));
     $this->filter->expects($this->exactly(2))->method('getField')->will($this->returnValue('price'));
     $this->config->expects($this->exactly(1))->method('getAttribute')->with(\Magento\Catalog\Model\Product::ENTITY, 'price')->will($this->returnValue($this->attribute));
     $this->resource->expects($this->once())->method('getTableName')->with('catalog_product_index_price')->will($this->returnValue('table_name'));
     $this->select->expects($this->once())->method('from')->with(['main_table' => 'table_name'], 'entity_id')->will($this->returnSelf());
     $this->select->expects($this->once())->method('where')->with('SELECT table.min_price FROM catalog_product_entity')->will($this->returnSelf());
     $this->select->expects($this->once())->method('__toString')->will($this->returnValue('TEST QUERY PART'));
     $actualResult = $this->target->process($this->filter, $isNegation, $query);
     $this->assertSame($expectedResult, $this->removeWhitespaces($actualResult));
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:16,代码来源:PreprocessorTest.php

示例5: setUp

 public function setUp()
 {
     $this->repository = new RuleRepository();
     $this->role1 = $this->getMock('gatekeeper\\Role');
     $this->role1->expects($this->any())->method('getRoleId')->will($this->returnValue('1'));
     $this->role1->expects($this->any())->method('getParentRole')->will($this->throwException(new HasNoParentRoleException()));
     $this->role2 = $this->getMock('gatekeeper\\Role');
     $this->role2->expects($this->any())->method('getRoleId')->will($this->returnValue('2'));
     $this->role2->expects($this->any())->method('getParentRole')->will($this->returnValue($this->role1));
     $this->resource1 = $this->getMock('gatekeeper\\Resource');
     $this->resource1->expects($this->any())->method('getResourceId')->will($this->returnValue('images'));
     $this->resource1->expects($this->any())->method('getParentResource')->will($this->throwException(new HasNoParentResourceException()));
     $this->resource2 = $this->getMock('gatekeeper\\Resource');
     $this->resource2->expects($this->any())->method('getResourceId')->will($this->returnValue('upload'));
     $this->resource2->expects($this->any())->method('getParentResource')->will($this->returnValue($this->resource1));
 }
开发者ID:heho,项目名称:gatekeeper,代码行数:16,代码来源:RuleRepositoryTest.php

示例6: testDeleteCl

 /**
  * Test deleting changelog table
  */
 public function testDeleteCl()
 {
     $this->_changelogMock->expects($this->any())->method('getName')->will($this->returnValue('catalog_product_flat_cl'));
     $this->_connectionMock->expects($this->once())->method('getTables')->with('catalog_product_flat_%')->will($this->returnValue(['catalog_product_flat_cl']));
     $this->_connectionMock->expects($this->never())->method('dropTable');
     $this->_resourceMock->expects($this->once())->method('getConnection')->will($this->returnValue($this->_connectionMock));
     $this->_setStoreManagerExpectedStores([1]);
     $this->_model->deleteAbandonedStoreFlatTables();
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:12,代码来源:IndexerTest.php

示例7: testMoveWithExistentFlatTable

 public function testMoveWithExistentFlatTable()
 {
     $flatTable = 'flat_table';
     $flatDropName = 'flat_table_to_drop';
     $temporaryFlatTableName = 'flat_tmp';
     $describedColumns = ['column_11' => 'column_definition', 'column_2' => 'column_definition', 'column_3' => 'column_definition'];
     $flatColumns = ['column_1' => 'column_definition', 'column_2' => 'column_definition', 'column_3' => 'column_definition'];
     $selectMock = $this->getMock('Magento\\Framework\\DB\\Select', [], [], '', false);
     $selectMock->expects($this->once())->method('from')->with(['tf' => sprintf('%s_tmp_indexer', $flatTable)], ['column_2', 'column_3']);
     $sql = md5(time());
     $selectMock->expects($this->once())->method('insertFromSelect')->with($flatTable, ['column_2', 'column_3'])->will($this->returnValue($sql));
     $this->_connectionMock->expects($this->once())->method('query')->with($sql);
     $this->_connectionMock->expects($this->once())->method('select')->will($this->returnValue($selectMock));
     $this->_connectionMock->expects($this->once())->method('isTableExists')->with($flatTable)->will($this->returnValue(true));
     $this->_connectionMock->expects($this->once())->method('describeTable')->with($flatTable)->will($this->returnValue($describedColumns));
     $this->_productIndexerHelper->expects($this->once())->method('getFlatColumns')->will($this->returnValue($flatColumns));
     $this->_connectionMock->expects($this->once())->method('dropTable')->with(sprintf('%s_tmp_indexer', $flatTable));
     $this->_resourceMock->expects($this->any())->method('getConnection')->will($this->returnValue($this->_connectionMock));
     $model = $this->_objectManager->getObject('Magento\\Catalog\\Model\\Indexer\\Product\\Flat\\Action\\Rows\\TableData', ['resource' => $this->_resourceMock, 'productIndexerHelper' => $this->_productIndexerHelper]);
     $model->move($flatTable, $flatDropName, $temporaryFlatTableName);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:21,代码来源:TableDataTest.php

示例8: testProcessNotStaticAttribute

 public function testProcessNotStaticAttribute()
 {
     $expectedResult = 'search_index.entity_id IN (select entity_id from (TEST QUERY PART) as filter)';
     $scopeId = 0;
     $isNegation = false;
     $query = 'SELECT field FROM table';
     $attributeId = 1234567;
     $this->scope->expects($this->once())->method('getId')->will($this->returnValue($scopeId));
     $this->filter->expects($this->exactly(4))->method('getField')->will($this->returnValue('not_static_attribute'));
     $this->config->expects($this->exactly(1))->method('getAttribute')->with(\Magento\Catalog\Model\Product::ENTITY, 'not_static_attribute')->will($this->returnValue($this->attribute));
     $this->attribute->expects($this->once())->method('isStatic')->will($this->returnValue(false));
     $this->attribute->expects($this->once())->method('getBackendTable')->will($this->returnValue('backend_table'));
     $this->attribute->expects($this->once())->method('getAttributeId')->will($this->returnValue($attributeId));
     $this->connection->expects($this->once())->method('getIfNullSql')->with('current_store.value', 'main_table.value')->will($this->returnValue('IF NULL SQL'));
     $this->resource->expects($this->once())->method('getTableName')->willReturn('catalog_product_entity');
     $this->select->expects($this->once())->method('from')->with(['e' => 'catalog_product_entity'], ['entity_id'])->will($this->returnSelf());
     $this->select->expects($this->once())->method('join')->with(['main_table' => 'backend_table'], "main_table.entity_id = e.entity_id")->will($this->returnSelf());
     $this->select->expects($this->once())->method('joinLeft')->with(['current_store' => 'backend_table'])->will($this->returnSelf());
     $this->select->expects($this->once())->method('columns')->with(['not_static_attribute' => 'IF NULL SQL'])->will($this->returnSelf());
     $this->select->expects($this->exactly(2))->method('where')->will($this->returnSelf());
     $this->select->expects($this->once())->method('__toString')->will($this->returnValue('TEST QUERY PART'));
     $actualResult = $this->target->process($this->filter, $isNegation, $query);
     $this->assertSame($expectedResult, $this->removeWhitespaces($actualResult));
 }
开发者ID:dragonsword007008,项目名称:magento2,代码行数:24,代码来源:PreprocessorTest.php


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