Skip to content

Commit 17997cf

Browse files
committed
minor twigphp#4214 Add test about Environment version constants. (VincentLanglet)
This PR was merged into the 3.x branch. Discussion ---------- Add test about Environment version constants. Hi `@fabpot` The Environment Version constants seems to be manually updated. https://github.com/twigphp/Twig/blob/fe36e084b4e208c44e30886053c8594bb99bd78f/src/Environment.php#L46-L51 A mistake was made on the 3.11 version, the MAJOR_VERSION was set to 4 instead of 3 https://github.com/twigphp/Twig/blob/e80fb8ebba85c7341a97a9ebf825d7fd4b77708d/src/Environment.php#L48 It was fixed in another version, but I think it could be useful to have some test about the consistency of all those constants. Such test would have fail for the 3.11 version and avoid the mistake. Commits ------- 254abc8 Add test about version
2 parents 675cb2d + 254abc8 commit 17997cf

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

tests/EnvironmentTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,21 @@ class EnvironmentTest extends TestCase
3838
{
3939
use ExpectDeprecationTrait;
4040

41+
public function testVersionConstants()
42+
{
43+
$version = Environment::VERSION;
44+
$exploded = explode('-', $version);
45+
$this->assertEquals(Environment::EXTRA_VERSION, $exploded[1] ?? '');
46+
47+
$version = $exploded[0];
48+
$exploded = explode('.', $version);
49+
$this->assertEquals(Environment::MAJOR_VERSION, $exploded[0]);
50+
$this->assertEquals(Environment::MINOR_VERSION, $exploded[1]);
51+
$this->assertEquals(Environment::RELEASE_VERSION, $exploded[2]);
52+
53+
$this->assertEquals(Environment::VERSION_ID, \sprintf('%s0%s0%s', $exploded[0], $exploded[1], $exploded[2]));
54+
}
55+
4156
public function testAutoescapeOption()
4257
{
4358
$loader = new ArrayLoader([

0 commit comments

Comments
 (0)