cvs: pear /Structures_DataGrid/tests DataSourceXMLTest.php

[email protected] ("Olivier Guilyardi") Mon, 05 May 2008 18:39:45 -0000
Newsgroups php.pear.cvs
Message-ID <cvsolivierg1210012785@cvsserver>
olivierg		Mon May  5 18:39:45 2008 UTC

  Modified files:              
    /pear/Structures_DataGrid/tests	DataSourceXMLTest.php 
  Log:
  add xml datasource unit test for fieldAttribute and labelAttribute options
  
http://cvs.php.net/viewvc.cgi/pear/Structures_DataGrid/tests/DataSourceXMLTest.php?r1=1.3&r2=1.4&diff_format=u
Index: pear/Structures_DataGrid/tests/DataSourceXMLTest.php
diff -u pear/Structures_DataGrid/tests/DataSourceXMLTest.php:1.3 pear/Structures_DataGrid/tests/DataSourceXMLTest.php:1.4
--- pear/Structures_DataGrid/tests/DataSourceXMLTest.php:1.3	Mon May  5 18:04:07 2008
+++ pear/Structures_DataGrid/tests/DataSourceXMLTest.php	Mon May  5 18:39:45 2008
@@ -34,9 +34,9 @@
  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
- * CVS file id: $Id: DataSourceXMLTest.php,v 1.3 2008/05/05 18:04:07 olivierg Exp $
+ * CVS file id: $Id: DataSourceXMLTest.php,v 1.4 2008/05/05 18:39:45 olivierg Exp $
  * 
- * @version  $Revision: 1.3 $
+ * @version  $Revision: 1.4 $
  * @package  Structures_DataGrid
  * @author   Olivier Guilyardi <[email protected]>
  * @author   Mark Wiesemann <[email protected]>
@@ -192,15 +192,34 @@
             $this->assertEquals('attributesacctname', $columns[0]->getField());
             $this->assertEquals('attributesadgroup', $columns[1]->getLabel());
             $this->assertEquals('attributesadgroup', $columns[1]->getField());
-        } else {
-            $this->fail("expected 2 columns");
-        }
+        } 
 
         $content = array(array('attributesacctname' => 'x', 'attributesadgroup' => 'foo'),
                 array('attributesacctname' => 'x', 'attributesadgroup' => 'bar'));
         $this->assertEquals($content, $this->datasource->fetch());                
     }
 
+    function testFieldAndLabelAttributes()
+    {
+        $xml = '<data><item name="foo" label="bar">test</item>'.
+            '<item name="foo" label="bar">test2</item></data>';
+        $this->datasource->setOption('generate_columns', true);
+        $this->datasource->setOption('fieldAttribute', 'name');
+        $this->datasource->setOption('labelAttribute', 'label');
+        $this->datasource->bind($xml);
+        $columns = $this->datasource->getColumns();
+        $this->assertEquals(3, count($columns));
+        if (count($columns) == 3) {
+            $this->assertEquals('attributesname', $columns[0]->getLabel());
+            $this->assertEquals('attributesname', $columns[0]->getField());
+            $this->assertEquals('attributeslabel', $columns[1]->getLabel());
+            $this->assertEquals('attributeslabel', $columns[1]->getField());
+            $this->assertEquals('bar', $columns[2]->getLabel());
+            $this->assertEquals('foo', $columns[2]->getField());
+        }
+
+    }
+
 }
 
 ?>