コード例 #1
0
 /**
  * @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
0
 /**
  * @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
0
ファイル: ResponseTest.php プロジェクト: uibar/lavinia2
 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
0
 /**
  * @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
0
ファイル: IndexTest.php プロジェクト: kid17/magento2
 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();
 }
 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
0
 /**
  * @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();
 }
 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
0
 /**
  * @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
0
 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
0
 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
0
 /**
  * This function checks if the error is added to session in case of ACTION_FLAG_PRODUCTS_PERMISSION_DENIED
  * is not set in Sales Order model
  */
 public function testViewActionWithoutError()
 {
     $this->_orderMock->setRealOrderId(1);
     $this->_controllerMock->expects($this->once())->method('_initOrder')->will($this->returnValue($this->_orderMock));
     $this->_messageMock->expects($this->never())->method('addError');
     $this->_orderMock->expects($this->once())->method('getRealOrderId')->will($this->returnValue(1));
     $this->_controllerMock->execute();
 }
コード例 #13
0
ファイル: IndexTest.php プロジェクト: Doability/magento2dev
 /**
  * @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();
 }
コード例 #14
0
ファイル: TaskManagerTest.php プロジェクト: TYPO3/Surf
 /**
  * @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');
 }
コード例 #15
0
 public function testNewsletterAction()
 {
     $subscriberMock = $this->getMock('\\Magento\\Newsletter\\Model\\Subscriber', [], [], '', false);
     $this->resultLayoutFactoryMock->expects($this->once())->method('create')->willReturn($this->resultLayoutMock);
     $subscriberMock->expects($this->once())->method('loadByCustomerId');
     $this->_objectManager->expects($this->at(1))->method('create')->with('Magento\\Newsletter\\Model\\Subscriber')->will($this->returnValue($subscriberMock));
     $this->assertInstanceOf('Magento\\Framework\\View\\Result\\Layout', $this->_testedObject->execute());
 }
コード例 #16
0
 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());
 }
コード例 #17
0
ファイル: AddTest.php プロジェクト: shabbirvividads/magento2
 /**
  * @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();
 }
コード例 #18
0
 /**
  * @test
  */
 public function taskFailsOnError()
 {
     $GLOBALS['TCA']['pages']['ctrl']['delete'] = 'deleted';
     $GLOBALS['TCA']['pages']['ctrl']['tstamp'] = 'tstamp';
     $tables = array('pages');
     $this->subject->setTcaTables($tables);
     $period = 14;
     $this->subject->setPeriod($period);
     $dbMock = $this->getMock(DatabaseConnection::class);
     $dbMock->expects($this->once())->method('sql_error')->willReturn(1049);
     $this->subject->setDatabaseConnection($dbMock);
     $this->assertFalse($this->subject->execute());
 }
コード例 #19
0
 public function testExecuteBadSecretKey()
 {
     $this->itemOptionMock->expects($this->once())->method('load')->willReturnSelf();
     $this->itemOptionMock->expects($this->once())->method('getId')->willReturn(self::OPTION_ID);
     $this->itemOptionMock->expects($this->any())->method('getCode')->willReturn(self::OPTION_CODE);
     $this->itemOptionMock->expects($this->any())->method('getProductId')->willReturn(self::OPTION_PRODUCT_ID);
     $this->itemOptionMock->expects($this->any())->method('getValue')->willReturn(self::OPTION_VALUE);
     $this->productOptionMock->expects($this->once())->method('load')->willReturnSelf();
     $this->productOptionMock->expects($this->any())->method('getId')->willReturn(self::OPTION_ID);
     $this->productOptionMock->expects($this->any())->method('getProductId')->willReturn(self::OPTION_PRODUCT_ID);
     $this->productOptionMock->expects($this->any())->method('getType')->willReturn(self::OPTION_TYPE);
     $this->unserializeMock->expects($this->once())->method('unserialize')->with(self::OPTION_VALUE)->willReturn([self::SECRET_KEY => 'bad_test_secret_key']);
     $this->resultForwardMock->expects($this->once())->method('forward')->with('noroute')->willReturn(true);
     $this->objectMock->execute();
 }
