/** * Test _prepareForm method */ public function testPrepareForm() { // TODO Move to unit tests after MAGETWO-4015 complete $this->assertEmpty($this->_block->getForm()); $this->_urlBuilder->expects($this->once())->method('getUrl')->with('*/*/save', array())->will($this->returnValue('action_url')); $this->_block->toHtml(); $form = $this->_block->getForm(); $this->assertInstanceOf('Varien_Data_Form', $form); $this->assertTrue($form->getUseContainer()); $this->assertEquals('edit_form', $form->getId()); $this->assertEquals('post', $form->getMethod()); $this->assertEquals('action_url', $form->getAction()); }
public function testUseSecretKey() { $this->_model->setNoSecret(true); $this->assertFalse($this->_model->useSecretKey()); $this->_model->setNoSecret(false); $this->assertTrue($this->_model->useSecretKey()); }
protected function setUp() { $mediaUploader = $this->getMockBuilder('Mage_Adminhtml_Block_Media_Uploader')->disableOriginalConstructor()->setMethods(array('getDataMaxSizeInBytes'))->getMock(); $mediaUploader->expects($this->once())->method('getDataMaxSizeInBytes')->will($this->returnValue('999')); $this->_url = $this->getMock('Mage_Backend_Model_Url', array('getUrl'), array(), '', false); $this->_url->expects($this->once())->method('getUrl')->will($this->returnValue('http://example.com/pub/images/catalog_product_gallery/upload/')); $jsonEncode = function ($value) { return json_encode($value); }; $this->_coreHelper = $this->getMockBuilder('Mage_Core_Helper_Data')->disableOriginalConstructor()->setMethods(array('escapeHtml', 'jsonEncode'))->getMock(); $this->_coreHelper->expects($this->any())->method('jsonEncode')->will($this->returnCallback($jsonEncode)); $this->_catalogHelperData = $this->getMockBuilder('Mage_Catalog_Helper_Data')->disableOriginalConstructor()->setMethods(array('__'))->getMock(); $this->_catalogHelperData->expects($this->any())->method('__')->will($this->returnCallback('json_encode')); $form = $this->getMockBuilder('Varien_Data_Form')->disableOriginalConstructor()->setMethods(null)->getMock(); $product = $this->getMockBuilder('Mage_Catalog_Model_Product')->disableOriginalConstructor()->setMethods(array('getMediaGalleryImages'))->getMock(); $form->setDataObject($product); $this->_block = new Mage_Adminhtml_Block_Catalog_Product_Helper_Form_BaseImage(array('name' => 'image', 'label' => 'Base Image', 'mediaUploader' => $mediaUploader, 'url' => $this->_url, 'coreHelper' => $this->_coreHelper, 'catalogHelperData' => $this->_catalogHelperData)); $this->_block->setForm($form); $this->_block->setHtmlId('image'); }
/** * Check that secret key generation is based on usage of routeName extracted from request Forward info */ public function testGetSecretKeyGenerationWithRouteNameInForwardInfo() { $routeName = 'adminhtml'; $controllerName = 'catalog'; $actionName = 'index'; $keyFromParams = $this->_model->getSecretKey($routeName, $controllerName, $actionName); $requestMock = $this->getMock('Mage_Core_Controller_Request_Http', array('getBeforeForwardInfo'), array(), '', false); $requestMock->expects($this->at(0))->method('getBeforeForwardInfo')->with('route_name')->will($this->returnValue('adminhtml')); $requestMock->expects($this->at(1))->method('getBeforeForwardInfo')->with('route_name')->will($this->returnValue('adminhtml')); $requestMock->expects($this->at(2))->method('getBeforeForwardInfo')->with('controller_name')->will($this->returnValue('catalog')); $requestMock->expects($this->at(3))->method('getBeforeForwardInfo')->with('controller_name')->will($this->returnValue('catalog')); $requestMock->expects($this->at(4))->method('getBeforeForwardInfo')->with('action_name')->will($this->returnValue('index')); $requestMock->expects($this->at(5))->method('getBeforeForwardInfo')->with('action_name')->will($this->returnValue('index')); $this->_model->setRequest($requestMock); $keyFromRequest = $this->_model->getSecretKey(); $this->assertEquals($keyFromParams, $keyFromRequest); }
/** * Get url to upload files * * @return string */ protected function _getUploadUrl() { return $this->_url->getUrl('*/catalog_product_gallery/upload'); }
/** * Replace Callback Secret Key * * @param array $match * @return string */ protected function _callbackSecretKey($match) { return Mage_Backend_Model_Url::SECRET_KEY_PARAM_NAME . '/' . $this->_url->getSecretKey($match[1], $match[2], $match[3]); }
/** * Retrieve menu item url * * @return string */ public function getUrl() { if ((bool) $this->_action) { return $this->_urlModel->getUrl((string) $this->_action, array('_cache_secret_key' => true)); } return '#'; }
/** * Create url for passed item using passed url model * @param Varien_Object $item * @return string */ public function getUrl($item) { $params = $this->_prepareParameters($item); return $this->_urlModel->getUrl($this->_path, $params); }
public function testGetSaveTemporaryLayoutUpdateUrl() { $this->_urlBuilder->expects($this->once())->method('getUrl')->will($this->returnArgument(0)); $this->assertEquals('*/*/saveTemporaryLayoutUpdate', $this->_block->getSaveTemporaryLayoutUpdateUrl()); }
/** * Test getCreateUrl method */ public function testGetCreateUrl() { $expectedUrl = 'create_url'; $this->_urlBuilder->expects($this->once())->method('getUrl')->with('*/*/edit', array())->will($this->returnValue($expectedUrl)); $this->assertEquals($expectedUrl, $this->_block->getCreateUrl()); }
/** * Test getSaveAndContinueUrl method */ public function testGetSaveAndContinueUrl() { $expectedUrl = 'save_and_continue_url'; $this->_urlBuilder->expects($this->once())->method('getUrl')->with('*/*/save', array('_current' => true, 'continue' => true))->will($this->returnValue($expectedUrl)); $this->assertEquals($expectedUrl, $this->_block->getSaveAndContinueUrl()); }