private function getMashableInboxFormWithDefaultValues($modelClassName, $getData) { $mashableInboxForm = MashableUtil::restoreSelectedOptionsAsStickyData($modelClassName); if ($mashableInboxForm->optionForModel == null) { $mashableInboxForm->optionForModel = 2; } if ($mashableInboxForm->filteredBy == null) { $mashableInboxForm->filteredBy = MashableInboxForm::FILTERED_BY_ALL; } if (isset($getData["MashableInboxForm"])) { $mashableInboxForm->attributes = $getData["MashableInboxForm"]; } if ($mashableInboxForm->massAction != null) { $this->resolveAjaxMassAction($modelClassName, $mashableInboxForm); } MashableUtil::saveSelectedOptionsAsStickyData($mashableInboxForm, $modelClassName); return $mashableInboxForm; }
public function testRestoreSelectedOptionsAsStickyData() { $key = MashableUtil::resolveKeyByModuleAndModel('MashableInboxModule', 'testClassName'); StickyUtil::clearDataByKey($key); $mashableInboxForm = MashableUtil::restoreSelectedOptionsAsStickyData('testClassName'); $mashableInboxFormForCompare = new MashableInboxForm(); $this->assertEquals($mashableInboxFormForCompare->attributes, $mashableInboxForm->attributes); $testData = array('optionForModel' => 'aaaaa', 'filteredBy' => 'bbbbb', 'searchTerm' => 'ccccc'); $key = MashableUtil::resolveKeyByModuleAndModel('MashableInboxModule', 'testClassName'); StickyUtil::clearDataByKey($key); StickyUtil::setDataByKeyAndData($key, $testData); $mashableInboxForm = MashableUtil::restoreSelectedOptionsAsStickyData('testClassName'); $this->assertEquals($testData, array_intersect($testData, StickyUtil::getDataByKey($key))); }