| 123456789101112131415161718192021222324252627282930313233 |
- <?php
- /** SystemServiceSetup.build must surface actionable hints when a capability is off. */
- require dirname(__DIR__) . "/vendor/autoload.php";
- use app\miniapi\service\SystemServiceSetup;
- $checks = 0;
- function check(bool $ok, string $label): void
- {
- global $checks;
- $checks++;
- if (!$ok) {
- throw new RuntimeException($label);
- }
- }
- $messages = SystemServiceSetup::build([
- "wechat_login" => false,
- "test_phone_login" => false,
- ]);
- check(isset($messages["wechat_login"]) && $messages["wechat_login"]["action"] === "configure", "wechat_login action is configure");
- check(count($messages["wechat_login"]["steps"]) >= 5, "wechat_login lists multi-step guidance");
- check(isset($messages["test_phone_login"]) && $messages["test_phone_login"]["action"] === "optional", "test_phone_login action is optional");
- $messagesOn = SystemServiceSetup::build([
- "wechat_login" => true,
- "test_phone_login" => true,
- ]);
- check(!isset($messagesOn["wechat_login"]), "no message when wechat_login is on");
- check(!isset($messagesOn["test_phone_login"]), "no message when test_phone_login is on");
- echo "PASS: " . $checks . " setup message checks.\n";
|