示例#1
0
 protected function setUp()
 {
     $helper = new Magento_Test_Helper_ObjectManager($this);
     $this->_objectManager = $this->getMockBuilder('Magento_ObjectManager')->disableOriginalConstructor()->setMethods(array('create'))->getMockForAbstractClass();
     $this->_expectedObject = $this->getMockBuilder('Mage_Webapi_Model_Acl_User')->disableOriginalConstructor()->getMock();
     $this->_model = $helper->getModel('Mage_Webapi_Model_Acl_User_Factory', array('objectManager' => $this->_objectManager));
 }
示例#2
0
 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);
 }
示例#3
0
 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);
 }
示例#4
0
 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());
 }
示例#5
0
 protected function setUp()
 {
     $helper = new Magento_Test_Helper_ObjectManager($this);
     $this->_objectManager = $this->getMockForAbstractClass('Magento_ObjectManager', array(), '', true, true, true, array('create'));
     $this->_expectedObject = $this->getMock('Mage_Webapi_Model_Authorization_Role', array(), array(), '', false);
     $this->_model = $helper->getModel('Mage_Webapi_Model_Authorization_Role_Factory', array('objectManager' => $this->_objectManager));
 }
示例#6
0
 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);
 }
示例#7
0
 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);
 }
示例#8
0
 /**
  * @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
 }
示例#9
0
 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);
 }
示例#10
0
 /**
  * Set up before test
  */
 protected function setUp()
 {
     $helper = new Magento_Test_Helper_ObjectManager($this);
     $this->_ruleResource = $this->getMock('Mage_Webapi_Model_Resource_Acl_Rule', array('getRuleList'), array(), '', false);
     $this->_acl = $this->getMock('Magento_Acl', array('has', 'hasRole', 'allow'), array(), '', false);
     $this->_model = $helper->getModel('Mage_Webapi_Model_Authorization_Loader_Rule', array('ruleResource' => $this->_ruleResource));
 }
示例#11
0
 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));
 }
示例#12
0
 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));
 }
示例#13
0
 /**
  * Set up before test
  */
 protected function setUp()
 {
     $helper = new Magento_Test_Helper_ObjectManager($this);
     $this->_resourceModelMock = $this->getMock('Mage_Webapi_Model_Resource_Acl_Role', array('getRolesIds'), array(), '', false);
     $this->_roleFactory = $this->getMock('Mage_Webapi_Model_Authorization_Role_Factory', array('createRole'), array(), '', false);
     $this->_acl = $this->getMock('Magento_Acl', array('addRole', 'deny'), array(), '', false);
     $this->_model = $helper->getModel('Mage_Webapi_Model_Authorization_Loader_Role', array('roleResource' => $this->_resourceModelMock, 'roleFactory' => $this->_roleFactory));
 }
示例#14
0
 protected function setUp()
 {
     $resource = $this->getMock('Mage_Eav_Model_Resource_Entity_Attribute_Set', array(), array(), '', false);
     $helper = $this->getMock('Mage_Eav_Helper_Data', array('__'));
     $helper->expects($this->any())->method('__')->will($this->returnArgument(0));
     $arguments = array('resource' => $resource, 'data' => array('helper' => $helper));
     $objectManagerHelper = new Magento_Test_Helper_ObjectManager($this);
     $this->_model = $objectManagerHelper->getModel('Mage_Eav_Model_Entity_Attribute_Set', $arguments);
 }
示例#15
0
 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);
 }
示例#16
0
 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);
 }
示例#17
0
 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);
 }
示例#18
0
 /**
  * Set up before test
  */
 protected function setUp()
 {
     $helper = new Magento_Test_Helper_ObjectManager($this);
     $this->_config = $this->getMockBuilder('Mage_Core_Model_Config')->disableOriginalConstructor()->setMethods(array('getModuleConfigurationFiles'))->getMock();
     $this->_readerFactory = $this->getMockBuilder('Mage_Webapi_Model_Authorization_Config_Reader_Factory')->disableOriginalConstructor()->setMethods(array('createReader'))->getMock();
     $this->_configReader = $this->getMockBuilder('Magento_Acl_Config_Reader')->disableOriginalConstructor()->setMethods(array('getAclResources'))->getMock();
     $this->_model = $helper->getModel('Mage_Webapi_Model_Authorization_Config', array('config' => $this->_config, 'readerFactory' => $this->_readerFactory));
     $this->_config->expects($this->any())->method('getModuleConfigurationFiles')->will($this->returnValue(array()));
     $this->_readerFactory->expects($this->any())->method('createReader')->will($this->returnValue($this->_configReader));
 }
