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'])]); }
/** * @covers ::initialize */ public function testInitialize() { $purchaseItem = PurchaseItem::getRepo(); $purchase = $purchaseItem->getRelOrError('purchase'); $this->assertEquals('CL\\Purchases\\Purchase', $purchase->getRepo()->getModelClass()); $storePurchase = $purchaseItem->getRelOrError('storePurchase'); $this->assertEquals('CL\\Purchases\\StorePurchase', $storePurchase->getRepo()->getModelClass()); }
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()); }