Output of the "Get the Symfony and PHP versions of the current environment" Symfony snippet

Environment:

  • Strangebuzz Snippet VM: 2.1.0
  • PHP: 7.4
  • Symfony: 5.1.0

Code execution output:

Array
(
    [php_minor_version] => 7.4
    [php_version] => 7.4.6
    [sf_major_version] => 5
    [sf_minor_version] => 5.1
    [sf_version] => 5.1.0
)

 Back to the code  ≪ this.showUnitTest ? this.trans.hide_unit_test : this.trans.show_unit_test ≫  More on Stackoverflow  Random snippet

<?php declare(strict_types=1);

namespace App\Tests\Controller\Snippets;

use App\Twig\Extension\EnvExtension;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;

/**
 * @covers Snippet12Trait
 */
final class Snippet12Test extends KernelTestCase
{
    /**
     * @var EnvExtension
     */
    private $envExtension;

    protected function setUp(): void
    {
        self::bootKernel();
        $this->envExtension = self::$container->get(EnvExtension::class);
    }

    /**
     * @covers Snippet12Trait::snippet12
     */
    public function testSnippet12(): void
    {
        $globals = $this->envExtension->getGlobals();
        $this->assertArrayHasKey('php_version', $globals);
        $this->assertArrayHasKey('php_minor_version', $globals);
        $this->assertArrayHasKey('sf_version', $globals);
        $this->assertArrayHasKey('sf_minor_version', $globals);
    }
}