Beispiel #1
0
 /**
  *
  * Get source path
  *
  * @param unknown_type $classFilename
  * @param unknown_type $methodName
  */
 public static function getSourceFolder($methodName)
 {
     $ar = explode('::', $methodName);
     $className = $ar[0];
     $path = Miao_Path::getDefaultInstance();
     $moduleRoot = $path->getModuleRoot($className);
     $classNamePath = explode('_', $className);
     array_shift($classNamePath);
     if (count($classNamePath) > 2) {
         array_shift($classNamePath);
     }
     if ('Test' === $classNamePath[count($classNamePath) - 1]) {
         array_pop($classNamePath);
     }
     $classNamePath = implode(DIRECTORY_SEPARATOR, $classNamePath);
     $classNamePath = rtrim($classNamePath, '\\/');
     $methodName = '';
     if (isset($ar[1])) {
         $methodName = $ar[1];
         $methodName = ltrim($methodName, 'provider');
     }
     $result = $moduleRoot . '/tests/sources/' . $classNamePath;
     $result = rtrim($result, '\\/');
     $result .= DIRECTORY_SEPARATOR . lcfirst($methodName);
     $result = rtrim($result, '\\/');
     return $result;
 }
Beispiel #2
0
 public function setUp()
 {
     $path = Miao_Path::getDefaultInstance();
     $this->_path = $path;
     $sourceDir = Miao_PHPUnit::getSourceFolder('Miaox_Compress_TestCompress_Test');
     $moduleRoot = $path->getModuleRoot('Miaox_TestCompress');
     Miao_PHPUnit::copyr($sourceDir, $moduleRoot);
     $this->_moduleRoot = $moduleRoot;
 }
 public function providerTestSetJarFilename()
 {
     $data = array();
     $moduleDir = Miao_Path::getDefaultInstance()->getModuleRoot(__CLASS__);
     $exceptionName = 'Miaox_Compress_Driver_ClosureCompiler_Exception';
     $data[] = array($moduleDir . '/data/compiler.jar');
     $data[] = array('');
     $data[] = array('asd.jar', $exceptionName);
     return $data;
 }
Beispiel #4
0
 /**
  * @return the $_templatesDir
  */
 public function getTemplatesDir()
 {
     $result = $this->_templatesDir;
     if (empty($result)) {
         //TODO; make with app
         $path = Miao_Path::getDefaultInstance();
         $result = $path->getTemplateDir(get_class($this));
     }
     return $result;
 }
 /**
  *
  *
  * @param unknown_type $jarFilename
  * @param array $options
  */
 public function __construct($jarFilename = '', Miao_Log $log = null)
 {
     if (empty($jarFilename)) {
         $jarFilename = Miao_Path::getDefaultInstance()->getModuleRoot(__CLASS__) . '/data/compiler.jar';
     }
     if (is_null($log)) {
         $log = Miao_Log::easyFactory('', '');
     }
     parent::__construct($log);
     $this->setJarFilename($jarFilename);
 }
Beispiel #6
0
 public function setUp()
 {
     $path = Miao_Path::getDefaultInstance();
     $this->_path = $path;
     $sourceDir = Miao_PHPUnit::getSourceFolder('Miao_Office_TestOffice_Test');
     $moduleRoot = $path->getModuleRoot('Miao_TestOffice');
     Miao_PHPUnit::copyr($sourceDir, $moduleRoot);
     $this->_moduleRoot = $moduleRoot;
     $templatesDir = $path->getModuleRoot('Miao_TestOffice_View_Main') . '/templates/layouts';
     $debugMode = true;
     $this->_templatesObj = new Miao_Office_TemplatesEngine_PhpNative($templatesDir, $debugMode);
 }
