public static function initialize(Config $config) { CurrencyTrait::initialize($config); ValueTrait::initialize($config); SoftDeleteTrait::initialize($config); $config->addRels([new Rel\BelongsTo('store', $config, Store::getRepo()), new Rel\HasMany('productItems', $config, ProductItem::getRepo(), ['foreignKey' => 'refId'])])->addAsserts([new Assert\Present('name'), new Assert\LengthLessThan('name', 150)]); }
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 ::getStorePurchaseForStore */ public function testGetStorePurchaseForStore() { $purchase = Purchase::find(2); $store = Store::find(1); $storePurchase = $purchase->getStorePurchaseForStore($store); $this->assertInstanceOf('CL\\Purchases\\StorePurchase', $storePurchase); $this->assertSame($store, $storePurchase->getStore()); $this->assertSame($purchase, $storePurchase->getPurchase()); $this->assertTrue($purchase->getStorePurchases()->has($storePurchase)); $storePurchase2 = $purchase->getStorePurchaseForStore($store); $this->assertSame($storePurchase2, $storePurchase); }
/** * @covers ::getStorePurchases */ public function testStorePurchases() { $store = new Store(); $items = $store->getStorePurchases(); $this->assertEquals(StorePurchase::getRepo(), $items->getRel()->getRepo()); }