Skip to content
Snippets Groups Projects
Commit 26b657a1 authored by chris's avatar chris
Browse files

additional unit tests for email addresses

darcs-hash:20070125143848-9b6ab-490215e5feef3a7f6ed268ee03a6cfe4ced1afbb.gz
parent 0a1d30bf
No related branches found
No related tags found
No related merge requests found
<?php
// use no mbstring help here
require_once DOKU_INC.'inc/mail.php';
class mail_isvalid extends UnitTestCase {
function test1(){
// we test multiple cases here - format: string, repl, additional, test
$tests = array();
$tests[] = array('bugs@php.net',true);
$tests[] = array('~someone@somewhere.com',true);
$tests[] = array('no+body.here@somewhere.com.au',true);
$tests[] = array("rfc2822+allthesechars_#*!'`/-={}are.legal@somewhere.com.au",true);
$tests[] = array('bugs@php.net1',false);
$tests[] = array('.bugs@php.net1',false);
$tests[] = array('bu..gs@php.net',false);
$tests[] = array('bugs@php..net',false);
$tests[] = array('bugs@.php.net',false);
$tests[] = array('bugs@php.net.',false);
$tests[] = array('bu(g)s@php.net1',false);
$tests[] = array('bu[g]s@php.net1',false);
foreach($tests as $test){
$this->assertEqual($test[0].'('.mail_isvalid($test[0]).')',$test[0].'('.(int)$test[1].')');
}
}
}
//Setup VIM: ex: et ts=4 enc=utf-8 :
......@@ -11,6 +11,7 @@
require_once DOKU_INC . 'inc/parser/parser.php';
require_once DOKU_INC . 'inc/parser/handler.php';
require_once DOKU_INC . 'inc/events.php';
require_once DOKU_INC . 'inc/mail.php';
//require_once DOKU . 'parser/renderer.php';
//Mock::generate('Doku_Renderer');
......
......@@ -97,6 +97,21 @@ class TestOfDoku_Parser_Links extends TestOfDoku_Parser {
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testEmailRFC2822() {
$this->P->addMode('emaillink',new Doku_Parser_Mode_Emaillink());
$this->P->parse("Foo <~fix+bug's.for/ev{e}r@php.net> Bar");
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n".'Foo ')),
array('emaillink',array("~fix+bug's.for/ev{e}r@php.net", NULL)),
array('cdata',array(' Bar'."\n")),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls);
}
function testInternalLinkOneChar() {
$this->P->addMode('internallink',new Doku_Parser_Mode_InternalLink());
$this->P->parse("Foo [[l]] Bar");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment