/**
  * save product data
  *
  * @param $observer
  *
  * @return $this
  */
 public function execute(EventObserver $observer)
 {
     $downloads = $this->context->getRequest()->getFiles('downloads', -1);
     if ($downloads != '-1') {
         // Get current product
         $product = $this->coreRegistry->registry('product');
         $productId = $product->getId();
         // Loop through uploaded downlaods
         foreach ($downloads as $download) {
             // Upload file
             $uploadedDownload = $this->upload->uploadFile($download);
             if ($uploadedDownload) {
                 $objectManager = $this->context->getObjectManager();
                 // Store date in database
                 $download = $objectManager->create('Sebwite\\ProductDownloads\\Model\\Download');
                 $download->setDownloadUrl($uploadedDownload['file']);
                 $download->setDownloadFile($uploadedDownload['name']);
                 $download->setDownloadType($uploadedDownload['type']);
                 $download->setProductId($productId);
                 $download->save();
             }
         }
     }
     return $this;
 }
Пример #2
0
 public function __construct(\Magento\Backend\App\Action\Context $context, \Magento\Framework\View\Result\PageFactory $resultPageFactory, \Magento\Backend\Model\View\Result\ForwardFactory $resultForwardFactory)
 {
     $this->resultPageFactory = $resultPageFactory;
     $this->resultForwardFactory = $resultForwardFactory;
     $this->resultRedirectFactory = $context->getResultRedirectFactory();
     parent::__construct($context);
 }
 /**
  * ResetContactImport constructor.
  *
  * @param \Dotdigitalgroup\Email\Model\ResourceModel\ContactFactory $contactResourceFactory
  * @param \Dotdigitalgroup\Email\Model\ContactFactory               $contactFactory
  * @param \Dotdigitalgroup\Email\Helper\Data                        $data
  * @param \Magento\Backend\App\Action\Context                       $context
  */
 public function __construct(\Dotdigitalgroup\Email\Model\ResourceModel\ContactFactory $contactResourceFactory, \Dotdigitalgroup\Email\Model\ContactFactory $contactFactory, \Dotdigitalgroup\Email\Helper\Data $data, \Magento\Backend\App\Action\Context $context)
 {
     $this->contactFactory = $contactFactory;
     $this->contactResourceFactory = $contactResourceFactory;
     $this->helper = $data;
     $this->messageManager = $context->getMessageManager();
 }
 /**
  * Execute method.
  *
  * @param \Magento\Framework\Event\Observer $observer
  *
  * @return $this
  * @codingStandardsIgnoreStart
  */
 public function execute(\Magento\Framework\Event\Observer $observer)
 {
     //@codingStandardsIgnoreEnd
     $groups = $this->context->getRequest()->getPost('groups');
     if (isset($groups['api']['fields']['username']['inherit']) || isset($groups['api']['fields']['password']['inherit'])) {
         return $this;
     }
     $apiUsername = isset($groups['api']['fields']['username']['value']) ? $groups['api']['fields']['username']['value'] : false;
     $apiPassword = isset($groups['api']['fields']['password']['value']) ? $groups['api']['fields']['password']['value'] : false;
     //skip if the inherit option is selected
     if ($apiUsername && $apiPassword) {
         $this->helper->log('----VALIDATING ACCOUNT---');
         $isValid = $this->test->validate($apiUsername, $apiPassword);
         if ($isValid) {
             //save endpoint for account
             foreach ($isValid->properties as $property) {
                 if ($property->name == 'ApiEndpoint' && !empty($property->value)) {
                     $this->saveApiEndpoint($property->value);
                     break;
                 }
             }
             $this->messageManager->addSuccessMessage(__('API Credentials Valid.'));
         } else {
             $this->messageManager->addWarningMessage(__('Authorization has been denied for this request.'));
         }
     }
     return $this;
 }
 /**
  * Automapdatafields constructor.
  *
  * @param \Dotdigitalgroup\Email\Helper\Data               $data
  * @param \Dotdigitalgroup\Email\Model\Connector\Datafield $datafield
  * @param \Magento\Backend\App\Action\Context              $context
  */
 public function __construct(\Dotdigitalgroup\Email\Helper\Data $data, \Dotdigitalgroup\Email\Model\Connector\Datafield $datafield, \Magento\Backend\App\Action\Context $context)
 {
     $this->data = $data;
     $this->datafield = $datafield;
     $this->messageManager = $context->getMessageManager();
     parent::__construct($context);
 }
Пример #6
0
 public function __construct(\Magento\Backend\App\Action\Context $context, \Wyomind\Watchlog\Cron\PeriodicalReport $periodicalReport, \Wyomind\Watchlog\Helper\Data $watchlogHelper)
 {
     $this->resultRedirectFactory = $context->getResultRedirectFactory();
     $this->periodicalReport = $periodicalReport;
     $this->watchlogHelper = $watchlogHelper;
     parent::__construct($context);
 }
