示例#1
0
 /**
  * @param string $methodClass
  * @param string $code
  * @dataProvider paymentMethodDataProvider
  * @throws Exception on various assertion failures
  */
 public function testPaymentMethod($code, $methodClass)
 {
     /** @var $blockFactory Mage_Core_Model_BlockFactory */
     $blockFactory = Mage::getObjectManager()->get('Mage_Core_Model_BlockFactory');
     $storeId = Mage::app()->getStore()->getId();
     /** @var $model Mage_Payment_Model_Method_Abstract */
     if (empty($methodClass)) {
         /**
          * Note that $code is not whatever the payment method getCode() returns
          */
         $this->fail("Model of '{$code}' payment method is not found.");
         // prevent fatal error
     }
     $model = new $methodClass();
     $this->assertNotEmpty($model->getTitle());
     foreach (array($model->getFormBlockType(), $model->getInfoBlockType()) as $blockClass) {
         $message = "Block class: {$blockClass}";
         /** @var $block Mage_Core_Block_Template */
         $block = $blockFactory->createBlock($blockClass);
         $block->setArea('frontend');
         $this->assertFileExists($block->getTemplateFile(), $message);
         if ($model->canUseInternal()) {
             try {
                 Mage::app()->getStore()->setId(Mage_Core_Model_App::ADMIN_STORE_ID);
                 $block->setArea('adminhtml');
                 $this->assertFileExists($block->getTemplateFile(), $message);
                 Mage::app()->getStore()->setId($storeId);
             } catch (Exception $e) {
                 Mage::app()->getStore()->setId($storeId);
                 throw $e;
             }
         }
     }
 }
示例#2
0
 public static function setUpBeforeClass()
 {
     self::$_objectManager = Mage::getObjectManager();
     // get list of not existing tables
     /** @var $application Mage_Core_Model_App */
     $application = self::$_objectManager->get('Mage_Core_Model_App');
     /** @var $categoryResource Mage_Catalog_Model_Resource_Category_Flat */
     $categoryResource = self::$_objectManager->create('Mage_Catalog_Model_Resource_Category_Flat');
     /** @var $setupModel Mage_Core_Model_Resource_Setup */
     $setupModel = self::$_objectManager->create('Mage_Core_Model_Resource_Setup', array('resourceName' => Mage_Core_Model_Resource_Setup::DEFAULT_SETUP_CONNECTION));
     $stores = $application->getStores();
     /** @var $store Mage_Core_Model_Store */
     foreach ($stores as $store) {
         $tableName = $categoryResource->getMainStoreTable($store->getId());
         if (!$setupModel->getConnection()->isTableExists($tableName)) {
             self::$_indexerTables[] = $tableName;
         }
     }
     // create flat tables
     /** @var $indexer Mage_Catalog_Model_Category_Indexer_Flat */
     $indexer = self::$_objectManager->create('Mage_Catalog_Model_Category_Indexer_Flat');
     $indexer->reindexAll();
     // set real time indexer mode
     $process = self::_getCategoryIndexerProcess();
     self::$_indexerMode = $process->getMode();
     $process->setMode(Mage_Index_Model_Process::MODE_REAL_TIME);
     $process->save();
 }
示例#3
0
 protected function setUp()
 {
     $this->_helper = Mage::helper('Mage_Catalog_Helper_Product_View');
     $request = new Magento_Test_Request();
     $request->setRouteName('catalog')->setControllerName('product')->setActionName('view');
     $this->_controller = Mage::getModel('Mage_Catalog_ProductController', array($request, new Magento_Test_Response(), 'frontend', Mage::getObjectManager(), Mage::getObjectManager()->get('Mage_Core_Controller_Varien_Front'), Mage::getObjectManager()->get('Mage_Core_Model_Layout_Factory')));
 }
示例#4
0
 protected function tearDown()
 {
     $filesystem = Mage::getObjectManager()->create('Magento_Filesystem');
     $filesystem->delete(self::$_fixtureTmpDir);
     $filesystem->delete(self::$_themePublicDir . '/adminhtml');
     $filesystem->delete(self::$_themePublicDir . '/frontend');
 }
