Location: PHPKode > scripts > cmysql_mset > cmysql_mset/test.php
<?

#: Test de la clase CMySQL_MSet.
#: |[|mArKitos|]|  ]]xP[[ Style 

?><HTML>
	<HEAD>
		<TITLE>Test De La Clase CMySQL_MSet</TITLE>
	</HEAD>
	
	<BODY BGCOLOR="#FFCC00"><?

	#: Incluimos clase y creamos un objeto instanciando la clase.
	include ("./CMySQL_MSet.class.inc");
    $Exito = $Fallo = 0;

	#: TEST 1
	echo "<H3> TEST 1 => ";
	$TCMySQL = new CMySQL_MSet ('cmysql_mset', 'cmysql_mset', 'cmysql_mset', 'localhost');
	$TCMySQL->OpenConnection();
	#: Preparamos sentencia y la ejecutamos
	$Test_SQL = "Select * From test";
	$Resultado = $TCMySQL -> ExecSQL($Test_SQL);
	if ($Resultado != 0){
		echo " OK</H3>\n";
		$Exito += 1;
	} else {
		$Fallo += 1;
     	echo " Failed</H3>\n";
	}
	#: Cerramos conexion
	$TCMySQL -> CloseConnection();

	#: TEST 2
	echo "<H3><H3> TEST 2 => ";
	$TCMySQL = new CMySQL_MSet ('cmysql_mset', 'cmysql_mset', 'cmysql_mset', 'localhost');
	$TCMySQL->OpenConnection();
	#: Preparamos sentencia y la ejecutamos
	$Test_SQL = "Select nombres From test Where nombres='Markitos'";
	$Resultado = $TCMySQL -> ExecSQL($Test_SQL);
	if ($Resultado != 0){
		echo " OK</H3>\n";
		$Exito += 1;
	} else {
     	echo " Failed</H3>\n";
		$Fallo += 1;
	}
	#: Cerramos conexion
	$TCMySQL -> CloseConnection();				


	#: TEST 3
	echo "<H3> TEST 3 => ";
	$TCMySQL = new CMySQL_MSet ('cmysql_mset', 'cmysql_mset', 'cmysql_mset', 'localhost');
	$TCMySQL->OpenConnection();
	$Resultado = $TCMySQL->SearchIn("test", "id, nombres","markitos", "1");
	if (count ($Resultado) == 1){
		echo " OK </H3>\n";
		$Exito += 1;
	} else {
     	echo " Failed </H3>\n";
		$Fallo += 1;
	}
	#: Cerramos conexion
	$TCMySQL -> CloseConnection();		

	#: TEST 4
	echo "<H3> TEST 4 => ";
	$TCMySQL = new CMySQL_MSet ('cmysql_mset', 'cmysql_mset', 'cmysql_mset', 'localhost');
	$TCMySQL->OpenConnection();
	$Resultado = $TCMySQL->SearchIn("test", "id, nombres", "pepitos", "2");
	if (count ($Resultado) == 1){
		echo " Failed </H3>\n";
		$Fallo += 1;
	} else {
     	echo " OK </H3>\n";
		$Exito += 1;
	}
	#: Cerramos conexion
	$TCMySQL -> CloseConnection();		

	#: TEST 5
	echo "<H3> TEST 5 => ";
	$TCMySQL = new CMySQL_MSet ('cmysql_mset', 'cmysql_mset', 'cmysql_mset', 'localhost');
	$TCMySQL->OpenConnection();
	$Resultado = $TCMySQL->SearchIn("test", "id, nombres", "I", "2");
	if (count ($Resultado) == 3){
		echo " OK </H3>\n";
		$Exito += 1;
	} else {
     	echo " Failed </H3>\n";
		$Fallo += 1;
	}
	#: Cerramos conexion
	$TCMySQL -> CloseConnection();		

	#: TEST 6
	echo "<H3> TEST 6 => ";
	$TCMySQL = new CMySQL_MSet ('cmysql_mset', 'cmysql_mset', 'cmysql_mset', 'localhost');
	$TCMySQL->OpenConnection();
	$Resultado = $TCMySQL->SearchIn("test", "id, nombres", "pEpItO", "1");
	if ($Resultado[0] == 2){
		echo " OK </H3>\n";
		$Exito += 1;
	} else {
     	echo " Failed </H3>\n";
		$Fallo += 1;
	}
	#: Cerramos conexion
	$TCMySQL -> CloseConnection();		
	
	#: TEST 7
	echo "<H3> TEST 7 => ";
	$TCMySQL = new CMySQL_MSet ('cmysql_mset', 'cmysql_mset', 'cmysql_mset', 'localhost');
	$TCMySQL->OpenConnection();
	$Resultado = $TCMySQL->SearchAdv("test", "id, nombres", "pEpItO", "1", "1", "0", "");
	if (!$Resultado){
		echo " OK </H3>\n";
		$Exito += 1;
	} else {
     	echo " Failed </H3>\n";
		$Fallo += 1;
	}
	#: Cerramos conexion
	$TCMySQL -> CloseConnection();			

	#: TEST 8
	echo "<H3> TEST 8 => ";
	$TCMySQL = new CMySQL_MSet ('cmysql_mset', 'cmysql_mset', 'cmysql_mset', 'localhost');
	$TCMySQL->OpenConnection();
	$Resultado = $TCMySQL->SearchAdv("test", "id, nombres", "Pepito", "1", "1", "0", "");
	if ($Resultado[0] == 2){
		echo " OK </H3>\n";
		$Exito += 1;
	} else {
    echo " Failed </H3>\n";
		$Fallo += 1;
	}
	#: Cerramos conexion
	$TCMySQL -> CloseConnection();

	#: TEST 9
	echo "<H3> TEST 9 => ";
	$TCMySQL = new CMySQL_MSet ('cmysql_mset', 'cmysql_mset', 'cmysql_mset', 'localhost');
	$TCMySQL->OpenConnection();
	$Resultado = $TCMySQL->SearchAdv("test", "id, nombres", "Pep", "0", "1", "0", "");
	if ($Resultado[0] == 2){
		echo " OK </H3>\n";
		$Exito += 1;
	} else {
    echo " Failed </H3>\n";
		$Fallo += 1;
	}
	#: Cerramos conexion
	$TCMySQL -> CloseConnection();

