diff --git a/tests/units/classes/Project/QgisProjectTest.php b/tests/units/classes/Project/QgisProjectTest.php index 73407dd27d..86199d660e 100644 --- a/tests/units/classes/Project/QgisProjectTest.php +++ b/tests/units/classes/Project/QgisProjectTest.php @@ -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); @@ -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); @@ -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); @@ -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()); } } diff --git a/tests/units/testslib/QgisProjectForTests.php b/tests/units/testslib/QgisProjectForTests.php index 8ad949013c..ef67591fd6 100644 --- a/tests/units/testslib/QgisProjectForTests.php +++ b/tests/units/testslib/QgisProjectForTests.php @@ -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); } } @@ -92,6 +92,11 @@ public function setLayerOpacityForTest($cfg) return $this->setLayerOpacity($cfg); } + public function getTheXmlAttribute() + { + return $this->xml; + } + public function getXmlForTest() { return $this->getXml();