/** * @dataProvider getMappingAttributeIdsByNameProvider * * @param $worklist_attrs */ public function test_getMappingAttributeIdsByName($worklist_attrs) { $worklist_attrs = array(); $expected = array(); foreach ($worklist_attrs as $attr) { $wa = ComponentStubGenerator::generate('WorklistAttribute', $attr); $expected[$attr['name']] = $wa; $worklist_attrs[] = $wa; } $worklist = new Worklist(); $worklist->mapping_attributes = $worklist_attrs; $this->assertEquals($expected, $worklist->getMappingAttributeIdsByName()); }
/** * @param Worklist $worklist * @param null $user * @param bool $display * * @return bool * * @throws CDbException */ public function createWorklistForUser(Worklist $worklist, $user = null, $display = true) { if (!$user) { $user = $this->getCurrentUser(); } $transaction = $this->startTransaction(); try { $worklist->created_user_id = $user->id; $worklist->last_modified_user_id = $user->id; // save call must force the parent class to accept the set owner id if (!$worklist->save(true, null, true)) { $this->addModelErrors($worklist->getErrors()); throw new Exception('Could not create Worklist.'); } if ($display) { if (!$this->addWorklistToUserDisplay($worklist, $user)) { throw new Exception('Could not set new worklist display order.'); } } $this->audit(self::$AUDIT_TARGET_MANUAL, 'create', array('worklist_id' => $worklist->id, 'owner_id' => $user->id), 'Worklist created.'); if ($transaction) { $transaction->commit(); } } catch (Exception $e) { $this->addError($e->getMessage()); if ($transaction) { $transaction->rollback(); } return false; } return true; }