create-berna-stencil 2.6.2 → 2.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/_tools/buildJs.js +1 -1
- package/_tools/cleanOutput.js +1 -1
- package/package.json +2 -2
- package/out/.htaccess +0 -16
- package/out/404.html +0 -163
- package/out/assets/brand/favicon.svg +0 -37
- package/out/assets/brand/logo.svg +0 -37
- package/out/backend/.htaccess +0 -7
- package/out/backend/_core/composer.json +0 -5
- package/out/backend/_core/composer.lock +0 -492
- package/out/backend/_core/index.php +0 -148
- package/out/backend/_core/init.php +0 -34
- package/out/backend/_core/modules/RateLimiter.php +0 -31
- package/out/backend/_core/modules/Response.php +0 -49
- package/out/backend/_core/vendor/autoload.php +0 -22
- package/out/backend/_core/vendor/composer/ClassLoader.php +0 -579
- package/out/backend/_core/vendor/composer/InstalledVersions.php +0 -396
- package/out/backend/_core/vendor/composer/LICENSE +0 -21
- package/out/backend/_core/vendor/composer/autoload_classmap.php +0 -15
- package/out/backend/_core/vendor/composer/autoload_files.php +0 -12
- package/out/backend/_core/vendor/composer/autoload_namespaces.php +0 -9
- package/out/backend/_core/vendor/composer/autoload_psr4.php +0 -15
- package/out/backend/_core/vendor/composer/autoload_real.php +0 -50
- package/out/backend/_core/vendor/composer/autoload_static.php +0 -81
- package/out/backend/_core/vendor/composer/installed.json +0 -497
- package/out/backend/_core/vendor/composer/installed.php +0 -77
- package/out/backend/_core/vendor/composer/platform_check.php +0 -25
- package/out/backend/_core/vendor/graham-campbell/result-type/CHANGELOG.md +0 -53
- package/out/backend/_core/vendor/graham-campbell/result-type/LICENSE +0 -21
- package/out/backend/_core/vendor/graham-campbell/result-type/README.md +0 -42
- package/out/backend/_core/vendor/graham-campbell/result-type/composer.json +0 -33
- package/out/backend/_core/vendor/graham-campbell/result-type/phpunit.xml.dist +0 -13
- package/out/backend/_core/vendor/graham-campbell/result-type/src/Error.php +0 -121
- package/out/backend/_core/vendor/graham-campbell/result-type/src/Result.php +0 -69
- package/out/backend/_core/vendor/graham-campbell/result-type/src/Success.php +0 -120
- package/out/backend/_core/vendor/graham-campbell/result-type/tests/ResultTest.php +0 -95
- package/out/backend/_core/vendor/phpoption/phpoption/LICENSE +0 -201
- package/out/backend/_core/vendor/phpoption/phpoption/Makefile +0 -17
- package/out/backend/_core/vendor/phpoption/phpoption/README.md +0 -201
- package/out/backend/_core/vendor/phpoption/phpoption/composer.json +0 -50
- package/out/backend/_core/vendor/phpoption/phpoption/phpstan-baseline.neon +0 -44
- package/out/backend/_core/vendor/phpoption/phpoption/phpstan.neon.dist +0 -7
- package/out/backend/_core/vendor/phpoption/phpoption/phpunit.xml.dist +0 -13
- package/out/backend/_core/vendor/phpoption/phpoption/src/PhpOption/LazyOption.php +0 -175
- package/out/backend/_core/vendor/phpoption/phpoption/src/PhpOption/None.php +0 -136
- package/out/backend/_core/vendor/phpoption/phpoption/src/PhpOption/Option.php +0 -434
- package/out/backend/_core/vendor/phpoption/phpoption/src/PhpOption/Some.php +0 -169
- package/out/backend/_core/vendor/phpoption/phpoption/tests/PhpOption/Tests/EnsureTest.php +0 -72
- package/out/backend/_core/vendor/phpoption/phpoption/tests/PhpOption/Tests/LazyOptionTest.php +0 -357
- package/out/backend/_core/vendor/phpoption/phpoption/tests/PhpOption/Tests/NoneTest.php +0 -153
- package/out/backend/_core/vendor/phpoption/phpoption/tests/PhpOption/Tests/OptionTest.php +0 -166
- package/out/backend/_core/vendor/phpoption/phpoption/tests/PhpOption/Tests/SomeTest.php +0 -194
- package/out/backend/_core/vendor/phpoption/phpoption/tests/bootstrap.php +0 -8
- package/out/backend/_core/vendor/phpoption/phpoption/vendor-bin/phpstan/composer.json +0 -8
- package/out/backend/_core/vendor/symfony/polyfill-ctype/Ctype.php +0 -232
- package/out/backend/_core/vendor/symfony/polyfill-ctype/LICENSE +0 -19
- package/out/backend/_core/vendor/symfony/polyfill-ctype/README.md +0 -12
- package/out/backend/_core/vendor/symfony/polyfill-ctype/bootstrap.php +0 -50
- package/out/backend/_core/vendor/symfony/polyfill-ctype/bootstrap80.php +0 -46
- package/out/backend/_core/vendor/symfony/polyfill-ctype/composer.json +0 -38
- package/out/backend/_core/vendor/symfony/polyfill-mbstring/LICENSE +0 -19
- package/out/backend/_core/vendor/symfony/polyfill-mbstring/Mbstring.php +0 -1077
- package/out/backend/_core/vendor/symfony/polyfill-mbstring/README.md +0 -13
- package/out/backend/_core/vendor/symfony/polyfill-mbstring/Resources/unidata/caseFolding.php +0 -119
- package/out/backend/_core/vendor/symfony/polyfill-mbstring/Resources/unidata/lowerCase.php +0 -1397
- package/out/backend/_core/vendor/symfony/polyfill-mbstring/Resources/unidata/titleCaseRegexp.php +0 -5
- package/out/backend/_core/vendor/symfony/polyfill-mbstring/Resources/unidata/upperCase.php +0 -1489
- package/out/backend/_core/vendor/symfony/polyfill-mbstring/bootstrap.php +0 -171
- package/out/backend/_core/vendor/symfony/polyfill-mbstring/bootstrap80.php +0 -167
- package/out/backend/_core/vendor/symfony/polyfill-mbstring/composer.json +0 -39
- package/out/backend/_core/vendor/symfony/polyfill-php80/LICENSE +0 -19
- package/out/backend/_core/vendor/symfony/polyfill-php80/Php80.php +0 -115
- package/out/backend/_core/vendor/symfony/polyfill-php80/PhpToken.php +0 -106
- package/out/backend/_core/vendor/symfony/polyfill-php80/README.md +0 -25
- package/out/backend/_core/vendor/symfony/polyfill-php80/Resources/stubs/Attribute.php +0 -31
- package/out/backend/_core/vendor/symfony/polyfill-php80/Resources/stubs/PhpToken.php +0 -16
- package/out/backend/_core/vendor/symfony/polyfill-php80/Resources/stubs/Stringable.php +0 -20
- package/out/backend/_core/vendor/symfony/polyfill-php80/Resources/stubs/UnhandledMatchError.php +0 -16
- package/out/backend/_core/vendor/symfony/polyfill-php80/Resources/stubs/ValueError.php +0 -16
- package/out/backend/_core/vendor/symfony/polyfill-php80/bootstrap.php +0 -42
- package/out/backend/_core/vendor/symfony/polyfill-php80/composer.json +0 -37
- package/out/backend/_core/vendor/vlucas/phpdotenv/.editorconfig +0 -15
- package/out/backend/_core/vendor/vlucas/phpdotenv/LICENSE +0 -30
- package/out/backend/_core/vendor/vlucas/phpdotenv/Makefile +0 -17
- package/out/backend/_core/vendor/vlucas/phpdotenv/README.md +0 -370
- package/out/backend/_core/vendor/vlucas/phpdotenv/UPGRADING.md +0 -196
- package/out/backend/_core/vendor/vlucas/phpdotenv/composer.json +0 -60
- package/out/backend/_core/vendor/vlucas/phpdotenv/phpstan-baseline.neon +0 -157
- package/out/backend/_core/vendor/vlucas/phpdotenv/phpstan.neon.dist +0 -7
- package/out/backend/_core/vendor/vlucas/phpdotenv/phpunit.xml.dist +0 -13
- package/out/backend/_core/vendor/vlucas/phpdotenv/src/Dotenv.php +0 -267
- package/out/backend/_core/vendor/vlucas/phpdotenv/src/Exception/ExceptionInterface.php +0 -12
- package/out/backend/_core/vendor/vlucas/phpdotenv/src/Exception/InvalidEncodingException.php +0 -12
- package/out/backend/_core/vendor/vlucas/phpdotenv/src/Exception/InvalidFileException.php +0 -12
- package/out/backend/_core/vendor/vlucas/phpdotenv/src/Exception/InvalidPathException.php +0 -12
- package/out/backend/_core/vendor/vlucas/phpdotenv/src/Exception/ValidationException.php +0 -12
- package/out/backend/_core/vendor/vlucas/phpdotenv/src/Loader/Loader.php +0 -48
- package/out/backend/_core/vendor/vlucas/phpdotenv/src/Loader/LoaderInterface.php +0 -20
- package/out/backend/_core/vendor/vlucas/phpdotenv/src/Loader/Resolver.php +0 -65
- package/out/backend/_core/vendor/vlucas/phpdotenv/src/Parser/Entry.php +0 -59
- package/out/backend/_core/vendor/vlucas/phpdotenv/src/Parser/EntryParser.php +0 -299
- package/out/backend/_core/vendor/vlucas/phpdotenv/src/Parser/Lexer.php +0 -58
- package/out/backend/_core/vendor/vlucas/phpdotenv/src/Parser/Lines.php +0 -127
- package/out/backend/_core/vendor/vlucas/phpdotenv/src/Parser/Parser.php +0 -53
- package/out/backend/_core/vendor/vlucas/phpdotenv/src/Parser/ParserInterface.php +0 -19
- package/out/backend/_core/vendor/vlucas/phpdotenv/src/Parser/Value.php +0 -88
- package/out/backend/_core/vendor/vlucas/phpdotenv/src/Repository/Adapter/AdapterInterface.php +0 -15
- package/out/backend/_core/vendor/vlucas/phpdotenv/src/Repository/Adapter/ApacheAdapter.php +0 -89
- package/out/backend/_core/vendor/vlucas/phpdotenv/src/Repository/Adapter/ArrayAdapter.php +0 -80
- package/out/backend/_core/vendor/vlucas/phpdotenv/src/Repository/Adapter/EnvConstAdapter.php +0 -88
- package/out/backend/_core/vendor/vlucas/phpdotenv/src/Repository/Adapter/GuardedWriter.php +0 -85
- package/out/backend/_core/vendor/vlucas/phpdotenv/src/Repository/Adapter/ImmutableWriter.php +0 -110
- package/out/backend/_core/vendor/vlucas/phpdotenv/src/Repository/Adapter/MultiReader.php +0 -48
- package/out/backend/_core/vendor/vlucas/phpdotenv/src/Repository/Adapter/MultiWriter.php +0 -64
- package/out/backend/_core/vendor/vlucas/phpdotenv/src/Repository/Adapter/PutenvAdapter.php +0 -91
- package/out/backend/_core/vendor/vlucas/phpdotenv/src/Repository/Adapter/ReaderInterface.php +0 -17
- package/out/backend/_core/vendor/vlucas/phpdotenv/src/Repository/Adapter/ReplacingWriter.php +0 -104
- package/out/backend/_core/vendor/vlucas/phpdotenv/src/Repository/Adapter/ServerConstAdapter.php +0 -88
- package/out/backend/_core/vendor/vlucas/phpdotenv/src/Repository/Adapter/WriterInterface.php +0 -27
- package/out/backend/_core/vendor/vlucas/phpdotenv/src/Repository/AdapterRepository.php +0 -107
- package/out/backend/_core/vendor/vlucas/phpdotenv/src/Repository/RepositoryBuilder.php +0 -272
- package/out/backend/_core/vendor/vlucas/phpdotenv/src/Repository/RepositoryInterface.php +0 -51
- package/out/backend/_core/vendor/vlucas/phpdotenv/src/Store/File/Paths.php +0 -44
- package/out/backend/_core/vendor/vlucas/phpdotenv/src/Store/File/Reader.php +0 -81
- package/out/backend/_core/vendor/vlucas/phpdotenv/src/Store/FileStore.php +0 -72
- package/out/backend/_core/vendor/vlucas/phpdotenv/src/Store/StoreBuilder.php +0 -141
- package/out/backend/_core/vendor/vlucas/phpdotenv/src/Store/StoreInterface.php +0 -17
- package/out/backend/_core/vendor/vlucas/phpdotenv/src/Store/StringStore.php +0 -37
- package/out/backend/_core/vendor/vlucas/phpdotenv/src/Util/Regex.php +0 -112
- package/out/backend/_core/vendor/vlucas/phpdotenv/src/Util/Str.php +0 -108
- package/out/backend/_core/vendor/vlucas/phpdotenv/src/Validator.php +0 -207
- package/out/backend/_core/vendor/vlucas/phpdotenv/tests/Dotenv/DotenvTest.php +0 -387
- package/out/backend/_core/vendor/vlucas/phpdotenv/tests/Dotenv/Loader/LoaderTest.php +0 -86
- package/out/backend/_core/vendor/vlucas/phpdotenv/tests/Dotenv/Parser/EntryParserTest.php +0 -234
- package/out/backend/_core/vendor/vlucas/phpdotenv/tests/Dotenv/Parser/LexerTest.php +0 -40
- package/out/backend/_core/vendor/vlucas/phpdotenv/tests/Dotenv/Parser/LinesTest.php +0 -53
- package/out/backend/_core/vendor/vlucas/phpdotenv/tests/Dotenv/Parser/ParserTest.php +0 -98
- package/out/backend/_core/vendor/vlucas/phpdotenv/tests/Dotenv/Repository/Adapter/ArrayAdapterTest.php +0 -57
- package/out/backend/_core/vendor/vlucas/phpdotenv/tests/Dotenv/Repository/Adapter/EnvConstAdapterTest.php +0 -75
- package/out/backend/_core/vendor/vlucas/phpdotenv/tests/Dotenv/Repository/Adapter/PutenvAdapterTest.php +0 -52
- package/out/backend/_core/vendor/vlucas/phpdotenv/tests/Dotenv/Repository/Adapter/ServerConstAdapterTest.php +0 -75
- package/out/backend/_core/vendor/vlucas/phpdotenv/tests/Dotenv/Repository/RepositoryTest.php +0 -305
- package/out/backend/_core/vendor/vlucas/phpdotenv/tests/Dotenv/Store/StoreTest.php +0 -141
- package/out/backend/_core/vendor/vlucas/phpdotenv/tests/Dotenv/ValidatorTest.php +0 -479
- package/out/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/.env +0 -5
- package/out/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/assertions.env +0 -18
- package/out/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/booleans.env +0 -33
- package/out/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/commented.env +0 -15
- package/out/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/empty.env +0 -1
- package/out/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/example.env +0 -1
- package/out/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/exported.env +0 -7
- package/out/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/immutable.env +0 -1
- package/out/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/integers.env +0 -17
- package/out/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/large.env +0 -2
- package/out/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/multibyte.env +0 -3
- package/out/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/multiline.env +0 -14
- package/out/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/multiple.env +0 -4
- package/out/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/mutable.env +0 -1
- package/out/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/nested.env +0 -15
- package/out/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/quoted.env +0 -11
- package/out/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/specialchars.env +0 -8
- package/out/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/unicodevarnames.env +0 -2
- package/out/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/utf8-with-bom-encoding.env +0 -3
- package/out/backend/_core/vendor/vlucas/phpdotenv/tests/fixtures/env/windows.env +0 -1
- package/out/backend/_core/vendor/vlucas/phpdotenv/vendor-bin/phpstan/composer.json +0 -15
- package/out/backend/api/protected/example-protected.php +0 -17
- package/out/backend/api/public/example-public.php +0 -17
- package/out/backend/database/Database.php +0 -24
- package/out/backend/database/migrations/create_example_db.sql +0 -1
- package/out/backend/web.config +0 -17
- package/out/css/fonts/bootstrap-icons.woff +0 -0
- package/out/css/fonts/bootstrap-icons.woff2 +0 -0
- package/out/css/github-markdown-dark.css +0 -1124
- package/out/css/github-markdown-light.css +0 -1124
- package/out/css/pages/404.css +0 -21517
- package/out/css/pages/homepage.css +0 -21508
- package/out/data/site.json +0 -44
- package/out/index.html +0 -1147
- package/out/js/bootstrap.bundle.min.js +0 -7
- package/out/js/pages/js/pages/404.js +0 -6
- package/out/js/pages/js/pages/homepage.js +0 -6
- package/out/js/pages/ts/pages/404.js +0 -6
- package/out/js/pages/ts/pages/homepage.js +0 -6
- package/out/llms.txt +0 -14
- package/out/robots.txt +0 -4
- package/out/sitemap.xml +0 -15
- package/out/web.config +0 -27
|
@@ -1,207 +0,0 @@
|
|
|
1
|
-
<?php
|
|
2
|
-
|
|
3
|
-
declare(strict_types=1);
|
|
4
|
-
|
|
5
|
-
namespace Dotenv;
|
|
6
|
-
|
|
7
|
-
use Dotenv\Exception\ValidationException;
|
|
8
|
-
use Dotenv\Repository\RepositoryInterface;
|
|
9
|
-
use Dotenv\Util\Regex;
|
|
10
|
-
use Dotenv\Util\Str;
|
|
11
|
-
|
|
12
|
-
class Validator
|
|
13
|
-
{
|
|
14
|
-
/**
|
|
15
|
-
* The environment repository instance.
|
|
16
|
-
*
|
|
17
|
-
* @var \Dotenv\Repository\RepositoryInterface
|
|
18
|
-
*/
|
|
19
|
-
private $repository;
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* The variables to validate.
|
|
23
|
-
*
|
|
24
|
-
* @var string[]
|
|
25
|
-
*/
|
|
26
|
-
private $variables;
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Create a new validator instance.
|
|
30
|
-
*
|
|
31
|
-
* @param \Dotenv\Repository\RepositoryInterface $repository
|
|
32
|
-
* @param string[] $variables
|
|
33
|
-
*
|
|
34
|
-
* @return void
|
|
35
|
-
*/
|
|
36
|
-
public function __construct(RepositoryInterface $repository, array $variables)
|
|
37
|
-
{
|
|
38
|
-
$this->repository = $repository;
|
|
39
|
-
$this->variables = $variables;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Assert that each variable is present.
|
|
44
|
-
*
|
|
45
|
-
* @throws \Dotenv\Exception\ValidationException
|
|
46
|
-
*
|
|
47
|
-
* @return \Dotenv\Validator
|
|
48
|
-
*/
|
|
49
|
-
public function required()
|
|
50
|
-
{
|
|
51
|
-
return $this->assert(
|
|
52
|
-
static function (?string $value) {
|
|
53
|
-
return $value !== null;
|
|
54
|
-
},
|
|
55
|
-
'is missing'
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Assert that each variable is not empty.
|
|
61
|
-
*
|
|
62
|
-
* @throws \Dotenv\Exception\ValidationException
|
|
63
|
-
*
|
|
64
|
-
* @return \Dotenv\Validator
|
|
65
|
-
*/
|
|
66
|
-
public function notEmpty()
|
|
67
|
-
{
|
|
68
|
-
return $this->assertNullable(
|
|
69
|
-
static function (string $value) {
|
|
70
|
-
return Str::len(\trim($value)) > 0;
|
|
71
|
-
},
|
|
72
|
-
'is empty'
|
|
73
|
-
);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Assert that each specified variable is an integer.
|
|
78
|
-
*
|
|
79
|
-
* @throws \Dotenv\Exception\ValidationException
|
|
80
|
-
*
|
|
81
|
-
* @return \Dotenv\Validator
|
|
82
|
-
*/
|
|
83
|
-
public function isInteger()
|
|
84
|
-
{
|
|
85
|
-
return $this->assertNullable(
|
|
86
|
-
static function (string $value) {
|
|
87
|
-
return \ctype_digit($value);
|
|
88
|
-
},
|
|
89
|
-
'is not an integer'
|
|
90
|
-
);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Assert that each specified variable is a boolean.
|
|
95
|
-
*
|
|
96
|
-
* @throws \Dotenv\Exception\ValidationException
|
|
97
|
-
*
|
|
98
|
-
* @return \Dotenv\Validator
|
|
99
|
-
*/
|
|
100
|
-
public function isBoolean()
|
|
101
|
-
{
|
|
102
|
-
return $this->assertNullable(
|
|
103
|
-
static function (string $value) {
|
|
104
|
-
if ($value === '') {
|
|
105
|
-
return false;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
return \filter_var($value, \FILTER_VALIDATE_BOOLEAN, \FILTER_NULL_ON_FAILURE) !== null;
|
|
109
|
-
},
|
|
110
|
-
'is not a boolean'
|
|
111
|
-
);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Assert that each variable is amongst the given choices.
|
|
116
|
-
*
|
|
117
|
-
* @param string[] $choices
|
|
118
|
-
*
|
|
119
|
-
* @throws \Dotenv\Exception\ValidationException
|
|
120
|
-
*
|
|
121
|
-
* @return \Dotenv\Validator
|
|
122
|
-
*/
|
|
123
|
-
public function allowedValues(array $choices)
|
|
124
|
-
{
|
|
125
|
-
return $this->assertNullable(
|
|
126
|
-
static function (string $value) use ($choices) {
|
|
127
|
-
return \in_array($value, $choices, true);
|
|
128
|
-
},
|
|
129
|
-
\sprintf('is not one of [%s]', \implode(', ', $choices))
|
|
130
|
-
);
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* Assert that each variable matches the given regular expression.
|
|
135
|
-
*
|
|
136
|
-
* @param string $regex
|
|
137
|
-
*
|
|
138
|
-
* @throws \Dotenv\Exception\ValidationException
|
|
139
|
-
*
|
|
140
|
-
* @return \Dotenv\Validator
|
|
141
|
-
*/
|
|
142
|
-
public function allowedRegexValues(string $regex)
|
|
143
|
-
{
|
|
144
|
-
return $this->assertNullable(
|
|
145
|
-
static function (string $value) use ($regex) {
|
|
146
|
-
return Regex::matches($regex, $value)->success()->getOrElse(false);
|
|
147
|
-
},
|
|
148
|
-
\sprintf('does not match "%s"', $regex)
|
|
149
|
-
);
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
* Assert that the callback returns true for each variable.
|
|
154
|
-
*
|
|
155
|
-
* @param callable(?string):bool $callback
|
|
156
|
-
* @param string $message
|
|
157
|
-
*
|
|
158
|
-
* @throws \Dotenv\Exception\ValidationException
|
|
159
|
-
*
|
|
160
|
-
* @return \Dotenv\Validator
|
|
161
|
-
*/
|
|
162
|
-
public function assert(callable $callback, string $message)
|
|
163
|
-
{
|
|
164
|
-
$failing = [];
|
|
165
|
-
|
|
166
|
-
foreach ($this->variables as $variable) {
|
|
167
|
-
if ($callback($this->repository->get($variable)) === false) {
|
|
168
|
-
$failing[] = \sprintf('%s %s', $variable, $message);
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
if (\count($failing) > 0) {
|
|
173
|
-
throw new ValidationException(\sprintf(
|
|
174
|
-
'One or more environment variables failed assertions: %s.',
|
|
175
|
-
\implode(', ', $failing)
|
|
176
|
-
));
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
return $this;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
/**
|
|
183
|
-
* Assert that the callback returns true for each variable.
|
|
184
|
-
*
|
|
185
|
-
* Skip checking null variable values.
|
|
186
|
-
*
|
|
187
|
-
* @param callable(string):bool $callback
|
|
188
|
-
* @param string $message
|
|
189
|
-
*
|
|
190
|
-
* @throws \Dotenv\Exception\ValidationException
|
|
191
|
-
*
|
|
192
|
-
* @return \Dotenv\Validator
|
|
193
|
-
*/
|
|
194
|
-
public function assertNullable(callable $callback, string $message)
|
|
195
|
-
{
|
|
196
|
-
return $this->assert(
|
|
197
|
-
static function (?string $value) use ($callback) {
|
|
198
|
-
if ($value === null) {
|
|
199
|
-
return true;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
return $callback($value);
|
|
203
|
-
},
|
|
204
|
-
$message
|
|
205
|
-
);
|
|
206
|
-
}
|
|
207
|
-
}
|
|
@@ -1,387 +0,0 @@
|
|
|
1
|
-
<?php
|
|
2
|
-
|
|
3
|
-
declare(strict_types=1);
|
|
4
|
-
|
|
5
|
-
namespace Dotenv\Tests;
|
|
6
|
-
|
|
7
|
-
use Dotenv\Dotenv;
|
|
8
|
-
use Dotenv\Exception\InvalidEncodingException;
|
|
9
|
-
use Dotenv\Exception\InvalidPathException;
|
|
10
|
-
use Dotenv\Loader\Loader;
|
|
11
|
-
use Dotenv\Parser\Parser;
|
|
12
|
-
use Dotenv\Repository\RepositoryBuilder;
|
|
13
|
-
use Dotenv\Store\StoreBuilder;
|
|
14
|
-
use PHPUnit\Framework\TestCase;
|
|
15
|
-
|
|
16
|
-
final class DotenvTest extends TestCase
|
|
17
|
-
{
|
|
18
|
-
/**
|
|
19
|
-
* @var string
|
|
20
|
-
*/
|
|
21
|
-
private static $folder;
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* @beforeClass
|
|
25
|
-
*
|
|
26
|
-
* @return void
|
|
27
|
-
*/
|
|
28
|
-
public static function setFolder()
|
|
29
|
-
{
|
|
30
|
-
self::$folder = \dirname(__DIR__).'/fixtures/env';
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
public function testDotenvThrowsExceptionIfUnableToLoadFile()
|
|
34
|
-
{
|
|
35
|
-
$dotenv = Dotenv::createMutable(__DIR__);
|
|
36
|
-
|
|
37
|
-
$this->expectException(InvalidPathException::class);
|
|
38
|
-
$this->expectExceptionMessage('Unable to read any of the environment file(s) at');
|
|
39
|
-
|
|
40
|
-
$dotenv->load();
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
public function testDotenvThrowsExceptionIfUnableToLoadFiles()
|
|
44
|
-
{
|
|
45
|
-
$dotenv = Dotenv::createMutable([__DIR__, __DIR__.'/foo/bar']);
|
|
46
|
-
|
|
47
|
-
$this->expectException(InvalidPathException::class);
|
|
48
|
-
$this->expectExceptionMessage('Unable to read any of the environment file(s) at');
|
|
49
|
-
|
|
50
|
-
$dotenv->load();
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
public function testDotenvThrowsExceptionWhenNoFiles()
|
|
54
|
-
{
|
|
55
|
-
$dotenv = Dotenv::createMutable([]);
|
|
56
|
-
|
|
57
|
-
$this->expectException(InvalidPathException::class);
|
|
58
|
-
$this->expectExceptionMessage('At least one environment file path must be provided.');
|
|
59
|
-
|
|
60
|
-
$dotenv->load();
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
public function testDotenvTriesPathsToLoad()
|
|
64
|
-
{
|
|
65
|
-
$dotenv = Dotenv::createMutable([__DIR__, self::$folder]);
|
|
66
|
-
self::assertCount(4, $dotenv->load());
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
public function testDotenvTriesPathsToLoadTwice()
|
|
70
|
-
{
|
|
71
|
-
$dotenv = Dotenv::createMutable([__DIR__, self::$folder]);
|
|
72
|
-
self::assertCount(4, $dotenv->load());
|
|
73
|
-
|
|
74
|
-
$dotenv = Dotenv::createImmutable([__DIR__, self::$folder]);
|
|
75
|
-
self::assertCount(0, $dotenv->load());
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
public function testDotenvTriesPathsToSafeLoad()
|
|
79
|
-
{
|
|
80
|
-
$dotenv = Dotenv::createMutable([__DIR__, self::$folder]);
|
|
81
|
-
self::assertCount(4, $dotenv->safeLoad());
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
public function testDotenvSkipsLoadingIfFileIsMissing()
|
|
85
|
-
{
|
|
86
|
-
$dotenv = Dotenv::createMutable(__DIR__);
|
|
87
|
-
self::assertSame([], $dotenv->safeLoad());
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
public function testDotenvLoadsEnvironmentVars()
|
|
91
|
-
{
|
|
92
|
-
$dotenv = Dotenv::createMutable(self::$folder);
|
|
93
|
-
self::assertSame(
|
|
94
|
-
['FOO' => 'bar', 'BAR' => 'baz', 'SPACED' => 'with spaces', 'NULL' => ''],
|
|
95
|
-
$dotenv->load()
|
|
96
|
-
);
|
|
97
|
-
self::assertSame('bar', $_SERVER['FOO']);
|
|
98
|
-
self::assertSame('baz', $_SERVER['BAR']);
|
|
99
|
-
self::assertSame('with spaces', $_SERVER['SPACED']);
|
|
100
|
-
self::assertEmpty($_SERVER['NULL']);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
public function testDotenvLoadsEnvironmentVarsMultipleWithShortCircuitMode()
|
|
104
|
-
{
|
|
105
|
-
$dotenv = Dotenv::createMutable(self::$folder, ['.env', 'example.env']);
|
|
106
|
-
|
|
107
|
-
self::assertSame(
|
|
108
|
-
['FOO' => 'bar', 'BAR' => 'baz', 'SPACED' => 'with spaces', 'NULL' => ''],
|
|
109
|
-
$dotenv->load()
|
|
110
|
-
);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
public function testDotenvLoadsEnvironmentVarsMultipleWithoutShortCircuitMode()
|
|
114
|
-
{
|
|
115
|
-
$dotenv = Dotenv::createMutable(self::$folder, ['.env', 'example.env'], false);
|
|
116
|
-
|
|
117
|
-
self::assertSame(
|
|
118
|
-
['FOO' => 'bar', 'BAR' => 'baz', 'SPACED' => 'with spaces', 'NULL' => '', 'EG' => 'example'],
|
|
119
|
-
$dotenv->load()
|
|
120
|
-
);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
public function testCommentedDotenvLoadsEnvironmentVars()
|
|
124
|
-
{
|
|
125
|
-
$dotenv = Dotenv::createMutable(self::$folder, 'commented.env');
|
|
126
|
-
$dotenv->load();
|
|
127
|
-
self::assertSame('bar', $_SERVER['CFOO']);
|
|
128
|
-
self::assertFalse(isset($_SERVER['CBAR']));
|
|
129
|
-
self::assertFalse(isset($_SERVER['CZOO']));
|
|
130
|
-
self::assertSame('with spaces', $_SERVER['CSPACED']);
|
|
131
|
-
self::assertSame('a value with a # character', $_SERVER['CQUOTES']);
|
|
132
|
-
self::assertSame('a value with a # character & a quote " character inside quotes', $_SERVER['CQUOTESWITHQUOTE']);
|
|
133
|
-
self::assertEmpty($_SERVER['CNULL']);
|
|
134
|
-
self::assertEmpty($_SERVER['EMPTY']);
|
|
135
|
-
self::assertEmpty($_SERVER['EMPTY2']);
|
|
136
|
-
self::assertSame('foo', $_SERVER['FOOO']);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
public function testQuotedDotenvLoadsEnvironmentVars()
|
|
140
|
-
{
|
|
141
|
-
$dotenv = Dotenv::createMutable(self::$folder, 'quoted.env');
|
|
142
|
-
$dotenv->load();
|
|
143
|
-
self::assertSame('bar', $_SERVER['QFOO']);
|
|
144
|
-
self::assertSame('baz', $_SERVER['QBAR']);
|
|
145
|
-
self::assertSame('with spaces', $_SERVER['QSPACED']);
|
|
146
|
-
self::assertEmpty(\getenv('QNULL'));
|
|
147
|
-
|
|
148
|
-
self::assertSame('pgsql:host=localhost;dbname=test', $_SERVER['QEQUALS']);
|
|
149
|
-
self::assertSame('test some escaped characters like a quote (") or maybe a backslash (\\)', $_SERVER['QESCAPED']);
|
|
150
|
-
self::assertSame('iiiiviiiixiiiiviiii\\n', $_SERVER['QSLASH']);
|
|
151
|
-
self::assertSame('iiiiviiiixiiiiviiii\\\\n', $_SERVER['SQSLASH']);
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
public function testLargeDotenvLoadsEnvironmentVars()
|
|
155
|
-
{
|
|
156
|
-
$dotenv = Dotenv::createMutable(self::$folder, 'large.env');
|
|
157
|
-
$dotenv->load();
|
|
158
|
-
self::assertSame(2730, \strlen($_SERVER['LARGE']));
|
|
159
|
-
self::assertSame(8192, \strlen($_SERVER['HUGE']));
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
public function testDotenvLoadsMultibyteVars()
|
|
163
|
-
{
|
|
164
|
-
$dotenv = Dotenv::createMutable(self::$folder, 'multibyte.env');
|
|
165
|
-
$dotenv->load();
|
|
166
|
-
self::assertSame('Ā ā Ă ă Ą ą Ć ć Ĉ ĉ Ċ ċ Č č Ď ď Đ đ Ē ē Ĕ ĕ Ė ė Ę ę Ě ě', $_SERVER['MB1']);
|
|
167
|
-
self::assertSame('行内支付', $_SERVER['MB2']);
|
|
168
|
-
self::assertSame('🚀', $_SERVER['APP_ENV']);
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
public function testDotenvLoadsMultibyteUTF8Vars()
|
|
172
|
-
{
|
|
173
|
-
$dotenv = Dotenv::createMutable(self::$folder, 'multibyte.env', false, 'UTF-8');
|
|
174
|
-
$dotenv->load();
|
|
175
|
-
self::assertSame('Ā ā Ă ă Ą ą Ć ć Ĉ ĉ Ċ ċ Č č Ď ď Đ đ Ē ē Ĕ ĕ Ė ė Ę ę Ě ě', $_SERVER['MB1']);
|
|
176
|
-
self::assertSame('行内支付', $_SERVER['MB2']);
|
|
177
|
-
self::assertSame('🚀', $_SERVER['APP_ENV']);
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
public function testDotenvLoadWithInvalidEncoding()
|
|
181
|
-
{
|
|
182
|
-
$dotenv = Dotenv::createMutable(self::$folder, 'multibyte.env', false, 'UTF-88');
|
|
183
|
-
|
|
184
|
-
$this->expectException(InvalidEncodingException::class);
|
|
185
|
-
$this->expectExceptionMessage('Illegal character encoding [UTF-88] specified.');
|
|
186
|
-
|
|
187
|
-
$dotenv->load();
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
public function testDotenvLoadsMultibyteWindowsVars()
|
|
191
|
-
{
|
|
192
|
-
$dotenv = Dotenv::createMutable(self::$folder, 'windows.env', false, 'Windows-1252');
|
|
193
|
-
$dotenv->load();
|
|
194
|
-
self::assertSame('ñá', $_SERVER['MBW']);
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
public function testMultipleDotenvLoadsEnvironmentVars()
|
|
198
|
-
{
|
|
199
|
-
$dotenv = Dotenv::createMutable(self::$folder, 'multiple.env');
|
|
200
|
-
$dotenv->load();
|
|
201
|
-
self::assertSame('bar', $_SERVER['MULTI1']);
|
|
202
|
-
self::assertSame('foo', $_SERVER['MULTI2']);
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
public function testExportedDotenvLoadsEnvironmentVars()
|
|
206
|
-
{
|
|
207
|
-
$dotenv = Dotenv::createMutable(self::$folder, 'exported.env');
|
|
208
|
-
$dotenv->load();
|
|
209
|
-
self::assertSame('bar', $_SERVER['EFOO']);
|
|
210
|
-
self::assertSame('baz', $_SERVER['EBAR']);
|
|
211
|
-
self::assertSame('with spaces', $_SERVER['ESPACED']);
|
|
212
|
-
self::assertSame('123', $_SERVER['EDQUOTED']);
|
|
213
|
-
self::assertSame('456', $_SERVER['ESQUOTED']);
|
|
214
|
-
self::assertEmpty($_SERVER['ENULL']);
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
public function testDotenvLoadsEnvGlobals()
|
|
218
|
-
{
|
|
219
|
-
$dotenv = Dotenv::createMutable(self::$folder);
|
|
220
|
-
$dotenv->load();
|
|
221
|
-
self::assertSame('bar', $_SERVER['FOO']);
|
|
222
|
-
self::assertSame('baz', $_SERVER['BAR']);
|
|
223
|
-
self::assertSame('with spaces', $_SERVER['SPACED']);
|
|
224
|
-
self::assertEmpty($_SERVER['NULL']);
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
public function testDotenvLoadsServerGlobals()
|
|
228
|
-
{
|
|
229
|
-
$dotenv = Dotenv::createMutable(self::$folder);
|
|
230
|
-
$dotenv->load();
|
|
231
|
-
self::assertSame('bar', $_ENV['FOO']);
|
|
232
|
-
self::assertSame('baz', $_ENV['BAR']);
|
|
233
|
-
self::assertSame('with spaces', $_ENV['SPACED']);
|
|
234
|
-
self::assertEmpty($_ENV['NULL']);
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
public function testDotenvNestedEnvironmentVars()
|
|
238
|
-
{
|
|
239
|
-
$dotenv = Dotenv::createMutable(self::$folder, 'nested.env');
|
|
240
|
-
$dotenv->load();
|
|
241
|
-
self::assertSame('{$NVAR1} {$NVAR2}', $_ENV['NVAR3']); // not resolved
|
|
242
|
-
self::assertSame('Hellō World!', $_ENV['NVAR4']);
|
|
243
|
-
self::assertSame('$NVAR1 {NVAR2}', $_ENV['NVAR5']); // not resolved
|
|
244
|
-
self::assertSame('Special Value', $_ENV['N.VAR6']); // new '.' (dot) in var name
|
|
245
|
-
self::assertSame('Special Value', $_ENV['NVAR7']); // nested '.' (dot) variable
|
|
246
|
-
self::assertSame('', $_ENV['NVAR8']); // nested variable is empty string
|
|
247
|
-
self::assertSame('', $_ENV['NVAR9']); // nested variable is empty string
|
|
248
|
-
self::assertSame('${NVAR888}', $_ENV['NVAR10']); // nested variable is not set
|
|
249
|
-
self::assertSame('NVAR1', $_ENV['NVAR11']);
|
|
250
|
-
self::assertSame('Hellō', $_ENV['NVAR12']);
|
|
251
|
-
self::assertSame('${${NVAR11}}', $_ENV['NVAR13']); // single quotes
|
|
252
|
-
self::assertSame('${NVAR1} ${NVAR2}', $_ENV['NVAR14']); // single quotes
|
|
253
|
-
self::assertSame('${NVAR1} ${NVAR2}', $_ENV['NVAR15']); // escaped
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
public function testDotenvNullFileArgumentUsesDefault()
|
|
257
|
-
{
|
|
258
|
-
$dotenv = Dotenv::createMutable(self::$folder, null);
|
|
259
|
-
$dotenv->load();
|
|
260
|
-
self::assertSame('bar', $_SERVER['FOO']);
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
/**
|
|
264
|
-
* The fixture data has whitespace between the key and in the value string.
|
|
265
|
-
*
|
|
266
|
-
* Test that these keys are trimmed down.
|
|
267
|
-
*/
|
|
268
|
-
public function testDotenvTrimmedKeys()
|
|
269
|
-
{
|
|
270
|
-
$dotenv = Dotenv::createMutable(self::$folder, 'quoted.env');
|
|
271
|
-
$dotenv->load();
|
|
272
|
-
self::assertSame('no space', $_SERVER['QWHITESPACE']);
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
public function testDotenvLoadDoesNotOverwriteEnv()
|
|
276
|
-
{
|
|
277
|
-
\putenv('IMMUTABLE=true');
|
|
278
|
-
$dotenv = Dotenv::createImmutable(self::$folder, 'immutable.env');
|
|
279
|
-
$dotenv->load();
|
|
280
|
-
self::assertSame('true', \getenv('IMMUTABLE'));
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
public function testDotenvLoadAfterOverload()
|
|
284
|
-
{
|
|
285
|
-
\putenv('IMMUTABLE=true');
|
|
286
|
-
$dotenv = Dotenv::createUnsafeMutable(self::$folder, 'immutable.env');
|
|
287
|
-
$dotenv->load();
|
|
288
|
-
self::assertSame('false', \getenv('IMMUTABLE'));
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
public function testDotenvOverloadAfterLoad()
|
|
292
|
-
{
|
|
293
|
-
\putenv('IMMUTABLE=true');
|
|
294
|
-
$dotenv = Dotenv::createUnsafeImmutable(self::$folder, 'immutable.env');
|
|
295
|
-
$dotenv->load();
|
|
296
|
-
self::assertSame('true', \getenv('IMMUTABLE'));
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
public function testDotenvOverloadDoesOverwriteEnv()
|
|
300
|
-
{
|
|
301
|
-
$dotenv = Dotenv::createUnsafeMutable(self::$folder, 'mutable.env');
|
|
302
|
-
$dotenv->load();
|
|
303
|
-
self::assertSame('true', \getenv('MUTABLE'));
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
public function testDotenvAllowsSpecialCharacters()
|
|
307
|
-
{
|
|
308
|
-
$dotenv = Dotenv::createUnsafeMutable(self::$folder, 'specialchars.env');
|
|
309
|
-
$dotenv->load();
|
|
310
|
-
self::assertSame('$a6^C7k%zs+e^.jvjXk', \getenv('SPVAR1'));
|
|
311
|
-
self::assertSame('?BUty3koaV3%GA*hMAwH}B', \getenv('SPVAR2'));
|
|
312
|
-
self::assertSame('jdgEB4{QgEC]HL))&GcXxokB+wqoN+j>xkV7K?m$r', \getenv('SPVAR3'));
|
|
313
|
-
self::assertSame('22222:22#2^{', \getenv('SPVAR4'));
|
|
314
|
-
self::assertSame('test some escaped characters like a quote " or maybe a backslash \\', \getenv('SPVAR5'));
|
|
315
|
-
self::assertSame('secret!@', \getenv('SPVAR6'));
|
|
316
|
-
self::assertSame('secret!@#', \getenv('SPVAR7'));
|
|
317
|
-
self::assertSame('secret!@#', \getenv('SPVAR8'));
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
public function testMultilineLoading()
|
|
321
|
-
{
|
|
322
|
-
$dotenv = Dotenv::createUnsafeMutable(self::$folder, 'multiline.env');
|
|
323
|
-
$dotenv->load();
|
|
324
|
-
self::assertSame("test\n test\"test\"\n test", \getenv('TEST'));
|
|
325
|
-
self::assertSame("test\ntest", \getenv('TEST_ND'));
|
|
326
|
-
self::assertSame('test\\ntest', \getenv('TEST_NS'));
|
|
327
|
-
|
|
328
|
-
self::assertSame('https://vision.googleapis.com/v1/images:annotate?key=', \getenv('TEST_EQD'));
|
|
329
|
-
self::assertSame('https://vision.googleapis.com/v1/images:annotate?key=', \getenv('TEST_EQS'));
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
public function testEmptyLoading()
|
|
333
|
-
{
|
|
334
|
-
$dotenv = Dotenv::createImmutable(self::$folder, 'empty.env');
|
|
335
|
-
self::assertSame(['EMPTY_VAR' => null], $dotenv->load());
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
public function testUnicodeVarNames()
|
|
339
|
-
{
|
|
340
|
-
$dotenv = Dotenv::createImmutable(self::$folder, 'unicodevarnames.env');
|
|
341
|
-
$dotenv->load();
|
|
342
|
-
self::assertSame('Skybert', $_SERVER['AlbertÅberg']);
|
|
343
|
-
self::assertSame('2022-04-01T00:00', $_SERVER['ДатаЗакрытияРасчетногоПериода']);
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
public function testDirectConstructor()
|
|
347
|
-
{
|
|
348
|
-
$repository = RepositoryBuilder::createWithDefaultAdapters()->make();
|
|
349
|
-
$store = StoreBuilder::createWithDefaultName()->addPath(self::$folder)->make();
|
|
350
|
-
|
|
351
|
-
$dotenv = new Dotenv($store, new Parser(), new Loader(), $repository);
|
|
352
|
-
|
|
353
|
-
self::assertSame([
|
|
354
|
-
'FOO' => 'bar',
|
|
355
|
-
'BAR' => 'baz',
|
|
356
|
-
'SPACED' => 'with spaces',
|
|
357
|
-
'NULL' => '',
|
|
358
|
-
], $dotenv->load());
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
public function testDotenvParseExample1()
|
|
362
|
-
{
|
|
363
|
-
$output = Dotenv::parse(
|
|
364
|
-
"BASE_DIR=\"/var/webroot/project-root\"\nCACHE_DIR=\"\${BASE_DIR}/cache\"\nTMP_DIR=\"\${BASE_DIR}/tmp\"\n"
|
|
365
|
-
);
|
|
366
|
-
|
|
367
|
-
self::assertSame($output, [
|
|
368
|
-
'BASE_DIR' => '/var/webroot/project-root',
|
|
369
|
-
'CACHE_DIR' => '/var/webroot/project-root/cache',
|
|
370
|
-
'TMP_DIR' => '/var/webroot/project-root/tmp',
|
|
371
|
-
]);
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
public function testDotenvParseExample2()
|
|
375
|
-
{
|
|
376
|
-
$output = Dotenv::parse("FOO=Bar\nBAZ=\"Hello \${FOO}\"");
|
|
377
|
-
|
|
378
|
-
self::assertSame($output, ['FOO' => 'Bar', 'BAZ' => 'Hello Bar']);
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
public function testDotenvParseEmptyCase()
|
|
382
|
-
{
|
|
383
|
-
$output = Dotenv::parse('');
|
|
384
|
-
|
|
385
|
-
self::assertSame($output, []);
|
|
386
|
-
}
|
|
387
|
-
}
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
<?php
|
|
2
|
-
|
|
3
|
-
declare(strict_types=1);
|
|
4
|
-
|
|
5
|
-
namespace Dotenv\Tests\Loader;
|
|
6
|
-
|
|
7
|
-
use Dotenv\Exception\InvalidFileException;
|
|
8
|
-
use Dotenv\Loader\Loader;
|
|
9
|
-
use Dotenv\Loader\LoaderInterface;
|
|
10
|
-
use Dotenv\Parser\Parser;
|
|
11
|
-
use Dotenv\Repository\Adapter\ArrayAdapter;
|
|
12
|
-
use Dotenv\Repository\Adapter\EnvConstAdapter;
|
|
13
|
-
use Dotenv\Repository\Adapter\ServerConstAdapter;
|
|
14
|
-
use Dotenv\Repository\RepositoryBuilder;
|
|
15
|
-
use PHPUnit\Framework\TestCase;
|
|
16
|
-
|
|
17
|
-
final class LoaderTest extends TestCase
|
|
18
|
-
{
|
|
19
|
-
public function testParserInstanceOf()
|
|
20
|
-
{
|
|
21
|
-
self::assertInstanceOf(LoaderInterface::class, new Loader());
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
public function testLoaderWithNoReaders()
|
|
25
|
-
{
|
|
26
|
-
$repository = RepositoryBuilder::createWithNoAdapters()->addWriter(ArrayAdapter::class)->make();
|
|
27
|
-
$loader = new Loader();
|
|
28
|
-
|
|
29
|
-
$content = "NVAR1=\"Hello\"\nNVAR2=\"World!\"\nNVAR3=\"{\$NVAR1} {\$NVAR2}\"\nNVAR4=\"\${NVAR1} \${NVAR2}\"";
|
|
30
|
-
$expected = ['NVAR1' => 'Hello', 'NVAR2' => 'World!', 'NVAR3' => '{$NVAR1} {$NVAR2}', 'NVAR4' => '${NVAR1} ${NVAR2}'];
|
|
31
|
-
|
|
32
|
-
self::assertSame($expected, $loader->load($repository, (new Parser())->parse($content)));
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
public function testLoaderWithAllowList()
|
|
36
|
-
{
|
|
37
|
-
$adapter = ArrayAdapter::create()->get();
|
|
38
|
-
$repository = RepositoryBuilder::createWithNoAdapters()->addReader($adapter)->addWriter($adapter)->allowList(['FOO'])->make();
|
|
39
|
-
$loader = new Loader();
|
|
40
|
-
|
|
41
|
-
self::assertSame(['FOO' => 'Hello'], $loader->load($repository, (new Parser())->parse("FOO=\"Hello\"\nBAR=\"World!\"\n")));
|
|
42
|
-
self::assertTrue($adapter->read('FOO')->isDefined());
|
|
43
|
-
self::assertSame('Hello', $adapter->read('FOO')->get());
|
|
44
|
-
self::assertFalse($adapter->read('BAR')->isDefined());
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
public function testLoaderWithGarbage()
|
|
48
|
-
{
|
|
49
|
-
$adapter = ArrayAdapter::create()->get();
|
|
50
|
-
$repository = RepositoryBuilder::createWithNoAdapters()->make();
|
|
51
|
-
$loader = new Loader();
|
|
52
|
-
|
|
53
|
-
$this->expectException(InvalidFileException::class);
|
|
54
|
-
$this->expectExceptionMessage('Failed to parse dotenv file. Encountered unexpected whitespace at ["""].');
|
|
55
|
-
|
|
56
|
-
$loader->load($repository, (new Parser())->parse('FOO="""'));
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* @return array<int,\Dotenv\Repository\Adapter\AdapterInterface|string>[]
|
|
61
|
-
*/
|
|
62
|
-
public static function providesAdapters()
|
|
63
|
-
{
|
|
64
|
-
return [
|
|
65
|
-
[ArrayAdapter::create()->get()],
|
|
66
|
-
[EnvConstAdapter::class],
|
|
67
|
-
[ServerConstAdapter::class],
|
|
68
|
-
];
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* @dataProvider providesAdapters
|
|
73
|
-
*
|
|
74
|
-
* @param \Dotenv\Repository\Adapter\AdapterInterface|string $adapter
|
|
75
|
-
*/
|
|
76
|
-
public function testLoaderWithSpecificAdapter($adapter)
|
|
77
|
-
{
|
|
78
|
-
$repository = RepositoryBuilder::createWithNoAdapters()->addReader($adapter)->addWriter($adapter)->make();
|
|
79
|
-
$loader = new Loader();
|
|
80
|
-
|
|
81
|
-
$content = "NVAR1=\"Hello\"\nNVAR2=\"World!\"\nNVAR3=\"{\$NVAR1} {\$NVAR2}\"\nNVAR4=\"\${NVAR1} \${NVAR2}\"";
|
|
82
|
-
$expected = ['NVAR1' => 'Hello', 'NVAR2' => 'World!', 'NVAR3' => '{$NVAR1} {$NVAR2}', 'NVAR4' => 'Hello World!'];
|
|
83
|
-
|
|
84
|
-
self::assertSame($expected, $loader->load($repository, (new Parser())->parse($content)));
|
|
85
|
-
}
|
|
86
|
-
}
|