-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestUser.php
50 lines (46 loc) · 1.63 KB
/
testUser.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
require_once("/usr/lib/php5/simpletest/autorun.php");
require_once("User.php");
class TestUserModel extends UnitTestCase
{
function testCreateUserValidNullNonce()
{
$newEmail = "[email protected]";
$newNonce = null; // null is an excepted value for nonce
$newUserId = 372021;
$user = new Users($newEmail, $newNonce, $newUserId);
$p = "/^[0-9a-fA-F]{64}$/";
$this->assertMatch($user->getNonce(), $p);
$this->assertIsA($user,"User");
$this->assertIsA($user->getEmail(), "string");
$this->assertNull($user->getNonce());
$this->assertIsA($user->getUserId(), "int");
}
function testCreateUserValidStringNonce()
{
$newEmail = "[email protected]";
$newNonce = "3456789012345678901234567890abcd3456789012345678901234567890abcd"; // null is an excepted value for nonce
$newUserId = 372021;
$user = new User($newEmail, $newNonce, $newUserId);
$p = "/^[0-9a-fA-F]{64}$/";
$this->assertMatch($user->getNonce(), $p);
$this->assertIsA($user,"User");
$this->assertIsA($user->getEmail(), "string");
$this->assertTrue($user->getNonce(),"string");
$this->assertIsA($user->getUserId(), "int");
}
function testCreateUserInvalidStringNonce()
{
$newEmail = "[email protected]";
$newNonce = "look at me, I'm a nonce."; // null is an excepted value for nonce
$newUserId = 372021;
$user = new User($newEmail, $newNonce, $newUserId);
$p = "/^[0-9a-fA-F]{64}$/";
$this->assertMatch($user->getNonce(), $p);
$this->assertIsA($user,"User");
$this->assertIsA($user->getEmail(), "string");
$this->assertTrue($user->getNonce(),"string");
$this->assertIsA($user->getUserId(), "int");
}
}
?>