OpenLayers OpenLayers

Changeset 7151

Show
Ignore:
Timestamp:
05/13/08 14:36:55 (5 months ago)
Author:
sbenthall
Message:

Streamlined, fleshed out tests on WFS protocol.commit

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • sandbox/vector-behavior/tests/Protocol/WFS/v1_0_0.html

    r7143 r7151  
    105105    //TODO: Add more commit tests 
    106106    function test_Protocol_WFS_v1_0_0_commit(t){ 
    107         t.plan(2); 
     107        t.plan(6); 
    108108         
    109109          var protocol = new OpenLayers.Protocol.WFS.v1_0_0({ 
     
    119119        } 
    120120         
    121          
    122         var test_feature = new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point(42, 7), {has : "cheeseburger"}); 
    123         test_feature.layer = { 
    124             projection: { 
    125                 getCode : function(){ 
    126                     return "EPSG:4326"; 
     121        var featureFactory = function(attribute, id){ 
     122            var feature = new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point(42, 7), {has : attribute}); 
     123             
     124            feature.layer = { 
     125                projection: { 
     126                    getCode : function(){ 
     127                        return "EPSG:4326"; 
     128                    } 
    127129                } 
    128130            } 
     131             
     132            feature.fid = "fid." + id; 
     133             
     134            return feature; 
    129135        } 
    130         test_feature.fid = "fid.7" 
     136         
     137        var test_feature1 = featureFactory("cheeseburger",7); 
    131138         
    132139         
    133         var request = protocol.commit([test_feature]); 
     140        var request = protocol.commit([test_feature1]); 
    134141         
    135142        var xml = new OpenLayers.Format.XML();         
    136143        var xData = xml.read(request.data).firstChild; 
    137144         
     145         
     146        // Basic tests 
    138147        t.eq(request.url, "http://sigma.openplans.org/geoserver/wfs", "Request url is correct.") 
    139148        t.eq(xData.nodeName, "wfs:Transaction", "Node name of commit request data is appropriate") 
    140149         
     150         
     151        //testing getMethod 
     152        test_feature1.state = OpenLayers.State.INSERT; 
     153         
     154        var test_feature2 = featureFactory("lolcat", 8); 
     155        test_feature2.state = OpenLayers.State.UPDATE; 
     156         
     157         
     158         
     159        var test_feature3 = featureFactory("asdf", 9); 
     160        test_feature3.state = OpenLayers.State.DELETE; 
     161         
     162        var request = protocol.commit([test_feature1, test_feature2, test_feature3]); 
     163         
     164        var xData = xml.read(request.data).firstChild; 
     165         
     166        t.eq(xData.textContent,"42,7cheeseburgerthe_geom42,7haslolcat","Data's text content is as expected"); 
     167        t.eq(xData.childNodes[0].nodeName,"wfs:Insert","has Insert node"); 
     168        t.eq(xData.childNodes[1].nodeName,"wfs:Update","has Update node"); 
     169        t.eq(xData.childNodes[2].nodeName,"wfs:Delete","had Delete node"); 
    141170         
    142171        OpenLayers.Request.POST = old_OpenLayers_Request_POST;