示例#5
0
 public function testGetUrl()
 {
     $action = Mage::getModel('Mage_Core_Controller_Front_Action', array(new Magento_Test_Request(), new Magento_Test_Response(), 'frontend', Mage::getObjectManager(), Mage::getObjectManager()->get('Mage_Core_Controller_Varien_Front'), Mage::getObjectManager()->get('Mage_Core_Model_Layout_Factory')));
     Mage::app()->getFrontController()->setAction($action);
     // done in action's constructor
     $this->assertStringEndsWith('/?cat%5B0%5D=valuePart1&cat%5B1%5D=valuePart2', $this->_model->getUrl());
 }
示例#6
0
 protected function setUp()
 {
     $this->_objectManager = Mage::getObjectManager();
     $this->_layout = $this->_objectManager->get('Mage_Core_Model_Layout');
     $this->_blockFactory = $this->_objectManager->get('Mage_Core_Model_BlockFactory');
     $this->_block = $this->_blockFactory->createBlock('Mage_Webapi_Block_Adminhtml_User_Edit_Tab_Main');
     $this->_layout->addBlock($this->_block);
 }
示例#7
0
 protected function setUp()
 {
     $this->_block = Mage::getObjectManager()->create('Mage_Catalog_Block_Product_View');
     $this->_product = Mage::getModel('Mage_Catalog_Model_Product');
     $this->_product->load(1);
     Mage::unregister('product');
     Mage::register('product', $this->_product);
 }
示例#8
0
 /**
  * @magentoDataFixture Mage/Catalog/_files/multiple_products.php
  */
 public function testGetListUrl()
 {
     /** @var $empty Mage_Catalog_Helper_Product_Compare */
     $empty = Mage::getObjectManager()->create('Mage_Catalog_Helper_Product_Compare');
     $this->assertContains('/catalog/product_compare/index/', $empty->getListUrl());
     $this->_populateCompareList();
     $this->assertRegExp('#/catalog/product_compare/index/items/(?:10,11|11,10)/#', $this->_helper->getListUrl());
 }
示例#9
0
 /**
  * @dataProvider getMoneybookersLogoSrcDataProvider
  */
 public function testGetMoneybookersLogoSrc($localeCode, $expectedFile)
 {
     Mage::app()->getLocale()->setLocale($localeCode);
     /** @var $blockFactory Mage_Core_Model_BlockFactory */
     $blockFactory = Mage::getObjectManager()->get('Mage_Core_Model_BlockFactory');
     $block = $blockFactory->createBlock('Phoenix_Moneybookers_Block_Payment');
     $this->assertStringEndsWith($expectedFile, $block->getMoneybookersLogoSrc());
 }
示例#10
0
 protected function setUp()
 {
     $resourceModel = Mage::getObjectManager()->get('Mage_Core_Model_Resource');
     $resource = $this->getMockForAbstractClass('Mage_Core_Model_Resource_Db_Abstract', array('resource' => $resourceModel), '', true, true, true, array('getMainTable', 'getIdFieldName'));
     $resource->expects($this->any())->method('getMainTable')->will($this->returnValue($resource->getTable('core_website')));
     $resource->expects($this->any())->method('getIdFieldName')->will($this->returnValue('website_id'));
     $this->_model = $this->getMockForAbstractClass('Mage_Core_Model_Resource_Db_Collection_Abstract', array($resource));
 }
示例#11
0
 protected function setUp()
 {
     Mage_Core_Utility_Theme::registerDesignMock();
     Mage::getDesign()->setDefaultDesignTheme();
     $this->_mail = $this->getMock('Zend_Mail', array('send', 'addTo', 'addBcc', 'setReturnPath', 'setReplyTo'), array('utf-8'));
     $this->_model = $this->getMockBuilder('Mage_Core_Model_Email_Template')->setMethods(array('_getMail'))->setConstructorArgs(array($this->getMockBuilder('Mage_Core_Model_Event_Manager')->disableOriginalConstructor()->getMock(), $this->getMockBuilder('Mage_Core_Model_Cache')->disableOriginalConstructor()->getMock(), Mage::getObjectManager()->create('Magento_Filesystem')))->getMock();
     $this->_model->expects($this->any())->method('_getMail')->will($this->returnCallback(array($this, 'getMail')));
     $this->_model->setSenderName('sender')->setSenderEmail('*****@*****.**')->setTemplateSubject('Subject');
 }