Пример #7
0
 /**
  * Init mocks for tests
  * @return void
  */
 public function setUp()
 {
     $this->objectManager = new ObjectManager($this);
     $this->contextMock = $this->getMockBuilder('\\Magento\\Backend\\App\\Action\\Context')->disableOriginalConstructor()->getMock();
     $this->viewMock = $this->getMock('\\Magento\\Framework\\App\\ViewInterface');
     $this->contextMock->expects($this->any())->method('getView')->will($this->returnValue($this->viewMock));
     $this->controller = $this->objectManager->getObject('\\Magento\\Security\\Controller\\Adminhtml\\Session\\Activity', ['context' => $this->contextMock]);
 }
 /**
  * AccountTransactionalDataCheck constructor.
  *
  * @param \Dotdigitalgroup\Email\Model\ContactFactory $contactFactory
  * @param \Dotdigitalgroup\Email\Helper\Data          $data
  * @param \Magento\Backend\App\Action\Context         $context
  * @param \Magento\Store\Model\StoreManagerInterface  $storeManagerInterface
  */
 public function __construct(\Dotdigitalgroup\Email\Model\ContactFactory $contactFactory, \Dotdigitalgroup\Email\Helper\Data $data, \Magento\Backend\App\Action\Context $context, \Magento\Store\Model\StoreManagerInterface $storeManagerInterface)
 {
     $this->_helper = $data;
     $this->_context = $context;
     $this->_contactFactory = $contactFactory;
     $this->_request = $context->getRequest();
     $this->_storeManager = $storeManagerInterface;
     $this->messageManager = $context->getMessageManager();
 }
 public function setUp()
 {
     $this->context = $this->getMockBuilder('Magento\\Backend\\App\\Action\\Context')->disableOriginalConstructor()->getMock();
     $this->resultFactory = $this->getMockBuilder('Magento\\Framework\\Controller\\ResultFactory')->disableOriginalConstructor()->getMock();
     $this->resultPage = $this->getMockBuilder('Magento\\Framework\\Controller\\ResultInterface')->setMethods(['setData'])->getMockForAbstractClass();
     $this->imageProcessor = $this->getMockBuilder('Magento\\Theme\\Model\\Design\\Config\\FileUploader\\ImageProcessor')->disableOriginalConstructor()->getMock();
     $this->context->expects($this->once())->method('getResultFactory')->willReturn($this->resultFactory);
     $this->controller = new Save($this->context, $this->imageProcessor);
 }
 protected function initContext()
 {
     $this->request = $this->getMockBuilder('Magento\\Framework\\App\\Request\\Http')->disableOriginalConstructor()->getMock();
     $this->context = $this->getMockBuilder('Magento\\Backend\\App\\Action\\Context')->disableOriginalConstructor()->getMock();
     $this->context->expects($this->any())->method('getRequest')->willReturn($this->request);
     $this->resultRedirect = $this->getMockBuilder('Magento\\Framework\\Controller\\Result\\Redirect')->disableOriginalConstructor()->getMock();
     $resultRedirectFactory = $this->getMockBuilder('Magento\\Framework\\Controller\\Result\\RedirectFactory')->disableOriginalConstructor()->setMethods(['create'])->getMock();
     $resultRedirectFactory->expects($this->any())->method('create')->willReturn($this->resultRedirect);
     $this->context->expects($this->any())->method('getResultRedirectFactory')->willReturn($resultRedirectFactory);
 }
Пример #11
0
 /**
  * save category data
  * @param $observer
  * @return $this
  */
 public function saveCategoryData($observer)
 {
     $post = $this->context->getRequest()->getPost('category_gemtoo_blog_articles', -1);
     if ($post != '-1') {
         $post = json_decode($post, true);
         $category = $this->coreRegistry->registry('category');
         $this->articleResource->saveArticleCategoryRelation($category, $post);
     }
     return $this;
 }
Пример #12
0
 /**
  * save category data
  * @param $observer
  * @return $this
  */
 public function saveCategoryData($observer)
 {
     $post = $this->context->getRequest()->getPost('category_sample_news_authors', -1);
     if ($post != '-1') {
         $post = json_decode($post, true);
         $category = $this->coreRegistry->registry('category');
         $this->authorResource->saveAuthorCategoryRelation($category, $post);
     }
     return $this;
 }
Пример #13
0
    protected function setUp()
    {
        $this->autocomplete = $this->getMockBuilder('Magento\Search\Model\AutocompleteInterface')
            ->disableOriginalConstructor()
            ->setMethods(['getItems'])
            ->getMockForAbstractClass();
        $this->request = $this->getMockBuilder('\Magento\Framework\App\RequestInterface')
            ->disableOriginalConstructor()
            ->setMethods([])
            ->getMockForAbstractClass();
        $this->url = $this->getMockBuilder('Magento\Framework\UrlInterface')
            ->disableOriginalConstructor()
            ->setMethods(['getBaseUrl'])
            ->getMockForAbstractClass();
        $this->resultFactoryMock = $this->getMockBuilder('Magento\Framework\Controller\ResultFactory')
            ->disableOriginalConstructor()
            ->getMock();
        $this->resultRedirectMock = $this->getMockBuilder('Magento\Backend\Model\View\Result\Redirect')
            ->disableOriginalConstructor()
            ->getMock();
        $this->resultJsonMock = $this->getMockBuilder('Magento\Framework\Controller\Result\Json')
            ->disableOriginalConstructor()
            ->getMock();

        $this->context = $this->getMockBuilder('Magento\Framework\App\Action\Context')
            ->disableOriginalConstructor()
            ->getMock();
        $this->context->expects($this->atLeastOnce())
            ->method('getRequest')
            ->will($this->returnValue($this->request));
        $this->context->expects($this->any())
            ->method('getUrl')
            ->will($this->returnValue($this->url));
        $this->context->expects($this->any())
            ->method('getResultFactory')
            ->willReturn($this->resultFactoryMock);
        $this->resultFactoryMock->expects($this->any())
            ->method('create')
            ->willReturnMap(
                [
                    [ResultFactory::TYPE_REDIRECT, [], $this->resultRedirectMock],
                    [ResultFactory::TYPE_JSON, [], $this->resultJsonMock]
                ]
            );

        $this->objectManagerHelper = new ObjectManagerHelper($this);
        $this->controller = $this->objectManagerHelper->getObject(
            'Magento\Search\Controller\Ajax\Suggest',
            [
                'context' => $this->context,
                'autocomplete' => $this->autocomplete
            ]
        );
    }
Пример #14
0
 /**
  * Set up
  */
 protected function setUp()
 {
     $this->resultPage = $this->getMock('Magento\\Backend\\Model\\View\\Result\\Page', ['setActiveMenu', 'getConfig', 'getTitle', 'prepend', 'addBreadcrumb'], [], '', false);
     $this->resultPage->expects($this->any())->method('getConfig')->willReturnSelf();
     $this->resultPage->expects($this->any())->method('getTitle')->willReturnSelf();
     $this->resultFactory = $this->getMock('Magento\\Framework\\Controller\\ResultFactory', ['create'], [], '', false);
     $this->resultFactory->expects($this->any())->method('create')->willReturn($this->resultPage);
     $this->context = $this->getMock('Magento\\Backend\\App\\Action\\Context', ['getResultFactory'], [], '', false);
     $this->context->expects($this->any())->method('getResultFactory')->willReturn($this->resultFactory);
     $this->objectManagerHelper = new ObjectManagerHelper($this);
     $this->indexController = $this->objectManagerHelper->getObject('Magento\\ImportExport\\Controller\\Adminhtml\\History\\Index', ['context' => $this->context]);
 }
