summaryrefslogtreecommitdiff
path: root/tests/FunctionalTests/active-controls/tests/ActiveCheckBoxListTestCase.php
blob: e1e0ba4b4c0967ab61487c1e3c021c8dfd355aae (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
<?php

class ActiveCheckBoxListTestCase extends PradoGenericSelenium2Test
{
	function test()
	{
		$base='ctl0_Content_';
		$this->url("active-controls/index.php?page=TActiveCheckBoxListTest");
		$this->assertTextPresent("TActiveCheckBoxList Test Case");

		$this->assertText("{$base}label1", "Label 1");

		$this->click("{$base}button1");
		$this->pause(800);
		$this->assertCheckBoxes(array(1,2,3));

		$this->click("{$base}button2");
		$this->pause(800);
		$this->assertCheckBoxes(array());


		$this->click("{$base}button3");
		$this->pause(800);
		$this->assertCheckBoxes(array(0));


		$this->click("{$base}button4");
		$this->pause(800);
		$this->assertCheckBoxes(array(4));


		$this->click("{$base}button5");
		$this->pause(800);
		$this->assertCheckBoxes(array(1,4));

		$this->click("{$base}list1_c2");
		$this->pause(800);
		$this->assertText("{$base}label1", "Selection: value 2, value 3, value 5");

		$this->click("{$base}list1_c2");
		$this->pause(800);
		$this->assertText("{$base}label1", "Selection: value 2, value 5");

	}

	function assertCheckBoxes($checks, $total = 5)
	{
		$base='ctl0_Content_';
		for($i = 0; $i < $total; $i++)
		{
			if(in_array($i, $checks))
				$this->assertChecked("{$base}list1_c{$i}");
			else
				$this->assertNotChecked("{$base}list1_c{$i}");
		}
	}
}