private function _parseCommonData($postArr) { $jobSpec = new JobSpec(); if (isset($postArr['txtFieldName']) && !empty($postArr['txtFieldName'])) { $jobSpec->setName(trim($postArr['txtFieldName'])); } if (isset($postArr['txtDesc']) && !empty($postArr['txtDesc'])) { $jobSpec->setDesc(trim($postArr['txtDesc'])); } if (isset($postArr['txtDuties']) && !empty($postArr['txtDuties'])) { $jobSpec->setDuties(trim($postArr['txtDuties'])); } return $jobSpec; }
/** * Create a JobSpec object with the passed parameters */ private function _getJobSpec($id, $name, $desc, $duties) { $spec = new JobSpec($id); $spec->setName($name); $spec->setDesc($desc); $spec->setDuties($duties); return $spec; }
/** * Creates a JobSpec object from a resultset row * * @param array $row Resultset row from the database. * @return JobSpec JobSpec object. */ private static function _createFromRow($row) { $spec = new JobSpec($row[self::DB_FIELD_ID]); $spec->setName($row[self::DB_FIELD_NAME]); $spec->setDesc($row[self::DB_FIELD_DESC]); $spec->setDuties($row[self::DB_FIELD_DUTIES]); return $spec; }
/** * Tests getJobSpecForJob method. */ public function testGetJobSpecForJob() { $viewController = new ViewController(); // invalid job title id $spec = $viewController->getJobSpecForJob('JOB010'); $this->assertNull($spec); // job title with no job spec assigned $spec = $viewController->getJobSpecForJob('JOB001'); $this->assertNull($spec); // job id with job spec assigned $spec = $viewController->getJobSpecForJob('JOB002'); $this->assertNotNull($spec); $expected = new JobSpec(); $expected->setId(1); $expected->setName('Spec 1'); $expected->setDesc('Desc 1'); $expected->setDuties('duties 1'); $this->assertEquals($expected, $spec); }