本文整理汇总了PHP中Mage::getObjectManager方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage::getObjectManager方法的具体用法?PHP Mage::getObjectManager怎么用?PHP Mage::getObjectManager使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage
的用法示例。
在下文中一共展示了Mage::getObjectManager方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUpBeforeClass
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();
}
示例2: setUp
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')));
}
示例3: testGetUrl
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());
}
示例4: setUp
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);
}
示例5: testGetListUrl
/**
* @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());
}
示例6: testGetMoneybookersLogoSrc
/**
* @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());
}
示例7: setUp
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('sender@example.com')->setTemplateSubject('Subject');
}
示例8: setUp
/**
* 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();
}
示例9: setUpBeforeClass
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();
}
示例10: getMaxUploadSizeMessage
/**
* 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;
}
示例11: setUp
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');
}
示例12: testWidgetTemplates
/**
* 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());
}
示例13: testIsThemeSelected
/**
* @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);
}
示例14: setUpBeforeClass
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');
}
示例15: testSetCustomerFilter
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);
}