if ($homeResource instanceof modResource) { $modx->resource = $homeResource; } else { echo "\nNo Resource\n"; } } } else { if (!$modx->user->hasSessionContext('mgr')) { die('Unauthorized Access'); } } // include 'lexiconhelper.class.php'; $modx->lexicon->load('mycomponent:default'); require_once $modx->getOption('mc.core_path', null, $modx->getOption('core_path') . 'components/mycomponent/') . 'model/mycomponent/lexiconhelper.class.php'; $props = isset($scriptProperties) ? $scriptProperties : array(); $lexiconHelper = new LexiconHelper($modx, $props); $lexiconHelper->init($props); $lexiconHelper->run(); $output = $lexiconHelper->helpers->getOutput(); $output .= "\n\n" . $modx->lexicon('mc_initial_memory_used') . ': ' . round($mem_usage / 1048576, 2) . ' ' . $modx->lexicon('mc_megabytes'); $mem_usage = memory_get_usage(); $peak_usage = memory_get_peak_usage(true); $output .= "\n" . $modx->lexicon('mc_final_memory_used') . ': ' . round($mem_usage / 1048576, 2) . ' ' . $modx->lexicon('mc_megabytes'); $output .= "\n" . $modx->lexicon('mc_peak_memory_used') . ': ' . round($peak_usage / 1048576, 2) . ' ' . $modx->lexicon('mc_megabytes'); /* report how long it took */ $mtime = microtime(); $mtime = explode(" ", $mtime); $mtime = $mtime[1] + $mtime[0]; $tend = $mtime; $totalTime = $tend - $tstart; $totalTime = sprintf("%2.4f s", $totalTime);
public function xtestEverything() { $this->utHelpers->rrmdir($this->targetLexDir); $lexHelper = new LexiconHelper($this->modx); $lexHelper->init(array(), 'unittest'); $lexHelper->run(); $this->assertNotEmpty($lexHelper->props, 'LexHelper->props is empty'); $this->assertEquals('unittest', $lexHelper->packageNameLower); $this->assertEquals('en', $lexHelper->primaryLanguage); $this->assertEquals($this->targetLexDir, $lexHelper->targetLexDir); $this->assertEquals($this->targetDataDir, $lexHelper->targetData); $file = $this->targetLexDir . 'en/' . 'chunks.inc.php'; $this->assertFileExists($file); $content = file_get_contents($file); $this->assertContains('$_lang[\'string1\'] = \'Hello \\\'columbus\\\'', $content); $this->assertContains("\$_lang['string2'] = 'Hello \"columbus\"'", $content); $this->assertContains("\$_lang['string3'] = 'Updated Empty string'", $content); $this->assertContains("\$_lang['string4'] = 'Updated String'", $content); $this->assertContains("\$_lang['string14'] = 'String in Chunk'", $content); $this->assertContains("\$_lang['string15'] = 'Hello \"Columbus\"'", $content); }