示例#12
0
 protected function setUp()
 {
     $this->_objectManager = Mage::getObjectManager();
     $this->_urlBuilder = $this->getMockBuilder('Mage_Backend_Model_Url')->disableOriginalConstructor()->getMock();
     $this->_layout = $this->_objectManager->get('Mage_Core_Model_Layout');
     $this->_blockFactory = $this->_objectManager->get('Mage_Core_Model_BlockFactory');
     $this->_block = $this->_blockFactory->createBlock($this->_formClass, array('urlBuilder' => $this->_urlBuilder));
     $this->_layout->addBlock($this->_block);
 }
示例#13
0
 /**
  * @covers Mage_DesignEditor_Model_Layout_Update::__beforeSave
  * @magentoDbIsolation enabled
  */
 public function testBeforeSave()
 {
     /** @var $model Mage_DesignEditor_Model_Layout_Update */
     $model = Mage::getObjectManager()->get('Mage_DesignEditor_Model_Layout_Update');
     $model->setData(array('handle' => 'layout_update_test'));
     $model->save();
     $this->assertTrue($model->getIsVde());
     $model->delete();
 }
示例#14
0
 protected function setUp()
 {
     $this->_layout = Mage::getModel('Mage_Core_Model_Layout');
     $this->_layout->addBlock('Mage_Core_Block_Text', 'root');
     $this->_layout->addBlock('Mage_Core_Block_Text', 'head');
     $this->_block = $this->_layout->createBlock('Mage_Tag_Block_Product_Result', 'test', array('layout' => $this->_layout));
     $this->_child = Mage::getObjectManager()->create('Mage_Core_Block_Text');
     $this->_layout->addBlock($this->_child, 'search_result_list', 'test');
 }
示例#15
0
 protected function setUp()
 {
     $this->_objectManager = Mage::getObjectManager();
     $this->_design = $this->_objectManager->get('Mage_Core_Model_Design_Package');
     $this->_themeId = $this->_design->getDesignTheme()->getThemeId();
     /** @var $theme Mage_Core_Model_Theme */
     $theme = $this->_objectManager->create('Mage_Core_Model_Theme');
     $theme->load('Test Theme', 'theme_title');
     $this->_design->getDesignTheme()->setThemeId($theme->getId());
 }
示例#16
0
 /**
  * Check logged state
  * @covers Mage_Backend_Adminhtml_AuthController::loginAction
  * @magentoDbIsolation enabled
  */
 public function testLoggedLoginAction()
 {
     $this->_login();
     $this->dispatch('backend/admin/auth/login');
     /** @var $backendUrlModel Mage_Backend_Model_Url */
     $backendUrlModel = Mage::getObjectManager()->get('Mage_Backend_Model_Url');
     $expected = $backendUrlModel->getUrl('adminhtml/dashboard');
     $this->assertRedirect($this->stringStartsWith($expected));
     $this->_logout();
 }
示例#17
0
 /**
  * Bootstrap application before eny test
  *
  * @return void
  */
 protected function setUp()
 {
     $this->_objectManager = Mage::getObjectManager();
     /**
      * Use run options from bootstrap
      */
     $this->_runOptions = $this->_getBootstrap()->getAppOptions();
     $this->_runOptions['request'] = $this->getRequest();
     $this->_runOptions['response'] = $this->getResponse();
 }
示例#18
0
 public static function setUpBeforeClass()
 {
     $mediaDir = Mage::app()->getConfig()->getOptions()->getMediaDir();
     $filesystem = Mage::getObjectManager()->create('Magento_Filesystem');
     $filesystem->delete($mediaDir . '/theme/frontend');
     $filesystem->delete($mediaDir . '/theme/_merged');
     $ioAdapter = new Varien_Io_File();
     $ioAdapter->cp(Mage::app()->getConfig()->getOptions()->getJsDir() . '/prototype/prototype.js', Mage::app()->getConfig()->getOptions()->getJsDir() . '/prototype/prototype.min.js');
     self::$_developerMode = Mage::getIsDeveloperMode();
 }
示例#19
0
 /**
  * Get maximum upload size message
  *
  * @return string
  */
 public function getMaxUploadSizeMessage()
 {
     $maxImageSize = Mage::getObjectManager()->get('Magento_File_Size')->getMaxFileSizeInMb();
     if ($maxImageSize) {
         $message = $this->__('Total size of uploadable files must not exceed %sM', $maxImageSize);
     } else {
         $message = $this->__('System doesn\'t allow to get file upload settings');
     }
     return $message;
 }
