public getTextForSide ( $side ) : string | ||
$side | ||
return | string |
public function getTextForSide($side)
{
$checkFunc = 'has' . ucfirst($side);
if ($this->{$checkFunc}() && !$this->{$side . '_readings'}) {
if ($this->{$side . '_unable_to_assess'}) {
$text = $this->getAttributeLabel($side . '_unable_to_assess');
if ($this->{$side . '_eye_missing'}) {
$text .= ', ' . $this->getAttributeLabel($side . '_eye_missing');
}
return $text;
} elseif ($this->{$side . '_eye_missing'}) {
return $this->getAttributeLabel($side . '_eye_missing');
} else {
return 'not recorded';
}
}
}
/** * @dataProvider getTextForSide_Provider */ public function testgetTextForSide($side, $readings, $unable, $eye_missing, $res) { $readingMock = $this->getMockBuilder('\\OEModule\\OphCiExamination\\models\\OphCiExamination_VisualAcuity_Reading')->setMethods(array('init'))->getMock(); $test = new models\Element_OphCiExamination_VisualAcuity(); if ($side == 'left') { $test->eye_id = Eye::LEFT; } else { $test->eye_id = Eye::RIGHT; } if ($readings) { $test->{$side . '_readings'} = array($readingMock); } $test->{$side . '_unable_to_assess'} = $unable; $test->{$side . '_eye_missing'} = $eye_missing; $this->assertEquals($res, $test->getTextForSide($side)); }