/** * add a product * * @param array $item * @return bool */ public function addItem($item) { $model = new Item($item); if ($model->validate()) { $this->items[] = $item; return true; } $this->errors = $model->errors; return false; }
/** * test whether item is created with given values */ public function testCreate() { $model = new Item(['name' => 'Item 1', 'amount' => 1, 'value' => 1000]); $this->assertTrue($model->validate()); }