Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

method to check if projet is compatible with target version #4078

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions lizmap/modules/lizmap/lib/Project/Project.php
Original file line number Diff line number Diff line change
Expand Up @@ -2313,6 +2313,19 @@ public function needsUpdateWarning()
return false;
}

/**
* test if provided version (int format 30520).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this docstring needs to be rephrased ?

*
* @param int $targetVersion the desired version (maj.min) as int (<Maj><Min as 2 digit>00)
*/
public function isCompatibleWithVersion(int $targetVersion): bool
{
// the projet version written for N are supported until N+2
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// the projet version written for N are supported until N+2
// the project version written for version N are supported until version N+2

$maxSupportedVersion = $this->getLizmapWebClientTargetVersion() + 200;

return $maxSupportedVersion >= $targetVersion;
}

/**
* Check acl rights on the project.
*
Expand Down
17 changes: 17 additions & 0 deletions tests/units/classes/Project/ProjectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -411,4 +411,21 @@ public function testCheckAcl($aclData, $options, $expectedRet)
$proj->setCfg($config);
$this->assertEquals($expectedRet, $proj->checkAcl());
}

public function testVersion() {
$rep = new Project\Repository('key', array(), null, null, null);
$context = new ContextForTests();
/**
* no "lizmap_web_client_target_version" value in metadata,
* value will be set as 30200
*/
$file = __DIR__.'/Ressources/events.qgs.cfg';
$data = json_decode(file_get_contents($file));
$config = new Project\ProjectConfig($data);
$proj = new ProjectForTests($context);
$proj->setRepo($rep);
$proj->setCfg($config);
$this->assertTrue($proj->isCompatibleWithVersion(30400), 'n+2 version still compatible');
$this->assertFalse($proj->isCompatibleWithVersion(30500), '>n+3 version break compatibility');
}
}
Loading