summaryrefslogtreecommitdiff
path: root/tests/FunctionalTests/quickstart/Controls/ListBoxTestCase.php
blob: 11910ba57aafeb5cc2b435dc00e88f0496ec495a (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
<?php

//New Test
class QuickstartListBoxTestCase extends PradoGenericSelenium2Test
{
	function test ()
	{
		$this->url("../../demos/quickstart/index.php?page=Controls.Samples.TListBox.Home&amp;notheme=true&amp;lang=en");

		// a default single selection listbox
		$this->assertAttribute("ctl0\$body\$ctl0@size","4");

		// single selection list box with initial options
		$this->assertEquals($this->getSelectOptions("ctl0\$body\$ctl1"), array('item 1', 'item 2', 'item 3', 'item 4'));
		$this->assertSelected("ctl0\$body\$ctl1","item 2");

		// a single selection list box with customized style
		$this->assertAttribute("ctl0\$body\$ctl2@size","3");
		$this->assertEquals($this->getSelectOptions("ctl0\$body\$ctl2"), array('item 1', 'item 2', 'item 3', 'item 4'));
		$this->assertSelected("ctl0\$body\$ctl2","item 2");

		// a disabled list box
		$this->assertAttribute("ctl0\$body\$ctl3@disabled","regexp:true|disabled");

		// an auto postback single selection list box
		$this->assertNotContains("Your selection is: (Index: 2, Value: value 3, Text: item 3)", $this->source());
		$this->selectAndWait("ctl0\$body\$ctl4", "item 3");
		$this->assertContains("Your selection is: (Index: 2, Value: value 3, Text: item 3)", $this->source());

		// a single selection list box upon postback
		$this->select("ctl0\$body\$ListBox1", "item 4");
		$this->assertNotContains("Your selection is: (Index: 3, Value: value 4, Text: item 4)", $this->source());
		$this->byXPath("//input[@type='submit' and @value='Submit']")->click();
		$this->assertContains("Your selection is: (Index: 3, Value: value 4, Text: item 4)", $this->source());

		// a multiple selection list box
		$this->assertAttribute("ctl0\$body\$ctl6[]@size","4");
		$this->assertAttribute("ctl0\$body\$ctl6[]@multiple","regexp:true|multiple");

		// a multiple selection list box with initial options
		$this->assertAttribute("ctl0\$body\$ctl7[]@multiple","regexp:true|multiple");
		$this->assertEquals($this->getSelectOptions("ctl0\$body\$ctl7[]"), array('item 1', 'item 2', 'item 3', 'item 4'));

		// multiselection list box's behavior upon postback
		$this->addSelection("ctl0\$body\$ListBox2[]", "item 3");
		$this->byName("ctl0\$body\$ctl8")->click();
		$this->assertText("ctl0_body_MultiSelectionResult2","Your selection is: (Index: 1, Value: value 2, Text: item 2)(Index: 2, Value: value 3, Text: item 3)(Index: 3, Value: value 4, Text: item 4)");

		// Auto postback multiselection list box
		$this->addSelection("ctl0\$body\$ctl9[]", "item 1");
		$this->assertText("ctl0_body_MultiSelectionResult","Your selection is: (Index: 0, Value: value 1, Text: item 1)(Index: 1, Value: value 2, Text: item 2)(Index: 3, Value: value 4, Text: item 4)");

		// Databind to an integer-indexed array
		$this->selectAndWait("ctl0\$body\$DBListBox1[]", "item 3");
		$this->assertContains("Your selection is: (Index: 2, Value: 2, Text: item 3)", $this->source());

		// Databind to an associative array
		$this->selectAndWait("ctl0\$body\$DBListBox2[]", "item 2");
		$this->assertContains("Your selection is: (Index: 1, Value: key 2, Text: item 2)", $this->source());

		// Databind with DataTextField and DataValueField specified
		$this->selectAndWait("ctl0\$body\$DBListBox3[]", "Cary");
		$this->assertContains("Your selection is: (Index: 2, Value: 003, Text: Cary)", $this->source());

		// List box is being validated
		$this->assertNotVisible('ctl0_body_ctl10');
		$this->byId("ctl0_body_ctl11")->click();
		$this->assertVisible('ctl0_body_ctl10');
		$this->select("ctl0\$body\$VListBox1", "item 2");
		$this->byId("ctl0_body_ctl11")->click();
		$this->assertNotVisible('ctl0_body_ctl10');

		// List box causing validation
		$this->assertNotVisible('ctl0_body_ctl12');
		$this->select("ctl0\$body\$VListBox2", "Agree");
		$this->assertVisible('ctl0_body_ctl12');
		$this->type("ctl0\$body\$TextBox", "test");
		$this->selectAndWait("ctl0\$body\$VListBox2", "Disagree");
		$this->assertNotVisible('ctl0_body_ctl12');
	}
}