Пример #15
0
    protected function setUp()
    {
        $this->request = $this->getMockBuilder('\Magento\Framework\App\RequestInterface')
            ->disableOriginalConstructor()
            ->setMethods([])
            ->getMockForAbstractClass();
        $this->objectManager = $this->getMockBuilder('\Magento\Framework\ObjectManagerInterface')
            ->disableOriginalConstructor()
            ->setMethods(['create'])
            ->getMockForAbstractClass();
        $this->messageManager = $this->getMockBuilder('\Magento\Framework\Message\ManagerInterface')
            ->disableOriginalConstructor()
            ->setMethods(['addSuccess', 'addError'])
            ->getMockForAbstractClass();
        $this->pageFactory = $this->getMockBuilder('Magento\Framework\View\Result\PageFactory')
            ->setMethods([])
            ->disableOriginalConstructor()
            ->getMock();
        $this->resultRedirectMock = $this->getMockBuilder('Magento\Backend\Model\View\Result\Redirect')
            ->disableOriginalConstructor()
            ->getMock();
        $this->resultFactoryMock = $this->getMockBuilder('Magento\Framework\Controller\ResultFactory')
            ->disableOriginalConstructor()
            ->getMock();
        $this->resultFactoryMock->expects($this->any())
            ->method('create')
            ->with(ResultFactory::TYPE_REDIRECT, [])
            ->willReturn($this->resultRedirectMock);
        $this->context = $this->getMockBuilder('Magento\Backend\App\Action\Context')
            ->disableOriginalConstructor()
            ->getMock();
        $this->context->expects($this->atLeastOnce())
            ->method('getRequest')
            ->willReturn($this->request);
        $this->context->expects($this->any())
            ->method('getObjectManager')
            ->willReturn($this->objectManager);
        $this->context->expects($this->any())
            ->method('getMessageManager')
            ->willReturn($this->messageManager);
        $this->context->expects($this->any())
            ->method('getResultFactory')
            ->willReturn($this->resultFactoryMock);

        $this->objectManagerHelper = new ObjectManagerHelper($this);
        $this->controller = $this->objectManagerHelper->getObject(
            'Magento\Search\Controller\Adminhtml\Term\MassDelete',
            [
                'context' => $this->context,
                'resultPageFactory' => $this->pageFactory,
            ]
        );
    }
Пример #16
0
 protected function setUp()
 {
     $this->objectManagerHelper = new ObjectManagerHelper($this);
     $this->context = $this->getMockBuilder('\\Magento\\Backend\\App\\Action\\Context')->disableOriginalConstructor()->getMock();
     $this->request = $this->getMock('Magento\\Framework\\App\\RequestInterface');
     $this->response = $this->getMock('\\Magento\\Framework\\App\\ResponseInterface', ['sendResponse', 'setBody']);
     $this->view = $this->getMock('\\Magento\\Framework\\App\\ViewInterface');
     $this->context->expects($this->any())->method('getRequest')->will($this->returnValue($this->request));
     $this->context->expects($this->any())->method('getResponse')->will($this->returnValue($this->response));
     $this->context->expects($this->any())->method('getView')->will($this->returnValue($this->view));
     $this->controller = $this->objectManagerHelper->getObject('\\Magento\\Bundle\\Controller\\Adminhtml\\Bundle\\Selection\\Grid', ['context' => $this->context]);
 }
 protected function setUp()
 {
     $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
     $this->messageManagerMock = $this->getMock('Magento\\Framework\\Message\\ManagerInterface', [], [], '', false);
     $this->resultFactoryMock = $this->getMockBuilder('Magento\\Framework\\Controller\\ResultFactory')->disableOriginalConstructor()->getMock();
     $this->resultRedirectMock = $this->getMockBuilder('Magento\\Backend\\Model\\View\\Result\\Redirect')->disableOriginalConstructor()->getMock();
     $this->resultFactoryMock->expects($this->any())->method('create')->with(ResultFactory::TYPE_REDIRECT, [])->willReturn($this->resultRedirectMock);
     $this->contextMock = $this->getMock('\\Magento\\Backend\\App\\Action\\Context', [], [], '', false);
     $this->filterMock = $this->getMockBuilder('Magento\\Ui\\Component\\MassAction\\Filter')->disableOriginalConstructor()->getMock();
     $this->contextMock->expects($this->any())->method('getMessageManager')->willReturn($this->messageManagerMock);
     $this->contextMock->expects($this->any())->method('getResultFactory')->willReturn($this->resultFactoryMock);
 }
Пример #18
0
 protected function setUp()
 {
     $this->objectManager = new ObjectManager($this);
     $this->contextMock = $this->getMockBuilder(Context::class)->disableOriginalConstructor()->getMock();
     $this->attributeLabelCacheMock = $this->getMockBuilder(FrontendInterface::class)->getMockForAbstractClass();
     $this->coreRegistryMock = $this->getMockBuilder(Registry::class)->disableOriginalConstructor()->getMock();
     $this->resultPageFactoryMock = $this->getMockBuilder(PageFactory::class)->disableOriginalConstructor()->getMock();
     $this->requestMock = $this->getMockBuilder(RequestInterface::class)->setMethods(['getPostValue', 'has'])->getMockForAbstractClass();
     $this->resultFactoryMock = $this->getMockBuilder(ResultFactory::class)->disableOriginalConstructor()->getMock();
     $this->contextMock->expects($this->any())->method('getRequest')->willReturn($this->requestMock);
     $this->contextMock->expects($this->any())->method('getResultFactory')->willReturn($this->resultFactoryMock);
 }
