Primera aproximación para realizar los tests con phpunit

Configuración cambiada totalmente para optimizar el código y prepararlo para los tests.
Quitada la clave APLICACION del fichero de configuración y de las clases que lo utilizaban (Aportacontenido, InformePDF y PDF_mysql_table)
Creados los esqueletos de test para: Configuración, Menu y Sql
Casi terminado el conjunto de pruebas de Configuración. Pendiente en @todo
This commit is contained in:
2014-03-10 00:17:05 +01:00
parent 26048fc889
commit 8647d08d51
8 changed files with 485 additions and 237 deletions

View File

@@ -118,14 +118,14 @@ class AportaContenido {
public function __call($metodo, $parametros) { public function __call($metodo, $parametros) {
switch ($metodo) { // Dependiendo del método invocado switch ($metodo) { // Dependiendo del método invocado
case 'titulo': // devolvemos el título case 'titulo': // devolvemos el título
return APLICACION; return PROGRAMA.VERSION;
case 'usuario': case 'usuario':
if ($this->registrado) if ($this->registrado)
return "Usuario=$this->usuario"; return "Usuario=$this->usuario";
else else
return ''; return '';
case 'fecha': return $this->fechaActual(); case 'fecha': return $this->fechaActual();
case 'aplicacion': return APLICACION; case 'aplicacion': return PROGRAMA.VERSION;
case 'menu': // el menú case 'menu': // el menú
if ($this->registrado) { if ($this->registrado) {
return $this->miMenu->insertaMenu(); return $this->miMenu->insertaMenu();

View File

@@ -1,231 +1,164 @@
<?php <?php
/**
* @package Inventario /**
* @copyright Copyright (c) 2008, Ricardo Montañana Gómez * @package Inventario
* @license http://www.gnu.org/licenses/gpl-3.0.txt * @copyright Copyright (c) 2008, Ricardo Montañana Gómez
* This file is part of Inventario. * @license http://www.gnu.org/licenses/gpl-3.0.txt
* Inventario is free software: you can redistribute it and/or modify * This file is part of Inventario.
* it under the terms of the GNU General Public License as published by * Inventario is free software: you can redistribute it and/or modify
* the Free Software Foundation, either version 3 of the License, or * it under the terms of the GNU General Public License as published by
* (at your option) any later version. * the Free Software Foundation, either version 3 of the License, or
* * (at your option) any later version.
* Inventario is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * Inventario is distributed in the hope that it will be useful,
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * but WITHOUT ANY WARRANTY; without even the implied warranty of
* GNU General Public License for more details. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* * GNU General Public License for more details.
* You should have received a copy of the GNU General Public License *
* along with Inventario. If not, see <http://www.gnu.org/licenses/>. * You should have received a copy of the GNU General Public License
* * along with Inventario. If not, see <http://www.gnu.org/licenses/>.
*/ *
class Configuracion { */
private $nombreCentro; class Configuracion {
private $numFilas; private $configuracion = "inc/configuracion.inc";
private $estilo; private $confNueva = "inc/configuracion.new";
private $servidor; private $confAnterior = "inc/configuracion.ant";
private $baseDatos; private $datosConf;
private $usuario; //Campos del fichero de configuración que se van a editar.
private $clave; private $lista = array('SERVIDOR', 'BASEDATOS', 'BASEDATOSTEST', 'USUARIO', 'CLAVE', 'CENTRO', 'NUMFILAS', 'ESTILO', 'PLANTILLA', 'COLORLAT', 'COLORFON', 'MYSQLDUMP', 'GZIP');
private $configuracion="inc/configuracion.inc"; private $campos;
private $confNueva="inc/configuracion.new";
private $confAnterior="inc/configuracion.ant"; public function __construct()
private $plantilla; {
private $colorLateral; $this->campos = implode(",", $this->lista);
private $colorFondo; }
private $mysqldump; //comando mysqldump para la copia de seguridad
private $gzip; //comando gzip para comprimir la copia de seguridad //Hecho público para poder efectuar los tests correspondientes.
public function obtieneFichero()
public function ejecuta() {
{ return file_get_contents($this->configuracion, FILE_TEXT);
$fichero=file_get_contents($this->configuracion,FILE_TEXT); }
$datos=explode("\n",$fichero);
$grabar=isset($_POST['servidor']); public function obtieneLista()
if ($grabar) { {
$fsalida=@fopen($this->confNueva,"wb"); return $this->lista;
} }
foreach($datos as $linea) {
if (stripos($linea,"DEFINE")!==false) { public function obtieneDatos($linea, &$clave, &$valor)
$filtro=str_replace("'","",$linea); {
list($clave,$valor)=explode(",",$filtro); $filtro = str_replace("'", "", $linea);
list($resto,$campo)=explode("(",$clave); list($clave, $valor) = explode(",", $filtro);
list($valor,$resto)=explode(")",$valor); list($resto, $campo) = explode("(", $clave);
//$salida.="[$campo]=[$valor]<br>\n"; list($valor, $resto) = explode(")", $valor);
switch ($campo) { list($resto, $clave) = explode("(", $clave);
case 'CENTRO': $valor = trim($valor);
$this->nombreCentro=$valor; }
if ($grabar) {
$linea=str_replace($valor, $_POST['centro'],$linea); public function ejecuta() {
$this->nombreCentro=$_POST['centro']; $fichero = $this->obtieneFichero();
} $datos = explode("\n", $fichero);
break; $grabar = isset($_POST['SERVIDOR']);
case 'NUMFILAS': if ($grabar) {
$this->numFilas=$valor; $fsalida = @fopen($this->confNueva, "wb");
if ($grabar) {
$linea=str_replace($valor, $_POST['filas'],$linea);
$this->numFilas=$_POST['filas'];
}
break;
case 'ESTILO':
$this->estilo=$valor;
if ($grabar) {
$linea=str_replace($valor, $_POST['estilo'],$linea);
$this->estilo=$_POST['estilo'];
}
break;
case 'PLANTILLA':
$this->plantilla=$valor;
if ($grabar) {
$linea=str_replace($valor, $_POST['plantilla'],$linea);
$this->plantilla=$_POST['plantilla'];
}
break;
case 'SERVIDOR':
$this->servidor=$valor;
if ($grabar) {
$linea=str_replace($valor, $_POST['servidor'],$linea);
$this->servidor=$_POST['servidor'];
}
break;
case 'BASEDATOS':
$this->baseDatos=$valor;
if ($grabar) {
$linea=str_replace($valor, $_POST['baseDatos'],$linea);
$this->baseDatos=$_POST['baseDatos'];
}
break;
case 'USUARIO':
$this->usuario=$valor;
if ($grabar) {
$linea=str_replace($valor, $_POST['usuario'],$linea);
$this->usuario=$_POST['usuario'];
}
break;
case 'CLAVE':
$this->clave=$valor;
if ($grabar) {
$linea=str_replace($valor, $_POST['clave'],$linea);
$this->clave=$_POST['clave'];
}
break;
case 'COLORLAT':
$valor = trim($valor);
$this->colorLateral = $valor;
if ($grabar) {
$linea=str_replace($valor,$_POST['colorLat'],$linea);
$this->colorLateral=$_POST['colorLat'];
}
break;
case 'COLORFON':
$valor = trim($valor);
$this->colorFondo = $valor;
if ($grabar) {
$linea=str_replace($valor,$_POST['colorFon'],$linea);
$this->colorFondo=$_POST['colorFon'];
}
break;
case 'MYSQLDUMP':
$valor = trim($valor);
$this->mysqldump = $valor;
if ($grabar) {
$linea=str_replace($valor,$_POST['mysqldump'],$linea);
$this->mysqldump=$_POST['mysqldump'];
}
break;
case 'GZIP':
$valor = trim($valor);
$this->gzip = $valor;
if ($grabar) {
$linea=str_replace($valor,$_POST['gzip'],$linea);
$this->gzip=$_POST['gzip'];
}
break;
}
}
if ($grabar) {
$registro=substr($linea,0,2)=="?>"?$linea:$linea."\n";
fwrite($fsalida,$registro);
}
}
$salida.=$this->formulario();
if ($grabar) {
//$salida.='<label class="warn">Configuraci&oacute;n guardada correctamente</label>';
$salida.='<p class="bg-primary">Configuraci&oacute;n guardada correctamente</p>';
fclose($fsalida);
//unlink($this->confAnterior);
rename($this->configuracion,$this->confAnterior);
rename($this->confNueva,$this->configuracion);
unlink($this->confAnterior);
}
return $salida;
} }
private function formulario() foreach ($datos as $linea) {
{ if (stripos($linea, "DEFINE") !== false) {
$coloresLateral = array( "Original" => "#C4FAEC", "Verde" => "#7bd148", "Azul marino" => "#5484ed", "Azul" => "#a4bdfc", "Turquesa" => "#46d6db", //Comprueba que tenga una definición correcta
"Verde claro" => "#7ae7bf", "Verde oscuro" => "#51b749", "Amarillo" => "#fbd75b", "Naranja" => "#ffb878", "Morado" => "#6633FF", $this->obtieneDatos($linea, $clave, $valor);
"Rojo oscuro" => "#dc2127", "P&uacute;rpura" => "#dbadff", "Gris" => "#e1e1e1"); $this->datosConf[$clave] = $valor;
$coloresFondo = array( "Verde" => "#7bd148", "Azul marino" => "#5484ed", "Azul" => "#a4bdfc", "Turquesa" => "#46d6db", if ($grabar && stripos($this->campos, $clave) !== false) {
"Verde claro" => "#7ae7bf", "Verde oscuro" => "#51b749", "Amarillo" => "#fbd75b", "Naranja" => "#ffb878", "Rojo" => "#ff887c", $linea = str_replace($valor, $_POST[$clave], $linea);
"Rojo oscuro" => "#dc2127", "P&uacute;rpura" => "#dbadff", "Gris" => "#e1e1e1", "Original" => '#F3FEC8'); $this->datosConf[$clave] = $_POST[$clave];
$personal=$this->estilo=="personal"?'selected':' ';
$bluecurve=$this->estilo=="bluecurve"?'selected':' ';
$cristal=$this->estilo=="cristal"?'selected':' ';
$normal=$this->plantilla=="normal"? 'selected':' ';
$bootstrap=$this->plantilla=="bootstrap" ? 'selected':' ';
$salida='<center><div class="col-sm-4 col-md-6"><form name="configura" method="post">';
//$salida.='<p align="center"><table border=1 class="tablaDatos"><tbody>';
$salida.='<p align="center"><table border=2 class="table table-hover"><tbody>';
$salida.='<th colspan=2 class="info"><center><b>Preferencias</b></center></th>';
$salida.='<tr><td>Nombre del Centro</td><td><input type="text" name="centro" value="'.$this->nombreCentro.'" size="30" /></td></tr>';
$salida.='<tr><td>N&uacute;mero de filas</td><td><input type="text" name="filas" value="'.$this->numFilas.'" size="3" /></td></tr>';
$salida.='<tr><td style="vertical-align:middle">Plantilla</td><td><select name="plantilla" class="form-control">';
$salida.='<option value="normal" '.$normal.'>normal</option>';
$salida.='<option '.$bootstrap.'>bootstrap</option></select></td></tr>';
$salida.='<tr><td style="vertical-align:middle">Estilo</td><td><select name="estilo" class="form-control">';
$salida.='<option value="personal" '.$personal.'>personal</option>';
$salida.='<option '.$bluecurve.'>bluecurve</option>';
$salida.='<option '.$cristal.'>cristal</option></select></td></tr>';
$salida.='<tr><td style="vertical-align:middle">Color Lateral (bootstrap)</td><td style="vertical-align:middle"><select name="colorLat" id="colorLat" class="form-control">';
foreach ($coloresLateral as $color => $codigo) {
$selec = "";
if ($this->colorLateral == $codigo) {
$selec = "selected";
} }
$salida.='<option value="'.$codigo.'" '.$selec.' >'.$color.'</option>'; //$salida = "DatosConf=".var_export($this->datosConf, true) . "stripos = " . stripos($campos, "GZIP");
//$salida .= "Post=" . var_export($_POST, true);
} }
$salida.='</select></td></tr>'; if ($grabar) {
$salida.='<tr><td style="vertical-align:middle">Color Fondo (bootstrap)</td><td style="vertical-align:middle"><select name="colorFon" id="colorFon" class="form-control">'; $registro = substr($linea, 0, 2) == "?>" ? $linea : $linea . "\n";
foreach ($coloresFondo as $color => $codigo) { fwrite($fsalida, $registro);
$selec = "";
if ($this->colorFondo == $codigo) {
$selec = "selected";
}
$salida.='<option value="'.$codigo.'" '.$selec.' >'.$color.'</option>';
} }
$salida.='</select></td></tr>'; }
$salida.='<th colspan=2 class="danger"><center><b>Base de datos</b></center></th>'; $salida.=$this->formulario();
$salida.='<tr><td>Servidor</td><td><input type="text" name="servidor" value="'.$this->servidor.'" size="30" /></td></tr>'; if ($grabar) {
$salida.='<tr><td>Base de datos</td><td><input type="text" name="baseDatos" value="'.$this->baseDatos.'" size="30" /></td></tr>'; $salida.='<p class="bg-primary">Configuraci&oacute;n guardada correctamente</p>';
$salida.='<tr><td>Usuario</td><td><input type="text" name="usuario" value="'.$this->usuario.'" size="30" /></td></tr>'; fclose($fsalida);
$salida.='<tr><td>Clave</td><td><input type="text" name="clave" value="'.$this->clave.'" size="30" /></td></tr>'; //unlink($this->confAnterior);
$salida.='<tr><td>mysqldump</td><td><input type="text" name="mysqldump" value="'.$this->mysqldump.'" size="30" /></td></tr>'; rename($this->configuracion, $this->confAnterior);
$salida.='<tr><td>gzip</td><td><input type="text" name="gzip" value="'.$this->gzip.'" size="30" /></td></tr>'; rename($this->confNueva, $this->configuracion);
$salida.='<tr align=center><td colspan=2><input type="submit" class="btn btn-primary" align="center" value="Aceptar" name="aceptar" /></td></tr></p>'; unlink($this->confAnterior);
$salida.='</form></div></center>'; }
$salida.="<script> return $salida;
}
private function formulario() {
$coloresLateral = array("Original" => "#C4FAEC", "Verde" => "#7bd148", "Azul marino" => "#5484ed", "Azul" => "#a4bdfc", "Turquesa" => "#46d6db",
"Verde claro" => "#7ae7bf", "Verde oscuro" => "#51b749", "Amarillo" => "#fbd75b", "Naranja" => "#ffb878", "Morado" => "#6633FF",
"Rojo oscuro" => "#dc2127", "P&uacute;rpura" => "#dbadff", "Gris" => "#e1e1e1");
$coloresFondo = array("Verde" => "#7bd148", "Azul marino" => "#5484ed", "Azul" => "#a4bdfc", "Turquesa" => "#46d6db",
"Verde claro" => "#7ae7bf", "Verde oscuro" => "#51b749", "Amarillo" => "#fbd75b", "Naranja" => "#ffb878", "Rojo" => "#ff887c",
"Rojo oscuro" => "#dc2127", "P&uacute;rpura" => "#dbadff", "Gris" => "#e1e1e1", "Original" => '#F3FEC8');
$personal = $this->datosConf['ESTILO'] == "personal" ? 'selected' : ' ';
$bluecurve = $this->datosConf['ESTILO'] == "bluecurve" ? 'selected' : ' ';
$cristal = $this->datosConf['ESTILO'] == "cristal" ? 'selected' : ' ';
$normal = $this->datosConf['PLANTILLA'] == "normal" ? 'selected' : ' ';
$bootstrap = $this->datosConf['PLANTILLA'] == "bootstrap" ? 'selected' : ' ';
$salida = '<center><div class="col-sm-4 col-md-6"><form name="configura" method="post">';
//$salida.='<p align="center"><table border=1 class="tablaDatos"><tbody>';
$salida.='<p align="center"><table border=2 class="table table-hover"><tbody>';
$salida.='<th colspan=2 class="info"><center><b>Preferencias</b></center></th>';
$salida.='<tr><td>Nombre del Centro</td><td><input type="text" name="CENTRO" value="' . $this->datosConf['CENTRO'] . '" size="30" /></td></tr>';
$salida.='<tr><td>N&uacute;mero de filas</td><td><input type="text" name="NUMFILAS" value="' . $this->datosConf['NUMFILAS'] . '" size="3" /></td></tr>';
$salida.='<tr><td style="vertical-align:middle">Plantilla</td><td><select name="PLANTILLA" class="form-control">';
$salida.='<option value="normal" ' . $normal . '>normal</option>';
$salida.='<option ' . $bootstrap . '>bootstrap</option></select></td></tr>';
$salida.='<tr><td style="vertical-align:middle">Estilo</td><td><select name="ESTILO" class="form-control">';
$salida.='<option value="personal" ' . $personal . '>personal</option>';
$salida.='<option ' . $bluecurve . '>bluecurve</option>';
$salida.='<option ' . $cristal . '>cristal</option></select></td></tr>';
$salida.='<tr><td style="vertical-align:middle">Color Lateral (bootstrap)</td><td style="vertical-align:middle"><select name="COLORLAT" id="COLORLAT" class="form-control">';
foreach ($coloresLateral as $color => $codigo) {
$selec = "";
if (trim($this->datosConf['COLORLAT']) == $codigo) {
$selec = "selected";
}
$salida.='<option value="' . $codigo . '" ' . $selec . ' >' . $color . '</option>';
}
$salida.='</select></td></tr>';
$salida.='<tr><td style="vertical-align:middle">Color Fondo (bootstrap)</td><td style="vertical-align:middle"><select name="COLORFON" id="COLORFON" class="form-control">';
foreach ($coloresFondo as $color => $codigo) {
$selec = "";
if (trim($this->datosConf['COLORFON']) == $codigo) {
$selec = "selected";
}
$salida.='<option value="' . $codigo . '" ' . $selec . ' >' . $color . '</option>';
}
$salida.='</select></td></tr>';
$salida.='<th colspan=2 class="danger"><center><b>Base de datos</b></center></th>';
$salida.='<tr><td>Servidor</td><td><input type="text" name="SERVIDOR" value="' . $this->datosConf['SERVIDOR'] . '" size="30" /></td></tr>';
$salida.='<tr><td>Base de datos</td><td><input type="text" name="BASEDATOS" value="' . $this->datosConf['BASEDATOS'] . '" size="30" /></td></tr>';
$salida.='<tr><td>Base de datos Tests</td><td><input type="text" name="BASEDATOSTEST" value="' . $this->datosConf['BASEDATOSTEST'] . '" size="30" /></td></tr>';
$salida.='<tr><td>Usuario</td><td><input type="text" name="USUARIO" value="' . $this->datosConf['USUARIO'] . '" size="30" /></td></tr>';
$salida.='<tr><td>Clave</td><td><input type="text" name="CLAVE" value="' . $this->datosConf['CLAVE'] . '" size="30" /></td></tr>';
$salida.='<tr><td>mysqldump</td><td><input type="text" name="MYSQLDUMP" value="' . $this->datosConf['MYSQLDUMP'] . '" size="30" /></td></tr>';
$salida.='<tr><td>gzip</td><td><input type="text" name="GZIP" value="' . $this->datosConf['GZIP'] . '" size="30" /></td></tr>';
$salida.='<tr align=center><td colspan=2><input type="submit" class="btn btn-primary" align="center" value="Aceptar" name="aceptar" /></td></tr></p>';
$salida.='</form></div></center>';
$salida.="<script>
$(document).ready(function() { $(document).ready(function() {
$('select[name=" .'"colorFon"'. "]').on('change', function() { $('select[name=" . '"COLORFON"' . "]').on('change', function() {
$(document.body).css('background-color', $('select[name=" .'"colorFon"'. "]').val()); $(document.body).css('background-color', $('select[name=" . '"COLORFON"' . "]').val());
$('.main').css('background-color', $('select[name=" .'"colorFon"'. "]').val()); $('.main').css('background-color', $('select[name=" . '"COLORFON"' . "]').val());
}); });
$('select[name=" .'"colorLat"'. "]').on('change', function() { $('select[name=" . '"COLORLAT"' . "]').on('change', function() {
$('.sidebar').css('background-color', $('select[name=" .'"colorLat"'. "]').val()); $('.sidebar').css('background-color', $('select[name=" . '"COLORLAT"' . "]').val());
}); });
$('select[name=". '"colorLat"' ."]').simplecolorpicker({theme: 'glyphicons'}); $('select[name=" . '"COLORLAT"' . "]').simplecolorpicker({theme: 'glyphicons'});
$('select[name=" .'"colorFon"' ."]').simplecolorpicker({theme: 'glyphicons'}); $('select[name=" . '"COLORFON"' . "]').simplecolorpicker({theme: 'glyphicons'});
}); });
</script>"; </script>";
//$salida.="<br>fondo=[$this->colorFondo] lateral=[$this->colorLateral]<br>"; return $salida;
return $salida;
}
} }
}
?> ?>

View File

@@ -55,7 +55,7 @@ class InformePDF {
//echo $def->Titulo.$def->Cabecera; //echo $def->Titulo.$def->Cabecera;
$this->pdf->Open(); $this->pdf->Open();
$this->pdf->setAuthor(AUTOR,true); $this->pdf->setAuthor(AUTOR,true);
$creador = CENTRO . " " . APLICACION; $creador = CENTRO . " " . PROGRAMA.VERSION;
$this->pdf->setCreator(html_entity_decode($creador),true); $this->pdf->setCreator(html_entity_decode($creador),true);
$this->pdf->setSubject($this->def->Titulo,true); $this->pdf->setSubject($this->def->Titulo,true);
$this->pdf->setAutoPageBreak(true, 10); $this->pdf->setAutoPageBreak(true, 10);

View File

@@ -61,7 +61,7 @@ class Pdf_mysql_table extends Fpdf
//Titulo //Titulo
$fecha=strftime("%d-%b-%Y %H:%M"); $fecha=strftime("%d-%b-%Y %H:%M");
$this->SetFont('Arial','',8); $this->SetFont('Arial','',8);
$this->Cell(0,4,html_entity_decode(CENTRO . " " . APLICACION,ENT_COMPAT | ENT_HTML401,'ISO-8859-1'),0,1,'L'); $this->Cell(0,4,html_entity_decode(CENTRO . " " . PROGRAMA . VERSION,ENT_COMPAT | ENT_HTML401,'ISO-8859-1'),0,1,'L');
$this->SetFont('Arial','',18); $this->SetFont('Arial','',18);
$this->Cell(0,6,utf8_decode($this->titulo),0,1,'C'); $this->Cell(0,6,utf8_decode($this->titulo),0,1,'C');
$this->SetFont('Arial','',8); $this->SetFont('Arial','',8);

View File

@@ -20,20 +20,20 @@
* along with Inventario. If not, see <http://www.gnu.org/licenses/>. * along with Inventario. If not, see <http://www.gnu.org/licenses/>.
* *
*/ */
define('AUTOR','Ricardo Montañana Gómez'); define('AUTOR', 'Ricardo Montañana Gómez');
define('SERVIDOR','localhost'); //Ubicación del servidor MySQL define('SERVIDOR', 'localhost'); //Ubicación del servidor MySQL
define('BASEDATOS','Inventario4'); //Nombre de la base de datos. define('BASEDATOS', 'Inventario4'); //Nombre de la base de datos.
define('USUARIO','test'); //Usuario con permisos de lectura/escritura en la base de datos define('BASEDATOSTEST', 'Inventario_test'); //Base de datos para los tests.
define('CLAVE','tset'); //contraseña del usuario. define('USUARIO', 'test'); //Usuario con permisos de lectura/escritura en la base de datos
define('VERSION','1.02'); define('CLAVE', 'tset'); //contraseña del usuario.
define('PROGRAMA','Gesti&oacute;n de Inventario.'); define('VERSION', '1.02');
define('CENTRO','I.E.S.O. Pascual Serrano'); define('PROGRAMA', 'Gesti&oacute;n de Inventario.');
define('APLICACION',PROGRAMA.VERSION); define('CENTRO', 'I.E.S.O. Pascual Serrano');
define('NUMFILAS',17); // Número de registros a mostrar en las pantallas de consulta iniciales define('NUMFILAS', '17'); // Número de registros a mostrar en las pantallas de consulta iniciales
define('PAUSA',2);//Nº segundos de pausa para mostrar mensaje id insertado define('PAUSA', '2');//Nº segundos de pausa para mostrar mensaje id insertado
define('ESTILO','personal'); //Estilo de los iconos de edición (personal, personal, personal) define('ESTILO', 'personal'); //Estilo de los iconos de edición (personal, personal, personal)
define('PLANTILLA','bootstrap'); //Estilo de la plantilla y recursos a utilizar define('PLANTILLA', 'bootstrap'); //Estilo de la plantilla y recursos a utilizar
define('COLORLAT', '#7ae7bf'); //Color de la barra de menú lateral define('COLORLAT', '#46d6db'); //Color de la barra de menú lateral
define('COLORFON', '#a4bdfc'); //Color del fondo de la pantalla define('COLORFON', '#a4bdfc'); //Color del fondo de la pantalla
define('MYSQLDUMP', '/usr/local/bin/mysqldump'); //camino a mysqldump define('MYSQLDUMP', '/usr/local/bin/mysqldump'); //camino a mysqldump
define('GZIP', '/usr/bin/gzip'); //Camino a gzip define('GZIP', '/usr/bin/gzip'); //Camino a gzip

View File

@@ -0,0 +1,71 @@
<?php
require_once 'Configuracion.php';
/**
* Generated by PHPUnit_SkeletonGenerator 1.2.1 on 2014-03-07 at 23:58:14.
*/
class ConfiguracionTest extends PHPUnit_Framework_TestCase {
/**
* @var Configuracion
*/
protected $config;
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
protected function setUp() {
$this->config = new Configuracion;
}
/**
* Tears down the fixture, for example, closes a network connection.
* This method is called after a test is executed.
*/
protected function tearDown() {
}
/**
* @covers Configuracion::ejecuta
*/
public function testEjecuta() {
$this->assertFileExists('inc/Configuracion.inc', "El fichero de configuración no existe");
$permisos = fileperms('inc/Configuracion.inc');
//Comprueba que el propietario o el grupo tengan derecho de escritura
$test = $permisos & 0x0080 || $permisos & 0x0010;
$this->assertTrue($test, "El fichero de configuración no tiene los permisos adecuados");
//Comprueba que existan todas las claves editables en el fichero de configuración.
$fichero = $this->config->obtieneFichero();
$this->assertNotNull($fichero,"El fichero de configuración no se ha leído o no tiene contenido");
$lineas = explode("\n", $fichero);
$campos = $this->config->obtieneLista();
$numero = 0;
$lista = implode(",", $campos);
//var_dump($campos);
//var_dump($lista);
foreach ($lineas as $linea) {
if (stripos($linea, "DEFINE") !== false) {
$this->assertStringMatchesFormat("define('%s', '%s');%S", $linea, "La línea [" . $linea . "] del fichero de configuración no tiene el formato correcto");
$this->config->obtieneDatos($linea, $clave, $valor);
if (stripos($lista, $clave) !== false) {
$this->assertContains($clave, $campos, "El fichero de configuración no tiene la clave [" . $clave . "]");
$numero++;
$verificados[] = $clave;
}
}
}
$this->assertCount($numero, $campos, "No se han verificado todas las claves");
if ($numero != count($campos)) {
echo "Las claves verificadas han sido: \n";
var_export($verificados);
}
// @todo comprobar que la salida incluye una tabla con todos los campos editables.
// @todo comprobar que los valores seleccionados se corresponden co los del fichero
$salida = $this->config->ejecuta();
}
}
?>

43
tests/MenuTest.php Normal file
View File

@@ -0,0 +1,43 @@
<?php
require_once('Menu.php');
/**
* Generated by PHPUnit_SkeletonGenerator 1.2.1 on 2014-03-08 at 17:47:42.
*/
class MenuTest extends PHPUnit_Framework_TestCase
{
/**
* @var Menu
*/
protected $object;
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
protected function setUp()
{
$this->object = new Menu('inc/inventario.menu');
}
/**
* Tears down the fixture, for example, closes a network connection.
* This method is called after a test is executed.
*/
protected function tearDown()
{
}
/**
* @covers Menu::insertaMenu
* @todo Implement testInsertaMenu().
*/
public function testInsertaMenu()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
}
?>

201
tests/SqlTest.php Normal file
View File

@@ -0,0 +1,201 @@
<?php
require_once('inc/configuracion.inc');
require_once('Sql.php');
/**
* Generated by PHPUnit_SkeletonGenerator 1.2.1 on 2014-03-08 at 01:19:34.
*/
class SqlTest extends PHPUnit_Framework_TestCase
{
/**
* @var Sql
*/
protected $bd;
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
* @covers Sql::__construct
* @uses Sql
*/
protected function setUp()
{
$this->bd = new Sql(SERVIDOR, USUARIO, CLAVE, BASEDATOSTEST);
$this->assertFalse($this->bd->error(),"No se ha conectado a la base de datos de pruebas [".BASEDATOSTEST."]");
}
/**
* Tears down the fixture, for example, closes a network connection.
* This method is called after a test is executed.
*/
protected function tearDown()
{
}
/**
* @covers Sql::__destruct
* @todo Implement test__destruct().
*/
public function test__destruct()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @covers Sql::filtra
* @todo Implement testFiltra().
*/
public function testFiltra()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @covers Sql::ejecuta
* @todo Implement testEjecuta().
*/
public function testEjecuta()
{
}
/**
* @covers Sql::procesaResultado
* @todo Implement testProcesaResultado().
*/
public function testProcesaResultado()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @covers Sql::camposResultado
* @todo Implement testCamposResultado().
*/
public function testCamposResultado()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @covers Sql::numeroTuplas
* @todo Implement testNumeroTuplas().
*/
public function testNumeroTuplas()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @covers Sql::error
* @todo Implement testError().
*/
public function testError()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @covers Sql::mensajeError
* @todo Implement testMensajeError().
*/
public function testMensajeError()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @covers Sql::estructura
* @todo Implement testEstructura().
*/
public function testEstructura()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @covers Sql::ultimoId
* @todo Implement testUltimoId().
*/
public function testUltimoId()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @covers Sql::obtieneManejador
* @todo Implement testObtieneManejador().
*/
public function testObtieneManejador()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @covers Sql::comienzaTransaccion
* @todo Implement testComienzaTransaccion().
*/
public function testComienzaTransaccion()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @covers Sql::abortaTransaccion
* @todo Implement testAbortaTransaccion().
*/
public function testAbortaTransaccion()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @covers Sql::confirmaTransaccion
* @todo Implement testConfirmaTransaccion().
*/
public function testConfirmaTransaccion()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
}
?>