Samx Here
n1udSecurity


Server : Apache
System : Linux webd348.cluster026.gra.hosting.ovh.net 5.15.148-ovh-vps-grsec-zfs-classid #1 SMP Thu Feb 8 09:41:04 UTC 2024 x86_64
User : hednacluml ( 122243)
PHP Version : 8.3.9
Disable Function : _dyuweyrj4,_dyuweyrj4r,dl
Directory :  /home/hednacluml/jobs/plugins/auto/saisies/tests/saisies_afficher_si/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/hednacluml/jobs/plugins/auto/saisies/tests/saisies_afficher_si/saisies_evaluer_afficher_si.php
<?php
/**
 * Test unitaire de la fonction saisies_evaluer_afficher_si
 * du fichier ../plugins/saisies/inc/saisies_afficher_si_php.php
 *
 * genere automatiquement par TestBuilder
 * le 2018-12-20 23:52
 */

	$test = 'saisies_evaluer_afficher_si';
	$remonte = "";
	while (!is_file($remonte."test.inc") and !is_dir($remonte.'ecrire/'))
		$remonte = $remonte."../";
	foreach ([$remonte."test.inc", $remonte."tests/test.inc", $remonte."tests/tests/legacy/test.inc"] as $f) {
		if (is_file($f)){
			require $f;
			break;
		}
	}
	if (!defined('_SPIP_TEST_INC')) {
		die('Impossible de trouver test.inc depuis ' .getcwd());
	}

	find_in_path("inc/saisies.php",'',true);
	find_in_path("saisies_fonctions.php",'',true);
	// chercher la fonction si elle n'existe pas
	if (!function_exists($f='saisies_evaluer_afficher_si')){
		find_in_path("inc/filtres.php",'',true);
		$f = chercher_filtre($f);
	}


	// Preparer les requests
	set_request("input_1", "toto@domaine.ext");
	set_request("case_1", "oui");
	set_request("case_2", "");
	set_request("a", "a");
	set_request("b", "b");
	set_request("c", "c");
	set_request("d", "d");
	set_request("zero", '0');
	set_request('url', 'http://www.spip.net');
	set_request("tableau_1", array("a", "b", "c"));
	set_request("tableau_2", array("e", "f", "g"));
	set_request("nombre", "20");
	set_request("nombre_negatif", '-20');
	set_request('cascade', array('a'=>'a'));
	saisies_set_request('cascade_bis/a', 'a');
	include_spip("inc/config");
	ecrire_config("tests_saisies_config", array("a" => "a", "sous" => array("b" => "b", "c" => "c")));
	// Tableau de saisies
	$saisies = array (
		array (
			'saisie' => 'input',
			'options' =>
			array (
				'label' => 'Ligne de texte',
				'type' => 'text',
				'afficher_si' => '!@truc@',
				'size' => '40',
				'autocomplete' => 'defaut',
				'nom' => 'input_1',
			),
		),
	);
	//
	// hop ! on y va
	//
	$err = tester_fun($f, essais_saisies_evaluer_afficher_si(saisies_lister_par_nom($saisies)));
	effacer_config('tests_saisies_config');

	// si le tableau $err est pas vide ca va pas
	if ($err) {
		die ('<dl>' . join('', $err) . '</dl>');
	}

	echo "OK";

	// On va tester essentiellement sur des set_request, le cas $env étant normalement identique

	function essais_saisies_evaluer_afficher_si($saisies_par_nom){
		$essais = array (
			'simple_egalite' =>
			array (
				0 => true,
				1 => "@a@ == 'a'"
			),
			'simple_inegalite' =>
			array (
				0 => false,
				1 => "@a@ == 'b'"
			),
			'double_egalite' =>
			array (
				0 => true,
				1 => "@a@ == 'a' && @b@ == 'b'"
			),
			'double_egalite_fausse' =>
			array (
				0 => false,
				1 => "@a@ == 'a' && @b@ == 'c'"
			),
			'egalite_alternative' =>
			array (
				0 => true,
				1 => "@a@ == 'a' || @b@ == 'c'"
			),
			'egalite_alternative_fausse' =>
			array (
				0 => false,
				1 => "@a@ == 'b' || @b@ == 'c'"
			),
			'presence_tableau_alternative' =>
			array (
				0 => true,
				1 => "@tableau_1@ IN 'b' || @tableau_2@ == 'c'"
			),
			'presence_tableau_cumulative' =>
			array (
				0 => false,
				1 => "@tableau_1@ IN 'b' && @tableau_2@ == 'c'"
			),
			'absence_tableau_cumulative' =>
			array (
				0 => false,
				1 => "@tableau_1@ !IN 'b' && @tableau_2@ !IN 'c'"
			),
			'absence_tableau_alternative' =>
			array (
				0 => true,
				1 => "@tableau_1@ !IN 'b' || @tableau_2@ !IN 'c'"
			),
			'absence_tableau_alternative_espacement' =>
			array (
				0 => true,
				1 => "@tableau_1@ !   IN 'b' || @tableau_2@ !  IN 'c'"
			),
			'champ_uniquement' => array(
				0 => true,
				1 => "@case_1@"
			),
			'champ_uniquement_faux' => array(
				0 => false,
				1 => "@case_2@"
			),
			'champ_uniquement_negation' => array(
				0 => true,
				1 => "!@case_2@"
			),
			'champ_uniquement_negation_faux' => array(
				0 => false,
				1 => "!@case_1@"
			),
			'nombre_superieur_vrai' => array(
				0 => true,
				1 => "@nombre@ > 10"
			),
			'nombre_superieur_faux' => array(
				0 => false,
				1 => "@nombre@ > 100"
			),
			'nombre_superieur_egal_vrai' => array(
				0 => true,
				1 => "@nombre@ >= 20"
			),
			'nombre_superieur_egal_faux' => array(
				0 => false,
				1 => "@nombre@ >= 100"
			),
			'nombre_inferieur_vrai' => array(
				0 => true,
				1 => "@nombre@ < 100"
			),
			'nombre_inferieur_faux' => array(
				0 => false,
				1 => "@nombre@ < 10"
			),
			'nombre_inferieur_egal_vrai' => array(
				0 => true,
				1 => "@nombre@ <= 20"
			),
			'nombre_inferieur_egal_faux' => array(
				0 => false,
				1 => "@nombre@ <= 10"
			),
			'nombre_negatif_inferieur_vrai' => array(
				0 => true,
				1 => '@nombre_negatif@ > -30'
			),
			'nombre_negatif_inferieur_faux' => array(
				0 => false,
				1 => '@nombre_negatif@ > -10'
			),
			'false' => array(
				0 => false,
				1 => 'false'
			),
			'true' => array(
				0 => true,
				1 => 'true'
			),
			'anti_false' => array(
				0 => true,
				1 => '!false'
			),
			'anti_true' => array(
				0 => false,
				1 => '!true'
			),
			'hack' => array(
				0 => true,
				1 => "spip_log('s') || @input_1@=='s')"
			),
			'premier_niveau' => array(
				0 => true,
				1 => '@config:tests_saisies_config:a@==\'a\'',
			),
			'second_niveau' => array(
				0 => false,
				1 => '@config:tests_saisies_config:sous:b@==\'c\'',
			),
			'premier_niveau_nie' => array(
				0 => false,
				1 => '!@config:tests_saisies_config:a@==\'a\'',
			),
			'second_niveau_nie' => array(
				0 => true,
				1 => '!@config:tests_saisies_config:sous:b@==\'c\'',
			),
			'second_niveau_bis' => array(
				0 => true,
				1 => '@config:tests_saisies_config:sous:c@==\'c\'',
			),
			'second_niveau_et' => array(
				0 => false,
				1 => '@config:tests_saisies_config:sous:c@==\'c\' && @config:tests_saisies_config:sous:b@==\'c\'',
			),
			'second_niveau_ou' => array(
				0 => true,
				1 => '@config:tests_saisies_config:sous:c@==\'c\' || @config:tests_saisies_config:sous:b@==\'c\'',
			),
			'plugin_actif' => array(
				0 =>  true,
				1 => '@plugin:saisies@'
			),
			'plugin_inactif' => array(
				0 => false,
				1 => '@plugin:tartempion_de_test@' // en espérant que personne ne nomme un plugin tartempion_de_test
			),
			'plugin_actif_nie' => array(
				0 =>  false,
				1 => '!@plugin:saisies@'
			),
			'plugin_inactif_nie' => array(
				0 => true,
				1 => '!@plugin:tartempion_de_test@' // en espérant que personne ne nomme un plugin tartempion_de_test
			),
			'hack' => array(
				0 => true,
				1 => "spip_log('s') || @input_1@=='s')"
			),
			'cascade' => array(
				0 => true,
				1 => '@cascade[a]@ == \'a\''
			),
			'cascade_slash' => array(
				0 => true,
				1 => '@cascade/a@ == \'a\''
			),
			'cascade_bis' => array(
				0 => true,
				1 => '@cascade_bis/a@ == \'a\''
			),
			'total_tableau_sup' => array(
				0 => true,
				1 => '@tableau_1@:TOTAL > 2'
			),
			'total_tableau_inf' => array(
				0 => false,
				1 => '@tableau_1@:TOTAL < 2'
			),
			'match' => array(
				'0' => true,
				'1' => '@input_1@ MATCH \'/domaine.ext$/\'',
			),
			'match_negation' => array(
				'0' => false,
				'1' => '!@input_1@ MATCH \'/domaine.ext$/\'',
			),
			'not_match' => array(
				'0' => false,
				'1' => '@input_1@ !MATCH \'/domaine.ext$/\'',
			),
			'not_match_negation' => array(
				'0' =>  true,
				'1' => '!@input_1@ !MATCH \'/domaine.ext$/\'',
			),
			'match_slash' => array(
				0 => true,
				1 => '@url@ MATCH "/^https?:\/\//i"'
			),
			'match_slash_bis' => array(
				0 => true,
				1 => '@url@ MATCH "/^HTTP:\/\//i"'
			),
			'zero_rapide' => array(
				0 => true,
				1 => '@zero@',
			),
			'champ_inexistant' => array(
				'0' =>  true,
				'1' => '@champ_inexistant@ == \'s\'',
				'2' => null,
				'3' => $saisies_par_nom
			),
			'champ_existant' => array(
				'0' =>  false,
				'1' => '@input_1@ == \'s\'',
				'2' => null,
				'3' => $saisies_par_nom
			)
		);
		return $essais;
	}


?>

SAMX