コード例 #1
0
 public function testValidation()
 {
     $validator = new OfferValidator();
     $id = 1;
     $ean = "1234567890123";
     $condition = Condition::COND_AS_NEW;
     $price = 3.5;
     $deliveryCode = DeliveryCode::DC_12D;
     $quantityInStock = 150;
     $publish = true;
     $referenceCode = "foo";
     $description = "bar";
     // Creation
     $offer = Offer::toCreate($id, $ean, $condition, $price, $deliveryCode, $quantityInStock, $publish, $referenceCode, $description);
     $validator->validateCreateOffer($offer);
     // Regular update
     $offer = Offer::toUpdate($id, $price, $deliveryCode, $publish, $referenceCode, $description);
     $validator->validateUpdateOffer($offer);
     // Stock update
     $offer = Offer::toUpdateStock($id, $quantityInStock);
     $validator->validateStockUpdate($offer);
     // Deletion
     $offer = Offer::toDelete($id);
     $validator->validateDelete($offer);
 }
コード例 #2
0
ファイル: Plaza.php プロジェクト: koenreiniers/bol-sdk
 /**
  * @inheritdoc
  */
 public function updateOfferStock($offer, $quantityInStock = null)
 {
     if (!$offer instanceof Offer) {
         $offer = Offer::toUpdateStock($offer, $quantityInStock);
     }
     if ($quantityInStock !== null) {
         $offer->setQuantityInStock($quantityInStock);
     }
     $this->validator->validateStockUpdate($offer);
     $content = $this->xmlWriter->write(__DIR__ . "/Templates/stockUpdate.xml", $offer);
     $target = "/offers/v1/" . $offer->getId() . "/stock";
     $response = $this->client->put($target, $content);
     $isUpdated = $response->getStatusCode() === 202;
     return $isUpdated;
 }
コード例 #3
0
    public function testWrite()
    {
        $writer = new XmlWriter();
        $id = 1;
        $quantityInStock = 150;
        $filename = __DIR__ . "/../../src/Templates/stockUpdate.xml";
        $offer = Offer::toUpdateStock($id, $quantityInStock);
        $output = $writer->write($filename, $offer);
        $expected = <<<EOF
<?xml version="1.0" encoding="UTF-8"?>
<StockUpdate xmlns="http://plazaapi.bol.com/offers/xsd/api-1.0.xsd">
    <QuantityInStock>150</QuantityInStock>
</StockUpdate>
EOF;
        $this->assertEquals($expected, $output);
    }
コード例 #4
0
ファイル: OfferTest.php プロジェクト: koenreiniers/bol-sdk
 public function testOfferCreation()
 {
     $id = 1;
     $ean = "1234567890123";
     $condition = Condition::COND_AS_NEW;
     $price = 3.5;
     $deliveryCode = DeliveryCode::DC_12D;
     $quantityInStock = 150;
     $publish = true;
     $referenceCode = "foo";
     $description = "bar";
     // Creation
     $offer = Offer::toCreate($id, $ean, $condition, $price, $deliveryCode, $quantityInStock, $publish, $referenceCode, $description);
     $this->assertEquals($id, $offer->getId());
     $this->assertEquals($ean, $offer->getEan());
     $this->assertEquals($condition, $offer->getCondition());
     $this->assertEquals($price, $offer->getPrice());
     $this->assertEquals($deliveryCode, $offer->getDeliveryCode());
     $this->assertEquals($quantityInStock, $offer->getQuantityInStock());
     $this->assertEquals($publish, $offer->getPublish());
     $this->assertEquals($referenceCode, $offer->getReferenceCode());
     $this->assertEquals($description, $offer->getDescription());
     // Regular update
     $offer = Offer::toUpdate($id, $price, $deliveryCode, $publish, $referenceCode, $description);
     $this->assertEquals($id, $offer->getId());
     $this->assertEquals($price, $offer->getPrice());
     $this->assertEquals($deliveryCode, $offer->getDeliveryCode());
     $this->assertEquals($publish, $offer->getPublish());
     $this->assertEquals($referenceCode, $offer->getReferenceCode());
     $this->assertEquals($description, $offer->getDescription());
     // Stock update
     $offer = Offer::toUpdateStock($id, $quantityInStock);
     $this->assertEquals($id, $offer->getId());
     $this->assertEquals($quantityInStock, $offer->getQuantityInStock());
     // Deletion
     $offer = Offer::toDelete($id);
     $this->assertEquals($id, $offer->getId());
 }