示例#20
0
 protected function setUp()
 {
     $this->_objectManager = Mage::getObjectManager();
     $this->_model = $this->_objectManager->create('Mage_Index_Model_Process_File');
     /** @var $configuration Mage_Core_Model_Config */
     $configuration = $this->_objectManager->get('Mage_Core_Model_Config');
     $this->_fileDirectory = $configuration->getVarDir('locks');
     $fullFileName = $this->_fileDirectory . DIRECTORY_SEPARATOR . self::FILE_NAME;
     $this->_testFileHandler = fopen($fullFileName, 'w');
 }
示例#21
0
 /**
  * Retrieve test layout with test layout update
  *
  * @param bool $isSanitizeBlocks
  * @param bool $enableWrapping
  * @return Mage_DesignEditor_Model_Layout
  */
 protected function _getLayoutWithTestUpdate($isSanitizeBlocks = true, $enableWrapping = true)
 {
     /** @var $layout Mage_DesignEditor_Model_Layout */
     $layout = Mage::getObjectManager()->create('Mage_DesignEditor_Model_Layout');
     $layout->setSanitizing($isSanitizeBlocks);
     $layout->setWrapping($enableWrapping);
     $layout->getUpdate()->addUpdate(file_get_contents(__DIR__ . '/_files/layout_update.xml'));
     $layout->generateXml();
     return $layout;
 }
示例#22
0
 /**
  * @param string $type
  * @dataProvider physicalTypesDataProvider
  */
 public function testIsVirtualUnchecked($type)
 {
     $currentProduct = Mage::getModel('Mage_Catalog_Model_Product');
     $currentProduct->setTypeInstance(Mage::getObjectManager()->create($type));
     $block = new Mage_Adminhtml_Block_Catalog_Product_Helper_Form_Weight_Renderer();
     $form = new Varien_Data_Form();
     $form->setDataObject($currentProduct);
     $block->setForm($form);
     $this->assertNotContains('checked="checked"', $block->getElementHtml(), 'Is Virtual checkbox is selected for physical products');
 }
示例#23
0
 /**
  * Check if all the declared widget templates actually exist
  *
  * @param string $class
  * @param string $template
  * @dataProvider widgetTemplatesDataProvider
  */
 public function testWidgetTemplates($class, $template)
 {
     /** @var $blockFactory Mage_Core_Model_BlockFactory */
     $blockFactory = Mage::getObjectManager()->get('Mage_Core_Model_BlockFactory');
     /** @var Mage_Core_Block_Template $block */
     $block = $blockFactory->createBlock($class);
     $this->assertInstanceOf('Mage_Core_Block_Template', $block);
     $block->setTemplate((string) $template);
     $this->assertFileExists($block->getTemplateFile());
 }
示例#24
0
 protected function setUp()
 {
     $this->_authorizationConfig = $this->getMockBuilder('Mage_Webapi_Model_Authorization_Config')->disableOriginalConstructor()->setMethods(array('getAclResourcesAsArray'))->getMock();
     $this->_ruleResource = $this->getMockBuilder('Mage_Webapi_Model_Resource_Acl_Rule')->disableOriginalConstructor()->setMethods(array('getResourceIdsByRole'))->getMock();
     $this->_objectManager = Mage::getObjectManager();
     $this->_layout = $this->_objectManager->get('Mage_Core_Model_Layout');
     $this->_blockFactory = $this->_objectManager->get('Mage_Core_Model_BlockFactory');
     $this->_block = $this->_blockFactory->createBlock('Mage_Webapi_Block_Adminhtml_Role_Edit_Tab_Resource', array('authorizationConfig' => $this->_authorizationConfig, 'ruleResource' => $this->_ruleResource));
     $this->_layout->addBlock($this->_block);
 }
示例#25
0
 /**
  * Mage_User_Model_Role
  *
  * @magentoAppIsolation enabled
  */
 public function setUp()
 {
     Mage::getConfig()->setCurrentAreaCode('adminhtml');
     $roleAdmin = Mage::getModel('Mage_User_Model_Role');
     $roleAdmin->load(Magento_Test_Bootstrap::ADMIN_ROLE_NAME, 'role_name');
     Mage::app()->getRequest()->setParam('rid', $roleAdmin->getId());
     $aclMock = $this->getMock('Magento_Acl', array(), array(), '', false);
     $aclMock->expects($this->any())->method('has')->will($this->returnValue(true));
     $this->_block = Mage::getObjectManager()->create('Mage_User_Block_Role_Tab_Edit', array('data' => array('acl' => $aclMock)));
 }
