00001 <?php 00008 class UTArray extends foUnitTestBase 00009 { 00010 public function doTest() 00011 { 00012 $this->_testArray(); 00013 } 00014 00015 private function _testArray() 00016 { 00017 $this->setSectionLabel('getHtmlArray'); 00018 00019 $arr = array(); 00020 $arr['contact']['first_name'] = 'Daniel'; 00021 $arr['contact']['last_name'] = 'Lindh'; 00022 $arr['contact']['address'] = ''; 00023 $arr['contact']['age'] = 32; 00024 $arr['contact']['parent_contact'] = NULL; 00025 $arr['contact']['has_icq'] = false; 00026 $arr['contact']['phone_numbers'] = array(); 00027 $arr['orders'][0]['id'] = 32; 00028 $arr['orders'][0]['description'] = 'Honda Fireblade 929 - 99'; 00029 $arr['orders'][0]['price'] = '45000'; 00030 $arr['orders'][0]['currency'] = 'SEK'; 00031 $arr['orders'][1]['id'] = 33; 00032 $arr['orders'][1]['description'] = 'Computer'; 00033 $arr['orders'][1]['price'] = '2000'; 00034 $arr['orders'][1]['currency'] = 'SEK'; 00035 00036 eval($this->needEqual('getHtmlArray($arr)', '"<table border=\"1\" cellspacing=\"0\" cellpadding=\"3\"><tr><td colspan=\"4\">Count:0</td></tr><tr><td>key</td><td>value</td><td>type</td><td>size</td></tr><tr><td>contact</td><td colspan=\"3\"><table border=\"1\" cellspacing=\"0\" cellpadding=\"3\"><tr><td colspan=\"4\">Count:0</td></tr><tr><td>key</td><td>value</td><td>type</td><td>size</td></tr><tr><td>first_name</td><td>Daniel</td><td>string</td><td>6</td></tr><tr><td>last_name</td><td>Lindh</td><td>string</td><td>5</td></tr><tr><td>address</td><td>EMPTY</td><td>string</td><td>0</td></tr><tr><td>age</td><td>32</td><td>integer</td><td>1</td></tr><tr><td>parent_contact</td><td>NULL</td><td>NULL</td><td>0</td></tr><tr><td>has_icq</td><td>FALSE</td><td>boolean</td><td>1</td></tr><tr><td>phone_numbers</td><td colspan=\"3\"><table border=\"1\" cellspacing=\"0\" cellpadding=\"3\"><tr><td colspan=\"4\">Count:0</td></tr><tr><td>key</td><td>value</td><td>type</td><td>size</td></tr></table></td></tr></table></td></tr><tr><td>orders</td><td colspan=\"3\"><table border=\"1\" cellspacing=\"0\" cellpadding=\"3\"><tr><td colspan=\"4\">Count:0</td></tr><tr><td>key</td><td>value</td><td>type</td><td>size</td></tr><tr><td>0</td><td colspan=\"3\"><table border=\"1\" cellspacing=\"0\" cellpadding=\"3\"><tr><td colspan=\"4\">Count:0</td></tr><tr><td>key</td><td>value</td><td>type</td><td>size</td></tr><tr><td>id</td><td>32</td><td>integer</td><td>1</td></tr><tr><td>description</td><td>Honda Fireblade 929 - 99</td><td>string</td><td>24</td></tr><tr><td>price</td><td>45000</td><td>string</td><td>5</td></tr><tr><td>currency</td><td>SEK</td><td>string</td><td>3</td></tr></table></td></tr><tr><td>1</td><td colspan=\"3\"><table border=\"1\" cellspacing=\"0\" cellpadding=\"3\"><tr><td colspan=\"4\">Count:0</td></tr><tr><td>key</td><td>value</td><td>type</td><td>size</td></tr><tr><td>id</td><td>33</td><td>integer</td><td>1</td></tr><tr><td>description</td><td>Computer</td><td>string</td><td>8</td></tr><tr><td>price</td><td>2000</td><td>string</td><td>4</td></tr><tr><td>currency</td><td>SEK</td><td>string</td><td>3</td></tr></table></td></tr></table></td></tr></table>"')); 00037 eval($this->needEqual('getHtmlArrayPhp($arr)', '"array<br/>(<br/> \'contact\' => array<br/> (<br/> \'first_name\' => \'Daniel\',<br/> \'last_name\' => \'Lindh\',<br/> \'address\' => \'\',<br/> \'age\' => 32,<br/> \'parent_contact\' => NULL,<br/> \'has_icq\' => FALSE,<br/> \'phone_numbers\' => array<br/> (<br/><br/> )<br/> ),<br/> \'orders\' => array<br/> (<br/> \'0\' => array<br/> (<br/> \'id\' => 32,<br/> \'description\' => \'Honda Fireblade 929 - 99\',<br/> \'price\' => \'45000\',<br/> \'currency\' => \'SEK\'<br/> ),<br/> \'1\' => array<br/> (<br/> \'id\' => 33,<br/> \'description\' => \'Computer\',<br/> \'price\' => \'2000\',<br/> \'currency\' => \'SEK\'<br/> )<br/> )<br/>)"')); 00038 00039 $arr2 = $arr; 00040 $arr2['diff_key']['key_diff'] = 'value'; 00041 $arr['orders'][1]['description'] = 'Compute'; 00042 eval($this->needEqual('array_diff_assoc_recursive($arr, $arr2)', 'array(\'orders\'=>array(\'1\'=>array(\'description\'=>\'Compute\')))')); 00043 eval($this->needEqual('array_diff_assoc_recursive($arr2, $arr)', 'array(\'orders\'=>array(\'1\'=>array(\'description\'=>\'Computer\')),\'diff_key\'=>array(\'key_diff\'=>\'value\'))')); 00044 } 00045 } 00046 ?>