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