mini_system_setup_test.php 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. /** SystemServiceSetup.build must surface actionable hints when a capability is off. */
  3. require dirname(__DIR__) . "/vendor/autoload.php";
  4. use app\miniapi\service\SystemServiceSetup;
  5. $checks = 0;
  6. function check(bool $ok, string $label): void
  7. {
  8. global $checks;
  9. $checks++;
  10. if (!$ok) {
  11. throw new RuntimeException($label);
  12. }
  13. }
  14. $messages = SystemServiceSetup::build([
  15. "wechat_login" => false,
  16. "test_phone_login" => false,
  17. ]);
  18. check(isset($messages["wechat_login"]) && $messages["wechat_login"]["action"] === "configure", "wechat_login action is configure");
  19. check(count($messages["wechat_login"]["steps"]) >= 5, "wechat_login lists multi-step guidance");
  20. check(isset($messages["test_phone_login"]) && $messages["test_phone_login"]["action"] === "optional", "test_phone_login action is optional");
  21. $messagesOn = SystemServiceSetup::build([
  22. "wechat_login" => true,
  23. "test_phone_login" => true,
  24. ]);
  25. check(!isset($messagesOn["wechat_login"]), "no message when wechat_login is on");
  26. check(!isset($messagesOn["test_phone_login"]), "no message when test_phone_login is on");
  27. echo "PASS: " . $checks . " setup message checks.\n";