svn: /pear/packages/Validate/trunk/tests/ email.phpt email_domaincheck.phpt uri.phpt uri_domaincheck.phpt

From: Date: Tue, 15 Mar 2011 00:28:59 +0000
Subject: svn: /pear/packages/Validate/trunk/tests/ email.phpt email_domaincheck.phpt uri.phpt uri_domaincheck.phpt
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-61439@lists.php.net to get a copy of this message
dufuz Tue, 15 Mar 2011 00:28:59 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=309242 Log: Implemented Request #17963: Allow test suite to run without DNS resolver [patch by remicollet, adjustments by dufuz] Bug: http://pear.php.net/bugs/17963 (unknown) Changed paths: U pear/packages/Validate/trunk/tests/email.phpt A pear/packages/Validate/trunk/tests/email_domaincheck.phpt U pear/packages/Validate/trunk/tests/uri.phpt A pear/packages/Validate/trunk/tests/uri_domaincheck.phpt Modified: pear/packages/Validate/trunk/tests/email.phpt =================================================================== --- pear/packages/Validate/trunk/tests/email.phpt 2011-03-15 00:27:44 UTC (rev 309241) +++ pear/packages/Validate/trunk/tests/email.phpt 2011-03-15 00:28:59 UTC (rev 309242) @@ -1,5 +1,5 @@ --TEST-- -email.phpt: Unit tests for +email.phpt: Unit tests for email validation --FILE-- <?php // $Id$ @@ -10,9 +10,6 @@ echo "Test Validate_Email\n"; $emails = array( - // Try dns lookup - array('pear-general@lists.php.net', true), // OK - array('example@fluffffffrefrffrfrfrfrfrfr.is', false), // OK // with out the dns lookup 'example@fluffffffrefrffrfrfrfrfrfr.is', // OK @@ -116,8 +113,6 @@ ?> --EXPECT-- Test Validate_Email -pear-general@lists.php.net: with domain check : YES -example@fluffffffrefrffrfrfrfrfrfr.is: without domain check : YES example@fluffffffrefrffrfrfrfrfrfr.is: YES davidc@php.net: YES example (though bad)@example.com: YES Added: pear/packages/Validate/trunk/tests/email_domaincheck.phpt =================================================================== --- pear/packages/Validate/trunk/tests/email_domaincheck.phpt (rev 0) +++ pear/packages/Validate/trunk/tests/email_domaincheck.phpt 2011-03-15 00:28:59 UTC (rev 309242) @@ -0,0 +1,49 @@ +--TEST-- +domaincheck.phpt: Unit tests for email validation with dns checks +--SKIPIF-- +<?php +if (!function_exists('checkdnsrr') || !checkdnsrr('php.net', 'A')) { + echo 'skip Missing checkdnsrr()'; +} +?> +--FILE-- +<?php +// $Id: email.phpt 276490 2009-02-26 09:32:16Z amir $ +// Validate test script +$noYes = array('NO', 'YES'); +require 'Validate.php'; + +echo "Test Validate_Email\n"; + +$emails = array( + // Try dns lookup + array('pear-general@lists.php.net', true), // OK + array('example@fluffffffrefrffrfrfrfrfrfr.is', true) // OK + ); + +list($version) = explode(".", phpversion(), 2); +foreach ($emails as $email) { + if (is_array($email)) { + echo "{$email[0]}:"; + if (!is_array($email[1])) { + echo " with". ($email[1] ? '' : 'out') . ' domain check :'; + } + echo ' ' . $noYes[Validate::email($email[0], $email[1])]."\n"; + } else { + echo "{$email}: "; + if ((int)$version > 4) { + try { + echo $noYes[Validate::email($email)]."\n"; + } catch (Exception $e) { + echo $e->getMessage()."\n"; + } + } else { + echo $noYes[Validate::email($email)]."\n"; + } + } +} +?> +--EXPECT-- +Test Validate_Email +pear-general@lists.php.net: with domain check : YES +example@fluffffffrefrffrfrfrfrfrfr.is: with domain check : NO \ No newline at end of file Modified: pear/packages/Validate/trunk/tests/uri.phpt =================================================================== --- pear/packages/Validate/trunk/tests/uri.phpt 2011-03-15 00:27:44 UTC (rev 309241) +++ pear/packages/Validate/trunk/tests/uri.phpt 2011-03-15 00:28:59 UTC (rev 309242) @@ -29,14 +29,9 @@ '//-.com', // NOK '//example.-com', // NOK '//-example.com-', // NOK - // Try dns lookup - array('//php.net', 'domain_check' => true), // OK - array('//example.gor', 'domain_check' => true), // NOK // Try schemes lookup array('//example.org', 'allowed_schemes' => array('ftp', 'http')), // NOK array('http://example.org', 'allowed_schemes' => array('ftp', 'http')), // OK - array('http://php.net', 'allowed_schemes' => array('ftp', 'http'), - 'domain_check' => true), // OK array( '//example.org/tkik-wkik_rss.php?ver=2http://www.hyperlecture.info//http://www.hyperlecture.info/accueil', 'strict' => ''), // OK @@ -83,11 +78,8 @@ //-.com: NO //example.-com: NO //-example.com-: NO -//php.net: schemes() with domain check : YES -//example.gor: schemes() with domain check : NO //example.org: schemes(ftp,http) without domain check : NO http://example.org: schemes(ftp,http) without domain check : YES -http://php.net: schemes(ftp,http) with domain check : YES //example.org/tkik-wkik_rss.php?ver=2http://www.hyperlecture.info//http://www.hyperlecture.info/accueil: schemes() without domain check : (strict : ) YES http://domain.tld//: YES http://domain.tld/.: YES Added: pear/packages/Validate/trunk/tests/uri_domaincheck.phpt =================================================================== --- pear/packages/Validate/trunk/tests/uri_domaincheck.phpt (rev 0) +++ pear/packages/Validate/trunk/tests/uri_domaincheck.phpt 2011-03-15 00:28:59 UTC (rev 309242) @@ -0,0 +1,48 @@ +--TEST-- +domaincheck.phpt: Unit tests for uri validation with dns check +--SKIPIF-- +<?php +if (!function_exists('checkdnsrr') || !checkdnsrr('php.net', 'A')) { + echo 'skip Missing checkdnsrr()'; +} +?> +--FILE-- +<?php +// $Id: $ +// Validate test script +$noYes = array('NO', 'YES'); +require 'Validate.php'; + +echo "Test Validate::uri()\n"; + +$uris = array( + // Try dns lookup + array('//php.net', 'domain_check' => true), // OK + array('//example.gor', 'domain_check' => true), // NOK + // Try schemes lookup + array('http://php.net', 'allowed_schemes' => array('ftp', 'http'), + 'domain_check' => true) // OK + ); + +foreach ($uris as $uri) { + if (is_array($uri)) { + $options = $uri; + unset($options[0]); + echo "{$uri[0]}: schemes(" . + (isset($options['allowed_schemes']) ? + implode(',', $options['allowed_schemes']) : '') .") with". + (isset($options['domain_check']) && $options['domain_check'] ? + '' : 'out') . ' domain check : '. + (isset($options['strict']) ? "(strict : {$options['strict']}) " : '') . + $noYes[Validate::uri($uri[0], $options )]."\n"; + } else { + echo "{$uri}: ". + $noYes[Validate::uri($uri)]."\n"; + } +} +?> +--EXPECT-- +Test Validate::uri() +//php.net: schemes() with domain check : YES +//example.gor: schemes() with domain check : NO +http://php.net: schemes(ftp,http) with domain check : YES

« previous php.pear.cvs (#61439) next »