/** * @covers Mage_Payment_Block_Form_ContainerAbstract::getChildBlock */ public function testSetMethodFormTemplate() { $objectManagerHelper = new Magento_Test_Helper_ObjectManager($this); $childBlockA = $objectManagerHelper->getBlock('Mage_Core_Block_Template'); $childBlockB = $objectManagerHelper->getBlock('Mage_Core_Block_Template'); $func = function ($blockName) use($childBlockA, $childBlockB) { switch ($blockName) { case 'payment.method.a': return $childBlockA; case 'payment.method.b': return $childBlockB; } return null; }; $block = $this->getMock('Mage_Payment_Block_Form_Container', array('getChildBlock'), array(), '', false); $block->expects($this->atLeastOnce())->method('getChildBlock')->will($this->returnCallback($func)); $template = 'any_template.phtml'; $this->assertNotEquals($template, $childBlockA->getTemplate()); $this->assertNotEquals($template, $childBlockB->getTemplate()); $block->setMethodFormTemplate('a', $template); $this->assertEquals($template, $childBlockA->getTemplate()); // Template is set to the block $this->assertNotEquals($template, $childBlockB->getTemplate()); // Template is not propagated to other blocks }
public function testGetTemplate() { $helper = new Magento_Test_Helper_ObjectManager($this); /** @var $block Mage_DesignEditor_Block_Page_Html_Head_Vde */ $block = $helper->getBlock('Mage_DesignEditor_Block_Page_Html_Head_Vde'); $this->assertNull($block->getTemplate()); }
protected function setUp() { $helper = new Magento_Test_Helper_ObjectManager($this); $this->_urlBuilder = $this->getMock('Mage_Backend_Model_Url', array('getUrl'), array(), '', false); $arguments = array('urlBuilder' => $this->_urlBuilder); $this->_block = $helper->getBlock('Mage_DesignEditor_Block_Adminhtml_Editor_Toolbar_Buttons', $arguments); }
public function testGetProductThumbnailUrlForConfigurable() { $url = 'pub/media/catalog/product/cache/1/thumbnail/75x/9df78eab33525d08d6e5fb8d27136e95/_/_/__green.gif'; $objectManagerHelper = new Magento_Test_Helper_ObjectManager($this); $configView = $this->getMock('Magento_Config_View', array('getVarValue'), array(), '', false); $configView->expects($this->any())->method('getVarValue')->will($this->returnValue(75)); $filesystem = $this->getMockBuilder('Magento_Filesystem')->disableOriginalConstructor()->getMock(); $designPackage = $this->getMock('Mage_Core_Model_Design_Package', array('getViewConfig'), array($filesystem)); $designPackage->expects($this->any())->method('getViewConfig')->will($this->returnValue($configView)); $configurable = $objectManagerHelper->getBlock('Mage_Checkout_Block_Cart_Item_Renderer_Configurable', array('designPackage' => $designPackage)); $product = $this->getMock('Mage_Catalog_Model_Product', array('isConfigurable'), array(), '', false); $product->expects($this->any())->method('isConfigurable')->will($this->returnValue(true)); $childProduct = $this->getMock('Mage_Catalog_Model_Product', array('getThumbnail', 'getDataByKey'), array(), '', false); $childProduct->expects($this->any())->method('getThumbnail')->will($this->returnValue('/_/_/__green.gif')); $childItem = $objectManagerHelper->getModel('Mage_Sales_Model_Quote_Item'); $childItem->setData('product', $childProduct); $item = $objectManagerHelper->getModel('Mage_Sales_Model_Quote_Item'); $item->setData('product', $product); $item->addChild($childItem); $helperImage = $this->getMock('Mage_Catalog_Helper_Image', array('init', 'resize', '__toString')); $helperImage->expects($this->any())->method('init')->will($this->returnValue($helperImage)); $helperImage->expects($this->any())->method('resize')->will($this->returnValue($helperImage)); $helperImage->expects($this->any())->method('__toString')->will($this->returnValue($url)); $layout = $configurable->getLayout(); $layout->expects($this->any())->method('helper')->will($this->returnValue($helperImage)); $configurable->setItem($item); $configurableUrl = $configurable->getProductThumbnailUrl(); $this->assertNotNull($configurableUrl); }
protected function setUp() { $objectManagerHelper = new Magento_Test_Helper_ObjectManager($this); $this->_resetRobotsBlock = $objectManagerHelper->getBlock('Mage_Adminhtml_Block_Page_System_Config_Robots_Reset', array('application' => $this->getMock('Mage_Core_Model_App', array(), array(), '', false), 'urlBuilder' => $this->getMock('Mage_Backend_Model_Url', array(), array(), '', false))); $this->_mockRobotsHelper = $this->getMockBuilder('Mage_Page_Helper_Robots')->setMethods(array('getRobotsDefaultCustomInstructions'))->getMock(); Mage::register('_helper/Mage_Page_Helper_Robots', $this->_mockRobotsHelper); }
/** * Test for _beforeToHtml method * * @dataProvider beforeToHtmlDataProvider * @param object $apiRole * @param array $expectedTabIds */ public function testBeforeToHtml($apiRole, $expectedTabIds) { $this->_block->setApiRole($apiRole); $mainBlock = $this->_helper->getBlock('Mage_Core_Block_Text'); $resourceBlock = $this->_helper->getBlock('Mage_Core_Block_Text'); $userBlock = $this->_helper->getBlock('Mage_Core_Block_Text'); $this->_layout->expects($this->any())->method('getBlock')->will($this->returnValueMap(array(array('webapi.role.edit.tab.main', $mainBlock), array('webapi.role.edit.tab.resource', $resourceBlock), array('webapi.role.edit.tab.users.grid', $userBlock)))); $this->_request->expects($this->any())->method('getParam')->will($this->returnValueMap(array(array('active_tab', null, 'main_section')))); // todo: do checks using toHtml() when DI is implemented for abstract blocks $toHtmlMethod = new ReflectionMethod($this->_block, '_beforeToHtml'); $toHtmlMethod->setAccessible(true); $toHtmlMethod->invoke($this->_block); $this->assertEquals($expectedTabIds, $this->_block->getTabsIds()); $this->assertEquals($apiRole, $mainBlock->getApiRole()); $this->assertEquals($apiRole, $resourceBlock->getApiRole()); }
public function setUp() { $this->_appMock = $this->getMock('Mage_Core_Model_App', array(), array(), '', false); $arguments = array('application' => $this->_appMock, 'urlBuilder' => $this->getMock('Mage_Backend_Model_Url', array(), array(), '', false)); $objectManagerHelper = new Magento_Test_Helper_ObjectManager($this); $this->_model = $objectManagerHelper->getBlock('Mage_Backend_Block_Widget_Grid_Column_Multistore', $arguments); }
protected function setUp() { $objectManager = new Magento_Test_Helper_ObjectManager($this); $registryMock = $this->getMock('Mage_Core_Model_Registry', array(), array(), '', false, false); $layoutMock = $this->getMock('Mage_Core_Model_Layout', array(), array(), '', false, false); $helperMock = $this->getMock('Mage_Adminhtml_Helper_Data', array(), array(), '', false, false); $menuConfigMock = $this->getMock('Mage_Backend_Model_Menu_Config', array(), array(), '', false, false); $menuMock = $this->getMock('Mage_Backend_Model_Menu', array(), array(), '', false, false); $menuItemMock = $this->getMock('Mage_Backend_Model_Menu_Item', array(), array(), '', false, false); $urlBuilder = $this->getMock('Mage_Backend_Model_Url', array(), array(), '', false, false); $this->_configStructureMock = $this->getMock('Mage_Backend_Model_Config_Structure', array(), array(), '', false, false); $params = array('urlBuilder' => $urlBuilder, 'registry' => $registryMock, 'layout' => $layoutMock, 'menuConfig' => $menuConfigMock, 'configStructure' => $this->_configStructureMock); $arguments = $objectManager->getConstructArguments(Magento_Test_Helper_ObjectManager::BLOCK_ENTITY, 'Mage_Adminhtml_Block_System_Email_Template_Edit', $params); $urlBuilder->expects($this->any())->method('getUrl')->will($this->returnArgument(0)); $menuConfigMock->expects($this->any())->method('getMenu')->will($this->returnValue($menuMock)); $menuMock->expects($this->any())->method('get')->will($this->returnValue($menuItemMock)); $menuItemMock->expects($this->any())->method('getModuleHelper')->will($this->returnValue($helperMock)); $menuItemMock->expects($this->any())->method('getTitle')->will($this->returnValue('Title')); $paths = array(array('scope' => 'scope_11', 'scope_id' => 'scope_id_1', 'path' => 'section1/group1/field1'), array('scope' => 'scope_11', 'scope_id' => 'scope_id_1', 'path' => 'section1/group1/group2/field1'), array('scope' => 'scope_11', 'scope_id' => 'scope_id_1', 'path' => 'section1/group1/group2/group3/field1')); $templateMock = $this->getMock('Mage_Adminhtml_Model_Email_Template', array(), array(), '', false, false); $templateMock->expects($this->once())->method('getSystemConfigPathsWhereUsedCurrently')->will($this->returnValue($paths)); $registryMock->expects($this->once())->method('registry')->with('current_email_template')->will($this->returnValue($templateMock)); $layoutMock->expects($this->any())->method('helper')->will($this->returnValue($helperMock)); $helperMock->expects($this->any())->method('__')->will($this->returnArgument(0)); $this->_block = $objectManager->getBlock('Mage_Adminhtml_Block_System_Email_Template_Edit', $arguments); }
/** * @param array $sourceItems * @param array $vdeItems * @param array $expectedItems * * @dataProvider getCssJsHtmlDataProvider */ public function testGetCssJsHtml(array $sourceItems, array $vdeItems = null, array $expectedItems = null) { $helper = new Magento_Test_Helper_ObjectManager($this); if ($vdeItems !== null) { /** @var $vdeHead Mage_DesignEditor_Block_Page_Html_Head_Vde */ $vdeHead = $helper->getBlock('Mage_DesignEditor_Block_Page_Html_Head_Vde'); $vdeHead->setData('items', $vdeItems); $layoutMock = $this->getMock('Mage_Core_Model_Layout', array('getBlock'), array(), '', false); $layoutMock->expects($this->once())->method('getBlock')->will($this->returnValue($vdeHead)); $this->_model = $helper->getBlock('Mage_DesignEditor_Block_Page_Html_Head', array('layout' => $layoutMock)); } else { $this->_model = $helper->getBlock('Mage_DesignEditor_Block_Page_Html_Head'); } $this->_model->setData('items', $sourceItems); $this->assertInternalType('string', $this->_model->getCssJsHtml()); $this->assertEquals($expectedItems, $this->_model->getData('items')); }
protected function setUp() { $this->_layout = $this->getMockBuilder('Mage_Core_Model_Layout')->disableOriginalConstructor()->setMethods(array('helper', 'getChildBlock', 'getChildName'))->getMock(); $this->_request = $this->getMockBuilder('Mage_Core_Controller_Request_Http')->disableOriginalConstructor()->setMethods(array('getParam'))->getMock(); $this->_request->expects($this->any())->method('getParam')->with('user_id')->will($this->returnValue(1)); $helper = new Magento_Test_Helper_ObjectManager($this); $this->_block = $helper->getBlock('Mage_Webapi_Block_Adminhtml_User_Edit', array('urlBuilder' => $this->getMockBuilder('Mage_Backend_Model_Url')->disableOriginalConstructor()->getMock(), 'layout' => $this->_layout, 'request' => $this->_request)); }
protected function setUp() { $this->_applicationModel = $this->getMock('Mage_Core_Model_App', array(), array(), '', false); $this->_websiteFactory = $this->getMock('Mage_Core_Model_Website_Factory', array(), array(), '', false); $this->_storeGroupFactory = $this->getMock('Mage_Core_Model_Store_Group_Factory', array(), array(), '', false); $helper = new Magento_Test_Helper_ObjectManager($this); $this->_object = $helper->getBlock('Mage_Backend_Block_Store_Switcher', array('urlBuilder' => $this->getMock('Mage_Backend_Model_Url', array(), array(), '', false), 'application' => $this->_applicationModel, 'websiteFactory' => $this->_websiteFactory, 'storeGroupFactory' => $this->_storeGroupFactory)); }
/** * @covers Magento_Test_TestCase_ObjectManager::getBlock */ public function testGetBlock() { $objectManager = new Magento_Test_Helper_ObjectManager($this); /** @var $template Mage_Core_Block_Template */ $template = $objectManager->getBlock('Mage_Core_Block_Template'); $this->assertInstanceOf('Mage_Core_Block_Template', $template); foreach ($this->_blockDependencies as $propertyName => $propertyType) { $this->assertAttributeInstanceOf($propertyType, '_' . $propertyName, $template); } $area = 'frontend'; /** @var $layoutMock Mage_Core_Model_Layout */ $layoutMock = $this->getMock('Mage_Core_Model_Layout', array('getArea'), array(), '', false); $layoutMock->expects($this->once())->method('getArea')->will($this->returnValue($area)); $arguments = array('layout' => $layoutMock); /** @var $template Mage_Core_Block_Template */ $template = $objectManager->getBlock('Mage_Core_Block_Template', $arguments); $this->assertEquals($area, $template->getArea()); }
protected function setUp() { $this->_helperMock = $this->getMock('Mage_Backend_Helper_Data', array(), array(), '', false); $this->_layoutMock = $this->getMock('Mage_Core_Model_Layout', array(), array(), '', false); $this->_layoutMock->expects($this->any())->method('helper')->will($this->returnValue($this->_helperMock)); $arguments = array('urlBuilder' => $this->getMock('Mage_Backend_Model_Url', array(), array(), '', false), 'layout' => $this->_layoutMock); $objectManagerHelper = new Magento_Test_Helper_ObjectManager($this); $this->_blockMock = $objectManagerHelper->getBlock('Mage_Backend_Block_Widget_Button', $arguments); }
protected function setUp() { $objectManagerHelper = new Magento_Test_Helper_ObjectManager($this); $this->_method = new Varien_Object(); $this->_info = $objectManagerHelper->getModel('Mage_Payment_Model_Info'); $this->_instructions = $objectManagerHelper->getBlock('Mage_Payment_Block_Info_Instructions'); $this->_info->setMethodInstance($this->_method); $this->_instructions->setInfo($this->_info); }
protected function setUp() { $objectManagerHelper = new Magento_Test_Helper_ObjectManager($this); $helperMock = $this->getMock('Mage_Tag_Helper_Data', array('__'), array(), '', false); $helperMock->expects($this->any())->method('__')->will($this->returnArgument(0)); $authSession = $this->getMock('Mage_Core_Model_Authorization', array('isAllowed'), array(), '', false); $authSession->expects($this->any())->method('isAllowed')->will($this->returnCallback(array($this, 'isAllowedCallback'))); $data = array('authSession' => $authSession, 'urlBuilder' => $this->getMock('Mage_Backend_Model_Url', array(), array(), '', false), 'data' => array('helpers' => array('Mage_Tag_Helper_Data' => $helperMock))); $this->_model = $objectManagerHelper->getBlock($this->_modelName, $data); }
public function setUp() { $coreHelper = $this->getMock('Mage_Core_Helper_Data', array('jsonEncode')); $coreHelper->expects($this->any())->method('jsonEncode')->will($this->returnCallback(array($this, 'jsonEncodeCallback'))); $importModel = $this->getMock('Mage_ImportExport_Model_Import', array('getEntityBehaviors', 'getUniqueEntityBehaviors')); $importModel->staticExpects($this->any())->method('getEntityBehaviors')->will($this->returnValue($this->_sourceEntities)); $importModel->staticExpects($this->any())->method('getUniqueEntityBehaviors')->will($this->returnValue($this->_sourceBehaviors)); $arguments = array('coreHelper' => $coreHelper, 'importModel' => $importModel, 'urlBuilder' => $this->getMock('Mage_Backend_Model_Url', array(), array(), '', false)); $objectManagerHelper = new Magento_Test_Helper_ObjectManager($this); $this->_model = $objectManagerHelper->getBlock('Mage_ImportExport_Block_Adminhtml_Import_Edit_Before', $arguments); }
protected function setUp() { $this->_appMock = $this->getMock('Mage_Core_Model_App', array(), array(), '', false); $this->_localeMock = $this->getMock('Mage_Core_Model_Locale', array(), array(), '', false); $this->_curLocatorMock = $this->getMock('Mage_Directory_Model_Currency_DefaultLocator', array(), array(), '', false); $this->_columnMock = $this->getMock('Mage_Backend_Block_Widget_Grid_Column', array('getIndex'), array(), '', false); $this->_columnMock->expects($this->any())->method('getIndex')->will($this->returnValue('columnIndex')); $this->_row = new Varien_Object(array('columnIndex' => '10')); $objectManagerHelper = new Magento_Test_Helper_ObjectManager($this); $this->_blockCurrency = $objectManagerHelper->getBlock('Mage_Backend_Block_Widget_Grid_Column_Renderer_Currency', array('locale' => $this->_localeMock, 'app' => $this->_appMock, 'currencyLocator' => $this->_curLocatorMock, 'urlBuilder' => $this->getMock('Mage_Backend_Model_Url', array(), array(), '', false))); $this->_blockCurrency->setColumn($this->_columnMock); }
/** * @covers Mage_Tag_Block_Catalog_Product_Rss_Link::getLinkUrl * @dataProvider getUrlTestDataProvider * * @param bool $rssEnabled * @param int $tagId * @param int $existTagId * @param string|bool $expected */ public function testGetLinkUrl($rssEnabled, $tagId, $existTagId, $expected) { $tagModelMock = $this->getMock('Mage_Tag_Model_Tag', array('getId', 'getName', 'load'), array(), '', false); $tagModelMock->expects($this->any())->method('getId')->will($this->returnValue($existTagId)); $tagModelMock->expects($this->any())->method('getName')->will($this->returnValue('test')); $urlModelMock = $this->getMock('Mage_Core_Model_Url', array('getUrl'), array(), '', false); $urlModelMock->expects($this->any())->method('getUrl')->will($this->returnCallback(array($this, 'validateGetUrlCallback'))); $data = array('rss_catalog_tag_enabled' => $rssEnabled, 'tag_id' => $tagId, 'tag_model' => $tagModelMock, 'core_url_model' => $urlModelMock); $objectManagerHelper = new Magento_Test_Helper_ObjectManager($this); $this->_model = $objectManagerHelper->getBlock('Mage_Tag_Block_Catalog_Product_Rss_Link', array('data' => $data)); $this->assertSame($expected, $this->_model->getLinkUrl()); }
protected function setUp() { $this->_systemConfigMock = $this->getMock('Mage_Backend_Model_Config_Structure', array(), array(), '', false, false); $this->_requestMock = $this->getMock('Mage_Core_Controller_Request_Http', array(), array(), '', false, false); $this->_requestMock->expects($this->any())->method('getParam')->with('section')->will($this->returnValue('test_section')); $this->_layoutMock = $this->getMock('Mage_Core_Model_Layout', array(), array(), '', false, false); $this->_urlModelMock = $this->getMock('Mage_Backend_Model_Url', array(), array(), '', false, false); $this->_sectionMock = $this->getMock('Mage_Backend_Model_Config_Structure_Element_Section', array(), array(), '', false); $this->_systemConfigMock->expects($this->any())->method('getElement')->with('test_section')->will($this->returnValue($this->_sectionMock)); $data = array('data' => array('systemConfig' => $this->_systemConfigMock), 'request' => $this->_requestMock, 'layout' => $this->_layoutMock, 'urlBuilder' => $this->_urlModelMock, 'configStructure' => $this->_systemConfigMock); $helper = new Magento_Test_Helper_ObjectManager($this); $this->_object = $helper->getBlock('Mage_Backend_Block_System_Config_Edit', $data); }
/** * @covers Mage_DesignEditor_Block_Adminhtml_Editor_Container::_prepareLayout */ public function testPrepareLayout() { $buttonTitle = 'Back'; $eventManager = $this->getMock('Mage_Core_Model_Event_Manager', array('dispatch')); $arguments = $this->_getBlockArguments(array('expectedTranslation' => $buttonTitle)); $arguments['eventManager'] = $eventManager; /** @var $block Mage_DesignEditor_Block_Adminhtml_Editor_Container */ $block = $this->_helper->getBlock('Mage_DesignEditor_Block_Adminhtml_Editor_Container', $arguments); $layout = $this->getMock('Mage_Core_Model_Layout', array(), array(), '', false); $block->setLayout($layout); $expectedButtonData = array('back_button' => array('label' => $buttonTitle, 'onclick' => 'setLocation(\'\')', 'class' => 'back', 'id' => 'back_button', 'region' => 'header', 'sort_order' => 10)); $this->assertAttributeContains($expectedButtonData, '_buttons', $block); }
protected function setUp() { $this->_appModelMock = $this->getMock('Mage_Core_Model_App', array(), array(), '', false, false); $this->_layoutMock = $this->getMock('Mage_Core_Model_Layout', array(), array(), '', false, false); $data = array('layout' => $this->_layoutMock, 'application' => $this->_appModelMock, 'urlBuilder' => $this->getMock('Mage_Backend_Model_Url', array(), array(), '', false)); $helper = new Magento_Test_Helper_ObjectManager($this); $this->_object = $helper->getBlock('Mage_Backend_Block_System_Config_Form_Field', $data); $this->_testData = array('htmlId' => 'test_field_id', 'name' => 'test_name', 'label' => 'test_label', 'elementHTML' => 'test_html'); $this->_elementMock = $this->getMock('Varien_Data_Form_Element_Text', array('getHtmlId', 'getName', 'getLabel', 'getElementHtml', 'getComment', 'getHint', 'getScope', 'getScopeLabel', 'getInherit', 'getCanUseWebsiteValue', 'getCanUseDefaultValue', 'setDisabled'), array(), '', false, false, true); $this->_elementMock->expects($this->any())->method('getHtmlId')->will($this->returnValue($this->_testData['htmlId'])); $this->_elementMock->expects($this->any())->method('getName')->will($this->returnValue($this->_testData['name'])); $this->_elementMock->expects($this->any())->method('getLabel')->will($this->returnValue($this->_testData['label'])); $this->_elementMock->expects($this->any())->method('getElementHtml')->will($this->returnValue($this->_testData['elementHTML'])); }
public function testSetInfoTemplate() { $block = $this->getMock('Mage_Payment_Block_Info_ContainerAbstract', array('getChildBlock', 'getPaymentInfo'), array(), '', false); $objectManagerHelper = new Magento_Test_Helper_ObjectManager($this); $paymentInfo = $objectManagerHelper->getModel('Mage_Payment_Model_Info'); $methodInstance = $objectManagerHelper->getModel('Mage_Payment_Model_Method_Checkmo'); $paymentInfo->setMethodInstance($methodInstance); $block->expects($this->atLeastOnce())->method('getPaymentInfo')->will($this->returnValue($paymentInfo)); $childBlock = $objectManagerHelper->getBlock('Mage_Core_Block_Template'); $block->expects($this->atLeastOnce())->method('getChildBlock')->with('payment.info.checkmo')->will($this->returnValue($childBlock)); $template = 'any_template.phtml'; $this->assertNotEquals($template, $childBlock->getTemplate()); $block->setInfoTemplate('checkmo', $template); $this->assertEquals($template, $childBlock->getTemplate()); }
protected function setUp() { $this->_gridMock = $this->getMock('Mage_Backend_Block_Widget_Grid', array('getId'), array(), '', false); $this->_gridMock->expects($this->any())->method('getId')->will($this->returnValue('test_grid')); $this->_layoutMock = $this->getMock('Mage_Core_Model_Layout', array('getParentName', 'getBlock', 'helper'), array(), '', false, false); $this->_backendHelperMock = $this->getMock('Mage_Backend_Helper_Data', array(), array(), '', false); $this->_layoutMock->expects($this->any())->method('helper')->will($this->returnValue($this->_backendHelperMock)); $this->_layoutMock->expects($this->any())->method('getParentName')->with('test_grid_massaction')->will($this->returnValue('test_grid')); $this->_layoutMock->expects($this->any())->method('getBlock')->with('test_grid')->will($this->returnValue($this->_gridMock)); $this->_requestMock = $this->getMock('Mage_Core_Controller_Request_Http', array('getParam'), array(), '', false); $arguments = array('layout' => $this->_layoutMock, 'request' => $this->_requestMock, 'urlBuilder' => $this->getMock('Mage_Backend_Model_Url', array(), array(), '', false), 'data' => array('massaction_id_field' => 'test_id', 'massaction_id_filter' => 'test_id')); $objectManagerHelper = new Magento_Test_Helper_ObjectManager($this); $this->_block = $objectManagerHelper->getBlock('Mage_Backend_Block_Widget_Grid_Massaction', $arguments); $this->_block->setNameInLayout('test_grid_massaction'); }
protected function setUp() { $this->_requestMock = $this->getMock('Mage_Core_Controller_Request_Http', array(), array(), '', false, false); $this->_urlModelMock = $this->getMock('Mage_Backend_Model_Url', array(), array(), '', false, false); $this->_layoutMock = $this->getMock('Mage_Core_Model_Layout', array(), array(), '', false, false); $data = array('request' => $this->_requestMock, 'urlBuilder' => $this->_urlModelMock, 'layout' => $this->_layoutMock, 'data' => array('group' => array('fieldset_css' => 'test_fieldset_css'))); $helper = new Magento_Test_Helper_ObjectManager($this); $this->_object = $helper->getBlock('Mage_Backend_Block_System_Config_Form_Fieldset', $data); $this->_testData = array('htmlId' => 'test_field_id', 'name' => 'test_name', 'label' => 'test_label', 'elementHTML' => 'test_html', 'legend' => 'test_legend', 'comment' => 'test_comment'); $this->_elementMock = $this->getMock('Varien_Data_Form_Element_Text', array('getHtmlId', 'getName', 'getExpanded', 'getSortedElements', 'getLegend', 'getComment'), array(), '', false, false, true); $this->_elementMock->expects($this->any())->method('getHtmlId')->will($this->returnValue($this->_testData['htmlId'])); $this->_elementMock->expects($this->any())->method('getName')->will($this->returnValue($this->_testData['name'])); $this->_elementMock->expects($this->any())->method('getExpanded')->will($this->returnValue(true)); $this->_elementMock->expects($this->any())->method('getLegend')->will($this->returnValue($this->_testData['legend'])); $this->_elementMock->expects($this->any())->method('getComment')->will($this->returnValue($this->_testData['comment'])); }
/** * Prepare mock for testCanShowTab * * @param boolean $isCustomer * @param boolean $isCustomerExist * @param boolean $isAllowed */ protected function _getMockForCanShowTab($isCustomer, $isCustomerExist, $isAllowed) { $customer = false; if ($isCustomer) { $customer = $this->getMock('Mage_Customer_Model_Customer', array('getId'), array(), '', false); $customer->expects($this->any())->method('getId')->will($this->returnValue($isCustomerExist)); } $authSession = $this->getMock('Mage_Core_Model_Authorization', array('isAllowed'), array(), '', false); $authSession->expects($this->any())->method('isAllowed')->will($this->returnValue($isAllowed)); $arguments = array('authSession' => $authSession, 'urlBuilder' => $this->getMock('Mage_Backend_Model_Url', array(), array(), '', false), 'data' => array('helpers' => $this->_helpers)); $objectManagerHelper = new Magento_Test_Helper_ObjectManager($this); $this->_model = $objectManagerHelper->getBlock('Mage_Tag_Block_Adminhtml_Customer_Edit_Tab_Tag', $arguments); if ($customer) { $this->_model->setCustomer($customer); } }
protected function setUp() { $this->_requestMock = $this->getMock('Mage_Core_Controller_Request_Http', array(), array(), '', false); $this->_requestMock->expects($this->any())->method('getParam')->with('section')->will($this->returnValue('currentSectionId')); $this->_structureMock = $this->getMock('Mage_Backend_Model_Config_Structure', array(), array(), '', false); $this->_structureMock->expects($this->once())->method('getTabs')->will($this->returnValue(array())); $this->_urlBuilderMock = $this->getMock('Mage_Backend_Model_Url', array(), array(), '', false); $layoutMock = $this->getMock('Mage_Core_Model_Layout', array(), array(), '', false); $helperMock = $this->getMock('Mage_Core_Helper_Data', array('__', 'addPageHelpUrl'), array(), '', false); $helperMock->expects($this->any())->method('__')->will($this->returnArgument(0)); $helperMock->expects($this->once())->method('addPageHelpUrl')->with('currentSectionId/'); $layoutMock->expects($this->any())->method('helper')->will($this->returnValue($helperMock)); $data = array('configStructure' => $this->_structureMock, 'request' => $this->_requestMock, 'urlBuilder' => $this->_urlBuilderMock, 'layout' => $layoutMock); $helper = new Magento_Test_Helper_ObjectManager($this); $this->_object = $helper->getBlock('Mage_Backend_Block_System_Config_Tabs', $data); }
/** * @covers Mage_Page_Block_Html_Header::getLogoSrc */ public function testGetLogoSrc() { $storeConfig = $this->getMock('Mage_Core_Model_Store_Config', array('getConfig')); $storeConfig->expects($this->once())->method('getConfig')->will($this->returnValue('default/image.gif')); $urlBuilder = $this->getMock('Mage_Core_Model_Url', array('getBaseUrl')); $urlBuilder->expects($this->once())->method('getBaseUrl')->will($this->returnValue('http://localhost/pub/media/')); $configOptions = $this->getMock('Mage_Core_Model_Config_Options', array('getDir')); $configOptions->expects($this->once())->method('getDir')->will($this->returnValue(__DIR__ . DIRECTORY_SEPARATOR . '_files')); $helper = $this->getMockBuilder('Mage_Core_Helper_File_Storage_Database')->setMethods(array('checkDbUsage'))->disableOriginalConstructor()->getMock(); $helper->expects($this->once())->method('checkDbUsage')->will($this->returnValue(false)); $helperFactory = $this->getMock('Mage_Core_Model_Factory_Helper', array('get')); $helperFactory->expects($this->once())->method('get')->will($this->returnValue($helper)); $objectManager = new Magento_Test_Helper_ObjectManager($this); $arguments = array('storeConfig' => $storeConfig, 'urlBuilder' => $urlBuilder, 'configOptions' => $configOptions, 'helperFactory' => $helperFactory); $this->_block = $objectManager->getBlock('Mage_Page_Block_Html_Header', $arguments); $this->assertEquals('http://localhost/pub/media/logo/default/image.gif', $this->_block->getLogoSrc()); }
protected function setUp() { $objectManagerHelper = new Magento_Test_Helper_ObjectManager($this); $helperData = $this->getMock('Mage_Core_Helper_Data', array('escapeHtml'), array(), '', false); $helperData->expects($this->any())->method('escapeHtml')->will($this->returnArgument(0)); $layoutMerge = $this->getMock('Mage_Core_Model_Layout_Merge', array('getPageHandleLabel'), array(), '', false); $layoutMerge->expects($this->any())->method('getPageHandleLabel')->with($this::HANDLE_NAME)->will($this->returnValue($this::HANDLE_LABEL)); $layout = $this->getMock('Mage_Core_Model_Layout', array('helper', 'getUpdate'), array(), '', false); $layout->expects($this->any())->method('helper')->with('Mage_Core_Helper_Data')->will($this->returnValue($helperData)); $layout->expects($this->any())->method('getUpdate')->will($this->returnValue($layoutMerge)); $vdeUrlBuilder = $this->getMock('Mage_DesignEditor_Model_Url_Handle', array('getUrl'), array(), '', false); $vdeUrlBuilder->expects($this->any())->method('getUrl')->will($this->returnCallback(function ($url, $parameter) { $key = key($parameter); return $url . '/' . $key . '/' . $parameter[$key]; })); $data = array('urlBuilder' => $this->getMock('Mage_Backend_Model_Url', array(), array(), '', false), 'layout' => $layout, 'vdeUrlBuilder' => $vdeUrlBuilder); $this->_model = $objectManagerHelper->getBlock($this->_modelName, $data); }
protected function setUp() { $this->_systemConfigMock = $this->getMock('Mage_Backend_Model_Config_Structure', array(), array(), '', false, false); $requestMock = $this->getMock('Mage_Core_Controller_Request_Http', array(), array(), '', false, false); $requestParams = array(array('website', '', 'website_code'), array('section', '', 'section_code'), array('store', '', 'store_code')); $requestMock->expects($this->any())->method('getParam')->will($this->returnValueMap($requestParams)); $helperMock = $this->getMock('Mage_Backend_Helper_Data', array(), array(), '', false, false); $layoutMock = $this->getMock('Mage_Core_Model_Layout', array(), array(), '', false, false); $layoutMock->expects($this->any())->method('helper')->will($this->returnValue($helperMock)); $helperMock->expects($this->any())->method('__')->will($this->returnArgument(0)); $this->_urlModelMock = $this->getMock('Mage_Backend_Model_Url', array(), array(), '', false, false); $configFactoryMock = $this->getMock('Mage_Backend_Model_Config_Factory', array(), array(), '', false, false); $this->_formFactoryMock = $this->getMock('Varien_Data_Form_Factory', array(), array(), '', false, false); $cloneFactoryMock = $this->getMock('Mage_Backend_Model_Config_Clone_Factory', array(), array(), '', false, false); $this->_fieldsetFactoryMock = $this->getMock('Mage_Backend_Block_System_Config_Form_Fieldset_Factory', array(), array(), '', false, false); $this->_fieldFactoryMock = $this->getMock('Mage_Backend_Block_System_Config_Form_Field_Factory', array(), array(), '', false, false); $this->_coreConfigMock = $this->getMock('Mage_Core_Model_Config', array(), array(), '', false, false); $this->_backendConfigMock = $this->getMock('Mage_Backend_Model_Config', array(), array(), '', false, false); $configFactoryMock->expects($this->once())->method('create')->with(array('section' => 'section_code', 'website' => 'website_code', 'store' => 'store_code'))->will($this->returnValue($this->_backendConfigMock)); $this->_backendConfigMock->expects($this->once())->method('load')->will($this->returnValue(array('section1/group1/field1' => 'some_value'))); $this->_formMock = $this->getMock('Varien_Data_Form', array('setParent', 'setBaseUrl', 'addFieldset'), array(), '', false, false); $data = array('request' => $requestMock, 'layout' => $layoutMock, 'urlBuilder' => $this->_urlModelMock, 'configStructure' => $this->_systemConfigMock, 'configFactory' => $configFactoryMock, 'formFactory' => $this->_formFactoryMock, 'cloneModelFactory' => $cloneFactoryMock, 'fieldsetFactory' => $this->_fieldsetFactoryMock, 'fieldFactory' => $this->_fieldFactoryMock, 'coreConfig' => $this->_coreConfigMock); $helper = new Magento_Test_Helper_ObjectManager($this); $this->_object = $helper->getBlock('Mage_Backend_Block_System_Config_Form', $data); $this->_object->setData('scope_id', 1); }
protected function setUp() { $this->_ruleResource = $this->getMockBuilder('Mage_Webapi_Model_Resource_Acl_Rule')->disableOriginalConstructor()->setMethods(array('getResourceIdsByRole'))->getMock(); $helper = new Magento_Test_Helper_ObjectManager($this); $this->_block = $helper->getBlock('Mage_Webapi_Block_Adminhtml_Role_Edit_Tab_Resource', array('urlBuilder' => $this->getMockBuilder('Mage_Backend_Model_Url')->disableOriginalConstructor()->getMock(), 'authorizationConfig' => $this->getMockBuilder('Mage_Webapi_Model_Authorization_Config')->disableOriginalConstructor()->getMock(), 'ruleResource' => $this->_ruleResource)); }