public function testGetFilename() { $params = array('area' => 'some_area', 'package' => 'some_package', 'theme' => 'some_theme'); $file = 'Some_Module::some_file.ext'; $expectedParams = $params + array('module' => 'Some_Module'); $expected = 'path/to/some_file.ext'; $this->_model->expects($this->once())->method('_getFallback')->with($expectedParams)->will($this->returnValue($this->_fallback)); $this->_fallback->expects($this->once())->method('getFile')->with('some_file.ext', 'Some_Module')->will($this->returnValue($expected)); $actual = $this->_model->getFilename($file, $params); $this->assertEquals($expected, $actual); }
/** * Test for the theme files fallback * * @param string $themeFile * @param array $designParams * @param string|null $expectedFilename * * @dataProvider getThemeFileFallbackDataProvider */ public function testThemeFileFallback($themeFile, array $designParams, $expectedFilename) { $expectedFilename = str_replace('/', DIRECTORY_SEPARATOR, $expectedFilename); $actualFilename = $this->_model->getFilename($themeFile, $designParams); if ($expectedFilename) { //$this->assertStringMatchesFormat($expectedFilename, $actualFilename); $this->assertFileExists($actualFilename); } else { $this->assertFileNotExists($actualFilename); } }
/** * Utilizes theme fallback to improve the compiler scss imports * * @param $file * * @return string */ public function importFallbackFunction($file) { //@TODO make directory dynamic in some way $filepath = parent::getFilename('scss' . DS . $file . '.scss', array('_type' => 'skin')); if (!$filepath) { $filepath = parent::getFilename('scss' . DS . '_' . $file . '.scss', array('_type' => 'skin')); } return $filepath; }
/** * Filename of css file or compiled css from sass file * This method is important for using css merging feature * * @param string $file * @param array $params * @return string */ public function getFilename($file, array $params) { $filename = parent::getFilename($file, $params); if ($this->_isSassFile($file)) { try { if (Mage::app()->useCache('sass')) { $cacheKey = $this->getCacheKey($filename); $compiledFilename = Mage::app()->loadCache($cacheKey); if (!$compiledFilename) { $compiledFilename = $this->convertToCss($filename); Mage::app()->saveCache($compiledFilename, $cacheKey, array('sass'), 86400); } } else { $compiledFilename = $this->convertToCss($filename); } $filename = $compiledFilename; } catch (Exception $e) { Mage::logException($e); $filename = ''; } } return $filename; }
public function testGetFilename() { $expected = '%s/frontend/test/default/Mage_Catalog/theme_template.phtml'; $actual = $this->_model->getFilename('Mage_Catalog::theme_template.phtml', array()); $this->_testExpectedVersusActualFilename($expected, $actual); }
/** * @dataProvider getFilenameDataProvider */ public function testGetFilename($file, $params) { $this->assertFileExists($this->_model->getFilename($file, $params)); }
/** * @param string $file * @expectedException Magento_Exception * @dataProvider extractScopeExceptionDataProvider */ public function testExtractScopeException($file) { $this->_model->getFilename($file, array()); }
/** * Use this one to get existing file name with fallback to default * * $params['_type'] is required * * @param string $file * @param array $params * @return string */ public function getFilename($file, array $params) { if (strpos($file, 'awmobile.xml') !== false && Mage::helper('awmobile')->getDisabledOutput()) { return ''; } if ($this->_needToInject() && strpos($file, 'awmobile.xml') === false) { return $this->_getNewFileName($file, $params); } else { return parent::getFilename($file, $params); } }