diff --git a/tests/php-unit-tests/unitary-tests/core/AttributeTextTest.php b/tests/php-unit-tests/unitary-tests/core/AttributeTextTest.php
index 00373af170..a84d5b897f 100644
--- a/tests/php-unit-tests/unitary-tests/core/AttributeTextTest.php
+++ b/tests/php-unit-tests/unitary-tests/core/AttributeTextTest.php
@@ -25,9 +25,9 @@ class AttributeTextTest extends ItopDataTestCase
public function testRenderWikiHtml_nonWikiUrlVariants()
{
// String value
- $input = 'This hyperlink https://combodo.com should be in an anchor tag.';
- $expected = 'This hyperlink https://combodo.com should be in an anchor tag.';
- $this->assertEquals($expected, AttributeText::RenderWikiHtml($input));
+ $sInput = 'This hyperlink https://combodo.com should be in an anchor tag.';
+ $sExpected = 'This hyperlink https://combodo.com should be in an anchor tag.';
+ $this->assertEquals($sExpected, AttributeText::RenderWikiHtml($sInput));
// Empty string value
$this->assertEquals('', AttributeText::RenderWikiHtml(''));
@@ -41,17 +41,17 @@ class AttributeTextTest extends ItopDataTestCase
*/
public function testRenderWikiHtml_bWikiOnlyAbsentOrFalse_shouldTransformBothRegularAndWikiHyperlinks()
{
- $input = 'A regular hyperlink https://combodo.com and a wiki hyperlink to an existing object [[Organization:'.$this->oTestOrganizationForAttributeText->GetKey().']]';
+ $sInput = 'A regular hyperlink https://combodo.com and a wiki hyperlink to an existing object [[Organization:'.$this->oTestOrganizationForAttributeText->GetKey().']]';
// bWikiOnly default value
- $result = AttributeText::RenderWikiHtml($input);
- $this->assertStringContainsString('', $result);
- $this->assertStringContainsString('class="object-ref-link"', $result);
+ $sResult = AttributeText::RenderWikiHtml($sInput);
+ $this->assertStringContainsString('', $sResult);
+ $this->assertStringContainsString('class="object-ref-link"', $sResult);
// bWikiOnly = false
- $result = AttributeText::RenderWikiHtml($input, false);
- $this->assertStringContainsString('', $result);
- $this->assertStringContainsString('class="object-ref-link"', $result);
+ $sResult = AttributeText::RenderWikiHtml($sInput, false);
+ $this->assertStringContainsString('', $sResult);
+ $this->assertStringContainsString('class="object-ref-link"', $sResult);
}
/**
@@ -59,10 +59,10 @@ class AttributeTextTest extends ItopDataTestCase
*/
public function testRenderWikiHtml_bWikiOnlyToTrue_shouldNotTransformRegularHyperlinkButTransformWikiHyperlink()
{
- $input = 'A regular hyperlink https://combodo.com and a wiki hyperlink to an existing object [[Organization:'.$this->oTestOrganizationForAttributeText->GetKey().']]';
- $result = AttributeText::RenderWikiHtml($input, true);
- $this->assertStringNotContainsString('', $result);
- $this->assertStringContainsString('class="object-ref-link"', $result);
+ $sInput = 'A regular hyperlink https://combodo.com and a wiki hyperlink to an existing object [[Organization:'.$this->oTestOrganizationForAttributeText->GetKey().']]';
+ $sResult = AttributeText::RenderWikiHtml($sInput, true);
+ $this->assertStringNotContainsString('', $sResult);
+ $this->assertStringContainsString('class="object-ref-link"', $sResult);
}
/**
@@ -70,9 +70,9 @@ class AttributeTextTest extends ItopDataTestCase
*/
public function testRenderWikiHtml_shouldTransformWikiHyperlinkForExistingObjectsOnly()
{
- $input = 'A wiki hyperlink to a non existing object [[Organization:123456789]] and a wiki hyperlink to an existing object [[Organization:'.$this->oTestOrganizationForAttributeText->GetKey().']]';
- $result = AttributeText::RenderWikiHtml($input);
- $this->assertStringContainsString('wiki_broken_link', $result);
- $this->assertStringContainsString('class="object-ref-link"', $result);
+ $sInput = 'A wiki hyperlink to a non existing object [[Organization:123456789]] and a wiki hyperlink to an existing object [[Organization:'.$this->oTestOrganizationForAttributeText->GetKey().']]';
+ $sResult = AttributeText::RenderWikiHtml($sInput);
+ $this->assertStringContainsString('wiki_broken_link', $sResult);
+ $this->assertStringContainsString('class="object-ref-link"', $sResult);
}
}
diff --git a/tests/php-unit-tests/unitary-tests/core/InlineImageTest.php b/tests/php-unit-tests/unitary-tests/core/InlineImageTest.php
index 68196a0439..1818c97e8c 100644
--- a/tests/php-unit-tests/unitary-tests/core/InlineImageTest.php
+++ b/tests/php-unit-tests/unitary-tests/core/InlineImageTest.php
@@ -59,4 +59,43 @@ class InlineImageTest extends ItopDataTestCase
],
];
}
+
+ /**
+ * @covers InlineImage::FixUrls
+ */
+ public function testFixUrls_shouldReturnAnEmptyStringIfNullOrEmptyStringPassed()
+ {
+ $sResult = InlineImage::FixUrls(null);
+ $this->assertEquals('', $sResult);
+
+ $sResult = InlineImage::FixUrls('');
+ $this->assertEquals('', $sResult);
+ }
+
+ /**
+ * @covers InlineImage::FixUrls
+ */
+ public function testFixUrls_shouldReturnUnchangedValueIfValueContainsNoImage()
+ {
+ $sHtml = '';
+ $sResult = InlineImage::FixUrls($sHtml);
+ $this->assertEquals($sHtml, $sResult);
+ }
+
+ /**
+ * @covers InlineImage::FixUrls
+ */
+ public function testFixUrls_shouldReplaceImagesSrcWithCurrentAppRootUrlAndSecret()
+ {
+ $sHtml = <<
+
+
+
+HTML;
+ $sResult = InlineImage::FixUrls($sHtml);
+ $this->assertStringContainsString('
assertStringContainsString(\utils::EscapeHtml(\utils::GetAbsoluteUrlAppRoot().INLINEIMAGE_DOWNLOAD_URL.'123&s=abc'), $sResult);
+ $this->assertStringContainsString(\utils::EscapeHtml(\utils::GetAbsoluteUrlAppRoot().INLINEIMAGE_DOWNLOAD_URL.'456&s=def'), $sResult);
+ }
}