Пример #1
0
 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)]);
 }
Пример #2
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'])]);
 }
Пример #3
0
 /**
  * @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);
 }
Пример #4
0
 /**
  * @covers ::getStorePurchases
  */
 public function testStorePurchases()
 {
     $store = new Store();
     $items = $store->getStorePurchases();
     $this->assertEquals(StorePurchase::getRepo(), $items->getRel()->getRepo());
 }