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/BootDatabaseGlobalContractT...

26 lines
872 B
PHP

<?php
$source = file_get_contents(
dirname(__DIR__) . '/app/Services/Boot.php'
);
if ($source === false) {
throw new RuntimeException('Unable to read the database bootstrap.');
}
$start = strpos($source, 'public static function bootDb()');
$end = strpos($source, 'private static function bootPaginator()', $start ?: 0);
if ($start === false || $end === false || $end <= $start) {
throw new RuntimeException('Unable to isolate Boot::bootDb().');
}
$method = substr($source, $start, $end - $start);
$global = strpos($method, '$capsule->setAsGlobal();');
$eloquent = strpos($method, '$capsule->bootEloquent();');
if ($global === false || $eloquent === false || $global > $eloquent) {
throw new RuntimeException(
'Boot::bootDb() must initialize Capsule static queries before Eloquent.'
);
}
echo "Boot database global contract tests passed\n";