コード例 #20
0
 /**
  * @test
  */
 public function taskFailsOnError()
 {
     $GLOBALS['TCA']['pages']['ctrl']['delete'] = 'deleted';
     $GLOBALS['TCA']['pages']['ctrl']['tstamp'] = 'tstamp';
     $this->subject->setTcaTables(['pages']);
     /** @var Connection|ObjectProphecy $connection */
     $connection = $this->prophesize(Connection::class);
     $connection->getDatabasePlatform()->willReturn(new MockPlatform());
     $connection->getExpressionBuilder()->willReturn(new ExpressionBuilder($connection->reveal()));
     $connection->quoteIdentifier(Argument::cetera())->willReturnArgument(0);
     $queryBuilder = GeneralUtility::makeInstance(QueryBuilder::class, $connection->reveal(), null, new \Doctrine\DBAL\Query\QueryBuilder($connection->reveal()));
     $connectionPool = $this->prophesize(ConnectionPool::class);
     $connectionPool->getQueryBuilderForTable('pages')->willReturn($queryBuilder);
     GeneralUtility::addInstance(ConnectionPool::class, $connectionPool->reveal());
     $connection->executeUpdate(Argument::cetera())->shouldBeCalled()->willThrow(new \Doctrine\DBAL\DBALException());
     $this->assertFalse($this->subject->execute());
 }
コード例 #21
0
ファイル: PostTest.php プロジェクト: pradeep-wagento/magento2
 public function testExecuteValidPost()
 {
     $post = ['name' => 'Name', 'comment' => 'Comment', 'email' => '*****@*****.**', 'hideit' => null];
     $this->_request->expects($this->any())->method('getPostValue')->will($this->returnValue($post));
     $transport = $this->getMock('\\Magento\\Framework\\Mail\\TransportInterface', [], [], '', false);
     $this->_transportBuilder->expects($this->once())->method('setTemplateIdentifier')->will($this->returnSelf());
     $this->_transportBuilder->expects($this->once())->method('setTemplateOptions')->with(['area' => \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE, 'store' => \Magento\Store\Model\Store::DEFAULT_STORE_ID])->will($this->returnSelf());
     $this->_transportBuilder->expects($this->once())->method('setTemplateVars')->will($this->returnSelf());
     $this->_transportBuilder->expects($this->once())->method('setFrom')->will($this->returnSelf());
     $this->_transportBuilder->expects($this->once())->method('addTo')->will($this->returnSelf());
     $this->_transportBuilder->expects($this->once())->method('setReplyTo')->with($post['email'])->will($this->returnSelf());
     $this->_transportBuilder->expects($this->once())->method('getTransport')->will($this->returnValue($transport));
     $transport->expects($this->once())->method('sendMessage');
     $this->_inlineTranslation->expects($this->once())->method('resume');
     $this->_inlineTranslation->expects($this->once())->method('suspend');
     $this->_controller->execute();
 }
コード例 #22
0
 /**
  * Run test execute method
  *
  * @param array $result
  * @param array $resultExpectation
  *
  * @dataProvider executeDataProvider
  */
 public function testExecute(array $result, array $resultExpectation)
 {
     $quoteId = 99;
     $quoteMock = $this->getMockBuilder('Magento\\Quote\\Model\\Quote')->disableOriginalConstructor()->getMock();
     $tokenMock = $this->getMockBuilder('Magento\\Framework\\Object')->setMethods(['getData', 'getSecuretoken'])->disableOriginalConstructor()->getMock();
     $jsonMock = $this->getMockBuilder('Magento\\Framework\\Controller\\Result\\Json')->disableOriginalConstructor()->getMock();
     $this->transparentMock->expects($this->once())->method('getCode')->willReturn('transparent');
     $this->sessionManagerMock->expects($this->atLeastOnce())->method('getQuote')->willReturn($quoteMock);
     $quoteMock->expects($this->once())->method('getId')->willReturn($quoteId);
     $this->sessionTransparentMock->expects($this->once())->method('setQuoteId')->with($quoteId);
     $this->secureTokenServiceMock->expects($this->once())->method('requestToken')->with($quoteMock)->willReturn($tokenMock);
     $this->transparentMock->expects($this->once())->method('getCode')->willReturn('transparent');
     $tokenMock->expects($this->once())->method('getData')->willReturn($result['transparent']['fields']);
     $tokenMock->expects($this->once())->method('getSecuretoken')->willReturn($result['success']);
     $this->resultJsonFactoryMock->expects($this->once())->method('create')->willReturn($jsonMock);
     $jsonMock->expects($this->once())->method('setData')->with($resultExpectation)->willReturnSelf();
     $this->assertEquals($jsonMock, $this->controller->execute());
 }
