private function saveGroup() { if ($this->groupObj->getId()) { return array('result' => true); } if (!$this->attributeSetObj) { return array('result' => false, 'error' => "Attribute Set '{$this->attributeSetId}' is not found."); } $this->groupObj->setAttributeGroupName($this->name); $this->groupObj->setAttributeSetId($this->attributeSetId); try { $this->groupObj->save(); } catch (\Exception $e) { return array('result' => false, 'error' => $e->getMessage()); } return array('result' => true, 'obj' => $this->groupObj); }
/** * @dataProvider attributeGroupCodeDataProvider * @param string $groupName * @param string $groupCode */ public function testBeforeSaveGeneratesGroupCodeBasedOnGroupName($groupName, $groupCode) { $this->model->setAttributeGroupName($groupName); $this->model->beforeSave(); $this->assertEquals($groupCode, $this->model->getAttributeGroupCode()); }