Exemplo n.º 1
0
 public function testMemoryPage()
 {
     //Title
     MemoryPage::setTitle("Teste de titulo");
     $this->assertEquals("Teste de titulo", MemoryPage::getTitle());
     Memory::clearAll();
     $this->assertEquals("", MemoryPage::getTitle(''));
     $this->assertEquals("default titulo", MemoryPage::getTitle('default titulo'));
     //Extra header
     $this->assertNotNull(MemoryPage::getExtraHeader());
     $this->assertEmpty(MemoryPage::getExtraHeader());
     MemoryPage::setExtraHeader('my content');
     $this->assertEquals('my content', MemoryPage::getExtraHeader());
     //CSS
     $this->assertEquals(array(), MemoryPage::getCss());
     MemoryPage::addCss('teste.css');
     $this->assertEquals(array('teste.css'), MemoryPage::getCss());
     MemoryPage::addCss('teste.css');
     $this->assertEquals(array('teste.css'), MemoryPage::getCss());
     MemoryPage::addCss('teste2.css');
     $this->assertEquals(array('teste.css', 'teste2.css'), MemoryPage::getCss());
     //JS
     $this->assertEquals(array(), MemoryPage::getJs());
     MemoryPage::addJs('teste.js');
     $this->assertEquals(array('teste.js'), MemoryPage::getJs());
     MemoryPage::addJs('teste.js');
     $this->assertEquals(array('teste.js'), MemoryPage::getJs());
     MemoryPage::addJs('teste2.js');
     $this->assertEquals(array('teste.js', 'teste2.js'), MemoryPage::getJs());
 }
Exemplo n.º 2
0
 public function testLog()
 {
     $log = Factory::log();
     $this->assertEquals(\Logger::getLogger('main'), $log);
     $this->assertEquals(Factory::log(), $log);
     Memory::set('debug', true);
     $this->assertEquals(\Logger::getLogger('debug'), Factory::log());
     Memory::clear('debug');
     $this->assertEquals(\Logger::getLogger('main'), $log);
 }
Exemplo n.º 3
0
 public function renderContent($content, $file = '')
 {
     if (!empty($file)) {
         $template = Template::singleton();
         # Memory::get('template') eh setado na Factory
         if (Memory::get('template') == 'default') {
             foreach (Memory::get('templates', array()) as $name => $mustache) {
                 $content[$name] = $template->renderTemplate($mustache, $content);
             }
         }
         $template->showRenderTemplate($file, $content);
         if (Memory::get('debug', false)) {
             echo "<pre>";
             var_dump($content);
             echo "</pre>";
         }
     } else {
         //TODO o filename do page não está setado...
         dump("[o arquivo de template não foi configurado para a página solicitada] : o filename do page não está setado");
         dump($content);
     }
 }
 public function testIsValid()
 {
     Memory::set('debug', true);
     foreach ($this->data as $k => $val) {
         $val2 = $this->object->sanitize($val);
         $this->assertTrue($this->object->isValid($val2), 'Error to validate the sanitized key: ' . $k);
     }
     $this->assertTrue($this->object->isValid(''));
     $this->assertFalse($this->object->isValid(' '));
     //Não é vazio, então não é válido
     $this->assertTrue($this->object->isValid(true));
     $this->assertTrue($this->object->isValid(false));
     $this->assertTrue($this->object->isValid(null));
     $required = array(Flag::REQUIRED => true);
     $this->assertFalse($this->object->isValid('', $required));
     $this->assertFalse($this->object->isValid(' ', $required));
     $this->assertFalse($this->object->isValid(null, $required));
     $this->assertFalse($this->object->isValid(' ', $required));
     $this->assertTrue($this->object->isValid(true, $required));
     //'true'
     $this->assertTrue($this->object->isValid(false, $required));
     //'false'
     $this->assertTrue($this->object->isValid('abc', $required));
     $this->assertTrue($this->object->isValid(0, $required));
     $this->assertTrue($this->object->isValid('0', $required));
     $required[Flag::MINLENGHT] = 2;
     $this->assertFalse($this->object->isValid(' ', $required));
     $this->assertFalse($this->object->isValid('a', $required));
     $this->assertTrue($this->object->isValid('213412', $required));
     $required[Flag::MAXLENGHT] = 5;
     $this->assertFalse($this->object->isValid('213412', $required));
     $this->assertFalse($this->object->isValid('      ', $required));
     $this->assertTrue($this->object->isValid('12', $required));
     $this->assertTrue($this->object->isValid('12345', $required));
     //Minlenght without required
     $this->assertTrue($this->object->isValid('', array(Flag::MINLENGHT => 3)));
 }
Exemplo n.º 5
0
 protected function setUp()
 {
     Memory::clear('debug');
     LoggerApp::clear();
 }
Exemplo n.º 6
0
define('DEVELOPMENT', 'DEVELOPMENT');
define('PRODUCTION', 'PRODUCTION');
define("SERVER_MODE", $appconfig['geral']['mode']);
define("DOMAIN", $appconfig['geral']['url']);
define("DOMAIN_EMAIL", $appconfig['geral']['domain']);
define("PAGE_TITLE_PREFIX", $appconfig['geral']['prefix']);
$databaseconfig = parse_ini_file("app/conf/database.{$env}.ini", true);
define("DATABASE_DRIVER", getValueFromArray($databaseconfig['database'], 'driver'), '');
define("DATABASE_NAME", getValueFromArray($databaseconfig['database'], 'dbname', ''));
define("DATABASE_HOST", getValueFromArray($databaseconfig['database'], 'host', ''));
define("DATABASE_PORT", getValueFromArray($databaseconfig['database'], 'port', ''));
define("DATABASE_USER", getValueFromArray($databaseconfig['database'], 'user', ''));
define("DATABASE_PASSWORD", getValueFromArray($databaseconfig['database'], 'password'), '');
//Default CSS and JS
foreach ($appconfig['html']['js'] as $jsfile) {
    MemoryPage::addJs($jsfile);
}
foreach ($appconfig['html']['css'] as $cssfile) {
    MemoryPage::addCss($cssfile);
}
//Set Memory values
foreach ($appconfig['memory'] as $k => $v) {
    Memory::set($k, $v);
}
//Error lib - http://logging.apache.org/log4php/quickstart.html
//require_once PATH_MYFRAME . '/src/LoggerApp.php';
Logger::configure(PATH_DEFAULT . '/conf/php4log.xml');
// pra rodar o instalador precisa comentar essas 3 linhas
if (file_exists(PATH_APP . '/appbootstrap.php')) {
    require_once PATH_APP . '/appbootstrap.php';
}
Exemplo n.º 7
0
 /**
  * Return/Create the Logger object
  * 
  * Levels:
  * $log->trace("Finest-grained informational events.");
  * $log->debug("Fine-grained informational events that are most useful to debug an application.");
  * $log->info("Informational messages that highlight the progress of the application at coarse-grained level.");
  * $log->warn("Potentially harmful situations which still allow the application to continue running.");
  * $log->error("Error events that might still allow the application to continue running.");
  * $log->fatal("Very severe error events that will presumably lead the application to abort.");
  * 
  * @return Logger
  */
 public static function log()
 {
     if (defined("TEST_OR_INSTALL")) {
         require_once PATH_LOCAL . '/../vendor/apache/log4php/src/main/php/Logger.php';
     } else {
         require_once PATH_LOCAL . '/vendor/apache/log4php/src/main/php/Logger.php';
     }
     if (Memory::get('debug', false)) {
         return Logger::getLogger('debug');
     } else {
         return Logger::getLogger('main');
     }
 }