| 1 |
lars |
1 |
--TEST--
|
|
|
2 |
multicard.phpt: Unit tests for 'Validate.php' : mutltiple() with credit card
|
|
|
3 |
This test needs Validate_Finance_CreditCard installed to be enabled
|
|
|
4 |
--SKIPIF--
|
|
|
5 |
<?php
|
|
|
6 |
// $Id: multicard.phpt 185969 2005-05-07 15:23:21Z toggg $
|
|
|
7 |
if (!@include_once 'Validate/Finance/CreditCard.php') {
|
|
|
8 |
echo ('skip Test skipped as Validate_Finance_CreditCard not installed');
|
|
|
9 |
}
|
|
|
10 |
?>
|
|
|
11 |
--FILE--
|
|
|
12 |
<?php
|
|
|
13 |
// Validate test script
|
|
|
14 |
$noYes = array('NO', 'YES');
|
|
|
15 |
|
|
|
16 |
require_once 'Validate.php';
|
|
|
17 |
|
|
|
18 |
$types = array(
|
|
|
19 |
'myemail' => array('type' => 'email'),
|
|
|
20 |
'myemail1' => array('type' => 'email'),
|
|
|
21 |
'no' => array('type' => 'number', array('min' => -8, 'max' => -7)),
|
|
|
22 |
'teststring' => array('type' => 'string', array('format' => VALIDATE_ALPHA)),
|
|
|
23 |
'date' => array('type' => 'date', array('format' => '%d%m%Y')),
|
|
|
24 |
'cc_no' => array('type' => 'Finance_CreditCard_number')
|
|
|
25 |
);
|
|
|
26 |
|
|
|
27 |
$data = array(
|
|
|
28 |
array(
|
|
|
29 |
'myemail' => 'webmaster@google.com', // OK
|
|
|
30 |
'myemail1' => 'webmaster.@google.com', // NOK
|
|
|
31 |
'no' => '-8', // OK
|
|
|
32 |
'teststring' => 'PEARrocks', // OK
|
|
|
33 |
'date' => '12121996', // OK
|
|
|
34 |
'cc_no' => '6762 1955 1506 1813' // OK
|
|
|
35 |
)
|
|
|
36 |
);
|
|
|
37 |
|
|
|
38 |
echo "Test Validate_Multiple\n";
|
|
|
39 |
echo "**********************\n\n";
|
|
|
40 |
foreach ($data as $value) {
|
|
|
41 |
$res = Validate::multiple($value, $types);
|
|
|
42 |
foreach ($value as $fld=>$val) {
|
|
|
43 |
echo "{$fld}: {$val} =>".(isset($res[$fld])? $noYes[$res[$fld]]: 'null')."\n";
|
|
|
44 |
}
|
|
|
45 |
echo "*****************************************\n\n";
|
|
|
46 |
}
|
|
|
47 |
|
|
|
48 |
?>
|
|
|
49 |
--EXPECT--
|
|
|
50 |
Test Validate_Multiple
|
|
|
51 |
**********************
|
|
|
52 |
|
|
|
53 |
myemail: webmaster@google.com =>YES
|
|
|
54 |
myemail1: webmaster.@google.com =>NO
|
|
|
55 |
no: -8 =>YES
|
|
|
56 |
teststring: PEARrocks =>YES
|
|
|
57 |
date: 12121996 =>YES
|
|
|
58 |
cc_no: 6762 1955 1506 1813 =>YES
|
|
|
59 |
*****************************************
|
|
|
60 |
|