Exemplo n.º 1
0
 public function getLog()
 {
     if (empty($this->_log)) {
         $logFilename = Miao_Config::Main()->get('paths.logs') . '/pdo_log';
         $this->_log = Miao_Log::easyFactory($logFilename);
     }
     return $this->_log;
 }
Exemplo n.º 2
0
 public function __construct(array $opts, array $remainingArgs)
 {
     $this->_opts = $opts;
     $this->_remainingArgs = $remainingArgs;
     $this->_init();
     $this->_testSuite = new PHPUnit_Framework_TestSuite();
     Miao_Session::getInstance()->start();
     $this->_log = Miao_Log::easyFactory('', true, 7);
 }
Exemplo n.º 3
0
 /**
  *
  * @return the $_logObj
  */
 public function getLogObj()
 {
     if (!$this->_log) {
         $debugMode = $this->getDebugMode();
         $logFilename = $this->_logFilename;
         $log = Miao_Log::easyFactory($logFilename, false, $debugMode ? Miao_Log::DEBUG : Miao_Log::ERR);
         $this->_log = $log;
     }
     return $this->_log;
 }
Exemplo n.º 4
0
 /**
  *
  * @param Miaox_PDO $pdo
  * @param Miao_Log $log
  */
 public function __construct(Miaox_PDO $pdo, Miao_Log $log = null)
 {
     if (!$log) {
         $this->_log = Miao_Log::easyFactory('');
     } else {
         $this->_log = $log;
     }
     $this->_pdo = $pdo;
     $this->_pdo->setLog($log);
     $this->_init();
 }
Exemplo n.º 5
0
 /**
  *
  *
  * @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);
 }
Exemplo n.º 6
0
 public function testLog()
 {
     $sourceDir = Miao_PHPUnit::getSourceFolder(__CLASS__);
     $filename = $sourceDir . '/unittest_log';
     $log = Miao_Log::easyFactory($filename);
     $msg = 'Hello world';
     $log->err($msg);
     $content = file_get_contents($filename);
     $this->assertTrue(!empty($content));
     unlink($filename);
 }
Exemplo n.º 7
0
 /**
  *
  * @dataProvider providerTestMinify
  */
 public function testMinify($fileList, $dstFilename, $options, $actualFilename, $exceptionName = '')
 {
     if (!empty($exceptionName)) {
         $this->setExpectedException($exceptionName);
     }
     $log = Miao_Log::easyFactory($this->_moduleRoot . '/' . 'test_minify_log', false);
     $obj = new Miaox_Compress_Driver_ClosureCompiler('', $log);
     $obj->minify($fileList, $dstFilename, $options);
     $this->assertFileEquals($dstFilename, $actualFilename);
     unlink($dstFilename);
 }
Exemplo n.º 8
0
 /**
  *
  * @dataProvider providerTestMergeFile
  */
 public function testMergeFile($files, $actualFilename, $exceptionName = '')
 {
     $log = Miao_Log::easyFactory($this->_tmpDir . '/' . 'test_merge_file_log');
     $obj = new Miaox_Compress_Driver($log);
     foreach ($files as &$file) {
         $file = $this->_sourceDir . $file;
     }
     $outpuFilename = $this->_tmpDir . '/total';
     $actualFilename = $this->_sourceDir . $actualFilename;
     $obj->mergeFiles($files, $outpuFilename);
     $this->assertFileEquals($outpuFilename, $actualFilename);
 }
Exemplo n.º 9
0
 public function testFileMode()
 {
     $sourceDir = Miao_PHPUnit::getSourceFolder(__CLASS__);
     $filename = $sourceDir . '/unittest_log';
     $log = Miao_Log::easyFactory($filename);
     $msg = 'Hello world';
     $log->err($msg);
     $expected = '0666';
     $actual = substr(sprintf('%o', fileperms($filename)), -4);
     $this->assertEquals($expected, $actual);
     unlink($filename);
 }
Exemplo n.º 10
0
 /**
  *
  * @dataProvider providerTestMinify
  */
 public function testMinify($fileList, $dstFilename, $options, $actualFilename, $exceptionName = '')
 {
     //$this->markTestSkipped( 'Miaox_Compress_Driver_Yui_Test test skipped, because work long time' );
     if (!empty($exceptionName)) {
         $this->setExpectedException($exceptionName);
     }
     $log = Miao_Log::easyFactory($this->_moduleRoot . '/' . 'test_minify_log', false);
     $obj = new Miaox_Compress_Driver_Yui('', $log);
     $obj->minify($fileList, $dstFilename, $options);
     $this->assertFileEquals($dstFilename, $actualFilename);
     unlink($dstFilename);
 }
Exemplo n.º 11
0
 protected function _pdo(array $config)
 {
     assert(array_key_exists('dsn', $config));
     assert(array_key_exists('username', $config));
     assert(array_key_exists('password', $config));
     if (isset($config['logFilename'])) {
         $verbose = isset($config['logVerbose']) ? $config['logVerbose'] : false;
         $log = Miao_Log::easyFactory($config['logFilename'], $verbose);
     }
     $dsn = $config['dsn'];
     $user = $config['username'];
     $pass = $config['password'];
     $options = isset($config['options']) ? $options : array();
     $pdo = new Miaox_PDO($dsn, $user, $pass, $options);
     $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
     $pdo->setLog($log);
     return $pdo;
 }
Exemplo n.º 12
0
        require_once __DIR__ . '/bootstrap.php';
    } else {
        if (file_exists($bootstrap) && is_readable($bootstrap)) {
            require_once $bootstrap;
        } else {
            $msg = sprintf('Invalid param --bootstrap, file (%s) not found or is not readable', $bootstrap);
            throw new Exception($msg);
        }
    }
}
try {
    $bootstrap = '';
    $opts = getopt('', array('bootstrap:'));
    extract($opts);
    includeBootstrap($bootstrap);
    $log = Miao_Log::easyFactory('', true);
    $message = 'Run script: ' . __FILE__;
    $log->debug($message);
    $message = sprintf('Params: %s', print_r($opts, true));
    $log->debug($message);
    $config = Miaox_Acs_Instance::getConfig();
    $config['log']['verbose'] = true;
    $adapter = Miaox_Acs_Instance::adapter($config);
    $builder = new Miaox_Acs_Adapter_Db_Builder($adapter);
    $builder->run();
} catch (Exception $ex) {
    echo "\n";
    echo "Error!\n";
    echo $ex->getMessage();
    echo "\n\n";
}
Exemplo n.º 13
0
            $msg = sprintf('Invalid param --bootstrap, file (%s) not found or is not readable', $bootstrap);
            throw new Exception($msg);
        }
    }
}
$action = '';
$userName = '';
$verbose = false;
$withTemplate = null;
$remainingArgs = array();
$bootstrap = '';
try {
    $data = parseOpts();
    extract($data);
    includeBootstrap($bootstrap);
    $log = Miao_Log::easyFactory(null, $verbose);
    $author = isset($_SERVER['USER']) ? $_SERVER['USER'] : '';
    $console = new Miao_Console($remainingArgs[0], $author, $log);
    $console->createTemplate($withTemplate);
    if ($action == 'cp' || $action == 'ren') {
        if (!isset($remainingArgs[1])) {
            help();
        }
        $console->{$action}($remainingArgs[1]);
    } else {
        $console->{$action}();
    }
} catch (Exception $ex) {
    echo "\n";
    echo "Console error!\n";
    echo $ex->getMessage();