Skip to content

Commit 502c767

Browse files
authored
Merge pull request #6125 from rldhont/backport-6009-to-release_3_9
[Backport release_3_9] GH Action - E2E QGIS - BLEEDING_EDGE with QGIS 3.44
2 parents c4c7242 + 975c487 commit 502c767

File tree

5 files changed

+207
-116
lines changed

5 files changed

+207
-116
lines changed

.github/workflows/e2e_tests.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,15 @@ jobs:
3030
pg-postgis: "14-3"
3131
qgis-server: "3.34"
3232
update-projects: "FALSE"
33+
- name: "LTR"
34+
php: "8.2"
35+
pg-postgis: "15-3"
36+
qgis-server: "3.40"
37+
update-projects: "TRUE"
3338
- name: "BLEEDING_EDGE"
3439
php: "8.3"
3540
pg-postgis: "17-3"
36-
qgis-server: "3.40"
41+
qgis-server: "3.44"
3742
update-projects: "TRUE"
3843
env:
3944
CYPRESS_CI: TRUE

lizmap/modules/lizmap/lib/Project/Qgis/LayerTreeGroup.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
* @property bool $mutuallyExclusive
2121
* @property array $customproperties
2222
* @property array<LayerTreeGroup|LayerTreeLayer> $items
23+
* @property null|string $shortname
24+
* @property null|string $title
25+
* @property null|string $abstract
2326
*/
2427
class LayerTreeGroup extends BaseQgisXmlObject
2528
{
@@ -29,6 +32,9 @@ class LayerTreeGroup extends BaseQgisXmlObject
2932
'mutuallyExclusive',
3033
'customproperties',
3134
'items',
35+
'shortname',
36+
'title',
37+
'abstract',
3238
);
3339

3440
/** @var array The default values for properties */
@@ -40,6 +46,13 @@ class LayerTreeGroup extends BaseQgisXmlObject
4046
/** @var string The XML element local name */
4147
protected static $qgisLocalName = 'layer-tree-group';
4248

49+
/** @var array<string> The XML element parsed children */
50+
protected static $children = array(
51+
'shortname',
52+
'title',
53+
'abstract',
54+
);
55+
4356
protected static $childParsers = array();
4457

4558
/** @var array<string, string> The XML element tagname associated with a collector property name */
@@ -76,6 +89,11 @@ public function getGroupShortNames()
7689
continue;
7790
}
7891
$data += $item->getGroupShortNames();
92+
if (isset($item->shortname) && $item->shortname != null) {
93+
$data[$item->name] = $item->shortname;
94+
95+
continue;
96+
}
7997
if (!array_key_exists('wmsShortName', $item->customproperties)) {
8098
continue;
8199
}

tests/end2end/cypress/integration/requests-service-ghaction.js

Lines changed: 0 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -232,121 +232,6 @@ describe('Request service', function () {
232232
})
233233
})
234234

