-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCapchaTest.php
97 lines (78 loc) · 2.5 KB
/
CapchaTest.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<?php
require_once "Capcha.php";
require_once "Random.php";
class CapchaTest extends PHPUnit_Framework_TestCase {
function testGetCapchaThreeNumberPlusFiveText() {
$expected = "3 + Five = 8";
$capcha = new Capcha();
$capcha->setFirstOperand("3");
$capcha->setSecondOperand("Five");
$capcha->setOperator("+");
$result = $capcha->getCapcha();
$this->assertEquals($expected, $result);
}
function testGetCapchaFiveTextMultipleOneNumber() {
$expected = "Five * 1 = 5";
$capcha = new Capcha();
$capcha->setFirstOperand("Five");
$capcha->setSecondOperand("1");
$capcha->setOperator("*");
$result = $capcha->getCapcha();
$this->assertEquals($expected, $result);
}
function testGetCapchaFourTextPlusTwoNumber() {
$expected = "Four + 2 = 6";
$capcha = new Capcha();
$capcha->setFirstOperand("Four");
$capcha->setSecondOperand("2");
$capcha->setOperator("+");
$result = $capcha->getCapcha();
$this->assertEquals($expected, $result);
}
function testGetCapchaFiveTextMultipleSixNumber() {
$expected = "Five * 6 = 30";
$capcha = new Capcha();
$capcha->setFirstOperand("Five");
$capcha->setSecondOperand("6");
$capcha->setOperator("*");
$result = $capcha->getCapcha();
$this->assertEquals($expected, $result);
}
function testGetCaphaArrayFourTextPlusTwoNumber() {
//$expected = "Four + 2 = 6";
$expected = array("Four", "+", "2", "=","6");
$capcha = new Capcha();
$capcha->setFirstOperand("Four");
$capcha->setSecondOperand("2");
$capcha->setOperator("+");
$result = $capcha->getCapchaArray();
$this->assertEquals($expected, $result);
}
function testGetRandomCaphaArrayFourTextPlusTwoNumber() {
$expected = array("Four", "+", "2", "=","6");
$capcha = new Capcha();
$stub = $this->getMock('Random');
$stub->expects($this->once())
->method('getRandomPattern')
->will($this->returnValue('TextNumberAndNumber'));
$stub->expects($this->once())
->method('getRandomTextNumber')
->will($this->returnValue('Four'));
$stub->expects($this->once())
->method('getRandomNumber')
->will($this->returnValue('2'));
$stub->expects($this->once())
->method('getRandomOperator')
->will($this->returnValue('+'));
$capcha->setRandom($stub);
$result = $capcha->getCapchaArray();
$this->assertEquals($expected, $result);
}
/*function testGetRandomOperator() {
$expected = array('+', '*');
$capcha = new Capcha();
$result = $capcha->getRandomOperator();
$this->assertContains($result, $expected);
}*/
}
?>