Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

allow the Product to be set when an Item is constructed

  • Loading branch information...
commit 457dbbd0f0fc65dd4c1f38b52b5e3b67588cd036 1 parent 852465e
@iampersistent iampersistent authored
Showing with 14 additions and 2 deletions.
  1. +14 −2 tests/Entity/Order/ItemTest.php
View
16 tests/Entity/Order/ItemTest.php
@@ -1,11 +1,23 @@
<?php
use Vespolina\Entity\Order\Item;
+use Vespolina\Entity\Product;
+
/**
* @author Richard Shank <develop@zestic.com>
*/
class ItemTest extends \PHPUnit_Framework_TestCase
{
+ public function testConstruct()
+ {
+ $item = new Item();
+ $this->assertNull($item->getProduct(), 'its ok if no product is passed in');
+
+ $product = new Product();
+ $item = new Item($product);
+ $this->assertSame($product, $item->getProduct(), 'the construct should set the product, if its passed in');
+ }
+
public function testOptionMethods()
{
$item = new Item();
@@ -33,7 +45,7 @@ public function testOptionMethods()
$rmClearOptions->setAccessible(true);
$rmSetProduct->invokeArgs($item, array($this->createProductOptionValidate(false)));
- $this->setExpectedException('Vespolina\Entity\Exception\InvalidOptionsException');
+ $this->setExpectedException('Vespolina\Exception\InvalidOptionsException');
$rmClearOptions->invoke($item);
$this->assertSame($options, $item->getOptions(), 'nothing should have been removed if the validation fails');
@@ -42,7 +54,7 @@ public function testOptionMethods()
$this->assertEmpty($item->getOptions());
$rmSetProduct->invokeArgs($item, array($this->createProductOptionValidate(false)));
- $this->setExpectedException('Vespolina\Entity\Exception\InvalidOptionsException');
+ $this->setExpectedException('Vespolina\Exception\InvalidOptionsException');
$rmSetOptions->invokeArgs($item, array('failure' => 0));
$this->assertEmpty($item->getOptions(), 'nothing should be added if the validation fails');
}
Please sign in to comment.
Something went wrong with that request. Please try again.