@@ -26,22 +26,24 @@ public function testNormalize()
26
26
$ obj = new GetSetDummy ();
27
27
$ obj ->setFoo ('foo ' );
28
28
$ obj ->setBar ('bar ' );
29
+ $ obj ->setBaz (true );
29
30
$ obj ->setCamelCase ('camelcase ' );
30
31
$ this ->assertEquals (
31
- array ('foo ' => 'foo ' , 'bar ' => 'bar ' , 'fooBar ' => 'foobar ' , 'camelCase ' => 'camelcase ' ),
32
+ array ('foo ' => 'foo ' , 'bar ' => 'bar ' , 'baz ' => true , ' fooBar ' => 'foobar ' , 'camelCase ' => 'camelcase ' ),
32
33
$ this ->normalizer ->normalize ($ obj , 'any ' )
33
34
);
34
35
}
35
36
36
37
public function testDenormalize ()
37
38
{
38
39
$ obj = $ this ->normalizer ->denormalize (
39
- array ('foo ' => 'foo ' , 'bar ' => 'bar ' , 'fooBar ' => 'foobar ' ),
40
+ array ('foo ' => 'foo ' , 'bar ' => 'bar ' , 'baz ' => true , ' fooBar ' => 'foobar ' ),
40
41
__NAMESPACE__ .'\GetSetDummy ' ,
41
42
'any '
42
43
);
43
44
$ this ->assertEquals ('foo ' , $ obj ->getFoo ());
44
45
$ this ->assertEquals ('bar ' , $ obj ->getBar ());
46
+ $ this ->assertTrue ($ obj ->isBaz ());
45
47
}
46
48
47
49
public function testDenormalizeOnCamelCaseFormat ()
@@ -80,10 +82,11 @@ public function attributeProvider()
80
82
public function testConstructorDenormalize ()
81
83
{
82
84
$ obj = $ this ->normalizer ->denormalize (
83
- array ('foo ' => 'foo ' , 'bar ' => 'bar ' , 'fooBar ' => 'foobar ' ),
85
+ array ('foo ' => 'foo ' , 'bar ' => 'bar ' , 'baz ' => true , ' fooBar ' => 'foobar ' ),
84
86
__NAMESPACE__ .'\GetConstructorDummy ' , 'any ' );
85
87
$ this ->assertEquals ('foo ' , $ obj ->getFoo ());
86
88
$ this ->assertEquals ('bar ' , $ obj ->getBar ());
89
+ $ this ->assertTrue ($ obj ->isBaz ());
87
90
}
88
91
89
92
/**
@@ -93,7 +96,7 @@ public function testCallbacks($callbacks, $value, $result, $message)
93
96
{
94
97
$ this ->normalizer ->setCallbacks ($ callbacks );
95
98
96
- $ obj = new GetConstructorDummy ('' , $ value );
99
+ $ obj = new GetConstructorDummy ('' , $ value, true );
97
100
98
101
$ this ->assertEquals (
99
102
$ result ,
@@ -109,18 +112,19 @@ public function testUncallableCallbacks()
109
112
{
110
113
$ this ->normalizer ->setCallbacks (array ('bar ' => null ));
111
114
112
- $ obj = new GetConstructorDummy ('baz ' , 'quux ' );
115
+ $ obj = new GetConstructorDummy ('baz ' , 'quux ' , true );
113
116
114
117
$ this ->normalizer ->normalize ($ obj , 'any ' );
115
118
}
116
119
117
120
public function testIgnoredAttributes ()
118
121
{
119
- $ this ->normalizer ->setIgnoredAttributes (array ('foo ' , 'bar ' , 'camelCase ' ));
122
+ $ this ->normalizer ->setIgnoredAttributes (array ('foo ' , 'bar ' , 'baz ' , ' camelCase ' ));
120
123
121
124
$ obj = new GetSetDummy ();
122
125
$ obj ->setFoo ('foo ' );
123
126
$ obj ->setBar ('bar ' );
127
+ $ obj ->setBaz (true );
124
128
125
129
$ this ->assertEquals (
126
130
array ('fooBar ' => 'foobar ' ),
@@ -138,7 +142,7 @@ public function provideCallbacks()
138
142
},
139
143
),
140
144
'baz ' ,
141
- array ('foo ' => '' , 'bar ' => 'baz ' ),
145
+ array ('foo ' => '' , 'bar ' => 'baz ' , ' baz ' => true ),
142
146
'Change a string ' ,
143
147
),
144
148
array (
@@ -148,7 +152,7 @@ public function provideCallbacks()
148
152
},
149
153
),
150
154
'baz ' ,
151
- array ('foo ' => '' , 'bar ' => null ),
155
+ array ('foo ' => '' , 'bar ' => null , ' baz ' => true ),
152
156
'Null an item '
153
157
),
154
158
array (
@@ -158,7 +162,7 @@ public function provideCallbacks()
158
162
},
159
163
),
160
164
new \DateTime ('2011-09-10 06:30:00 ' ),
161
- array ('foo ' => '' , 'bar ' => '10-09-2011 06:30:00 ' ),
165
+ array ('foo ' => '' , 'bar ' => '10-09-2011 06:30:00 ' , ' baz ' => true ),
162
166
'Format a date ' ,
163
167
),
164
168
array (
@@ -172,8 +176,8 @@ public function provideCallbacks()
172
176
return $ foos ;
173
177
},
174
178
),
175
- array (new GetConstructorDummy ('baz ' , '' ), new GetConstructorDummy ('quux ' , '' )),
176
- array ('foo ' => '' , 'bar ' => 'bazquux ' ),
179
+ array (new GetConstructorDummy ('baz ' , '' , false ), new GetConstructorDummy ('quux ' , '' , false )),
180
+ array ('foo ' => '' , 'bar ' => 'bazquux ' , ' baz ' => true ),
177
181
'Collect a property ' ,
178
182
),
179
183
array (
@@ -182,8 +186,8 @@ public function provideCallbacks()
182
186
return count ($ bars );
183
187
},
184
188
),
185
- array (new GetConstructorDummy ('baz ' , '' ), new GetConstructorDummy ('quux ' , '' )),
186
- array ('foo ' => '' , 'bar ' => 2 ),
189
+ array (new GetConstructorDummy ('baz ' , '' , false ), new GetConstructorDummy ('quux ' , '' , false )),
190
+ array ('foo ' => '' , 'bar ' => 2 , ' baz ' => true ),
187
191
'Count a property ' ,
188
192
),
189
193
);
@@ -194,6 +198,7 @@ class GetSetDummy
194
198
{
195
199
protected $ foo ;
196
200
private $ bar ;
201
+ private $ baz ;
197
202
protected $ camelCase ;
198
203
199
204
public function getFoo ()
@@ -216,6 +221,16 @@ public function setBar($bar)
216
221
$ this ->bar = $ bar ;
217
222
}
218
223
224
+ public function isBaz ()
225
+ {
226
+ return $ this ->baz ;
227
+ }
228
+
229
+ public function setBaz ($ baz )
230
+ {
231
+ $ this ->baz = $ baz ;
232
+ }
233
+
219
234
public function getFooBar ()
220
235
{
221
236
return $ this ->foo .$ this ->bar ;
@@ -241,11 +256,13 @@ class GetConstructorDummy
241
256
{
242
257
protected $ foo ;
243
258
private $ bar ;
259
+ private $ baz ;
244
260
245
- public function __construct ($ foo , $ bar )
261
+ public function __construct ($ foo , $ bar, $ baz )
246
262
{
247
263
$ this ->foo = $ foo ;
248
264
$ this ->bar = $ bar ;
265
+ $ this ->baz = $ baz ;
249
266
}
250
267
251
268
public function getFoo ()
@@ -258,6 +275,11 @@ public function getBar()
258
275
return $ this ->bar ;
259
276
}
260
277
278
+ public function isBaz ()
279
+ {
280
+ return $ this ->baz ;
281
+ }
282
+
261
283
public function otherMethod ()
262
284
{
263
285
throw new \RuntimeException ("Dummy::otherMethod() should not be called " );
0 commit comments