diff --git a/tests/unit/workflow/engine/classes/PmDynaformTest.php b/tests/unit/workflow/engine/classes/PmDynaformTest.php index d02565b06..5c6a10f0b 100644 --- a/tests/unit/workflow/engine/classes/PmDynaformTest.php +++ b/tests/unit/workflow/engine/classes/PmDynaformTest.php @@ -963,6 +963,27 @@ class PmDynaformTest extends TestCase $this->assertEquals(strlen($sqlOriginal), strlen($sqlParsed)); } + + /** + * Review if the title of a Dynaform is correct + * + * @covers PmDynaform::getDynaformTitle() + * @test + */ + public function it_should_get_dynaform_title() + { + // Create a Dynaform + $dynaform = factory(Dynaform::class)->create([]); + + // Instance the class to test + $pmDynaform = new PmDynaform(); + + // Get the title of the Dynaform + $dynaformTitle = $pmDynaform->getDynaformTitle($dynaform->DYN_UID); + + // Compare the values + $this->assertEquals($dynaformTitle, $dynaform->DYN_TITLE); + } } // Dummy function used for the coverture diff --git a/workflow/engine/classes/PmDynaform.php b/workflow/engine/classes/PmDynaform.php index 0fd7cf05e..48e4354f9 100644 --- a/workflow/engine/classes/PmDynaform.php +++ b/workflow/engine/classes/PmDynaform.php @@ -149,12 +149,16 @@ class PmDynaform return $labelsPo; } - public function getDynaformTitle($idDynaform) + /** + * Get the title of a Dynaform + * + * @param string $dynUid + * @return string + */ + public function getDynaformTitle($dynUid) { - $d = new Dynaform(); - $d->setDynUid($idDynaform); - $titleDynaform = $d->getDynTitle(); - return $titleDynaform; + $dynaform = ModelDynaform::getByDynUid($dynUid); + return $dynaform->DYN_TITLE; } /**