Пример #19
0
 protected function setUp()
 {
     $this->autocomplete = $this->getMockBuilder('Magento\\Search\\Model\\AutocompleteInterface')->disableOriginalConstructor()->setMethods(['getItems'])->getMockForAbstractClass();
     $this->request = $this->getMockBuilder('\\Magento\\Framework\\App\\RequestInterface')->disableOriginalConstructor()->setMethods([])->getMockForAbstractClass();
     $this->response = $this->getMockBuilder('\\Magento\\Framework\\App\\ResponseInterface')->disableOriginalConstructor()->setMethods(['representJson', 'setRedirect'])->getMockForAbstractClass();
     $this->url = $this->getMockBuilder('Magento\\Framework\\UrlInterface')->disableOriginalConstructor()->setMethods(['getBaseUrl'])->getMockForAbstractClass();
     $this->context = $this->getMockBuilder('Magento\\Framework\\App\\Action\\Context')->setMethods(['getRequest', 'getResponse', 'getUrl'])->disableOriginalConstructor()->getMock();
     $this->context->expects($this->atLeastOnce())->method('getRequest')->will($this->returnValue($this->request));
     $this->context->expects($this->atLeastOnce())->method('getResponse')->will($this->returnValue($this->response));
     $this->context->expects($this->any())->method('getUrl')->will($this->returnValue($this->url));
     $this->objectManagerHelper = new ObjectManagerHelper($this);
     $this->controller = $this->objectManagerHelper->getObject('Magento\\Search\\Controller\\Ajax\\Suggest', ['context' => $this->context, 'autocomplete' => $this->autocomplete]);
 }
 protected function setUp()
 {
     $this->objectManagerHelper = new ObjectManagerHelper($this);
     $this->context = $this->getMockBuilder('\\Magento\\Backend\\App\\Action\\Context')->disableOriginalConstructor()->getMock();
     $this->request = $this->getMock('Magento\\Framework\\App\\RequestInterface');
     $this->response = $this->getMock('\\Magento\\Framework\\App\\ResponseInterface', ['sendResponse', 'setBody']);
     $this->productBuilder = $this->getMockBuilder('\\Magento\\Catalog\\Controller\\Adminhtml\\Product\\Builder')->disableOriginalConstructor()->setMethods(['build'])->getMock();
     $this->view = $this->getMock('\\Magento\\Framework\\App\\ViewInterface');
     $this->context->expects($this->any())->method('getRequest')->will($this->returnValue($this->request));
     $this->context->expects($this->any())->method('getResponse')->will($this->returnValue($this->response));
     $this->context->expects($this->any())->method('getView')->will($this->returnValue($this->view));
     $this->controller = $this->objectManagerHelper->getObject('\\Magento\\ConfigurableProduct\\Controller\\Adminhtml\\Product\\AddAttribute', ['context' => $this->context, 'productBuilder' => $this->productBuilder]);
 }
Пример #21
0
 private function prepareContext()
 {
     $this->request = $this->getMockBuilder('Magento\\Framework\\App\\Request\\Http')->setMethods(['getParam', 'getParams', 'setParams'])->disableOriginalConstructor()->getMock();
     $objectManager = $this->getMock('Magento\\Framework\\ObjectManagerInterface');
     $product = $this->getMockBuilder('Magento\\Catalog\\Model\\Product')->setMethods(['isProductsHasSku'])->disableOriginalConstructor()->getMock();
     $product->expects($this->any())->method('isProductsHasSku')->with([1, 2, 3])->willReturn(true);
     $objectManager->expects($this->any())->method('create')->with('Magento\\Catalog\\Model\\Product')->willReturn($product);
     $messageManager = $this->getMockBuilder('\\Magento\\Framework\\Message\\ManagerInterface')->setMethods([])->disableOriginalConstructor()->getMock();
     $messageManager->expects($this->any())->method('addError')->willReturn(true);
     $this->context = $this->getMockBuilder('Magento\\Backend\\App\\Action\\Context')->setMethods(['getRequest', 'getObjectManager', 'getMessageManager', 'getResultRedirectFactory'])->disableOriginalConstructor()->getMock();
     $this->context->expects($this->any())->method('getRequest')->willReturn($this->request);
     $this->context->expects($this->any())->method('getObjectManager')->willReturn($objectManager);
     $this->context->expects($this->any())->method('getMessageManager')->willReturn($messageManager);
     $this->context->expects($this->any())->method('getResultRedirectFactory')->willReturn($this->resultRedirectFactory);
 }
Пример #22
0
 protected function setUp()
 {
     $this->objectManagerHelper = new ObjectManagerHelper($this);
     $this->context = $this->getMockBuilder(\Magento\Backend\App\Action\Context::class)->disableOriginalConstructor()->getMock();
     $this->request = $this->getMock(\Magento\Framework\App\RequestInterface::class);
     $this->resultFactory = $this->getMock(\Magento\Framework\Controller\ResultFactory::class, [], [], '', false);
     $this->response = $this->getMock(\Magento\Framework\App\ResponseInterface::class, ['sendResponse', 'setBody']);
     $this->productBuilder = $this->getMockBuilder(\Magento\Catalog\Controller\Adminhtml\Product\Builder::class)->disableOriginalConstructor()->setMethods(['build'])->getMock();
     $this->view = $this->getMock(\Magento\Framework\App\ViewInterface::class);
     $this->context->expects($this->any())->method('getRequest')->will($this->returnValue($this->request));
     $this->context->expects($this->any())->method('getResponse')->will($this->returnValue($this->response));
     $this->context->expects($this->any())->method('getResultFactory')->will($this->returnValue($this->resultFactory));
     $this->context->expects($this->any())->method('getView')->will($this->returnValue($this->view));
     $this->controller = $this->objectManagerHelper->getObject(\Magento\ConfigurableProduct\Controller\Adminhtml\Product\AddAttribute::class, ['context' => $this->context, 'productBuilder' => $this->productBuilder]);
 }
