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
 /**
  * @inheritdoc
  */
 public function deleteOffer($offer)
 {
     if (!$offer instanceof Offer) {
         $offer = Offer::toDelete($offer);
     }
     $this->validator->validateDelete($offer);
     $target = "/offers/v1/" . $offer->getId();
     $response = $this->client->delete($target);
     $isDeleted = $response->getStatusCode() === 202;
     return $isDeleted;
 }
示例#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
 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());
 }
示例#5
0
 /**
  * Validate Offer model when it is used to delete an offer
  * @param Offer $offer
  */
 public function validateDelete(Offer $offer)
 {
     Assert::id($offer->getId());
 }