Example #1
0
 /**
  * @depends testGetRules
  */
 public function testAddRules()
 {
     $form = new Form(array('first_name' => array()));
     $form->addRules(array('last_name' => array()));
     $this->assertEquals(array('first_name' => array(), 'last_name' => array()), $form->getRules());
     $form = new Form(array('first_name' => array('required')));
     $form->addRules(array('first_name' => array('min_length' => 2)));
     $this->assertEquals(array('first_name' => array('required' => true, 'min_length' => 2)), $form->getRules());
     $form = new Form(array('first_name' => array('min_length' => 2)));
     $form->addRules(array('first_name' => array('required')));
     $this->assertEquals(array('first_name' => array('required' => true, 'min_length' => 2)), $form->getRules());
 }
Example #2
0
// CARGO LOS PARAMETROS DE CONFIGURACION.
// ---------------------------------------------------------------
$config = sfYaml::load('../config/config.yml');
$app = $config['config']['app'];
// ---------------------------------------------------------------
// ACTIVAR EL AUTOLOADER DE CLASES Y FICHEROS A INCLUIR
// ---------------------------------------------------------------
define("APP_PATH", $_SERVER['DOCUMENT_ROOT'] . $app['path'] . "/");
include_once "../" . $app['framework'] . "Autoloader.class.php";
Autoloader::setCacheFilePath(APP_PATH . 'tmp/class_path_cache.txt');
Autoloader::excludeFolderNamesMatchingRegex('/^CVS|\\..*$/');
Autoloader::setClassPaths(array('../' . $app['framework'], '../entities/', '../lib/'));
spl_autoload_register(array('Autoloader', 'loadClass'));
// Crear el lote nuevo
$formulario = new Form('Lotes');
$rules = $formulario->getRules();
unset($formulario);
$lote = new Lotes();
$lote->setIDArticulo($_GET['idArticulo']);
$lote->setLote($_GET['lote']);
$lote->setFechaFabricacion($_GET['fFabricacion']);
$lote->setFechaCaducidad($_GET['fCaducidad']);
if ($lote->valida($rules)) {
    $idLote = $lote->create();
}
$errores = $lote->getErrores();
if (count($errores)) {
    foreach ($errores as $error) {
        $tag .= $error . "\n";
    }
}