Пример #23
0
 public function setUp()
 {
     $this->request = $this->getMock('Magento\\Framework\\App\\RequestInterface');
     $this->response = $this->getMock('Magento\\Framework\\App\\ResponseInterface');
     $this->categoryHelper = $this->getMock('Magento\\Catalog\\Helper\\Category', [], [], '', false);
     $this->objectManager = $this->getMock('Magento\\Framework\\ObjectManager', [], [], '', false);
     $this->eventManager = $this->getMock('Magento\\Framework\\Event\\ManagerInterface');
     $this->update = $this->getMock('Magento\\Framework\\View\\Layout\\ProcessorInterface');
     $this->layout = $this->getMock('Magento\\Framework\\View\\Layout', [], [], '', false);
     $this->layout->expects($this->any())->method('getUpdate')->will($this->returnValue($this->update));
     $this->view = $this->getMock('Magento\\Framework\\App\\ViewInterface');
     $this->view->expects($this->any())->method('getLayout')->will($this->returnValue($this->layout));
     $this->context = $this->getMock('Magento\\Backend\\App\\Action\\Context', [], [], '', false);
     $this->context->expects($this->any())->method('getRequest')->will($this->returnValue($this->request));
     $this->context->expects($this->any())->method('getResponse')->will($this->returnValue($this->response));
     $this->context->expects($this->any())->method('getObjectManager')->will($this->returnValue($this->objectManager));
     $this->context->expects($this->any())->method('getEventManager')->will($this->returnValue($this->eventManager));
     $this->context->expects($this->any())->method('getView')->will($this->returnValue($this->view));
     $this->category = $this->getMock('Magento\\Catalog\\Model\\Category', [], [], '', false);
     $this->categoryFactory = $this->getMock('Magento\\Catalog\\Model\\CategoryFactory', ['create'], [], '', false);
     $this->store = $this->getMock('Magento\\Store\\Model\\Store', [], [], '', false);
     $this->storeManager = $this->getMock('Magento\\Store\\Model\\StoreManagerInterface');
     $this->storeManager->expects($this->any())->method('getStore')->will($this->returnValue($this->store));
     $this->catalogDesign = $this->getMock('Magento\\Catalog\\Model\\Design', [], [], '', false);
     $this->layoutHelper = $this->getMock('Magento\\Theme\\Helper\\Layout', [], [], '', false);
     $this->action = (new ObjectManager($this))->getObject('Magento\\Catalog\\Controller\\Category\\View', ['context' => $this->context, 'catalogDesign' => $this->catalogDesign, 'categoryFactory' => $this->categoryFactory, 'storeManager' => $this->storeManager]);
 }
Пример #24
0
 public function setUp()
 {
     $this->requestMock = $this->getMock('Magento\\Framework\\App\\RequestInterface', [], [], '', false);
     $this->responseMock = $this->getMock('Magento\\Framework\\App\\ResponseInterface', [], [], '', false);
     $this->directoryMock = $this->getMock('Magento\\Framework\\Filesystem\\Directory\\ReadInterface', [], [], '', false);
     $this->fileSystemMock = $this->getMock('Magento\\Framework\\Filesystem', [], [], '', false);
     $this->storage = $this->getMock('Magento\\MediaStorage\\Helper\\File\\Storage', [], [], '', false);
     $this->objectManager = $this->getMock('Magento\\Framework\\ObjectManagerInterface', [], [], '', false);
     $this->contextMock = $this->getMock('Magento\\Backend\\App\\Action\\Context', [], [], '', false);
     $this->contextMock->expects($this->any())->method('getRequest')->willReturn($this->requestMock);
     $this->contextMock->expects($this->any())->method('getResponse')->willReturn($this->responseMock);
     $this->contextMock->expects($this->any())->method('getObjectManager')->willReturn($this->objectManager);
     $this->urlDecoderMock = $this->getMock('Magento\\Framework\\Url\\DecoderInterface', [], [], '', false);
     $this->resultRawMock = $this->getMock('Magento\\Framework\\Controller\\Result\\Raw', [], [], '', false);
     $this->resultRawFactoryMock = $this->getMock('Magento\\Framework\\Controller\\Result\\RawFactory', ['create'], [], '', false);
 }
Пример #25
0
 /**
  * @param \Magento\Backend\App\Action\Context $context
  * @param \Magento\Framework\Model\Context $contextModel
  * @param \Magento\Framework\Registry $coreRegistry
  * @param \Magento\Framework\View\Result\PageFactory $resultPageFactory
  * @param \Wyomind\Core\Helper\Data $coreHelper
  * @param \Wyomind\SimpleGoogleShopping\Helper\Data $sgsHelper
  * @param \Wyomind\SimpleGoogleShopping\Model\Feeds $sgsModel
  * @param \Magento\Framework\Model\Context $context_
  * @param \Magento\Backend\Model\View\Result\ForwardFactory $resultForwardFactory
  * @param \Magento\Framework\Controller\Result\RawFactory $resultRawFactory
  * @param \Magento\Framework\Filesystem\Directory\ReadFactory $directoryRead
  * @param \Wyomind\SimpleGoogleShopping\Helper\Parser $parserHelper
  * @param \Magento\Eav\Api\AttributeRepositoryInterface $attributeRepository
  */
 public function __construct(\Magento\Backend\App\Action\Context $context, \Magento\Framework\Model\Context $contextModel, \Magento\Framework\Registry $coreRegistry, \Magento\Framework\View\Result\PageFactory $resultPageFactory, \Wyomind\Core\Helper\Data $coreHelper, \Wyomind\SimpleGoogleShopping\Helper\Data $sgsHelper, \Wyomind\SimpleGoogleShopping\Model\Feeds $sgsModel, \Magento\Backend\Model\View\Result\ForwardFactory $resultForwardFactory, \Magento\Framework\Controller\Result\RawFactory $resultRawFactory, \Magento\Framework\Filesystem\Directory\ReadFactory $directoryRead, \Wyomind\SimpleGoogleShopping\Helper\Parser $parserHelper, \Magento\Eav\Api\AttributeRepositoryInterface $attributeRepository)
 {
     $this->coreRegistry = $coreRegistry;
     $this->resultPageFactory = $resultPageFactory;
     $this->coreHelper = $coreHelper;
     $this->cacheManager = $contextModel->getCacheManager();
     $this->sgsHelper = $sgsHelper;
     $this->sgsModel = $sgsModel;
     $this->resultForwardFactory = $resultForwardFactory;
     $this->resultRedirectFactory = $context->getResultRedirectFactory();
     $this->resultRawFactory = $resultRawFactory;
     $this->parserHelper = $parserHelper;
     $this->attributeRepository = $attributeRepository;
     $this->directoryRead = $directoryRead->create("app/code/Wyomind/SimpleGoogleShopping");
     parent::__construct($context);
 }
