From 6800a3290bf3cd535dad8891ec50a9b158b7c6b9 Mon Sep 17 00:00:00 2001 From: Bart van den Eijnden Date: Mon, 10 Mar 2014 15:37:29 +0100 Subject: [PATCH] Port over test case for multiple Query elements --- src/ol/format/wfsformat.js | 4 +++- .../ol/format/wfs}/GetFeatureMultiple.xml | 2 +- test/spec/ol/format/wfsformat.test.js | 21 +++++++++++++++++++ 3 files changed, 25 insertions(+), 2 deletions(-) rename {old/test/spec/ol/parser/ogc/xml/wfs_v1 => test/spec/ol/format/wfs}/GetFeatureMultiple.xml (57%) diff --git a/src/ol/format/wfsformat.js b/src/ol/format/wfsformat.js index ec1cf31e24..ed99a47c15 100644 --- a/src/ol/format/wfsformat.js +++ b/src/ol/format/wfsformat.js @@ -442,7 +442,9 @@ ol.format.WFS.writeQuery_ = function(node, featureType, objectStack) { var srsName = goog.object.get(context, 'srsName'); var prefix = goog.isDef(featurePrefix) ? featurePrefix + ':' : ''; node.setAttribute('typeName', prefix + featureType); - node.setAttribute('srsName', srsName); + if (goog.isDef(srsName)) { + node.setAttribute('srsName', srsName); + } if (goog.isDef(featureNS)) { node.setAttribute('xmlns:' + featurePrefix, featureNS); } diff --git a/old/test/spec/ol/parser/ogc/xml/wfs_v1/GetFeatureMultiple.xml b/test/spec/ol/format/wfs/GetFeatureMultiple.xml similarity index 57% rename from old/test/spec/ol/parser/ogc/xml/wfs_v1/GetFeatureMultiple.xml rename to test/spec/ol/format/wfs/GetFeatureMultiple.xml index e1717ddc38..10dcdb2fa7 100644 --- a/old/test/spec/ol/parser/ogc/xml/wfs_v1/GetFeatureMultiple.xml +++ b/test/spec/ol/format/wfs/GetFeatureMultiple.xml @@ -1,4 +1,4 @@ - + diff --git a/test/spec/ol/format/wfsformat.test.js b/test/spec/ol/format/wfsformat.test.js index cd03aa504e..760e3d8e6d 100644 --- a/test/spec/ol/format/wfsformat.test.js +++ b/test/spec/ol/format/wfsformat.test.js @@ -259,6 +259,27 @@ describe('ol.format.WFS', function() { expect(serialized).to.xmleql(ol.xml.load(text)); }); }); + + describe('when writing out a GetFeature request', function() { + var text; + before(function(done) { + afterLoadText('spec/ol/format/wfs/GetFeatureMultiple.xml', function(xml) { + text = xml; + done(); + }); + }); + + it('handles writing multiple Query elements', function() { + var format = new ol.format.WFS(); + var serialized = format.writeGetFeature({ + featureNS: 'http://www.openplans.org/topp', + featureTypes: ['states', 'cities'], + featurePrefix: 'topp' + }); + expect(serialized).to.xmleql(ol.xml.load(text)); + }); + }); + });