/** * Expect that the generator can be configured to alter the behaviour of the xmlSerialize method. */ public function testXmlSerializationAttributeOverrides() { $rootDirectory = realpath(sprintf('%s/../../', __DIR__)); $xsdPath = sprintf('%s/tests/integration/xsd', $rootDirectory); MethodGenerator::addXmlSerializationAttributeOverride('Money', 'id'); $generator = new Generator($xsdPath); $generator->generate(); $generatedFHIRMoneyClassPath = sprintf('%s/output/PHPFHIRGenerated/FHIRMoney.php', $rootDirectory); $expectedFHIRMoneyClassPath = sprintf('%s/tests/integration/expected/FHIRMoneyIdAsAttribute.php', $rootDirectory); $this->assertFileExists($generatedFHIRMoneyClassPath); $generatedFHIRMoneyClassContents = $this->stripDynamicCode(file_get_contents($generatedFHIRMoneyClassPath)); $expectedFHIRMoneyClassContents = trim(file_get_contents($expectedFHIRMoneyClassPath)); $this->assertSame($expectedFHIRMoneyClassContents, $generatedFHIRMoneyClassContents); // reset generator behaviour MethodGenerator::setXmlSerializationAttributeOverride(array()); }
/** * @param ClassTemplate $classTemplate */ public static function addBaseClassMethods(ClassTemplate $classTemplate) { MethodGenerator::implementToString($classTemplate); MethodGenerator::implementJsonSerialize($classTemplate); MethodGenerator::implementXMLSerialize($classTemplate); }