本文整理汇总了PHP中Magento\Framework\Event\Observer::expects方法的典型用法代码示例。如果您正苦于以下问题:PHP Observer::expects方法的具体用法?PHP Observer::expects怎么用?PHP Observer::expects使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\Event\Observer
的用法示例。
在下文中一共展示了Observer::expects方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testSyncRemove
public function testSyncRemove()
{
$this->eventObserverMock->expects($this->once())->method('getDataObject')->willReturn($this->salesModelMock);
$this->salesModelMock->expects($this->once())->method('getId')->willReturn('sales-id-value');
$this->gridAggregatorMock->expects($this->once())->method('purge')->with('sales-id-value');
$this->unit->execute($this->eventObserverMock);
}
示例2: setUp
protected function setUp()
{
$this->_observer = $this->getMock('Magento\\Framework\\Event\\Observer', array(), array(), '', false);
$this->_testModel = new \Magento\RecurringPayment\Model\Observer\AddFormExcludedAttribute();
$this->_event = $this->getMock('Magento\\Framework\\Event', array('getProductElement', 'getProduct', 'getResult', 'getBuyRequest', 'getQuote', 'getApi', 'getObject'), array(), '', false);
$this->_observer->expects($this->any())->method('getEvent')->will($this->returnValue($this->_event));
}
示例3: testExecute
/**
* @param bool $cacheState
* @param bool $varnishIsEnabled
* @param bool $scopeIsPrivate
* @param int|null $blockTtl
* @param string $expectedOutput
* @dataProvider processLayoutRenderDataProvider
*/
public function testExecute($cacheState, $varnishIsEnabled, $scopeIsPrivate, $blockTtl, $expectedOutput)
{
$eventMock = $this->getMock('Magento\\Framework\\Event', ['getLayout', 'getElementName', 'getTransport'], [], '', false);
$this->_observerMock->expects($this->once())->method('getEvent')->will($this->returnValue($eventMock));
$eventMock->expects($this->once())->method('getLayout')->will($this->returnValue($this->_layoutMock));
$this->_configMock->expects($this->any())->method('isEnabled')->will($this->returnValue($cacheState));
if ($cacheState) {
$eventMock->expects($this->once())->method('getElementName')->will($this->returnValue('blockName'));
$eventMock->expects($this->once())->method('getTransport')->will($this->returnValue($this->_transport));
$this->_layoutMock->expects($this->once())->method('isCacheable')->will($this->returnValue(true));
$this->_layoutMock->expects($this->any())->method('getUpdate')->will($this->returnSelf());
$this->_layoutMock->expects($this->any())->method('getHandles')->will($this->returnValue([]));
$this->_layoutMock->expects($this->once())->method('getBlock')->will($this->returnValue($this->_blockMock));
if ($varnishIsEnabled) {
$this->_blockMock->expects($this->once())->method('getData')->with('ttl')->will($this->returnValue($blockTtl));
$this->_blockMock->expects($this->any())->method('getUrl')->will($this->returnValue('page_cache/block/wrapesi/with/handles/and/other/stuff'));
}
if ($scopeIsPrivate) {
$this->_blockMock->expects($this->once())->method('getNameInLayout')->will($this->returnValue('testBlockName'));
$this->_blockMock->expects($this->once())->method('isScopePrivate')->will($this->returnValue($scopeIsPrivate));
}
$this->_configMock->expects($this->any())->method('getType')->will($this->returnValue($varnishIsEnabled));
}
$this->_model->execute($this->_observerMock);
$this->assertEquals($expectedOutput, $this->_transport['output']);
}
示例4: setUp
protected function setUp()
{
$this->stockHelper = $this->getMock('Magento\\CatalogInventory\\Helper\\Stock', [], [], '', false);
$this->event = $this->getMockBuilder('Magento\\Framework\\Event')->disableOriginalConstructor()->setMethods(['getProduct'])->getMock();
$this->eventObserver = $this->getMockBuilder('Magento\\Framework\\Event\\Observer')->disableOriginalConstructor()->setMethods(['getEvent'])->getMock();
$this->eventObserver->expects($this->atLeastOnce())->method('getEvent')->will($this->returnValue($this->event));
$this->observer = (new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this))->getObject('Magento\\CatalogInventory\\Observer\\AddInventoryDataObserver', ['stockHelper' => $this->stockHelper]);
}
示例5: testSyncInsert
public function testSyncInsert()
{
$this->eventObserverMock->expects($this->once())->method('getObject')->willReturn($this->salesModelMock);
$this->salesModelMock->expects($this->once())->method('getId')->willReturn('sales-id-value');
$this->scopeConfigurationMock->expects($this->once())->method('getValue')->with('dev/grid/async_indexing', 'default', null)->willReturn(false);
$this->gridAggregatorMock->expects($this->once())->method('refresh')->with('sales-id-value');
$this->unit->execute($this->eventObserverMock);
}
示例6: setUp
protected function setUp()
{
$this->resourceStock = $this->getMock('Magento\\CatalogInventory\\Model\\ResourceModel\\Stock', [], [], '', false);
$this->event = $this->getMockBuilder('Magento\\Framework\\Event')->disableOriginalConstructor()->setMethods(['getWebsite'])->getMock();
$this->eventObserver = $this->getMockBuilder('Magento\\Framework\\Event\\Observer')->disableOriginalConstructor()->setMethods(['getEvent'])->getMock();
$this->eventObserver->expects($this->atLeastOnce())->method('getEvent')->will($this->returnValue($this->event));
$this->observer = (new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this))->getObject('Magento\\CatalogInventory\\Observer\\UpdateItemsStockUponConfigChangeObserver', ['resourceStock' => $this->resourceStock]);
}
示例7: setUp
protected function setUp()
{
$this->subtractQuoteInventoryObserver = $this->getMock('Magento\\CatalogInventory\\Observer\\SubtractQuoteInventoryObserver', [], [], '', false);
$this->reindexQuoteInventoryObserver = $this->getMock('Magento\\CatalogInventory\\Observer\\ReindexQuoteInventoryObserver', [], [], '', false);
$this->event = $this->getMockBuilder('Magento\\Framework\\Event')->disableOriginalConstructor()->setMethods(['getProduct', 'getCollection', 'getCreditmemo', 'getQuote', 'getWebsite'])->getMock();
$this->eventObserver = $this->getMockBuilder('Magento\\Framework\\Event\\Observer')->disableOriginalConstructor()->setMethods(['getEvent'])->getMock();
$this->eventObserver->expects($this->atLeastOnce())->method('getEvent')->will($this->returnValue($this->event));
$this->observer = (new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this))->getObject('Magento\\CatalogInventory\\Observer\\CheckoutAllSubmitAfterObserver', ['subtractQuoteInventoryObserver' => $this->subtractQuoteInventoryObserver, 'reindexQuoteInventoryObserver' => $this->reindexQuoteInventoryObserver]);
}
示例8: 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);
}
示例9: setUp
public function setUp()
{
$this->mockSymbolFactory = $this->getMock('Magento\\CurrencySymbol\\Model\\System\\CurrencysymbolFactory', ['create'], [], '', false);
$this->mockSymbol = $this->getMock('Magento\\CurrencySymbol\\Model\\System\\Currencysymbol', ['getCurrencySymbol'], [], '', false);
$this->mockEventObserver = $this->getMock('Magento\\Framework\\Event\\Observer', ['getEvent'], [], '', false);
$this->mockEvent = $this->getMock('Magento\\Framework\\Event', ['getBaseCode', 'getCurrencyOptions'], [], '', false);
$this->mockEventObserver->expects($this->any())->method('getEvent')->willReturn($this->mockEvent);
$this->mockSymbolFactory->expects($this->any())->method('create')->willReturn($this->mockSymbol);
$this->observer = new \Magento\CurrencySymbol\Observer\CurrencyDisplayOptions($this->mockSymbolFactory);
}
示例10: testNoRoute
/**
* @covers \Magento\Cms\Observer\NoRouteObserver::execute
*/
public function testNoRoute()
{
$this->observerMock->expects($this->atLeastOnce())->method('getEvent')->willReturn($this->eventMock);
$this->eventMock->expects($this->atLeastOnce())->method('getStatus')->willReturn($this->objectMock);
$this->objectMock->expects($this->atLeastOnce())->method('setLoaded')->with(true)->willReturnSelf();
$this->objectMock->expects($this->atLeastOnce())->method('setForwardModule')->with('cms')->willReturnSelf();
$this->objectMock->expects($this->atLeastOnce())->method('setForwardController')->with('index')->willReturnSelf();
$this->objectMock->expects($this->atLeastOnce())->method('setForwardAction')->with('noroute')->willReturnSelf();
$this->assertEquals($this->noRouteObserver, $this->noRouteObserver->execute($this->observerMock));
}
示例11: 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);
}
示例12: setUp
protected function setUp()
{
$this->storeManagerMock = $this->getMockBuilder('Magento\\Store\\Model\\StoreManagerInterface')->disableOriginalConstructor()->getMock();
$this->configMock = $this->getMockBuilder('Magento\\Customer\\Model\\Config\\Share')->disableOriginalConstructor()->getMock();
$this->quoteRepositoryMock = $this->getMock('\\Magento\\Quote\\Api\\CartRepositoryInterface');
$this->observerMock = $this->getMockBuilder('Magento\\Framework\\Event\\Observer')->disableOriginalConstructor()->getMock();
$this->eventMock = $this->getMockBuilder('Magento\\Framework\\Event')->disableOriginalConstructor()->setMethods(['getCustomerDataObject'])->getMock();
$this->observerMock->expects($this->any())->method('getEvent')->will($this->returnValue($this->eventMock));
$objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
$this->customerQuote = $objectManager->getObject('Magento\\Quote\\Observer\\Backend\\CustomerQuoteObserver', ['storeManager' => $this->storeManagerMock, 'config' => $this->configMock, 'quoteRepository' => $this->quoteRepositoryMock]);
}
示例13: setUp
protected function setUp()
{
$this->stockIndexerProcessor = $this->getMock('Magento\\CatalogInventory\\Model\\Indexer\\Stock\\Processor', ['reindexList'], [], '', false);
$this->stockManagement = $this->getMock('Magento\\CatalogInventory\\Model\\StockManagement', [], [], '', false);
$this->stockConfiguration = $this->getMockForAbstractClass('Magento\\CatalogInventory\\Api\\StockConfigurationInterface', ['isAutoReturnEnabled', 'isDisplayProductStockStatus'], '', false);
$this->priceIndexer = $this->getMockBuilder('Magento\\Catalog\\Model\\Indexer\\Product\\Price\\Processor')->disableOriginalConstructor()->getMock();
$this->event = $this->getMockBuilder('Magento\\Framework\\Event')->disableOriginalConstructor()->setMethods(['getProduct', 'getCollection', 'getCreditmemo', 'getQuote', 'getWebsite'])->getMock();
$this->eventObserver = $this->getMockBuilder('Magento\\Framework\\Event\\Observer')->disableOriginalConstructor()->setMethods(['getEvent'])->getMock();
$this->eventObserver->expects($this->atLeastOnce())->method('getEvent')->will($this->returnValue($this->event));
$this->observer = (new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this))->getObject('Magento\\CatalogInventory\\Observer\\RefundOrderInventoryObserver', ['stockConfiguration' => $this->stockConfiguration, 'stockManagement' => $this->stockManagement, 'stockIndexerProcessor' => $this->stockIndexerProcessor, 'priceIndexer' => $this->priceIndexer]);
}
示例14: setUp
/**
* Set up all mocks and data for test
*/
public function setUp()
{
$this->configMock = $this->getMock('Magento\\PageCache\\Model\\Config', ['getType', 'isEnabled'], [], '', false);
$this->typeListMock = $this->getMock('Magento\\Framework\\App\\Cache\\TypeList', [], [], '', false);
$this->model = new \Magento\PageCache\Observer\InvalidateCacheIfChanged($this->configMock, $this->typeListMock);
$this->observerMock = $this->getMock('Magento\\Framework\\Event\\Observer', [], [], '', false);
$eventMock = $this->getMock('Magento\\Framework\\Event', ['getObject'], [], '', false);
$this->objectMock = $this->getMockForAbstractClass('Magento\\Framework\\DataObject\\IdentityInterface', [], '', false);
$eventMock->expects($this->any())->method('getObject')->willReturn($this->objectMock);
$this->observerMock->expects($this->any())->method('getEvent')->willReturn($eventMock);
}
示例15: setUp
protected function setUp()
{
$this->_observer = $this->getMock('Magento\\Framework\\Event\\Observer', array(), array(), '', false);
$this->_fieldsBlock = $this->getMock('\\Magento\\RecurringPayment\\Block\\Fields', array('getFieldLabel'), array(), '', false);
$this->_recurringPaymentFactory = $this->getMock('\\Magento\\RecurringPayment\\Model\\RecurringPaymentFactory', array('create'), array(), '', false);
$this->_paymentFactory = $this->getMock('\\Magento\\RecurringPayment\\Model\\PaymentFactory', array('create', 'importProduct'), array(), '', false);
$helper = new \Magento\TestFramework\Helper\ObjectManager($this);
$this->_testModel = $helper->getObject('Magento\\RecurringPayment\\Model\\Observer', array('recurringPaymentFactory' => $this->_recurringPaymentFactory, 'fields' => $this->_fieldsBlock, 'paymentFactory' => $this->_paymentFactory));
$this->_event = $this->getMock('Magento\\Framework\\Event', array('getProductElement', 'getProduct', 'getResult', 'getBuyRequest', 'getQuote', 'getApi', 'getObject'), array(), '', false);
$this->_observer->expects($this->any())->method('getEvent')->will($this->returnValue($this->_event));
$this->_payment = $this->getMock('Magento\\RecurringPayment\\Model\\Payment', array('__sleep', '__wakeup', 'isValid', 'importQuote', 'importQuoteItem', 'submit', 'getId', 'setMethodCode'), array(), '', false);
}