Beispiel #7
0
 public function getListFileListByLibName($libName)
 {
     try {
         $path = Miao_Path::getDefaultInstance();
         $dir = $path->getRootByLibName($libName);
     } catch (Miao_Path_Exception $e) {
         throw new Miao_PHPUnit_Exception($e->getMessage());
     }
     $result = array();
     if (is_dir($dir)) {
         $result = $this->_getFileList($dir);
     }
     return $result;
 }
Beispiel #8
0
 public function providerTestGetSourceFolder()
 {
     $data = array();
     $path = Miao_Path::getDefaultInstance();
     $expected = $path->getModuleRoot('Miao_PHPUnit_Test');
     $data[] = array(__METHOD__, $expected . '/tests/sources/PHPUnit/testGetSourceFolder');
     $expected = $path->getModuleRoot('Miao_FrontOffice_ViewBlock_Test');
     $data[] = array('Miao_FrontOffice_ViewBlock_Test::providerTestFetch', $expected . '/tests/sources/ViewBlock/testFetch');
     $expected = $path->getModuleRoot('Miao_TestOffice');
     $data[] = array('Miao_TestOffice_Test', $expected . '/tests/sources/TestOffice');
     $expected = $path->getModuleRoot('Miao_TestOffice');
     $data[] = array('Miao_TestOffice', $expected . '/tests/sources/TestOffice');
     return $data;
 }
Beispiel #9
0
 private function _getBaseByLibName($libName)
 {
     if (!isset($this->_baseInstanceList[$libName])) {
         $path = Miao_Path::getDefaultInstance();
         if ($libName == self::MAIN) {
             $filename = $path->getMainConfigFilename();
         } else {
             $filename = $path->getRootByLibName($libName) . '/data/config.php';
         }
         $configData = (include $filename);
         $base = new Miao_Config_Base($configData);
         $this->_baseInstanceList[$libName] = $base;
     }
     return $this->_baseInstanceList[$libName];
 }
Beispiel #10
0
 public function getOffice(array $params, array $default = array('_view' => 'Main'))
 {
     $list = $this->getClassList($params, $default);
     $frontOffice = new Miao_Office();
     $frontOffice->setFactory($this);
     /**
      * TODO: refactoring
      */
     $resource = new $list[lcfirst(Miao_Office::TYPE_RESOURCE)]($frontOffice);
     if ($list[lcfirst(Miao_Office::TYPE_VIEW)]) {
         $className = $list[lcfirst(Miao_Office::TYPE_VIEW)];
         $path = Miao_Path::getDefaultInstance();
         $templatesDir = $path->getModuleRoot($className) . '/templates';
         $templatesObj = new Miao_Office_TemplatesEngine_PhpNative($templatesDir);
         $view = new $list[lcfirst(Miao_Office::TYPE_VIEW)]($templatesObj);
         $frontOffice->setView($view);
     }
     if ($list[lcfirst(Miao_Office::TYPE_VIEWBLOCK)]) {
         $viewBlock = new $list[lcfirst(Miao_Office::TYPE_VIEWBLOCK)]();
         $frontOffice->setViewBlock($viewBlock);
     }
     if ($list[lcfirst(Miao_Office::TYPE_ACTION)]) {
         $action = new $list[lcfirst(Miao_Office::TYPE_ACTION)]();
         $frontOffice->setAction($action);
     }
     $frontOffice->setResource($resource);
     $header = new Miao_Office_Header();
     $frontOffice->setHeader($header);
     return $frontOffice;
 }
Beispiel #11
0
 /**
  * Путь к шаблону
  * @param $className
  * @return string
  */
 protected function _getTemplatePath($className)
 {
     $parts = explode('_', $className);
     $filename = strtolower(array_pop($parts)) . '.tpl';
     $dir = Miao_Path::getDefaultInstance()->getTemplateDir(implode('_', $parts));
     if (!empty($dir)) {
         $dir .= DIRECTORY_SEPARATOR;
     }
     return $dir . $filename;
 }
