N°8681 - Fix PHP code styles

This commit is contained in:
Molkobain
2026-02-16 16:46:00 +01:00
parent 6bd5a7b634
commit c0a2771d4e

View File

@@ -1,4 +1,5 @@
<?php
/*
* @copyright Copyright (C) 2010-2026 Combodo SAS
* @license http://opensource.org/licenses/AGPL-3.0
@@ -20,59 +21,59 @@ class AttributeTextTest extends ItopDataTestCase
}
/**
* @covers AttributeText::RenderWikiHtml
*/
public function testRenderWikiHtml_nonWikiUrlVariants()
{
// String value
$sInput = 'This hyperlink https://combodo.com should be in an anchor tag.';
$sExpected = 'This hyperlink <a href="https://combodo.com">https://combodo.com</a> should be in an anchor tag.';
$this->assertEquals($sExpected, AttributeText::RenderWikiHtml($sInput));
* @covers AttributeText::RenderWikiHtml
*/
public function testRenderWikiHtml_nonWikiUrlVariants()
{
// String value
$sInput = 'This hyperlink https://combodo.com should be in an anchor tag.';
$sExpected = 'This hyperlink <a href="https://combodo.com">https://combodo.com</a> should be in an anchor tag.';
$this->assertEquals($sExpected, AttributeText::RenderWikiHtml($sInput));
// Empty string value
$this->assertEquals('', AttributeText::RenderWikiHtml(''));
// Empty string value
$this->assertEquals('', AttributeText::RenderWikiHtml(''));
// Null value
$this->assertEquals('', AttributeText::RenderWikiHtml(null));
}
// Null value
$this->assertEquals('', AttributeText::RenderWikiHtml(null));
}
/**
* @covers AttributeText::RenderWikiHtml
*/
public function testRenderWikiHtml_bWikiOnlyAbsentOrFalse_shouldTransformBothRegularAndWikiHyperlinks()
{
$sInput = 'A regular hyperlink https://combodo.com and a wiki hyperlink to an existing object [[Organization:'.$this->oTestOrganizationForAttributeText->GetKey().']]';
/**
* @covers AttributeText::RenderWikiHtml
*/
public function testRenderWikiHtml_bWikiOnlyAbsentOrFalse_shouldTransformBothRegularAndWikiHyperlinks()
{
$sInput = 'A regular hyperlink https://combodo.com and a wiki hyperlink to an existing object [[Organization:'.$this->oTestOrganizationForAttributeText->GetKey().']]';
// bWikiOnly default value
$sResult = AttributeText::RenderWikiHtml($sInput);
$this->assertStringContainsString('<a href="https://combodo.com">', $sResult);
$this->assertStringContainsString('class="object-ref-link"', $sResult);
$sResult = AttributeText::RenderWikiHtml($sInput);
$this->assertStringContainsString('<a href="https://combodo.com">', $sResult);
$this->assertStringContainsString('class="object-ref-link"', $sResult);
// bWikiOnly = false
$sResult = AttributeText::RenderWikiHtml($sInput, false);
$this->assertStringContainsString('<a href="https://combodo.com">', $sResult);
$this->assertStringContainsString('class="object-ref-link"', $sResult);
}
$sResult = AttributeText::RenderWikiHtml($sInput, false);
$this->assertStringContainsString('<a href="https://combodo.com">', $sResult);
$this->assertStringContainsString('class="object-ref-link"', $sResult);
}
/**
* @covers AttributeText::RenderWikiHtml
*/
public function testRenderWikiHtml_bWikiOnlyToTrue_shouldNotTransformRegularHyperlinkButTransformWikiHyperlink()
{
$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('<a href="https://combodo.com">', $sResult);
$this->assertStringContainsString('class="object-ref-link"', $sResult);
}
/**
* @covers AttributeText::RenderWikiHtml
*/
public function testRenderWikiHtml_bWikiOnlyToTrue_shouldNotTransformRegularHyperlinkButTransformWikiHyperlink()
{
$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('<a href="https://combodo.com">', $sResult);
$this->assertStringContainsString('class="object-ref-link"', $sResult);
}
/**
* @covers AttributeText::RenderWikiHtml
*/
public function testRenderWikiHtml_shouldTransformWikiHyperlinkForExistingObjectsOnly()
{
$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);
}
/**
* @covers AttributeText::RenderWikiHtml
*/
public function testRenderWikiHtml_shouldTransformWikiHyperlinkForExistingObjectsOnly()
{
$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);
}
}