#: TEST 10
	echo "<H3> TEST 10 => ";
	$TCMySQL = new CMySQL_MSet ('cmysql_mset', 'cmysql_mset', 'cmysql_mset', 'localhost');
	$TCMySQL->OpenConnection();
	$Resultado = $TCMySQL->SearchAdv("test", "id, nombres", "pEpItO", "1", "1", "0", "");
	if (!$Resultado){
		echo " OK </H3>\n";
		$Exito += 1;
	} else {
    echo " Failed </H3>\n";
		$Fallo += 1;
	}
	#: Cerramos conexion
	$TCMySQL -> CloseConnection();

#: TEST 11
	echo "<H3> TEST 11 => ";
	$TCMySQL = new CMySQL_MSet ('cmysql_mset', 'cmysql_mset', 'cmysql_mset', 'localhost');
	$TCMySQL->OpenConnection();
	$Clausula = "WHERE id='1'";
	$Resultado = $TCMySQL->SearchAdv("test", "id, nombres", "mArKitos", "1", "0", "1", "$Clausula");
	if ($Resultado[0] == 1){
		echo " OK </H3>\n";
		$Exito += 1;
	} else {
    echo " Failed </H3>\n";
		$Fallo += 1;
	}
	#: Cerramos conexion
	$TCMySQL -> CloseConnection();

	
	?><BR><HR><BR><?
	
	$Porc = ($Exito*100)/11;
	if (eregi ("([0-9]+)\.[0-9]*",$Porc, $Items)){
		$Porc =  $Items[1];
	}
	
	echo "<H3>Test Pasados...........: $Exito</H3>\n";
	echo "<H3>Test Fallidos..........: $Fallo</H3><HR>\n";	
	echo "<H1>Porcentaje De Exito: ", $Porc , "% <H1><HR>\n";


	?></BODY>
</HTML><?

?>
Return current item: cmysql_mset