public static generateRandomSecret ( Composer\Script\Event $event ) | ||
$event | Composer\Script\Event |
public static function generateRandomSecret(Event $event)
{
$extra = $event->getComposer()->getPackage()->getExtra();
if (!isset($extra['incenteev-parameters']) || !self::canGenerateSecret($extra['incenteev-parameters'])) {
return;
}
if (!function_exists('random_bytes')) {
self::loadRandomCompat($event);
}
putenv(static::RANDOM_SECRET_NAME . '=' . bin2hex(random_bytes(32)));
}
/** * Tests that no secret is generated if at least one of multiple configuration files exists. */ public function testGeneratesNoRandomSecretIfFileExistsArray() { $this->assertRandomSecretDoesNotExist(); touch(__DIR__ . '/../Fixtures/app/config/parameters.yml'); $this->handler->generateRandomSecret($this->getComposerEvent(['incenteev-parameters' => [['file' => __DIR__ . '/../Fixtures/app/config/parameters.yml'], ['file' => __DIR__ . '/../Fixtures/app/config/test.yml']]])); unlink(__DIR__ . '/../Fixtures/app/config/parameters.yml'); $this->assertRandomSecretDoesNotExist(); }