@@ -26,22 +26,24 @@ public function testNormalize()
2626 $ obj = new GetSetDummy ();
2727 $ obj ->setFoo ('foo ' );
2828 $ obj ->setBar ('bar ' );
29+ $ obj ->setBaz (true );
2930 $ obj ->setCamelCase ('camelcase ' );
3031 $ this ->assertEquals (
31- array ('foo ' => 'foo ' , 'bar ' => 'bar ' , 'fooBar ' => 'foobar ' , 'camelCase ' => 'camelcase ' ),
32+ array ('foo ' => 'foo ' , 'bar ' => 'bar ' , 'baz ' => true , ' fooBar ' => 'foobar ' , 'camelCase ' => 'camelcase ' ),
3233 $ this ->normalizer ->normalize ($ obj , 'any ' )
3334 );
3435 }
3536
3637 public function testDenormalize ()
3738 {
3839 $ obj = $ this ->normalizer ->denormalize (
39- array ('foo ' => 'foo ' , 'bar ' => 'bar ' , 'fooBar ' => 'foobar ' ),
40+ array ('foo ' => 'foo ' , 'bar ' => 'bar ' , 'baz ' => true , ' fooBar ' => 'foobar ' ),
4041 __NAMESPACE__ .'\GetSetDummy ' ,
4142 'any '
4243 );
4344 $ this ->assertEquals ('foo ' , $ obj ->getFoo ());
4445 $ this ->assertEquals ('bar ' , $ obj ->getBar ());
46+ $ this ->assertTrue ($ obj ->isBaz ());
4547 }
4648
4749 public function testDenormalizeOnCamelCaseFormat ()
@@ -80,10 +82,11 @@ public function attributeProvider()
8082 public function testConstructorDenormalize ()
8183 {
8284 $ obj = $ this ->normalizer ->denormalize (
83- array ('foo ' => 'foo ' , 'bar ' => 'bar ' , 'fooBar ' => 'foobar ' ),
85+ array ('foo ' => 'foo ' , 'bar ' => 'bar ' , 'baz ' => true , ' fooBar ' => 'foobar ' ),
8486 __NAMESPACE__ .'\GetConstructorDummy ' , 'any ' );
8587 $ this ->assertEquals ('foo ' , $ obj ->getFoo ());
8688 $ this ->assertEquals ('bar ' , $ obj ->getBar ());
89+ $ this ->assertTrue ($ obj ->isBaz ());
8790 }
8891
8992 /**
@@ -93,7 +96,7 @@ public function testCallbacks($callbacks, $value, $result, $message)
9396 {
9497 $ this ->normalizer ->setCallbacks ($ callbacks );
9598
96- $ obj = new GetConstructorDummy ('' , $ value );
99+ $ obj = new GetConstructorDummy ('' , $ value, true );
97100
98101 $ this ->assertEquals (
99102 $ result ,
@@ -109,18 +112,19 @@ public function testUncallableCallbacks()
109112 {
110113 $ this ->normalizer ->setCallbacks (array ('bar ' => null ));
111114
112- $ obj = new GetConstructorDummy ('baz ' , 'quux ' );
115+ $ obj = new GetConstructorDummy ('baz ' , 'quux ' , true );
113116
114117 $ this ->normalizer ->normalize ($ obj , 'any ' );
115118 }
116119
117120 public function testIgnoredAttributes ()
118121 {
119- $ this ->normalizer ->setIgnoredAttributes (array ('foo ' , 'bar ' , 'camelCase ' ));
122+ $ this ->normalizer ->setIgnoredAttributes (array ('foo ' , 'bar ' , 'baz ' , ' camelCase ' ));
120123
121124 $ obj = new GetSetDummy ();
122125 $ obj ->setFoo ('foo ' );
123126 $ obj ->setBar ('bar ' );
127+ $ obj ->setBaz (true );
124128
125129 $ this ->assertEquals (
126130 array ('fooBar ' => 'foobar ' ),
@@ -138,7 +142,7 @@ public function provideCallbacks()
138142 },
139143 ),
140144 'baz ' ,
141- array ('foo ' => '' , 'bar ' => 'baz ' ),
145+ array ('foo ' => '' , 'bar ' => 'baz ' , ' baz ' => true ),
142146 'Change a string ' ,
143147 ),
144148 array (
@@ -148,7 +152,7 @@ public function provideCallbacks()
148152 },
149153 ),
150154 'baz ' ,
151- array ('foo ' => '' , 'bar ' => null ),
155+ array ('foo ' => '' , 'bar ' => null , ' baz ' => true ),
152156 'Null an item '
153157 ),
154158 array (
@@ -158,7 +162,7 @@ public function provideCallbacks()
158162 },
159163 ),
160164 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 ),
162166 'Format a date ' ,
163167 ),
164168 array (
@@ -172,8 +176,8 @@ public function provideCallbacks()
172176 return $ foos ;
173177 },
174178 ),
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 ),
177181 'Collect a property ' ,
178182 ),
179183 array (
@@ -182,8 +186,8 @@ public function provideCallbacks()
182186 return count ($ bars );
183187 },
184188 ),
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 ),
187191 'Count a property ' ,
188192 ),
189193 );
@@ -194,6 +198,7 @@ class GetSetDummy
194198{
195199 protected $ foo ;
196200 private $ bar ;
201+ private $ baz ;
197202 protected $ camelCase ;
198203
199204 public function getFoo ()
@@ -216,6 +221,16 @@ public function setBar($bar)
216221 $ this ->bar = $ bar ;
217222 }
218223
224+ public function isBaz ()
225+ {
226+ return $ this ->baz ;
227+ }
228+
229+ public function setBaz ($ baz )
230+ {
231+ $ this ->baz = $ baz ;
232+ }
233+
219234 public function getFooBar ()
220235 {
221236 return $ this ->foo .$ this ->bar ;
@@ -241,11 +256,13 @@ class GetConstructorDummy
241256{
242257 protected $ foo ;
243258 private $ bar ;
259+ private $ baz ;
244260
245- public function __construct ($ foo , $ bar )
261+ public function __construct ($ foo , $ bar, $ baz )
246262 {
247263 $ this ->foo = $ foo ;
248264 $ this ->bar = $ bar ;
265+ $ this ->baz = $ baz ;
249266 }
250267
251268 public function getFoo ()
@@ -258,6 +275,11 @@ public function getBar()
258275 return $ this ->bar ;
259276 }
260277
278+ public function isBaz ()
279+ {
280+ return $ this ->baz ;
281+ }
282+
261283 public function otherMethod ()
262284 {
263285 throw new \RuntimeException ("Dummy::otherMethod() should not be called " );
0 commit comments