EmailAddressTest.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_Validate
  17. * @subpackage UnitTests
  18. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id$
  21. */
  22. if (!defined('PHPUnit_MAIN_METHOD')) {
  23. define('PHPUnit_MAIN_METHOD', 'Zend_Validate_EmailAddressTest::main');
  24. }
  25. /**
  26. * @see Zend_Validate_EmailAddress
  27. */
  28. require_once 'Zend/Validate/EmailAddress.php';
  29. /**
  30. * @category Zend
  31. * @package Zend_Validate
  32. * @subpackage UnitTests
  33. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  34. * @license http://framework.zend.com/license/new-bsd New BSD License
  35. * @group Zend_Validate
  36. */
  37. class Zend_Validate_EmailAddressTest extends PHPUnit_Framework_TestCase
  38. {
  39. /**
  40. * Default instance created for all test methods
  41. *
  42. * @var Zend_Validate_EmailAddress
  43. */
  44. protected $_validator;
  45. /**
  46. * Runs this test suite
  47. *
  48. * @return void
  49. */
  50. public static function main()
  51. {
  52. $suite = new PHPUnit_Framework_TestSuite(__CLASS__);
  53. $result = PHPUnit_TextUI_TestRunner::run($suite);
  54. }
  55. /**
  56. * Creates a new Zend_Validate_EmailAddress object for each test method
  57. *
  58. * @return void
  59. */
  60. public function setUp()
  61. {
  62. $this->_validator = new Zend_Validate_EmailAddress();
  63. }
  64. /**
  65. * Ensures that a basic valid e-mail address passes validation
  66. *
  67. * @return void
  68. */
  69. public function testBasic()
  70. {
  71. $this->assertTrue($this->_validator->isValid('username@example.com'));
  72. }
  73. /**
  74. * Ensures that localhost address is valid
  75. *
  76. * @return void
  77. */
  78. public function testLocalhostAllowed()
  79. {
  80. $validator = new Zend_Validate_EmailAddress(Zend_Validate_Hostname::ALLOW_ALL);
  81. $this->assertTrue($validator->isValid('username@localhost'));
  82. }
  83. /**
  84. * Ensures that local domain names are valid
  85. *
  86. * @return void
  87. */
  88. public function testLocaldomainAllowed()
  89. {
  90. $validator = new Zend_Validate_EmailAddress(Zend_Validate_Hostname::ALLOW_ALL);
  91. $this->assertTrue($validator->isValid('username@localhost.localdomain'));
  92. }
  93. /**
  94. * Ensures that IP hostnames are valid
  95. *
  96. * @return void
  97. */
  98. public function testIPAllowed()
  99. {
  100. $validator = new Zend_Validate_EmailAddress(Zend_Validate_Hostname::ALLOW_DNS | Zend_Validate_Hostname::ALLOW_IP);
  101. $valuesExpected = array(
  102. array(Zend_Validate_Hostname::ALLOW_DNS, true, array('bob@212.212.20.4')),
  103. array(Zend_Validate_Hostname::ALLOW_DNS, false, array('bob@localhost'))
  104. );
  105. foreach ($valuesExpected as $element) {
  106. foreach ($element[2] as $input) {
  107. $this->assertEquals($element[1], $validator->isValid($input), implode("\n", $validator->getMessages()));
  108. }
  109. }
  110. }
  111. /**
  112. * Ensures that validation fails when the local part is missing
  113. *
  114. * @return void
  115. */
  116. public function testLocalPartMissing()
  117. {
  118. $this->assertFalse($this->_validator->isValid('@example.com'));
  119. $messages = $this->_validator->getMessages();
  120. $this->assertEquals(1, count($messages));
  121. $this->assertContains('local-part@hostname', current($messages));
  122. }
  123. /**
  124. * Ensures that validation fails and produces the expected messages when the local part is invalid
  125. *
  126. * @return void
  127. */
  128. public function testLocalPartInvalid()
  129. {
  130. $this->assertFalse($this->_validator->isValid('Some User@example.com'));
  131. $messages = $this->_validator->getMessages();
  132. $this->assertEquals(3, count($messages));
  133. $this->assertContains('Some User', current($messages));
  134. $this->assertContains('dot-atom', current($messages));
  135. $this->assertContains('Some User', next($messages));
  136. $this->assertContains('quoted-string', current($messages));
  137. $this->assertContains('Some User', next($messages));
  138. $this->assertContains('not a valid local part', current($messages));
  139. }
  140. /**
  141. * Ensures that no validation failure message is produced when the local part follows the quoted-string format
  142. *
  143. * @return void
  144. */
  145. public function testLocalPartQuotedString()
  146. {
  147. $this->assertTrue($this->_validator->isValid('"Some User"@example.com'));
  148. $messages = $this->_validator->getMessages();
  149. $this->assertTrue(is_array($messages));
  150. $this->assertEquals(0, count($messages));
  151. }
  152. /**
  153. * Ensures that validation fails when the hostname is invalid
  154. *
  155. * @return void
  156. */
  157. public function testHostnameInvalid()
  158. {
  159. $this->assertFalse($this->_validator->isValid('username@ example . com'));
  160. $messages = $this->_validator->getMessages();
  161. $this->assertThat(count($messages), $this->greaterThanOrEqual(1));
  162. $this->assertContains('not a valid hostname', current($messages));
  163. }
  164. /**
  165. * Ensures that quoted-string local part is considered valid
  166. *
  167. * @return void
  168. */
  169. public function testQuotedString()
  170. {
  171. $emailAddresses = array(
  172. '""@domain.com', // Optional
  173. '" "@domain.com', // x20
  174. '"!"@domain.com', // x21
  175. '"\""@domain.com', // \" (escaped x22)
  176. '"#"@domain.com', // x23
  177. '"$"@domain.com', // x24
  178. '"Z"@domain.com', // x5A
  179. '"["@domain.com', // x5B
  180. '"\\\"@domain.com', // \\ (escaped x5C)
  181. '"]"@domain.com', // x5D
  182. '"^"@domain.com', // x5E
  183. '"}"@domain.com', // x7D
  184. '"~"@domain.com', // x7E
  185. '"username"@example.com',
  186. '"bob%jones"@domain.com',
  187. '"bob jones"@domain.com',
  188. '"bob@jones"@domain.com',
  189. '"[[ bob ]]"@domain.com',
  190. '"jones"@domain.com'
  191. );
  192. foreach ($emailAddresses as $input) {
  193. $this->assertTrue($this->_validator->isValid($input), "$input failed to pass validation:\n"
  194. . implode("\n", $this->_validator->getMessages()));
  195. }
  196. }
  197. /**
  198. * Ensures that quoted-string local part is considered invalid
  199. *
  200. * @return void
  201. */
  202. public function testInvalidQuotedString()
  203. {
  204. $emailAddresses = array(
  205. "\"\x00\"@example.com",
  206. "\"\x01\"@example.com",
  207. "\"\x1E\"@example.com",
  208. "\"\x1F\"@example.com",
  209. '"""@example.com', // x22 (not escaped)
  210. '"\"@example.com', // x5C (not escaped)
  211. "\"\x7F\"@example.com",
  212. );
  213. foreach ($emailAddresses as $input) {
  214. $this->assertFalse($this->_validator->isValid($input), "$input failed to pass validation:\n"
  215. . implode("\n", $this->_validator->getMessages()));
  216. }
  217. }
  218. /**
  219. * Ensures that validation fails when the e-mail is given as for display,
  220. * with angle brackets around the actual address
  221. *
  222. * @return void
  223. */
  224. public function testEmailDisplay()
  225. {
  226. $this->assertFalse($this->_validator->isValid('User Name <username@example.com>'));
  227. $messages = $this->_validator->getMessages();
  228. $this->assertThat(count($messages), $this->greaterThanOrEqual(3));
  229. $this->assertContains('not a valid hostname', current($messages));
  230. $this->assertContains('cannot match TLD', next($messages));
  231. $this->assertContains('does not appear to be a valid local network name', next($messages));
  232. }
  233. /**
  234. * Ensures that the validator follows expected behavior for valid email addresses
  235. *
  236. * @return void
  237. */
  238. public function testBasicValid()
  239. {
  240. $emailAddresses = array(
  241. 'bob@domain.com',
  242. 'bob.jones@domain.co.uk',
  243. 'bob.jones.smythe@domain.co.uk',
  244. 'BoB@domain.museum',
  245. 'bobjones@domain.info',
  246. "B.O'Callaghan@domain.com",
  247. 'bob+jones@domain.us',
  248. 'bob+jones@domain.co.uk',
  249. 'bob@some.domain.uk.com',
  250. 'bob@verylongdomainsupercalifragilisticexpialidociousspoonfulofsugar.com'
  251. );
  252. foreach ($emailAddresses as $input) {
  253. $this->assertTrue($this->_validator->isValid($input), "$input failed to pass validation:\n"
  254. . implode("\n", $this->_validator->getMessages()));
  255. }
  256. }
  257. /**
  258. * Ensures that the validator follows expected behavior for invalid email addresses
  259. *
  260. * @return void
  261. */
  262. public function testBasicInvalid()
  263. {
  264. $emailAddresses = array(
  265. '',
  266. 'bob
  267. @domain.com',
  268. 'bob jones@domain.com',
  269. '.bobJones@studio24.com',
  270. 'bobJones.@studio24.com',
  271. 'bob.Jones.@studio24.com',
  272. '"bob%jones@domain.com',
  273. 'bob@verylongdomainsupercalifragilisticexpialidociousaspoonfulofsugar.com',
  274. 'bob+domain.com',
  275. 'bob.domain.com',
  276. 'bob @domain.com',
  277. 'bob@ domain.com',
  278. 'bob @ domain.com',
  279. 'Abc..123@example.com'
  280. );
  281. foreach ($emailAddresses as $input) {
  282. $this->assertFalse($this->_validator->isValid($input), implode("\n", $this->_validator->getMessages()) . $input);
  283. }
  284. }
  285. /**
  286. * Ensures that the validator follows expected behavior for valid email addresses with complex local parts
  287. *
  288. * @return void
  289. */
  290. public function testComplexLocalValid()
  291. {
  292. $emailAddresses = array(
  293. 'Bob.Jones@domain.com',
  294. 'Bob.Jones!@domain.com',
  295. 'Bob&Jones@domain.com',
  296. '/Bob.Jones@domain.com',
  297. '#Bob.Jones@domain.com',
  298. 'Bob.Jones?@domain.com',
  299. 'Bob~Jones@domain.com'
  300. );
  301. foreach ($emailAddresses as $input) {
  302. $this->assertTrue($this->_validator->isValid($input));
  303. }
  304. }
  305. /**
  306. * Ensures that the validator follows expected behavior for checking MX records
  307. *
  308. * @return void
  309. */
  310. public function testMXRecords()
  311. {
  312. if (!defined('TESTS_ZEND_VALIDATE_ONLINE_ENABLED')
  313. || !constant('TESTS_ZEND_VALIDATE_ONLINE_ENABLED')
  314. ) {
  315. $this->markTestSkipped('Testing MX records only works when a valid internet connection is available');
  316. return;
  317. }
  318. $validator = new Zend_Validate_EmailAddress(Zend_Validate_Hostname::ALLOW_DNS, true);
  319. // Are MX checks supported by this system?
  320. if (!$validator->validateMxSupported()) {
  321. $this->markTestSkipped('Testing MX records is not supported with this configuration');
  322. return;
  323. }
  324. $valuesExpected = array(
  325. array(true, array('Bob.Jones@zend.com', 'Bob.Jones@php.net')),
  326. array(false, array('Bob.Jones@bad.example.com', 'Bob.Jones@anotherbad.example.com'))
  327. );
  328. foreach ($valuesExpected as $element) {
  329. foreach ($element[1] as $input) {
  330. $this->assertEquals($element[0], $validator->isValid($input), implode("\n", $validator->getMessages()));
  331. }
  332. }
  333. // Try a check via setting the option via a method
  334. unset($validator);
  335. $validator = new Zend_Validate_EmailAddress();
  336. $validator->setValidateMx(true);
  337. foreach ($valuesExpected as $element) {
  338. foreach ($element[1] as $input) {
  339. $this->assertEquals($element[0], $validator->isValid($input), implode("\n", $validator->getMessages()));
  340. }
  341. }
  342. }
  343. /**
  344. * Test changing hostname settings via EmailAddress object
  345. *
  346. * @return void
  347. */
  348. public function testHostnameSettings()
  349. {
  350. $validator = new Zend_Validate_EmailAddress();
  351. // Check no IDN matching
  352. $validator->getHostnameValidator()->setValidateIdn(false);
  353. $valuesExpected = array(
  354. array(false, array('name@b�rger.de', 'name@h�llo.de', 'name@h�llo.se'))
  355. );
  356. foreach ($valuesExpected as $element) {
  357. foreach ($element[1] as $input) {
  358. $this->assertEquals($element[0], $validator->isValid($input), implode("\n", $validator->getMessages()));
  359. }
  360. }
  361. // Check no TLD matching
  362. $validator->getHostnameValidator()->setValidateTld(false);
  363. $valuesExpected = array(
  364. array(true, array('name@domain.xx', 'name@domain.zz', 'name@domain.madeup'))
  365. );
  366. foreach ($valuesExpected as $element) {
  367. foreach ($element[1] as $input) {
  368. $this->assertEquals($element[0], $validator->isValid($input), implode("\n", $validator->getMessages()));
  369. }
  370. }
  371. }
  372. /**
  373. * Ensures that getMessages() returns expected default value (an empty array)
  374. *
  375. * @return void
  376. */
  377. public function testGetMessages()
  378. {
  379. $this->assertEquals(array(), $this->_validator->getMessages());
  380. }
  381. /**
  382. * @group ZF-2861
  383. */
  384. public function testHostnameValidatorMessagesShouldBeTranslated()
  385. {
  386. require_once 'Zend/Validate/Hostname.php';
  387. $hostnameValidator = new Zend_Validate_Hostname();
  388. require_once 'Zend/Translate.php';
  389. $translations = array(
  390. 'hostnameIpAddressNotAllowed' => 'hostnameIpAddressNotAllowed translation',
  391. 'hostnameUnknownTld' => 'hostnameUnknownTld translation',
  392. 'hostnameDashCharacter' => 'hostnameDashCharacter translation',
  393. 'hostnameInvalidHostnameSchema' => 'hostnameInvalidHostnameSchema translation',
  394. 'hostnameUndecipherableTld' => 'hostnameUndecipherableTld translation',
  395. 'hostnameInvalidHostname' => 'hostnameInvalidHostname translation',
  396. 'hostnameInvalidLocalName' => 'hostnameInvalidLocalName translation',
  397. 'hostnameLocalNameNotAllowed' => 'hostnameLocalNameNotAllowed translation',
  398. );
  399. $translator = new Zend_Translate('array', $translations);
  400. $this->_validator->setTranslator($translator)->setHostnameValidator($hostnameValidator);
  401. $this->_validator->isValid('_XX.!!3xx@0.239,512.777');
  402. $messages = $hostnameValidator->getMessages();
  403. $found = false;
  404. foreach ($messages as $code => $message) {
  405. if (array_key_exists($code, $translations)) {
  406. $this->assertEquals($translations[$code], $message);
  407. $found = true;
  408. break;
  409. }
  410. }
  411. $this->assertTrue($found);
  412. }
  413. /**
  414. * @group ZF-4888
  415. */
  416. public function testEmailsExceedingLength()
  417. {
  418. $emailAddresses = array(
  419. 'thislocalpathoftheemailadressislongerthantheallowedsizeof64characters@domain.com',
  420. 'bob@verylongdomainsupercalifragilisticexpialidociousspoonfulofsugarverylongdomainsupercalifragilisticexpialidociousspoonfulofsugarverylongdomainsupercalifragilisticexpialidociousspoonfulofsugarverylongdomainsupercalifragilisticexpialidociousspoonfulofsugarexpialidociousspoonfulofsugar.com',
  421. );
  422. foreach ($emailAddresses as $input) {
  423. $this->assertFalse($this->_validator->isValid($input));
  424. }
  425. }
  426. /**
  427. * @group ZF-4352
  428. */
  429. public function testNonStringValidation()
  430. {
  431. $this->assertFalse($this->_validator->isValid(array(1 => 1)));
  432. }
  433. /**
  434. * @group ZF-7490
  435. */
  436. public function testSettingHostnameMessagesThroughEmailValidator()
  437. {
  438. $translations = array(
  439. 'hostnameIpAddressNotAllowed' => 'hostnameIpAddressNotAllowed translation',
  440. 'hostnameUnknownTld' => 'hostnameUnknownTld translation',
  441. 'hostnameDashCharacter' => 'hostnameDashCharacter translation',
  442. 'hostnameInvalidHostnameSchema' => 'hostnameInvalidHostnameSchema translation',
  443. 'hostnameUndecipherableTld' => 'hostnameUndecipherableTld translation',
  444. 'hostnameInvalidHostname' => 'hostnameInvalidHostname translation',
  445. 'hostnameInvalidLocalName' => 'hostnameInvalidLocalName translation',
  446. 'hostnameLocalNameNotAllowed' => 'hostnameLocalNameNotAllowed translation',
  447. );
  448. $this->_validator->setMessages($translations);
  449. $this->_validator->isValid('_XX.!!3xx@0.239,512.777');
  450. $messages = $this->_validator->getMessages();
  451. $found = false;
  452. foreach ($messages as $code => $message) {
  453. if (array_key_exists($code, $translations)) {
  454. $this->assertEquals($translations[$code], $message);
  455. $found = true;
  456. break;
  457. }
  458. }
  459. $this->assertTrue($found);
  460. }
  461. /**
  462. * Testing initializing with several options
  463. */
  464. public function testInstanceWithOldOptions()
  465. {
  466. $handler = set_error_handler(array($this, 'errorHandler'), E_USER_NOTICE);
  467. $validator = new Zend_Validate_EmailAddress();
  468. $options = $validator->getOptions();
  469. $this->assertEquals(Zend_Validate_Hostname::ALLOW_DNS, $options['allow']);
  470. $this->assertFalse($options['mx']);
  471. try {
  472. $validator = new Zend_Validate_EmailAddress(Zend_Validate_Hostname::ALLOW_ALL, true, new Zend_Validate_Hostname(Zend_Validate_Hostname::ALLOW_ALL));
  473. $options = $validator->getOptions();
  474. $this->assertEquals(Zend_Validate_Hostname::ALLOW_ALL, $options['allow']);
  475. $this->assertTrue($options['mx']);
  476. set_error_handler($handler);
  477. } catch (Zend_Exception $e) {
  478. $this->markTestSkipped('MX not available on this system');
  479. }
  480. }
  481. /**
  482. * Testing setOptions
  483. */
  484. public function testSetOptions()
  485. {
  486. $this->_validator->setOptions(array('messages' => array(Zend_Validate_EmailAddress::INVALID => 'TestMessage')));
  487. $messages = $this->_validator->getMessageTemplates();
  488. $this->assertEquals('TestMessage', $messages[Zend_Validate_EmailAddress::INVALID]);
  489. $oldHostname = $this->_validator->getHostnameValidator();
  490. $this->_validator->setOptions(array('hostname' => new Zend_Validate_Hostname(Zend_Validate_Hostname::ALLOW_ALL)));
  491. $hostname = $this->_validator->getHostnameValidator();
  492. $this->assertNotEquals($oldHostname, $hostname);
  493. }
  494. /**
  495. * Testing setMessage
  496. */
  497. public function testSetSingleMessage()
  498. {
  499. $messages = $this->_validator->getMessageTemplates();
  500. $this->assertNotEquals('TestMessage', $messages[Zend_Validate_EmailAddress::INVALID]);
  501. $this->_validator->setMessage('TestMessage');
  502. $messages = $this->_validator->getMessageTemplates();
  503. $this->assertEquals('TestMessage', $messages[Zend_Validate_EmailAddress::INVALID]);
  504. }
  505. /**
  506. * Testing setMessage for all messages
  507. *
  508. * @group ZF-10690
  509. */
  510. public function testSetMultipleMessages()
  511. {
  512. $messages = $this->_validator->getMessageTemplates();
  513. $this->assertNotEquals('TestMessage', $messages[Zend_Validate_EmailAddress::INVALID]);
  514. $this->_validator->setMessage('TestMessage');
  515. $messages = $this->_validator->getMessageTemplates();
  516. $this->assertEquals('TestMessage', $messages[Zend_Validate_EmailAddress::INVALID]);
  517. $this->assertEquals('TestMessage', $messages[Zend_Validate_EmailAddress::INVALID_FORMAT]);
  518. $this->assertEquals('TestMessage', $messages[Zend_Validate_EmailAddress::DOT_ATOM]);
  519. }
  520. /**
  521. * Testing validateMxSupported
  522. */
  523. public function testValidateMxSupported()
  524. {
  525. if (function_exists('getmxrr')) {
  526. $this->assertTrue($this->_validator->validateMxSupported());
  527. } else {
  528. $this->assertFalse($this->_validator->validateMxSupported());
  529. }
  530. }
  531. /**
  532. * Testing getValidateMx
  533. */
  534. public function testGetValidateMx()
  535. {
  536. $this->assertFalse($this->_validator->getValidateMx());
  537. }
  538. /**
  539. * Testing getDeepMxCheck
  540. */
  541. public function testGetDeepMxCheck()
  542. {
  543. $this->assertFalse($this->_validator->getDeepMxCheck());
  544. }
  545. /**
  546. * Testing getDomainCheck
  547. */
  548. public function testGetDomainCheck()
  549. {
  550. $this->assertTrue($this->_validator->getDomainCheck());
  551. }
  552. public function errorHandler($errno, $errstr)
  553. {
  554. if (strstr($errstr, 'deprecated')) {
  555. $this->multipleOptionsDetected = true;
  556. }
  557. }
  558. /**
  559. * @group ZF-11239
  560. */
  561. public function testNotSetHostnameValidator()
  562. {
  563. $hostname = $this->_validator->getHostnameValidator();
  564. $this->assertTrue($hostname instanceof Zend_Validate_Hostname);
  565. }
  566. /**
  567. * @group GH-62
  568. */
  569. public function testIdnHostnameInEmaillAddress()
  570. {
  571. if (version_compare(PHP_VERSION, '5.3.0', '<')) {
  572. $this->markTestSkipped('idn_to_ascii() is available in intl in PHP 5.3.0+');
  573. }
  574. $validator = new Zend_Validate_EmailAddress();
  575. $validator->setValidateMx(true);
  576. $this->assertTrue($validator->isValid('testmail@faß.de'));
  577. }
  578. /**
  579. * @group GH-517
  580. */
  581. public function testNonReservedIp()
  582. {
  583. $validator = new Zend_Validate_EmailAddress(Zend_Validate_Hostname::ALLOW_IP);
  584. $this->assertTrue($validator->isValid('bob@192.162.33.24'));
  585. }
  586. }
  587. if (PHPUnit_MAIN_METHOD == 'Zend_Validate_EmailAddressTest::main') {
  588. Zend_Validate_EmailAddressTest::main();
  589. }