Skip to content

Commit

Permalink
update setter/getter test helper for object attrs that can be nulled.
Browse files Browse the repository at this point in the history
  • Loading branch information
stopfstedt committed Feb 13, 2024
1 parent f4f66aa commit 97885ce
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion tests/Ilios/MeSH/Model/BaseTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,9 @@ protected function basicSetTest(object $model, string $property, string $type, b
* @param object $model
* @param string $property
* @param string $modelName
* @param bool $nullable if TRUE then an additional getter/setter check for NULL is performed.
*/
protected function modelSetTest(object $model, string $property, string $modelName): void
protected function modelSetTest(object $model, string $property, string $modelName, bool $nullable = false): void
{
$setMethod = $this->getSetMethodForProperty($property);
$getMethod = $this->getGetMethodForProperty($property);
Expand All @@ -146,6 +147,10 @@ protected function modelSetTest(object $model, string $property, string $modelNa
$expected = m::mock('Ilios\\MeSH\\Model\\' . $modelName);
$model->$setMethod($expected);
$this->assertSame($expected, $model->$getMethod());
if ($nullable) {
$model->$setMethod(null);
$this->assertNull($model->$getMethod());
}
}

/**
Expand Down

0 comments on commit 97885ce

Please sign in to comment.