/** * testValidXML * * Make sure it builds valid XML */ public function testValidXML() { $fragment = new ShippingMethod(); $fragment->setModuleCode('ModuleCode')->setMethodCode('MethodCode'); $expectedXml = '<ShippingMethod module_code="ModuleCode" method_code="MethodCode" />'; $this->assertXmlStringEqualsXmlString($expectedXml, $fragment->toXML()->saveXML()); }
/** * testValidXML * * Make sure it builds valid XML */ public function testValidXML() { $fragment = new ProductShippingRulesUpdate(); $fragment->setProductCode('ProductCode')->setShipsInOwnPackaging('ShipsInOwnPackaging')->setWidth('Width')->setLength('Length')->setHeight('Height')->setLimitShippingMethods('LimitShippingMethods'); $testMethods = array(array('bar', 'foo'), array('bin', 'baz')); foreach ($testMethods as $testMethod) { $method = new ShippingMethod(); $method->setModuleCode($testMethod[0])->setMethodCode($testMethod[1]); $fragment->addShippingMethod($method); } $expectedXml = '<ProductShippingRules_Update product_code="ProductCode"> <ShipsInOwnPackaging>ShipsInOwnPackaging</ShipsInOwnPackaging> <Width>Width</Width> <Length>Length</Length> <Height>Height</Height> <LimitShippingMethods>LimitShippingMethods</LimitShippingMethods> <ShippingMethods> <ShippingMethod module_code="bar" method_code="foo"/> <ShippingMethod module_code="bin" method_code="baz"/> </ShippingMethods> </ProductShippingRules_Update>'; $this->assertXmlStringEqualsXmlString($expectedXml, $fragment->toXML()->saveXML()); }