Changeset 1062
- Timestamp:
- 11/22/07 21:55:55 (11 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/main/php/net/stubbles/xml/serializer/stubXMLSerializer.php
r730 r1062 36 36 37 37 /** 38 * Option to define the strategy 39 */ 40 const OPT_STATIC = 'static'; 41 42 /** 38 43 * Do not export any properties or methods 39 44 */ … … 62 67 private $defaultOpts = array( 63 68 self::OPT_ROOT_TAG => null, 64 self::OPT_STRATEGY => self::STRATEGY_ALL 69 self::OPT_STRATEGY => self::STRATEGY_ALL, 70 self::OPT_STATIC => false 65 71 ); 66 72 … … 214 220 continue; 215 221 } 222 if ($property->isStatic() && $this->opts[self::OPT_STATIC] === false) { 223 continue; 224 } 216 225 $tagName = $property->getName(); 217 226 } … … 287 296 continue; 288 297 } 298 if ($method->isStatic() && $this->opts[self::OPT_STATIC] === false) { 299 continue; 300 } 301 289 302 $tagName = $method->getName(); 290 303 } trunk/src/test/php/net/stubbles/xml/serializer/stubXMLSerializerTestCase.php
r1017 r1062 232 232 233 233 } 234 235 /** 236 * Simple Test class to test the XMLSerializer and static properties/methods 237 */ 238 class stubXMLSerializerTestCase_Static { 239 public static $foo = 'foo'; 240 241 public static function getBar() { 242 return 'bar'; 243 } 244 } 245 234 246 235 247 /** … … 422 434 423 435 /** 436 * Test serializing an object with static properties and methods 437 */ 438 public function testObjectStatic() { 439 $writer = new stubDomXMLStreamWriter(); 440 $obj = new stubXMLSerializerTestCase_Static(); 441 $this->serializer->serialize($obj, $writer, array(stubXMLSerializer::OPT_STATIC => true)); 442 $this->assertEqual('<?xml version="1.0" encoding="UTF-8"?>' . "\n" . '<stubXMLSerializerTestCase_Static><foo>foo</foo><getBar>bar</getBar></stubXMLSerializerTestCase_Static>', $writer->asXML()); 443 444 $writer = new stubDomXMLStreamWriter(); 445 $this->serializer->serialize($obj, $writer); 446 $this->assertEqual('<?xml version="1.0" encoding="UTF-8"?>' . "\n" . '<stubXMLSerializerTestCase_Static/>', $writer->asXML()); 447 } 448 449 /** 424 450 * Test serializing an object with umlauts 425 451 */
