Skip to content

Commit eeac8d0

Browse files
committed
tests : add unit test for empty value in qgs + docstring
1 parent 7446307 commit eeac8d0

File tree

3 files changed

+2568
-3
lines changed

3 files changed

+2568
-3
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222
* @property string $version
2323
* @property string $projectname
2424
* @property string $title
25-
* @property null|string $saveDateTime
26-
* @property null|string $saveUser
27-
* @property null|string $saveUserFull
25+
* @property string $saveDateTime
26+
* @property string $saveUser
27+
* @property string $saveUserFull
2828
* @property SpatialRefSys $projectCrs
2929
* @property ProjectProperties $properties
3030
* @property LayerTreeRoot $layerTreeRoot

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,4 +262,23 @@ public function testJsonEncode(): void
262262
$this->assertNotNull($json);
263263
$this->assertStringStartsWith('{"version":', $json);
264264
}
265+
266+
public function testProjetWithMissingProjetInfo(): void
267+
{
268+
$xml_path_invalid = __DIR__.'/../../Project/Ressources/project_empty_qgis_tag.qgs';
269+
270+
$oXml = App\XmlTools::xmlReaderFromFile($xml_path_invalid);
271+
$project = Qgis\ProjectInfo::fromXmlReader($oXml);
272+
// missing values on XML will be empty string
273+
$emptyProps = array(
274+
'version',
275+
'projectname',
276+
'saveDateTime',
277+
'saveUser',
278+
'saveUserFull',
279+
);
280+
foreach ($emptyProps as $prop ) {
281+
$this->assertEmpty($project->{$prop});
282+
}
283+
}
265284
}

0 commit comments

Comments
 (0)