提交
This commit is contained in:
22
tests/customer_center_route_order_self_check.php
Normal file
22
tests/customer_center_route_order_self_check.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
$routes = file_get_contents(__DIR__ . '/../route/app.php');
|
||||
if (!is_string($routes)) {
|
||||
throw new RuntimeException('Unable to read route configuration');
|
||||
}
|
||||
|
||||
$detail = strpos($routes, "Route::post('customer-center/applicant',");
|
||||
$save = strpos($routes, "Route::post('customer-center/applicant/save',");
|
||||
$remove = strpos($routes, "Route::post('customer-center/applicant/remove',");
|
||||
if ($detail === false || $save === false || $remove === false) {
|
||||
throw new RuntimeException('Customer center applicant routes are incomplete');
|
||||
}
|
||||
if ($save > $detail || $remove > $detail) {
|
||||
throw new RuntimeException('Specific applicant routes must be registered before the detail route');
|
||||
}
|
||||
if (!preg_match("/Route::post\('customer-center\\/applicant',\s*'CustomerCenter\\/applicant'\)->completeMatch\(\);/", $routes)) {
|
||||
throw new RuntimeException('Applicant detail route must use complete matching');
|
||||
}
|
||||
|
||||
echo "Customer center route order self-check passed\n";
|
||||
Reference in New Issue
Block a user