本文整理汇总了PHP中PHPUnit_Framework_MockObject_MockObject::execute方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPUnit_Framework_MockObject_MockObject::execute方法的具体用法?PHP PHPUnit_Framework_MockObject_MockObject::execute怎么用?PHP PHPUnit_Framework_MockObject_MockObject::execute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPUnit_Framework_MockObject_MockObject
的用法示例。
在下文中一共展示了PHPUnit_Framework_MockObject_MockObject::execute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testExecutionStatus
/**
* @dataProvider executionStatusProvider
*/
public function testExecutionStatus($result)
{
$this->command->expects($this->any())->method('__invoke')->willReturn($result);
$this->assertEquals([null], $this->collection->getExecutionStatus());
$this->collection->execute($this->payload);
$this->assertEquals([$result], $this->collection->getExecutionStatus());
}
示例2: 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);
}
示例3: testExecuteWithException
public function testExecuteWithException()
{
$objectMock = $this->getMockBuilder('Magento\\Framework\\DataObject')->disableOriginalConstructor()->getMock();
$this->transactionMock->expects($this->once())->method('getResponseObject')->willReturn($objectMock);
$this->responseValidatorMock->expects($this->once())->method('validate')->with($objectMock, $this->payflowFacade)->willThrowException(new \Magento\Framework\Exception\LocalizedException(__('Error')));
$this->coreRegistryMock->expects($this->once())->method('register')->with('transparent_form_params', $this->arrayHasKey('error'));
$this->resultLayoutMock->expects($this->once())->method('addDefaultHandle')->willReturnSelf();
$this->resultLayoutMock->expects($this->once())->method('getLayout')->willReturn($this->getLayoutMock());
$this->assertInstanceOf('\\Magento\\Framework\\Controller\\ResultInterface', $this->object->execute());
}
示例4: 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);
}
示例5: testExecute
public function testExecute()
{
$layout = $this->getMock('\\Magento\\Framework\\View\\Layout', ['getBlock', 'initMessages'], [], '', false);
$block = $this->getMockForAbstractClass('\\Magento\\Framework\\View\\Element\\AbstractBlock', ['setFormAction'], '', false);
$layout->expects($this->once())->method('getBlock')->with('contactForm')->will($this->returnValue($block));
$this->_view->expects($this->once())->method('loadLayout');
$this->_view->expects($this->exactly(1))->method('getLayout')->will($this->returnValue($layout));
$this->_view->expects($this->once())->method('renderLayout');
$this->_controller->execute();
}
示例6: testExecute
public function testExecute()
{
$data = new \DateTime();
$this->localeResolver->expects($this->once())->method('emulate')->with(0);
$this->localeDate->expects($this->once())->method('date')->will($this->returnValue($data));
$this->reportRule->expects($this->once())->method('aggregate')->with($data);
$this->localeResolver->expects($this->once())->method('revert');
$scheduleMock = $this->getMock('Magento\\Cron\\Model\\Schedule', [], [], '', false);
$this->assertEquals($this->model, $this->model->execute($scheduleMock));
}
示例7: testExecuteWithException
/**
* @expectedException \RuntimeException
* @covers \Magento\Setup\Model\Cron\JobStaticRegenerate::execute
*/
public function testExecuteWithException()
{
$modeObjectMock = $this->getModeObjectMock(['getMode']);
$modeObjectMock->expects($this->once())->method('getMode')->will($this->throwException(new \Exception('error')));
$this->jobStaticRegenerate->expects($this->once())->method('getModeObject')->will($this->returnValue($modeObjectMock));
$statusObject = $this->getStatucObjectMock(['toggleUpdateError']);
$statusObject->expects($this->once())->method('toggleUpdateError');
$this->jobStaticRegenerate->expects($this->once())->method('getStatusObject')->will($this->returnValue($statusObject));
$this->jobStaticRegenerate->execute();
}
示例8: testCatalogAttributeDeleteAfter
public function testCatalogAttributeDeleteAfter()
{
$attributeCode = 'attributeCode';
$observer = $this->getMock('Magento\\Framework\\Event\\Observer', [], [], '', false);
$event = $this->getMock('Magento\\Framework\\Event', ['getAttribute', '__wakeup'], [], '', false);
$attribute = $this->getMock('Magento\\Catalog\\Model\\ResourceModel\\Eav\\Attribute', ['dataHasChangedFor', 'getIsUsedForPromoRules', 'getAttributeCode', '__wakeup'], [], '', false);
$observer->expects($this->once())->method('getEvent')->will($this->returnValue($event));
$event->expects($this->any())->method('getAttribute')->will($this->returnValue($attribute));
$attribute->expects($this->any())->method('getIsUsedForPromoRules')->will($this->returnValue(true));
$attribute->expects($this->any())->method('getAttributeCode')->will($this->returnValue($attributeCode));
$this->checkSalesRulesAvailability->expects($this->once())->method('checkSalesRulesAvailability')->willReturn('true');
$this->assertEquals($this->model, $this->model->execute($observer));
}
示例9: testExecute
/**
* @param boolean $expectedAllowed
* @param boolean|null $conditionAllowed
* @dataProvider executeDataProvider
*/
public function testExecute($expectedAllowed, $conditionAllowed = null)
{
$context = array('key' => 'value');
if ($expectedAllowed) {
$this->action->expects($this->once())->method('executeAction')->with($context);
} else {
$this->action->expects($this->never())->method('executeAction');
}
if ($conditionAllowed !== null) {
$condition = new ArrayCondition(array('allowed' => $conditionAllowed));
$this->action->setCondition($condition);
}
$this->action->execute($context);
}
示例10: testAddSalesRuleNameToOrder
public function testAddSalesRuleNameToOrder()
{
$observer = $this->getMock('Magento\\Framework\\Event\\Observer', ['getOrder'], [], '', false);
$rule = $this->getMock('Magento\\SalesRule\\Model\\Rule', ['load', 'getName', '__wakeup'], [], '', false);
$order = $this->getMock('Magento\\Sales\\Model\\Order', ['setCouponRuleName', 'getCouponCode', '__wakeup'], [], '', false);
$couponCode = 'coupon code';
$ruleId = 1;
$observer->expects($this->any())->method('getOrder')->will($this->returnValue($order));
$order->expects($this->once())->method('getCouponCode')->will($this->returnValue($couponCode));
$this->couponMock->expects($this->once())->method('getRuleId')->will($this->returnValue($ruleId));
$this->ruleFactory->expects($this->once())->method('create')->will($this->returnValue($rule));
$rule->expects($this->once())->method('load')->with($ruleId)->will($this->returnSelf());
$order->expects($this->once())->method('setCouponRuleName');
$this->assertEquals($this->model, $this->model->execute($observer));
}
示例11: testNewsletterAction
public function testNewsletterAction()
{
$subscriberMock = $this->getMock('\\Magento\\Newsletter\\Model\\Subscriber', array(), array(), '', false);
$subscriberMock->expects($this->once())->method('loadByCustomerId');
$this->_objectManager->expects($this->at(1))->method('create')->with('Magento\\Newsletter\\Model\\Subscriber')->will($this->returnValue($subscriberMock));
$this->_testedObject->execute();
}
示例12: testExecute
/**
* @covers \Magento\Marketplace\Controller\Adminhtml\Partners\Index::execute
*/
public function testExecute()
{
$requestMock = $this->getRequestMock(['isAjax']);
$requestMock->expects($this->once())->method('isAjax')->will($this->returnValue(true));
$this->partnersControllerMock->expects($this->once())->method('getRequest')->will($this->returnValue($requestMock));
$layoutMock = $this->getLayoutMock();
$blockMock = $this->getBlockInterfaceMock();
$blockMock->expects($this->once())->method('toHtml')->will($this->returnValue(''));
$layoutMock->expects($this->once())->method('createBlock')->will($this->returnValue($blockMock));
$layoutMockFactory = $this->getLayoutFactoryMock(['create']);
$layoutMockFactory->expects($this->once())->method('create')->will($this->returnValue($layoutMock));
$this->partnersControllerMock->expects($this->once())->method('getLayoutFactory')->will($this->returnValue($layoutMockFactory));
$responseMock = $this->getResponseMock(['appendBody']);
$responseMock->expects($this->once())->method('appendBody')->will($this->returnValue(''));
$this->partnersControllerMock->expects($this->once())->method('getResponse')->will($this->returnValue($responseMock));
$this->partnersControllerMock->execute();
}
示例13: executePassePrefixedDefinedTaskOptionsToDefinedTask
/**
* @test
*/
public function executePassePrefixedDefinedTaskOptionsToDefinedTask()
{
$globalOptions = array('MyVendor\\MyPackage\\DefinedTask\\TaskGroup\\MyTask[taskOption]' => 'Foo');
$this->deployment->setOptions($globalOptions);
$this->task->expects($this->atLeastOnce())->method('execute')->with($this->anything(), $this->anything(), $this->anything(), $this->arrayHasKey('taskOption'));
$localOptions = array();
$this->taskManager->execute('MyVendor\\MyPackage\\Task\\TaskGroup\\MyTask', $this->node, $this->application, $this->deployment, 'test', $localOptions, 'MyVendor\\MyPackage\\DefinedTask\\TaskGroup\\MyTask');
}
示例14: testExecuteEmptyQuoteError
public function testExecuteEmptyQuoteError()
{
$resultExpectation = ['success' => false, 'error' => true, 'error_messages' => __('Your payment has been declined. Please try again.')];
$quoteMock = null;
$jsonMock = $this->getMockBuilder('Magento\\Framework\\Controller\\Result\\Json')->disableOriginalConstructor()->getMock();
$this->sessionManagerMock->expects($this->atLeastOnce())->method('getQuote')->willReturn($quoteMock);
$this->resultJsonFactoryMock->expects($this->once())->method('create')->willReturn($jsonMock);
$jsonMock->expects($this->once())->method('setData')->with($resultExpectation)->willReturnSelf();
$this->assertEquals($jsonMock, $this->controller->execute());
}
示例15: testExecuteProductAddedToWishlistAfterObjectManagerThrowException
/**
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function testExecuteProductAddedToWishlistAfterObjectManagerThrowException()
{
$product = $this->getMock('Magento\\Catalog\\Model\\Product', ['isVisibleInCatalog', 'getName'], [], '', false);
$product->expects($this->once())->method('isVisibleInCatalog')->will($this->returnValue(true));
$product->expects($this->once())->method('getName')->will($this->returnValue('Product test name'));
$this->productRepository->expects($this->once())->method('getById')->with(2)->will($this->returnValue($product));
$exception = new \Exception('Exception');
$wishListItem = new \stdClass();
$wishlist = $this->getMock('Magento\\Wishlist\\Model\\Wishlist', ['addNewItem', 'save', 'getId'], [], '', false);
$wishlist->expects($this->once())->method('addNewItem')->will($this->returnValue($wishListItem));
$wishlist->expects($this->once())->method('getId')->will($this->returnValue(2));
$wishlist->expects($this->once())->method('save')->will($this->returnValue(true));
$this->wishlistProvider->expects($this->once())->method('getWishlist')->will($this->returnValue($wishlist));
$request = $this->getMock('Magento\\Framework\\App\\Request\\Http', ['getParams'], [], '', false);
$request->expects($this->once())->method('getParams')->will($this->returnValue(['product' => 2]));
$wishlistHelper = $this->getMock('Magento\\Wishlist\\Helper\\Data', ['calculate'], [], '', false);
$wishlistHelper->expects($this->once())->method('calculate')->will($this->returnSelf());
$escaper = $this->getMock('Magento\\Framework\\Escaper', ['escapeHtml', 'escapeUrl'], [], '', false);
$escaper->expects($this->once())->method('escapeHtml')->with('Product test name')->will($this->returnValue('Product test name'));
$escaper->expects($this->once())->method('escapeUrl')->with('http://test-url.com')->will($this->returnValue('http://test-url.com'));
$logger = $this->getMock('Magento\\Framework\\Logger\\Monolog', ['critical'], [], '', false);
$logger->expects($this->once())->method('critical')->with($exception)->will($this->returnValue(true));
$om = $this->getMock('Magento\\Framework\\App\\ObjectManager', ['get'], [], '', false);
$om->expects($this->at(0))->method('get')->with('Magento\\Wishlist\\Helper\\Data')->will($this->returnValue($wishlistHelper));
$om->expects($this->at(1))->method('get')->with('Magento\\Framework\\Escaper')->will($this->returnValue($escaper));
$om->expects($this->at(2))->method('get')->with('Magento\\Framework\\Escaper')->will($this->returnValue($escaper));
$om->expects($this->at(3))->method('get')->with('Psr\\Log\\LoggerInterface')->will($this->returnValue($logger));
$response = $this->getMock('Magento\\Framework\\App\\Response\\Http', null, [], '', false);
$eventManager = $this->getMock('Magento\\Framework\\Event\\Manager', ['dispatch'], [], '', false);
$eventManager->expects($this->once())->method('dispatch')->with('wishlist_add_product', ['wishlist' => $wishlist, 'product' => $product, 'item' => $wishListItem])->will($this->returnValue(true));
$url = $this->getMock('Magento\\Framework\\Url', null, [], '', false);
$actionFlag = $this->getMock('Magento\\Framework\\App\\ActionFlag', null, [], '', false);
$redirect = $this->getMock('\\Magento\\Store\\App\\Response\\Redirect', ['redirect'], [], '', false);
$redirect->expects($this->once())->method('redirect')->with($response, '*', ['wishlist_id' => 2])->will($this->returnValue(null));
$view = $this->getMock('Magento\\Framework\\App\\View', null, [], '', false);
$messageManager = $this->getMock('Magento\\Framework\\Message\\Manager', ['addError', 'addSuccess'], [], '', false);
$messageManager->expects($this->once())->method('addError')->with('An error occurred while adding item to wish list.')->will($this->returnValue(null));
$messageManager->expects($this->once())->method('addSuccess')->will($this->throwException($exception));
$this->context->expects($this->any())->method('getObjectManager')->will($this->returnValue($om));
$this->context->expects($this->any())->method('getRequest')->will($this->returnValue($request));
$this->context->expects($this->any())->method('getResponse')->will($this->returnValue($response));
$this->context->expects($this->any())->method('getEventManager')->will($this->returnValue($eventManager));
$this->context->expects($this->any())->method('getUrl')->will($this->returnValue($url));
$this->context->expects($this->any())->method('getActionFlag')->will($this->returnValue($actionFlag));
$this->context->expects($this->any())->method('getRedirect')->will($this->returnValue($redirect));
$this->context->expects($this->any())->method('getView')->will($this->returnValue($view));
$this->context->expects($this->any())->method('getMessageManager')->will($this->returnValue($messageManager));
$this->customerSession->expects($this->exactly(1))->method('getBeforeWishlistRequest')->will($this->returnValue(false));
$this->customerSession->expects($this->never())->method('unsBeforeWishlistRequest')->will($this->returnValue(null));
$this->customerSession->expects($this->once())->method('getBeforeWishlistUrl')->will($this->returnValue('http://test-url.com'));
$this->customerSession->expects($this->once())->method('setBeforeWishlistUrl')->with(null)->will($this->returnValue(null));
$this->createController();
$this->controller->execute();
}