選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

LuBoolDboArrayTest.php 4.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. <?php
  2. use Luticate\Utils\Dbo\LuDboDeserializeException;
  3. use Luticate\Utils\Dbo\LuBoolDboArray;
  4. /**
  5. * Created by PhpStorm.
  6. * User: robin
  7. * Date: 5/29/16
  8. * Time: 2:57 PM
  9. */
  10. class LuBoolDboArrayTest extends \PHPUnit_Framework_TestCase
  11. {
  12. public function testArrayEmpty()
  13. {
  14. $dbo = LuBoolDboArray::jsonDeserialize([]);
  15. $this->assertSame([], $dbo->getArray());
  16. }
  17. public function testArrayStringTrue()
  18. {
  19. $dbo = LuBoolDboArray::jsonDeserialize(["true"]);
  20. $this->assertSame([true], $dbo->getArray());
  21. }
  22. public function testArrayStringTrueCase()
  23. {
  24. $dbo = LuBoolDboArray::jsonDeserialize(["tRue"]);
  25. $this->assertSame([true], $dbo->getArray());
  26. }
  27. public function testArrayStringFalse()
  28. {
  29. $dbo = LuBoolDboArray::jsonDeserialize(["false"]);
  30. $this->assertSame([false], $dbo->getArray());
  31. }
  32. public function testArrayStringFalseCase()
  33. {
  34. $dbo = LuBoolDboArray::jsonDeserialize(["faLse"]);
  35. $this->assertSame([false], $dbo->getArray());
  36. }
  37. public function testArrayMultipleString()
  38. {
  39. $dbo = LuBoolDboArray::jsonDeserialize(["true", "false", "true"]);
  40. $this->assertSame([true, false, true], $dbo->getArray());
  41. }
  42. public function testArrayMultipleStringPlusData()
  43. {
  44. $this->expectException(LuDboDeserializeException::class);
  45. LuBoolDboArray::jsonDeserialize(["true", null, "true"]);
  46. }
  47. public function testArrayInt()
  48. {
  49. $this->expectException(LuDboDeserializeException::class);
  50. LuBoolDboArray::jsonDeserialize([42]);
  51. }
  52. public function testArrayMultipleInt()
  53. {
  54. $this->expectException(LuDboDeserializeException::class);
  55. LuBoolDboArray::jsonDeserialize([42, 24, 48]);
  56. }
  57. public function testArrayMultipleStringInt()
  58. {
  59. $this->expectException(LuDboDeserializeException::class);
  60. LuBoolDboArray::jsonDeserialize(["42", "24", "48"]);
  61. }
  62. public function testArrayStringInt()
  63. {
  64. $this->expectException(LuDboDeserializeException::class);
  65. LuBoolDboArray::jsonDeserialize(["42"]);
  66. }
  67. public function testArrayStringIntPlusData()
  68. {
  69. $this->expectException(LuDboDeserializeException::class);
  70. LuBoolDboArray::jsonDeserialize(["42test"]);
  71. }
  72. public function testArrayMultipleStringIntPlusData()
  73. {
  74. $this->expectException(LuDboDeserializeException::class);
  75. LuBoolDboArray::jsonDeserialize(["42", 42, "42test"]);
  76. }
  77. public function testIntString()
  78. {
  79. $this->expectException(LuDboDeserializeException::class);
  80. LuBoolDboArray::jsonDeserialize("42");
  81. }
  82. public function testInt()
  83. {
  84. $this->expectException(LuDboDeserializeException::class);
  85. LuBoolDboArray::jsonDeserialize(42);
  86. }
  87. public function testIntNegativeString()
  88. {
  89. $this->expectException(LuDboDeserializeException::class);
  90. LuBoolDboArray::jsonDeserialize("-42");
  91. }
  92. public function testIntNegative()
  93. {
  94. $this->expectException(LuDboDeserializeException::class);
  95. LuBoolDboArray::jsonDeserialize(-42);
  96. }
  97. public function testFloat()
  98. {
  99. $this->expectException(LuDboDeserializeException::class);
  100. LuBoolDboArray::jsonDeserialize(42.42);
  101. }
  102. public function testFloatString()
  103. {
  104. $this->expectException(LuDboDeserializeException::class);
  105. LuBoolDboArray::jsonDeserialize("42.42");
  106. }
  107. public function testExponentialString()
  108. {
  109. $this->expectException(LuDboDeserializeException::class);
  110. LuBoolDboArray::jsonDeserialize("42e+01");
  111. }
  112. public function testBool()
  113. {
  114. $this->expectException(LuDboDeserializeException::class);
  115. LuBoolDboArray::jsonDeserialize(true);
  116. }
  117. public function testBoolString()
  118. {
  119. $this->expectException(LuDboDeserializeException::class);
  120. LuBoolDboArray::jsonDeserialize("true");
  121. }
  122. public function testArrayFloat()
  123. {
  124. $this->expectException(LuDboDeserializeException::class);
  125. LuBoolDboArray::jsonDeserialize([42.42]);
  126. }
  127. public function testNull()
  128. {
  129. $this->expectException(LuDboDeserializeException::class);
  130. LuBoolDboArray::jsonDeserialize(null);
  131. }
  132. public function testObject()
  133. {
  134. $this->expectException(LuDboDeserializeException::class);
  135. LuBoolDboArray::jsonDeserialize(new self());
  136. }
  137. }