Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

1001 B
Raw Blame
<?php

it('formats values so that parseEnvFormatToArray reads them back unchanged', function (string $value) {
    $formatted = formatEnvValueForDevView($value);

    expect(parseEnvFormatToArray("KEY={$formatted}"))
        ->toBe(['KEY' => ['value' => $value, 'comment' => null]]);
})->with([
    'plain' => ['plain-value'],
    'empty' => [''],
    'double quoted' => ['"abc"'],
    'single quoted' => ["'\$FOO'"],
    'leading double quote only' => ['"abc'],
    'quotes inside' => ['He said "hi" and \'bye\''],
    'hash after whitespace' => ['value #not-a-comment'],
    'hash without whitespace' => ['value#hash'],
    'double quoted with suffix' => ['"Company :: App" <[email protected]>'],
]);

it('returns null for values that the env format cannot hold', function (string $value) {
    expect(formatEnvValueForDevView($value))->toBeNull();
})->with([
    'both quote types and a leading quote' => ['\'"Company :: App" <[email protected]>\''],
    'line break' => ["first\nsecond"],
]);