示例#19
0
 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);
 }
示例#20
0
 /**
  * Return Mock of Theme Model loaded from configuration
  *
  * @param string $designDir
  * @param string $targetPath
  * @return mixed
  */
 protected function _getThemeModel($designDir, $targetPath)
 {
     Mage::getConfig()->getOptions()->setData('design_dir', $designDir);
     $objectManagerHelper = new Magento_Test_Helper_ObjectManager($this);
     /** @var $themeMock Mage_Core_Model_Theme */
     $arguments = $objectManagerHelper->getConstructArguments(Magento_Test_Helper_ObjectManager::MODEL_ENTITY);
     $themeMock = $this->getMock('Mage_Core_Model_Theme', array('_init'), $arguments, '', true);
     /** @var $collectionMock Mage_Core_Model_Theme_Collection|PHPUnit_Framework_MockObject_MockObject */
     $collectionMock = $this->getMock('Mage_Core_Model_Theme_Collection', array('getNewEmptyItem'));
     $collectionMock->expects($this->any())->method('getNewEmptyItem')->will($this->returnValue($themeMock));
     return $collectionMock->setBaseDir($designDir)->addTargetPattern($targetPath)->getFirstItem();
 }
示例#21
0
 /**
  * @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());
 }
示例#22
0
 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);
 }
示例#23
0
 /**
  * Set up before test
  */
 protected function setUp()
 {
     $this->_helper = new Magento_Test_Helper_ObjectManager($this);
     $resource = new Magento_Acl_Resource('test resource');
     /** @var $resourceFactory Magento_Acl_ResourceFactory */
     $resourceFactory = $this->getMock('Magento_Acl_ResourceFactory', array('createResource'), array(), '', false);
     $resourceFactory->expects($this->any())->method('createResource')->will($this->returnValue($resource));
     $this->_config = $this->getMock('Mage_Webapi_Model_Authorization_Config', array('getAclResources', 'getAclVirtualResources'), array(), '', false);
     $this->_config->expects($this->once())->method('getAclResources')->will($this->returnValue($this->getResourceXPath()->query('/config/acl/resources/*')));
     $this->_model = $this->_helper->getModel('Mage_Webapi_Model_Authorization_Loader_Resource', array('resourceFactory' => $resourceFactory, 'configuration' => $this->_config));
     $this->_acl = $this->getMock('Magento_Acl', array('has', 'addResource', 'deny', 'getResources'), array(), '', false);
 }
示例#24
0
 /**
  * @dataProvider updateDataProvider
  * @param int $roleId
  * @param array $filters
  * @param bool $isAjax
  * @param mixed $param
  */
 public function testUpdate($roleId, $filters, $isAjax, $param)
 {
     $this->_request->expects($this->any())->method('getParam')->will($this->returnValueMap(array(array('role_id', null, $roleId), array('filter', '', $filters))));
     $this->_request->expects($this->any())->method('isAjax')->will($this->returnValue($isAjax));
     if ($param) {
         $this->_collection->expects($this->once())->method('addFieldToFilter')->with('role_id', $param);
     } else {
         $this->_collection->expects($this->never())->method('addFieldToFilter');
     }
     /** @var Mage_Webapi_Model_Acl_Role_UsersUpdater $model */
     $model = $this->_helper->getModel('Mage_Webapi_Model_Acl_Role_UsersUpdater', array('request' => $this->_request, 'backendHelper' => $this->_backendHelper));
     $this->assertEquals($this->_collection, $model->update($this->_collection));
 }
示例#25
0
 protected function setUp()
 {
     $objectManager = new Magento_Test_Helper_ObjectManager($this);
     $modelConstructorArgs = $objectManager->getConstructArguments(Magento_Test_Helper_ObjectManager::MODEL_ENTITY, 'Mage_Sales_Model_Order');
     $this->_order = $this->getMock('Mage_Sales_Model_Order', array('formatPriceTxt'), $modelConstructorArgs);
     $this->_order->expects($this->any())->method('formatPriceTxt')->will($this->returnCallback(array($this, 'formatPrice')));
     $this->_pdf = $this->getMock('Mage_Sales_Model_Order_Pdf_Abstract', array('drawLineBlocks', 'getPdf'));
     $this->_model = $this->getMock('Mage_Downloadable_Model_Sales_Order_Pdf_Items_Creditmemo', array('getLinks', 'getLinksTitle'), $modelConstructorArgs);
     $this->_model->setStringHelper(new Mage_Core_Helper_String());
     $this->_model->setOrder($this->_order);
     $this->_model->setPdf($this->_pdf);
     $this->_model->setPage(new Zend_Pdf_Page('a4'));
 }
