-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #169 from elecena/fix/skin-null-handling
Skin::renderHead - do not pass null to htmlspecialchars()
- Loading branch information
Showing
2 changed files
with
46 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
use Nano\NanoBaseTest; | ||
|
||
class TestSkin extends Skin | ||
{ | ||
const NAME = 'test-skin'; | ||
} | ||
|
||
class SkinTest extends NanoBaseTest | ||
{ | ||
private TestSkin $skin; | ||
|
||
public function setUp(): void | ||
{ | ||
$app = Nano::app(__DIR__ . '/app'); | ||
$this->skin = new TestSkin($app, TestSkin::NAME); | ||
} | ||
|
||
public function testRenderHeadNullHandling() | ||
{ | ||
$this->skin->addMeta('null', null); | ||
$this->skin->addMeta('empty_string', ''); | ||
$this->skin->addMeta('a_string', 'Foo Bar'); | ||
$this->skin->addMeta('a_number', 42); | ||
|
||
$this->skin->addLink('foo', null); | ||
$this->skin->addLink('bar', 'test', ['type' => 'some/thing']); | ||
|
||
$head = $this->skin->renderHead(); | ||
|
||
$this->assertStringContainsString('<meta name="null" value="">', $head, ); | ||
$this->assertStringContainsString('<meta name="empty_string" value="">', $head, ); | ||
$this->assertStringContainsString('<meta name="a_string" value="Foo Bar">', $head, ); | ||
$this->assertStringContainsString('<meta name="a_number" value="42">', $head, ); | ||
|
||
$this->assertStringContainsString('<link rel="foo" value="">', $head, ); | ||
$this->assertStringContainsString('<link rel="bar" value="test" type="some/thing">', $head, ); | ||
} | ||
} |