Beispiel #12
0
 protected function _initDefault()
 {
     $this->_alphabet = "0123456789abcdefghijklmnopqrstuvwxyz";
     $this->_allowed_symbols = "23456789abcdegikpqsvxyz";
     $this->_fontsdir = Miao_Path::getDefaultInstance()->getModuleRoot(__CLASS__) . '/data/fonts';
     $this->_length = mt_rand(5, 7);
     $this->_width = 160;
     $this->_height = 80;
     $this->_fluctuationAmplitude = 8;
     $this->_whiteNoiseDensity = 1 / 6;
     $this->_blackNoiseDensity = 1 / 30;
     $this->_noSpaces = true;
     $this->_showCredits = false;
     $this->_credits = '';
     $this->_foregroundColor = array(mt_rand(0, 80), mt_rand(0, 80), mt_rand(0, 80));
     $this->_backgroundColor = array(mt_rand(220, 255), mt_rand(220, 255), mt_rand(220, 255));
     $this->_jpegQuality = 90;
 }
Beispiel #13
0
 protected function _makeViewTemplate()
 {
     $className = get_class($this);
     $ar = explode('_', $className);
     $prefix = array();
     $prefix[] = array_shift($ar);
     $prefix[] = array_shift($ar);
     $prefix[] = array_shift($ar);
     $ar = array_map('strtolower', $ar);
     $result = implode('_', $ar);
     $result .= '.tpl';
     $path = Miao_Path::getDefaultInstance();
     $templateDir = $path->getTemplateDir(implode('_', $prefix));
     $result = $templateDir . DIRECTORY_SEPARATOR . $result;
     return $result;
 }
Beispiel #14
0
 /**
  * Путь к шаблону
  * @param $className
  * @return string
  */
 protected function _getTemplatePath($className)
 {
     $parts = explode('_', $className);
     if ($parts[2] != 'View') {
         $filename = ucfirst(array_pop($parts)) . '/index.tpl';
         $dir = Miao_Path::getDefaultInstance()->getTemplateDir(implode('_', $parts));
     } else {
         $filename = strtolower(array_pop($parts)) . '.tpl';
         $forDir = array_slice($parts, 0, 3);
         $dir = Miao_Path::getDefaultInstance()->getTemplateDir(implode('_', $forDir));
         $forFile = array_slice($parts, 3);
         $prefixFilename = strtolower(implode('_', $forFile));
         if (!empty($prefixFilename)) {
             $prefixFilename .= '_';
         }
         $filename = $prefixFilename . $filename;
     }
     if (!empty($dir)) {
         $dir .= DIRECTORY_SEPARATOR;
     }
     return $dir . $filename;
 }
Beispiel #15
0
 protected function _deleteFolders(array $list)
 {
     foreach ($list as $className) {
         try {
             $path = Miao_Path::getDefaultInstance()->getModuleRoot($className);
             Miao_PHPUnit::rmdirr($path);
         } catch (Exception $ex) {
         }
     }
 }
Beispiel #16
0
<?php

$config = (include dirname(__FILE__) . '/../data/config_map.php');
foreach ($config['libs'] as $value) {
    if ('Miao' == $value['name']) {
        require_once $value['path'] . '/modules/Autoload/classes/Autoload.class.php';
        break;
    }
}
Miao_Autoload::register($config['libs']);
Miao_Path::register($config);
Miao_Env::defaultRegister();
Beispiel #17
0
 /**
  *
  *
  * @dataProvider providerTestGetFilenameByClassName
  *
  * @param unknown_type $className
  * @param unknown_type $actual
  * @param unknown_type $expectedException
  */
 public function testGetFilenameByClassName($className, $actual, $expectedException = '')
 {
     if ($expectedException) {
         $this->setExpectedException($expectedException);
     }
     $path = Miao_Path::getDefaultInstance();
     $expected = $path->getFilenameByClassName($className);
     $this->assertEquals($expected, $actual);
 }
Beispiel #18
0
 public function setUp()
 {
     $this->_path = Miao_Path::getDefaultInstance();
 }