示例#26
0
 /**
  * @magentoDbIsolation enabled
  * @magentoAppIsolation enabled
  */
 public function testIsThemeSelected()
 {
     $themeOld = Mage::getObjectManager()->create('Mage_Core_Model_Theme')->setData($this->_getThemeSampleData())->setThemePath('a/b')->setThemeCode('b')->save();
     $themeNew = Mage::getObjectManager()->create('Mage_Core_Model_Theme')->setData($this->_getThemeSampleData())->setThemePath('c/d')->setThemeCode('d')->save();
     Mage::getDesign()->setDesignTheme($themeOld);
     $isSelected = $this->_block->isThemeSelected($themeOld->getId());
     $this->assertTrue($isSelected);
     Mage::getDesign()->setDesignTheme($themeNew);
     $isSelected = $this->_block->isThemeSelected($themeOld->getId());
     $this->assertFalse($isSelected);
 }
示例#27
0
 /**
  * Build a model to test
  *
  * @param string $area
  * @param string $themePath
  * @param string|null $locale
  * @return Mage_Core_Model_Design_Fallback
  */
 protected function _buildModel($area, $themePath, $locale)
 {
     $testDir = implode(DS, array(dirname(__DIR__), '_files', 'fallback'));
     Mage::getConfig()->getOptions()->addData(array('js_dir' => implode(DS, array($testDir, 'pub', 'js')), 'design_dir' => $testDir . DIRECTORY_SEPARATOR . 'design'));
     /** @var $collection Mage_Core_Model_Theme_Collection */
     $collection = Mage::getModel('Mage_Core_Model_Theme_Collection');
     $themeModel = $collection->setBaseDir($testDir . DIRECTORY_SEPARATOR . 'design')->addDefaultPattern()->addFilter('theme_path', $themePath)->addFilter('area', $area)->getFirstItem();
     // Build model
     $params = array('area' => $area, 'locale' => $locale, 'themeModel' => $themeModel);
     return Mage::getObjectManager()->create('Mage_Core_Model_Design_Fallback', array('data' => $params));
 }
示例#28
0
 public static function setUpBeforeClass()
 {
     /* Point application to predefined layout fixtures */
     Mage::getConfig()->setOptions(array('design_dir' => realpath(__DIR__ . '/../../_files/design')));
     /** @var $themeRegistration Mage_Core_Model_Theme_Registration */
     $themeRegistration = Mage::getObjectManager()->create('Mage_Core_Model_Theme_Registration');
     $themeRegistration->register();
     Mage::getDesign()->setDesignTheme('test/default', 'adminhtml');
     /* Disable loading and saving layout cache */
     Mage::app()->getCacheInstance()->banUse('layout');
 }
示例#29
0
 public function testSetCustomerFilter()
 {
     $collection = new Mage_Customer_Model_Resource_Address_Collection();
     $select = $collection->getSelect();
     $this->assertSame($collection, $collection->setCustomerFilter(array(1, 2)));
     $customer = Mage::getObjectManager()->create('Mage_Customer_Model_Customer');
     $collection->setCustomerFilter($customer);
     $customer->setId(3);
     $collection->setCustomerFilter($customer);
     $this->assertStringMatchesFormat('%AWHERE%S(%Sparent_id%S IN(%S1%S, %S2%S))%SAND%S(%Sparent_id%S = %S-1%S)%SAND%S(%Sparent_id%S = %S3%S)%A', (string) $select);
 }
示例#30
0
 /**
  * @magentoAppIsolation enabled
  * @magentoDataFixture Mage/Cms/_files/pages.php
  */
 public function testRenderPage()
 {
     $page = Mage::getSingleton('Mage_Cms_Model_Page');
     $page->load('page_design_modern', 'identifier');
     // fixture
     /** @var $helper Mage_Cms_Helper_Page */
     $helper = Mage::helper('Mage_Cms_Helper_Page');
     $result = $helper->renderPage(Mage::getModel('Mage_Core_Controller_Front_Action', array(new Magento_Test_Request(), new Magento_Test_Response(), 'frontend', Mage::getObjectManager(), Mage::getObjectManager()->get('Mage_Core_Controller_Varien_Front'), Mage::getObjectManager()->get('Mage_Core_Model_Layout_Factory'))), $page->getId());
     $this->assertEquals('default/modern', Mage::getDesign()->getDesignTheme()->getThemePath());
     $this->assertTrue($result);
 }