summaryrefslogtreecommitdiff
path: root/tests/unit/Data/SqlMap/TestQueryForMap.php
blob: f50d0c7624ea8b16b860db91fa957189f5723ade (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
<?php
require_once(dirname(__FILE__).'/BaseCase.php');

/**
 * @package System.Data.SqlMap
 */
class TestQueryForMap extends BaseCase
{
	function __construct()
	{
		parent::__construct();
		$this->initSqlMap();
	}

	/**
	 * Test ExecuteQueryForMap : Hashtable.
	 */
	function testExecuteQueryForMap()
	{
		$map = $this->sqlmap->QueryForMap("GetAllAccountsViaResultClass", null, "FirstName",null,0,2);
		$this->assertSame(2, count($map));
		$this->assertAccount1($map["Joe"]);

		$this->assertSame(1, $map["Joe"]->getID());
		$this->assertSame(2, $map["Averel"]->getID());
	}

	/**
	 * Test ExecuteQueryForMap with value property :
	 * "FirstName" as key, "EmailAddress" as value
	 */
	function testExecuteQueryForMapWithValueProperty()
	{
		$map = $this->sqlmap->QueryForMap("GetAllAccountsViaResultClass", null,
						"FirstName", "EmailAddress",1,3);

		$this->assertSame(3, count($map));

		$this->assertSame("Averel.Dalton@somewhere.com", $map["Averel"]);
		$this->assertNull($map["William"]);
		$this->assertSame("Jack.Dalton@somewhere.com", $map["Jack"]);
	}

}