Beispiel #1
0
 public static function initialize(Config $config)
 {
     ItemGroupTrait::initialize($config);
     TimestampsTrait::initialize($config);
     RandomKeyTrait::initialize($config);
     $config->setTable('StorePurchase')->addRels([new Rel\BelongsTo('purchase', $config, Purchase::getRepo()), new Rel\BelongsTo('store', $config, Store::getRepo()), new Rel\HasMany('items', $config, PurchaseItem::getRepo(), ['inverseOf' => 'storePurchase']), new Rel\HasMany('refunds', $config, Refund::getRepo(), ['inverseOf' => 'storePurchase'])]);
 }
Beispiel #2
0
 public static function initialize(Config $config)
 {
     TransferTrait::initialize($config);
     ItemGroupTrait::initialize($config);
     TimestampsTrait::initialize($config);
     RandomKeyTrait::initialize($config);
     CurrencyTrait::initialize($config);
     $config->setTable('Purchase')->addRels([new Rel\HasMany('items', $config, PurchaseItem::getRepo(), ['inverseOf' => 'purchase']), new Rel\HasMany('storePurchases', $config, StorePurchase::getRepo(), ['inverseOf' => 'purchase']), new Rel\BelongsTo('billing', $config, Address::getRepo())]);
 }
 /**
  * @covers ::getItems
  */
 public function testItems()
 {
     $storePurchase = new StorePurchase();
     $items = $storePurchase->getItems();
     $this->assertEquals(PurchaseItem::getRepo(), $items->getRel()->getRepo());
 }
Beispiel #4
0
 /**
  * @coversNothing
  */
 public function testIntegration()
 {
     $purchase = Purchase::find(1);
     $item1 = PurchaseItem::find(1);
     $item2 = PurchaseItem::find(2);
     $item3 = PurchaseItem::find(3);
     $item4 = PurchaseItem::find(4);
     $storePurchase1 = StorePurchase::find(1);
     $storePurchase2 = StorePurchase::find(2);
     $billing = Address::find(1);
     $items = $purchase->getItems();
     $this->assertSame([$item1, $item2, $item3, $item4], $purchase->getItems()->toArray());
     $this->assertSame([$storePurchase1, $storePurchase2], $purchase->getStorePurchases()->toArray());
     $this->assertSame($billing, $purchase->getBilling());
 }
Beispiel #5
0
 public static function initialize(Config $config)
 {
     parent::initialize($config);
     $config->addRels([new Rel\BelongsTo('product', $config, Product::getRepo(), ['key' => 'sourceId'])]);
 }
 /**
  * @covers ::getSourceValue
  */
 public function testSourceValue()
 {
     $item = new PurchaseItem(['value' => 1000]);
     $value = new Money(1000, new Currency('GBP'));
     $this->assertEquals($value, $item->getSourceValue());
 }