public function testSetBaseCurrencyCode() { $xml = new \XMLWriter(); $xml->openMemory(); $xml->setIndent(true); $xml->setIndentString("\t"); $node = new CurrencyAmount(); $this->setExpectedException('InvalidArgumentException'); $node->setBaseCurrencyCode('Foo'); }
public function testPrice() { $xml = new \XMLWriter(); $xml->openMemory(); $xml->setIndent(true); $price = new Price($xml); $price->setDepositAmount(DataType\CurrencyAmount::factory('1.00', 'USD'))->setMAP(DataType\CurrencyAmount::factory('2.00', 'USD'))->setPrevious(DataType\DatedPrice::factory(new \DateTime('2000-01-01T00:00:00-06:00'), new \DateTime('2001-01-01T00:00:00-06:00'), DataType\CurrencyAmount::factory('3.00', 'USD')))->setSale(DataType\Sale::factory(new \DateTime('2002-01-01T00:00:00-06:00'), new \DateTime('2003-01-03T00:00:00-06:00'), DataType\CurrencyAmount::factory('4.00', 'USD')))->setSku('ASDF')->setStandardPrice(DataType\CurrencyAmount::factory('5.00', 'USD')); $price->writeXml(); $dom = new \DOMDocument(); $dom->loadXML($xml->outputMemory(true)); $this->assertTrue($dom->schemaValidate(__DIR__ . '/../../../XSD/Price.xsd')); }
public function testAbstractProduct() { $xml = new \XMLWriter(); $xml->openMemory(); $xml->setIndent(true); $xml->setIndentString("\t"); $product = new ClothingProduct($xml); $product->addBulletPoint('Foo')->addCPSIAWarning('choking_hazard_balloon')->addOtherItemAttributes('Test')->addPlatinumKeywords('Sample')->addPromotionKeywords('Test')->addRebate('50')->addSearchTerms('Foo')->addSubjectContent('Test')->addTargetAudience('asdf')->addUsedFor('Bar')->setAutographed(true)->setBrand('adidas')->setBrowseExclusion(false)->setCPSIAWarningDescription('blah')->setCondition(DataType\ConditionInfo::factory('New'))->setDeliveryChannel('direct_ship')->setDescription('How now brown cow')->setDesigner('John Doe')->setDiscontinueDate(new \DateTime('2011-01-01T00:00:00-06:00'))->setIsDiscontinuedByManufacturer(false)->setIsGiftMessageAvailable(false)->setIsGiftWrapAvailable(false)->setItemDimensions(DataType\Dimensions::factory(DataType\LengthDimension::factory(1, 'IN'), DataType\LengthDimension::factory(2, 'IN')))->setItemPackageQuantity(1)->setItemType('Shoe')->setLaunchDate(new \DateTime('2000-01-01T00:00:00-06:00'))->setLegalDisclaimer('Foo')->setManufacturer('Acme')->setMaxAggregateShipQuantity(1)->setMaxOrderQuantity(1)->setMemorabilia(false)->setMerchantCatalogNumber(1234)->setMfrPartNumber('0001')->setMsrp(DataType\CurrencyAmount::factory(100, 'USD'))->setNumberOfItems(1)->setPackageDimensions(DataType\SpatialDimensions::factory(DataType\LengthDimension::factory(1, 'IN'), DataType\LengthDimension::factory(2, 'IN'), DataType\LengthDimension::factory(3, 'IN')))->setPackageWeight(DataType\WeightDimension::factory(1, 'LB'))->setPriority(1)->setProductTaxCode('A_GEN_TAX')->setProp65(false)->setRecommendationExclusion(false)->setReleaseDate(new \DateTime('2002-01-01T00:00:00-06:00'))->setSerialNumberRequired(false)->setShippingWeight(DataType\WeightDimension::factory(1, 'LB'))->setSku('ASDF')->setStandardProductId(DataType\StandardProductId::factory('UPC', 1234))->setTitle('Sample'); $product->writeXml(); $dom = new \DOMDocument(); $dom->loadXML($xml->outputMemory(true)); //$this->assertXmlStringEqualsXmlFile(__DIR__ . '/Mock/AbstractProduct.xml', $dom->saveXML()); }
/** * @depends testPriceFeed */ public function testAddPrice() { $client = $this->getServiceBuilder()->get('test.mws'); $feed = $client->getFeed('price'); $price = new Price($feed->getXml()); $price->setSku('ASDF')->setStandardPrice(DataType\CurrencyAmount::factory(10.0, 'USD')); $feed->addPrice($price); $dom = new \DOMDocument(); $dom->loadXML($feed->toString()); $this->assertSelectEquals('AmazonEnvelope Message MessageID', '1', true, $dom, null, false); $this->assertSelectEquals('AmazonEnvelope Message OperationType', 'Update', true, $dom, null, false); $this->assertSelectCount('AmazonEnvelope Message Price', 1, $dom, null, false); }
public function testSale() { $xml = new \XMLWriter(); $xml->openMemory(); $xml->setIndent(true); $xml->setIndentString("\t"); $node = new Sale(new \DateTime(), new \DateTime(), CurrencyAmount::factory(1, 'USD')); $node->setStartDate(new \DateTime())->setEndDate(new \DateTime())->setSalePrice(CurrencyAmount::factory(1, 'USD')); $node->writeXml($xml, 'Sale'); $dom = new \DOMDocument(); $dom->loadXML($xml->outputMemory(true)); $this->assertTrue($dom->schemaValidate(__DIR__ . '/../../../../XSD/DataType.xsd')); }