Skip to content

Commit

Permalink
Tests PHP: QgisProject does not use DOM
Browse files Browse the repository at this point in the history
  • Loading branch information
rldhont committed Oct 1, 2024
1 parent f1d8d39 commit 73c4107
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 1 deletion.
51 changes: 51 additions & 0 deletions tests/units/classes/Project/QgisProjectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,8 @@ public function testEmbeddedRelation()
$testQgis->setPath($file);
$testQgis->readXMLProjectTest($file);

$this->assertNull($testQgis->getTheXmlAttribute());

//check layers
foreach ($testQgis->getLayers() as $layers){
$this->assertEquals($layers["embedded"],1);
Expand Down Expand Up @@ -365,6 +367,8 @@ public function testEmbeddedRelation()
$testQgisParent->setPath($file);
$testQgisParent->readXMLProjectTest($file);

$this->assertNull($testQgis->getTheXmlAttribute());

$parentRelations = $testQgisParent->getRelations();
$parentRelationFields = $testQgisParent->getRelationsFields();
$this->assertEquals($relations,$parentRelations);
Expand Down Expand Up @@ -497,6 +501,8 @@ public function testReadEditionFormsForEmbeddedLayers()
$testQgis->setPath($file);
$testQgis->readXMLProjectTest($file);

$this->assertNull($testQgis->getTheXmlAttribute());

$cfg = json_decode(file_get_contents($file.'.cfg'));
$config = new Project\ProjectConfig($cfg);

Expand Down Expand Up @@ -2217,7 +2223,52 @@ public function testUploadField()
$this->assertEquals('', $remotePath->getUploadAccept());
$this->assertEquals(array(), $remotePath->getMimeTypes());
$this->assertFalse($remotePath->isImageUpload());
}

public function testReadProject()
{
//$services = new lizmapServices(array(), (object) array(), false, '', '');
$testQgis = new qgisProjectForTests(array());
$file = __DIR__.'/Ressources/montpellier.qgs';
$testQgis->setPath($file);
$testQgis->readXMLProjectTest($file);

$this->assertNull($testQgis->getTheXmlAttribute());

$cfg = json_decode(file_get_contents($file.'.cfg'));
$config = new Project\ProjectConfig($cfg);

$testQgis->setPropertiesAfterRead($config);

$this->assertNull($testQgis->getTheXmlAttribute());

$testQgis->getPrintTemplates();

$this->assertNull($testQgis->getTheXmlAttribute());

$testQgis->readLocateByLayer($config->getLocateByLayer());

$this->assertNull($testQgis->getTheXmlAttribute());

$testQgis->readEditionLayers($config->getEditionLayers());

$this->assertNull($testQgis->getTheXmlAttribute());

$testQgis->readLayersOrder($config->getLayers());

$this->assertNull($testQgis->getTheXmlAttribute());

$testQgis->readAttributeLayers($config->getAttributeLayers());

$this->assertNull($testQgis->getTheXmlAttribute());

$testQgis->readEditionForms($config->getEditionLayers(), null);

$this->assertNull($testQgis->getTheXmlAttribute());

$testQgis->readLayersLabeledFieldsConfig($config->getLayersWithLabels(), null);

$this->assertNull($testQgis->getTheXmlAttribute());

}
}
7 changes: 6 additions & 1 deletion tests/units/testslib/QgisProjectForTests.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class QgisProjectForTests extends QgisProject
{
public function __construct($data = null)
{
if ($data) {
if ($data !== null) {
parent::__construct(null, new lizmapServices(null, (object) array(), false, '', ''), new ContextForTests(), $data);
}
}
Expand Down Expand Up @@ -92,6 +92,11 @@ public function setLayerOpacityForTest($cfg)
return $this->setLayerOpacity($cfg);
}

public function getTheXmlAttribute()
{
return $this->xml;
}

public function getXmlForTest()
{
return $this->getXml();
Expand Down

0 comments on commit 73c4107

Please sign in to comment.