| 1 |
lars |
1 |
--TEST--
|
|
|
2 |
multiple.phpt: Unit tests for 'Validate.php' without extension (credit card)
|
|
|
3 |
--FILE--
|
|
|
4 |
<?php
|
|
|
5 |
// $Id: multiple.phpt 234544 2007-04-26 16:29:40Z toggg $
|
|
|
6 |
// Validate test script
|
|
|
7 |
$noYes = array('NO', 'YES');
|
|
|
8 |
|
|
|
9 |
require_once 'Validate.php';
|
|
|
10 |
|
|
|
11 |
$types = array(
|
|
|
12 |
'myemail' => array('type' => 'email'),
|
|
|
13 |
'myemail1' => array('type' => 'email'),
|
|
|
14 |
'no' => array('type' => 'number', array('min' => -8, 'max' => -7)),
|
|
|
15 |
'teststring' => array('type' => 'string', array('format' => VALIDATE_ALPHA)),
|
|
|
16 |
'test10844' => array('type' => 'string', 'format' => '0-9'),
|
|
|
17 |
'date' => array('type' => 'date', array('format' => '%d%m%Y'))
|
|
|
18 |
);
|
|
|
19 |
|
|
|
20 |
$data = array(
|
|
|
21 |
array(
|
|
|
22 |
'myemail' => 'webmaster@google.com', // OK
|
|
|
23 |
'myemail1' => 'webmaster.@google.com', // NOK
|
|
|
24 |
'no' => '-8', // OK
|
|
|
25 |
'teststring' => 'PEARrocks', // OK
|
|
|
26 |
'test10844' => 'dsfasdf', // NOK
|
|
|
27 |
'date' => '12121996' // OK
|
|
|
28 |
)
|
|
|
29 |
);
|
|
|
30 |
|
|
|
31 |
echo "Test Validate_Multiple\n";
|
|
|
32 |
echo "**********************\n\n";
|
|
|
33 |
foreach ($data as $value) {
|
|
|
34 |
$res = Validate::multiple($value, $types);
|
|
|
35 |
foreach ($value as $fld=>$val) {
|
|
|
36 |
echo "{$fld}: {$val} =>".(isset($res[$fld])? $noYes[$res[$fld]]: 'null')."\n";
|
|
|
37 |
}
|
|
|
38 |
echo "*****************************************\n\n";
|
|
|
39 |
}
|
|
|
40 |
|
|
|
41 |
?>
|
|
|
42 |
--EXPECT--
|
|
|
43 |
Test Validate_Multiple
|
|
|
44 |
**********************
|
|
|
45 |
|
|
|
46 |
myemail: webmaster@google.com =>YES
|
|
|
47 |
myemail1: webmaster.@google.com =>NO
|
|
|
48 |
no: -8 =>YES
|
|
|
49 |
teststring: PEARrocks =>YES
|
|
|
50 |
test10844: dsfasdf =>NO
|
|
|
51 |
date: 12121996 =>YES
|
|
|
52 |
*****************************************
|
|
|
53 |
|