Exemple #1
0
 /**
  * @covers ::getProducts
  */
 public function testProducts()
 {
     $store = new Store();
     $items = $store->getProducts();
     $this->assertInstanceOf('Harp\\Harp\\Repo\\LinkMany', $items);
     $this->assertEquals(Product::getRepo(), $items->getRel()->getRepo());
 }
Exemple #2
0
 /**
  * @covers ::initialize
  */
 public function testInitialize()
 {
     $product = Product::getRepo();
     $store = $product->getRelOrError('store');
     $this->assertEquals('CL\\Purchases\\Store', $store->getRepo()->getModelClass());
     $items = $product->getRelOrError('productItems');
     $this->assertEquals('CL\\Purchases\\ProductItem', $items->getRepo()->getModelClass());
     $model = new Product();
     $this->assertFalse($model->validate());
     $errors = $model->getErrors()->humanize();
     $expected = 'name must be present';
     $this->assertEquals($expected, $errors);
 }
Exemple #3
0
 public static function initialize(Config $config)
 {
     parent::initialize($config);
     $config->addRels([new Rel\BelongsTo('product', $config, Product::getRepo(), ['key' => 'sourceId'])]);
 }
Exemple #4
0
 public static function initialize(Config $config)
 {
     SoftDeleteTrait::initialize($config);
     $config->addRels([new Rel\HasMany('products', $config, Product::getRepo(), ['inverseOf' => 'store']), new Rel\HasMany('storePurchases', $config, StorePurchase::getRepo(), ['inverseOf' => 'store'])])->addAsserts([new Assert\Present('name'), new Assert\LengthLessThan('name', 150)]);
 }