summaryrefslogtreecommitdiff
path: root/tests/unit/Web/UI/WebControls/TDropDownListTest.php
blob: 3db425b9cf6160a5cd526cb506e2b6079422b97c (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
<?php
require_once dirname(__FILE__).'/../../../phpunit.php';

Prado::using('System.Web.UI.WebControls.TDropDownList');

/**
 * @package System.Web.UI.WebControls
 */
class TDropDownListTest extends PHPUnit_Framework_TestCase {

  public function testSetDataSource() {
    $list = new TDropDownList();
    $data = array('a' => 1,
		  'b' => 2,
		  'c' => 3);
    $list->setDataSource($data);
    $list->dataBind();
    $items =& $list->getItems();
    $this->assertTrue($items instanceof TListItemCollection);
    $expected_keys = array_keys($data);
    $i = 0;
    foreach($items as $item) {
      $this->assertEquals($expected_keys[$i], $item->getValue());
      $this->assertEquals((string)$data[$expected_keys[$i]], $item->getText());
      $i++;
    }
  }
}

?>