| [ Index ] |
PHP Cross Reference of Web Application Component Toolkit |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * @package WACT_TESTS 4 * @version $Id: dataspace.test.php,v 1.5 2004/11/15 01:46:04 jeffmoore Exp $ 5 */ 6 require_once TEST_CASES . '/util/datasource.inc.php'; 7 8 require_once WACT_ROOT . 'util/datacomponent.inc.php'; 9 10 11 class RectangleDataSpace extends DataComponent { 12 13 function getArea() { 14 return $this->get('length') * $this->get('width'); 15 } 16 17 function setTest($value) { 18 if ($value == 'Y') { 19 $this->properties['test'] = TRUE; 20 } else { 21 $this->properties['test'] = FALSE; 22 } 23 } 24 25 } 26 27 /** 28 * Cases for dataspace are defined in shared cases/dataspace.inc.php 29 * @package WACT_TESTS 30 */ 31 class DataSpaceTestCase extends DataSourceTestCase { 32 function DataSpaceTestCase($name = 'DataSpace test cases') { 33 $this->DataSourceTestCase($name); 34 } 35 36 function testPropertyGetAccessor() { 37 $rect =& new RectangleDataSpace(); 38 $rect->set('length', 5); 39 $rect->set('width', 2); 40 $this->assertEqual($rect->get('area'), 10); 41 } 42 43 function testPropertySetAccessor() { 44 $rect =& new RectangleDataSpace(); 45 $rect->set('test', 'Y'); 46 $this->assertIdentical($rect->get('test'), TRUE); 47 } 48 49 function testHasPropertyAccessor() { 50 $rect =& new RectangleDataSpace(); 51 $this->assertTrue($rect->hasProperty('area')); 52 } 53 54 function testGetPropertyListAccessor() { 55 $rect =& new RectangleDataSpace(); 56 $this->assertEqual(count($rect->getPropertyList()), 1); 57 $this->assertEqual($rect->getPropertyList(), array('Area')); 58 } 59 60 function testGetPropertyList() { 61 $this->dataspace->set('test', 'value'); 62 $this->assertEqual(count($this->dataspace->getPropertyList()), 1); 63 $this->assertEqual($this->dataspace->getPropertyList(), array('test')); 64 } 65 66 function testGetPath() { 67 $dataspace =& new DataSpace(); 68 $dataspace->set('test', array('var' => 'value')); 69 $this->assertEqual($dataspace->getPath('test.var'), 'value'); 70 } 71 72 function testSetPath() { 73 $dataspace =& new DataSpace(); 74 $dataspace->set('test', array('var' => 'value')); 75 $dataspace->setPath('test.var', 'test'); 76 $this->assertEqual($dataspace->getPath('test.var'), 'test'); 77 } 78 79 function testSetNewPath() { 80 $dataspace =& new DataSpace(); 81 $dataspace->setPath('test.var', 'test'); 82 $this->assertEqual($dataspace->getPath('test.var'), 'test'); 83 } 84 85 function testSetPathNestedDataSpace() { 86 $dataspace =& new DataSpace(); 87 $dataspace->set('test', new DataSpace()); 88 $dataspace->setPath('test.var', 'test'); 89 $this->assertEqual($dataspace->getPath('test.var'), 'test'); 90 } 91 92 93 } 94 95 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Sun Nov 28 19:36:09 2004 | Cross-referenced by PHPXref 0.5 |