public function setUp()
 {
     $objectManagerHelper = new ObjectManagerHelper($this);
     $this->contextMock = $this->getMock('Magento\\Backend\\App\\Action\\Context', [], [], '', false);
     $resultRedirectFactory = $this->getMock('Magento\\Backend\\Model\\View\\Result\\RedirectFactory', [], [], '', false);
     $this->responseMock = $this->getMock('Magento\\Framework\\App\\ResponseInterface', [], [], '', false);
     $this->requestMock = $this->getMockBuilder('Magento\\Framework\\App\\Request\\Http')->disableOriginalConstructor()->getMock();
     $this->objectManagerMock = $this->getMock('Magento\\Framework\\ObjectManager\\ObjectManager', ['create'], [], '', false);
     $this->messageManagerMock = $this->getMock('Magento\\Framework\\Message\\Manager', [], [], '', false);
     $this->customerCollectionMock = $this->getMockBuilder('Magento\\Customer\\Model\\ResourceModel\\Customer\\Collection')->disableOriginalConstructor()->getMock();
     $this->customerCollectionFactoryMock = $this->getMockBuilder('Magento\\Customer\\Model\\ResourceModel\\Customer\\CollectionFactory')->disableOriginalConstructor()->setMethods(['create'])->getMock();
     $redirectMock = $this->getMockBuilder('Magento\\Backend\\Model\\View\\Result\\Redirect')->disableOriginalConstructor()->getMock();
     $resultFactoryMock = $this->getMockBuilder('Magento\\Framework\\Controller\\ResultFactory')->disableOriginalConstructor()->getMock();
     $resultFactoryMock->expects($this->any())->method('create')->with(\Magento\Framework\Controller\ResultFactory::TYPE_REDIRECT)->willReturn($redirectMock);
     $this->resultRedirectMock = $this->getMockBuilder('Magento\\Backend\\Model\\View\\Result\\Redirect')->disableOriginalConstructor()->getMock();
     $resultRedirectFactory->expects($this->any())->method('create')->willReturn($this->resultRedirectMock);
     $this->contextMock->expects($this->once())->method('getMessageManager')->willReturn($this->messageManagerMock);
     $this->contextMock->expects($this->once())->method('getRequest')->willReturn($this->requestMock);
     $this->contextMock->expects($this->once())->method('getResponse')->willReturn($this->responseMock);
     $this->contextMock->expects($this->once())->method('getObjectManager')->willReturn($this->objectManagerMock);
     $this->contextMock->expects($this->any())->method('getResultRedirectFactory')->willReturn($resultRedirectFactory);
     $this->contextMock->expects($this->any())->method('getResultFactory')->willReturn($resultFactoryMock);
     $this->filterMock = $this->getMock('Magento\\Ui\\Component\\MassAction\\Filter', [], [], '', false);
     $this->filterMock->expects($this->once())->method('getCollection')->with($this->customerCollectionMock)->willReturnArgument(0);
     $this->customerCollectionFactoryMock->expects($this->once())->method('create')->willReturn($this->customerCollectionMock);
     $this->customerRepositoryMock = $this->getMockBuilder('Magento\\Customer\\Api\\CustomerRepositoryInterface')->getMockForAbstractClass();
     $this->massAction = $objectManagerHelper->getObject('Magento\\Customer\\Controller\\Adminhtml\\Index\\MassAssignGroup', ['context' => $this->contextMock, 'filter' => $this->filterMock, 'collectionFactory' => $this->customerCollectionFactoryMock, 'customerRepository' => $this->customerRepositoryMock]);
 }
 public function setUp()
 {
     $objectManagerHelper = new ObjectManagerHelper($this);
     $this->contextMock = $this->getMock('Magento\\Backend\\App\\Action\\Context', [], [], '', false);
     $resultRedirectFactory = $this->getMock('Magento\\Backend\\Model\\View\\Result\\RedirectFactory', [], [], '', false);
     $this->responseMock = $this->getMock('Magento\\Framework\\App\\ResponseInterface', [], [], '', false);
     $this->requestMock = $this->getMockBuilder('Magento\\Framework\\App\\Request\\Http')->disableOriginalConstructor()->getMock();
     $this->objectManagerMock = $this->getMock('Magento\\Framework\\ObjectManager\\ObjectManager', [], [], '', false);
     $this->messageManagerMock = $this->getMock('Magento\\Framework\\Message\\Manager', [], [], '', false);
     $this->orderCollectionMock = $this->getMockBuilder('Magento\\Sales\\Model\\ResourceModel\\Order\\Collection')->disableOriginalConstructor()->getMock();
     $orderCollection = 'Magento\\Sales\\Model\\ResourceModel\\Order\\CollectionFactory';
     $this->orderCollectionFactoryMock = $this->getMockBuilder($orderCollection)->disableOriginalConstructor()->setMethods(['create'])->getMock();
     $this->sessionMock = $this->getMock('Magento\\Backend\\Model\\Session', ['setIsUrlNotice'], [], '', false);
     $this->actionFlagMock = $this->getMock('Magento\\Framework\\App\\ActionFlag', ['get', 'set'], [], '', false);
     $this->helperMock = $this->getMock('\\Magento\\Backend\\Helper\\Data', ['getUrl'], [], '', false);
     $this->resultRedirectMock = $this->getMock('Magento\\Backend\\Model\\View\\Result\\Redirect', [], [], '', false);
     $resultRedirectFactory->expects($this->any())->method('create')->willReturn($this->resultRedirectMock);
     $redirectMock = $this->getMockBuilder('Magento\\Backend\\Model\\View\\Result\\Redirect')->disableOriginalConstructor()->getMock();
     $resultFactoryMock = $this->getMockBuilder('Magento\\Framework\\Controller\\ResultFactory')->disableOriginalConstructor()->getMock();
     $resultFactoryMock->expects($this->any())->method('create')->with(\Magento\Framework\Controller\ResultFactory::TYPE_REDIRECT)->willReturn($redirectMock);
     $this->contextMock->expects($this->once())->method('getMessageManager')->willReturn($this->messageManagerMock);
     $this->contextMock->expects($this->once())->method('getRequest')->willReturn($this->requestMock);
     $this->contextMock->expects($this->once())->method('getResponse')->willReturn($this->responseMock);
     $this->contextMock->expects($this->once())->method('getObjectManager')->willReturn($this->objectManagerMock);
     $this->contextMock->expects($this->once())->method('getSession')->willReturn($this->sessionMock);
     $this->contextMock->expects($this->once())->method('getActionFlag')->willReturn($this->actionFlagMock);
     $this->contextMock->expects($this->once())->method('getHelper')->willReturn($this->helperMock);
     $this->contextMock->expects($this->once())->method('getResultRedirectFactory')->willReturn($resultRedirectFactory);
     $this->contextMock->expects($this->any())->method('getResultFactory')->willReturn($resultFactoryMock);
     $this->filterMock = $this->getMock('Magento\\Ui\\Component\\MassAction\\Filter', [], [], '', false);
     $this->filterMock->expects($this->once())->method('getCollection')->with($this->orderCollectionMock)->willReturn($this->orderCollectionMock);
     $this->orderCollectionFactoryMock->expects($this->once())->method('create')->willReturn($this->orderCollectionMock);
     $this->massAction = $objectManagerHelper->getObject('Magento\\Sales\\Controller\\Adminhtml\\Order\\MassUnhold', ['context' => $this->contextMock, 'filter' => $this->filterMock, 'collectionFactory' => $this->orderCollectionFactoryMock]);
 }
