mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-22 01:58:47 +02:00
N°2889 - Improve PHPDoc and unit test cases
This commit is contained in:
@@ -7318,9 +7318,14 @@ abstract class MetaModel
|
||||
/**
|
||||
* Replaces all the parameters by the values passed in the hash array
|
||||
*
|
||||
* @param string $sInput
|
||||
* @param array $aParams
|
||||
* @param string $sInput Can be plain text or HTML. Note that some part may be url-encoded if a placeholder is used in an URL.
|
||||
* @param array $aParams Placeholder descriptor as key, replacement as value. Possible placeholders can be of the forms:
|
||||
* * foo_bar : Static placeholder
|
||||
* * foo->bar : Another static placeholder
|
||||
* * foo->object() : Will be developed into a set of placeholders depending on the attribute of the given \DBObject and their corresponding transformation methods {@see \AttributeDefinition::GetForTemplate()}
|
||||
* Example: foo->hyperlink(), foo->name, foo->html(name), foo->head(log), foo->head_html(log), ...
|
||||
*
|
||||
* @link https://www.itophub.io/wiki/page?id=latest:admin:placeholders
|
||||
* @return string
|
||||
*
|
||||
* @throws \Exception
|
||||
|
||||
@@ -23,6 +23,7 @@ class MetaModelTest extends ItopDataTestCase
|
||||
protected static $iDefaultUserCallerId = 1;
|
||||
protected static $sDefaultUserRequestTitle = 'Unit test title';
|
||||
protected static $sDefaultUserRequestDescription = 'Unit test description';
|
||||
protected static $sDefaultUserRequestDescriptionAsHtml = '<p>Unit test description</p>';
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
@@ -49,7 +50,7 @@ class MetaModelTest extends ItopDataTestCase
|
||||
'org_id' => static::$iDefaultUserOrgId,
|
||||
'caller_id' => static::$iDefaultUserCallerId,
|
||||
'title' => static::$sDefaultUserRequestTitle,
|
||||
'description' => static::$sDefaultUserRequestDescription,
|
||||
'description' => static::$sDefaultUserRequestDescriptionAsHtml,
|
||||
)
|
||||
);
|
||||
|
||||
@@ -105,6 +106,21 @@ class MetaModelTest extends ItopDataTestCase
|
||||
$aParams,
|
||||
'Title: <a href="http://foo.bar/'.$sTitle.'">Hyperlink</a>',
|
||||
],
|
||||
'Placeholder for an object HTML attribute as its default format' => [
|
||||
'$this->description$',
|
||||
$aParams,
|
||||
static::$sDefaultUserRequestDescriptionAsHtml,
|
||||
],
|
||||
'Placeholder for an object HTML attribute as plain text' => [
|
||||
'$this->text(description)$',
|
||||
$aParams,
|
||||
static::$sDefaultUserRequestDescription,
|
||||
],
|
||||
'Placeholder for an object HTML attribute as HTML' => [
|
||||
'$this->html(description)$',
|
||||
$aParams,
|
||||
'<div class="HTML ibo-is-html-content" ><p>Unit test description</p></div>', // As the AttributeText::GetForHTML() called by AttributeDefinition::GetForTemplate() adds this markup, we have to mock it here as well
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user