diff --git a/src/Sylius/Bundle/InventoryBundle/Entity/Stockable.php b/src/Sylius/Bundle/InventoryBundle/Entity/Stockable.php new file mode 100644 index 00000000000..8b7064a4100 --- /dev/null +++ b/src/Sylius/Bundle/InventoryBundle/Entity/Stockable.php @@ -0,0 +1,23 @@ + + */ +class Stockable extends BaseStockable +{ +} diff --git a/src/Sylius/Bundle/InventoryBundle/Model/Stockable.php b/src/Sylius/Bundle/InventoryBundle/Model/Stockable.php new file mode 100644 index 00000000000..94ac4c74847 --- /dev/null +++ b/src/Sylius/Bundle/InventoryBundle/Model/Stockable.php @@ -0,0 +1,129 @@ + + */ +class Stockable implements StockableInterface +{ + /** + * Stockable id. + * + * @var mixed + */ + protected $id; + + /** + * Stockable SKU. + * + * @var string + */ + protected $sku; + + /** + * Inventory displayed name. + * + * @var string + */ + protected $inventoryName; + + /** + * Current stock level. + * + * @var int + */ + protected $onHand; + + /** + * Is stock available on demand? + * + * @var Boolean + */ + protected $availableOnDemand; + + public function __construct() + { + $this->onHand = 1; + $this->availableOnDemand = true; + } + + public function getId() + { + return $this->id; + } + + /** + * {@inheritdoc} + */ + public function getSku() + { + return $this->sku; + } + + public function setSku($sku) + { + $this->sku = $sku; + } + + /** + * {@inheritdoc} + */ + public function getInventoryName() + { + return $this->inventoryName; + } + + public function setInventoryName($inventoryName) + { + $this->inventoryName = $inventoryName; + } + + /** + * {@inheritdoc} + */ + public function isInStock() + { + return 0 < $this->onHand; + } + + /** + * {@inheritdoc} + */ + public function isAvailableOnDemand() + { + return $this->availableOnDemand; + } + + public function setAvailableOnDemand($availableOnDemand) + { + $this->availableOnDemand = (Boolean) $availableOnDemand; + } + + /** + * {@inheritdoc} + */ + public function getOnHand() + { + return $this->onHand; + } + + /** + * {@inheritdoc} + */ + public function setOnHand($onHand) + { + $this->onHand = $onHand; + } +} diff --git a/src/Sylius/Bundle/InventoryBundle/Resources/config/doctrine/Stockable.orm.xml b/src/Sylius/Bundle/InventoryBundle/Resources/config/doctrine/Stockable.orm.xml new file mode 100644 index 00000000000..4289885c7c7 --- /dev/null +++ b/src/Sylius/Bundle/InventoryBundle/Resources/config/doctrine/Stockable.orm.xml @@ -0,0 +1,27 @@ + + + + + + xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping + http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd"> + + + + + + + + + diff --git a/src/Sylius/Bundle/InventoryBundle/spec/Sylius/Bundle/InventoryBundle/Entity/InventoryUnit.php b/src/Sylius/Bundle/InventoryBundle/spec/Sylius/Bundle/InventoryBundle/Entity/InventoryUnit.php index 84dc75be59f..2e3d6ae5d75 100644 --- a/src/Sylius/Bundle/InventoryBundle/spec/Sylius/Bundle/InventoryBundle/Entity/InventoryUnit.php +++ b/src/Sylius/Bundle/InventoryBundle/spec/Sylius/Bundle/InventoryBundle/Entity/InventoryUnit.php @@ -5,7 +5,7 @@ use PHPSpec2\ObjectBehavior; /** - * Shipment item mapped superclass spec. + * Inventory unit entity spec. * * @author Pawęł Jędrzejewski */ diff --git a/src/Sylius/Bundle/InventoryBundle/spec/Sylius/Bundle/InventoryBundle/Entity/Stockable.php b/src/Sylius/Bundle/InventoryBundle/spec/Sylius/Bundle/InventoryBundle/Entity/Stockable.php new file mode 100644 index 00000000000..f0af0d0c6bf --- /dev/null +++ b/src/Sylius/Bundle/InventoryBundle/spec/Sylius/Bundle/InventoryBundle/Entity/Stockable.php @@ -0,0 +1,28 @@ + + */ +class Stockable extends ObjectBehavior +{ + function it_should_be_initializable() + { + $this->shouldHaveType('Sylius\Bundle\InventoryBundle\Entity\Stockable'); + } + + function it_should_be_a_Sylius_stockable() + { + $this->shouldImplement('Sylius\Bundle\InventoryBundle\Model\StockableInterface'); + } + + function it_should_extend_Sylius_stockable_model() + { + $this->shouldHaveType('Sylius\Bundle\InventoryBundle\Model\Stockable'); + } +} diff --git a/src/Sylius/Bundle/InventoryBundle/spec/Sylius/Bundle/InventoryBundle/Model/InventoryUnit.php b/src/Sylius/Bundle/InventoryBundle/spec/Sylius/Bundle/InventoryBundle/Model/InventoryUnit.php index ddb2db1e174..0272371b4cb 100644 --- a/src/Sylius/Bundle/InventoryBundle/spec/Sylius/Bundle/InventoryBundle/Model/InventoryUnit.php +++ b/src/Sylius/Bundle/InventoryBundle/spec/Sylius/Bundle/InventoryBundle/Model/InventoryUnit.php @@ -6,7 +6,7 @@ use Sylius\Bundle\InventoryBundle\Model\InventoryUnitInterface; /** - * Stockable item model spec. + * Inventory unit model spec. * * @author Paweł Jędrzejewski */ diff --git a/src/Sylius/Bundle/InventoryBundle/spec/Sylius/Bundle/InventoryBundle/Model/Stockable.php b/src/Sylius/Bundle/InventoryBundle/spec/Sylius/Bundle/InventoryBundle/Model/Stockable.php new file mode 100644 index 00000000000..63cabfce1ff --- /dev/null +++ b/src/Sylius/Bundle/InventoryBundle/spec/Sylius/Bundle/InventoryBundle/Model/Stockable.php @@ -0,0 +1,78 @@ + + */ +class Stockable extends ObjectBehavior +{ + function it_should_be_initializable() + { + $this->shouldHaveType('Sylius\Bundle\InventoryBundle\Model\Stockable'); + } + + function it_should_be_a_Sylius_stockable() + { + $this->shouldImplement('Sylius\Bundle\InventoryBundle\Model\StockableInterface'); + } + + function it_should_not_have_id_by_default() + { + $this->getId()->shouldReturn(null); + } + + function it_should_not_have_defined_sku_by_default() + { + $this->getSku()->shouldReturn(null); + } + + function its_sku_should_be_mutable() + { + $this->setSku('1234R'); + $this->getSku()->shouldReturn('1234R'); + } + + function it_should_not_have_defined_inventory_name_by_default() + { + $this->getInventoryName()->shouldReturn(null); + } + + function its_inventory_name_should_be_mutable() + { + $this->setInventoryName('Lorem Ipsum'); + $this->getInventoryName()->shouldReturn('Lorem Ipsum'); + } + + function it_should_be_in_stock_by_default() + { + $this->isInStock()->shouldReturn(true); + } + + function it_should_be_available_on_demand_by_default() + { + $this->isAvailableOnDemand()->shouldReturn(true); + } + + function its_available_on_demand_should_be_mutable() + { + $this->setAvailableOnDemand(false); + $this->isAvailableOnDemand()->shouldReturn(false); + } + + function it_should_have_1_on_hand_by_default() + { + $this->getOnHand()->shouldReturn(1); + } + + + function its_on_hand_should_be_mutable() + { + $this->setOnHand(5); + $this->getOnHand()->shouldReturn(5); + } +}