Пример #1
0
 function _run_from_file($file_name, $all_in_one_test = true)
 {
     $multiple_expected_php = $multiple_sintags = '';
     $tests = explode('===================================', file_get_contents(AK_TEST_DIR . DS . 'fixtures' . DS . 'data' . DS . $file_name));
     foreach ($tests as $test) {
         list($sintags, $php) = explode('-----------------------------------', $test);
         $sintags = trim($sintags);
         $expected_php = trim($php);
         if (empty($sintags)) {
             break;
         } else {
             $multiple_sintags .= $sintags;
             $multiple_expected_php .= $expected_php;
         }
         $AkSintags =& new AkSintagsParser();
         $php = $AkSintags->parse($sintags);
         if ($php != $expected_php) {
             Ak::trace("GENERATED: \n" . $php);
             Ak::trace("EXPECTED: \n" . $expected_php);
             Ak::trace("SINTAGS: \n" . $sintags);
         }
         $this->assertEqual($php, $expected_php);
     }
     if ($all_in_one_test) {
         $AkSintags =& new AkSintagsParser();
         $php = $AkSintags->parse($multiple_sintags);
         if ($php != $multiple_expected_php) {
             Ak::trace("GENERATED: \n" . $php);
             Ak::trace("EXPECTED: \n" . $expected_php);
             Ak::trace("SINTAGS: \n" . $sintags);
         }
         $this->assertEqual($php, $multiple_expected_php);
     }
 }
Пример #2
0
 function log_memory($reset = false, $vervose = false)
 {
     ($reset || empty($this->initial)) && ($this->initial = memory_get_usage());
     $this->current = memory_get_usage();
     $this->difference = $this->current - $this->initial;
     $this->difference && $vervose && Ak::trace($this->difference / 1048576 . ' MB increased');
     return $this->difference;
 }
Пример #3
0
 function file_put_contents($file_name, $content, $options = array())
 {
     $default_options = array('ftp' => defined('AK_UPLOAD_FILES_USING_FTP') && AK_UPLOAD_FILES_USING_FTP, 'base_path' => AK_BASE_DIR);
     $options = array_merge($default_options, $options);
     if (!function_exists('file_put_contents')) {
         include_once AK_CONTRIB_DIR . DS . 'pear' . DS . 'PHP' . DS . 'Compat.php';
         PHP_Compat::loadFunction(array('file_put_contents'));
     }
     $file_name = trim(str_replace($options['base_path'], '', $file_name), DS);
     if ($options['ftp']) {
         require_once AK_LIB_DIR . DS . 'AkFtp.php';
         $file_name = trim(str_replace(array(DS, '//'), array('/', '/'), $file_name), '/');
         if (!AkFtp::is_dir(dirname($file_name))) {
             AkFtp::make_dir(dirname($file_name));
         }
         return AkFtp::put_contents($file_name, $content);
     } else {
         if (!is_dir(dirname($options['base_path'] . DS . $file_name))) {
             Ak::make_dir(dirname($options['base_path'] . DS . $file_name), $options);
         }
         if (!($result = file_put_contents($options['base_path'] . DS . $file_name, $content))) {
             if (!empty($content)) {
                 Ak::trace("Could not write to file: \"" . $options['base_path'] . DS . "{$file_name}\". Please change file/dir permissions or enable FTP file handling by" . " setting the following on your config/" . AK_ENVIRONMENT . ".php file \n<pre>define('AK_UPLOAD_FILES_USING_FTP', true);\n" . "define('AK_READ_FILES_USING_FTP', false);\n" . "define('AK_DELETE_FILES_USING_FTP', true);\n" . "define('AK_FTP_PATH', 'ftp://*****:*****@example.com/path_to_the_framework');\n" . "define('AK_FTP_AUTO_DISCONNECT', true);\n</pre>");
             }
         }
         return $result;
     }
 }
Пример #4
0
 function ak_trace_db_query($message, $new_line = true)
 {
     if (Ak::getStaticVar('ak_trace_db_query') === false) {
         return;
     }
     if (!AK_TRACE_DB_QUERIES_INCLUDES_DB_TYPE) {
         $message = preg_replace('/\\([a-z0-9]+\\): /', '', trim($message, "\n-"));
     }
     $details = Ak::getLastFileAndLineAndMethod(AK_TRACE_ONLY_APP_DB_QUERIES);
     if (empty($details)) {
         $details = array(null, null, null);
     }
     $message = trim(html_entity_decode(strip_tags($message)));
     if (!AK_DEBUG_OUTPUT_AS_HTML) {
         echo $message . "\n";
     } else {
         Ak::trace($message, $details[1], $details[0], $details[2]);
     }
 }
Пример #5
0
 public function failTransaction()
 {
     if(AK_DEBUG && !empty($this->connection->debug)){
         Ak::trace(ak_backtrace(), null, null, null, false);
     }
     return $this->connection->FailTrans();
 }
Пример #6
0
 function dbugging($trace_this_on_debug_mode = null)
 {
     if(!empty($this->_db->debug) && !empty($trace_this_on_debug_mode)){
         $message = !is_scalar($trace_this_on_debug_mode) ? var_export($trace_this_on_debug_mode, true) : (string)$trace_this_on_debug_mode;
         Ak::trace($message);
     }
     return !empty($this->_db->debug);
 }
Пример #7
0
 function _displayLog($type, $error_mode, $error_message)
 {
     $message = $this->_getLogFormatedAsHtml($type, $error_mode, $error_message);
     if ($this->print_display_message) {
         Ak::trace($message);
     }
     return $message;
 }