summaryrefslogtreecommitdiff
path: root/tests/FunctionalTests/validators/tests/RangeValidatorTestCase.php
blob: 485c6a248800ea2df98284b253236770f10d83d2 (plain)
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
<?php

//New Test
class RangeValidatorTestCase extends PradoGenericSelenium2Test
{
	function testIntegerRange()
	{
		$base = "ctl0_Content_";
		$this->url("validators/index.php?page=RangeValidatorInteger");
		$this->assertContains("Prado RangeValidator Tests Integer", $this->source());

		//between 1 and 4
		$this->type("{$base}text1", "ad");
		$this->assertNotVisible("{$base}validator1");
		$this->byXPath("//input[@type='submit' and @value='Test']")->click();
		$this->assertVisible("{$base}validator1");
		$this->type("{$base}text1", "12");
		$this->byXPath("//input[@type='submit' and @value='Test']")->click();
		$this->assertVisible("{$base}validator1");
		$this->type("{$base}text1", "2");
		$this->assertNotVisible("{$base}validator1");
		$this->byXPath("//input[@type='submit' and @value='Test']")->click();
		$this->assertNotVisible("{$base}validator1");


		// >= 2
		$this->assertNotVisible("{$base}validator2");
		$this->type("{$base}text2", "1");
		$this->byXPath("//input[@type='submit' and @value='Test']")->click();
		$this->assertVisible("{$base}validator2");
		$this->type("{$base}text2", "10");
		$this->byXPath("//input[@type='submit' and @value='Test']")->click();
		$this->assertNotVisible("{$base}validator2");

		// <= 20
		$this->assertNotVisible("{$base}validator3");
		$this->type("{$base}text3", "100");
		$this->byXPath("//input[@type='submit' and @value='Test']")->click();
		$this->assertVisible("{$base}validator3");
		$this->type("{$base}text3", "10");
		$this->byXPath("//input[@type='submit' and @value='Test']")->click();
		$this->assertNotVisible("{$base}validator3");

	}

	function testFloatRange()
	{
		$base = "ctl0_Content_";
		$this->url("validators/index.php?page=RangeValidatorFloat");
		$this->assertContains("Prado RangeValidator Tests Float", $this->source());

		//between 1 and 4
		$this->type("{$base}text1", "ad");
		$this->assertNotVisible("{$base}validator1");
		$this->byXPath("//input[@type='submit' and @value='Test']")->click();
		$this->assertVisible("{$base}validator1");
		$this->type("{$base}text1", "12");
		$this->byXPath("//input[@type='submit' and @value='Test']")->click();
		$this->assertVisible("{$base}validator1");
		$this->type("{$base}text1", "2");
		$this->assertNotVisible("{$base}validator1");
		$this->byXPath("//input[@type='submit' and @value='Test']")->click();
		$this->assertNotVisible("{$base}validator1");


		// >= 2
		$this->assertNotVisible("{$base}validator2");
		$this->type("{$base}text2", "1");
		$this->byXPath("//input[@type='submit' and @value='Test']")->click();
		$this->assertVisible("{$base}validator2");
		$this->type("{$base}text2", "10");
		$this->byXPath("//input[@type='submit' and @value='Test']")->click();
		$this->assertNotVisible("{$base}validator2");

		// <= 20
		$this->assertNotVisible("{$base}validator3");
		$this->type("{$base}text3", "100");
		$this->byXPath("//input[@type='submit' and @value='Test']")->click();
		$this->assertVisible("{$base}validator3");
		$this->type("{$base}text3", "10");
		$this->byXPath("//input[@type='submit' and @value='Test']")->click();
		$this->assertNotVisible("{$base}validator3");
	}

	function testDateRange()
	{
		$base = "ctl0_Content_";
		$this->url("validators/index.php?page=RangeValidatorDate");
		$this->assertContains("Prado RangeValidator Tests Date", $this->source());

		//between 22/1/2005 and 3/2/2005
		$this->type("{$base}text1", "ad");
		$this->assertNotVisible("{$base}validator1");
		$this->byXPath("//input[@type='submit' and @value='Test']")->click();
		$this->assertVisible("{$base}validator1");
		$this->type("{$base}text1", "27/2/2005");
		$this->byXPath("//input[@type='submit' and @value='Test']")->click();
		$this->assertVisible("{$base}validator1");
		$this->type("{$base}text1", "1/2/2005");
		$this->byXPath("//input[@type='submit' and @value='Test']")->click();
		$this->assertNotVisible("{$base}validator1");
		$this->byXPath("//input[@type='submit' and @value='Test']")->click();
		$this->assertNotVisible("{$base}validator1");


		// >= 22/1/2005
		$this->assertNotVisible("{$base}validator2");
		$this->type("{$base}text2", "1/1/2005");
		$this->byXPath("//input[@type='submit' and @value='Test']")->click();
		$this->pause(250);
		$this->assertVisible("{$base}validator2");
		$this->type("{$base}text2", "1/4/2005");
		$this->byXPath("//input[@type='submit' and @value='Test']")->click();
		$this->assertNotVisible("{$base}validator2");

		// <= 3/2/2005
		$this->assertNotVisible("{$base}validator3");
		$this->type("{$base}text3", "4/5/2005");
		$this->byXPath("//input[@type='submit' and @value='Test']")->click();
		$this->pause(250);
		$this->assertVisible("{$base}validator3");
		$this->type("{$base}text3", "1/2/2005");
		$this->byXPath("//input[@type='submit' and @value='Test']")->click();
		$this->assertNotVisible("{$base}validator3");
	}

	function testStringRange()
	{
		$base = "ctl0_Content_";
		$this->url("validators/index.php?page=RangeValidatorString");
		$this->assertContains("Prado RangeValidator Tests String", $this->source());

		//between 'd' and 'y'
		$this->type("{$base}text1", "a");
		$this->assertNotVisible("{$base}validator1");
		$this->byXPath("//input[@type='submit' and @value='Test']")->click();
		$this->assertVisible("{$base}validator1");
		$this->type("{$base}text1", "b");
		$this->byXPath("//input[@type='submit' and @value='Test']")->click();
		$this->assertVisible("{$base}validator1");
		$this->type("{$base}text1", "f");
		$this->assertNotVisible("{$base}validator1");
		$this->byXPath("//input[@type='submit' and @value='Test']")->click();
		$this->assertNotVisible("{$base}validator1");


		// >= 'd'
		$this->assertNotVisible("{$base}validator2");
		$this->type("{$base}text2", "a");
		$this->byXPath("//input[@type='submit' and @value='Test']")->click();
		$this->assertVisible("{$base}validator2");
		$this->type("{$base}text2", "g");
		$this->byXPath("//input[@type='submit' and @value='Test']")->click();
		$this->assertNotVisible("{$base}validator2");

		// <= 'y'
		$this->assertNotVisible("{$base}validator3");
		$this->type("{$base}text3", "z");
		$this->byXPath("//input[@type='submit' and @value='Test']")->click();
		$this->assertVisible("{$base}validator3");
		$this->type("{$base}text3", "t");
		$this->byXPath("//input[@type='submit' and @value='Test']")->click();
		$this->assertNotVisible("{$base}validator3");
	}
}