added version ID for simpler comparison (#2439)

This commit is contained in:
Kevin Papst
2021-03-16 11:24:19 +01:00
committed by GitHub
parent e1c9af795c
commit 75e62b800c
4 changed files with 55 additions and 3 deletions

View File

@@ -46,12 +46,14 @@ class StatusControllerTest extends APIControllerBaseTest
$this->assertIsArray($result);
$this->assertArrayHasKey('version', $result);
$this->assertArrayHasKey('versionId', $result);
$this->assertArrayHasKey('candidate', $result);
$this->assertArrayHasKey('semver', $result);
$this->assertArrayHasKey('name', $result);
$this->assertArrayHasKey('copyright', $result);
$this->assertSame(Constants::VERSION, $result['version']);
$this->assertSame(Constants::VERSION_ID, $result['versionId']);
$this->assertEquals(Constants::STATUS, $result['candidate']);
$this->assertEquals(Constants::VERSION . '-' . Constants::STATUS, $result['semver']);
$this->assertEquals(Constants::NAME, $result['name']);

34
tests/ConstantsTest.php Normal file
View 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');
}
}