TupleTypingTest.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <?php
  2. namespace JsonSchema\Tests;
  3. class TupleTypingTest extends BaseTestCase
  4. {
  5. public function getInvalidTests()
  6. {
  7. return array(
  8. array(
  9. '{
  10. "tupleTyping":[2,"a"]
  11. }',
  12. '{
  13. "type":"object",
  14. "properties":{
  15. "tupleTyping":{
  16. "type":"array",
  17. "items":[
  18. {"type":"string"},
  19. {"type":"number"}
  20. ]
  21. }
  22. }
  23. }'
  24. ),
  25. array(
  26. '{
  27. "tupleTyping":["2",2,3]
  28. }',
  29. '{
  30. "type":"object",
  31. "properties":{
  32. "tupleTyping":{
  33. "type":"array",
  34. "items":[
  35. {"type":"string"},
  36. {"type":"number"}
  37. ] ,
  38. "additionalProperties":false
  39. }
  40. }
  41. }'
  42. ),
  43. array(
  44. '{
  45. "tupleTyping":["2",2,3]
  46. }',
  47. '{
  48. "type":"object",
  49. "properties":{
  50. "tupleTyping":{
  51. "type":"array",
  52. "items":[
  53. {"type":"string"},
  54. {"type":"number"}
  55. ] ,
  56. "additionalProperties":{"type":"string"}
  57. }
  58. }
  59. }'
  60. ),
  61. array(
  62. '{
  63. "tupleTyping":["2"]
  64. }',
  65. '{
  66. "type":"object",
  67. "properties":{
  68. "tupleTyping":{
  69. "type":"array",
  70. "items":[
  71. {"type":"string"},
  72. {"type":"number"},
  73. {"required":true}
  74. ]
  75. }
  76. }
  77. }'
  78. )
  79. );
  80. }
  81. public function getValidTests()
  82. {
  83. return array(
  84. array(
  85. '{
  86. "tupleTyping":["2"]
  87. }',
  88. '{
  89. "type":"object",
  90. "properties":{
  91. "tupleTyping":{
  92. "type":"array",
  93. "items":[
  94. {"type":"string"},
  95. {"type":"number","required":false},
  96. {"type":"number","required":false}
  97. ]
  98. }
  99. }
  100. }'
  101. )
  102. );
  103. }
  104. }