forked from leogout/SeoBundle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMetaTagTest.php
83 lines (69 loc) · 2.02 KB
/
MetaTagTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<?php
namespace Leogout\Bundle\SeoBundle\Tests\Model;
use Leogout\Bundle\SeoBundle\Model\MetaTag;
use Leogout\Bundle\SeoBundle\Tests\TestCase;
use InvalidArgumentException;
/**
* Description of MetaTagTest.
*
* @author: leogout
*/
class MetaTagTest extends TestCase
{
public function testNullValues()
{
$metaTag = new MetaTag();
$this->assertNull($metaTag->getValue());
$this->assertNull($metaTag->getContent());
}
public function testRenderName()
{
$metaTag = new MetaTag();
$metaTag
->setType(MetaTag::NAME_TYPE)
->setValue('keywords')
->setContent('your, tags');
$this->assertEquals(
'<meta name="keywords" content="your, tags" />',
$metaTag->render()
);
}
public function testRenderProperty()
{
$metaTag = new MetaTag();
$metaTag
->setType(MetaTag::PROPERTY_TYPE)
->setValue('og:title')
->setContent('My awesome site');
$this->assertEquals(
'<meta property="og:title" content="My awesome site" />',
$metaTag->render()
);
}
public function testRenderHttpEquiv()
{
$metaTag = new MetaTag();
$metaTag
->setType(MetaTag::HTTP_EQUIV_TYPE)
->setValue('Cache-Control')
->setContent('no-cache');
$this->assertEquals(
'<meta http-equiv="Cache-Control" content="no-cache" />',
$metaTag->render()
);
}
public function testRenderNothing()
{
$metaTag = new MetaTag();
$this->assertEquals(
'<meta name="" content="" />',
$metaTag->render()
);
}
public function testSetUnknownType()
{
$this->expectException(InvalidArgumentException::class, sprintf('Meta tag of type "%s" doesn\'t exist. Existing types are: name, property and http-equiv.', 'unknownType'));
$metaTag = new MetaTag();
$metaTag->setType('unknownType');
}
}