示例#3
0
 public function testExecutePageRequested()
 {
     $this->request->expects($this->any())->method('getParam')->with('filters')->willReturn(['placeholder' => true]);
     $this->request->expects($this->any())->method('getParams')->willReturn(['namespace' => 'product_listing', 'exclude' => true, 'filters' => ['placeholder' => true]]);
     $this->attributeHelper->expects($this->any())->method('getProductIds')->willReturn([1, 2, 3]);
     $this->attributeHelper->expects($this->any())->method('setProductIds')->with([1, 2, 3]);
     $collection = $this->getMockBuilder('Magento\\Catalog\\Model\\ResourceModel\\Product\\Collection')->setMethods(['getAllIds'])->disableOriginalConstructor()->getMock();
     $collection->expects($this->any())->method('getAllIds')->willReturn([1, 2, 3]);
     $this->filter->expects($this->any())->method('getCollection')->with($collection)->willReturn($collection);
     $this->collectionFactory->expects($this->any())->method('create')->willReturn($collection);
     $title = $this->getMockBuilder('Magento\\Framework\\View\\Page\\Title')->setMethods(['prepend'])->disableOriginalConstructor()->getMock();
     $config = $this->getMockBuilder('Magento\\Framework\\View\\Page\\Config')->setMethods(['getTitle'])->disableOriginalConstructor()->getMock();
     $config->expects($this->any())->method('getTitle')->willReturn($title);
     $this->resultPage->expects($this->any())->method('getConfig')->willReturn($config);
     $this->assertSame($this->resultPage, $this->object->execute());
 }