TestEnvTypesTest.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. namespace YdbPlatform\Ydb\Test;
  3. use PHPUnit\Framework\TestCase;
  4. use YdbPlatform\Ydb\Auth\EnvironCredentials;
  5. use YdbPlatform\Ydb\Ydb;
  6. use YdbPlatform\Ydb\YdbTable;
  7. class TestEnvTypesTest extends TestCase{
  8. public function testEnvironCredentials(){
  9. $dataset = [
  10. [
  11. "env" => [
  12. "name" => "YDB_SERVICE_ACCOUNT_KEY_FILE_CREDENTIALS",
  13. "value" => "./tests/some.json"
  14. ],
  15. "wait" => "SA JSON key"
  16. ],
  17. [
  18. "env" => [
  19. "name" => "YDB_ACCESS_TOKEN_CREDENTIALS",
  20. "value" => "76254876234"
  21. ],
  22. "wait" => "Access token"
  23. ],
  24. [
  25. "env" => [
  26. "name" => "YDB_ANONYMOUS_CREDENTIALS",
  27. "value" => "1"
  28. ],
  29. "wait" => "Anonymous"
  30. ],
  31. [
  32. "env" => [
  33. "name" => "YDB_METADATA_CREDENTIALS",
  34. "value" => "1"
  35. ],
  36. "wait" => "Metadata URL"
  37. ],
  38. [
  39. "env" => [
  40. "name" => "YDB_ANONYMOUS_CREDENTIALS",
  41. "value" => "0"
  42. ],
  43. "wait" => "Metadata URL"
  44. ],
  45. [
  46. "env" => [
  47. "name" => "none",
  48. "value" => "none"
  49. ],
  50. "wait" => "Metadata URL"
  51. ],
  52. ];
  53. foreach ($dataset as $data){
  54. putenv($data["env"]["name"]."=".$data["env"]["value"]);
  55. self::assertEquals(
  56. $data["wait"],
  57. (new EnvironCredentials())->getName()
  58. );
  59. putenv($data["env"]["name"]);
  60. }
  61. }
  62. }