Пример #26
0
 /**
  * Set up test
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 protected function setUp()
 {
     $this->contextMock = $this->getMock('Magento\\Backend\\App\\Action\\Context', ['getAuthorization', 'getSession', 'getActionFlag', 'getAuth', 'getView', 'getHelper', 'getBackendUrl', 'getFormKeyValidator', 'getLocaleResolver', 'getCanUseBaseUrl', 'getRequest', 'getResponse', 'getObjectManager', 'getMessageManager'], [], '', false);
     $this->response = $this->getMock('Magento\\Framework\\App\\ResponseInterface', ['setRedirect', 'sendResponse'], [], '', false);
     $this->view = $this->getMock('\\Magento\\Framework\\App\\ViewInterface', ['loadLayout', 'getPage', 'getConfig', 'getTitle', 'renderLayout', 'loadLayoutUpdates', 'getDefaultLayoutHandle', 'addPageLayoutHandles', 'generateLayoutBlocks', 'generateLayoutXml', 'getLayout', 'addActionLayoutHandles', 'setIsLayoutLoaded', 'isLayoutLoaded'], [], '', false);
     $this->session = $this->getMock('\\Magento\\Backend\\Model\\Session', ['setIsUrlNotice'], [], '', false);
     $this->session->expects($this->any())->method('setIsUrlNotice')->willReturn($this->objectManager);
     $this->actionFlag = $this->getMock('\\Magento\\Framework\\App\\ActionFlag', ['get'], [], '', false);
     $this->actionFlag->expects($this->any())->method("get")->willReturn($this->objectManager);
     $this->objectManager = $this->getMock('Magento\\Framework\\TestFramework\\Unit\\Helper\\ObjectManager', ['get'], [], '', false);
     $this->request = $this->getMockForAbstractClass('\\Magento\\Framework\\App\\RequestInterface', ['getParam', 'getRequest'], '', false);
     $this->response->expects($this->any())->method("setRedirect")->willReturn(1);
     $this->page = $this->getMock('\\Magento\\Framework\\View\\Result\\Page', [], [], '', false);
     $this->config = $this->getMock('\\Magento\\Framework\\View\\Result\\Page', [], [], '', false);
     $this->title = $this->getMock('\\Magento\\Framework\\View\\Page\\Title', [], [], '', false);
     $this->messageManager = $this->getMockForAbstractClass('\\Magento\\Framework\\Message\\ManagerInterface', ['addError', 'addSuccess'], '', false);
     $this->indexReg = $this->getMock('Magento\\Framework\\Indexer\\IndexerRegistry', ['get', 'setScheduled'], [], '', false);
     $this->helper = $this->getMock('\\Magento\\Backend\\Helper\\Data', ['getUrl'], [], '', false);
     $this->contextMock->expects($this->any())->method("getObjectManager")->willReturn($this->objectManager);
     $this->contextMock->expects($this->any())->method("getRequest")->willReturn($this->request);
     $this->contextMock->expects($this->any())->method("getResponse")->willReturn($this->response);
     $this->contextMock->expects($this->any())->method("getMessageManager")->willReturn($this->messageManager);
     $this->contextMock->expects($this->any())->method("getSession")->willReturn($this->session);
     $this->contextMock->expects($this->any())->method("getActionFlag")->willReturn($this->actionFlag);
     $this->contextMock->expects($this->any())->method("getHelper")->willReturn($this->helper);
 }
Пример #27
0
 /**
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 public function setUp()
 {
     $objectManagerHelper = new ObjectManagerHelper($this);
     $this->shipmentLoader = $this->getMockBuilder('Magento\\Shipping\\Controller\\Adminhtml\\Order\\ShipmentLoader')->disableOriginalConstructor()->setMethods([])->getMock();
     $this->labelGenerator = $this->getMockBuilder('Magento\\Shipping\\Model\\Shipping\\LabelGenerator')->disableOriginalConstructor()->setMethods([])->getMock();
     $this->shipmentSender = $this->getMockBuilder('Magento\\Sales\\Model\\Order\\Email\\Sender\\ShipmentSender')->disableOriginalConstructor()->setMethods([])->getMock();
     $this->objectManager = $this->getMock('Magento\\Framework\\ObjectManagerInterface');
     $this->context = $this->getMock('Magento\\Backend\\App\\Action\\Context', ['getRequest', 'getResponse', 'getMessageManager', 'getRedirect', 'getObjectManager', 'getSession', 'getActionFlag', 'getHelper', 'getResultRedirectFactory', 'getFormKeyValidator'], [], '', false);
     $this->response = $this->getMock('Magento\\Framework\\App\\ResponseInterface', ['setRedirect', 'sendResponse'], [], '', false);
     $this->request = $this->getMockBuilder('Magento\\Framework\\App\\Request\\Http')->disableOriginalConstructor()->getMock();
     $this->objectManager = $this->getMock('Magento\\Framework\\ObjectManager\\ObjectManager', ['create', 'get'], [], '', false);
     $this->messageManager = $this->getMock('Magento\\Framework\\Message\\Manager', ['addSuccess', 'addError'], [], '', false);
     $this->session = $this->getMock('Magento\\Backend\\Model\\Session', ['setIsUrlNotice', 'getCommentText'], [], '', false);
     $this->actionFlag = $this->getMock('Magento\\Framework\\App\\ActionFlag', ['get'], [], '', false);
     $this->helper = $this->getMock('Magento\\Backend\\Helper\\Data', ['getUrl'], [], '', false);
     $this->resultRedirect = $this->getMock('Magento\\Framework\\Controller\\Result\\Redirect', ['setPath'], [], '', false);
     $this->resultRedirect->expects($this->any())->method('setPath')->willReturn($this->resultRedirect);
     $resultRedirectFactory = $this->getMock('Magento\\Framework\\Controller\\Result\\RedirectFactory', ['create'], [], '', false);
     $resultRedirectFactory->expects($this->once())->method('create')->willReturn($this->resultRedirect);
     $this->formKeyValidator = $this->getMock('Magento\\Framework\\Data\\Form\\FormKey\\Validator', ['validate'], [], '', false);
     $this->context->expects($this->once())->method('getMessageManager')->will($this->returnValue($this->messageManager));
     $this->context->expects($this->once())->method('getRequest')->will($this->returnValue($this->request));
     $this->context->expects($this->once())->method('getResponse')->will($this->returnValue($this->response));
     $this->context->expects($this->once())->method('getObjectManager')->will($this->returnValue($this->objectManager));
     $this->context->expects($this->once())->method('getSession')->will($this->returnValue($this->session));
     $this->context->expects($this->once())->method('getActionFlag')->will($this->returnValue($this->actionFlag));
     $this->context->expects($this->once())->method('getHelper')->will($this->returnValue($this->helper));
     $this->context->expects($this->once())->method('getResultRedirectFactory')->will($this->returnValue($resultRedirectFactory));
     $this->context->expects($this->once())->method('getFormKeyValidator')->will($this->returnValue($this->formKeyValidator));
     $this->saveAction = $objectManagerHelper->getObject('Magento\\Shipping\\Controller\\Adminhtml\\Order\\Shipment\\Save', ['labelGenerator' => $this->labelGenerator, 'shipmentSender' => $this->shipmentSender, 'context' => $this->context, 'shipmentLoader' => $this->shipmentLoader, 'request' => $this->request, 'response' => $this->response]);
 }
Пример #28
0
 /**
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 public function setUp()
 {
     $objectManagerHelper = new ObjectManagerHelper($this);
     $this->shipmentLoader = $this->getMockBuilder('Magento\\Shipping\\Controller\\Adminhtml\\Order\\ShipmentLoader')->disableOriginalConstructor()->setMethods([])->getMock();
     $this->labelGenerator = $this->getMockBuilder('Magento\\Shipping\\Model\\Shipping\\LabelGenerator')->disableOriginalConstructor()->setMethods([])->getMock();
     $this->shipmentSender = $this->getMockBuilder('Magento\\Sales\\Model\\Order\\Email\\Sender\\ShipmentSender')->disableOriginalConstructor()->setMethods([])->getMock();
     $this->context = $this->getMockBuilder('Magento\\Backend\\App\\Action\\Context')->disableOriginalConstructor()->setMethods([])->getMock();
     $this->objectManager = $this->getMock('Magento\\Framework\\ObjectManagerInterface');
     $this->context = $this->getMock('Magento\\Backend\\App\\Action\\Context', ['getRequest', 'getResponse', 'getMessageManager', 'getRedirect', 'getObjectManager', 'getSession', 'getActionFlag', 'getHelper', 'getView'], [], '', false);
     $this->response = $this->getMock('Magento\\Framework\\App\\ResponseInterface', ['setRedirect', 'sendResponse'], [], '', false);
     $this->request = $this->getMockBuilder('Magento\\Framework\\App\\Request\\Http')->disableOriginalConstructor()->getMock();
     $this->messageManager = $this->getMock('Magento\\Framework\\Message\\Manager', ['addSuccess', 'addError'], [], '', false);
     $this->session = $this->getMock('Magento\\Backend\\Model\\Session', ['setIsUrlNotice', 'getCommentText'], [], '', false);
     $this->actionFlag = $this->getMock('Magento\\Framework\\App\\ActionFlag', ['get'], [], '', false);
     $this->helper = $this->getMock('Magento\\Backend\\Helper\\Data', ['getUrl'], [], '', false);
     $this->view = $this->getMock('Magento\\Framework\\App\\ViewInterface', [], [], '', false);
     $this->resultPageMock = $this->getMockBuilder('Magento\\Framework\\View\\Result\\Page')->disableOriginalConstructor()->getMock();
     $this->pageConfigMock = $this->getMockBuilder('Magento\\Framework\\View\\Page\\Config')->disableOriginalConstructor()->getMock();
     $this->pageTitleMock = $this->getMockBuilder('Magento\\Framework\\View\\Page\\Title')->disableOriginalConstructor()->getMock();
     $this->context->expects($this->once())->method('getMessageManager')->will($this->returnValue($this->messageManager));
     $this->context->expects($this->once())->method('getRequest')->will($this->returnValue($this->request));
     $this->context->expects($this->once())->method('getResponse')->will($this->returnValue($this->response));
     $this->context->expects($this->once())->method('getObjectManager')->will($this->returnValue($this->objectManager));
     $this->context->expects($this->once())->method('getSession')->will($this->returnValue($this->session));
     $this->context->expects($this->once())->method('getActionFlag')->will($this->returnValue($this->actionFlag));
     $this->context->expects($this->once())->method('getHelper')->will($this->returnValue($this->helper));
     $this->context->expects($this->once())->method('getView')->will($this->returnValue($this->view));
     $this->newAction = $objectManagerHelper->getObject('Magento\\Shipping\\Controller\\Adminhtml\\Order\\Shipment\\NewAction', ['context' => $this->context, 'shipmentLoader' => $this->shipmentLoader, 'request' => $this->request, 'response' => $this->response, 'view' => $this->view]);
 }
 /**
  * Set up
  *
  * @return void
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 protected function setUp()
 {
     $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
     $this->categoryMock = $this->getMock('Magento\\Catalog\\Model\\Category', ['getPath', 'addData', 'getId', 'getName', 'getResource', 'setStoreId', 'toArray'], [], '', false);
     $this->contextMock = $this->getMock('Magento\\Backend\\App\\Action\\Context', ['getTitle', 'getRequest', 'getObjectManager', 'getEventManager', 'getResponse', 'getMessageManager', 'getResultRedirectFactory', 'getSession'], [], '', false);
     $this->resultRedirectFactoryMock = $this->getMock('Magento\\Backend\\Model\\View\\Result\\RedirectFactory', ['create'], [], '', false);
     $this->resultPageMock = $this->getMock('Magento\\Framework\\View\\Result\\Page', ['setActiveMenu', 'getConfig', 'addBreadcrumb', 'getLayout', 'getBlock', 'getTitle', 'prepend'], [], '', false);
     $this->resultPageMock->expects($this->any())->method('getConfig')->will($this->returnSelf());
     $this->resultPageMock->expects($this->any())->method('getTitle')->will($this->returnSelf());
     $this->resultPageFactoryMock = $this->getMock('Magento\\Framework\\View\\Result\\PageFactory', ['create'], [], '', false);
     $this->resultPageFactoryMock->expects($this->any())->method('create')->willReturn($this->resultPageMock);
     $this->resultJsonFactoryMock = $this->getMock('Magento\\Framework\\Controller\\Result\\JsonFactory', ['create'], [], '', false);
     $this->storeManagerInterfaceMock = $this->getMockForAbstractClass('Magento\\Store\\Model\\StoreManagerInterface', [], '', false, true, true, ['getStore', 'getDefaultStoreView', 'getRootCategoryId']);
     $this->requestMock = $this->getMockForAbstractClass('Magento\\Framework\\App\\RequestInterface', [], '', false, true, true, ['getParam', 'getPost', 'getPostValue', 'getQuery', 'setParam']);
     $this->objectManagerMock = $this->getMockBuilder('Magento\\Framework\\ObjectManagerInterface')->disableOriginalConstructor()->getMock();
     $this->eventManagerMock = $this->getMockForAbstractClass('Magento\\Framework\\Event\\ManagerInterface', [], '', false, true, true, ['dispatch']);
     $this->sessionMock = $this->getMock('Magento\\Backend\\Model\\Session', ['__call'], [], '', false);
     $this->contextMock->expects($this->any())->method('getTitle')->willReturn($this->titleMock);
     $this->contextMock->expects($this->any())->method('getRequest')->willReturn($this->requestMock);
     $this->contextMock->expects($this->any())->method('getObjectManager')->willReturn($this->objectManagerMock);
     $this->contextMock->expects($this->any())->method('getEventManager')->willReturn($this->eventManagerMock);
     $this->contextMock->expects($this->any())->method('getResponse')->willReturn($this->responseMock);
     $this->contextMock->expects($this->any())->method('getSession')->willReturn($this->sessionMock);
     $this->contextMock->expects($this->any())->method('getResultRedirectFactory')->willReturn($this->resultRedirectFactoryMock);
     $this->edit = $this->objectManager->getObject('Magento\\Catalog\\Controller\\Adminhtml\\Category\\Edit', ['context' => $this->contextMock, 'resultPageFactory' => $this->resultPageFactoryMock, 'resultJsonFactory' => $this->resultJsonFactoryMock, 'storeManager' => $this->storeManagerInterfaceMock]);
 }
Пример #30
0
 protected function setUp()
 {
     $this->directpostSessionMock = $this->getMockBuilder('Magento\\Authorizenet\\Model\\Directpost\\Session')->setMethods(['getLastOrderIncrementId', 'removeCheckoutOrderIncrementId', 'isCheckoutOrderIncrementIdExist', 'unsetData'])->disableOriginalConstructor()->getMock();
     $this->objectManagerMock = $this->getMock('Magento\\Framework\\ObjectManagerInterface');
     $this->orderMock = $this->getMockBuilder('Magento\\Sales\\Model\\Order')->setMethods(['getId', 'getState', 'getIncrementId', 'registerCancellation', 'loadByIncrementId', 'save'])->disableOriginalConstructor()->getMock();
     $this->adminOrderCreateMock = $this->getMockBuilder('Magento\\Sales\\Model\\AdminOrder\\Create')->setMethods(['getSession'])->disableOriginalConstructor()->getMock();
     $sessionMock = $this->getMockBuilder('Magento\\Backend\\Model\\Session')->disableOriginalConstructor()->getMock();
     $this->sessionQuoteMock = $this->getMockBuilder('Magento\\Backend\\Model\\Session\\Quote')->setMethods(['getOrder', 'clearStorage'])->disableOriginalConstructor()->getMock();
     $this->objectManagerMock->expects($this->atLeastOnce())->method('get')->willReturnMap([['Magento\\Authorizenet\\Model\\Directpost\\Session', $this->directpostSessionMock], ['Magento\\Sales\\Model\\AdminOrder\\Create', $this->adminOrderCreateMock], ['Magento\\Backend\\Model\\Session\\Quote', $this->sessionQuoteMock], ['Magento\\Backend\\Model\\Session', $sessionMock]]);
     $this->objectManagerMock->expects($this->any())->method('create')->with('Magento\\Sales\\Model\\Order')->willReturn($this->orderMock);
     $this->requestMock = $this->getMockBuilder('Magento\\Framework\\App\\RequestInterface')->setMethods(['getParams'])->getMockForAbstractClass();
     $responseMock = $this->getMockForAbstractClass('Magento\\Framework\\App\\ResponseInterface');
     $redirectMock = $this->getMock('Magento\\Framework\\App\\Response\\RedirectInterface');
     $this->messageManagerMock = $this->getMock('Magento\\Framework\\Message\\ManagerInterface');
     $this->contextMock = $this->getMockBuilder('Magento\\Backend\\App\\Action\\Context')->setMethods(['getObjectManager', 'getRequest', 'getResponse', 'getRedirect', 'getMessageManager'])->disableOriginalConstructor()->getMock();
     $this->contextMock->expects($this->any())->method('getObjectManager')->willReturn($this->objectManagerMock);
     $this->contextMock->expects($this->any())->method('getRequest')->willReturn($this->requestMock);
     $this->contextMock->expects($this->any())->method('getResponse')->willReturn($responseMock);
     $this->contextMock->expects($this->any())->method('getRedirect')->willReturn($redirectMock);
     $this->contextMock->expects($this->any())->method('getMessageManager')->willReturn($this->messageManagerMock);
     $this->productHelperMock = $this->getMockBuilder('Magento\\Catalog\\Helper\\Product')->disableOriginalConstructor()->getMock();
     $this->escaperMock = $this->getMockBuilder('Magento\\Framework\\Escaper')->disableOriginalConstructor()->getMock();
     $this->resultPageFactoryMock = $this->getMockBuilder('Magento\\Framework\\View\\Result\\PageFactory')->disableOriginalConstructor()->getMock();
     $this->forwardFactoryMock = $this->getMockBuilder('Magento\\Backend\\Model\\View\\Result\\ForwardFactory')->setMethods(['create'])->disableOriginalConstructor()->getMock();
     $this->coreRegistryMock = $this->getMockBuilder('Magento\\Framework\\Registry')->setMethods(['register'])->disableOriginalConstructor()->getMock();
     $resultLayoutMock = $this->getMockBuilder('Magento\\Framework\\View\\Result\\Layout')->disableOriginalConstructor()->getMock();
     $this->resultLayoutFactoryMock = $this->getMockBuilder('Magento\\Framework\\View\\Result\\LayoutFactory')->setMethods(['create'])->disableOriginalConstructor()->getMock();
     $this->resultLayoutFactoryMock->expects($this->once())->method('create')->willReturn($resultLayoutMock);
     $this->helperMock = $this->getMockBuilder('Magento\\Authorizenet\\Helper\\Backend\\Data')->setMethods(['getSuccessOrderUrl'])->disableOriginalConstructor()->getMock();
     $this->controller = new Redirect($this->contextMock, $this->productHelperMock, $this->escaperMock, $this->resultPageFactoryMock, $this->forwardFactoryMock, $this->coreRegistryMock, $this->resultLayoutFactoryMock, $this->helperMock);
 }