Пример #1
0
 public function testExecute()
 {
     $this->objectManager->expects($this->once())->method('get')->with('Magento\\Theme\\Helper\\Storage')->willReturn($this->storageHelper);
     $this->storageHelper->expects($this->once())->method('getRelativeUrl')->willReturn('http://relative.url/');
     $this->response->expects($this->once())->method('setBody')->with('http://relative.url/');
     $this->controller->execute();
 }
Пример #2
0
    public function testExecute()
    {
        $this->storageHelper->expects($this->once())
            ->method('getCurrentPath')
            ->willReturn('/current/path/');

        $this->objectManager->expects($this->at(0))
            ->method('get')
            ->with('Magento\Theme\Model\Wysiwyg\Storage')
            ->willReturn($this->storage);
        $this->storage->expects($this->once())
            ->method('deleteDirectory')
            ->with('/current/path/')
            ->willThrowException(new \Exception('Message'));

        $jsonData = $this->getMock('Magento\Framework\Json\Helper\Data', [], [], '', false);
        $jsonData->expects($this->once())
            ->method('jsonEncode')
            ->with(['error' => true, 'message' => 'Message'])
            ->willReturn('{"error":"true","message":"Message"}');

        $this->objectManager->expects($this->at(1))
            ->method('get')
            ->with('Magento\Framework\Json\Helper\Data')
            ->willReturn($jsonData);

        $this->controller->executeInternal();
    }
Пример #3
0
 public function testGetTreeLoaderUrl()
 {
     $requestParams = [\Magento\Theme\Helper\Storage::PARAM_THEME_ID => 1, \Magento\Theme\Helper\Storage::PARAM_CONTENT_TYPE => \Magento\Theme\Model\Wysiwyg\Storage::TYPE_IMAGE, \Magento\Theme\Helper\Storage::PARAM_NODE => 'root'];
     $expectedUrl = 'some_url';
     $this->_helperStorage->expects($this->once())->method('getRequestParams')->will($this->returnValue($requestParams));
     $this->_urlBuilder->expects($this->once())->method('getUrl')->with('adminhtml/*/treeJson', $requestParams)->will($this->returnValue($expectedUrl));
     $this->assertEquals($expectedUrl, $this->_filesTree->getTreeLoaderUrl());
 }
Пример #4
0
 public function testExecute()
 {
     $this->request->expects($this->once())->method('isPost')->willReturn(true);
     $this->request->expects($this->once())->method('getParam')->with('files')->willReturn('{"files":"file"}');
     $jsonData = $this->getMock('Magento\\Framework\\Json\\Helper\\Data', [], [], '', false);
     $jsonData->expects($this->once())->method('jsonDecode')->with('{"files":"file"}')->willReturn(['files' => 'file']);
     $this->objectManager->expects($this->at(0))->method('get')->with('Magento\\Framework\\Json\\Helper\\Data')->willReturn($jsonData);
     $this->objectManager->expects($this->at(1))->method('get')->with('Magento\\Theme\\Model\\Wysiwyg\\Storage')->willReturn($this->storage);
     $this->storage->expects($this->once())->method('deleteFile')->with('file');
     $this->controller->execute();
 }
Пример #5
0
    public function testExecute()
    {
        $layout = $this->getMockForAbstractClass('Magento\Framework\View\LayoutInterface', [], '', false);
        $storage = $this->getMock('Magento\Theme\Model\Wysiwyg\Storage', [], [], '', false);
        $block = $this->getMockForAbstractClass(
            'Magento\Framework\View\Element\BlockInterface',
            [],
            '',
            false,
            false,
            true,
            ['setStorage']
        );

        $this->view->expects($this->once())
            ->method('loadLayout')
            ->with('empty');
        $this->view->expects($this->once())
            ->method('getLayout')
            ->willReturn($layout);
        $layout->expects($this->once())
            ->method('getBlock')
            ->with('wysiwyg_files.files')
            ->willReturn($block);
        $block->expects($this->once())
            ->method('setStorage')
            ->with($storage);
        $this->objectManager->expects($this->at(0))
            ->method('get')
            ->with('Magento\Theme\Model\Wysiwyg\Storage')
            ->willReturn($storage);
        $this->storage->expects($this->once())
            ->method('getCurrentPath')
            ->willThrowException(new \Exception('Message'));

        $jsonData = $this->getMock('Magento\Framework\Json\Helper\Data', [], [], '', false);
        $jsonData->expects($this->once())
            ->method('jsonEncode')
            ->with(['error' => true, 'message' => 'Message'])
            ->willReturn('{"error":"true","message":"Message"}');

        $this->objectManager->expects($this->at(1))
            ->method('get')
            ->with('Magento\Framework\Json\Helper\Data')
            ->willReturn($jsonData);

        $this->response->expects($this->once())
            ->method('representJson');

        $this->controller->executeInternal();
    }
Пример #6
0
 public function testGetContentsUrl()
 {
     $expectedUrl = 'some_url';
     $expectedRequest = 'some_request';
     $requestParams = [\Magento\Theme\Helper\Storage::PARAM_THEME_ID => 1, \Magento\Theme\Helper\Storage::PARAM_CONTENT_TYPE => \Magento\Theme\Model\Wysiwyg\Storage::TYPE_IMAGE, \Magento\Theme\Helper\Storage::PARAM_NODE => 'root'];
     $this->_urlBuilder->expects($this->once())->method('getUrl')->with('adminhtml/*/contents', ['type' => $expectedRequest] + $requestParams)->will($this->returnValue($expectedUrl));
     $this->_request->expects($this->once())->method('getParam')->with('type')->will($this->returnValue($expectedRequest));
     $this->_helperStorage->expects($this->once())->method('getRequestParams')->will($this->returnValue($requestParams));
     $this->assertEquals($expectedUrl, $this->_filesContent->getContentsUrl());
 }
Пример #7
0
 /**
  * cover \Magento\Theme\Model\Wysiwyg\Storage::deleteDirectory
  * @expectedException \Magento\Framework\Exception\LocalizedException
  */
 public function testDeleteRootDirectory()
 {
     $directoryPath = $this->_storageRoot;
     $this->_helperStorage->expects($this->atLeastOnce())->method('getStorageRoot')->will($this->returnValue($this->_storageRoot));
     $this->_storageModel->deleteDirectory($directoryPath);
 }