/**
  * Finds a list of all language files for a specific language by
  * searching the application/languages folder as well as all core_module
  * folders for folders matching the language name.
  *
  * @param string $language The language
  *
  * @return array An array of files.
  */
 function list_lang_files($language = 'english')
 {
     $ci =& get_instance();
     $ci->load->helper('file');
     $lang_files = array();
     // Base language files.
     $lang_files['core'] = find_lang_files(APPPATH . 'language/' . $language . '/');
     // Module lang files
     $modules = module_list();
     $custom_modules = module_list(TRUE);
     foreach ($modules as $module) {
         $module_langs = module_files($module, 'language');
         $type = 'core';
         if (isset($module_langs[$module]['language'][$language])) {
             $path = implode('/', array($module, 'language', $language));
             if (in_array($module, $custom_modules)) {
                 $files = find_lang_files(realpath(APPPATH . '../modules/' . $path) . '/');
                 $type = 'custom';
             } else {
                 $files = find_lang_files(APPPATH . 'core_modules/' . $path . '/');
             }
             foreach ($files as $file) {
                 $lang_files[$type][] = $file;
             }
         }
         //end if
     }
     //end foreach
     return $lang_files;
 }
Example #2
0
 private function get_module_versions()
 {
     $mod_versions = array();
     $modules = module_files(null, 'migrations');
     if ($modules === false) {
         return false;
     }
     foreach ($modules as $module => $migrations) {
         $mod_versions[$module] = array('installed_version' => $this->migrations->get_schema_version($module . '_'), 'latest_version' => $this->migrations->get_latest_version($module . '_'), 'migrations' => $migrations['migrations']);
     }
     return $mod_versions;
 }
Example #3
0
 public function run()
 {
     if ($this->input->post('submit') && !$this->input->post('tests')) {
         Template::set_message('Please select one or more modules to run tests on.', 'attention');
         redirect(SITE_AREA . '/developer/tester');
     }
     $this->load->library('unit_test');
     $this->load->library('Unit_tester');
     $this->unit->set_test_items(array('test_name', 'result', 'notes'));
     $vars = array();
     $vars['results'] = array();
     // Someplace to store the results of all of our tests.
     $modules = is_array($this->input->post('tests')) ? $this->input->post('tests') : array($this->input->post('tests'));
     // Send to view for reload
     Template::set('test_names', $modules);
     Template::set_block('sub_nav', 'developer/_sub_nav');
     // Run through each module, running their tests.
     foreach ($modules as $module) {
         $tests = module_files($module, 'tests');
         $tests = $tests[$module]['tests'];
         // Run all of the tests.
         foreach ($tests as $test) {
             // We need to make sure it's not a sql file!
             if (strpos($test, '.sql') === false) {
                 // Grab our test class
                 $test_class = str_replace(EXT, '', end(explode('/', $test)));
                 $module_file_path = module_file_path($module, 'tests', $test);
                 require $module_file_path;
                 $class = new $test_class();
                 // Tell it what module it's running.
                 // (Saves us from manually doing it for every test class)
                 $class->set_module_path(dirname($module_file_path));
                 // Clear previous unit results
                 $this->unit->reset();
                 // Run the tests
                 $class->run_all();
                 // Store our results for processing later.
                 $vars['results'][$module . ' : <b>' . ucwords(str_replace('_', ' ', $test_class)) . '</b>'] = array('report' => $this->unit->report(), 'raw' => $this->unit->result(), 'passed' => 0, 'failed' => 0);
             }
         }
     }
     // Find our totals
     $vars['total_passed'] = 0;
     $vars['total_failed'] = 0;
     if (count($vars['results'])) {
         foreach ($vars['results'] as $key => $result) {
             foreach ($result['raw'] as $k => $v) {
                 // We're not using the results so strip it.
                 unset($vars['results'][$key]['report']);
                 if (isset($v['Result'])) {
                     if (strtolower($v['Result']) == 'passed') {
                         $vars['total_passed']++;
                         $vars['results'][$key]['passed']++;
                         //print_r($vars['results'][$key]);
                     } else {
                         $vars['total_failed']++;
                         $vars['results'][$key]['failed']++;
                     }
                 }
             }
         }
     }
     Template::set($vars);
     // display the results
     Template::render();
 }
Example #4
0
 /**
  * Get all versions available for the modules
  *
  * @access private
  *
  * @return array Array of available versions for each module
  */
 private function get_module_versions()
 {
     $mod_versions = array();
     $modules = module_files(null, 'migrations');
     if ($modules === false) {
         return false;
     }
     // Sort Module Migrations in Reverse Order instead of Randomness.
     foreach ($modules as &$mod) {
         if (!array_key_exists('migrations', $mod)) {
             continue;
         }
         arsort($mod['migrations']);
     }
     foreach ($modules as $module => $migrations) {
         $mod_versions[$module] = array('installed_version' => $this->migrations->get_schema_version($module . '_'), 'latest_version' => $this->migrations->get_latest_version($module . '_'), 'migrations' => $migrations['migrations']);
     }
     return $mod_versions;
 }