public function setUp() { if (Magento_Test_Bootstrap::getInstance()->getDbVendorName() != 'mysql') { $this->markTestSkipped('Test is designed to run on MySQL only.'); } $this->_model = Mage::getModel('Mage_Core_Model_Resource'); }
/** * Test lost connection re-initializing * * @covers Varien_Db_Adapter_Pdo_Mysql::raw_query * @covers Varien_Db_Adapter_Pdo_Mysql::query * @throws Exception */ public function testWaitTimeout() { if (Magento_Test_Bootstrap::getInstance()->getDbVendorName() != 'mysql') { $this->markTestSkipped('Test is designed to run on MySQL only.'); } if (!$this->_getConnection() instanceof Varien_Db_Adapter_Pdo_Mysql) { $this->markTestSkipped('This test is for Varien_Db_Adapter_Pdo_Mysql'); } try { $defaultWaitTimeout = $this->_getWaitTimeout(); $minWaitTimeout = 1; $this->_setWaitTimeout($minWaitTimeout); $this->assertEquals($minWaitTimeout, $this->_getWaitTimeout(), 'Wait timeout was not changed'); // Sleep for time greater than wait_timeout and try to perform query sleep($minWaitTimeout + 1); $result = $this->_getConnection()->raw_query('SELECT 1'); $this->assertInstanceOf('Varien_Db_Statement_Pdo_Mysql', $result); // Restore wait_timeout $this->_setWaitTimeout($defaultWaitTimeout); $this->assertEquals($defaultWaitTimeout, $this->_getWaitTimeout(), 'Default wait timeout was not restored'); } catch (Exception $e) { // Reset connection on failure to restore global variables $this->_getConnection()->closeConnection(); throw $e; } }
/** * Isolate global application objects */ protected function _isolateApp() { if ($this->_hasNonIsolatedTests) { Magento_Test_Bootstrap::getInstance()->cleanupCache(); Magento_Test_Bootstrap::getInstance()->initialize(); $this->_hasNonIsolatedTests = false; } }
protected function setUp() { if (Magento_Test_Bootstrap::getInstance()->getDbVendorName() != 'mysql') { $this->markTestSkipped('Test is designed to run on MySQL only.'); } $this->_model = Mage::getResourceModel('Mage_Core_Model_Resource_Helper_Mysql4', array('modulePrefix' => 'core')); $collection = Mage::getResourceModel('Mage_Core_Model_Resource_Store_Collection'); $this->_select = $collection->getSelect(); }
public function testToHtml() { if (Magento_Test_Bootstrap::getInstance()->getDbVendorName() != 'mysql') { $this->markTestIncomplete('bug: MAGETWO-4227'); } $block = Mage::app()->getLayout()->createBlock('Mage_Rss_Block_Order_Status'); $this->assertEmpty($block->toHtml()); $uniqid = uniqid(); $order = $this->getMock('Varien_Object', array('formatPrice'), array(array('id' => $uniqid))); Mage::register('current_order', $order); $this->assertContains($uniqid, $block->toHtml()); }
/** * Remove cache polluted by other tests excluding performance critical cache (configuration, ddl) */ protected function _cleanupCache() { /* * Cache cleanup relies on the initialized config object, which could be polluted from within a test. * For instance, any test could explicitly call Mage::reset() to destroy the config object. */ $expectedOptions = Magento_Test_Bootstrap::getInstance()->getAppOptions(); $actualOptions = Mage::getConfig() ? Mage::getConfig()->getOptions()->getData() : array(); $isConfigPolluted = array_intersect_assoc($expectedOptions, $actualOptions) !== $expectedOptions; if ($isConfigPolluted) { Magento_Test_Bootstrap::getInstance()->initialize(); } Mage::app()->getCache()->clean(Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG, array(Mage_Core_Model_Config::CACHE_TAG, Varien_Db_Adapter_Pdo_Mysql::DDL_CACHE_TAG, 'DB_PDO_MSSQL_DDL', 'DB_ORACLE_DDL')); }
public static function tearDownAfterClass() { Mage::app()->getConfig()->deleteConfig(self::SAMPLE_CONFIG_PATH); Magento_Test_Bootstrap::getInstance()->refreshConfiguration(); }
public static function setUpBeforeClass() { self::$_options = Magento_Test_Bootstrap::getInstance()->getAppOptions(); }
/** * Bootstrap instance getter * * @return Magento_Test_Bootstrap */ protected function _getBootstrap() { return Magento_Test_Bootstrap::getInstance(); }
/** * @magentoDataIsolation enabled * @magentoDataFixture mediaImportImageFixture */ public function testSaveMediaImage() { if (Magento_Test_Bootstrap::getInstance()->getDbVendorName() != 'mysql') { $this->markTestIncomplete('bug: MAGETWO-4227'); } $attribute = Mage::getModel('Mage_Catalog_Model_Entity_Attribute'); $attribute->loadByCode('catalog_product', 'media_gallery'); $data = implode(',', array('sku', '_attribute_set', '_type', '_product_websites', 'name', 'price', 'description', 'short_description', 'weight', 'status', 'visibility', 'tax_class_id', '_media_attribute_id', '_media_image', '_media_label', '_media_position', '_media_is_disabled')) . "\n"; $data .= implode(',', array('test_sku', 'Default', Mage_Catalog_Model_Product_Type::DEFAULT_TYPE, 'base', 'Product Name', '9.99', 'Product description', 'Short desc.', '1', Mage_Catalog_Model_Product_Status::STATUS_ENABLED, Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH, 0, $attribute->getId(), 'magento_image.jpg', 'Image Label', '1', '0')) . "\n"; $data = 'data://text/plain;base64,' . base64_encode($data); $fixture = new Mage_ImportExport_Model_Import_Source_Csv($data); foreach (new Mage_Catalog_Model_Resource_Product_Collection() as $product) { $this->fail("Unexpected precondition - product exists: '{$product->getId()}'."); } $this->_model->setSource($fixture)->setParameters(array('behavior' => Mage_ImportExport_Model_Import::BEHAVIOR_APPEND))->isDataValid(); $this->_model->importData(); $resource = new Mage_Catalog_Model_Resource_Product(); $productId = $resource->getIdBySku('test_sku'); // fixture $product = Mage::getModel('Mage_Catalog_Model_Product'); $product->load($productId); $gallery = $product->getMediaGalleryImages(); $this->assertInstanceOf('Varien_Data_Collection', $gallery); $items = $gallery->getItems(); $this->assertCount(1, $items); $item = array_pop($items); $this->assertInstanceOf('Varien_Object', $item); $this->assertEquals('/m/a/magento_image.jpg', $item->getFile()); $this->assertEquals('Image Label', $item->getLabel()); }
public function saveDataProvider() { $dir = Magento_Test_Bootstrap::getInstance()->getTmpDir() . DIRECTORY_SEPARATOR; return $this->_prepareData(array(array($this->_getFixture('image_adapters_test.png'), array($dir . uniqid('test_image_adapter'))), array($this->_getFixture('image_adapters_test.png'), array($dir, uniqid('test_image_adapter'))))); }
/** * @magentoConfigFixture current_store dev/log/active 1 * @magentoConfigFixture current_store dev/log/exception_file php://output * @magentoAppIsolation enabled */ public function testLogException() { // reinitialization is needed here, too Magento_Test_Bootstrap::getInstance()->reinitialize(); $msg = uniqid(); $exception = new Exception((string) $msg); Mage::logException($exception); $this->expectOutputRegex('/' . $msg . '/'); }
/** * Reset current working directory (CWD) */ protected function _resetWorkingDirectory() { chdir(Magento_Test_Bootstrap::getInstance()->getTestsDir()); }
/** * @depends testGetInstance */ public function testSetGetInstance() { Magento_Test_Bootstrap::setInstance($this->_bootstrap); $this->assertSame($this->_bootstrap, Magento_Test_Bootstrap::getInstance()); }
public static function setUpBeforeClass() { self::$_skinPublicDir = Mage::app()->getConfig()->getOptions()->getMediaDir() . '/skin'; self::$_fixtureTmpDir = Magento_Test_Bootstrap::getInstance()->getTmpDir() . '/publication'; }
public static function setUpBeforeClass() { parent::setUpBeforeClass(); self::$_tmpMediaDir = realpath(Magento_Test_Bootstrap::getInstance()->getTmpDir()) . DIRECTORY_SEPARATOR . 'media'; self::$_tmpSkinDir = self::$_tmpMediaDir . DIRECTORY_SEPARATOR . 'skin'; }
/** * Remove cached configuration and reinitialize the application */ protected static function _refreshConfiguration() { Mage::app()->cleanCache(array(Mage_Core_Model_Config::CACHE_TAG)); Magento_Test_Bootstrap::getInstance()->initialize(); }