summaryrefslogtreecommitdiff
path: root/tests/FunctionalTests/quickstart/Controls/DataList2TestCase.php
blob: 911fdc93f140e841e4c1420e6db68c400807d79b (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
<?php

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

		// verify initial presentation
		$this->assertContains("Motherboard", $this->source());
		$this->assertContains("Monitor", $this->source());

		// verify selecting an item
		$this->byLinkText("ITN003")->click();
		$this->assertContains("Quantity", $this->source());
		$this->assertContains("Price", $this->source());
		$this->assertContains("\$80", $this->source());
		$this->byLinkText("ITN005")->click();
		$this->assertContains("\$150", $this->source());

		// verify editting an item
		$this->byId("ctl0_body_DataList_ctl5_ctl0")->click();
		$this->type("ctl0\$body\$DataList\$ctl5\$ProductQuantity", "11");
		$this->type("ctl0\$body\$DataList\$ctl5\$ProductPrice", "140.99");
		$this->byXPath("//input[@name='ctl0\$body\$DataList\$ctl5\$ProductImported']")->click();
		$this->byLinkText("Save")->click();

		// verify item is saved
		$this->byLinkText("ITN005")->click();
		$this->assertContains("\$140.99", $this->source());
		$this->assertContains("11", $this->source());

		// verify editting another item
		$this->byId("ctl0_body_DataList_ctl3_ctl1")->click();
		$this->type("ctl0\$body\$DataList\$ctl3\$ProductName", "Hard Drive");
		$this->type("ctl0\$body\$DataList\$ctl3\$ProductQuantity", "23");
		$this->byXPath("//input[@name='ctl0\$body\$DataList\$ctl3\$ProductImported']")->click();
		$this->byLinkText("Cancel")->click();

		// verify item is canceled
		$this->byLinkText("ITN003")->click();
		$this->assertContains("2", $this->source());
		$this->assertContains("Harddrive", $this->source());

		// verify item deletion
		$this->byId("ctl0_body_DataList_ctl3_ctl1")->click();

		$this->assertEquals("Are you sure?", $this->alertText());
		$this->acceptAlert();

		$this->byId("ctl0_body_DataList_ctl5_ctl2")->click();

		$this->assertEquals("Are you sure?", $this->alertText());
		$this->dismissAlert();

		$this->assertContains("Motherboard", $this->source());
		$this->assertContains("CPU", $this->source());
		$this->assertNotContains("Harddrive", $this->source());
		$this->assertContains("Sound card", $this->source());
		$this->assertContains("Video card", $this->source());
		$this->assertContains("Keyboard", $this->source());
		$this->assertContains("Monitor", $this->source());
	}
}