235-
it('WMTS GetCapabilities', function () {
236-
cy.request('/index.php/lizmap/service/?repository=testsrepository&project=cache&SERVICE=WMTS&VERSION=1.0.0&REQUEST=GetCapabilities')
237-
.then((resp) => {
238-
expect(resp.status).to.eq(200)
239-
expect(resp.headers['content-type']).to.eq('text/xml; charset=utf-8')
240-
expect(resp.headers['cache-control']).to.eq('no-cache')
241-
expect(resp.headers['etag']).to.not.eq(undefined)
242-
243-
expect(resp.body).to.contain('version="1.0.0"')
244-
expect(resp.body).to.contain('<ows:Identifier>Quartiers</ows:Identifier>')
245-
expect(resp.body).to.contain('<TileMatrixSet>EPSG:3857</TileMatrixSet>')
246-
247-
const etag = resp.headers['etag']
248-
cy.request({
249-
url: '/index.php/lizmap/service/?repository=testsrepository&project=cache&SERVICE=WMTS&VERSION=1.0.0&REQUEST=GetCapabilities',
250-
headers: {
251-
'If-None-Match': etag,
252-
},
253-
failOnStatusCode: false,
254-
}).then((resp) => {
255-
expect(resp.status).to.eq(304)
256-
expect(resp.body).to.have.length(0)
257-
})
258-
})
259-
})
260-
261-
it('WMTS GetTile', function () {
262-
// Get full transparent tile TILEMATRIX=13&TILEROW=2989&TILECOL=4185
263-
cy.request({
264-
method: 'GET',
265-
url: '/index.php/lizmap/service/?repository=testsrepository&project=cache',
266-
qs: {
267-
'SERVICE': 'WMTS',
268-
'VERSION': '1.0.0',
269-
'REQUEST': 'GetTile',
270-
'LAYER': 'Quartiers',
271-
'STYLE': 'default',
272-
'TILEMATRIXSET': 'EPSG:3857',
273-
'TILEMATRIX': '13',
274-
'TILEROW': '2989',
275-
'TILECOL': '4185',
276-
'FORMAT': 'image/png',
277-
},
278-
}).then((resp) => {
279-
expect(resp.status).to.eq(200)
280-
expect(resp.headers['content-type']).to.contain('image/png')
281-
expect(resp.headers).to.have.property('content-length', '355') // Transparent
282-
expect(resp.headers).to.have.property('date')
283-
const tileDate = new Date(resp.headers['date'])
284-
expect(resp.headers).to.have.property('expires')
285-
const tileExpires = new Date(resp.headers['expires'])
286-
expect(tileExpires).to.be.greaterThan(tileDate)
287-
/*expect(resp.body).to.contain('version="1.0.0"')*/
288-
})
289-
290-
// Get not full transparent tile TILEMATRIX=13&TILEROW=2991&TILECOL=4184
291-
cy.request({
292-
method: 'GET',
293-
url: '/index.php/lizmap/service/?repository=testsrepository&project=cache',
294-
qs: {
295-
'SERVICE': 'WMTS',
296-
'VERSION': '1.0.0',
297-
'REQUEST': 'GetTile',
298-
'LAYER': 'Quartiers',
299-
'STYLE': 'default',
300-
'TILEMATRIXSET': 'EPSG:3857',
301-
'TILEMATRIX': '13',
302-
'TILEROW': '2991',
303-
'TILECOL': '4184',
304-
'FORMAT': 'image/png',
305-
},
306-
}).then((resp) => {
307-
expect(resp.status).to.eq(200)
308-
expect(resp.headers['content-type']).to.contain('image/png')
309-
expect(resp.headers).to.have.property('content-length')
310-
expect(parseInt(resp.headers['content-length'])).to.be.greaterThan(355) // Not transparent
311-
expect(parseInt(resp.headers['content-length'])).to.be.within(11020, 11030 ) // Monochrome
312-
expect(resp.headers).to.have.property('date')
313-
const tileDate = new Date(resp.headers['date'])
314-
expect(resp.headers).to.have.property('expires')
315-
const tileExpires = new Date(resp.headers['expires'])
316-
expect(tileExpires).to.be.greaterThan(tileDate)
317-
/*expect(resp.body).to.contain('version="1.0.0"')*/
318-
})
319-
320-
// Get monochrome tile TILEMATRIX=15&TILEROW=11964&TILECOL=16736
321-
cy.request({
322-
method: 'GET',
323-
url: '/index.php/lizmap/service/?repository=testsrepository&project=cache',
324-
qs: {
325-
'SERVICE': 'WMTS',
326-
'VERSION': '1.0.0',
327-
'REQUEST': 'GetTile',
328-
'LAYER': 'Quartiers',
329-
'STYLE': 'default',
330-
'TILEMATRIXSET': 'EPSG:3857',
331-
'TILEMATRIX': '15',
332-
'TILEROW': '11964',
333-
'TILECOL': '16736',
334-
'FORMAT': 'image/png',
335-
},
336-
}).then((resp) => {
337-
expect(resp.status).to.eq(200)
338-
expect(resp.headers['content-type']).to.contain('image/png')
339-
expect(resp.headers).to.have.property('content-length')
340-
expect(parseInt(resp.headers['content-length'])).to.be.greaterThan(355) // Not transparent
341-
expect(resp.headers).to.have.property('date')
342-
const tileDate = new Date(resp.headers['date'])
343-
expect(resp.headers).to.have.property('expires')
344-
const tileExpires = new Date(resp.headers['expires'])
345-
expect(tileExpires).to.be.greaterThan(tileDate)
346-
/*expect(resp.body).to.contain('version="1.0.0"')*/
347-
})
348-
})
349-
350235
it('Project parameter is mandatory', function () {
351236
cy.request({
352237
url: '/index.php/lizmap/service/?repository=testsrepository&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetCapabilities',
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
// @ts-check
2+
import { test, expect } from '@playwright/test';
3+
4+
test.describe('WMTS Requests @requests @readonly', () => {
5+
test('WMTS Getcapabilities', async({ request }) => {
6+
let params = new URLSearchParams({
7+
repository: 'testsrepository',
8+
project: 'cache',
9+
SERVICE: 'WMTS',
10+
VERSION: '1.0.0',
11+
REQUEST: 'GetCapabilities',
12+
});
13+
let url = `/index.php/lizmap/service?${params}`;
14+
let response = await request.get(url, {});
15+
// check response
16+
expect(response.ok()).toBeTruthy();
17+
expect(response.status()).toBe(200);
18+
// check content-type header
19+
expect(response.headers()['content-type']).toBe('text/xml; charset=utf-8');
20+
// check headers
21+
expect(response.headers()).toHaveProperty('cache-control');
22+
expect(response.headers()['cache-control']).toBe('no-cache');
23+
expect(response.headers()).toHaveProperty('etag');
24+
const etag = response.headers()['etag'];
25+
expect(etag).not.toBe('');
26+
expect(etag).toHaveLength(43);
27+
28+
// check body
29+
let body = await response.text();
30+
expect(body).toContain('Capabilities');
31+
expect(body).toContain('version="1.0.0"');
32+
expect(body).toContain('xmlns="http://www.opengis.net/wmts/1.0"');
33+
expect(body).toContain('<ows:Identifier>Quartiers</ows:Identifier>');
34+
expect(body).toContain('<TileMatrixSet>EPSG:3857</TileMatrixSet>');
35+
36+
// GET request with the etag
37+
response = await request.get(url, {
38+
headers: {
39+
'If-None-Match': etag
40+
}
41+
});
42+
await expect(response).not.toBeOK();
43+
expect(response.status()).toBe(304);
44+
})
45+
46+
test('WMTS GetTile', async({ request }) => {
47+
let params = new URLSearchParams({
48+
repository: 'testsrepository',
49+
project: 'cache',
50+
SERVICE: 'WMTS',
51+
VERSION: '1.0.0',
52+
REQUEST: 'GetTile',
53+
LAYER: 'Quartiers',
54+
STYLE: 'default',
55+
TILEMATRIXSET: 'EPSG:3857',
56+
TILEMATRIX: '13',
57+
TILEROW: '2989',
58+
TILECOL: '4185',
59+
FORMAT: 'image/png',
60+
});
61+
let url = `/index.php/lizmap/service?${params}`;
62+
let response = await request.get(url, {});
63+
// check response
64+
await expect(response).toBeOK();
65+
expect(response.status()).toBe(200);
66+
// check content-type header
67+
expect(response.headers()['content-type']).toBe('image/png');
68+
// check headers
69+
expect(response.headers()).toHaveProperty('content-length');
70+
expect(response.headers()['content-length']).toBe('355'); // Transparent
71+
expect(response.headers()).toHaveProperty('date');
72+
expect(response.headers()).toHaveProperty('expires');
73+
let tileDate = new Date(response.headers()['date'])
74+
let tileExpires = new Date(response.headers()['expires'])
75+
expect(tileExpires > tileDate).toBeTruthy();
76+
77+
params = new URLSearchParams({
78+
repository: 'testsrepository',
79+
project: 'cache',
80+
SERVICE: 'WMTS',
81+
VERSION: '1.0.0',
82+
REQUEST: 'GetTile',
83+
LAYER: 'Quartiers',
84+
STYLE: 'default',
85+
TILEMATRIXSET: 'EPSG:3857',
86+
TILEMATRIX: '13',
87+
TILEROW: '2991',
88+
TILECOL: '4184',
89+
FORMAT: 'image/png',
90+
});
91+
url = `/index.php/lizmap/service?${params}`;
92+
response = await request.get(url, {});
93+
// check response
94+
await expect(response).toBeOK();
95+
expect(response.status()).toBe(200);
96+
// check content-type header
97+
expect(response.headers()['content-type']).toBe('image/png');
98+
// check headers
99+
expect(response.headers()).toHaveProperty('content-length');
100+
let contentLength = Number(response.headers()['content-length']);
101+
expect(contentLength).toBeGreaterThan(355); // Not transparent
102+
expect(contentLength).toBeGreaterThan(11000); // 11019
103+
expect(contentLength).toBeLessThan(11100); // 11019
104+
expect(response.headers()).toHaveProperty('date');
105+
expect(response.headers()).toHaveProperty('expires');
106+
tileDate = new Date(response.headers()['date'])
107+
tileExpires = new Date(response.headers()['expires'])
108+
expect(tileExpires > tileDate).toBeTruthy();
109+
110+
params = new URLSearchParams({
111+
repository: 'testsrepository',
112+
project: 'cache',
113+
SERVICE: 'WMTS',
114+
VERSION: '1.0.0',
115+
REQUEST: 'GetTile',
116+
LAYER: 'Quartiers',
117+
STYLE: 'default',
118+
TILEMATRIXSET: 'EPSG:3857',
119+
TILEMATRIX: '15',
120+
TILEROW: '11964',
121+
TILECOL: '16736',
122+
FORMAT: 'image/png',
123+
});
124+
url = `/index.php/lizmap/service?${params}`;
125+
response = await request.get(url, {});
126+
// check response
127+
await expect(response).toBeOK();
128+
expect(response.status()).toBe(200);
129+
// check content-type header
130+
expect(response.headers()['content-type']).toBe('image/png');
131+
// check headers
132+
expect(response.headers()).toHaveProperty('content-length');
133+
contentLength = Number(response.headers()['content-length']);
134+
expect(contentLength).toBeGreaterThan(355); // Not transparent
135+
expect(contentLength).toBeGreaterThan(650); // 687
136+
expect(contentLength).toBeLessThan(700); // 687
137+
expect(response.headers()).toHaveProperty('date');
138+
expect(response.headers()).toHaveProperty('expires');
139+
tileDate = new Date(response.headers()['date'])
140+
tileExpires = new Date(response.headers()['expires'])
141+
expect(tileExpires > tileDate).toBeTruthy();
142+
})
143+
})

tests/units/classes/Project/Qgis/LayerTreeGroupTest.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,46 @@ public function testConstruct(): void
5858
$this->assertEquals('publicbuildings_tramstop', $treeGroup->items[1]->name);
5959
}
6060

61+
public function testShortName(): void
62+
{
63+
64+
$xmlStr = '
65+
<layer-tree-group checked="Qt::Unchecked" expanded="1" name="overview">
66+
<customproperties>
67+
<Option type="Map">
68+
<Option name="wmsShortName" type="QString" value="Overview"></Option>
69+
</Option>
70+
</customproperties>
71+
<layer-tree-layer expanded="1" patch_size="-1,-1" providerKey="" legend_split_behavior="0" id="quartiers_c6fea644_09fc_4f73_b4e8_201a2cc9f131" name="quartiers_overview" checked="Qt::Unchecked" source="service=\'lizmapdb\' sslmode=prefer key=\'quartier\' estimatedmetadata=true srid=4326 type=MultiPolygon checkPrimaryKeyUnicity=\'1\' table=&quot;tests_projects&quot;.&quot;quartiers&quot; (geom)" legend_exp="">
72+
<customproperties>
73+
<Option></Option>
74+
</customproperties>
75+
</layer-tree-layer>
76+
</layer-tree-group>
77+
';
78+
$oXml = App\XmlTools::xmlReaderFromString($xmlStr);
79+
$treeGroup = Qgis\LayerTreeGroup::fromXmlReader($oXml);
80+
$this->assertEquals(null, $treeGroup->shortname);
81+
$this->assertEquals('Overview', $treeGroup->customproperties['wmsShortName']);
82+
83+
$xmlStr = '
84+
<layer-tree-group expanded="1" name="overview" checked="Qt::Unchecked" groupLayer="">
85+
<customproperties>
86+
<Option/>
87+
</customproperties>
88+
<shortname>Overview</shortname>
89+
<layer-tree-layer expanded="1" patch_size="-1,-1" providerKey="" legend_split_behavior="0" id="quartiers_c6fea644_09fc_4f73_b4e8_201a2cc9f131" name="quartiers_overview" checked="Qt::Unchecked" source="service=\'lizmapdb\' sslmode=prefer key=\'quartier\' estimatedmetadata=true srid=4326 type=MultiPolygon checkPrimaryKeyUnicity=\'1\' table=&quot;tests_projects&quot;.&quot;quartiers&quot; (geom)" legend_exp="">
90+
<customproperties>
91+
<Option/>
92+
</customproperties>
93+
</layer-tree-layer>
94+
</layer-tree-group>
95+
';
96+
$oXml = App\XmlTools::xmlReaderFromString($xmlStr);
97+
$treeGroup = Qgis\LayerTreeGroup::fromXmlReader($oXml);
98+
$this->assertEquals('Overview', $treeGroup->shortname);
99+
}
100+
61101
public function testEmpty(): void
62102
{
63103
$xmlStr = '

0 commit comments

Comments
 (0)