本文整理汇总了PHP中Magento\Framework\Module\Manager::expects方法的典型用法代码示例。如果您正苦于以下问题:PHP Manager::expects方法的具体用法?PHP Manager::expects怎么用?PHP Manager::expects使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\Module\Manager
的用法示例。
在下文中一共展示了Manager::expects方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testConvertWithDisabledModules
public function testConvertWithDisabledModules()
{
$testDom = $this->filePath . 'import.xml';
$dom = new \DOMDocument();
$dom->load($testDom);
$notExpectedArray = (include $this->filePath . 'import.php');
$this->moduleManager->expects($this->any())->method('isOutputEnabled')->willReturn(false);
$this->assertNotEquals($notExpectedArray, $this->model->convert($dom));
}
示例2: testAddSwatchAttributeType
/**
* @dataProvider dataAddSwatch
*/
public function testAddSwatchAttributeType($exp)
{
$this->moduleManagerMock->expects($this->once())->method('isOutputEnabled')->willReturn($exp['isOutputEnabled']);
$eventMock = $this->getMock('\\Magento\\Framework\\Event', ['getResponse'], [], '', false);
$this->eventObserverMock->expects($this->exactly($exp['methods_count']))->method('getEvent')->willReturn($eventMock);
$response = $this->getMock('\\Magento\\Framework\\DataObject', ['getTypes'], [], '', false);
$eventMock->expects($this->exactly($exp['methods_count']))->method('getResponse')->willReturn($response);
$response->expects($this->exactly($exp['methods_count']))->method('getTypes')->willReturn($exp['outputArray']);
$this->observerMock->execute($this->eventObserverMock);
}
示例3: testAddFields
/**
* @dataProvider dataAddFields
*/
public function testAddFields($expected)
{
$this->moduleManagerMock->expects($this->once())->method('isOutputEnabled')->willReturn($expected['isOutputEnabled']);
$this->eventObserverMock->expects($this->exactly($expected['methods_count']))->method('getForm')->willReturn($this->formMock);
$element = $this->getMock('Magento\\Framework\\Data\\Form\\Element\\AbstractElement', [], [], '', false);
$this->formMock->expects($this->exactly($expected['methods_count']))->method('getElement')->with('base_fieldset')->willReturn($element);
$element->expects($this->exactly($expected['addField_count']))->method('addField');
$this->yesNoMock->expects($this->exactly($expected['yesno_count']))->method('toOptionArray');
$this->observerMock->execute($this->eventObserverMock);
}
示例4: testCheckIfDepersonalize
/**
* @param array $requestResult
* @param bool $moduleManagerResult
* @param bool $cacheConfigResult
* @param bool $layoutResult
* @param bool $can Depersonalize
* @dataProvider checkIfDepersonalizeDataProvider
*/
public function testCheckIfDepersonalize(array $requestResult, $moduleManagerResult, $cacheConfigResult, $layoutResult, $canDepersonalize)
{
$this->requestMock->expects($this->any())->method('isAjax')->willReturn($requestResult['ajax']);
$this->requestMock->expects($this->any())->method('isGet')->willReturn($requestResult['get']);
$this->requestMock->expects($this->any())->method('isHead')->willReturn($requestResult['head']);
$this->moduleManagerMock->expects($this->any())->method('isEnabled')->with('Magento_PageCache')->willReturn($moduleManagerResult);
$this->cacheConfigMock->expects($this->any())->method('isEnabled')->willReturn($cacheConfigResult);
$layoutMock = $this->getMockForAbstractClass('Magento\\Framework\\View\\LayoutInterface', [], '', false);
$layoutMock->expects($this->any())->method('isCacheable')->willReturn($layoutResult);
$object = new DepersonalizeChecker($this->requestMock, $this->moduleManagerMock, $this->cacheConfigMock);
$this->assertEquals($canDepersonalize, $object->checkIfDepersonalize($layoutMock));
}
示例5: testToOptionArray
public function testToOptionArray()
{
$customerGroups = [['label' => __('ALL GROUPS'), 'value' => 32000], ['label' => __('NOT LOGGED IN'), 'value' => 0]];
$this->moduleManagerMock->expects($this->any())->method('isEnabled')->willReturn(true);
$this->searchCriteriaBuilderMock->expects($this->any())->method('create')->willReturn($this->searchCriteriaMock);
$this->groupRepositoryMock->expects($this->any())->method('getList')->with($this->searchCriteriaMock)->willReturn($this->searchResultMock);
$this->groupRepositoryMock->expects($this->any())->method('getList')->with($this->searchCriteriaMock)->willReturn($this->searchResultMock);
$groupTest = $this->getMockBuilder('\\Magento\\Customer\\Api\\Data\\GroupInterface')->disableOriginalConstructor()->setMethods(['getCode', 'getId'])->getMockForAbstractClass();
$groupTest->expects($this->any())->method('getCode')->willReturn(__('NOT LOGGED IN'));
$groupTest->expects($this->any())->method('getId')->willReturn(0);
$groups = [$groupTest];
$this->searchResultMock->expects($this->any())->method('getItems')->willReturn($groups);
$this->assertEquals($customerGroups, $this->model->toOptionArray());
}
示例6: testGetModuleDataRefreshOrStatement
/**
* Tests modules data returns array and saving in DB
*
* @dataProvider itemDataProvider
* @return void
*/
public function testGetModuleDataRefreshOrStatement($data)
{
$moduleCollectionMock = $this->getMockBuilder('Magento\\NewRelicReporting\\Model\\ResourceModel\\Module\\Collection')->disableOriginalConstructor()->getMock();
/** @var \Magento\NewRelicReporting\Model\Module|\PHPUnit_Framework_MockObject_MockObject $itemMock */
$itemMock = $this->getMock('Magento\\NewRelicReporting\\Model\\Module', ['getName', 'getData', 'setData', 'getState', 'save'], [], '', false);
$modulesMockArray = ['Module_Name1' => ['name' => 'Module_Name1', 'setup_version' => '2.0.0', 'sequence' => []]];
$itemMock->setData($data);
$testChangesMockArray = ['entity_id' => '3', 'name' => 'Name', 'active' => 'false', 'state' => 'enabled', 'setup_version' => '2.0.0', 'some_param' => 'some_value', 'updated_at' => '2015-09-02 18:38:17'];
$itemMockArray = [$itemMock];
$enabledModulesMockArray = ['Module_Name2'];
$allModulesMockArray = ['Module_Name1', 'Module_Name2'];
$this->moduleCollectionFactoryMock->expects($this->any())->method('create')->willReturn($moduleCollectionMock);
$this->moduleFactoryMock->expects($this->any())->method('create')->willReturn($itemMock);
$itemMock->expects($this->any())->method('setData')->willReturnSelf();
$itemMock->expects($this->any())->method('save')->willReturnSelf();
$itemMock->expects($this->any())->method('getState')->willReturn($data['state']);
$itemMock->expects($this->any())->method('getName')->willReturn($data['name']);
$moduleCollectionMock->expects($this->any())->method('getItems')->willReturn($itemMockArray);
$itemMock->expects($this->any())->method('getData')->willReturn($testChangesMockArray);
$this->fullModuleListMock->expects($this->once())->method('getAll')->willReturn($modulesMockArray);
$this->fullModuleListMock->expects($this->any())->method('getNames')->willReturn($allModulesMockArray);
$this->moduleListMock->expects($this->any())->method('getNames')->willReturn($enabledModulesMockArray);
$this->moduleManagerMock->expects($this->any())->method('isOutputEnabled')->will($this->returnValue(true));
$this->assertInternalType('array', $this->model->getModuleData());
}
示例7: testGetCustomerLoadCustomerFromService
/**
* test get customer method, method returns customer from service
*/
public function testGetCustomerLoadCustomerFromService()
{
$this->moduleManagerMock->expects($this->once())->method('isEnabled')->with($this->equalTo('Magento_PageCache'))->will($this->returnValue(false));
$this->customerSessionMock->expects($this->once())->method('getId')->will($this->returnValue($this->customerId));
$this->customerRepositoryMock->expects($this->once())->method('getById')->with($this->equalTo($this->customerId))->will($this->returnValue($this->customerDataMock));
$this->assertEquals($this->customerDataMock, $this->currentCustomer->getCustomer());
}
示例8: testAroundDispatchException
/**
* @param array $schemaValueMap
* @param array $dataValueMap
*
* @dataProvider aroundDispatchExceptionDataProvider
* @expectedException \Magento\Framework\Module\Exception
* @expectedExceptionMessage Looks like database is outdated. Please, use setup tool to perform update
*/
public function testAroundDispatchException(array $schemaValueMap, array $dataValueMap)
{
$this->_cacheMock->expects($this->once())->method('load')->with('db_is_up_to_date')->will($this->returnValue(false));
$this->_cacheMock->expects($this->never())->method('save');
$this->moduleManager->expects($this->any())->method('isDbSchemaUpToDate')->will($this->returnValueMap($schemaValueMap));
$this->moduleManager->expects($this->any())->method('isDbDataUpToDate')->will($this->returnValueMap($dataValueMap));
$this->_model->aroundDispatch($this->subjectMock, $this->closureMock, $this->requestMock);
}
示例9: testAfterAddressSave
public function testAfterAddressSave()
{
$this->moduleManagerMock->expects($this->once())->method('isEnabled')->with('Magento_PageCache')->willReturn(true);
$this->cacheConfigMock->expects($this->once())->method('isEnabled')->willReturn(true);
$this->taxHelperMock->expects($this->any())->method('isCatalogPriceDisplayAffectedByTax')->willReturn(true);
$address = $this->objectManager->getObject('Magento\\Customer\\Model\\Address');
$address->setIsDefaultShipping(true);
$address->setIsDefaultBilling(true);
$address->setIsPrimaryBilling(true);
$address->setIsPrimaryShipping(true);
$address->setCountryId(1);
$address->setData('postcode', 11111);
$this->customerSessionMock->expects($this->once())->method('setDefaultTaxBillingAddress')->with(['country_id' => 1, 'region_id' => null, 'postcode' => 11111]);
$this->customerSessionMock->expects($this->once())->method('setDefaultTaxShippingAddress')->with(['country_id' => 1, 'region_id' => null, 'postcode' => 11111]);
$this->observerMock->expects($this->once())->method('getCustomerAddress')->willReturn($address);
$this->session->afterAddressSave($this->observerMock);
}
示例10: testAroundDispatch
public function testAroundDispatch()
{
$this->moduleManagerMock->expects($this->any())->method('isEnabled')->with('Magento_PageCache')->willReturn(true);
$this->cacheConfigMock->expects($this->any())->method('isEnabled')->willReturn(true);
$this->taxHelperMock->expects($this->any())->method('isCatalogPriceDisplayAffectedByTax')->willReturn(true);
$this->customerSessionMock->expects($this->once())->method('getDefaultTaxBillingAddress')->willReturn(['country_id' => 1, 'region_id' => null, 'postcode' => 11111]);
$this->customerSessionMock->expects($this->once())->method('getDefaultTaxShippingAddress')->willReturn(['country_id' => 1, 'region_id' => null, 'postcode' => 11111]);
$this->customerSessionMock->expects($this->once())->method('getCustomerTaxClassId')->willReturn(1);
$this->taxCalculationMock->expects($this->once())->method('getTaxRates')->with(['country_id' => 1, 'region_id' => null, 'postcode' => 11111], ['country_id' => 1, 'region_id' => null, 'postcode' => 11111], 1)->willReturn([]);
$this->httpContextMock->expects($this->once())->method('setValue')->with('tax_rates', [], 0);
$action = $this->objectManager->getObject('Magento\\Framework\\App\\Action\\Action');
$request = $this->getMock('\\Magento\\Framework\\App\\Request\\Http', ['getActionName'], [], '', false);
$expectedResult = 'expectedResult';
$proceed = function ($request) use($expectedResult) {
return $expectedResult;
};
$this->contextPlugin->aroundDispatch($action, $proceed, $request);
}
示例11: testExecute
public function testExecute()
{
$this->moduleManagerMock->expects($this->once())->method('isEnabled')->with('Magento_PageCache')->willReturn(true);
$this->cacheConfigMock->expects($this->once())->method('isEnabled')->willReturn(true);
$this->weeeHelperMock->expects($this->any())->method('isEnabled')->willReturn(true);
$customerMock = $this->getMockBuilder('Magento\\Customer\\Model\\Data\\Customer')->disableOriginalConstructor()->getMock();
$this->observerMock->expects($this->once())->method('getData')->with('customer')->willReturn($customerMock);
$address = $this->objectManager->getObject('Magento\\Customer\\Model\\Data\\Address');
$address->setIsDefaultShipping(true);
$address->setIsDefaultBilling(true);
$address->setCountryId(1);
$address->setPostCode(11111);
$addresses = [$address];
$customerMock->expects($this->once())->method('getAddresses')->willReturn($addresses);
$this->customerSessionMock->expects($this->once())->method('setDefaultTaxBillingAddress')->with(['country_id' => 1, 'region_id' => null, 'postcode' => 11111]);
$this->customerSessionMock->expects($this->once())->method('setDefaultTaxShippingAddress')->with(['country_id' => 1, 'region_id' => null, 'postcode' => 11111]);
$this->session->execute($this->observerMock);
}
示例12: testGetStockOption
/**
* Run test getStockOption method
*
* @param bool $moduleEnabled
* @return void
*
* @dataProvider dataProviderModuleEnabled
*/
public function testGetStockOption($moduleEnabled)
{
$this->moduleManager->expects($this->once())->method('isEnabled')->with('Magento_CatalogInventory')->will($this->returnValue($moduleEnabled));
if ($moduleEnabled) {
$this->stockMock->expects($this->once())->method('toOptionArray')->will($this->returnValue(['test-value', 'test-value']));
}
$result = $this->inventory->getStockOption();
$this->assertEquals($moduleEnabled, !empty($result));
}
示例13: testFromArray
/**
* Run test fromArray method
*
* @return void
*/
public function testFromArray()
{
$data = ['stock_item' => ['stock-item-data']];
$stockItemMock = $this->getMockForAbstractClass('Magento\\Framework\\Api\\AbstractSimpleObject', [], '', false, true, true, ['setProduct']);
$this->moduleManager->expects($this->once())->method('isEnabled')->with('Magento_CatalogInventory')->will($this->returnValue(true));
$this->dataObjectHelperMock->expects($this->once())->method('populateWithArray')->with($stockItemMock, $data['stock_item'], '\\Magento\\CatalogInventory\\Api\\Data\\StockItemInterface')->will($this->returnSelf());
$this->stockItemFactoryMock->expects($this->once())->method('create')->will($this->returnValue($stockItemMock));
$stockItemMock->expects($this->once())->method('setProduct')->with($this->model);
$this->assertEquals($this->model, $this->model->fromArray($data));
}
示例14: testUpdateDataNoUpdates
public function testUpdateDataNoUpdates()
{
$this->moduleManager->expects($this->once())->method('isDbSchemaUpToDate')->with('Test_Module', 'catalog_setup')->will($this->returnValue(true));
$this->moduleManager->expects($this->once())->method('isDbDataUpToDate')->with('Test_Module', 'catalog_setup')->will($this->returnValue(true));
$this->_factoryMock->expects($this->never())->method('create');
$this->_appStateMock->expects($this->at(0))->method('setUpdateMode')->with(true);
$this->_appStateMock->expects($this->at(1))->method('setUpdateMode')->with(false);
$this->_factoryMock->expects($this->never())->method('create');
$this->_model->updateScheme();
$this->_model->updateData();
}
示例15: testAroundDispatchBasedOnShipping
public function testAroundDispatchBasedOnShipping()
{
$this->customerSessionMock->expects($this->once())->method('isLoggedIn')->willReturn(true);
$this->moduleManagerMock->expects($this->once())->method('isEnabled')->with('Magento_PageCache')->willReturn(true);
$this->cacheConfigMock->expects($this->once())->method('isEnabled')->willReturn(true);
$this->weeeHelperMock->expects($this->once())->method('isEnabled')->willReturn(true);
$this->taxHelperMock->expects($this->once())->method('getTaxBasedOn')->willReturn('shipping');
$storeMock = $this->getMockBuilder('Magento\\Store\\Model\\Store')->disableOriginalConstructor()->getMock();
$storeMock->expects($this->once())->method('getWebsiteId')->willReturn(1);
$this->storeManagerMock->expects($this->once())->method('getStore')->willReturn($storeMock);
$this->scopeConfigMock->expects($this->at(0))->method('getValue')->with(\Magento\Tax\Model\Config::CONFIG_XML_PATH_DEFAULT_COUNTRY, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, null)->willReturn('US');
$this->scopeConfigMock->expects($this->at(1))->method('getValue')->with(\Magento\Tax\Model\Config::CONFIG_XML_PATH_DEFAULT_REGION, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, null)->willReturn(0);
$this->customerSessionMock->expects($this->once())->method('getDefaultTaxShippingAddress')->willReturn(['country_id' => 'US', 'region_id' => 1]);
$this->weeeTaxMock->expects($this->once())->method('isWeeeInLocation')->with('US', 1, 1)->willReturn(true);
$this->httpContextMock->expects($this->once())->method('setValue')->with('weee_tax_region', ['countryId' => 'US', 'regionId' => 1], 0);
$action = $this->objectManager->getObject('Magento\\Framework\\App\\Test\\Unit\\Action\\Stub\\ActionStub');
$request = $this->getMock('\\Magento\\Framework\\App\\Request\\Http', ['getActionName'], [], '', false);
$expectedResult = 'expectedResult';
$proceed = function ($request) use($expectedResult) {
return $expectedResult;
};
$this->contextPlugin->aroundDispatch($action, $proceed, $request);
}