Skip to content
Snippets Groups Projects
Commit e2d28789 authored by Andy Summers's avatar Andy Summers
Browse files

Merge branch 'php7-product-price' into 'master'

Add PHP 7 type annotation to Product/Price classes

See merge request !76
parents 975357b5 5a2999cb
No related branches found
No related tags found
1 merge request!76Add PHP 7 type annotation to Product/Price classes
......@@ -29,7 +29,7 @@ class MockPriceService implements PriceService, MockService
/**
* {@inheritdoc}
*/
public function updateProductPrice($sku, Money $price)
public function updateProductPrice(string $sku, Money $price): PriceServiceResponse
{
return $this->response;
}
......
......@@ -14,10 +14,10 @@ interface PriceService extends Service
/**
* Update the price for the given SKU.
*
* @param $sku
* @param string $sku
* @param Money $price
* @return PriceServiceResponse
*/
public function updateProductPrice($sku, Money $price);
public function updateProductPrice(string $sku, Money $price): PriceServiceResponse;
}
......@@ -52,7 +52,7 @@ class SoapPriceService implements PriceService, SoapService
/**
* @inheritdoc
*/
public function updateProductPrice($sku, Money $price)
public function updateProductPrice(string $sku, Money $price): PriceServiceResponse
{
$outputParameters = $this->soapClient->ITEM_PRICING(
new InputParameters(
......
......@@ -27,7 +27,7 @@ class MockProductService implements ProductService, MockService
/**
* {@inheritDoc}
*/
public function createProduct(Product $product)
public function createProduct(Product $product): ProductServiceResponse
{
return $this->response;
}
......@@ -35,7 +35,7 @@ class MockProductService implements ProductService, MockService
/**
* {@inheritDoc}
*/
public function updateProduct(Product $product)
public function updateProduct(Product $product): ProductServiceResponse
{
return $this->response;
}
......
......@@ -18,8 +18,8 @@ class Product
/** @var string CBS value for MinMax inactive */
const MIN_MAX_INACTIVE = 'no';
/** @var float Stock Keeping Unit, a unique product identifier */
private $sku;
/** @var string Stock Keeping Unit, a unique product identifier */
private $itemNumber;
/** @var string name / short description */
private $name = '';
......@@ -60,9 +60,6 @@ class Product
/** @var string UPC (barcode) */
private $upc = '';
/** @var string UDDS number */
private $udds = '';
/** @var int CBS Item Template */
private $cbsItemTemplate;
......@@ -91,26 +88,26 @@ class Product
private $testMode;
/**
* @return float
* @return string
*/
public function getSku()
public function getItemNumber(): string
{
return $this->sku;
return $this->itemNumber;
}
/**
* @param float $sku
* @param string $itemNumber
* @return Product
*/
public function setSku($sku)
public function setItemNumber(string $itemNumber): Product
{
$this->sku = $sku;
$this->itemNumber = $itemNumber;
return $this;
}
/**
* @return string
*/
public function getName()
public function getName(): string
{
return $this->name;
}
......@@ -119,14 +116,14 @@ class Product
* @param string $name
* @return Product
*/
public function setName($name)
public function setName(string $name): Product
{
$this->name = $name;
return $this;
}
/**
* @return Money
* @return Money|null
*/
public function getCost()
{
......@@ -137,7 +134,7 @@ class Product
* @param Money $cost
* @return Product
*/
public function setCost(Money $cost = null)
public function setCost(Money $cost = null): Product
{
$this->cost = $cost;
return $this;
......@@ -146,7 +143,7 @@ class Product
/**
* @return string
*/
public function getCategory()
public function getCategory(): string
{
return $this->category;
}
......@@ -155,7 +152,7 @@ class Product
* @param string $category
* @return Product
*/
public function setCategory($category)
public function setCategory(string $category): Product
{
$this->category = $category;
return $this;
......@@ -164,7 +161,7 @@ class Product
/**
* @return string
*/
public function getManufacturer()
public function getManufacturer(): string
{
return $this->manufacturer;
}
......@@ -173,7 +170,7 @@ class Product
* @param string $manufacturer
* @return Product
*/
public function setManufacturer($manufacturer)
public function setManufacturer(string $manufacturer): Product
{
$this->manufacturer = $manufacturer;
return $this;
......@@ -182,7 +179,7 @@ class Product
/**
* @return string
*/
public function getManufacturerPartNumber()
public function getManufacturerPartNumber(): string
{
return $this->manufacturerPartNumber;
}
......@@ -191,43 +188,43 @@ class Product
* @param string $manufacturerPartNumber
* @return Product
*/
public function setManufacturerPartNumber($manufacturerPartNumber)
public function setManufacturerPartNumber(string $manufacturerPartNumber): Product
{
$this->manufacturerPartNumber = $manufacturerPartNumber;
return $this;
}
/**
* @return string
* @return float
*/
public function getMinQuantity()
public function getMinQuantity(): float
{
return $this->minQuantity;
}
/**
* @param string $minQuantity
* @param float $minQuantity
* @return Product
*/
public function setMinQuantity($minQuantity)
public function setMinQuantity(float $minQuantity): Product
{
$this->minQuantity = $minQuantity;
return $this;
}
/**
* @return string
* @return float
*/
public function getMaxQuantity()
public function getMaxQuantity(): float
{
return $this->maxQuantity;
}
/**
* @param string $maxQuantity
* @param float $maxQuantity
* @return Product
*/
public function setMaxQuantity($maxQuantity)
public function setMaxQuantity(float $maxQuantity): Product
{
$this->maxQuantity = $maxQuantity;
return $this;
......@@ -236,7 +233,7 @@ class Product
/**
* @return string
*/
public function getLifecycle()
public function getLifecycle(): string
{
return $this->lifecycle;
}
......@@ -245,7 +242,7 @@ class Product
* @param string $lifecycle
* @return Product
*/
public function setLifecycle($lifecycle)
public function setLifecycle(string $lifecycle): Product
{
$this->lifecycle = $lifecycle;
return $this;
......@@ -254,7 +251,7 @@ class Product
/**
* @return string
*/
public function getSerialControlFlag()
public function getSerialControlFlag(): string
{
return $this->serialControlFlag;
}
......@@ -263,7 +260,7 @@ class Product
* @param string $serialControlFlag
* @return Product
*/
public function setSerialControlFlag($serialControlFlag)
public function setSerialControlFlag(string $serialControlFlag): Product
{
$this->serialControlFlag = $serialControlFlag;
return $this;
......@@ -272,7 +269,7 @@ class Product
/**
* @return string
*/
public function getVendor()
public function getVendor(): string
{
return $this->vendor;
}
......@@ -281,7 +278,7 @@ class Product
* @param string $vendor
* @return Product
*/
public function setVendor($vendor)
public function setVendor(string $vendor): Product
{
$this->vendor = $vendor;
return $this;
......@@ -290,7 +287,7 @@ class Product
/**
* @return string
*/
public function getVendorPartNumber()
public function getVendorPartNumber(): string
{
return $this->vendorPartNumber;
}
......@@ -299,7 +296,7 @@ class Product
* @param string $vendorPartNumber
* @return Product
*/
public function setVendorPartNumber($vendorPartNumber)
public function setVendorPartNumber(string $vendorPartNumber): Product
{
$this->vendorPartNumber = $vendorPartNumber;
return $this;
......@@ -308,7 +305,7 @@ class Product
/**
* @return string
*/
public function getUpc()
public function getUpc(): string
{
return $this->upc;
}
......@@ -317,7 +314,7 @@ class Product
* @param string $upc
* @return Product
*/
public function setUpc($upc)
public function setUpc(string $upc): Product
{
$this->upc = $upc;
return $this;
......@@ -326,34 +323,16 @@ class Product
/**
* @return string
*/
public function getUdds()
{
return $this->udds;
}
/**
* @param string $udds
* @return Product
*/
public function setUdds($udds)
{
$this->udds = $udds;
return $this;
}
/**
* @return int
*/
public function getCbsItemTemplate()
public function getCbsItemTemplate(): string
{
return $this->cbsItemTemplate;
}
/**
* @param int $cbsItemTemplate
* @param string $cbsItemTemplate
* @return Product
*/
public function setCbsItemTemplate($cbsItemTemplate)
public function setCbsItemTemplate(string $cbsItemTemplate): Product
{
$this->cbsItemTemplate = $cbsItemTemplate;
return $this;
......@@ -363,7 +342,7 @@ class Product
* @param string $pricingTemplate
* @return Product
*/
public function setPricingTemplate($pricingTemplate)
public function setPricingTemplate(string $pricingTemplate): Product
{
$this->pricingTemplate = $pricingTemplate;
return $this;
......@@ -372,7 +351,7 @@ class Product
/**
* @return string
*/
public function getPricingTemplate()
public function getPricingTemplate(): string
{
return $this->pricingTemplate;
}
......@@ -380,7 +359,7 @@ class Product
/**
* @return float
*/
public function getBasePrice()
public function getBasePrice(): float
{
return $this->basePrice;
}
......@@ -389,7 +368,7 @@ class Product
* @param float $basePrice
* @return Product
*/
public function setBasePrice($basePrice)
public function setBasePrice(float $basePrice): Product
{
$this->basePrice = $basePrice;
return $this;
......@@ -398,7 +377,7 @@ class Product
/**
* @return string
*/
public function getReference()
public function getReference(): string
{
return $this->reference;
}
......@@ -407,25 +386,25 @@ class Product
* @param string $reference
* @return Product
*/
public function setReference($reference)
public function setReference(string $reference): Product
{
$this->reference = $reference;
return $this;
}
/**
* @return string
* @return float
*/
public function getCostCenter()
public function getCostCenter(): float
{
return $this->costCenter;
}
/**
* @param string $costCenter
* @param float $costCenter
* @return Product
*/
public function setCostCenter($costCenter)
public function setCostCenter($costCenter): Product
{
$this->costCenter = $costCenter;
return $this;
......@@ -434,7 +413,7 @@ class Product
/**
* @return string
*/
public function getPlannerCode()
public function getPlannerCode(): string
{
return $this->plannerCode;
}
......@@ -443,7 +422,7 @@ class Product
* @param string $plannerCode
* @return Product
*/
public function setPlannerCode($plannerCode)
public function setPlannerCode(string $plannerCode): Product
{
$this->plannerCode = $plannerCode;
return $this;
......@@ -452,7 +431,7 @@ class Product
/**
* @return string
*/
public function getMinMaxActive()
public function getMinMaxActive(): string
{
return $this->minMaxActive;
}
......@@ -461,7 +440,7 @@ class Product
* @param string $minMaxActive
* @return Product
*/
public function setMinMaxActive($minMaxActive)
public function setMinMaxActive(string $minMaxActive): Product
{
$this->minMaxActive = $minMaxActive;
return $this;
......@@ -470,7 +449,7 @@ class Product
/**
* @return string
*/
public function getBuyer()
public function getBuyer(): string
{
return $this->buyer;
}
......@@ -479,7 +458,7 @@ class Product
* @param string $buyer
* @return Product
*/
public function setBuyer($buyer)
public function setBuyer(string $buyer): Product
{
$this->buyer = $buyer;
return $this;
......@@ -488,7 +467,7 @@ class Product
/**
* @return string
*/
public function getProductManager()
public function getProductManager(): string
{
return $this->productManager;
}
......@@ -497,7 +476,7 @@ class Product
* @param string $productManager
* @return Product
*/
public function setProductManager($productManager)
public function setProductManager(string $productManager): Product
{
$this->productManager = $productManager;
return $this;
......@@ -506,7 +485,7 @@ class Product
/**
* @return string
*/
public function getTestMode()
public function getTestMode(): string
{
return $this->testMode;
}
......@@ -515,7 +494,7 @@ class Product
* @param string $testMode
* @return Product
*/
public function setTestMode($testMode)
public function setTestMode(string $testMode): Product
{
$this->testMode = $testMode;
return $this;
......
......@@ -81,7 +81,7 @@ class ProductInputParametersMapper
);
}
$inputParameters->setP_ITEM_NUMBER($product->getSku())
$inputParameters->setP_ITEM_NUMBER($product->getItemNumber())
->setP_ITEM_DESCRIPTION($product->getName())
->setP_CBS_ITEM_TEMPLATE($product->getCbsItemTemplate())
->setP_ITEM_CATEGORY($product->getCategory())
......
......@@ -18,7 +18,7 @@ interface ProductService extends Service
* @param Product product to create
* @return ProductServiceResponse
*/
public function createProduct(Product $product);
public function createProduct(Product $product): ProductServiceResponse;
/**
* Update an existing product.
......@@ -26,6 +26,6 @@ interface ProductService extends Service
* @param Product product to update
* @return ProductServiceResponse
*/
public function updateProduct(Product $product);
public function updateProduct(Product $product): ProductServiceResponse;
}
......@@ -86,7 +86,7 @@ class SoapProductService implements ProductService
/**
* {@inheritDoc}
*/
public function createProduct(Product $product)
public function createProduct(Product $product): ProductServiceResponse
{
$outputParameters = $this->productCreateSoapClient->ITEM_CREATE(
ProductInputParametersMapper::toInputParameters(
......@@ -100,7 +100,7 @@ class SoapProductService implements ProductService
/**
* {@inheritDoc}
*/
public function updateProduct(Product $product)
public function updateProduct(Product $product): ProductServiceResponse
{
$outputParameters = $this->productUpdateSoapClient->ITEM_UPDATE(
ProductInputParametersMapper::toInputParameters(
......
......@@ -13,7 +13,7 @@ class ProductInputParametersMapperTest extends \PHPUnit_Framework_TestCase
public function mapsProductToInputParameters()
{
$product = (new Product())
->setSku('itemNumber')
->setItemNumber('itemNumber')
->setName('name')
->setCategory('category')
->setCbsItemTemplate(1389)
......@@ -30,7 +30,7 @@ class ProductInputParametersMapperTest extends \PHPUnit_Framework_TestCase
->setBasePrice(5.0)
->setPricingTemplate('template')
->setReference('reference')
->setCostCenter('A123456')
->setCostCenter(5060)
->setPlannerCode('code')
->setMinMaxActive('no')
->setBuyer('Bucky Badger')
......@@ -42,7 +42,7 @@ class ProductInputParametersMapperTest extends \PHPUnit_Framework_TestCase
ProductInputParametersMapper::$CREATE
);
static::assertEquals($product->getSku(), $inputParameters->getP_ITEM_NUMBER());
static::assertEquals($product->getItemNumber(), $inputParameters->getP_ITEM_NUMBER());
static::assertEquals($product->getName(), $inputParameters->getP_ITEM_DESCRIPTION());
static::assertEquals($product->getCategory(), $inputParameters->getP_ITEM_CATEGORY());
static::assertEquals($product->getCbsItemTemplate(), $inputParameters->getP_CBS_ITEM_TEMPLATE());
......@@ -72,8 +72,32 @@ class ProductInputParametersMapperTest extends \PHPUnit_Framework_TestCase
/** @test */
public function handlesNullCost()
{
$product = (new Product())
->setItemNumber('itemNumber')
->setName('name')
->setCategory('category')
->setCbsItemTemplate(1389)
->setManufacturer('manufacturer')
->setManufacturerPartNumber('manufacturerPartNumber')
->setMinQuantity(1)
->setMaxQuantity(5)
->setLifecycle('lifecycle')
->setSerialControlFlag('serialCtrlFlag')
->setVendor('vendor')
->setVendorPartNumber('vendorPartNumber')
->setUpc('upc')
->setBasePrice(5.0)
->setPricingTemplate('template')
->setReference('reference')
->setCostCenter(5060)
->setPlannerCode('code')
->setMinMaxActive('no')
->setBuyer('Bucky Badger')
->setProductManager('Bucky Badger')
->setTestMode('yesplz');
$inputParameters = ProductInputParametersMapper::toInputParameters(
new Product(),
$product,
ProductInputParametersMapper::$CREATE
);
static::assertNull($inputParameters->getP_COST());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment