/**
  * @param RedBeanModel $model
  * @param array $explicitReadWriteModelPermissions
  */
 protected function afterSetAttributesDuringSave($model, $explicitReadWriteModelPermissions)
 {
     assert('$model instanceof ProductTemplate');
     $postData = PostUtil::getData();
     if (isset($postData[$this->productTemplateProductCategoryFormName])) {
         $this->peopleAddedAsProductTemplateProductCategories = ProductTemplateProductCategoriesUtil::resolveProductTemplateHasManyProductCategoriesFromPost($model, $postData[$this->productTemplateProductCategoryFormName]);
     }
 }
 public function testResolveProductTemplateHasManyProductCategoriesFromPost()
 {
     $super = User::getByUsername('super');
     Yii::app()->user->userModel = $super;
     $category1 = ProductCategoryTestHelper::createProductCategoryByName('Test Product Category');
     $category2 = ProductCategoryTestHelper::createProductCategoryByName('Test Product Category2');
     $productTemplate = ProductTemplateTestHelper::createProductTemplateByName('PT1');
     $postData = array('categoryIds' => $category1->id . ',' . $category2->id);
     // Not Coding Standard
     $id = $productTemplate->id;
     $productTemplate->forget();
     unset($productTemplate);
     $productTemplate = ProductTemplate::getById($id);
     $categories = ProductTemplateProductCategoriesUtil::resolveProductTemplateHasManyProductCategoriesFromPost($productTemplate, $postData);
     $this->assertEquals(count($categories), 2);
     $this->assertEquals($categories[$category1->id]->id, $category1->id);
 }