3 require_once 'PHPUnit/Framework/TestCase.php';
4 require_once dirname(__FILE__) . '/../../../src/common/include/utils.php';
7 * Simple tests for the utils library.
10 * @author Alain Peyrat <aljeux@free.fr>
11 * @copyright 2009 Alain Peyrat. All rights reserved.
12 * @license GPL License
14 class Utils_Tests extends PHPUnit_Framework_TestCase
17 * test the validate_email function.
19 public function testEmail()
21 $this->assertTrue(validate_email('al@fx.fr'), 'al@fx.fr is a valid email address');
23 $this->assertFalse(validate_email('al @fx.fr'), 'al @fx.fr is not a valid email address');
25 $this->assertFalse(validate_email('al'), 'al is not a valid email address');
29 * test the validate_hostname function.
31 public function testHostname()
33 $this->assertTrue(valid_hostname('myhost.com'), 'myhost.com is a valid hostname.');
35 $this->assertTrue(valid_hostname('myhost.com.'), 'myhost.com. is a valid hostname.');
37 $this->assertFalse(valid_hostname('my host.com'), 'my host.com is not a valid hostname');
39 $this->assertFalse(valid_hostname('O@O'), 'O@O is not a valid hostname');