added version ID for simpler comparison (#2439)
This commit is contained in:
@@ -20,7 +20,7 @@ use JMS\Serializer\Annotation as Serializer;
|
|||||||
class Version
|
class Version
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Kimai Version, eg. "1.9"
|
* Kimai Version, eg. "1.14"
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*
|
*
|
||||||
@@ -29,6 +29,18 @@ class Version
|
|||||||
* @Serializer\Type(name="string")
|
* @Serializer\Type(name="string")
|
||||||
*/
|
*/
|
||||||
protected $version = Constants::VERSION;
|
protected $version = Constants::VERSION;
|
||||||
|
/**
|
||||||
|
* Kimai Version as integer, eg. 11400
|
||||||
|
*
|
||||||
|
* Follows the same logic as PHP_VERSION_ID, see https://www.php.net/manual/de/function.phpversion.php
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*
|
||||||
|
* @Serializer\Expose()
|
||||||
|
* @Serializer\Groups({"Default"})
|
||||||
|
* @Serializer\Type(name="integer")
|
||||||
|
*/
|
||||||
|
protected $versionId = Constants::VERSION_ID;
|
||||||
/**
|
/**
|
||||||
* Candidate: either "prod" or "dev"
|
* Candidate: either "prod" or "dev"
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -17,11 +17,15 @@ class Constants
|
|||||||
/**
|
/**
|
||||||
* The current release version
|
* The current release version
|
||||||
*/
|
*/
|
||||||
public const VERSION = '1.13';
|
public const VERSION = '1.14';
|
||||||
|
/**
|
||||||
|
* The current release: major * 10000 + minor * 100 + patch
|
||||||
|
*/
|
||||||
|
public const VERSION_ID = 11400;
|
||||||
/**
|
/**
|
||||||
* The current release status, either "stable" or "dev"
|
* The current release status, either "stable" or "dev"
|
||||||
*/
|
*/
|
||||||
public const STATUS = 'stable';
|
public const STATUS = 'dev';
|
||||||
/**
|
/**
|
||||||
* The software name
|
* The software name
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -46,12 +46,14 @@ class StatusControllerTest extends APIControllerBaseTest
|
|||||||
$this->assertIsArray($result);
|
$this->assertIsArray($result);
|
||||||
|
|
||||||
$this->assertArrayHasKey('version', $result);
|
$this->assertArrayHasKey('version', $result);
|
||||||
|
$this->assertArrayHasKey('versionId', $result);
|
||||||
$this->assertArrayHasKey('candidate', $result);
|
$this->assertArrayHasKey('candidate', $result);
|
||||||
$this->assertArrayHasKey('semver', $result);
|
$this->assertArrayHasKey('semver', $result);
|
||||||
$this->assertArrayHasKey('name', $result);
|
$this->assertArrayHasKey('name', $result);
|
||||||
$this->assertArrayHasKey('copyright', $result);
|
$this->assertArrayHasKey('copyright', $result);
|
||||||
|
|
||||||
$this->assertSame(Constants::VERSION, $result['version']);
|
$this->assertSame(Constants::VERSION, $result['version']);
|
||||||
|
$this->assertSame(Constants::VERSION_ID, $result['versionId']);
|
||||||
$this->assertEquals(Constants::STATUS, $result['candidate']);
|
$this->assertEquals(Constants::STATUS, $result['candidate']);
|
||||||
$this->assertEquals(Constants::VERSION . '-' . Constants::STATUS, $result['semver']);
|
$this->assertEquals(Constants::VERSION . '-' . Constants::STATUS, $result['semver']);
|
||||||
$this->assertEquals(Constants::NAME, $result['name']);
|
$this->assertEquals(Constants::NAME, $result['name']);
|
||||||
|
|||||||
34
tests/ConstantsTest.php
Normal file
34
tests/ConstantsTest.php
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Kimai time-tracking app.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace App\Tests;
|
||||||
|
|
||||||
|
use App\Constants;
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers \App\Constants
|
||||||
|
*/
|
||||||
|
class ConstantsTest extends TestCase
|
||||||
|
{
|
||||||
|
public function testBuild()
|
||||||
|
{
|
||||||
|
$version = Constants::VERSION;
|
||||||
|
$versionParts = explode('.', $version);
|
||||||
|
$major = (int) $versionParts[0];
|
||||||
|
$minor = (int) $versionParts[1];
|
||||||
|
$patch = isset($versionParts[2]) ? (int) $versionParts[2] : 0;
|
||||||
|
|
||||||
|
$expectedId = $major * 10000 + $minor * 100 + $patch;
|
||||||
|
|
||||||
|
self::assertEquals('1.14', Constants::VERSION, 'Invalid release number');
|
||||||
|
self::assertEquals('dev', Constants::STATUS, 'Invalid status');
|
||||||
|
self::assertEquals($expectedId, Constants::VERSION_ID, 'Invalid version ID');
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user