Output of the "Get a random value from an array created on the fly" PHP snippet

Environment:

  • Strangebuzz Snippet VM: 2.2.1
  • PHP: 7.4

Code execution output:

Random value 🎲: Bac+2

 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 Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;

/**
 * @covers Snippet42Trait
 */
final class Snippet42Test extends KernelTestCase
{
    /**
     * @covers Snippet42Trait::snippet42
     */
    public function testSnippet42(): void
    {
        $value = array_rand(array_flip(['Première', 'Bac+2', 'Terminale']));
        self::assertContains($value, ['Première', 'Bac+2', 'Terminale']);
    }
}