示例#26
0
 public function testUpdate()
 {
     $roleId = 5;
     $expectedValues = array(7, 8, 9);
     $helper = new Magento_Test_Helper_ObjectManager($this);
     $request = $this->getMockBuilder('Mage_Core_Controller_Request_Http')->disableOriginalConstructor()->getMock();
     $request->expects($this->any())->method('getParam')->will($this->returnValueMap(array(array('role_id', null, $roleId))));
     $userResource = $this->getMockBuilder('Mage_Webapi_Model_Resource_Acl_User')->disableOriginalConstructor()->getMock();
     $userResource->expects($this->once())->method('getRoleUsers')->with($roleId)->will($this->returnValue($expectedValues));
     /** @var Mage_Webapi_Model_Acl_Role_InRoleUserUpdater $model */
     $model = $helper->getModel('Mage_Webapi_Model_Acl_Role_InRoleUserUpdater', array('request' => $request, 'userResource' => $userResource));
     $this->assertEquals($expectedValues, $model->update(array()));
 }
示例#27
0
 protected function setUp()
 {
     $helper = $this->getMock('Mage_Core_Helper_String', array('__'));
     $helper->expects($this->any())->method('__')->will($this->returnArgument(0));
     $attributeData = array('store_label' => 'Test', 'attribute_code' => 'test', 'is_required' => 1, 'validate_rules' => array('min_text_length' => 0, 'max_text_length' => 0, 'input_validation' => 0));
     $attributeClass = 'Mage_Eav_Model_Entity_Attribute_Abstract';
     $objectManagerHelper = new Magento_Test_Helper_ObjectManager($this);
     $arguments = $objectManagerHelper->getConstructArguments(Magento_Test_Helper_ObjectManager::MODEL_ENTITY, $attributeClass, array('data' => $attributeData));
     /** @var $attribute Mage_Eav_Model_Entity_Attribute_Abstract|PHPUnit_Framework_MockObject_MockObject */
     $attribute = $this->getMock($attributeClass, array('_init'), $arguments);
     $this->_model = new Mage_Eav_Model_Attribute_Data_Text(array('translationHelper' => $helper, 'stringHelper' => $helper));
     $this->_model->setAttribute($attribute);
 }
示例#28
0
 /**
  * Retrieve new invoice collection from an array of invoices' data
  *
  * @param array $invoicesData
  * @return Varien_Data_Collection
  */
 protected function _getInvoiceCollection(array $invoicesData)
 {
     $className = 'Mage_Sales_Model_Order_Invoice';
     $result = new Varien_Data_Collection();
     $objectManagerHelper = new Magento_Test_Helper_ObjectManager($this);
     foreach ($invoicesData as $oneInvoiceData) {
         $arguments = $objectManagerHelper->getConstructArguments(Magento_Test_Helper_ObjectManager::MODEL_ENTITY, $className, array('data' => $oneInvoiceData));
         /** @var $prevInvoice Mage_Sales_Model_Order_Invoice */
         $prevInvoice = $this->getMock($className, array('_init'), $arguments);
         $result->addItem($prevInvoice);
     }
     return $result;
 }
示例#29
0
 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);
 }
示例#30
0
 public function testBeforeSave()
 {
     $resourceModel = $this->getMock('Mage_Core_Model_Resource_Layout_Update', array('formatDate', 'getIdFieldName', 'beginTransaction', 'save', 'addCommitCallback', 'commit'), array(), '', false);
     $resourceModel->expects($this->once())->method('formatDate')->with($this->isType('int'))->will($this->returnValue(self::TEST_FORMATTED_TIME));
     $resourceModel->expects($this->once())->method('addCommitCallback')->will($this->returnSelf());
     $helper = new Magento_Test_Helper_ObjectManager($this);
     /** @var $model Mage_Core_Model_Layout_Update */
     $model = $helper->getModel('Mage_Core_Model_Layout_Update', array('resource' => $resourceModel));
     $model->setId(0);
     // set any data to set _hasDataChanges flag
     $model->save();
     $this->assertEquals(self::TEST_FORMATTED_TIME, $model->getUpdatedAt());
 }