You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
virt/web/tests/UserCopyRuntimeNoDatabaseCo...

40 lines
1.1 KiB
PHTML

<?php
$root = dirname(__DIR__) . '/app/Services/UserCopy';
$files = glob($root . '/*.php');
if (!is_array($files) || $files === []) {
throw new RuntimeException('User copy runtime module is missing.');
}
$forbidden = [
'/Illuminate\\\\Database/',
'/\\bCapsule\\b/',
'/\\bPDO\\b/',
'/\\bPredis\\b/',
'/\\bRedis(?:Client)?\\b/',
'/\\bDB::/',
];
foreach ($files as $file) {
$source = file_get_contents($file);
if (!is_string($source)) {
throw new RuntimeException('Unable to read ' . $file);
}
foreach ($forbidden as $pattern) {
if (preg_match($pattern, $source) === 1) {
throw new RuntimeException(
basename($file) . ' introduced a runtime persistence dependency.'
);
}
}
}
$reader = file_get_contents($root . '/UserCopyRuntimeReader.php');
if (!is_string($reader)
|| preg_match('/\\b(?:fopen|fwrite|rename|mkdir|unlink)\\s*\\(/', $reader) === 1) {
throw new RuntimeException(
'The user copy runtime reader is no longer read-only.'
);
}
echo "User copy runtime stays filesystem-only and read-only.\n";