コード例 #23
0
ファイル: ResetPasswordTest.php プロジェクト: opexsw/magento2
 public function testResetPasswordActionSendEmail()
 {
     $customerId = 1;
     $email = '*****@*****.**';
     $websiteId = 1;
     $redirectLink = 'customer/*/edit';
     $this->_request->expects($this->once())->method('getParam')->with($this->equalTo('customer_id'), $this->equalTo(0))->will($this->returnValue($customerId));
     $customer = $this->getMockForAbstractClass('\\Magento\\Customer\\Api\\Data\\CustomerInterface', ['getId', 'getEmail', 'getWebsiteId']);
     $customer->expects($this->once())->method('getEmail')->will($this->returnValue($email));
     $customer->expects($this->once())->method('getWebsiteId')->will($this->returnValue($websiteId));
     $this->_customerRepositoryMock->expects($this->once())->method('getById')->with($customerId)->will($this->returnValue($customer));
     // verify initiatePasswordReset() is called
     $this->_customerAccountManagementMock->expects($this->once())->method('initiatePasswordReset')->with($email, AccountManagement::EMAIL_REMINDER, $websiteId);
     // verify success message
     $this->messageManager->expects($this->once())->method('addSuccess')->with($this->equalTo('Customer will receive an email with a link to reset password.'));
     // verify redirect
     $this->_helper->expects($this->any())->method('getUrl')->with($this->equalTo('customer/*/edit'), $this->equalTo(['id' => $customerId, '_current' => true]))->will($this->returnValue($redirectLink));
     $this->resultRedirectMock->expects($this->once())->method('setPath')->with($redirectLink, ['id' => $customerId, '_current' => true]);
     $this->assertInstanceOf('Magento\\Backend\\Model\\View\\Result\\Redirect', $this->_testedObject->execute());
 }
コード例 #24
0
 public function testExecuteValidPost()
 {
     $post = ['name' => 'Name', 'comment' => 'Comment', 'email' => '*****@*****.**', 'hideit' => null];
     $this->_request->expects($this->any())->method('getPost')->will($this->returnValue($post));
     $store = $this->getMock('\\Magento\\Store\\Model\\Store', ['getId', '__sleep', '__wakeup'], [], '', false);
     $store->expects($this->once())->method('getId')->will($this->returnValue(1));
     $this->_storeManager->expects($this->any())->method('getStore')->will($this->returnValue($store));
     $transport = $this->getMock('\\Magento\\Framework\\Mail\\TransportInterface', [], [], '', false);
     $this->_transportBuilder->expects($this->once())->method('setTemplateIdentifier')->will($this->returnSelf());
     $this->_transportBuilder->expects($this->once())->method('setTemplateOptions')->with(['area' => \Magento\Framework\App\Area::AREA_FRONTEND, 'store' => 1])->will($this->returnSelf());
     $this->_transportBuilder->expects($this->once())->method('setTemplateVars')->will($this->returnSelf());
     $this->_transportBuilder->expects($this->once())->method('setFrom')->will($this->returnSelf());
     $this->_transportBuilder->expects($this->once())->method('addTo')->will($this->returnSelf());
     $this->_transportBuilder->expects($this->once())->method('setReplyTo')->with($post['email'])->will($this->returnSelf());
     $this->_transportBuilder->expects($this->once())->method('getTransport')->will($this->returnValue($transport));
     $transport->expects($this->once())->method('sendMessage');
     $this->_inlineTranslation->expects($this->once())->method('resume');
     $this->_inlineTranslation->expects($this->once())->method('suspend');
     $this->_controller->execute();
 }
