mirror of
https://github.com/codeigniter4/CodeIgniter4.git
synced 2025-02-20 11:44:28 +08:00
fix: fix incorrect test and support other patterns
This commit is contained in:
parent
28222928de
commit
fb7649386f
@ -265,7 +265,7 @@ if (! function_exists('link_tag')) {
|
||||
|
||||
$link .= 'rel="' . $rel . '" ';
|
||||
|
||||
if ($type !== '' && $rel !== 'canonical' && $hreflang === '') {
|
||||
if ($type !== '' && $rel !== 'canonical' && $hreflang === '' && ! ($rel === 'alternate' && $media !== '')) {
|
||||
$link .= 'type="' . $type . '" ';
|
||||
}
|
||||
|
||||
|
@ -312,11 +312,21 @@ final class HTMLHelperTest extends CIUnitTestCase
|
||||
$this->assertSame($expected, link_tag($target));
|
||||
}
|
||||
|
||||
public function testLinkTagComplete()
|
||||
public function testLinkTagMedia()
|
||||
{
|
||||
$target = 'https://styles.com/css/mystyles.css';
|
||||
$expected = '<link href="https://styles.com/css/mystyles.css" rel="banana" type="fruit" media="VHS" title="Go away" />';
|
||||
$this->assertSame($expected, link_tag($target, 'banana', 'fruit', 'Go away', 'VHS'));
|
||||
$target = 'https://styles.com/css/mystyles.css';
|
||||
$tag = link_tag($target, 'stylesheet', 'text/css', '', 'print');
|
||||
|
||||
$expected = '<link href="https://styles.com/css/mystyles.css" rel="stylesheet" type="text/css" media="print" />';
|
||||
$this->assertSame($expected, $tag);
|
||||
}
|
||||
|
||||
public function testLinkTagTitle()
|
||||
{
|
||||
$tag = link_tag('default.css', 'stylesheet', 'text/css', 'Default Style');
|
||||
|
||||
$expected = '<link href="http://example.com/default.css" rel="stylesheet" type="text/css" title="Default Style" />';
|
||||
$this->assertSame($expected, $tag);
|
||||
}
|
||||
|
||||
public function testLinkTagFavicon()
|
||||
@ -349,6 +359,18 @@ final class HTMLHelperTest extends CIUnitTestCase
|
||||
$this->assertSame($expected, $tag);
|
||||
}
|
||||
|
||||
public function testLinkTagArrayAlternate()
|
||||
{
|
||||
$tag = link_tag([
|
||||
'href' => 'http://sp.example.com/',
|
||||
'rel' => 'alternate',
|
||||
'media' => 'only screen and (max-width: 640px)',
|
||||
]);
|
||||
|
||||
$expected = '<link href="http://sp.example.com/" rel="alternate" media="only screen and (max-width: 640px)" />';
|
||||
$this->assertSame($expected, $tag);
|
||||
}
|
||||
|
||||
public function testLinkTagCanonical()
|
||||
{
|
||||
$tag = link_tag('http://www.example.com/', 'canonical');
|
||||
|
Loading…
x
Reference in New Issue
Block a user