Sie sind hier : sebastian1012.bplaced.net/ homepage-neu / Kurze-Scripte-und-Codeschnipsel / index.php

Zurück


Der Quellcode dazu


setResultFilter("html");

//Outputvariante Form
$t->setOutputVariant("Form");

$t->start('check phpcheck Instance');
$t->check($t instanceof phpcheck, true);

//check without ->start
$result = 5 + 4;
$expect = 9;
$t->check($result, $result === $expect);

$t->start('check: ok, simple addition');
$result = 5 + 4;
$expect = 9;
$t->check($result, $result === $expect);

$t->start('check: error');
$result = 3 + 4;
$expect = 9;
$t->check($result, $result === $expect);

$t->start('checkEqual:ok, simple addition');
$result = 5 + 4;
$expect = 9;
$t->checkEqual($result, $expect);

$t->start('checkEqual:error');
$result = 5 + 4;
$expect = "9";
//error: $result is a integer, string expect 
$t->checkEqual($result, $expect);

$t->start('checkEqual:error');
$result = 1/3;
$expect = 0.33333333;
$t->checkEqual($result, $expect);

$t->start('checkEqual: ok, compare with delta');
$result = 1/3;
$expect = 0.33333333;
$delta =  0.00000001;
$t->checkEqual($result, $expect,"", $delta);

$t->start('checkEqualHex: ok');
$result = "abc\n";
$expect = "abc\x0a";
$t->checkEqualHex($result, $expect);

$t->start('checkHTML: ok');
$t->setResultFilter("html");
$result = "Fett";
$t->checkHTML($result);

$t->start('checkHTML: false, invalid HTML');
$t->setResultFilter();  //default
$result = "Fett";
$t->checkHTML($result);

$t->start('checkMultiple: ');
$userFct = function($par1,$par2){
  return $par1 * $par2;
};
$tests = array(
  array(4,5,20),  //par1,par2, expect
  array(-2,5,-10),  //par1,par2, expect
);
$t->checkMultiple($userFct,$tests);

$t->startOutput('start Output: 1');
echo "A Message";
$t->checkOutput("A Message");

$t->startOutput('start Output: 2');
echo "

A Message

"; $t->checkHTML(null, "A Message"); $t->startOutput('Output a input text field1'); $t->setResultFilter("html"); echo ''; $t->checkHTML(null); $t->start('check $_POST'); $result = $_POST; $testOk = ( empty($_POST) //first Call OR isset($_POST["field1"]) //after Send Form ); $t->check($result, $testOk); /* * End Tests */ //output as table echo $t->gethtml();

Add Comment

* Required information
1000
Powered by Commentics

Comments (1)

Gravatar
Admin
Sascha65says...

Die Canvas Balken Uhr ist ja mal Fett