Beispiel #1
0
 /**
  * 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());
 }
Beispiel #2
0
 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');
 }
Beispiel #3
0
 public function testGetSaveTemporaryLayoutUpdateUrl()
 {
     $this->_urlBuilder->expects($this->once())->method('getUrl')->will($this->returnArgument(0));
     $this->assertEquals('*/*/saveTemporaryLayoutUpdate', $this->_block->getSaveTemporaryLayoutUpdateUrl());
 }
Beispiel #4
0
 /**
  * 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());
 }
Beispiel #5
0
 /**
  * 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());
 }