/** * Tests MyValidator->email() */ public function testEmail() { //该单元测试用例采用等价类的方式测试,黑盒测试 // 以.开头,含有特殊字符,user超出长度,domin超出长度 // 正常 $this->MyValidator->setValue("*****@*****.**"); $this->assertEquals(1, $this->MyValidator->email()); //unit1 以.开头 $this->MyValidator->setValue("*****@*****.**"); $this->assertEquals(0, $this->MyValidator->telephone()); //unit2 含有特殊字符 $this->MyValidator->setValue("re\$%^njiangang@baixing.com"); $this->assertEquals(0, $this->MyValidator->telephone()); //unit3 user超出长度 $this->MyValidator->setValue("*****@*****.**"); $this->assertEquals(0, $this->MyValidator->telephone()); //unit4 domin超出长度 $this->MyValidator->setValue("renjiangang@bai.fdsfs.fdfsfsdfsdfsdfsdfsdfsdfsdfsdfsfsdfsfs.fdsfsdfsdfsd.fsdfsdfds\n .fsdfsdfs\n sfsd.fdsfs.fsdfs.fdsfs.fdsfsd.fsfsdf.fdsf.fsdfsf\n .fssf.fssf.fssf.fssf.fssf.fssf.fssf.fssf.fssf.fssf.fssf.fsxing.com"); $this->assertEquals(0, $this->MyValidator->telephone()); }