コード例 #25
0
 public function testResetPasswordActionSendEmail()
 {
     $customerId = 1;
     $email = "*****@*****.**";
     $websiteId = 1;
     $redirectLink = 'http://example.com';
     $this->_request->expects($this->once())->method('getParam')->with($this->equalTo('customer_id'), $this->equalTo(0))->will($this->returnValue($customerId));
     $customerBuilder = $this->getMock('\\Magento\\Customer\\Service\\V1\\Data\\CustomerBuilder', [], [], '', false);
     $data = ['id' => $customerId, 'email' => $email, 'website_id' => $websiteId];
     $customerBuilder->expects($this->once())->method('getData')->will($this->returnValue($data));
     $customer = new \Magento\Customer\Service\V1\Data\Customer($customerBuilder);
     $this->_acctServiceMock->expects($this->once())->method('getCustomer')->with($customerId)->will($this->returnValue($customer));
     // verify initiatePasswordReset() is called
     $this->_acctServiceMock->expects($this->once())->method('initiatePasswordReset')->with($email, CustomerAccountServiceInterface::EMAIL_REMINDER, $websiteId);
     // verify success message
     $this->messageManager->expects($this->once())->method('addSuccess')->with($this->equalTo('Customer will receive an email with a link to reset password.'));
     // verify redirect
     $this->_helper->expects($this->any())->method('getUrl')->with($this->equalTo('customer/*/edit'), $this->equalTo(array('id' => $customerId, '_current' => true)))->will($this->returnValue($redirectLink));
     $this->_response->expects($this->once())->method('setRedirect')->with($this->equalTo($redirectLink));
     $this->_testedObject->execute();
 }
コード例 #26
0
 /**
  * @param int|bool $ruleCustomerId
  * @dataProvider salesOrderAfterPlaceDataProvider
  */
 public function testSalesOrderAfterPlace($ruleCustomerId)
 {
     $observer = $this->getMock('Magento\\Framework\\Event\\Observer', [], [], '', false);
     $rule = $this->getMock('Magento\\SalesRule\\Model\\Rule', [], [], '', false);
     $ruleCustomer = $this->getMock('Magento\\SalesRule\\Model\\Rule\\Customer', ['setCustomerId', 'loadByCustomerRule', 'getId', 'setTimesUsed', 'setRuleId', 'save', '__wakeup'], [], '', false);
     $order = $this->initOrderFromEvent($observer);
     $ruleId = 1;
     $couponId = 1;
     $customerId = 1;
     $discountAmount = 10;
     $order->expects($this->once())->method('getAppliedRuleIds')->will($this->returnValue($ruleId));
     $order->expects($this->once())->method('getDiscountAmount')->will($this->returnValue($discountAmount));
     $order->expects($this->once())->method('getCustomerId')->will($this->returnValue($customerId));
     $this->ruleFactory->expects($this->once())->method('create')->will($this->returnValue($rule));
     $rule->expects($this->once())->method('getId')->will($this->returnValue($ruleId));
     $this->ruleCustomerFactory->expects($this->once())->method('create')->will($this->returnValue($ruleCustomer));
     $ruleCustomer->expects($this->once())->method('getId')->will($this->returnValue($ruleCustomerId));
     $ruleCustomer->expects($this->any())->method('setCustomerId')->will($this->returnSelf());
     $ruleCustomer->expects($this->any())->method('setRuleId')->will($this->returnSelf());
     $this->couponMock->expects($this->any())->method('getId')->will($this->returnValue($couponId));
     $this->couponUsage->expects($this->once())->method('updateCustomerCouponTimesUsed')->with($customerId, $couponId);
     $this->assertEquals($this->model, $this->model->execute($observer));
 }
コード例 #27
0
 /**
  * Test execute
  *
  * @return void
  */
 public function testExecute()
 {
     $ids = [1, 2, 5];
     $this->indexer->expects($this->once())->method('doExecuteList')->with($ids);
     $this->indexer->execute($ids);
 }
コード例 #28
0
 public function testExecuteNoValue()
 {
     $this->deploymentConfigMock->expects($this->once())->method('get')->with(ConfigOptionsList::CONFIG_PATH_CUSTOM_OPTION)->willReturn(null);
     $this->commandTester->execute([]);
     $this->assertContains('is not set', $this->commandTester->getDisplay());
 }
コード例 #29
0
ファイル: TaskTest.php プロジェクト: rickymathew/TYPO3.CMS
 /**
  * @test
  */
 public function executeReturnsTrueIfNoExceptionIsCaught()
 {
     $this->task->_set('taskExecutor', $this->taskExecutor);
     $this->assertTrue($this->task->execute());
 }